diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..06c92d07df --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# gitattributes +*.exe -diff binary executable windows dfsg-nonfree debian-ignore +*.wav -diff binary sound +*.gif -diff binary image +*.jpg -diff binary image +*.jpeg -diff binary image +*.pbm -diff binary image +/clients/flex* dfsg-nonfree +/debian* debian-ignore +/freeswitch.xcodeproj debian-ignore +/libs/ilbc* dfsg-nonfree +/libs/libg722_1* dfsg-nonfree +/libs/win32* windows debian-ignore +/htdocs* dfsg-nonfree debian-ignore +/w32* windows debian-ignore diff --git a/.gitignore b/.gitignore index 55e1e9856b..1039628aeb 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ configure.lineno config.log config.status core.* +TAGS *.2010.log *.Build.CppClean.log *.tlog @@ -57,6 +58,7 @@ core.* !/w32/Setup/inno_setup/vcredist_x86.exe /.version +/.stamp-* /a.out.dSYM /AUTHORS /ChangeLog @@ -71,6 +73,7 @@ core.* /Makefile.in /modules.conf /NEWS +/noreg /Path /quiet_libtool /README @@ -81,6 +84,8 @@ core.* /Debug/ /bin/ /Release/ +/ipch/ +/*.log /build/config/compile /build/config/config.guess @@ -96,6 +101,7 @@ core.* /build/Makefile /build/Makefile.in /build/modmake.rules +/build/print_git_revision /libs/curl/lib/ca-bundle.h /libs/esl/fs_cli @@ -199,3 +205,23 @@ src/mod/formats/mod_shout/*/*/mod_shout.log /src/mod/languages/mod_managed/x64/Release_CLR/FREESWITCH.MANAGED.DLL.metagen /src/mod/languages/mod_managed/x64/Release_CLR/RSAENH.DLL.bi /src/mod/languages/mod_managed/x64/Release_CLR/TZRES.DLL.bi +libs/apr-util/a.out.dSYM/Contents/Info.plist +libs/apr-util/a.out.dSYM/Contents/Resources/DWARF/a.out +libs/apr/a.out.dSYM/Contents/Info.plist +libs/apr/a.out.dSYM/Contents/Resources/DWARF/a.out +libs/iksemel/a.out.dSYM/Contents/Info.plist +libs/iksemel/a.out.dSYM/Contents/Resources/DWARF/a.out +libs/ilbc/a.out.dSYM/Contents/Info.plist +libs/ilbc/a.out.dSYM/Contents/Resources/DWARF/a.out +libs/libedit/a.out.dSYM/Contents/Info.plist +libs/libedit/a.out.dSYM/Contents/Resources/DWARF/a.out +libs/pcre/a.out.dSYM/Contents/Info.plist +libs/pcre/a.out.dSYM/Contents/Resources/DWARF/a.out +libs/sqlite/lemon.dSYM/Contents/Info.plist +libs/sqlite/lemon.dSYM/Contents/Resources/DWARF/lemon +libs/sqlite/mkkeywordhash.dSYM/Contents/Info.plist +libs/sqlite/mkkeywordhash.dSYM/Contents/Resources/DWARF/mkkeywordhash +libs/sqlite/sqlite3.dSYM/Contents/Info.plist +libs/sqlite/sqlite3.dSYM/Contents/Resources/DWARF/sqlite3 +libs/srtp/a.out.dSYM/Contents/Info.plist +libs/srtp/a.out.dSYM/Contents/Resources/DWARF/a.out diff --git a/.version.in b/.version.in deleted file mode 100644 index 449460b02e..0000000000 --- a/.version.in +++ /dev/null @@ -1 +0,0 @@ -@SWITCH_VERSION_REVISION@ diff --git a/Freeswitch.2008.express.sln b/Freeswitch.2008.express.sln index cd0033bba2..c077efb7ff 100644 --- a/Freeswitch.2008.express.sln +++ b/Freeswitch.2008.express.sln @@ -542,6 +542,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_lcr", "src\mod\applicat EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libs\spandsp\src\libspandsp.2008.vcproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" ProjectSection(ProjectDependencies) = postProject + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A} = {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A} {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} @@ -667,6 +668,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_directory", "src\mod\ap EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2008.vcproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download libjpeg", "libs\win32\Download libjpeg.2008.vcproj", "{21A7DA70-555E-49FA-942B-D84A38B61243}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "libs\win32\libjpeg\libjpeg.2008.vcproj", "{FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}" + ProjectSection(ProjectDependencies) = postProject + {21A7DA70-555E-49FA-942B-D84A38B61243} = {21A7DA70-555E-49FA-942B-D84A38B61243} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -2138,6 +2146,24 @@ Global {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.ActiveCfg = Release|Win32 {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.Build.0 = Release|Win32 {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.All|Win32.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.All|Win32.Build.0 = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.All|x64.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|Win32.ActiveCfg = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|Win32.Build.0 = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|x64.ActiveCfg = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|Win32.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|Win32.Build.0 = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|x64.ActiveCfg = Release|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.All|Win32.ActiveCfg = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.All|Win32.Build.0 = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.All|x64.ActiveCfg = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|Win32.ActiveCfg = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|Win32.Build.0 = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|x64.ActiveCfg = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|Win32.ActiveCfg = Release|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|Win32.Build.0 = Release|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln index 30e947b575..62b24591a7 100644 --- a/Freeswitch.2008.sln +++ b/Freeswitch.2008.sln @@ -718,6 +718,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "libs\spandsp\src EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libs\spandsp\src\libspandsp.2008.vcproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" ProjectSection(ProjectDependencies) = postProject + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A} = {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A} {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} @@ -953,6 +954,20 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_abstraction", "src\mod\ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_gsmopen", "src\mod\endpoints\mod_gsmopen\mod_gsmopen.2008.vcproj", "{74B120FF-6935-4DFE-A142-CDB6BEA99C90}" + ProjectSection(ProjectDependencies) = postProject + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} = {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gsmlib", "src\mod\endpoints\mod_gsmopen\gsmlib\gsmlib-1.10-patched-13ubuntu\win32\gsmlib.vcproj", "{26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "libs\win32\libjpeg\libjpeg.2008.vcproj", "{FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}" + ProjectSection(ProjectDependencies) = postProject + {21A7DA70-555E-49FA-942B-D84A38B61243} = {21A7DA70-555E-49FA-942B-D84A38B61243} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download libjpeg", "libs\win32\Download libjpeg.2008.vcproj", "{21A7DA70-555E-49FA-942B-D84A38B61243}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -2698,6 +2713,42 @@ Global {BDA173DB-F8EF-4270-9553-B453AF92E43A}.Release|Win32.Build.0 = Release|Win32 {BDA173DB-F8EF-4270-9553-B453AF92E43A}.Release|x64.ActiveCfg = Release|x64 {BDA173DB-F8EF-4270-9553-B453AF92E43A}.Release|x64.Build.0 = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|Win32.ActiveCfg = Release|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|Win32.Build.0 = Release|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|x64.ActiveCfg = Release|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Debug|Win32.ActiveCfg = Debug|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Debug|x64.ActiveCfg = Debug|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|Win32.ActiveCfg = Release|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|x64.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|Win32.ActiveCfg = Debug|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|Win32.Build.0 = Debug|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|x64.ActiveCfg = Debug|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Debug|Win32.ActiveCfg = Debug|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Debug|x64.ActiveCfg = Debug|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Release|Win32.ActiveCfg = Release|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Release|x64.ActiveCfg = Release|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.All|Win32.ActiveCfg = Debug|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.All|x64.ActiveCfg = Debug|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.All|x64.Build.0 = Debug|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|Win32.ActiveCfg = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|Win32.Build.0 = Debug|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|x64.ActiveCfg = Debug|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Debug|x64.Build.0 = Debug|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|Win32.ActiveCfg = Release|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|Win32.Build.0 = Release|Win32 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|x64.ActiveCfg = Release|x64 + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A}.Release|x64.Build.0 = Release|x64 + {21A7DA70-555E-49FA-942B-D84A38B61243}.All|Win32.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.All|Win32.Build.0 = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.All|x64.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|Win32.ActiveCfg = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|Win32.Build.0 = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|x64.ActiveCfg = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Debug|x64.Build.0 = Debug|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|Win32.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|Win32.Build.0 = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|x64.ActiveCfg = Release|Win32 + {21A7DA70-555E-49FA-942B-D84A38B61243}.Release|x64.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2723,6 +2774,7 @@ Global {CC1DD008-9406-448D-A0AD-33C3186CFADB} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {48414740-C693-4968-9846-EE058020C64F} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} + {74B120FF-6935-4DFE-A142-CDB6BEA99C90} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {C24FB505-05D7-4319-8485-7540B44C8603} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} @@ -2822,6 +2874,8 @@ Global {56B91D01-9150-4BBF-AFA1-5B68AB991B76} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {B376D494-D7DD-4B2A-99E2-52916D5A8CD8} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {23B4D303-79FC-49E0-89E2-2280E7E28940} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {FE02CD06-DD97-489C-8F61-B5E7F89BCC0A} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A} = {C120A020-773F-4EA3-923F-B67AF28B750D} {4F92B672-DADB-4047-8D6A-4BB3796733FD} = {C120A020-773F-4EA3-923F-B67AF28B750D} {2DEE4895-1134-439C-B688-52203E57D878} = {C120A020-773F-4EA3-923F-B67AF28B750D} @@ -2840,6 +2894,7 @@ Global {FFF82F9B-6A2B-4BE3-95D8-DC5A4FC71E19} = {C120A020-773F-4EA3-923F-B67AF28B750D} {B808178B-82F0-4CF4-A2B1-921939FA24D0} = {C120A020-773F-4EA3-923F-B67AF28B750D} {D578E676-7EC8-4548-BD8B-845C635F14AD} = {C120A020-773F-4EA3-923F-B67AF28B750D} + {21A7DA70-555E-49FA-942B-D84A38B61243} = {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} diff --git a/Freeswitch.2010.express.sln b/Freeswitch.2010.express.sln index b0df7d9c35..6833f61bc3 100644 --- a/Freeswitch.2010.express.sln +++ b/Freeswitch.2010.express.sln @@ -219,6 +219,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_lcr", "src\mod\applications\mod_lcr\mod_lcr.2010.vcxproj", "{1A3793D1-05D1-4B57-9B0F-5AF3E79DC439}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libs\spandsp\src\libspandsp.2010.vcxproj", "{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}" + ProjectSection(ProjectDependencies) = postProject + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspeex", "libs\speex\win32\VS2008\libspeex\libspeex.vcxproj", "{E972C52F-9E85-4D65-B19C-031E511E9DB4}" EndProject @@ -320,6 +323,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldn EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpcre Generate pcre_chartables.c", "libs\win32\pcre\pcre_chartables.c.2010.vcxproj", "{1CED5987-A529-46DC-B30F-870D85FF9C94}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp", "libs\libzrtp\projects\win\libzrtp.2010.vcxproj", "{C13CC324-0032-4492-9A30-310A6BD64FF5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download libjpeg", "libs\win32\Download libjpeg.2010.vcxproj", "{652AD5F7-8488-489F-AAD0-7FBE064703B6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "libs\win32\libjpeg\libjpeg.2010.vcxproj", "{019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}" + ProjectSection(ProjectDependencies) = postProject + {652AD5F7-8488-489F-AAD0-7FBE064703B6} = {652AD5F7-8488-489F-AAD0-7FBE064703B6} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -1989,6 +2001,35 @@ Global {1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|Win32.ActiveCfg = Release|Win32 {1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|Win32.Build.0 = Release|Win32 {1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|x64.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|Win32.ActiveCfg = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|x64.ActiveCfg = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|x64.Build.0 = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|Win32.ActiveCfg = Debug|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|Win32.Build.0 = Debug|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64.ActiveCfg = Debug|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64.Build.0 = Debug|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|Win32.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|Win32.Build.0 = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64.ActiveCfg = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64.Build.0 = Release|x64 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|Win32.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|Win32.Build.0 = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|x64.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|Win32.ActiveCfg = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|Win32.Build.0 = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|x64.ActiveCfg = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|Win32.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|Win32.Build.0 = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|x64.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|Win32.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|Win32.Build.0 = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|x64.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|Win32.ActiveCfg = Debug|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|Win32.Build.0 = Debug|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|x64.ActiveCfg = Debug|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|Win32.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|Win32.Build.0 = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2089,6 +2130,7 @@ Global {ABB71A76-42B0-47A4-973A-42E3D920C6FD} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {9778F1C0-09BC-4698-8EBC-BD982247209A} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {56B91D01-9150-4BBF-AFA1-5B68AB991B76} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {C13CC324-0032-4492-9A30-310A6BD64FF5} = {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} {ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000} diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln index 5079f1f987..68f0b9dc84 100644 --- a/Freeswitch.2010.sln +++ b/Freeswitch.2010.sln @@ -235,6 +235,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsndfile", "libs\win32\libsndfile\libsndfile.2010.vcxproj", "{3D0370CA-BED2-4657-A475-32375CBCB6E4}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "curllib", "libs\win32\curl\curllib.2010.vcxproj", "{87EE9DA4-DE1E-4448-8324-183C98DCA588}" + ProjectSection(ProjectDependencies) = postProject + {25BD39B1-C8BF-4676-A738-9CABD9C6BC79} = {25BD39B1-C8BF-4676-A738-9CABD9C6BC79} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml", "libs\win32\apr-util\xml.2010.vcxproj", "{155844C3-EC5F-407F-97A4-A2DDADED9B2F}" EndProject @@ -494,6 +497,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssleay32", "libs\win32\openssl\ssleay32.2010.vcxproj", "{B4B62169-5AD4-4559-8707-3D933AC5DB39}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openssl", "libs\win32\openssl\openssl.2010.vcxproj", "{25BD39B1-C8BF-4676-A738-9CABD9C6BC79}" + ProjectSection(ProjectDependencies) = postProject + {D578E676-7EC8-4548-BD8B-845C635F14AD} = {D578E676-7EC8-4548-BD8B-845C635F14AD} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download OPENSSL", "libs\win32\Download OPENSSL.2010.vcxproj", "{D578E676-7EC8-4548-BD8B-845C635F14AD}" EndProject @@ -521,6 +527,21 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_abstraction", "src\mod\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sms", "src\mod\applications\mod_sms\mod_sms.2010.vcxproj", "{2469B306-B027-4FF2-8815-C9C1EA2CAE79}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gsmlib", "src\mod\endpoints\mod_gsmopen\gsmlib\gsmlib-1.10-patched-13ubuntu\win32\gsmlib.2010.vcxproj", "{26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_gsmopen", "src\mod\endpoints\mod_gsmopen\mod_gsmopen.2010.vcxproj", "{74B120FF-6935-4DFE-A142-CDB6BEA99C90}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp", "libs\libzrtp\projects\win\libzrtp.2010.vcxproj", "{C13CC324-0032-4492-9A30-310A6BD64FF5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_redis", "src\mod\applications\mod_redis\mod_redis.2010.vcxproj", "{886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download libjpeg", "libs\win32\Download libjpeg.2010.vcxproj", "{652AD5F7-8488-489F-AAD0-7FBE064703B6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "libs\win32\libjpeg\libjpeg.2010.vcxproj", "{019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}" + ProjectSection(ProjectDependencies) = postProject + {652AD5F7-8488-489F-AAD0-7FBE064703B6} = {652AD5F7-8488-489F-AAD0-7FBE064703B6} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -1238,11 +1259,15 @@ Global {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.All|x64 Setup.Build.0 = Release|x64 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.All|x86 Setup.ActiveCfg = Release|x64 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Debug|Win32.ActiveCfg = Debug|Win32 + {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Debug|Win32.Build.0 = Debug|Win32 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Debug|x64.ActiveCfg = Debug|x64 + {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Debug|x64.Build.0 = Debug|x64 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Debug|x64 Setup.ActiveCfg = Debug|x64 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Release|Win32.ActiveCfg = Release|Win32 + {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Release|Win32.Build.0 = Release|Win32 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Release|x64.ActiveCfg = Release|x64 + {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Release|x64.Build.0 = Release|x64 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Release|x64 Setup.ActiveCfg = Release|x64 {7F1610F1-DD5A-4CF7-8610-30AB12C60ADD}.Release|x86 Setup.ActiveCfg = Release|Win32 {9254C4B0-6F60-42B6-BB3A-36D63FC001C7}.All|Win32.ActiveCfg = Release|x64 @@ -2098,11 +2123,15 @@ Global {66444AEE-554C-11DD-A9F0-8C5D56D89593}.All|x64 Setup.Build.0 = Release Static|x64 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.All|x86 Setup.ActiveCfg = Release Static|x64 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Debug|Win32.ActiveCfg = Debug|Win32 + {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Debug|Win32.Build.0 = Debug|Win32 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Debug|x64.ActiveCfg = Debug|x64 + {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Debug|x64.Build.0 = Debug|x64 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Debug|x64 Setup.ActiveCfg = Debug|x64 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Release|Win32.ActiveCfg = Release|Win32 + {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Release|Win32.Build.0 = Release|Win32 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Release|x64.ActiveCfg = Release|x64 + {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Release|x64.Build.0 = Release|x64 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Release|x64 Setup.ActiveCfg = Release|x64 {66444AEE-554C-11DD-A9F0-8C5D56D89593}.Release|x86 Setup.ActiveCfg = Release|Win32 {D5D2BF72-29FE-4982-A9FA-82FDD086DB1B}.All|Win32.ActiveCfg = Release|Win32 @@ -2636,11 +2665,15 @@ Global {CC1DD008-9406-448D-A0AD-33C3186CFADB}.All|x64 Setup.ActiveCfg = Release|Win32 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.All|x86 Setup.ActiveCfg = Release|Win32 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Debug|Win32.ActiveCfg = Debug|Win32 + {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Debug|Win32.Build.0 = Debug|Win32 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Debug|x64.ActiveCfg = Debug|x64 + {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Debug|x64.Build.0 = Debug|x64 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Debug|x64 Setup.ActiveCfg = Debug|x64 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Release|Win32.ActiveCfg = Release|Win32 + {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Release|Win32.Build.0 = Release|Win32 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Release|x64.ActiveCfg = Release|x64 + {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Release|x64.Build.0 = Release|x64 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Release|x64 Setup.ActiveCfg = Release|x64 {CC1DD008-9406-448D-A0AD-33C3186CFADB}.Release|x86 Setup.ActiveCfg = Release|Win32 {48414740-C693-4968-9846-EE058020C64F}.All|Win32.ActiveCfg = Release|Win32 @@ -2648,11 +2681,15 @@ Global {48414740-C693-4968-9846-EE058020C64F}.All|x64 Setup.ActiveCfg = Release|Win32 {48414740-C693-4968-9846-EE058020C64F}.All|x86 Setup.ActiveCfg = Release|Win32 {48414740-C693-4968-9846-EE058020C64F}.Debug|Win32.ActiveCfg = Debug|Win32 + {48414740-C693-4968-9846-EE058020C64F}.Debug|Win32.Build.0 = Debug|Win32 {48414740-C693-4968-9846-EE058020C64F}.Debug|x64.ActiveCfg = Debug|x64 + {48414740-C693-4968-9846-EE058020C64F}.Debug|x64.Build.0 = Debug|x64 {48414740-C693-4968-9846-EE058020C64F}.Debug|x64 Setup.ActiveCfg = Debug|x64 {48414740-C693-4968-9846-EE058020C64F}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {48414740-C693-4968-9846-EE058020C64F}.Release|Win32.ActiveCfg = Release|Win32 + {48414740-C693-4968-9846-EE058020C64F}.Release|Win32.Build.0 = Release|Win32 {48414740-C693-4968-9846-EE058020C64F}.Release|x64.ActiveCfg = Release|x64 + {48414740-C693-4968-9846-EE058020C64F}.Release|x64.Build.0 = Release|x64 {48414740-C693-4968-9846-EE058020C64F}.Release|x64 Setup.ActiveCfg = Release|x64 {48414740-C693-4968-9846-EE058020C64F}.Release|x86 Setup.ActiveCfg = Release|Win32 {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.ActiveCfg = All|Win32 @@ -2712,11 +2749,15 @@ Global {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.All|x86 Setup.ActiveCfg = Release|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.All|x86 Setup.Build.0 = Release|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|Win32.ActiveCfg = Debug|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|Win32.Build.0 = Debug|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|x64.ActiveCfg = Debug|x64 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|x64.Build.0 = Debug|x64 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|x64 Setup.ActiveCfg = Debug|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|Win32.ActiveCfg = Release|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|Win32.Build.0 = Release|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|x64.ActiveCfg = Release|x64 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|x64.Build.0 = Release|x64 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|x64 Setup.ActiveCfg = Release|Win32 {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|x86 Setup.ActiveCfg = Release|Win32 {1F0A8A77-E661-418F-BB92-82172AE43803}.All|Win32.ActiveCfg = Release|Win32 @@ -3386,11 +3427,15 @@ Global {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.All|x64 Setup.Build.0 = Release|x64 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.All|x86 Setup.ActiveCfg = Release|x64 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|Win32.ActiveCfg = Debug|Win32 + {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|Win32.Build.0 = Debug|Win32 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|x64.ActiveCfg = Debug|x64 + {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|x64.Build.0 = Debug|x64 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|x64 Setup.ActiveCfg = Debug|x64 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|Win32.ActiveCfg = Release|Win32 + {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|Win32.Build.0 = Release|Win32 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|x64.ActiveCfg = Release|x64 + {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|x64.Build.0 = Release|x64 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|x64 Setup.ActiveCfg = Release|x64 {B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|x86 Setup.ActiveCfg = Release|Win32 {05C9FB27-480E-4D53-B3B7-7338E2514666}.All|Win32.ActiveCfg = Release|Win32 @@ -3414,11 +3459,15 @@ Global {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.All|x64 Setup.Build.0 = Release|x64 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.All|x86 Setup.ActiveCfg = Release|x64 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Debug|Win32.ActiveCfg = Debug|Win32 + {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Debug|Win32.Build.0 = Debug|Win32 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Debug|x64.ActiveCfg = Debug|x64 + {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Debug|x64.Build.0 = Debug|x64 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Debug|x64 Setup.ActiveCfg = Debug|x64 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Debug|x86 Setup.ActiveCfg = Debug|Win32 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Release|Win32.ActiveCfg = Release|Win32 + {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Release|Win32.Build.0 = Release|Win32 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Release|x64.ActiveCfg = Release|x64 + {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Release|x64.Build.0 = Release|x64 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Release|x64 Setup.ActiveCfg = Release|x64 {5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F}.Release|x86 Setup.ActiveCfg = Release|Win32 {47213370-B933-487D-9F45-BCA26D7E2B6F}.All|Win32.ActiveCfg = Release|x86 @@ -3453,7 +3502,7 @@ Global {7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64.ActiveCfg = Release|x64 {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|x64 + {7C22BDFF-CC09-400C-8A09-660733980028}.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 @@ -3470,33 +3519,41 @@ Global {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.ActiveCfg = Release|x64 {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.Build.0 = Release|x64 {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64 Setup.ActiveCfg = Release|x64 - {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x86 Setup.ActiveCfg = Release|x64 + {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x86 Setup.ActiveCfg = Release|Win32 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|Win32.ActiveCfg = Release|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x64.ActiveCfg = Release|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x64.Build.0 = Release|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x64 Setup.ActiveCfg = Release|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x86 Setup.ActiveCfg = Release|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|Win32.ActiveCfg = Debug|Win32 + {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|Win32.Build.0 = Debug|Win32 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x64.ActiveCfg = Debug|x64 + {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x64.Build.0 = Debug|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x64 Setup.ActiveCfg = Debug|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x86 Setup.ActiveCfg = Debug|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|Win32.ActiveCfg = Release|Win32 + {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|Win32.Build.0 = Release|Win32 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x64.ActiveCfg = Release|x64 + {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x64.Build.0 = Release|x64 {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x64 Setup.ActiveCfg = Release|x64 - {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x86 Setup.ActiveCfg = Release|x64 + {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x86 Setup.ActiveCfg = Release|Win32 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.All|Win32.ActiveCfg = Release|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.All|x64.ActiveCfg = Release|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.All|x64.Build.0 = Release|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.All|x64 Setup.ActiveCfg = Release|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.All|x86 Setup.ActiveCfg = Release|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Debug|Win32.ActiveCfg = Debug|Win32 + {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Debug|Win32.Build.0 = Debug|Win32 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Debug|x64.ActiveCfg = Debug|x64 + {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Debug|x64.Build.0 = Debug|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Debug|x64 Setup.ActiveCfg = Debug|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Debug|x86 Setup.ActiveCfg = Debug|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|Win32.ActiveCfg = Release|Win32 + {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|Win32.Build.0 = Release|Win32 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|x64.ActiveCfg = Release|x64 + {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|x64.Build.0 = Release|x64 {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|x64 Setup.ActiveCfg = Release|x64 - {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|x86 Setup.ActiveCfg = Release|x64 + {50AAC2CE-BFC9-4912-87CC-C6381850D735}.Release|x86 Setup.ActiveCfg = Release|Win32 {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.All|Win32.ActiveCfg = Release|x64 {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.All|x64.ActiveCfg = Release|x64 {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.All|x64.Build.0 = Release|x64 @@ -3513,7 +3570,7 @@ Global {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.Release|x64.ActiveCfg = Release|x64 {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.Release|x64.Build.0 = Release|x64 {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.Release|x64 Setup.ActiveCfg = Release|x64 - {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.Release|x86 Setup.ActiveCfg = Release|x64 + {4748FF56-CA85-4809-97D6-A94C0FAC1D77}.Release|x86 Setup.ActiveCfg = Release|Win32 {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.All|Win32.ActiveCfg = Release|x64 {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.All|x64.ActiveCfg = Release|x64 {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.All|x64.Build.0 = Release|x64 @@ -3530,20 +3587,118 @@ Global {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.Release|x64.ActiveCfg = Release|x64 {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.Release|x64.Build.0 = Release|x64 {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.Release|x64 Setup.ActiveCfg = Release|x64 - {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.Release|x86 Setup.ActiveCfg = Release|x64 + {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F}.Release|x86 Setup.ActiveCfg = Release|Win32 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.All|Win32.ActiveCfg = Release|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.All|x64.ActiveCfg = Release|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.All|x64.Build.0 = Release|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.All|x64 Setup.ActiveCfg = Release|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.All|x86 Setup.ActiveCfg = Release|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Debug|Win32.ActiveCfg = Debug|Win32 + {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Debug|Win32.Build.0 = Debug|Win32 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Debug|x64.ActiveCfg = Debug|x64 + {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Debug|x64.Build.0 = Debug|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Debug|x64 Setup.ActiveCfg = Debug|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Debug|x86 Setup.ActiveCfg = Debug|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|Win32.ActiveCfg = Release|Win32 + {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|Win32.Build.0 = Release|Win32 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|x64.ActiveCfg = Release|x64 + {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|x64.Build.0 = Release|x64 {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|x64 Setup.ActiveCfg = Release|x64 - {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|x86 Setup.ActiveCfg = Release|x64 + {2469B306-B027-4FF2-8815-C9C1EA2CAE79}.Release|x86 Setup.ActiveCfg = Release|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|Win32.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|x64.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|x64.Build.0 = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|x64 Setup.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.All|x86 Setup.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Debug|Win32.ActiveCfg = Debug|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Debug|x64.ActiveCfg = Debug|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Debug|x86 Setup.ActiveCfg = Debug|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Release|Win32.ActiveCfg = Release|Win32 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Release|x64.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Release|x64 Setup.ActiveCfg = Release|x64 + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53}.Release|x86 Setup.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|Win32.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|x64.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|x64.Build.0 = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|x64 Setup.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.All|x86 Setup.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Debug|Win32.ActiveCfg = Debug|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Debug|x64.ActiveCfg = Debug|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Debug|x86 Setup.ActiveCfg = Debug|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|Win32.ActiveCfg = Release|Win32 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|x64.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|x64 Setup.ActiveCfg = Release|x64 + {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|x86 Setup.ActiveCfg = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|Win32.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|Win32.Build.0 = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|x64.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|x64 Setup.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|x86 Setup.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|Win32.ActiveCfg = Debug|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|Win32.Build.0 = Debug|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64.ActiveCfg = Debug|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64.Build.0 = Debug|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|Win32.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|Win32.Build.0 = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64.ActiveCfg = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64.Build.0 = Release|x64 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64 Setup.ActiveCfg = Release|Win32 + {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x86 Setup.ActiveCfg = Release|Win32 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|Win32.ActiveCfg = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|x64.ActiveCfg = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|x64.Build.0 = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|x64 Setup.ActiveCfg = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|x86 Setup.ActiveCfg = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Debug|Win32.ActiveCfg = Debug|Win32 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Debug|Win32.Build.0 = Debug|Win32 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Debug|x64.ActiveCfg = Debug|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Debug|x64.Build.0 = Debug|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Debug|x64 Setup.ActiveCfg = Debug|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Debug|x86 Setup.ActiveCfg = Debug|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Release|Win32.ActiveCfg = Release|Win32 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Release|Win32.Build.0 = Release|Win32 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Release|x64.ActiveCfg = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Release|x64.Build.0 = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Release|x64 Setup.ActiveCfg = Release|x64 + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.Release|x86 Setup.ActiveCfg = Release|x64 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|Win32.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|Win32.Build.0 = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|x64.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|x64 Setup.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.All|x86 Setup.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|Win32.ActiveCfg = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|Win32.Build.0 = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|x64.ActiveCfg = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|x64.Build.0 = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|x64 Setup.ActiveCfg = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Debug|x86 Setup.ActiveCfg = Debug|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|Win32.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|Win32.Build.0 = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|x64.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|x64.Build.0 = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|x64 Setup.ActiveCfg = Release|Win32 + {652AD5F7-8488-489F-AAD0-7FBE064703B6}.Release|x86 Setup.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|Win32.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|Win32.Build.0 = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|x64.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|x64 Setup.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.All|x86 Setup.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|Win32.ActiveCfg = Debug|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|Win32.Build.0 = Debug|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|x64.ActiveCfg = Debug|x64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|x64.Build.0 = Debug|x64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|x64 Setup.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Debug|x86 Setup.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|Win32.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|Win32.Build.0 = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x64.ActiveCfg = Release|x64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x64.Build.0 = Release|x64 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x64 Setup.ActiveCfg = Release|Win32 + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}.Release|x86 Setup.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3569,6 +3724,7 @@ Global {48414740-C693-4968-9846-EE058020C64F} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {05C9FB27-480E-4D53-B3B7-7338E2514666} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} + {74B120FF-6935-4DFE-A142-CDB6BEA99C90} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {C24FB505-05D7-4319-8485-7540B44C8603} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} @@ -3598,6 +3754,7 @@ Global {4748FF56-CA85-4809-97D6-A94C0FAC1D77} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {60C542EE-6882-4EA2-8C21-5AB6DB1BA73F} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {2469B306-B027-4FF2-8815-C9C1EA2CAE79} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} @@ -3655,6 +3812,9 @@ Global {E4D29906-8B73-4F8A-B5F4-CA8BFA648F5A} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {23B4D303-79FC-49E0-89E2-2280E7E28940} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {C13CC324-0032-4492-9A30-310A6BD64FF5} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {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} {ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000} @@ -3693,6 +3853,7 @@ Global {FFF82F9B-6A2B-4BE3-95D8-DC5A4FC71E19} = {C120A020-773F-4EA3-923F-B67AF28B750D} {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} {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} diff --git a/Makefile.am b/Makefile.am index c6e112c4b9..653974d67c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,11 +20,18 @@ DEFAULT_SOUNDS=en-us-callie-8000 sounds_version=`grep $$base_sound_dir $(switch_srcdir)/build/sounds_version.txt | cut -d ' ' -f2`;\ soundfile=`echo freeswitch-sounds-$$full_sound_dir-$$moh_version.tar.gz`; \ echo $$full_sound_dir | grep music >/dev/null || soundfile=`echo freeswitch-sounds-$$full_sound_dir-$$sounds_version.tar.gz`; \ - if test "$$target" = "install"; then $(MAKE) $(AM_MAKEFLAGS) core_install; else $(MAKE) $(AM_MAKEFLAGS) core ; fi; \ if test "$$target_prefix" = "sounds"; then \ - if test "$$target" = "install"; then $(GETSOUNDS) $$soundfile $(DESTDIR)$(soundsdir)/; else $(GETSOUNDS) $$soundfile ; fi; \ + if test "$$target" = "install"; then \ + $(GETSOUNDS) $$soundfile $(DESTDIR)$(soundsdir)/;\ + else \ + $(GETSOUNDS) $$soundfile ; \ + fi; \ else \ - cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@ ;\ + if test "$$target" = "install"; then \ + $(MAKE) $(AM_MAKEFLAGS) core_install && cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@ ; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) core && cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@ ;\ + fi; \ fi sounds: sounds-en-us-callie-8000 @@ -102,7 +109,7 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/pcre CORE_CFLAGS += -I$(switch_srcdir)/libs/speex/include -Ilibs/speex/include 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-3.8.2/libtiff +CORE_CFLAGS += -I$(switch_srcdir)/libs/spandsp/src -I$(switch_srcdir)/libs/tiff-4.0.2/libtiff 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 @@ -150,8 +157,8 @@ if ENABLE_ZRTP CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bgaes CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bnlib CORE_CFLAGS += -isystem $(switch_srcdir)/libs/libzrtp/include -ZRTP_LDFLAGS = -Llibs/libzrtp/third_party/bnlib -ZRTP_LDFLAGS += -Llibs/libzrtp/projects/gnu/build +ZRTP_LDFLAGS = -L$(switch_srcdir)/libs/libzrtp/third_party/bnlib +ZRTP_LDFLAGS += -L$(switch_srcdir)/libs/libzrtp/projects/gnu/build ZRTP_LIBS = -lbn -lzrtp libfreeswitch_la_LDFLAGS += $(ZRTP_LDFLAGS) libfreeswitch_la_LIBADD += $(ZRTP_LIBS) @@ -408,29 +415,19 @@ $(OUR_MODULES): $(switch_builddir)/modules.conf libfreeswitch.la $(switch_builddir)/quiet_libtool: $(switch_builddir)/libtool @cat libtool | sed -e 's|$$show "$$command"|if test -z "$$suppress_output" ; then $$show "Compiling $$srcfile ..." ; fi|' > $(switch_builddir)/quiet_libtool -src/include/switch_version.h: src/include/switch_version.h.in .version $(libfreeswitch_la_SOURCES) $(library_include_HEADERS) - @have_version=1 ; \ - force=0 ; \ - grep "@SWITCH_VERSION_REVISION@" src/include/switch_version.h.in > /dev/null && have_version=0 ; \ - test ! -f src/include/switch_version.h || grep "@SWITCH_VERSION_REVISION@" src/include/switch_version.h > /dev/null && force=1 ; \ - if test $$have_version = 1 ; then \ - cat src/include/switch_version.h.in > src/include/switch_version.h ; \ - touch .version ; \ - else \ - if [ -d .git ] ; then \ - version=`git log --pretty=format:"%h %ci" -1 HEAD | head -1 | sed -e 's|:|-|g' || echo hacked` ; \ - if [ "x$$version" = "xhacked" ] ; then \ - version="hacked-`date -u +%Y%m%dT%H%M%SZ`" ; \ - else \ - version="git-$$version" ; \ - fi ;\ - fi ; \ - oldversion=`cat .version 2>/dev/null || echo "0"` ; \ - if test "$$oldversion" != "$$version" || test $$force = 1 ; then \ - cat src/include/switch_version.h.in | sed "s/@SWITCH_VERSION_REVISION@/$$version/g" > src/include/switch_version.h ; \ - echo $$version > .version ; \ - fi ; \ - fi ; +build/print_git_revision: build/print_git_revision.c + $(CC) -o $@ $< + +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 \ + xver="$$(./build/print_git_revision)"; \ + xhver="$$(./build/print_git_revision -h)"; \ + sed \ + -e "/#define *SWITCH_VERSION_REVISION[^a-zA-Z0-9_]/{s/\"\([^\"]*\)\"/\"\1$$xver\"/;}" \ + -e "/#define *SWITCH_VERSION_REVISION_HUMAN[^a-zA-Z0-9_]/{s/\"\([^\"]*\)\"/\"\1$$xhver\"/;}" \ + $< > $@; \ + fi; ## ## Dependency targets @@ -537,7 +534,6 @@ is-scm: update: is-scm @if test -d .git ; then \ - test ! -f .version || rm -f .version ; \ echo "Pulling updates..." ; \ git pull ; \ else \ @@ -621,8 +617,8 @@ sndfile-reconf: cd libs/libsndfile && ./config.status tiff-reconf: - cd libs/tiff-3.8.2 && autoreconf -fi - cd libs/tiff-3.8.2 && sh ./configure.gnu + cd libs/tiff-4.0.2 && autoreconf -fi + cd libs/tiff-4.0.2 && sh ./configure.gnu cd libs/spandsp && autoreconf -fi cd libs/spandsp && sh ./configure.gnu make mod_voipcodecs-clean @@ -663,6 +659,7 @@ cluecon: @clear @echo Thank you for updating. This is going to take a while so relax. @echo Now would be a good time to register for ClueCon! + @cat cluecon2.tmpl @echo @echo http://www.cluecon.com @sleep 5 diff --git a/bootstrap.sh b/bootstrap.sh index 93c96f4088..f6d4cfd05a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -9,8 +9,8 @@ VERBOSE=false BASEDIR=`pwd`; LIBDIR=${BASEDIR}/libs; SUBDIRS="apr \ - libzrtp ilbc curl iksemel js js/nsprpub ldns libdingaling libedit libsndfile pcre sofia-sip \ - speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk libcodec2 \ + libzrtp ilbc curl iksemel js js/nsprpub ldns libdingaling libedit libsndfile pcre sofia-sip libwebsockets \ + speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-4.0.2 broadvoice silk libcodec2 \ fs"; while getopts 'jhd:v' o; do @@ -209,24 +209,11 @@ check_make() { check_awk() { - # - # Check to make sure we have GNU Make installed - # - - awk=`which awk` - if [ -x "$awk" ]; then - awk_version=`$awk --version | head -n 1 |grep GNU` - if [ $? -ne 0 ]; then - awk=`which gawk` - if [ -x "$awk" ]; then - awk_version=`$awk --version | head -n 1 |grep GNU` - if [ $? -ne 0 ]; then - echo "GNU awk does not exist or is not executable" - exit 1; - fi - fi - fi - fi + # TODO: Building with mawk on at least Debian squeeze is know to + # work, but mawk is believed to fail on some systems. If we can + # replicate this, we need a particular behavior that we can test + # here to verify whether we have an acceptable awk. + : } @@ -356,11 +343,7 @@ bootstrap_apr() { echo "Entering directory ${LIBDIR}/apr-util" cd ${LIBDIR}/apr-util - if ! ${BGJOB}; then - ./buildconf - else - ./buildconf & - fi + ./buildconf } bootstrap_libzrtp() { @@ -447,7 +430,7 @@ bootstrap_libs_post() { ldns) cd $BASEDIR/libs/ldns if test ! -x install-sh; then - ex automake --add-missing --copy + ex ${AUTOMAKE:-automake} --add-missing --copy ex rm -rf autom4te*.cache fi ;; @@ -467,9 +450,10 @@ bootstrap_libs() { if ! ${BGJOB}; then libbootstrap ${i} ; bootstrap_libs_post ${i} else - ((libbootstrap ${i} ; bootstrap_libs_post ${i}) &) + (libbootstrap ${i} ; bootstrap_libs_post ${i}) & fi done + ${BGJOB} && wait } run() { @@ -484,7 +468,6 @@ run() { check_libtoolize print_autotools_vers bootstrap_libs - ${BGJOB} && wait return 0 } diff --git a/build/Makefile.am b/build/Makefile.am index 1d57dad528..3feb22157d 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -11,7 +11,7 @@ all: @echo " + http://www.cluecon.com +" @echo " + +" @echo " +-----------------------------------------------+" - + @cat ../cluecon2.tmpl install: @echo " +---------- FreeSWITCH install Complete ----------+" @@ -69,7 +69,7 @@ install: @echo " + http://www.cluecon.com +" @echo " + +" @echo " +-------------------------------------------------+" - + @cat ../cluecon2.tmpl .PHONY: check dvi html info install-data \ diff --git a/build/buildopal.sh b/build/buildopal.sh index 78b7a20ab1..a838d9c339 100755 --- a/build/buildopal.sh +++ b/build/buildopal.sh @@ -1,20 +1,61 @@ #!/bin/sh + +if [ -z "$1" ]; then + INSTALLDIR=/usr/local +else + INSTALLDIR="$1" +fi + +if [ -z `which svn` ]; then + echo "Need SVN installed!" + exit 1 +fi + uname -a | grep -qi bsd && MAKE=gmake || MAKE=make + +#Locate our script, then go up one directory to be in FreeSWITCH root +cd `dirname $0` +cd .. FS_DIR=`pwd` -cd /root -svn co https://opalvoip.svn.sourceforge.net/svnroot/opalvoip/ptlib/trunk ptlib -cd ptlib -./configure --prefix=/usr -${MAKE} -${MAKE} install +export PKG_CONFIG_PATH=$INSTALLDIR/lib/pkgconfig -cd .. -svn co https://opalvoip.svn.sourceforge.net/svnroot/opalvoip/opal/branches/v3_6 opal -cd opal -export PKG_CONFIG_PATH=/usr/lib/pkgconfig -./configure --prefix=/usr + +# Version and patch for PTLib and OPAL. These are almost always in lock +# step so shoud be the same unless you really know ehat you are doing! +# The PATCH should be set to a specific"snapshot release" when things +# are nice and stable. + +VERSION=10 +#PATCH=6 + +if [ -z "$PATCH" ]; then + PTLIB_VERSION=branches/v2_$VERSION + OPAL_VERSION=branches/v3_$VERSION +else + PTLIB_VERSION=tags/v2_${VERSION}_$PATCH + OPAL_VERSION=tags/v3_${VERSION}_$PATCH +fi + + +cd $FS_DIR/libs +svn co https://opalvoip.svn.sourceforge.net/svnroot/opalvoip/ptlib/$PTLIB_VERSION ptlib +cd $FS_DIR/libs/ptlib +# LDAP disabled due to conflict wit libs in spidermonkey +./configure --disable-plugins --disable-openldap --prefix=$INSTALLDIR ${MAKE} -${MAKE} install -cd ${FS_DIR} -${MAKE} mod_opal-install +sudo ${MAKE} install + +cd $FS_DIR/libs +svn co https://opalvoip.svn.sourceforge.net/svnroot/opalvoip/opal/$OPAL_VERSION opal +cd $FS_DIR/libs/opal +./configure --disable-plugins --prefix=$INSTALLDIR +$MAKE +sudo $MAKE install + +echo "======================================" +echo "PTLib/OPAL build and install completed" +echo "======================================" + +cd $FS_DIR +$MAKE mod_opal-install diff --git a/build/freeswitch.init.suse b/build/freeswitch.init.suse index 2859ddc501..29f832d86a 100644 --- a/build/freeswitch.init.suse +++ b/build/freeswitch.init.suse @@ -46,12 +46,7 @@ # Voice Platform ### END INIT INFO # -# Check for missing binaries (stale symlinks should not happen) -# Note: Special treatment of stop for LSB conformance FREESWITCH_BIN=/opt/freeswitch/bin/freeswitch -test -x $FREESWITCH_BIN || { echo "$FREESWITCH_BIN not installed"; - if [ "$1" = "stop" ]; then exit 0; - else exit 5; fi; } # Check for existence of needed config file and read it FREESWITCH_CONFIG=/etc/sysconfig/freeswitch @@ -62,6 +57,12 @@ test -r $FREESWITCH_CONFIG || { echo "$FREESWITCH_CONFIG not existing"; # Read config . $FREESWITCH_CONFIG +# Check for missing binaries (stale symlinks should not happen) +# Note: Special treatment of stop for LSB conformance +test -x $FREESWITCH_BIN || { echo "$FREESWITCH_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + # Source LSB init functions # providing start_daemon, killproc, pidofproc, # log_success_msg, log_failure_msg and log_warning_msg. @@ -202,7 +203,7 @@ case "$1" in ## argument to this init script which is required for a reload. ## Note: probe is not (yet) part of LSB (as of 1.9) - test /opt/freeswitch/conf/freeswitch.xml -nt /opt/freeswitch/run/freeswitch.pid && echo reload + test ${FREESWITCH_HOME}/conf/freeswitch.xml -nt ${FREESWITCH_HOME}/run/freeswitch.pid && echo reload ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" diff --git a/build/getlib.sh.in b/build/getlib.sh.in index bbfe696f79..f18ec1da2d 100755 --- a/build/getlib.sh.in +++ b/build/getlib.sh.in @@ -1,4 +1,5 @@ #!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- TAR=@TAR@ ZCAT=@ZCAT@ @@ -8,39 +9,39 @@ WGET=@WGET@ CURL=@CURL@ if [ -f "$WGET" ]; then - DOWNLOAD_CMD=$WGET + DOWNLOAD_CMD=$WGET elif [ -f "$CURL" ]; then - DOWNLOAD_CMD="$CURL -O" + DOWNLOAD_CMD="$CURL -O" fi if [ -n "`echo $1 | grep '://'`" ]; then - base=$1/ - tarfile=$2 + base=$1/ + tarfile=$2 else - base=http://files.freeswitch.org/downloads/libs/ - tarfile=$1 + base=http://files.freeswitch.org/downloads/libs/ + tarfile=$1 fi uncompressed=`echo $tarfile | sed 's/\(\(\.tar\.gz\|\.tar\.bz2\|\.tar\.xz\)\|\(\.tgz\|\.tbz2\)\)$//'` case `echo $tarfile | sed 's/^.*\.//'` in - bz2|tbz2) UNZIPPER=$BZIP ;; - xz) UNZIPPER=$XZ ;; - gz|tgz|*) UNZIPPER=$ZCAT ;; + bz2|tbz2) UNZIPPER=$BZIP ;; + xz) UNZIPPER=$XZ ;; + gz|tgz|*) UNZIPPER=$ZCAT ;; esac if [ ! -d $tarfile ]; then + if [ ! -f $tarfile ]; then + rm -fr $uncompressed + $DOWNLOAD_CMD $base$tarfile if [ ! -f $tarfile ]; then - rm -fr $uncompressed - $DOWNLOAD_CMD $base$tarfile - if [ ! -f $tarfile ]; then - echo cannot find $tarfile - exit 1 - fi - fi - if [ ! -d $uncompressed ]; then - $UNZIPPER -c -d $tarfile | $TAR -xf - + echo cannot find $tarfile + exit 1 fi + fi + if [ ! -d $uncompressed ]; then + $UNZIPPER -c -d $tarfile | $TAR -xf - + fi fi exit 0 diff --git a/build/getsounds.sh.in b/build/getsounds.sh.in index 09105fd280..3f14eab822 100755 --- a/build/getsounds.sh.in +++ b/build/getsounds.sh.in @@ -1,4 +1,5 @@ #!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- TAR=@TAR@ ZCAT=@ZCAT@ @@ -7,11 +8,11 @@ CURL=@CURL@ DIR=`pwd` -if [ -x "$WGET" ] ; then - DOWNLOAD_CMD=$WGET +if [ -x "$WGET" ]; then + DOWNLOAD_CMD=$WGET fi if [ "x${DOWNLOAD_CMD}" = "x" -a -x "$CURL" ] ; then - DOWNLOAD_CMD="$CURL -O" + DOWNLOAD_CMD="$CURL -O" fi base=http://files.freeswitch.org/ @@ -22,17 +23,22 @@ echo -n "#" pwd echo "# $0 $1 $2" -if [ ! -f $tarfile ] ; then - $DOWNLOAD_CMD $base$tarfile - if [ ! -f $tarfile ] ; then - echo cannot find $tarfile - exit 1 - fi +if [ -n "$FS_SOUNDS_DIR" ]; then + [ -d $FS_SOUNDS_DIR ] || mkdir -p $FS_SOUNDS_DIR + DIR=$FS_SOUNDS_DIR fi -if [ ! -z $install ] ; then - test -d $install || mkdir $install - cd $install && $ZCAT -c -d $DIR/$tarfile | $TAR xf - +if [ ! -f $DIR/$tarfile ]; then + (cd $DIR && $DOWNLOAD_CMD $base$tarfile) + if [ ! -f $DIR/$tarfile ]; then + echo "cannot find $tarfile" + exit 1 + fi +fi + +if [ ! -z "$install" ]; then + test -d $install || mkdir $install + (cd $install && $ZCAT -c -d $DIR/$tarfile | $TAR xf -) fi exit 0 diff --git a/build/ignore_helper.pl b/build/ignore_helper.pl index cc89c6814c..154afc7d4c 100644 --- a/build/ignore_helper.pl +++ b/build/ignore_helper.pl @@ -1,6 +1,6 @@ ################################################################################ # ignore_helper.pl -# Copyright (c) 2007-2009 Anthony Minessale II +# Copyright (c) 2007-2012 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/modules.conf.in b/build/modules.conf.in index 18babbfec9..80970cf7f6 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -42,6 +42,7 @@ applications/mod_valet_parking #applications/mod_vmd applications/mod_voicemail #applications/mod_voicemail_ivr +#applications/mod_random #asr_tts/mod_cepstral #asr_tts/mod_flite #asr_tts/mod_pocketsphinx @@ -57,12 +58,13 @@ codecs/mod_bv codecs/mod_g723_1 codecs/mod_g729 codecs/mod_h26x -codecs/mod_ilbc +codecs/mod_vp8 +#codecs/mod_ilbc #codecs/mod_isac #codecs/mod_opus #codecs/mod_sangoma_codec #codecs/mod_silk -codecs/mod_siren +#codecs/mod_siren codecs/mod_speex dialplans/mod_dialplan_asterisk #dialplans/mod_dialplan_directory @@ -71,6 +73,7 @@ dialplans/mod_dialplan_xml #endpoints/mod_alsa #endpoints/mod_dingaling #endpoints/mod_h323 +#endpoints/mod_html5 #endpoints/mod_khomp endpoints/mod_loopback #endpoints/mod_opal @@ -96,6 +99,7 @@ formats/mod_native_file #formats/mod_shout formats/mod_sndfile formats/mod_tone_stream +#formats/mod_vlc #languages/mod_java languages/mod_lua #languages/mod_managed @@ -124,6 +128,7 @@ xml_int/mod_xml_cdr #xml_int/mod_xml_curl #xml_int/mod_xml_ldap xml_int/mod_xml_rpc +xml_int/mod_xml_scgi #../../libs/freetdm/mod_freetdm #../../libs/openzap/mod_openzap diff --git a/build/next-release.txt b/build/next-release.txt new file mode 100644 index 0000000000..996f71d3b9 --- /dev/null +++ b/build/next-release.txt @@ -0,0 +1 @@ +1.2-rc3 diff --git a/build/print_git_revision.c b/build/print_git_revision.c new file mode 100644 index 0000000000..0f8e680b37 --- /dev/null +++ b/build/print_git_revision.c @@ -0,0 +1,93 @@ +/* -*- mode:c; indent-tabs-mode:nil; c-basic-offset:2 -*- + * Author: Travis Cross + */ + +#include +#include +#include +#include +#include +#include + +static int show_unclean = 0; + +static int sys(char *buf, int buflen, char *cmd) { + int i, p[2]; + if (pipe(p)) return 255; + if (!(i=fork())) { + close(p[0]); + dup2(p[1],1); + close(p[1]); + execlp("sh","sh","-c",cmd,NULL); + } else { + int s, x=0; + close(p[1]); + waitpid(i,&s,0); + if (!(WIFEXITED(s))) return 255; + if (WEXITSTATUS(s)) return WEXITSTATUS(s); + if (buf) { + while (buflen>1 && (x=read(p[0],buf,buflen-1))>0) buf+=x,buflen-=x; + close(p[0]); + if (x<0) return 255; + *buf=0; + } else close(p[0]); + } + return 0; +} + +static int sys1(char *buf, int buflen, char *cmd) { + int r; char *c; + if ((r=sys(buf,buflen,cmd))) return r; + if ((c=strstr(buf,"\n"))) *c=0; + return 0; +} + +static int print_version(void) { + char xver[256], xdate[256], xfdate[256], xcommit[256]; + time_t xdate_t; struct tm *xdate_tm; + if ((sys1(xdate,sizeof(xdate),"git log -n1 --format='%ct' HEAD"))) return 1; + xdate_t=(time_t)atoi(xdate); + if (!(xdate_tm=gmtime(&xdate_t))) return 1; + strftime(xfdate,sizeof(xfdate),"%Y%m%dT%H%M%SZ",xdate_tm); + if ((sys1(xcommit,sizeof(xcommit),"git rev-list -n1 --abbrev=10 --abbrev-commit HEAD"))) + return 1; + snprintf(xver,sizeof(xver),"+git~%s~%s",xfdate,xcommit); + if (show_unclean && (sys(NULL,0,"git diff-index --quiet HEAD"))) { + char buf[256], now[256]; time_t now_t=time(NULL); struct tm *now_tm; + if (!(now_tm=gmtime(&now_t))) return 1; + strftime(now,sizeof(now),"%Y%m%dT%H%M%SZ",now_tm); + snprintf(buf,sizeof(buf),"%s+unclean~%s",xver,now); + strncpy(xver,buf,sizeof(xver)); + } + printf("%s\n",xver); + return 0; +} + +static int print_human_version(void) { + char xver[256], xdate[256], xfdate[256], xcommit[256]; + time_t xdate_t; struct tm *xdate_tm; + if ((sys1(xdate,sizeof(xdate),"git log -n1 --format='%ct' HEAD"))) return 1; + xdate_t=(time_t)atoi(xdate); + if (!(xdate_tm=gmtime(&xdate_t))) return 1; + strftime(xfdate,sizeof(xfdate),"%a, %d %b %Y %H:%M:%S Z",xdate_tm); + if ((sys1(xcommit,sizeof(xcommit),"git rev-list -n1 --abbrev=10 --abbrev-commit HEAD"))) + return 1; + snprintf(xver,sizeof(xver),"; git at commit %s on %s",xcommit,xfdate); + if (show_unclean && (sys(NULL,0,"git diff-index --quiet HEAD"))) { + char buf[256], now[256]; time_t now_t=time(NULL); struct tm *now_tm; + if (!(now_tm=gmtime(&now_t))) return 1; + strftime(now,sizeof(now),"%a, %d %b %Y %H:%M:%S Z",now_tm); + snprintf(buf,sizeof(buf),"%s; unclean git build on %s",xver,now); + strncpy(xver,buf,sizeof(xver)); + } + printf("%s\n",xver); + return 0; +} + +int main(int argc, char **argv) { + if (argc > 1 && !strcasecmp(argv[1],"-h")) + return print_human_version(); + else + return print_version(); +} + diff --git a/build/set-fs-version.sh b/build/set-fs-version.sh new file mode 100755 index 0000000000..6743b58b5f --- /dev/null +++ b/build/set-fs-version.sh @@ -0,0 +1,16 @@ +#!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- + +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/../scripts/ci/common.sh + +check_pwd +check_input_ver_build $@ +in_ver="$1" +if [ "$in_ver" = "auto" ]; then + in_ver="$(cat build/next-release.txt)" +fi +eval $(parse_version "$in_ver") +set_fs_ver "$gver" "$gmajor" "$gminor" "$gmicro" "$grev" + diff --git a/cc.sh b/cc.sh new file mode 100755 index 0000000000..85ab418e26 --- /dev/null +++ b/cc.sh @@ -0,0 +1,8 @@ +cc=`cat cluecon.tmpl | sed 's/\\\\/\\\\\\\\/g' | awk '{printf "%s\\\\n", $0}' ` + +cat < src/include/cc.h + +const char *cc = "$cc"; + +EOF + diff --git a/cluecon.tmpl b/cluecon.tmpl new file mode 100644 index 0000000000..39cc3d1d65 --- /dev/null +++ b/cluecon.tmpl @@ -0,0 +1,26 @@ +.========================================================================================================. +| ____ _____ ____ _ ____ _ _ _____ | +| / ___|___ _ __ ___ ___ |_ _|__ / ___| |_ _ ___ / ___|___ _ __ ( ) |___ / | +| | | / _ \| '_ ` _ \ / _ \ | |/ _ \ | | | | | | |/ _ \ | / _ \| '_ \ |/| | |_ \ | +| | |__| (_) | | | | | | __/ | | (_) | | |___| | |_| | __/ |__| (_) | | | | | |___) | | +| \____\___/|_| |_| |_|\___| |_|\___/ \____|_|\__,_|\___|\____\___/|_| |_| |_|____/ | +| | +| ____ _ _ _ _ ____ _ | +| / ___| |__ (_) ___ __ _ __ _ ___ | | | / ___| / \ | +| | | | '_ \| |/ __/ _` |/ _` |/ _ \ | | | \___ \ / _ \ | +| | |___| | | | | (_| (_| | (_| | (_) | | |_| |___) / ___ \ | +| \____|_| |_|_|\___\__,_|\__, |\___( ) \___/|____/_/ \_\ | +| |___/ |/ | +| _ _ __ _ _ ___ _ _ ____ ___ _ _____ | +| / \ _ _ __ _ _ _ ___| |_ / /_ | |_| |__ ( _ )| |_| |__ |___ \ / _ \/ |___ / | +| / _ \| | | |/ _` | | | / __| __| | '_ \| __| '_ \ _____ / _ \| __| '_ \ __) | | | | | |_ \ | +| / ___ \ |_| | (_| | |_| \__ \ |_ | (_) | |_| | | | |_____| | (_) | |_| | | | / __/| |_| | |___) | | +| /_/ \_\__,_|\__, |\__,_|___/\__| \___/ \__|_| |_| \___/ \__|_| |_| |_____|\___/|_|____/ | +| |___/ | +| _ | +| __ ____ ____ __ ___| |_ _ ___ ___ ___ _ __ ___ ___ _ __ ___ | +| \ \ /\ / /\ \ /\ / /\ \ /\ / / / __| | | | |/ _ \/ __/ _ \| '_ \ / __/ _ \| '_ ` _ \ | +| \ V V / \ V V / \ V V / _ | (__| | |_| | __/ (_| (_) | | | | _ | (_| (_) | | | | | | | +| \_/\_/ \_/\_/ \_/\_/ (_) \___|_|\__,_|\___|\___\___/|_| |_| (_) \___\___/|_| |_| |_| | +| | +.========================================================================================================. diff --git a/cluecon2.tmpl b/cluecon2.tmpl new file mode 100644 index 0000000000..f96668977c --- /dev/null +++ b/cluecon2.tmpl @@ -0,0 +1,29 @@ + +.========================================================================================================. +| ____ _____ ____ _ ____ _ _ _____ | +| / ___|___ _ __ ___ ___ |_ _|__ / ___| |_ _ ___ / ___|___ _ __ ( ) |___ / | +| | | / _ \| '_ ` _ \ / _ \ | |/ _ \ | | | | | | |/ _ \ | / _ \| '_ \ |/| | |_ \ | +| | |__| (_) | | | | | | __/ | | (_) | | |___| | |_| | __/ |__| (_) | | | | | |___) | | +| \____\___/|_| |_| |_|\___| |_|\___/ \____|_|\__,_|\___|\____\___/|_| |_| |_|____/ | +| | +| ____ _ _ _ _ ____ _ | +| / ___| |__ (_) ___ __ _ __ _ ___ | | | / ___| / \ | +| | | | '_ \| |/ __/ _` |/ _` |/ _ \ | | | \___ \ / _ \ | +| | |___| | | | | (_| (_| | (_| | (_) | | |_| |___) / ___ \ | +| \____|_| |_|_|\___\__,_|\__, |\___( ) \___/|____/_/ \_\ | +| |___/ |/ | +| _ _ __ _ _ ___ _ _ ____ ___ _ _____ | +| / \ _ _ __ _ _ _ ___| |_ / /_ | |_| |__ ( _ )| |_| |__ |___ \ / _ \/ |___ / | +| / _ \| | | |/ _` | | | / __| __| | '_ \| __| '_ \ _____ / _ \| __| '_ \ __) | | | | | |_ \ | +| / ___ \ |_| | (_| | |_| \__ \ |_ | (_) | |_| | | | |_____| | (_) | |_| | | | / __/| |_| | |___) | | +| /_/ \_\__,_|\__, |\__,_|___/\__| \___/ \__|_| |_| \___/ \__|_| |_| |_____|\___/|_|____/ | +| |___/ | +| _ | +| __ ____ ____ __ ___| |_ _ ___ ___ ___ _ __ ___ ___ _ __ ___ | +| \ \ /\ / /\ \ /\ / /\ \ /\ / / / __| | | | |/ _ \/ __/ _ \| '_ \ / __/ _ \| '_ ` _ \ | +| \ V V / \ V V / \ V V / _ | (__| | |_| | __/ (_| (_) | | | | _ | (_| (_) | | | | | | | +| \_/\_/ \_/\_/ \_/\_/ (_) \___|_|\__,_|\___|\___\___/|_| |_| (_) \___\___/|_| |_| |_| | +| | +.========================================================================================================. + + diff --git a/conf/curl/autoload_configs/timezones.conf.xml b/conf/curl/autoload_configs/timezones.conf.xml index 85c805ff25..397e9a979f 100644 --- a/conf/curl/autoload_configs/timezones.conf.xml +++ b/conf/curl/autoload_configs/timezones.conf.xml @@ -13,7 +13,7 @@ - + diff --git a/conf/insideout/autoload_configs/modules.conf.xml b/conf/insideout/autoload_configs/modules.conf.xml index 8793a003ba..7f17362509 100644 --- a/conf/insideout/autoload_configs/modules.conf.xml +++ b/conf/insideout/autoload_configs/modules.conf.xml @@ -60,9 +60,10 @@ - + + diff --git a/conf/insideout/autoload_configs/timezones.conf.xml b/conf/insideout/autoload_configs/timezones.conf.xml index 85c805ff25..397e9a979f 100644 --- a/conf/insideout/autoload_configs/timezones.conf.xml +++ b/conf/insideout/autoload_configs/timezones.conf.xml @@ -13,7 +13,7 @@ - + diff --git a/conf/insideout/sip_profiles/external.xml b/conf/insideout/sip_profiles/external.xml index 6f6045255d..22fd155434 100644 --- a/conf/insideout/sip_profiles/external.xml +++ b/conf/insideout/sip_profiles/external.xml @@ -1,4 +1,4 @@ - + @@ -29,10 +29,10 @@ - @@ -47,8 +47,10 @@ + + diff --git a/conf/insideout/sip_profiles/external/example.xml b/conf/insideout/sip_profiles/external/example.xml index 7ac8db1186..c6b79e8fe3 100644 --- a/conf/insideout/sip_profiles/external/example.xml +++ b/conf/insideout/sip_profiles/external/example.xml @@ -9,7 +9,7 @@ - + diff --git a/conf/insideout/sip_profiles/internal-ipv6.xml b/conf/insideout/sip_profiles/internal-ipv6.xml index 856ac4905d..525554f4b8 100644 --- a/conf/insideout/sip_profiles/internal-ipv6.xml +++ b/conf/insideout/sip_profiles/internal-ipv6.xml @@ -53,36 +53,39 @@ - + - + - - - - + + + + + + + - + - + - + @@ -128,4 +131,3 @@ - diff --git a/conf/insideout/sip_profiles/internal.xml b/conf/insideout/sip_profiles/internal.xml index a6010b2945..666f7de5ab 100644 --- a/conf/insideout/sip_profiles/internal.xml +++ b/conf/insideout/sip_profiles/internal.xml @@ -1,7 +1,7 @@ @@ -16,24 +16,24 @@ - + - + - + @@ -63,7 +63,7 @@ - + @@ -88,36 +88,39 @@ - + - + - - - - + + + + + + + - + - + - + @@ -138,7 +141,7 @@ - + @@ -158,24 +161,24 @@ - + - + @@ -186,4 +189,3 @@ - diff --git a/conf/insideout/sip_profiles/internal/example.xml b/conf/insideout/sip_profiles/internal/example.xml index 7ac8db1186..c6b79e8fe3 100644 --- a/conf/insideout/sip_profiles/internal/example.xml +++ b/conf/insideout/sip_profiles/internal/example.xml @@ -9,7 +9,7 @@ - + diff --git a/conf/sbc/autoload_configs/modules.conf.xml b/conf/sbc/autoload_configs/modules.conf.xml index 31b96dd27a..71d7a110f6 100644 --- a/conf/sbc/autoload_configs/modules.conf.xml +++ b/conf/sbc/autoload_configs/modules.conf.xml @@ -39,9 +39,10 @@ - + + diff --git a/conf/sbc/autoload_configs/timezones.conf.xml b/conf/sbc/autoload_configs/timezones.conf.xml index 85c805ff25..397e9a979f 100644 --- a/conf/sbc/autoload_configs/timezones.conf.xml +++ b/conf/sbc/autoload_configs/timezones.conf.xml @@ -13,7 +13,7 @@ - + diff --git a/conf/sbc/sbc_profiles/external.xml b/conf/sbc/sbc_profiles/external.xml index d16813960f..7bf024658b 100644 --- a/conf/sbc/sbc_profiles/external.xml +++ b/conf/sbc/sbc_profiles/external.xml @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ - + @@ -30,10 +30,10 @@ - @@ -48,8 +48,10 @@ + + diff --git a/conf/sbc/sbc_profiles/external/example.xml b/conf/sbc/sbc_profiles/external/example.xml index 7ac8db1186..c6b79e8fe3 100644 --- a/conf/sbc/sbc_profiles/external/example.xml +++ b/conf/sbc/sbc_profiles/external/example.xml @@ -9,7 +9,7 @@ - + diff --git a/conf/sbc/sbc_profiles/internal-ipv6.xml b/conf/sbc/sbc_profiles/internal-ipv6.xml index 856ac4905d..525554f4b8 100644 --- a/conf/sbc/sbc_profiles/internal-ipv6.xml +++ b/conf/sbc/sbc_profiles/internal-ipv6.xml @@ -53,36 +53,39 @@ - + - + - - - - + + + + + + + - + - + - + @@ -128,4 +131,3 @@ - diff --git a/conf/sbc/sbc_profiles/internal.xml b/conf/sbc/sbc_profiles/internal.xml index d06e3a76cd..d4b2efd37b 100644 --- a/conf/sbc/sbc_profiles/internal.xml +++ b/conf/sbc/sbc_profiles/internal.xml @@ -1,7 +1,7 @@ @@ -15,24 +15,24 @@ - + - + - + @@ -69,7 +69,7 @@ - + @@ -94,36 +94,39 @@ - + - + - - - - + + + + + + + - + - + - + @@ -154,24 +157,24 @@ - + - + @@ -182,4 +185,3 @@ - diff --git a/conf/sbc/sbc_profiles/internal/example.xml b/conf/sbc/sbc_profiles/internal/example.xml index 7ac8db1186..c6b79e8fe3 100644 --- a/conf/sbc/sbc_profiles/internal/example.xml +++ b/conf/sbc/sbc_profiles/internal/example.xml @@ -9,7 +9,7 @@ - + diff --git a/conf/softphone/freeswitch.xml b/conf/softphone/freeswitch.xml index 00a2bc31cb..66e7c2a923 100644 --- a/conf/softphone/freeswitch.xml +++ b/conf/softphone/freeswitch.xml @@ -3,7 +3,7 @@ - + @@ -86,10 +86,8 @@ - - diff --git a/conf/vanilla/autoload_configs/dingaling.conf.xml b/conf/vanilla/autoload_configs/dingaling.conf.xml index e68c8b4b44..dd6c9a5da1 100644 --- a/conf/vanilla/autoload_configs/dingaling.conf.xml +++ b/conf/vanilla/autoload_configs/dingaling.conf.xml @@ -1,7 +1,7 @@ - + diff --git a/conf/vanilla/autoload_configs/enum.conf.xml b/conf/vanilla/autoload_configs/enum.conf.xml index 0304d0dacd..b9813efa27 100644 --- a/conf/vanilla/autoload_configs/enum.conf.xml +++ b/conf/vanilla/autoload_configs/enum.conf.xml @@ -2,12 +2,20 @@ - + + + + + + + + - + + diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml index 50353ac849..a12b9684ba 100644 --- a/conf/vanilla/autoload_configs/modules.conf.xml +++ b/conf/vanilla/autoload_configs/modules.conf.xml @@ -16,6 +16,7 @@ + @@ -62,6 +63,7 @@ + @@ -80,10 +82,11 @@ - + - + + diff --git a/conf/vanilla/autoload_configs/opal.conf.xml b/conf/vanilla/autoload_configs/opal.conf.xml index 1133227499..2378d1d6e0 100644 --- a/conf/vanilla/autoload_configs/opal.conf.xml +++ b/conf/vanilla/autoload_configs/opal.conf.xml @@ -1,12 +1,14 @@ - + - - - - + + + + + + diff --git a/conf/vanilla/autoload_configs/spandsp.conf.xml b/conf/vanilla/autoload_configs/spandsp.conf.xml index 6f062cc731..f70416bc66 100644 --- a/conf/vanilla/autoload_configs/spandsp.conf.xml +++ b/conf/vanilla/autoload_configs/spandsp.conf.xml @@ -42,20 +42,25 @@ - + + + + - - + + + - - + + + diff --git a/conf/vanilla/autoload_configs/timezones.conf.xml b/conf/vanilla/autoload_configs/timezones.conf.xml index 85c805ff25..397e9a979f 100644 --- a/conf/vanilla/autoload_configs/timezones.conf.xml +++ b/conf/vanilla/autoload_configs/timezones.conf.xml @@ -13,7 +13,7 @@ - + diff --git a/conf/vanilla/autoload_configs/xml_scgi.conf.xml b/conf/vanilla/autoload_configs/xml_scgi.conf.xml new file mode 100644 index 0000000000..b9662d1638 --- /dev/null +++ b/conf/vanilla/autoload_configs/xml_scgi.conf.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/conf/vanilla/dialplan/default.xml b/conf/vanilla/dialplan/default.xml index fb6713d0ce..82189d6633 100644 --- a/conf/vanilla/dialplan/default.xml +++ b/conf/vanilla/dialplan/default.xml @@ -720,6 +720,15 @@ + + + + + + + + + diff --git a/conf/vanilla/freeswitch.xml b/conf/vanilla/freeswitch.xml index 7a1b1d3d15..b067d986c4 100644 --- a/conf/vanilla/freeswitch.xml +++ b/conf/vanilla/freeswitch.xml @@ -63,5 +63,9 @@ + + + + diff --git a/conf/vanilla/ivr_menus/new_demo_ivr.xml b/conf/vanilla/ivr_menus/new_demo_ivr.xml new file mode 100644 index 0000000000..f2ca7dc68e --- /dev/null +++ b/conf/vanilla/ivr_menus/new_demo_ivr.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/jingle_profiles/client.xml b/conf/vanilla/jingle_profiles/client.xml index cac70692e8..20a8dd809d 100644 --- a/conf/vanilla/jingle_profiles/client.xml +++ b/conf/vanilla/jingle_profiles/client.xml @@ -28,5 +28,9 @@ + + + + diff --git a/conf/vanilla/lang/en/demo/funnies.xml b/conf/vanilla/lang/en/demo/funnies.xml new file mode 100644 index 0000000000..e901c5ad9c --- /dev/null +++ b/conf/vanilla/lang/en/demo/funnies.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/conf/vanilla/lang/en/demo/new-demo-ivr.xml b/conf/vanilla/lang/en/demo/new-demo-ivr.xml new file mode 100644 index 0000000000..619d9921e9 --- /dev/null +++ b/conf/vanilla/lang/en/demo/new-demo-ivr.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/en/vm/sounds.xml b/conf/vanilla/lang/en/vm/sounds.xml index ff8844ae97..fdef472a5b 100644 --- a/conf/vanilla/lang/en/vm/sounds.xml +++ b/conf/vanilla/lang/en/vm/sounds.xml @@ -29,7 +29,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/conf/vanilla/lang/es/demo/demo-es-ES.xml b/conf/vanilla/lang/es/demo/demo-es-ES.xml new file mode 100644 index 0000000000..4c6919dd0e --- /dev/null +++ b/conf/vanilla/lang/es/demo/demo-es-ES.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/demo/demo-es-MX.xml b/conf/vanilla/lang/es/demo/demo-es-MX.xml new file mode 100644 index 0000000000..4c6919dd0e --- /dev/null +++ b/conf/vanilla/lang/es/demo/demo-es-MX.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/demo/demo-ivr-es-ES.xml b/conf/vanilla/lang/es/demo/demo-ivr-es-ES.xml new file mode 100644 index 0000000000..ec7d7bccd2 --- /dev/null +++ b/conf/vanilla/lang/es/demo/demo-ivr-es-ES.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/demo/demo-ivr-es-MX.xml b/conf/vanilla/lang/es/demo/demo-ivr-es-MX.xml new file mode 100644 index 0000000000..ec7d7bccd2 --- /dev/null +++ b/conf/vanilla/lang/es/demo/demo-ivr-es-MX.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/dir/sounds-es-ES.xml b/conf/vanilla/lang/es/dir/sounds-es-ES.xml new file mode 100644 index 0000000000..2bdc1492ec --- /dev/null +++ b/conf/vanilla/lang/es/dir/sounds-es-ES.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/dir/sounds-es-MX.xml b/conf/vanilla/lang/es/dir/sounds-es-MX.xml new file mode 100644 index 0000000000..2bdc1492ec --- /dev/null +++ b/conf/vanilla/lang/es/dir/sounds-es-MX.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/dir/tts-es-ES.xml b/conf/vanilla/lang/es/dir/tts-es-ES.xml new file mode 100644 index 0000000000..fbdeca703c --- /dev/null +++ b/conf/vanilla/lang/es/dir/tts-es-ES.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/dir/tts-es-MX.xml b/conf/vanilla/lang/es/dir/tts-es-MX.xml new file mode 100644 index 0000000000..ddf15d0a50 --- /dev/null +++ b/conf/vanilla/lang/es/dir/tts-es-MX.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/es_ES.xml b/conf/vanilla/lang/es/es_ES.xml new file mode 100644 index 0000000000..f8de6858ea --- /dev/null +++ b/conf/vanilla/lang/es/es_ES.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/conf/vanilla/lang/es/es_MX.xml b/conf/vanilla/lang/es/es_MX.xml new file mode 100644 index 0000000000..936abcf16f --- /dev/null +++ b/conf/vanilla/lang/es/es_MX.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/conf/vanilla/lang/es/vm/sounds-es-ES.xml b/conf/vanilla/lang/es/vm/sounds-es-ES.xml new file mode 100644 index 0000000000..dcc9d9f76f --- /dev/null +++ b/conf/vanilla/lang/es/vm/sounds-es-ES.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/vm/sounds-es-MX.xml b/conf/vanilla/lang/es/vm/sounds-es-MX.xml new file mode 100644 index 0000000000..1f22c43bdc --- /dev/null +++ b/conf/vanilla/lang/es/vm/sounds-es-MX.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/vm/tts-es-ES.xml b/conf/vanilla/lang/es/vm/tts-es-ES.xml new file mode 100644 index 0000000000..6dab48ca60 --- /dev/null +++ b/conf/vanilla/lang/es/vm/tts-es-ES.xml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/es/vm/tts-es-MX.xml b/conf/vanilla/lang/es/vm/tts-es-MX.xml new file mode 100644 index 0000000000..ce5722e934 --- /dev/null +++ b/conf/vanilla/lang/es/vm/tts-es-MX.xml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/demo/demo-ivr-pt-BR.xml b/conf/vanilla/lang/pt/demo/demo-ivr-pt-BR.xml new file mode 100644 index 0000000000..ec7d7bccd2 --- /dev/null +++ b/conf/vanilla/lang/pt/demo/demo-ivr-pt-BR.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/demo/demo-ivr-pt-PT.xml b/conf/vanilla/lang/pt/demo/demo-ivr-pt-PT.xml new file mode 100644 index 0000000000..ec7d7bccd2 --- /dev/null +++ b/conf/vanilla/lang/pt/demo/demo-ivr-pt-PT.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/demo/demo-pt-BR.xml b/conf/vanilla/lang/pt/demo/demo-pt-BR.xml new file mode 100644 index 0000000000..846561a541 --- /dev/null +++ b/conf/vanilla/lang/pt/demo/demo-pt-BR.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/demo/demo-pt-PT.xml b/conf/vanilla/lang/pt/demo/demo-pt-PT.xml new file mode 100644 index 0000000000..34464f7a6d --- /dev/null +++ b/conf/vanilla/lang/pt/demo/demo-pt-PT.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/dir/sounds-pt-BR.xml b/conf/vanilla/lang/pt/dir/sounds-pt-BR.xml new file mode 100644 index 0000000000..2bdc1492ec --- /dev/null +++ b/conf/vanilla/lang/pt/dir/sounds-pt-BR.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/dir/sounds-pt-PT.xml b/conf/vanilla/lang/pt/dir/sounds-pt-PT.xml new file mode 100644 index 0000000000..2bdc1492ec --- /dev/null +++ b/conf/vanilla/lang/pt/dir/sounds-pt-PT.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/dir/tts-pt-BR.xml b/conf/vanilla/lang/pt/dir/tts-pt-BR.xml new file mode 100644 index 0000000000..71b79c60a8 --- /dev/null +++ b/conf/vanilla/lang/pt/dir/tts-pt-BR.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/dir/tts-pt-PT.xml b/conf/vanilla/lang/pt/dir/tts-pt-PT.xml new file mode 100644 index 0000000000..4f03c5abdb --- /dev/null +++ b/conf/vanilla/lang/pt/dir/tts-pt-PT.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/pt_BR.xml b/conf/vanilla/lang/pt/pt_BR.xml new file mode 100644 index 0000000000..690ee6974c --- /dev/null +++ b/conf/vanilla/lang/pt/pt_BR.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/conf/vanilla/lang/pt/pt_PT.xml b/conf/vanilla/lang/pt/pt_PT.xml new file mode 100644 index 0000000000..c30b3612f1 --- /dev/null +++ b/conf/vanilla/lang/pt/pt_PT.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/conf/vanilla/lang/pt/vm/sounds-pt-BR.xml b/conf/vanilla/lang/pt/vm/sounds-pt-BR.xml new file mode 100644 index 0000000000..1ab472a71e --- /dev/null +++ b/conf/vanilla/lang/pt/vm/sounds-pt-BR.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/vm/sounds-pt-PT.xml b/conf/vanilla/lang/pt/vm/sounds-pt-PT.xml new file mode 100644 index 0000000000..587d3fe5bd --- /dev/null +++ b/conf/vanilla/lang/pt/vm/sounds-pt-PT.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/vm/tts-pt-BR.xml b/conf/vanilla/lang/pt/vm/tts-pt-BR.xml new file mode 100644 index 0000000000..4f770457e5 --- /dev/null +++ b/conf/vanilla/lang/pt/vm/tts-pt-BR.xml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/lang/pt/vm/tts-pt-PT.xml b/conf/vanilla/lang/pt/vm/tts-pt-PT.xml new file mode 100644 index 0000000000..c3dfc3a066 --- /dev/null +++ b/conf/vanilla/lang/pt/vm/tts-pt-PT.xml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/vanilla/sip_profiles/external.xml b/conf/vanilla/sip_profiles/external.xml index a709cbb94c..5070c87913 100644 --- a/conf/vanilla/sip_profiles/external.xml +++ b/conf/vanilla/sip_profiles/external.xml @@ -1,14 +1,14 @@ - + - @@ -18,10 +18,10 @@ - - + + - + @@ -34,15 +34,15 @@ - + - @@ -56,8 +56,10 @@ + + @@ -90,6 +92,5 @@ - diff --git a/conf/vanilla/sip_profiles/external/example.xml b/conf/vanilla/sip_profiles/external/example.xml index 70668a9ce5..2a4df31aaf 100644 --- a/conf/vanilla/sip_profiles/external/example.xml +++ b/conf/vanilla/sip_profiles/external/example.xml @@ -9,7 +9,7 @@ - + diff --git a/conf/vanilla/sip_profiles/internal-ipv6.xml b/conf/vanilla/sip_profiles/internal-ipv6.xml index ee27a241a0..62b9708e8b 100644 --- a/conf/vanilla/sip_profiles/internal-ipv6.xml +++ b/conf/vanilla/sip_profiles/internal-ipv6.xml @@ -54,36 +54,39 @@ - + - + - - - - + + + + + + + - + - + - + @@ -103,8 +106,8 @@ @@ -121,10 +124,9 @@ - - - + + + - diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index b9605a192c..7d37da863e 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -2,30 +2,30 @@ - + - + - + - + @@ -33,31 +33,31 @@ - - + + - + - @@ -106,26 +106,26 @@ - - - + + + @@ -134,10 +134,10 @@ - + - + @@ -164,7 +164,7 @@ - + @@ -203,39 +203,42 @@ - + - + - + - - - - + + + + + + + - + - + - + @@ -252,16 +255,16 @@ - + + Used as the public IP address for SDP. + Can be an one of: + ip address - "12.34.56.78" + a stun server lookup - "stun:stun.server.com" + a DNS name - "host:host.server.com" + auto - Use guessed ip. + auto-nat - Use ip learned from NAT-PMP or UPNP + --> @@ -274,8 +277,8 @@ @@ -297,28 +300,27 @@ - - + @@ -332,59 +334,58 @@ - - - - + + + - - - - - - - - - - - - - - + - - + + + + + - - - + + + + + + + + + + + + + - diff --git a/conf/vanilla/sip_profiles/internal/example.xml b/conf/vanilla/sip_profiles/internal/example.xml index fc061f96d1..10263b05a5 100644 --- a/conf/vanilla/sip_profiles/internal/example.xml +++ b/conf/vanilla/sip_profiles/internal/example.xml @@ -9,7 +9,7 @@ - + diff --git a/conf/vanilla/vars.xml b/conf/vanilla/vars.xml index 4f13a61fbb..907c6f1015 100644 --- a/conf/vanilla/vars.xml +++ b/conf/vanilla/vars.xml @@ -123,7 +123,7 @@ 127 - BV32 --> - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -554,6 +619,9 @@ + + + diff --git a/docs/phrase/phrase_es.xml b/docs/phrase/phrase_es.xml index 69b1e57994..518d7fce64 100644 --- a/docs/phrase/phrase_es.xml +++ b/docs/phrase/phrase_es.xml @@ -21,10 +21,10 @@ - + - + diff --git a/docs/phrase/phrase_es_ES.xml b/docs/phrase/phrase_es_ES.xml index ad99c1bf73..791088697b 100644 --- a/docs/phrase/phrase_es_ES.xml +++ b/docs/phrase/phrase_es_ES.xml @@ -19,7 +19,7 @@ - + diff --git a/docs/phrase/phrase_es_MX.xml b/docs/phrase/phrase_es_MX.xml index 527f8c3c89..188b5c68b1 100644 --- a/docs/phrase/phrase_es_MX.xml +++ b/docs/phrase/phrase_es_MX.xml @@ -19,7 +19,7 @@ - + diff --git a/freeswitch-sounds-en-us-callie.spec b/freeswitch-sounds-en-us-callie.spec index 468911c53d..68c79e42b6 100644 --- a/freeswitch-sounds-en-us-callie.spec +++ b/freeswitch-sounds-en-us-callie.spec @@ -77,6 +77,7 @@ BuildArch: noarch BuildRequires: sox Requires: freeswitch Requires: freeswitch-sounds-en-us-callie-48000 +Requires: sox BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description diff --git a/freeswitch-sounds-music.spec b/freeswitch-sounds-music.spec index e43ada5736..520a7dddfe 100644 --- a/freeswitch-sounds-music.spec +++ b/freeswitch-sounds-music.spec @@ -1,3 +1,4 @@ +%define fsname freeswitch %define PREFIX %{_prefix} %define EXECPREFIX %{_exec_prefix} %define BINDIR %{_bindir} diff --git a/freeswitch.spec b/freeswitch.spec index 6fd9ad706e..f4e3399715 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -1,5 +1,4 @@ ###################################################################################################################### -###################################################################################################################### # # spec file for package freeswitch # @@ -11,20 +10,20 @@ # # This file is part of: # FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -# Copyright (C) 2005-2010, Anthony Minessale II +# Copyright (C) 2005-2012, Anthony Minessale II # # This file and all modifications and additions to the pristine package are under the same license as the package itself. # # Contributor(s): Mike Jerris -# Brian West -# Raul Fragoso -# Rupa Shomaker -# Marc Olivier Chouinard -# Raymond Chandler -# Anthony Minessale II +# Brian West +# Anthony Minessale II +# Raul Fragoso +# Rupa Shomaker +# Marc Olivier Chouinard +# Raymond Chandler +# Ken Rice # -# -# Maintainer(s): Michal Bielicki # ###################################################################################################################### # Module build settings @@ -1434,7 +1433,7 @@ export ACLOCAL_FLAGS="-I /usr/share/aclocal" if test ! -f Makefile.in then - ./bootstrap.sh -j + ./bootstrap.sh fi %configure -C \ @@ -1594,6 +1593,7 @@ fi #################################### Basic Directory Structure ####################################################### # %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} @@ -1757,6 +1757,7 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/xml_cdr.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/xml_curl.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/xml_rpc.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/xml_scgi.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/zeroconf.conf.xml ###################################################################################################################### # Chatplans diff --git a/fscomm/call.cpp b/fscomm/call.cpp index 3b91d7ee90..d60084d483 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/call.h b/fscomm/call.h index d2626f35af..72ea93f6de 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/debugtools/sortfilterproxymodel.h b/fscomm/debugtools/sortfilterproxymodel.h index c0b1c53890..d157856bfc 100644 --- a/fscomm/debugtools/sortfilterproxymodel.h +++ b/fscomm/debugtools/sortfilterproxymodel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 2bb5b36cd6..a113b33958 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/fshost.h b/fscomm/fshost.h index ce4371191d..59cf2024e9 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/main.cpp b/fscomm/main.cpp index c1069eded1..18a97e2757 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index 30450e1215..8f1323b374 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/fscomm/mainwindow.h b/fscomm/mainwindow.h index 84f4103b3e..33f36b87ba 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/.gitignore b/libs/.gitignore index e39b1f4bf1..5b0f00bde8 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -13,11 +13,16 @@ libtool ltmain.sh missing +ptlib +opal + *_manifest.rc *.pc /*.tar.* +/*/*.dSYM/ + /apr/apr-1-config /apr/apr.exp /apr/build/apr_rules.mk @@ -225,6 +230,7 @@ missing /ldns/doc/ldns_manpages /ldns/include/ /ldns/ldns/config.h +/ldns/ldns/ldns /ldns/ldns/net.h /ldns/ldns/util.h /ldns/lib @@ -522,6 +528,11 @@ missing /spandsp/doc/Makefile.in /spandsp/Makefile /spandsp/Makefile.in +/spandsp/m4/libtool.m4 +/spandsp/m4/ltoptions.m4 +/spandsp/m4/ltsugar.m4 +/spandsp/m4/ltversion.m4 +/spandsp/m4/lt~obsolete.m4 /spandsp/spandsp-sim/Makefile /spandsp/spandsp-sim/Makefile.in /spandsp/src/at_interpreter_dictionary.h @@ -572,6 +583,7 @@ missing /spandsp/test-data/Makefile.in /spandsp/tests/Makefile /spandsp/tests/Makefile.in +/spandsp/src/make_cielab_luts /speex/config.h /speex/include/Makefile /speex/include/Makefile.in @@ -874,6 +886,7 @@ missing /yaml/tests/run-parser /yaml/tests/run-scanner /zeromq-*/ +/jpeg-8d/ # build products we should remove !/apr-util/xml/expat/conftools/config.guess diff --git a/libs/apr/include/apr_pools.h b/libs/apr/include/apr_pools.h index 74ed59e35b..886323fa66 100644 --- a/libs/apr/include/apr_pools.h +++ b/libs/apr/include/apr_pools.h @@ -409,7 +409,7 @@ APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b); * @param pool The pool to tag * @param tag The tag */ -APR_DECLARE(char *) apr_pool_tag(apr_pool_t *pool, const char *tag); +APR_DECLARE(const char *) apr_pool_tag(apr_pool_t *pool, const char *tag); #if APR_HAS_THREADS /** diff --git a/libs/apr/memory/unix/apr_pools.c b/libs/apr/memory/unix/apr_pools.c index 99e1888b1f..7ddc5e2af8 100644 --- a/libs/apr/memory/unix/apr_pools.c +++ b/libs/apr/memory/unix/apr_pools.c @@ -1895,7 +1895,7 @@ APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b) return 0; } -APR_DECLARE(char *) apr_pool_tag(apr_pool_t *pool, const char *tag) +APR_DECLARE(const char *) apr_pool_tag(apr_pool_t *pool, const char *tag) { if (tag) { pool->tag = tag; diff --git a/libs/apr/random/unix/sha2.c b/libs/apr/random/unix/sha2.c index 7f55dac959..169afd5a78 100644 --- a/libs/apr/random/unix/sha2.c +++ b/libs/apr/random/unix/sha2.c @@ -557,7 +557,7 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { } /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); usedspace = 0; } @@ -578,7 +578,7 @@ char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH); return buffer; @@ -889,7 +889,7 @@ void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { } /* Zero out state data */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) { @@ -909,7 +909,7 @@ char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH); return buffer; @@ -964,7 +964,7 @@ void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { } /* Zero out state data */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) { @@ -984,7 +984,7 @@ char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH); return buffer; diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 408c946d29..95629da76e 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -903,28 +903,46 @@ static const char *basic_gets(int *cnt) } static const char *banner = - " _____ ____ ____ _ ___ \n" - " | ___/ ___| / ___| | |_ _| \n" - " | |_ \\___ \\ | | | | | | \n" - " | _| ___) | | |___| |___ | | \n" - " |_| |____/ \\____|_____|___| \n" - "\n" - "*******************************************************\n" - "* Anthony Minessale II, Ken Rice, *\n" - "* Michael Jerris, Travis Cross *\n" - "* FreeSWITCH (http://www.freeswitch.org) *\n" - "* Paypal Donations Appreciated: paypal@freeswitch.org *\n" - "* Brought to you by ClueCon http://www.cluecon.com/ *\n" - "*******************************************************\n" - "\n" - "Type /help to see a list of commands\n\n\n"; + ".=======================================================.\n" + "| _____ ____ ____ _ ___ |\n" + "| | ___/ ___| / ___| | |_ _| |\n" + "| | |_ \\___ \\ | | | | | | |\n" + "| | _| ___) | | |___| |___ | | |\n" + "| |_| |____/ \\____|_____|___| |\n" + "| |\n" + ".=======================================================.\n" + "| Anthony Minessale II, Ken Rice, |\n" + "| Michael Jerris, Travis Cross |\n" + "| FreeSWITCH (http://www.freeswitch.org) |\n" + "| Paypal Donations Appreciated: paypal@freeswitch.org |\n" + "| Brought to you by ClueCon http://www.cluecon.com/ |\n" + ".=======================================================.\n" + "\n"; + +static const char *inf = "Type /help to see a list of commands\n\n\n"; static void print_banner(FILE *stream) { -#ifndef WIN32 - fprintf(stream, "%s%s", output_text_color, banner); +#include + +#ifdef WIN32 + /* Print banner in yellow with blue background */ + SetConsoleTextAttribute(hStdout, ESL_SEQ_FYELLOW | BACKGROUND_BLUE); + WriteFile(hStdout, banner, (DWORD) strlen(banner), NULL, NULL); + WriteFile(hStdout, cc, (DWORD) strlen(cc), NULL, NULL); + SetConsoleTextAttribute(hStdout, wOldColorAttrs); + + /* Print the rest info in default colors */ + fprintf(stream, "\n%s\n", inf); #else - fprintf(stream, "%s", banner); + fprintf(stream, + "%s%s%s%s%s%s\n%s\n", + ESL_SEQ_DEFAULT_COLOR, + ESL_SEQ_FYELLOW, ESL_SEQ_BBLUE, + banner, + cc, ESL_SEQ_DEFAULT_COLOR, inf); + + fprintf(stream, "%s", output_text_color); #endif } diff --git a/libs/esl/ivrd.c b/libs/esl/ivrd.c index c71e392117..6098abcaf9 100644 --- a/libs/esl/ivrd.c +++ b/libs/esl/ivrd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,12 +35,68 @@ #include #include #include +#include + +static void handle_SIGCHLD(int sig) +{ + int status = 0; + + wait(&status); + return; +} + +static void my_forking_callback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) +{ + esl_handle_t handle = {{0}}; + char path_buffer[1024] = { 0 }; + const char *path; + char arg[64] = { 0 }; + + signal(SIGCHLD, handle_SIGCHLD); + + if (fork()) { + close(client_sock); + return; + } + + if (esl_attach_handle(&handle, client_sock, addr) != ESL_SUCCESS || !handle.info_event) { + esl_log(ESL_LOG_ERROR, "Socket Error\n"); + exit(0); + } + + if (!(path = esl_event_get_header(handle.info_event, "variable_ivr_path"))) { + esl_disconnect(&handle); + esl_log(ESL_LOG_ERROR, "Missing ivr_path param!\n"); + exit(0); + } + + snprintf(arg, sizeof(arg), "%d", client_sock); + + strncpy(path_buffer, path, sizeof(path_buffer) - 1); + + /* hotwire the socket to STDIN/STDOUT */ + /* hotwire the socket to STDIN/STDOUT */ + if (!(dup2(client_sock, STDIN_FILENO)) && !(dup2(client_sock, STDOUT_FILENO))){ + esl_disconnect(&handle); + esl_log(ESL_LOG_ERROR, "Socket Error hotwiring socket to STDIN/STDOUT!\n"); + return; + } + + /* close the handle but leak the socket on purpose cos the child will need it open */ + handle.sock = -1; + esl_disconnect(&handle); + + execl(path_buffer, path_buffer, arg, (char *)NULL); + close(client_sock); + exit(0); +} static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) { esl_handle_t handle = {{0}}; const char *path; - + char path_buffer[1024] = { 0 }; + if (esl_attach_handle(&handle, client_sock, addr) != ESL_SUCCESS || !handle.info_event) { close(client_sock); esl_log(ESL_LOG_ERROR, "Socket Error\n"); @@ -53,16 +109,13 @@ static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struc return; } - /* hotwire the socket to STDIN/STDOUT */ - if (!(dup2(client_sock, STDIN_FILENO)) && !(dup2(client_sock, STDOUT_FILENO))){ - esl_disconnect(&handle); - esl_log(ESL_LOG_ERROR, "Socket Error hotwiring socket to STDIN/STDOUT!\n"); - return; - } + snprintf(path_buffer, sizeof(path_buffer), "%s %d", path, client_sock); - if(system(path)) { + + if (system(path_buffer)) { esl_log(ESL_LOG_ERROR, "System Call Failed! [%s]\n", strerror(errno)); } + esl_disconnect(&handle); } @@ -71,24 +124,43 @@ int main(int argc, char *argv[]) { int i; char *ip = NULL; - int port = 0; + int port = 0, thread = 0; - for (i = 1; i + 1 < argc; ) { - if (!strcasecmp(argv[i], "-h")) { - ip = argv[++i]; - } else if (!strcasecmp(argv[i], "-p")) { - port = atoi(argv[++i]); - } else { - i++; + for (i = 1; i < argc; ) { + int cont = 0; + + if (i + 1 < argc) { + if (!strcasecmp(argv[i], "-h")) { + ip = argv[++i]; cont++; + } else if (!strcasecmp(argv[i], "-p")) { + port = atoi(argv[++i]); cont++; + } } + + if (cont) { + i++; + continue; + } + + if (!strcasecmp(argv[i], "-t")) { + thread++; + } + + i++; } if (!(ip && port)) { - fprintf(stderr, "Usage %s -h -p \n", argv[0]); + fprintf(stderr, "Usage %s [-t] -h -p \n", argv[0]); return -1; } - esl_listen(ip, port, mycallback, 100000); + if (thread) { + printf("Starting threaded listener.\n"); + esl_listen_threaded(ip, port, mycallback, 100000); + } else { + printf("Starting forking listener.\n"); + esl_listen(ip, port, my_forking_callback); + } return 0; } diff --git a/libs/esl/perl/dump_events.pl b/libs/esl/perl/dump_events.pl new file mode 100755 index 0000000000..7ed018e7fa --- /dev/null +++ b/libs/esl/perl/dump_events.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl +require ESL; + +my $command = shift; +my $args = join(" ", @ARGV); + +my $con = new ESL::ESLconnection("localhost", "8021", "ClueCon"); +$con->events("plain","all"); +while ( $con->connected() ) { + my $e = $con->recvEventTimed(0); + print $e->serialize; +} diff --git a/libs/esl/php/Makefile b/libs/esl/php/Makefile index e970ff7d82..dce8fd4bd1 100644 --- a/libs/esl/php/Makefile +++ b/libs/esl/php/Makefile @@ -1,8 +1,16 @@ +PHP=php +PHP_CONFIG=php-config + +PHP_LDFLAGS=$(shell $(PHP_CONFIG) --ldflags) +PHP_LIBS=$(shell $(PHP_CONFIG) --libs | sed -r 's/ ?-l(bz2|pcre|xml2|gssapi_krb5|krb5|k5crypto|com_err|history|z|readline|gmp|ssl|crypto)//g') +PHP_EXT_DIR=$(shell $(PHP_CONFIG) --extension-dir) +PHP_INC_DIR=$(shell $(PHP) -r 'echo ini_get("include_path");' | cut -d: -f2) +PHP_INI_DIR=$(shell $(PHP_CONFIG) --configure-options | tr " " "\n" | grep -- --with-config-file-scan-dir | cut -f2 -d=) + LOCAL_CFLAGS=$(shell php-config --includes) -PHP_LDFLAGS=$(shell php-config --ldflags) -PHP_LIBS=$(shell php-config --libs | sed -r 's/ ?-l(bz2|pcre|xml2|gssapi_krb5|krb5|k5crypto|com_err|history|z|readline|gmp|ssl|crypto)//g') LOCAL_LDFLAGS=$(PHP_LDFLAGS) $(PHP_LIBS) LOCAL_LDFLAGS+=-lpthread + WRAP_GCC_WARNING_SILENCE=-Wno-unused-label -Wno-unused-function all: ESL.so @@ -25,6 +33,9 @@ swigclean: reswig: swigclean esl_wrap.cpp install: ESL.so - cp ESL.so $(DESTDIR)/$(shell php-config --extension-dir) - cp ESL.php /$(DESTDIR)/$(shell php -r 'echo ini_get("include_path");' | cut -d: -f2) - echo 'extension=ESL.so' >> $(DESTDIR)/$(shell php-config --configure-options | tr " " "\n" | grep -- --with-config-file-scan-dir | cut -f2 -d=)/esl.ini + test -d "$(DESTDIR)$(PHP_EXT_DIR)" || mkdir -p "$(DESTDIR)$(PHP_EXT_DIR)" + cp ESL.so "$(DESTDIR)$(PHP_EXT_DIR)" + test -d "$(DESTDIR)$(PHP_INC_DIR)" || mkdir -p "$(DESTDIR)$(PHP_INC_DIR)" + cp ESL.php "$(DESTDIR)$(PHP_INC_DIR)" + test -d "$(DESTDIR)$(PHP_INI_DIR)" || mkdir -p "$(DESTDIR)$(PHP_INI_DIR)" + test -f "$(DESTDIR)$(PHP_INI_DIR)/esl.ini" || echo 'extension=ESL.so' > "$(DESTDIR)$(PHP_INI_DIR)/esl.ini" diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index f6caeca0b3..b092991988 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -568,11 +568,10 @@ ESL_DECLARE(esl_status_t) esl_sendmsg(esl_handle_t *handle, esl_event_t *event, assert(cmd_buf); memset(cmd_buf, 0, len); - if (uuid) { - snprintf(cmd_buf, sizeof(cmd_buf), "sendmsg %s\n%s", uuid, txt); + snprintf(cmd_buf, len, "sendmsg %s\n%s", uuid, txt); } else { - snprintf(cmd_buf, sizeof(cmd_buf), "sendmsg\n%s", txt); + snprintf(cmd_buf, len, "sendmsg\n%s", txt); } esl_log(ESL_LOG_DEBUG, "%s%s\n", cmd_buf, txt); @@ -649,7 +648,64 @@ static void *client_thread(esl_thread_t *me, void *obj) } -ESL_DECLARE(esl_status_t) esl_listen(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) +{ + 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; + } + + esl_socket_reuseaddr(server_sock); + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = htonl(INADDR_ANY); + addr.sin_port = htons(port); + + if (bind(server_sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + status = ESL_FAIL; + goto end; + } + + if (listen(server_sock, 10000) < 0) { + status = ESL_FAIL; + goto end; + } + + for (;;) { + int client_sock; + struct sockaddr_in echoClntAddr; +#ifdef WIN32 + int clntLen; +#else + unsigned int clntLen; +#endif + + clntLen = sizeof(echoClntAddr); + + if ((client_sock = accept(server_sock, (struct sockaddr *) &echoClntAddr, &clntLen)) == ESL_SOCK_INVALID) { + status = ESL_FAIL; + goto end; + } + + callback(server_sock, client_sock, &echoClntAddr); + } + + end: + + if (server_sock != ESL_SOCK_INVALID) { + closesocket(server_sock); + server_sock = ESL_SOCK_INVALID; + } + + return status; + +} + +ESL_DECLARE(esl_status_t) esl_listen_threaded(const char *host, esl_port_t port, esl_listen_callback_t callback, int max) { esl_socket_t server_sock = ESL_SOCK_INVALID; struct sockaddr_in addr; diff --git a/libs/esl/src/esl_buffer.c b/libs/esl/src/esl_buffer.c index 173c9cb76c..97f6b5813b 100644 --- a/libs/esl/src/esl_buffer.c +++ b/libs/esl/src/esl_buffer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Anthony Minessale II + * Copyright (c) 2010-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/libs/esl/src/esl_config.c b/libs/esl/src/esl_config.c index 2e24007799..8954c874a1 100644 --- a/libs/esl/src/esl_config.c +++ b/libs/esl/src/esl_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 1271e46e4f..60547b1be2 100644 --- a/libs/esl/src/esl_event.c +++ b/libs/esl/src/esl_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -127,6 +127,7 @@ static const char *EVENT_NAMES[] = { "SERVER_DISCONNECTED", "SEND_INFO", "RECV_INFO", + "RECV_RTCP_MESSAGE", "CALL_SECURE", "NAT", "RECORD_START", @@ -137,7 +138,11 @@ static const char *EVENT_NAMES[] = { "FAILURE", "SOCKET_DATA", "MEDIA_BUG_START", - "MEDIA_BUG_START", + "MEDIA_BUG_STOP", + "CONFERENCE_DATA_QUERY", + "CONFERENCE_DATA", + "CALL_SETUP_REQ", + "CALL_SETUP_RESULT", "ALL" }; diff --git a/libs/esl/src/include/cc.h b/libs/esl/src/include/cc.h new file mode 100644 index 0000000000..44666193c6 --- /dev/null +++ b/libs/esl/src/include/cc.h @@ -0,0 +1,2 @@ +const char *cc = ".========================================================================================================.\n| ____ _____ ____ _ ____ _ _ _____ |\n| / ___|___ _ __ ___ ___ |_ _|__ / ___| |_ _ ___ / ___|___ _ __ ( ) |___ / |\n| | | / _ \\| '_ ` _ \\ / _ \\ | |/ _ \\ | | | | | | |/ _ \\ | / _ \\| '_ \\ |/| | |_ \\ |\n| | |__| (_) | | | | | | __/ | | (_) | | |___| | |_| | __/ |__| (_) | | | | | |___) | |\n| \\____\\___/|_| |_| |_|\\___| |_|\\___/ \\____|_|\\__,_|\\___|\\____\\___/|_| |_| |_|____/ |\n| |\n| ____ _ _ _ _ ____ _ |\n| / ___| |__ (_) ___ __ _ __ _ ___ | | | / ___| / \\ |\n| | | | '_ \\| |/ __/ _` |/ _` |/ _ \\ | | | \\___ \\ / _ \\ |\n| | |___| | | | | (_| (_| | (_| | (_) | | |_| |___) / ___ \\ |\n| \\____|_| |_|_|\\___\\__,_|\\__, |\\___( ) \\___/|____/_/ \\_\\ |\n| |___/ |/ |\n| _ _ __ _ _ ___ _ _ ____ ___ _ _____ |\n| / \\ _ _ __ _ _ _ ___| |_ / /_ | |_| |__ ( _ )| |_| |__ |___ \\ / _ \\/ |___ / |\n| / _ \\| | | |/ _` | | | / __| __| | '_ \\| __| '_ \\ _____ / _ \\| __| '_ \\ __) | | | | | |_ \\ |\n| / ___ \\ |_| | (_| | |_| \\__ \\ |_ | (_) | |_| | | | |_____| | (_) | |_| | | | / __/| |_| | |___) | |\n| /_/ \\_\\__,_|\\__, |\\__,_|___/\\__| \\___/ \\__|_| |_| \\___/ \\__|_| |_| |_____|\\___/|_|____/ |\n| |___/ |\n| _ |\n| __ ____ ____ __ ___| |_ _ ___ ___ ___ _ __ ___ ___ _ __ ___ |\n| \\ \\ /\\ / /\\ \\ /\\ / /\\ \\ /\\ / / / __| | | | |/ _ \\/ __/ _ \\| '_ \\ / __/ _ \\| '_ ` _ \\ |\n| \\ V V / \\ V V / \\ V V / _ | (__| | |_| | __/ (_| (_) | | | | _ | (_| (_) | | | | | | |\n| \\_/\\_/ \\_/\\_/ \\_/\\_/ (_) \\___|_|\\__,_|\\___|\\___\\___/|_| |_| (_) \\___\\___/|_| |_| |_| |\n| |\n.========================================================================================================.\n"; + diff --git a/libs/esl/src/include/esl.h b/libs/esl/src/include/esl.h index 2f1a50949a..4296175f3a 100644 --- a/libs/esl/src/include/esl.h +++ b/libs/esl/src/include/esl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -391,7 +391,9 @@ ESL_DECLARE(esl_status_t) esl_attach_handle(esl_handle_t *handle, esl_socket_t s \param port Port to bind to \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, int max); + +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); /*! \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_buffer.h b/libs/esl/src/include/esl_buffer.h index c7901e4ede..9be62110d9 100644 --- a/libs/esl/src/include/esl_buffer.h +++ b/libs/esl/src/include/esl_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Anthony Minessale II + * Copyright (c) 2010-2012, 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_config.h b/libs/esl/src/include/esl_config.h index 44fb23c911..515fd73cdb 100644 --- a/libs/esl/src/include/esl_config.h +++ b/libs/esl/src/include/esl_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 1cc6134e42..1b6e6e29b4 100644 --- a/libs/esl/src/include/esl_event.h +++ b/libs/esl/src/include/esl_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -128,6 +128,10 @@ typedef enum { ESL_EVENT_SOCKET_DATA, ESL_EVENT_MEDIA_BUG_START, ESL_EVENT_MEDIA_BUG_STOP, + ESL_EVENT_CONFERENCE_DATA_QUERY, + ESL_EVENT_CONFERENCE_DATA, + ESL_EVENT_CALL_SETUP_REQ, + ESL_EVENT_CALL_SETUP_RESULT, ESL_EVENT_ALL } esl_event_types_t; diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 0ea1e5da89..9ffdae73a7 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 cf60313fe7..1477d8d71e 100644 --- a/libs/esl/testserver.c +++ b/libs/esl/testserver.c @@ -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("localhost", 8084, mycallback, 100000); + esl_listen_threaded("localhost", 8084, mycallback, 100000); return 0; } diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am index 35f1cecd1e..03477ad359 100644 --- a/libs/freetdm/Makefile.am +++ b/libs/freetdm/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2007, Anthony Minessale II +# Copyright (c) 2007-2012, Anthony Minessale II # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -79,7 +79,8 @@ libfreetdm_la_SOURCES = \ $(SRC)/ftdm_buffer.c \ $(SRC)/ftdm_threadmutex.c \ $(SRC)/ftdm_dso.c \ - $(SRC)/ftdm_cpu_monitor.c + $(SRC)/ftdm_cpu_monitor.c \ + $(SRC)/ftdm_backtrace.c library_include_HEADERS = \ $(SRC)/include/freetdm.h \ @@ -150,7 +151,7 @@ ftmod_zt_la_LIBADD = libfreetdm.la ftmod_skel_la_SOURCES = $(SRC)/ftmod/ftmod_skel/ftmod_skel.c ftmod_skel_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_skel_la_LDFLAGS = -module -avoid-version +ftmod_skel_la_LDFLAGS = -shared -module -avoid-version ftmod_skel_la_LIBADD = libfreetdm.la ftmod_analog_la_SOURCES = $(SRC)/ftmod/ftmod_analog/ftmod_analog.c @@ -248,6 +249,14 @@ ftmod_r2_la_LDFLAGS = -shared -module -avoid-version -lopenr2 ftmod_r2_la_LIBADD = libfreetdm.la endif +if HAVE_WAT +mod_LTLIBRARIES += ftmod_gsm.la +ftmod_gsm_la_SOURCES = $(SRC)/ftmod/ftmod_gsm/ftmod_gsm.c +ftmod_gsm_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) +ftmod_gsm_la_LDFLAGS = -shared -module -avoid-version -lwat +ftmod_gsm_la_LIBADD = libfreetdm.la +endif + if HAVE_MISDN mod_LTLIBRARIES += ftmod_misdn.la ftmod_misdn_la_SOURCES = $(SRC)/ftmod/ftmod_misdn/ftmod_misdn.c diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac index a888d20ef4..93e30f6d40 100644 --- a/libs/freetdm/configure.ac +++ b/libs/freetdm/configure.ac @@ -136,7 +136,7 @@ AC_CHECK_LIB([dl], [dlopen]) AC_CHECK_LIB([pthread], [pthread_create]) AC_CHECK_LIB([m], [cos]) -AC_CHECK_HEADERS([netdb.h sys/select.h]) +AC_CHECK_HEADERS([netdb.h sys/select.h execinfo.h]) AC_CHECK_FUNC([gethostbyname_r], [], [AC_CHECK_LIB([nsl], [gethostbyname_r])] @@ -189,6 +189,14 @@ AC_CHECK_LIB([openr2], [openr2_context_set_io_type], [HAVE_OPENR2="yes"]) AC_MSG_RESULT([checking whether to build ftmod_r2... ${HAVE_OPENR2}]) AM_CONDITIONAL([HAVE_OPENR2], [test "${HAVE_OPENR2}" = "yes"]) +## +# WAT GSM stack +# +HAVE_WAT="no" +AC_CHECK_LIB([wat], [wat_version], [HAVE_WAT="yes"]) +AC_MSG_RESULT([checking whether to build ftmod_wat... ${HAVE_WAT}]) +AM_CONDITIONAL([HAVE_WAT], [test "${HAVE_WAT}" = "yes"]) + ## # Digium libpri (TODO: add checks) # @@ -305,7 +313,7 @@ AC_MSG_RESULT([checking whether to build ftmod_sangoma_isdn... ${HAVE_SNG_ISDN}] AM_CONDITIONAL([HAVE_SNG_ISDN], [test "${HAVE_SNG_ISDN}" = "yes"]) if test "${HAVE_SNG_ISDN}" = "yes"; then - if test "${build}" == "${host}" + if test "${build}" = "${host}" then case "${host}" in x86_64-*) @@ -326,7 +334,7 @@ AC_MSG_RESULT([checking whether to build ftmod_sangoma_ss7... ${HAVE_SNG_SS7}]) AM_CONDITIONAL([HAVE_SNG_SS7], [test "${HAVE_SNG_SS7}" = "yes"]) if test "${HAVE_SNG_SS7}" = "yes"; then - if test "${build}" == "${host}" + if test "${build}" = "${host}" then case "${host}" in x86_64-*) @@ -451,13 +459,17 @@ AC_MSG_RESULT([ + Modules Signalling: + ftmod_analog....................... yes + ftmod_analog_em.................... yes ftmod_isdn......................... ${HAVE_LIBISDN} ftmod_libpri....................... ${HAVE_LIBPRI} ftmod_sangoma_isdn................. ${HAVE_SNG_ISDN} ftmod_sangoma_ss7.................. ${HAVE_SNG_SS7} ftmod_r2........................... ${HAVE_OPENR2} + ftmod_gsm.......................... ${HAVE_WAT} ftmod_pritap....................... ${HAVE_PRITAP} I/O: + ftmod_zt........................... yes ftmod_wanpipe...................... ${HAVE_LIBSANGOMA} ftmod_misdn........................ ${HAVE_MISDN} diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index a2dacafd43..0813e630ed 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -26,7 +26,7 @@ * Anthony Minessale II * Moises Silva * David Yat Sin - * + * Gideon Sadan * * mod_freetdm.c -- FreeTDM Endpoint Module * @@ -35,13 +35,6 @@ #include "freetdm.h" //#define CUDATEL_DEBUG -#ifdef CUDATEL_DEBUG -#ifndef _BSD_SOURCE -#define _BSD_SOURCE -#endif -#include -#include -#endif #ifndef __FUNCTION__ #define __FUNCTION__ __SWITCH_FUNC__ @@ -288,7 +281,7 @@ static void cycle_foreground(ftdm_channel_t *ftdmchan, int flash, const char *bc const char *buuid; tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); - buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + buuid = switch_channel_get_partner_uuid(channel); if (tokencnt == 1 && flash) { @@ -499,6 +492,21 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) return SWITCH_STATUS_SUCCESS; } +#ifdef CUDATEL_DEBUG +struct cudatel_trace_priv { + const char *name; + int span_id; + int chan_id; +}; + +static void cudatel_trace(const int tid, const void *addr, const char *symbol, void *priv) +{ + struct cudatel_trace_priv *data = priv; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d][tid:%d] %s -> %s\n", + data->span_id, data->chan_id, tid, data->name, symbol); +} +#endif + static switch_status_t channel_on_hangup(switch_core_session_t *session) { switch_channel_t *channel = NULL; @@ -558,19 +566,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) #ifdef CUDATEL_DEBUG { - pid_t tid = 0; - size_t size = 0; - char **symbols = NULL; - void *stacktrace[50]; - int si = 0; - size = backtrace(stacktrace, ftdm_array_len(stacktrace)); - symbols = backtrace_symbols(stacktrace, size); - tid = syscall(SYS_gettid); - for (si = 0; si < size; si++) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d][tid:%d] %s -> %s\n", - span_id, chan_id, tid, name, symbols[si]); - } - free(symbols); + struct cudatel_trace_priv trace_data; + trace_data.name = name; + trace_data.span_id = span_id; + trace_data.chan_id = chan_id; + ftdm_backtrace_walk(&cudatel_trace, &trace_data); } #endif @@ -864,7 +864,7 @@ 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 note ready) in channel %s device %d:%d!\n", name, span_id, chan_id); + 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); return SWITCH_STATUS_SUCCESS; } @@ -1774,6 +1774,10 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Plan", "%d", channel_caller_data->rdnis.plan); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CPC", "%s", ftdm_calling_party_category2str(channel_caller_data->cpc)); + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_clg_nadi"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-NADI", "%d", var_value); + } var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdnis_screen_ind"); if (!ftdm_strlen_zero(var_value)) { @@ -1825,8 +1829,19 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM", "%s", var_value); } + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_cic"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CIC", "%s", var_value); + } + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Screen", "%d", channel_caller_data->screen); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Presentation", "%d", channel_caller_data->pres); + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CallReference", "%d", channel_caller_data->call_reference); + + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_opc"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OPC", "%s", var_value); + } } /* Add any call variable to the dial plan */ @@ -1872,6 +1887,24 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal) switch (sigmsg->event_id) { + case FTDM_SIGEVENT_SMS: + { + ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); + ftdm_sms_data_t *sms = (ftdm_sms_data_t*) caller_data->priv; + + + ftdm_log(FTDM_LOG_INFO,"FTDM_SIGEVENT_SMS from %s: %s", sms->from, sms->body); + if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "failed to create SMS event\n"); + return FTDM_FAIL; + } + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", sms->from); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "body", sms->body); + alarmbits = 0; + } + //return FTDM_BREAK; + break; + case FTDM_SIGEVENT_ALARM_CLEAR: case FTDM_SIGEVENT_ALARM_TRAP: { @@ -1919,6 +1952,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal) return FTDM_SUCCESS; } break; + case FTDM_SIGEVENT_RELEASED: case FTDM_SIGEVENT_INDICATION_COMPLETED: case FTDM_SIGEVENT_DIALING: @@ -1947,6 +1981,8 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal) } if (event) { + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(sigmsg->channel)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(sigmsg->channel)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(sigmsg->channel)); @@ -2104,19 +2140,19 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal) if ((session_a = switch_core_session_locate(ftdm_channel_get_token(sigmsg->channel, 0)))) { channel_a = switch_core_session_get_channel(session_a); - br_a_uuid = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE); + br_a_uuid = switch_channel_get_partner_uuid(channel_a); tech_pvt = switch_core_session_get_private(session_a); - stop_hold(session_a, switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE)); + stop_hold(session_a, switch_channel_get_partner_uuid(channel_a)); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); } if ((session_b = switch_core_session_locate(ftdm_channel_get_token(sigmsg->channel, 1)))) { channel_b = switch_core_session_get_channel(session_b); - br_b_uuid = switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE); + br_b_uuid = switch_channel_get_partner_uuid(channel_b); tech_pvt = switch_core_session_get_private(session_b); - stop_hold(session_a, switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE)); + stop_hold(session_a, switch_channel_get_partner_uuid(channel_b)); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); } @@ -2184,7 +2220,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal) tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); - buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + buuid = switch_channel_get_partner_uuid(channel); ftdm_channel_call_unhold(sigmsg->channel); stop_hold(session, buuid); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); @@ -2804,6 +2840,95 @@ static int add_profile_parameters(switch_xml_t cfg, const char *profname, ftdm_c return paramindex; } +static void parse_gsm_spans(switch_xml_t cfg, switch_xml_t spans) +{ + switch_xml_t myspan, param; + + for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { + ftdm_status_t zstatus = FTDM_FAIL; + const char *context = "default"; + const char *dialplan = "XML"; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; + char *id = (char *) switch_xml_attr(myspan, "id"); + char *name = (char *) switch_xml_attr(myspan, "name"); + char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); + ftdm_span_t *span = NULL; + uint32_t span_id = 0; + unsigned paramindex = 0; + + if (!name && !id) { + CONFIG_ERROR("GSM span missing required attribute 'id' or 'name', skipping ...\n"); + continue; + } + + if (name) { + zstatus = ftdm_span_find_by_name(name, &span); + } else { + if (switch_is_number(id)) { + span_id = atoi(id); + zstatus = ftdm_span_find(span_id, &span); + } + + if (zstatus != FTDM_SUCCESS) { + zstatus = ftdm_span_find_by_name(id, &span); + } + } + + if (zstatus != FTDM_SUCCESS) { + CONFIG_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); + continue; + } + + if (!span_id) { + span_id = ftdm_span_get_id(span); + } + + memset(spanparameters, 0, sizeof(spanparameters)); + paramindex = 0; + + if (configname) { + paramindex = add_profile_parameters(cfg, configname, spanparameters, ftdm_array_len(spanparameters)); + if (paramindex) { + ftdm_log(FTDM_LOG_DEBUG, "Added %d parameters from profile %s for span %d\n", paramindex, configname, span_id); + } + } + + for (param = switch_xml_child(myspan, "param"); param; param = param->next) { + char *var = (char *) switch_xml_attr_soft(param, "name"); + char *val = (char *) switch_xml_attr_soft(param, "value"); + + if (ftdm_array_len(spanparameters) - 1 == paramindex) { + CONFIG_ERROR("Too many parameters for GSM span, ignoring any parameter after %s\n", var); + break; + } + + if (!strcasecmp(var, "context")) { + context = val; + } else if (!strcasecmp(var, "dialplan")) { + dialplan = val; + } else { + spanparameters[paramindex].var = var; + spanparameters[paramindex].val = val; + paramindex++; + } + } + + if (ftdm_configure_span_signaling(span, + "gsm", + on_clear_channel_signal, + spanparameters) != FTDM_SUCCESS) { + CONFIG_ERROR("Error configuring Sangoma GSM FreeTDM span %d\n", span_id); + continue; + } + SPAN_CONFIG[span_id].span = span; + switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); + switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); + switch_copy_string(SPAN_CONFIG[span_id].type, "GSM", sizeof(SPAN_CONFIG[span_id].type)); + ftdm_log(FTDM_LOG_DEBUG, "Configured GSM FreeTDM span %d\n", span_id); + ftdm_span_start(span); + } +} + static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans) { switch_xml_t myspan, param; @@ -2812,7 +2937,7 @@ static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans) ftdm_status_t zstatus = FTDM_FAIL; const char *context = "default"; const char *dialplan = "XML"; - ftdm_conf_parameter_t spanparameters[30]; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; char *id = (char *) switch_xml_attr(myspan, "id"); char *name = (char *) switch_xml_attr(myspan, "name"); char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); @@ -2981,13 +3106,17 @@ static switch_status_t load_config(void) parse_bri_pri_spans(cfg, spans); } + if ((spans = switch_xml_child(cfg, "gsm_spans"))) { + parse_gsm_spans(cfg, spans); + } + switch_core_hash_init(&globals.ss7_configs, module_pool); if ((spans = switch_xml_child(cfg, "sangoma_ss7_spans"))) { for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { ftdm_status_t zstatus = FTDM_FAIL; const char *context = "default"; const char *dialplan = "XML"; - ftdm_conf_parameter_t spanparameters[30]; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; char *id = (char *) switch_xml_attr(myspan, "id"); char *name = (char *) switch_xml_attr(myspan, "name"); char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); @@ -3389,7 +3518,7 @@ static switch_status_t load_config(void) if ((spans = switch_xml_child(cfg, "pri_spans"))) { for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { char *name = (char *) switch_xml_attr(myspan, "name"); - ftdm_conf_parameter_t spanparameters[10]; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; ftdm_status_t zstatus = FTDM_FAIL; const char *context = "default"; const char *dialplan = "XML"; @@ -3457,7 +3586,7 @@ static switch_status_t load_config(void) ftdm_status_t zstatus = FTDM_FAIL; unsigned paramindex = 0; - ftdm_conf_parameter_t spanparameters[10]; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; const char *context = "default"; const char *dialplan = "XML"; ftdm_span_t *span = NULL; @@ -3515,7 +3644,7 @@ static switch_status_t load_config(void) if ((spans = switch_xml_child(cfg, "libpri_spans"))) { for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { char *name = (char *) switch_xml_attr(myspan, "name"); - ftdm_conf_parameter_t spanparameters[10]; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; ftdm_status_t zstatus = FTDM_FAIL; const char *context = "default"; const char *dialplan = "XML"; @@ -3590,7 +3719,7 @@ static switch_status_t load_config(void) uint32_t span_id = 0; ftdm_span_t *span = NULL; - ftdm_conf_parameter_t spanparameters[30]; + ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; unsigned paramindex = 0; if (!name) { diff --git a/libs/freetdm/ozrename.sh b/libs/freetdm/ozrename.sh deleted file mode 100755 index 369be1c3a1..0000000000 --- a/libs/freetdm/ozrename.sh +++ /dev/null @@ -1,99 +0,0 @@ -# renaming main header and build file -copy="cp -r" - -$copy src/include/openzap.h src/include/freetdm.h -svn delete src/include/openzap.h -$copy openzap.pc.in freetdm.pc.in -svn delete openzap.pc.in - -# create mod_freetdm -mkdir mod_freetdm -cp mod_openzap/* mod_freetdm/ -mv mod_freetdm/mod_openzap.c mod_freetdm/mod_freetdm.c -svn delete --force mod_openzap - - -##### ozmod stuff #### -# rename anything ozmod to ftmod, including directories first -mkdir ./src/ftmod -for file in `find ./src/ozmod -name *ozmod_* -type d` -do - $copy ${file} ${file//ozmod/ftmod} -done - -#remove .svn directories in the copied ozmod dirs -find ./src/ftmod -name *.svn -exec rm -rf {} \; - -# copy ozmod c files -for file in `find ./src/ftmod -name *ozmod_*.c` -do - mv $file ${file//ozmod/ftmod} -done - -# copy ozmod h files -for file in `find ./src/ftmod -name *ozmod_*.h` -do - mv $file ${file//ozmod/ftmod} -done - -#### end ozmod stuff #### - -# renaming other zap files -for file in `find ./ -name *zap_*.c` -do - mv $file ${file//zap_/ftdm_} -done - -for file in `find ./ -name *zap_*.h` -do - mv $file ${file//zap_/ftdm_} -done - -svn revert -R src/ozmod -svn delete --force src/ozmod - -# replace full openzap occurences first (handles openzap.h, libopenzap etc) -find ./ -name *.c -exec sed -i 's,openzap,freetdm,g' {} \; - -find ./ -name *.h -exec sed -i 's,openzap,freetdm,g' {} \; - -sed -i 's,openzap,freetdm,g' Makefile.am - -sed -i 's,openzap,freetdm,g' configure.ac - -sed -i 's,openzap,freetdm,g' mod_freetdm/Makefile.in - -# replace inside files -find ./ -name *.c -exec sed -i 's,oz,ft,g' {} \; -find ./ -name *.c -exec sed -i 's,OZ,FT,g' {} \; -find ./ -name *.c -exec sed -i 's,zap,ftdm,g' {} \; -find ./ -name *.c -exec sed -i 's,ZAP,FTDM,g' {} \; -find ./ -name *.c -exec sed -i 's,zchan,ftdmchan,g' {} \; - -find ./ -name *.h -exec sed -i 's,oz,ft,g' {} \; -find ./ -name *.h -exec sed -i 's,OZ,FT,g' {} \; -find ./ -name *.h -exec sed -i 's,zap,ftdm,g' {} \; -find ./ -name *.h -exec sed -i 's,ZAP,FTDM,g' {} \; -find ./ -name *.h -exec sed -i 's,zchan,ftdmchan,g' {} \; - -sed -i 's,oz,ft,g' Makefile.am -sed -i 's,OZ,FT,g' Makefile.am -sed -i 's,zap,ftdm,g' Makefile.am -sed -i 's,ZAP,FTDM,g' Makefile.am -sed -i 's,zchan,ftdmchan,g' Makefile.am - -sed -i 's,oz,ft,g' configure.ac -sed -i 's,OZ,FT,g' configure.ac -sed -i 's,zap,ftdm,g' configure.ac -sed -i 's,ZAP,FTDM,g' configure.ac -sed -i 's,zchan,ftdmchan,g' configure.ac - -sed -i 's,oz,ft,g' mod_freetdm/Makefile.in -sed -i 's,OZ,FT,g' mod_freetdm/Makefile.in -sed -i 's,zap,ftdm,g' mod_freetdm/Makefile.in -sed -i 's,ZAP,FTDM,g' mod_freetdm/Makefile.in -sed -i 's,zchan,ftdmchan,g' mod_freetdm/Makefile.in - -svn add src/ftmod/ -svn add mod_freetdm/ - diff --git a/libs/freetdm/ozreplace.sh b/libs/freetdm/ozreplace.sh deleted file mode 100755 index 71f4b13766..0000000000 --- a/libs/freetdm/ozreplace.sh +++ /dev/null @@ -1,13 +0,0 @@ -##### ozmod stuff #### -# replace full openzap occurences first (handles openzap.h, libopenzap etc) -sed -i 's,openzap,freetdm,g' $1 -sed -i 's,ozmod,ftmod,g' $1 - -sed -i 's,zchan,ftdmchan,g' $1 -sed -i 's,oz,ft,g' $1 -sed -i 's,OZ,FT,g' $1 -sed -i 's,zap,ftdm,g' $1 -sed -i 's,ZAP,FTDM,g' $1 -sed -i 's,zio,fio,g' $1 -sed -i 's,ZIO,FIO,g' $1 - diff --git a/libs/freetdm/src/ftdm_backtrace.c b/libs/freetdm/src/ftdm_backtrace.c new file mode 100644 index 0000000000..70eef159d1 --- /dev/null +++ b/libs/freetdm/src/ftdm_backtrace.c @@ -0,0 +1,75 @@ +/* + * + * + */ +#define _BSD_SOURCE +#include "private/ftdm_core.h" + +#ifdef HAVE_EXECINFO_H +#include +#include +#include +#include + +#define FTDM_BACKTRACE_MAX 50 + +FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv) +{ + void *stacktrace[FTDM_BACKTRACE_MAX]; + char **symbols = NULL; + size_t size = 0; + pid_t tid = 0; + int si = 0; + + if (!callback) { + return FTDM_EINVAL; + } + + tid = syscall(SYS_gettid); + + size = backtrace(stacktrace, ftdm_array_len(stacktrace)); + symbols = backtrace_symbols(stacktrace, size); + + for (si = 0; si < size; si++) { + callback(tid, stacktrace[si], symbols[si], priv); + } + + free(symbols); + return FTDM_SUCCESS; +} + +#else /* !HAVE_EXECINFO_H */ + +FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv) +{ + ftdm_log(FTDM_LOG_DEBUG, "Stack traces are not available on this platform!\n"); + return FTDM_NOTIMPL; +} + +#endif + + +static void span_backtrace(const int tid, const void *addr, const char *symbol, void *priv) +{ + ftdm_span_t *span = priv; + ftdm_log(FTDM_LOG_DEBUG, "[%d][tid:%d] %p -> %s\n", + ftdm_span_get_id(span), tid, addr, symbol); +} + +FT_DECLARE(ftdm_status_t) ftdm_backtrace_span(ftdm_span_t *span) +{ + return ftdm_backtrace_walk(&span_backtrace, span); +} + + +static void chan_backtrace(const int tid, const void *addr, const char *symbol, void *priv) +{ + ftdm_channel_t *chan = priv; + ftdm_log(FTDM_LOG_DEBUG, "[%d:%d][tid:%d] %p -> %s\n", + ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan), tid, addr, symbol); +} + +FT_DECLARE(ftdm_status_t) ftdm_backtrace_chan(ftdm_channel_t *chan) +{ + return ftdm_backtrace_walk(&chan_backtrace, chan); +} diff --git a/libs/freetdm/src/ftdm_buffer.c b/libs/freetdm/src/ftdm_buffer.c index 000cddd3f9..015402556f 100644 --- a/libs/freetdm/src/ftdm_buffer.c +++ b/libs/freetdm/src/ftdm_buffer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 4dfc395e06..42b93cd78e 100644 --- a/libs/freetdm/src/ftdm_config.c +++ b/libs/freetdm/src/ftdm_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 caab35143a..6986804753 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -262,9 +262,12 @@ FTDM_STR2ENUM(ftdm_str2ftdm_tonemap, ftdm_tonemap2str, ftdm_tonemap_t, TONEMAP_N FTDM_ENUM_NAMES(OOB_NAMES, OOB_STRINGS) FTDM_STR2ENUM(ftdm_str2ftdm_oob_event, ftdm_oob_event2str, ftdm_oob_event_t, OOB_NAMES, FTDM_OOB_INVALID) -FTDM_ENUM_NAMES(TRUNK_TYPE_NAMES, TRUNK_STRINGS) +FTDM_ENUM_NAMES(TRUNK_TYPE_NAMES, TRUNK_TYPE_STRINGS) FTDM_STR2ENUM(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t, TRUNK_TYPE_NAMES, FTDM_TRUNK_NONE) +FTDM_ENUM_NAMES(TRUNK_MODE_NAMES, TRUNK_MODE_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_trunk_mode, ftdm_trunk_mode2str, ftdm_trunk_mode_t, TRUNK_MODE_NAMES, FTDM_TRUNK_MODE_INVALID) + FTDM_ENUM_NAMES(START_TYPE_NAMES, START_TYPE_STRINGS) FTDM_STR2ENUM(ftdm_str2ftdm_analog_start_type, ftdm_analog_start_type2str, ftdm_analog_start_type_t, START_TYPE_NAMES, FTDM_ANALOG_START_NA) @@ -757,11 +760,16 @@ FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span) goto done; } + /* Stop SIG */ status = span->stop(span); - if (FTDM_SUCCESS == status) { + if (status == FTDM_SUCCESS) { ftdm_clear_flag(span, FTDM_SPAN_STARTED); } + /* Stop I/O */ + if (span->fio && span->fio->span_stop) { + status = span->fio->span_stop(span); + } done: ftdm_mutex_unlock(span->mutex); @@ -816,6 +824,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_create(const char *iotype, const char *name, ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_BUSY], "%(500,500,480,620)", FTDM_TONEMAP_LEN); ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_ATTN], "%(100,100,1400,2060,2450,2600)", FTDM_TONEMAP_LEN); new_span->trunk_type = FTDM_TRUNK_NONE; + new_span->trunk_mode = FTDM_TRUNK_MODE_CPE; new_span->data_type = FTDM_TYPE_SPAN; ftdm_mutex_lock(globals.span_mutex); @@ -1994,6 +2003,21 @@ FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span) return ftdm_trunk_type2str(span->trunk_type); } +FT_DECLARE(void) ftdm_span_set_trunk_mode(ftdm_span_t *span, ftdm_trunk_mode_t mode) +{ + span->trunk_mode = mode; +} + +FT_DECLARE(ftdm_trunk_mode_t) ftdm_span_get_trunk_mode(const ftdm_span_t *span) +{ + return span->trunk_mode; +} + +FT_DECLARE(const char *) ftdm_span_get_trunk_mode_str(const ftdm_span_t *span) +{ + return ftdm_trunk_mode2str(span->trunk_mode); +} + FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span) { return span->span_id; @@ -4181,6 +4205,9 @@ FT_DECLARE(ftdm_iterator_t *) ftdm_get_iterator(ftdm_iterator_type_t type, ftdm_ FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter) { + if (!span->chan_count) { + return NULL; + } if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_CHANS, iter))) { return NULL; } @@ -4624,7 +4651,7 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const static ftdm_status_t load_config(void) { - char cfg_name[] = "freetdm.conf"; + const char cfg_name[] = "freetdm.conf"; ftdm_config_t cfg; char *var, *val; int catno = -1; @@ -4642,7 +4669,9 @@ static ftdm_status_t load_config(void) if (!ftdm_config_open_file(&cfg, cfg_name)) { return FTDM_FAIL; } - ftdm_log(FTDM_LOG_DEBUG, "Reading FreeTDM configuration file\n"); + + ftdm_log(FTDM_LOG_DEBUG, "Reading FreeTDM configuration file\n"); + while (ftdm_config_next_pair(&cfg, &var, &val)) { if (*cfg.category == '#') { if (cfg.catno != catno) { @@ -4653,14 +4682,14 @@ static ftdm_status_t load_config(void) if (cfg.catno != catno) { char *type = cfg.category + 4; char *name; - + if (*type == ' ') { type++; } - + ftdm_log(FTDM_LOG_DEBUG, "found config for span\n"); catno = cfg.catno; - + if (ftdm_strlen_zero(type)) { ftdm_log(FTDM_LOG_CRIT, "failure creating span, no type specified.\n"); span = NULL; @@ -4671,7 +4700,7 @@ static ftdm_status_t load_config(void) *name++ = '\0'; } - /* Verify is trunk_type was specified for previous span */ + /* Verify if trunk_type was specified for previous span */ if (span && span->trunk_type == FTDM_TRUNK_NONE) { ftdm_log(FTDM_LOG_ERROR, "trunk_type not specified for span %d (%s)\n", span->span_id, span->name); ret = FTDM_FAIL; @@ -4698,11 +4727,15 @@ static ftdm_status_t load_config(void) } ftdm_log(FTDM_LOG_DEBUG, "span %d [%s]=[%s]\n", span->span_id, var, val); - + if (!strcasecmp(var, "trunk_type")) { ftdm_trunk_type_t trtype = ftdm_str2ftdm_trunk_type(val); ftdm_span_set_trunk_type(span, trtype); - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s'\n", ftdm_trunk_type2str(trtype)); + ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s'\n", ftdm_trunk_type2str(trtype)); + } else if (!strcasecmp(var, "trunk_mode")) { + ftdm_trunk_mode_t trmode = ftdm_str2ftdm_trunk_mode(val); + ftdm_span_set_trunk_mode(span, trmode); + ftdm_log(FTDM_LOG_DEBUG, "setting trunk mode to '%s'\n", ftdm_trunk_mode2str(trmode)); } else if (!strcasecmp(var, "name")) { if (!strcasecmp(val, "undef")) { chan_config.name[0] = '\0'; @@ -4719,16 +4752,17 @@ static ftdm_status_t load_config(void) if (span->trunk_type == FTDM_TRUNK_FXS || span->trunk_type == FTDM_TRUNK_FXO || span->trunk_type == FTDM_TRUNK_EM) { if ((tmp = ftdm_str2ftdm_analog_start_type(val)) != FTDM_ANALOG_START_NA) { span->start_type = tmp; - ftdm_log(FTDM_LOG_DEBUG, "changing start type to '%s'\n", ftdm_analog_start_type2str(span->start_type)); + ftdm_log(FTDM_LOG_DEBUG, "changing start type to '%s'\n", ftdm_analog_start_type2str(span->start_type)); } } else { ftdm_log(FTDM_LOG_ERROR, "This option is only valid on analog trunks!\n"); } } else if (!strcasecmp(var, "fxo-channel")) { if (span->trunk_type == FTDM_TRUNK_NONE) { - span->trunk_type = FTDM_TRUNK_FXO; - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", ftdm_trunk_type2str(span->trunk_type), - ftdm_analog_start_type2str(span->start_type)); + span->trunk_type = FTDM_TRUNK_FXO; + span->trunk_mode = FTDM_TRUNK_MODE_CPE; + ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type), + ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode)); } if (span->trunk_type == FTDM_TRUNK_FXO) { unsigned chans_configured = 0; @@ -4737,13 +4771,14 @@ static ftdm_status_t load_config(void) configured += chans_configured; } } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add FXO channels to an FXS trunk!\n"); + ftdm_log(FTDM_LOG_WARNING, "Cannot add FXO channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); } } else if (!strcasecmp(var, "fxs-channel")) { if (span->trunk_type == FTDM_TRUNK_NONE) { span->trunk_type = FTDM_TRUNK_FXS; - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", ftdm_trunk_type2str(span->trunk_type), - ftdm_analog_start_type2str(span->start_type)); + span->trunk_mode = FTDM_TRUNK_MODE_NET; + ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type), + ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode)); } if (span->trunk_type == FTDM_TRUNK_FXS) { unsigned chans_configured = 0; @@ -4752,13 +4787,14 @@ static ftdm_status_t load_config(void) configured += chans_configured; } } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add FXS channels to an FXO trunk!\n"); + ftdm_log(FTDM_LOG_WARNING, "Cannot add FXS channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); } } else if (!strcasecmp(var, "em-channel")) { if (span->trunk_type == FTDM_TRUNK_NONE) { span->trunk_type = FTDM_TRUNK_EM; - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", ftdm_trunk_type2str(span->trunk_type), - ftdm_analog_start_type2str(span->start_type)); + span->trunk_mode = FTDM_TRUNK_MODE_CPE; + ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type), + ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode)); } if (span->trunk_type == FTDM_TRUNK_EM) { unsigned chans_configured = 0; @@ -4767,19 +4803,33 @@ static ftdm_status_t load_config(void) configured += chans_configured; } } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add EM channels to a non-EM trunk!\n"); + ftdm_log(FTDM_LOG_WARNING, "Cannot add EM channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); } } else if (!strcasecmp(var, "b-channel")) { - unsigned chans_configured = 0; - chan_config.type = FTDM_CHAN_TYPE_B; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; + if (span->trunk_type == FTDM_TRUNK_NONE) { + ftdm_log(FTDM_LOG_ERROR, "No trunk type specified in configuration file\n"); + break; + } + if (FTDM_SPAN_IS_DIGITAL(span)) { + unsigned chans_configured = 0; + chan_config.type = FTDM_CHAN_TYPE_B; + if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { + configured += chans_configured; + } + } else { + ftdm_log(FTDM_LOG_WARNING, "Cannot add B channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); } } else if (!strcasecmp(var, "d-channel")) { - if (d) { - ftdm_log(FTDM_LOG_WARNING, "ignoring extra d-channel\n"); - } else { + if (span->trunk_type == FTDM_TRUNK_NONE) { + ftdm_log(FTDM_LOG_ERROR, "No trunk type specified in configuration file\n"); + break; + } + if (FTDM_SPAN_IS_DIGITAL(span)) { unsigned chans_configured = 0; + if (d) { + ftdm_log(FTDM_LOG_WARNING, "ignoring extra d-channel\n"); + continue; + } if (!strncasecmp(val, "lapd:", 5)) { chan_config.type = FTDM_CHAN_TYPE_DQ931; val += 5; @@ -4790,11 +4840,12 @@ static ftdm_status_t load_config(void) configured += chans_configured; } d++; + } else { + ftdm_log(FTDM_LOG_WARNING, "Cannot add D channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); } } else if (!strcasecmp(var, "cas-channel")) { unsigned chans_configured = 0; chan_config.type = FTDM_CHAN_TYPE_CAS; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { configured += chans_configured; } @@ -4916,7 +4967,7 @@ done: if (!configured) { ret = FTDM_FAIL; } - + return ret; } @@ -5263,6 +5314,14 @@ FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span) goto done; } + /* Start I/O */ + if (span->fio && span->fio->span_start) { + status = span->fio->span_start(span); + if (status != FTDM_SUCCESS) + goto done; + } + + /* Start SIG */ status = ftdm_report_initial_channels_alarms(span); if (status != FTDM_SUCCESS) { goto done; @@ -5661,7 +5720,7 @@ static void *ftdm_cpu_monitor_run(ftdm_thread_t *me, void *obj) static ftdm_status_t ftdm_cpu_monitor_start(void) { - if (ftdm_interrupt_create(&globals.cpu_monitor.interrupt, FTDM_INVALID_SOCKET) != FTDM_SUCCESS) { + if (ftdm_interrupt_create(&globals.cpu_monitor.interrupt, FTDM_INVALID_SOCKET, FTDM_NO_FLAGS) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed to create CPU monitor interrupt\n"); return FTDM_FAIL; } diff --git a/libs/freetdm/src/ftdm_queue.c b/libs/freetdm/src/ftdm_queue.c index 75d18033da..625f22ec36 100644 --- a/libs/freetdm/src/ftdm_queue.c +++ b/libs/freetdm/src/ftdm_queue.c @@ -98,7 +98,7 @@ static ftdm_status_t ftdm_std_queue_create(ftdm_queue_t **outqueue, ftdm_size_t goto failed; } - if (ftdm_interrupt_create(&queue->interrupt, FTDM_INVALID_SOCKET) != FTDM_SUCCESS) { + if (ftdm_interrupt_create(&queue->interrupt, FTDM_INVALID_SOCKET, FTDM_NO_FLAGS) != FTDM_SUCCESS) { goto failed; } diff --git a/libs/freetdm/src/ftdm_state.c b/libs/freetdm/src/ftdm_state.c index 54ecde530d..db4097e84b 100644 --- a/libs/freetdm/src/ftdm_state.c +++ b/libs/freetdm/src/ftdm_state.c @@ -92,7 +92,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const c diff = fchan->history[hindex].end_time - fchan->history[hindex].time; - ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Completed state change from %s to %s in %llums\n", + ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Completed state change from %s to %s in %"FTDM_TIME_FMT" ms\n", ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(state), diff); @@ -209,7 +209,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_cancel_state(const char *file, const char /* NOTE * we could potentially also take out the channel from the pendingchans queue, but I believe is easier just leave it, * the only side effect will be a call to ftdm_channel_advance_states() for a channel that has nothing to advance */ - ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Cancelled state change from %s to %s in %llums\n", + ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Cancelled state change from %s to %s in %"FTDM_TIME_FMT" ms\n", ftdm_channel_state2str(last_state), ftdm_channel_state2str(state), diff); return FTDM_SUCCESS; @@ -254,7 +254,7 @@ static ftdm_status_t ftdm_core_set_state(const char *file, const char *func, int } if (!ftdmchan->state_completed_interrupt) { - status = ftdm_interrupt_create(&ftdmchan->state_completed_interrupt, FTDM_INVALID_SOCKET); + status = ftdm_interrupt_create(&ftdmchan->state_completed_interrupt, FTDM_INVALID_SOCKET, FTDM_NO_FLAGS); if (status != FTDM_SUCCESS) { ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_CRIT, "Failed to create state change interrupt when moving from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); @@ -370,12 +370,19 @@ end: } ftdm_set_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE); - ftdm_mutex_lock(ftdmchan->span->mutex); - ftdm_set_flag(ftdmchan->span, FTDM_SPAN_STATE_CHANGE); if (ftdmchan->span->pendingchans) { ftdm_queue_enqueue(ftdmchan->span->pendingchans, ftdmchan); + } else { + /* there is a potential deadlock here, if a signaling module is processing + * state changes while the ftdm_span_stop() function is called, the signaling + * thread will block until it can acquire the span lock, but the thread calling + * ftdm_span_stop() which holds the span lock is waiting on the signaling thread + * to finish ... The only reason to acquire the span lock is this flag, new + * signaling modules should use the pendingchans queue instead of this flag, + * as of today a few modules need still to be updated before we can get rid of + * this flag (ie, ftmod_libpri, ftmod_isdn, ftmod_analog) */ + ftdm_set_flag_locked(ftdmchan->span, FTDM_SPAN_STATE_CHANGE); } - ftdm_mutex_unlock(ftdmchan->span->mutex); if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) { /* the channel should not block waiting for state processing */ diff --git a/libs/freetdm/src/ftdm_threadmutex.c b/libs/freetdm/src/ftdm_threadmutex.c index 20b85ae91e..302cd32e64 100644 --- a/libs/freetdm/src/ftdm_threadmutex.c +++ b/libs/freetdm/src/ftdm_threadmutex.c @@ -73,6 +73,8 @@ struct ftdm_mutex { struct ftdm_interrupt { ftdm_socket_t device; + ftdm_wait_flag_t device_input_flags; + ftdm_wait_flag_t device_output_flags; #ifdef WIN32 /* for generic interruption */ HANDLE event; @@ -323,7 +325,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_mutex_unlock(const char *file, int line, const c } -FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **ininterrupt, ftdm_socket_t device) +FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **ininterrupt, ftdm_socket_t device, ftdm_wait_flag_t device_flags) { ftdm_status_t status = FTDM_SUCCESS; ftdm_interrupt_t *interrupt = NULL; @@ -340,6 +342,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **ininterrupt, } interrupt->device = device; + interrupt->device_input_flags = device_flags; #ifdef WIN32 interrupt->event = CreateEvent(NULL, FALSE, FALSE, NULL); if (!interrupt->event) { @@ -389,15 +392,16 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_wait(ftdm_interrupt_t *interrupt, int m char pipebuf[255]; #endif - ftdm_assert_return(interrupt != NULL, FTDM_FAIL, "Condition is null!\n"); - + ftdm_assert_return(interrupt != NULL, FTDM_FAIL, "Interrupt is null!\n"); + interrupt->device_output_flags = FTDM_NO_FLAGS; /* start implementation */ #ifdef WIN32 ints[0] = interrupt->event; if (interrupt->device != FTDM_INVALID_SOCKET) { num++; ints[1] = interrupt->device; + ftdm_log(FTDM_LOG_CRIT, "implement me! (Windows support for device_output_flags member!)\n"); } res = WaitForMultipleObjects(num, ints, FALSE, ms >= 0 ? ms : INFINITE); switch (res) { @@ -422,7 +426,7 @@ pollagain: if (interrupt->device != FTDM_INVALID_SOCKET) { num++; ints[1].fd = interrupt->device; - ints[1].events = POLLIN; + ints[1].events = interrupt->device_input_flags; ints[1].revents = 0; } @@ -446,7 +450,17 @@ pollagain: ftdm_log(FTDM_LOG_CRIT, "reading interrupt descriptor failed (%s)\n", strerror(errno)); } } - + if (interrupt->device != FTDM_INVALID_SOCKET) { + if (ints[1].revents & POLLIN) { + interrupt->device_output_flags |= FTDM_READ; + } + if (ints[1].revents & POLLOUT) { + interrupt->device_output_flags |= FTDM_WRITE; + } + if (ints[1].revents & POLLPRI) { + interrupt->device_output_flags |= FTDM_EVENTS; + } + } return FTDM_SUCCESS; #endif } @@ -515,10 +529,12 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru for (i = 0; i < size; i++) { ints[i] = interrupts[i]->event; + interrupts[i]->device_output_flags = FTDM_NO_FLAGS; if (interrupts[i]->device != FTDM_INVALID_SOCKET) { - + /* WARNING: if the device is ready for data we must implement for Windows the device_output_flags member */ ints[size+numdevices] = interrupts[i]->device; numdevices++; + ftdm_log(FTDM_LOG_CRIT, "implement me! (Windows support for device_data_ready member!)\n", size); } } @@ -548,17 +564,16 @@ pollagain: ints[i].events = POLLIN; ints[i].revents = 0; ints[i].fd = interrupts[i]->readfd; + interrupts[i]->device_output_flags = FTDM_NO_FLAGS; if (interrupts[i]->device != FTDM_INVALID_SOCKET) { - ints[size+numdevices].events = POLLIN; + ints[size+numdevices].events = interrupts[i]->device_input_flags; ints[size+numdevices].revents = 0; ints[size+numdevices].fd = interrupts[i]->device; - numdevices++; } } res = poll(ints, size + numdevices, ms); - if (res == -1) { if (errno == EINTR) { goto pollagain; @@ -571,7 +586,8 @@ pollagain: return FTDM_TIMEOUT; } - /* check for events in the pipes, NOT in the devices */ + /* check for events in the pipes and in the devices, but service only the pipes */ + numdevices = 0; for (i = 0; i < size; i++) { if (ints[i].revents & POLLIN) { res = read(ints[i].fd, pipebuf, sizeof(pipebuf)); @@ -579,6 +595,18 @@ pollagain: ftdm_log(FTDM_LOG_CRIT, "reading interrupt descriptor failed (%s)\n", strerror(errno)); } } + if (interrupts[i]->device != FTDM_INVALID_SOCKET) { + if (ints[size+numdevices].revents & POLLIN) { + interrupts[i]->device_output_flags |= FTDM_READ; + } + if (ints[size+numdevices].revents & POLLOUT) { + interrupts[i]->device_output_flags |= FTDM_WRITE; + } + if (ints[size+numdevices].revents & POLLPRI) { + interrupts[i]->device_output_flags |= FTDM_EVENTS; + } + numdevices++; + } } #else /* for MacOS compilation, unused vars */ @@ -587,6 +615,15 @@ pollagain: return FTDM_SUCCESS; } +FT_DECLARE(ftdm_wait_flag_t) ftdm_interrupt_device_ready(ftdm_interrupt_t *interrupt) +{ +#if defined(__WINDOWS__) + /* device output flags are not currently filled for Windows upon returning from a wait function */ + ftdm_log(FTDM_LOG_CRIT, "IMPLEMENT ME!\n"); +#endif + return interrupt->device_output_flags; +} + /* For Emacs: * Local Variables: * mode:c diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h b/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h index a2339120c5..47a7a43491 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index 85da471739..8abfce78df 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, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -473,7 +473,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) sig.span_id = ftdmchan->span_id; sig.channel = ftdmchan; - ftdm_assert(interval != 0, NULL); + ftdm_assert(interval != 0, "Invalid interval"); if (!dial_timeout) { ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Not waiting for dial tone to dial number %s\n", ftdmchan->caller_data.dnis.digits); diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h b/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h index 83d5bb31d9..22a1c25132 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h +++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Anthony Minessale II + * Copyright (c) 2008-2012, 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.c b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c index 907a8cb034..f7f0683673 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Anthony Minessale II + * Copyright (c) 2008-2012, 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_gsm/ftmod_gsm.c b/libs/freetdm/src/ftmod/ftmod_gsm/ftmod_gsm.c new file mode 100755 index 0000000000..a787a2b9eb --- /dev/null +++ b/libs/freetdm/src/ftmod/ftmod_gsm/ftmod_gsm.c @@ -0,0 +1,1329 @@ +/* + * Copyright (c) 2011, Sangoma Technologies + * 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 original 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. + * + * Contributors: + * + * Gideon Sadan + * Moises Silva + * + */ + + +#define _GNU_SOURCE + +#include +#include +#include + +#include +#include +#include +#include +#include +/*========================*/ + +#include +#include +#include + +#include + +// Debug +#define LOG_SIG_DATA 0 +#define DEBUG_STATES 0 + + +#if DEBUG_STATES // state debugging +#define STATE_ADVANCE_LOG_LEVEL FTDM_LOG_CRIT +#else +#define STATE_ADVANCE_LOG_LEVEL FTDM_LOG_DEBUG +#endif + + +/********************************************************************************/ +/* */ +/* MACROS */ +/* */ +/********************************************************************************/ +// Macro to send signals +#define SEND_STATE_SIGNAL(sig) \ + { \ + ftdm_sigmsg_t sigev; \ + memset(&sigev, 0, sizeof(sigev)); \ + sigev.event_id = sig; \ + sigev.channel = ftdmchan; \ + ftdm_span_send_signal(ftdmchan->span, &sigev); \ + } + +// Syntax message +#define FT_SYNTAX "USAGE:\n" \ +"--------------------------------------------------------------------------------\n" \ +"ftdm gsm version \n" \ +"ftdm gsm status \n" \ +"ftdm gsm sms \n" \ +"--------------------------------------------------------------------------------\n" + +// Used to declare command handler +#define COMMAND_HANDLER(name) \ + ftdm_status_t fCMD_##name(ftdm_stream_handle_t *stream, char *argv[], int argc); \ + ftdm_status_t fCMD_##name(ftdm_stream_handle_t *stream, char *argv[], int argc) + +// Used to define command entry in the command map. +#define COMMAND(name, argc) {#name, argc, fCMD_##name} + +/********************************************************************************/ +/* */ +/* types */ +/* */ +/********************************************************************************/ + +// private data +typedef struct ftdm_gsm_span_data_s { + ftdm_span_t *span; + ftdm_channel_t *dchan; + ftdm_channel_t *bchan; + int32_t call_id; +} ftdm_gsm_span_data_t; + +// command handler function type. +typedef ftdm_status_t (*fCMD)(ftdm_stream_handle_t *stream, char *argv[], int argc); + + + +/********************************************************************************/ +/* */ +/* function declaration */ +/* */ +/********************************************************************************/ +static ftdm_status_t init_wat_lib(void); +static int wat_lib_initialized = 0; +static FIO_API_FUNCTION(ftdm_gsm_api); + + + +/* wat callbacks */ +int on_wat_span_write(unsigned char span_id, void *buffer, unsigned len); + +void on_wat_con_ind(unsigned char span_id, uint8_t call_id, wat_con_event_t *con_event); +void on_wat_con_sts(unsigned char span_id, uint8_t call_id, wat_con_status_t *status); +void on_wat_rel_ind(unsigned char span_id, uint8_t call_id, wat_rel_event_t *rel_event); +void on_wat_rel_cfm(unsigned char span_id, uint8_t call_id); +void on_wat_sms_ind(unsigned char span_id, wat_sms_event_t *sms_event); +void on_wat_sms_sts(unsigned char span_id, uint8_t sms_id, wat_sms_status_t *status); + + +void on_wat_log(uint8_t level, char *fmt, ...); +void *on_wat_malloc(size_t size); +void *on_wat_calloc(size_t nmemb, size_t size); +void on_wat_free(void *ptr); +void on_wat_log_span(uint8_t span_id, uint8_t level, char *fmt, ...); + + +ftdm_span_t *GetSpanByID(unsigned char span_id, ftdm_gsm_span_data_t **gsm_data); + +static void *ftdm_gsm_run(ftdm_thread_t *me, void *obj); + +/********************************************************************************/ +/* */ +/* static & global data */ +/* */ +/********************************************************************************/ +int g_outbound_call_id = 8; + +/* IO interface for the command API */ +static ftdm_io_interface_t g_ftdm_gsm_interface; + +/********************************************************************************/ +/* */ +/* implementation */ +/* */ +/********************************************************************************/ +static int read_channel(ftdm_channel_t *ftdm_chan , const void *buf, int size) +{ + + ftdm_size_t outsize = size; + ftdm_status_t status = ftdm_channel_read(ftdm_chan, (void *)buf, &outsize); + if (FTDM_FAIL == status) { + return -1; + } + return (int)outsize; +} + + +int on_wat_span_write(unsigned char span_id, void *buffer, unsigned len) +{ + +#if LOG_SIG_DATA + fprintf(stdout, " Out Data ====================>>> %s \r\n (%d) - %d\n", (char *)buffer, len, (int) span_id); +#endif + + ftdm_span_t *span = NULL; + ftdm_status_t status = FTDM_FAIL; + ftdm_gsm_span_data_t *gsm_data = NULL; + ftdm_size_t outsize = len; + + status = ftdm_span_find(span_id, &span); + if (status != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "Failed to find span %d to write %d bytes\n", span_id, len); + return -1; + } + + gsm_data = span->signal_data; + status = ftdm_channel_write(gsm_data->dchan, (void *)buffer, len, &outsize); + if (status != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "Failed to write %d bytes to d-channel in span %s\n", len, span->name); + return -1; + } + +//#if LOG_SIG_DATA +// fprintf(stdout, "\r\n==================== len=%d outsize=%d \r\n", len, (int)outsize); +//#endif + + fflush(stdout); + return len; + + +} + +static void on_wat_span_status(unsigned char span_id, wat_span_status_t *status) +{ + switch (status->type) { + case WAT_SPAN_STS_READY: + { + ftdm_log(FTDM_LOG_INFO, "span %d: Ready\n", span_id); + } + break; + case WAT_SPAN_STS_SIGSTATUS: + { + if (status->sts.sigstatus == WAT_SIGSTATUS_UP) { + ftdm_log(FTDM_LOG_INFO, "span %d: Signaling is now up\n", span_id); + } else { + ftdm_log(FTDM_LOG_INFO, "span %d: Signaling is now down\n", span_id); + } + } + break; + case WAT_SPAN_STS_SIM_INFO_READY: + { + ftdm_log(FTDM_LOG_INFO, "span %d: SIM information ready\n", span_id); + } + break; + case WAT_SPAN_STS_ALARM: + { + ftdm_log(FTDM_LOG_INFO, "span %d: Alarm received\n", span_id); + } + break; + default: + { + ftdm_log(FTDM_LOG_INFO, "span %d: Unhandled span status notification %d\n", span_id, status->type); + } + break; + } +} + +void on_wat_con_ind(unsigned char span_id, uint8_t call_id, wat_con_event_t *con_event) +{ + //fprintf(stdout, "s%d: Incoming call (id:%d) Calling Number:%s Calling Name:\"%s\" type:%d plan:%d\n", span_id, call_id, con_event->calling_num.digits, con_event->calling_name, con_event->calling_num.type, con_event->calling_num.plan); + + ftdm_log(FTDM_LOG_INFO, "s%d: Incoming call (id:%d) Calling Number:%s Calling Name:\"%s\" type:%d plan:%d\n", span_id, call_id, con_event->calling_num.digits, con_event->calling_name, con_event->calling_num.type, con_event->calling_num.plan); + + ftdm_span_t *span = NULL; + //ftdm_status_t ftdm_status = FTDM_FAIL; + ftdm_gsm_span_data_t *gsm_data = NULL; + + if(!(span = GetSpanByID(span_id, &gsm_data))) { + return; + } + + gsm_data->call_id = call_id; + + #define ZERO_ARRAY(arr) memset(arr, 0, sizeof(arr)) + // cid date + { + time_t t; + struct tm *tmp; + t = time(NULL); + tmp = localtime(&t); + if (tmp == NULL) { + ZERO_ARRAY(gsm_data->bchan->caller_data.cid_date); + strftime(gsm_data->bchan->caller_data.cid_date, sizeof(gsm_data->bchan->caller_data.cid_date), "%y/%m/%d", tmp); + } + + } + + // cid name + ZERO_ARRAY(gsm_data->bchan->caller_data.cid_name); + strncpy(gsm_data->bchan->caller_data.cid_name, con_event->calling_name,sizeof(gsm_data->bchan->caller_data.cid_name)); + + // dnis + ZERO_ARRAY(gsm_data->bchan->caller_data.dnis.digits); + strncpy(gsm_data->bchan->caller_data.dnis.digits, con_event->calling_num.digits, FTDM_DIGITS_LIMIT); + + //collected + ZERO_ARRAY(gsm_data->bchan->caller_data.collected); + strncpy(gsm_data->bchan->caller_data.collected, con_event->calling_num.digits, FTDM_DIGITS_LIMIT); + + ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_RING); + + if (ftdm_channel_open_chan(gsm_data->bchan) != FTDM_SUCCESS) { + ftdm_log_chan(gsm_data->bchan, FTDM_LOG_ERROR, "Failed to open GSM b-channel of span %s!\n", span->name); + } + +} + + +ftdm_span_t *GetSpanByID(unsigned char span_id, ftdm_gsm_span_data_t **gsm_data) +{ + ftdm_status_t ftdm_status = FTDM_FAIL; + ftdm_span_t *span = NULL; + if(gsm_data) { + (*gsm_data) = NULL; + } + + ftdm_status = ftdm_span_find(span_id, &span); + if (ftdm_status != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "GetSpanByID - Failed to find span %d\n", span_id); + return NULL; + } + + if(gsm_data) { + (*gsm_data) = span->signal_data; + } + + return span; + +} + +void on_wat_con_sts(unsigned char span_id, uint8_t call_id, wat_con_status_t *status) +{ + + ftdm_span_t *span = NULL; + //ftdm_status_t ftdm_status = FTDM_FAIL; + ftdm_gsm_span_data_t *gsm_data = NULL; + + if(!(span = GetSpanByID(span_id, &gsm_data))) { + return; + } + + + + switch(status->type) { + + case WAT_CON_STATUS_TYPE_RINGING: + ftdm_log(FTDM_LOG_INFO, "on_wat_con_sts - WAT_CON_STATUS_TYPE_RINGING\r\n"); + ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_RINGING); + break; + + case WAT_CON_STATUS_TYPE_ANSWER: + ftdm_log(FTDM_LOG_INFO, "on_wat_con_sts - WAT_CON_STATUS_TYPE_ANSWER\r\n"); + ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); + break; + default: + ftdm_log(FTDM_LOG_INFO, "on_wat_con_sts - Unhandled state %d\n", span_id); + + }; + + + return; +} + +void on_wat_rel_ind(unsigned char span_id, uint8_t call_id, wat_rel_event_t *rel_event) +{ + ftdm_log(FTDM_LOG_INFO, "s%d: Call hangup (id:%d) cause:%d\n", span_id, call_id, rel_event->cause); + + ftdm_span_t *span = NULL; + //ftdm_status_t ftdm_status = FTDM_FAIL; + ftdm_gsm_span_data_t *gsm_data = NULL; + + if(!(span = GetSpanByID(span_id, &gsm_data))) { + return; + } + + ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_HANGUP); + + +} + +void on_wat_rel_cfm(unsigned char span_id, uint8_t call_id) +{ + ftdm_log(FTDM_LOG_INFO, "s%d: Call hangup complete (id:%d)\n", span_id, call_id); + ftdm_span_t *span = NULL; + //ftdm_status_t ftdm_status = FTDM_FAIL; + ftdm_gsm_span_data_t *gsm_data = NULL; + + if(!(span = GetSpanByID(span_id, &gsm_data))) { + return; + } + + switch(gsm_data->dchan->state) { + case FTDM_CHANNEL_STATE_UP: + ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_HANGUP); + break; + default: + ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_DOWN); + break; + } + +} + +void on_wat_sms_ind(unsigned char span_id, wat_sms_event_t *sms_event) +{ + //printf("on_wat_sms_ind\r\n"); + + ftdm_span_t *span = NULL; + ftdm_channel_t *ftdmchan; + + ftdm_gsm_span_data_t *gsm_data = NULL; + + if(!(span = GetSpanByID(span_id, &gsm_data))) { + return; + } + + ftdmchan = gsm_data->dchan; + + { + ftdm_sms_data_t sms_data; + memset(&sms_data, 0, sizeof(sms_data)); + + strncpy(sms_data.from, sms_event->from.digits, sizeof(sms_data.from)); + strncpy(sms_data.body, sms_event->content.data, sizeof(sms_data.body)); + + ftdm_sigmsg_t sigev; + memset(&sigev, 0, sizeof(sigev)); + sigev.event_id = FTDM_SIGEVENT_SMS; + sigev.channel = ftdmchan ; + gsm_data->dchan->caller_data.priv = (void *)&sms_data; + ftdm_span_send_signal(span, &sigev); + } +// SEND_STATE_SIGNAL(FTDM_SIGEVENT_SMS); + return; +} + +void on_wat_sms_sts(unsigned char span_id, uint8_t sms_id, wat_sms_status_t *status) +{ + + if(status->success) { + ftdm_log(FTDM_LOG_INFO, "Span %d SMS Send - OK\n", span_id ); + } + else { + ftdm_log(FTDM_LOG_CRIT, "Span %d SMS Send - FAIL (%s)\n", span_id, status->error); + + } + + + return; +} + + + +void on_wat_log(uint8_t level, char *fmt, ...) +{ + + int ftdm_level; + + va_list argptr; + va_start(argptr, fmt); + + char buff[10001]; + switch(level) { + case WAT_LOG_CRIT: ftdm_level = FTDM_LOG_LEVEL_CRIT; break; + case WAT_LOG_ERROR: ftdm_level = FTDM_LOG_LEVEL_ERROR; break; + default: + case WAT_LOG_WARNING: ftdm_level = FTDM_LOG_LEVEL_WARNING; break; + case WAT_LOG_INFO: ftdm_level = FTDM_LOG_LEVEL_INFO; break; + case WAT_LOG_NOTICE: ftdm_level = FTDM_LOG_LEVEL_NOTICE; break; + case WAT_LOG_DEBUG: ftdm_level = FTDM_LOG_LEVEL_DEBUG; break; + + }; + + + vsprintf(buff, fmt, argptr); + + ftdm_log(FTDM_PRE, ftdm_level, "WAT :%s", buff); + + va_end(argptr); +} + + +void *on_wat_malloc(size_t size) +{ + return ftdm_malloc(size); +} + +void *on_wat_calloc(size_t nmemb, size_t size) +{ + return ftdm_calloc(nmemb, size); +} + +void on_wat_free(void *ptr) +{ + ftdm_free(ptr); +} + +void on_wat_log_span(uint8_t span_id, uint8_t level, char *fmt, ...) +{ + int ftdm_level; +return; + va_list argptr; + va_start(argptr, fmt); + + char buff[10001]; + switch(level) { + case WAT_LOG_CRIT: ftdm_level = FTDM_LOG_LEVEL_CRIT; break; + case WAT_LOG_ERROR: ftdm_level = FTDM_LOG_LEVEL_ERROR; break; + default: + + case WAT_LOG_WARNING: ftdm_level = FTDM_LOG_LEVEL_WARNING; break; + case WAT_LOG_INFO: ftdm_level = FTDM_LOG_LEVEL_INFO; break; + case WAT_LOG_NOTICE: ftdm_level = FTDM_LOG_LEVEL_NOTICE; break; + case WAT_LOG_DEBUG: ftdm_level = FTDM_LOG_LEVEL_DEBUG; break; + + }; + + + vsprintf(buff, fmt, argptr); + + ftdm_log(FTDM_PRE, ftdm_level, "WAT span %d:%s", span_id, buff); + + va_end(argptr); + + +} + + +/* END wat callbacks */ + +/* span monitor thread */ +static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(gsm_outgoing_call) +{ + + return FTDM_SUCCESS; +} + +static ftdm_status_t ftdm_gsm_start(ftdm_span_t *span) +{ + if (wat_span_start(span->span_id)) { + ftdm_log(FTDM_LOG_ERROR, "Failed to start span %s!\n", span->name); + return FTDM_SUCCESS; + } + + return ftdm_thread_create_detached(ftdm_gsm_run, span); +} + +static ftdm_status_t ftdm_gsm_stop(ftdm_span_t *span) +{ + return FTDM_SUCCESS; +} + +static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_gsm_get_channel_sig_status) +{ + ftdm_log(FTDM_LOG_INFO, "\r\nftdm_gsm_get_channel_sig_status\r\n"); + + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { + *status = FTDM_SIG_STATE_UP; + } + else { + *status = FTDM_SIG_STATE_DOWN; + } + *status = FTDM_SIG_STATE_UP; + return FTDM_SUCCESS; + +} + +static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_gsm_set_channel_sig_status) +{ + return FTDM_SUCCESS; +} + +static FIO_SPAN_GET_SIG_STATUS_FUNCTION(ftdm_gsm_get_span_sig_status) +{ + *status = FTDM_SIG_STATE_UP; + return FTDM_SUCCESS; +} + +static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_gsm_set_span_sig_status) +{ + return FTDM_SUCCESS; +} + +static ftdm_state_map_t gsm_state_map = { + { + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_ANY_STATE, FTDM_END}, + {FTDM_CHANNEL_STATE_RESET, FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_RESET, FTDM_END}, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, + {FTDM_CHANNEL_STATE_RING, FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_RING, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_END}, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_END}, + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_END}, + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_UP, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END}, + }, + + /* Outbound states */ + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_ANY_STATE, FTDM_END}, + {FTDM_CHANNEL_STATE_RESET, FTDM_END} + }, + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_RESET, FTDM_END}, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END} + }, + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, + {FTDM_CHANNEL_STATE_DIALING, FTDM_END} + }, + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_RINGING, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_RINGING, FTDM_END} + }, + + + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_END}, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END} + }, + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_END} + }, + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_END} + }, + + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_UP, FTDM_END}, + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END} + }, + } +}; + +static ftdm_status_t ftdm_gsm_state_advance(ftdm_channel_t *ftdmchan) +{ + + ftdm_log_chan(ftdmchan, STATE_ADVANCE_LOG_LEVEL , "Executing state handler for %s\n", ftdm_channel_state2str(ftdmchan->state)); + + ftdm_channel_complete_state(ftdmchan); + + switch (ftdmchan->state) { + + /* starting an incoming call */ + case FTDM_CHANNEL_STATE_COLLECT: + { + + + } + break; + + /* starting an outgoing call */ + case FTDM_CHANNEL_STATE_DIALING: + { + uint32_t interval = 0; + + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Starting outgoing call with interval %d\n", interval); + + { + + ftdm_gsm_span_data_t *gsm_data; + gsm_data = ftdmchan->span->signal_data; + gsm_data->call_id = g_outbound_call_id++; + wat_con_event_t con_event; + memset(&con_event, 0, sizeof(con_event)); + ftdm_set_string(con_event.called_num.digits, ftdmchan->caller_data.dnis.digits); + ftdm_log(FTDM_LOG_DEBUG, "Dialing number %s\n", con_event.called_num.digits); + wat_con_req(ftdmchan->span->span_id, gsm_data->call_id , &con_event); + + SEND_STATE_SIGNAL(FTDM_SIGEVENT_DIALING); + + + } + + + } + break; + + /* incoming call was offered */ + case FTDM_CHANNEL_STATE_RING: + + /* notify the user about the new call */ + + ftdm_log(FTDM_LOG_INFO, "Answering Incomming Call\r\n"); + SEND_STATE_SIGNAL(FTDM_SIGEVENT_START); + + break; + + /* the call is making progress */ + case FTDM_CHANNEL_STATE_PROGRESS: + case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: + { + SEND_STATE_SIGNAL(FTDM_SIGEVENT_PROGRESS_MEDIA); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); + } + break; + + /* the call was answered */ + case FTDM_CHANNEL_STATE_UP: + { + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { + + SEND_STATE_SIGNAL(FTDM_SIGEVENT_UP); + } + else { + ftdm_gsm_span_data_t *gsm_data; + gsm_data = ftdmchan->span->signal_data; + wat_con_cfm(ftdmchan->span->span_id, gsm_data->call_id); + } + + + } + break; + + /* just got hangup */ + case FTDM_CHANNEL_STATE_HANGUP: + { + ftdm_gsm_span_data_t *gsm_data; + gsm_data = ftdmchan->span->signal_data; + wat_rel_req(ftdmchan->span->span_id, gsm_data->call_id); + gsm_data->call_id = 0; + SEND_STATE_SIGNAL(FTDM_SIGEVENT_STOP); + } + break; + + case FTDM_CHANNEL_STATE_TERMINATING: + { + SEND_STATE_SIGNAL(FTDM_SIGEVENT_STOP); + } + break; + + /* finished call for good */ + case FTDM_CHANNEL_STATE_DOWN: + { + ftdm_channel_t *closed_chan; + closed_chan = ftdmchan; + ftdm_channel_close(&closed_chan); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "State processing ended.\n"); + SEND_STATE_SIGNAL(FTDM_SIGEVENT_STOP); + } + break; + + /* INDICATE_RINGING doesn't apply to MFC/R2. maybe we could generate a tone */ + case FTDM_CHANNEL_STATE_RINGING: + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "RINGING indicated, ignoring it as it doesn't apply to MFC/R2\n"); + SEND_STATE_SIGNAL(FTDM_SIGEVENT_RINGING); + + break; + + /* put the r2 channel back to IDLE, close ftdmchan and set it's state as DOWN */ + case FTDM_CHANNEL_STATE_RESET: + { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "RESET indicated, putting the R2 channel back to IDLE\n"); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + } + break; + + default: + { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled channel state change: %s\n", ftdm_channel_state2str(ftdmchan->state)); + } + break; + } + + + return FTDM_SUCCESS; +} + + + +static ftdm_status_t init_wat_lib(void) +{ + if (wat_lib_initialized) { + return FTDM_SUCCESS; + } + + wat_interface_t wat_interface; + + ftdm_log(FTDM_LOG_DEBUG, "Registering interface to WAT Library...\n"); + + memset(&wat_interface, 0, sizeof(wat_interface)); + wat_interface.wat_span_write = on_wat_span_write; + + wat_interface.wat_log = on_wat_log; + wat_interface.wat_log_span = on_wat_log_span; + wat_interface.wat_malloc = on_wat_malloc; + wat_interface.wat_calloc = on_wat_calloc; + wat_interface.wat_free = on_wat_free; + + wat_interface.wat_con_ind = on_wat_con_ind; + wat_interface.wat_con_sts = on_wat_con_sts; + wat_interface.wat_rel_ind = on_wat_rel_ind; + wat_interface.wat_rel_cfm = on_wat_rel_cfm; + wat_interface.wat_sms_ind = on_wat_sms_ind; + wat_interface.wat_sms_sts = on_wat_sms_sts; + wat_interface.wat_span_sts = on_wat_span_status; + + if (wat_register(&wat_interface)) { + ftdm_log(FTDM_LOG_DEBUG, "Failed registering interface to WAT library ...\n"); + return FTDM_FAIL; + } + + ftdm_log(FTDM_LOG_DEBUG, "Registered interface to WAT library\n"); + + wat_lib_initialized = 1; + return FTDM_SUCCESS; +} + + +static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_gsm_configure_span_signaling) +{ + wat_span_config_t span_config; + ftdm_gsm_span_data_t *gsm_data = NULL; + ftdm_iterator_t *chaniter = NULL; + ftdm_iterator_t *citer = NULL; + ftdm_channel_t *ftdmchan = NULL; + ftdm_channel_t *dchan = NULL; + ftdm_channel_t *bchan = NULL; + + unsigned paramindex = 0; + const char *var = NULL; + const char *val = NULL; + + /* libwat is smart enough to set good default values for the timers if they are set to 0 */ + memset(&span_config, 0, sizeof(span_config)); + + /* set some span defaults */ + span_config.moduletype = WAT_MODULE_TELIT; + + if (FTDM_SUCCESS != init_wat_lib()) { + return FTDM_FAIL; + } + + if (!sig_cb) { + ftdm_log(FTDM_LOG_ERROR, "No signaling callback provided\n"); + return FTDM_FAIL; + } + + if (span->signal_type) { + ftdm_log(FTDM_LOG_ERROR, "Span %s is already configured for another signaling\n", span->name); + return FTDM_FAIL; + } + + /* verify the span has one d-channel */ + chaniter = ftdm_span_get_chan_iterator(span, NULL); + + if (!chaniter) { + ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); + return FTDM_FAIL; + } + + citer = ftdm_span_get_chan_iterator(span, chaniter); + for ( ; citer; citer = ftdm_iterator_next(citer)) { + ftdmchan = ftdm_iterator_current(citer); + + if ((NULL == dchan) && FTDM_IS_DCHAN(ftdmchan)) { + dchan = ftdmchan; + } + if ((NULL == bchan) && FTDM_IS_VOICE_CHANNEL(ftdmchan)) { + bchan = ftdmchan; + } + + } + ftdm_iterator_free(chaniter); + + if (!dchan) { + ftdm_log(FTDM_LOG_CRIT, "Could not find a d-channel for GSM span %s!\n", span->name); + return FTDM_FAIL; + } + if (!bchan) { + ftdm_log(FTDM_LOG_CRIT, "Could not find a b-channel for GSM span %s!\n", span->name); + return FTDM_FAIL; + } + + + + + + gsm_data = ftdm_calloc(1, sizeof(*gsm_data)); + if (!gsm_data) { + return FTDM_FAIL; + } + gsm_data->dchan = dchan; + gsm_data->bchan = bchan; + + //sprintf(gsm_data->dchan->chan_name, "%s\t\n", "GSM dchan"); + //sprintf(gsm_data->bchan->chan_name, "%s\r\n", "GSM bchan"); + + for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { + var = ftdm_parameters[paramindex].var; + val = ftdm_parameters[paramindex].val; + if (!ftdm_strlen_zero_buf(val)) { + ftdm_log(FTDM_LOG_WARNING, "Ignoring empty GSM parameter %s for span %s\n", var, span->name); + continue; + } + ftdm_log(FTDM_LOG_DEBUG, "Reading GSM parameter %s=%s for span %s\n", var, val, span->name); + if (!strcasecmp(var, "moduletype")) { + span_config.moduletype = wat_str2wat_moduletype(val); + if (span_config.moduletype == WAT_MODULE_INVALID) { + ftdm_log(FTDM_LOG_DEBUG, "Unknown GSM module type %s for span %s\n", val, span->name); + continue; + } + ftdm_log(FTDM_LOG_DEBUG, "Configuring GSM span %s with moduletype %s\n", span->name, val); + } else { + ftdm_log(FTDM_LOG_ERROR, "Ignoring unknown GSM parameter '%s'", var); + } + } + + /* Bind function pointers for control operations */ + span->start = ftdm_gsm_start; + span->stop = ftdm_gsm_stop; + span->sig_read = NULL; + span->sig_write = NULL; + + span->signal_cb = sig_cb; + span->signal_type = FTDM_SIGTYPE_GSM; + span->signal_data = gsm_data; /* Gideon, plz fill me with gsm span specific data (you allocate and free) */ + span->outgoing_call = gsm_outgoing_call; + span->get_span_sig_status = ftdm_gsm_get_span_sig_status; + span->set_span_sig_status = ftdm_gsm_set_span_sig_status; + span->get_channel_sig_status = ftdm_gsm_get_channel_sig_status; + span->set_channel_sig_status = ftdm_gsm_set_channel_sig_status; + + //printf("\r\nspan->state_map = &gsm_state_map;\r\n"); + span->state_map = &gsm_state_map; + span->state_processor = ftdm_gsm_state_advance; + + /* use signals queue */ + ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); + ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE); + + /* we can skip states (going straight from RING to UP) */ + ftdm_set_flag(span, FTDM_SPAN_USE_SKIP_STATES); + + gsm_data->span = span; + +#if 0 + /* setup the scheduler (create if needed) */ + snprintf(schedname, sizeof(schedname), "ftmod_r2_%s", span->name); + ftdm_assert(ftdm_sched_create(&r2data->sched, schedname) == FTDM_SUCCESS, "Failed to create schedule!\n"); + spanpvt->sched = r2data->sched; +#endif + + +fprintf(stdout, "Configuring wat span %d %s \r\n", span->span_id, span->name); + if (wat_span_config(span->span_id, &span_config)) { + ftdm_log(FTDM_LOG_ERROR, "Failed to configure span %s for GSM signaling!!\n", span->name); + return FTDM_FAIL; + } + + { + int codec = FTDM_CODEC_SLIN; + int interval = 20; + + ftdm_channel_command(gsm_data->bchan, FTDM_COMMAND_SET_NATIVE_CODEC, &codec); + ftdm_channel_command(gsm_data->bchan, FTDM_COMMAND_SET_CODEC, &codec); + ftdm_channel_command(gsm_data->bchan, FTDM_COMMAND_SET_INTERVAL, &interval); + } + + return FTDM_SUCCESS; + +} + +#define GSM_POLL_INTERVAL_MS 20 +static void *ftdm_gsm_run(ftdm_thread_t *me, void *obj) +{ + + ftdm_log(FTDM_LOG_INFO,"ftdm_gsm_run\r\n"); + + ftdm_channel_t *ftdmchan = NULL; + ftdm_span_t *span = (ftdm_span_t *) obj; + ftdm_gsm_span_data_t *gsm_data = NULL; + ftdm_interrupt_t *data_sources[2] = {NULL, NULL}; + int waitms = 0; + + gsm_data = span->signal_data; + + ftdm_assert_return(gsm_data != NULL, NULL, "No gsm data attached to span\n"); + + ftdm_log(FTDM_LOG_DEBUG, "GSM monitor thread for span %s started\n", span->name); + if (!gsm_data->dchan || ftdm_channel_open_chan(gsm_data->dchan) != FTDM_SUCCESS) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to open GSM d-channel of span %s!\n", span->name); + gsm_data->dchan = NULL; + goto done; + } + + + + + while (ftdm_running()) { + + wat_span_run(span->span_id); + + waitms = wat_span_schedule_next(span->span_id); + if (waitms > GSM_POLL_INTERVAL_MS) { + waitms = GSM_POLL_INTERVAL_MS; + } + +///////////////////// + + + { + ftdm_wait_flag_t flags = FTDM_READ | FTDM_EVENTS; + ftdm_status_t status = ftdm_channel_wait(gsm_data->dchan, &flags, waitms); + + + /* double check that this channel has a state change pending */ + ftdm_channel_lock(gsm_data->bchan); + ftdm_channel_advance_states(gsm_data->bchan); + + if(FTDM_SUCCESS == status ) { + + if(flags &FTDM_READ ) { + char buffer[1025]; + int n = 0, m = 0; + memset(buffer, 0, sizeof(buffer)); + + n = read_channel(gsm_data->dchan, buffer, sizeof(buffer)-1); + m = strlen(buffer); + wat_span_process_read(span->span_id, buffer, m); +#if LOG_SIG_DATA + printf("<<======================= incomming data len = %d, %s\r\n", n, buffer); +#endif + + } + } + + ftdm_channel_advance_states(gsm_data->bchan); + + ftdm_channel_unlock(gsm_data->bchan); + + + } + + + + + ftdm_span_trigger_signals(span); + + + } + +done: + if (data_sources[0]) { + ftdm_interrupt_destroy(&data_sources[0]); + } + + ftdm_log(FTDM_LOG_DEBUG, "GSM thread ending.\n"); + + return NULL; +} + + + +static FIO_IO_LOAD_FUNCTION(ftdm_gsm_io_init) +{ + assert(fio != NULL); + memset(&g_ftdm_gsm_interface, 0, sizeof(g_ftdm_gsm_interface)); + + g_ftdm_gsm_interface.name = "gsm"; + g_ftdm_gsm_interface.api = ftdm_gsm_api; + + *fio = &g_ftdm_gsm_interface; + + return (FTDM_SUCCESS); +} +static FIO_SIG_LOAD_FUNCTION(ftdm_gsm_init) +{ + /* this is called on module load */ + return FTDM_SUCCESS; +} + +static FIO_SIG_UNLOAD_FUNCTION(ftdm_gsm_destroy) +{ + /* this is called on module unload */ + return FTDM_SUCCESS; +} + +EX_DECLARE_DATA ftdm_module_t ftdm_module = { + /* .name */ "gsm", + /* .io_load */ ftdm_gsm_io_init, + /* .io_unload */ NULL, + /* .sig_load */ ftdm_gsm_init, + /* .sig_configure */ NULL, + /* .sig_unload */ ftdm_gsm_destroy, + /* .configure_span_signaling */ ftdm_gsm_configure_span_signaling +}; + + +/* 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: + */ + + +/********************************************************************************/ +/* */ +/* COMMAND HANDLERS */ +/* */ +/********************************************************************************/ + + +// Version Command Handler +COMMAND_HANDLER(version) +{ + uint8_t current = 0, revision = 0, age = 0; + wat_version(¤t, &revision, &age); + stream->write_function(stream, "libwat version: %d.%d.%d\n", current, revision, age); + stream->write_function(stream, "+OK.\n"); + return FTDM_SUCCESS; +} + + +// Status Command Handler +COMMAND_HANDLER(status) +{ + int span_id = 0; + ftdm_span_t *span = NULL; + const wat_chip_info_t *chip_info = NULL; + const wat_sim_info_t *sim_info = NULL; + const wat_net_info_t *net_info = NULL; + const wat_sig_info_t *sig_info = NULL; + const wat_pin_stat_t *pin_stat = NULL; + + + span_id = atoi(argv[0]); + if (ftdm_span_find_by_name(argv[0], &span) != FTDM_SUCCESS && ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { + stream->write_function(stream, "-ERR Failed to find GSM span '%s'\n", argv[1]); + return FTDM_FAIL; + } + + if (!span || !span->signal_data || (span->start != ftdm_gsm_start)) { + stream->write_function(stream, "-ERR '%s' is not a valid GSM span\n", argv[1]); + return FTDM_FAIL; + } + + chip_info = wat_span_get_chip_info(span->span_id); + sim_info = wat_span_get_sim_info(span->span_id); + net_info = wat_span_get_net_info(span->span_id); + sig_info = wat_span_get_sig_info(span->span_id); + pin_stat = wat_span_get_pin_info(span->span_id); + + stream->write_function(stream, "Span %d (%s):\n", span->span_id, span->name); + + stream->write_function(stream, "CHIP type - %s (%s), revision %s, serial %s \n", + chip_info->manufacturer, + chip_info->model, + chip_info->revision, + chip_info->serial); + + stream->write_function(stream, "SIM - Subscriber type %s, imsi %s\n", sim_info->subscriber_type, sim_info->imsi); + + stream->write_function(stream, "Subscriber - Number %s, Plan %s, validity %s\n", + sim_info->subscriber.digits, + wat_number_type2str(sim_info->subscriber.type), + wat_number_plan2str(sim_info->subscriber.plan), + wat_number_validity2str(sim_info->subscriber.validity)); + + stream->write_function(stream, "Network - status %s, Area Code %d, Cell ID %d, Operator %s\n", + wat_net_stat2str(net_info->stat), net_info->lac, net_info->ci, net_info->operator_name); + + + stream->write_function(stream, "\n"); + + stream->write_function(stream, "+OK.\n"); + + return FTDM_SUCCESS; +} + +// SMS Command Handler +COMMAND_HANDLER(sms) +{ + int span_id = 0,i; + ftdm_span_t *span = NULL; + wat_sms_event_t sms; + + + span_id = atoi(argv[0]); + if (ftdm_span_find_by_name(argv[0], &span) != FTDM_SUCCESS && ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { + stream->write_function(stream, "-ERR Failed to find GSM span '%s'\n", argv[1]); + return FTDM_FAIL; + } + + if (!span || !span->signal_data || (span->start != ftdm_gsm_start)) { + stream->write_function(stream, "-ERR '%s' is not a valid GSM span\n", argv[1]); + return FTDM_FAIL; + } + + memset(&sms, 0, sizeof(sms)); + + strcpy(sms.to.digits, argv[1]); + sms.type = WAT_SMS_TXT; + sms.content.data[0] = '\0'; + for(i=2;ispan_id, g_outbound_call_id++ , &sms)) { + stream->write_function(stream, "Failed to Send SMS \n"); + } + else { + stream->write_function(stream, "SMS Sent.\n"); + } + return FTDM_SUCCESS; +} + + + +// command map +struct { + const char*CMD; // command + int Argc; // minimum args + fCMD Handler; // handling function +} + GSM_COMMANDS[] = { + COMMAND(version, 0), + COMMAND(status, 1), + COMMAND(sms, 3) + }; + +// Commnand API entry point +static FIO_API_FUNCTION(ftdm_gsm_api) +{ + + char *mycmd = NULL, *argv[10] = { 0 }; + int argc = 0; + int i; + ftdm_status_t status = FTDM_FAIL; + ftdm_status_t syntax = FTDM_FAIL; + + + if (data) { + mycmd = ftdm_strdup(data); + argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + if(argc > 0) { + for(i=0;i= GSM_COMMANDS[i].Argc) { + syntax = FTDM_SUCCESS; + status = GSM_COMMANDS[i].Handler(stream, &argv[1], argc-1); + + } + + break; + } + + } + } + + if(FTDM_SUCCESS != syntax) { + stream->write_function(stream, "%s", FT_SYNTAX); + } + else + if(FTDM_SUCCESS != status) { + stream->write_function(stream, "%s Command Failed\r\n", GSM_COMMANDS[i].CMD); + } + ftdm_safe_free(mycmd); + + return FTDM_SUCCESS; +} + + diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c index 4abddf16e1..99ff253835 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, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -469,10 +469,15 @@ static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request) } if (new_chan && new_chan->state == FTDM_CHANNEL_STATE_DOWN) { - isdn_data->channels_local_crv[gen->CRV] = new_chan; + struct Q931_Call *call = NULL; + memset(&new_chan->caller_data, 0, sizeof(new_chan->caller_data)); ftdm_set_flag(new_chan, FTDM_CHANNEL_OUTBOUND); ftdm_set_state_locked(new_chan, FTDM_CHANNEL_STATE_DIALING); + + call = Q931GetCallByCRV(&isdn_data->q931, gen->CRV); + Q931CallSetPrivate(call, new_chan); + switch(gen->MesType) { case Q931mes_ALERTING: new_chan->init_state = FTDM_CHANNEL_STATE_PROGRESS_MEDIA; @@ -539,21 +544,17 @@ static void ftdm_isdn_call_event(struct Q931_Call *call, struct Q931_CallEvent * { Q931_TrunkInfo_t *trunk = NULL; ftdm_isdn_data_t *isdn_data = NULL; - ftdm_span_t *zspan = NULL; + ftdm_span_t *span = priv; + + assert(span); assert(call); assert(event); trunk = Q931CallGetTrunk(call); assert(trunk); - zspan = Q931CallGetPrivate(call); - if (!zspan) { - zspan = priv; - Q931CallSetPrivate(call, zspan); - } - assert(zspan); - - isdn_data = zspan->signal_data; + isdn_data = span->signal_data; + assert(isdn_data); if (Q931CallIsGlobal(call)) { /* @@ -575,7 +576,7 @@ static void ftdm_isdn_call_event(struct Q931_Call *call, struct Q931_CallEvent * * Try to get associated zap channel * and init sigmsg struct if there is one */ - ftdmchan = Q931CallIsOutgoing(call) ? isdn_data->channels_local_crv[call_crv] : isdn_data->channels_remote_crv[call_crv]; + ftdmchan = Q931CallGetPrivate(call); if (ftdmchan) { memset(&sig, 0, sizeof(ftdm_sigmsg_t)); sig.chan_id = ftdmchan->chan_id; @@ -598,7 +599,9 @@ static void ftdm_isdn_call_event(struct Q931_Call *call, struct Q931_CallEvent * return; } - if (ftdm_channel_get_state(ftdmchan) != FTDM_CHANNEL_STATE_DOWN) { + if (ftdm_channel_get_state(ftdmchan) != FTDM_CHANNEL_STATE_DOWN && + ftdm_channel_get_state(ftdmchan) != FTDM_CHANNEL_STATE_HANGUP_COMPLETE) + { ftdm_log(FTDM_LOG_DEBUG, "Channel %d:%d not in DOWN state, cleaning up\n", ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan)); @@ -763,29 +766,23 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic assert(span != NULL); assert(isdn_data != NULL); - /* - * Support code for the new event handling system - * Remove this as soon as we have the new api to set up calls - */ -#ifdef __OLD__ - if (gen->CRV) { - struct Q931_Call *call; - - call = Q931GetCallByCRV(&isdn_data->q931, gen->CRV); - if (call && !Q931CallGetPrivate(call)) { - ftdm_log(FTDM_LOG_DEBUG, "Storing reference to current span in call %d [0x%x]\n", gen->CRV, gen->CRV); - Q931CallSetPrivate(call, span); + /* ftdm channel is stored in call private */ + if (call) { + ftdmchan = Q931CallGetPrivate(call); + if (!ftdmchan) { + ftdm_log(FTDM_LOG_DEBUG, "[s%d] No channel associated to call [%#x] private\n", + ftdm_span_get_id(span), Q931CallGetCRV(call)); } } -#else - if (call && !Q931CallGetPrivate(call)) { - ftdm_log(FTDM_LOG_DEBUG, "Storing reference to current span in call %d [0x%x]\n", gen->CRV, gen->CRV); - Q931CallSetPrivate(call, span); - } -#endif - ftdm_log(FTDM_LOG_DEBUG, "Yay I got an event! Type:[%02x] Size:[%d] CRV: %d (%#hx, CTX: %s)\n", gen->MesType, gen->Size, gen->CRV, gen->CRV, gen->CRVFlag ? "Terminator" : "Originator"); -#ifdef __TODO_OR_REMOVE__ + ftdm_log(FTDM_LOG_DEBUG, "Yay I got an event! Type:[%02x] Size:[%d] CRV: %d (%#hx, CTX: %s)\n", + gen->MesType, gen->Size, gen->CRV, gen->CRV, gen->CRVFlag ? "Terminator" : "Originator"); + +#ifdef __TODO__ + /* + * This code block is needed for isdn_channel_request() + * isdn_data->outbound_crv has been removed so another way to pass data around is required + */ if (gen->CRVFlag && (caller_data = isdn_data->outbound_crv[gen->CRV])) { if (chan_id) { caller_data->chan_id = chan_id; @@ -808,18 +805,10 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic return 0; } #endif - - if (gen->CRVFlag) { - ftdmchan = isdn_data->channels_local_crv[gen->CRV]; - } else { - ftdmchan = isdn_data->channels_remote_crv[gen->CRV]; - } - - ftdm_log(FTDM_LOG_DEBUG, "ftdmchan %x (%d:%d) source isdn_data->channels_%s_crv[%#hx]\n", + ftdm_log(FTDM_LOG_DEBUG, "ftdmchan %p (%d:%d) via CRV[%#hx]\n", ftdmchan, ((ftdmchan) ? ftdm_channel_get_span_id(ftdmchan) : -1), ((ftdmchan) ? ftdm_channel_get_id(ftdmchan) : -1), - ((gen->CRVFlag) ? "local" : "remote"), gen->CRV); if (gen->ProtDisc == 3) { @@ -874,12 +863,14 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic uint32_t i; for (i = 1; i < ftdm_span_get_chan_count(span); i++) { + ftdmchan = ftdm_span_get_channel(span, chan_id); + /* Skip channels that are down and D-Channels (#OpenZAP-39) */ - if (ftdm_channel_get_state(span->channels[i]) == FTDM_CHANNEL_STATE_DOWN || - ftdm_channel_get_type(span->channels[i]) == FTDM_CHAN_TYPE_DQ921) + if (ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DOWN || + ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_DQ921) continue; - ftdm_set_state_locked(span->channels[i], FTDM_CHANNEL_STATE_RESTART); + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART); } } } @@ -898,6 +889,10 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); } } + else if (gen->MesType == Q931mes_RELEASE_COMPLETE && ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DIALTONE) { + /* Go DOWN */ + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + } else if ((gen->MesType == Q931mes_RELEASE && ftdm_channel_get_state(ftdmchan) <= FTDM_CHANNEL_STATE_UP) || (gen->MesType == Q931mes_RELEASE_COMPLETE && ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DIALING)) { @@ -906,7 +901,6 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic */ Q931ie_Cause *cause = Q931GetIEPtr(gen->Cause, gen->buf); ftdm_sigmsg_t sig; - ftdm_status_t status; memset(&sig, 0, sizeof(sig)); sig.span_id = ftdm_channel_get_span_id(ftdmchan); @@ -915,14 +909,15 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic sig.channel->caller_data.hangup_cause = (cause) ? cause->Value : FTDM_CAUSE_NORMAL_UNSPECIFIED; sig.event_id = FTDM_SIGEVENT_STOP; - status = ftdm_span_send_signal(span, &sig); + ftdm_span_send_signal(span, &sig); ftdm_log(FTDM_LOG_DEBUG, "Received %s in state %s, requested hangup for channel %d:%d\n", what, ftdm_channel_get_state_str(ftdmchan), ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan)); } else { - ftdm_log(FTDM_LOG_DEBUG, "Ignoring %s on channel %d\n", what, ftdm_channel_get_id(ftdmchan)); + ftdm_log(FTDM_LOG_DEBUG, "Ignoring %s on channel %d in state %s\n", what, + ftdm_channel_get_id(ftdmchan), ftdm_channel_get_state_str(ftdmchan)); } } else { ftdm_log(FTDM_LOG_CRIT, "Received %s with no matching channel %d\n", what, chan_id); @@ -983,7 +978,7 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic int fail_cause = 0; int fail = 1; - if (ftdmchan && ftdmchan == isdn_data->channels_remote_crv[gen->CRV]) { + if (ftdmchan && ftdmchan == Q931CallGetPrivate(call)) { ftdm_log(FTDM_LOG_INFO, "Duplicate SETUP message(?) for Channel %d:%d ~ %d:%d in state %s [ignoring]\n", ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan), @@ -1039,7 +1034,7 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic } } - if (!callednum || !strlen((char *)callednum->Digit)) { + if (!callednum || ftdm_strlen_zero((char *)callednum->Digit)) { if (FTDM_SPAN_IS_NT(span)) { ftdm_log(FTDM_LOG_NOTICE, "No destination number found, assuming overlap dial\n"); overlap_dial++; @@ -1080,7 +1075,6 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic if (ftdmchan && ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DOWN) { ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(ftdmchan); - isdn_data->channels_remote_crv[gen->CRV] = ftdmchan; memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); if (ftdmchan->call_data) { @@ -1095,19 +1089,12 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic if (!overlap_dial) { isdn_get_number(callednum, caller_data->dnis.digits); } -#ifdef __TODO_OR_REMOVE__ - ftdmchan->caller_data.CRV = gen->CRV; -#endif -#if 0 /* FIXME */ - if (cplen > sizeof(caller_data->raw_data)) { - cplen = sizeof(caller_data->raw_data); - } -#endif + + ftdmchan->caller_data.call_reference = gen->CRV; + Q931CallSetPrivate(call, ftdmchan); + gen->CRVFlag = !(gen->CRVFlag); -#if 0 /* FIXME */ - memcpy(caller_data->raw_data, msg, cplen); - caller_data->raw_data_len = cplen; -#endif + fail = 0; } } @@ -1134,7 +1121,7 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic } if (ftdmchan) { - ftdm_log(FTDM_LOG_CRIT, "Channel is busy\n"); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Channel is busy\n"); } else { ftdm_log(FTDM_LOG_CRIT, "Failed to open channel for new setup message\n"); } @@ -1191,7 +1178,7 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic case Q931mes_CALL_PROCEEDING: { if (ftdmchan) { - ftdm_log(FTDM_LOG_CRIT, "Received CALL PROCEEDING message for channel %d\n", ftdm_channel_get_id(ftdmchan)); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Received CALL PROCEEDING message for channel\n"); ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); } else { ftdm_log(FTDM_LOG_CRIT, "Received CALL PROCEEDING with no matching channel %d\n", chan_id); @@ -1201,7 +1188,7 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic case Q931mes_CONNECT_ACKNOWLEDGE: { if (ftdmchan) { - ftdm_log(FTDM_LOG_DEBUG, "Received CONNECT_ACK message for channel %d\n", ftdm_channel_get_id(ftdmchan)); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Received CONNECT_ACK message for channel\n"); } else { ftdm_log(FTDM_LOG_DEBUG, "Received CONNECT_ACK with no matching channel %d\n", chan_id); } @@ -1211,7 +1198,7 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic case Q931mes_INFORMATION: { if (ftdmchan) { - ftdm_log(FTDM_LOG_CRIT, "Received INFORMATION message for channel %d\n", ftdm_channel_get_id(ftdmchan)); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Received INFORMATION message for channel\n"); if (ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DIALTONE) { char digit = '\0'; @@ -1305,19 +1292,25 @@ static int ftdm_isdn_921_21(void *pvt, L2UCHAR *msg, L2INT mlen) static __inline__ void state_advance(ftdm_channel_t *ftdmchan) { - ftdm_isdn_data_t *isdn_data = ftdmchan->span->signal_data; ftdm_span_t *span = ftdm_channel_get_span(ftdmchan); + ftdm_isdn_data_t *isdn_data = NULL; ftdm_sigmsg_t sig; ftdm_status_t status; -#if 1 /* FIXME caller_data.raw_data does not exist anymore, see docs/variables.txt for more info */ Q931mes_Generic empty_gen; Q931mes_Generic *gen = &empty_gen; - - memset(&empty_gen, 0, sizeof(empty_gen)) ; -#else - Q931mes_Generic *gen = (Q931mes_Generic *) ftdmchan->caller_data.raw_data; -#endif + struct Q931_Call *call = NULL; + + Q931InitMesGeneric(gen); + + isdn_data = span->signal_data; + assert(isdn_data); + + call = Q931GetCallByCRV(&isdn_data->q931, ftdmchan->caller_data.call_reference); + if (call) { + gen->CRV = Q931CallGetCRV(call); + gen->CRVFlag = Q931CallGetDirection(call) == Q931_DIRECTION_INBOUND ? 1 : 0; + } ftdm_log(FTDM_LOG_DEBUG, "%d:%d STATE [%s]\n", ftdm_channel_get_span_id(ftdmchan), @@ -1329,17 +1322,17 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) sig.chan_id = ftdm_channel_get_id(ftdmchan); sig.channel = ftdmchan; + /* Acknowledge channel state change */ + ftdm_channel_complete_state(ftdmchan); + switch (ftdm_channel_get_state(ftdmchan)) { case FTDM_CHANNEL_STATE_DOWN: { if (gen->CRV) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - isdn_data->channels_local_crv[gen->CRV] = NULL; - } else { - isdn_data->channels_remote_crv[gen->CRV] = NULL; - } + Q931CallSetPrivate(call, NULL); Q931ReleaseCRV(&isdn_data->q931, gen->CRV); } + ftdmchan->caller_data.call_reference = 0; ftdm_channel_close(&ftdmchan); } break; @@ -1348,15 +1341,10 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS; if ((status = ftdm_span_send_signal(ftdm_channel_get_span(ftdmchan), &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); } } else { - int crv = gen->CRV; - - Q931InitMesGeneric(gen); gen->MesType = Q931mes_CALL_PROCEEDING; - gen->CRV = crv; - gen->CRVFlag = 1; /* inbound */ if (FTDM_SPAN_IS_NT(ftdm_channel_get_span(ftdmchan))) { Q931ie_ChanID ChanID; @@ -1396,7 +1384,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_START; if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); } } } @@ -1406,7 +1394,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; sig.event_id = FTDM_SIGEVENT_RESTART; status = ftdm_span_send_signal(span, &sig); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); } break; case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: @@ -1414,17 +1402,16 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); } } else { if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); return; } } gen->MesType = Q931mes_ALERTING; - gen->CRVFlag = 1; /* inbound call */ Q931Rx43(&isdn_data->q931, gen, gen->Size); } } @@ -1434,21 +1421,19 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_UP; if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); } } else { if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); return; } } + gen->MesType = Q931mes_CONNECT; - gen->BearerCap = 0; - gen->CRVFlag = 1; /* inbound call */ -#if 0 /* FIXME */ - Q931Rx43(&isdn_data->q931, gen, ftdmchan->caller_data.raw_data_len); -#endif + + Q931Rx43(&isdn_data->q931, gen, gen->Size); } } break; @@ -1560,19 +1545,18 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) gen->HLComp = Q931AppendIE(gen, (L3UCHAR *) &HLComp); Q931Rx43(&isdn_data->q931, gen, gen->Size); - isdn_data->channels_local_crv[gen->CRV] = ftdmchan; /* * Support code for the new event handling system * Remove this as soon as we have the new api to set up calls */ if (gen->CRV) { - struct Q931_Call *call; - call = Q931GetCallByCRV(&isdn_data->q931, gen->CRV); if (call) { ftdm_log(FTDM_LOG_DEBUG, "Storing reference to current span in call %d [0x%x]\n", gen->CRV, gen->CRV); - Q931CallSetPrivate(call, ftdm_channel_get_span(ftdmchan)); + + Q931CallSetPrivate(call, ftdmchan); + ftdmchan->caller_data.call_reference = gen->CRV; } } } @@ -1585,7 +1569,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) Q931Rx43(&isdn_data->q931, gen, gen->Size); } - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); } break; case FTDM_CHANNEL_STATE_HANGUP: @@ -1593,9 +1577,8 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(ftdmchan); Q931ie_Cause cause; - ftdm_log(FTDM_LOG_DEBUG, "Hangup: Direction %s\n", ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound"); - - gen->CRVFlag = ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? 0 : 1; + ftdm_log(FTDM_LOG_DEBUG, "Hangup: Call direction %s\n", + ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound"); cause.IEId = Q931ie_CAUSE; cause.Size = sizeof(Q931ie_Cause); @@ -1612,7 +1595,13 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) * inbound call [was: number unknown (= not found in routing state)] * (in Q.931 spec terms: Reject request) */ - gen->MesType = Q931mes_RELEASE_COMPLETE; + if (!FTDM_SPAN_IS_NT(span)) { + gen->MesType = Q931mes_RELEASE_COMPLETE; /* TE mode: Reject call */ + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + } else { + gen->MesType = Q931mes_DISCONNECT; /* NT mode: Disconnect and wait */ + //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); + } //cause.Value = (unsigned char) FTDM_CAUSE_UNALLOCATED; cause.Value = (unsigned char) caller_data->hangup_cause; @@ -1621,8 +1610,8 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) Q931Rx43(&isdn_data->q931, gen, gen->Size); /* we're done, release channel */ - //ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + ////ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); + //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); } else if (ftdm_channel_get_last_state(ftdmchan) <= FTDM_CHANNEL_STATE_PROGRESS) { /* @@ -1636,7 +1625,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) Q931Rx43(&isdn_data->q931, gen, gen->Size); /* this will be triggered by the RELEASE_COMPLETE reply */ - /* ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); */ + /* ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); */ } else { /* @@ -1653,13 +1642,13 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) break; case FTDM_CHANNEL_STATE_TERMINATING: { - ftdm_log(FTDM_LOG_DEBUG, "Terminating: Direction %s\n", ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound"); + ftdm_log(FTDM_LOG_DEBUG, "Terminating: Call direction %s\n", + ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound"); sig.event_id = FTDM_SIGEVENT_STOP; status = ftdm_span_send_signal(span, &sig); gen->MesType = Q931mes_RELEASE; - gen->CRVFlag = ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? 0 : 1; Q931Rx43(&isdn_data->q931, gen, gen->Size); } default: @@ -1679,11 +1668,8 @@ static __inline__ void check_state(ftdm_span_t *span) if (ftdm_test_flag(chan, FTDM_CHANNEL_STATE_CHANGE)) { ftdm_channel_lock(chan); - ftdm_clear_flag(chan, FTDM_CHANNEL_STATE_CHANGE); state_advance(chan); - ftdm_channel_complete_state(chan); - ftdm_channel_unlock(chan); } } @@ -1820,7 +1806,6 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) teletone_generation_session_t ts = {{{{0}}}};; unsigned char frame[1024]; int x, interval; - int offset = 0; ftdm_log(FTDM_LOG_DEBUG, "ISDN tones thread starting.\n"); ftdm_set_flag(isdn_data, FTDM_ISDN_TONES_RUNNING); @@ -1865,6 +1850,7 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) for (x = 1; x <= ftdm_span_get_chan_count(span); x++) { ftdm_channel_t *chan = ftdm_span_get_channel(span, x); ftdm_size_t len = sizeof(frame), rlen; + ftdm_isdn_bchan_data_t *data = chan->call_data; if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { continue; @@ -1878,7 +1864,6 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) switch (ftdm_channel_get_state(chan)) { case FTDM_CHANNEL_STATE_DIALTONE: { - ftdm_isdn_bchan_data_t *data = (ftdm_isdn_bchan_data_t *)chan->call_data; ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); /* check overlap dial timeout first before generating tone */ @@ -1951,13 +1936,24 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) continue; } + /* + * Teletone operates on SLIN data (2 bytes per sample). + * Convert the length of non-SLIN codecs, so we read + * the right amount of samples from the buffer. + */ if (chan->effective_codec != FTDM_CODEC_SLIN) { len *= 2; } /* seek to current offset */ - ftdm_buffer_seek(dt_buffer, offset); + ftdm_buffer_seek(dt_buffer, data->offset); + /* + * ftdm_channel_read() can read up to sizeof(frame) bytes + * (in certain situations). Avoid overflowing the stack (and smashing dt_buffer) + * if the codec is not slin and we had to double the length. + */ + len = ftdm_min(len, sizeof(frame)); rlen = ftdm_buffer_read_loop(dt_buffer, frame, len); if (chan->effective_codec != FTDM_CODEC_SLIN) { @@ -1969,6 +1965,12 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) codec_func = fio_slin2alaw; } + /* + * Convert SLIN to native format (a-law/u-law), + * input size is 2 bytes per sample, output size + * (after conversion) is one byte per sample + * (= max. half the input size). + */ if (codec_func) { status = codec_func(frame, sizeof(frame), &rlen); } else { @@ -1976,7 +1978,21 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) goto done; } } - ftdm_channel_write(chan, frame, sizeof(frame), &rlen); + + if (ftdm_channel_write(chan, frame, sizeof(frame), &rlen) == FTDM_SUCCESS) { + /* + * Advance offset in teletone buffer by amount + * of data actually written to channel. + */ + if (chan->effective_codec != FTDM_CODEC_SLIN) { + data->offset += rlen << 1; /* Teletone buffer is in SLIN (= rlen * 2) */ + } else { + data->offset += rlen; + } + + /* Limit offset to [0..Rate(Samples/s)-1] in SLIN (2 bytes per sample) units. */ + data->offset %= (ts.rate << 1); + } } /* @@ -1985,11 +2001,6 @@ static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) if (!gated) { ftdm_sleep(interval); } - - offset += (ts.rate / (1000 / interval)) << 1; - if (offset >= ts.rate) { - offset = 0; - } } done: @@ -2055,10 +2066,13 @@ static void *ftdm_isdn_run(ftdm_thread_t *me, void *obj) break; default: { - errs = 0; if (flags & FTDM_READ) { len = sizeof(frame); - if (ftdm_channel_read(isdn_data->dchan, frame, &len) == FTDM_SUCCESS) { + if (ftdm_channel_read(isdn_data->dchan, frame, &len) != FTDM_SUCCESS) { + ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_ERROR, "Failed to read from D-Channel\n"); + continue; + } + if (len > 0) { #ifdef HAVE_PCAP if (isdn_pcap_capture_both(isdn_data)) { isdn_pcap_write(isdn_data, frame, len, ISDN_PCAP_INCOMING); @@ -2066,6 +2080,9 @@ static void *ftdm_isdn_run(ftdm_thread_t *me, void *obj) #endif Q921QueueHDLCFrame(&isdn_data->q921, frame, (int)len); Q921Rx12(&isdn_data->q921); + + /* Successful read, reset error counter */ + errs = 0; } } else { ftdm_log(FTDM_LOG_DEBUG, "No Read FLAG!\n"); @@ -2209,7 +2226,7 @@ static ftdm_state_map_t isdn_state_map = { ZSD_INBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_DIALTONE, FTDM_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END} + {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_DOWN, FTDM_END} }, { ZSD_INBOUND, @@ -2676,11 +2693,24 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(isdn_configure_span) isdn_data = malloc(sizeof(*isdn_data)); assert(isdn_data != NULL); - memset(isdn_data, 0, sizeof(*isdn_data)); - isdn_data->mode = Q931_TE; + memset(isdn_data, 0, sizeof(*isdn_data)); dialect = Q931_Dialect_Q931; + /* Use trunk_mode span parameter to set default */ + switch (ftdm_span_get_trunk_mode(span)) { + case FTDM_TRUNK_MODE_NET: + ftdm_log(FTDM_LOG_INFO, "Span '%s' [s%d] defaulting to NET mode\n", + ftdm_span_get_name(span), ftdm_span_get_id(span)); + isdn_data->mode = Q931_NT; + break; + default: + ftdm_log(FTDM_LOG_INFO, "Span '%s' [s%d] defaulting to USER mode\n", + ftdm_span_get_name(span), ftdm_span_get_id(span)); + isdn_data->mode = Q931_TE; + break; + } + for (i = 0; ftdm_parameters[i].var; i++) { const char *var = ftdm_parameters[i].var; const char *val = ftdm_parameters[i].val; @@ -2744,6 +2774,16 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(isdn_configure_span) digit_timeout = DEFAULT_DIGIT_TIMEOUT; } + /* Check if modes match and log a message if they do not. Just to be on the safe side. */ + if (isdn_data->mode == Q931_TE && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { + ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for TE/CPE/USER mode, while port is running in NT/NET mode. You may want to check your 'trunk_mode' settings.\n", + ftdm_span_get_name(span)); + } + else if (isdn_data->mode == Q931_NT && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_CPE) { + ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for NT/NET mode, while port is running in TE/CPE/USER mode. You may want to check your 'trunk_mode' settings.\n", + ftdm_span_get_name(span)); + } + /* allocate per b-chan data */ if (isdn_data->mode == Q931_NT) { ftdm_isdn_bchan_data_t *data; diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h index 6b17f2cbef..e12520f691 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, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,9 +67,6 @@ struct ftdm_isdn_data { int32_t mode; int32_t digit_timeout; ftdm_isdn_opts_t opts; - ftdm_caller_data_t *outbound_crv[32768]; - ftdm_channel_t *channels_local_crv[32768]; - ftdm_channel_t *channels_remote_crv[32768]; #ifdef HAVE_PCAP struct pcap_context *pcap; #endif @@ -81,7 +78,8 @@ typedef struct ftdm_isdn_data ftdm_isdn_data_t; /* b-channel private data */ struct ftdm_isdn_bchan_data { - int32_t digit_timeout; + ftdm_time_t digit_timeout; + int offset; /* offset in teletone buffer */ }; typedef struct ftdm_isdn_bchan_data ftdm_isdn_bchan_data_t; diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c index 2e11f52f26..033d24b620 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, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * Copyright (c) 2010, Stefan Knoblich * All rights reserved. * @@ -34,9 +34,12 @@ #include "private/ftdm_core.h" #include "ftmod_libpri.h" -#ifndef MIN -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#endif + +static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span); +static ftdm_io_interface_t ftdm_libpri_interface; + +static int on_timeout_t302(struct lpwrap_pri *spri, struct lpwrap_timer *timer); + static void _ftdm_channel_set_state_force(ftdm_channel_t *chan, const ftdm_channel_state_t state) { @@ -258,8 +261,178 @@ out: return 0; } -static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span); -static ftdm_io_interface_t ftdm_libpri_interface; + +/*************************************************************** + * MSN filter + ***************************************************************/ + +/** + * Initialize MSN filter data structures + * \param[in] isdn_data Span private data + * \return FTDM_SUCCESS, FTDM_FAIL + */ +static int msn_filter_init(ftdm_libpri_data_t *isdn_data) +{ + if (!isdn_data) + return FTDM_FAIL; + + isdn_data->msn_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); + if (!isdn_data->msn_hash) + return FTDM_FAIL; + + if (ftdm_mutex_create(&isdn_data->msn_mutex)) { + hashtable_destroy(isdn_data->msn_hash); + return FTDM_FAIL; + } + + return FTDM_SUCCESS; +} + +/** + * Destroy MSN filter data structures + * \param[in] isdn_data Span private data + * \return FTDM_SUCCESS, FTDM_FAIL + */ +static int msn_filter_destroy(ftdm_libpri_data_t *isdn_data) +{ + if (!isdn_data) + return FTDM_FAIL; + + if (isdn_data->msn_hash) + hashtable_destroy(isdn_data->msn_hash); + if (isdn_data->msn_mutex) + ftdm_mutex_destroy(&isdn_data->msn_mutex); + + return FTDM_SUCCESS; +} + +/** + * Check if the given string is a valid MSN/DDI + * (i.e.: Not empty, not longer than FDM_DIGITS_LIMIT and all numbers) + * \param[in] str String to check + * \return FTDM_SUCCESS, FTDM_FAIL + */ +static int msn_filter_verify(const char *str) +{ + if (ftdm_strlen_zero(str) || strlen(str) >= FTDM_DIGITS_LIMIT) + return FTDM_FALSE; + + if (ftdm_is_number(str) != FTDM_SUCCESS) + return FTDM_FALSE; + + return FTDM_TRUE; +} + +/** + * Add a new MSN/DDI to the filter + * \param[in] isdn_data Span private data + * \param[in] msn New MSN/DDI to add + * \return FTDM_SUCCESS, FTDM_FAIL + */ +static int msn_filter_add(ftdm_libpri_data_t *isdn_data, const char *msn) +{ + static const int value = 0xdeadbeef; + char *key = NULL; + int ret = FTDM_SUCCESS; + + if (!isdn_data || !msn_filter_verify(msn)) + return FTDM_FAIL; + + ftdm_mutex_lock(isdn_data->msn_mutex); + + /* check for duplicates (ignore if already in set) */ + if (hashtable_search(isdn_data->msn_hash, (void *)msn)) { + ret = FTDM_SUCCESS; + goto out; + } + + /* Copy MSN (transient string), hashtable will free it in hashtable_destroy() */ + key = ftdm_strdup(msn); + if (!key) { + ret = FTDM_FAIL; + goto out; + } + + /* add MSN to list/hash */ + if (!hashtable_insert(isdn_data->msn_hash, (void *)key, (void *)&value, HASHTABLE_FLAG_FREE_KEY)) { + ftdm_safe_free(key); + ret = FTDM_FAIL; + } +out: + ftdm_mutex_unlock(isdn_data->msn_mutex); + return ret; +} + + +/** + * Check if a DNIS (destination number) is a valid MSN/DDI + * \param[in] isdn_data Span private data + * \param[in] msn Number to check + * \retval FTDM_TRUE \p msn is a valid MSN/DDI or filter list is empty + * \retval FTDM_FALSE \p msn is not a valid MSN/DDI + */ +static int msn_filter_match(ftdm_libpri_data_t *isdn_data, const char *msn) +{ + int ret = FTDM_FALSE; + + if (!isdn_data) + return FTDM_FALSE; + /* No number? return match found */ + if (ftdm_strlen_zero(msn)) + return FTDM_TRUE; + + ftdm_mutex_lock(isdn_data->msn_mutex); + + /* No MSN configured? */ + if (hashtable_count(isdn_data->msn_hash) <= 0) { + ret = FTDM_TRUE; + goto out; + } + /* Search for a matching MSN */ + if (hashtable_search(isdn_data->msn_hash, (void *)msn)) + ret = FTDM_TRUE; +out: + ftdm_mutex_unlock(isdn_data->msn_mutex); + return ret; +} + +/** + * Helper function to iterate over MSNs in the filter hash (handles locking) + * \param[in] isdn_data Span private data + * \param[in] func Callback function that is invoked for each entry + * \param[in] data Private data passed to callback + * \return FTDM_SUCCESS, FTDM_FAIL + */ +static int msn_filter_foreach(ftdm_libpri_data_t *isdn_data, int (* func)(const char *, void *), void *data) +{ + ftdm_hash_iterator_t *iter = NULL; + int ret = FTDM_SUCCESS; + + if (!isdn_data || !func) + return FTDM_FAIL; + + /* iterate over MSNs */ + ftdm_mutex_lock(isdn_data->msn_mutex); + + for (iter = hashtable_first(isdn_data->msn_hash); iter; iter = hashtable_next(iter)) { + const void *msn = NULL; + + hashtable_this(iter, &msn, NULL, NULL); + + if (ftdm_strlen_zero((const char *)msn)) + break; + if ((ret = func(msn, data)) != FTDM_SUCCESS) + break; + } + + ftdm_mutex_unlock(isdn_data->msn_mutex); + return ret; +} + + +/*************************************************************** + * Module API (CLI) interface + ***************************************************************/ static const char *ftdm_libpri_usage = "Usage:\n" @@ -268,6 +441,7 @@ static const char *ftdm_libpri_usage = "libpri restart \n" "libpri maintenance \n" "libpri debug [all|none|flag,...flagN]\n" + "libpri msn \n" "\n" "Possible debug flags:\n" "\tq921_raw - Q.921 Raw messages\n" @@ -287,6 +461,33 @@ static const char *ftdm_libpri_usage = "\tnone - Disable debugging\n" "\tall - Enable all debug options\n"; + +/** + * Custom data handle for list iterator functions + */ +struct msn_list_cb_private { + ftdm_stream_handle_t *stream; + unsigned int count; +}; + +/** + * "ftdm libpri msn " API command callback + * function for msn_filter_foreach() + */ +static int msn_list_cb(const char *msn, void *priv) +{ + struct msn_list_cb_private *data = priv; + ftdm_stream_handle_t *stream = data->stream; + + if (!stream || ftdm_strlen_zero(msn)) + return FTDM_FAIL; + + stream->write_function(stream, "\t%s\n", msn); + data->count++; + return FTDM_SUCCESS; +} + + /** * \brief API function to kill or debug a libpri span * \param stream API stream handler @@ -331,6 +532,40 @@ static FIO_API_FUNCTION(ftdm_libpri_api) goto done; } } + if (!strcasecmp(argv[0], "msn")) { + ftdm_span_t *span = NULL; + struct msn_list_cb_private data; + data.stream = stream; + data.count = 0; + + if (ftdm_span_find_by_name(argv[1], &span) != FTDM_SUCCESS) { + stream->write_function(stream, "%s: -ERR span '%s' not found.\n", + __FILE__, argv[1]); + goto done; + } + if (span->start != ftdm_libpri_start) { + stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", + __FILE__, ftdm_span_get_name(span)); + goto done; + } + + /* header */ + stream->write_function(stream, "------------------------------------------------------------------------------\n"); + + if (msn_filter_foreach(span->signal_data, msn_list_cb, &data)) { + stream->write_function(stream, "-ERR: Failed to list MSN(s)\n"); + goto done; + } + if (data.count == 0) { + stream->write_function(stream, "\t\t\t -- no entries --\n"); + } + + /* footer */ + stream->write_function(stream, "---------------------------------------------------------------[ %02d MSN(s) ]--\n", + data.count); + stream->write_function(stream, "+OK"); + goto done; + } } else if (argc >= 2) { if (!strcasecmp(argv[0], "debug")) { ftdm_span_t *span = NULL; @@ -669,8 +904,10 @@ static ftdm_state_map_t isdn_state_map = { */ static ftdm_status_t state_advance(ftdm_channel_t *chan) { - ftdm_libpri_data_t *isdn_data = chan->span->signal_data; - q931_call *call = (q931_call *)chan->call_data; + ftdm_span_t *span = ftdm_channel_get_span(chan); + ftdm_libpri_data_t *isdn_data = span->signal_data; + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + q931_call *call = chan_priv->call; ftdm_status_t status; ftdm_sigmsg_t sig; @@ -687,21 +924,26 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) switch (ftdm_channel_get_state(chan)) { case FTDM_CHANNEL_STATE_DOWN: { - ftdm_channel_t *chtmp = chan; + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_channel_t *chtmp = chan; - if (call) { - pri_destroycall(isdn_data->spri.pri, call); - chan->call_data = NULL; - } + if (call) { + pri_destroycall(isdn_data->spri.pri, call); + chan_priv->call = NULL; + } - if (ftdm_channel_close(&chtmp) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_WARNING, "-- Failed to close channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Closed channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); + /* Stop T302 */ + lpwrap_stop_timer(&isdn_data->spri, &chan_priv->t302); + + if (ftdm_channel_close(&chtmp) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_WARNING, "-- Failed to close channel %d:%d\n", + ftdm_channel_get_span_id(chan), + ftdm_channel_get_id(chan)); + } else { + ftdm_log(FTDM_LOG_DEBUG, "-- Closed channel %d:%d\n", + ftdm_channel_get_span_id(chan), + ftdm_channel_get_id(chan)); + } } } break; @@ -710,7 +952,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -725,7 +967,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_RINGING; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -741,7 +983,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -761,7 +1003,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { /* PROCEED from other end, notify user */ sig.event_id = FTDM_SIGEVENT_PROCEED; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_log(FTDM_LOG_ERROR, "Failed to send PROCEED sigevent on Channel %d:%d\n", ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); @@ -791,6 +1033,11 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } + else { + /* Start T302 */ + lpwrap_start_timer(&isdn_data->spri, &chan_priv->t302, + isdn_data->overlap_timeout_ms, &on_timeout_t302); + } } else { ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "Overlap receiving on outbound call?\n"); ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); @@ -809,7 +1056,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) pri_proceeding(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); // pri_acknowledge(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); sig.event_id = FTDM_SIGEVENT_START; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else { @@ -821,10 +1068,20 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) case FTDM_CHANNEL_STATE_RESTART: { - chan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; - sig.event_id = FTDM_SIGEVENT_RESTART; - status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + chan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; + sig.event_id = FTDM_SIGEVENT_RESTART; + status = ftdm_span_send_signal(span, &sig); + + if (!(chan_priv->flags & FTDM_LIBPRI_B_REMOTE_RESTART)) { + /* Locally triggered restart, send RESTART to remote, wait for ACK */ + pri_reset(isdn_data->spri.pri, ftdm_channel_get_id(chan)); + } else { + /* Remote restart complete, clear flag */ + chan_priv->flags &= ~FTDM_LIBPRI_B_REMOTE_RESTART; + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + } + } } break; @@ -832,7 +1089,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_UP; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -876,7 +1133,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) ton = isdn_data->ton; } - chan->call_data = call; + chan_priv->call = call; sr = pri_sr_new(); if (!sr) { @@ -922,7 +1179,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) pri_hangup(isdn_data->spri.pri, call, caller_data->hangup_cause); // pri_destroycall(isdn_data->spri.pri, call); -// chan->call_data = NULL; +// chan_priv->call = NULL; } ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); } @@ -932,7 +1189,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { // if (call) { // pri_destroycall(isdn_data->spri.pri, call); -// chan->call_data = NULL; +// chan_priv->call = NULL; // } ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); } @@ -941,7 +1198,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) case FTDM_CHANNEL_STATE_TERMINATING: { sig.event_id = FTDM_SIGEVENT_STOP; - status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig); + status = ftdm_span_send_signal(span, &sig); /* user moves us to HANGUP and from there we go to DOWN */ } default: @@ -970,65 +1227,101 @@ static __inline__ void check_state(ftdm_span_t *span) } } + /** - * \brief Handler for libpri information event (incoming call?) + * \brief Handler for libpri keypad digit event * \param spri Pri wrapper structure (libpri, span, dchan) * \param event_type Event type (unused) * \param pevent Event * \return 0 */ -static int on_info(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) +static int on_keypad_digit(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) { ftdm_span_t *span = spri->span; ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); - ftdm_caller_data_t *caller_data = NULL; if (!chan) { - ftdm_log(FTDM_LOG_CRIT, "-- Info on channel %d:%d %s but it's not in use?\n", ftdm_span_get_id(span), pevent->ring.channel); + ftdm_log(FTDM_LOG_ERROR, "-- Keypad event on invalid channel %d:%d\n", + ftdm_span_get_id(span), pevent->ring.channel); + return 0; + } + + ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Keypad event received, incoming digits: '%s'\n", + pevent->digit.digits); + + /* Enqueue DTMF digits on channel */ + ftdm_channel_queue_dtmf(chan, pevent->digit.digits); + return 0; +} + + +/** + * \brief Handler for libpri information event (overlap receiving) + * \param spri Pri wrapper structure (libpri, span, dchan) + * \param event_type Event type (unused) + * \param pevent Event + * \return 0 + */ +static int on_information(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) +{ + ftdm_span_t *span = spri->span; + ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); + ftdm_libpri_b_chan_t *chan_priv = NULL; + ftdm_caller_data_t *caller_data = NULL; + ftdm_libpri_data_t *isdn_data = span->signal_data; + + if (!chan) { + ftdm_log(FTDM_LOG_CRIT, "-- Info on channel %d:%d but it's not in use?\n", ftdm_span_get_id(span), pevent->ring.channel); return 0; } caller_data = ftdm_channel_get_caller_data(chan); + chan_priv = chan->call_data; switch (ftdm_channel_get_state(chan)) { case FTDM_CHANNEL_STATE_COLLECT: /* TE-mode overlap receiving */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, current called number: '%s', number complete: %s\n", - pevent->ring.callednum, pevent->ring.complete ? "yes" : "no"); + case FTDM_CHANNEL_STATE_DIALTONE: /* NT-mode overlap receiving */ + + ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, received digits: '%s', number complete: %c, collected digits: '%s'\n", + pevent->ring.callednum, + pevent->ring.complete ? 'Y' : 'N', + caller_data->dnis.digits); + + /* Stop T302 */ + lpwrap_stop_timer(spri, &chan_priv->t302); /* append digits to dnis */ if (!ftdm_strlen_zero(pevent->ring.callednum)) { int digits = strlen(pevent->ring.callednum); int offset = strlen(caller_data->dnis.digits); - int len = MIN(sizeof(caller_data->dnis.digits) - 1 - offset, digits); /* max. length without terminator */ + int len = 0; - if (len < digits) { - ftdm_log_chan(chan, FTDM_LOG_WARNING, "Length %d of digit string exceeds available space %d of DNIS, truncating!\n", - digits, len); + if (strchr(pevent->ring.callednum, '#')) { + pevent->ring.complete = 1; + digits--; } - ftdm_copy_string(&caller_data->dnis.digits[offset], (char *)pevent->ring.callednum, len + 1); /* max. length with terminator */ - caller_data->dnis.digits[offset + len] = '\0'; + len = ftdm_min(sizeof(caller_data->dnis.digits) - 1 - offset, digits); /* max. length without terminator */ + if (len < digits) { + ftdm_log_chan(chan, FTDM_LOG_WARNING, "Digit string of length %d exceeds available space %d of DNIS, truncating!\n", + digits, len); + } + if (len) { + ftdm_copy_string(&caller_data->dnis.digits[offset], (char *)pevent->ring.callednum, len + 1); /* max. length with terminator */ + caller_data->dnis.digits[offset + len] = '\0'; + } } if (pevent->ring.complete) { - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Number complete indicated, moving channel to RING state\n"); + ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Number complete indication received, moving channel to RING state\n"); /* notify switch */ ftdm_set_state(chan, FTDM_CHANNEL_STATE_RING); - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: /* NT-mode overlap receiving */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, current called number: '%s'\n", - pevent->ring.callednum); - - /* Need to add proper support for overlap receiving in NT-mode (requires FreeSWITCH + FreeTDM core support) */ - if (strlen(pevent->ring.callednum) > 3) { - ftdm_log(FTDM_LOG_DEBUG, "final number is: %s\n", pevent->ring.callednum); - pri_answer(spri->pri, pevent->ring.call, 0, 1); + } else { + /* Restart T302 */ + lpwrap_start_timer(spri, &chan_priv->t302, isdn_data->overlap_timeout_ms, &on_timeout_t302); } break; default: - ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- INFORMATION indication on channel %d:%d in invalid state '%s'\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan), + ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- INFORMATION indication in invalid state '%s'\n", ftdm_channel_get_state_str(chan)); } return 0; @@ -1047,7 +1340,7 @@ static int on_hangup(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_even ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->hangup.channel); if (!chan) { - ftdm_log(FTDM_LOG_CRIT, "-- Hangup on channel %d:%d %s but it's not in use?\n", ftdm_span_get_id(spri->span), pevent->hangup.channel); + ftdm_log(FTDM_LOG_CRIT, "-- Hangup on channel %d:%d but it's not in use?\n", ftdm_span_get_id(spri->span), pevent->hangup.channel); return 0; } @@ -1298,6 +1591,107 @@ out: return 0; } + +/** + * Look up FreeTDM channel by call reference value + * \param[in] span Span object + * \param[in] crv CRV to search for + * \return Channel on success, NULL otherwise + */ +static ftdm_channel_t *find_channel_by_cref(ftdm_span_t *span, const int cref) +{ + ftdm_iterator_t *iter = NULL; + ftdm_channel_t *chan = NULL; + + if (!span || cref <= 0) + return NULL; + + ftdm_mutex_lock(span->mutex); + + /* Iterate over all channels on this span */ + for (iter = ftdm_span_get_chan_iterator(span, NULL); iter; iter = ftdm_iterator_next(iter)) { + ftdm_channel_t *cur = ftdm_iterator_current(iter); + ftdm_caller_data_t *caller_data = NULL; + + if (ftdm_channel_get_type(cur) != FTDM_CHAN_TYPE_B) + continue; + + caller_data = ftdm_channel_get_caller_data(cur); + + if (caller_data->call_reference == cref) { + chan = cur; + break; + } + } + + ftdm_iterator_free(iter); + ftdm_mutex_unlock(span->mutex); + return chan; +} + + +/** + * Hunt for free channel (NT-mode only) + * \param[in] span Span to hunt on + * \param[in] hint Channel ID hint (preferred by remote end) + * \param[in] excl Is the hint exclusive (or preferred)? + * \param[out] chan Selected channel + * \retval FTDM_SUCCESS A free channel has been found + * \retval FTDM_FAIL No free channels could be found on the span + * \retval FTDM_EBUSY The channel indicated in the exclusive hint is already in use + */ +static ftdm_status_t hunt_channel(ftdm_span_t *span, const int hint, const ftdm_bool_t excl, ftdm_channel_t **chan) +{ + ftdm_iterator_t *iter = NULL; + ftdm_channel_t *tmp = NULL; + int ret = FTDM_FAIL; + + /* lock span */ + ftdm_mutex_lock(span->mutex); + + /* Check hint */ + if (hint > 0) { + tmp = ftdm_span_get_channel(span, hint); + if (!tmp) { + ftdm_log(FTDM_LOG_NOTICE, "Invalid channel hint '%d' given (out of bounds)\n", hint); + } + else if (!ftdm_test_flag(tmp, FTDM_CHANNEL_INUSE) && ftdm_channel_get_type(tmp) == FTDM_CHAN_TYPE_B) { + ftdm_log(FTDM_LOG_DEBUG, "Using channel '%d' from hint\n", ftdm_channel_get_id(tmp)); + ftdm_channel_use(tmp); + ret = FTDM_SUCCESS; + *chan = tmp; + goto out; + } + else if (excl) { + ftdm_log(FTDM_LOG_NOTICE, "Channel '%d' in exclusive hint is not available\n", + ftdm_channel_get_id(tmp)); + ret = FTDM_EBUSY; + goto out; + } + } + + /* Iterate over all channels on this span */ + for (iter = ftdm_span_get_chan_iterator(span, NULL); iter; iter = ftdm_iterator_next(iter)) { + tmp = ftdm_iterator_current(iter); + + if (ftdm_channel_get_type(tmp) != FTDM_CHAN_TYPE_B) + continue; + + if (!ftdm_test_flag(tmp, FTDM_CHANNEL_INUSE)) { + ftdm_channel_use(tmp); + ret = FTDM_SUCCESS; + *chan = tmp; + break; + } + } + + ftdm_iterator_free(iter); +out: + ftdm_mutex_unlock(span->mutex); + return ret; +} + + /** * \brief Handler for libpri ring event * \param spri Pri wrapper structure (libpri, span, dchan) @@ -1309,62 +1703,104 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event { ftdm_span_t *span = spri->span; ftdm_libpri_data_t *isdn_data = span->signal_data; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); + ftdm_libpri_b_chan_t *chan_priv = NULL; + ftdm_channel_t *chan = NULL; ftdm_caller_data_t *caller_data = NULL; int ret = 0; - if (!chan) { - ftdm_log(FTDM_LOG_ERROR, "-- Unable to get channel %d:%d\n", ftdm_span_get_id(span), pevent->ring.channel); + /* + * Check if call has an associated channel (duplicate ring event) + */ + if ((chan = find_channel_by_cref(span, pevent->ring.cref))) { + ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "-- Duplicate ring received (ignored)\n"); return ret; } - ftdm_channel_lock(chan); - - if (chan->call_data) { - /* we could drop the incoming call, but most likely the pointer is just a ghost of the past, - * this check is just to detect potentially unreleased pointers */ - ftdm_log_chan(chan, FTDM_LOG_ERROR, "channel already has call %p!\n", chan->call_data); - chan->call_data = NULL; - } - - if (ftdm_channel_get_state(chan) != FTDM_CHANNEL_STATE_DOWN || ftdm_test_flag(chan, FTDM_CHANNEL_INUSE)) { - ftdm_log(FTDM_LOG_WARNING, "-- Duplicate Ring on channel %d:%d (ignored)\n", ftdm_span_get_id(span), pevent->ring.channel); - goto done; - } - - if ((pevent->ring.progressmask & PRI_PROG_INBAND_AVAILABLE)) { - /* Open channel if inband information is available */ - ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, opening B-Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && ftdm_channel_open_chan(chan) != FTDM_SUCCESS) { -// ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log(FTDM_LOG_WARNING, "-- Error opening channel %d:%d (ignored)\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - -// caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; -// ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); -// goto done; + if (isdn_data->mode == PRI_NETWORK) { + /* + * Always hunt for a free channel in NT-mode, + * but use the pre-selected one as hint + */ + switch (hunt_channel(span, pevent->ring.channel, !pevent->ring.flexible, &chan)) { + case FTDM_SUCCESS: /* OK channel found */ + break; + case FTDM_EBUSY: /* Exclusive channel hint is not available */ + ftdm_log(FTDM_LOG_ERROR, "-- New call without channel on span '%s' [NOTE: Initial SETUP w/o channel selection is not supported by FreeTDM]\n", + ftdm_span_get_name(span)); + pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_CHANNEL_UNACCEPTABLE); + return ret; + default: + ftdm_log(FTDM_LOG_ERROR, "-- New call without channel on span '%s' [NOTE: Initial SETUP w/o channel selection is not supported by FreeTDM]\n", + ftdm_span_get_name(span)); + pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION); + return ret; } + + ftdm_channel_lock(chan); + + } else if (pevent->ring.channel == -1) { + /* + * TE-mode incoming call without channel selection (not supported) + */ + ftdm_log(FTDM_LOG_ERROR, "-- New call without channel on span '%s' [NOTE: Initial SETUP w/o channel selection is not supported by FreeTDM]\n", + ftdm_span_get_name(span)); + pri_destroycall(spri->pri, pevent->ring.call); + return ret; } else { - /* Reserve channel, don't open it yet */ - if (ftdm_channel_use(chan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_WARNING, "-- Error reserving channel %d:%d (ignored)\n", + /* + * TE-mode, check MSN filter, ignore calls that aren't for this PTMP terminal + */ + if (!msn_filter_match(isdn_data, pevent->ring.callednum)) { + ftdm_log(FTDM_LOG_INFO, "-- MSN filter not matching incoming DNIS '%s', ignoring call\n", + pevent->ring.callednum); + pri_destroycall(spri->pri, pevent->ring.call); + return ret; + } + + /* + * TE-mode channel selection, use whatever the NT tells us to + */ + chan = ftdm_span_get_channel(span, pevent->ring.channel); + if (!chan) { + ftdm_log(FTDM_LOG_ERROR, "-- Unable to get channel %d:%d\n", ftdm_span_get_id(span), pevent->ring.channel); + pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_DESTINATION_OUT_OF_ORDER); + return ret; + } + + ftdm_channel_lock(chan); + + if (ftdm_channel_get_state(chan) != FTDM_CHANNEL_STATE_DOWN || ftdm_test_flag(chan, FTDM_CHANNEL_INUSE)) { + ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "-- Selected channel is already in use\n"); + pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_DESTINATION_OUT_OF_ORDER); + goto done; + } + + /* Reserve channel */ + if (ftdm_channel_use(chan) != FTDM_SUCCESS) { + ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "-- Error reserving channel\n"); + pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_DESTINATION_OUT_OF_ORDER); goto done; } } - ftdm_log(FTDM_LOG_NOTICE, "-- Ring on channel %d:%d (from %s to %s)\n", ftdm_span_get_id(span), pevent->ring.channel, - pevent->ring.callingnum, pevent->ring.callednum); + /* Get per-channel private data */ + chan_priv = chan->call_data; + + if (chan_priv->call) { + /* we could drop the incoming call, but most likely the pointer is just a ghost of the past, + * this check is just to detect potentially unreleased pointers */ + ftdm_log_chan(chan, FTDM_LOG_WARNING, "Channel already has call %p!\n", chan_priv->call); + chan_priv->call = NULL; + } caller_data = ftdm_channel_get_caller_data(chan); memset(caller_data, 0, sizeof(*caller_data)); + /* Save CRV, so we can do proper duplicate RING detection */ + caller_data->call_reference = pevent->ring.cref; + ftdm_set_string(caller_data->cid_num.digits, (char *)pevent->ring.callingnum); ftdm_set_string(caller_data->ani.digits, (char *)pevent->ring.callingani); ftdm_set_string(caller_data->dnis.digits, (char *)pevent->ring.callednum); @@ -1382,9 +1818,32 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event // scary to trust this pointer, you'd think they would give you a copy of the call data so you own it...... /* hurr, this is valid as along as nobody releases the call */ - chan->call_data = pevent->ring.call; + chan_priv->call = pevent->ring.call; - /* only go to RING state if we have the complete called number (indicated via pevent->complete flag) */ + /* Open Channel if inband information is available */ + if ((pevent->ring.progressmask & PRI_PROG_INBAND_AVAILABLE)) { + /* Open channel if inband information is available */ + ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, opening B-Channel %d:%d\n", + ftdm_channel_get_span_id(chan), + ftdm_channel_get_id(chan)); + + if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && ftdm_channel_open_chan(chan) != FTDM_SUCCESS) { +// ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); + + ftdm_log(FTDM_LOG_WARNING, "-- Error opening channel %d:%d (ignored)\n", + ftdm_channel_get_span_id(chan), + ftdm_channel_get_id(chan)); + +// caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; +// ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); +// goto done; + } + } + + ftdm_log(FTDM_LOG_NOTICE, "-- Ring on channel %d:%d (from %s to %s)\n", ftdm_span_get_id(span), pevent->ring.channel, + pevent->ring.callingnum, pevent->ring.callednum); + + /* Only go to RING state if we have the complete called number (indicated via pevent->complete flag) */ if (!pevent->ring.complete && (isdn_data->overlap & FTMOD_LIBPRI_OVERLAP_RECEIVE)) { ftdm_log(FTDM_LOG_DEBUG, "RING event without complete indicator, waiting for more digits\n"); ftdm_set_state(chan, FTDM_CHANNEL_STATE_COLLECT); @@ -1397,6 +1856,21 @@ done: return ret; } + +/** + * Timeout handler for T302 (overlap receiving) + */ +static int on_timeout_t302(struct lpwrap_pri *spri, struct lpwrap_timer *timer) +{ + ftdm_libpri_b_chan_t *chan_priv = ftdm_container_of(timer, ftdm_libpri_b_chan_t, t302); + ftdm_channel_t *chan = chan_priv->channel; + + ftdm_log(FTDM_LOG_NOTICE, "-- T302 timed out, going to state RING\n"); + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RING); + return 0; +} + + /** * \brief Processes freetdm event * \param span Span on which the event was fired @@ -1424,22 +1898,15 @@ static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *e } ftdm_set_flag(event->channel, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_get_alarms(event->channel, &alarmbits); - ftdm_log(FTDM_LOG_WARNING, "channel %d:%d (%d:%d) has alarms! [%s]\n", - ftdm_channel_get_span_id(event->channel), ftdm_channel_get_id(event->channel), - ftdm_channel_get_ph_span_id(event->channel), ftdm_channel_get_ph_id(event->channel), - ftdm_channel_get_last_error(event->channel)); + ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, "channel has alarms!\n"); } break; case FTDM_OOB_ALARM_CLEAR: { - ftdm_log(FTDM_LOG_WARNING, "channel %d:%d (%d:%d) alarms Cleared!\n", - ftdm_channel_get_span_id(event->channel), ftdm_channel_get_id(event->channel), - ftdm_channel_get_ph_span_id(event->channel), ftdm_channel_get_ph_id(event->channel)); - ftdm_clear_flag(event->channel, FTDM_CHANNEL_SUSPENDED); ftdm_channel_get_alarms(event->channel, &alarmbits); + ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, "channel alarms cleared!\n"); } break; } @@ -1490,11 +1957,6 @@ static __inline__ void check_events(ftdm_span_t *span) static int check_flags(lpwrap_pri_t *spri) { ftdm_span_t *span = spri->span; - - if (!ftdm_running() || ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - return -1; - } - check_state(span); check_events(span); return 0; @@ -1509,24 +1971,84 @@ static int check_flags(lpwrap_pri_t *spri) */ static int on_restart(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) { + ftdm_channel_t *chan = NULL; ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->restart.channel); - - ftdm_log(FTDM_LOG_NOTICE, "-- Restarting %d:%d\n", ftdm_span_get_id(span), pevent->restart.channel); - _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); - - if (!chan) { - return 0; - } + int i; if (pevent->restart.channel < 1) { - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - } else { + ftdm_log_chan_msg(spri->dchan, FTDM_LOG_NOTICE, "-- Restarting interface\n"); + + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + chan = ftdm_span_get_channel(span, i); + if (!chan) + continue; + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + chan_priv->flags |= FTDM_LIBPRI_B_REMOTE_RESTART; /* Remote triggered RESTART, set flag */ + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); + } + } + } + else if ((chan = ftdm_span_get_channel(span, pevent->restart.channel))) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + + ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "-- Restarting single channel\n"); + chan_priv->flags |= FTDM_LIBPRI_B_REMOTE_RESTART; ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); } + else { + ftdm_log(FTDM_LOG_ERROR, "Invalid restart indicator / channel id '%d' received\n", + pevent->restart.channel); + } + + _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); return 0; } +/** + * \brief Handler for libpri restart acknowledge event + * \param spri Pri wrapper structure (libpri, span, dchan) + * \param event_type Event type (unused) + * \param pevent Event + * \return 0 + */ +static int on_restart_ack(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) +{ + ftdm_channel_t *chan = NULL; + ftdm_span_t *span = spri->span; + int i; + + if (pevent->restartack.channel < 1) { + ftdm_log_chan_msg(spri->dchan, FTDM_LOG_NOTICE, "-- Restart of interface completed\n"); + + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + chan = ftdm_span_get_channel(span, i); + if (!chan) + continue; + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + if (!(chan_priv->flags & FTDM_LIBPRI_B_REMOTE_RESTART)) { + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + } + } + } + } + else if ((chan = ftdm_span_get_channel(span, pevent->restart.channel))) { + ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "-- Restart of channel completed\n"); + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + } + else { + ftdm_log(FTDM_LOG_ERROR, "Invalid restart indicator / channel id '%d' received\n", + pevent->restartack.channel); + } + + _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); + return 0; +} + + + + /* * FACILITY Advice-On-Charge handler */ @@ -1822,110 +2344,88 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj) ftdm_span_t *span = (ftdm_span_t *) obj; ftdm_libpri_data_t *isdn_data = span->signal_data; int down = 0; - int got_d = 0; int res = 0; + int i; ftdm_set_flag(span, FTDM_SPAN_IN_THREAD); + isdn_data->dchan = NULL; + /* + * Open D-Channel + */ + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + ftdm_channel_t *chan = ftdm_span_get_channel(span, i); + + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { + if (ftdm_channel_open(ftdm_span_get_id(span), i, &isdn_data->dchan) == FTDM_SUCCESS) { + ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Opened D-Channel\n"); + break; + } else { + ftdm_log_chan_msg(chan, FTDM_LOG_CRIT, "Failed to open D-Channel\n"); + goto out; + } + } + } + + /* + * Initialize BRI/PRI context + */ + res = lpwrap_init_pri(&isdn_data->spri, span, isdn_data->dchan, + isdn_data->dialect, isdn_data->mode, isdn_data->debug_mask); + + if (res) { + ftdm_log(FTDM_LOG_CRIT, "Failed to initialize BRI/PRI on span %d\n", + ftdm_span_get_id(span)); + goto out; + } + +#ifdef HAVE_LIBPRI_AOC + /* + * Only enable facility on trunk if really required, + * this may help avoid problems on troublesome lines. + */ + if (isdn_data->opts & FTMOD_LIBPRI_OPT_FACILITY_AOC) { + pri_facility_enable(isdn_data->spri.pri); + } +#endif + /* Support the different switch of service status */ + if (isdn_data->service_message_support) { + pri_set_service_message_support(isdn_data->spri.pri, 1); + } + + /* Callbacks for libpri events */ + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANY, on_anything); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RING, on_ring); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RINGING, on_ringing); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROCEEDING, on_proceeding); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROGRESS, on_progress); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANSWER, on_answer); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_UP, on_dchan_up); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_DOWN, on_dchan_down); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_REQ, on_hangup); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_ACK, on_hangup); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP, on_hangup); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_information); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_KEYPAD_DIGIT, on_keypad_digit); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART_ACK, on_restart_ack); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_IO_FAIL, on_io_fail); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_FACILITY, on_facility); + + /* Callback invoked on each iteration of the lpwrap_run_pri() event loop */ + isdn_data->spri.on_loop = check_flags; + + /* + * Event loop + */ while (ftdm_running() && !ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - if (!got_d) { - int i, x; - - for (i = 1, x = 0; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { - if (ftdm_channel_open(ftdm_span_get_id(span), i, &isdn_data->dchan) == FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "opening D-Channel #%d %d:%d\n", x, - ftdm_channel_get_span_id(isdn_data->dchan), ftdm_channel_get_id(isdn_data->dchan)); - got_d = 1; - x++; - break; - } else { - ftdm_log(FTDM_LOG_ERROR, "failed to open D-Channel #%d %d:%d\n", x, - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); - } - } - } - } - if (!got_d || !isdn_data->dchan) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get a D-Channel in span %d\n", ftdm_span_get_id(span)); - break; + if (down) { + ftdm_log(FTDM_LOG_INFO, "PRI back up on span %d\n", ftdm_span_get_id(span)); + ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); + down = 0; } - /* Initialize libpri trunk */ - switch (ftdm_span_get_trunk_type(span)) { - case FTDM_TRUNK_E1: - case FTDM_TRUNK_T1: - case FTDM_TRUNK_J1: - res = lpwrap_init_pri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, isdn_data->debug_mask); - break; - case FTDM_TRUNK_BRI: - res = lpwrap_init_bri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, 1, isdn_data->debug_mask); -#ifndef HAVE_LIBPRI_BRI - goto out; -#endif - break; - case FTDM_TRUNK_BRI_PTMP: - res = lpwrap_init_bri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, 0, isdn_data->debug_mask); -#ifndef HAVE_LIBPRI_BRI - goto out; -#endif - break; - default: - snprintf(span->last_error, sizeof(span->last_error), "Invalid trunk type"); - goto out; - } - -#ifdef HAVE_LIBPRI_AOC - /* - * Only enable facility on trunk if really required, - * this may help avoid problems on troublesome lines. - */ - if (isdn_data->opts & FTMOD_LIBPRI_OPT_FACILITY_AOC) { - pri_facility_enable(isdn_data->spri.pri); - } -#endif - /* Support the different switch of service status */ - if (isdn_data->service_message_support) { - pri_set_service_message_support(isdn_data->spri.pri, 1 /* True */); - } - - if (res == 0) { - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANY, on_anything); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RING, on_ring); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RINGING, on_ringing); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROCEEDING, on_proceeding); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROGRESS, on_progress); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANSWER, on_answer); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_UP, on_dchan_up); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_DOWN, on_dchan_down); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_REQ, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_ACK, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_info); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_IO_FAIL, on_io_fail); -#ifdef HAVE_LIBPRI_AOC - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_FACILITY, on_facility); -#endif - if (down) { - ftdm_log(FTDM_LOG_INFO, "PRI back up on span %d\n", ftdm_span_get_id(span)); - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - down = 0; - } - - isdn_data->spri.on_loop = check_flags; - - lpwrap_run_pri(&isdn_data->spri); - } else { - ftdm_log(FTDM_LOG_CRIT, "PRI init failed!\n"); - snprintf(span->last_error, sizeof(span->last_error), "PRI init failed!"); - break; - } + lpwrap_run_pri(&isdn_data->spri); if (!ftdm_running() || ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { break; @@ -1951,8 +2451,7 @@ out: /* close d-channel, if set */ if (isdn_data->dchan) { if (ftdm_channel_close(&isdn_data->dchan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to close D-Channel %d:%d\n", - ftdm_channel_get_span_id(isdn_data->dchan), ftdm_channel_get_id(isdn_data->dchan)); + ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_ERROR, "Failed to close D-Channel\n"); } } @@ -1961,6 +2460,7 @@ out: ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); ftdm_clear_flag(isdn_data, FTMOD_LIBPRI_RUNNING); + lpwrap_destroy_pri(&isdn_data->spri); return NULL; } @@ -1979,11 +2479,14 @@ static ftdm_status_t ftdm_libpri_stop(ftdm_span_t *span) return FTDM_FAIL; } - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); + ftdm_log(FTDM_LOG_INFO, "Stopping span [s%d][%s]\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); check_state(span); ftdm_set_flag(span, FTDM_SPAN_STOP_THREAD); + lpwrap_stop_pri(&isdn_data->spri); while (ftdm_test_flag(span, FTDM_SPAN_IN_THREAD)) { ftdm_sleep(100); @@ -2009,6 +2512,9 @@ static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span) return FTDM_FAIL; } + ftdm_log(FTDM_LOG_INFO, "Starting span [s%d][%s]\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); @@ -2150,7 +2656,6 @@ static uint32_t parse_opts(const char *in) static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) { ftdm_libpri_data_t *isdn_data = NULL; - //ftdm_channel_t *dchan = NULL; uint32_t bchan_count = 0; uint32_t dchan_count = 0; uint32_t i; @@ -2167,23 +2672,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) case FTDM_CHAN_TYPE_DQ921: if (dchan_count > 1) { ftdm_log(FTDM_LOG_ERROR, "Span has more than 2 D-Channels!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has more than 2 D-Channels!"); return FTDM_FAIL; - } else { -#if 0 - if (ftdm_channel_open(ftdm_span_get_id(span), i, &dchan) == FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "opening D-Channel %d:%d\n", ftdm_channel_get_span_id(dchan), ftdm_channel_get_id(dchan)); - _ftdm_channel_set_state_force(dchan, FTDM_CHANNEL_STATE_UP); - } else { - ftdm_log(FTDM_LOG_ERROR, "Failed to open D-Channel %d:%d\n", ftdm_channel_get_span_id(chan), ftdm_channel_getid(chan)); - snprintf(span->last_error, sizeof(span->last_error), "Failed to open D-Channel %d:%d\n", ftdm_channel_get_span_id(chan), ftdm_channel_getid(chan)); - return FTDM_FAIL; - } -#endif - dchan_count++; } + dchan_count++; break; - case FTDM_CHAN_TYPE_B: bchan_count++; break; @@ -2193,12 +2685,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) } if (!dchan_count) { ftdm_log(FTDM_LOG_ERROR, "Span has no D-Channel!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has no D-Channel!"); return FTDM_FAIL; } if (!bchan_count) { ftdm_log(FTDM_LOG_ERROR, "Span has no B-Channels!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has no B-Channels!"); return FTDM_FAIL; } @@ -2207,16 +2697,22 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) memset(isdn_data, 0, sizeof(*isdn_data)); /* set some default values */ - isdn_data->mode = PRI_CPE; - isdn_data->ton = PRI_UNKNOWN; + isdn_data->ton = PRI_UNKNOWN; + isdn_data->overlap_timeout_ms = OVERLAP_TIMEOUT_MS_DEFAULT; + + /* Use span's trunk_mode as a reference for the default libpri mode */ + if (ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { + isdn_data->mode = PRI_NETWORK; + } else { + isdn_data->mode = PRI_CPE; + } switch (ftdm_span_get_trunk_type(span)) { case FTDM_TRUNK_BRI: case FTDM_TRUNK_BRI_PTMP: #ifndef HAVE_LIBPRI_BRI ftdm_log(FTDM_LOG_ERROR, "Unsupported trunk type: '%s', libpri too old\n", ftdm_span_get_trunk_type_str(span)); - snprintf(span->last_error, sizeof(span->last_error), "Unsupported trunk type [%s], libpri too old", ftdm_span_get_trunk_type_str(span)); - return FTDM_FAIL; + goto error; #endif case FTDM_TRUNK_E1: ftdm_log(FTDM_LOG_NOTICE, "Setting default Layer 1 to ALAW since this is an E1/BRI/BRI PTMP trunk\n"); @@ -2231,8 +2727,15 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) break; default: ftdm_log(FTDM_LOG_ERROR, "Invalid trunk type: '%s'\n", ftdm_span_get_trunk_type_str(span)); - snprintf(span->last_error, sizeof(span->last_error), "Invalid trunk type [%s]", ftdm_span_get_trunk_type_str(span)); - return FTDM_FAIL; + goto error; + } + + /* + * Init MSN filter + */ + if (msn_filter_init(isdn_data) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "Failed to init MSN filter\n"); + goto error; } for (i = 0; ftdm_parameters[i].var; i++) { @@ -2246,14 +2749,13 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) if (ftdm_strlen_zero(val)) { ftdm_log(FTDM_LOG_ERROR, "Parameter '%s' has no value\n", var); - snprintf(span->last_error, sizeof(span->last_error), "Parameter [%s] has no value", var); - return FTDM_FAIL; + goto error; } if (!strcasecmp(var, "node") || !strcasecmp(var, "mode")) { if ((isdn_data->mode = parse_mode(val)) == -1) { - ftdm_log(FTDM_LOG_ERROR, "Unknown node type '%s', defaulting to CPE mode\n", val); - isdn_data->mode = PRI_CPE; + ftdm_log(FTDM_LOG_ERROR, "Unknown node type '%s'\n", val); + goto error; } } else if (!strcasecmp(var, "switch") || !strcasecmp(var, "dialect")) { @@ -2274,6 +2776,17 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) isdn_data->overlap = FTMOD_LIBPRI_OVERLAP_NONE; } } + else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "t302")) { + int tmp = atoi(val); + if (!tmp) { + isdn_data->overlap_timeout_ms = 0; /* disabled */ + } + else if ((isdn_data->overlap_timeout_ms = ftdm_clamp(tmp, OVERLAP_TIMEOUT_MS_MIN, OVERLAP_TIMEOUT_MS_MAX)) != tmp) { + ftdm_log(FTDM_LOG_WARNING, "'%s' value '%d' outside of range [%d:%d], using '%d' ms instead\n", + var, tmp, OVERLAP_TIMEOUT_MS_MIN, OVERLAP_TIMEOUT_MS_MAX, + isdn_data->overlap_timeout_ms); + } + } else if (!strcasecmp(var, "debug")) { if (parse_debug(val, &isdn_data->debug_mask) == -1) { ftdm_log(FTDM_LOG_ERROR, "Invalid debug flag, ignoring parameter\n"); @@ -2285,13 +2798,28 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) isdn_data->service_message_support = 1; } } + else if (!strcasecmp(var, "local-number") || !strcasecmp(var, "msn")) { + if (msn_filter_add(isdn_data, val) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "Invalid MSN/DDI(s) '%s' specified\n", val); + goto error; + } + } else { ftdm_log(FTDM_LOG_ERROR, "Unknown parameter '%s', aborting configuration\n", var); - snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var); - return FTDM_FAIL; + goto error; } } + /* Check if modes match and log a message if they do not. Just to be on the safe side. */ + if (isdn_data->mode == PRI_CPE && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { + ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for TE/CPE/USER mode, while port is running in NT/NET mode. You may want to check your 'trunk_mode' settings.\n", + ftdm_span_get_name(span)); + } + else if (isdn_data->mode == PRI_NETWORK && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_CPE) { + ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for NT/NET mode, while port is running in TE/CPE/USER mode. You may want to check your 'trunk_mode' settings.\n", + ftdm_span_get_name(span)); + } + span->start = ftdm_libpri_start; span->stop = ftdm_libpri_stop; span->signal_cb = sig_cb; @@ -2314,7 +2842,31 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) ftdm_set_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID); } + /* Allocate per-channel private data */ + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + ftdm_channel_t *chan = ftdm_span_get_channel(span, i); + + if (!chan) + continue; + + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *priv = NULL; + + priv = calloc(1, sizeof(*priv)); + if (!priv) { + ftdm_log_chan_msg(chan, FTDM_LOG_CRIT, "Failed to allocate per-channel private data\n"); + goto error; + } + priv->channel = chan; + chan->call_data = priv; + } + } return FTDM_SUCCESS; +error: + /* TODO: free per-channel private data */ + msn_filter_destroy(isdn_data); + ftdm_safe_free(isdn_data); + return FTDM_FAIL; } /** diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h index 27b1763fec..fcaa1bc457 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,18 +30,21 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -typedef enum { - SERVICE_CHANGE_STATUS_INSERVICE = 0, - SERVICE_CHANGE_STATUS_MAINTENANCE = 1, - SERVICE_CHANGE_STATUS_OUTOFSERVICE = 2 -} service_change_status_t; - #ifndef FTMOD_LIBPRI_H #define FTMOD_LIBPRI_H #include "freetdm.h" #include "lpwrap_pri.h" +#define OVERLAP_TIMEOUT_MS_DEFAULT 5000 /* 5 sec */ +#define OVERLAP_TIMEOUT_MS_MIN 3000 /* 3 sec */ +#define OVERLAP_TIMEOUT_MS_MAX 30000 /* 30 sec */ + +typedef enum { + SERVICE_CHANGE_STATUS_INSERVICE = 0, + SERVICE_CHANGE_STATUS_MAINTENANCE, + SERVICE_CHANGE_STATUS_OUTOFSERVICE +} service_change_status_t; + typedef enum { FTMOD_LIBPRI_OPT_NONE = 0, FTMOD_LIBPRI_OPT_SUGGEST_CHANNEL = (1 << 0), @@ -72,15 +75,41 @@ struct ftdm_libpri_data { int mode; int dialect; int overlap; /*!< Overlap dial flags */ + int overlap_timeout_ms; /*!< Overlap dial timeout */ unsigned int layer1; unsigned int ton; unsigned int service_message_support; lpwrap_pri_t spri; + + /* MSN filter */ + ftdm_hash_t *msn_hash; + ftdm_mutex_t *msn_mutex; }; typedef struct ftdm_libpri_data ftdm_libpri_data_t; + +/* + * b-channel flags + */ +enum { + FTDM_LIBPRI_B_NONE = 0, + FTDM_LIBPRI_B_REMOTE_RESTART = (1 << 0), /*!< Remote triggered channel restart */ +}; + +/** + * Per-b-channel private data + */ +struct ftdm_libpri_b_chan { + struct lpwrap_timer t302; /*!< T302 overlap receive timer */ + ftdm_channel_t *channel; /*!< back-pointer to b-channel */ + q931_call *call; /*!< libpri opaque call handle */ + uint32_t flags; /*!< channel flags */ +}; + +typedef struct ftdm_libpri_b_chan ftdm_libpri_b_chan_t; + #endif /* For Emacs: diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c index bfb67e4c78..7cbcc7cd41 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,51 +36,7 @@ #include "private/ftdm_core.h" #include "lpwrap_pri.h" -#ifndef HAVE_GETTIMEOFDAY -#ifdef WIN32 -#include - -static __inline int gettimeofday(struct timeval *tp, void *nothing) -{ -#ifdef WITHOUT_MM_LIB - SYSTEMTIME st; - time_t tt; - struct tm tmtm; - /* mktime converts local to UTC */ - GetLocalTime (&st); - tmtm.tm_sec = st.wSecond; - tmtm.tm_min = st.wMinute; - tmtm.tm_hour = st.wHour; - tmtm.tm_mday = st.wDay; - tmtm.tm_mon = st.wMonth - 1; - tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1; - tt = mktime (&tmtm); - tp->tv_sec = tt; - tp->tv_usec = st.wMilliseconds * 1000; -#else - /** - ** The earlier time calculations using GetLocalTime - ** had a time resolution of 10ms.The timeGetTime, part - ** of multimedia apis offer a better time resolution - ** of 1ms.Need to link against winmm.lib for this - **/ - unsigned long Ticks = 0; - unsigned long Sec =0; - unsigned long Usec = 0; - Ticks = timeGetTime(); - - Sec = Ticks/1000; - Usec = (Ticks - (Sec*1000))*1000; - tp->tv_sec = Sec; - tp->tv_usec = Usec; -#endif /* WITHOUT_MM_LIB */ - (void)nothing; - return 0; -} -#endif /* WIN32 */ -#endif /* HAVE_GETTIMEOFDAY */ - -static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[] = { +static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[LPWRAP_PRI_EVENT_MAX] = { {0, LPWRAP_PRI_EVENT_ANY, "ANY"}, {1, LPWRAP_PRI_EVENT_DCHAN_UP, "DCHAN_UP"}, {2, LPWRAP_PRI_EVENT_DCHAN_DOWN, "DCHAN_DOWN"}, @@ -103,8 +59,6 @@ static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[] = { {19, LPWRAP_PRI_EVENT_IO_FAIL, "IO_FAIL"}, }; -#define LINE "--------------------------------------------------------------------------------" - const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id) { if (event_id < 0 || event_id >= LPWRAP_PRI_EVENT_MAX) @@ -170,6 +124,10 @@ static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen) return (int)buflen; } + +/* + * Unified init function for BRI + PRI libpri spans + */ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug) { int ret = -1; @@ -179,115 +137,255 @@ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t * spri->span = span; if (!spri->dchan) { - ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create PRI\n"); + ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create BRI/PRI\n"); return ret; } - if ((spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))) { - unsigned char buf[4] = { 0 }; - size_t buflen = sizeof(buf), len = 0; - - pri_set_debug(spri->pri, debug); -#ifdef HAVE_LIBPRI_AOC - pri_aoc_events_enable(spri->pri, 1); -#endif - ftdm_channel_write(spri->dchan, buf, buflen, &len); - - ret = 0; - } else { - ftdm_log(FTDM_LOG_ERROR, "Unable to create PRI\n"); + if (ftdm_mutex_create(&spri->timer_mutex) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "Failed to create timer list mutex\n"); + return ret; } - return ret; -} - -int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug) -{ - int ret = -1; + switch (ftdm_span_get_trunk_type(span)) { + case FTDM_TRUNK_E1: + case FTDM_TRUNK_J1: + case FTDM_TRUNK_T1: + spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); + break; #ifdef HAVE_LIBPRI_BRI - memset(spri, 0, sizeof(struct lpwrap_pri)); - spri->dchan = dchan; - spri->span = span; - - if (!spri->dchan) { - ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create BRI\n"); + case FTDM_TRUNK_BRI: + spri->pri = pri_new_bri_cb(spri->dchan->sockfd, 1, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); + break; + case FTDM_TRUNK_BRI_PTMP: + spri->pri = pri_new_bri_cb(spri->dchan->sockfd, 0, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); + break; +#endif + default: + ftdm_log(FTDM_LOG_CRIT, "Invalid/unsupported trunk type '%s'\n", + ftdm_span_get_trunk_type_str(span)); + ftdm_mutex_destroy(&spri->timer_mutex); return ret; } - if ((spri->pri = pri_new_bri_cb(spri->dchan->sockfd, ptp, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))) { - unsigned char buf[4] = { 0 }; - size_t buflen = sizeof(buf), len = 0; - + if (spri->pri) { pri_set_debug(spri->pri, debug); #ifdef HAVE_LIBPRI_AOC pri_aoc_events_enable(spri->pri, 1); #endif - ftdm_channel_write(spri->dchan, buf, buflen, &len); - ret = 0; } else { - ftdm_log(FTDM_LOG_ERROR, "Unable to create BRI\n"); + ftdm_log(FTDM_LOG_CRIT, "Unable to create BRI/PRI\n"); + ftdm_mutex_destroy(&spri->timer_mutex); } -#else - ftdm_log(FTDM_LOG_ERROR, "Installed libpri version (%s) has no BRI support\n", - pri_get_version()); -#endif return ret; } -int lpwrap_one_loop(struct lpwrap_pri *spri) +#define timeval_to_ms(x) \ + (((ftdm_time_t)(x)->tv_sec * 1000) + (ftdm_time_t)((x)->tv_usec / 1000)) + +int lpwrap_start_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer, const uint32_t timeout_ms, timeout_handler callback) { - fd_set rfds, efds; - struct timeval now = {0,0}, *next = NULL; + struct lpwrap_timer **prev, *cur; + + if (!spri || !timer || timer->timeout) + return -1; + + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "-- Starting timer %p with timeout %u ms\n", + timer, timeout_ms); + + timer->timeout = ftdm_current_time_in_ms() + timeout_ms; + timer->callback = callback; + timer->next = NULL; + + ftdm_mutex_lock(spri->timer_mutex); + + for (prev = &spri->timer_list, cur = spri->timer_list; cur; prev = &(*prev)->next, cur = cur->next) { + if (cur->timeout < timer->timeout) { + *prev = timer; + timer->next = cur; + break; + } + } + if (!cur) { + *prev = timer; + } + + ftdm_mutex_unlock(spri->timer_mutex); + return 0; +} + +int lpwrap_stop_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer) +{ + struct lpwrap_timer **prev, *cur; + + if (!spri || !timer) + return -1; + + if (!timer->timeout) + return 0; + + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "-- Stopping timer %p\n", timer); + + ftdm_mutex_lock(spri->timer_mutex); + + for (prev = &spri->timer_list, cur = spri->timer_list; cur; prev = &(*prev)->next, cur = cur->next) { + if (cur == timer) { + *prev = cur->next; + break; + } + } + + ftdm_mutex_unlock(spri->timer_mutex); + + timer->next = NULL; + timer->timeout = 0; + timer->callback = NULL; + return 0; +} + +static struct lpwrap_timer *lpwrap_timer_next(struct lpwrap_pri *spri) +{ + return spri ? spri->timer_list : NULL; +} + +static int lpwrap_run_expired(struct lpwrap_pri *spri, ftdm_time_t now_ms) +{ + struct lpwrap_timer *expired_list = NULL; + struct lpwrap_timer **prev, *cur; + + if (!spri || !spri->timer_list) + return 0; + + ftdm_mutex_lock(spri->timer_mutex); + + /* Move all timers to expired list */ + expired_list = spri->timer_list; + + for (prev = &expired_list, cur = expired_list; cur; prev = &(*prev)->next, cur = cur->next) { + if (cur->timeout > now_ms) { + *prev = NULL; + break; + } + } + /* Move non-expired timer to front of timer_list (or clear list if there are none) */ + spri->timer_list = cur; + + ftdm_mutex_unlock(spri->timer_mutex); + + /* fire callbacks */ + while ((cur = expired_list)) { + expired_list = cur->next; + if (cur->callback) + cur->callback(spri, cur); + /* stop timer */ + cur->next = NULL; + cur->timeout = 0; + cur->callback = NULL; + } + + return 0; +} + + +#define LPWRAP_MAX_TIMEOUT_MS 100 +#define LPWRAP_MAX_ERRORS 2 + +int lpwrap_run_pri_once(struct lpwrap_pri *spri) +{ + struct timeval *next = NULL; + struct lpwrap_timer *timer = NULL; pri_event *event = NULL; - event_handler handler; - int sel; + ftdm_wait_flag_t flags; + ftdm_time_t now_ms, next_ms, timeout_ms, tmp_ms; + int ret; if (spri->on_loop) { - if ((sel = spri->on_loop(spri)) < 0) { - return sel; + if ((ret = spri->on_loop(spri)) < 0) + return FTDM_FAIL; + } + + /* Default timeout when no scheduled events are pending */ + timeout_ms = LPWRAP_MAX_TIMEOUT_MS; + next_ms = 0; + now_ms = ftdm_current_time_in_ms(); + + /* + * Get the next scheduled timer from libpri to set the maximum timeout, + * but limit it to MAX_TIMEOUT_MS (100ms). + */ + if ((next = pri_schedule_next(spri->pri))) { + next_ms = timeval_to_ms(next); + if (now_ms >= next_ms) { + /* Already late, handle timeout */ + timeout_ms = 0; + } else { + /* Calculate new timeout and limit it to MAX_TIMEOUT_MS miliseconds */ + tmp_ms = ftdm_min(next_ms - now_ms, LPWRAP_MAX_TIMEOUT_MS); + timeout_ms = ftdm_min(timeout_ms, tmp_ms); } } - if (spri->errs >= 2) { - spri->errs = 0; - return -1; + /* + * Next lpwrap_timer timeout + */ + if ((timer = lpwrap_timer_next(spri))) { + if (now_ms >= timer->timeout) { + /* Already late, handle timeout */ + timeout_ms = 0; + } else { + /* Calculate new timeout and limit it to MAX_TIMEOUT_MS miliseconds */ + tmp_ms = ftdm_min(timer->timeout - now_ms, LPWRAP_MAX_TIMEOUT_MS); + timeout_ms = ftdm_min(timeout_ms, tmp_ms); + } } - FD_ZERO(&rfds); - FD_ZERO(&efds); + /* */ + if (timeout_ms > 0) { + flags = FTDM_READ | FTDM_EVENTS; + ret = ftdm_channel_wait(spri->dchan, &flags, timeout_ms); -#ifdef _MSC_VER - //Windows macro for FD_SET includes a warning C4127: conditional expression is constant -#pragma warning(push) -#pragma warning(disable:4127) -#endif + if (spri->flags & LPWRAP_PRI_ABORT) + return FTDM_SUCCESS; - FD_SET(pri_fd(spri->pri), &rfds); - FD_SET(pri_fd(spri->pri), &efds); + if (ret == FTDM_TIMEOUT) { + now_ms = ftdm_current_time_in_ms(); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - now.tv_sec = 0; - now.tv_usec = 100000; - - sel = select(pri_fd(spri->pri) + 1, &rfds, NULL, &efds, &now); - if (!sel) { - if ((next = pri_schedule_next(spri->pri))) { - gettimeofday(&now, NULL); - if (now.tv_sec >= next->tv_sec && (now.tv_usec >= next->tv_usec || next->tv_usec <= 100000)) { - //ftdm_log(FTDM_LOG_DEBUG, "Check event\n"); + if (next) { + if (next_ms < now_ms) { + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "pri timer %d ms late\n", + (int)(now_ms - next_ms)); + } event = pri_schedule_run(spri->pri); } + if (timer) { + if (timer->timeout < now_ms) { + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "lpwrap timer %d ms late\n", + (int)(now_ms - timer->timeout)); + } + lpwrap_run_expired(spri, now_ms); + } + } else if (flags & (FTDM_READ | FTDM_EVENTS)) { + event = pri_check_event(spri->pri); + } + } else { + /* + * Scheduled event has already expired, handle it immediately + */ + if (next) { + event = pri_schedule_run(spri->pri); + } + if (timer) { + lpwrap_run_expired(spri, now_ms); } - } else if (sel > 0) { - event = pri_check_event(spri->pri); } + if (spri->flags & LPWRAP_PRI_ABORT) + return FTDM_SUCCESS; + if (event) { + event_handler handler; + /* 0 is catchall event handler */ if (event->e < 0 || event->e >= LPWRAP_PRI_EVENT_MAX) { handler = spri->eventmap[0]; @@ -303,28 +401,47 @@ int lpwrap_one_loop(struct lpwrap_pri *spri) ftdm_log(FTDM_LOG_CRIT, "No event handler found for event %d.\n", event->e); } } - return sel; + + return FTDM_SUCCESS; } int lpwrap_run_pri(struct lpwrap_pri *spri) { int ret = 0; - for (;;) { - if ((ret = lpwrap_one_loop(spri)) < 0) { -#ifndef WIN32 //This needs to be adressed fror WIN32 still - if (errno == EINTR){ - /* Igonore an interrupted system call */ - continue; - } -#endif - ftdm_log(FTDM_LOG_CRIT, "Error = %i [%s]\n", ret, strerror(errno)); + while (!(spri->flags & LPWRAP_PRI_ABORT)) { + ret = lpwrap_run_pri_once(spri); + if (ret) { + ftdm_log(FTDM_LOG_ERROR, "Error = %d, [%s]\n", + ret, strerror(errno)); + spri->errs++; + } else { + spri->errs = 0; + } + if (!ftdm_running()) + break; + if (spri->errs >= LPWRAP_MAX_ERRORS) { + ftdm_log(FTDM_LOG_CRIT, "Too many errors on span, restarting\n"); + spri->errs = 0; break; } } return ret; } +int lpwrap_stop_pri(struct lpwrap_pri *spri) +{ + spri->flags |= LPWRAP_PRI_ABORT; + return FTDM_SUCCESS; +} + +int lpwrap_destroy_pri(struct lpwrap_pri *spri) +{ + if (spri->timer_mutex) + ftdm_mutex_destroy(&spri->timer_mutex); + return FTDM_SUCCESS; +} + /* For Emacs: * Local Variables: * mode:c diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h index b62e5fb176..89708da270 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h +++ b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -92,10 +92,14 @@ typedef enum { } lpwrap_pri_switch_t; typedef enum { - LPWRAP_PRI_READY = (1 << 0) + LPWRAP_PRI_READY = (1 << 0), + LPWRAP_PRI_ABORT = (1 << 1) } lpwrap_pri_flag_t; struct lpwrap_pri; +struct lpwrap_timer; + +typedef int (*timeout_handler)(struct lpwrap_pri *, struct lpwrap_timer *); typedef int (*event_handler)(struct lpwrap_pri *, lpwrap_pri_event_t, pri_event *); typedef int (*loop_handler)(struct lpwrap_pri *); @@ -108,6 +112,8 @@ struct lpwrap_pri { event_handler eventmap[LPWRAP_PRI_EVENT_MAX]; loop_handler on_loop; int errs; + struct lpwrap_timer *timer_list; + ftdm_mutex_t *timer_mutex; }; typedef struct lpwrap_pri lpwrap_pri_t; @@ -118,15 +124,21 @@ struct lpwrap_pri_event_list { const char *name; }; +struct lpwrap_timer { + struct lpwrap_timer *next; + ftdm_time_t timeout; + timeout_handler callback; +}; +int lpwrap_start_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer, const uint32_t timeout_ms, timeout_handler callback); +int lpwrap_stop_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer); #define LPWRAP_MAP_PRI_EVENT(spri, event, func) spri.eventmap[event] = func; - const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id); -int lpwrap_one_loop(struct lpwrap_pri *spri); -int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug); -int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug); -int lpwrap_run_pri(struct lpwrap_pri *spri); -#define lpwrap_run_bri(x) lpwrap_run_pri(x) +int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug); +int lpwrap_destroy_pri(struct lpwrap_pri *spri); +int lpwrap_run_pri_once(struct lpwrap_pri *spri); +int lpwrap_run_pri(struct lpwrap_pri *spri); +int lpwrap_stop_pri(struct lpwrap_pri *spri); #endif diff --git a/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c b/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c index 60e3c1425d..84133601f3 100644 --- a/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c +++ b/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c @@ -44,6 +44,7 @@ #include #include #include +#include /* this is how it should have been... #ifdef HAVE_FREETDM_FREETDM_H @@ -70,18 +71,7 @@ //#define MISDN_DEBUG_EVENTS //#define MISDN_DEBUG_IO -#ifndef MIN -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#endif - -#ifndef MAX -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef CLAMP -#define CLAMP(val,min,max) (MIN(max,MAX(min,val))) -#endif - +#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) typedef enum { MISDN_CAPS_NONE = 0, @@ -157,7 +147,7 @@ const static struct { #undef MISDN_CONTROL_TYPE }; -#if 0 /* unused for now */ +#ifdef MISDN_DEBUG_EVENTS static const char *misdn_control2str(const int ctrl) { int x; @@ -231,6 +221,16 @@ static inline void misdn_convert_audio_bits(char *buf, int buflen) * mISDN <-> FreeTDM data structures ***********************************************************************************/ +typedef enum { + MISDN_CMD_NONE = 0, + MISDN_CMD_STOP, /*!< Stop the I/O thread */ +} misdn_cmd_t; + +struct misdn_command { + misdn_cmd_t type; +/* union { } cmd; */ /*!< Command-specific parameters */ +}; + enum { MISDN_SPAN_NONE = 0, MISDN_SPAN_RUNNING = (1 << 0), @@ -239,29 +239,35 @@ enum { struct misdn_span_private { int flags; + int running; + + int event_pipe_in; + int event_pipe_out; /* event conditional */ pthread_mutex_t event_cond_mutex; pthread_cond_t event_cond; -}; -#define MISDN_CHAN_STATE_CLOSED 0 -#define MISDN_CHAN_STATE_OPEN 1 + /* start / stop feedback */ + pthread_mutex_t ctrl_cond_mutex; + pthread_cond_t ctrl_cond; +}; struct misdn_event_queue; struct misdn_chan_private { /* */ - int state; int debugfd; int active; /* hw addr of channel */ struct sockaddr_mISDN addr; - /* audio tx pipe */ - int audio_pipe_in; - int audio_pipe_out; + /* audio tx pipe (= socketpair ends) */ + int tx_audio_pipe_in; + int tx_audio_pipe_out; + int rx_audio_pipe_in; + int rx_audio_pipe_out; /* counters */ unsigned long tx_cnt; @@ -270,6 +276,14 @@ struct misdn_chan_private { unsigned long slip_rx_cnt; unsigned long slip_tx_cnt; + unsigned long tx_pipe_wr_bytes; /*!< Number of bytes written into tx audio pipe */ + unsigned long tx_pipe_rd_bytes; /*!< Number of bytes read from tx audio pipe */ + unsigned long tx_miss_bytes; /*!< Number of bytes missing in short reads from tx audio pipe */ + unsigned long tx_lost_bytes; /*!< Number of bytes lost in short writes to the mISDN B-Channel */ + unsigned long tx_sent_bytes; /*!< Number of bytes successfully sent to the mISDN B-Channel */ + unsigned long tx_pipe_under_cnt; /*!< Number of tx audio pipe underflows */ + unsigned long tx_pipe_over_cnt; /*!< Number of tx audio pipe overflows */ + struct misdn_event_queue *events; }; @@ -470,7 +484,50 @@ static inline int ts_before(struct timespec *a, struct timespec *b) return 0; } -static ftdm_status_t misdn_activate_channel(ftdm_channel_t *chan, int activate) +/* + * Asynchronous channel (de-)activation + */ +static ftdm_status_t _misdn_toggle_channel_nowait(ftdm_channel_t *chan, int activate) +{ + struct misdn_chan_private *priv = ftdm_chan_io_private(chan); + char buf[MAX_DATA_MEM] = { 0 }; + struct mISDNhead *hh = (struct mISDNhead *) buf; + int retval; + + /* NOTE: sending PH_DEACTIVATE_REQ to closed b-channels kills the d-channel (hfcsusb)... */ + if ((activate && priv->active) || (!activate && !priv->active)) + return FTDM_SUCCESS; + + ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN sending %s request\n", + (activate) ? "activation" : "deactivation"); + + /* prepare + send request primitive */ + hh->prim = (activate) ? PH_ACTIVATE_REQ : PH_DEACTIVATE_REQ; + hh->id = MISDN_ID_ANY; + + if ((retval = sendto(chan->sockfd, hh, sizeof(*hh), 0, NULL, 0)) < sizeof(*hh)) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to send activation request: %s\n", + strerror(errno)); + return FTDM_FAIL; + } + + return FTDM_SUCCESS; +} + +static ftdm_status_t misdn_activate_channel_nowait(ftdm_channel_t *chan) +{ + return _misdn_toggle_channel_nowait(chan, 1); +} + +static ftdm_status_t misdn_deactivate_channel_nowait(ftdm_channel_t *chan) +{ + return _misdn_toggle_channel_nowait(chan, 0); +} + +/* + * Synchronous channel (de-)activation + */ +static ftdm_status_t _misdn_toggle_channel(ftdm_channel_t *chan, int activate) { struct misdn_chan_private *priv = ftdm_chan_io_private(chan); char buf[MAX_DATA_MEM] = { 0 }; @@ -530,11 +587,11 @@ static ftdm_status_t misdn_activate_channel(ftdm_channel_t *chan, int activate) (activate) ? "activation" : "deactivation", strerror(errno)); return FTDM_FAIL; } -//#ifdef MISDN_DEBUG_EVENTS +#ifdef MISDN_DEBUG_EVENTS ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN got event '%s (%#x)', id %#x, while waiting for %s confirmation on %c-channel\n", misdn_event2str(hh->prim), hh->prim, hh->id, (activate) ? "activation" : "deactivation", ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); -//#endif +#endif switch (hh->prim) { case PH_ACTIVATE_IND: case PH_ACTIVATE_CNF: @@ -590,6 +647,16 @@ out: return FTDM_SUCCESS; } +static ftdm_status_t misdn_activate_channel(ftdm_channel_t *chan) +{ + return _misdn_toggle_channel(chan, 1); +} + +static ftdm_status_t misdn_deactivate_channel(ftdm_channel_t *chan) +{ + return _misdn_toggle_channel(chan, 0); +} + #if 0 /* unused for now */ static ftdm_status_t misdn_get_ph_info(ftdm_channel_t *chan, struct ph_info *info) @@ -648,10 +715,10 @@ static ftdm_status_t misdn_get_ph_info(ftdm_channel_t *chan, struct ph_info *inf misdn_event2str(req), strerror(errno)); return FTDM_FAIL; } -//#ifdef MISDN_DEBUG_EVENTS +#ifdef MISDN_DEBUG_EVENTS ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN got event '%s' while waiting for %s answer\n", misdn_event2str(hh->prim), misdn_event2str(req)); -//#endif +#endif switch (hh->prim) { case MPH_INFORMATION_IND: /* success */ if (retval < MISDN_HEADER_LEN + sizeof(*info)) { @@ -831,7 +898,7 @@ static int misdn_handle_mph_information_ind(ftdm_channel_t *chan, const struct m } bch_info = &info->bch[0]; - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN port state:\n\tD-Chan proto:\t%hu\n\tD-Chan state:\t%s (%hu)\n\tD-Chan flags:\t%#lx\n\t\t\t%-70s\n", + ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN port state:\n\tD-Chan proto:\t%hu\n\tD-Chan state:\t%s (%hu)\n\tD-Chan flags:\t%#"FTDM_XINT64_FMT"\n\t\t\t%-70s\n", info->dch.ch.protocol, misdn_hw_state_name(info->dch.ch.protocol, info->dch.state), info->dch.state, info->dch.ch.Flags, @@ -899,7 +966,7 @@ static int misdn_handle_mph_information_ind(ftdm_channel_t *chan, const struct m * mISDN <-> FreeTDM interface functions ***********************************************************************************/ -struct misdn_globals { +static struct misdn_globals { int sockfd; } globals; @@ -917,7 +984,7 @@ static FIO_OPEN_FUNCTION(misdn_open) assert(chan_priv); assert(span_priv); - if (chan_priv->state == MISDN_CHAN_STATE_OPEN) { + if (chan_priv->active) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "mISDN channel is already open, skipping activation\n"); return FTDM_SUCCESS; } @@ -928,24 +995,27 @@ static FIO_OPEN_FUNCTION(misdn_open) /* * Send activation request */ - ret = misdn_activate_channel(ftdmchan, 1); + ret = misdn_activate_channel(ftdmchan); if (ret != FTDM_SUCCESS) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to activate channel (socket: %d)\n", ftdmchan->sockfd); - return FTDM_FAIL; - } + /* + * Ignore error, ftdm_channel_open() does not correctly handle return FTDM_FAIL cases. + * We will try to activate the channel later. + */ + } else { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN channel activation request sent\n"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN channel activation request sent\n"); - - switch (ftdmchan->type) { - case FTDM_CHAN_TYPE_B: - case FTDM_CHAN_TYPE_DQ921: - chan_priv->state = MISDN_CHAN_STATE_OPEN; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN invalid channel type '%s'\n", - ftdm_channel_get_type_str(ftdmchan)); - break; + switch (ftdmchan->type) { + case FTDM_CHAN_TYPE_B: + case FTDM_CHAN_TYPE_DQ921: + chan_priv->active = 1; + break; + default: + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN invalid channel type '%s'\n", + ftdm_channel_get_type_str(ftdmchan)); + break; + } } return FTDM_SUCCESS; } @@ -964,21 +1034,30 @@ static FIO_CLOSE_FUNCTION(misdn_close) ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "mISDN trying to close %c-channel\n", ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); - /* deactivate b-channels on close */ - if (ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B) { - /* - * Send deactivation request (don't wait for answer) - */ - ret = misdn_activate_channel(ftdmchan, 0); + if (chan_priv->active) { + + if (ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B) { + ret = misdn_deactivate_channel(ftdmchan); + } else { + /* Don't wait for D-Channel deactivation */ + ret = misdn_deactivate_channel_nowait(ftdmchan); + } + if (ret != FTDM_SUCCESS) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to deactivate %c-channel\n", ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); - return FTDM_FAIL; + /* Ignore error, channel might be closed already */ + } else { + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "mISDN %c-channel deactivated\n", + ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); } - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "mISDN %c-channel deactivated\n", - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); - chan_priv->state = MISDN_CHAN_STATE_CLOSED; + ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "mISDN tx stats: wr: %lu, rd: %lu, tx: %lu, tx-lost: %lu, tx-miss: %lu, tx-under#: %lu, tx-over#: %lu\n", + chan_priv->tx_pipe_wr_bytes, chan_priv->tx_pipe_rd_bytes, + chan_priv->tx_sent_bytes, chan_priv->tx_lost_bytes, chan_priv->tx_miss_bytes, + chan_priv->tx_pipe_over_cnt, chan_priv->tx_pipe_under_cnt); + + chan_priv->active = 0; } return FTDM_SUCCESS; @@ -1065,16 +1144,22 @@ static FIO_WAIT_FUNCTION(misdn_wait) switch (ftdm_channel_get_type(ftdmchan)) { case FTDM_CHAN_TYPE_B: if (*flags & FTDM_WRITE) { - pfds[nr_fds].fd = chan_priv->audio_pipe_in; + pfds[nr_fds].fd = chan_priv->tx_audio_pipe_in; pfds[nr_fds].events = POLLOUT; nr_fds++; } - if (*flags & (FTDM_READ | FTDM_EVENTS)) { + if (*flags & FTDM_READ) { + pfds[nr_fds].fd = chan_priv->rx_audio_pipe_out; + pfds[nr_fds].events = POLLIN; + nr_fds++; + } +/* if (*flags & (FTDM_READ | FTDM_EVENTS)) { pfds[nr_fds].fd = ftdmchan->sockfd; pfds[nr_fds].events |= (*flags & FTDM_READ) ? POLLIN : 0; pfds[nr_fds].events |= (*flags & FTDM_EVENTS) ? POLLPRI : 0; nr_fds++; } +*/ break; default: if (*flags & FTDM_READ) @@ -1105,7 +1190,7 @@ static FIO_WAIT_FUNCTION(misdn_wait) switch (ftdm_channel_get_type(ftdmchan)) { case FTDM_CHAN_TYPE_B: - if (pfds[0].revents & POLLOUT) + if ((pfds[0].revents & POLLOUT) || (pfds[1].revents & POLLOUT)) *flags |= FTDM_WRITE; if ((pfds[0].revents & POLLIN) || (pfds[1].revents & POLLIN)) *flags |= FTDM_READ; @@ -1127,10 +1212,10 @@ static FIO_WAIT_FUNCTION(misdn_wait) /** * Handle incoming mISDN message on d-channel - * @param[in] ftdmchan - * @param[in] msg_buf - * @param[in] msg_len - * @internal + * \param[in] ftdmchan + * \param[in] msg_buf + * \param[in] msg_len + * \internal */ static ftdm_status_t misdn_handle_incoming(ftdm_channel_t *ftdmchan, const char *msg_buf, const int msg_len) { @@ -1143,7 +1228,7 @@ static ftdm_status_t misdn_handle_incoming(ftdm_channel_t *ftdmchan, const char assert(priv); if (msg_len < sizeof(*hh)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN message to small (%d < %d bytes)\n", + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN message to small (%d < %"FTDM_SIZE_FMT" bytes)\n", msg_len, sizeof(*hh)); return FTDM_FAIL; } @@ -1214,13 +1299,6 @@ static FIO_READ_FUNCTION(misdn_read) int retval; int maxretry = 10; - if (priv->state == MISDN_CHAN_STATE_CLOSED) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN ignoring read on closed channel\n"); - /* ignore */ - *datalen = 0; - return FTDM_SUCCESS; - } - /* nothing read yet */ *datalen = 0; @@ -1229,111 +1307,61 @@ static FIO_READ_FUNCTION(misdn_read) * we'll get a lot of "mISDN_send: error -12" message in dmesg otherwise * (= b-channel receive queue overflowing) */ - while (maxretry--) { - struct sockaddr_mISDN addr; - socklen_t addrlen = sizeof(addr); + switch (ftdm_channel_get_type(ftdmchan)) { + case FTDM_CHAN_TYPE_DQ921: { + while (maxretry--) { + struct sockaddr_mISDN addr; + socklen_t addrlen = sizeof(addr); - if ((retval = recvfrom(ftdmchan->sockfd, rbuf, sizeof(rbuf), 0, (struct sockaddr *)&addr, &addrlen)) < 0) { - if (errno == EWOULDBLOCK || errno == EAGAIN) break; - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to receive incoming message: %s\n", + if ((retval = recvfrom(ftdmchan->sockfd, rbuf, sizeof(rbuf), 0, (struct sockaddr *)&addr, &addrlen)) < 0) { + if (errno == EWOULDBLOCK || errno == EAGAIN) break; + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to receive incoming message: %s\n", + strerror(errno)); + return FTDM_FAIL; + } + + if (retval < MISDN_HEADER_LEN) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "mISDN received message too small\n"); + return FTDM_FAIL; + } + + if (hh->prim == PH_DATA_IND) { + *datalen = ftdm_clamp(retval - MISDN_HEADER_LEN, 0, bytes); + + if (*datalen <= 0) + continue; + + /* + * Copy data into ouput buffer (excluding the mISDN message header) + * NOTE: audio data needs to be converted to a-law / u-law! + */ + memcpy(data, rbuf + MISDN_HEADER_LEN, *datalen); + return FTDM_SUCCESS; + } else { + *datalen = 0; + /* event */ + misdn_handle_incoming(ftdmchan, rbuf, retval); + } + } + break; + } + case FTDM_CHAN_TYPE_B: { + if (!priv->active) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN ignoring read on closed b-channel\n"); + return FTDM_SUCCESS; + } + + if ((retval = read(priv->rx_audio_pipe_out, data, bytes)) < 0) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to read audio data from rx pipe: %s\n", strerror(errno)); return FTDM_FAIL; } - - if (retval < MISDN_HEADER_LEN) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "mISDN received message too small\n"); - return FTDM_FAIL; - } - - if (hh->prim == PH_DATA_IND) { - *datalen = CLAMP(retval - MISDN_HEADER_LEN, 0, bytes); -#ifdef MISDN_DEBUG_IO - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "misdn_read() received '%s', id: %#x, with %d bytes from channel socket %d [dev.ch: %d.%d]\n", - misdn_event2str(hh->prim), hh->id, retval - MISDN_HEADER_LEN, ftdmchan->sockfd, addr.dev, addr.channel); - - if (*datalen > 0) { - char hbuf[MAX_DATA_MEM] = { 0 }; - print_hex_bytes(data, *datalen, hbuf, sizeof(hbuf)); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN read data: %s\n", hbuf); - } -#endif - if (*datalen <= 0) - continue; - - /* - * Copy data into ouput buffer (excluding the mISDN message header) - * NOTE: audio data needs to be converted to a-law / u-law! - */ - memcpy(data, rbuf + MISDN_HEADER_LEN, *datalen); - - switch (ftdm_channel_get_type(ftdmchan)) { - case FTDM_CHAN_TYPE_B: - hh->prim = PH_DATA_REQ; - hh->id = MISDN_ID_ANY; - bytes = *datalen; - - /* Convert incoming audio data to *-law */ - misdn_convert_audio_bits(data, *datalen); - - /* - * Fetch required amount of audio from tx pipe, using the amount - * of received bytes as an indicator for how much free space the - * b-channel tx buffer has available. - * - * (see misdn_write() for the part that fills the tx pipe) - * - * NOTE: can't use blocking I/O here since both parts are serviced - * from the same thread - */ - if ((retval = read(priv->audio_pipe_out, rbuf + MISDN_HEADER_LEN, bytes)) < 0) { - if (!(errno == EAGAIN || errno == EWOULDBLOCK)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to read %d bytes of audio data: %s\n", - bytes, strerror(errno)); - break; - } - /* Tx pipe is empty, completely fill buffer up to "bytes" with silence value */ - retval = 0; - } - - /* - * Use a-law / u-law silence to fill missing bytes, - * in case there was not enough audio data available in the - * tx pipe to satisfy the request. - */ - if (retval < bytes) { - memset(&rbuf[MISDN_HEADER_LEN + retval], - (ftdm_channel_get_codec(ftdmchan) == FTDM_CODEC_ALAW) ? 0x2a : 0xff, - bytes - retval); - } - - /* Convert outgoing audio data to wire format */ - misdn_convert_audio_bits(rbuf + MISDN_HEADER_LEN, bytes); - bytes += MISDN_HEADER_LEN; - - /* Send converted audio to b-channel */ - if ((retval = sendto(ftdmchan->sockfd, rbuf, bytes, 0, (struct sockaddr *)&priv->addr, sizeof(priv->addr))) < bytes) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to send %d bytes of audio data: (%d) %s\n", - bytes, retval, strerror(errno)); - } - break; - default: - break; - } - return FTDM_SUCCESS; - } else { - *datalen = 0; -#ifdef MISDN_DEBUG_IO - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "misdn_read() received '%s', id: %#x, with %d bytes from channel socket %d [dev.ch: %d.%d]\n", - misdn_event2str(hh->prim), hh->id, retval - MISDN_HEADER_LEN, ftdmchan->sockfd, addr.dev, addr.channel); -#endif - /* event */ - misdn_handle_incoming(ftdmchan, rbuf, retval); - } + *datalen = retval; + break; + } + default: + break; } -#ifdef MISDN_DEBUG_IO - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN nothing received on %c-channel\n", - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); -#endif return FTDM_SUCCESS; } @@ -1369,6 +1397,13 @@ static FIO_WRITE_FUNCTION(misdn_write) switch (ftdm_channel_get_type(ftdmchan)) { case FTDM_CHAN_TYPE_B: + /* + * Check state, send activation request (async) if channel is not open + */ + if (!priv->active) { + misdn_activate_channel_nowait(ftdmchan); + return FTDM_SUCCESS; /* eat data */ + } /* * Write to audio pipe, misdn_read() will pull * from there as needed and send it to the b-channel @@ -1376,11 +1411,18 @@ static FIO_WRITE_FUNCTION(misdn_write) * NOTE: can't use blocking I/O here since both parts are serviced * from the same thread */ - if ((retval = write(priv->audio_pipe_in, data, size)) < size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN channel audio pipe write error: %s\n", - strerror(errno)); + if ((retval = write(priv->tx_audio_pipe_in, data, size)) < 0) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN channel audio pipe write error [wr: %lu, rd: %lu: tx: %lu, tx-under#: %lu, tx-over#: %lu]: %s\n", + priv->tx_pipe_wr_bytes, priv->tx_pipe_rd_bytes, priv->tx_sent_bytes, + priv->tx_pipe_under_cnt, priv->tx_pipe_over_cnt, strerror(errno)); return FTDM_FAIL; + } else if (retval < size) { + priv->tx_pipe_over_cnt++; + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "mISDN channel audio pipe short write [wr: %lu, rd: %lu: tx: %lu, tx-under#: %lu, tx-over#: %lu], expected: %d, written: %d\n", + priv->tx_pipe_wr_bytes, priv->tx_pipe_rd_bytes, priv->tx_sent_bytes, + priv->tx_pipe_under_cnt, priv->tx_pipe_over_cnt, size, retval); } + ACCESS_ONCE(priv->tx_pipe_wr_bytes) += retval; *datalen = retval; break; default: @@ -1388,11 +1430,22 @@ static FIO_WRITE_FUNCTION(misdn_write) hh->id = MISDN_ID_ANY; /* Avoid buffer overflow */ - size = MIN(size, MAX_DATA_MEM - MISDN_HEADER_LEN); + size = ftdm_min(size, MAX_DATA_MEM - MISDN_HEADER_LEN); memcpy(wbuf + MISDN_HEADER_LEN, data, size); size += MISDN_HEADER_LEN; + /* + * Check state, send activation request (sync) if channel is not open + */ + if (!priv->active) { + retval = misdn_activate_channel(ftdmchan); + if (retval) { + *datalen = 0; + return FTDM_FAIL; + } + } + /* wait for channel to get ready */ wflags = FTDM_WRITE; retval = misdn_wait(ftdmchan, &wflags, 20); @@ -1420,6 +1473,12 @@ static FIO_WRITE_FUNCTION(misdn_write) return FTDM_SUCCESS; } +/** + * Carefully choosen size for socket send/recv buffers + * larger values will add more latency, while lower values will cause deadlocks + * (see misdn_span_run() comments below for an explanation) + */ +#define SOCKETPAIR_BUFFER_SIZE 3072 static ftdm_status_t misdn_open_range(ftdm_span_t *span, ftdm_chan_type_t type, struct mISDN_devinfo *devinfo, int start, int end) { @@ -1432,12 +1491,12 @@ static ftdm_status_t misdn_open_range(ftdm_span_t *span, ftdm_chan_type_t type, switch (ftdm_span_get_trunk_type(span)) { case FTDM_TRUNK_E1: - d_protocol = ISDN_P_TE_E1; + d_protocol = ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET ? ISDN_P_NT_E1 : ISDN_P_TE_E1; d_channel = 16; break; case FTDM_TRUNK_BRI: case FTDM_TRUNK_BRI_PTMP: - d_protocol = ISDN_P_TE_S0; + d_protocol = ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET ? ISDN_P_NT_S0 : ISDN_P_TE_S0; d_channel = 0; break; default: @@ -1494,9 +1553,11 @@ static ftdm_status_t misdn_open_range(ftdm_span_t *span, ftdm_chan_type_t type, ftdm_log(FTDM_LOG_DEBUG, "mISDN opened socket (on chan:dev => %d:%d): %d\n", addr.dev, addr.channel, sockfd); - /* set non-blocking */ + /* Set mISDN channel socket non-blocking */ if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket fd to non-blocking: %s\n", strerror(errno)); + ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket fd to non-blocking: %s\n", + strerror(errno)); + close(sockfd); return FTDM_FAIL; } @@ -1542,28 +1603,112 @@ static ftdm_status_t misdn_open_range(ftdm_span_t *span, ftdm_chan_type_t type, if (ftdmchan->type == FTDM_CHAN_TYPE_B) { int pipefd[2] = { -1, -1 }; - ftdmchan->packet_len = 10 /* ms */ * (ftdmchan->rate / 1000); + ftdmchan->packet_len = 30 /* ms */ * (ftdmchan->rate / 1000); ftdmchan->effective_interval = ftdmchan->native_interval = ftdmchan->packet_len / 8; ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_ALAW; - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL); +// ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL); +#ifdef USE_PIPE /* * Create audio tx pipe, use non-blocking I/O to avoid deadlock since both ends * are used from the same thread */ - if (pipe2(pipefd, O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio write pipe [%d:%d]: %s\n", + if (pipe2(pipefd, 0 | O_NONBLOCK) < 0) { + ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio tx pipe [%d:%d]: %s\n", addr.dev, x, strerror(errno)); close(sockfd); return FTDM_FAIL; } - priv->audio_pipe_in = pipefd[1]; - priv->audio_pipe_out = pipefd[0]; + priv->tx_audio_pipe_in = pipefd[1]; + priv->tx_audio_pipe_out = pipefd[0]; +#if 1 || defined(HAVE_F_SETPIPE_SZ) + if (fcntl(priv->tx_audio_pipe_in, F_SETPIPE_SZ, 4096) < 0) { + ftdm_log(FTDM_LOG_WARNING, "Failed to set mISDN audio tx pipe size [%d:%d]: %s\n", + addr.dev, x, strerror(errno)); + } +#endif + /* + * Create audio rx pipe, use non-blocking I/O to avoid deadlock since both ends + * are used from the same thread + */ + if (pipe2(pipefd, 0 | O_NONBLOCK) < 0) { + ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio rx pipe [%d:%d]: %s\n", + addr.dev, x, strerror(errno)); + close(sockfd); + return FTDM_FAIL; + } + priv->rx_audio_pipe_in = pipefd[1]; + priv->rx_audio_pipe_out = pipefd[0]; + +#if 1 || defined(HAVE_F_SETPIPE_SZ) + if (fcntl(priv->rx_audio_pipe_in, F_SETPIPE_SZ, 4096) < 0) { + ftdm_log(FTDM_LOG_WARNING, "Failed to set mISDN audio rx pipe size [%d:%d]: %s\n", + addr.dev, x, strerror(errno)); + } +#endif +#else /* !USE_PIPE */ + /* + * Use a socket pair for audio rx/tx, allows for more fine-grained control + * of latency (= amounts of data in buffers) + */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd) < 0) { + ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio socket pair [%d:%d]: %s\n", + addr.dev, x, strerror(errno)); + close(sockfd); + return FTDM_FAIL; + } else { + int opt = SOCKETPAIR_BUFFER_SIZE; + socklen_t optlen = sizeof(opt); + + if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket pair fd[0] to non-blocking: %s\n", + strerror(errno)); + close(sockfd); + close(pipefd[0]); + close(pipefd[1]); + return FTDM_FAIL; + } + if (fcntl(pipefd[1], F_SETFL, O_NONBLOCK) < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket pair fd[1] to non-blocking: %s\n", + strerror(errno)); + close(sockfd); + close(pipefd[0]); + close(pipefd[1]); + return FTDM_FAIL; + } + + /* + * Set RX/TX buffer sizes on each end of the socket pair + */ + if (setsockopt(pipefd[0], SOL_SOCKET, SO_RCVBUF, &opt, optlen) < 0) { + ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[0] RCVBUF: %s\n", + strerror(errno)); + } + if (setsockopt(pipefd[0], SOL_SOCKET, SO_SNDBUF, &opt, optlen) < 0) { + ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[0] SNDBUF: %s\n", + strerror(errno)); + } + if (setsockopt(pipefd[1], SOL_SOCKET, SO_RCVBUF, &opt, optlen) < 0) { + ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[1] RCVBUF: %s\n", + strerror(errno)); + } + if (setsockopt(pipefd[1], SOL_SOCKET, SO_SNDBUF, &opt, optlen) < 0) { + ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[1] SNDBUF: %s\n", + strerror(errno)); + } + + priv->rx_audio_pipe_in = pipefd[1]; + priv->rx_audio_pipe_out = pipefd[0]; + + priv->tx_audio_pipe_in = pipefd[0]; + priv->tx_audio_pipe_out = pipefd[1]; + } +#endif } else { /* early activate D-Channel */ - misdn_activate_channel(ftdmchan, 1); + misdn_activate_channel(ftdmchan); ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_NONE; } num_configured++; @@ -1676,6 +1821,8 @@ static FIO_CONFIGURE_SPAN_FUNCTION(misdn_configure_span) /* allocate span private */ if (!span_priv) { + int pipe[2] = { -1, -1 }; + /* * Not perfect, there should be something like span_create too */ @@ -1689,6 +1836,19 @@ static FIO_CONFIGURE_SPAN_FUNCTION(misdn_configure_span) /* init event condition */ pthread_cond_init(&span_priv->event_cond, NULL); pthread_mutex_init(&span_priv->event_cond_mutex, NULL); + + /* init control condition */ + pthread_cond_init(&span_priv->ctrl_cond, NULL); + pthread_mutex_init(&span_priv->ctrl_cond_mutex, NULL); + + /* create event pipe */ + if (pipe2(pipe, O_CLOEXEC) < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN failed to create event pipe: %s\n", + strerror(errno)); + return FTDM_FAIL; + } + span_priv->event_pipe_in = pipe[0]; + span_priv->event_pipe_out = pipe[1]; } /* split channel list by ',' */ @@ -1757,8 +1917,6 @@ static FIO_GET_ALARMS_FUNCTION(misdn_get_alarms) add event queues and data fifos, so we can sift all the messages we get to forward them to the right receiver */ - ftdm_span_t *span = ftdm_channel_get_span(ftdmchan); - struct misdn_span_private *span_priv = ftdm_span_io_private(span); char buf[MAX_DATA_MEM] = { 0 }; struct sockaddr_mISDN addr; struct mISDNhead *hh; @@ -1848,31 +2006,50 @@ static FIO_SPAN_POLL_EVENT_FUNCTION(misdn_poll_event) int retval = 0, nr_events = 0; int i; - clock_gettime(CLOCK_REALTIME, &ts); - ts_add_msec(&ts, ms); - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { ftdm_channel_t *chan = ftdm_span_get_channel(span, i); struct misdn_chan_private *chan_priv = ftdm_chan_io_private(chan); + /* Skip channels that have event processing pending (Avoids event storms) */ + if (ftdm_test_io_flag(chan, FTDM_CHANNEL_IO_EVENT)) + continue; + if (misdn_event_queue_has_data(chan_priv->events)) { #ifdef MISDN_DEBUG_EVENTS ftdm_log(FTDM_LOG_DEBUG, "mISDN channel %d:%d has event(s)\n", ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); #endif - ftdm_set_flag(chan, FTDM_CHANNEL_IO_EVENT); + ftdm_set_io_flag(chan, FTDM_CHANNEL_IO_EVENT); chan->last_event_time = ftdm_current_time_in_ms(); nr_events++; } } - if (nr_events) + if (nr_events) { +#ifdef MISDN_DEBUG_EVENTS + ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d has %d new events pending (pre poll)\n", + ftdm_span_get_id(span), nr_events); +#endif return FTDM_SUCCESS; + } + + +#ifdef MISDN_DEBUG_EVENTS + ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d has no events pending, polling for new events with %d ms timeout\n", + ftdm_span_get_id(span), ms); +#endif + /* Wait at least 1 ms, max 1 s */ + ms = ftdm_clamp(ms, 1, 1000); + + clock_gettime(CLOCK_REALTIME, &ts); + ts_add_msec(&ts, ms); if ((retval = pthread_cond_timedwait(&span_priv->event_cond, &span_priv->event_cond_mutex, &ts))) { switch (retval) { case ETIMEDOUT: -// ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d: No events within %d ms\n", -// ftdm_span_get_id(span), ms); +#ifdef MISDN_DEBUG_EVENTS + ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d: No events within %d ms\n", + ftdm_span_get_id(span), ms); +#endif return FTDM_TIMEOUT; default: ftdm_log(FTDM_LOG_DEBUG, "mISDN failed to poll for events on span %d: %s\n", @@ -1881,12 +2058,20 @@ static FIO_SPAN_POLL_EVENT_FUNCTION(misdn_poll_event) } } +#ifdef MISDN_DEBUG_EVENTS + ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d received new event notification, checking channel event queues\n", + ftdm_span_get_id(span)); +#endif for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { ftdm_channel_t *chan = ftdm_span_get_channel(span, i); struct misdn_chan_private *chan_priv = ftdm_chan_io_private(chan); + /* Skip channels that have event processing pending (Avoids event storms) */ + if (ftdm_test_io_flag(chan, FTDM_CHANNEL_IO_EVENT)) + continue; + if (misdn_event_queue_has_data(chan_priv->events)) { - ftdm_set_flag(chan, FTDM_CHANNEL_IO_EVENT); + ftdm_set_io_flag(chan, FTDM_CHANNEL_IO_EVENT); chan->last_event_time = ftdm_current_time_in_ms(); nr_events++; } @@ -1894,6 +2079,57 @@ static FIO_SPAN_POLL_EVENT_FUNCTION(misdn_poll_event) return (nr_events) ? FTDM_SUCCESS : FTDM_TIMEOUT; /* no events? => timeout */ } +/** + * Retrieve event from channel + * \param ftdmchan Channel to retrieve event from + * \param event FreeTDM event to return + * \return Success or failure + */ +static FIO_CHANNEL_NEXT_EVENT_FUNCTION(misdn_channel_next_event) +{ + struct misdn_chan_private *chan_priv = ftdm_chan_io_private(ftdmchan); + struct misdn_event *evt = NULL; + ftdm_span_t *span = ftdm_channel_get_span(ftdmchan); + uint32_t event_id = FTDM_OOB_INVALID; + + ftdm_assert(span, "span == NULL"); + + ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); + + if (!(evt = misdn_event_queue_pop(chan_priv->events))) { +#ifdef MISDN_DEBUG_EVENTS + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN channel event queue has no events\n"); +#endif + return FTDM_FAIL; + } + +#ifdef MISDN_DEBUG_EVENTS + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Got event '%s' from channel event queue\n", + misdn_event2str(evt->id)); +#endif + /* Convert from misdn event to ftdm */ + switch (evt->id) { + case PH_DEACTIVATE_IND: + event_id = FTDM_OOB_ALARM_TRAP; + ftdmchan->alarm_flags |= FTDM_ALARM_RED; + break; + case PH_ACTIVATE_IND: + event_id = FTDM_OOB_ALARM_CLEAR; + ftdmchan->alarm_flags &= ~FTDM_ALARM_RED; + break; + default: + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled event id %d (0x%x) %s\n", + evt->id, evt->id, misdn_event2str(evt->id)); + } + + ftdmchan->last_event_time = 0; + span->event_header.e_type = FTDM_EVENT_OOB; + span->event_header.enum_id = event_id; + span->event_header.channel = ftdmchan; + *event = &span->event_header; + return FTDM_SUCCESS; +} + /** * \brief Retrieve event * \param span FreeTDM span @@ -1912,11 +2148,12 @@ static FIO_SPAN_NEXT_EVENT_FUNCTION(misdn_next_event) struct misdn_chan_private *chan_priv = ftdm_chan_io_private(chan); struct misdn_event *evt = NULL; + ftdm_clear_io_flag(chan, FTDM_CHANNEL_IO_EVENT); + if (!(evt = misdn_event_queue_pop(chan_priv->events))) { #ifdef MISDN_DEBUG_EVENTS ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "mISDN channel event queue has no events\n"); #endif - ftdm_clear_io_flag(chan, FTDM_CHANNEL_IO_EVENT); continue; } @@ -1989,6 +2226,7 @@ static FIO_SPAN_DESTROY_FUNCTION(misdn_span_destroy) { struct misdn_span_private *span_priv = ftdm_span_io_private(span); + /* free resources */ ftdm_span_io_private(span) = NULL; ftdm_safe_free(span_priv); @@ -1998,10 +2236,397 @@ static FIO_SPAN_DESTROY_FUNCTION(misdn_span_destroy) } +/** + * Called by misdn_span_run() to handle incoming b-channel events + * \param[in] chan FreeTDM channel object + * \return FTDM_SUCCESS on success, FTDM_* on error + */ +static ftdm_status_t handle_b_channel_event(ftdm_channel_t *chan) +{ + struct misdn_chan_private *priv = ftdm_chan_io_private(chan); + char buf[MAX_DATA_MEM] = { 0 }; + struct mISDNhead *mh = (void *)buf; + int retval; + + if ((retval = recvfrom(chan->sockfd, buf, sizeof(buf), 0, NULL, NULL)) <= 0) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to receive message: %s\n", + strerror(errno)); + return FTDM_FAIL; + } + + if (retval < MISDN_HEADER_LEN) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN message too short, min.: %d, read: %d\n", + (int)MISDN_HEADER_LEN, retval); + return FTDM_FAIL; + } + + switch (mh->prim) { + case PH_DATA_IND: { + int datalen = retval - MISDN_HEADER_LEN; + char *data = buf + MISDN_HEADER_LEN; + + /* Convert audio data */ + misdn_convert_audio_bits(data, datalen); + + /* Write audio into receive pipe */ + if ((retval = write(priv->rx_audio_pipe_in, data, datalen)) < 0) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to write audio data into rx pipe: %s\n", + strerror(errno)); + return FTDM_FAIL; + } else if (retval < datalen) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN short write into rx pipe, written: %d, expected: %d\n", + retval, datalen); + return FTDM_FAIL; + } + + /* Get receive buffer usage */ + if (ioctl(priv->tx_audio_pipe_out, FIONREAD, &retval) < 0) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to get tx audio buffer usage: %s\n", + strerror(errno)); + return FTDM_FAIL; + } else if (retval < datalen) { +// ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN has not enough bytes in tx audio pipe, available: %d, requested: %d\n", +// retval, datalen); + priv->tx_pipe_under_cnt++; + return FTDM_SUCCESS; + } + +#ifdef MISDN_DEBUG_IO + ftdm_log_chan(chan, FTDM_LOG_INFO, "mISDN tx audio buffer usage: %d\n", + retval); +#endif + + /* Get audio from tx pipe */ + if ((retval = read(priv->tx_audio_pipe_out, data, datalen)) < 0) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to read audio data from tx pipe: %s\n", + strerror(errno)); + return FTDM_FAIL; + } else if (retval == 0) { + ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "mISDN tx pipe is empty\n"); + priv->tx_pipe_under_cnt++; + return FTDM_SUCCESS; + } else if (retval < datalen) { + ftdm_log_chan(chan, FTDM_LOG_NOTICE, "mISDN short read from tx pipe, read: %d, expected: %d\n", + retval, datalen); + priv->tx_pipe_under_cnt++; + priv->tx_miss_bytes += ftdm_max(0, datalen - retval); + datalen = retval; + } + priv->tx_pipe_rd_bytes += retval; + + if (!priv->active) { + /* discard */ + return FTDM_SUCCESS; + } + + /* Convert audio data */ + misdn_convert_audio_bits(data, datalen); + + /* Write to channel */ + mh->prim = PH_DATA_REQ; + mh->id = 0; + datalen += MISDN_HEADER_LEN; + + if ((retval = write(chan->sockfd, buf, datalen)) < 0) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to write audio data into b-channel: %s\n", + strerror(errno)); + return FTDM_FAIL; + } else if (retval < datalen) { + ftdm_log_chan(chan, FTDM_LOG_WARNING, "mISDN short write into b-channel, written: %d, expected: %d\n", + retval, datalen); + priv->tx_lost_bytes += ftdm_max(0, datalen - retval - MISDN_HEADER_LEN); + } + priv->tx_sent_bytes += ftdm_max(0, retval - MISDN_HEADER_LEN); + break; + } + case PH_DATA_CNF: + priv->tx_ack_cnt++; + break; + case PH_DEACTIVATE_IND: + priv->active = 0; + break; + case PH_ACTIVATE_IND: + priv->active = 1; + break; + default: + ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN received unknown/unhandled event primitive: (%d) %s\n", + mh->prim, misdn_event2str(mh->prim)); + break; + } + return FTDM_SUCCESS; +} + + +/** + * Timeout (miliseconds) for epoll_wait() + */ +#define MISDN_EPOLL_WAIT_MAX_MSEC 1000 + +/** + * mISDN I/O thread + * This thread handles all of the B-Channel I/O, this avoids all of the hazzles with + * intermixed data + control frames on mISDN sockets and the missing write poll support on B-Channels. + * + * Each channel uses a unix stream socketpair as a two-way, pipe replacement for incoming and outgoing + * data. Socketpairs allow a more fine grained tuning of the buffer sizes (pipe are restricted to multiples of + * the native page size (with the smallest possible size (4k) being already 500ms worth of audio). + * + * The socketpair buffer sizes and the send algorithm have been carefully tuned to: + * + * - Minimize the risk of sending too much data and making the mISDN drivers unhappy, by + * sending PH_DATA_REQ only when there is as much data available as we have received in + * the PH_DATA_IND. + * + * - Avoid deadlocks between ftdm_write() trying to fill an almust full socket buffer and + * the I/O thread not having enough data to send a PH_DATA_REQ message. + * (The write() call will return EAGAIN since there is not ehough space free to send all audio data.) + * + * \param thread FreeTDM thread handle + * \param data Private data pointer passed to ftdm_thread_create_detached() (the span object) + * \return Always returns NULL (unused) + * + * \note + * ftdm_span_start/_stop() locks the span mutex, + * use direct access to span members to avoid deadlocking + * + * \todo + * Move D-Channel handling into the I/O thread too. + * Use custom ring buffer structures instead of socketpairs + * (for even more fine grained size control). + */ +static void *misdn_span_run(ftdm_thread_t *thread, void *data) +{ + ftdm_span_t *span = data; + struct misdn_span_private *priv = ftdm_span_io_private(span); + struct epoll_event evh; + int epfd = -1; + int ret; + int i; + + ftdm_log(FTDM_LOG_NOTICE, "mISDN[%d:%s] span thread initializing\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + /* Use epoll for event handling */ + epfd = epoll_create(1); + if (epfd < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to create epoll context: %s\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); + goto error; + } + + ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] adding event pipe to epoll context\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + /* Add event pipe */ + evh.events = EPOLLIN | EPOLLPRI | EPOLLERR; + evh.data.fd = priv->event_pipe_out; + + ret = epoll_ctl(epfd, EPOLL_CTL_ADD, priv->event_pipe_out, &evh); + if (ret < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to add event pipe to epoll context: %s\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); + goto error; + } + + ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] adding b-channels to epoll context\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + /* Add b-channels */ + for (i = 1; i <= span->chan_count; i++) { + ftdm_channel_t *chan = span->channels[i]; + ftdm_assert(chan, "channel == NULL"); + + if (ftdm_channel_get_type(chan) != FTDM_CHAN_TYPE_B) + continue; + + ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] adding b-channel [%d:%d] to epoll context\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), + ftdm_channel_get_id(chan), ftdm_channel_get_ph_id(chan)); + + evh.events = EPOLLIN | EPOLLPRI | EPOLLERR; + evh.data.ptr = chan; + + ret = epoll_ctl(epfd, EPOLL_CTL_ADD, chan->sockfd, &evh); + if (ret < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to add b-channel [%d] socket to epoll context: %s\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), ftdm_channel_get_id(chan), strerror(errno)); + goto error; + } + } + + ftdm_log(FTDM_LOG_NOTICE, "mISDN[%d:%s] span thread started\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + /* Notify world we're running */ + priv->running = 1; + pthread_cond_signal(&priv->ctrl_cond); + + while (priv->running > 0) { + struct epoll_event ev[10]; + int timeout_ms = MISDN_EPOLL_WAIT_MAX_MSEC; + + ret = epoll_wait(epfd, ev, ftdm_array_len(ev), timeout_ms); + if (ret < 0) { + switch (errno) { + case EAGAIN: + case EINTR: + continue; + default: + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] epoll_wait() failed: %s\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); + goto error; + } + } + /* Check events */ + for (i = 0; i < ret; i++) { + /* */ + if (ev[i].data.fd == priv->event_pipe_out) { + struct misdn_command cmd; + /* event pipe */ + ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] event pipe notification\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + ret = read(priv->event_pipe_out, &cmd, sizeof(cmd)); + if (ret < sizeof(cmd)) { + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to read span thread command\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + continue; + } + + switch (cmd.type) { + case MISDN_CMD_STOP: + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] got STOP command\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + priv->running = -1; + break; + default: + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] got unknown command: %d\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), cmd.type); + } + + } else { + ftdm_channel_t *chan = ev[i].data.ptr; + handle_b_channel_event(chan); + } + } + } +error: + ftdm_log(FTDM_LOG_NOTICE, "mISDN[%d:%s] span thread stopped\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + /* Remove epoll event sources */ + for (i = 1; i <= span->chan_count; i++) { + ftdm_channel_t *chan = span->channels[i]; + ftdm_assert(chan, "channel == NULL"); + + if (ftdm_channel_get_type(chan) != FTDM_CHAN_TYPE_B) + continue; + + ret = epoll_ctl(epfd, EPOLL_CTL_DEL, chan->sockfd, NULL); + if (ret < 0) { + ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to remove b-channel [%d] socket from epoll context: %s\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), ftdm_channel_get_id(chan), strerror(errno)); + } + } + + /* Close epoll context */ + if (epfd >= 0) close(epfd); + + /* Notify world we stopped running */ + priv->running = 0; + pthread_cond_signal(&priv->ctrl_cond); + return NULL; +} + +/** + * Timeout (miliseconds) for span start/stop completion + */ +#define SPAN_DEFAULT_TIMEOUT_MSEC 10000 + +static FIO_SPAN_START_FUNCTION(misdn_span_start) +{ + struct misdn_span_private *span_priv = ftdm_span_io_private(span); + struct timespec timeout; + int retval; + + ftdm_log(FTDM_LOG_NOTICE, "mISDN starting span %d (%s)\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + span_priv->running = 0; + + if (ftdm_thread_create_detached(misdn_span_run, span) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "mISDN failed to start span %d (%s)\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + return FTDM_FAIL; + } + + /* + * Wait SPAN_DEFAULT_TIMEOUT_MSEC miliseconds for I/O thread to start up + */ + clock_gettime(CLOCK_REALTIME, &timeout); + ts_add_msec(&timeout, SPAN_DEFAULT_TIMEOUT_MSEC); + + pthread_mutex_lock(&span_priv->ctrl_cond_mutex); + + retval = pthread_cond_timedwait(&span_priv->ctrl_cond, &span_priv->ctrl_cond_mutex, &timeout); + if (retval == ETIMEDOUT) { + ftdm_log(FTDM_LOG_ERROR, "mISDN failed to start span %d (%s) in 10 seconds\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + return FTDM_FAIL; + } else if (retval) { + ftdm_log(FTDM_LOG_ERROR, "mISDN failed to start span %d (%s): %s\n", + ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); + return FTDM_FAIL; + } + + pthread_mutex_unlock(&span_priv->ctrl_cond_mutex); + return FTDM_SUCCESS; +} + +static FIO_SPAN_STOP_FUNCTION(misdn_span_stop) +{ + struct misdn_span_private *span_priv = ftdm_span_io_private(span); + struct timespec timeout; + struct misdn_command cmd; + int retval; + + ftdm_log(FTDM_LOG_NOTICE, "mISDN stopping span %d (%s)\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + + span_priv->running = -1; + + /* Wake up thread */ + cmd.type = MISDN_CMD_STOP; + retval = write(span_priv->event_pipe_in, &cmd, sizeof(cmd)); + if (retval < sizeof(cmd)) { + ftdm_log(FTDM_LOG_WARNING, "mISDN failed to send STOP command to span thread\n"); + } + + /* + * Wait SPAN_DEFAULT_TIMEOUT_MSEC miliseconds for I/O thread to shut down + */ + clock_gettime(CLOCK_REALTIME, &timeout); + ts_add_msec(&timeout, SPAN_DEFAULT_TIMEOUT_MSEC); + + pthread_mutex_lock(&span_priv->ctrl_cond_mutex); + + retval = pthread_cond_timedwait(&span_priv->ctrl_cond, &span_priv->ctrl_cond_mutex, &timeout); + if (retval == ETIMEDOUT) { + ftdm_log(FTDM_LOG_ERROR, "mISDN failed to stop thread in 10 seconds\n"); + return FTDM_FAIL; + } else if (retval) { + ftdm_log(FTDM_LOG_ERROR, "mISDN failed to stop thread: %s\n", + strerror(errno)); + return FTDM_FAIL; + } + + pthread_mutex_unlock(&span_priv->ctrl_cond_mutex); + return FTDM_SUCCESS; +} + + /** * \brief ftmod_misdn interface */ -//static const ftdm_io_interface_t misdn_interface = { static const ftdm_io_interface_t misdn_interface = { .name = "misdn", @@ -2018,8 +2643,12 @@ static const ftdm_io_interface_t misdn_interface = { .get_alarms = misdn_get_alarms, .configure = misdn_configure, /* configure global parameters */ .configure_span = misdn_configure_span, /* assign channels to span */ + .channel_next_event = misdn_channel_next_event, .channel_destroy = misdn_channel_destroy, /* clean up channel */ .span_destroy = misdn_span_destroy, /* clean up span */ + + .span_start = misdn_span_start, + .span_stop = misdn_span_stop, }; diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h b/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h index 882eaba411..1bcf82e285 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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.c b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c index aaafdb33cc..0e1ed24afe 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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_pritap/ftmod_pritap.c b/libs/freetdm/src/ftmod/ftmod_pritap/ftmod_pritap.c index 29c7860220..f136d59d9c 100644 --- a/libs/freetdm/src/ftmod/ftmod_pritap/ftmod_pritap.c +++ b/libs/freetdm/src/ftmod/ftmod_pritap/ftmod_pritap.c @@ -782,7 +782,7 @@ static ftdm_status_t ftdm_pritap_sig_read(ftdm_channel_t *ftdmchan, void *data, return FTDM_FAIL; } if (sizeread != size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "read from peer channel only %d bytes!\n", sizeread); + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "read from peer channel only %"FTDM_SIZE_FMT" bytes!\n", sizeread); return FTDM_FAIL; } @@ -854,7 +854,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_pritap_configure_span) } if (!dchan) { - ftdm_log(FTDM_LOG_ERROR, "No d-channel specified in freetdm.conf!\n", ftdm_trunk_type2str(span->trunk_type)); + ftdm_log(FTDM_LOG_ERROR, "No d-channel specified in freetdm.conf!\n"); return FTDM_FAIL; } diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c index 8333a306c4..b74d5b003c 100755 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c @@ -1557,10 +1557,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling) intval = atoi(val); if (intval < 0) { r2conf.mf_dump_size = FTDM_IO_DUMP_DEFAULT_BUFF_SIZE; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with default mf_dump_size = %d bytes\n", span->name, r2conf.mf_dump_size); + ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with default mf_dump_size = %"FTDM_SIZE_FMT" bytes\n", span->name, r2conf.mf_dump_size); } else { r2conf.mf_dump_size = intval; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with mf_dump_size = %d bytes\n", span->name, r2conf.mf_dump_size); + ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with mf_dump_size = %"FTDM_SIZE_FMT" bytes\n", span->name, r2conf.mf_dump_size); } } else if (!strcasecmp(var, "allow_collect_calls")) { r2conf.allow_collect_calls = ftdm_true(val); @@ -1970,7 +1970,7 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj) r2data->monitor_thread_id = syscall(SYS_gettid); #endif - ftdm_log(FTDM_LOG_DEBUG, "OpenR2 monitor thread %lu started.\n", r2data->monitor_thread_id); + ftdm_log(FTDM_LOG_DEBUG, "OpenR2 monitor thread %u started.\n", r2data->monitor_thread_id); r2chan = NULL; chaniter = ftdm_span_get_chan_iterator(span, NULL); if (!chaniter) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 0f9a63fde2..65f17fa47b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -451,17 +451,17 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) /* get an interrupt queue for this span */ if (ftdm_queue_get_interrupt(span->pendingchans, &ftdm_sangoma_isdn_int[0]) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to get a ftdm_interrupt for span = %s!\n", span->name); + ftdm_log(FTDM_LOG_CRIT, "Failed to get a ftdm_interrupt for span = %s!\n", span->name); goto ftdm_sangoma_isdn_run_exit; } if (ftdm_queue_get_interrupt(span->pendingsignals, &ftdm_sangoma_isdn_int[1]) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to get a signal interrupt for span = %s!\n", span->name); + ftdm_log(FTDM_LOG_CRIT, "Failed to get a signal interrupt for span = %s!\n", span->name); goto ftdm_sangoma_isdn_run_exit; } if (ftdm_queue_get_interrupt(signal_data->event_queue, &ftdm_sangoma_isdn_int[2]) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to get a event interrupt for span = %s!\n", span->name); + ftdm_log(FTDM_LOG_CRIT, "Failed to get a event interrupt for span = %s!\n", span->name); goto ftdm_sangoma_isdn_run_exit; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 0034add153..fc93155ffa 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -528,6 +528,7 @@ ftdm_status_t set_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb); ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb); ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt); ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad); +ftdm_status_t set_called_subaddr(ftdm_channel_t *ftdmchan, CdPtySad *cdPtySad); ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind); ftdm_status_t set_bear_cap_ie(ftdm_channel_t *ftdmchan, BearCap *bearCap); ftdm_status_t set_network_specific_fac(ftdm_channel_t *ftdmchan, NetFac *netFac); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index eedb677f2b..47da32d865 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -131,7 +131,7 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span /* can be > 1 for some BRI variants */ break; default: - ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported trunktype:%s\n", span->name, switch_name, ftdm_trunk_type2str(span->trunk_type)); + ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported trunktype:%s\n", span->name, ftdm_trunk_type2str(span->trunk_type)); return FTDM_FAIL; } @@ -523,7 +523,7 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ parse_yesno(var, val, &signal_data->restart_opt); } else if (!strcasecmp(var, "channel-restart-timeout")) { signal_data->restart_timeout = atoi(val); - } else if (!strcasecmp(var, "local-number")) { + } else if (!strcasecmp(var, "local-number")) { if (add_local_number(val, span) != FTDM_SUCCESS) { return FTDM_FAIL; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index b96a801243..52daf3ad7b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -719,7 +719,11 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.t.cfg.s.inDLSAP.clrGlr = FALSE; /* in case of glare, do not clear local call */ cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE; - cfg.t.cfg.s.inDLSAP.rstOpt = TRUE; + if (signal_data->ftdm_span->trunk_type == FTDM_TRUNK_BRI_PTMP) { + cfg.t.cfg.s.inDLSAP.rstOpt = FALSE; + } else { + cfg.t.cfg.s.inDLSAP.rstOpt = TRUE; + } } else { cfg.t.cfg.s.inDLSAP.ackOpt = FALSE; cfg.t.cfg.s.inDLSAP.intType = USER; @@ -841,19 +845,17 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.t.cfg.s.inDLSAP.tmr.t308.enb = TRUE; cfg.t.cfg.s.inDLSAP.tmr.t308.val = 4; + cfg.t.cfg.s.inDLSAP.tmr.t310.enb = TRUE; + cfg.t.cfg.s.inDLSAP.tmr.t310.val = 120; if (signal_data->timer_t308 > 0) { cfg.t.cfg.s.inDLSAP.tmr.t308.val = signal_data->timer_t308; } if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.inDLSAP.tmr.t310.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t310.val = 10; cfg.t.cfg.s.inDLSAP.tmr.t312.enb = TRUE; cfg.t.cfg.s.inDLSAP.tmr.t312.val = cfg.t.cfg.s.inDLSAP.tmr.t303.val+2; } else { - cfg.t.cfg.s.inDLSAP.tmr.t310.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t310.val = 120; cfg.t.cfg.s.inDLSAP.tmr.t312.enb = FALSE; } @@ -967,7 +969,7 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.t.cfg.s.inDLSAP.dChannelNum = 0; /* Unused for BRI */ cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_BRI_CHANNELS_PER_SPAN; cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; - cfg.t.cfg.s.inDLSAP.callRefLen = 1; + cfg.t.cfg.s.inDLSAP.callRefLen = 1; cfg.t.cfg.s.inDLSAP.teiAlloc = IN_STATIC; cfg.t.cfg.s.inDLSAP.intCfg = IN_INTCFG_PTPT; break; @@ -1023,7 +1025,13 @@ ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) cfg.t.cfg.s.inLCe.sapId = signal_data->link_id; - cfg.t.cfg.s.inLCe.lnkUpDwnInd = TRUE; + if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { + /* Stack will send Restart CFM's each time link is established (TEI negotiated), + and we do not want thi s event */ + cfg.t.cfg.s.inLCe.lnkUpDwnInd = FALSE; + } else { + cfg.t.cfg.s.inLCe.lnkUpDwnInd = TRUE; + } if (FTDM_SPAN_IS_BRI(span)) { /* tCon Timer causes unwanted hangup on BRI links @@ -1225,7 +1233,7 @@ uint8_t sng_isdn_stack_switchtype(sngisdn_switchtype_t switchtype) case SNGISDN_SWITCH_INSNET: return SW_INSNET; case SNGISDN_SWITCH_INVALID: - ftdm_log(FTDM_LOG_ERROR, "%s:Invalid switchtype:%d\n", switchtype); + ftdm_log(FTDM_LOG_ERROR, "Invalid switchtype: %d\n", switchtype); break; } return 0; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 15bff0390e..c2d18f01a9 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -493,7 +493,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) if (cnStEvnt->sndCmplt.eh.pres || num_digits >= min_digits) { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "received %d of %d digits\n", num_digits, min_digits); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "received %"FTDM_SIZE_FMT" of %"FTDM_SIZE_FMT" digits\n", num_digits, min_digits); } } break; @@ -509,7 +509,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n"); break; default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "\n", suId, suInstId, spInstId); + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Unhandled INFO (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); break; } } @@ -966,6 +966,12 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event) break; case 2: /* overlap sending */ switch (ftdmchan->state) { + case FTDM_CHANNEL_STATE_COLLECT: + /* T302 Timeout reached */ + /* Send the call to user, and see if they accept it */ + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "T302 Timer expired, proceeding with call\n"); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + break; case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_RINGING: @@ -1196,7 +1202,16 @@ void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event) return; } - if (rstEvnt->rstInd.eh.pres == PRSNT_NODEF && rstEvnt->rstInd.rstClass.pres == PRSNT_NODEF) { + ftdm_log(FTDM_LOG_DEBUG, "%s: Processing RESTART CFM (suId:%u dChan:%d ces:%d %s(%d))\n", + signal_data->ftdm_span->name, + suId, dChan, ces, + (evntType == IN_LNK_DWN)?"LNK_DOWN": + (evntType == IN_LNK_UP)?"LNK_UP": + (evntType == IN_INDCHAN)?"b-channel": + (evntType == IN_LNK_DWN_DM_RLS)?"NFAS service procedures": + (evntType == IN_SWCHD_BU_DCHAN)?"NFAS switchover to backup":"Unknown", evntType); + + if (rstEvnt->rstInd.eh.pres == PRSNT_NODEF && rstEvnt->rstInd.rstClass.pres == PRSNT_NODEF) { switch(rstEvnt->rstInd.rstClass.val) { case IN_CL_INDCHAN: /* Indicated b-channel */ if (rstEvnt->chanId.eh.pres) { @@ -1342,28 +1357,29 @@ void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event) } if (chan_no) { /* For a single channel */ - if (chan_no > ftdm_span_get_chan_count(signal_data->ftdm_span)) { - ftdm_log(FTDM_LOG_CRIT, "Received RESTART IND on invalid channel:%d\n", chan_no); - } else { - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - if (ftdmchan->physical_chan_id == chan_no) { - sngisdn_bring_down(ftdmchan); - } + ftdm_iterator_t *chaniter = NULL; + ftdm_iterator_t *curr = NULL; + + chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); + for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { + ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; + if (sngisdn_info->ces == ces && ftdmchan->physical_chan_id == chan_no) { + sngisdn_bring_down(ftdmchan); } - ftdm_iterator_free(chaniter); } + ftdm_iterator_free(chaniter); } else { /* for all channels */ ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - sngisdn_bring_down((ftdm_channel_t*)ftdm_iterator_current(curr)); + ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; + if (sngisdn_info->ces == ces) { + sngisdn_bring_down(ftdmchan); + } } ftdm_iterator_free(chaniter); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 20b0c86ca9..b05ee41356 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -67,6 +67,7 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) set_calling_num(ftdmchan, &conEvnt.cgPtyNmb); set_calling_num2(ftdmchan, &conEvnt.cgPtyNmb2); set_calling_subaddr(ftdmchan, &conEvnt.cgPtySad); + set_called_subaddr(ftdmchan, &conEvnt.cdPtySad); set_redir_num(ftdmchan, &conEvnt.redirNmb); set_calling_name(ftdmchan, &conEvnt); set_network_specific_fac(ftdmchan, &conEvnt.netFac[0]); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index 17e8d54084..a5ba7c54b9 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -1084,7 +1084,7 @@ void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...) switch (level) { case SNG_LOGLEVEL_DEBUG: - ftdm_log(FTDM_LOG_DEBUG, "sng_isdn->%s", data); + ftdm_log(FTDM_LOG_DEBUG, "sng_isdn->%s\n", data); break; case SNG_LOGLEVEL_WARN: if ( strncmp(data, "Invalid Q.921/Q.931 frame", 25) ) { @@ -1092,21 +1092,21 @@ void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...) } break; case SNG_LOGLEVEL_INFO: - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s", data); + ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s\n", data); break; case SNG_LOGLEVEL_STATS: - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s", data); + ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s\n", data); break; case SNG_LOGLEVEL_ERROR: - ftdm_log(FTDM_LOG_ERROR, "sng_isdn->%s", data); + ftdm_log(FTDM_LOG_ERROR, "sng_isdn->%s\n", data); /*ftdm_assert(0, "Got an error from stack");*/ break; case SNG_LOGLEVEL_CRIT: - ftdm_log(FTDM_LOG_CRIT, "sng_isdn->%s", data); + ftdm_log(FTDM_LOG_CRIT, "sng_isdn->%s\n", data); /* ftdm_assert(0, "Got an error from stack"); */ break; default: - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s", data); + ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s\n", data); break; } ftdm_safe_free(data); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 737805c0cd..5f63f384d7 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -453,7 +453,7 @@ ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) } memset(subaddress, 0, sizeof(subaddress)); if(cgPtySad->sadInfo.len >= sizeof(subaddress)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Calling Party Subaddress exceeds local size limit (len:%d max:%d)\n", cgPtySad->sadInfo.len, sizeof(subaddress)); + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Calling Party Subaddress exceeds local size limit (len:%d max:%"FTDM_SIZE_FMT")\n", cgPtySad->sadInfo.len, sizeof(subaddress)); cgPtySad->sadInfo.len = sizeof(subaddress)-1; } @@ -847,6 +847,26 @@ ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) return FTDM_SUCCESS; } +ftdm_status_t set_called_subaddr(ftdm_channel_t *ftdmchan, CdPtySad *cdPtySad) +{ + const char* cld_subaddr = NULL; + cld_subaddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.called_subaddr"); + if (!ftdm_strlen_zero(cld_subaddr)) { + unsigned len = strlen (cld_subaddr); + cdPtySad->eh.pres = PRSNT_NODEF; + cdPtySad->typeSad.pres = 1; + cdPtySad->typeSad.val = 0; /* NSAP */ + cdPtySad->oddEvenInd.pres = 1; + cdPtySad->oddEvenInd.val = 0; + + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Called Party Subaddress:%s\n", cld_subaddr); + cdPtySad->sadInfo.pres = 1; + cdPtySad->sadInfo.len = len; + memcpy(cdPtySad->sadInfo.val, cld_subaddr, len); + } + return FTDM_SUCCESS; +} + ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) { ftdm_status_t status; @@ -1198,7 +1218,7 @@ void sngisdn_restart_timeout(void *p_signal_data) ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; - ftdm_log(FTDM_LOG_DEBUG, "s%d:Did not receive a RESTART from remote switch in %d ms - restarting\n", span->name, signal_data->restart_timeout); + ftdm_log(FTDM_LOG_DEBUG, "s%s:Did not receive a RESTART from remote switch in %d ms - restarting\n", span->name, signal_data->restart_timeout); chaniter = ftdm_span_get_chan_iterator(span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c index 407b826d60..5df54f48ea 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c @@ -152,7 +152,7 @@ static ftdm_status_t att_courtesy_vru(ftdm_channel_t *ftdmchan, sngisdn_transfer goto done; } if (strlen(val) > COURTESY_TRANSFER_MAX_DATA_SIZE) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Data exceeds max size (len:%d max:%d), cannot perform transfer\n", strlen(val), COURTESY_TRANSFER_MAX_DATA_SIZE); + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Data exceeds max size (len:%"FTDM_SIZE_FMT" max:%d), cannot perform transfer\n", strlen(val), COURTESY_TRANSFER_MAX_DATA_SIZE); goto done; } memcpy(sngisdn_info->transfer_data.tdata.att_courtesy_vru.data, val, strlen(val)); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c index 34d79837f0..dd1058f420 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c @@ -99,17 +99,18 @@ int ft_to_sngss7_cfg_all(void) return 1; } else { SS7_INFO("Started Stack Manager!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED); } /* check if the configuration had a Relay Channel */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_PRESENT)) { /* start up the relay task */ if (sng_isup_init_relay()) { SS7_CRITICAL("Failed to start Relay\n"); return 1; } else { SS7_INFO("Started Relay!\n"); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED); } /* run general configuration on the relay task */ @@ -122,12 +123,13 @@ int ft_to_sngss7_cfg_all(void) } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_PRESENT)) { if (sng_isup_init_cc()) { SS7_CRITICAL("Failed to start Call-Control\n"); return 1; } else { SS7_INFO("Started Call-Control!\n"); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_STARTED); } if (ftmod_ss7_cc_gen_config()) { SS7_CRITICAL("CC General configuration FAILED!\n"); @@ -143,12 +145,13 @@ int ft_to_sngss7_cfg_all(void) } } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_PRESENT)) { if (sng_isup_init_isup()) { SS7_CRITICAL("Failed to start ISUP\n"); return 1; } else { SS7_INFO("Started ISUP!\n"); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED); } if (ftmod_ss7_isup_gen_config()) { SS7_CRITICAL("ISUP General configuration FAILED!\n"); @@ -158,12 +161,13 @@ int ft_to_sngss7_cfg_all(void) } } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_PRESENT)) { if (sng_isup_init_mtp3()) { SS7_CRITICAL("Failed to start MTP3\n"); return 1; } else { SS7_INFO("Started MTP3!\n"); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_STARTED); } if (ftmod_ss7_mtp3_gen_config()) { @@ -174,18 +178,20 @@ int ft_to_sngss7_cfg_all(void) } } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_PRESENT)) { if (sng_isup_init_mtp2()) { SS7_CRITICAL("Failed to start MTP2\n"); return 1; } else { SS7_INFO("Started MTP2!\n"); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED); } if (sng_isup_init_mtp1()) { - SS7_CRITICAL("Failed to start MTP2\n"); + SS7_CRITICAL("Failed to start MTP1\n"); return 1; } else { SS7_INFO("Started MTP1!\n"); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_STARTED); } if (ftmod_ss7_mtp1_gen_config()) { SS7_CRITICAL("MTP1 General configuration FAILED!\n"); @@ -376,7 +382,7 @@ int ft_to_sngss7_cfg_all(void) x++; } /* while (x < (MAX_ISAPS)) */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED)) { x = 1; while (x < (MAX_ISUP_INFS)) { /* check if this link has been configured already */ @@ -913,13 +919,14 @@ int ftmod_ss7_mtp3_dlsap_config(int id) #endif /* SDT2 */ cfg.t.cfg.s.snDLSAP.lnkId = 0; /* signalling link allocation procedure identity */ cfg.t.cfg.s.snDLSAP.lnkTstSLC = k->slc; /* link selection code for link test */ - cfg.t.cfg.s.snDLSAP.tstLen = 6; /* link test pattern length */ - cfg.t.cfg.s.snDLSAP.tst[0] = 'K'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[1] = 'O'; /* link test pattern */ + cfg.t.cfg.s.snDLSAP.tstLen = 7; /* link test pattern length */ + cfg.t.cfg.s.snDLSAP.tst[0] = 'S'; /* link test pattern */ + cfg.t.cfg.s.snDLSAP.tst[1] = 'A'; /* link test pattern */ cfg.t.cfg.s.snDLSAP.tst[2] = 'N'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[3] = 'R'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[4] = 'A'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[5] = 'D'; /* link test pattern */ + cfg.t.cfg.s.snDLSAP.tst[3] = 'G'; /* link test pattern */ + cfg.t.cfg.s.snDLSAP.tst[4] = 'O'; /* link test pattern */ + cfg.t.cfg.s.snDLSAP.tst[5] = 'M'; /* link test pattern */ + cfg.t.cfg.s.snDLSAP.tst[6] = 'A'; /* link test pattern */ cfg.t.cfg.s.snDLSAP.ssf = k->ssf; /* sub service field */ cfg.t.cfg.s.snDLSAP.dstProcId = k->mtp2ProcId; /* destination processor id */ cfg.t.cfg.s.snDLSAP.dstEnt = ENTSD; /* entity */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c index 5f87ffd877..9eb737a7f3 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c @@ -29,8 +29,16 @@ * 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. + * + * Contributors: + * James Zhang + * */ +#if 0 +#define SMG_RELAY_DBG +#endif + /* INCLUDE ********************************************************************/ #include "ftmod_sangoma_ss7_main.h" /******************************************************************************/ @@ -44,7 +52,7 @@ /* PROTOTYPES *****************************************************************/ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data); -static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream); +static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream); static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream); @@ -88,8 +96,31 @@ static ftdm_status_t handle_status_isup_ckt(ftdm_stream_handle_t *stream, char * static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan); static ftdm_status_t check_arg_count(int args, int min); -/******************************************************************************/ + + +static ftdm_status_t cli_ss7_show_general(ftdm_stream_handle_t *stream); + +static ftdm_status_t cli_ss7_show_mtp2link_by_id(ftdm_stream_handle_t *stream, int rcId); +static ftdm_status_t cli_ss7_show_mtp2link_by_name(ftdm_stream_handle_t *stream, char *name); +static ftdm_status_t cli_ss7_show_all_mtp2link(ftdm_stream_handle_t *stream); + +static ftdm_status_t cli_ss7_show_mtp3link_by_id(ftdm_stream_handle_t *stream, int rcId); +static ftdm_status_t cli_ss7_show_mtp3link_by_name(ftdm_stream_handle_t *stream, char *name); +static ftdm_status_t cli_ss7_show_all_mtp3link(ftdm_stream_handle_t *stream); + +static ftdm_status_t cli_ss7_show_relay_by_id(ftdm_stream_handle_t *stream, int rcId); +static ftdm_status_t cli_ss7_show_relay_by_name(ftdm_stream_handle_t *stream, char *name); +static ftdm_status_t cli_ss7_show_all_relay(ftdm_stream_handle_t *stream); + +static ftdm_status_t cli_ss7_show_channel_detail_of_span(ftdm_stream_handle_t *stream, char *span_id, char *chan_id); +static ftdm_status_t cli_ss7_show_all_channels_of_span(ftdm_stream_handle_t *stream, char *span_id); + +static ftdm_status_t cli_ss7_show_span_by_id(ftdm_stream_handle_t *stream, char *span_id); +static ftdm_status_t cli_ss7_show_all_spans_general(ftdm_stream_handle_t *stream); +static ftdm_status_t cli_ss7_show_all_spans_detail(ftdm_stream_handle_t *stream); + +/******************************************************************************/ /* FUNCTIONS ******************************************************************/ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data) { @@ -109,16 +140,72 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha argc = ftdm_separate_string(mycmd, ' ', argv, ftdm_array_len(argv)); } - if (check_arg_count(argc, 1)) goto handle_cli_error_argc; - + if (check_arg_count(argc, 1)) { + goto handle_cli_error_argc; + } + if (!strcasecmp(argv[c], "show")) { /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; + if (check_arg_count(argc, 2)) { + cli_ss7_show_general(stream); + return FTDM_SUCCESS; + } c++; - if (!strcasecmp(argv[c], "status")) { + if (!strcasecmp(argv[c], "relay")) { /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; + c++; + handle_status_relay(stream, argv[c]); + + } else if (!strcasecmp(argv[c], "span")) { + /**********************************************************************/ + switch (argc) { + case 2: + { + /* > ftdm ss7 show span */ + cli_ss7_show_all_spans_general(stream); + } + break; + + case 3: + { + if (!strcasecmp(argv[2], "all")) { + /* > ftdm ss7 show span all */ + cli_ss7_show_all_spans_detail(stream); + } else { + /* > ftdm ss7 show span 1 */ + cli_ss7_show_span_by_id(stream, argv[2]); + } + } + break; + + case 4: + { + /* > ftdm ss7 show span 1 chan */ + cli_ss7_show_all_channels_of_span(stream, argv[2]); + } + break; + + case 5: + default: + { + if (!strcasecmp(argv[3], "chan")) { + /* > ftdm ss7 show span 1 chan 2 */ + cli_ss7_show_channel_detail_of_span(stream, argv[2], argv[4]); + } else { + /* > ftdm ss7 show span 1 bla bla bla*/ + cli_ss7_show_all_channels_of_span(stream, argv[2]); + } + } + break; + } + } else if (!strcasecmp(argv[c], "status")) { + /**********************************************************************/ + if (check_arg_count(argc, 3)) { + cli_ss7_show_general(stream); + return FTDM_SUCCESS; + } + c++; if (!strcasecmp(argv[c], "mtp3")) { @@ -675,38 +762,40 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha handle_cli_error_argc: stream->write_function(stream, "Invalid # of arguments in command\n"); - handle_print_usuage(stream); + handle_print_usage(stream); return FTDM_SUCCESS; handle_cli_error_span_chan: stream->write_function(stream, "Unknown \"span\\chan\" command\n"); - handle_print_usuage(stream); + handle_print_usage(stream); return FTDM_SUCCESS; handle_cli_error: stream->write_function(stream, "Unknown command requested\n"); - handle_print_usuage(stream); + handle_print_usage(stream); return FTDM_SUCCESS; } /******************************************************************************/ -static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream) +static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream) { - stream->write_function(stream, "Sangoma SS7 CLI usuage:\n\n"); + stream->write_function(stream, "Sangoma SS7 CLI usage:\n\n"); - stream->write_function(stream, "Ftmod_sangoma_ss7 general control:\n"); + stream->write_function(stream, "ftmod_sangoma_ss7 general control:\n"); stream->write_function(stream, "ftdm ss7 set ftrace X Y\n"); stream->write_function(stream, "ftdm ss7 set mtrace X Y\n"); stream->write_function(stream, "\n"); - stream->write_function(stream, "Ftmod_sangoma_ss7 information:\n"); + stream->write_function(stream, "ftmod_sangoma_ss7 information:\n"); stream->write_function(stream, "ftdm ss7 show status mtp3 X\n"); stream->write_function(stream, "ftdm ss7 show status mtp2 X\n"); stream->write_function(stream, "ftdm ss7 show status span X chan Y\n"); stream->write_function(stream, "ftdm ss7 show free span X chan Y\n"); + stream->write_function(stream, "ftdm ss7 show blocks span X chan Y\n"); + stream->write_function(stream, "ftdm ss7 show inuse span X chan Y\n"); stream->write_function(stream, "ftdm ss7 show inreset span X chan Y\n"); stream->write_function(stream, "\n"); - stream->write_function(stream, "Ftmod_sangoma_ss7 circuit control:\n"); + stream->write_function(stream, "ftmod_sangoma_ss7 circuit control:\n"); stream->write_function(stream, "ftdm ss7 blo span X chan Y\n"); stream->write_function(stream, "ftdm ss7 ubl span X chan Y\n"); stream->write_function(stream, "ftdm ss7 rsc span X chan Y\n"); @@ -714,7 +803,7 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream) stream->write_function(stream, "ftdm ss7 cgb span X chan Y range Z\n"); stream->write_function(stream, "ftdm ss7 cgu span X chan Y range Z\n"); stream->write_function(stream, "\n"); - stream->write_function(stream, "Ftmod_sangoma_ss7 link control:\n"); + stream->write_function(stream, "ftmod_sangoma_ss7 link control:\n"); stream->write_function(stream, "ftdm ss7 inhibit link X\n"); stream->write_function(stream, "ftdm ss7 uninhibit link X\n"); stream->write_function(stream, "ftdm ss7 activate link X\n"); @@ -724,8 +813,14 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream) stream->write_function(stream, "ftdm ss7 lpo link X\n"); stream->write_function(stream, "ftdm ss7 lpr link X\n"); stream->write_function(stream, "\n"); - stream->write_function(stream, "Ftmod_sangoma_ss7 Relay status:\n"); + + + stream->write_function(stream, "ftmod_sangoma_ss7 Relay status:\n"); stream->write_function(stream, "ftdm ss7 show status relay X\n"); + stream->write_function(stream, "ftdm ss7 show relay X\n"); + stream->write_function(stream, "ftdm ss7 show relay\n"); + stream->write_function(stream, "\n"); + stream->write_function(stream, "\n"); return FTDM_SUCCESS; @@ -1106,6 +1201,9 @@ static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span, stream->write_function(stream, "l_ucic=N|"); } +#ifdef SMG_RELAY_DBG + stream->write_function(stream," blk_flag=%x | ckt_flag=%x | chan_flag=%x", ss7_info->blk_flags, ss7_info->ckt_flags, ftdmchan->flags); +#endif stream->write_function(stream, "\n"); } /* if ( span and chan) */ @@ -1210,13 +1308,18 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, stream->write_function(stream, "r_hw=N|"); } - if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_RELAY_DOWN)) { + + if (g_ftdm_sngss7_data.cfg.procId != 1) { + /* if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_RELAY_DOWN)) { */ stream->write_function(stream, "relay=Y|"); }else { stream->write_function(stream, "relay=N"); } } +#ifdef SMG_RELAY_DBG + stream->write_function(stream," blk_flag=%x | ckt_flag=%x | chan_flag=%x", ss7_info->blk_flags, ss7_info->ckt_flags, ftdmchan->flags); +#endif stream->write_function(stream, "\n"); } /* if ( hole, sig, voice) */ } /* if ( span and chan) */ @@ -1226,6 +1329,7 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, return FTDM_SUCCESS; } + /******************************************************************************/ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int chan, int verbose) { @@ -1263,7 +1367,7 @@ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int c if (check_for_state_change(ftdmchan)) { SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic); /* check if we need to die */ - SS7_ASSERT; + ftdm_assert(0, "State change not completed\n"); /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); /* move to the next channel */ @@ -1329,7 +1433,7 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c if (check_for_state_change(ftdmchan)) { SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic); /* check if we need to die */ - SS7_ASSERT; + ftdm_assert(0, "State change not completed\n"); /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); /* move to the next channel */ @@ -1341,6 +1445,9 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c /* clear the block flag */ sngss7_clear_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX); + /* check group blocking */ + sngss7_clear_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX); + /* set the channel to suspended state */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); } @@ -1348,103 +1455,47 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); - } /* if ( span and chan) */ + } - } /* if ( cic != 0) */ + } /* go the next circuit */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ + } handle_show_blocks(stream, span, chan, verbose); return FTDM_SUCCESS; } + /******************************************************************************/ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name) { - int x = 0; - SnMngmt sta; + SS7_RELAY_DBG_FUN(handle_status_mtp3link); - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Invalid stream\n"); - /* send the status request */ - if (ftmod_ss7_mtp3link_sta(x, &sta)) { - stream->write_function(stream, "Failed to read link=%s status\n", name); - return FTDM_FAIL; - } + if (!name) { + return cli_ss7_show_all_mtp3link(stream); + } - /* print the results */ - stream->write_function(stream, "%s|span=%d|chan=%d|sap=%d|state=%s|l_blk=%s|r_blk=%s|l_inhbt=%s|r_inhbt=%s\n", - name, - g_ftdm_sngss7_data.cfg.mtp1Link[x].span, - g_ftdm_sngss7_data.cfg.mtp1Link[x].chan, - g_ftdm_sngss7_data.cfg.mtp3Link[x].id, - DECODE_LSN_LINK_STATUS(sta.t.ssta.s.snDLSAP.state), - (sta.t.ssta.s.snDLSAP.locBlkd) ? "Y":"N", - (sta.t.ssta.s.snDLSAP.remBlkd) ? "Y":"N", - (sta.t.ssta.s.snDLSAP.locInhbt) ? "Y":"N", - (sta.t.ssta.s.snDLSAP.rmtInhbt) ? "Y":"N"); - - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Failed to find link=\"%s\"\n", name); - -success: - return FTDM_SUCCESS; + return cli_ss7_show_mtp3link_by_name(stream, name); } + /******************************************************************************/ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name) { - int x = 0; - SdMngmt sta; + SS7_RELAY_DBG_FUN(handle_status_mtp2link); - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) { + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Invalid stream\n"); - /* send the status request */ - if (ftmod_ss7_mtp2link_sta(x, &sta)) { - stream->write_function(stream, "Failed to read link=%s status\n", name); - return FTDM_FAIL; - } + if (!name) { + return cli_ss7_show_all_mtp2link(stream); + } - /* print the results */ - stream->write_function(stream, "%s|span=%d|chan=%d|sap=%d|state=%s|outsFrm=%d|drpdFrm=%d|lclStatus=%s|rmtStatus=%s|fsn=%d|bsn=%d\n", - name, - g_ftdm_sngss7_data.cfg.mtp1Link[x].span, - g_ftdm_sngss7_data.cfg.mtp1Link[x].chan, - g_ftdm_sngss7_data.cfg.mtp2Link[x].id, - DECODE_LSD_LINK_STATUS(sta.t.ssta.s.sdDLSAP.hlSt), - sta.t.ssta.s.sdDLSAP.psOutsFrm, - sta.t.ssta.s.sdDLSAP.cntMaDrop, - (sta.t.ssta.s.sdDLSAP.lclBsy) ? "Y":"N", - (sta.t.ssta.s.sdDLSAP.remBsy) ? "Y":"N", - sta.t.ssta.s.sdDLSAP.fsn, - sta.t.ssta.s.sdDLSAP.bsn); - - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Failed to find link=\"%s\"\n", name); - -success: - return FTDM_SUCCESS; + return cli_ss7_show_mtp2link_by_name(stream, name); } /******************************************************************************/ @@ -1721,8 +1772,8 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c memset (&sigev, 0, sizeof (sigev)); - if (range > 31) { - stream->write_function(stream, "Invalid range value %d", range); + if (range <= 1 || range > 31) { + stream->write_function(stream, "Invalid range value %d. Range value must be greater than 1 and less than 31. \n", range); return FTDM_SUCCESS; } @@ -1740,7 +1791,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_mutex_lock(ftdmchan->mutex); + ftdm_channel_lock(ftdmchan); /* throw the grp maint. block flag */ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX); @@ -1753,9 +1804,11 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c /* attach the cgb information */ main_chan = ftdmchan; sngss7_span->tx_cgb.circuit = sngss7_info->circuit->id; - sngss7_span->tx_cgb.range = range-1; + sngss7_span->tx_cgb.range = 0; sngss7_span->tx_cgb.type = 0; /* maintenace block */ - } /* if (ftdmchan->physical_chan_id == chan) */ + } else { + ((sngss7_span_data_t*)(main_chan->span->signal_data))->tx_cgb.range++; + } /* update the status field */ sngss7_span->tx_cgb.status[byte] = (sngss7_span->tx_cgb.status[byte] | (1 << bit)); @@ -1768,12 +1821,12 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c } /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - } /* if ( span and chan) */ - } /* if ( cic == voice) */ + ftdm_channel_unlock(ftdmchan); + } + } /* go the next circuit */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ + } if (!main_chan) { stream->write_function(stream, "Failed to find a voice cic in span %d chan %d range %d", span, chan, range); @@ -1794,7 +1847,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c if ((ftdmchan->physical_span_id == span) && ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - handle_show_status(stream, span, chan, verbose); + handle_show_status(stream, ftdmchan->physical_span_id, ftdmchan->physical_chan_id, verbose); } } /* if ( cic == voice) */ @@ -1809,24 +1862,48 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c /******************************************************************************/ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose) { - int x; - sngss7_chan_data_t *sngss7_info; - ftdm_channel_t *ftdmchan; - ftdm_channel_t *main_chan = NULL; - sngss7_span_data_t *sngss7_span; - int byte = 0; - int bit = 0; - ftdm_sigmsg_t sigev; + sngss7_chan_data_t *sngss7_info = NULL; + ftdm_channel_t *ftdmchan = NULL; + ftdm_channel_t *main_chan = NULL; + sngss7_span_data_t *sngss7_span = NULL; + sngss7_chan_data_t *ubl_sng_info[MAX_CIC_MAP_LENGTH+1]; + int x = 0; + int byte = 0; + int bit = 0; + int ubl_sng_info_idx = 1; + ftdm_sigmsg_t sigev; + memset(ubl_sng_info, 0, sizeof(ubl_sng_info)); memset (&sigev, 0, sizeof (sigev)); - - if (range > 31) { - stream->write_function(stream, "Invalid range value %d", range); + if (range <= 1 || range > 31) { + stream->write_function(stream, "Invalid range value %d. Range value must be greater than 1 and less than 31.\n", range); return FTDM_SUCCESS; } - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; + /* verify that there is not hardware block in the range. + * if there is any channel within the group unblock range, do not execute the group unblock */ + x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; + while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { + if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { + sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; + ftdmchan = sngss7_info->ftdmchan; + sngss7_span = ftdmchan->span->signal_data; + + if ( (ftdmchan->physical_span_id == span) + && (ftdmchan->physical_chan_id >= chan) + && (ftdmchan->physical_chan_id < (chan+range)) + && sngss7_test_ckt_blk_flag(sngss7_info, (FLAG_GRP_HW_BLOCK_TX | FLAG_GRP_HW_BLOCK_TX_DN)) + ) { + stream->write_function(stream, "There is at least one channel with hardware block. Group unblock operation not allowed at this time.\n"); + return FTDM_SUCCESS; + } + } + x++; + } + + + x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { @@ -1840,10 +1917,15 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_mutex_lock(ftdmchan->mutex); + ftdm_channel_lock(ftdmchan); /* throw the grp maint. block flag */ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX); + + if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) { + ubl_sng_info[ubl_sng_info_idx] = sngss7_info; + ubl_sng_info_idx++; + } /* bring the sig status up */ sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); @@ -1853,9 +1935,11 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c /* attach the cgb information */ main_chan = ftdmchan; sngss7_span->tx_cgu.circuit = sngss7_info->circuit->id; - sngss7_span->tx_cgu.range = range-1; + sngss7_span->tx_cgu.range = 0; sngss7_span->tx_cgu.type = 0; /* maintenace block */ - } /* if (ftdmchan->physical_chan_id == chan) */ + } else { + ((sngss7_span_data_t*)(main_chan->span->signal_data))->tx_cgu.range++; + } /* update the status field */ sngss7_span->tx_cgu.status[byte] = (sngss7_span->tx_cgu.status[byte] | (1 << bit)); @@ -1868,12 +1952,12 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c } /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - } /* if ( span and chan) */ - } /* if ( cic == voice) */ + ftdm_channel_unlock(ftdmchan); + } + } /* go the next circuit */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ + } if (!main_chan) { stream->write_function(stream, "Failed to find a voice cic in span %d chan %d range %d", span, chan, range); @@ -1883,6 +1967,13 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c /* send the circuit group block */ ft_to_sngss7_cgu(main_chan); + /* clearing blocking flags */ + for (x = 1; ubl_sng_info[x]; x++) { + sngss7_info = ubl_sng_info[x]; + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN); + } + x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { @@ -1894,7 +1985,8 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c if ((ftdmchan->physical_span_id == span) && ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - handle_show_status(stream, span, chan, verbose); + handle_show_status(stream, ftdmchan->physical_span_id, ftdmchan->physical_chan_id, verbose); + } } /* if ( cic == voice) */ @@ -2158,42 +2250,11 @@ success: /******************************************************************************/ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name) { - RyMngmt sta; - int x = 0; - - memset(&sta, 0x0, sizeof(sta)); - - - /* find the channel request by it's name */ - x = 1; - while(x < (MAX_RELAY_CHANNELS)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) { - - if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[x].id, &sta)) { - stream->write_function(stream, "Failed to read relay =%s status\n", name); - return FTDM_FAIL; - } - - /* print the results */ - stream->write_function(stream, "%s|sap=%d|type=%d|port=%d|hostname=%s|procId=%d|status=%s\n", - name, - g_ftdm_sngss7_data.cfg.relay[x].id, - g_ftdm_sngss7_data.cfg.relay[x].type, - g_ftdm_sngss7_data.cfg.relay[x].port, - g_ftdm_sngss7_data.cfg.relay[x].hostname, - g_ftdm_sngss7_data.cfg.relay[x].procId, - DECODE_LRY_CHAN_STATUS(sta.t.ssta.rySta.cStatus)); - - goto success; - } - - /* move to the next link */ - x++; - - } /* x < (MAX_RELAY_CHANNELS) */ - -success: - return FTDM_SUCCESS; + SS7_RELAY_DBG_FUN(handle_status_relay); + if (!name) { + return cli_ss7_show_all_relay(stream); + } + return cli_ss7_show_relay_by_name(stream, name); } /******************************************************************************/ @@ -2426,6 +2487,468 @@ static ftdm_status_t check_arg_count(int args, int min) } } + +/****************************************************************************** +* Fun: cli_ss7_show_mtp2link_by_id() +* Desc: display mtp3 link information with id +* Param: +* stream : output stream object +* rcId : mtp2 link's id +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_mtp2link_by_id(ftdm_stream_handle_t *stream, int rcId) +{ + SdMngmt sta; + + SS7_RELAY_DBG_FUN(cli_ss7_show_mtp2link_by_id); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + if (ftmod_ss7_mtp2link_sta(rcId, &sta)) { + stream->write_function(stream, "Failed to read status of MTP2 link, id=%d \n", rcId); + return FTDM_FAIL; + } + + stream->write_function(stream, "name=%s|span=%d|chan=%d|sap=%d|state=%s|outsFrm=%d|drpdFrm=%d|lclStatus=%s|rmtStatus=%s|fsn=%d|bsn=%d\n", + g_ftdm_sngss7_data.cfg.mtp2Link[rcId].name, + g_ftdm_sngss7_data.cfg.mtp1Link[rcId].span, + g_ftdm_sngss7_data.cfg.mtp1Link[rcId].chan, + g_ftdm_sngss7_data.cfg.mtp2Link[rcId].id, + DECODE_LSD_LINK_STATUS(sta.t.ssta.s.sdDLSAP.hlSt), + sta.t.ssta.s.sdDLSAP.psOutsFrm, + sta.t.ssta.s.sdDLSAP.cntMaDrop, + (sta.t.ssta.s.sdDLSAP.lclBsy) ? "Y":"N", + (sta.t.ssta.s.sdDLSAP.remBsy) ? "Y":"N", + sta.t.ssta.s.sdDLSAP.fsn, + sta.t.ssta.s.sdDLSAP.bsn + ); + + return FTDM_SUCCESS; +} + +/****************************************************************************** +* Fun: cli_ss7_show_mtp2link_by_name() +* Desc: display all relay channels information +* Param: +* stream : output stream object +* rcName: mtp2 link's name +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_mtp2link_by_name(ftdm_stream_handle_t *stream, char *name) +{ + int x = 0; + SS7_RELAY_DBG_FUN(cli_ss7_show_mtp2link_by_name); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + ftdm_assert_return(!ftdm_strlen_zero(name), FTDM_FAIL, "Null MTP2 link name\n"); + + for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { + if (0 == strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) { + return cli_ss7_show_mtp2link_by_id( stream, x ); + } + } + + stream->write_function (stream, "The MTP2 link with name \'%s\' is not found. \n", name); + return FTDM_FAIL; +} + +/****************************************************************************** +* Fun: cli_ss7_show_all_mtp2link() +* Desc: display all mtp2 links information +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_mtp2link(ftdm_stream_handle_t *stream) +{ + int x = 0; + + SS7_RELAY_DBG_FUN(cli_ss7_show_all_mtp2link); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { + if (!ftdm_strlen_zero( g_ftdm_sngss7_data.cfg.mtp2Link[x].name)) { + cli_ss7_show_mtp2link_by_id(stream, x ); + } + } + + return FTDM_SUCCESS; +} + +/****************************************************************************** +* Fun: cli_ss7_show_mtp3link_by_id() +* Desc: display mtp3 link information with id +* Param: +* stream : output stream object +* rcId : mtp3 link's id +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_mtp3link_by_id(ftdm_stream_handle_t *stream, int rcId) +{ + SnMngmt sta; + + SS7_RELAY_DBG_FUN(cli_ss7_show_mtp3link_by_id); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + memset(&sta, 0, sizeof(sta)); + if (ftmod_ss7_mtp3link_sta(rcId, &sta)) { + stream->write_function(stream, "Failed to read status of MTP3 link, id=%d \n", rcId); + return FTDM_FAIL; + } + + stream->write_function(stream, "name=%s|span=%d|chan=%d|sap=%d|state=%s|l_blk=%s|r_blk=%s|l_inhbt=%s|r_inhbt=%s\n", + g_ftdm_sngss7_data.cfg.mtp3Link[rcId].name, + g_ftdm_sngss7_data.cfg.mtp1Link[rcId].span, + g_ftdm_sngss7_data.cfg.mtp1Link[rcId].chan, + g_ftdm_sngss7_data.cfg.mtp3Link[rcId].id, + DECODE_LSN_LINK_STATUS(sta.t.ssta.s.snDLSAP.state), + (sta.t.ssta.s.snDLSAP.locBlkd) ? "Y":"N", + (sta.t.ssta.s.snDLSAP.remBlkd) ? "Y":"N", + (sta.t.ssta.s.snDLSAP.locInhbt) ? "Y":"N", + (sta.t.ssta.s.snDLSAP.rmtInhbt) ? "Y":"N" + ); + + return FTDM_SUCCESS; +} + +/****************************************************************************** +* Fun: cli_ss7_show_mtp3link_by_name() +* Desc: display all relay channels information +* Param: +* stream : output stream object +* rcName: mtp3 link's name +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_mtp3link_by_name(ftdm_stream_handle_t *stream, char *name) +{ + int x=0; + SS7_RELAY_DBG_FUN(cli_ss7_show_mtp3link_by_name); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + ftdm_assert_return(!ftdm_strlen_zero(name), FTDM_FAIL, "Null MTP3 link name\n"); + + for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { + if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { + return cli_ss7_show_mtp3link_by_id(stream, x ); + } + } + + stream->write_function(stream, "The MTP3 link with name \'%s\' is not found. \n", name); + return FTDM_FAIL; +} +/****************************************************************************** +* Fun: cli_ss7_show_all_mtp3link() +* Desc: display all mtp3 links information +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_mtp3link(ftdm_stream_handle_t *stream) +{ + int x = 0; + + SS7_RELAY_DBG_FUN(cli_ss7_show_all_mtp3link); + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { + if (!ftdm_strlen_zero(g_ftdm_sngss7_data.cfg.mtp3Link[x].name)) { + cli_ss7_show_mtp3link_by_id(stream, x); + } + } + + return FTDM_SUCCESS; +} + + +/****************************************************************************** +* Fun: cli_ss7_show_all_linkset() +* Desc: display all mtp3 linksets information +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_linkset(ftdm_stream_handle_t *stream) +{ + int x = 0; + SnMngmt sta; + + SS7_RELAY_DBG_FUN(cli_ss7_show_all_linkset); + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + x = 1; + while(x < (MAX_MTP_LINKSETS+1)) { + if (!ftdm_strlen_zero(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name)) { + if (ftmod_ss7_mtplinkSet_sta(x, &sta)) { + stream->write_function(stream, "Failed to read linkset=%s status\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name); + } else { + stream->write_function(stream, "name=%s|state=%s|nmbActLnk=%d\n", + g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, + DECODE_LSN_LINKSET_STATUS(sta.t.ssta.s.snLnkSet.state), sta.t.ssta.s.snLnkSet.nmbActLnks + ); + } + } + x++; + } + return FTDM_SUCCESS; +} + + +/****************************************************************************** +* Fun: cli_ss7_show_general() +* Desc: display all general information about ss7 +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_general(ftdm_stream_handle_t *stream) +{ + SS7_RELAY_DBG_FUN(cli_ss7_show_general); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + stream->write_function(stream, "MTP2 status: \n"); + cli_ss7_show_all_mtp2link(stream); + + stream->write_function(stream, "\nMTP3 status: \n"); + cli_ss7_show_all_mtp3link(stream); + + stream->write_function(stream, "\nMTP3 linkset status: \n"); + cli_ss7_show_all_linkset(stream); + +#if 0 + stream->write_function(stream, "\nMTP3 link route status: \n"); + + stream->write_function(stream, "\nISUP status: \n"); +#endif + + stream->write_function(stream, "\nRelay status: \n"); + cli_ss7_show_all_relay(stream); + + return FTDM_SUCCESS; +} + +/****************************************************************************** +* Fun: cli_ss7_show_relay_by_id() +* Desc: display all relay channels information +* Param: +* stream : output stream object +* rcId : channel's id +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_relay_by_id(ftdm_stream_handle_t *stream, int rcId) +{ + RyMngmt sta; + + SS7_RELAY_DBG_FUN(cli_ss7_show_relay_by_id); + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + memset(&sta, 0x0, sizeof(sta)); + if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[rcId].id, &sta)) { + stream->write_function(stream, "Failed to read relay =%s status\n", g_ftdm_sngss7_data.cfg.relay[rcId].name); + return FTDM_FAIL; + } + + stream->write_function(stream, "name=%s|sap=%d|type=%d|port=%d|hostname=%s|procId=%d|status=%s\n", + g_ftdm_sngss7_data.cfg.relay[rcId].name, + g_ftdm_sngss7_data.cfg.relay[rcId].id, + g_ftdm_sngss7_data.cfg.relay[rcId].type, + g_ftdm_sngss7_data.cfg.relay[rcId].port, + g_ftdm_sngss7_data.cfg.relay[rcId].hostname, + g_ftdm_sngss7_data.cfg.relay[rcId].procId, + DECODE_LRY_CHAN_STATUS(sta.t.ssta.rySta.cStatus) + ); + + return FTDM_SUCCESS; +} +/****************************************************************************** +* Fun: cli_ss7_show_relay_by_name() +* Desc: display all relay channels information +* Param: +* stream : output stream object +* rcName: channel's name +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_relay_by_name(ftdm_stream_handle_t *stream, char *name) +{ + int x = 0; + + SS7_RELAY_DBG_FUN(cli_ss7_show_relay_by_name); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + ftdm_assert_return(!ftdm_strlen_zero(name), FTDM_FAIL, "Null relay link name\n"); + + for (x = 1; x < MAX_RELAY_CHANNELS; x++) { + if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) { + return cli_ss7_show_relay_by_id(stream, x); + } + } + + stream->write_function( stream, "The relay channel with name \'%s\' is not found. \n", name); + return FTDM_FAIL; + +} +/****************************************************************************** +* Fun: cli_ss7_show_all_relay() +* Desc: display all relay channels information +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_relay(ftdm_stream_handle_t *stream) +{ + int x = 0; + SS7_RELAY_DBG_FUN(cli_ss7_show_relay_by_name); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + + for (x = 1; x < MAX_RELAY_CHANNELS; x++) { + if (!ftdm_strlen_zero(g_ftdm_sngss7_data.cfg.relay[x].name)) { + cli_ss7_show_relay_by_id (stream, x); + } + } + + return FTDM_SUCCESS; +} + + +/****************************************************************************** +* Fun: cli_ss7_show_channel_detail_of_span() +* Desc: display span information of a given id +* Param: +* stream : output stream object +* span_id : span id string received from cli +* chan_id : channel id string received from cli +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_channel_detail_of_span(ftdm_stream_handle_t *stream, char *span_id, char *chan_id) +{ + int x, y; + + SS7_RELAY_DBG_FUN(cli_ss7_show_channel_detail_of_span); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + ftdm_assert_return(span_id != 0, FTDM_FAIL, "Invalid span id\n"); + ftdm_assert_return(chan_id != 0, FTDM_FAIL, "Invalid chan id\n"); + + x = atoi(span_id); + y = atoi(chan_id); + if (!x) { + stream->write_function( stream, "Span \'%s\' does not exist. \n", span_id); + return FTDM_FAIL; + } + + return handle_show_status(stream, x, y, 1); +} + +/****************************************************************************** +* Fun: cli_ss7_show_all_channels_of_span() +* Desc: display span information of a given id +* Param: +* stream : output stream object +* span_id : span id string received from cli +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_channels_of_span(ftdm_stream_handle_t *stream, char *span_id) +{ + int x=-1; + SS7_RELAY_DBG_FUN(cli_ss7_show_all_channels_of_span); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + ftdm_assert_return(span_id != 0, FTDM_FAIL, "Invalid span id\n"); + + x = atoi(span_id); + if (!x) { + stream->write_function( stream, "Span \'%s\' does not exist. \n", span_id); + return FTDM_FAIL; + } + return handle_show_status(stream, x, 0, 1); +} + +/****************************************************************************** +* Fun: cli_ss7_show_span_by_id() +* Desc: display span information of a given id +* Param: +* stream : output stream object +* span_id : span id string received from cli +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_span_by_id(ftdm_stream_handle_t *stream, char *span_id) +{ + int x = -1; + + SS7_RELAY_DBG_FUN(cli_ss7_show_span_by_id); + + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + ftdm_assert_return(span_id != 0, FTDM_FAIL, "Invalid span id\n"); + + x = atoi(span_id); + if (!x) { + stream->write_function(stream, "Span \'%s\' does not exist. \n", span_id); + return FTDM_FAIL; + } + +#if 0 + stream->write_function( stream, "JZ: we should display span details here \n" ); +#endif + + cli_ss7_show_all_channels_of_span(stream, span_id); + + return FTDM_FAIL; +} + + +/****************************************************************************** +* Fun: cli_ss7_show_all_spans_detail() +* Desc: display all spans information in detail +* Param: +* stream : output stream object +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_spans_detail(ftdm_stream_handle_t *stream) +{ + SS7_RELAY_DBG_FUN(cli_ss7_show_all_spans_detail); + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + return handle_show_status(stream, 0, 0, 1); +} + +/****************************************************************************** +* Fun: cli_ss7_show_all_spans_general() +* Desc: display all spans information in general +* Param: +* stream : output stream object +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: James Zhang +*******************************************************************************/ +static ftdm_status_t cli_ss7_show_all_spans_general(ftdm_stream_handle_t *stream) +{ + SS7_RELAY_DBG_FUN(cli_ss7_show_all_spans_general); + ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); + return FTDM_FAIL; +} + /******************************************************************************/ /* For Emacs: * Local Variables: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c index 20e9a1261c..24ea92e6db 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c @@ -89,12 +89,13 @@ ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt) { - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - char nadi[2]; - SS7_FUNC_TRACE_ENTER(__FUNCTION__); - memset(nadi, '\0', sizeof(nadi)); + + sngss7_chan_data_t *sngss7_info = NULL; + ftdm_channel_t *ftdmchan = NULL; + char var[FTDM_DIGITS_LIMIT]; + + memset(var, '\0', sizeof(var)); /* get the ftdmchan and ss7_chan_data from the circuit */ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { @@ -209,12 +210,52 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ } /* add any special variables for the dialplan */ - sprintf(nadi, "%d", siConEvnt->cgPtyNum.natAddrInd.val); - sngss7_add_var(sngss7_info, "ss7_clg_nadi", nadi); + sprintf(var, "%d", siConEvnt->cgPtyNum.natAddrInd.val); + sngss7_add_var(sngss7_info, "ss7_clg_nadi", var); - sprintf(nadi, "%d", siConEvnt->cdPtyNum.natAddrInd.val); - sngss7_add_var(sngss7_info, "ss7_cld_nadi", nadi); + sprintf(var, "%d", siConEvnt->cdPtyNum.natAddrInd.val); + sngss7_add_var(sngss7_info, "ss7_cld_nadi", var); + /* Retrieve the Location Number if present (see ITU Q.763, 3.30) */ + if (siConEvnt->cgPtyNum1.eh.pres) { + if (siConEvnt->cgPtyNum1.addrSig.pres) { + /* fill in the ss7 location address number */ + copy_tknStr_from_sngss7(siConEvnt->cgPtyNum1.addrSig, var, siConEvnt->cgPtyNum1.oddEven); + sngss7_add_var(sngss7_info, "ss7_loc_digits", var); + } + + if (siConEvnt->cgPtyNum1.scrnInd.pres) { + /* fill in the screening indication value */ + sprintf(var, "%d", siConEvnt->cgPtyNum1.scrnInd.val); + sngss7_add_var(sngss7_info, "ss7_loc_screen_ind", var); + } + + if (siConEvnt->cgPtyNum1.presRest.pres) { + /* fill in the presentation value */ + sprintf(var, "%d", siConEvnt->cgPtyNum1.presRest.val); + sngss7_add_var(sngss7_info, "ss7_loc_pres_ind", var); + } + + if (siConEvnt->cgPtyNum1.natAddrInd.pres) { + sprintf(var, "%d", siConEvnt->cgPtyNum1.natAddrInd.val); + sngss7_add_var(sngss7_info, "ss7_loc_nadi", var); + } + } else { + SS7_DEBUG_CHAN(ftdmchan, "No Location Number information in IAM%s\n", " "); + } + + sprintf(var, "%d", sngss7_info->circuit->cic); + sngss7_add_var(sngss7_info, "ss7_cic", var); + + sprintf(var, "%d", g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc ); + sngss7_add_var(sngss7_info, "ss7_opc", var); + + if (siConEvnt->callRef.callId.pres) { + ftdmchan->caller_data.call_reference = (unsigned int)siConEvnt->callRef.callId.val; + } else { + ftdmchan->caller_data.call_reference = 0; + } + if (sngss7_info->circuit->transparent_iam) { sngss7_save_iam(ftdmchan, siConEvnt); } @@ -252,9 +293,9 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ case (FTDM_CHANNEL_STATE_HANGUP_COMPLETE): handle_glare: /* the core already has plans for this channel...glare */ - SS7_INFO_CHAN(ftdmchan, "Got IAM on channel that is already inuse (state=%s|inuse=%d)...glare!\n", + SS7_INFO_CHAN(ftdmchan, "Got IAM on channel that is already inuse (state=%s|inuse=%c)...glare!\n", ftdm_channel_state2str (ftdmchan->state), - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)); + ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE) ? 'Y' : 'N'); /* save the info so that we can use it later on */ sngss7_info->glare.spInstId = spInstId; @@ -401,6 +442,8 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ append_tknStr_from_sngss7(siCnStEvnt->subNum.addrSig, ftdmchan->caller_data.dnis.digits, siCnStEvnt->subNum.oddEven); + SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Rx SAM (digits = %s)\n", sngss7_info->circuit->cic, + ftdmchan->caller_data.dnis.digits); } else { SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in SAM!%s\n", " "); } @@ -696,7 +739,7 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ * ITU Q.784 Test Number 3.8 * Collision of REL messages */ - SS7_DEBUG_CHAN(ftdmchan, "Collision of REL messages. Rx REL while waiting for RLC.\n", " "); + SS7_DEBUG_CHAN(ftdmchan, "Collision of REL messages. Rx REL while waiting for RLC.%s\n", " "); if (sngss7_test_ckt_flag(sngss7_info, FLAG_LOCAL_REL) && !sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) { /* locally requested hangup completed, wait for remote RLC */ @@ -1639,8 +1682,8 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ ftdm_mutex_lock(ftdmchan->mutex); /* check if the channel is blocked */ - if (!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX))) { - SS7_WARN("Received UBL on circuit that is not blocked!\n"); + if (!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) && !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) { + SS7_WARN("Received UBL on circuit that is not blocked! span= %d, chan= %d , flag = %x \n", g_ftdm_sngss7_data.cfg.isupCkt[circuit].span, g_ftdm_sngss7_data.cfg.isupCkt[circuit].chan,sngss7_info->blk_flags ); } /* throw the unblock flag */ @@ -1648,6 +1691,8 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* clear the block flag */ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX_DN); /* set the channel to suspended state */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); @@ -1688,14 +1733,6 @@ ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ DECODE_LCC_EVENT(evntType)); } - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* KONRAD FIX ME */ - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - SS7_FUNC_TRACE_EXIT(__FUNCTION__); return FTDM_SUCCESS; } @@ -1860,7 +1897,7 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* go to DOWN */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); } else { - SS7_ERROR("Received RSC-RLC but we're not waiting on a RSC-RLC on CIC #, dropping\n", sngss7_info->circuit->cic); + SS7_ERROR("Received RSC-RLC but we're not waiting on a RSC-RLC on CIC #%d, dropping\n", sngss7_info->circuit->cic); } break; @@ -2449,6 +2486,8 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ /**********************************************************************/ case 0: /* maintenance oriented */ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); break; /**********************************************************************/ case 1: /* hardware failure oriented */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c index 4c6c16350d..b13c98b1e6 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c @@ -486,47 +486,47 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic); } - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; + x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; while ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) && - (g_ftdm_sngss7_data.cfg.isupCkt[x].id < ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) { - /**********************************************************************/ + (g_ftdm_sngss7_data.cfg.isupCkt[x].id < ((g_ftdm_sngss7_data.cfg.procId + 1) * MAX_CIC_MAP_LENGTH))) { + /**********************************************************************/ /* confirm this is a voice channel and not a gap/sig (no ftdmchan there) */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) goto move_along; + if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { + /* compare the intfIds */ + if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) { + /* we have a match, setup the pointers to the correct values */ + circuit = x; - /* compare the intfIds */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) { - /* we have a match, setup the pointers to the correct values */ - circuit = x; + /* confirm that the circuit is active on our side otherwise move to the next circuit */ + if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) { + SS7_DEBUG("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n", + g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, + DECODE_LCC_EVENT(evntType)); + x++; + continue; + } - /* confirm that the circuit is active on our side otherwise move to the next circuit */ - if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) { - SS7_DEBUG("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - continue; - } - - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FUNCTION__); - return; + if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { + SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); + SS7_FUNC_TRACE_EXIT(__FUNCTION__); + return; + } + + /* bounce out of the loop */ + break; } + } - /* bounce out of the loop */ - break; - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].intfId == intfId) */ - -move_along: - /* move along ... nothing to see here */ x++; - - /**********************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ + /**********************************************************************/ + } /* check if we found any circuits that are on the intfId, drop the message - * if none are found - */ - if (ftdmchan == NULL) goto sta_ind_end; + * if none are found */ + if (!ftdmchan) { + SS7_FUNC_TRACE_EXIT(__FUNCTION__); + return; + } break; /**************************************************************************/ @@ -544,7 +544,6 @@ move_along: SS7_FUNC_TRACE_EXIT(__FUNCTION__); return; } - break; /**************************************************************************/ } /* switch (evntType) */ @@ -571,9 +570,6 @@ move_along: /* enqueue this event */ ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - -sta_ind_end: - SS7_FUNC_TRACE_EXIT(__FUNCTION__); } /******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c index 4b5787c0cb..cdedf791ce 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c @@ -31,6 +31,7 @@ * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + /* INCLUDE ********************************************************************/ #include "ftmod_sangoma_ss7_main.h" /******************************************************************************/ @@ -279,7 +280,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); } - ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %d\n", + ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n", buf, DECODE_LSD_EVENT(sta->t.usta.alarm.event), DECODE_DISC_REASON(sta->t.usta.evntParm[1])); @@ -353,6 +354,8 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta) char buf[50]; int x = 1; + SS7_RELAY_DBG_FUN(handle_sng_mtp3_alarm); + memset(buf, '\0', sizeof(buf)); switch (sta->hdr.elmId.elmnt) { @@ -492,6 +495,8 @@ void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta) char tmp[25]; char *p = NULL; int x = 0; + + SS7_RELAY_DBG_FUN(handle_sng_isup_alarm); /* initalize the msg variable to NULLs */ memset(&msg[0], '\0', sizeof(&msg)); @@ -502,7 +507,6 @@ void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta) return; } - /* point p to the first spot in msg */ p = &msg[0]; @@ -742,6 +746,7 @@ void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta) void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta) { + SS7_RELAY_DBG_FUN(handle_sng_cc_alarm); return; } /* handle_cc_alarm */ @@ -749,6 +754,7 @@ void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta) void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta) { + SS7_RELAY_DBG_FUN(handle_sng_relay_alarm); switch (sta->hdr.elmId.elmnt) { /**************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index 6601c2e91a..049aa1546d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -60,6 +60,7 @@ static ftdm_status_t ftdm_sangoma_ss7_stop (ftdm_span_t * span); static ftdm_status_t ftdm_sangoma_ss7_start (ftdm_span_t * span); /******************************************************************************/ + /* STATE MAP ******************************************************************/ ftdm_state_map_t sangoma_ss7_state_map = { { @@ -281,7 +282,37 @@ ftdm_state_map_t sangoma_ss7_state_map = { } }; -/******************************************************************************/ +static void handle_hw_alarm(ftdm_event_t *e) +{ + sngss7_chan_data_t *ss7_info = NULL; + ftdm_channel_t *ftdmchan = NULL; + int x = 0; + + ftdm_assert(e != NULL, "Null event!\n"); + + for (x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0; x++) { + if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { + ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; + ftdmchan = ss7_info->ftdmchan; + + if (e->channel->span_id == ftdmchan->physical_span_id && + e->channel->chan_id == ftdmchan->physical_chan_id) { + if (e->enum_id == FTDM_OOB_ALARM_TRAP) { + sngss7_set_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX); + if (ftdmchan->state != FTDM_CHANNEL_STATE_SUSPENDED) { + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); + } + } else { + sngss7_set_ckt_blk_flag(ss7_info, FLAG_GRP_HW_UNBLK_TX); + sngss7_clear_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX); + if (ftdmchan->state != FTDM_CHANNEL_STATE_SUSPENDED) { + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); + } + } + } + } + } +} /* MONITIOR THREADS ***********************************************************/ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) @@ -293,6 +324,9 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) sngss7_event_data_t *sngss7_event = NULL; sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data; + int b_alarm_test = 1; + sngss7_chan_data_t *ss7_info=NULL; + ftdm_log (FTDM_LOG_INFO, "ftmod_sangoma_ss7 monitor thread for span=%u started.\n", ftdmspan->span_id); /* set IN_THREAD flag so that we know this thread is running */ @@ -311,6 +345,30 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) } while (ftdm_running () && !(ftdm_test_flag (ftdmspan, FTDM_SPAN_STOP_THREAD))) { + int x = 0; + if (b_alarm_test) { + b_alarm_test = 0; + for (x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; + g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0; x++) { + if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { + ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; + ftdmchan = ss7_info->ftdmchan; + if (!ftdmchan) { + continue; + } + + if (ftdmchan->alarm_flags != 0) { /* we'll send out block */ + sngss7_set_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX ); + } else { /* we'll send out reset */ + sngss7_clear_ckt_blk_flag( ss7_info, FLAG_GRP_HW_BLOCK_TX ); + sngss7_clear_ckt_blk_flag( ss7_info, FLAG_GRP_HW_BLOCK_TX_DN ); + sngss7_set_ckt_blk_flag (ss7_info, FLAG_GRP_HW_UNBLK_TX); + } + } + usleep(50); + } + ftdmchan = NULL; + } /* check the channel state queue for an event*/ switch ((ftdm_interrupt_multiple_wait(ftdm_sangoma_ss7_int, 2, 100))) { @@ -388,7 +446,11 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) switch (ftdm_span_poll_event(ftdmspan, 0, NULL)) { /**********************************************************************/ case FTDM_SUCCESS: - while (ftdm_span_next_event(ftdmspan, &event) == FTDM_SUCCESS); + while (ftdm_span_next_event(ftdmspan, &event) == FTDM_SUCCESS) { + if (event->e_type == FTDM_EVENT_OOB) { + handle_hw_alarm(event); + } + } break; /**********************************************************************/ case FTDM_TIMEOUT: @@ -530,6 +592,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) i++; } + /* kill t10 if active */ + if (sngss7_info->t10.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); + } + /* check if the end of pulsing (ST) character has arrived or the right number of digits */ if (ftdmchan->caller_data.dnis.digits[i-1] == 'F') { SS7_DEBUG_CHAN(ftdmchan, "Received the end of pulsing character %s\n", ""); @@ -551,7 +618,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) } else { /* if we are coming from idle state then we have already been here once before */ if (ftdmchan->last_state != FTDM_CHANNEL_STATE_IDLE) { - SS7_INFO_CHAN(ftdmchan,"Received %d out of %d so far: %s...starting T35\n", + SS7_INFO_CHAN(ftdmchan, "Received %d out of %d so far: %s...starting T35\n", i, sngss7_info->circuit->min_digits, ftdmchan->caller_data.dnis.digits); @@ -566,7 +633,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) SS7_ERROR ("Unable to schedule timer, hanging up call!\n"); - ftdmchan->caller_data.hangup_cause = 41; + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; /* set the flag to indicate this hangup is started from the local side */ sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); @@ -574,9 +641,29 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /* end the call */ state_flag = 0; ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - } /* if (ftdm_sched_timer(sngss7_info->t35.sched, */ - } /* if (ftdmchan->last_state != FTDM_CHANNEL_STATE_IDLE) */ - } /* checking ST/#digits */ + } + } + + /* start ISUP t10 */ + if (ftdm_sched_timer (sngss7_info->t10.sched, + "t10", + sngss7_info->t10.beat, + sngss7_info->t10.callback, + &sngss7_info->t10, + &sngss7_info->t10.hb_timer_id)) { + + SS7_ERROR ("Unable to schedule timer, hanging up call!\n"); + + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; + + /* set the flag to indicate this hangup is started from the local side */ + sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); + + /* end the call */ + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); + } + } break; @@ -656,10 +743,14 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) { /* inform the user there is media avai */ sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_PROGRESS_MEDIA); + } else { + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_ACM)) { + sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_ACM); + ft_to_sngss7_acm(ftdmchan); + } + ft_to_sngss7_cpg(ftdmchan); } - - /* nothing to do at this time */ break; /**************************************************************************/ case FTDM_CHANNEL_STATE_UP: /*call is accpeted...both incoming and outgoing */ @@ -751,9 +842,18 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) { /* check if this hangup is from a tx RSC */ if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) { - /* go to RESTART State until RSCa is received */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT)) { + ft_to_sngss7_rsc (ftdmchan); + sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); + } else if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) { + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + } else { + /* go to RESTART State until RSCa is received */ + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); + } } else { /* if the hangup is from a rx RSC, rx GRS, or glare don't sent RLC */ if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) && @@ -844,7 +944,9 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /* check if we came from reset (aka we just processed a reset) */ if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) || - (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED)) { + (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) || + (ftdmchan->last_state == FTDM_CHANNEL_STATE_HANGUP_COMPLETE)) { + /* check if reset flags are up indicating there is more processing to do yet */ if (!(sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) && @@ -949,9 +1051,12 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) && !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) { - /* send a reset request */ - ft_to_sngss7_rsc (ftdmchan); - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT); + /* don't send out reset before finished hanging up if I'm in-use. */ + if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { + /* send a reset request */ + ft_to_sngss7_rsc (ftdmchan); + sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT); + } } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */ @@ -1102,16 +1207,97 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /* clear the unblock flag */ sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX); - /* bring the sig status up */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + /* not bring the cic up if there is a hardware block */ + if( !sngss7_test_ckt_blk_flag(sngss7_info, (FLAG_GRP_HW_BLOCK_TX | FLAG_GRP_HW_BLOCK_TX_DN) ) ) { + /* bring the sig status up */ + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - /* send a uba */ - ft_to_sngss7_uba (ftdmchan); + /* send a uba */ + ft_to_sngss7_uba (ftdmchan); + } /* check the last state and return to it to allow the call to finish */ goto suspend_goto_last; } + + /**********************************************************************/ + /* hardware block/unblock tx */ + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_GRP_HW_BLOCK_TX ) && + !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN )) { + + SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_BLOCK_TX flag %s\n", ""); + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); + + /* dont send block again if the channel is already blocked by maintenance */ + if( !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) && + !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN) + ) { + ft_to_sngss7_blo(ftdmchan); + } + sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN); + + goto suspend_goto_last; + } + + if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_TX)) { + SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_UNBLK_TX flag %s\n", ""); + + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_TX); + + /* do not set the channel up if it's blocked by blo/cgb command OR blocked by receiving blo/cgb */ + if (!sngss7_test_ckt_blk_flag(sngss7_info, ( FLAG_CKT_MN_BLOCK_TX + | FLAG_CKT_MN_BLOCK_TX + | FLAG_GRP_MN_BLOCK_TX + | FLAG_GRP_MN_BLOCK_TX_DN + | FLAG_CKT_MN_BLOCK_RX + | FLAG_CKT_MN_BLOCK_RX_DN + | FLAG_GRP_MN_BLOCK_RX + | FLAG_GRP_MN_BLOCK_RX_DN + ) + ) + ) { + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + ft_to_sngss7_ubl(ftdmchan); + } + + goto suspend_goto_last; + } +#if 0 +//jz: there is no such thing of "remote hw block". for receiver, there are only block and unblock + + /**********************************************************************/ + // jz: hardware block/unblock rx + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_GRP_HW_BLOCK_RX ) && + !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN )) { + + SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_BLOCK_RX flag %s\n", ""); + + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); + ft_to_sngss7_bla(ftdmchan); + sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN); + + goto suspend_goto_last; + } + + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_GRP_HW_UNBLK_RX )){ + SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_UNBLK_RX flag %s\n", ""); + + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_RX); + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + + ft_to_sngss7_uba(ftdmchan); + + goto suspend_goto_last; + } +#endif + + + /**********************************************************************/ if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) && !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) { @@ -1142,11 +1328,14 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /* clear the unblock flag */ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); - /* bring the sig status up */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + /* not bring the cic up if there is a hardware block */ + if (!sngss7_test_ckt_blk_flag(sngss7_info, (FLAG_GRP_HW_BLOCK_TX | FLAG_GRP_HW_BLOCK_TX_DN))) { + /* bring the sig status up */ + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - /* send a ubl */ - ft_to_sngss7_ubl (ftdmchan); + /* send a ubl */ + ft_to_sngss7_ubl(ftdmchan); + } /* check the last state and return to it to allow the call to finish */ goto suspend_goto_last; @@ -1624,32 +1813,37 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) ftdm_log (FTDM_LOG_INFO, "Starting ftmod_sangoma_ss7 unload...\n"); - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) { + + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_STARTED)) { sng_isup_free_cc(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_STARTED); } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED)) { ftmod_ss7_shutdown_isup(); sng_isup_free_isup(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED); } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_STARTED)) { ftmod_ss7_shutdown_mtp3(); sng_isup_free_mtp3(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_STARTED); } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED)) { ftmod_ss7_shutdown_mtp2(); sng_isup_free_mtp2(); - sng_isup_free_mtp1(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED); } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) { - /* go through all the relays channels and configure it */ + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_STARTED)) { + sng_isup_free_mtp1(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_STARTED); + } + + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED)) { + /* go through all the relays channels and disable them */ x = 1; while (x < (MAX_RELAY_CHANNELS)) { /* check if this relay channel has been configured already */ @@ -1658,24 +1852,28 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) /* send the specific configuration */ if (ftmod_ss7_disable_relay_channel(x)) { SS7_CRITICAL("Relay Channel %d disable failed!\n", x); - return 1; + /* jz: dont leave like this + * return 1; + * */ } else { SS7_INFO("Relay Channel %d disable DONE!\n", x); } /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.relay[x].flags &= !SNGSS7_CONFIGURED; + g_ftdm_sngss7_data.cfg.relay[x].flags &= ~(SNGSS7_CONFIGURED); } /* if !SNGSS7_CONFIGURED */ x++; } /* while (x < (MAX_RELAY_CHANNELS)) */ ftmod_ss7_shutdown_relay(); sng_isup_free_relay(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED); } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM)) { + + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED)) { sng_isup_free_sm(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED); } sng_isup_free_gen(); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index b433bfb20d..caef19af12 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -51,7 +51,7 @@ /* DEFINES ********************************************************************/ #define MAX_NAME_LEN 25 -#define MAX_PATH 255 +#define MAX_PATH 4096 #define MAX_CIC_LENGTH 5 #define MAX_CIC_MAP_LENGTH 1000 @@ -64,12 +64,10 @@ (switchtype == LSI_SW_ANS92) || \ (switchtype == LSI_SW_ANS95) -typedef struct ftdm2trillium -{ +typedef struct ftdm2trillium { uint8_t ftdm_val; uint8_t trillium_val; -}ftdm2trillium_t; - +} ftdm2trillium_t; typedef enum { SNGSS7_CON_IND_EVENT = 0, @@ -290,7 +288,6 @@ typedef struct sng_isup_intf { uint32_t ssf; uint32_t isap; uint16_t t4; - uint32_t t10; uint32_t t11; uint32_t t18; uint32_t t19; @@ -346,6 +343,7 @@ typedef struct sng_isup_ckt { uint8_t transparent_iam; void *obj; uint16_t t3; + uint32_t t10; uint16_t t12; uint16_t t13; uint16_t t14; @@ -473,6 +471,7 @@ typedef struct sngss7_chan_data { void *raw_data; /* send on next sigevent */ sngss7_glare_data_t glare; sngss7_timer_data_t t35; + sngss7_timer_data_t t10; sngss7_group_data_t rx_grs; sngss7_group_data_t rx_gra; sngss7_group_data_t tx_grs; @@ -609,22 +608,20 @@ typedef enum { "TX CKT BLK DN", \ "TX CKT UNBLK", \ "TX CKT UNBLK DN", \ - "RX GRP MN BLK", \ - "RX GRP MN BLK DN", \ - "RX GRP MN UNBLK", \ - "RX GRP MN UNBLK DN", \ - "TX GRP MN BLK", \ - "TX GRP MN BLK DN", \ - "TX GRP MN UNBLK", \ - "TX GRP MN UNBLK DN", \ "RX GRP HW BLK", \ "RX GRP HW BLK DN", \ - "RX GRP HW UNBLK", \ - "RX GRP HW UNBLK DN", \ "TX GRP HW BLK", \ "TX GRP HW BLK DN", \ + "RX GRP MN BLK", \ + "RX GRP MN BLK DN", \ + "TX GRP MN BLK", \ + "TX GRP MN BLK DN", \ "TX GRP HW UNBLK", \ - "TX GRP HW UNBLK DN" + "TX GRP HW UNBLK DN", \ + "TX GRP MN UNBLK", \ + "TX GRP MN UNBLK DN", \ + "RX GRP HW UNBLK", \ + "RX GRP HW UNBLK DN" FTDM_STR2ENUM_P(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t) /* valid for every cfg array except circuits */ @@ -636,13 +633,25 @@ typedef enum { } sng_cfg_flag_t; typedef enum { - SNGSS7_SM = (1 << 0), - SNGSS7_RY = (1 << 1), - SNGSS7_MTP1 = (1 << 2), - SNGSS7_MTP2 = (1 << 3), - SNGSS7_MTP3 = (1 << 4), - SNGSS7_ISUP = (1 << 5), - SNGSS7_CC = (1 << 6) + SNGSS7_SM_STARTED = (1 << 0), + + SNGSS7_RY_PRESENT = (1 << 2), + SNGSS7_RY_STARTED = (1 << 3), + + SNGSS7_MTP1_PRESENT = (1 << 4), + SNGSS7_MTP1_STARTED = (1 << 5), + + SNGSS7_MTP2_PRESENT = (1 << 6), + SNGSS7_MTP2_STARTED = (1 << 7), + + SNGSS7_MTP3_PRESENT = (1 << 8), + SNGSS7_MTP3_STARTED = (1 << 9), + + SNGSS7_ISUP_PRESENT = (1 << 10), + SNGSS7_ISUP_STARTED = (1 << 11), + + SNGSS7_CC_PRESENT = (1 << 12), + SNGSS7_CC_STARTED = (1 << 13), } sng_task_flag_t; /******************************************************************************/ @@ -739,6 +748,7 @@ int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state); /* in ftmod_sangoma_ss7_out.c */ void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan); void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan); +void ft_to_sngss7_cpg (ftdm_channel_t *ftdmchan); void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan); void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan); void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan); @@ -878,6 +888,7 @@ ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data /* in ftmod_sangoma_ss7_timers.c */ void handle_isup_t35(void *userdata); +void handle_isup_t10(void *userdata); /******************************************************************************/ @@ -1029,13 +1040,12 @@ if (ftdmchan->state == new_state) { \ #define sngss7_set_options(obj, option) ((obj)->options |= (option)) -#ifdef SS7_PRODUCTION -# define SS7_ASSERT \ - SS7_INFO_CHAN(ftdmchan,"Production Mode, continuing%s\n", ""); +#ifdef SMG_RELAY_DBG +#define SS7_RELAY_DBG(a,...) printf(a"\n", ##__VA_ARGS__) +#define SS7_RELAY_DBG_FUN(a) printf(#a"\n") #else -# define SS7_ASSERT \ - SS7_ERROR_CHAN(ftdmchan, "Debugging Mode, ending%s\n", ""); \ - *(int*)0=0; +#define SS7_RELAY_DBG(a, ...) +#define SS7_RELAY_DBG_FUN(a) #endif /******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 56238abdf9..b729552092 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -36,6 +36,8 @@ /******************************************************************************/ /* DEFINES ********************************************************************/ +#define SNGSS7_EVNTINFO_IND_INBAND_AVAIL 0x03 +/******************************************************************************/ /* GLOBALS ********************************************************************/ @@ -171,6 +173,7 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) acm.optBckCalInd.simpleSegmInd.pres = PRSNT_DEF; acm.optBckCalInd.mlppUserInd.pres = PRSNT_DEF; acm.optBckCalInd.usrNetIneractInd.pres = PRSNT_DEF; + acm.optBckCalInd.netExcDelInd.pres = PRSNT_DEF; } /* if (sngss7_test_options(isup_intf, SNGSS7_ACM_OBCI_BITA)) */ /* send the ACM request to LibSngSS7 */ @@ -187,6 +190,31 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) return; } +void ft_to_sngss7_cpg (ftdm_channel_t *ftdmchan) +{ + SiCnStEvnt cpg; + SS7_FUNC_TRACE_ENTER (__FUNCTION__); + + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + + + memset (&cpg, 0, sizeof (cpg)); + + cpg.evntInfo.eh.pres = PRSNT_NODEF; + + cpg.evntInfo.evntInd.pres = PRSNT_NODEF; + cpg.evntInfo.evntInd.val = SNGSS7_EVNTINFO_IND_INBAND_AVAIL; /* Event Indicator = In-band info is now available */ + + cpg.evntInfo.evntPresResInd.pres = PRSNT_NODEF; + cpg.evntInfo.evntPresResInd.val = 0; /* Event presentation restricted indicator = no indication */ + + /* send the CPG request to LibSngSS7 */ + sng_cc_con_status (1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &cpg, PROGRESS); + + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "[CIC:%d]Tx CPG\n", sngss7_info->circuit->cic); + SS7_FUNC_TRACE_EXIT (__FUNCTION__); + return; +} void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan) { SS7_FUNC_TRACE_ENTER (__FUNCTION__); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c index 16624cc902..c99a14a7e7 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c @@ -49,7 +49,7 @@ ftdm_status_t handle_relay_disconnect(RyMngmt *sta); static ftdm_status_t reconfig_all_ckts_for_relay(void); static ftdm_status_t disable_all_ckts_for_relay(void); static ftdm_status_t block_all_ckts_for_relay(uint32_t procId); -static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId); +/* static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId); */ static ftdm_status_t disable_all_sigs_for_relay(uint32_t procId); static ftdm_status_t disble_all_mtp2_sigs_for_relay(void); /******************************************************************************/ @@ -59,43 +59,26 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta) { sng_relay_t *sng_relay = &g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id]; - - /* test if this is the first time the channel comes up */ if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) { - SS7_INFO("Relay Channel %d initial connection UP\n", sng_relay->id); - - /* mark the channel as being up */ + /* SS7_INFO("Relay Channel %d initial connection UP\n", sng_relay->id); */ sngss7_set_flag(sng_relay, SNGSS7_RELAY_INIT); - } else { - SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id); - - /* react based on type of channel */ - switch (sng_relay->type) { - /******************************************************************/ - case (LRY_CT_TCP_CLIENT): - /* reconfigure all ISUP ckts, since the main system would have lost all configs */ + } + + SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id); + if (sng_relay->type == LRY_CT_TCP_CLIENT) { + if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) { if (reconfig_all_ckts_for_relay()) { SS7_ERROR("Failed to reconfigure ISUP Ckts!\n"); /* we're done....this is very bad! */ } - break; - /******************************************************************/ - case (LRY_CT_TCP_SERVER): - /* bring the sig links on the client system back up */ - ftmod_ss7_enable_grp_mtp3Link(sta->t.usta.s.ryUpUsta.id); - - /* unbloock the ckts on the client system */ - unblock_all_ckts_for_relay(sta->t.usta.s.ryUpUsta.id); - - break; - /******************************************************************/ - default: - break; - /******************************************************************/ - } /* switch (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id].type) */ - } /* intial up? */ - - return FTDM_SUCCESS; + } + return FTDM_SUCCESS; + } else if (sng_relay->type == LRY_CT_TCP_SERVER) { + ftmod_ss7_enable_grp_mtp3Link(sta->t.usta.s.ryUpUsta.id); + /* unbloock the ckts on the client system */ + return FTDM_SUCCESS; + } + return FTDM_FAIL; } /******************************************************************************/ @@ -300,7 +283,7 @@ ftdm_status_t disable_all_sigs_for_relay(uint32_t procId) ftdm_status_t disble_all_mtp2_sigs_for_relay(void) { /* check if there is a local mtp2 link*/ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) { + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED)) { SS7_INFO("Disalbing all mtp2 sig links on local system\n"); ftmod_ss7_disable_grp_mtp2Link(1); @@ -310,6 +293,7 @@ ftdm_status_t disble_all_mtp2_sigs_for_relay(void) } +#if 0 /******************************************************************************/ static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId) { @@ -345,6 +329,7 @@ static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId) return FTDM_SUCCESS; } +#endif /******************************************************************************/ /* For Emacs: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c index 613ad6d95e..457964a95f 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c @@ -319,7 +319,7 @@ ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb if (genNmb->nmbQual.pres == PRSNT_NODEF) { snprintf(val, sizeof(val), "%d", genNmb->nmbQual.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"number qualifier\" \n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"number qualifier\" \"%s\"\n", val); sngss7_add_var(sngss7_info, "ss7_gn_numqual", val); } @@ -2454,7 +2454,7 @@ ftdm_status_t sngss7_save_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt) goto done; } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%d\n", len); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%lu\n", len); /* Worst case: size will triple after url encode */ url_encoded_iam = ftdm_malloc(3*sizeof(*siConEvnt)); @@ -2468,10 +2468,10 @@ ftdm_status_t sngss7_save_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt) /* URL encode buffer to that its safe to store it in a string */ ftdm_url_encode((const char*)compressed_iam, url_encoded_iam, len); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%d\n", strlen(url_encoded_iam)); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%"FTDM_SIZE_FMT"\n", strlen(url_encoded_iam)); if (strlen(url_encoded_iam) > g_ftdm_sngss7_data.cfg.transparent_iam_max_size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "IAM variable length exceeds max size (len:%d max:%d) \n", strlen(url_encoded_iam), g_ftdm_sngss7_data.cfg.transparent_iam_max_size); + ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "IAM variable length exceeds max size (len:%"FTDM_SIZE_FMT" max:%d) \n", strlen(url_encoded_iam), g_ftdm_sngss7_data.cfg.transparent_iam_max_size); ret_val = FTDM_FAIL; goto done; } @@ -2505,10 +2505,10 @@ ftdm_status_t sngss7_retrieve_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt url_encoded_iam = ftdm_strdup(val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%d\n", strlen(val)); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%"FTDM_SIZE_FMT"\n", strlen(val)); ftdm_url_decode(url_encoded_iam, &url_encoded_iam_len); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%d\n", url_encoded_iam_len); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%"FTDM_SIZE_FMT"\n", url_encoded_iam_len); uncompressed_buffer = ftdm_malloc(sizeof(*siConEvnt)); ftdm_assert_return(uncompressed_buffer, FTDM_FAIL, "Failed to allocate buffer for uncompressed buffer\n"); @@ -2520,7 +2520,7 @@ ftdm_status_t sngss7_retrieve_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt } if (len != sizeof(*siConEvnt)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Incompatible IAM structure size (expected:%d size:%d)\n", sizeof(*siConEvnt), strlen(uncompressed_buffer)); + ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Incompatible IAM structure size (expected:%"FTDM_SIZE_FMT" size:%"FTDM_SIZE_FMT")\n", sizeof(*siConEvnt), strlen(uncompressed_buffer)); goto done; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c index ff66cc6b41..6138ea34b0 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c @@ -1,5 +1,6 @@ /* - * Copyright (c) 2009, Konrad Hammel + * Copyright (c) 2009, Sangoma Technologies + * Konrad Hammel * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,6 +30,11 @@ * 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. + * + * Contributors: + * + * Moises Silva + * */ /* INCLUDE ********************************************************************/ @@ -56,25 +62,53 @@ void handle_isup_t35(void *userdata) ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_mutex_lock(ftdmchan->mutex); + ftdm_channel_lock(ftdmchan); + /* Q.764 2.2.5 Address incomplete (T35 expiry action is hangup with cause 28 according to Table A.1/Q.764) */ SS7_ERROR("[Call-Control] Timer 35 expired on CIC = %d\n", sngss7_info->circuit->cic); /* set the flag to indicate this hangup is started from the local side */ sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL); /* hang up on timer expiry */ - ftdmchan->caller_data.hangup_cause = 28; + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_INVALID_NUMBER_FORMAT; /* end the call */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); + /* kill t10 if active */ + if (sngss7_info->t10.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); + } + /*unlock*/ - ftdm_mutex_unlock(ftdmchan->mutex); + ftdm_channel_unlock(ftdmchan); SS7_FUNC_TRACE_EXIT(__FUNCTION__); return; } + + +void handle_isup_t10(void *userdata) +{ + SS7_FUNC_TRACE_ENTER(__FUNCTION__); + + sngss7_timer_data_t *timer = userdata; + sngss7_chan_data_t *sngss7_info = timer->sngss7_info; + ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; + + ftdm_channel_lock(ftdmchan); + + SS7_DEBUG("[Call-Control] Timer 10 expired on CIC = %d\n", sngss7_info->circuit->cic); + + /* send the call to the user */ + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + + ftdm_channel_unlock(ftdmchan); + + SS7_FUNC_TRACE_EXIT(__FUNCTION__); +} + /******************************************************************************/ /* For Emacs: * Local Variables: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index 32c02a76c3..1631aec216 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -62,6 +62,7 @@ sng_switch_type_t sng_switch_type_map[] = { 1, "india" , LSI_SW_INDIA , LSI_SW_INDIA }, { 1, "uk" , LSI_SW_UK , LSI_SW_UK }, { 1, "russia" , LSI_SW_RUSSIA , LSI_SW_RUSSIA }, + { 1, "china" , LSI_SW_CHINA , LSI_SW_CHINA }, { 0, "", 0, 0 }, }; @@ -127,6 +128,7 @@ typedef struct sng_ccSpan uint8_t itx_auto_reply; uint8_t transparent_iam; uint32_t t3; + uint32_t t10; uint32_t t12; uint32_t t13; uint32_t t14; @@ -1570,11 +1572,6 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface) sng_isap.t9 = atoi(parm->val); SS7_DEBUG("Found isup t9 = %d\n",sng_isap.t9); /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t10")) { - /**********************************************************************/ - sng_isup.t10 = atoi(parm->val); - SS7_DEBUG("Found isup t10 = %d\n",sng_isup.t10); - /**********************************************************************/ } else if (!strcasecmp(parm->var, "isup.t11")) { /**********************************************************************/ sng_isup.t11 = atoi(parm->val); @@ -1965,6 +1962,10 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) /**********************************************************************/ sng_ccSpan.t3 = atoi(parm->val); SS7_DEBUG("Found isup t3 = %d\n", sng_ccSpan.t3); + } else if (!strcasecmp(parm->var, "isup.t10")) { + /**********************************************************************/ + sng_ccSpan.t10 = atoi(parm->val); + SS7_DEBUG("Found isup t10 = %d\n", sng_ccSpan.t10); /**********************************************************************/ } else if (!strcasecmp(parm->var, "isup.t12")) { /**********************************************************************/ @@ -2082,7 +2083,7 @@ static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel) relay_channel->port, relay_channel->procId, relay_channel->id); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_PRESENT); } else { relay_channel->id = i; SS7_DEBUG("found existing relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n", @@ -2116,7 +2117,7 @@ static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link) /* check if this id value has been used already */ if (g_ftdm_sngss7_data.cfg.mtp1Link[i].id == 0) { SS7_DEBUG("Found new MTP1 Link: id=%d, name=%s\n", mtp1Link->id, mtp1Link->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_PRESENT); } else { SS7_DEBUG("Found an existing MTP1 Link: id=%d, name=%s (old name=%s)\n", mtp1Link->id, @@ -2142,7 +2143,7 @@ static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp2Link) /* check if this id value has been used already */ if (g_ftdm_sngss7_data.cfg.mtp2Link[i].id == 0) { SS7_DEBUG("Found new MTP2 Link: id=%d, name=%s\n", mtp2Link->id, mtp2Link->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_PRESENT); } else { SS7_DEBUG("Found an existing MTP2 Link: id=%d, name=%s (old name=%s)\n", mtp2Link->id, @@ -2219,7 +2220,7 @@ static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp3Link) /* check if this id value has been used already */ if (g_ftdm_sngss7_data.cfg.mtp3Link[i].id == 0) { SS7_DEBUG("Found new MTP3 Link: id=%d, name=%s\n", mtp3Link->id, mtp3Link->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_PRESENT); } else { SS7_DEBUG("Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n", mtp3Link->id, @@ -2560,7 +2561,7 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup) /* check if this id value has been used already */ if (g_ftdm_sngss7_data.cfg.isupIntf[i].id == 0) { SS7_DEBUG("Found new ISUP Interface: id=%d, name=%s\n", sng_isup->id, sng_isup->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_PRESENT); } else { SS7_DEBUG("Found an existing ISUP Interface: id=%d, name=%s (old name=%s)\n", sng_isup->id, @@ -2584,11 +2585,6 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup) } else { g_ftdm_sngss7_data.cfg.isupIntf[i].t4 = 3000; } - if (sng_isup->t10 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t10 = sng_isup->t10; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t10 = 50; - } if (sng_isup->t11 != 0) { g_ftdm_sngss7_data.cfg.isupIntf[i].t11 = sng_isup->t11; } else { @@ -2908,7 +2904,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) g_ftdm_sngss7_data.cfg.isupCkt[x].type = SNG_CKT_VOICE; /* throw the flag to indicate that we need to start call control */ - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC); + sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_PRESENT); } if (timeslot.channel) { @@ -2935,6 +2931,11 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) } else { g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = ccSpan->t3; } + if (ccSpan->t10 == 0) { + g_ftdm_sngss7_data.cfg.isupCkt[x].t10 = 50; + } else { + g_ftdm_sngss7_data.cfg.isupCkt[x].t10 = ccSpan->t10; + } if (ccSpan->t12 == 0) { g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = 300; } else { @@ -2966,9 +2967,10 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = ccSpan->t17; } if (ccSpan->t35 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = 170; + /* Q.764 2.2.5 Address incomplete (T35 is 15-20 seconds according to Table A.1/Q.764) */ + g_ftdm_sngss7_data.cfg.isupCkt[x].t35 = 170; } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = ccSpan->t35; + g_ftdm_sngss7_data.cfg.isupCkt[x].t35 = ccSpan->t35; } if (ccSpan->tval == 0) { g_ftdm_sngss7_data.cfg.isupCkt[x].tval = 10; @@ -3062,12 +3064,18 @@ static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan) ftdmchan->call_data = ss7_info; /* prepare the timer structures */ - ss7_info->t35.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; + ss7_info->t35.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; ss7_info->t35.counter = 1; - ss7_info->t35.beat = (isupCkt->t35) * 100; /* beat is in ms, t35 is in 100ms */ + ss7_info->t35.beat = (isupCkt->t35) * 100; /* beat is in ms, t35 is in 100ms */ ss7_info->t35.callback = handle_isup_t35; ss7_info->t35.sngss7_info = ss7_info; + ss7_info->t10.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; + ss7_info->t10.counter = 1; + ss7_info->t10.beat = (isupCkt->t10) * 100; /* beat is in ms, t10 is in 100ms */ + ss7_info->t10.callback = handle_isup_t10; + ss7_info->t10.sngss7_info = ss7_info; + /**************************************************************************/ } /* for (i == 1; i < ftdmspan->chan_count; i++) */ diff --git a/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c b/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c index ee06a0716d..96475f58d9 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c old mode 100644 new mode 100755 index a6c6e8cd5a..c26cbec02c --- 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, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,9 +36,9 @@ * David Yat Sin * Nenad Corbic * Arnaldo Pereira + * Gideon Sadan * - */ - + */ #ifdef WP_DEBUG_IO #define _BSD_SOURCE #include @@ -121,6 +121,16 @@ FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event); FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_span_next_event); FIO_CHANNEL_NEXT_EVENT_FUNCTION(wanpipe_channel_next_event); +static void wp_swap16(char *data, int datalen) +{ + int i = 0; + uint16_t *samples = (uint16_t *)data; + for (i = 0; i < datalen/2; i++) { + uint16_t sample = ((samples[i] & 0x00FF) << 8) | ((samples[i] & 0xFF00) >> 8); + samples[i] = sample; + } +} + /** * \brief Poll for event on a wanpipe socket * \param fd Wanpipe socket descriptor @@ -305,11 +315,20 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start err = sangoma_tdm_get_hw_coding(chan->sockfd, &tdm_api); + + if (tdm_api.wp_tdm_cmd.hw_tdm_coding) { chan->native_codec = chan->effective_codec = FTDM_CODEC_ALAW; } else { chan->native_codec = chan->effective_codec = FTDM_CODEC_ULAW; } + + + if ((span->trunk_type == FTDM_TRUNK_GSM) && (chan->type == FTDM_CHAN_TYPE_B)) { + chan->native_codec = FTDM_CODEC_SLIN; + chan->native_interval = 20; + chan->packet_len = 320; + } err = sangoma_tdm_get_hw_dtmf(chan->sockfd, &tdm_api); if (err > 0) { @@ -580,8 +599,9 @@ static FIO_OPEN_FUNCTION(wanpipe_open) ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL); ftdmchan->effective_interval = ftdmchan->native_interval = wp_globals.codec_ms; - ftdmchan->packet_len = ftdmchan->native_interval * 8; - + + /* The packet len will depend on the codec and interval */ + ftdmchan->packet_len = ftdmchan->native_interval * ((ftdmchan->native_codec==FTDM_CODEC_SLIN) ? 16 : 8); if (wp_globals.txqueue_size > 0) { ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &wp_globals.txqueue_size); } @@ -772,6 +792,7 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) case FTDM_COMMAND_SET_INTERVAL: { err=sangoma_tdm_set_usr_period(ftdmchan->sockfd, &tdm_api, FTDM_COMMAND_OBJ_INT); + ftdmchan->packet_len = ftdmchan->native_interval * (ftdmchan->effective_codec == FTDM_CODEC_SLIN ? 16 : 8); } break; @@ -793,7 +814,7 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) FTDM_COMMAND_OBJ_INT = wanpipe_swap_bits(rbsbits); } #else - // does sangoma_tdm_read_rbs is available here? + /* is sangoma_tdm_read_rbs available here? */ FTDM_COMMAND_OBJ_INT = ftdmchan->rx_cas_bits; #endif } @@ -885,17 +906,11 @@ static void wanpipe_write_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_tx_hdr_t *t } if (ftdmchan->iostats.tx.idle_packets < tx_stats->wp_api_tx_hdr_tx_idle_packets) { - /* HDLC channels do not always transmit, so its ok for drivers to fill with idle - * also do not report idle warning when we just started transmitting */ - if (ftdmchan->iostats.tx.packets && FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Tx idle changed from %d to %d\n", - ftdmchan->iostats.tx.idle_packets, tx_stats->wp_api_tx_hdr_tx_idle_packets); - } ftdmchan->iostats.tx.idle_packets = tx_stats->wp_api_tx_hdr_tx_idle_packets; } if (!ftdmchan->iostats.tx.packets) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "First packet write stats: Tx queue len: %d, Tx queue size: %d, Tx idle: %d\n", + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "First packet write stats: Tx queue len: %d, Tx queue size: %d, Tx idle: %"FTDM_UINT64_FMT"\n", ftdmchan->iostats.tx.queue_len, ftdmchan->iostats.tx.queue_size, ftdmchan->iostats.tx.idle_packets); @@ -941,11 +956,11 @@ static void wanpipe_read_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_rx_hdr_t *rx } if (ftdmchan->iostats.rx.queue_len >= (0.8 * ftdmchan->iostats.rx.queue_size)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue length exceeded 80% threshold (%d/%d)\n", + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue length exceeded 80%% threshold (%d/%d)\n", ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); } else if (ftdm_test_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)){ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue length reduced 80% threshold (%d/%d)\n", + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue length reduced 80%% threshold (%d/%d)\n", ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); } @@ -975,12 +990,15 @@ static void wanpipe_read_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_rx_hdr_t *rx * \param datalen Size of data buffer * \return Success, failure or timeout */ + + static FIO_READ_FUNCTION(wanpipe_read) { int rx_len = 0; int rq_len = (int)*datalen; wp_tdm_api_rx_hdr_t hdrframe; + #ifdef WP_DEBUG_IO wp_channel_t *wchan = ftdmchan->io_data; ftdm_time_t time_diff = 0; @@ -1040,6 +1058,10 @@ static FIO_READ_FUNCTION(wanpipe_read) wanpipe_read_stats(ftdmchan, &hdrframe); } + if ((ftdmchan->type == FTDM_CHAN_TYPE_B) && (ftdmchan->span->trunk_type == FTDM_TRUNK_GSM)) { + wp_swap16(data, *datalen); + } + return FTDM_SUCCESS; } @@ -1056,6 +1078,10 @@ static FIO_WRITE_FUNCTION(wanpipe_write) int err = 0; wp_tdm_api_tx_hdr_t hdrframe; + if ((ftdmchan->type == FTDM_CHAN_TYPE_B) && (ftdmchan->span->trunk_type == FTDM_TRUNK_GSM)) { + wp_swap16(data, *datalen); + } + /* Do we even need the headerframe here? on windows, we don't even pass it to the driver */ memset(&hdrframe, 0, sizeof(hdrframe)); if (*datalen == 0) { @@ -1490,10 +1516,10 @@ static __inline__ ftdm_status_t wanpipe_channel_process_event(ftdm_channel_t *fc if (fchan->dtmfdetect.duration_ms) { ftdm_time_t diff = ftdm_current_time_in_ms() - fchan->dtmfdetect.start_time; if (diff > fchan->dtmfdetect.duration_ms) { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c (duration:%d min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms); + ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c (duration:%"FTDM_TIME_FMT" min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms); ftdm_channel_queue_dtmf(fchan, tmp_dtmf); } else { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe DTMF: %c (duration:%d min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms); + ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe DTMF: %c (duration:%"FTDM_TIME_FMT" min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms); } } else if (!fchan->dtmfdetect.trigger_on_start) { ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c\n", tmp_dtmf[0]); @@ -1591,7 +1617,7 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_span_next_event) ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_FLASH); ftdm_set_flag_locked(span->channels[i], FTDM_CHANNEL_OFFHOOK); event_id = FTDM_OOB_OFFHOOK; - ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Diff since last event = %llums, delivering %s now\n", diff, ftdm_oob_event2str(event_id)); + ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Diff since last event = %"FTDM_TIME_FMT" ms, delivering %s now\n", diff, ftdm_oob_event2str(event_id)); goto event; } } @@ -1610,7 +1636,7 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_span_next_event) sangoma_tdm_txsig_onhook(ftdmchan->sockfd,&tdm_api); } - ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Diff since last event = %llums, delivering %s now\n", diff, ftdm_oob_event2str(event_id)); + ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Diff since last event = %"FTDM_TIME_FMT" ms, delivering %s now\n", diff, ftdm_oob_event2str(event_id)); goto event; } } diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c index 5be2e79872..2569ea49fd 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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_zt/ftmod_zt.h b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h index 40b5a4e71d..c9bb171b55 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 0fbc4bf29b..1476ee0158 100755 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,6 +62,9 @@ /*! \brief Max number of groups */ #define FTDM_MAX_GROUPS_INTERFACE FTDM_MAX_SPANS_INTERFACE +/*! \brief Max number of key=value pairs to be sent as signaling stack parameters */ +#define FTDM_MAX_SIG_PARAMETERS 30 + #define FTDM_INVALID_INT_PARM 0xFF /*! \brief Thread/Mutex OS abstraction API. */ @@ -201,10 +204,19 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_chan_type, ftdm_chan_type2str, ftdm_chan_type_t) (fchan)->span->trunk_type == FTDM_TRUNK_BRI || \ (fchan)->span->trunk_type == FTDM_TRUNK_BRI_PTMP) +/*! \brief Test if a span is digital */ +#define FTDM_SPAN_IS_DIGITAL(span) \ + ((span)->trunk_type == FTDM_TRUNK_E1 || \ + (span)->trunk_type == FTDM_TRUNK_T1 || \ + (span)->trunk_type == FTDM_TRUNK_J1 || \ + (span)->trunk_type == FTDM_TRUNK_BRI || \ + (span)->trunk_type == FTDM_TRUNK_BRI_PTMP) + + /*! \brief Logging function prototype to be used for all FreeTDM logs * you should use ftdm_global_set_logger to set your own logger */ -typedef void (*ftdm_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...); +typedef void (*ftdm_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...) __ftdm_check_printf(5, 6); /*! \brief Data queue operation functions * you can use ftdm_global_set_queue_handler if you want to override the default implementation (not recommended) @@ -343,6 +355,11 @@ typedef struct { uint8_t plan; } ftdm_number_t; +typedef struct { + char from[FTDM_MAX_NUMBER_STR_SZ]; + char body[FTDM_MAX_NAME_STR_SZ]; +} ftdm_sms_data_t; + /*! \brief Caller information */ typedef struct ftdm_caller_data { char cid_date[8]; /*!< Caller ID date */ @@ -362,6 +379,7 @@ typedef struct ftdm_caller_data { /* user information layer 1 protocol */ ftdm_user_layer1_prot_t bearer_layer1; ftdm_calling_party_category_t cpc; /*!< Calling party category */ + uint32_t call_reference; ftdm_channel_t *fchan; /*!< FreeTDM channel associated (can be NULL) */ @@ -452,12 +470,13 @@ typedef enum { FTDM_SIGEVENT_INDICATION_COMPLETED, /*!< Last requested indication was completed */ FTDM_SIGEVENT_DIALING, /*!< Outgoing call just started */ FTDM_SIGEVENT_TRANSFER_COMPLETED, /*!< Transfer request is completed */ + FTDM_SIGEVENT_SMS, FTDM_SIGEVENT_INVALID, /*! @@ -203,6 +245,14 @@ typedef enum { FTDM_TRUE } ftdm_bool_t; +/*! \brief I/O waiting flags */ +typedef enum { + FTDM_NO_FLAGS = 0, + FTDM_READ = (1 << 0), + FTDM_WRITE = (1 << 1), + FTDM_EVENTS = (1 << 2) +} ftdm_wait_flag_t; + /*! * \brief FreeTDM channel. * This is the basic data structure used to place calls and I/O operations diff --git a/libs/freetdm/src/include/ftdm_os.h b/libs/freetdm/src/include/ftdm_os.h index a4605c3371..39afec94be 100644 --- a/libs/freetdm/src/include/ftdm_os.h +++ b/libs/freetdm/src/include/ftdm_os.h @@ -53,6 +53,8 @@ extern "C" { /*! \brief time data type */ typedef uint64_t ftdm_time_t; +/*! format string for ftdm_time_t */ +#define FTDM_TIME_FMT FTDM_UINT64_FMT /*! \brief sleep x amount of milliseconds */ #ifdef __WINDOWS__ @@ -76,6 +78,55 @@ typedef uint64_t ftdm_time_t; /*! \brief array len helper */ #define ftdm_array_len(array) sizeof(array)/sizeof(array[0]) +/*! \brief Get smaller value */ +#define ftdm_min(x,y) ((x) < (y) ? (x) : (y)) + +/*! \brief Get larger value */ +#define ftdm_max(x,y) ((x) > (y) ? (x) : (y)) + +/*! \brief Get value that is in range [vmin,vmax] */ +#define ftdm_clamp(val,vmin,vmax) ftdm_max(vmin,ftdm_min(val,vmax)) + +/*! + * \brief Get offset of member in structure + * \param[in] type Type of struct + * \param[in] member Name of struct member + * \code + * struct a { + * int foo; + * int bar; + * }; + * + * int offset_a_bar = ftdm_offset_of(struct a, bar); // 4 byte offset + * \endcode + */ +#define ftdm_offset_of(type,member) (uintptr_t)&(((type *)0)->member) + +/*! + * \brief Get pointer to enclosing structrure from pointer to embedded member + * \param[in] ptr Pointer to embedded member + * \param[in] type Type of parent/container structure + * \param[in] member Name of embedded member in parent/container struct + * \code + * struct engine { + * int nr_cyl; + * }; + * + * struct car { + * char model[10]; + * struct engine eng; // struct engine embedded in car(!) + * }; + * + * int somefunc(struct engine *e) { + * struct car *c = ftdm_container_of(e, struct car, eng); + * + * ... do something with car ... + * } + * \endcode + */ +#define ftdm_container_of(ptr,type,member) (type *)((uintptr_t)(ptr) - ftdm_offset_of(type, member)) + + /*! \brief The memory handler. Do not use directly this variable, use the memory macros and ftdm_global_set_memory_handler to override */ FT_DECLARE_DATA extern ftdm_memory_handler_t g_ftdm_mem_handler; diff --git a/libs/freetdm/src/include/ftdm_threadmutex.h b/libs/freetdm/src/include/ftdm_threadmutex.h index 2e802fe913..b77f19f4bb 100644 --- a/libs/freetdm/src/include/ftdm_threadmutex.h +++ b/libs/freetdm/src/include/ftdm_threadmutex.h @@ -52,11 +52,12 @@ FT_DECLARE(ftdm_status_t) _ftdm_mutex_trylock(const char *file, int line, const #define ftdm_mutex_unlock(_x) _ftdm_mutex_unlock(__FILE__, __LINE__, __FUNCTION__, _x) FT_DECLARE(ftdm_status_t) _ftdm_mutex_unlock(const char *file, int line, const char *func, ftdm_mutex_t *mutex); -FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **cond, ftdm_socket_t device); +FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **cond, ftdm_socket_t device, ftdm_wait_flag_t device_flags); FT_DECLARE(ftdm_status_t) ftdm_interrupt_destroy(ftdm_interrupt_t **cond); FT_DECLARE(ftdm_status_t) ftdm_interrupt_signal(ftdm_interrupt_t *cond); FT_DECLARE(ftdm_status_t) ftdm_interrupt_wait(ftdm_interrupt_t *cond, int ms); FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interrupts[], ftdm_size_t size, int ms); +FT_DECLARE(ftdm_wait_flag_t) ftdm_interrupt_device_ready(ftdm_interrupt_t *interrupt); #ifdef __cplusplus } diff --git a/libs/freetdm/src/include/private/ftdm_buffer.h b/libs/freetdm/src/include/private/ftdm_buffer.h index e069e2d44b..0ad969b721 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 0f96a8f872..91b0ca5a15 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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_core.h b/libs/freetdm/src/include/private/ftdm_core.h index d27bac345b..6725f25655 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -214,12 +214,33 @@ extern "C" { ftdm_mutex_lock(obj->mutex); \ } \ if(!__safety) { \ - ftdm_log(FTDM_LOG_CRIT, "flag %d was never cleared\n", flag); \ + ftdm_log(FTDM_LOG_CRIT, "flag %"FTDM_UINT64_FMT" was never cleared\n", (uint64_t)flag); \ } \ } while(0); #define ftdm_is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119) +#ifdef __linux__ +#define ftdm_print_stack(level) \ + do { \ + void *__stacktrace[100] = { 0 }; \ + char **__symbols = NULL; \ + int __size = 0; \ + int __i = 0; \ + __size = backtrace(__stacktrace, ftdm_array_len(__stacktrace)); \ + __symbols = backtrace_symbols(__stacktrace, __size); \ + if (__symbols) { \ + for (__i = 0; __i < __size; __i++) { \ + ftdm_log(__level, "%s\n", __symbols[i]); \ + } \ + free(__symbols); \ + } \ + } while (0); +#else +#define ftdm_print_stack(level) ftdm_log(level, "FTDM_PRINT_STACK is not implemented in this operating system!\n"); +#endif + + #define FTDM_SPAN_IS_BRI(x) ((x)->trunk_type == FTDM_TRUNK_BRI || (x)->trunk_type == FTDM_TRUNK_BRI_PTMP) /*! \brief Copy flags from one arbitrary object to another @@ -464,6 +485,7 @@ struct ftdm_span { fio_event_cb_t event_callback; ftdm_mutex_t *mutex; ftdm_trunk_type_t trunk_type; + ftdm_trunk_mode_t trunk_mode; ftdm_analog_start_type_t start_type; ftdm_signal_type_t signal_type; uint32_t last_used_index; @@ -673,7 +695,7 @@ FT_DECLARE(ftdm_status_t) ftdm_sigmsg_set_raw_data(ftdm_sigmsg_t *sigmsg, void * */ #define ftdm_assert(assertion, msg) \ if (!(assertion)) { \ - ftdm_log(FTDM_LOG_CRIT, msg); \ + ftdm_log(FTDM_LOG_CRIT, "%s", msg); \ if (g_ftdm_crash_policy & FTDM_CRASH_ON_ASSERT) { \ ftdm_abort(); \ } \ @@ -684,7 +706,7 @@ FT_DECLARE(ftdm_status_t) ftdm_sigmsg_set_raw_data(ftdm_sigmsg_t *sigmsg, void * */ #define ftdm_assert_return(assertion, retval, msg) \ if (!(assertion)) { \ - ftdm_log(FTDM_LOG_CRIT, msg); \ + ftdm_log(FTDM_LOG_CRIT, "%s", msg); \ if (g_ftdm_crash_policy & FTDM_CRASH_ON_ASSERT) { \ ftdm_abort(); \ } else { \ diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index 2ed9fd04c5..d87bcd423f 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, Anthony Minessale II + * Copyright (c) 2007-2012, Anthony Minessale II * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -163,7 +163,8 @@ typedef enum { FTDM_SIGTYPE_SANGOMABOOST, FTDM_SIGTYPE_M3UA, FTDM_SIGTYPE_R2, - FTDM_SIGTYPE_SS7 + FTDM_SIGTYPE_SS7, + FTDM_SIGTYPE_GSM } ftdm_signal_type_t; typedef enum { @@ -173,6 +174,12 @@ typedef enum { FTDM_SPAN_SUSPENDED = (1 << 3), FTDM_SPAN_IN_THREAD = (1 << 4), FTDM_SPAN_STOP_THREAD = (1 << 5), + /*! Signaling modules set this flag to use fchan->pendingchans queue instead + * of the FTDM_SPAN_STATE_CHANGE flag to detect when there is channels with + * a state change pending in the span. If you set this member you can't rely + * on FTDM_SPAN_STATE_CHANGE anymore and must use the queue only instead. This + * is the new way of detecting state changes, new modules should always set this + * flag, the old modules still relying on FTDM_SPAN_STATE_CHANGE should be updated */ FTDM_SPAN_USE_CHAN_QUEUE = (1 << 6), FTDM_SPAN_SUGGEST_CHAN_ID = (1 << 7), FTDM_SPAN_USE_AV_RATE = (1 << 8), diff --git a/libs/freetdm/src/include/private/libteletone.h b/libs/freetdm/src/include/private/libteletone.h index b039f1f078..54537562bf 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 28ae2f5492..3ecac062bd 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 8e49afaabe..853f9da81b 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/freetdm/src/priserver.c b/libs/freetdm/src/priserver.c index 4e5ec8706d..033934c32e 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 Anthony Minessale II + * Copyright: (c) 2005-2012 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 4adcf017cf..60d0154a39 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 Anthony Minessale II + * Copyright: (c) 2005-2012 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 d37622a6da..2072c8b08a 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 Anthony Minessale II + * Copyright: (c) 2005-2012 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/testr2.c b/libs/freetdm/src/testr2.c index 24dde38b08..530e6321bc 100644 --- a/libs/freetdm/src/testr2.c +++ b/libs/freetdm/src/testr2.c @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) ftdm_channel_call_indicate(lchan, ind); stop = ftdm_current_time_in_ms(); diff = stop - start; - ftdm_log(FTDM_LOG_DEBUG, "Setting indication %s took %llums\n", + ftdm_log(FTDM_LOG_DEBUG, "Setting indication %s took %"FTDM_TIME_FMT" ms\n", ftdm_channel_indication2str(ind), diff); } } diff --git a/libs/libdingaling/src/ldl_compat.h b/libs/libdingaling/src/ldl_compat.h index 26ae586632..2507cd5957 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 0b11411ffd..e2b32a0637 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -27,8 +27,11 @@ * * libdingaling.c -- Main Library Code * + * QMOD: XMPP Video Signaling + Presentation (video-v1 & camera-v1) + * */ + #ifndef _MSC_VER #include #include @@ -157,8 +160,10 @@ struct ldl_session { char *login; ldl_payload_t payloads[LDL_MAX_PAYLOADS]; unsigned int payload_len; - ldl_candidate_t candidates[LDL_MAX_CANDIDATES]; - unsigned int candidate_len; + /*! \brief Transport candidates, organized per type */ + ldl_candidate_t candidates[LDL_TPORT_MAX][LDL_MAX_CANDIDATES]; + /*! \brief Length of the candidate list, per transport type */ + unsigned int candidate_len[LDL_TPORT_MAX]; apr_pool_t *pool; apr_hash_t *variables; apr_time_t created; @@ -181,6 +186,8 @@ typedef struct ldl_feature ldl_feature_t; #define FEATURE_VERSION "jabber:iq:version" #define FEATURE_VCARD "vcard-temp" #define FEATURE_VOICE "http://www.google.com/xmpp/protocol/voice/v1" +#define FEATURE_VIDEO "http://www.google.com/xmpp/protocol/video/v1" +#define FEATURE_CAMERA "http://www.google.com/xmpp/protocol/camera/v1" #define FEATURE_LAST "jabber:iq:last" static ldl_feature_t FEATURES[] = { @@ -189,6 +196,8 @@ static ldl_feature_t FEATURES[] = { { FEATURE_VERSION, on_disco_default }, { FEATURE_VCARD, on_vcard}, { FEATURE_VOICE, on_disco_default }, + { FEATURE_VIDEO, on_disco_default }, + { FEATURE_CAMERA, on_disco_default }, { FEATURE_LAST, on_disco_default }, { NULL, NULL} }; @@ -253,7 +262,6 @@ static unsigned int next_id(void) return globals.id++; } - static char *iks_name_nons(iks *x) { char *r = iks_name(x); @@ -296,7 +304,7 @@ ldl_status ldl_session_destroy(ldl_session_t **session_p) apr_hash_t *hash = session->handle->sessions; if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Destroyed Session %s\n", session->id); + globals.logger(DL_LOG_CRIT, "Destroyed Session %s\n", session->id); } if (session->id) { @@ -322,7 +330,7 @@ ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, c ldl_session_t *session = NULL; if (!(session = apr_palloc(handle->pool, sizeof(ldl_session_t)))) { - globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n"); + globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); *session_p = NULL; return LDL_STATUS_MEMERR; } @@ -352,7 +360,7 @@ ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, c if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Created Session %s\n", id); + globals.logger(DL_LOG_CRIT, "Created Session %s\n", id); } return LDL_STATUS_SUCCESS; @@ -374,21 +382,22 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, if (!session) { if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Non-Existent Session %s!\n", id); + globals.logger(DL_LOG_CRIT, "Non-Existent Session %s!\n", id); } return LDL_STATUS_MEMERR; } if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Message for Session %s\n", id); + globals.logger(DL_LOG_CRIT, "Message for Session %s\n", id); } while(xml) { char *type = NULL; iks *tag; - if (iks_type(xml)!=IKS_CDATA) + if (iks_type(xml) != IKS_CDATA) { type = xtype ? xtype : iks_find_attrib(xml, "type"); + } if (type) { @@ -429,18 +438,28 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, char *name = iks_find_attrib(itag, "name"); char *id = iks_find_attrib(itag, "id"); char *rate = iks_find_attrib(itag, "clockrate"); + char *ptime = iks_find_attrib(itag, "ptime"); if (name && id) { session->payloads[session->payload_len].name = apr_pstrdup(session->pool, name); session->payloads[session->payload_len].id = atoi(id); + if (ptime) { + session->payloads[session->payload_len].ptime = atoi(ptime); + } else { + session->payloads[session->payload_len].ptime = 20; + } if (rate) { session->payloads[session->payload_len].rate = atoi(rate); } else { - session->payloads[session->payload_len].rate = 8000; + if (!strncasecmp(iks_name(itag), "vid", 3)) { + session->payloads[session->payload_len].rate = 90000; + } else { + session->payloads[session->payload_len].rate = 8000; + } } session->payload_len++; if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Add Payload [%s] id='%s'\n", name, id); + globals.logger(DL_LOG_CRIT, "Add Payload [%s] id='%s'\n", name, id); } } } @@ -462,27 +481,46 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, tag = iks_child(tag); } - while(tag) { + for (;tag;tag = iks_next_tag(tag)) { if (!strcasecmp(iks_name_nons(tag), "info_element")) { char *name = iks_find_attrib(tag, "name"); char *value = iks_find_attrib(tag, "value"); if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Info Element [%s]=[%s]\n", name, value); + globals.logger(DL_LOG_CRIT, "Info Element [%s]=[%s]\n", name, value); } ldl_session_set_value(session, name, value); - } else if (!strcasecmp(iks_name_nons(tag), "candidate") && session->candidate_len < LDL_MAX_CANDIDATES) { + } else if (!strcasecmp(iks_name_nons(tag), "candidate") /*&& session->candidate_len < LDL_MAX_CANDIDATES*/) { char *key; double pref = 0.0; int index = -1; + ldl_transport_type_t tport; + unsigned int *candidate_len = NULL; + ldl_candidate_t (*candidates)[LDL_MAX_CANDIDATES] = NULL; + if ((key = iks_find_attrib(tag, "preference"))) { unsigned int x; + pref = strtod(key, NULL); - for (x = 0; x < session->candidate_len; x++) { - if (session->candidates[x].pref == pref) { + /* Check what kind of candidate this is */ + if ((key = iks_find_attrib(tag, "name")) && ((tport = ldl_transport_type_parse(key)) != LDL_TPORT_MAX)) { + candidates = &(session->candidates[tport]); + candidate_len = &(session->candidate_len[tport]); + } else { + globals.logger(DL_LOG_WARNING, "No such transport type: %s\n", key); + continue; + } + + if (*candidate_len >= LDL_MAX_CANDIDATES) { + globals.logger(DL_LOG_WARNING, "Too many %s candidates\n", key); + continue; + } + + for (x = 0; x < *candidate_len; x++) { + if ((*candidates)[x].pref == pref) { if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Duplicate Pref!\n"); + globals.logger(DL_LOG_CRIT, "Duplicate Pref! Updating...\n"); } index = x; break; @@ -491,44 +529,44 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, } if (index < 0) { - index = session->candidate_len++; + index = (*candidate_len)++; } - session->candidates[index].pref = pref; + (*candidates)[index].pref = pref; if (tid) { - session->candidates[index].tid = apr_pstrdup(session->pool, tid); + (*candidates)[index].tid = apr_pstrdup(session->pool, tid); } if ((key = iks_find_attrib(tag, "name"))) { - session->candidates[index].name = apr_pstrdup(session->pool, key); + (*candidates)[index].name = apr_pstrdup(session->pool, key); } if ((key = iks_find_attrib(tag, "type"))) { - session->candidates[index].type = apr_pstrdup(session->pool, key); + (*candidates)[index].type = apr_pstrdup(session->pool, key); } if ((key = iks_find_attrib(tag, "protocol"))) { - session->candidates[index].protocol = apr_pstrdup(session->pool, key); + (*candidates)[index].protocol = apr_pstrdup(session->pool, key); } if ((key = iks_find_attrib(tag, "username"))) { - session->candidates[index].username = apr_pstrdup(session->pool, key); + (*candidates)[index].username = apr_pstrdup(session->pool, key); } if ((key = iks_find_attrib(tag, "password"))) { - session->candidates[index].password = apr_pstrdup(session->pool, key); + (*candidates)[index].password = apr_pstrdup(session->pool, key); } if ((key = iks_find_attrib(tag, "address"))) { - session->candidates[index].address = apr_pstrdup(session->pool, key); + (*candidates)[index].address = apr_pstrdup(session->pool, key); } if ((key = iks_find_attrib(tag, "port"))) { - session->candidates[index].port = (uint16_t)atoi(key); + (*candidates)[index].port = (uint16_t)atoi(key); } - if (!session->candidates[index].type) { - session->candidates[index].type = apr_pstrdup(session->pool, "stun"); + if (!(*candidates)[index].type) { + (*candidates)[index].type = apr_pstrdup(session->pool, "stun"); } if (globals.debug) { - globals.logger(DL_LOG_DEBUG, + globals.logger(DL_LOG_CRIT, "New Candidate %d\n" "name=%s\n" "type=%s\n" @@ -538,19 +576,18 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, "address=%s\n" "port=%d\n" "pref=%0.2f\n", - session->candidate_len, - session->candidates[index].name, - session->candidates[index].type, - session->candidates[index].protocol, - session->candidates[index].username, - session->candidates[index].password, - session->candidates[index].address, - session->candidates[index].port, - session->candidates[index].pref + *candidate_len, + (*candidates)[index].name, + (*candidates)[index].type, + (*candidates)[index].protocol, + (*candidates)[index].username, + (*candidates)[index].password, + (*candidates)[index].address, + (*candidates)[index].port, + (*candidates)[index].pref ); } } - tag = iks_next_tag(tag); } } else if (!strcasecmp(type, "terminate")) { dl_signal = LDL_SIGNAL_TERMINATE; @@ -569,6 +606,301 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, return LDL_STATUS_SUCCESS; } + +static ldl_status parse_jingle_code(ldl_handle_t *handle, iks *xml, char *to, char *from, char *type) +{ + ldl_session_t *session = NULL; + ldl_signal_t dl_signal = LDL_SIGNAL_NONE; + char *initiator = iks_find_attrib(xml, "initiator"); + char *msg = NULL; + char *id = iks_find_attrib(xml, "sid"); + char *action = iks_find_attrib(xml, "action"); + iks *tag; + + + if (!strcasecmp(type, "error")) { + action = type; + } + + + if (!(id && action)) { + globals.logger(DL_LOG_CRIT, "missing required params\n"); + return LDL_STATUS_FALSE; + } + + if (!(session = apr_hash_get(handle->sessions, id, APR_HASH_KEY_STRING))) { + ldl_session_create(&session, handle, id, from, to, LDL_FLAG_NONE); + if (!session) { + return LDL_STATUS_MEMERR; + } + } + + if (!session) { + if (globals.debug) { + globals.logger(DL_LOG_CRIT, "Non-Existent Session %s!\n", id); + } + return LDL_STATUS_MEMERR; + } + + if (globals.debug) { + globals.logger(DL_LOG_CRIT, "Message for Session %s\n", id); + } + + + if (action) { + + if (!strcasecmp(action, "redirect")) { + apr_hash_t *hash = session->handle->sessions; + char *p = to; + if ((p = strchr(to, ':'))) { + p++; + } else { + p = to; + } + + + apr_hash_set(hash, session->them, APR_HASH_KEY_STRING, NULL); + apr_hash_set(hash, session->id, APR_HASH_KEY_STRING, NULL); + session->them = apr_pstrdup(session->pool, p); + apr_hash_set(handle->sessions, session->them, APR_HASH_KEY_STRING, session); + apr_hash_set(handle->sessions, session->id, APR_HASH_KEY_STRING, session); + + dl_signal = LDL_SIGNAL_REDIRECT; + } else if (!strcasecmp(action, "session-initiate") || !strcasecmp(action, "session-accept")) { + + dl_signal = LDL_SIGNAL_INITIATE; + + if (!strcasecmp(action, "session-accept")) { + msg = "accept"; + } + + if (!session->initiator && initiator) { + session->initiator = apr_pstrdup(session->pool, initiator); + } + tag = iks_child (xml); + + while(tag) { + + if (!strcasecmp(iks_name_nons(tag), "content")) { + iks *dtag = iks_child (tag); + char key[512]; + + if (!strcasecmp(iks_name_nons(dtag), "description")) { + iks *itag = iks_child (dtag); + char *name = iks_find_attrib(tag, "name"); + char *media = iks_find_attrib(dtag, "media"); + + if (globals.debug) { + globals.logger(DL_LOG_CRIT, "Found description of type '%s' media type '%s'\n", name, media); + + } + + while(itag) { + if (!strcasecmp(iks_name_nons(itag), "rtcp-mux")) { + snprintf(key, sizeof(key), "%s:rtcp-mux", media); + ldl_session_set_value(session, key, "true"); + } + + if (!strcasecmp(iks_name_nons(itag), "encryption")) { + iks *etag = iks_child (itag); + + while(etag) { + char *suite = iks_find_attrib(etag, "crypto-suite"); + char *params = iks_find_attrib(etag, "key-params"); + char *tag = iks_find_attrib(etag, "tag"); + char val[512]; + + if (suite && params && tag) { + snprintf(key, sizeof(key), "%s:crypto:%s", media, tag); + snprintf(val, sizeof(val), "%s %s %s", tag, suite, params); + + ldl_session_set_value(session, key, val); + } + + etag = iks_next_tag(etag); + } + } + + + if (!strcasecmp(iks_name_nons(itag), "payload-type") && session->payload_len < LDL_MAX_PAYLOADS) { + char *name = iks_find_attrib(itag, "name"); + char *id = iks_find_attrib(itag, "id"); + char *rate = iks_find_attrib(itag, "clockrate"); + + if (name && id) { + session->payloads[session->payload_len].name = apr_pstrdup(session->pool, name); + session->payloads[session->payload_len].id = atoi(id); + if (rate) { + session->payloads[session->payload_len].rate = atoi(rate); + } else { + if (!strcasecmp(media, "video")) { + session->payloads[session->payload_len].rate = 90000; + } else { + session->payloads[session->payload_len].rate = 8000; + } + } + session->payload_len++; + + if (globals.debug) { + globals.logger(DL_LOG_CRIT, "Add Payload [%s] id='%s'\n", name, id); + } + } + } + itag = iks_next_tag(itag); + } + + } + } + + tag = iks_next_tag(tag); + } + } else if (!strcasecmp(action, "transport-accept")) { + dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT; + } else if (!strcasecmp(action, "reject")) { + dl_signal = LDL_SIGNAL_REJECT; + } else if (!strcasecmp(action, "transport-info")) { + + tag = iks_child (xml); + + while(tag) { + + if (!strcasecmp(iks_name_nons(tag), "content")) { + iks *ttag = iks_child (tag); + + dl_signal = LDL_SIGNAL_CANDIDATES; + + id = action; + + if (ttag && !strcasecmp(iks_name_nons(ttag), "transport")) { + ttag = iks_child(ttag); + } + + for (;ttag;ttag = iks_next_tag(ttag)) { + if (!strcasecmp(iks_name_nons(ttag), "info_element")) { + char *name = iks_find_attrib(ttag, "name"); + char *value = iks_find_attrib(ttag, "value"); + if (globals.debug) { + globals.logger(DL_LOG_CRIT, "Info Element [%s]=[%s]\n", name, value); + } + ldl_session_set_value(session, name, value); + + } else if (!strcasecmp(iks_name_nons(ttag), "candidate")) { + char *key; + double pref = 0.0; + int index = -1; + ldl_transport_type_t tport; + unsigned int *candidate_len = NULL; + ldl_candidate_t (*candidates)[LDL_MAX_CANDIDATES] = NULL; + + if ((key = iks_find_attrib(ttag, "preference"))) { + unsigned int x; + + pref = strtod(key, NULL); + + /* Check what kind of candidate this is */ + if ((key = iks_find_attrib(ttag, "name")) && ((tport = ldl_transport_type_parse(key)) != LDL_TPORT_MAX)) { + candidates = &(session->candidates[tport]); + candidate_len = &(session->candidate_len[tport]); + } else { + globals.logger(DL_LOG_WARNING, "No such transport type: %s\n", key); + continue; + } + + if (*candidate_len >= LDL_MAX_CANDIDATES) { + globals.logger(DL_LOG_WARNING, "Too many %s candidates\n", key); + continue; + } + + for (x = 0; x < *candidate_len; x++) { + if ((*candidates)[x].pref == pref) { + if (globals.debug) { + globals.logger(DL_LOG_CRIT, "Duplicate Pref!\n"); + } + index = x; + break; + } + } + } + + if (index < 0) { + index = (*candidate_len)++; + } + + (*candidates)[index].pref = pref; + + if ((key = iks_find_attrib(ttag, "name"))) { + (*candidates)[index].name = apr_pstrdup(session->pool, key); + } + if ((key = iks_find_attrib(ttag, "type"))) { + (*candidates)[index].type = apr_pstrdup(session->pool, key); + } + if ((key = iks_find_attrib(ttag, "protocol"))) { + (*candidates)[index].protocol = apr_pstrdup(session->pool, key); + } + if ((key = iks_find_attrib(ttag, "username"))) { + (*candidates)[index].username = apr_pstrdup(session->pool, key); + } + if ((key = iks_find_attrib(ttag, "password"))) { + (*candidates)[index].password = apr_pstrdup(session->pool, key); + } + if ((key = iks_find_attrib(ttag, "address"))) { + (*candidates)[index].address = apr_pstrdup(session->pool, key); + } + if ((key = iks_find_attrib(ttag, "port"))) { + (*candidates)[index].port = (uint16_t)atoi(key); + } + + if (!(*candidates)[index].type) { + (*candidates)[index].type = apr_pstrdup(session->pool, "stun"); + } + + + if (globals.debug) { + globals.logger(DL_LOG_CRIT, + "New Candidate %d\n" + "name=%s\n" + "type=%s\n" + "protocol=%s\n" + "username=%s\n" + "password=%s\n" + "address=%s\n" + "port=%d\n" + "pref=%0.2f\n", + *candidate_len, + (*candidates)[index].name, + (*candidates)[index].type, + (*candidates)[index].protocol, + (*candidates)[index].username, + (*candidates)[index].password, + (*candidates)[index].address, + (*candidates)[index].port, + (*candidates)[index].pref + ); + } + } + } + } + + tag = iks_next_tag(tag); + } + } else if (!strcasecmp(action, "session-terminate")) { + dl_signal = LDL_SIGNAL_TERMINATE; + } else if (!strcasecmp(action, "error")) { + dl_signal = LDL_SIGNAL_ERROR; + } + } + + + + if (handle->session_callback && dl_signal) { + handle->session_callback(handle, session, dl_signal, to, from, id, msg); + } + + return LDL_STATUS_SUCCESS; +} + + + const char *marker = "TRUE"; @@ -601,12 +933,12 @@ static int on_disco_default(void *user_data, ikspak *pak) } if (pak->subtype == IKS_TYPE_RESULT) { - globals.logger(DL_LOG_DEBUG, "FixME!!! node=[%s]\n", node?node:""); + globals.logger(DL_LOG_CRIT, "FixME!!! node=[%s]\n", node?node:""); } else if (pak->subtype == IKS_TYPE_GET) { if ((iq = iks_new("iq"))) { int all = 0; - iks_insert_attrib(iq, "from", iks_find_attrib(pak->x, "to")); + iks_insert_attrib(iq, "from", handle->login); if (pak->from) { iks_insert_attrib(iq, "to", pak->from->full); } @@ -673,7 +1005,7 @@ static int on_disco_default(void *user_data, ikspak *pak) } if (!send) { - globals.logger(DL_LOG_DEBUG, "Memory Error!\n"); + globals.logger(DL_LOG_CRIT, "Memory Error!\n"); } } @@ -838,12 +1170,12 @@ static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type, char buf[512]; iks *tag; - if (from && !strchr(from, '/')) { + if (!strchr(from, '/')) { snprintf(buf, sizeof(buf), "%s/talk", from); from = buf; } - if (ldl_test_flag(handle, LDL_FLAG_COMPONENT) && from && to && ldl_jid_domcmp(from, to)) { + if (ldl_test_flag(handle, LDL_FLAG_COMPONENT) && ldl_jid_domcmp(from, to)) { globals.logger(DL_LOG_ERR, "Refusal to send presence from and to the same domain in component mode [%s][%s]\n", from, to); return; } @@ -890,7 +1222,7 @@ static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type, if ((tag = iks_insert(pres, "c"))) { iks_insert_attrib(tag, "node", "http://www.freeswitch.org/xmpp/client/caps"); iks_insert_attrib(tag, "ver", LDL_CAPS_VER); - iks_insert_attrib(tag, "ext", "sidebar voice-v1"); + iks_insert_attrib(tag, "ext", "sidebar voice-v1 video-v1 camera-v1"); iks_insert_attrib(tag, "client", "libdingaling"); iks_insert_attrib(tag, "xmlns", "http://jabber.org/protocol/caps"); } @@ -970,7 +1302,7 @@ static void cancel_retry(ldl_handle_t *handle, char *id) apr_thread_mutex_lock(handle->lock); if ((packet_node = apr_hash_get(handle->retry_hash, id, APR_HASH_KEY_STRING))) { if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Cancel packet %s\n", packet_node->id); + globals.logger(DL_LOG_CRIT, "Cancel packet %s\n", packet_node->id); } packet_node->retries = 0; } @@ -989,6 +1321,30 @@ static iks* working_find(iks *tag, const char *name) return NULL; } +static iks* working_find_nons(iks *tag, const char *name) +{ + while(tag) { + char *a = iks_name(tag); + char *b = (char *)name; + char *p; + + if ((p = strchr(a, ':'))) { + a = p+1; + } + + if ((p = strchr(b, ':'))) { + b = p+1; + } + + if (!strcasecmp(a,b)) { + return tag; + } + tag = iks_next_tag(tag); + } + + return NULL; +} + static int on_commands(void *user_data, ikspak *pak) { ldl_handle_t *handle = user_data; @@ -999,6 +1355,8 @@ static int on_commands(void *user_data, ikspak *pak) uint8_t is_result = strcasecmp(type, "result") ? 0 : 1; uint8_t is_error = strcasecmp(type, "error") ? 0 : 1; iks *xml, *xsession, *xerror = NULL, *xredir = NULL; + iks *xjingle; + xml = iks_child (pak->x); @@ -1062,8 +1420,21 @@ static int on_commands(void *user_data, ikspak *pak) } } - - if ((xsession = working_find(xml, "ses:session")) || (xsession = working_find(xml, "session"))) { + + + if ((handle->flags & LDL_FLAG_JINGLE) && (xjingle = working_find_nons(xml, "jin:jingle"))) { + if (parse_jingle_code(handle, xjingle, to, from, type) == LDL_STATUS_SUCCESS) { + iks *reply; + if ((reply = iks_make_iq(IKS_TYPE_RESULT, NULL))) { + iks_insert_attrib(reply, "to", from); + iks_insert_attrib(reply, "from", to); + iks_insert_attrib(reply, "id", iqid); + apr_queue_push(handle->queue, reply); + reply = NULL; + } + } + + } else if ((xsession = working_find_nons(xml, "ses:session"))) { char *id; id = iks_find_attrib(xsession, "id"); @@ -1102,7 +1473,7 @@ static int on_result(void *user_data, ikspak *pak) ctag = iks_insert(msg, "c"); iks_insert_attrib(ctag, "node", "http://www.freeswitch.org/xmpp/client/caps"); iks_insert_attrib(ctag, "ver", "1.0.0.1"); - iks_insert_attrib(ctag, "ext", "sidebar voice-v1"); + iks_insert_attrib(ctag, "ext", "sidebar voice-v1 video-v1"); iks_insert_attrib(ctag, "client", "libdingaling"); iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps"); @@ -1239,7 +1610,7 @@ static int on_stream(ldl_handle_t *handle, int type, iks *node) if (iks_has_tls()) { iks_start_tls(handle->parser); } else { - globals.logger(DL_LOG_DEBUG, "TLS NOT SUPPORTED IN THIS BUILD!\n"); + globals.logger(DL_LOG_WARNING, "TLS NOT SUPPORTED IN THIS BUILD!\n"); } } break; @@ -1284,19 +1655,19 @@ static int on_stream(ldl_handle_t *handle, int type, iks *node) apr_queue_push(handle->queue, x); x = NULL; } else { - globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n"); + globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); break; } } } } else if (node && strcmp("failure", iks_name_nons(node)) == 0) { - globals.logger(DL_LOG_DEBUG, "sasl authentication failed\n"); + globals.logger(DL_LOG_CRIT, "sasl authentication failed\n"); if (handle->session_callback) { handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_FAILURE, "user", "core", "Login Failure", handle->login); } } else if (node && strcmp("success", iks_name_nons(node)) == 0) { - globals.logger(DL_LOG_DEBUG, "XMPP server connected\n"); + globals.logger(DL_LOG_NOTICE, "XMPP server connected\n"); iks_send_header(handle->parser, handle->acc->server); ldl_set_flag_locked(handle, LDL_FLAG_CONNECTED); if (handle->session_callback) { @@ -1308,7 +1679,7 @@ static int on_stream(ldl_handle_t *handle, int type, iks *node) if (handle->session_callback) { handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "user", "core", "Login Success", handle->login); } - globals.logger(DL_LOG_DEBUG, "XMPP authenticated\n"); + globals.logger(DL_LOG_NOTICE, "XMPP authenticated\n"); ldl_set_flag_locked(handle, LDL_FLAG_AUTHORIZED); } if (node) { @@ -1360,18 +1731,20 @@ static int on_msg(void *user_data, ikspak *pak) static int on_error(void *user_data, ikspak * pak) { - globals.logger(DL_LOG_DEBUG, "authorization failed\n"); + globals.logger(DL_LOG_ERR, "authorization failed\n"); return IKS_FILTER_EAT; } static void on_log(ldl_handle_t *handle, const char *data, size_t size, int is_incoming) { + if (globals.debug) { if (is_incoming) { globals.logger(DL_LOG_INFO, "+xml:%s%s:%s", iks_is_secure(handle->parser) ? "Sec" : "", is_incoming ? "RECV" : "SEND", data); } else { globals.logger(DL_LOG_NOTICE, "+xml:%s%s:%s", iks_is_secure(handle->parser) ? "Sec" : "", is_incoming ? "RECV" : "SEND", data); } + } } @@ -1443,11 +1816,7 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done) while(apr_queue_trypop(handle->queue, &pop) == APR_SUCCESS) { if (pop) { msg = (iks *) pop; - if (!done) { - if (iks_send(handle->parser, msg) != IKS_OK) { - globals.logger(DL_LOG_DEBUG, "Failed sending data!\n"); - }; - }; + if (!done) iks_send(handle->parser, msg); iks_delete(msg); pop = NULL; sent_data = LDL_QUEUE_SENT; @@ -1458,7 +1827,7 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done) len = apr_queue_size(handle->retry_queue); if (globals.debug && len) { - globals.logger(DL_LOG_DEBUG, "Processing %u packets in retry queue\n", len); + globals.logger(DL_LOG_CRIT, "Processing %u packets in retry queue\n", len); } pop = NULL; @@ -1475,18 +1844,16 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done) if (packet_node->retries > 0) { packet_node->retries--; if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries); + globals.logger(DL_LOG_CRIT, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries); } - if (iks_send(handle->parser, packet_node->xml) != IKS_OK) { - globals.logger(DL_LOG_DEBUG, "Failed trying re-sending data!\n"); - }; + iks_send(handle->parser, packet_node->xml); packet_node->next = now + 5000000; sent_data = LDL_QUEUE_SENT; } } if (packet_node->retries == 0 || done) { if (globals.debug) { - globals.logger(DL_LOG_DEBUG, "Discarding packet %s\n", packet_node->id); + globals.logger(DL_LOG_CRIT, "Discarding packet %s\n", packet_node->id); } apr_hash_set(handle->retry_hash, packet_node->id, APR_HASH_KEY_STRING, NULL); iks_delete(packet_node->xml); @@ -1505,8 +1872,8 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done) static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) { - int count_ka = LDL_KEEPALIVE_TIMEOUT; - time_t tstart, tnow; + int timeout_ka = LDL_KEEPALIVE_TIMEOUT; + int count_ka = timeout_ka; while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { int e; @@ -1537,8 +1904,6 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) j_setup_filter(handle); - globals.logger(DL_LOG_DEBUG, "xmpp connecting\n"); - e = iks_connect_via(handle->parser, handle->server ? handle->server : handle->acc->server, handle->port ? handle->port : IKS_JABBER_PORT, @@ -1548,27 +1913,31 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) case IKS_OK: break; case IKS_NET_NODNS: - globals.logger(DL_LOG_DEBUG, "hostname lookup failed\n"); + globals.logger(DL_LOG_CRIT, "hostname lookup failed\n"); microsleep(1000); goto fail; case IKS_NET_NOCONN: - globals.logger(DL_LOG_DEBUG, "connection failed\n"); + globals.logger(DL_LOG_CRIT, "connection failed\n"); microsleep(1000); goto fail; default: - globals.logger(DL_LOG_DEBUG, "io error 1 %d\n", e); + globals.logger(DL_LOG_CRIT, "io error 1 %d\n", e); microsleep(1000); goto fail; } handle->counter = opt_timeout; - if ((tstart = time(NULL)) == -1) { - globals.logger(DL_LOG_DEBUG, "error determining connection time"); - } while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { e = iks_recv(handle->parser, 1); + if (count_ka-- <= 0) { + if( iks_send_raw(handle->parser, " ") == IKS_OK) { + count_ka = timeout_ka; + globals.logger(DL_LOG_DEBUG, "Sent keep alive signal\n"); + } + } + if (handle->loop_callback) { if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) { ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); @@ -1585,51 +1954,31 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) } if (IKS_OK != e || ldl_test_flag(handle, LDL_FLAG_BREAK)) { - globals.logger(DL_LOG_DEBUG, "io error 2 %d retry in %d second(s)", e, ++handle->fail_count); - if ((tnow = time(NULL)) == -1) { - globals.logger(DL_LOG_DEBUG, "error deterniming io error time"); - } - if (difftime(tnow, tstart) > 30) { - /* this is a new error situation: reset counter */ - globals.logger(DL_LOG_DEBUG, "resetting fail count"); - handle->fail_count = 1; - } + globals.logger(DL_LOG_DEBUG, "io error 2 %d retry in %d second(s)\n", e, ++handle->fail_count); microsleep(1000 * handle->fail_count); goto fail; } if (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { - if (ldl_flush_queue(handle, 0) == LDL_QUEUE_SENT) { - count_ka = LDL_KEEPALIVE_TIMEOUT; - } - } + ldl_flush_queue(handle, 0); + } handle->counter--; if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) { if (IKS_NET_TLSFAIL == e) { - globals.logger(DL_LOG_DEBUG, "tls handshake failed\n"); + globals.logger(DL_LOG_CRIT, "tls handshake failed\n"); microsleep(500); break; } if (handle->counter == 0) { - globals.logger(DL_LOG_DEBUG, "network timeout\n"); - microsleep(500); - break; - } - } - - if (count_ka-- <= 0) { - if( iks_send_raw(handle->parser, " ") == IKS_OK) { - globals.logger(DL_LOG_DEBUG, "Sent keep alive signal"); - count_ka = LDL_KEEPALIVE_TIMEOUT; - } else { - globals.logger(DL_LOG_DEBUG, "Failed sending keep alive signal"); + globals.logger(DL_LOG_CRIT, "network timeout\n"); microsleep(500); break; } } + microsleep(100); } fail: @@ -1657,7 +2006,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) static void add_elements(ldl_session_t *session, iks *tag) { apr_hash_index_t *hi; - + return; for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) { void *val = NULL; const void *key = NULL; @@ -1672,6 +2021,42 @@ static void add_elements(ldl_session_t *session, iks *tag) } } + +static iks *ldl_set_jingle_tag(ldl_session_t *session, iks *iq, char *action) +{ + iks *jin = iks_insert (iq, "jin:jingle"); + iks_insert_attrib(jin, "xmlns:jin", "urn:xmpp:jingle:1"); + iks_insert_attrib(jin, "action", action); + iks_insert_attrib(jin, "sid", session->id); + //iks_insert_attrib(jin, "initiator", session->initiator ? session->initiator : session->them); + + return jin; +} + +static ldl_status new_jingle_iq(ldl_session_t *session, iks **iqp, iks **jinp, unsigned int *id, char *action) +{ + iks *iq , *jin; + unsigned int myid; + char idbuf[80]; + + myid = next_id(); + snprintf(idbuf, sizeof(idbuf), "%u", myid); + iq = iks_new("iq"); + iks_insert_attrib(iq, "xmlns", "jabber:client"); + iks_insert_attrib(iq, "from", session->login); + iks_insert_attrib(iq, "to", session->them); + iks_insert_attrib(iq, "type", "set"); + iks_insert_attrib(iq, "id", idbuf); + + jin = ldl_set_jingle_tag(session, iq, action); + + *jinp = jin; + *iqp = iq; + *id = myid; + return LDL_STATUS_SUCCESS; +} + + static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp, unsigned int *id, char *type) { iks *iq, *sess; @@ -1973,6 +2358,11 @@ unsigned int ldl_session_terminate(ldl_session_t *session) apr_hash_t *hash = session->handle->sessions; new_session_iq(session, &iq, &sess, &id, "terminate"); + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + ldl_set_jingle_tag(session, iq, "session-terminate"); + } + schedule_packet(session->handle, id, iq, LDL_RETRY); if (session->id) { @@ -1998,6 +2388,12 @@ unsigned int ldl_session_transport(ldl_session_t *session, unsigned int x, id = 0; + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + return ldl_session_candidates(session, candidates, clen); + } + + + for (x = 0; x < clen; x++) { char buf[512]; iq = NULL; @@ -2005,13 +2401,13 @@ unsigned int ldl_session_transport(ldl_session_t *session, id = 0; new_session_iq(session, &iq, &sess, &id, "transport-info"); - //tag = iks_insert(sess, "transport"); - //iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p"); + tag = sess; - if (0) add_elements(session, tag); + //if (0) add_elements(session, tag); tag = iks_insert(tag, "transport"); iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p"); + //iks_insert_attrib(tag, "xmlns", "urn:xmpp:jingle:transports:raw-udp:1"); tag = iks_insert(tag, "candidate"); @@ -2047,7 +2443,6 @@ unsigned int ldl_session_transport(ldl_session_t *session, schedule_packet(session->handle, id, iq, LDL_RETRY); } - return id; } @@ -2056,23 +2451,103 @@ unsigned int ldl_session_candidates(ldl_session_t *session, unsigned int clen) { - iks *iq, *sess, *tag; - unsigned int x, id = 0; + iks *iq = NULL, *sess = NULL, *tag = NULL; + unsigned int x = 0, id = 0; + unsigned int pass = 0; + iks *jingle = NULL, *jin_content = NULL, *p_trans = NULL; + const char *tname = ""; + const char *type = ""; + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + + + new_jingle_iq(session, &iq, &jingle, &id, "transport-info"); + + for (pass = 0; pass < 2; pass++) { + + if (pass == 0) { + type = "rtp"; + tname = "audio"; + } else { + type = "video_rtp"; + tname = "video"; + } + + jin_content = iks_insert(jingle, "jin:content"); + iks_insert_attrib(jin_content, "name", tname); + iks_insert_attrib(jin_content, "creator", "initiator"); + + for (x = 0; x < clen; x++) { + char buf[512]; + + if (strcasecmp(candidates[x].name, type)) { + continue; + } + + p_trans = iks_insert(jin_content, "p:transport"); + iks_insert_attrib(p_trans, "xmlns:p", "http://www.google.com/transport/p2p"); + + + + tag = iks_insert(p_trans, "candidate"); + + if (candidates[x].name) { + iks_insert_attrib(tag, "name", candidates[x].name); + } + if (candidates[x].address) { + iks_insert_attrib(tag, "address", candidates[x].address); + } + if (candidates[x].port) { + snprintf(buf, sizeof(buf), "%u", candidates[x].port); + iks_insert_attrib(tag, "port", buf); + } + if (candidates[x].username) { + iks_insert_attrib(tag, "username", candidates[x].username); + } + if (candidates[x].password) { + iks_insert_attrib(tag, "password", candidates[x].password); + } + if (candidates[x].pref) { + snprintf(buf, sizeof(buf), "%0.1f", candidates[x].pref); + iks_insert_attrib(tag, "preference", buf); + } + if (candidates[x].protocol) { + iks_insert_attrib(tag, "protocol", candidates[x].protocol); + } + if (candidates[x].type) { + iks_insert_attrib(tag, "type", candidates[x].type); + } + + iks_insert_attrib(tag, "network", "0"); + iks_insert_attrib(tag, "generation", "0"); + } + } + + + schedule_packet(session->handle, id, iq, LDL_RETRY); + + iq = NULL; + sess = NULL; + tag = NULL; + x = 0; + id = 0; + } + + + new_session_iq(session, &iq, &sess, &id, "candidates"); + add_elements(session, sess); + for (x = 0; x < clen; x++) { char buf[512]; - iq = NULL; - sess = NULL; - id = 0; + //iq = NULL; + //sess = NULL; + //id = 0; - new_session_iq(session, &iq, &sess, &id, "candidates"); - //tag = iks_insert(sess, "transport"); - //iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p"); - tag = sess; + tag = iks_insert(sess, "ses:candidate"); + - add_elements(session, tag); - tag = iks_insert(tag, "ses:candidate"); if (candidates[x].name) { iks_insert_attrib(tag, "name", candidates[x].name); @@ -2103,9 +2578,10 @@ unsigned int ldl_session_candidates(ldl_session_t *session, iks_insert_attrib(tag, "network", "0"); iks_insert_attrib(tag, "generation", "0"); - schedule_packet(session->handle, id, iq, LDL_RETRY); + } + schedule_packet(session->handle, id, iq, LDL_RETRY); return id; } @@ -2192,11 +2668,11 @@ char *ldl_handle_disco(ldl_handle_t *handle, char *id, char *from, char *buf, un iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info"); } else { iks_delete(iq); - globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n"); + globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); return NULL; } } else { - globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n"); + globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); return NULL; } @@ -2236,42 +2712,274 @@ char *ldl_handle_disco(ldl_handle_t *handle, char *id, char *from, char *buf, un } + unsigned int ldl_session_describe(ldl_session_t *session, - ldl_payload_t *payloads, - unsigned int plen, - ldl_description_t description) + ldl_payload_t *payloads, + unsigned int plen, + ldl_description_t description, unsigned int *audio_ssrc, unsigned int *video_ssrc, + ldl_crypto_data_t *audio_crypto_data, ldl_crypto_data_t *video_crypto_data) { - iks *iq, *sess, *tag, *payload, *tp; + iks *iq; + iks *sess, *payload = NULL, *tag = NULL;//, *u = NULL; + unsigned int x, id; - + int video_call = 0; + int compat = 1; + //char *vid_mux = ldl_session_get_value(session, "video:rtcp-mux"); + //char *aud_mux = ldl_session_get_value(session, "audio:rtcp-mux"); + char tmp[80]; + iks *jpayload = NULL, *tp = NULL; + iks *jingle, *jin_audio, *jin_audio_desc = NULL, *jin_video = NULL, *jin_video_desc = NULL, *crypto; - new_session_iq(session, &iq, &sess, &id, description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate"); - tag = iks_insert(sess, "pho:description"); - iks_insert_attrib(tag, "xmlns:pho", "http://www.google.com/session/phone"); - iks_insert_attrib(tag, "xml:lang", "en"); - for (x = 0; x < plen; x++) { - char idbuf[80]; - payload = iks_insert(tag, "pho:payload-type"); - iks_insert_attrib(payload, "xmlns:pho", "http://www.google.com/session/phone"); - sprintf(idbuf, "%d", payloads[x].id); - iks_insert_attrib(payload, "id", idbuf); - iks_insert_attrib(payload, "name", payloads[x].name); - if (payloads[x].rate) { - sprintf(idbuf, "%d", payloads[x].rate); - iks_insert_attrib(payload, "clockrate", idbuf); + if (!*audio_ssrc) { + *audio_ssrc = (uint32_t) ((intptr_t) session + (uint32_t) time(NULL)); + } + + if (!*video_ssrc) { + *video_ssrc = (uint32_t) ((intptr_t) payloads + (uint32_t) time(NULL)); + } + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + new_jingle_iq(session, &iq, &jingle, &id, description == LDL_DESCRIPTION_ACCEPT ? "session-accept" : "session-initiate"); + iks_insert_attrib(jingle, "initiator", session->initiator ? session->initiator : session->them); + + if (compat) { + sess = iks_insert (iq, "ses:session"); + iks_insert_attrib(sess, "xmlns:ses", "http://www.google.com/session"); + + iks_insert_attrib(sess, "type", description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate"); + iks_insert_attrib(sess, "id", session->id); + iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them); } - if (payloads[x].bps) { - sprintf(idbuf, "%d", payloads[x].bps); - iks_insert_attrib(payload, "bitrate", idbuf); + + } else { + new_session_iq(session, &iq, &sess, &id, description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate"); + } + + + /* Check if this is a video call */ + for (x = 0; x < plen; x++) { + if (payloads[x].type == LDL_PAYLOAD_VIDEO) { + video_call = 1; + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + jin_video = iks_insert(jingle, "jin:content"); + iks_insert_attrib(jin_video, "name", "video"); + iks_insert_attrib(jin_video, "creator", "initiator"); + //iks_insert_attrib(jin_video, "senders", "both"); + jin_video_desc = iks_insert(jin_video, "rtp:description"); + iks_insert_attrib(jin_video_desc, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); + iks_insert_attrib(jin_video_desc, "media", "video"); + snprintf(tmp, sizeof(tmp), "%u", *video_ssrc); + iks_insert_attrib(jin_video_desc, "ssrc", tmp); + tp = iks_insert(jin_video, "p:transport"); + iks_insert_attrib(tp, "xmlns:p", "http://www.google.com/transport/p2p"); + + } + + break; } } + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + jin_audio = iks_insert(jingle, "jin:content"); + iks_insert_attrib(jin_audio, "name", "audio"); + iks_insert_attrib(jin_audio, "creator", "initiator"); + //iks_insert_attrib(jin_audio, "senders", "both"); + jin_audio_desc = iks_insert(jin_audio, "rtp:description"); + iks_insert_attrib(jin_audio_desc, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); + iks_insert_attrib(jin_audio_desc, "media", "audio"); + snprintf(tmp, sizeof(tmp), "%u", *audio_ssrc); + iks_insert_attrib(jin_audio_desc, "ssrc", tmp); + tp = iks_insert(jin_audio, "p:transport"); + iks_insert_attrib(tp, "xmlns:p", "http://www.google.com/transport/p2p"); + } + + if (compat) { + + if (video_call) { + tag = iks_insert(sess, "vid:description"); + iks_insert_attrib(tag, "xmlns:vid", "http://www.google.com/session/video"); + } else { + tag = iks_insert(sess, "pho:description"); + iks_insert_attrib(tag, "xmlns:pho", "http://www.google.com/session/phone"); + } + + if (video_call) { + + for (x = 0; x < plen; x++) { + char idbuf[80]; + + if (payloads[x].type != LDL_PAYLOAD_VIDEO) { + continue; + } + + sprintf(idbuf, "%d", payloads[x].id); + + + payload = iks_insert(tag, "vid:payload-type"); + + iks_insert_attrib(payload, "id", idbuf); + iks_insert_attrib(payload, "name", payloads[x].name); + + if (payloads[x].type == LDL_PAYLOAD_VIDEO && video_call) { + if (payloads[x].width) { + sprintf(idbuf, "%d", payloads[x].width); + iks_insert_attrib(payload, "width", idbuf); + } + if (payloads[x].height) { + sprintf(idbuf, "%d", payloads[x].height); + iks_insert_attrib(payload, "height", idbuf); + } + if (payloads[x].framerate) { + sprintf(idbuf, "%d", payloads[x].framerate); + iks_insert_attrib(payload, "framerate", idbuf); + } + } + + } + + + //if (vid_mux) { + // iks_insert(tag, "rtcp-mux"); + //} + + //payload = iks_insert(tag, "vid:src-id"); + //iks_insert_cdata(payload, "123456789", 0); + + + //iks_insert_attrib(payload, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); + //iks_insert(payload, "vid:usage"); + } + } + + for (x = 0; x < plen; x++) { + char idbuf[80]; + + if (payloads[x].type == LDL_PAYLOAD_VIDEO && !video_call) { + continue; + } + + sprintf(idbuf, "%d", payloads[x].id); + + if (payloads[x].type == LDL_PAYLOAD_AUDIO) { + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + char ratebuf[80]; + char buf[80]; + iks *param; + + jpayload = iks_insert(jin_audio_desc, "rtp:payload-type"); + iks_insert_attrib(jpayload, "id", idbuf); + sprintf(ratebuf, "%d", payloads[x].rate); + iks_insert_attrib(jpayload, "name", payloads[x].name); + iks_insert_attrib(jpayload, "clockrate", ratebuf); + param = iks_insert(jpayload, "rtp:parameter"); + iks_insert_attrib(param, "name", "bitrate"); + sprintf(buf, "%d", payloads[x].bps); + iks_insert_attrib(param, "value", buf); + + sprintf(buf, "%d", payloads[x].ptime); + iks_insert_attrib(jpayload, "ptime", ratebuf); + iks_insert_attrib(jpayload, "maxptime", ratebuf); + + } + + } else if (payloads[x].type == LDL_PAYLOAD_VIDEO && video_call) { + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + char buf[80]; + iks *param; + + jpayload = iks_insert(jin_video_desc, "rtp:payload-type"); + iks_insert_attrib(jpayload, "id", idbuf); + iks_insert_attrib(jpayload, "name", payloads[x].name); + param = iks_insert(jpayload, "rtp:parameter"); + iks_insert_attrib(param, "name", "width"); + sprintf(buf, "%d", payloads[x].width); + iks_insert_attrib(param, "value", buf); + + + param = iks_insert(jpayload, "rtp:parameter"); + iks_insert_attrib(param, "name", "height"); + sprintf(buf, "%d", payloads[x].height); + iks_insert_attrib(param, "value", buf); + + param = iks_insert(jpayload, "rtp:parameter"); + iks_insert_attrib(param, "name", "framerate"); + sprintf(buf, "%d", payloads[x].framerate); + iks_insert_attrib(param, "value", buf); + + } + } + + if (compat) { + + if (payloads[x].type == LDL_PAYLOAD_AUDIO) { + + payload = iks_insert(tag, "pho:payload-type"); + + iks_insert_attrib(payload, "id", idbuf); + iks_insert_attrib(payload, "name", payloads[x].name); + + if (payloads[x].rate) { + sprintf(idbuf, "%d", payloads[x].rate); + iks_insert_attrib(payload, "clockrate", idbuf); + } + + if (payloads[x].bps) { + sprintf(idbuf, "%d", payloads[x].bps); + iks_insert_attrib(payload, "bitrate", idbuf); + } + + iks_insert_attrib(payload, "xmlns:pho", "http://www.google.com/session/phone"); + } + } + //if (payloads[x].id == 34) payloads[x].id = 98; /* XXX */ + + } + + if ((session->handle->flags & LDL_FLAG_JINGLE)) { + if (jin_video_desc && video_crypto_data) { + payload = iks_insert(jin_video_desc, "rtp:encryption"); + crypto = iks_insert(payload, "rtp:crypto"); + iks_insert_attrib(crypto, "crypto-suite", video_crypto_data->suite); + iks_insert_attrib(crypto, "key-params", video_crypto_data->key); + iks_insert_attrib(crypto, "tag", video_crypto_data->tag); + } + + + if (jin_audio_desc && audio_crypto_data) { + payload = iks_insert(jin_audio_desc, "rtp:encryption"); + crypto = iks_insert(payload, "rtp:crypto"); + iks_insert_attrib(crypto, "crypto-suite", audio_crypto_data->suite); + iks_insert_attrib(crypto, "key-params", audio_crypto_data->key); + iks_insert_attrib(crypto, "tag", audio_crypto_data->tag); + } + } + + //if (aud_mux) { + // iks_insert(tag, "rtcp-mux"); + //} + + //payload = iks_insert(tag, "pho:src-id"); + //iks_insert_cdata(payload, "987654321", 0); + //iks_insert_attrib(payload, "xmlns:pho", "http://www.google.com/session/phone"); + + //payload = iks_insert(tag, "rtp:encryption"); + //iks_insert_attrib(payload, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); + //u = iks_insert(payload, "pho:usage"); + //iks_insert_attrib(u, "xmlns:pho", "http://www.google.com/session/phone"); + +#if 0 if (description == LDL_DESCRIPTION_INITIATE) { tp = iks_insert (sess, "transport"); iks_insert_attrib(tp, "xmlns", "http://www.google.com/transport/p2p"); } - +#endif + + schedule_packet(session->handle, id, iq, LDL_RETRY); return id; @@ -2282,11 +2990,13 @@ ldl_state_t ldl_session_get_state(ldl_session_t *session) return session->state; } -ldl_status ldl_session_get_candidates(ldl_session_t *session, ldl_candidate_t **candidates, unsigned int *len) +ldl_status ldl_session_get_candidates(ldl_session_t *session, ldl_transport_type_t tport, ldl_candidate_t **candidates, unsigned int *len) { + assert(tport < LDL_TPORT_MAX); + if (session->candidate_len) { - *candidates = session->candidates; - *len = session->candidate_len; + *candidates = session->candidates[tport]; + *len = session->candidate_len[tport]; return LDL_STATUS_SUCCESS; } else { *candidates = NULL; @@ -2332,7 +3042,7 @@ ldl_status ldl_global_init(int debug) memset(&globals, 0, sizeof(globals)); if (apr_pool_create(&globals.memory_pool, NULL) != LDL_STATUS_SUCCESS) { - globals.logger(DL_LOG_DEBUG, "Could not allocate memory pool\n"); + globals.logger(DL_LOG_CRIT, "Could not allocate memory pool\n"); return LDL_STATUS_MEMERR; } diff --git a/libs/libdingaling/src/libdingaling.h b/libs/libdingaling/src/libdingaling.h index 1f43167dab..e76be86ecf 100644 --- a/libs/libdingaling/src/libdingaling.h +++ b/libs/libdingaling/src/libdingaling.h @@ -1,6 +1,6 @@ /* * libDingaLing XMPP Jingle Library - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -28,6 +28,7 @@ * libdingaling.h -- Main Header File * */ + /*! \file libdingaling.h \brief Main Header File */ @@ -60,12 +61,18 @@ extern "C" { #endif #define LDL_HANDLE_QLEN 2000 -#define LDL_MAX_CANDIDATES 10 +#define LDL_MAX_CANDIDATES 25 #define LDL_MAX_PAYLOADS 50 #define LDL_RETRY 3 #define IKS_NS_COMPONENT "jabber:component:accept" -/* period between keep alive signals in 1sec units*/ -#define LDL_KEEPALIVE_TIMEOUT 300 +/* period between keep alive signals in 0.1sec units*/ +#define LDL_KEEPALIVE_TIMEOUT 6000 + +typedef struct ldl_crypto_data_s { + char *tag; + char *suite; + char *key; +} ldl_crypto_data_t; /*! \brief A structure to store a jingle candidate */ struct ldl_candidate { @@ -90,19 +97,89 @@ struct ldl_candidate { }; typedef struct ldl_candidate ldl_candidate_t; -/*! \brief A structure to store a jingle payload */ +typedef enum { + LDL_PAYLOAD_AUDIO, + LDL_PAYLOAD_VIDEO +} ldl_payload_type_t; + +/*! \brief A structure to store a jingle audio payload */ struct ldl_payload { + /*! the type of the payload */ + ldl_payload_type_t type; /*! the iana name of the payload type */ char *name; /*! the iana id of the payload type */ unsigned int id; + + /* Audio */ + /*! the transfer rate of the payload type */ unsigned int rate; /*! the bits per second of the payload type */ unsigned int bps; + + /* Video */ + + /*! the width of the video payload type */ + unsigned int width; + /*! the width of the video payload type */ + unsigned int height; + /*! the framerate of the video payload type */ + unsigned int framerate; + + unsigned int ptime; }; typedef struct ldl_payload ldl_payload_t; + +enum ldl_transport_type { + LDL_TPORT_RTP, + LDL_TPORT_VIDEO_RTP, + LDL_TPORT_RTCP, + LDL_TPORT_VIDEO_RTCP, + + /* Nothing below that line */ + LDL_TPORT_MAX +}; +typedef enum ldl_transport_type ldl_transport_type_t; + +static inline const char *ldl_transport_type_str(ldl_transport_type_t type) +{ + static const char *name[] = { "rtp", "video_rtp", "rtcp", "video_rtcp" }; + return type >= LDL_TPORT_MAX ? NULL : name[type]; +} + +static inline ldl_transport_type_t ldl_transport_type_parse(const char *type) { + if (!strcasecmp(type, "rtp")) { + return LDL_TPORT_RTP; + } else if (!strcasecmp(type, "rtcp")) { + return LDL_TPORT_RTCP; + } else if (!strcasecmp(type, "video_rtp")) { + return LDL_TPORT_VIDEO_RTP; + } else if (!strcasecmp(type, "video_rtcp")) { + return LDL_TPORT_VIDEO_RTCP; + } else { + return LDL_TPORT_MAX; + } +} + +#if 0 +/*! \brief A structure to store a jingle video payload */ +struct ldl_vpayload { + /*! the iana name of the video payload type */ + char *name; + /*! the iana id of the video payload type */ + unsigned int id; + /*! the width of the video payload type */ + unsigned int width; + /*! the width of the video payload type */ + unsigned int height; + /*! the framerate of the video payload type */ + unsigned int framerate; +}; +typedef struct ldl_vpayload ldl_vpayload_t; +#endif + struct ldl_handle; typedef struct ldl_handle ldl_handle_t; @@ -132,7 +209,8 @@ typedef enum { LDL_FLAG_SASL_MD5 = (1 << 12), LDL_FLAG_COMPONENT = (1 << 13), LDL_FLAG_OUTBOUND = (1 << 14), - LDL_FLAG_GATEWAY = (1 << 15) + LDL_FLAG_GATEWAY = (1 << 15), + LDL_FLAG_JINGLE = (1 << 16) } ldl_user_flag_t; typedef enum { @@ -514,9 +592,10 @@ unsigned int ldl_session_transport(ldl_session_t *session, \return the message_id of the generated xmpp request */ unsigned int ldl_session_describe(ldl_session_t *session, - ldl_payload_t *payloads, - unsigned int plen, - ldl_description_t description); + ldl_payload_t *payloads, + unsigned int plen, + ldl_description_t description, unsigned int *audio_ssrc, unsigned int *video_ssrc, + ldl_crypto_data_t *audio_crypto_data, ldl_crypto_data_t *video_crypto_data); /*! @@ -530,11 +609,12 @@ ldl_state_t ldl_session_get_state(ldl_session_t *session); /*! \brief get the candidates \param session the session + \param tport type of transport (rtp,rtcp,video_rtp,video_rtcp,etc.) \param candidates pointer to point at array of the candidates \param len the resulting len of the array pointer \return success or failure */ -ldl_status ldl_session_get_candidates(ldl_session_t *session, ldl_candidate_t **candidates, unsigned int *len); +ldl_status ldl_session_get_candidates(ldl_session_t *session, ldl_transport_type_t tport, ldl_candidate_t **candidates, unsigned int *len); /*! \brief get the payloads diff --git a/libs/libg722_1/README b/libs/libg722_1/README index 424c281581..865accacde 100644 --- a/libs/libg722_1/README +++ b/libs/libg722_1/README @@ -18,7 +18,7 @@ a separate process, and your application communicates with it through pipes or sockets. This implementation of G.722.1 is adapted from the reference source code -provided by Polycom. Polycom has given its concent for this library to be +provided by Polycom. Polycom has given its consent for this library to be distributed as source code, either on its own or as part of a larger package which they have licenced under their royalty free licencing scheme. diff --git a/libs/libscgi/FSSCGI.i b/libs/libscgi/FSSCGI.i new file mode 100644 index 0000000000..186cef6244 --- /dev/null +++ b/libs/libscgi/FSSCGI.i @@ -0,0 +1,6 @@ +%{ +#include "scgi.h" +#include "scgi_oop.h" +%} + +%include "scgi_oop.h" diff --git a/libs/libscgi/Makefile b/libs/libscgi/Makefile new file mode 100644 index 0000000000..265834ae69 --- /dev/null +++ b/libs/libscgi/Makefile @@ -0,0 +1,51 @@ +PWD=$(shell pwd) +INCS=-I$(PWD)/src/include +DEBUG=-g -ggdb +BASE_FLAGS=$(INCS) $(DEBUG) -fPIC +PICKY=-O2 +CFLAGS=$(BASE_FLAGS) $(PICKY) +CXXFLAGS=$(BASE_FLAGS) +MYLIB=libscgi.a +LIBS= +LDFLAGS=-L. +OBJS=src/scgi.o +SRC=src/scgi.c src/scgi_oop.cpp +HEADERS=src/include/scgi.h src/include/scgi_oop.h +SOLINK=-shared -Xlinker -x + +# comment the next line to disable c++ (no swig mods for you then) +OBJS += src/scgi_oop.o + +all: $(MYLIB) testclient testserver + +$(MYLIB): $(OBJS) $(HEADERS) $(SRC) + ar rcs $(MYLIB) $(OBJS) + ranlib $(MYLIB) + +%.o: %.c $(HEADERS) + $(CC) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@ + +%.o: %.cpp $(HEADERS) + $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) -c $< -o $@ + +testclient: $(MYLIB) testclient.c + $(CC) $(CC_CFLAGS) $(CFLAGS) testclient.c -o testclient -lscgi $(LDFLAGS) $(LIBS) + +testserver: $(MYLIB) testserver.c + $(CC) $(CC_CFLAGS) $(CFLAGS) testserver.c -o testserver -lscgi $(LDFLAGS) $(LIBS) + +clean: + rm -f *.o src/*.o libscgi.a *~ src/*~ src/include/*~ testclient testserver + $(MAKE) -C perl clean + +reswig: swigclean + $(MAKE) -C perl reswig + +swigclean: clean + $(MAKE) -C perl swigclean + +perlmod: $(MYLIB) + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C perl + +perlmod-install: perlmod + $(MAKE) -C perl install diff --git a/libs/libscgi/perl/FSSCGI.pm b/libs/libscgi/perl/FSSCGI.pm new file mode 100644 index 0000000000..05370a12a7 --- /dev/null +++ b/libs/libscgi/perl/FSSCGI.pm @@ -0,0 +1,105 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.35 +# +# Don't modify this file, modify the SWIG interface instead. + +package FSSCGI; +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +package FSSCGIc; +bootstrap FSSCGI; +package FSSCGI; +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- + +package FSSCGI; + +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub FIRSTKEY { } + +sub NEXTKEY { } + +sub FETCH { + my ($self,$field) = @_; + my $member_func = "swig_${field}_get"; + $self->$member_func(); +} + +sub STORE { + my ($self,$field,$newval) = @_; + my $member_func = "swig_${field}_set"; + $self->$member_func($newval); +} + +sub this { + my $ptr = shift; + return tied(%$ptr); +} + + +# ------- FUNCTION WRAPPERS -------- + +package FSSCGI; + + +############# Class : FSSCGI::SCGIhandle ############## + +package FSSCGI::SCGIhandle; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( FSSCGI ); +%OWNER = (); +%ITERATORS = (); +sub new { + my $pkg = shift; + my $self = FSSCGIc::new_SCGIhandle(@_); + bless $self, $pkg if defined($self); +} + +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + FSSCGIc::delete_SCGIhandle($self); + delete $OWNER{$self}; + } +} + +*connected = *FSSCGIc::SCGIhandle_connected; +*socketDescriptor = *FSSCGIc::SCGIhandle_socketDescriptor; +*disconnect = *FSSCGIc::SCGIhandle_disconnect; +*addParam = *FSSCGIc::SCGIhandle_addParam; +*addBody = *FSSCGIc::SCGIhandle_addBody; +*getBody = *FSSCGIc::SCGIhandle_getBody; +*getParam = *FSSCGIc::SCGIhandle_getParam; +*sendRequest = *FSSCGIc::SCGIhandle_sendRequest; +*respond = *FSSCGIc::SCGIhandle_respond; +*bind = *FSSCGIc::SCGIhandle_bind; +*accept = *FSSCGIc::SCGIhandle_accept; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +# ------- VARIABLE STUBS -------- + +package FSSCGI; + +1; diff --git a/libs/libscgi/perl/Makefile b/libs/libscgi/perl/Makefile new file mode 100644 index 0000000000..3bce02368d --- /dev/null +++ b/libs/libscgi/perl/Makefile @@ -0,0 +1,38 @@ +PERL=$(shell which perl) +PERL_SITEDIR=$(shell perl -MConfig -e 'print $$Config{sitelibexp}') +PERL_LIBDIR=-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE +PERL_LIBS=$(shell perl -MConfig -e 'print $$Config{libs}') +LOCAL_CFLAGS=-w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL +LOCAL_LDFLAGS=$(shell $(PERL) -MExtUtils::Embed -e ldopts) $(shell $(PERL) -MConfig -e 'print $$Config{libs}') +GCC_WARNING_JUNK=-w +PERL_INC=$(shell $(PERL) -MExtUtils::Embed -e perl_inc) +all: FSSCGI.so + +scgi_wrap.cpp: + swig -module FSSCGI -shadow -perl5 -c++ -DMULTIPLICITY -I../src/include -o scgi_wrap.cpp ../FSSCGI.i + +perlxsi.c: + $(PERL) -MExtUtils::Embed -e xsinit -- -o perlxsi.c + +perlxsi.o: perlxsi.c + $(CC) $(CC_CFLAGS) $(CFLAGS) $(LOCAL_CFLAGS) -c perlxsi.c -o perlxsi.o + +scgi_wrap.o: scgi_wrap.cpp + $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(GCC_WARNING_JUNK) $(PERL_INC) -c scgi_wrap.cpp -o scgi_wrap.o + +FSSCGI.so: scgi_wrap.o perlxsi.o + $(CXX) $(SOLINK) scgi_wrap.o perlxsi.o $(MYLIB) $(LOCAL_LDFLAGS) -o FSSCGI.so -L. $(LIBS) + +clean: + rm -f *.o *.so *~ + +swigclean: + rm -f scgi_wrap.* FSSCGI.so FSSCGI.pm perlxsi.* + +reswig: swigclean scgi_wrap.cpp perlxsi.c + +install: FSSCGI.so + install -m 755 FSSCGI.so $(PERL_SITEDIR) + install -m 755 FSSCGI.pm $(PERL_SITEDIR) + install -d -m 755 FSSCGI $(PERL_SITEDIR)/FSSCGI + install -m 755 FSSCGI/* $(PERL_SITEDIR)/FSSCGI diff --git a/libs/libscgi/perl/esl_wrap.cpp b/libs/libscgi/perl/esl_wrap.cpp new file mode 100644 index 0000000000..832289f156 --- /dev/null +++ b/libs/libscgi/perl/esl_wrap.cpp @@ -0,0 +1,4149 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.35 + * + * 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 SWIGPERL +#define SWIG_CASTRANK_MODE + +#ifdef __cplusplus +template class SwigValueWrapper { + T *tt; +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); +}; + +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 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 + + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + 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'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and 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: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + 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 + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + 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. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + 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) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#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 +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* 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); +} + +/* Same as previous function, 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); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include +#include +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef SvPV_nolen +# define SvPV_nolen(x) SvPV(x,PL_na) +#endif + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + + +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to declare an XS function */ +#ifndef XSPROTO +# define XSPROTO(name) void name(pTHX_ CV* cv) +#endif + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC + +#else /* PERL_OBJECT */ + +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED + +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#else /* MULTIPLICITY */ + +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif /* MULTIPLICITY */ +#endif /* PERL_OBJECT */ + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + +/* + Define how strict is the cast between strings and integers/doubles + when overloading between these types occurs. + + The default is making it as strict as possible by using SWIG_AddCast + when needed. + + You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to + disable the SWIG_AddCast, making the casting between string and + numbers less strict. + + In the end, we try to solve the overloading between strings and + numerical types in the more natural way, but if you can avoid it, + well, avoid it using %rename, for example. +*/ +#ifndef SWIG_PERL_NO_STRICT_STR2NUM +# ifndef SWIG_PERL_STRICT_STR2NUM +# define SWIG_PERL_STRICT_STR2NUM +# endif +#endif +#ifdef SWIG_PERL_STRICT_STR2NUM +/* string takes precedence */ +#define SWIG_Str2NumCast(x) SWIG_AddCast(x) +#else +/* number takes precedence */ +#define SWIG_Str2NumCast(x) x +#endif + + + +#include + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV_nolen(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XSPROTO(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFunc) get; + mg->mg_virtual->svt_set = (SwigMagicFunc) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif + +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif +#ifdef seekdir + #undef seekdir +#endif +#ifdef open + #undef open +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_ESLconnection swig_types[0] +#define SWIGTYPE_p_ESLevent swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_esl_event_t swig_types[3] +#define SWIGTYPE_p_esl_priority_t swig_types[4] +static swig_type_info *swig_types[6]; +static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_ESL + +#define SWIG_name "ESLc::boot_ESL" +#define SWIG_prefix "ESLc::" + +#define SWIGVERSION 0x010335 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include + + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif + + +#include "esl.h" +#include "esl_oop.h" + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (carray) { + sv_setpvn(obj, carray, size); + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + double v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + long v; + errno = 0; + v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + + +SWIGINTERNINLINE SV * +SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value) +{ + return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value); +} + + +SWIGINTERNINLINE SV * +SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) +{ + SV *obj = sv_newmortal(); + if (value) { + sv_setsv(obj, &PL_sv_yes); + } else { + sv_setsv(obj, &PL_sv_no); + } + return obj; +} + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_ESL_var:: +class _wrap_ESL_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) { + MAGIC_PPERL + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif +XS(_wrap_ESLevent_event_set) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + esl_event_t *arg2 = (esl_event_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLevent_event_set(self,event);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_event_set" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_esl_event_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_event_set" "', argument " "2"" of type '" "esl_event_t *""'"); + } + arg2 = reinterpret_cast< esl_event_t * >(argp2); + if (arg1) (arg1)->event = arg2; + + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_event_get) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + esl_event_t *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_event_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_event_get" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (esl_event_t *) ((arg1)->event); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_esl_event_t, 0 | 0); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_serialized_string_set) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLevent_serialized_string_set(self,serialized_string);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_serialized_string_set" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialized_string_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (arg1->serialized_string) delete[] arg1->serialized_string; + if (arg2) { + size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1; + arg1->serialized_string = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size))); + } else { + arg1->serialized_string = 0; + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_serialized_string_get) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_serialized_string_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_serialized_string_get" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *) ((arg1)->serialized_string); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_mine_set) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLevent_mine_set(self,mine);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_mine_set" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ESLevent_mine_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + if (arg1) (arg1)->mine = arg2; + + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_mine_get) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_mine_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_mine_get" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (int) ((arg1)->mine); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLevent__SWIG_0) { + { + 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 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: new_ESLevent(type,subclass_name);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLevent" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + } + result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLevent__SWIG_1) { + { + 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 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: new_ESLevent(wrap_me,free_me);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_esl_event_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "esl_event_t *""'"); + } + arg1 = reinterpret_cast< esl_event_t * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLevent" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + result = (ESLevent *)new ESLevent(arg1,arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLevent__SWIG_2) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: new_ESLevent(me);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (ESLevent *)new ESLevent(arg1); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLevent) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if ((items >= 1) && (items <= 2)) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_esl_event_t, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (items > 1) { + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + } + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 1) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_ESLevent, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + if ((items >= 1) && (items <= 2)) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_3; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (items > 1) { + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_3; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + } + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 3; + if (_rank == _rankm) goto dispatch; + } + } + check_3: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLevent__SWIG_1); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLevent__SWIG_2); return; + case 3: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLevent__SWIG_0); return; + } + } + + croak("No matching function for overloaded 'new_ESLevent'"); + XSRETURN(0); +} + + +XS(_wrap_delete_ESLevent) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_ESLevent(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ESLevent" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + delete arg1; + + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_serialize) { + { + 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 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: ESLevent_serialize(self,format);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_serialize" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialize" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + } + result = (char *)(arg1)->serialize((char const *)arg2); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_setPriority) { + { + 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 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: ESLevent_setPriority(self,priority);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_setPriority" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + if (items > 1) { + { + res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_esl_priority_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_setPriority" "', argument " "2"" of type '" "esl_priority_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ESLevent_setPriority" "', argument " "2"" of type '" "esl_priority_t""'"); + } else { + arg2 = *(reinterpret_cast< esl_priority_t * >(argp2)); + } + } + } + result = (bool)(arg1)->setPriority(arg2); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_getHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) -1 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: ESLevent_getHeader(self,header_name,idx);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_getHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ESLevent_getHeader" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + result = (char *)(arg1)->getHeader((char const *)arg2,arg3); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_getBody) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_getBody(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_getBody" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->getBody(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_getType) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_getType(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_getType" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->getType(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_addBody) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLevent_addBody(self,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_addBody" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addBody" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)(arg1)->addBody((char const *)arg2); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_addHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: ESLevent_addHeader(self,header_name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_addHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_addHeader" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_pushHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: ESLevent_pushHeader(self,header_name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_pushHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_pushHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_pushHeader" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (bool)(arg1)->pushHeader((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_unshiftHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: ESLevent_unshiftHeader(self,header_name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_unshiftHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_unshiftHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_unshiftHeader" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (bool)(arg1)->unshiftHeader((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_delHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLevent_delHeader(self,header_name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_delHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_delHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)(arg1)->delHeader((char const *)arg2); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_firstHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_firstHeader(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_firstHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->firstHeader(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLevent_nextHeader) { + { + ESLevent *arg1 = (ESLevent *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLevent_nextHeader(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_nextHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + result = (char *)(arg1)->nextHeader(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_0) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: new_ESLconnection(host,port,user,password);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_1) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + ESLconnection *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: new_ESLconnection(host,port,password);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection__SWIG_2) { + { + int arg1 ; + ESLconnection *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: new_ESLconnection(socket);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + result = (ESLconnection *)new ESLconnection(arg1); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ESLconnection) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 1) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 3) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + if (items == 4) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_3; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_3; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_3; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_3; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 3; + if (_rank == _rankm) goto dispatch; + } + } + check_3: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_2); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_1); return; + case 3: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_0); return; + } + } + + croak("No matching function for overloaded 'new_ESLconnection'"); + XSRETURN(0); +} + + +XS(_wrap_delete_ESLconnection) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_ESLconnection(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ESLconnection" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + delete arg1; + + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_socketDescriptor) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_socketDescriptor(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_socketDescriptor" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->socketDescriptor(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_connected) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_connected(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_connected" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->connected(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_getInfo) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_getInfo(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_getInfo" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (ESLevent *)(arg1)->getInfo(); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_send) { + { + 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 argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLconnection_send(self,cmd);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_send" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_send" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->send((char const *)arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_sendRecv) { + { + 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 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLconnection_sendRecv(self,cmd);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_sendRecv" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendRecv" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (ESLevent *)(arg1)->sendRecv((char const *)arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_api) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: ESLconnection_api(self,cmd,arg);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_api" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_api" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_api" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_bgapi) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: ESLconnection_bgapi(self,cmd,arg,job_uuid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_bgapi" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_bgapi" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_bgapi" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_bgapi" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_sendEvent) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *arg2 = (ESLevent *) 0 ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLconnection_sendEvent(self,send_me);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_sendEvent" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendEvent" "', argument " "2"" of type '" "ESLevent *""'"); + } + arg2 = reinterpret_cast< ESLevent * >(argp2); + result = (ESLevent *)(arg1)->sendEvent(arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_sendMSG) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *arg2 = (ESLevent *) 0 ; + char *arg3 = (char *) NULL ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: ESLconnection_sendMSG(self,send_me,uuid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_sendMSG" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendMSG" "', argument " "2"" of type '" "ESLevent *""'"); + } + arg2 = reinterpret_cast< ESLevent * >(argp2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_sendMSG" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + result = (int)(arg1)->sendMSG(arg2,(char const *)arg3); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_recvEvent) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_recvEvent(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_recvEvent" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (ESLevent *)(arg1)->recvEvent(); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_recvEventTimed) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int arg2 ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLconnection_recvEventTimed(self,ms);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_recvEventTimed" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ESLconnection_recvEventTimed" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = (ESLevent *)(arg1)->recvEventTimed(arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_filter) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: ESLconnection_filter(self,header,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_filter" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_filter" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_events) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: ESLconnection_events(self,etype,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_events" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_events" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_events" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (int)(arg1)->events((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_execute) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: ESLconnection_execute(self,app,arg,uuid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_execute" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_execute" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_execute" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_execute" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (ESLevent *)(arg1)->execute((char const *)arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_executeAsync) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + ESLevent *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: ESLconnection_executeAsync(self,app,arg,uuid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_executeAsync" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_executeAsync" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_executeAsync" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_executeAsync" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (ESLevent *)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_setAsyncExecute) { + { + 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 argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLconnection_setAsyncExecute(self,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setAsyncExecute" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setAsyncExecute" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->setAsyncExecute((char const *)arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_setEventLock) { + { + 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 argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ESLconnection_setEventLock(self,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setEventLock" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setEventLock" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->setEventLock((char const *)arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_ESLconnection_disconnect) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_disconnect(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_disconnect" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->disconnect(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_eslSetLogLevel) { + { + int arg1 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: eslSetLogLevel(level);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "eslSetLogLevel" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + eslSetLogLevel(arg1); + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_ESLconnection = {"_p_ESLconnection", "ESLconnection *", 0, 0, (void*)"ESL::ESLconnection", 0}; +static swig_type_info _swigt__p_ESLevent = {"_p_ESLevent", "ESLevent *", 0, 0, (void*)"ESL::ESLevent", 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_esl_event_t = {"_p_esl_event_t", "esl_event_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_esl_priority_t = {"_p_esl_priority_t", "esl_priority_t *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_ESLconnection, + &_swigt__p_ESLevent, + &_swigt__p_char, + &_swigt__p_esl_event_t, + &_swigt__p_esl_priority_t, +}; + +static swig_cast_info _swigc__p_ESLconnection[] = { {&_swigt__p_ESLconnection, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ESLevent[] = { {&_swigt__p_ESLevent, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_esl_event_t[] = { {&_swigt__p_esl_event_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_esl_priority_t[] = { {&_swigt__p_esl_priority_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_ESLconnection, + _swigc__p_ESLevent, + _swigc__p_char, + _swigc__p_esl_event_t, + _swigc__p_esl_priority_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{"ESLc::ESLevent_event_set", _wrap_ESLevent_event_set}, +{"ESLc::ESLevent_event_get", _wrap_ESLevent_event_get}, +{"ESLc::ESLevent_serialized_string_set", _wrap_ESLevent_serialized_string_set}, +{"ESLc::ESLevent_serialized_string_get", _wrap_ESLevent_serialized_string_get}, +{"ESLc::ESLevent_mine_set", _wrap_ESLevent_mine_set}, +{"ESLc::ESLevent_mine_get", _wrap_ESLevent_mine_get}, +{"ESLc::new_ESLevent", _wrap_new_ESLevent}, +{"ESLc::delete_ESLevent", _wrap_delete_ESLevent}, +{"ESLc::ESLevent_serialize", _wrap_ESLevent_serialize}, +{"ESLc::ESLevent_setPriority", _wrap_ESLevent_setPriority}, +{"ESLc::ESLevent_getHeader", _wrap_ESLevent_getHeader}, +{"ESLc::ESLevent_getBody", _wrap_ESLevent_getBody}, +{"ESLc::ESLevent_getType", _wrap_ESLevent_getType}, +{"ESLc::ESLevent_addBody", _wrap_ESLevent_addBody}, +{"ESLc::ESLevent_addHeader", _wrap_ESLevent_addHeader}, +{"ESLc::ESLevent_pushHeader", _wrap_ESLevent_pushHeader}, +{"ESLc::ESLevent_unshiftHeader", _wrap_ESLevent_unshiftHeader}, +{"ESLc::ESLevent_delHeader", _wrap_ESLevent_delHeader}, +{"ESLc::ESLevent_firstHeader", _wrap_ESLevent_firstHeader}, +{"ESLc::ESLevent_nextHeader", _wrap_ESLevent_nextHeader}, +{"ESLc::new_ESLconnection", _wrap_new_ESLconnection}, +{"ESLc::delete_ESLconnection", _wrap_delete_ESLconnection}, +{"ESLc::ESLconnection_socketDescriptor", _wrap_ESLconnection_socketDescriptor}, +{"ESLc::ESLconnection_connected", _wrap_ESLconnection_connected}, +{"ESLc::ESLconnection_getInfo", _wrap_ESLconnection_getInfo}, +{"ESLc::ESLconnection_send", _wrap_ESLconnection_send}, +{"ESLc::ESLconnection_sendRecv", _wrap_ESLconnection_sendRecv}, +{"ESLc::ESLconnection_api", _wrap_ESLconnection_api}, +{"ESLc::ESLconnection_bgapi", _wrap_ESLconnection_bgapi}, +{"ESLc::ESLconnection_sendEvent", _wrap_ESLconnection_sendEvent}, +{"ESLc::ESLconnection_sendMSG", _wrap_ESLconnection_sendMSG}, +{"ESLc::ESLconnection_recvEvent", _wrap_ESLconnection_recvEvent}, +{"ESLc::ESLconnection_recvEventTimed", _wrap_ESLconnection_recvEventTimed}, +{"ESLc::ESLconnection_filter", _wrap_ESLconnection_filter}, +{"ESLc::ESLconnection_events", _wrap_ESLconnection_events}, +{"ESLc::ESLconnection_execute", _wrap_ESLconnection_execute}, +{"ESLc::ESLconnection_executeAsync", _wrap_ESLconnection_executeAsync}, +{"ESLc::ESLconnection_setAsyncExecute", _wrap_ESLconnection_setAsyncExecute}, +{"ESLc::ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock}, +{"ESLc::ESLconnection_disconnect", _wrap_ESLconnection_disconnect}, +{"ESLc::eslSetLogLevel", _wrap_eslSetLogLevel}, +{0,0} +}; +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + clientdata = clientdata; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + SWIG_TypeClientData(SWIGTYPE_p_ESLevent, (void*) "ESL::ESLevent"); + SWIG_TypeClientData(SWIGTYPE_p_ESLconnection, (void*) "ESL::ESLconnection"); + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/libs/libscgi/perl/perlxsi.c b/libs/libscgi/perl/perlxsi.c new file mode 100644 index 0000000000..9ca8fc1fb1 --- /dev/null +++ b/libs/libscgi/perl/perlxsi.c @@ -0,0 +1,16 @@ +#include +#include + +EXTERN_C void xs_init (pTHX); + +EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); + +EXTERN_C void +xs_init(pTHX) +{ + char *file = __FILE__; + dXSUB_SYS; + + /* DynaLoader is a special case */ + newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); +} diff --git a/libs/libscgi/perl/scgi_wrap.cpp b/libs/libscgi/perl/scgi_wrap.cpp new file mode 100644 index 0000000000..cc96e9494c --- /dev/null +++ b/libs/libscgi/perl/scgi_wrap.cpp @@ -0,0 +1,2539 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.35 + * + * 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 SWIGPERL +#define SWIG_CASTRANK_MODE + +#ifdef __cplusplus +template class SwigValueWrapper { + T *tt; +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); +}; + +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 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 + + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + 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'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and 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: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + 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 + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + 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. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + 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) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#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 +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* 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); +} + +/* Same as previous function, 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); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include +#include +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef SvPV_nolen +# define SvPV_nolen(x) SvPV(x,PL_na) +#endif + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + + +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to declare an XS function */ +#ifndef XSPROTO +# define XSPROTO(name) void name(pTHX_ CV* cv) +#endif + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC + +#else /* PERL_OBJECT */ + +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED + +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#else /* MULTIPLICITY */ + +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif /* MULTIPLICITY */ +#endif /* PERL_OBJECT */ + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + +/* + Define how strict is the cast between strings and integers/doubles + when overloading between these types occurs. + + The default is making it as strict as possible by using SWIG_AddCast + when needed. + + You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to + disable the SWIG_AddCast, making the casting between string and + numbers less strict. + + In the end, we try to solve the overloading between strings and + numerical types in the more natural way, but if you can avoid it, + well, avoid it using %rename, for example. +*/ +#ifndef SWIG_PERL_NO_STRICT_STR2NUM +# ifndef SWIG_PERL_STRICT_STR2NUM +# define SWIG_PERL_STRICT_STR2NUM +# endif +#endif +#ifdef SWIG_PERL_STRICT_STR2NUM +/* string takes precedence */ +#define SWIG_Str2NumCast(x) SWIG_AddCast(x) +#else +/* number takes precedence */ +#define SWIG_Str2NumCast(x) x +#endif + + + +#include + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV_nolen(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XSPROTO(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFunc) get; + mg->mg_virtual->svt_set = (SwigMagicFunc) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif + +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif +#ifdef seekdir + #undef seekdir +#endif +#ifdef open + #undef open +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_SCGIhandle swig_types[0] +#define SWIGTYPE_p_char swig_types[1] +static swig_type_info *swig_types[3]; +static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_FSSCGI + +#define SWIG_name "FSSCGIc::boot_FSSCGI" +#define SWIG_prefix "FSSCGIc::" + +#define SWIGVERSION 0x010335 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include + + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif + + +#include "scgi.h" +#include "scgi_oop.h" + + +SWIGINTERNINLINE SV * +SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value) +{ + return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value); +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (carray) { + sv_setpvn(obj, carray, size); + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + double v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + long v; + errno = 0; + v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_FSSCGI_var:: +class _wrap_FSSCGI_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) { + MAGIC_PPERL + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif +XS(_wrap_new_SCGIhandle) { + { + SCGIhandle *result = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: new_SCGIhandle();"); + } + result = (SCGIhandle *)new SCGIhandle(); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SCGIhandle, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_SCGIhandle) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_SCGIhandle(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SCGIhandle" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + delete arg1; + + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_connected) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SCGIhandle_connected(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_connected" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + result = (int)(arg1)->connected(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_socketDescriptor) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SCGIhandle_socketDescriptor(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_socketDescriptor" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + result = (int)(arg1)->socketDescriptor(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_disconnect) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SCGIhandle_disconnect(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_disconnect" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + result = (int)(arg1)->disconnect(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_addParam) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SCGIhandle_addParam(self,name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_addParam" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SCGIhandle_addParam" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "SCGIhandle_addParam" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (int)(arg1)->addParam((char const *)arg2,(char const *)arg3); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_addBody) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SCGIhandle_addBody(self,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_addBody" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SCGIhandle_addBody" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->addBody((char const *)arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_getBody) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SCGIhandle_getBody(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_getBody" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + result = (char *)(arg1)->getBody(); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_getParam) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SCGIhandle_getParam(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_getParam" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SCGIhandle_getParam" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (char *)(arg1)->getParam((char const *)arg2); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_sendRequest) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: SCGIhandle_sendRequest(self,host,port,timeout);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_sendRequest" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SCGIhandle_sendRequest" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SCGIhandle_sendRequest" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SCGIhandle_sendRequest" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + result = (char *)(arg1)->sendRequest((char const *)arg2,arg3,arg4); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_respond) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SCGIhandle_respond(self,msg);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_respond" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SCGIhandle_respond" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->respond(arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_bind) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SCGIhandle_bind(self,host,port);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_bind" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SCGIhandle_bind" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SCGIhandle_bind" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (int)(arg1)->bind((char const *)arg2,arg3); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SCGIhandle_accept) { + { + SCGIhandle *arg1 = (SCGIhandle *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SCGIhandle_accept(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SCGIhandle, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SCGIhandle_accept" "', argument " "1"" of type '" "SCGIhandle *""'"); + } + arg1 = reinterpret_cast< SCGIhandle * >(argp1); + result = (int)(arg1)->accept(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_SCGIhandle = {"_p_SCGIhandle", "SCGIhandle *", 0, 0, (void*)"FSSCGI::SCGIhandle", 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_SCGIhandle, + &_swigt__p_char, +}; + +static swig_cast_info _swigc__p_SCGIhandle[] = { {&_swigt__p_SCGIhandle, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_SCGIhandle, + _swigc__p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{"FSSCGIc::new_SCGIhandle", _wrap_new_SCGIhandle}, +{"FSSCGIc::delete_SCGIhandle", _wrap_delete_SCGIhandle}, +{"FSSCGIc::SCGIhandle_connected", _wrap_SCGIhandle_connected}, +{"FSSCGIc::SCGIhandle_socketDescriptor", _wrap_SCGIhandle_socketDescriptor}, +{"FSSCGIc::SCGIhandle_disconnect", _wrap_SCGIhandle_disconnect}, +{"FSSCGIc::SCGIhandle_addParam", _wrap_SCGIhandle_addParam}, +{"FSSCGIc::SCGIhandle_addBody", _wrap_SCGIhandle_addBody}, +{"FSSCGIc::SCGIhandle_getBody", _wrap_SCGIhandle_getBody}, +{"FSSCGIc::SCGIhandle_getParam", _wrap_SCGIhandle_getParam}, +{"FSSCGIc::SCGIhandle_sendRequest", _wrap_SCGIhandle_sendRequest}, +{"FSSCGIc::SCGIhandle_respond", _wrap_SCGIhandle_respond}, +{"FSSCGIc::SCGIhandle_bind", _wrap_SCGIhandle_bind}, +{"FSSCGIc::SCGIhandle_accept", _wrap_SCGIhandle_accept}, +{0,0} +}; +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + clientdata = clientdata; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + SWIG_TypeClientData(SWIGTYPE_p_SCGIhandle, (void*) "FSSCGI::SCGIhandle"); + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/libs/libscgi/perl/testclient.pl b/libs/libscgi/perl/testclient.pl new file mode 100644 index 0000000000..59415baf72 --- /dev/null +++ b/libs/libscgi/perl/testclient.pl @@ -0,0 +1,19 @@ +use FSSCGI; + + +my $handle = new FSSCGI::SCGIhandle(); + + $handle->addParam( "REQUEST_METHOD", "POST"); + $handle->addParam( "REQUEST_URI", "/deepthought"); + $handle->addParam( "TESTING", "TRUE"); + $handle->addParam( "TESTING", "TRUE"); + $handle->addBody("What is the answer to life?"); + + + +if ((my $response = $handle->sendRequest("127.0.0.1", 7777, 10000))) { + print "RESP[$response]\n"; +} else { + print "ERROR!\n"; +} + diff --git a/libs/libscgi/perl/testserver.pl b/libs/libscgi/perl/testserver.pl new file mode 100644 index 0000000000..6e03d5c5e4 --- /dev/null +++ b/libs/libscgi/perl/testserver.pl @@ -0,0 +1,17 @@ +use FSSCGI; + + +my $handle = new FSSCGI::SCGIhandle(); + +if ($handle->bind("127.0.0.1", 7777)) { + + while($handle->accept()) { + print "REQ: " . $handle->getBody(). "\n\n"; + $handle->respond("W00t!!!!!!\n"); + } + + print "DONE\n"; + +} else { + print "FAIL\n"; +} diff --git a/libs/libscgi/protocol.txt b/libs/libscgi/protocol.txt new file mode 100644 index 0000000000..34c128005f --- /dev/null +++ b/libs/libscgi/protocol.txt @@ -0,0 +1,101 @@ +SCGI: A Simple Common Gateway Interface alternative +Neil Schemenauer +2008-06-23 + +1. Introduction + + The SCGI protocol is a replacement for the Common Gateway Interface + (CGI) protocol. It is a standard for applications to interface with + HTTP servers. It is similar to FastCGI but is designed to be easier + to implement. + + In this document, a string of 8-bit bytes may be written in two + different forms: as a series of hexadecimal numbers between angle + brackets, or as a sequence of ASCII characters between double quotes. + For example, <68 65 6c 6c 6f 20 77 6f 72 6c 64 21> is a string of + length 12; it is the same as the string "hello world!". Note that + these notations are part of this document, not part of the protocol. + + +2. Protocol + + The client connects to a SCGI server over a reliable stream protocol + allowing transmission of 8-bit bytes. The client begins by sending a + request. See section 3 for the format of the request. When the SCGI + server sees the end of the request it sends back a response and closes + the connection. The format of the response is not specified by this + protocol. + + +3. Request Format + + A request consists of a number of headers and a body. The format of + the headers is: + + headers ::= header* + header ::= name NUL value NUL + name ::= notnull+ + value ::= notnull* + notnull ::= <01> | <02> | <03> | ... | + NUL = <00> + + Duplicate names are not allowed in the headers. The first header + must have the name "CONTENT_LENGTH" and a value that is a nonempty + sequence of ASCII digits giving the of the body length in decimal. + The "CONTENT_LENGTH" header must always be present, even if its + value is "0". There must also always be a header with the name + "SCGI" and a value of "1". In order to facilitate the transition + from CGI, standard CGI environment variables should be provided as + SCGI headers. + + The headers are sent encoded as a netstring. Netstring encoding is + explained in section 4. The body is sent following the headers and + its length is specified by the "CONTENT_LENGTH" header. + + +4. Netstrings + + Any string of 8-bit bytes may be encoded as [len]":"[string]",". Here + [string] is the string and [len] is a nonempty sequence of ASCII + digits giving the length of [string] in decimal. The ASCII digits are + <30> for 0, <31> for 1, and so on up through <39> for 9. Extra zeros + at the front of [len] are prohibited: [len] begins with <30> exactly + when [string] is empty. + + For example, the string "hello world!" is encoded as <31 32 3a 68 65 + 6c 6c 6f 20 77 6f 72 6c 64 21 2c>, i.e., "12:hello world!,". The empty + string is encoded as "0:,". + + [len]":"[string]"," is called a netstring. [string] is called the + interpretation of the netstring. + + +5. Example + + The web server (a SCGI client) opens a connection and sends the + concatenation of the following strings: + + "70:" + "CONTENT_LENGTH" <00> "27" <00> + "SCGI" <00> "1" <00> + "REQUEST_METHOD" <00> "POST" <00> + "REQUEST_URI" <00> "/deepthought" <00> + "," + "What is the answer to life?" + + The SCGI server sends the following response: + + "Status: 200 OK" <0d 0a> + "Content-Type: text/plain" <0d 0a> + "" <0d 0a> + "42" + + The SCGI server closes the connection. + + +6. Copyright + + This document has been placed in the public domain. + + +/* vim: set ai tw=74 et sw=4 sts=4: */ diff --git a/libs/libscgi/src/include/scgi.h b/libs/libscgi/src/include/scgi.h new file mode 100644 index 0000000000..575a45f7f9 --- /dev/null +++ b/libs/libscgi/src/include/scgi.h @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2012-2013, Anthony Minessale II + * 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 original 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. + */ + +#ifndef _SCGI_H_ +#define _SCGI_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* defined(__cplusplus) */ +#if EMACS_BUG +} +#endif + +#ifdef _MSC_VER +#define FD_SETSIZE 8192 +#define SCGI_USE_SELECT +#else +#define SCGI_USE_POLL +#endif + + + +#ifdef SCGI_USE_POLL +#include +#endif + +#ifdef WIN32 +#include +#include +typedef SOCKET scgi_socket_t; +typedef unsigned __int64 uint64_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int8 uint8_t; +typedef __int64 int64_t; +typedef __int32 int32_t; +typedef __int16 int16_t; +typedef __int8 int8_t; +typedef intptr_t scgi_ssize_t; +typedef int scgi_filehandle_t; +#define SCGI_SOCK_INVALID INVALID_SOCKET +#define strerror_r(num, buf, size) strerror_s(buf, size, num) +#if defined(SCGI_DECLARE_STATIC) +#define SCGI_DECLARE(type) type __stdcall +#define SCGI_DECLARE_NONSTD(type) type __cdecl +#define SCGI_DECLARE_DATA +#elif defined(SCGI_EXPORTS) +#define SCGI_DECLARE(type) __declspec(dllexport) type __stdcall +#define SCGI_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl +#define SCGI_DECLARE_DATA __declspec(dllexport) +#else +#define SCGI_DECLARE(type) __declspec(dllimport) type __stdcall +#define SCGI_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl +#define SCGI_DECLARE_DATA __declspec(dllimport) +#endif +#else +#define SCGI_DECLARE(type) type +#define SCGI_DECLARE_NONSTD(type) type +#define SCGI_DECLARE_DATA +#include +#include +#include +#include +#include +#include +#include +#define SCGI_SOCK_INVALID -1 +typedef int scgi_socket_t; +typedef ssize_t scgi_ssize_t; +typedef int scgi_filehandle_t; +#endif + + +#include +#ifndef WIN32 +#include +#endif + +#include +#include +#include +#include +#ifndef WIN32 +#include +#include +#include +#include +#include +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif +#include + +#if (_MSC_VER >= 1400) // VC8+ +#define scgi_assert(expr) assert(expr);__analysis_assume( expr ) +#endif + +#ifndef scgi_assert +#define scgi_assert(_x) assert(_x) +#endif + +#define scgi_safe_free(_x) if (_x) free(_x); _x = NULL +#define scgi_strlen_zero(s) (!s || *(s) == '\0') +#define scgi_strlen_zero_buf(s) (*(s) == '\0') +#define end_of(_s) *(*_s == '\0' ? _s : _s + strlen(_s) - 1) +#define end_of_p(_s) (*_s == '\0' ? _s : _s + strlen(_s) - 1) + +typedef enum { + SCGI_POLL_READ = (1 << 0), + SCGI_POLL_WRITE = (1 << 1), + SCGI_POLL_ERROR = (1 << 2) +} scgi_poll_t; + + +typedef struct scgi_param_s { + char *name; + char *value; + struct scgi_param_s *next; +} scgi_param_t; + +typedef struct scgi_handle_s { + scgi_param_t *params; + char *body; + struct sockaddr_in sockaddr; + struct hostent hostent; + char hostbuf[256]; + scgi_socket_t sock; + char err[256]; + int errnum; + int connected; + struct sockaddr_in addr; + int destroyed; +} scgi_handle_t; + + +typedef int16_t scgi_port_t; +typedef size_t scgi_size_t; + +typedef enum { + SCGI_SUCCESS, + SCGI_FAIL, + SCGI_BREAK, + SCGI_DISCONNECTED, + SCGI_GENERR +} scgi_status_t; + +typedef void (*scgi_listen_callback_t)(scgi_socket_t server_sock, scgi_socket_t *client_sock, struct sockaddr_in *addr); + +SCGI_DECLARE(scgi_status_t) scgi_connect(scgi_handle_t *handle, const char *host, scgi_port_t port, uint32_t timeout); +SCGI_DECLARE(scgi_status_t) scgi_disconnect(scgi_handle_t *handle); +SCGI_DECLARE(scgi_status_t) scgi_parse(scgi_socket_t sock, scgi_handle_t *handle); +SCGI_DECLARE(int) scgi_wait_sock(scgi_socket_t sock, uint32_t ms, scgi_poll_t flags); +SCGI_DECLARE(ssize_t) scgi_recv(scgi_handle_t *handle, unsigned char *buf, size_t buflen); +SCGI_DECLARE(scgi_status_t) scgi_send_request(scgi_handle_t *handle); +SCGI_DECLARE(scgi_status_t) scgi_add_param(scgi_handle_t *handle, const char *name, const char *value); +SCGI_DECLARE(scgi_status_t) scgi_add_body(scgi_handle_t *handle, const char *value); +SCGI_DECLARE(size_t) scgi_build_message(scgi_handle_t *handle, char **buffer); +SCGI_DECLARE(scgi_status_t) scgi_destroy_params(scgi_handle_t *handle); +SCGI_DECLARE(scgi_status_t) scgi_listen(const char *host, scgi_port_t port, scgi_listen_callback_t callback); +SCGI_DECLARE(const char *) scgi_get_body(scgi_handle_t *handle); +SCGI_DECLARE(const char *) scgi_get_param(scgi_handle_t *handle, const char *name); +SCGI_DECLARE(scgi_status_t) scgi_bind(const char *host, scgi_port_t port, scgi_socket_t *socketp); +SCGI_DECLARE(scgi_status_t) scgi_accept(scgi_socket_t server_sock, scgi_socket_t *client_sock_p, struct sockaddr_in *echoClntAddr); + +#ifndef WIN32 +#define closesocket(x) close(x) +#endif + +#ifdef __cplusplus +} +#endif /* defined(__cplusplus) */ + + +#endif /* defined(_SCGI_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: + */ diff --git a/libs/libscgi/src/include/scgi_oop.h b/libs/libscgi/src/include/scgi_oop.h new file mode 100644 index 0000000000..64f3267779 --- /dev/null +++ b/libs/libscgi/src/include/scgi_oop.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2007-2012, Anthony Minessale II + * 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 original 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. + */ + +#ifndef _SCGI_OOP_H_ +#define _SCGI_OOP_H_ +#include +#ifdef __cplusplus +extern "C" { +#endif + +#define this_check(x) do { if (!this) { scgi_log(SCGI_LOG_ERROR, "object is not initalized\n"); return x;}} while(0) +#define this_check_void() do { if (!this) { scgi_log(SCGI_LOG_ERROR, "object is not initalized\n"); return;}} while(0) + + + +class SCGIhandle { + private: + scgi_socket_t server_sock; + scgi_handle_t handle; + unsigned char buf[65536]; + char *data_buf; + int buflen; + int bufsize; + public: + SCGIhandle(); + virtual ~SCGIhandle(); + int connected(); + int socketDescriptor(); + int disconnect(void); + int addParam(const char *name, const char *value); + int addBody(const char *value); + char *getBody(); + char *getParam(const char *name); + char *sendRequest(const char *host, int port, int timeout); + int respond(char *msg); + int bind(const char *host, int port); + int accept(void); +}; + + + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/libscgi/src/scgi.c b/libs/libscgi/src/scgi.c new file mode 100644 index 0000000000..d0eeab5203 --- /dev/null +++ b/libs/libscgi/src/scgi.c @@ -0,0 +1,739 @@ +/* + * Copyright (c) 2012-2013, Anthony Minessale II + * 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 original 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 + +#ifndef WIN32 +#include +#include +#else +#pragma warning (disable:6386) +/* These warnings need to be ignored warning in sdk header */ +#include +#include +#ifndef errno +#define errno WSAGetLastError() +#endif +#ifndef EINTR +#define EINTR WSAEINTR +#endif +#pragma warning (default:6386) +#endif + +static scgi_status_t scgi_push_param(scgi_handle_t *handle, const char *name, const char *value); + +static int sock_setup(scgi_handle_t *handle) +{ + + if (handle->sock == SCGI_SOCK_INVALID) { + return SCGI_FAIL; + } + +#ifdef WIN32 + { + BOOL bOptVal = TRUE; + int bOptLen = sizeof(BOOL); + setsockopt(handle->sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&bOptVal, bOptLen); + } +#else + { + int x = 1; + setsockopt(handle->sock, IPPROTO_TCP, TCP_NODELAY, &x, sizeof(x)); + } +#endif + + return SCGI_SUCCESS; +} + + +SCGI_DECLARE(size_t) scgi_build_message(scgi_handle_t *handle, char **bufferp) +{ + scgi_param_t *pp; + size_t len = 0, plen = 0, ctlen = 0; + char *s, *bp; + char *buffer = NULL; + char tmp[128] = ""; + + scgi_push_param(handle, "SCGI", "1"); + + if (handle->body) { + ctlen = strlen(handle->body); + } + + snprintf(tmp, sizeof(tmp), "%d", (int)ctlen); + + scgi_push_param(handle, "CONTENT_LENGTH", tmp); + + + for(pp = handle->params; pp; pp = pp->next) { + plen += (strlen(pp->name) + strlen(pp->value) + 2); + } + + snprintf(tmp, sizeof(tmp), "%d", (int) (plen + ctlen)); + + len = plen + ctlen + strlen(tmp) + 2; + + buffer = malloc(len); + memset(buffer, 0, len); + + snprintf(buffer, len, "%d:", (int)plen); + bp = buffer + strlen(buffer); + + for(pp = handle->params; pp; pp = pp->next) { + + for (s = pp->name; s && *s; s++) { + *bp++ = *s; + } + + *bp++ = '\0'; + + for (s = pp->value; s && *s; s++) { + *bp++ = *s; + } + + *bp++ = '\0'; + } + + *bp++ = ','; + + if (handle->body) { + for (s = handle->body; s && *s; s++) { + *bp++ = *s; + } + } + + *bufferp = buffer; + + return len; +} + +SCGI_DECLARE(scgi_status_t) scgi_destroy_params(scgi_handle_t *handle) +{ + scgi_param_t *param, *pp; + + pp = handle->params; + + while(pp) { + param = pp; + pp = pp->next; + + free(param->name); + free(param->value); + free(param); + } + + handle->params = NULL; + + return SCGI_SUCCESS; +} + +SCGI_DECLARE(scgi_status_t) scgi_add_body(scgi_handle_t *handle, const char *value) +{ + handle->body = strdup(value); + + return SCGI_SUCCESS; +} + +SCGI_DECLARE(const char *) scgi_get_body(scgi_handle_t *handle) +{ + return handle->body; +} + +SCGI_DECLARE(scgi_status_t) scgi_add_param(scgi_handle_t *handle, const char *name, const char *value) +{ + scgi_param_t *param, *pp; + + for(pp = handle->params; pp && pp->next; pp = pp->next) { + if (!strcasecmp(pp->name, name)) { + return SCGI_FAIL; + } + } + + param = malloc(sizeof(*param)); + memset(param, 0, sizeof(*param)); + + param->name = strdup(name); + param->value = strdup(value); + + if (!pp) { + handle->params = param; + } else { + pp->next = param; + } + + return SCGI_SUCCESS; +} + +SCGI_DECLARE(const char *) scgi_get_param(scgi_handle_t *handle, const char *name) +{ + scgi_param_t *pp; + + for(pp = handle->params; pp; pp = pp->next) { + if (!strcasecmp(pp->name, name)) { + return pp->value; + } + } + + return NULL; +} + +static scgi_status_t scgi_push_param(scgi_handle_t *handle, const char *name, const char *value) +{ + scgi_param_t *param; + + param = malloc(sizeof(*param)); + memset(param, 0, sizeof(*param)); + + param->name = strdup(name); + param->value = strdup(value); + + param->next = handle->params; + handle->params = param; + + return SCGI_SUCCESS; +} + +SCGI_DECLARE(scgi_status_t) scgi_send_request(scgi_handle_t *handle) +{ + scgi_status_t status = SCGI_SUCCESS; + char *buffer = NULL; + size_t bytes = 0; + ssize_t sent = 0; + + if (handle->connected != 1) { + return SCGI_FAIL; + } + + bytes = scgi_build_message(handle, &buffer); + sent = send(handle->sock, buffer, bytes, 0); + + if (sent <= 0) { + handle->connected = -1; + } + + scgi_safe_free(buffer); + + return status; +} + + +SCGI_DECLARE(ssize_t) scgi_recv(scgi_handle_t *handle, unsigned char *buf, size_t buflen) +{ + ssize_t recvd; + + if (handle->connected != 1) { + return -1; + } + + recvd = recv(handle->sock, buf, buflen, 0); + + if (recvd == 0) { + handle->connected = -1; + } + + + return recvd; +} + +SCGI_DECLARE(scgi_status_t) scgi_connect(scgi_handle_t *handle, const char *host, scgi_port_t port, uint32_t timeout) +{ + int rval = 0; + + struct addrinfo hints = { 0 }, *result; +#ifndef WIN32 + int fd_flags = 0; +#else + WORD wVersionRequested = MAKEWORD(2, 0); + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + snprintf(handle->err, sizeof(handle->err), "WSAStartup Error"); + return SCGI_FAIL; + } + +#endif + + handle->sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + + if (handle->sock == SCGI_SOCK_INVALID) { + snprintf(handle->err, sizeof(handle->err), "Socket Error"); + return SCGI_FAIL; + } + + + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + + if (getaddrinfo(host, NULL, &hints, &result)) { + strncpy(handle->err, "Cannot resolve host", sizeof(handle->err)); + goto fail; + } + + memcpy(&handle->sockaddr, result->ai_addr, sizeof(handle->sockaddr)); + handle->sockaddr.sin_family = AF_INET; + handle->sockaddr.sin_port = htons(port); + freeaddrinfo(result); + + if (timeout) { +#ifdef WIN32 + u_long arg = 1; + if (ioctlsocket(handle->sock, FIONBIO, &arg) == SOCKET_ERROR) { + snprintf(handle->err, sizeof(handle->err), "Socket Connection Error"); + goto fail; + } +#else + fd_flags = fcntl(handle->sock, F_GETFL, 0); + if (fcntl(handle->sock, F_SETFL, fd_flags | O_NONBLOCK)) { + snprintf(handle->err, sizeof(handle->err), "Socket Connection Error"); + goto fail; + } +#endif + } + + rval = connect(handle->sock, (struct sockaddr*)&handle->sockaddr, sizeof(handle->sockaddr)); + + if (timeout) { + int r; + + + r = scgi_wait_sock(handle->sock, timeout, SCGI_POLL_WRITE); + + if (r <= 0) { + snprintf(handle->err, sizeof(handle->err), "Connection timed out"); + goto fail; + } + + if (!(r & SCGI_POLL_WRITE)) { + snprintf(handle->err, sizeof(handle->err), "Connection timed out"); + goto fail; + } + +#ifdef WIN32 + { + u_long arg = 0; + if (ioctlsocket(handle->sock, FIONBIO, &arg) == SOCKET_ERROR) { + snprintf(handle->err, sizeof(handle->err), "Socket Connection Error"); + goto fail; + } + } +#else + fcntl(handle->sock, F_SETFL, fd_flags); +#endif + rval = 0; + } + + result = NULL; + + if (rval) { + snprintf(handle->err, sizeof(handle->err), "Socket Connection Error"); + goto fail; + } + + sock_setup(handle); + + handle->connected = 1; + + + return SCGI_SUCCESS; + + fail: + + handle->connected = 0; + scgi_disconnect(handle); + + return SCGI_FAIL; +} + + + +SCGI_DECLARE(scgi_status_t) scgi_disconnect(scgi_handle_t *handle) +{ + scgi_status_t status = SCGI_FAIL; + + if (handle->destroyed) { + return SCGI_FAIL; + } + + if (handle->sock != SCGI_SOCK_INVALID) { + closesocket(handle->sock); + handle->sock = SCGI_SOCK_INVALID; + status = SCGI_SUCCESS; + } + + handle->destroyed = 1; + handle->connected = 0; + + scgi_destroy_params(handle); + scgi_safe_free(handle->body); + + return status; +} + + +/* USE WSAPoll on vista or higher */ +#ifdef SCGI_USE_WSAPOLL +SCGI_DECLARE(int) scgi_wait_sock(scgi_socket_t sock, uint32_t ms, scgi_poll_t flags) +{ +} +#endif + + +#ifdef SCGI_USE_SELECT +#ifdef WIN32 +#pragma warning( push ) +#pragma warning( disable : 6262 ) /* warning C6262: Function uses '98348' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap */ +#endif +SCGI_DECLARE(int) scgi_wait_sock(scgi_socket_t sock, uint32_t ms, scgi_poll_t flags) +{ + int s = 0, r = 0; + fd_set rfds; + fd_set wfds; + fd_set efds; + struct timeval tv; + + FD_ZERO(&rfds); + FD_ZERO(&wfds); + FD_ZERO(&efds); + +#ifndef WIN32 + /* Wouldn't you rather know?? */ + assert(sock <= FD_SETSIZE); +#endif + + if ((flags & SCGI_POLL_READ)) { + +#ifdef WIN32 +#pragma warning( push ) +#pragma warning( disable : 4127 ) + FD_SET(sock, &rfds); +#pragma warning( pop ) +#else + FD_SET(sock, &rfds); +#endif + } + + if ((flags & SCGI_POLL_WRITE)) { + +#ifdef WIN32 +#pragma warning( push ) +#pragma warning( disable : 4127 ) + FD_SET(sock, &wfds); +#pragma warning( pop ) +#else + FD_SET(sock, &wfds); +#endif + } + + if ((flags & SCGI_POLL_ERROR)) { + +#ifdef WIN32 +#pragma warning( push ) +#pragma warning( disable : 4127 ) + FD_SET(sock, &efds); +#pragma warning( pop ) +#else + FD_SET(sock, &efds); +#endif + } + + tv.tv_sec = ms / 1000; + tv.tv_usec = (ms % 1000) * ms; + + s = select(sock + 1, (flags & SCGI_POLL_READ) ? &rfds : NULL, (flags & SCGI_POLL_WRITE) ? &wfds : NULL, (flags & SCGI_POLL_ERROR) ? &efds : NULL, &tv); + + if (s < 0) { + r = s; + } else if (s > 0) { + if ((flags & SCGI_POLL_READ) && FD_ISSET(sock, &rfds)) { + r |= SCGI_POLL_READ; + } + + if ((flags & SCGI_POLL_WRITE) && FD_ISSET(sock, &wfds)) { + r |= SCGI_POLL_WRITE; + } + + if ((flags & SCGI_POLL_ERROR) && FD_ISSET(sock, &efds)) { + r |= SCGI_POLL_ERROR; + } + } + + return r; + +} +#ifdef WIN32 +#pragma warning( pop ) +#endif +#endif + +#ifdef SCGI_USE_POLL +SCGI_DECLARE(int) scgi_wait_sock(scgi_socket_t sock, uint32_t ms, scgi_poll_t flags) +{ + struct pollfd pfds[2] = { { 0 } }; + int s = 0, r = 0; + + pfds[0].fd = sock; + + if ((flags & SCGI_POLL_READ)) { + pfds[0].events |= POLLIN; + } + + if ((flags & SCGI_POLL_WRITE)) { + pfds[0].events |= POLLOUT; + } + + if ((flags & SCGI_POLL_ERROR)) { + pfds[0].events |= POLLERR; + } + + s = poll(pfds, 1, ms); + + if (s < 0) { + r = s; + } else if (s > 0) { + if ((pfds[0].revents & POLLIN)) { + r |= SCGI_POLL_READ; + } + if ((pfds[0].revents & POLLOUT)) { + r |= SCGI_POLL_WRITE; + } + if ((pfds[0].revents & POLLERR)) { + r |= SCGI_POLL_ERROR; + } + } + + return r; + +} +#endif + +static int scgi_socket_reuseaddr(scgi_socket_t socket) +{ +#ifdef WIN32 + BOOL reuse_addr = TRUE; + return setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse_addr, sizeof(reuse_addr)); +#else + int reuse_addr = 1; + return setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr)); +#endif +} + +SCGI_DECLARE(scgi_status_t) scgi_bind(const char *host, scgi_port_t port, scgi_socket_t *socketp) +{ + scgi_socket_t server_sock = SCGI_SOCK_INVALID; + struct sockaddr_in addr; + scgi_status_t status = SCGI_SUCCESS; + + if ((server_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + return SCGI_FAIL; + } + + scgi_socket_reuseaddr(server_sock); + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = htonl(INADDR_ANY); + addr.sin_port = htons(port); + + if (bind(server_sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + status = SCGI_FAIL; + goto end; + } + + if (listen(server_sock, 10000) < 0) { + status = SCGI_FAIL; + goto end; + } + + end: + + if (status == SCGI_FAIL) { + if (server_sock != SCGI_SOCK_INVALID) { + closesocket(server_sock); + server_sock = SCGI_SOCK_INVALID; + } + } else { + *socketp = server_sock; + } + + return status; +} + +SCGI_DECLARE(scgi_status_t) scgi_accept(scgi_socket_t server_sock, scgi_socket_t *client_sock_p, struct sockaddr_in *echoClntAddr) +{ + scgi_status_t status = SCGI_SUCCESS; + int client_sock; + struct sockaddr_in local_echoClntAddr; +#ifdef WIN32 + int clntLen; +#else + unsigned int clntLen; +#endif + + if (!echoClntAddr) { + echoClntAddr = &local_echoClntAddr; + } + + clntLen = sizeof(*echoClntAddr); + + if ((client_sock = accept(server_sock, (struct sockaddr *) echoClntAddr, &clntLen)) == SCGI_SOCK_INVALID) { + //printf("FRICK %s\n", strerror(errno)); + status = SCGI_FAIL; + } else { + *client_sock_p = client_sock; + } + + return status; +} + +SCGI_DECLARE(scgi_status_t) scgi_listen(const char *host, scgi_port_t port, scgi_listen_callback_t callback) +{ + + scgi_socket_t server_sock = SCGI_SOCK_INVALID, client_sock = SCGI_SOCK_INVALID; + scgi_status_t status = SCGI_FAIL; + struct sockaddr_in echoClntAddr; + + if ((status = scgi_bind(host, port, &server_sock)) == SCGI_SUCCESS) { + + while(scgi_accept(server_sock, &client_sock, &echoClntAddr) == SCGI_SUCCESS) { + callback(server_sock, &client_sock, &echoClntAddr); + + if (client_sock != SCGI_SOCK_INVALID) { + closesocket(client_sock); + client_sock = SCGI_SOCK_INVALID; + } + } + } + + return status; + +} + +#define next_str(_e, _s) _s = _e; while(*_s) _s++; _s++ + +SCGI_DECLARE(scgi_status_t) scgi_parse(scgi_socket_t sock, scgi_handle_t *handle) +{ + char sbuf[128] = ""; + char *p = sbuf, *e, *end; + ssize_t r = 0; + scgi_status_t status = SCGI_FAIL; + ssize_t bytes = 0; + char *headers = NULL; + int loops = 0; + ssize_t clen = 0; + char *body = NULL; + char comma = 0; + + memset(handle, 0, sizeof(*handle)); + + handle->sock = sock; + + handle->connected = 1; + sock_setup(handle); + + for(;;) { + + if ((r = recv(sock, p, 1, 0)) < 1) { + break; + } + + if (*p == ':') { + *p = '\0'; + break; + } + p++; + } + + if (r <= 0) goto end; + + bytes = atoi(sbuf); + + if (bytes <= 0) goto end; + + headers = malloc(bytes); + r = recv(sock, headers, bytes, 0); + if (r <= 0) goto end; + + r = recv(sock, &comma, 1, 0); + if (r <= 0 || comma != ',') goto end; + + + p = headers; + end = p + bytes; + e = NULL; + + while(p < end) { + next_str(p, e); + + if (!e) break; + + if (!loops++) { + if (!strcasecmp(p, "CONTENT_LENGTH") && e) { + clen = atoi(e); + if (clen) { + body = malloc(clen+1); + r = recv(sock, body, clen, 0); + *(body + clen) = '\0'; + if (r <= 0) goto end; + scgi_add_body(handle, body); + scgi_safe_free(body); + } + + status = SCGI_SUCCESS; + + } else { + goto end; + } + } + + scgi_add_param(handle, p, e); + next_str(e, p); + } + + end: + + scgi_safe_free(headers); + + return status; +} + + +/* 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: + */ diff --git a/libs/libscgi/src/scgi_oop.cpp b/libs/libscgi/src/scgi_oop.cpp new file mode 100644 index 0000000000..4001b748a3 --- /dev/null +++ b/libs/libscgi/src/scgi_oop.cpp @@ -0,0 +1,127 @@ +#include +#include + +#define connection_construct_common() memset(&handle, 0, sizeof(handle)) + + + +SCGIhandle::SCGIhandle(void) +{ + connection_construct_common(); +} + +SCGIhandle::~SCGIhandle() +{ + + scgi_disconnect(&handle); + scgi_safe_free(data_buf); + buflen = 0; + bufsize = 0; + +} + +int SCGIhandle::socketDescriptor() +{ + if (handle.connected) { + return (int) handle.sock; + } + + return -1; +} + + +int SCGIhandle::disconnect() +{ + return scgi_disconnect(&handle); +} + +int SCGIhandle::connected() +{ + return handle.connected; +} + +int SCGIhandle::addParam(const char *name, const char *value) +{ + return (int) scgi_add_param(&handle, name, value); +} + +int SCGIhandle::addBody(const char *value) +{ + return (int) scgi_add_body(&handle, value); +} + +char *SCGIhandle::getBody() +{ + return handle.body; +} + +char *SCGIhandle::getParam(const char *name) +{ + return (char *) scgi_get_param(&handle, name); +} + +char *SCGIhandle::sendRequest(const char *host, int port, int timeout) +{ + ssize_t len; + + if (!host) { + return 0; + } + + if (timeout < 1000) { + timeout = 1000; + } + + if (scgi_connect(&handle, host, port, timeout) == SCGI_SUCCESS) { + if (scgi_send_request(&handle) == SCGI_SUCCESS) { + while((len = scgi_recv(&handle, buf, sizeof(buf))) > 0) { + if (buflen + len > bufsize) { + bufsize = buflen + len + 1024; + void *tmp = realloc(data_buf, bufsize); + assert(tmp); + data_buf = (char *)tmp; + + *(data_buf+buflen) = '\0'; + } + snprintf(data_buf+buflen, bufsize-buflen, "%s", buf); + buflen += len; + } + + return data_buf; + } + } + + return (char *) ""; +} + +int SCGIhandle::bind(const char *host, int port) +{ + return (scgi_bind(host, port, &server_sock) == SCGI_SUCCESS) ? 1 : 0; +} + + +int SCGIhandle::accept(void) +{ + scgi_socket_t client_sock; + + if (scgi_accept(server_sock, &client_sock, NULL) == SCGI_SUCCESS) { + if (scgi_parse(client_sock, &handle) == SCGI_SUCCESS) { + return 1; + } + + closesocket(client_sock); + } + + return 0; +} + + +int SCGIhandle::respond(char *msg) +{ + int b = write(handle.sock, msg, strlen(msg)); + scgi_disconnect(&handle); + scgi_safe_free(data_buf); + buflen = 0; + bufsize = 0; + return b; +} diff --git a/libs/libscgi/testclient.c b/libs/libscgi/testclient.c new file mode 100644 index 0000000000..9b9078691c --- /dev/null +++ b/libs/libscgi/testclient.c @@ -0,0 +1,40 @@ +#include + + +int main(int argc, char *argv[]) +{ + char buf[16336] = ""; + ssize_t len; + scgi_handle_t handle = { 0 }; + char *ip; + int port = 0; + + if (argc < 2) { + fprintf(stderr, "usage: testclient \n"); + exit(-1); + } + + ip = argv[1]; + port = atoi(argv[2]); + + + + scgi_add_param(&handle, "REQUEST_METHOD", "POST"); + scgi_add_param(&handle, "REQUEST_URI", "/deepthought"); + scgi_add_param(&handle, "TESTING", "TRUE"); + scgi_add_param(&handle, "TESTING", "TRUE"); + scgi_add_body(&handle, "What is the answer to life?"); + + + scgi_connect(&handle, ip, port, 10000); + + scgi_send_request(&handle); + + + while((len = scgi_recv(&handle, buf, sizeof(buf))) > 0) { + printf("READ [%s]\n", buf); + } + + scgi_disconnect(&handle); + +} diff --git a/libs/libscgi/testserver.c b/libs/libscgi/testserver.c new file mode 100644 index 0000000000..153a215c0e --- /dev/null +++ b/libs/libscgi/testserver.c @@ -0,0 +1,43 @@ +#include + +static void callback(scgi_socket_t server_sock, scgi_socket_t *client_sock, struct sockaddr_in *addr) +{ + scgi_handle_t handle = { 0 }; + + if (scgi_parse(*client_sock, &handle) == SCGI_SUCCESS) { + scgi_param_t *pp; + + *client_sock = SCGI_SOCK_INVALID; + + for(pp = handle.params; pp; pp = pp->next) { + printf("HEADER: [%s] VALUE: [%s]\n", pp->name, pp->value); + } + + if (handle.body) { + printf("\n\nBODY:\n%s\n\n", handle.body); + } + + scgi_disconnect(&handle); + } + +} + +int main(int argc, char *argv[]) +{ + char *ip; + int port = 0; + + if (argc < 2) { + fprintf(stderr, "usage: testserver \n"); + exit(-1); + } + + ip = argv[1]; + port = atoi(argv[2]); + + + scgi_listen(ip, port, callback); + + + +} diff --git a/libs/libteletone/src/libteletone.h b/libs/libteletone/src/libteletone.h index 61078b4984..026f10141b 100644 --- a/libs/libteletone/src/libteletone.h +++ b/libs/libteletone/src/libteletone.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libteletone/src/libteletone_detect.h b/libs/libteletone/src/libteletone_detect.h index 4da368969c..b4b70fcd92 100644 --- a/libs/libteletone/src/libteletone_detect.h +++ b/libs/libteletone/src/libteletone_detect.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libteletone/src/libteletone_generate.h b/libs/libteletone/src/libteletone_generate.h index 0ff39e0dfa..a49e45a658 100644 --- a/libs/libteletone/src/libteletone_generate.h +++ b/libs/libteletone/src/libteletone_generate.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/libs/libwebsockets/.gitignore b/libs/libwebsockets/.gitignore new file mode 100644 index 0000000000..5431dbcc9e --- /dev/null +++ b/libs/libwebsockets/.gitignore @@ -0,0 +1,16 @@ +output/ +win32port/ipch/ +win32port/Debug*/ +win32port/Release*/ +win32port/server/Debug*/ +win32port/server/Release*/ +win32port/client/Debug*/ +win32port/client/Release*/ +win32port/libwebsocketswin32/Debug*/ +win32port/libwebsocketswin32/Release*/ +win32port/zlib/Debug*/ +win32port/zlib/Release*/ +*.vcxproj.user +*.opensdf +*.sdf +*.suo diff --git a/libs/libwebsockets/.update b/libs/libwebsockets/.update new file mode 100644 index 0000000000..b80af12cbe --- /dev/null +++ b/libs/libwebsockets/.update @@ -0,0 +1 @@ +Mon Aug 13 14:34:46 CDT 2012 diff --git a/libs/libwebsockets/AUTHORS b/libs/libwebsockets/AUTHORS new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/COPYING b/libs/libwebsockets/COPYING new file mode 100644 index 0000000000..a134777643 --- /dev/null +++ b/libs/libwebsockets/COPYING @@ -0,0 +1,503 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 the Free Software Foundation; either + version 2.1 of the License. + + This library 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 library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + diff --git a/libs/libwebsockets/ChangeLog b/libs/libwebsockets/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/INSTALL b/libs/libwebsockets/INSTALL new file mode 100644 index 0000000000..7d1c323bea --- /dev/null +++ b/libs/libwebsockets/INSTALL @@ -0,0 +1,365 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 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. + + 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 bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /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/libwebsockets/Makefile.am b/libs/libwebsockets/Makefile.am new file mode 100644 index 0000000000..dec9704f49 --- /dev/null +++ b/libs/libwebsockets/Makefile.am @@ -0,0 +1,2 @@ + +SUBDIRS=lib test-server diff --git a/libs/libwebsockets/NEWS b/libs/libwebsockets/NEWS new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/README b/libs/libwebsockets/README new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/README-test-server b/libs/libwebsockets/README-test-server new file mode 100644 index 0000000000..e2e0116015 --- /dev/null +++ b/libs/libwebsockets/README-test-server @@ -0,0 +1,292 @@ +Using test-server as a quickstart +--------------------------------- + +You need to regenerate the autotools and libtoolize stuff for your system + +$ autoreconf +$ libtoolize + +Then for a Fedora x86_86 box, the following config line was +needed: + + ./configure --prefix=/usr --libdir=/usr/lib64 --enable-openssl + +For Apple systems, Christopher Baker reported that this is needed +(and I was told separately enabling openssl makes trouble somehow) + +./configure CC="gcc -arch i386 -arch x86_64" CXX="g++ -arch i386 -arch +x86_64" CPP="gcc -E" CXXCPP="g++ -E" --enable-nofork + +For mingw build, I did the following to get working build, ping test is +disabled when building this way + +1) install mingw64_w32 compiler packages from Fedora +2) additionally install mingw64-zlib package +3) ./configure --prefix=/usr --enable-mingw --host=x86_64-w64-mingw32 +4) make + +otherwise if /usr/local/... and /usr/local/lib are OK then... + +$ ./configure +$ make clean +$ make +$ sudo make install +$ libwebsockets-test-server + +should be enough to get a test server listening on port 7861. + +There are a couple of other possible configure options + +--enable-nofork disables the fork into the background API + and removes all references to fork() and + pr_ctl() from the sources. Use it if your + platform doesn't support forking. + +--enable-libcrypto by default libwebsockets uses its own + built-in md5 and sha-1 implementation for + simplicity. However the libcrypto ones + may be faster, and in a distro context it + may be highly desirable to use a common + library implementation for ease of security + upgrades. Give this configure option + to disable the built-in ones and force use + of the libcrypto (part of openssl) ones. + +--with-client-cert-dir=dir tells the client ssl support where to + look for trust certificates to validate + the remote certificate against. + +--enable-noping Don't try to build the ping test app + It needs some unixy environment that + may choke in other build contexts, this + lets you cleanly stop it being built + +--enable-x-google-mux Enable experimental x-google-mux support + in the build (see notes later in document) + +Testing server with a browser +----------------------------- + +If you point your browser (eg, Chrome) to + + http://127.0.0.1:7681 + +It will fetch a script in the form of test.html, and then run the +script in there on the browser to open a websocket connection. +Incrementing numbers should appear in the browser display. + +Using SSL on the server side +---------------------------- + +To test it using SSL/WSS, just run the test server with + +$ libwebsockets-test-server --ssl + +and use the URL + + https://127.0.0.1:7681 + +The connection will be entirely encrypted using some generated +certificates that your browser will not accept, since they are +not signed by any real Certificate Authority. Just accept the +certificates in the browser and the connection will proceed +in first https and then websocket wss, acting exactly the +same. + +test-server.c is all that is needed to use libwebsockets for +serving both the script html over http and websockets. + + +Forkless operation +------------------ + +If your target device does not offer fork(), you can use +libwebsockets from your own main loop instead. Use the +configure option --nofork and simply call libwebsocket_service() +from your own main loop as shown in the test app sources. + + +Testing websocket client support +-------------------------------- + +If you run the test server as described above, you can also +connect to it using the test client as well as a browser. + +$ libwebsockets-test-client localhost + +will by default connect to the test server on localhost:7681 +and print the dumb increment number from the server at the +same time as drawing random circles in the mirror protocol; +if you connect to the test server using a browser at the +same time you will be able to see the circles being drawn. + + +Testing SSL on the client side +------------------------------ + +To test SSL/WSS client action, just run the client test with + +$ libwebsockets-test-client localhost --ssl + +By default the client test applet is set to accept selfsigned +certificates used by the test server, this is indicated by the +use_ssl var being set to 2. Set it to 1 to reject any server +certificate that it doesn't have a trusted CA cert for. + + +Using the websocket ping utility +-------------------------------- + +libwebsockets-test-ping connects as a client to a remote +websocket server using 04 protocol and pings it like the +normal unix ping utility. + +$ libwebsockets-test-ping localhost +handshake OK for protocol lws-mirror-protocol +Websocket PING localhost.localdomain (127.0.0.1) 64 bytes of data. +64 bytes from localhost: req=1 time=0.1ms +64 bytes from localhost: req=2 time=0.1ms +64 bytes from localhost: req=3 time=0.1ms +64 bytes from localhost: req=4 time=0.2ms +64 bytes from localhost: req=5 time=0.1ms +64 bytes from localhost: req=6 time=0.2ms +64 bytes from localhost: req=7 time=0.2ms +64 bytes from localhost: req=8 time=0.1ms +^C +--- localhost.localdomain websocket ping statistics --- +8 packets transmitted, 8 received, 0% packet loss, time 7458ms +rtt min/avg/max = 0.110/0.185/0.218 ms +$ + +By default it sends 64 byte payload packets using the 04 +PING packet opcode type. You can change the payload size +using the -s= flag, up to a maximum of 125 mandated by the +04 standard. + +Using the lws-mirror protocol that is provided by the test +server, libwebsockets-test-ping can also use larger payload +sizes up to 4096 is BINARY packets; lws-mirror will copy +them back to the client and they appear as a PONG. Use the +-m flag to select this operation. + +The default interval between pings is 1s, you can use the -i= +flag to set this, including fractions like -i=0.01 for 10ms +interval. + +Before you can even use the PING opcode that is part of the +standard, you must complete a handshake with a specified +protocol. By default lws-mirror-protocol is used which is +supported by the test server. But if you are using it on +another server, you can specify the protcol to handshake with +by --protocol=protocolname + + +Fraggle test app +---------------- + +By default it runs in server mode + +$ libwebsockets-test-fraggle +libwebsockets test fraggle +(C) Copyright 2010-2011 Andy Green licensed under LGPL2.1 + Compiled with SSL support, not using it + Listening on port 7681 +server sees client connect +accepted v06 connection +Spamming 360 random fragments +Spamming session over, len = 371913. sum = 0x2D3C0AE +Spamming 895 random fragments +Spamming session over, len = 875970. sum = 0x6A74DA1 +... + +You need to run a second session in client mode, you have to +give the -c switch and the server address at least: + +$ libwebsockets-test-fraggle -c localhost +libwebsockets test fraggle +(C) Copyright 2010-2011 Andy Green licensed under LGPL2.1 + Client mode +Connecting to localhost:7681 +denied deflate-stream extension +handshake OK for protocol fraggle-protocol +client connects to server +EOM received 371913 correctly from 360 fragments +EOM received 875970 correctly from 895 fragments +EOM received 247140 correctly from 258 fragments +EOM received 695451 correctly from 692 fragments +... + +The fraggle test sends a random number up to 1024 fragmented websocket frames +each of a random size between 1 and 2001 bytes in a single message, then sends +a checksum and starts sending a new randomly sized and fragmented message. + +The fraggle test client receives the same message fragments and computes the +same checksum using websocket framing to see when the message has ended. It +then accepts the server checksum message and compares that to its checksum. + + +proxy support +------------- + +The http_proxy environment variable is respected by the client +connection code for both ws:// and wss://. It doesn't support +authentication yet. + +You use it like this + +export http_proxy=myproxy.com:3128 +libwebsockets-test-client someserver.com + + +Websocket version supported +--------------------------- + +The websocket client code is 04 and 05 version, the server +supports 00/76 in text mode and 04 and 05 dynamically +per-connection depending on the version of the +client / browser. + + +External Polling Loop support +----------------------------- + +libwebsockets maintains an internal poll() array for all of its +sockets, but you can instead integrate the sockets into an +external polling array. That's needed if libwebsockets will +cooperate with an existing poll array maintained by another +server. + +Four callbacks LWS_CALLBACK_ADD_POLL_FD, LWS_CALLBACK_DEL_POLL_FD, +LWS_CALLBACK_SET_MODE_POLL_FD and LWS_CALLBACK_CLEAR_MODE_POLL_FD +appear in the callback for protocol 0 and allow interface code to +manage socket descriptors in other poll loops. + + +x-google-mux support +-------------------- + +Experimental and super-preliminary x-google-mux support is available if +enabled in ./configure with --enable-x-google-mux. Note that when changing +configurations, you will need to do a make distclean before, then the new +configure and then make ; make install. Don't forget the necessary other +flags for your platform as described at the top of the readme. + +It has the following notes: + + 1) To enable it, reconfigure with --enable-x-google-mux + + 2) It deviates from the google standard by sending full + headers in the addchannel subcommand rather than just + changed ones from original connect + + 3) Quota is not implemented yet + +However despite those caveats, in fact it can run the +test client reliably over one socket (both dumb-increment +and lws-mirror-protocol), you can open a browser on the +same test server too and see the circles, etc. + +It also works compatibly with deflate-stream automatically. + +2012-04-12 Andy Green + diff --git a/libs/libwebsockets/configure.ac b/libs/libwebsockets/configure.ac new file mode 100644 index 0000000000..a2ca6f599e --- /dev/null +++ b/libs/libwebsockets/configure.ac @@ -0,0 +1,130 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + + +AC_INIT(libwebsockets, 0.3, andy@warmcat.com) +AM_INIT_AUTOMAKE(libwebsockets,0.3) +AC_CONFIG_SRCDIR([test-server/test-server.c]) +AC_CONFIG_HEADERS([config.h]) + +#LT_INIT(shared) + +#AX_PTHREAD + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_CONFIG_MACRO_DIR([m4]) +AC_PROG_LIBTOOL + +# +# +# +AC_ARG_ENABLE(openssl, + [ --enable-openssl Enables https support and needs openssl libs], + [ openssl=yes + ]) + +if test "x$openssl" = "xyes" ; then +AC_CHECK_LIB([ssl], [SSL_library_init]) +CFLAGS="$CFLAGS -DLWS_OPENSSL_SUPPORT" +fi + +# +# +# +AC_ARG_ENABLE(nofork, + [ --enable-nofork Disables fork-related options], + [ nofork=yes + ]) + +if test "x$nofork" = "xyes" ; then +CFLAGS="$CFLAGS -DLWS_NO_FORK" +else +AC_FUNC_FORK +fi + +# +# +# +AC_ARG_ENABLE(libcrypto, + [ --enable-libcrypto Use libcrypto MD5 and SHA1 implementations], + [ libcrypto=yes + ]) + +if test "x$libcrypto" = "xyes" ; then +CFLAGS="$CFLAGS -DLWS_LIBCRYPTO" +LDFLAGS="$LDFLAGS -lcrypto" +fi +AM_CONDITIONAL(LIBCRYPTO, test x$libcrypto = xyes) + + +# +# +# +AC_ARG_ENABLE(x-google-mux, + [ --enable-x-google-mux Build experimental x-google-mux], + [ x_google_mux=yes + ]) +if test "x$x_google_mux" = "xyes" ; then +CFLAGS="$CFLAGS -DLWS_EXT_GOOGLE_MUX" +fi +AM_CONDITIONAL(EXT_GOOGLE_MUX, test x$x_google_mux = xyes) + +# +# +# +AC_ARG_ENABLE(mingw, + [ --enable-mingw Using mingw compilers, disables ping test build], + [ mingw=yes + noping=yes + ]) + +if test "x$mingw" = "xyes" ; then +CFLAGS="$CFLAGS -DLWS_MINGW_SUPPORT" +fi +AM_CONDITIONAL(MINGW, test x$mingw = xyes) + +# +# +# +AC_ARG_WITH([client-cert-dir], +[AS_HELP_STRING([--with-client-cert-dir],[directory containing client certs, defaults to /etc/pki/tls/certs/])], +[clientcertdir=$withval], +[clientcertdir=/etc/pki/tls/certs/] +) +AC_SUBST([clientcertdir]) + +AC_SUBST([CFLAGS]) + + +# +# +# +AC_ARG_ENABLE(noping, + [ --enable-noping Do not build ping test app, which has some unixy stuff in sources], + [ noping=yes + ]) + +AM_CONDITIONAL(NOPING, test x$noping = xyes) + + + +# Checks for header files. +AC_CHECK_HEADERS([zlib.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h sys/prctl.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_SIZE_T + +# Checks for library functions. + +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([bzero memset socket strerror]) + +AC_CONFIG_FILES([Makefile + lib/Makefile + test-server/Makefile]) + +AC_OUTPUT diff --git a/libs/tiff-3.8.2/configure.gnu b/libs/libwebsockets/configure.gnu old mode 100755 new mode 100644 similarity index 55% rename from libs/tiff-3.8.2/configure.gnu rename to libs/libwebsockets/configure.gnu index c78238de46..53c204581f --- a/libs/tiff-3.8.2/configure.gnu +++ b/libs/libwebsockets/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 diff --git a/libs/libwebsockets/lib/Makefile.am b/libs/libwebsockets/lib/Makefile.am new file mode 100644 index 0000000000..1607b0173e --- /dev/null +++ b/libs/libwebsockets/lib/Makefile.am @@ -0,0 +1,44 @@ +lib_LTLIBRARIES=libwebsockets.la +include_HEADERS=libwebsockets.h +dist_libwebsockets_la_SOURCES=libwebsockets.c \ + handshake.c \ + parsers.c \ + libwebsockets.h \ + base64-decode.c \ + client-handshake.c \ + extension.c \ + extension-deflate-stream.c \ + private-libwebsockets.h + +if EXT_GOOGLE_MUX +dist_libwebsockets_la_SOURCES += extension-x-google-mux.c +endif + +if LIBCRYPTO +else +dist_libwebsockets_la_SOURCES += md5.c sha-1.c +endif + +libwebsockets_la_CFLAGS=-Wall -std=gnu99 -pedantic +libwebsockets_la_LDFLAGS= + +if MINGW +libwebsockets_la_CFLAGS+= -w -I../win32port/win32helpers -I ../win32port/zlib/ +libwebsockets_la_LDFLAGS+= -lm -luser32 -ladvapi32 -lkernel32 -lgcc +else +libwebsockets_la_CFLAGS+= -rdynamic -fPIC -Werror +libwebsockets_la_LDFLAGS+= -version-info 0:3 +endif + +libwebsockets_la_CFLAGS+= -c \ + -DINSTALL_DATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" +libwebsockets_la_LDFLAGS+= -lz + +all-local: + ../scripts/kernel-doc -html \ + libwebsockets.c \ + parsers.c \ + client-handshake.c \ + libwebsockets.h \ + > ../libwebsockets-api-doc.html + diff --git a/libs/libwebsockets/lib/base64-decode.c b/libs/libwebsockets/lib/base64-decode.c new file mode 100644 index 0000000000..95d4ba4ac2 --- /dev/null +++ b/libs/libwebsockets/lib/base64-decode.c @@ -0,0 +1,188 @@ +/* + * This code originally came from here + * + * http://base64.sourceforge.net/b64.c + * + * with the following license: + * + * LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the + * Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * VERSION HISTORY: + * Bob Trower 08/04/01 -- Create Version 0.00.00B + * + * I cleaned it up quite a bit to match the (linux kernel) style of the rest + * of libwebsockets; this version is under LGPL2 like the rest of libwebsockets + * since he explictly allows sublicensing, but I give the URL above so you can + * get the original with Bob's super-liberal terms directly if you prefer. + */ + + +#include +#include + +static const char encode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char decode[] = "|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW" + "$$$$$$XYZ[\\]^_`abcdefghijklmnopq"; + +int +lws_b64_encode_string(const char *in, int in_len, char *out, int out_size) +{ + unsigned char triple[3]; + int i; + int len; + int line = 0; + int done = 0; + + while (in_len) { + len = 0; + for (i = 0; i < 3; i++) { + if (in_len) { + triple[i] = *in++; + len++; + in_len--; + } else + triple[i] = 0; + } + if (!len) + continue; + + if (done + 4 >= out_size) + return -1; + + *out++ = encode[triple[0] >> 2]; + *out++ = encode[((triple[0] & 0x03) << 4) | + ((triple[1] & 0xf0) >> 4)]; + *out++ = (len > 1 ? encode[((triple[1] & 0x0f) << 2) | + ((triple[2] & 0xc0) >> 6)] : '='); + *out++ = (len > 2 ? encode[triple[2] & 0x3f] : '='); + + done += 4; + line += 4; + } + + if (done + 1 >= out_size) + return -1; + + *out++ = '\0'; + + return done; +} + +/* + * returns length of decoded string in out, or -1 if out was too small + * according to out_size + */ + +int +lws_b64_decode_string(const char *in, char *out, int out_size) +{ + int len; + int i; + int done = 0; + unsigned char v; + unsigned char quad[4]; + + while (*in) { + + len = 0; + for (i = 0; i < 4 && *in; i++) { + + v = 0; + while (*in && !v) { + + v = *in++; + v = (v < 43 || v > 122) ? 0 : decode[v - 43]; + if (v) + v = (v == '$') ? 0 : v - 61; + if (*in) { + len++; + if (v) + quad[i] = v - 1; + } else + quad[i] = 0; + } + } + if (!len) + continue; + + if (out_size < (done + len - 1)) + /* out buffer is too small */ + return -1; + + if (len >= 2) + *out++ = quad[0] << 2 | quad[1] >> 4; + if (len >= 3) + *out++ = quad[1] << 4 | quad[2] >> 2; + if (len >= 4) + *out++ = ((quad[2] << 6) & 0xc0) | quad[3]; + + done += len - 1; + } + + if (done + 1 >= out_size) + return -1; + + *out++ = '\0'; + + return done; +} + +int +lws_b64_selftest(void) +{ + char buf[64]; + int n; + int test; + static const char * const plaintext[] = { + "sanity check base 64" + }; + static const char * const coded[] = { + "c2FuaXR5IGNoZWNrIGJhc2UgNjQ=" + }; + + for (test = 0; test < sizeof plaintext / sizeof(plaintext[0]); test++) { + + buf[sizeof(buf) - 1] = '\0'; + n = lws_b64_encode_string(plaintext[test], + strlen(plaintext[test]), buf, sizeof buf); + if (n != strlen(coded[test]) || strcmp(buf, coded[test])) { + fprintf(stderr, "Failed lws_b64 encode selftest " + "%d result '%s' %d\n", test, buf, n); + return -1; + } + + buf[sizeof(buf) - 1] = '\0'; + n = lws_b64_decode_string(coded[test], buf, sizeof buf); + if (n != strlen(plaintext[test]) || + strcmp(buf, plaintext[test])) { + fprintf(stderr, "Failed lws_b64 decode selftest " + "%d result '%s' %d\n", test, buf, n); + return -1; + } + } + + return 0; +} diff --git a/libs/libwebsockets/lib/client-handshake.c b/libs/libwebsockets/lib/client-handshake.c new file mode 100644 index 0000000000..ceb5f76f22 --- /dev/null +++ b/libs/libwebsockets/lib/client-handshake.c @@ -0,0 +1,408 @@ +#include "private-libwebsockets.h" + +struct libwebsocket *__libwebsocket_client_connect_2( + struct libwebsocket_context *context, + struct libwebsocket *wsi +) { + struct pollfd pfd; + struct timeval tv; + struct hostent *server_hostent; + struct sockaddr_in server_addr; + int n; + int plen = 0; + char pkt[512]; + int opt = 1; +#if defined(__APPLE__) + struct protoent *tcp_proto; +#endif + + debug("__libwebsocket_client_connect_2\n"); + + wsi->candidate_children_list = NULL; + + /* + * proxy? + */ + + if (context->http_proxy_port) { + plen = sprintf(pkt, "CONNECT %s:%u HTTP/1.0\x0d\x0a" + "User-agent: libwebsockets\x0d\x0a" +/*Proxy-authorization: basic aGVsbG86d29ybGQ= */ + "\x0d\x0a", wsi->c_address, wsi->c_port); + + /* OK from now on we talk via the proxy */ + + free(wsi->c_address); + wsi->c_address = strdup(context->http_proxy_address); + wsi->c_port = context->http_proxy_port; + } + + /* + * prepare the actual connection (to the proxy, if any) + */ + + debug("__libwebsocket_client_connect_2: address %s", wsi->c_address); + + server_hostent = gethostbyname(wsi->c_address); + if (server_hostent == NULL) { + fprintf(stderr, "Unable to get host name from %s\n", + wsi->c_address); + goto oom4; + } + + wsi->sock = socket(AF_INET, SOCK_STREAM, 0); + + if (wsi->sock < 0) { + fprintf(stderr, "Unable to open socket\n"); + goto oom4; + } + + server_addr.sin_family = AF_INET; + server_addr.sin_port = htons(wsi->c_port); + server_addr.sin_addr = *((struct in_addr *)server_hostent->h_addr); + bzero(&server_addr.sin_zero, 8); + + /* Disable Nagle */ +#if !defined(__APPLE__) + setsockopt(wsi->sock, SOL_TCP, TCP_NODELAY, + (const void *)&opt, sizeof(opt)); +#else + tcp_proto = getprotobyname("TCP"); + setsockopt(wsi->sock, tcp_proto->p_proto, TCP_NODELAY, + &opt, sizeof(opt)); +#endif + + /* Set receiving timeout */ + tv.tv_sec = 0; + tv.tv_usec = 100 * 1000; + setsockopt(wsi->sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv); + + if (connect(wsi->sock, (struct sockaddr *)&server_addr, + sizeof(struct sockaddr)) == -1) { + fprintf(stderr, "Connect failed\n"); +#ifdef WIN32 + closesocket(wsi->sock); +#else + close(wsi->sock); +#endif + goto oom4; + } + + debug("connected\n"); + + /* into fd -> wsi hashtable */ + + insert_wsi(context, wsi); + + /* into internal poll list */ + + context->fds[context->fds_count].fd = wsi->sock; + context->fds[context->fds_count].revents = 0; + context->fds[context->fds_count++].events = POLLIN; + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_ADD_POLL_FD, + (void *)(long)wsi->sock, NULL, POLLIN); + + /* we are connected to server, or proxy */ + + if (context->http_proxy_port) { + + n = send(wsi->sock, pkt, plen, 0); + if (n < 0) { +#ifdef WIN32 + closesocket(wsi->sock); +#else + close(wsi->sock); +#endif + fprintf(stderr, "ERROR writing to proxy socket\n"); + goto bail1; + } + + libwebsocket_set_timeout(wsi, + PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE, 5); + + wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY; + + return wsi; + } + + /* + * provoke service to issue the handshake directly + * we need to do it this way because in the proxy case, this is the + * next state and executed only if and when we get a good proxy + * response inside the state machine + */ + + wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE; + pfd.fd = wsi->sock; + pfd.revents = POLLIN; + if (libwebsocket_service_fd(context, &pfd) < 0) + goto oom4; + + return wsi; + +oom4: + if (wsi->c_protocol) + free(wsi->c_protocol); + + if (wsi->c_origin) + free(wsi->c_origin); + + free(wsi->c_host); + free(wsi->c_path); + +bail1: + free(wsi); + + return NULL; +} + +/** + * libwebsocket_client_connect() - Connect to another websocket server + * @context: Websocket context + * @address: Remote server address, eg, "myserver.com" + * @port: Port to connect to on the remote server, eg, 80 + * @ssl_connection: 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self + * signed certs + * @path: Websocket path on server + * @host: Hostname on server + * @origin: Socket origin name + * @protocol: Comma-separated list of protocols being asked for from + * the server, or just one. The server will pick the one it + * likes best. + * @ietf_version_or_minus_one: -1 to ask to connect using the default, latest + * protocol supported, or the specific protocol ordinal + * + * This function creates a connection to a remote server + */ + +struct libwebsocket * +libwebsocket_client_connect(struct libwebsocket_context *context, + const char *address, + int port, + int ssl_connection, + const char *path, + const char *host, + const char *origin, + const char *protocol, + int ietf_version_or_minus_one) +{ + struct libwebsocket *wsi; + int n; + int m; + struct libwebsocket_extension *ext; + int handled; +#ifndef LWS_OPENSSL_SUPPORT + if (ssl_connection) { + fprintf(stderr, "libwebsockets not configured for ssl\n"); + return NULL; + } +#endif + + wsi = malloc(sizeof(struct libwebsocket)); + if (wsi == NULL) + goto bail1; + + memset(wsi, 0, sizeof *wsi); + + /* -1 means just use latest supported */ + + if (ietf_version_or_minus_one == -1) + ietf_version_or_minus_one = SPEC_LATEST_SUPPORTED; + + wsi->ietf_spec_revision = ietf_version_or_minus_one; + wsi->name_buffer_pos = 0; + wsi->user_space = NULL; + wsi->state = WSI_STATE_CLIENT_UNCONNECTED; + wsi->pings_vs_pongs = 0; + wsi->protocol = NULL; + wsi->pending_timeout = NO_PENDING_TIMEOUT; + wsi->count_active_extensions = 0; +#ifdef LWS_OPENSSL_SUPPORT + wsi->use_ssl = ssl_connection; +#endif + + wsi->c_port = port; + wsi->c_address = strdup(address); + + /* copy parameters over so state machine has access */ + + wsi->c_path = malloc(strlen(path) + 1); + if (wsi->c_path == NULL) + goto bail1; + strcpy(wsi->c_path, path); + + wsi->c_host = malloc(strlen(host) + 1); + if (wsi->c_host == NULL) + goto oom1; + strcpy(wsi->c_host, host); + + if (origin) { + wsi->c_origin = malloc(strlen(origin) + 1); + strcpy(wsi->c_origin, origin); + if (wsi->c_origin == NULL) + goto oom2; + } else + wsi->c_origin = NULL; + + wsi->c_callback = NULL; + if (protocol) { + const char *pc; + struct libwebsocket_protocols *pp; + + wsi->c_protocol = malloc(strlen(protocol) + 1); + if (wsi->c_protocol == NULL) + goto oom3; + + strcpy(wsi->c_protocol, protocol); + + pc = protocol; + while (*pc && *pc != ',') + pc++; + n = pc - protocol; + pp = context->protocols; + while (pp->name && !wsi->c_callback) { + if (!strncmp(protocol, pp->name, n)) + wsi->c_callback = pp->callback; + pp++; + } + } else + wsi->c_protocol = NULL; + + if (!wsi->c_callback) + wsi->c_callback = context->protocols[0].callback; + + /* set up appropriate masking */ + + wsi->xor_mask = xor_no_mask; + + switch (wsi->ietf_spec_revision) { + case 0: + break; + case 4: + wsi->xor_mask = xor_mask_04; + break; + case 5: + case 6: + case 7: + case 8: + case 13: + wsi->xor_mask = xor_mask_05; + break; + default: + fprintf(stderr, + "Client ietf version %d not supported\n", + wsi->ietf_spec_revision); + goto oom4; + } + + /* force no mask if he asks for that though */ + + if (context->options & LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK) + wsi->xor_mask = xor_no_mask; + + for (n = 0; n < WSI_TOKEN_COUNT; n++) { + wsi->utf8_token[n].token = NULL; + wsi->utf8_token[n].token_len = 0; + } + + /* + * Check with each extension if it is able to route and proxy this + * connection for us. For example, an extension like x-google-mux + * can handle this and then we don't need an actual socket for this + * connection. + */ + + handled = 0; + ext = context->extensions; + n = 0; + + while (ext && ext->callback && !handled) { + m = ext->callback(context, ext, wsi, + LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION, + (void *)(long)n, (void *)address, port); + if (m) + handled = 1; + + ext++; + n++; + } + + if (handled) { + debug("libwebsocket_client_connect: ext handling conn\n"); + + libwebsocket_set_timeout(wsi, + PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE, 5); + + wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT; + return wsi; + } + + debug("libwebsocket_client_connect: direct conn\n"); + + return __libwebsocket_client_connect_2(context, wsi); + + +oom4: + if (wsi->c_protocol) + free(wsi->c_protocol); + +oom3: + if (wsi->c_origin) + free(wsi->c_origin); + +oom2: + free(wsi->c_host); + +oom1: + free(wsi->c_path); + +bail1: + free(wsi); + + return NULL; +} + + +/** + * libwebsocket_client_connect_extended() - Connect to another websocket server + * @context: Websocket context + * @address: Remote server address, eg, "myserver.com" + * @port: Port to connect to on the remote server, eg, 80 + * @ssl_connection: 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self + * signed certs + * @path: Websocket path on server + * @host: Hostname on server + * @origin: Socket origin name + * @protocol: Comma-separated list of protocols being asked for from + * the server, or just one. The server will pick the one it + * likes best. + * @ietf_version_or_minus_one: -1 to ask to connect using the default, latest + * protocol supported, or the specific protocol ordinal + * @userdata: Pre-allocated user data + * + * This function creates a connection to a remote server + */ + +struct libwebsocket * +libwebsocket_client_connect_extended(struct libwebsocket_context *context, + const char *address, + int port, + int ssl_connection, + const char *path, + const char *host, + const char *origin, + const char *protocol, + int ietf_version_or_minus_one, + void *userdata) +{ + struct libwebsocket *ws = + libwebsocket_client_connect(context, address, port, ssl_connection, path, host, origin, protocol, ietf_version_or_minus_one) ; + + if (ws && !ws->user_space && userdata) + ws->user_space = userdata ; + + return ws ; + } diff --git a/libs/libwebsockets/lib/extension-deflate-stream.c b/libs/libwebsockets/lib/extension-deflate-stream.c new file mode 100644 index 0000000000..2e4ad6c1a4 --- /dev/null +++ b/libs/libwebsockets/lib/extension-deflate-stream.c @@ -0,0 +1,150 @@ +#include "private-libwebsockets.h" +#include "extension-deflate-stream.h" +#include +#include +#include + +#define LWS_ZLIB_WINDOW_BITS 15 +#define LWS_ZLIB_MEMLEVEL 8 + +int lws_extension_callback_deflate_stream( + struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, + void *user, void *in, size_t len) +{ + struct lws_ext_deflate_stream_conn *conn = + (struct lws_ext_deflate_stream_conn *)user; + int n; + struct lws_tokens *eff_buf = (struct lws_tokens *)in; + + switch (reason) { + + /* + * for deflate-stream, both client and server sides act the same + */ + + case LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: + case LWS_EXT_CALLBACK_CONSTRUCT: + conn->zs_in.zalloc = conn->zs_out.zalloc = Z_NULL; + conn->zs_in.zfree = conn->zs_out.zfree = Z_NULL; + conn->zs_in.opaque = conn->zs_out.opaque = Z_NULL; + n = inflateInit2(&conn->zs_in, -LWS_ZLIB_WINDOW_BITS); + if (n != Z_OK) { + fprintf(stderr, "deflateInit returned %d\n", n); + return 1; + } + n = deflateInit2(&conn->zs_out, + DEFLATE_STREAM_COMPRESSION_LEVEL, Z_DEFLATED, + -LWS_ZLIB_WINDOW_BITS, LWS_ZLIB_MEMLEVEL, + Z_DEFAULT_STRATEGY); + if (n != Z_OK) { + fprintf(stderr, "deflateInit returned %d\n", n); + return 1; + } + debug("zlibs constructed\n"); + break; + + case LWS_EXT_CALLBACK_DESTROY: + (void)inflateEnd(&conn->zs_in); + (void)deflateEnd(&conn->zs_out); + debug("zlibs destructed\n"); + break; + + case LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: + + /* + * inflate the incoming compressed data + * Notice, length may be 0 and pointer NULL + * in the case we are flushing with nothing new coming in + */ + + conn->zs_in.next_in = (unsigned char *)eff_buf->token; + conn->zs_in.avail_in = eff_buf->token_len; + + conn->zs_in.next_out = conn->buf; + conn->zs_in.avail_out = sizeof(conn->buf); + + n = inflate(&conn->zs_in, Z_SYNC_FLUSH); + switch (n) { + case Z_NEED_DICT: + case Z_DATA_ERROR: + case Z_MEM_ERROR: + /* + * screwed.. close the connection... we will get a + * destroy callback to take care of closing nicely + */ + fprintf(stderr, "zlib error inflate %d\n", n); + return -1; + } + + /* rewrite the buffer pointers and length */ + + eff_buf->token = (char *)conn->buf; + eff_buf->token_len = sizeof(conn->buf) - conn->zs_in.avail_out; + + /* + * if we filled the output buffer, signal that we likely have + * more and need to be called again + */ + + if (eff_buf->token_len == sizeof(conn->buf)) + return 1; + + /* we don't need calling again until new input data comes */ + + return 0; + + case LWS_EXT_CALLBACK_FLUSH_PENDING_TX: + case LWS_EXT_CALLBACK_PACKET_TX_PRESEND: + + /* + * deflate the outgoing compressed data + */ + + conn->zs_out.next_in = (unsigned char *)eff_buf->token; + conn->zs_out.avail_in = eff_buf->token_len; + + conn->zs_out.next_out = conn->buf; + conn->zs_out.avail_out = sizeof(conn->buf); + + n = Z_PARTIAL_FLUSH; + if (reason == LWS_EXT_CALLBACK_FLUSH_PENDING_TX) + n = Z_FULL_FLUSH; + + n = deflate(&conn->zs_out, n); + if (n == Z_STREAM_ERROR) { + /* + * screwed.. close the connection... we will get a + * destroy callback to take care of closing nicely + */ + fprintf(stderr, "zlib error deflate\n"); + + return -1; + } + + /* rewrite the buffer pointers and length */ + + eff_buf->token = (char *)conn->buf; + eff_buf->token_len = sizeof(conn->buf) - conn->zs_out.avail_out; + + /* + * if we filled the output buffer, signal that we likely have + * more and need to be called again... even in deflate case + * we might sometimes need to spill more than came in + */ + + if (eff_buf->token_len == sizeof(conn->buf)) + return 1; + + /* we don't need calling again until new input data comes */ + + return 0; + + default: + break; + } + + return 0; +} diff --git a/libs/libwebsockets/lib/extension-deflate-stream.h b/libs/libwebsockets/lib/extension-deflate-stream.h new file mode 100644 index 0000000000..a8187bc3ac --- /dev/null +++ b/libs/libwebsockets/lib/extension-deflate-stream.h @@ -0,0 +1,18 @@ + +#include + +#define DEFLATE_STREAM_CHUNK 128 +#define DEFLATE_STREAM_COMPRESSION_LEVEL 1 + +struct lws_ext_deflate_stream_conn { + z_stream zs_in; + z_stream zs_out; + unsigned char buf[2000]; +}; + +extern int lws_extension_callback_deflate_stream( + struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, + void *user, void *in, size_t len); diff --git a/libs/libwebsockets/lib/extension-x-google-mux.c b/libs/libwebsockets/lib/extension-x-google-mux.c new file mode 100644 index 0000000000..f501c925a5 --- /dev/null +++ b/libs/libwebsockets/lib/extension-x-google-mux.c @@ -0,0 +1,1223 @@ +#include "private-libwebsockets.h" +#include "extension-x-google-mux.h" + +#define MUX_REAL_CHILD_INDEX_OFFSET 2 + +static int ongoing_subchannel; +static struct libwebsocket * tag_with_parent = NULL; +static int client_handshake_generation_is_for_mux_child; + +static int lws_addheader_mux_opcode(unsigned char *pb, int len) +{ + unsigned char *start = pb; + + *pb++ = LWS_WS_OPCODE_07__NOSPEC__MUX | 0x80; + if (len < 126) + *pb++ = len; + else { + if (len > 65535) { + *pb++ = 127; + *pb++ = 0; + *pb++ = 0; + *pb++ = 0; + *pb++ = 0; + *pb++ = (len ) >> 24; + *pb++ = (len) >> 16; + *pb++ = (len) >> 8; + *pb++ = (len) >> 0; + } else { + *pb++ = 126; + *pb++ = (len) >> 8; + *pb++ = (len) >> 0; + } + } + + return pb - start; +} + +static int +lws_mux_subcommand_header(int cmd, int channel, unsigned char *pb, int len) +{ + unsigned char *start = pb; + + if (channel == 0) { + muxdebug("lws_mux_subcommand_header: given ch 0\n"); + *((int *)0) = 0; + } + + if (channel < 31) + *pb++ = (channel << 3) | cmd; + else { + *pb++ = (31 << 3) | cmd; + *pb++ = channel >> 8; + *pb++ = channel; + } + + if (len <= 253) + *pb++ = len; + else { + if (len <= 65535) { + *pb++ = 254; + *pb++ = len >> 8; + *pb++ = len; + } else { + *pb++ = 255; + *pb++ = len >> 24; + *pb++ = len >> 16; + *pb++ = len >> 8; + *pb++ = len; + } + } + + return pb - start; +} + +static int lws_ext_x_google_mux__send_addchannel( + struct libwebsocket_context *context, + struct libwebsocket *wsi, + struct lws_ext_x_google_mux_conn *parent_conn, + struct libwebsocket *wsi_child, + int channel, + const char *url +) { + + unsigned char send_buf[LWS_SEND_BUFFER_PRE_PADDING + 2048 + + LWS_SEND_BUFFER_POST_PADDING]; + unsigned char *pb = &send_buf[LWS_SEND_BUFFER_PRE_PADDING]; + char *p; + char delta_headers[1536]; + int delta_headers_len; + int subcommand_length; + int n; + + if (channel == 0) { + muxdebug("lws_ext_x_google_mux__send_addchannel: given ch 0\n"); + *((int *)0) = 0; + } + + wsi_child->ietf_spec_revision = wsi->ietf_spec_revision; + + client_handshake_generation_is_for_mux_child = 1; + p = libwebsockets_generate_client_handshake(context, wsi_child, + delta_headers); + client_handshake_generation_is_for_mux_child = 0; + delta_headers_len = p - delta_headers; + + subcommand_length = lws_mux_subcommand_header( + LWS_EXT_XGM_OPC__ADDCHANNEL, channel, pb, delta_headers_len); + + pb += lws_addheader_mux_opcode(pb, subcommand_length + delta_headers_len); + pb += lws_mux_subcommand_header(LWS_EXT_XGM_OPC__ADDCHANNEL, channel, + pb, delta_headers_len); + +// n = sprintf((char *)pb, "%s\x0d\x0a", url); +// pb += n; + + if (delta_headers_len) + memcpy(pb, delta_headers, delta_headers_len); + + pb += delta_headers_len; + + muxdebug("add channel sends %ld\n", + pb - &send_buf[LWS_SEND_BUFFER_PRE_PADDING]); + + parent_conn->defeat_mux_opcode_wrapping = 1; + + /* send the request to the server */ + + n = lws_issue_raw_ext_access(wsi, &send_buf[LWS_SEND_BUFFER_PRE_PADDING], + pb - &send_buf[LWS_SEND_BUFFER_PRE_PADDING]); + + parent_conn->defeat_mux_opcode_wrapping = 0; + + return n; +} + +/** + * lws_extension_x_google_mux_parser(): Parse mux buffer headers coming in + * from a muxed connection into subchannel + * specific actions + * @wsi: muxed websocket instance + * @conn: x-google-mux private data bound to that @wsi + * @c: next character in muxed stream + */ + +static int +lws_extension_x_google_mux_parser(struct libwebsocket_context *context, + struct libwebsocket *wsi, + struct libwebsocket_extension *this_ext, + struct lws_ext_x_google_mux_conn *conn, unsigned char c) +{ + struct libwebsocket *wsi_child = NULL; + struct libwebsocket_extension *ext; + struct lws_ext_x_google_mux_conn *child_conn = NULL; + int n; + void *v; + +// fprintf(stderr, "XRX: %02X %d %d\n", c, conn->state, conn->length); + + /* + * [ ] + * [ ] + */ + + switch (conn->state) { + + case LWS_EXT_XGM_STATE__MUX_BLOCK_1: +// fprintf(stderr, "LWS_EXT_XGM_STATE__MUX_BLOCK_1: opc=%d channel=%d\n", c & 7, c >> 3); + conn->block_subopcode = c & 7; + conn->block_subchannel = (c >> 3) & 0x1f; + conn->ignore_cmd = 0; + + if (conn->block_subchannel != 31) + goto interpret; + else + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_2; + break; + + case LWS_EXT_XGM_STATE__MUX_BLOCK_2: + conn->block_subchannel = c << 8; + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_3; + break; + + case LWS_EXT_XGM_STATE__MUX_BLOCK_3: + conn->block_subchannel |= c; + +interpret: +// fprintf(stderr, "LWS_EXT_XGM_STATE__MUX_BLOCK_3: subchannel=%d\n", conn->block_subchannel); + ongoing_subchannel = conn->block_subchannel; + + /* + * convert the subchannel index to a child wsi + */ + + /* act on the muxing opcode */ + + switch (conn->block_subopcode) { + case LWS_EXT_XGM_OPC__DATA: + conn->state = LWS_EXT_XGM_STATE__DATA; + break; + case LWS_EXT_XGM_OPC__ADDCHANNEL: + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN; + switch (wsi->mode) { + + /* client: parse accepted headers returned by server */ + + case LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY: + case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE: + case LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY: + case LWS_CONNMODE_WS_CLIENT: + wsi_child = conn->wsi_children[conn->block_subchannel - MUX_REAL_CHILD_INDEX_OFFSET]; + wsi_child->state = WSI_STATE_HTTP_HEADERS; + wsi_child->parser_state = WSI_TOKEN_NAME_PART; + break; + default: + wsi_child = libwebsocket_create_new_server_wsi(context); + conn->wsi_children[conn->block_subchannel - MUX_REAL_CHILD_INDEX_OFFSET] = wsi_child; + wsi_child->state = WSI_STATE_HTTP_HEADERS; + wsi_child->parser_state = WSI_TOKEN_NAME_PART; + wsi_child->extension_handles = wsi; + muxdebug("MUX LWS_EXT_XGM_OPC__ADDCHANNEL... " + "created child subchannel %d\n", conn->block_subchannel); + break; + } + break; + case LWS_EXT_XGM_OPC__DROPCHANNEL: + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + break; + case LWS_EXT_XGM_OPC__FLOWCONTROL: + conn->state = LWS_EXT_XGM_STATE__FLOWCONTROL_1; + break; + default: + fprintf(stderr, "xgm: unknown subopcode\n"); + return -1; + } + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN: + switch (c) { + case 254: + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_1; + break; + case 255: + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_1; + break; + default: + conn->length = c; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS; + break; + } + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_1: + conn->length = c << 8; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_2; + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_2: + conn->length |= c; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS; + muxdebug("conn->length in mux block is %d\n", conn->length); + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_1: + conn->length = c << 24; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_2; + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_2: + conn->length |= c << 16; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_3; + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_3: + conn->length |= c << 8; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_4; + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_4: + conn->length |= c; + conn->state = LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS; + break; + + case LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS: + + if (conn->block_subchannel == 0 || conn->block_subchannel >= + (sizeof(conn->wsi_children) / + sizeof(conn->wsi_children[0]))) { + fprintf(stderr, "Illegal subchannel %d in " + "LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS, ignoring", + conn->block_subchannel); + conn->ignore_cmd = 1; + } + + if (conn->block_subchannel == 1 && !conn->original_ch1_closed) { + fprintf(stderr, "illegal request to add ch1 when it's still live, ignoring\n"); + conn->ignore_cmd = 1; + } + + if (conn->ignore_cmd) { + if (--conn->length) + return 0; + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + return 0; + } + + switch (wsi->mode) { + + /* client: parse accepted headers returned by server */ + + case LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY: + case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE: + case LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY: + case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT: + case LWS_CONNMODE_WS_CLIENT: + + muxdebug("Client LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS in %c\n", c); + if (conn->block_subchannel == 1) { + muxdebug("adding ch1\n"); + wsi_child = wsi; + child_conn = conn; + } else + wsi_child = conn->wsi_children[ + conn->block_subchannel - + MUX_REAL_CHILD_INDEX_OFFSET]; + + libwebsocket_parse(wsi_child, c); + + if (--conn->length) + return 0; + + /* it's here we create the actual ext conn via callback */ + tag_with_parent = wsi; + lws_client_interpret_server_handshake(context, wsi_child); + tag_with_parent = NULL; + + //if (wsi->parser_state != WSI_PARSING_COMPLETE) +// break; + + /* client: we received all server's ADD ack */ + + if (conn->block_subchannel != 1) { + child_conn = lws_get_extension_user_matching_ext( + wsi_child, this_ext); + muxdebug("Received server's ADD Channel ACK for " + "subchannel %d child_conn=%p!\n", + conn->block_subchannel, (void *)child_conn); + + wsi_child->xor_mask = xor_no_mask; + wsi_child->ietf_spec_revision = wsi->ietf_spec_revision; + + wsi_child->mode = LWS_CONNMODE_WS_CLIENT; + wsi_child->state = WSI_STATE_ESTABLISHED; + child_conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + } + + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + child_conn->subchannel = conn->block_subchannel; + + /* allocate the per-connection user memory (if any) */ + + if (wsi_child->protocol->per_session_data_size) { + wsi_child->user_space = malloc( + wsi_child->protocol->per_session_data_size); + if (wsi_child->user_space == NULL) { + fprintf(stderr, "Out of memory for " + "conn user space\n"); + goto bail2; + } + } else + wsi_child->user_space = NULL; + + /* clear his proxy connection timeout */ + + libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0); + + /* mark him as being alive */ + + wsi_child->state = WSI_STATE_ESTABLISHED; + wsi_child->mode = LWS_CONNMODE_WS_CLIENT; + + if (wsi_child->protocol) + muxdebug("mux handshake OK for protocol %s\n", + wsi_child->protocol->name); + else + muxdebug("mux child handshake ends up with no protocol!\n"); + + /* + * inform all extensions, not just active ones since they + * already know + */ + + ext = context->extensions; + + while (ext && ext->callback) { + v = NULL; + for (n = 0; n < wsi_child->count_active_extensions; n++) + if (wsi_child->active_extensions[n] == ext) { + v = wsi_child->active_extensions_user[n]; + } + + ext->callback(context, ext, wsi_child, + LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED, v, NULL, 0); + ext++; + } + + /* call him back to inform him he is up */ + + wsi->protocol->callback(context, wsi_child, + LWS_CALLBACK_CLIENT_ESTABLISHED, + wsi_child->user_space, + NULL, 0); + + return 0; + +bail2: + exit(1); + + /* server: parse proposed changed headers from client */ + + default: + break; + } + + /* + * SERVER + */ + + wsi_child = conn->wsi_children[conn->block_subchannel - MUX_REAL_CHILD_INDEX_OFFSET]; + + muxdebug("Server LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS in %d\n", conn->length); + + libwebsocket_read(context, wsi_child, &c, 1); + + if (--conn->length > 0) + break; + + muxdebug("Server LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS done\n"); + + /* + * server: header diffs are all seen, we must process + * the add action + */ + + /* reply with ADDCHANNEL to ack it */ + + wsi->xor_mask = xor_no_mask; + child_conn = lws_get_extension_user_matching_ext(wsi_child, + this_ext); + if (!child_conn) { + fprintf(stderr, "wsi_child %p has no child conn!", (void *)wsi_child); + break; + } + child_conn->wsi_parent = wsi; + conn->sticky_mux_used = 1; + child_conn->subchannel = conn->block_subchannel; + + + muxdebug("Setting child conn parent to %p\n", (void *)wsi); + + wsi_child->mode = LWS_CONNMODE_WS_SERVING; + wsi_child->state = WSI_STATE_ESTABLISHED; + wsi_child->lws_rx_parse_state = LWS_RXPS_NEW; + wsi_child->rx_packet_length = 0; + + /* allocate the per-connection user memory (if any) */ + + if (wsi_child->protocol->per_session_data_size) { + wsi_child->user_space = malloc( + wsi_child->protocol->per_session_data_size); + if (wsi_child->user_space == NULL) { + fprintf(stderr, "Out of memory for " + "conn user space\n"); + break; + } + } else + wsi_child->user_space = NULL; + + + conn->wsi_children[conn->block_subchannel - + MUX_REAL_CHILD_INDEX_OFFSET] = wsi_child; + if (conn->highest_child_subchannel <= + conn->block_subchannel - MUX_REAL_CHILD_INDEX_OFFSET) + conn->highest_child_subchannel = + conn->block_subchannel - + MUX_REAL_CHILD_INDEX_OFFSET + 1; + + + /* notify user code that we're ready to roll */ + + if (wsi_child->protocol->callback) + wsi_child->protocol->callback( + wsi_child->protocol->owning_server, + wsi_child, LWS_CALLBACK_ESTABLISHED, + wsi_child->user_space, NULL, 0); + + muxdebug("setting conn state LWS_EXT_XGM_STATE__MUX_BLOCK_1\n"); + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + break; + + case LWS_EXT_XGM_STATE__FLOWCONTROL_1: + conn->length = c << 24; + conn->state = LWS_EXT_XGM_STATE__FLOWCONTROL_2; + break; + + case LWS_EXT_XGM_STATE__FLOWCONTROL_2: + conn->length |= c << 16; + conn->state = LWS_EXT_XGM_STATE__FLOWCONTROL_3; + break; + + case LWS_EXT_XGM_STATE__FLOWCONTROL_3: + conn->length |= c << 8; + conn->state = LWS_EXT_XGM_STATE__FLOWCONTROL_4; + break; + + case LWS_EXT_XGM_STATE__FLOWCONTROL_4: + conn->length |= c; + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + break; + + case LWS_EXT_XGM_STATE__DATA: + +// fprintf(stderr, "LWS_EXT_XGM_STATE__DATA in\n"); + + /* + * we have cooked websocket frame content following just like + * it went on the wire without mux, including masking and any + * other extensions (including this guy can himself be another + * level of channel mux, there's no restriction). + * + * We deal with it by just feeding it to the child wsi's rx + * state machine. The only issue is, we need that state machine + * to tell us when it ate a full frame, so we watch its state + * afterwards + */ + if (conn->block_subchannel - MUX_REAL_CHILD_INDEX_OFFSET >= conn->highest_child_subchannel) { + fprintf(stderr, "Illegal subchannel %d\n", conn->block_subchannel); + return -1; + } + + // fprintf(stderr, "LWS_EXT_XGM_STATE__DATA: ch %d\n", conn->block_subchannel); + + if (conn->block_subchannel == 1) { + if (conn->original_ch1_closed) { + fprintf(stderr, "data sent to closed ch1\n"); + return -1; + } + wsi_child = wsi; + } else + wsi_child = conn->wsi_children[conn->block_subchannel - MUX_REAL_CHILD_INDEX_OFFSET]; + + if (!wsi_child) { + fprintf(stderr, "Bad subchannel %d\n", conn->block_subchannel); + return -1; + } + + switch (wsi_child->mode) { + + /* client receives something */ + + case LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY: + case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE: + case LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY: + case LWS_CONNMODE_WS_CLIENT: +// fprintf(stderr, " client\n"); + if (libwebsocket_client_rx_sm(wsi_child, c) < 0) { + libwebsocket_close_and_free_session( + context, + wsi_child, + LWS_CLOSE_STATUS_GOINGAWAY); + } + + return 0; + + /* server is receiving from client */ + + default: +// fprintf(stderr, " server\n"); + if (libwebsocket_rx_sm(wsi_child, c) < 0) { + muxdebug("probs\n"); + libwebsocket_close_and_free_session( + context, + wsi_child, + LWS_CLOSE_STATUS_GOINGAWAY); + } + break; + } + break; + } + + return 0; +} + + + +int lws_extension_callback_x_google_mux( + struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, + void *user, void *in, size_t len) +{ + unsigned char send_buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 + + LWS_SEND_BUFFER_POST_PADDING]; + struct lws_ext_x_google_mux_conn *conn = + (struct lws_ext_x_google_mux_conn *)user; + struct lws_ext_x_google_mux_conn *parent_conn; + struct lws_ext_x_google_mux_conn *child_conn; + int n; + struct lws_tokens *eff_buf = (struct lws_tokens *)in; + unsigned char *p = NULL; + struct lws_ext_x_google_mux_context *mux_ctx = + ext->per_context_private_data; + struct libwebsocket *wsi_parent; + struct libwebsocket *wsi_child; + struct libwebsocket *wsi_temp; + unsigned char *pin = (unsigned char *)in; + unsigned char *basepin; + int m; + int done = 0; + unsigned char *pb = &send_buf[LWS_SEND_BUFFER_PRE_PADDING]; + int subcommand_length; + + if (eff_buf) + p = (unsigned char *)eff_buf->token; + + switch (reason) { + + /* these guys are once per context */ + + case LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT: + case LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT: + + ext->per_context_private_data = malloc( + sizeof (struct lws_ext_x_google_mux_context)); + mux_ctx = (struct lws_ext_x_google_mux_context *) + ext->per_context_private_data; + mux_ctx->active_conns = 0; + break; + + case LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT: + case LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT: + + if (!mux_ctx) + break; + for (n = 0; n < mux_ctx->active_conns; n++) + if (mux_ctx->wsi_muxconns[n]) { + libwebsocket_close_and_free_session( + context, mux_ctx->wsi_muxconns[n], + LWS_CLOSE_STATUS_GOINGAWAY); + mux_ctx->wsi_muxconns[n] = NULL; + } + + free(mux_ctx); + break; + + /* + * channel management + */ + + case LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION: + + muxdebug("LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION %s:%u\n", + (char *)in, (unsigned int)len); + + /* + * Does a physcial connection to the same server:port already + * exist so we can piggyback on it? + */ + + for (n = 0; n < mux_ctx->active_conns && !done; n++) { + + wsi_parent = mux_ctx->wsi_muxconns[n]; + if (!wsi_parent) + continue; + + muxdebug(" %s / %s\n", wsi_parent->c_address, (char *)in); + if (strcmp(wsi_parent->c_address, in)) + continue; + muxdebug(" %u / %u\n", wsi_parent->c_port, (unsigned int)len); + + if (wsi_parent->c_port != (unsigned int)len) + continue; + + /* + * does this potential parent already have an + * x-google-mux conn associated with him? + */ + + parent_conn = NULL; + for (m = 0; m < wsi_parent->count_active_extensions; m++) + if (ext == wsi_parent->active_extensions[m]) + parent_conn = (struct lws_ext_x_google_mux_conn *) + wsi_parent->active_extensions_user[m]; + + if (parent_conn == NULL) { + + /* + * he doesn't -- see if that's just because it + * is early in his connection sequence or if we + * should give up on him + */ + + switch (wsi_parent->mode) { + case LWS_CONNMODE_WS_SERVING: + case LWS_CONNMODE_WS_CLIENT: + continue; + default: + break; + } + + /* + * our putative parent is still connecting + * himself, we have to become a candidate child + * and find out our final fate when the parent + * completes connection + */ + + wsi->candidate_children_list = wsi_parent->candidate_children_list; + wsi_parent->candidate_children_list = wsi; + wsi->mode = LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD; + + done = 1; + continue; + } + + if (parent_conn->highest_child_subchannel >= + (sizeof(parent_conn->wsi_children) / + sizeof(parent_conn->wsi_children[0]))) { + fprintf(stderr, "Can't add any more children\n"); + continue; + } + /* + * this established connection will do, bind them + * from now on child will only operate through parent + * connection + */ + + wsi->candidate_children_list = wsi_parent->candidate_children_list; + wsi_parent->candidate_children_list = wsi; + wsi->mode = LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD; + + muxdebug("attaching to existing mux\n"); + + conn = parent_conn; + wsi = wsi_parent; + + goto handle_additions; + + } + + /* + * either way, note the existence of this connection in case + * he will become a possible mux parent later + */ + + mux_ctx->wsi_muxconns[mux_ctx->active_conns++] = wsi; + if (done) + return 1; + + muxdebug("x-google-mux: unable to mux connection\n"); + + break; + + /* these guys are once per connection */ + + case LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: + muxdebug("LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: setting parent = %p\n", (void *)tag_with_parent); + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + if (conn->block_subchannel != 1) + conn->wsi_parent = tag_with_parent; + break; + + case LWS_EXT_CALLBACK_CONSTRUCT: + muxdebug("LWS_EXT_CALLBACK_CONSTRUCT\n"); + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + break; + + case LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE: + muxdebug("LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE\n"); + + if (conn->subchannel == 1) { + + /* + * special case of original mux parent channel closing + */ + + conn->original_ch1_closed = 1; + + fprintf(stderr, "original mux parent channel closing\n"); + + parent_conn = conn; + } else { + + parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext); + if (parent_conn == 0) { + muxdebug("failed to get parent conn\n"); + break; + } + } + + /* see if that was the end of the mux entirely */ + + if (!parent_conn->original_ch1_closed) + break; + + done = 0; + for (n = 0; n < !done && parent_conn->highest_child_subchannel; n++) + if (parent_conn->wsi_children[n]) + done = 1; + + /* if he has children, don't let him close for real! */ + + if (done) { + fprintf(stderr, "VETO closure\n"); + return 1; + } + + /* no children, ch1 is closed, let him destroy himself */ + + if (conn->subchannel == 1) + fprintf(stderr, "ALLOW closure of mux parent\n"); + + break; + + case LWS_EXT_CALLBACK_DESTROY: + muxdebug("LWS_EXT_CALLBACK_DESTROY\n"); + + /* + * remove us from parent if noted in parent + */ + + if (conn->subchannel == 1) { + + /* + * special case of original mux parent channel closing + */ + + conn->original_ch1_closed = 1; + + fprintf(stderr, "original mux parent channel closing\n"); + + parent_conn = conn; + wsi_parent = wsi; + } else { + + wsi_parent = conn->wsi_parent; + parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext); + if (parent_conn == 0) { + muxdebug("failed to get parent conn\n"); + break; + } + for (n = 0; n < parent_conn->highest_child_subchannel; n++) + if (parent_conn->wsi_children[n] == wsi) + parent_conn->wsi_children[n] = NULL; + } + + /* see if that was the end of the mux entirely */ + + if (!parent_conn->original_ch1_closed) + break; + + done = 0; + for (n = 0; n < !done && parent_conn->highest_child_subchannel; n++) + if (parent_conn->wsi_children[n]) + done = 1; + + if (done == 0) + if (parent_conn != conn) + + /* + * parent closed last and no children left + * ... and we are not parent already ourselves + */ + + libwebsocket_close_and_free_session(context, wsi_parent, LWS_CLOSE_STATUS_NORMAL); + + break; + + case LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING: + muxdebug("LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING\n"); + + for (n = 0; n < mux_ctx->active_conns; n++) + if (mux_ctx->wsi_muxconns[n] == wsi) { + while (n++ < mux_ctx->active_conns) + mux_ctx->wsi_muxconns[n - 1] = + mux_ctx->wsi_muxconns[n]; + mux_ctx->active_conns--; + return 0; + } + + /* + * liberate any candidate children otherwise imprisoned + */ + + wsi_parent = wsi->candidate_children_list; + while (wsi_parent) { + wsi_temp = wsi_parent->candidate_children_list; + /* let them each connect privately then */ + __libwebsocket_client_connect_2(context, wsi_parent); + wsi_parent = wsi_temp; + } + + break; + + case LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED: + muxdebug("LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED\n"); + +handle_additions: + /* + * did this putative parent get x-google-mux authorized in the + * end? + */ + + if (!conn) { + + muxdebug(" Putative parent didn't get mux extension, let them go it alone\n"); + + /* + * no, we can't be a parent for mux children. Let + * them all go it alone + */ + + wsi_child = wsi->candidate_children_list; + while (wsi_child) { + wsi_temp = wsi_child->candidate_children_list; + /* let them each connect privately then */ + __libwebsocket_client_connect_2(context, wsi_child); + wsi_child = wsi_temp; + } + + return 1; + } + + /* + * we did get mux extension authorized by server, in that case + * if we have any candidate children let's try to attach them + * as mux subchannel real children + */ + + wsi_child = wsi->candidate_children_list; + n = 0; + while (wsi_child) { + + wsi_temp = wsi_child->candidate_children_list; + + /* find an empty subchannel */ + + while ((n < (sizeof(conn->wsi_children) / sizeof(conn->wsi_children[0]))) && + conn->wsi_children[n] != NULL) + n++; + + if (n >= (sizeof(conn->wsi_children) / sizeof(conn->wsi_children[0]))) { + /* no room at the inn */ + + /* let them each connect privately then */ + __libwebsocket_client_connect_2(context, wsi_child); + wsi_child = wsi_temp; + continue; + } + + muxdebug(" using mux addchannel action for candidate child\n"); + + /* pile the children on the parent */ + lws_ext_x_google_mux__send_addchannel(context, wsi, + conn, wsi_child, + n + MUX_REAL_CHILD_INDEX_OFFSET, wsi->c_path); + + conn->sticky_mux_used = 1; + + conn->wsi_children[n] = wsi_child; + if ((n + 1) > conn->highest_child_subchannel) + conn->highest_child_subchannel = n + 1; + + muxdebug("Setting CHILD LIST entry %d to %p\n", + n + MUX_REAL_CHILD_INDEX_OFFSET, (void *)wsi_parent); + wsi_child = wsi_temp; + } + wsi->candidate_children_list = NULL; + return 1; + + /* + * whenever we receive something on a muxed link + */ + + case LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX: + + muxdebug("LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX\n"); + + if (wsi->opcode != LWS_WS_OPCODE_07__NOSPEC__MUX) + return 0; /* unhandled */ + + conn->state = LWS_EXT_XGM_STATE__MUX_BLOCK_1; + + n = eff_buf->token_len; + while (n--) + if (lws_extension_x_google_mux_parser(context, wsi, ext, + conn, *p++) < 0) { + return -1; + } + return 1; /* handled */ + + /* + * when something might need sending on our transport + */ + + case LWS_EXT_CALLBACK_PACKET_TX_DO_SEND: + + muxdebug("LWS_EXT_CALLBACK_PACKET_TX_DO_SEND: %p, " + "my subchannel=%d\n", + (void *)conn->wsi_parent, conn->subchannel); + + pin = *((unsigned char **)in); + basepin = pin; + + wsi_parent = conn->wsi_parent; + + if (conn->subchannel == 1) { + + /* + * if we weren't 'closed', then we were the original + * connection that established this link, ie, it's + * the parent wsi + */ + + if (conn->original_ch1_closed) { + fprintf(stderr, "Trying to send on dead original ch1\n"); + return 0; + } + + /* send on ourselves */ + + wsi_parent = wsi; + + } else { + + /* + * he's not a child connection of a mux + */ + + if (!conn->wsi_parent) { + // fprintf(stderr, "conn %p has no parent\n", (void *)conn); + return 0; + } + + /* + * get parent / transport mux context + */ + + parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext); + if (parent_conn == 0) { + muxdebug("failed to get parent conn\n"); + return 0; + } + + /* + * mux transport is in singular mode, let the caller send it + * no more muxified than it already is + */ + + if (!parent_conn->sticky_mux_used) { + // fprintf(stderr, "parent in singular mode\n"); + return 0; + } + } + + if (!conn->defeat_mux_opcode_wrapping) { + + n = 1; + if (conn->subchannel >= 31) + n = 3; + + /* + * otherwise we need to take care of the sending action using + * mux protocol. Prepend the channel + opcode + */ + + pin -= lws_addheader_mux_opcode(send_buf, len + n) + n; + basepin = pin; + pin += lws_addheader_mux_opcode(pin, len + n); + + if (conn->subchannel >= 31) { + *pin++ = (31 << 3) | LWS_EXT_XGM_OPC__DATA; + *pin++ = conn->subchannel >> 8; + *pin++ = conn->subchannel; + } else + *pin++ = (conn->subchannel << 3) | LWS_EXT_XGM_OPC__DATA; + } + + /* + * recurse to allow nesting + */ + + lws_issue_raw_ext_access(wsi_parent, basepin, (pin - basepin) + len); + + return 1; /* handled */ + + case LWS_EXT_CALLBACK_1HZ: + /* + * if we have children, service their timeouts using the same + * handler as toplevel guys to allow recursion + */ + for (n = 0; n < conn->highest_child_subchannel; n++) + if (conn->wsi_children[n]) + libwebsocket_service_timeout_check(context, + conn->wsi_children[n], len); + break; + + case LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE: + /* + * if a mux child is asking for callback on writable, we have + * to pass it up to his parent + */ + + muxdebug("LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE %s\n", wsi->protocol->name); + + if (conn->wsi_parent == NULL) { + muxdebug(" no parent\n"); + break; + } + + if (!conn->awaiting_POLLOUT) { + + muxdebug(" !conn->awaiting_POLLOUT\n"); + + conn->awaiting_POLLOUT = 1; + parent_conn = NULL; + for (m = 0; m < conn->wsi_parent->count_active_extensions; m++) + if (ext == conn->wsi_parent->active_extensions[m]) + parent_conn = (struct lws_ext_x_google_mux_conn *) + conn->wsi_parent->active_extensions_user[m]; + + if (parent_conn != NULL) { + parent_conn->count_children_needing_POLLOUT++; + muxdebug(" count_children_needing_POLLOUT bumped\n"); + } else + muxdebug("unable to identify parent conn\n"); + } + muxdebug(" requesting on parent %p\n", (void *)conn->wsi_parent); + libwebsocket_callback_on_writable(context, conn->wsi_parent); + + return 1; + + case LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX: + + muxdebug("LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX %p\n", + (void *)wsi->extension_handles); + + /* send raw if we're not a child */ + + if (!wsi->extension_handles) + return 0; + + subcommand_length = lws_mux_subcommand_header(LWS_EXT_XGM_OPC__ADDCHANNEL, ongoing_subchannel, pb, len); + + pb += lws_addheader_mux_opcode(pb, subcommand_length + len); + pb += lws_mux_subcommand_header(LWS_EXT_XGM_OPC__ADDCHANNEL, ongoing_subchannel, pb, len); + memcpy(pb, in, len); + pb += len; + + lws_issue_raw_ext_access(wsi->extension_handles, &send_buf[LWS_SEND_BUFFER_PRE_PADDING], + pb - &send_buf[LWS_SEND_BUFFER_PRE_PADDING]); + + + return 1; /* handled */ + + case LWS_EXT_CALLBACK_IS_WRITEABLE: + /* + * we are writable, inform children if any care + */ + muxdebug("LWS_EXT_CALLBACK_IS_WRITEABLE: %s\n", wsi->protocol->name); + + if (!conn->count_children_needing_POLLOUT) { + muxdebug(" no children need POLLOUT\n"); + return 0; + } + + for (n = 0; n < conn->highest_child_subchannel; n++) { + + if (!conn->wsi_children[n]) + continue; + + child_conn = NULL; + for (m = 0; m < conn->wsi_children[n]->count_active_extensions; m++) + if (ext == conn->wsi_children[n]->active_extensions[m]) + child_conn = (struct lws_ext_x_google_mux_conn *) + conn->wsi_children[n]->active_extensions_user[m]; + + if (!child_conn) { + muxdebug("unable to identify child conn\n"); + continue; + } + + if (!child_conn->awaiting_POLLOUT) + continue; + + child_conn->awaiting_POLLOUT = 0; + conn->count_children_needing_POLLOUT--; + lws_handle_POLLOUT_event(context, conn->wsi_children[n], NULL); + if (!conn->count_children_needing_POLLOUT) + return 2; /* all handled */ + else + return 1; /* handled but need more */ + } + break; + + case LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION: + + /* disallow deflate-stream if we are a mux child connection */ + + if (strcmp(in, "deflate-stream") == 0 && + client_handshake_generation_is_for_mux_child) { + + muxdebug("mux banned deflate-stream on child connection\n"); + return 1; /* disallow */ + } + break; + + default: + break; + } + + return 0; +} diff --git a/libs/libwebsockets/lib/extension-x-google-mux.h b/libs/libwebsockets/lib/extension-x-google-mux.h new file mode 100644 index 0000000000..4f4d397c2e --- /dev/null +++ b/libs/libwebsockets/lib/extension-x-google-mux.h @@ -0,0 +1,96 @@ + +#if 0 +#ifdef WIN32 +static +#else +static inline +#endif +void muxdebug(const char *format, ...) +{ + va_list ap; + va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); +} +#else +#ifdef WIN32 +static +#else +static inline +#endif +void muxdebug(const char *format, ...) +{ +} +#endif + +#define MAX_XGM_SUBCHANNELS 8192 + +enum lws_ext_x_google_mux__parser_states { + LWS_EXT_XGM_STATE__MUX_BLOCK_1, + LWS_EXT_XGM_STATE__MUX_BLOCK_2, + LWS_EXT_XGM_STATE__MUX_BLOCK_3, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_1, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_2, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_1, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_2, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_3, + LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_4, + LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS, + LWS_EXT_XGM_STATE__FLOWCONTROL_1, + LWS_EXT_XGM_STATE__FLOWCONTROL_2, + LWS_EXT_XGM_STATE__FLOWCONTROL_3, + LWS_EXT_XGM_STATE__FLOWCONTROL_4, + LWS_EXT_XGM_STATE__DATA, +}; + +enum lws_ext_x_goole_mux__mux_opcodes { + LWS_EXT_XGM_OPC__DATA, + LWS_EXT_XGM_OPC__ADDCHANNEL, + LWS_EXT_XGM_OPC__DROPCHANNEL, + LWS_EXT_XGM_OPC__FLOWCONTROL, + LWS_EXT_XGM_OPC__RESERVED_4, + LWS_EXT_XGM_OPC__RESERVED_5, + LWS_EXT_XGM_OPC__RESERVED_6, + LWS_EXT_XGM_OPC__RESERVED_7, +}; + +/* one of these per context (server or client) */ + +struct lws_ext_x_google_mux_context { + /* + * these are listing physical connections, not children sharing a + * parent mux physical connection + */ + struct libwebsocket *wsi_muxconns[MAX_CLIENTS]; + /* + * when this is < 2, we do not do any mux blocks + * just pure websockets + */ + int active_conns; +}; + +/* one of these per connection (server or client) */ + +struct lws_ext_x_google_mux_conn { + enum lws_ext_x_goole_mux__mux_opcodes block_subopcode; + int block_subchannel; + unsigned int length; + enum lws_ext_x_google_mux__parser_states state; + /* child points to the mux wsi using this */ + struct libwebsocket *wsi_parent; + int subchannel; + struct libwebsocket *wsi_children[MAX_CLIENTS]; + int highest_child_subchannel; + char awaiting_POLLOUT; + int count_children_needing_POLLOUT; + int sticky_mux_used; + int defeat_mux_opcode_wrapping; + int original_ch1_closed; + int ignore_cmd; +}; + +extern int +lws_extension_callback_x_google_mux(struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, + void *user, void *in, size_t len); diff --git a/libs/libwebsockets/lib/extension.c b/libs/libwebsockets/lib/extension.c new file mode 100644 index 0000000000..890930872a --- /dev/null +++ b/libs/libwebsockets/lib/extension.c @@ -0,0 +1,22 @@ +#include "private-libwebsockets.h" + +#include "extension-deflate-stream.h" +#include "extension-x-google-mux.h" + +struct libwebsocket_extension libwebsocket_internal_extensions[] = { +#ifdef LWS_EXT_GOOGLE_MUX + { + "x-google-mux", + lws_extension_callback_x_google_mux, + sizeof (struct lws_ext_x_google_mux_conn) + }, +#endif + { + "deflate-stream", + lws_extension_callback_deflate_stream, + sizeof (struct lws_ext_deflate_stream_conn) + }, + { /* terminator */ + NULL, NULL, 0 + } +}; diff --git a/libs/libwebsockets/lib/handshake.c b/libs/libwebsockets/lib/handshake.c new file mode 100644 index 0000000000..70fe3a87eb --- /dev/null +++ b/libs/libwebsockets/lib/handshake.c @@ -0,0 +1,722 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "private-libwebsockets.h" + +#define LWS_CPYAPP(ptr, str) { strcpy(ptr, str); ptr += strlen(str); } +#define LWS_CPYAPP_TOKEN(ptr, tok) { strcpy(p, wsi->utf8_token[tok].token); \ + p += wsi->utf8_token[tok].token_len; } + +static int +interpret_key(const char *key, unsigned long *result) +{ + char digits[20]; + int digit_pos = 0; + const char *p = key; + unsigned int spaces = 0; + unsigned long acc = 0; + int rem = 0; + + while (*p) { + if (!isdigit(*p)) { + p++; + continue; + } + if (digit_pos == sizeof(digits) - 1) + return -1; + digits[digit_pos++] = *p++; + } + digits[digit_pos] = '\0'; + if (!digit_pos) + return -2; + + while (*key) { + if (*key == ' ') + spaces++; + key++; + } + + if (!spaces) + return -3; + + p = &digits[0]; + while (*p) { + rem = (rem * 10) + ((*p++) - '0'); + acc = (acc * 10) + (rem / spaces); + rem -= (rem / spaces) * spaces; + } + + if (rem) { + fprintf(stderr, "nonzero handshake remainder\n"); + return -1; + } + + *result = acc; + + return 0; +} + + +static int +handshake_00(struct libwebsocket_context *context, struct libwebsocket *wsi) +{ + unsigned long key1, key2; + unsigned char sum[16]; + char *response; + char *p; + int n; + + /* Confirm we have all the necessary pieces */ + + if (!wsi->utf8_token[WSI_TOKEN_ORIGIN].token_len || + !wsi->utf8_token[WSI_TOKEN_HOST].token_len || + !wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len || + !wsi->utf8_token[WSI_TOKEN_KEY1].token_len || + !wsi->utf8_token[WSI_TOKEN_KEY2].token_len) + /* completed header processing, but missing some bits */ + goto bail; + + /* allocate the per-connection user memory (if any) */ + if (wsi->protocol->per_session_data_size && + !libwebsocket_ensure_user_space(wsi)) + goto bail; + + /* create the response packet */ + + /* make a buffer big enough for everything */ + + response = malloc(256 + + wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len + + wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len + + wsi->utf8_token[WSI_TOKEN_HOST].token_len + + wsi->utf8_token[WSI_TOKEN_ORIGIN].token_len + + wsi->utf8_token[WSI_TOKEN_GET_URI].token_len + + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len); + if (!response) { + fprintf(stderr, "Out of memory for response buffer\n"); + goto bail; + } + + p = response; + LWS_CPYAPP(p, "HTTP/1.1 101 WebSocket Protocol Handshake\x0d\x0a" + "Upgrade: WebSocket\x0d\x0a" + "Connection: Upgrade\x0d\x0a" + "Sec-WebSocket-Origin: "); + strcpy(p, wsi->utf8_token[WSI_TOKEN_ORIGIN].token); + p += wsi->utf8_token[WSI_TOKEN_ORIGIN].token_len; +#ifdef LWS_OPENSSL_SUPPORT + if (wsi->ssl) { + LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Location: wss://"); + } else { + LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Location: ws://"); + } +#else + LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Location: ws://"); +#endif + + LWS_CPYAPP_TOKEN(p, WSI_TOKEN_HOST); + LWS_CPYAPP_TOKEN(p, WSI_TOKEN_GET_URI); + + if (wsi->utf8_token[WSI_TOKEN_PROTOCOL].token) { + LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Protocol: "); + LWS_CPYAPP_TOKEN(p, WSI_TOKEN_PROTOCOL); + } + + LWS_CPYAPP(p, "\x0d\x0a\x0d\x0a"); + + /* convert the two keys into 32-bit integers */ + + if (interpret_key(wsi->utf8_token[WSI_TOKEN_KEY1].token, &key1)) + goto bail; + if (interpret_key(wsi->utf8_token[WSI_TOKEN_KEY2].token, &key2)) + goto bail; + + /* lay them out in network byte order (MSB first */ + + sum[0] = key1 >> 24; + sum[1] = key1 >> 16; + sum[2] = key1 >> 8; + sum[3] = key1; + sum[4] = key2 >> 24; + sum[5] = key2 >> 16; + sum[6] = key2 >> 8; + sum[7] = key2; + + /* follow them with the challenge token we were sent */ + + memcpy(&sum[8], wsi->utf8_token[WSI_TOKEN_CHALLENGE].token, 8); + + /* + * compute the md5sum of that 16-byte series and use as our + * payload after our headers + */ + + MD5(sum, 16, (unsigned char *)p); + p += 16; + + /* it's complete: go ahead and send it */ + + debug("issuing response packet %d len\n", (int)(p - response)); +#ifdef DEBUG + fwrite(response, 1, p - response, stderr); +#endif + n = libwebsocket_write(wsi, (unsigned char *)response, + p - response, LWS_WRITE_HTTP); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + goto bail; + } + + /* alright clean up and set ourselves into established state */ + + free(response); + wsi->state = WSI_STATE_ESTABLISHED; + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + + /* notify user code that we're ready to roll */ + + if (wsi->protocol->callback) + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_ESTABLISHED, + wsi->user_space, NULL, 0); + + return 0; + +bail: + return -1; +} + +/* + * Perform the newer BASE64-encoded handshake scheme + */ + +static int +handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi) +{ + static const char *websocket_magic_guid_04 = + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + static const char *websocket_magic_guid_04_masking = + "61AC5F19-FBBA-4540-B96F-6561F1AB40A8"; + char accept_buf[MAX_WEBSOCKET_04_KEY_LEN + 37]; + char nonce_buf[256]; + char mask_summing_buf[256 + MAX_WEBSOCKET_04_KEY_LEN + 37]; + unsigned char hash[20]; + int n; + char *response; + char *p; + char *m = mask_summing_buf; + int nonce_len = 0; + int accept_len; + char *c; + char ext_name[128]; + struct libwebsocket_extension *ext; + int ext_count = 0; + int more = 1; + + if (!wsi->utf8_token[WSI_TOKEN_HOST].token_len || + !wsi->utf8_token[WSI_TOKEN_KEY].token_len) { + debug("handshake_04 missing pieces\n"); + /* completed header processing, but missing some bits */ + goto bail; + } + + if (wsi->utf8_token[WSI_TOKEN_KEY].token_len >= + MAX_WEBSOCKET_04_KEY_LEN) { + fprintf(stderr, "Client sent handshake key longer " + "than max supported %d\n", MAX_WEBSOCKET_04_KEY_LEN); + goto bail; + } + + strcpy(accept_buf, wsi->utf8_token[WSI_TOKEN_KEY].token); + strcpy(accept_buf + wsi->utf8_token[WSI_TOKEN_KEY].token_len, + websocket_magic_guid_04); + + SHA1((unsigned char *)accept_buf, + wsi->utf8_token[WSI_TOKEN_KEY].token_len + + strlen(websocket_magic_guid_04), hash); + + accept_len = lws_b64_encode_string((char *)hash, 20, accept_buf, + sizeof accept_buf); + if (accept_len < 0) { + fprintf(stderr, "Base64 encoded hash too long\n"); + goto bail; + } + + /* allocate the per-connection user memory (if any) */ + if (wsi->protocol->per_session_data_size && + !libwebsocket_ensure_user_space(wsi)) + goto bail; + + /* create the response packet */ + + /* make a buffer big enough for everything */ + + response = malloc(256 + + wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len + + wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len + + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len); + if (!response) { + fprintf(stderr, "Out of memory for response buffer\n"); + goto bail; + } + + p = response; + LWS_CPYAPP(p, "HTTP/1.1 101 Switching Protocols\x0d\x0a" + "Upgrade: WebSocket\x0d\x0a" + "Connection: Upgrade\x0d\x0a" + "Sec-WebSocket-Accept: "); + strcpy(p, accept_buf); + p += accept_len; + + if (wsi->ietf_spec_revision == 4) { + LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Nonce: "); + + /* select the nonce */ + + n = libwebsockets_get_random(wsi->protocol->owning_server, + hash, 16); + if (n != 16) { + fprintf(stderr, "Unable to read random device %s %d\n", + SYSTEM_RANDOM_FILEPATH, n); + if (wsi->user_space) + free(wsi->user_space); + goto bail; + } + + /* encode the nonce */ + + nonce_len = lws_b64_encode_string((const char *)hash, 16, + nonce_buf, sizeof nonce_buf); + if (nonce_len < 0) { + fprintf(stderr, "Failed to base 64 encode the nonce\n"); + if (wsi->user_space) + free(wsi->user_space); + goto bail; + } + + /* apply the nonce */ + + strcpy(p, nonce_buf); + p += nonce_len; + } + + if (wsi->utf8_token[WSI_TOKEN_PROTOCOL].token) { + LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Protocol: "); + LWS_CPYAPP_TOKEN(p, WSI_TOKEN_PROTOCOL); + } + + /* + * Figure out which extensions the client has that we want to + * enable on this connection, and give him back the list + */ + + if (wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token_len) { + + /* + * break down the list of client extensions + * and go through them + */ + + c = wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token; + debug("wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token = %s\n", + wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token); + wsi->count_active_extensions = 0; + n = 0; + while (more) { + + if (*c && (*c != ',' && *c != ' ' && *c != '\t')) { + ext_name[n] = *c++; + if (n < sizeof(ext_name) - 1) + n++; + continue; + } + ext_name[n] = '\0'; + if (!*c) + more = 0; + else { + c++; + if (!n) + continue; + } + + /* check a client's extension against our support */ + + ext = wsi->protocol->owning_server->extensions; + + while (ext && ext->callback) { + + if (strcmp(ext_name, ext->name)) { + ext++; + continue; + } + + /* + * oh, we do support this one he + * asked for... but let's ask user + * code if it's OK to apply it on this + * particular connection + protocol + */ + + n = wsi->protocol->owning_server-> + protocols[0].callback( + wsi->protocol->owning_server, + wsi, + LWS_CALLBACK_CONFIRM_EXTENSION_OKAY, + wsi->user_space, ext_name, 0); + + /* + * zero return from callback means + * go ahead and allow the extension, + * it's what we get if the callback is + * unhandled + */ + + if (n) { + ext++; + continue; + } + + /* apply it */ + + if (ext_count) + *p++ = ','; + else + LWS_CPYAPP(p, + "\x0d\x0aSec-WebSocket-Extensions: "); + p += sprintf(p, "%s", ext_name); + ext_count++; + + /* instantiate the extension on this conn */ + + wsi->active_extensions_user[ + wsi->count_active_extensions] = + malloc(ext->per_session_data_size); + memset(wsi->active_extensions_user[ + wsi->count_active_extensions], 0, + ext->per_session_data_size); + + wsi->active_extensions[ + wsi->count_active_extensions] = ext; + + /* allow him to construct his context */ + + ext->callback(wsi->protocol->owning_server, + ext, wsi, + LWS_EXT_CALLBACK_CONSTRUCT, + wsi->active_extensions_user[ + wsi->count_active_extensions], NULL, 0); + + wsi->count_active_extensions++; + debug("wsi->count_active_extensions <- %d", + wsi->count_active_extensions); + + ext++; + } + + n = 0; + } + } + + /* end of response packet */ + + LWS_CPYAPP(p, "\x0d\x0a\x0d\x0a"); + + if (wsi->ietf_spec_revision == 4) { + + /* + * precompute the masking key the client will use from the SHA1 + * hash of ( base 64 client key we were sent, concatenated with + * the bse 64 nonce we sent, concatenated with a magic constant + * guid specified by the 04 standard ) + * + * We store the hash in the connection's wsi ready to use with + * undoing the masking the client has done on framed data it + * sends (we send our data to the client in clear). + */ + + strcpy(mask_summing_buf, wsi->utf8_token[WSI_TOKEN_KEY].token); + m += wsi->utf8_token[WSI_TOKEN_KEY].token_len; + strcpy(m, nonce_buf); + m += nonce_len; + strcpy(m, websocket_magic_guid_04_masking); + m += strlen(websocket_magic_guid_04_masking); + + SHA1((unsigned char *)mask_summing_buf, m - mask_summing_buf, + wsi->masking_key_04); + } + + if (!lws_any_extension_handled(context, wsi, + LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX, + response, p - response)) { + + /* okay send the handshake response accepting the connection */ + + debug("issuing response packet %d len\n", (int)(p - response)); + #ifdef DEBUG + fwrite(response, 1, p - response, stderr); + #endif + n = libwebsocket_write(wsi, (unsigned char *)response, + p - response, LWS_WRITE_HTTP); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + goto bail; + } + + } + + /* alright clean up and set ourselves into established state */ + + free(response); + wsi->state = WSI_STATE_ESTABLISHED; + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + wsi->rx_packet_length = 0; + + /* notify user code that we're ready to roll */ + + if (wsi->protocol->callback) + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_ESTABLISHED, + wsi->user_space, NULL, 0); + + return 0; + + +bail: + return -1; +} + + +/* + * -04 of the protocol (actually the 80th version) has a radically different + * handshake. The 04 spec gives the following idea + * + * The handshake from the client looks as follows: + * + * GET /chat HTTP/1.1 + * Host: server.example.com + * Upgrade: websocket + * Connection: Upgrade + * Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== + * Sec-WebSocket-Origin: http://example.com + * Sec-WebSocket-Protocol: chat, superchat + * Sec-WebSocket-Version: 4 + * + * The handshake from the server looks as follows: + * + * HTTP/1.1 101 Switching Protocols + * Upgrade: websocket + * Connection: Upgrade + * Sec-WebSocket-Accept: me89jWimTRKTWwrS3aRrL53YZSo= + * Sec-WebSocket-Nonce: AQIDBAUGBwgJCgsMDQ4PEC== + * Sec-WebSocket-Protocol: chat + */ + +/* + * We have to take care about parsing because the headers may be split + * into multiple fragments. They may contain unknown headers with arbitrary + * argument lengths. So, we parse using a single-character at a time state + * machine that is completely independent of packet size. + */ + +int +libwebsocket_read(struct libwebsocket_context *context, + struct libwebsocket *wsi, unsigned char * buf, size_t len) +{ + size_t n; + + switch (wsi->state) { + case WSI_STATE_HTTP: + wsi->state = WSI_STATE_HTTP_HEADERS; + wsi->parser_state = WSI_TOKEN_NAME_PART; + /* fallthru */ + case WSI_STATE_HTTP_HEADERS: + + debug("issuing %d bytes to parser\n", (int)len); +#ifdef DEBUG + fwrite(buf, 1, len, stderr); +#endif + + switch (wsi->mode) { + case LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY: + case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE: + case LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY: + case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT: + case LWS_CONNMODE_WS_CLIENT: + for (n = 0; n < len; n++) + libwebsocket_client_rx_sm(wsi, *buf++); + + return 0; + default: + break; + } + + /* LWS_CONNMODE_WS_SERVING */ + + for (n = 0; n < len; n++) + libwebsocket_parse(wsi, *buf++); + + if (wsi->parser_state != WSI_PARSING_COMPLETE) + break; + + debug("seem to be serving, mode is %d\n", wsi->mode); + + debug("libwebsocket_parse sees parsing complete\n"); + + /* is this websocket protocol or normal http 1.0? */ + + if (!wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len || + !wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len) { + wsi->state = WSI_STATE_HTTP; + if (wsi->protocol->callback) + (wsi->protocol->callback)(context, wsi, + LWS_CALLBACK_HTTP, wsi->user_space, + wsi->utf8_token[WSI_TOKEN_GET_URI].token, 0); + return 0; + } + + if (!wsi->protocol) + fprintf(stderr, "NULL protocol at libwebsocket_read\n"); + + /* + * It's websocket + * + * Make sure user side is happy about protocol + */ + + while (wsi->protocol->callback) { + + if (wsi->utf8_token[WSI_TOKEN_PROTOCOL].token == NULL) { + if (wsi->protocol->name == NULL) + break; + } else + if (wsi->protocol->name && strcmp( + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token, + wsi->protocol->name) == 0) + break; + + wsi->protocol++; + } + + /* we didn't find a protocol he wanted? */ + + if (wsi->protocol->callback == NULL) { + if (wsi->utf8_token[WSI_TOKEN_PROTOCOL].token == NULL) + fprintf(stderr, "[no protocol] " + "not supported (use NULL .name)\n"); + else + fprintf(stderr, "Requested protocol %s " + "not supported\n", + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token); + goto bail; + } + + /* + * find out which spec version the client is using + * if this header is not given, we default to 00 (aka 76) + */ + + if (wsi->utf8_token[WSI_TOKEN_VERSION].token_len) + wsi->ietf_spec_revision = + atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token); + + /* + * Give the user code a chance to study the request and + * have the opportunity to deny it + */ + + if ((wsi->protocol->callback)(wsi->protocol->owning_server, wsi, + LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION, + &wsi->utf8_token[0], NULL, 0)) { + fprintf(stderr, "User code denied connection\n"); + goto bail; + } + + + /* + * Perform the handshake according to the protocol version the + * client announced + */ + + switch (wsi->ietf_spec_revision) { + case 0: /* applies to 76 and 00 */ + wsi->xor_mask = xor_no_mask; + if (handshake_00(context, wsi)) + goto bail; + break; + case 4: /* 04 */ + wsi->xor_mask = xor_mask_04; + debug("libwebsocket_parse calling handshake_04\n"); + if (handshake_0405(context, wsi)) + goto bail; + break; + case 5: + case 6: + case 7: + case 8: + case 13: + wsi->xor_mask = xor_mask_05; + debug("libwebsocket_parse calling handshake_04\n"); + if (handshake_0405(context, wsi)) + goto bail; + break; + + default: + fprintf(stderr, "Unknown client spec version %d\n", + wsi->ietf_spec_revision); + goto bail; + } + + debug("accepted v%02d connection\n", + wsi->ietf_spec_revision); + + break; + + case WSI_STATE_AWAITING_CLOSE_ACK: + case WSI_STATE_ESTABLISHED: + switch (wsi->mode) { + case LWS_CONNMODE_WS_CLIENT: + for (n = 0; n < len; n++) + if (libwebsocket_client_rx_sm(wsi, *buf++) < 0) + goto bail; + + return 0; + default: + break; + } + + /* LWS_CONNMODE_WS_SERVING */ + + if (libwebsocket_interpret_incoming_packet(wsi, buf, len) < 0) + goto bail; + + break; + default: + break; + } + + return 0; + +bail: + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + + return -1; +} diff --git a/libs/libwebsockets/lib/libwebsockets.c b/libs/libwebsockets/lib/libwebsockets.c new file mode 100644 index 0000000000..03147e16fd --- /dev/null +++ b/libs/libwebsockets/lib/libwebsockets.c @@ -0,0 +1,3183 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "private-libwebsockets.h" + +#ifdef WIN32 + +#else +#include +#include +#include +#include +#endif + +#ifdef LWS_OPENSSL_SUPPORT +int openssl_websocket_private_data_index; +#endif + +#ifdef __MINGW32__ +#include "../win32port/win32helpers/websock-w32.c" +#else +#ifdef __MINGW64__ +#include "../win32port/win32helpers/websock-w32.c" +#endif +#endif + +/* + * In-place str to lower case + */ + +static void +strtolower(char *s) +{ + while (*s) { + *s = tolower(*s); + s++; + } +} + +/* file descriptor hash management */ + +struct libwebsocket * +wsi_from_fd(struct libwebsocket_context *context, int fd) +{ + int h = LWS_FD_HASH(fd); + int n = 0; + + for (n = 0; n < context->fd_hashtable[h].length; n++) + if (context->fd_hashtable[h].wsi[n]->sock == fd) + return context->fd_hashtable[h].wsi[n]; + + return NULL; +} + +int +insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi) +{ + int h = LWS_FD_HASH(wsi->sock); + + if (context->fd_hashtable[h].length == MAX_CLIENTS - 1) { + fprintf(stderr, "hash table overflow\n"); + return 1; + } + + context->fd_hashtable[h].wsi[context->fd_hashtable[h].length++] = wsi; + + return 0; +} + +int +delete_from_fd(struct libwebsocket_context *context, int fd) +{ + int h = LWS_FD_HASH(fd); + int n = 0; + + for (n = 0; n < context->fd_hashtable[h].length; n++) + if (context->fd_hashtable[h].wsi[n]->sock == fd) { + while (n < context->fd_hashtable[h].length) { + context->fd_hashtable[h].wsi[n] = + context->fd_hashtable[h].wsi[n + 1]; + n++; + } + context->fd_hashtable[h].length--; + + return 0; + } + + fprintf(stderr, "Failed to find fd %d requested for " + "delete in hashtable\n", fd); + return 1; +} + +#ifdef LWS_OPENSSL_SUPPORT +static void +libwebsockets_decode_ssl_error(void) +{ + char buf[256]; + u_long err; + + while ((err = ERR_get_error()) != 0) { + ERR_error_string_n(err, buf, sizeof(buf)); + fprintf(stderr, "*** %s\n", buf); + } +} +#endif + + +static int +interface_to_sa(const char *ifname, struct sockaddr_in *addr, size_t addrlen) +{ + int rc = -1; +#ifdef WIN32 + /* TODO */ +#else + struct ifaddrs *ifr; + struct ifaddrs *ifc; + struct sockaddr_in *sin; + + getifaddrs(&ifr); + for (ifc = ifr; ifc != NULL; ifc = ifc->ifa_next) { + if (strcmp(ifc->ifa_name, ifname)) + continue; + if (ifc->ifa_addr == NULL) + continue; + sin = (struct sockaddr_in *)ifc->ifa_addr; + if (sin->sin_family != AF_INET) + continue; + memcpy(addr, sin, addrlen); + rc = 0; + } + + freeifaddrs(ifr); +#endif + return rc; +} + +void +libwebsocket_close_and_free_session(struct libwebsocket_context *context, + struct libwebsocket *wsi, enum lws_close_status reason) +{ + int n; + int old_state; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 2 + + LWS_SEND_BUFFER_POST_PADDING]; + int ret; + int m; + struct lws_tokens eff_buf; + struct libwebsocket_extension *ext; + + if (!wsi) + return; + + old_state = wsi->state; + + if (old_state == WSI_STATE_DEAD_SOCKET) + return; + + wsi->close_reason = reason; + + /* + * are his extensions okay with him closing? Eg he might be a mux + * parent and just his ch1 aspect is closing? + */ + + + for (n = 0; n < wsi->count_active_extensions; n++) { + if (!wsi->active_extensions[n]->callback) + continue; + + m = wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE, + wsi->active_extensions_user[n], NULL, 0); + + /* + * if somebody vetoed actually closing him at this time.... + * up to the extension to track the attempted close, let's + * just bail + */ + + if (m) { + debug("extension vetoed close\n"); + return; + } + } + + + + /* + * flush any tx pending from extensions, since we may send close packet + * if there are problems with send, just nuke the connection + */ + + ret = 1; + while (ret == 1) { + + /* default to nobody has more to spill */ + + ret = 0; + eff_buf.token = NULL; + eff_buf.token_len = 0; + + /* show every extension the new incoming data */ + + for (n = 0; n < wsi->count_active_extensions; n++) { + m = wsi->active_extensions[n]->callback( + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_FLUSH_PENDING_TX, + wsi->active_extensions_user[n], &eff_buf, 0); + if (m < 0) { + fprintf(stderr, "Extension reports " + "fatal error\n"); + goto just_kill_connection; + } + if (m) + /* + * at least one extension told us he has more + * to spill, so we will go around again after + */ + ret = 1; + } + + /* assuming they left us something to send, send it */ + + if (eff_buf.token_len) + if (lws_issue_raw(wsi, (unsigned char *)eff_buf.token, + eff_buf.token_len)) + goto just_kill_connection; + } + + /* + * signal we are closing, libsocket_write will + * add any necessary version-specific stuff. If the write fails, + * no worries we are closing anyway. If we didn't initiate this + * close, then our state has been changed to + * WSI_STATE_RETURNED_CLOSE_ALREADY and we will skip this. + * + * Likewise if it's a second call to close this connection after we + * sent the close indication to the peer already, we are in state + * WSI_STATE_AWAITING_CLOSE_ACK and will skip doing this a second time. + */ + + if (old_state == WSI_STATE_ESTABLISHED && + reason != LWS_CLOSE_STATUS_NOSTATUS) { + + debug("sending close indication...\n"); + + n = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], + 0, LWS_WRITE_CLOSE); + if (!n) { + /* + * we have sent a nice protocol level indication we + * now wish to close, we should not send anything more + */ + + wsi->state = WSI_STATE_AWAITING_CLOSE_ACK; + + /* and we should wait for a reply for a bit */ + + libwebsocket_set_timeout(wsi, + PENDING_TIMEOUT_CLOSE_ACK, 5); + + debug("sent close indication, awaiting ack\n"); + + return; + } + + /* else, the send failed and we should just hang up */ + } + +just_kill_connection: + + debug("libwebsocket_close_and_free_session: just_kill_connection\n"); + + /* + * we won't be servicing or receiving anything further from this guy + * remove this fd from wsi mapping hashtable + */ + + if (wsi->sock) + delete_from_fd(context, wsi->sock); + + /* delete it from the internal poll list if still present */ + + for (n = 0; n < context->fds_count; n++) { + if (context->fds[n].fd != wsi->sock) + continue; + while (n < context->fds_count - 1) { + context->fds[n] = context->fds[n + 1]; + n++; + } + context->fds_count--; + /* we only have to deal with one */ + n = context->fds_count; + } + + /* remove also from external POLL support via protocol 0 */ + if (wsi->sock) + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_DEL_POLL_FD, (void *)(long)wsi->sock, NULL, 0); + + wsi->state = WSI_STATE_DEAD_SOCKET; + + /* tell the user it's all over for this guy */ + + if (wsi->protocol && wsi->protocol->callback && + ((old_state == WSI_STATE_ESTABLISHED) || + (old_state == WSI_STATE_RETURNED_CLOSE_ALREADY) || + (old_state == WSI_STATE_AWAITING_CLOSE_ACK))) { + debug("calling back CLOSED\n"); + wsi->protocol->callback(context, wsi, LWS_CALLBACK_CLOSED, + wsi->user_space, NULL, 0); + } else + debug("not calling back closed, old_state=%d\n", old_state); + + /* deallocate any active extension contexts */ + + for (n = 0; n < wsi->count_active_extensions; n++) { + if (!wsi->active_extensions[n]->callback) + continue; + + wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_DESTROY, + wsi->active_extensions_user[n], NULL, 0); + + free(wsi->active_extensions_user[n]); + } + + /* + * inform all extensions in case they tracked this guy out of band + * even though not active on him specifically + */ + + ext = context->extensions; + while (ext && ext->callback) { + ext->callback(context, ext, wsi, + LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING, + NULL, NULL, 0); + ext++; + } + + /* free up his parsing allocations */ + + for (n = 0; n < WSI_TOKEN_COUNT; n++) + if (wsi->utf8_token[n].token) + free(wsi->utf8_token[n].token); + + if (wsi->c_address) + free(wsi->c_address); + +/* fprintf(stderr, "closing fd=%d\n", wsi->sock); */ + +#ifdef LWS_OPENSSL_SUPPORT + if (wsi->ssl) { + n = SSL_get_fd(wsi->ssl); + SSL_shutdown(wsi->ssl); +#ifdef WIN32 + closesocket(n); +#else + close(n); +#endif + SSL_free(wsi->ssl); + } else { +#endif + shutdown(wsi->sock, SHUT_RDWR); +#ifdef WIN32 + if (wsi->sock) + closesocket(wsi->sock); +#else + if (wsi->sock) + close(wsi->sock); +#endif +#ifdef LWS_OPENSSL_SUPPORT + } +#endif + if (wsi->protocol && wsi->protocol->per_session_data_size && wsi->user_space) /* user code may own */ + free(wsi->user_space); + + free(wsi); +} + +/** + * libwebsockets_hangup_on_client() - Server calls to terminate client + * connection + * @context: libwebsockets context + * @fd: Connection socket descriptor + */ + +void +libwebsockets_hangup_on_client(struct libwebsocket_context *context, int fd) +{ + struct libwebsocket *wsi = wsi_from_fd(context, fd); + + if (wsi == NULL) + return; + + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); +} + + +/** + * libwebsockets_get_peer_addresses() - Get client address information + * @fd: Connection socket descriptor + * @name: Buffer to take client address name + * @name_len: Length of client address name buffer + * @rip: Buffer to take client address IP qotted quad + * @rip_len: Length of client address IP buffer + * + * This function fills in @name and @rip with the name and IP of + * the client connected with socket descriptor @fd. Names may be + * truncated if there is not enough room. If either cannot be + * determined, they will be returned as valid zero-length strings. + */ + +void +libwebsockets_get_peer_addresses(int fd, char *name, int name_len, + char *rip, int rip_len) +{ + unsigned int len; + struct sockaddr_in sin; + struct hostent *host; + struct hostent *host1; + char ip[128]; + unsigned char *p; + int n; + struct sockaddr_un *un; + + rip[0] = '\0'; + name[0] = '\0'; + + len = sizeof sin; + if (getpeername(fd, (struct sockaddr *) &sin, &len) < 0) { + perror("getpeername"); + return; + } + + host = gethostbyaddr((char *) &sin.sin_addr, sizeof sin.sin_addr, + AF_INET); + if (host == NULL) { + perror("gethostbyaddr"); + return; + } + + strncpy(name, host->h_name, name_len); + name[name_len - 1] = '\0'; + + host1 = gethostbyname(host->h_name); + if (host1 == NULL) + return; + p = (unsigned char *)host1; + n = 0; + while (p != NULL) { + p = (unsigned char *)host1->h_addr_list[n++]; + if (p == NULL) + continue; + if ((host1->h_addrtype != AF_INET) +#ifdef AF_LOCAL + && (host1->h_addrtype != AF_LOCAL) +#endif + ) + continue; + + if (host1->h_addrtype == AF_INET) + sprintf(ip, "%u.%u.%u.%u", p[0], p[1], p[2], p[3]); +#ifdef AF_LOCAL + else { + un = (struct sockaddr_un *)p; + strncpy(ip, un->sun_path, sizeof(ip) - 1); + ip[sizeof(ip) - 1] = '\0'; + } +#endif + p = NULL; + strncpy(rip, ip, rip_len); + rip[rip_len - 1] = '\0'; + } +} + +int libwebsockets_get_random(struct libwebsocket_context *context, + void *buf, int len) +{ + int n; + char *p = buf; + +#ifdef WIN32 + for (n = 0; n < len; n++) + p[n] = (unsigned char)rand(); +#else + n = read(context->fd_random, p, len); +#endif + + return n; +} + +unsigned char * +libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md) +{ + return SHA1(d, n, md); +} + +void libwebsockets_00_spaceout(char *key, int spaces, int seed) +{ + char *p; + + key++; + while (spaces--) { + if (*key && (seed & 1)) + key++; + seed >>= 1; + + p = key + strlen(key); + while (p >= key) { + p[1] = p[0]; + p--; + } + *key++ = ' '; + } +} + +void libwebsockets_00_spam(char *key, int count, int seed) +{ + char *p; + + key++; + while (count--) { + + if (*key && (seed & 1)) + key++; + seed >>= 1; + + p = key + strlen(key); + while (p >= key) { + p[1] = p[0]; + p--; + } + *key++ = 0x21 + ((seed & 0xffff) % 15); + /* 4 would use it up too fast.. not like it matters */ + seed >>= 1; + } +} + +int lws_send_pipe_choked(struct libwebsocket *wsi) +{ + struct pollfd fds; + + fds.fd = wsi->sock; + fds.events = POLLOUT; + fds.revents = 0; + + if (poll(&fds, 1, 0) != 1) + return 1; + + if ((fds.revents & POLLOUT) == 0) + return 1; + + /* okay to send another packet without blocking */ + + return 0; +} + +int +lws_handle_POLLOUT_event(struct libwebsocket_context *context, + struct libwebsocket *wsi, struct pollfd *pollfd) +{ + struct lws_tokens eff_buf; + int n; + int ret; + int m; + int handled = 0; + + for (n = 0; n < wsi->count_active_extensions; n++) { + if (!wsi->active_extensions[n]->callback) + continue; + + m = wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_IS_WRITEABLE, + wsi->active_extensions_user[n], NULL, 0); + if (m > handled) + handled = m; + } + + if (handled == 1) + goto notify_action; + + if (!wsi->extension_data_pending || handled == 2) + goto user_service; + + /* + * check in on the active extensions, see if they + * had pending stuff to spill... they need to get the + * first look-in otherwise sequence will be disordered + * + * NULL, zero-length eff_buf means just spill pending + */ + + ret = 1; + while (ret == 1) { + + /* default to nobody has more to spill */ + + ret = 0; + eff_buf.token = NULL; + eff_buf.token_len = 0; + + /* give every extension a chance to spill */ + + for (n = 0; n < wsi->count_active_extensions; n++) { + m = wsi->active_extensions[n]->callback( + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_PACKET_TX_PRESEND, + wsi->active_extensions_user[n], &eff_buf, 0); + if (m < 0) { + fprintf(stderr, "ext reports fatal error\n"); + return -1; + } + if (m) + /* + * at least one extension told us he has more + * to spill, so we will go around again after + */ + ret = 1; + } + + /* assuming they gave us something to send, send it */ + + if (eff_buf.token_len) { + if (lws_issue_raw(wsi, (unsigned char *)eff_buf.token, + eff_buf.token_len)) + return -1; + } else + continue; + + /* no extension has more to spill */ + + if (!ret) + continue; + + /* + * There's more to spill from an extension, but we just sent + * something... did that leave the pipe choked? + */ + + if (!lws_send_pipe_choked(wsi)) + /* no we could add more */ + continue; + + debug("choked in POLLOUT service\n"); + + /* + * Yes, he's choked. Leave the POLLOUT masked on so we will + * come back here when he is unchoked. Don't call the user + * callback to enforce ordering of spilling, he'll get called + * when we come back here and there's nothing more to spill. + */ + + return 0; + } + + wsi->extension_data_pending = 0; + +user_service: + /* one shot */ + + if (pollfd) { + pollfd->events &= ~POLLOUT; + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_CLEAR_MODE_POLL_FD, + (void *)(long)wsi->sock, NULL, POLLOUT); + } + +notify_action: + + if (wsi->mode == LWS_CONNMODE_WS_CLIENT) + n = LWS_CALLBACK_CLIENT_WRITEABLE; + else + n = LWS_CALLBACK_SERVER_WRITEABLE; + + wsi->protocol->callback(context, wsi, n, wsi->user_space, NULL, 0); + + return 0; +} + + + +void +libwebsocket_service_timeout_check(struct libwebsocket_context *context, + struct libwebsocket *wsi, unsigned int sec) +{ + int n; + + /* + * if extensions want in on it (eg, we are a mux parent) + * give them a chance to service child timeouts + */ + + for (n = 0; n < wsi->count_active_extensions; n++) + wsi->active_extensions[n]->callback( + context, wsi->active_extensions[n], + wsi, LWS_EXT_CALLBACK_1HZ, + wsi->active_extensions_user[n], NULL, sec); + + if (!wsi->pending_timeout) + return; + + /* + * if we went beyond the allowed time, kill the + * connection + */ + + if (sec > wsi->pending_timeout_limit) { + debug("TIMEDOUT WAITING\n"); + libwebsocket_close_and_free_session(context, + wsi, LWS_CLOSE_STATUS_NOSTATUS); + } +} + +struct libwebsocket * +libwebsocket_create_new_server_wsi(struct libwebsocket_context *context) +{ + struct libwebsocket *new_wsi; + int n; + + new_wsi = malloc(sizeof(struct libwebsocket)); + if (new_wsi == NULL) { + fprintf(stderr, "Out of memory for new connection\n"); + return NULL; + } + + memset(new_wsi, 0, sizeof(struct libwebsocket)); + new_wsi->count_active_extensions = 0; + new_wsi->pending_timeout = NO_PENDING_TIMEOUT; + + /* intialize the instance struct */ + + new_wsi->state = WSI_STATE_HTTP; + new_wsi->name_buffer_pos = 0; + new_wsi->mode = LWS_CONNMODE_WS_SERVING; + + for (n = 0; n < WSI_TOKEN_COUNT; n++) { + new_wsi->utf8_token[n].token = NULL; + new_wsi->utf8_token[n].token_len = 0; + } + + /* + * these can only be set once the protocol is known + * we set an unestablished connection's protocol pointer + * to the start of the supported list, so it can look + * for matching ones during the handshake + */ + new_wsi->protocol = context->protocols; + new_wsi->user_space = NULL; + + /* + * Default protocol is 76 / 00 + * After 76, there's a header specified to inform which + * draft the client wants, when that's seen we modify + * the individual connection's spec revision accordingly + */ + new_wsi->ietf_spec_revision = 0; + + return new_wsi; +} + +char * +libwebsockets_generate_client_handshake(struct libwebsocket_context *context, + struct libwebsocket *wsi, char *pkt) +{ + char hash[20]; + char *p = pkt; + int n; + struct libwebsocket_extension *ext; + struct libwebsocket_extension *ext1; + int ext_count = 0; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1 + + MAX_BROADCAST_PAYLOAD + LWS_SEND_BUFFER_POST_PADDING]; + static const char magic_websocket_guid[] = + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + + /* + * create the random key + */ + + n = libwebsockets_get_random(context, hash, 16); + if (n != 16) { + fprintf(stderr, "Unable to read from random dev %s\n", + SYSTEM_RANDOM_FILEPATH); + free(wsi->c_path); + free(wsi->c_host); + if (wsi->c_origin) + free(wsi->c_origin); + if (wsi->c_protocol) + free(wsi->c_protocol); + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return NULL; + } + + lws_b64_encode_string(hash, 16, wsi->key_b64, + sizeof wsi->key_b64); + + /* + * 00 example client handshake + * + * GET /socket.io/websocket HTTP/1.1 + * Upgrade: WebSocket + * Connection: Upgrade + * Host: 127.0.0.1:9999 + * Origin: http://127.0.0.1 + * Sec-WebSocket-Key1: 1 0 2#0W 9 89 7 92 ^ + * Sec-WebSocket-Key2: 7 7Y 4328 B2v[8(z1 + * Cookie: socketio=websocket + * + * (îÄ0¶†≥ + * + * 04 example client handshake + * + * GET /chat HTTP/1.1 + * Host: server.example.com + * Upgrade: websocket + * Connection: Upgrade + * Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== + * Sec-WebSocket-Origin: http://example.com + * Sec-WebSocket-Protocol: chat, superchat + * Sec-WebSocket-Version: 4 + */ + + p += sprintf(p, "GET %s HTTP/1.1\x0d\x0a", wsi->c_path); + + if (wsi->ietf_spec_revision == 0) { + unsigned char spaces_1, spaces_2; + unsigned int max_1, max_2; + unsigned int num_1, num_2; + unsigned long product_1, product_2; + char key_1[40]; + char key_2[40]; + unsigned int seed; + unsigned int count; + char challenge[16]; + + libwebsockets_get_random(context, &spaces_1, sizeof(char)); + libwebsockets_get_random(context, &spaces_2, sizeof(char)); + + spaces_1 = (spaces_1 % 12) + 1; + spaces_2 = (spaces_2 % 12) + 1; + + max_1 = 4294967295 / spaces_1; + max_2 = 4294967295 / spaces_2; + + libwebsockets_get_random(context, &num_1, sizeof(int)); + libwebsockets_get_random(context, &num_2, sizeof(int)); + + num_1 = (num_1 % max_1); + num_2 = (num_2 % max_2); + + challenge[0] = num_1 >> 24; + challenge[1] = num_1 >> 16; + challenge[2] = num_1 >> 8; + challenge[3] = num_1; + challenge[4] = num_2 >> 24; + challenge[5] = num_2 >> 16; + challenge[6] = num_2 >> 8; + challenge[7] = num_2; + + product_1 = num_1 * spaces_1; + product_2 = num_2 * spaces_2; + + sprintf(key_1, "%lu", product_1); + sprintf(key_2, "%lu", product_2); + + libwebsockets_get_random(context, &seed, sizeof(int)); + libwebsockets_get_random(context, &count, sizeof(int)); + + libwebsockets_00_spam(key_1, (count % 12) + 1, seed); + + libwebsockets_get_random(context, &seed, sizeof(int)); + libwebsockets_get_random(context, &count, sizeof(int)); + + libwebsockets_00_spam(key_2, (count % 12) + 1, seed); + + libwebsockets_get_random(context, &seed, sizeof(int)); + + libwebsockets_00_spaceout(key_1, spaces_1, seed); + libwebsockets_00_spaceout(key_2, spaces_2, seed >> 16); + + p += sprintf(p, "Upgrade: WebSocket\x0d\x0a" + "Connection: Upgrade\x0d\x0aHost: %s\x0d\x0a", + wsi->c_host); + if (wsi->c_origin) + p += sprintf(p, "Origin: %s\x0d\x0a", wsi->c_origin); + + if (wsi->c_protocol) + p += sprintf(p, "Sec-WebSocket-Protocol: %s" + "\x0d\x0a", wsi->c_protocol); + + p += sprintf(p, "Sec-WebSocket-Key1: %s\x0d\x0a", key_1); + p += sprintf(p, "Sec-WebSocket-Key2: %s\x0d\x0a", key_2); + + /* give userland a chance to append, eg, cookies */ + + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, + NULL, &p, (pkt + sizeof(pkt)) - p - 12); + + p += sprintf(p, "\x0d\x0a"); + + if (libwebsockets_get_random(context, p, 8) != 8) + return NULL; + memcpy(&challenge[8], p, 8); + p += 8; + + /* precompute what we want to see from the server */ + + MD5((unsigned char *)challenge, 16, + (unsigned char *)wsi->initial_handshake_hash_base64); + + goto issue_hdr; + } + + p += sprintf(p, "Host: %s\x0d\x0a", wsi->c_host); + p += sprintf(p, "Upgrade: websocket\x0d\x0a"); + p += sprintf(p, "Connection: Upgrade\x0d\x0a" + "Sec-WebSocket-Key: "); + strcpy(p, wsi->key_b64); + p += strlen(wsi->key_b64); + p += sprintf(p, "\x0d\x0a"); + if (wsi->c_origin) + p += sprintf(p, "Sec-WebSocket-Origin: %s\x0d\x0a", + wsi->c_origin); + if (wsi->c_protocol) + p += sprintf(p, "Sec-WebSocket-Protocol: %s\x0d\x0a", + wsi->c_protocol); + + /* tell the server what extensions we could support */ + + p += sprintf(p, "Sec-WebSocket-Extensions: "); + + ext = context->extensions; + while (ext && ext->callback) { + + n = 0; + ext1 = context->extensions; + + while (ext1 && ext1->callback) { + n |= ext1->callback(context, ext1, wsi, + LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION, + NULL, (char *)ext->name, 0); + + ext1++; + } + + if (n) { /* an extension vetos us */ + debug("ext %s vetoed\n", (char *)ext->name); + ext++; + continue; + } + + n = context->protocols[0].callback(context, wsi, + LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED, + wsi->user_space, (char *)ext->name, 0); + + /* + * zero return from callback means + * go ahead and allow the extension, + * it's what we get if the callback is + * unhandled + */ + + if (n) { + ext++; + continue; + } + + /* apply it */ + + if (ext_count) + *p++ = ','; + p += sprintf(p, "%s", ext->name); + ext_count++; + + ext++; + } + + p += sprintf(p, "\x0d\x0a"); + + if (wsi->ietf_spec_revision) + p += sprintf(p, "Sec-WebSocket-Version: %d\x0d\x0a", + wsi->ietf_spec_revision); + + /* give userland a chance to append, eg, cookies */ + + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, + NULL, &p, (pkt + sizeof(pkt)) - p - 12); + + p += sprintf(p, "\x0d\x0a"); + + /* prepare the expected server accept response */ + + strcpy((char *)buf, wsi->key_b64); + strcpy((char *)&buf[strlen((char *)buf)], magic_websocket_guid); + + SHA1(buf, strlen((char *)buf), (unsigned char *)hash); + + lws_b64_encode_string(hash, 20, + wsi->initial_handshake_hash_base64, + sizeof wsi->initial_handshake_hash_base64); + +issue_hdr: + +#if 0 + puts(pkt); +#endif + + /* done with these now */ + + free(wsi->c_path); + free(wsi->c_host); + if (wsi->c_origin) + free(wsi->c_origin); + + return p; +} + +int +lws_client_interpret_server_handshake(struct libwebsocket_context *context, + struct libwebsocket *wsi) +{ + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1 + + MAX_BROADCAST_PAYLOAD + LWS_SEND_BUFFER_POST_PADDING]; + char pkt[1024]; + char *p = &pkt[0]; + const char *pc; + const char *c; + int more = 1; + int okay = 0; + char ext_name[128]; + struct libwebsocket_extension *ext; + void *v; + int len = 0; + int n; + static const char magic_websocket_04_masking_guid[] = + "61AC5F19-FBBA-4540-B96F-6561F1AB40A8"; + + /* + * 00 / 76 --> + * + * HTTP/1.1 101 WebSocket Protocol Handshake + * Upgrade: WebSocket + * Connection: Upgrade + * Sec-WebSocket-Origin: http://127.0.0.1 + * Sec-WebSocket-Location: ws://127.0.0.1:9999/socket.io/websocket + * + * xxxxxxxxxxxxxxxx + */ + + if (wsi->ietf_spec_revision == 0) { + if (!wsi->utf8_token[WSI_TOKEN_HTTP].token_len || + !wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len || + !wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len || + !wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len || + (!wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len && + wsi->c_protocol != NULL)) { + debug("libwebsocket_client_handshake " + "missing required header(s)\n"); + pkt[len] = '\0'; + debug("%s", pkt); + goto bail3; + } + + strtolower(wsi->utf8_token[WSI_TOKEN_HTTP].token); + if (strncmp(wsi->utf8_token[WSI_TOKEN_HTTP].token, "101", 3)) { + fprintf(stderr, "libwebsocket_client_handshake " + "server sent bad HTTP response '%s'\n", + wsi->utf8_token[WSI_TOKEN_HTTP].token); + goto bail3; + } + + if (wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len < 16) { + fprintf(stderr, "libwebsocket_client_handshake " + "challenge reply too short %d\n", + wsi->utf8_token[ + WSI_TOKEN_CHALLENGE].token_len); + pkt[len] = '\0'; + debug("%s", pkt); + goto bail3; + + } + + goto select_protocol; + } + + /* + * well, what the server sent looked reasonable for syntax. + * Now let's confirm it sent all the necessary headers + */ +#if 0 + fprintf(stderr, "WSI_TOKEN_HTTP: %d\n", + wsi->utf8_token[WSI_TOKEN_HTTP].token_len); + fprintf(stderr, "WSI_TOKEN_UPGRADE: %d\n", + wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len); + fprintf(stderr, "WSI_TOKEN_CONNECTION: %d\n", + wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len); + fprintf(stderr, "WSI_TOKEN_ACCEPT: %d\n", + wsi->utf8_token[WSI_TOKEN_ACCEPT].token_len); + fprintf(stderr, "WSI_TOKEN_NONCE: %d\n", + wsi->utf8_token[WSI_TOKEN_NONCE].token_len); + fprintf(stderr, "WSI_TOKEN_PROTOCOL: %d\n", + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len); +#endif + if (!wsi->utf8_token[WSI_TOKEN_HTTP].token_len || + !wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len || + !wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len || + !wsi->utf8_token[WSI_TOKEN_ACCEPT].token_len || + (!wsi->utf8_token[WSI_TOKEN_NONCE].token_len && + wsi->ietf_spec_revision == 4) || + (!wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len && + wsi->c_protocol != NULL)) { + debug("libwebsocket_client_handshake " + "missing required header(s)\n"); + pkt[len] = '\0'; + debug("%s", pkt); + goto bail3; + } + + /* + * Everything seems to be there, now take a closer look at what + * is in each header + */ + + strtolower(wsi->utf8_token[WSI_TOKEN_HTTP].token); + if (strncmp(wsi->utf8_token[WSI_TOKEN_HTTP].token, "101", 3)) { + fprintf(stderr, "libwebsocket_client_handshake " + "server sent bad HTTP response '%s'\n", + wsi->utf8_token[WSI_TOKEN_HTTP].token); + goto bail3; + } + + strtolower(wsi->utf8_token[WSI_TOKEN_UPGRADE].token); + if (strcmp(wsi->utf8_token[WSI_TOKEN_UPGRADE].token, + "websocket")) { + fprintf(stderr, "libwebsocket_client_handshake server " + "sent bad Upgrade header '%s'\n", + wsi->utf8_token[WSI_TOKEN_UPGRADE].token); + goto bail3; + } + + strtolower(wsi->utf8_token[WSI_TOKEN_CONNECTION].token); + if (strcmp(wsi->utf8_token[WSI_TOKEN_CONNECTION].token, + "upgrade")) { + fprintf(stderr, "libwebsocket_client_handshake server " + "sent bad Connection hdr '%s'\n", + wsi->utf8_token[WSI_TOKEN_CONNECTION].token); + goto bail3; + } + +select_protocol: + pc = wsi->c_protocol; + if (pc == NULL) + fprintf(stderr, "lws_client_interpret_server_handshake: " + "NULL c_protocol\n"); + else + debug("lws_client_interpret_server_handshake: " + "cPprotocol='%s'\n", pc); + + /* + * confirm the protocol the server wants to talk was in the list + * of protocols we offered + */ + + if (!wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len) { + + fprintf(stderr, "lws_client_interpret_server_handshake " + "WSI_TOKEN_PROTOCOL is null\n"); + /* + * no protocol name to work from, + * default to first protocol + */ + wsi->protocol = &context->protocols[0]; + wsi->c_callback = wsi->protocol->callback; + free(wsi->c_protocol); + + goto check_accept; + } + + while (*pc && !okay) { + if ((!strncmp(pc, wsi->utf8_token[WSI_TOKEN_PROTOCOL].token, + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len)) && + (pc[wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len] == ',' || + pc[wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len] == '\0')) { + okay = 1; + continue; + } + while (*pc && *pc != ',') + pc++; + while (*pc && *pc != ' ') + pc++; + } + + /* done with him now */ + + if (wsi->c_protocol) + free(wsi->c_protocol); + + if (!okay) { + fprintf(stderr, "libwebsocket_client_handshake server " + "sent bad protocol '%s'\n", + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token); + goto bail2; + } + + /* + * identify the selected protocol struct and set it + */ + n = 0; + wsi->protocol = NULL; + while (context->protocols[n].callback && !wsi->protocol) { /* Stop after finding first one?? */ + if (strcmp(wsi->utf8_token[WSI_TOKEN_PROTOCOL].token, + context->protocols[n].name) == 0) { + wsi->protocol = &context->protocols[n]; + wsi->c_callback = wsi->protocol->callback; + } + n++; + } + + if (wsi->protocol == NULL) { + fprintf(stderr, "libwebsocket_client_handshake server " + "requested protocol '%s', which we " + "said we supported but we don't!\n", + wsi->utf8_token[WSI_TOKEN_PROTOCOL].token); + goto bail2; + } + + + /* instantiate the accepted extensions */ + + if (!wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token_len) { + debug("no client extenstions allowed by server\n"); + goto check_accept; + } + + /* + * break down the list of server accepted extensions + * and go through matching them or identifying bogons + */ + + c = wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token; + n = 0; + while (more) { + + if (*c && (*c != ',' && *c != ' ' && *c != '\t')) { + ext_name[n] = *c++; + if (n < sizeof(ext_name) - 1) + n++; + continue; + } + ext_name[n] = '\0'; + if (!*c) + more = 0; + else { + c++; + if (!n) + continue; + } + + /* check we actually support it */ + + debug("checking client ext %s\n", ext_name); + + n = 0; + ext = wsi->protocol->owning_server->extensions; + while (ext && ext->callback) { + + if (strcmp(ext_name, ext->name)) { + ext++; + continue; + } + + n = 1; + + debug("instantiating client ext %s\n", ext_name); + + /* instantiate the extension on this conn */ + + wsi->active_extensions_user[ + wsi->count_active_extensions] = + malloc(ext->per_session_data_size); + memset(wsi->active_extensions_user[ + wsi->count_active_extensions], 0, + ext->per_session_data_size); + wsi->active_extensions[ + wsi->count_active_extensions] = ext; + + /* allow him to construct his context */ + + ext->callback(wsi->protocol->owning_server, + ext, wsi, + LWS_EXT_CALLBACK_CLIENT_CONSTRUCT, + wsi->active_extensions_user[ + wsi->count_active_extensions], + NULL, 0); + + wsi->count_active_extensions++; + + ext++; + } + + if (n == 0) { + fprintf(stderr, "Server said we should use" + "an unknown extension '%s'!\n", ext_name); + goto bail2; + } + + n = 0; + } + + +check_accept: + + if (wsi->ietf_spec_revision == 0) { + + if (memcmp(wsi->initial_handshake_hash_base64, + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token, 16)) { + fprintf(stderr, "libwebsocket_client_handshake " + "failed 00 challenge compare\n"); + pkt[len] = '\0'; + fprintf(stderr, "%s", pkt); + goto bail2; + } + + goto accept_ok; + } + + /* + * Confirm his accept token is the one we precomputed + */ + + if (strcmp(wsi->utf8_token[WSI_TOKEN_ACCEPT].token, + wsi->initial_handshake_hash_base64)) { + fprintf(stderr, "libwebsocket_client_handshake server " + "sent bad ACCEPT '%s' vs computed '%s'\n", + wsi->utf8_token[WSI_TOKEN_ACCEPT].token, + wsi->initial_handshake_hash_base64); + goto bail2; + } + + if (wsi->ietf_spec_revision == 4) { + /* + * Calculate the 04 masking key to use when + * sending data to server + */ + + strcpy((char *)buf, wsi->key_b64); + p = (char *)buf + strlen(wsi->key_b64); + strcpy(p, wsi->utf8_token[WSI_TOKEN_NONCE].token); + p += wsi->utf8_token[WSI_TOKEN_NONCE].token_len; + strcpy(p, magic_websocket_04_masking_guid); + SHA1(buf, strlen((char *)buf), wsi->masking_key_04); + } +accept_ok: + + /* allocate the per-connection user memory (if any) */ + if (wsi->protocol->per_session_data_size && + !libwebsocket_ensure_user_space(wsi)) + goto bail2; + + /* clear his proxy connection timeout */ + + libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0); + + /* mark him as being alive */ + + wsi->state = WSI_STATE_ESTABLISHED; + wsi->mode = LWS_CONNMODE_WS_CLIENT; + + debug("handshake OK for protocol %s\n", wsi->protocol->name); + + /* call him back to inform him he is up */ + + wsi->protocol->callback(context, wsi, + LWS_CALLBACK_CLIENT_ESTABLISHED, + wsi->user_space, NULL, 0); + + /* + * inform all extensions, not just active ones since they + * already know + */ + + ext = context->extensions; + + while (ext && ext->callback) { + v = NULL; + for (n = 0; n < wsi->count_active_extensions; n++) + if (wsi->active_extensions[n] == ext) + v = wsi->active_extensions_user[n]; + + ext->callback(context, ext, wsi, + LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED, v, NULL, 0); + ext++; + } + + return 0; + +bail3: + if (wsi->c_protocol) + free(wsi->c_protocol); + +bail2: + if (wsi->c_callback) wsi->c_callback(context, wsi, + LWS_CALLBACK_CLIENT_CONNECTION_ERROR, + wsi->user_space, + NULL, 0); + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); // But this should be LWS_CLOSE_STATUS_PROTOCOL_ERR + + return 1; +} + + + +/** + * libwebsocket_service_fd() - Service polled socket with something waiting + * @context: Websocket context + * @pollfd: The pollfd entry describing the socket fd and which events + * happened. + * + * This function closes any active connections and then frees the + * context. After calling this, any further use of the context is + * undefined. + */ + +int +libwebsocket_service_fd(struct libwebsocket_context *context, + struct pollfd *pollfd) +{ + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1 + + MAX_BROADCAST_PAYLOAD + LWS_SEND_BUFFER_POST_PADDING]; + struct libwebsocket *wsi; + struct libwebsocket *new_wsi; + int n; + int m; + ssize_t len; + int accept_fd; + unsigned int clilen; + struct sockaddr_in cli_addr; + struct timeval tv; + char pkt[1024]; + char *p = &pkt[0]; + int more = 1; + struct lws_tokens eff_buf; + int opt = 1; + char c; + +#ifdef LWS_OPENSSL_SUPPORT + char ssl_err_buf[512]; +#endif + /* + * you can call us with pollfd = NULL to just allow the once-per-second + * global timeout checks; if less than a second since the last check + * it returns immediately then. + */ + + gettimeofday(&tv, NULL); + + if (context->last_timeout_check_s != tv.tv_sec) { + context->last_timeout_check_s = tv.tv_sec; + + /* global timeout check once per second */ + + for (n = 0; n < context->fds_count; n++) { + wsi = wsi_from_fd(context, context->fds[n].fd); + + libwebsocket_service_timeout_check(context, wsi, + tv.tv_sec); + } + } + + /* just here for timeout management? */ + + if (pollfd == NULL) + return 0; + + /* no, here to service a socket descriptor */ + + wsi = wsi_from_fd(context, pollfd->fd); + + if (wsi == NULL) + return 1; + + switch (wsi->mode) { + case LWS_CONNMODE_SERVER_LISTENER: + + /* pollin means a client has connected to us then */ + + if (!pollfd->revents & POLLIN) + break; + + if (context->fds_count >= MAX_CLIENTS) { + fprintf(stderr, "too busy to accept new client\n"); + break; + } + + /* listen socket got an unencrypted connection... */ + + clilen = sizeof(cli_addr); + accept_fd = accept(pollfd->fd, (struct sockaddr *)&cli_addr, + &clilen); + if (accept_fd < 0) { + debug("ERROR on accept\n"); + return -1; + } + + /* Disable Nagle */ + opt = 1; + setsockopt(accept_fd, IPPROTO_TCP, TCP_NODELAY, + (const void *)&opt, sizeof(opt)); + + /* + * look at who we connected to and give user code a chance + * to reject based on client IP. There's no protocol selected + * yet so we issue this to protocols[0] + */ + + if ((context->protocols[0].callback)(context, wsi, + LWS_CALLBACK_FILTER_NETWORK_CONNECTION, + (void *)(long)accept_fd, NULL, 0)) { + debug("Callback denied network connection\n"); +#ifdef WIN32 + closesocket(accept_fd); +#else + close(accept_fd); +#endif + break; + } + + /* accepting connection to main listener */ + + new_wsi = libwebsocket_create_new_server_wsi(context); + if (new_wsi == NULL) + break; + + new_wsi->sock = accept_fd; + + +#ifdef LWS_OPENSSL_SUPPORT + new_wsi->ssl = NULL; + + if (context->use_ssl) { + + new_wsi->ssl = SSL_new(context->ssl_ctx); + if (new_wsi->ssl == NULL) { + fprintf(stderr, "SSL_new failed: %s\n", + ERR_error_string(SSL_get_error( + new_wsi->ssl, 0), NULL)); + libwebsockets_decode_ssl_error(); + free(new_wsi); + break; + } + + SSL_set_fd(new_wsi->ssl, accept_fd); + + n = SSL_accept(new_wsi->ssl); + if (n != 1) { + /* + * browsers seem to probe with various + * ssl params which fail then retry + * and succeed + */ + debug("SSL_accept failed skt %u: %s\n", + pollfd->fd, + ERR_error_string(SSL_get_error( + new_wsi->ssl, n), NULL)); + SSL_free( + new_wsi->ssl); + free(new_wsi); + break; + } + + debug("accepted new SSL conn " + "port %u on fd=%d SSL ver %s\n", + ntohs(cli_addr.sin_port), accept_fd, + SSL_get_version(new_wsi->ssl)); + + } else +#endif + debug("accepted new conn port %u on fd=%d\n", + ntohs(cli_addr.sin_port), accept_fd); + + insert_wsi(context, new_wsi); + + /* + * make sure NO events are seen yet on this new socket + * (otherwise we inherit old fds[client].revents from + * previous socket there and die mysteriously! ) + */ + context->fds[context->fds_count].revents = 0; + + context->fds[context->fds_count].events = POLLIN; + context->fds[context->fds_count++].fd = accept_fd; + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, new_wsi, + LWS_CALLBACK_ADD_POLL_FD, + (void *)(long)accept_fd, NULL, POLLIN); + + break; + + case LWS_CONNMODE_BROADCAST_PROXY_LISTENER: + + /* as we are listening, POLLIN means accept() is needed */ + + if (!pollfd->revents & POLLIN) + break; + + /* listen socket got an unencrypted connection... */ + + clilen = sizeof(cli_addr); + accept_fd = accept(pollfd->fd, (struct sockaddr *)&cli_addr, + &clilen); + if (accept_fd < 0) { + debug("ERROR on accept\n"); + return -1; + } + + if (context->fds_count >= MAX_CLIENTS) { + fprintf(stderr, "too busy to accept new broadcast " + "proxy client\n"); +#ifdef WIN32 + closesocket(accept_fd); +#else + close(accept_fd); +#endif + break; + } + + /* create a dummy wsi for the connection and add it */ + + new_wsi = malloc(sizeof(struct libwebsocket)); + memset(new_wsi, 0, sizeof(struct libwebsocket)); + new_wsi->sock = accept_fd; + new_wsi->mode = LWS_CONNMODE_BROADCAST_PROXY; + new_wsi->state = WSI_STATE_ESTABLISHED; + new_wsi->count_active_extensions = 0; + /* note which protocol we are proxying */ + new_wsi->protocol_index_for_broadcast_proxy = + wsi->protocol_index_for_broadcast_proxy; + insert_wsi(context, new_wsi); + + /* add connected socket to internal poll array */ + + context->fds[context->fds_count].revents = 0; + context->fds[context->fds_count].events = POLLIN; + context->fds[context->fds_count++].fd = accept_fd; + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, new_wsi, + LWS_CALLBACK_ADD_POLL_FD, + (void *)(long)accept_fd, NULL, POLLIN); + + break; + + case LWS_CONNMODE_BROADCAST_PROXY: + + /* handle session socket closed */ + + if (pollfd->revents & (POLLERR | POLLHUP)) { + + debug("Session Socket %p (fd=%d) dead\n", + (void *)wsi, pollfd->fd); + + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NORMAL); + return 1; + } + + /* + * either extension code with stuff to spill, or the user code, + * requested a callback when it was OK to write + */ + + if (pollfd->revents & POLLOUT) + if (lws_handle_POLLOUT_event(context, wsi, + pollfd) < 0) { + libwebsocket_close_and_free_session( + context, wsi, LWS_CLOSE_STATUS_NORMAL); + return 1; + } + + /* any incoming data ready? */ + + if (!(pollfd->revents & POLLIN)) + break; + + /* get the issued broadcast payload from the socket */ + + len = read(pollfd->fd, buf + LWS_SEND_BUFFER_PRE_PADDING, + MAX_BROADCAST_PAYLOAD); + if (len < 0) { + fprintf(stderr, "Error reading broadcast payload\n"); + break; + } + + /* broadcast it to all guys with this protocol index */ + + for (n = 0; n < FD_HASHTABLE_MODULUS; n++) { + + for (m = 0; m < context->fd_hashtable[n].length; m++) { + + new_wsi = context->fd_hashtable[n].wsi[m]; + + /* only to clients we are serving to */ + + if (new_wsi->mode != LWS_CONNMODE_WS_SERVING) + continue; + + /* + * never broadcast to non-established + * connection + */ + + if (new_wsi->state != WSI_STATE_ESTABLISHED) + continue; + + /* + * only broadcast to connections using + * the requested protocol + */ + + if (new_wsi->protocol->protocol_index != + wsi->protocol_index_for_broadcast_proxy) + continue; + + /* broadcast it to this connection */ + + new_wsi->protocol->callback(context, new_wsi, + LWS_CALLBACK_BROADCAST, + new_wsi->user_space, + buf + LWS_SEND_BUFFER_PRE_PADDING, len); + } + } + break; + + case LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY: + + /* handle proxy hung up on us */ + + if (pollfd->revents & (POLLERR | POLLHUP)) { + + fprintf(stderr, "Proxy connection %p (fd=%d) dead\n", + (void *)wsi, pollfd->fd); + + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + + n = recv(wsi->sock, pkt, sizeof pkt, 0); + if (n < 0) { + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + fprintf(stderr, "ERROR reading from proxy socket\n"); + return 1; + } + + pkt[13] = '\0'; + if (strcmp(pkt, "HTTP/1.0 200 ") != 0) { + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + fprintf(stderr, "ERROR from proxy: %s\n", pkt); + return 1; + } + + /* clear his proxy connection timeout */ + + libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0); + + /* fallthru */ + + case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE: + + #ifdef LWS_OPENSSL_SUPPORT + if (wsi->use_ssl && !wsi->ssl) { + + wsi->ssl = SSL_new(context->ssl_client_ctx); + wsi->client_bio = BIO_new_socket(wsi->sock, + BIO_NOCLOSE); + SSL_set_bio(wsi->ssl, wsi->client_bio, wsi->client_bio); + + SSL_set_ex_data(wsi->ssl, + openssl_websocket_private_data_index, + context); + } + + if (wsi->use_ssl) { + if (SSL_connect(wsi->ssl) <= 0) { + + /* + * retry if new data comes until we + * run into the connection timeout or win + */ + + fprintf(stderr, "SSL connect error %s\n", + ERR_error_string(ERR_get_error(), + ssl_err_buf)); + return 0; + } + + n = SSL_get_verify_result(wsi->ssl); + if ((n != X509_V_OK) && ( + n != X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT || + wsi->use_ssl != 2)) { + + fprintf(stderr, "server's cert didn't " + "look good %d\n", n); + libwebsocket_close_and_free_session(context, + wsi, LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + } else + wsi->ssl = NULL; + #endif + + p = libwebsockets_generate_client_handshake(context, wsi, p); + if (p == NULL) + return 1; + + /* send our request to the server */ + + #ifdef LWS_OPENSSL_SUPPORT + if (wsi->use_ssl) + n = SSL_write(wsi->ssl, pkt, p - pkt); + else + #endif + n = send(wsi->sock, pkt, p - pkt, 0); + + if (n < 0) { + fprintf(stderr, "ERROR writing to client socket\n"); + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + + wsi->parser_state = WSI_TOKEN_NAME_PART; + wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY; + libwebsocket_set_timeout(wsi, + PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE, 5); + + break; + + case LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY: + + /* handle server hung up on us */ + + if (pollfd->revents & (POLLERR | POLLHUP)) { + + fprintf(stderr, "Server connection %p (fd=%d) dead\n", + (void *)wsi, pollfd->fd); + + goto bail3; + } + + + /* interpret the server response */ + + /* + * HTTP/1.1 101 Switching Protocols + * Upgrade: websocket + * Connection: Upgrade + * Sec-WebSocket-Accept: me89jWimTRKTWwrS3aRrL53YZSo= + * Sec-WebSocket-Nonce: AQIDBAUGBwgJCgsMDQ4PEC== + * Sec-WebSocket-Protocol: chat + */ + + /* + * we have to take some care here to only take from the + * socket bytewise. The browser may (and has been seen to + * in the case that onopen() performs websocket traffic) + * coalesce both handshake response and websocket traffic + * in one packet, since at that point the connection is + * definitively ready from browser pov. + */ + + len = 1; + while (wsi->parser_state != WSI_PARSING_COMPLETE && len > 0) { +#ifdef LWS_OPENSSL_SUPPORT + if (wsi->use_ssl) + len = SSL_read(wsi->ssl, &c, 1); + else +#endif + len = recv(wsi->sock, &c, 1, 0); + + libwebsocket_parse(wsi, c); + } + + /* + * hs may also be coming in multiple packets, there is a 5-sec + * libwebsocket timeout still active here too, so if parsing did + * not complete just wait for next packet coming in this state + */ + + if (wsi->parser_state != WSI_PARSING_COMPLETE) + break; + + /* + * otherwise deal with the handshake. If there's any + * packet traffic already arrived we'll trigger poll() again + * right away and deal with it that way + */ + + return lws_client_interpret_server_handshake(context, wsi); + +bail3: + if (wsi->c_protocol) + free(wsi->c_protocol); + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return 1; + + case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT: + fprintf(stderr, + "LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT\n"); + break; + + case LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD: + fprintf(stderr, + "LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD\n"); + break; + + + case LWS_CONNMODE_WS_SERVING: + case LWS_CONNMODE_WS_CLIENT: + + /* handle session socket closed */ + + if (pollfd->revents & (POLLERR | POLLHUP)) { + + fprintf(stderr, "Session Socket %p (fd=%d) dead\n", + (void *)wsi, pollfd->fd); + + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + + /* the guy requested a callback when it was OK to write */ + + if ((pollfd->revents & POLLOUT) && + wsi->state == WSI_STATE_ESTABLISHED) + if (lws_handle_POLLOUT_event(context, wsi, + pollfd) < 0) { + libwebsocket_close_and_free_session( + context, wsi, LWS_CLOSE_STATUS_NORMAL); + return 1; + } + + + /* any incoming data ready? */ + + if (!(pollfd->revents & POLLIN)) + break; + +#ifdef LWS_OPENSSL_SUPPORT + if (wsi->ssl) + eff_buf.token_len = SSL_read(wsi->ssl, buf, sizeof buf); + else +#endif + eff_buf.token_len = + recv(pollfd->fd, buf, sizeof buf, 0); + + if (eff_buf.token_len < 0) { + fprintf(stderr, "Socket read returned %d\n", + eff_buf.token_len); + if (errno != EINTR) + libwebsocket_close_and_free_session(context, + wsi, LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + if (!eff_buf.token_len) { + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + + /* + * give any active extensions a chance to munge the buffer + * before parse. We pass in a pointer to an lws_tokens struct + * prepared with the default buffer and content length that's in + * there. Rather than rewrite the default buffer, extensions + * that expect to grow the buffer can adapt .token to + * point to their own per-connection buffer in the extension + * user allocation. By default with no extensions or no + * extension callback handling, just the normal input buffer is + * used then so it is efficient. + */ + + eff_buf.token = (char *)buf; + + more = 1; + while (more) { + + more = 0; + + for (n = 0; n < wsi->count_active_extensions; n++) { + m = wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_PACKET_RX_PREPARSE, + wsi->active_extensions_user[n], + &eff_buf, 0); + if (m < 0) { + fprintf(stderr, + "Extension reports fatal error\n"); + libwebsocket_close_and_free_session( + context, wsi, + LWS_CLOSE_STATUS_NOSTATUS); + return 1; + } + if (m) + more = 1; + } + + /* service incoming data */ + + if (eff_buf.token_len) { + n = libwebsocket_read(context, wsi, + (unsigned char *)eff_buf.token, + eff_buf.token_len); + if (n < 0) + /* we closed wsi */ + return 1; + } + + eff_buf.token = NULL; + eff_buf.token_len = 0; + } + break; + } + + return 0; +} + + +/** + * libwebsocket_context_destroy() - Destroy the websocket context + * @context: Websocket context + * + * This function closes any active connections and then frees the + * context. After calling this, any further use of the context is + * undefined. + */ +void +libwebsocket_context_destroy(struct libwebsocket_context *context) +{ + int n; + int m; + struct libwebsocket *wsi; + struct libwebsocket_extension *ext; + + for (n = 0; n < FD_HASHTABLE_MODULUS; n++) + for (m = 0; m < context->fd_hashtable[n].length; m++) { + wsi = context->fd_hashtable[n].wsi[m]; + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_GOINGAWAY); + } + + /* + * give all extensions a chance to clean up any per-context + * allocations they might have made + */ + + ext = context->extensions; + m = LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT; + if (context->listen_port) + m = LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT; + while (ext && ext->callback) { + ext->callback(context, ext, NULL, m, NULL, NULL, 0); + ext++; + } + +#ifdef WIN32 +#else + close(context->fd_random); +#endif + +#ifdef LWS_OPENSSL_SUPPORT + if (context->ssl_ctx) + SSL_CTX_free(context->ssl_ctx); + if (context->ssl_client_ctx) + SSL_CTX_free(context->ssl_client_ctx); +#endif + + free(context); + +#ifdef WIN32 + WSACleanup(); +#endif +} + +/** + * libwebsocket_service() - Service any pending websocket activity + * @context: Websocket context + * @timeout_ms: Timeout for poll; 0 means return immediately if nothing needed + * service otherwise block and service immediately, returning + * after the timeout if nothing needed service. + * + * This function deals with any pending websocket traffic, for three + * kinds of event. It handles these events on both server and client + * types of connection the same. + * + * 1) Accept new connections to our context's server + * + * 2) Perform pending broadcast writes initiated from other forked + * processes (effectively serializing asynchronous broadcasts) + * + * 3) Call the receive callback for incoming frame data received by + * server or client connections. + * + * You need to call this service function periodically to all the above + * functions to happen; if your application is single-threaded you can + * just call it in your main event loop. + * + * Alternatively you can fork a new process that asynchronously handles + * calling this service in a loop. In that case you are happy if this + * call blocks your thread until it needs to take care of something and + * would call it with a large nonzero timeout. Your loop then takes no + * CPU while there is nothing happening. + * + * If you are calling it in a single-threaded app, you don't want it to + * wait around blocking other things in your loop from happening, so you + * would call it with a timeout_ms of 0, so it returns immediately if + * nothing is pending, or as soon as it services whatever was pending. + */ + + +int +libwebsocket_service(struct libwebsocket_context *context, int timeout_ms) +{ + int n; + + /* stay dead once we are dead */ + + if (context == NULL) + return 1; + + /* wait for something to need service */ + + n = poll(context->fds, context->fds_count, timeout_ms); + if (n == 0) /* poll timeout */ + return 0; + + if (n < 0) { + /* + fprintf(stderr, "Listen Socket dead\n"); + */ + return -1; + } + + /* handle accept on listening socket? */ + + for (n = 0; n < context->fds_count; n++) + if (context->fds[n].revents) + if (libwebsocket_service_fd(context, + &context->fds[n]) < 0) + return -1; + return 0; +} + +int +lws_any_extension_handled(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons r, + void *v, size_t len) +{ + int n; + int handled = 0; + + /* maybe an extension will take care of it for us */ + + for (n = 0; n < wsi->count_active_extensions && !handled; n++) { + if (!wsi->active_extensions[n]->callback) + continue; + + handled |= wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + r, wsi->active_extensions_user[n], v, len); + } + + return handled; +} + + +void * +lws_get_extension_user_matching_ext(struct libwebsocket *wsi, + struct libwebsocket_extension *ext) +{ + int n = 0; + + if (wsi == NULL) + return NULL; + + while (n < wsi->count_active_extensions) { + if (wsi->active_extensions[n] != ext) { + n++; + continue; + } + return wsi->active_extensions_user[n]; + } + + return NULL; +} + +/** + * libwebsocket_callback_on_writable() - Request a callback when this socket + * becomes able to be written to without + * blocking + * + * @context: libwebsockets context + * @wsi: Websocket connection instance to get callback for + */ + +int +libwebsocket_callback_on_writable(struct libwebsocket_context *context, + struct libwebsocket *wsi) +{ + int n; + int handled = 0; + + /* maybe an extension will take care of it for us */ + + for (n = 0; n < wsi->count_active_extensions; n++) { + if (!wsi->active_extensions[n]->callback) + continue; + + handled |= wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE, + wsi->active_extensions_user[n], NULL, 0); + } + + if (handled) + return 1; + + for (n = 0; n < context->fds_count; n++) + if (context->fds[n].fd == wsi->sock) { + context->fds[n].events |= POLLOUT; + n = context->fds_count + 1; + } + + if (n == context->fds_count) + fprintf(stderr, "libwebsocket_callback_on_writable: " + "failed to find socket %d\n", wsi->sock); + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_SET_MODE_POLL_FD, + (void *)(long)wsi->sock, NULL, POLLOUT); + + return 1; +} + +/** + * libwebsocket_callback_on_writable_all_protocol() - Request a callback for + * all connections using the given protocol when it + * becomes possible to write to each socket without + * blocking in turn. + * + * @protocol: Protocol whose connections will get callbacks + */ + +int +libwebsocket_callback_on_writable_all_protocol( + const struct libwebsocket_protocols *protocol) +{ + struct libwebsocket_context *context = protocol->owning_server; + int n; + int m; + struct libwebsocket *wsi; + + for (n = 0; n < FD_HASHTABLE_MODULUS; n++) { + + for (m = 0; m < context->fd_hashtable[n].length; m++) { + + wsi = context->fd_hashtable[n].wsi[m]; + + if (wsi->protocol == protocol) + libwebsocket_callback_on_writable(context, wsi); + } + } + + return 0; +} + +/** + * libwebsocket_set_timeout() - marks the wsi as subject to a timeout + * + * You will not need this unless you are doing something special + * + * @wsi: Websocket connection instance + * @reason: timeout reason + * @secs: how many seconds + */ + +void +libwebsocket_set_timeout(struct libwebsocket *wsi, + enum pending_timeout reason, int secs) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + wsi->pending_timeout_limit = tv.tv_sec + secs; + wsi->pending_timeout = reason; +} + + +/** + * libwebsocket_get_socket_fd() - returns the socket file descriptor + * + * You will not need this unless you are doing something special + * + * @wsi: Websocket connection instance + */ + +int +libwebsocket_get_socket_fd(struct libwebsocket *wsi) +{ + return wsi->sock; +} + +/** + * libwebsocket_rx_flow_control() - Enable and disable socket servicing for + * receieved packets. + * + * If the output side of a server process becomes choked, this allows flow + * control for the input side. + * + * @wsi: Websocket connection instance to get callback for + * @enable: 0 = disable read servicing for this connection, 1 = enable + */ + +int +libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable) +{ + struct libwebsocket_context *context = wsi->protocol->owning_server; + int n; + + for (n = 0; n < context->fds_count; n++) + if (context->fds[n].fd == wsi->sock) { + if (enable) + context->fds[n].events |= POLLIN; + else + context->fds[n].events &= ~POLLIN; + + return 0; + } + + if (enable) + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_SET_MODE_POLL_FD, + (void *)(long)wsi->sock, NULL, POLLIN); + else + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_CLEAR_MODE_POLL_FD, + (void *)(long)wsi->sock, NULL, POLLIN); + +#if 0 + fprintf(stderr, "libwebsocket_rx_flow_control " + "unable to find socket\n"); +#endif + return 1; +} + +/** + * libwebsocket_canonical_hostname() - returns this host's hostname + * + * This is typically used by client code to fill in the host parameter + * when making a client connection. You can only call it after the context + * has been created. + * + * @context: Websocket context + */ + + +extern const char * +libwebsocket_canonical_hostname(struct libwebsocket_context *context) +{ + return (const char *)context->canonical_hostname; +} + + +static void sigpipe_handler(int x) +{ +} + +#ifdef LWS_OPENSSL_SUPPORT +static int +OpenSSL_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) +{ + + SSL *ssl; + int n; + struct libwebsocket_context *context; + + ssl = X509_STORE_CTX_get_ex_data(x509_ctx, + SSL_get_ex_data_X509_STORE_CTX_idx()); + + /* + * !!! nasty openssl requires the index to come as a library-scope + * static + */ + context = SSL_get_ex_data(ssl, openssl_websocket_private_data_index); + + n = context->protocols[0].callback(NULL, NULL, + LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION, + x509_ctx, ssl, preverify_ok); + + /* convert return code from 0 = OK to 1 = OK */ + + if (!n) + n = 1; + else + n = 0; + + return n; +} +#endif + + +/** + * libwebsocket_create_context() - Create the websocket handler + * @port: Port to listen on... you can use 0 to suppress listening on + * any port, that's what you want if you are not running a + * websocket server at all but just using it as a client + * @interf: NULL to bind the listen socket to all interfaces, or the + * interface name, eg, "eth2" + * @protocols: Array of structures listing supported protocols and a protocol- + * specific callback for each one. The list is ended with an + * entry that has a NULL callback pointer. + * It's not const because we write the owning_server member + * @extensions: NULL or array of libwebsocket_extension structs listing the + * extensions this context supports + * @ssl_cert_filepath: If libwebsockets was compiled to use ssl, and you want + * to listen using SSL, set to the filepath to fetch the + * server cert from, otherwise NULL for unencrypted + * @ssl_private_key_filepath: filepath to private key if wanting SSL mode, + * else ignored + * @gid: group id to change to after setting listen socket, or -1. + * @uid: user id to change to after setting listen socket, or -1. + * @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK + * + * This function creates the listening socket and takes care + * of all initialization in one step. + * + * After initialization, it returns a struct libwebsocket_context * that + * represents this server. After calling, user code needs to take care + * of calling libwebsocket_service() with the context pointer to get the + * server's sockets serviced. This can be done in the same process context + * or a forked process, or another thread, + * + * The protocol callback functions are called for a handful of events + * including http requests coming in, websocket connections becoming + * established, and data arriving; it's also called periodically to allow + * async transmission. + * + * HTTP requests are sent always to the FIRST protocol in @protocol, since + * at that time websocket protocol has not been negotiated. Other + * protocols after the first one never see any HTTP callack activity. + * + * The server created is a simple http server by default; part of the + * websocket standard is upgrading this http connection to a websocket one. + * + * This allows the same server to provide files like scripts and favicon / + * images or whatever over http and dynamic data over websockets all in + * one place; they're all handled in the user callback. + */ + +struct libwebsocket_context * +libwebsocket_create_context(int port, const char *interf, + struct libwebsocket_protocols *protocols, + struct libwebsocket_extension *extensions, + const char *ssl_cert_filepath, + const char *ssl_private_key_filepath, + int gid, int uid, unsigned int options) +{ + int n; + int m; + int sockfd = 0; + int fd; + struct sockaddr_in serv_addr, cli_addr; + int opt = 1; + struct libwebsocket_context *context = NULL; + unsigned int slen; + char *p; + char hostname[1024] = ""; +// struct hostent *he; + struct libwebsocket *wsi; + struct sockaddr sa; + +#ifdef LWS_OPENSSL_SUPPORT + SSL_METHOD *method; + char ssl_err_buf[512]; +#endif + +#ifdef _WIN32 + { + WORD wVersionRequested; + WSADATA wsaData; + int err; + HMODULE wsdll; + + /* Use the MAKEWORD(lowbyte, highbyte) macro from Windef.h */ + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + /* Tell the user that we could not find a usable */ + /* Winsock DLL. */ + fprintf(stderr, "WSAStartup failed with error: %d\n", + err); + return NULL; + } + + /* default to a poll() made out of select() */ + poll = emulated_poll; + + /* if windows socket lib available, use his WSAPoll */ + wsdll = GetModuleHandle("Ws2_32.dll"); + if (wsdll) + poll = (PFNWSAPOLL)GetProcAddress(wsdll, "WSAPoll"); + } +#endif + + + context = malloc(sizeof(struct libwebsocket_context)); + if (!context) { + fprintf(stderr, "No memory for websocket context\n"); + return NULL; + } + context->protocols = protocols; + context->listen_port = port; + context->http_proxy_port = 0; + context->http_proxy_address[0] = '\0'; + context->options = options; + context->fds_count = 0; + context->extensions = extensions; + context->last_timeout_check_s = 0; + +#ifdef WIN32 + context->fd_random = 0; +#else + context->fd_random = open(SYSTEM_RANDOM_FILEPATH, O_RDONLY); + if (context->fd_random < 0) { + fprintf(stderr, "Unable to open random device %s %d\n", + SYSTEM_RANDOM_FILEPATH, context->fd_random); + return NULL; + } +#endif + +#ifdef LWS_OPENSSL_SUPPORT + context->use_ssl = 0; + context->ssl_ctx = NULL; + context->ssl_client_ctx = NULL; + openssl_websocket_private_data_index = 0; +#endif + /* find canonical hostname */ + + hostname[(sizeof hostname) - 1] = '\0'; + memset(&sa, 0, sizeof(sa)); + sa.sa_family = AF_INET; + sa.sa_data[(sizeof sa.sa_data) - 1] = '\0'; + gethostname(hostname, (sizeof hostname) - 1); + + n = 0; + + if (strlen(hostname) < sizeof(sa.sa_data) - 1) { + strcpy(sa.sa_data, hostname); +// fprintf(stderr, "my host name is %s\n", sa.sa_data); + n = getnameinfo(&sa, sizeof(sa), hostname, + (sizeof hostname) - 1, NULL, 0, 0); + } + + if (!n) { + strncpy(context->canonical_hostname, hostname, + sizeof context->canonical_hostname - 1); + context->canonical_hostname[ + sizeof context->canonical_hostname - 1] = '\0'; + } else + strncpy(context->canonical_hostname, hostname, + sizeof context->canonical_hostname - 1); + +// fprintf(stderr, "context->canonical_hostname = %s\n", +// context->canonical_hostname); + + /* split the proxy ads:port if given */ + + p = getenv("http_proxy"); + if (p) { + strncpy(context->http_proxy_address, p, + sizeof context->http_proxy_address - 1); + context->http_proxy_address[ + sizeof context->http_proxy_address - 1] = '\0'; + + p = strchr(context->http_proxy_address, ':'); + if (p == NULL) { + fprintf(stderr, "http_proxy needs to be ads:port\n"); + return NULL; + } + *p = '\0'; + context->http_proxy_port = atoi(p + 1); + + fprintf(stderr, "Using proxy %s:%u\n", + context->http_proxy_address, + context->http_proxy_port); + } + + if (port) { + +#ifdef LWS_OPENSSL_SUPPORT + context->use_ssl = ssl_cert_filepath != NULL && + ssl_private_key_filepath != NULL; + if (context->use_ssl) + fprintf(stderr, " Compiled with SSL support, " + "using it\n"); + else + fprintf(stderr, " Compiled with SSL support, " + "not using it\n"); + +#else + if (ssl_cert_filepath != NULL && + ssl_private_key_filepath != NULL) { + fprintf(stderr, " Not compiled for OpenSSl support!\n"); + return NULL; + } + fprintf(stderr, " Compiled without SSL support, " + "serving unencrypted\n"); +#endif + } + + /* ignore SIGPIPE */ +#ifdef WIN32 +#else + signal(SIGPIPE, sigpipe_handler); +#endif + + +#ifdef LWS_OPENSSL_SUPPORT + + /* basic openssl init */ + + SSL_library_init(); + + OpenSSL_add_all_algorithms(); + SSL_load_error_strings(); + + openssl_websocket_private_data_index = + SSL_get_ex_new_index(0, "libwebsockets", NULL, NULL, NULL); + + /* + * Firefox insists on SSLv23 not SSLv3 + * Konq disables SSLv2 by default now, SSLv23 works + */ + + method = (SSL_METHOD *)SSLv23_server_method(); + if (!method) { + fprintf(stderr, "problem creating ssl method: %s\n", + ERR_error_string(ERR_get_error(), ssl_err_buf)); + return NULL; + } + context->ssl_ctx = SSL_CTX_new(method); /* create context */ + if (!context->ssl_ctx) { + fprintf(stderr, "problem creating ssl context: %s\n", + ERR_error_string(ERR_get_error(), ssl_err_buf)); + return NULL; + } + + /* client context */ + + if (port == CONTEXT_PORT_NO_LISTEN) { + method = (SSL_METHOD *)SSLv23_client_method(); + if (!method) { + fprintf(stderr, "problem creating ssl method: %s\n", + ERR_error_string(ERR_get_error(), ssl_err_buf)); + return NULL; + } + /* create context */ + context->ssl_client_ctx = SSL_CTX_new(method); + if (!context->ssl_client_ctx) { + fprintf(stderr, "problem creating ssl context: %s\n", + ERR_error_string(ERR_get_error(), ssl_err_buf)); + return NULL; + } + + /* openssl init for cert verification (for client sockets) */ + + if (!SSL_CTX_load_verify_locations( + context->ssl_client_ctx, NULL, + LWS_OPENSSL_CLIENT_CERTS)) + fprintf(stderr, + "Unable to load SSL Client certs from %s " + "(set by --with-client-cert-dir= in configure) -- " + " client ssl isn't going to work", + LWS_OPENSSL_CLIENT_CERTS); + + /* + * callback allowing user code to load extra verification certs + * helping the client to verify server identity + */ + + context->protocols[0].callback(context, NULL, + LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS, + context->ssl_client_ctx, NULL, 0); + } + + /* as a server, are we requiring clients to identify themselves? */ + + if (options & LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT) { + + /* absolutely require the client cert */ + + SSL_CTX_set_verify(context->ssl_ctx, + SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + OpenSSL_verify_callback); + + /* + * give user code a chance to load certs into the server + * allowing it to verify incoming client certs + */ + + context->protocols[0].callback(context, NULL, + LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS, + context->ssl_ctx, NULL, 0); + } + + if (context->use_ssl) { + + /* openssl init for server sockets */ + + /* set the local certificate from CertFile */ + n = SSL_CTX_use_certificate_file(context->ssl_ctx, + ssl_cert_filepath, SSL_FILETYPE_PEM); + if (n != 1) { + fprintf(stderr, "problem getting cert '%s': %s\n", + ssl_cert_filepath, + ERR_error_string(ERR_get_error(), ssl_err_buf)); + return NULL; + } + /* set the private key from KeyFile */ + if (SSL_CTX_use_PrivateKey_file(context->ssl_ctx, + ssl_private_key_filepath, SSL_FILETYPE_PEM) != 1) { + fprintf(stderr, "ssl problem getting key '%s': %s\n", + ssl_private_key_filepath, + ERR_error_string(ERR_get_error(), ssl_err_buf)); + return NULL; + } + /* verify private key */ + if (!SSL_CTX_check_private_key(context->ssl_ctx)) { + fprintf(stderr, "Private SSL key doesn't match cert\n"); + return NULL; + } + + /* SSL is happy and has a cert it's content with */ + } +#endif + + /* selftest */ + + if (lws_b64_selftest()) + return NULL; + + /* fd hashtable init */ + + for (n = 0; n < FD_HASHTABLE_MODULUS; n++) + context->fd_hashtable[n].length = 0; + + /* set up our external listening socket we serve on */ + + if (port) { + + sockfd = socket(AF_INET, SOCK_STREAM, 0); + if (sockfd < 0) { + fprintf(stderr, "ERROR opening socket"); + return NULL; + } + + /* allow us to restart even if old sockets in TIME_WAIT */ + setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, + (const void *)&opt, sizeof(opt)); + + /* Disable Nagle */ + opt = 1; + setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, + (const void *)&opt, sizeof(opt)); + + bzero((char *) &serv_addr, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + if (interf == NULL) + serv_addr.sin_addr.s_addr = INADDR_ANY; + else + interface_to_sa(interf, &serv_addr, + sizeof(serv_addr)); + serv_addr.sin_port = htons(port); + + n = bind(sockfd, (struct sockaddr *) &serv_addr, + sizeof(serv_addr)); + if (n < 0) { + fprintf(stderr, "ERROR on binding to port %d (%d %d)\n", + port, n, errno); + return NULL; + } + + wsi = malloc(sizeof(struct libwebsocket)); + memset(wsi, 0, sizeof(struct libwebsocket)); + wsi->sock = sockfd; + wsi->count_active_extensions = 0; + wsi->mode = LWS_CONNMODE_SERVER_LISTENER; + insert_wsi(context, wsi); + + listen(sockfd, 5); + fprintf(stderr, " Listening on port %d\n", port); + + /* list in the internal poll array */ + + context->fds[context->fds_count].fd = sockfd; + context->fds[context->fds_count++].events = POLLIN; + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_ADD_POLL_FD, + (void *)(long)sockfd, NULL, POLLIN); + + } + + /* + * drop any root privs for this process + * to listen on port < 1023 we would have needed root, but now we are + * listening, we don't want the power for anything else + */ +#ifdef WIN32 +#else + if (gid != -1) + if (setgid(gid)) + fprintf(stderr, "setgid: %s\n", strerror(errno)); + if (uid != -1) + if (setuid(uid)) + fprintf(stderr, "setuid: %s\n", strerror(errno)); +#endif + + /* set up our internal broadcast trigger sockets per-protocol */ + + for (context->count_protocols = 0; + protocols[context->count_protocols].callback; + context->count_protocols++) { + + debug(" Protocol: %s\n", protocols[context->count_protocols].name); + + protocols[context->count_protocols].owning_server = context; + protocols[context->count_protocols].protocol_index = + context->count_protocols; + + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) { + fprintf(stderr, "ERROR opening socket"); + return NULL; + } + + /* allow us to restart even if old sockets in TIME_WAIT */ + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&opt, + sizeof(opt)); + + bzero((char *) &serv_addr, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + serv_addr.sin_port = 0; /* pick the port for us */ + + n = bind(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)); + if (n < 0) { + fprintf(stderr, "ERROR on binding to port %d (%d %d)\n", + port, n, errno); + return NULL; + } + + slen = sizeof cli_addr; + n = getsockname(fd, (struct sockaddr *)&cli_addr, &slen); + if (n < 0) { + fprintf(stderr, "getsockname failed\n"); + return NULL; + } + protocols[context->count_protocols].broadcast_socket_port = + ntohs(cli_addr.sin_port); + listen(fd, 5); + + debug(" Protocol %s broadcast socket %d\n", + protocols[context->count_protocols].name, + ntohs(cli_addr.sin_port)); + + /* dummy wsi per broadcast proxy socket */ + + wsi = malloc(sizeof(struct libwebsocket)); + memset(wsi, 0, sizeof(struct libwebsocket)); + wsi->sock = fd; + wsi->mode = LWS_CONNMODE_BROADCAST_PROXY_LISTENER; + wsi->count_active_extensions = 0; + /* note which protocol we are proxying */ + wsi->protocol_index_for_broadcast_proxy = + context->count_protocols; + insert_wsi(context, wsi); + + /* list in internal poll array */ + + context->fds[context->fds_count].fd = fd; + context->fds[context->fds_count].events = POLLIN; + context->fds[context->fds_count].revents = 0; + context->fds_count++; + + /* external POLL support via protocol 0 */ + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_ADD_POLL_FD, + (void *)(long)fd, NULL, POLLIN); + } + + /* + * give all extensions a chance to create any per-context + * allocations they need + */ + + m = LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT; + if (port) + m = LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT; + + if (extensions) { + while (extensions->callback) { + debug(" Extension: %s\n", extensions->name); + extensions->callback(context, extensions, + NULL, m, NULL, NULL, 0); + extensions++; + } + } + + return context; +} + + +#ifndef LWS_NO_FORK + +/** + * libwebsockets_fork_service_loop() - Optional helper function forks off + * a process for the websocket server loop. + * You don't have to use this but if not, you + * have to make sure you are calling + * libwebsocket_service periodically to service + * the websocket traffic + * @context: server context returned by creation function + */ + +int +libwebsockets_fork_service_loop(struct libwebsocket_context *context) +{ + int fd; + struct sockaddr_in cli_addr; + int n; + int p; + + n = fork(); + if (n < 0) + return n; + + if (!n) { + + /* main process context */ + + /* + * set up the proxy sockets to allow broadcast from + * service process context + */ + + for (p = 0; p < context->count_protocols; p++) { + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) { + fprintf(stderr, "Unable to create socket\n"); + return -1; + } + cli_addr.sin_family = AF_INET; + cli_addr.sin_port = htons( + context->protocols[p].broadcast_socket_port); + cli_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + n = connect(fd, (struct sockaddr *)&cli_addr, + sizeof cli_addr); + if (n < 0) { + fprintf(stderr, "Unable to connect to " + "broadcast socket %d, %s\n", + n, strerror(errno)); + return -1; + } + + context->protocols[p].broadcast_socket_user_fd = fd; + } + + return 0; + } + +#ifdef HAVE_SYS_PRCTL_H + /* we want a SIGHUP when our parent goes down */ + prctl(PR_SET_PDEATHSIG, SIGHUP); +#endif + + /* in this forked process, sit and service websocket connections */ + + while (1) { + if (libwebsocket_service(context, 1000)) + break; +#ifndef HAVE_SYS_PRCTL_H +/* + * on systems without prctl() (i.e. anything but linux) we can notice that our + * parent is dead if getppid() returns 1. FIXME apparently this is not true for + * solaris, could remember ppid right after fork and wait for it to change. + */ + + if (getppid() == 1) + break; +#endif + } + + + return 1; +} + +#endif + +/** + * libwebsockets_get_protocol() - Returns a protocol pointer from a websocket + * connection. + * @wsi: pointer to struct websocket you want to know the protocol of + * + * + * This is useful to get the protocol to broadcast back to from inside + * the callback. + */ + +const struct libwebsocket_protocols * +libwebsockets_get_protocol(struct libwebsocket *wsi) +{ + return wsi->protocol; +} + +/** + * libwebsockets_broadcast() - Sends a buffer to the callback for all active + * connections of the given protocol. + * @protocol: pointer to the protocol you will broadcast to all members of + * @buf: buffer containing the data to be broadcase. NOTE: this has to be + * allocated with LWS_SEND_BUFFER_PRE_PADDING valid bytes before + * the pointer and LWS_SEND_BUFFER_POST_PADDING afterwards in the + * case you are calling this function from callback context. + * @len: length of payload data in buf, starting from buf. + * + * This function allows bulk sending of a packet to every connection using + * the given protocol. It does not send the data directly; instead it calls + * the callback with a reason type of LWS_CALLBACK_BROADCAST. If the callback + * wants to actually send the data for that connection, the callback itself + * should call libwebsocket_write(). + * + * libwebsockets_broadcast() can be called from another fork context without + * having to take any care about data visibility between the processes, it'll + * "just work". + */ + + +int +libwebsockets_broadcast(const struct libwebsocket_protocols *protocol, + unsigned char *buf, size_t len) +{ + struct libwebsocket_context *context = protocol->owning_server; + int n; + int m; + struct libwebsocket *wsi; + + if (!protocol->broadcast_socket_user_fd) { + /* + * We are either running unforked / flat, or we are being + * called from poll thread context + * eg, from a callback. In that case don't use sockets for + * broadcast IPC (since we can't open a socket connection to + * a socket listening on our own thread) but directly do the + * send action. + * + * Locking is not needed because we are by definition being + * called in the poll thread context and are serialized. + */ + + for (n = 0; n < FD_HASHTABLE_MODULUS; n++) { + + for (m = 0; m < context->fd_hashtable[n].length; m++) { + + wsi = context->fd_hashtable[n].wsi[m]; + + if (wsi->mode != LWS_CONNMODE_WS_SERVING) + continue; + + /* + * never broadcast to + * non-established connections + */ + if (wsi->state != WSI_STATE_ESTABLISHED) + continue; + + /* only broadcast to guys using + * requested protocol + */ + if (wsi->protocol != protocol) + continue; + + wsi->protocol->callback(context, wsi, + LWS_CALLBACK_BROADCAST, + wsi->user_space, + buf, len); + } + } + + return 0; + } + + /* + * We're being called from a different process context than the server + * loop. Instead of broadcasting directly, we send our + * payload on a socket to do the IPC; the server process will serialize + * the broadcast action in its main poll() loop. + * + * There's one broadcast socket listening for each protocol supported + * set up when the websocket server initializes + */ + + n = send(protocol->broadcast_socket_user_fd, buf, len, MSG_NOSIGNAL); + + return n; +} + +int +libwebsocket_is_final_fragment(struct libwebsocket *wsi) +{ + return wsi->final; +} + +void * +libwebsocket_ensure_user_space(struct libwebsocket *wsi) +{ + /* allocate the per-connection user memory (if any) */ + + if (wsi->protocol->per_session_data_size && !wsi->user_space) { + wsi->user_space = malloc( + wsi->protocol->per_session_data_size); + if (wsi->user_space == NULL) { + fprintf(stderr, "Out of memory for " + "conn user space\n"); + return NULL; + } + memset(wsi->user_space, 0, + wsi->protocol->per_session_data_size); + } + return wsi->user_space; +} diff --git a/libs/libwebsockets/lib/libwebsockets.h b/libs/libwebsockets/lib/libwebsockets.h new file mode 100644 index 0000000000..60e7468cdc --- /dev/null +++ b/libs/libwebsockets/lib/libwebsockets.h @@ -0,0 +1,731 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef __LIBWEBSOCKET_H__ +#define __LIBWEBSOCKET_H__ + +#ifdef __cplusplus +extern "C" { +#include +#endif + +#ifdef WIN32 + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include "../win32port/win32helpers/websock-w32.h" + +#include "../win32port/win32helpers/gettimeofday.h" + +#define strcasecmp stricmp + +typedef int ssize_t; + +#ifdef LWS_DLL +#ifdef LWS_INTERNAL +#define LWS_EXTERN extern __declspec(dllexport) +#else +#define LWS_EXTERN extern __declspec(dllimport) +#endif +#endif + +#else +#include +#endif + +#ifndef LWS_EXTERN +#define LWS_EXTERN extern +#endif + +#define CONTEXT_PORT_NO_LISTEN 0 +#define MAX_MUX_RECURSION 2 + +enum libwebsocket_context_options { + LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK = 1, + LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2, +}; + +enum libwebsocket_callback_reasons { + LWS_CALLBACK_ESTABLISHED, + LWS_CALLBACK_CLIENT_CONNECTION_ERROR, + LWS_CALLBACK_CLIENT_ESTABLISHED, + LWS_CALLBACK_CLOSED, + LWS_CALLBACK_RECEIVE, + LWS_CALLBACK_CLIENT_RECEIVE, + LWS_CALLBACK_CLIENT_RECEIVE_PONG, + LWS_CALLBACK_CLIENT_WRITEABLE, + LWS_CALLBACK_SERVER_WRITEABLE, + LWS_CALLBACK_HTTP, + LWS_CALLBACK_BROADCAST, + LWS_CALLBACK_FILTER_NETWORK_CONNECTION, + LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION, + LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS, + LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS, + LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION, + LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, + LWS_CALLBACK_CONFIRM_EXTENSION_OKAY, + LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED, + /* external poll() management support */ + LWS_CALLBACK_ADD_POLL_FD, + LWS_CALLBACK_DEL_POLL_FD, + LWS_CALLBACK_SET_MODE_POLL_FD, + LWS_CALLBACK_CLEAR_MODE_POLL_FD, +}; + +enum libwebsocket_extension_callback_reasons { + LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT, + LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT, + LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT, + LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT, + LWS_EXT_CALLBACK_CONSTRUCT, + LWS_EXT_CALLBACK_CLIENT_CONSTRUCT, + LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE, + LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION, + LWS_EXT_CALLBACK_DESTROY, + LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING, + LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED, + LWS_EXT_CALLBACK_PACKET_RX_PREPARSE, + LWS_EXT_CALLBACK_PACKET_TX_PRESEND, + LWS_EXT_CALLBACK_PACKET_TX_DO_SEND, + LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX, + LWS_EXT_CALLBACK_FLUSH_PENDING_TX, + LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX, + LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION, + LWS_EXT_CALLBACK_1HZ, + LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE, + LWS_EXT_CALLBACK_IS_WRITEABLE, +}; + +enum libwebsocket_write_protocol { + LWS_WRITE_TEXT, + LWS_WRITE_BINARY, + LWS_WRITE_CONTINUATION, + LWS_WRITE_HTTP, + + /* special 04+ opcodes */ + + LWS_WRITE_CLOSE, + LWS_WRITE_PING, + LWS_WRITE_PONG, + + /* flags */ + + LWS_WRITE_NO_FIN = 0x40, + /* + * client packet payload goes out on wire unmunged + * only useful for security tests since normal servers cannot + * decode the content if used + */ + LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80 +}; + +/* + * you need these to look at headers that have been parsed if using the + * LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum + * list below is absent, .token = NULL and token_len = 0. Otherwise .token + * points to .token_len chars containing that header content. + */ + +struct lws_tokens { + char *token; + int token_len; +}; + +enum lws_token_indexes { + WSI_TOKEN_GET_URI, + WSI_TOKEN_HOST, + WSI_TOKEN_CONNECTION, + WSI_TOKEN_KEY1, + WSI_TOKEN_KEY2, + WSI_TOKEN_PROTOCOL, + WSI_TOKEN_UPGRADE, + WSI_TOKEN_ORIGIN, + WSI_TOKEN_DRAFT, + WSI_TOKEN_CHALLENGE, + + /* new for 04 */ + WSI_TOKEN_KEY, + WSI_TOKEN_VERSION, + WSI_TOKEN_SWORIGIN, + + /* new for 05 */ + WSI_TOKEN_EXTENSIONS, + + /* client receives these */ + WSI_TOKEN_ACCEPT, + WSI_TOKEN_NONCE, + WSI_TOKEN_HTTP, + WSI_TOKEN_MUXURL, + + /* always last real token index*/ + WSI_TOKEN_COUNT, + /* parser state additions */ + WSI_TOKEN_NAME_PART, + WSI_TOKEN_SKIPPING, + WSI_TOKEN_SKIPPING_SAW_CR, + WSI_PARSING_COMPLETE, + WSI_INIT_TOKEN_MUXURL, +}; + +/* + * From 06 spec + 1000 + + 1000 indicates a normal closure, meaning whatever purpose the + connection was established for has been fulfilled. + + 1001 + + 1001 indicates that an endpoint is "going away", such as a server + going down, or a browser having navigated away from a page. + + 1002 + + 1002 indicates that an endpoint is terminating the connection due + to a protocol error. + + 1003 + + 1003 indicates that an endpoint is terminating the connection + because it has received a type of data it cannot accept (e.g. an + endpoint that understands only text data may send this if it + receives a binary message.) + + 1004 + + 1004 indicates that an endpoint is terminating the connection + because it has received a message that is too large. +*/ + +enum lws_close_status { + LWS_CLOSE_STATUS_NOSTATUS = 0, + LWS_CLOSE_STATUS_NORMAL = 1000, + LWS_CLOSE_STATUS_GOINGAWAY = 1001, + LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002, + LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003, + LWS_CLOSE_STATUS_PAYLOAD_TOO_LARGE = 1004, +}; + +struct libwebsocket; +struct libwebsocket_context; +struct libwebsocket_extension; + +/** + * callback_function() - User server actions + * @context: Websockets context + * @wsi: Opaque websocket instance pointer + * @reason: The reason for the call + * @user: Pointer to per-session user data allocated by library + * @in: Pointer used for some callback reasons + * @len: Length set for some callback reasons + * + * This callback is the way the user controls what is served. All the + * protocol detail is hidden and handled by the library. + * + * For each connection / session there is user data allocated that is + * pointed to by "user". You set the size of this user data area when + * the library is initialized with libwebsocket_create_server. + * + * You get an opportunity to initialize user data when called back with + * LWS_CALLBACK_ESTABLISHED reason. + * + * LWS_CALLBACK_ESTABLISHED: after the server completes a handshake with + * an incoming client + * + * LWS_CALLBACK_CLIENT_CONNECTION_ERROR: the request client connection has + * been unable to complete a handshake with the remote server + * + * LWS_CALLBACK_CLIENT_ESTABLISHED: after your client connection completed + * a handshake with the remote server + * + * LWS_CALLBACK_CLOSED: when the websocket session ends + * + * LWS_CALLBACK_BROADCAST: signal to send to client (you would use + * libwebsocket_write() taking care about the + * special buffer requirements + * + * LWS_CALLBACK_RECEIVE: data has appeared for this server endpoint from a + * remote client, it can be found at *in and is + * len bytes long + * + * LWS_CALLBACK_CLIENT_RECEIVE_PONG: if you elected to see PONG packets, + * they appear with this callback reason. PONG + * packets only exist in 04+ protocol + * + * LWS_CALLBACK_CLIENT_RECEIVE: data has appeared from the server for the + * client connection, it can be found at *in and + * is len bytes long + * + * LWS_CALLBACK_HTTP: an http request has come from a client that is not + * asking to upgrade the connection to a websocket + * one. This is a chance to serve http content, + * for example, to send a script to the client + * which will then open the websockets connection. + * @in points to the URI path requested and + * libwebsockets_serve_http_file() makes it very + * simple to send back a file to the client. + * + * LWS_CALLBACK_CLIENT_WRITEABLE: + * LWS_CALLBACK_SERVER_WRITEABLE: If you call + * libwebsocket_callback_on_writable() on a connection, you will + * get one of these callbacks coming when the connection socket + * is able to accept another write packet without blocking. + * If it already was able to take another packet without blocking, + * you'll get this callback at the next call to the service loop + * function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE + * and servers get LWS_CALLBACK_SERVER_WRITEABLE. + * + * LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to + * the server at network level; the connection is accepted but then + * passed to this callback to decide whether to hang up immediately + * or not, based on the client IP. @user contains the connection + * socket's descriptor. Return non-zero to terminate + * the connection before sending or receiving anything. + * Because this happens immediately after the network connection + * from the client, there's no websocket protocol selected yet so + * this callback is issued only to protocol 0. + * + * LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has + * been received and parsed from the client, but the response is + * not sent yet. Return non-zero to disallow the connection. + * @user is a pointer to an array of struct lws_tokens, you can + * use the header enums lws_token_indexes from libwebsockets.h + * to check for and read the supported header presence and + * content before deciding to allow the handshake to proceed or + * to kill the connection. + * + * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: if configured for + * including OpenSSL support, this callback allows your user code + * to perform extra SSL_CTX_load_verify_locations() or similar + * calls to direct OpenSSL where to find certificates the client + * can use to confirm the remote server identity. @user is the + * OpenSSL SSL_CTX* + * + * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for + * including OpenSSL support, this callback allows your user code + * to load extra certifcates into the server which allow it to + * verify the validity of certificates returned by clients. @user + * is the server's OpenSSL SSL_CTX* + * + * LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: if the + * libwebsockets context was created with the option + * LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this + * callback is generated during OpenSSL verification of the cert + * sent from the client. It is sent to protocol[0] callback as + * no protocol has been negotiated on the connection yet. + * Notice that the libwebsockets context and wsi are both NULL + * during this callback. See + * http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html + * to understand more detail about the OpenSSL callback that + * generates this libwebsockets callback and the meanings of the + * arguments passed. In this callback, @user is the x509_ctx, + * @in is the ssl pointer and @len is preverify_ok + * Notice that this callback maintains libwebsocket return + * conventions, return 0 to mean the cert is OK or 1 to fail it. + * This also means that if you don't handle this callback then + * the default callback action of returning 0 allows the client + * certificates. + * + * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER: this callback happens + * when a client handshake is being compiled. @user is NULL, + * @in is a char **, it's pointing to a char * which holds the + * next location in the header buffer where you can add + * headers, and @len is the remaining space in the header buffer, + * which is typically some hundreds of bytes. So, to add a canned + * cookie, your handler code might look similar to: + * + * char **p = (char **)in; + * + * if (len < 100) + * return 1; + * + * *p += sprintf(*p, "Cookie: a=b\x0d\x0a"); + * + * return 0; + * + * Notice if you add anything, you just have to take care about + * the CRLF on the line you added. Obviously this callback is + * optional, if you don't handle it everything is fine. + * + * Notice the callback is coming to protocols[0] all the time, + * because there is no specific protocol handshook yet. + * + * LWS_CALLBACK_CONFIRM_EXTENSION_OKAY: When the server handshake code + * sees that it does support a requested extension, before + * accepting the extension by additing to the list sent back to + * the client it gives this callback just to check that it's okay + * to use that extension. It calls back to the requested protocol + * and with @in being the extension name, @len is 0 and @user is + * valid. Note though at this time the ESTABLISHED callback hasn't + * happened yet so if you initialize @user content there, @user + * content during this callback might not be useful for anything. + * Notice this callback comes to protocols[0]. + * + * LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: When a client + * connection is being prepared to start a handshake to a server, + * each supported extension is checked with protocols[0] callback + * with this reason, giving the user code a chance to suppress the + * claim to support that extension by returning non-zero. If + * unhandled, by default 0 will be returned and the extension + * support included in the header to the server. Notice this + * callback comes to protocols[0]. + * + * The next four reasons are optional and only need taking care of if you + * will be integrating libwebsockets sockets into an external polling + * array. + * + * LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop + * internally, but in the case you are integrating with another + * server you will need to have libwebsocket sockets share a + * polling array with the other server. This and the other + * POLL_FD related callbacks let you put your specialized + * poll array interface code in the callback for protocol 0, the + * first protocol you support, usually the HTTP protocol in the + * serving case. This callback happens when a socket needs to be + * added to the polling loop: @user contains the fd, and + * @len is the events bitmap (like, POLLIN). If you are using the + * internal polling loop (the "service" callback), you can just + * ignore these callbacks. + * + * LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor + * needs to be removed from an external polling array. @user is + * the socket desricptor. If you are using the internal polling + * loop, you can just ignore it. + * + * LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets + * wants to modify the events for the socket descriptor in @user. + * The handler should OR @len on to the events member of the pollfd + * struct for this socket descriptor. If you are using the + * internal polling loop, you can just ignore it. + * + * LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets + * wants to modify the events for the socket descriptor in @user. + * The handler should AND ~@len on to the events member of the + * pollfd struct for this socket descriptor. If you are using the + * internal polling loop, you can just ignore it. + */ +LWS_EXTERN int callback(struct libwebsocket_context * context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, void *user, + void *in, size_t len); + +typedef int (callback_function)(struct libwebsocket_context * context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, void *user, + void *in, size_t len); + + +/** + * extension_callback_function() - Hooks to allow extensions to operate + * @context: Websockets context + * @ext: This extension + * @wsi: Opaque websocket instance pointer + * @reason: The reason for the call + * @user: Pointer to per-session user data allocated by library + * @in: Pointer used for some callback reasons + * @len: Length set for some callback reasons + * + * Each extension that is active on a particular connection receives + * callbacks during the connection lifetime to allow the extension to + * operate on websocket data and manage itself. + * + * Libwebsockets takes care of allocating and freeing "user" memory for + * each active extension on each connection. That is what is pointed to + * by the @user parameter. + * + * LWS_EXT_CALLBACK_CONSTRUCT: called when the server has decided to + * select this extension from the list provided by the client, + * just before the server will send back the handshake accepting + * the connection with this extension active. This gives the + * extension a chance to initialize its connection context found + * in @user. + * + * LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: same as LWS_EXT_CALLBACK_CONSTRUCT + * but called when client is instantiating this extension. Some + * extensions will work the same on client and server side and then + * you can just merge handlers for both CONSTRUCTS. + * + * LWS_EXT_CALLBACK_DESTROY: called when the connection the extension was + * being used on is about to be closed and deallocated. It's the + * last chance for the extension to deallocate anything it has + * allocated in the user data (pointed to by @user) before the + * user data is deleted. This same callback is used whether you + * are in client or server instantiation context. + * + * LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: when this extension was active on + * a connection, and a packet of data arrived at the connection, + * it is passed to this callback to give the extension a chance to + * change the data, eg, decompress it. @user is pointing to the + * extension's private connection context data, @in is pointing + * to an lws_tokens struct, it consists of a char * pointer called + * token, and an int called token_len. At entry, these are + * set to point to the received buffer and set to the content + * length. If the extension will grow the content, it should use + * a new buffer allocated in its private user context data and + * set the pointed-to lws_tokens members to point to its buffer. + * + * LWS_EXT_CALLBACK_PACKET_TX_PRESEND: this works the same way as + * LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the + * extension a chance to change websocket data just before it will + * be sent out. Using the same lws_token pointer scheme in @in, + * the extension can change the buffer and the length to be + * transmitted how it likes. Again if it wants to grow the + * buffer safely, it should copy the data into its own buffer and + * set the lws_tokens token pointer to it. + */ +LWS_EXTERN int extension_callback(struct libwebsocket_context * context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, void *user, + void *in, size_t len); + +typedef int (extension_callback_function)(struct libwebsocket_context * context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, void *user, + void *in, size_t len); + +/** + * struct libwebsocket_protocols - List of protocols and handlers server + * supports. + * @name: Protocol name that must match the one given in the client + * Javascript new WebSocket(url, 'protocol') name + * @callback: The service callback used for this protocol. It allows the + * service action for an entire protocol to be encapsulated in + * the protocol-specific callback + * @per_session_data_size: Each new connection using this protocol gets + * this much memory allocated on connection establishment and + * freed on connection takedown. A pointer to this per-connection + * allocation is passed into the callback in the 'user' parameter + * @owning_server: the server init call fills in this opaque pointer when + * registering this protocol with the server. + * @broadcast_socket_port: the server init call fills this in with the + * localhost port number used to forward broadcasts for this + * protocol + * @broadcast_socket_user_fd: the server init call fills this in ... the main() + * process context can write to this socket to perform broadcasts + * (use the libwebsockets_broadcast() api to do this instead, + * it works from any process context) + * @protocol_index: which protocol we are starting from zero + * + * This structure represents one protocol supported by the server. An + * array of these structures is passed to libwebsocket_create_server() + * allows as many protocols as you like to be handled by one server. + */ + +struct libwebsocket_protocols { + const char *name; + callback_function *callback; + size_t per_session_data_size; + + /* + * below are filled in on server init and can be left uninitialized, + * no need for user to use them directly either + */ + + struct libwebsocket_context *owning_server; + int broadcast_socket_port; + int broadcast_socket_user_fd; + int protocol_index; +}; + +/** + * struct libwebsocket_extension - An extension we know how to cope with + * + * @name: Formal extension name, eg, "deflate-stream" + * @callback: Service callback + * @per_session_data_size: Libwebsockets will auto-malloc this much + * memory for the use of the extension, a pointer + * to it comes in the @user callback parameter + * @per_context_private_data: Optional storage for this externsion that + * is per-context, so it can track stuff across + * all sessions, etc, if it wants + */ + +struct libwebsocket_extension { + const char *name; + extension_callback_function *callback; + size_t per_session_data_size; + void * per_context_private_data; +}; + + + +LWS_EXTERN struct libwebsocket_context * +libwebsocket_create_context(int port, const char * interf, + struct libwebsocket_protocols *protocols, + struct libwebsocket_extension *extensions, + const char *ssl_cert_filepath, + const char *ssl_private_key_filepath, int gid, int uid, + unsigned int options); + +LWS_EXTERN void +libwebsocket_context_destroy(struct libwebsocket_context *context); + +LWS_EXTERN int +libwebsockets_fork_service_loop(struct libwebsocket_context *context); + +LWS_EXTERN int +libwebsocket_service(struct libwebsocket_context *context, int timeout_ms); + +LWS_EXTERN int +libwebsocket_service_fd(struct libwebsocket_context *context, + struct pollfd *pollfd); + +/* + * IMPORTANT NOTICE! + * + * When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY) + * the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE + * buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + len). + * + * This allows us to add protocol info before and after the data, and send as + * one packet on the network without payload copying, for maximum efficiency. + * + * So for example you need this kind of code to use libwebsocket_write with a + * 128-byte payload + * + * char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING]; + * + * // fill your part of the buffer... for example here it's all zeros + * memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128); + * + * libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128); + * + * When sending LWS_WRITE_HTTP, there is no protocol addition and you can just + * use the whole buffer without taking care of the above. + */ + +/* + * this is the frame nonce plus two header plus 8 length + * there's an additional two for mux extension per mux nesting level + * 2 byte prepend on close will already fit because control frames cannot use + * the big length style + */ + +#define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION)) +#define LWS_SEND_BUFFER_POST_PADDING 1 + +LWS_EXTERN int +libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len, + enum libwebsocket_write_protocol protocol); + +LWS_EXTERN int +libwebsockets_serve_http_file(struct libwebsocket *wsi, const char *file, + const char *content_type); + +/* notice - you need the pre- and post- padding allocation for buf below */ + +LWS_EXTERN int +libwebsockets_broadcast(const struct libwebsocket_protocols *protocol, + unsigned char *buf, size_t len); + +LWS_EXTERN const struct libwebsocket_protocols * +libwebsockets_get_protocol(struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_callback_on_writable(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_callback_on_writable_all_protocol( + const struct libwebsocket_protocols *protocol); + +LWS_EXTERN int +libwebsocket_get_socket_fd(struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_is_final_fragment(struct libwebsocket *wsi); + +LWS_EXTERN void * +libwebsocket_ensure_user_space(struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable); + +LWS_EXTERN size_t +libwebsockets_remaining_packet_payload(struct libwebsocket *wsi); + +LWS_EXTERN struct libwebsocket * +libwebsocket_client_connect(struct libwebsocket_context *clients, + const char *address, + int port, + int ssl_connection, + const char *path, + const char *host, + const char *origin, + const char *protocol, + int ietf_version_or_minus_one); + +LWS_EXTERN struct libwebsocket * +libwebsocket_client_connect_extended(struct libwebsocket_context *clients, + const char *address, + int port, + int ssl_connection, + const char *path, + const char *host, + const char *origin, + const char *protocol, + int ietf_version_or_minus_one, + void *userdata); + +LWS_EXTERN const char * +libwebsocket_canonical_hostname(struct libwebsocket_context *context); + + +LWS_EXTERN void +libwebsockets_get_peer_addresses(int fd, char *name, int name_len, + char *rip, int rip_len); + +LWS_EXTERN void +libwebsockets_hangup_on_client(struct libwebsocket_context *context, int fd); + +LWS_EXTERN void +libwebsocket_close_and_free_session(struct libwebsocket_context *context, + struct libwebsocket *wsi, enum lws_close_status); + +LWS_EXTERN int +libwebsockets_get_random(struct libwebsocket_context *context, + void *buf, int len); + +LWS_EXTERN int +lws_send_pipe_choked(struct libwebsocket *wsi); + +LWS_EXTERN unsigned char * +libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md); + +LWS_EXTERN int +lws_b64_encode_string(const char *in, int in_len, char *out, int out_size); + +LWS_EXTERN int +lws_b64_decode_string(const char *in, char *out, int out_size); + +LWS_EXTERN struct libwebsocket_extension libwebsocket_internal_extensions[]; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/libwebsockets/lib/md5.c b/libs/libwebsockets/lib/md5.c new file mode 100644 index 0000000000..042db3b8e4 --- /dev/null +++ b/libs/libwebsockets/lib/md5.c @@ -0,0 +1,217 @@ +/* + * Modified from Polarssl here + * http://polarssl.org/show_source?file=md5 + * under GPL2 or later + */ + +#include +#include + + +#define GET_ULONG_LE(n, b, i) \ +{ \ + (n) = ((unsigned long)(b)[i]) \ + | ((unsigned long)(b)[(i) + 1] << 8) \ + | ((unsigned long)(b)[(i) + 2] << 16) \ + | ((unsigned long)(b)[(i) + 3] << 24); \ +} + +#define PUT_ULONG_LE(n, b, i) \ +{ \ + (b)[i] = (unsigned char)(n); \ + (b)[(i) + 1] = (unsigned char)((n) >> 8); \ + (b)[(i) + 2] = (unsigned char)((n) >> 16); \ + (b)[(i) + 3] = (unsigned char)((n) >> 24); \ +} + +static const unsigned char md5_padding[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const unsigned long state_init[] = { + 0, 0, 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476 +}; + +static void +md5_process(unsigned long *state, const unsigned char *data) +{ + unsigned long X[16], A, B, C, D; + int v; + + for (v = 0; v < 16; v++) + GET_ULONG_LE(X[v], data, v << 2); + +#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define P(a, b, c, d, k, s, t) { a += F(b, c, d) + X[k] + t; a = S(a, s) + b; } + + A = state[0]; + B = state[1]; + C = state[2]; + D = state[3]; + +#define F(x, y, z) (z ^ (x & (y ^ z))) + + P(A, B, C, D, 0, 7, 0xD76AA478); + P(D, A, B, C, 1, 12, 0xE8C7B756); + P(C, D, A, B, 2, 17, 0x242070DB); + P(B, C, D, A, 3, 22, 0xC1BDCEEE); + P(A, B, C, D, 4, 7, 0xF57C0FAF); + P(D, A, B, C, 5, 12, 0x4787C62A); + P(C, D, A, B, 6, 17, 0xA8304613); + P(B, C, D, A, 7, 22, 0xFD469501); + P(A, B, C, D, 8, 7, 0x698098D8); + P(D, A, B, C, 9, 12, 0x8B44F7AF); + P(C, D, A, B, 10, 17, 0xFFFF5BB1); + P(B, C, D, A, 11, 22, 0x895CD7BE); + P(A, B, C, D, 12, 7, 0x6B901122); + P(D, A, B, C, 13, 12, 0xFD987193); + P(C, D, A, B, 14, 17, 0xA679438E); + P(B, C, D, A, 15, 22, 0x49B40821); + +#undef F + +#define F(x, y, z) (y ^ (z & (x ^ y))) + + P(A, B, C, D, 1, 5, 0xF61E2562); + P(D, A, B, C, 6, 9, 0xC040B340); + P(C, D, A, B, 11, 14, 0x265E5A51); + P(B, C, D, A, 0, 20, 0xE9B6C7AA); + P(A, B, C, D, 5, 5, 0xD62F105D); + P(D, A, B, C, 10, 9, 0x02441453); + P(C, D, A, B, 15, 14, 0xD8A1E681); + P(B, C, D, A, 4, 20, 0xE7D3FBC8); + P(A, B, C, D, 9, 5, 0x21E1CDE6); + P(D, A, B, C, 14, 9, 0xC33707D6); + P(C, D, A, B, 3, 14, 0xF4D50D87); + P(B, C, D, A, 8, 20, 0x455A14ED); + P(A, B, C, D, 13, 5, 0xA9E3E905); + P(D, A, B, C, 2, 9, 0xFCEFA3F8); + P(C, D, A, B, 7, 14, 0x676F02D9); + P(B, C, D, A, 12, 20, 0x8D2A4C8A); + +#undef F + +#define F(x, y, z) (x ^ y ^ z) + + P(A, B, C, D, 5, 4, 0xFFFA3942); + P(D, A, B, C, 8, 11, 0x8771F681); + P(C, D, A, B, 11, 16, 0x6D9D6122); + P(B, C, D, A, 14, 23, 0xFDE5380C); + P(A, B, C, D, 1, 4, 0xA4BEEA44); + P(D, A, B, C, 4, 11, 0x4BDECFA9); + P(C, D, A, B, 7, 16, 0xF6BB4B60); + P(B, C, D, A, 10, 23, 0xBEBFBC70); + P(A, B, C, D, 13, 4, 0x289B7EC6); + P(D, A, B, C, 0, 11, 0xEAA127FA); + P(C, D, A, B, 3, 16, 0xD4EF3085); + P(B, C, D, A, 6, 23, 0x04881D05); + P(A, B, C, D, 9, 4, 0xD9D4D039); + P(D, A, B, C, 12, 11, 0xE6DB99E5); + P(C, D, A, B, 15, 16, 0x1FA27CF8); + P(B, C, D, A, 2, 23, 0xC4AC5665); + +#undef F + +#define F(x, y, z) (y ^ (x | ~z)) + + P(A, B, C, D, 0, 6, 0xF4292244); + P(D, A, B, C, 7, 10, 0x432AFF97); + P(C, D, A, B, 14, 15, 0xAB9423A7); + P(B, C, D, A, 5, 21, 0xFC93A039); + P(A, B, C, D, 12, 6, 0x655B59C3); + P(D, A, B, C, 3, 10, 0x8F0CCC92); + P(C, D, A, B, 10, 15, 0xFFEFF47D); + P(B, C, D, A, 1, 21, 0x85845DD1); + P(A, B, C, D, 8, 6, 0x6FA87E4F); + P(D, A, B, C, 15, 10, 0xFE2CE6E0); + P(C, D, A, B, 6, 15, 0xA3014314); + P(B, C, D, A, 13, 21, 0x4E0811A1); + P(A, B, C, D, 4, 6, 0xF7537E82); + P(D, A, B, C, 11, 10, 0xBD3AF235); + P(C, D, A, B, 2, 15, 0x2AD7D2BB); + P(B, C, D, A, 9, 21, 0xEB86D391); + +#undef F + + state[0] += A; + state[1] += B; + state[2] += C; + state[3] += D; +} + +static +void md5_update(unsigned long *state, unsigned char *buffer, + const unsigned char *input, int ilen) +{ + int fill; + unsigned long left; + + if (ilen <= 0) + return; + + left = state[0] & 0x3F; + fill = 64 - left; + + state[0] += ilen; + state[0] &= 0xFFFFFFFF; + + if (state[0] < (unsigned long)ilen) + state[1]++; + + if (left && ilen >= fill) { + memcpy(buffer + left, input, fill); + md5_process(&state[2], buffer); + input += fill; + ilen -= fill; + left = 0; + } + + while (ilen >= 64) { + md5_process(&state[2], input); + input += 64; + ilen -= 64; + } + + if (ilen > 0) + memcpy(buffer + left, input, ilen); +} + +void +MD5(const unsigned char *input, int ilen, unsigned char *output) +{ + unsigned long last, padn; + unsigned long high, low; + unsigned char msglen[8]; + unsigned long state[6]; + unsigned char buffer[64]; + + memcpy(&state[0], &state_init[0], sizeof(state_init)); + + md5_update(state, buffer, input, ilen); + + high = (state[0] >> 29) | (state[1] << 3); + low = state[0] << 3; + + PUT_ULONG_LE(low, msglen, 0); + PUT_ULONG_LE(high, msglen, 4); + + last = state[0] & 0x3F; + padn = (last < 56) ? (56 - last) : (120 - last); + + md5_update(state, buffer, md5_padding, padn); + md5_update(state, buffer, msglen, 8); + + PUT_ULONG_LE(state[2], output, 0); + PUT_ULONG_LE(state[3], output, 4); + PUT_ULONG_LE(state[4], output, 8); + PUT_ULONG_LE(state[5], output, 12); +} + diff --git a/libs/libwebsockets/lib/parsers.c b/libs/libwebsockets/lib/parsers.c new file mode 100644 index 0000000000..a185971610 --- /dev/null +++ b/libs/libwebsockets/lib/parsers.c @@ -0,0 +1,1967 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "private-libwebsockets.h" + +const struct lws_tokens lws_tokens[WSI_TOKEN_COUNT] = { + + /* win32 can't do C99 */ + +/* [WSI_TOKEN_GET_URI] = */{ "GET ", 4 }, +/* [WSI_TOKEN_HOST] = */{ "Host:", 5 }, +/* [WSI_TOKEN_CONNECTION] = */{ "Connection:", 11 }, +/* [WSI_TOKEN_KEY1] = */{ "Sec-WebSocket-Key1:", 19 }, +/* [WSI_TOKEN_KEY2] = */{ "Sec-WebSocket-Key2:", 19 }, +/* [WSI_TOKEN_PROTOCOL] = */{ "Sec-WebSocket-Protocol:", 23 }, +/* [WSI_TOKEN_UPGRADE] = */{ "Upgrade:", 8 }, +/* [WSI_TOKEN_ORIGIN] = */{ "Origin:", 7 }, +/* [WSI_TOKEN_DRAFT] = */{ "Sec-WebSocket-Draft:", 20 }, +/* [WSI_TOKEN_CHALLENGE] = */{ "\x0d\x0a", 2 }, + +/* [WSI_TOKEN_KEY] = */{ "Sec-WebSocket-Key:", 18 }, +/* [WSI_TOKEN_VERSION] = */{ "Sec-WebSocket-Version:", 22 }, +/* [WSI_TOKEN_SWORIGIN]= */{ "Sec-WebSocket-Origin:", 21 }, + +/* [WSI_TOKEN_EXTENSIONS] = */{ "Sec-WebSocket-Extensions:", 25 }, + +/* [WSI_TOKEN_ACCEPT] = */{ "Sec-WebSocket-Accept:", 21 }, +/* [WSI_TOKEN_NONCE] = */{ "Sec-WebSocket-Nonce:", 20 }, +/* [WSI_TOKEN_HTTP] = */{ "HTTP/1.1 ", 9 }, +/* [WSI_TOKEN_MUXURL] = */{ "", -1 }, + +}; + +int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c) +{ + int n; + + switch (wsi->parser_state) { + case WSI_TOKEN_GET_URI: + case WSI_TOKEN_HOST: + case WSI_TOKEN_CONNECTION: + case WSI_TOKEN_KEY1: + case WSI_TOKEN_KEY2: + case WSI_TOKEN_PROTOCOL: + case WSI_TOKEN_UPGRADE: + case WSI_TOKEN_ORIGIN: + case WSI_TOKEN_SWORIGIN: + case WSI_TOKEN_DRAFT: + case WSI_TOKEN_CHALLENGE: + case WSI_TOKEN_KEY: + case WSI_TOKEN_VERSION: + case WSI_TOKEN_ACCEPT: + case WSI_TOKEN_NONCE: + case WSI_TOKEN_EXTENSIONS: + case WSI_TOKEN_HTTP: + case WSI_TOKEN_MUXURL: + + debug("WSI_TOKEN_(%d) '%c'\n", wsi->parser_state, c); + + /* collect into malloc'd buffers */ + /* optional space swallow */ + if (!wsi->utf8_token[wsi->parser_state].token_len && c == ' ') + break; + + /* special case space terminator for get-uri */ + if (wsi->parser_state == WSI_TOKEN_GET_URI && c == ' ') { + wsi->utf8_token[wsi->parser_state].token[ + wsi->utf8_token[wsi->parser_state].token_len] = '\0'; + wsi->parser_state = WSI_TOKEN_SKIPPING; + break; + } + + /* allocate appropriate memory */ + if (wsi->utf8_token[wsi->parser_state].token_len == + wsi->current_alloc_len - 1) { + /* need to extend */ + wsi->current_alloc_len += LWS_ADDITIONAL_HDR_ALLOC; + if (wsi->current_alloc_len >= LWS_MAX_HEADER_LEN) { + /* it's waaay to much payload, fail it */ + strcpy(wsi->utf8_token[wsi->parser_state].token, + "!!! Length exceeded maximum supported !!!"); + wsi->parser_state = WSI_TOKEN_SKIPPING; + break; + } + wsi->utf8_token[wsi->parser_state].token = + realloc(wsi->utf8_token[wsi->parser_state].token, + wsi->current_alloc_len); + } + + /* bail at EOL */ + if (wsi->parser_state != WSI_TOKEN_CHALLENGE && c == '\x0d') { + wsi->utf8_token[wsi->parser_state].token[ + wsi->utf8_token[wsi->parser_state].token_len] = '\0'; + wsi->parser_state = WSI_TOKEN_SKIPPING_SAW_CR; + debug("*\n"); + break; + } + + wsi->utf8_token[wsi->parser_state].token[ + wsi->utf8_token[wsi->parser_state].token_len++] = c; + + /* per-protocol end of headers management */ + + if (wsi->parser_state != WSI_TOKEN_CHALLENGE) + break; + + /* -76 has no version header ... server */ + if (!wsi->utf8_token[WSI_TOKEN_VERSION].token_len && + wsi->mode != LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY && + wsi->utf8_token[wsi->parser_state].token_len != 8) + break; + + /* -76 has no version header ... client */ + if (!wsi->utf8_token[WSI_TOKEN_VERSION].token_len && + wsi->mode == LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY && + wsi->utf8_token[wsi->parser_state].token_len != 16) + break; + + /* <= 03 has old handshake with version header needs 8 bytes */ + if (wsi->utf8_token[WSI_TOKEN_VERSION].token_len && + atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token) < 4 && + wsi->utf8_token[wsi->parser_state].token_len != 8) + break; + + /* no payload challenge in 01 + */ + + if (wsi->utf8_token[WSI_TOKEN_VERSION].token_len && + atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token) > 0) { + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len = 0; + free(wsi->utf8_token[WSI_TOKEN_CHALLENGE].token); + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token = NULL; + } + + /* For any supported protocol we have enough payload */ + + debug("Setting WSI_PARSING_COMPLETE\n"); + wsi->parser_state = WSI_PARSING_COMPLETE; + break; + + case WSI_INIT_TOKEN_MUXURL: + wsi->parser_state = WSI_TOKEN_MUXURL; + wsi->current_alloc_len = LWS_INITIAL_HDR_ALLOC; + + wsi->utf8_token[wsi->parser_state].token = + malloc(wsi->current_alloc_len); + wsi->utf8_token[wsi->parser_state].token_len = 0; + break; + + /* collecting and checking a name part */ + case WSI_TOKEN_NAME_PART: + debug("WSI_TOKEN_NAME_PART '%c'\n", c); + + if (wsi->name_buffer_pos == sizeof(wsi->name_buffer) - 1) { + /* name bigger than we can handle, skip until next */ + wsi->parser_state = WSI_TOKEN_SKIPPING; + break; + } + wsi->name_buffer[wsi->name_buffer_pos++] = c; + wsi->name_buffer[wsi->name_buffer_pos] = '\0'; + + for (n = 0; n < WSI_TOKEN_COUNT; n++) { + if (wsi->name_buffer_pos != lws_tokens[n].token_len) + continue; + if (strcasecmp(lws_tokens[n].token, wsi->name_buffer)) + continue; + debug("known hdr '%s'\n", wsi->name_buffer); + + /* + * WSORIGIN is protocol equiv to ORIGIN, + * JWebSocket likes to send it, map to ORIGIN + */ + if (n == WSI_TOKEN_SWORIGIN) + n = WSI_TOKEN_ORIGIN; + + wsi->parser_state = WSI_TOKEN_GET_URI + n; + + n = WSI_TOKEN_COUNT; + + /* If the header has been seen already, just append */ + if (wsi->utf8_token[wsi->parser_state].token) + continue; + + wsi->current_alloc_len = LWS_INITIAL_HDR_ALLOC; + wsi->utf8_token[wsi->parser_state].token = + malloc(wsi->current_alloc_len); + wsi->utf8_token[wsi->parser_state].token_len = 0; + } + + /* colon delimiter means we just don't know this name */ + + if (wsi->parser_state == WSI_TOKEN_NAME_PART && c == ':') { + debug("skipping unknown header '%s'\n", + wsi->name_buffer); + wsi->parser_state = WSI_TOKEN_SKIPPING; + break; + } + + if (wsi->parser_state != WSI_TOKEN_CHALLENGE) + break; + + /* don't look for payload when it can just be http headers */ + + if (!wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len) { + /* they're HTTP headers, not websocket upgrade! */ + debug("Setting WSI_PARSING_COMPLETE " + "from http headers\n"); + wsi->parser_state = WSI_PARSING_COMPLETE; + } + + /* 04 version has no packet content after end of hdrs */ + + if (wsi->utf8_token[WSI_TOKEN_VERSION].token_len && + atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token) >= 4) { + debug("04 header completed\n"); + wsi->parser_state = WSI_PARSING_COMPLETE; + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len = 0; + free(wsi->utf8_token[WSI_TOKEN_CHALLENGE].token); + wsi->utf8_token[WSI_TOKEN_CHALLENGE].token = NULL; + } + + /* client parser? */ + + if (wsi->ietf_spec_revision >= 4) { + debug("04 header completed\n"); + wsi->parser_state = WSI_PARSING_COMPLETE; + } + + break; + + /* skipping arg part of a name we didn't recognize */ + case WSI_TOKEN_SKIPPING: + debug("WSI_TOKEN_SKIPPING '%c'\n", c); + if (c == '\x0d') + wsi->parser_state = WSI_TOKEN_SKIPPING_SAW_CR; + break; + case WSI_TOKEN_SKIPPING_SAW_CR: + debug("WSI_TOKEN_SKIPPING_SAW_CR '%c'\n", c); + if (c == '\x0a') + wsi->parser_state = WSI_TOKEN_NAME_PART; + else + wsi->parser_state = WSI_TOKEN_SKIPPING; + wsi->name_buffer_pos = 0; + break; + /* we're done, ignore anything else */ + case WSI_PARSING_COMPLETE: + debug("WSI_PARSING_COMPLETE '%c'\n", c); + break; + + default: /* keep gcc happy */ + break; + } + + return 0; +} + +unsigned char +xor_no_mask(struct libwebsocket *wsi, unsigned char c) +{ + return c; +} + +unsigned char +xor_mask_04(struct libwebsocket *wsi, unsigned char c) +{ + c ^= wsi->masking_key_04[wsi->frame_mask_index++]; + if (wsi->frame_mask_index == 20) + wsi->frame_mask_index = 0; + + return c; +} + +unsigned char +xor_mask_05(struct libwebsocket *wsi, unsigned char c) +{ + return c ^ wsi->frame_masking_nonce_04[(wsi->frame_mask_index++) & 3]; +} + + + +int +libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c) +{ + int n; + unsigned char buf[20 + 4]; + struct lws_tokens eff_buf; + int handled; + int m; + +#if 0 + fprintf(stderr, "RX: %02X ", c); +#endif + + switch (wsi->lws_rx_parse_state) { + case LWS_RXPS_NEW: + + switch (wsi->ietf_spec_revision) { + /* Firefox 4.0b6 likes this as of 30 Oct 2010 */ + case 0: + if (c == 0xff) + wsi->lws_rx_parse_state = LWS_RXPS_SEEN_76_FF; + if (c == 0) { + wsi->lws_rx_parse_state = + LWS_RXPS_EAT_UNTIL_76_FF; + wsi->rx_user_buffer_head = 0; + } + break; + case 4: + case 5: + case 6: + wsi->all_zero_nonce = 1; + wsi->frame_masking_nonce_04[0] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_04_MASK_NONCE_1; + break; + case 7: + case 8: + case 13: + /* + * no prepended frame key any more + */ + wsi->all_zero_nonce = 1; + goto handle_first; + + default: + fprintf(stderr, "libwebsocket_rx_sm doesn't know " + "about spec version %d\n", wsi->ietf_spec_revision); + break; + } + break; + case LWS_RXPS_04_MASK_NONCE_1: + wsi->frame_masking_nonce_04[1] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_04_MASK_NONCE_2; + break; + case LWS_RXPS_04_MASK_NONCE_2: + wsi->frame_masking_nonce_04[2] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_04_MASK_NONCE_3; + break; + case LWS_RXPS_04_MASK_NONCE_3: + wsi->frame_masking_nonce_04[3] = c; + if (c) + wsi->all_zero_nonce = 0; + + if (wsi->protocol->owning_server->options & + LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK) + goto post_mask; + + if (wsi->ietf_spec_revision > 4) + goto post_sha1; + + /* + * we are able to compute the frame key now + * it's a SHA1 of ( frame nonce we were just sent, concatenated + * with the connection masking key we computed at handshake + * time ) -- yeah every frame from the client invokes a SHA1 + * for no real reason so much for lightweight. + */ + + buf[0] = wsi->frame_masking_nonce_04[0]; + buf[1] = wsi->frame_masking_nonce_04[1]; + buf[2] = wsi->frame_masking_nonce_04[2]; + buf[3] = wsi->frame_masking_nonce_04[3]; + + memcpy(buf + 4, wsi->masking_key_04, 20); + + /* + * wsi->frame_mask_04 will be our recirculating 20-byte XOR key + * for this frame + */ + + SHA1((unsigned char *)buf, 4 + 20, wsi->frame_mask_04); + +post_sha1: + + /* + * start from the zero'th byte in the XOR key buffer since + * this is the start of a frame with a new key + */ + + wsi->frame_mask_index = 0; + +post_mask: + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_1; + break; + + /* + * 04 logical framing from the spec (all this is masked when incoming + * and has to be unmasked) + * + * We ignore the possibility of extension data because we don't + * negotiate any extensions at the moment. + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-------+-+-------------+-------------------------------+ + * |F|R|R|R| opcode|R| Payload len | Extended payload length | + * |I|S|S|S| (4) |S| (7) | (16/63) | + * |N|V|V|V| |V| | (if payload len==126/127) | + * | |1|2|3| |4| | | + * +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + + * | Extended payload length continued, if payload len == 127 | + * + - - - - - - - - - - - - - - - +-------------------------------+ + * | | Extension data | + * +-------------------------------+ - - - - - - - - - - - - - - - + + * : : + * +---------------------------------------------------------------+ + * : Application data : + * +---------------------------------------------------------------+ + * + * We pass payload through to userland as soon as we get it, ignoring + * FIN. It's up to userland to buffer it up if it wants to see a + * whole unfragmented block of the original size (which may be up to + * 2^63 long!) + */ + + case LWS_RXPS_04_FRAME_HDR_1: +handle_first: + + /* + * 04 spec defines the opcode like this: (1, 2, and 3 are + * "control frame" opcodes which may not be fragmented or + * have size larger than 126) + * + * frame-opcode = + * %x0 ; continuation frame + * / %x1 ; connection close + * / %x2 ; ping + * / %x3 ; pong + * / %x4 ; text frame + * / %x5 ; binary frame + * / %x6-F ; reserved + * + * FIN (b7) + */ + + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + + if (c & 0x70) + fprintf(stderr, + "Frame has unknown extension bits set 1 %02X\n", c); + + /* translate all incoming opcodes into v7+ map */ + if (wsi->ietf_spec_revision < 7) + switch (c & 0xf) { + case LWS_WS_OPCODE_04__CONTINUATION: + wsi->opcode = LWS_WS_OPCODE_07__CONTINUATION; + break; + case LWS_WS_OPCODE_04__CLOSE: + wsi->opcode = LWS_WS_OPCODE_07__CLOSE; + break; + case LWS_WS_OPCODE_04__PING: + wsi->opcode = LWS_WS_OPCODE_07__PING; + break; + case LWS_WS_OPCODE_04__PONG: + wsi->opcode = LWS_WS_OPCODE_07__PONG; + break; + case LWS_WS_OPCODE_04__TEXT_FRAME: + wsi->opcode = LWS_WS_OPCODE_07__TEXT_FRAME; + break; + case LWS_WS_OPCODE_04__BINARY_FRAME: + wsi->opcode = LWS_WS_OPCODE_07__BINARY_FRAME; + break; + default: + fprintf(stderr, "reserved opcodes not " + "usable pre v7 protocol\n"); + return -1; + } + else + wsi->opcode = c & 0xf; + + wsi->final = !!((c >> 7) & 1); + + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN: + + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + + if ((c & 0x80) && wsi->ietf_spec_revision < 7) { + fprintf(stderr, "Frame has extensions " + "set illegally 2\n"); + /* kill the connection */ + return -1; + } + + wsi->this_frame_masked = !!(c & 0x80); + + switch (c & 0x7f) { + case 126: + /* control frames are not allowed to have big lengths */ + if (wsi->opcode & 8) + goto illegal_ctl_length; + + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN16_2; + break; + case 127: + /* control frames are not allowed to have big lengths */ + if (wsi->opcode & 8) + goto illegal_ctl_length; + + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_8; + break; + default: + wsi->rx_packet_length = c & 0x7f; + if (wsi->this_frame_masked) + wsi->lws_rx_parse_state = + LWS_RXPS_07_COLLECT_FRAME_KEY_1; + else + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + break; + } + break; + + case LWS_RXPS_04_FRAME_HDR_LEN16_2: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + + wsi->rx_packet_length = c << 8; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN16_1; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN16_1: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + + wsi->rx_packet_length |= c; + if (wsi->this_frame_masked) + wsi->lws_rx_parse_state = + LWS_RXPS_07_COLLECT_FRAME_KEY_1; + else + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_8: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + if (c & 0x80) { + fprintf(stderr, "b63 of length must be zero\n"); + /* kill the connection */ + return -1; + } +#if defined __LP64__ + wsi->rx_packet_length = ((size_t)c) << 56; +#else + wsi->rx_packet_length = 0; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_7; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_7: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); +#if defined __LP64__ + wsi->rx_packet_length |= ((size_t)c) << 48; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_6; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_6: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); +#if defined __LP64__ + wsi->rx_packet_length |= ((size_t)c) << 40; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_5; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_5: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); +#if defined __LP64__ + wsi->rx_packet_length |= ((size_t)c) << 32; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_4; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_4: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + wsi->rx_packet_length |= ((size_t)c) << 24; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_3; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_3: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + wsi->rx_packet_length |= ((size_t)c) << 16; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_2; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_2: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + wsi->rx_packet_length |= ((size_t)c) << 8; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_1; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_1: + if (wsi->ietf_spec_revision < 7) + c = wsi->xor_mask(wsi, c); + wsi->rx_packet_length |= ((size_t)c); + if (wsi->this_frame_masked) + wsi->lws_rx_parse_state = + LWS_RXPS_07_COLLECT_FRAME_KEY_1; + else + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + break; + + case LWS_RXPS_EAT_UNTIL_76_FF: + if (c == 0xff) { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto issue; + } + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + (wsi->rx_user_buffer_head++)] = c; + + if (wsi->rx_user_buffer_head != MAX_USER_RX_BUFFER) + break; +issue: + if (wsi->protocol->callback) + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_RECEIVE, + wsi->user_space, + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head); + wsi->rx_user_buffer_head = 0; + break; + case LWS_RXPS_SEEN_76_FF: + if (c) + break; + + debug("Seen that client is requesting " + "a v76 close, sending ack\n"); + buf[0] = 0xff; + buf[1] = 0; + n = libwebsocket_write(wsi, buf, 2, LWS_WRITE_HTTP); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + return -1; + } + debug(" v76 close ack sent, server closing skt\n"); + /* returning < 0 will get it closed in parent */ + return -1; + + case LWS_RXPS_PULLING_76_LENGTH: + break; + + + case LWS_RXPS_07_COLLECT_FRAME_KEY_1: + wsi->frame_masking_nonce_04[0] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_2; + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_2: + wsi->frame_masking_nonce_04[1] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_3; + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_3: + wsi->frame_masking_nonce_04[2] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_4; + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_4: + wsi->frame_masking_nonce_04[3] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + wsi->frame_mask_index = 0; + break; + + + case LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED: + if (wsi->ietf_spec_revision < 4 || + (wsi->all_zero_nonce && wsi->ietf_spec_revision >= 5)) + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + (wsi->rx_user_buffer_head++)] = c; + else + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + (wsi->rx_user_buffer_head++)] = + wsi->xor_mask(wsi, c); + + if (--wsi->rx_packet_length == 0) { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto spill; + } + if (wsi->rx_user_buffer_head != MAX_USER_RX_BUFFER) + break; +spill: + /* + * is this frame a control packet we should take care of at this + * layer? If so service it and hide it from the user callback + */ + + debug("spill on %s\n", wsi->protocol->name); + + switch (wsi->opcode) { + case LWS_WS_OPCODE_07__CLOSE: + /* is this an acknowledgement of our close? */ + if (wsi->state == WSI_STATE_AWAITING_CLOSE_ACK) { + /* + * fine he has told us he is closing too, let's + * finish our close + */ + debug("seen client close ack\n"); + return -1; + } + debug("server sees client close packet\n"); + /* parrot the close packet payload back */ + n = libwebsocket_write(wsi, (unsigned char *) + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head, LWS_WRITE_CLOSE); + wsi->state = WSI_STATE_RETURNED_CLOSE_ALREADY; + /* close the connection */ + return -1; + + case LWS_WS_OPCODE_07__PING: + /* parrot the ping packet payload back as a pong */ + n = libwebsocket_write(wsi, (unsigned char *) + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head, LWS_WRITE_PONG); + /* ... then just drop it */ + wsi->rx_user_buffer_head = 0; + return 0; + + case LWS_WS_OPCODE_07__PONG: + /* keep the statistics... */ + wsi->pings_vs_pongs--; + /* ... then just drop it */ + wsi->rx_user_buffer_head = 0; + return 0; + + case LWS_WS_OPCODE_07__TEXT_FRAME: + case LWS_WS_OPCODE_07__BINARY_FRAME: + break; + + default: + + debug("passing opcode %x up to exts\n", wsi->opcode); + + /* + * It's something special we can't understand here. + * Pass the payload up to the extension's parsing + * state machine. + */ + + eff_buf.token = &wsi->rx_user_buffer[ + LWS_SEND_BUFFER_PRE_PADDING]; + eff_buf.token_len = wsi->rx_user_buffer_head; + + handled = 0; + for (n = 0; n < wsi->count_active_extensions; n++) { + m = wsi->active_extensions[n]->callback( + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX, + wsi->active_extensions_user[n], + &eff_buf, 0); + if (m) + handled = 1; + } + + if (!handled) + fprintf(stderr, "Unhandled extended opcode " + "0x%x - ignoring frame\n", wsi->opcode); + + wsi->rx_user_buffer_head = 0; + return 0; + } + + /* + * No it's real payload, pass it up to the user callback. + * It's nicely buffered with the pre-padding taken care of + * so it can be sent straight out again using libwebsocket_write + */ + + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + wsi->rx_user_buffer_head] = '\0'; + + if (wsi->protocol->callback) + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, LWS_CALLBACK_RECEIVE, + wsi->user_space, + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head); + else + fprintf(stderr, "No callback on payload spill!\n"); + + wsi->rx_user_buffer_head = 0; + break; + } + + return 0; + +illegal_ctl_length: + + fprintf(stderr, "Control frame asking for " + "extended length is illegal\n"); + /* kill the connection */ + return -1; +} + + +int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c) +{ + int n; + unsigned char buf[20 + 4]; + int callback_action = LWS_CALLBACK_CLIENT_RECEIVE; + int handled; + struct lws_tokens eff_buf; + int m; + + debug(" CRX: %02X %d\n", c, wsi->lws_rx_parse_state); + + switch (wsi->lws_rx_parse_state) { + case LWS_RXPS_NEW: + + switch (wsi->ietf_spec_revision) { + /* Firefox 4.0b6 likes this as of 30 Oct */ + case 0: + if (c == 0xff) + wsi->lws_rx_parse_state = LWS_RXPS_SEEN_76_FF; + if (c == 0) { + wsi->lws_rx_parse_state = + LWS_RXPS_EAT_UNTIL_76_FF; + wsi->rx_user_buffer_head = 0; + } + break; + case 4: + case 5: + case 6: + case 7: + case 8: + case 13: + /* + * 04 logical framing from the spec (all this is masked when + * incoming and has to be unmasked) + * + * We ignore the possibility of extension data because we don't + * negotiate any extensions at the moment. + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-------+-+-------------+-------------------------------+ + * |F|R|R|R| opcode|R| Payload len | Extended payload length | + * |I|S|S|S| (4) |S| (7) | (16/63) | + * |N|V|V|V| |V| | (if payload len==126/127) | + * | |1|2|3| |4| | | + * +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + + * | Extended payload length continued, if payload len == 127 | + * + - - - - - - - - - - - - - - - +-------------------------------+ + * | | Extension data | + * +-------------------------------+ - - - - - - - - - - - - - - - + + * : : + * +---------------------------------------------------------------+ + * : Application data : + * +---------------------------------------------------------------+ + * + * We pass payload through to userland as soon as we get it, ignoring + * FIN. It's up to userland to buffer it up if it wants to see a + * whole unfragmented block of the original size (which may be up to + * 2^63 long!) + * + * Notice in v7 RSV4 is set to indicate 32-bit frame key is coming in + * after length, unlike extension data which is now deprecated, this + * does not impact the payload length calculation. + */ + + /* + * 04 spec defines the opcode like this: (1, 2, and 3 are + * "control frame" opcodes which may not be fragmented or + * have size larger than 126) + * + * frame-opcode = + * %x0 ; continuation frame + * / %x1 ; connection close + * / %x2 ; ping + * / %x3 ; pong + * / %x4 ; text frame + * / %x5 ; binary frame + * / %x6-F ; reserved + * + * FIN (b7) + */ + + if (c & 0x70) + fprintf(stderr, "Frame has unknown extension " + "bits set on first framing byte %02X\n", c); + + if (wsi->ietf_spec_revision < 7) + switch (c & 0xf) { + case LWS_WS_OPCODE_04__CONTINUATION: + wsi->opcode = + LWS_WS_OPCODE_07__CONTINUATION; + break; + case LWS_WS_OPCODE_04__CLOSE: + wsi->opcode = LWS_WS_OPCODE_07__CLOSE; + break; + case LWS_WS_OPCODE_04__PING: + wsi->opcode = LWS_WS_OPCODE_07__PING; + break; + case LWS_WS_OPCODE_04__PONG: + wsi->opcode = LWS_WS_OPCODE_07__PONG; + break; + case LWS_WS_OPCODE_04__TEXT_FRAME: + wsi->opcode = + LWS_WS_OPCODE_07__TEXT_FRAME; + break; + case LWS_WS_OPCODE_04__BINARY_FRAME: + wsi->opcode = + LWS_WS_OPCODE_07__BINARY_FRAME; + break; + default: + fprintf(stderr, "reserved opcodes not " + "usable pre v7 protocol\n"); + return -1; + } + else + wsi->opcode = c & 0xf; + + wsi->final = !!((c >> 7) & 1); + + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN; + break; + + default: + fprintf(stderr, "client_rx_sm doesn't know how " + "to handle spec version %02d\n", + wsi->ietf_spec_revision); + break; + } + break; + + + case LWS_RXPS_04_FRAME_HDR_LEN: + + if ((c & 0x80) && wsi->ietf_spec_revision < 7) { + fprintf(stderr, + "Frame has extensions set illegally 4\n"); + /* kill the connection */ + return -1; + } + + wsi->this_frame_masked = !!(c & 0x80); + + switch (c & 0x7f) { + case 126: + /* control frames are not allowed to have big lengths */ + if (wsi->opcode & 8) + goto illegal_ctl_length; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN16_2; + break; + case 127: + /* control frames are not allowed to have big lengths */ + if (wsi->opcode & 8) + goto illegal_ctl_length; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_8; + break; + default: + wsi->rx_packet_length = c; + if (wsi->this_frame_masked) + wsi->lws_rx_parse_state = + LWS_RXPS_07_COLLECT_FRAME_KEY_1; + else { + if (c) + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + else { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto spill; + } + } + break; + } + break; + + case LWS_RXPS_04_FRAME_HDR_LEN16_2: + wsi->rx_packet_length = c << 8; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN16_1; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN16_1: + wsi->rx_packet_length |= c; + if (wsi->this_frame_masked) + wsi->lws_rx_parse_state = + LWS_RXPS_07_COLLECT_FRAME_KEY_1; + else { + if (wsi->rx_packet_length) + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + else { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto spill; + } + } + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_8: + if (c & 0x80) { + fprintf(stderr, "b63 of length must be zero\n"); + /* kill the connection */ + return -1; + } +#if defined __LP64__ + wsi->rx_packet_length = ((size_t)c) << 56; +#else + wsi->rx_packet_length = 0; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_7; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_7: +#if defined __LP64__ + wsi->rx_packet_length |= ((size_t)c) << 48; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_6; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_6: +#if defined __LP64__ + wsi->rx_packet_length |= ((size_t)c) << 40; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_5; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_5: +#if defined __LP64__ + wsi->rx_packet_length |= ((size_t)c) << 32; +#endif + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_4; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_4: + wsi->rx_packet_length |= ((size_t)c) << 24; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_3; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_3: + wsi->rx_packet_length |= ((size_t)c) << 16; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_2; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_2: + wsi->rx_packet_length |= ((size_t)c) << 8; + wsi->lws_rx_parse_state = LWS_RXPS_04_FRAME_HDR_LEN64_1; + break; + + case LWS_RXPS_04_FRAME_HDR_LEN64_1: + wsi->rx_packet_length |= (size_t)c; + if (wsi->this_frame_masked) + wsi->lws_rx_parse_state = + LWS_RXPS_07_COLLECT_FRAME_KEY_1; + else { + if (wsi->rx_packet_length) + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + else { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto spill; + } + } + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_1: + wsi->frame_masking_nonce_04[0] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_2; + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_2: + wsi->frame_masking_nonce_04[1] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_3; + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_3: + wsi->frame_masking_nonce_04[2] = c; + if (c) + wsi->all_zero_nonce = 0; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_4; + break; + + case LWS_RXPS_07_COLLECT_FRAME_KEY_4: + wsi->frame_masking_nonce_04[3] = c; + if (c) + wsi->all_zero_nonce = 0; + + if (wsi->rx_packet_length) + wsi->lws_rx_parse_state = + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED; + else { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto spill; + } + break; + + case LWS_RXPS_EAT_UNTIL_76_FF: + if (c == 0xff) { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto issue; + } + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + (wsi->rx_user_buffer_head++)] = c; + + if (wsi->rx_user_buffer_head != MAX_USER_RX_BUFFER) + break; +issue: + if (wsi->protocol->callback) + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, + LWS_CALLBACK_CLIENT_RECEIVE, + wsi->user_space, + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head); + wsi->rx_user_buffer_head = 0; + break; + case LWS_RXPS_SEEN_76_FF: + if (c) + break; + + debug("Seen that client is requesting " + "a v76 close, sending ack\n"); + buf[0] = 0xff; + buf[1] = 0; + n = libwebsocket_write(wsi, buf, 2, LWS_WRITE_HTTP); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + return -1; + } + debug(" v76 close ack sent, server closing skt\n"); + /* returning < 0 will get it closed in parent */ + return -1; + + case LWS_RXPS_PULLING_76_LENGTH: + break; + + case LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED: + if ((!wsi->this_frame_masked) || wsi->all_zero_nonce) + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + (wsi->rx_user_buffer_head++)] = c; + else + wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + + (wsi->rx_user_buffer_head++)] = + wsi->xor_mask(wsi, c); + + if (--wsi->rx_packet_length == 0) { + wsi->lws_rx_parse_state = LWS_RXPS_NEW; + goto spill; + } + if (wsi->rx_user_buffer_head != MAX_USER_RX_BUFFER) + break; +spill: + + handled = 0; + + /* + * is this frame a control packet we should take care of at this + * layer? If so service it and hide it from the user callback + */ + + switch (wsi->opcode) { + case LWS_WS_OPCODE_07__CLOSE: + /* is this an acknowledgement of our close? */ + if (wsi->state == WSI_STATE_AWAITING_CLOSE_ACK) { + /* + * fine he has told us he is closing too, let's + * finish our close + */ + debug("seen server's close ack\n"); + return -1; + } + debug("client sees server close packet len = %d\n", wsi->rx_user_buffer_head); + /* parrot the close packet payload back */ + n = libwebsocket_write(wsi, (unsigned char *) + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head, LWS_WRITE_CLOSE); + debug("client writing close ack returned %d\n", n); + wsi->state = WSI_STATE_RETURNED_CLOSE_ALREADY; + /* close the connection */ + return -1; + + case LWS_WS_OPCODE_07__PING: + /* parrot the ping packet payload back as a pong*/ + n = libwebsocket_write(wsi, (unsigned char *) + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head, LWS_WRITE_PONG); + handled = 1; + break; + + case LWS_WS_OPCODE_07__PONG: + /* keep the statistics... */ + wsi->pings_vs_pongs--; + + /* issue it */ + callback_action = LWS_CALLBACK_CLIENT_RECEIVE_PONG; + break; + + case LWS_WS_OPCODE_07__CONTINUATION: + case LWS_WS_OPCODE_07__TEXT_FRAME: + case LWS_WS_OPCODE_07__BINARY_FRAME: + break; + + default: + + debug("Reserved opcode 0x%2X\n", wsi->opcode); + /* + * It's something special we can't understand here. + * Pass the payload up to the extension's parsing + * state machine. + */ + + eff_buf.token = &wsi->rx_user_buffer[ + LWS_SEND_BUFFER_PRE_PADDING]; + eff_buf.token_len = wsi->rx_user_buffer_head; + + for (n = 0; n < wsi->count_active_extensions; n++) { + m = wsi->active_extensions[n]->callback( + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX, + wsi->active_extensions_user[n], + &eff_buf, 0); + if (m) + handled = 1; + } + + if (!handled) { + fprintf(stderr, "Unhandled extended opcode " + "0x%x - ignoring frame\n", wsi->opcode); + wsi->rx_user_buffer_head = 0; + + return 0; + } + + break; + } + + /* + * No it's real payload, pass it up to the user callback. + * It's nicely buffered with the pre-padding taken care of + * so it can be sent straight out again using libwebsocket_write + */ + + if (!handled && wsi->protocol->callback) + wsi->protocol->callback(wsi->protocol->owning_server, + wsi, callback_action, + wsi->user_space, + &wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING], + wsi->rx_user_buffer_head); + wsi->rx_user_buffer_head = 0; + break; + default: + fprintf(stderr, "client rx illegal state\n"); + return 1; + } + + return 0; + +illegal_ctl_length: + + fprintf(stderr, "Control frame asking for " + "extended length is illegal\n"); + /* kill the connection */ + return -1; + +} + + + +int libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi, + unsigned char *buf, size_t len) +{ + int n; + +#ifdef DEBUG + fprintf(stderr, "received %d byte packet\n", (int)len); + for (n = 0; n < len; n++) + fprintf(stderr, "%02X ", buf[n]); + fprintf(stderr, "\n"); +#endif + + /* let the rx protocol state machine have as much as it needs */ + + n = 0; + while (n < len) + if (libwebsocket_rx_sm(wsi, buf[n++]) < 0) + return -1; + + return 0; +} + + +static int +libwebsocket_0405_frame_mask_generate(struct libwebsocket *wsi) +{ + char buf[4 + 20]; + int n; + + /* fetch the per-frame nonce */ + + n = libwebsockets_get_random(wsi->protocol->owning_server, + wsi->frame_masking_nonce_04, 4); + if (n != 4) { + fprintf(stderr, "Unable to read from random device %s %d\n", + SYSTEM_RANDOM_FILEPATH, n); + return 1; + } + + /* start masking from first byte of masking key buffer */ + wsi->frame_mask_index = 0; + + if (wsi->ietf_spec_revision != 4) + return 0; + + /* 04 only does SHA-1 more complex key */ + + /* + * the frame key is the frame nonce (4 bytes) followed by the + * connection masking key, hashed by SHA1 + */ + + memcpy(buf, wsi->frame_masking_nonce_04, 4); + + memcpy(buf + 4, wsi->masking_key_04, 20); + + /* concatenate the nonce with the connection key then hash it */ + + SHA1((unsigned char *)buf, 4 + 20, wsi->frame_mask_04); + + return 0; +} + +void lws_stderr_hexdump(unsigned char *buf, size_t len) +{ + int n; + int m; + int start; + + fprintf(stderr, "\n"); + + for (n = 0; n < len;) { + start = n; + + fprintf(stderr, "%04X: ", start); + + for (m = 0; m < 16 && n < len; m++) + fprintf(stderr, "%02X ", buf[n++]); + while (m++ < 16) + fprintf(stderr, " "); + + fprintf(stderr, " "); + + for (m = 0; m < 16 && (start + m) < len; m++) { + if (buf[start + m] >= ' ' && buf[start + m] <= 127) + fprintf(stderr, "%c", buf[start + m]); + else + fprintf(stderr, "."); + } + while (m++ < 16) + fprintf(stderr, " "); + + fprintf(stderr, "\n"); + } + fprintf(stderr, "\n"); +} + +int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len) +{ + int n; + int m; + + /* + * one of the extensions is carrying our data itself? Like mux? + */ + + for (n = 0; n < wsi->count_active_extensions; n++) { + /* + * there can only be active extensions after handshake completed + * so we can rely on protocol being set already in here + */ + m = wsi->active_extensions[n]->callback( + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_PACKET_TX_DO_SEND, + wsi->active_extensions_user[n], &buf, len); + if (m < 0) { + fprintf(stderr, "Extension reports fatal error\n"); + return -1; + } + if (m) /* handled */ { +/* fprintf(stderr, "ext sent it\n"); */ + return 0; + } + } + + if (!wsi->sock) + fprintf(stderr, "** error 0 sock but expected to send\n"); + + /* + * nope, send it on the socket directly + */ + +#if 0 + fprintf(stderr, " TX: "); + lws_stderr_hexdump(buf, len); +#endif + +#ifdef LWS_OPENSSL_SUPPORT + if (wsi->ssl) { + n = SSL_write(wsi->ssl, buf, len); + if (n < 0) { + fprintf(stderr, + "ERROR writing to socket\n"); + return -1; + } + } else { +#endif + n = send(wsi->sock, buf, len, MSG_NOSIGNAL); + if (n < 0) { + fprintf(stderr, + "ERROR writing to socket\n"); + return -1; + } +#ifdef LWS_OPENSSL_SUPPORT + } +#endif + return 0; +} + +int +lws_issue_raw_ext_access(struct libwebsocket *wsi, + unsigned char *buf, size_t len) +{ + int ret; + struct lws_tokens eff_buf; + int m; + int n; + + eff_buf.token = (char *)buf; + eff_buf.token_len = len; + + /* + * while we have original buf to spill ourselves, or extensions report + * more in their pipeline + */ + + ret = 1; + while (ret == 1) { + + /* default to nobody has more to spill */ + + ret = 0; + + /* show every extension the new incoming data */ + + for (n = 0; n < wsi->count_active_extensions; n++) { + m = wsi->active_extensions[n]->callback( + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_PACKET_TX_PRESEND, + wsi->active_extensions_user[n], &eff_buf, 0); + if (m < 0) { + fprintf(stderr, "Extension: fatal error\n"); + return -1; + } + if (m) + /* + * at least one extension told us he has more + * to spill, so we will go around again after + */ + ret = 1; + } + + /* assuming they left us something to send, send it */ + + if (eff_buf.token_len) + if (lws_issue_raw(wsi, (unsigned char *)eff_buf.token, + eff_buf.token_len)) + return -1; + + /* we used up what we had */ + + eff_buf.token = NULL; + eff_buf.token_len = 0; + + /* + * Did that leave the pipe choked? + */ + + if (!lws_send_pipe_choked(wsi)) + /* no we could add more */ + continue; + + debug("choked\n"); + + /* + * Yes, he's choked. Don't spill the rest now get a callback + * when he is ready to send and take care of it there + */ + libwebsocket_callback_on_writable( + wsi->protocol->owning_server, wsi); + wsi->extension_data_pending = 1; + ret = 0; + } + + debug("written %d bytes to client\n", eff_buf.token_len); + + return 0; +} + +/** + * libwebsocket_write() - Apply protocol then write data to client + * @wsi: Websocket instance (available from user callback) + * @buf: The data to send. For data being sent on a websocket + * connection (ie, not default http), this buffer MUST have + * LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE the pointer + * and an additional LWS_SEND_BUFFER_POST_PADDING bytes valid + * in the buffer after (buf + len). This is so the protocol + * header and trailer data can be added in-situ. + * @len: Count of the data bytes in the payload starting from buf + * @protocol: Use LWS_WRITE_HTTP to reply to an http connection, and one + * of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate + * data on a websockets connection. Remember to allow the extra + * bytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT + * are used. + * + * This function provides the way to issue data back to the client + * for both http and websocket protocols. + * + * In the case of sending using websocket protocol, be sure to allocate + * valid storage before and after buf as explained above. This scheme + * allows maximum efficiency of sending data and protocol in a single + * packet while not burdening the user code with any protocol knowledge. + */ + +int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, + size_t len, enum libwebsocket_write_protocol protocol) +{ + int n; + int pre = 0; + int post = 0; + int shift = 7; + int masked7 = wsi->mode == LWS_CONNMODE_WS_CLIENT && + wsi->xor_mask != xor_no_mask; + unsigned char *dropmask = NULL; + unsigned char is_masked_bit = 0; + + if (len == 0 && protocol != LWS_WRITE_CLOSE) { + fprintf(stderr, "zero length libwebsocket_write attempt\n"); + return 0; + } + + if (protocol == LWS_WRITE_HTTP) + goto send_raw; + + /* websocket protocol, either binary or text */ + + if (wsi->state != WSI_STATE_ESTABLISHED) + return -1; + + switch (wsi->ietf_spec_revision) { + /* chrome likes this as of 30 Oct 2010 */ + /* Firefox 4.0b6 likes this as of 30 Oct 2010 */ + case 0: + if ((protocol & 0xf) == LWS_WRITE_BINARY) { + /* in binary mode we send 7-bit used length blocks */ + pre = 1; + while (len & (127 << shift)) { + pre++; + shift += 7; + } + n = 0; + shift -= 7; + while (shift >= 0) { + if (shift) + buf[0 - pre + n] = + ((len >> shift) & 127) | 0x80; + else + buf[0 - pre + n] = + ((len >> shift) & 127); + n++; + shift -= 7; + } + break; + } + + /* frame type = text, length-free spam mode */ + + pre = 1; + buf[-pre] = 0; + buf[len] = 0xff; /* EOT marker */ + post = 1; + break; + + case 7: + case 8: + case 13: + if (masked7) { + pre += 4; + dropmask = &buf[0 - pre]; + is_masked_bit = 0x80; + } + /* fallthru */ + case 4: + case 5: + case 6: + switch (protocol & 0xf) { + case LWS_WRITE_TEXT: + if (wsi->ietf_spec_revision < 7) + n = LWS_WS_OPCODE_04__TEXT_FRAME; + else + n = LWS_WS_OPCODE_07__TEXT_FRAME; + break; + case LWS_WRITE_BINARY: + if (wsi->ietf_spec_revision < 7) + n = LWS_WS_OPCODE_04__BINARY_FRAME; + else + n = LWS_WS_OPCODE_07__BINARY_FRAME; + break; + case LWS_WRITE_CONTINUATION: + if (wsi->ietf_spec_revision < 7) + n = LWS_WS_OPCODE_04__CONTINUATION; + else + n = LWS_WS_OPCODE_07__CONTINUATION; + break; + + case LWS_WRITE_CLOSE: + if (wsi->ietf_spec_revision < 7) + n = LWS_WS_OPCODE_04__CLOSE; + else + n = LWS_WS_OPCODE_07__CLOSE; + + /* + * v5 mandates the first byte of close packet + * in both client and server directions + */ + + switch (wsi->ietf_spec_revision) { + case 0: + case 4: + break; + case 5: + /* we can do this because we demand post-buf */ + + if (len < 1) + len = 1; + + switch (wsi->mode) { + case LWS_CONNMODE_WS_SERVING: + /* + fprintf(stderr, "LWS_WRITE_CLOSE S\n"); + */ + buf[0] = 'S'; + break; + case LWS_CONNMODE_WS_CLIENT: + /* + fprintf(stderr, "LWS_WRITE_CLOSE C\n"); + */ + buf[0] = 'C'; + break; + default: + break; + } + break; + default: + /* + * 06 has a 2-byte status code in network order + * we can do this because we demand post-buf + */ + + if (wsi->close_reason) { + /* reason codes count as data bytes */ + buf -= 2; + buf[0] = wsi->close_reason >> 8; + buf[1] = wsi->close_reason; + len += 2; + } + break; + } + break; + case LWS_WRITE_PING: + if (wsi->ietf_spec_revision < 7) + n = LWS_WS_OPCODE_04__PING; + else + n = LWS_WS_OPCODE_07__PING; + + wsi->pings_vs_pongs++; + break; + case LWS_WRITE_PONG: + if (wsi->ietf_spec_revision < 7) + n = LWS_WS_OPCODE_04__PONG; + else + n = LWS_WS_OPCODE_07__PONG; + break; + default: + fprintf(stderr, "libwebsocket_write: unknown write " + "opcode / protocol\n"); + return -1; + } + + if (!(protocol & LWS_WRITE_NO_FIN)) + n |= 1 << 7; + + if (len < 126) { + pre += 2; + buf[-pre] = n; + buf[-pre + 1] = len | is_masked_bit; + } else { + if (len < 65536) { + pre += 4; + buf[-pre] = n; + buf[-pre + 1] = 126 | is_masked_bit; + buf[-pre + 2] = len >> 8; + buf[-pre + 3] = len; + } else { + pre += 10; + buf[-pre] = n; + buf[-pre + 1] = 127 | is_masked_bit; +#if defined __LP64__ + buf[-pre + 2] = (len >> 56) & 0x7f; + buf[-pre + 3] = len >> 48; + buf[-pre + 4] = len >> 40; + buf[-pre + 5] = len >> 32; +#else + buf[-pre + 2] = 0; + buf[-pre + 3] = 0; + buf[-pre + 4] = 0; + buf[-pre + 5] = 0; +#endif + buf[-pre + 6] = len >> 24; + buf[-pre + 7] = len >> 16; + buf[-pre + 8] = len >> 8; + buf[-pre + 9] = len; + } + } + break; + } + + /* + * Deal with masking if we are in client -> server direction and + * the protocol demands it + */ + + if (wsi->mode == LWS_CONNMODE_WS_CLIENT && + wsi->ietf_spec_revision >= 4) { + + /* + * this is only useful for security tests where it's required + * to control the raw packet payload content + */ + + if (!(protocol & LWS_WRITE_CLIENT_IGNORE_XOR_MASK) && + wsi->xor_mask != xor_no_mask) { + + if (libwebsocket_0405_frame_mask_generate(wsi)) { + fprintf(stderr, "libwebsocket_write: " + "frame mask generation failed\n"); + return 1; + } + + + if (wsi->ietf_spec_revision < 7) + /* + * use the XOR masking against everything we + * send past the frame key + */ + for (n = -pre; n < ((int)len + post); n++) + buf[n] = wsi->xor_mask(wsi, buf[n]); + else + /* + * in v7, just mask the payload + */ + for (n = 0; n < (int)len; n++) + dropmask[n + 4] = + wsi->xor_mask(wsi, dropmask[n + 4]); + + + if (wsi->ietf_spec_revision < 7) { + /* make space for the frame nonce in clear */ + pre += 4; + + dropmask = &buf[0 - pre]; + } + + if (dropmask) + /* copy the frame nonce into place */ + memcpy(dropmask, + wsi->frame_masking_nonce_04, 4); + + } else { + if (wsi->ietf_spec_revision < 7) { + + /* make space for the frame nonce in clear */ + pre += 4; + + buf[0 - pre] = 0; + buf[1 - pre] = 0; + buf[2 - pre] = 0; + buf[3 - pre] = 0; + } else { + if (dropmask && wsi->xor_mask != xor_no_mask) { + dropmask[0] = 0; + dropmask[1] = 0; + dropmask[2] = 0; + dropmask[3] = 0; + } + } + } + + } + +send_raw: + +#if 0 + fprintf(stderr, "send %ld: ", len + post); + for (n = -pre; n < ((int)len + post); n++) + fprintf(stderr, "%02X ", buf[n]); + + fprintf(stderr, "\n"); +#endif + + if (protocol == LWS_WRITE_HTTP) { + if (lws_issue_raw(wsi, (unsigned char *)buf - pre, + len + pre + post)) + return -1; + + return 0; + } + + /* + * give any active extensions a chance to munge the buffer + * before send. We pass in a pointer to an lws_tokens struct + * prepared with the default buffer and content length that's in + * there. Rather than rewrite the default buffer, extensions + * that expect to grow the buffer can adapt .token to + * point to their own per-connection buffer in the extension + * user allocation. By default with no extensions or no + * extension callback handling, just the normal input buffer is + * used then so it is efficient. + * + * callback returns 1 in case it wants to spill more buffers + */ + + return lws_issue_raw_ext_access(wsi, buf - pre, len + pre + post); +} + + +/** + * libwebsockets_serve_http_file() - Send a file back to the client using http + * @wsi: Websocket instance (available from user callback) + * @file: The file to issue over http + * @content_type: The http content type, eg, text/html + * + * This function is intended to be called from the callback in response + * to http requests from the client. It allows the callback to issue + * local files down the http link in a single step. + */ + +int libwebsockets_serve_http_file(struct libwebsocket *wsi, const char *file, + const char *content_type) +{ + int fd; + struct stat stat_buf; + char buf[512]; + char *p = buf; + int n; + +#ifdef WIN32 + fd = open(file, O_RDONLY | _O_BINARY); +#else + fd = open(file, O_RDONLY); +#endif + if (fd < 1) { + p += sprintf(p, "HTTP/1.0 400 Bad\x0d\x0a" + "Server: libwebsockets\x0d\x0a" + "\x0d\x0a" + ); + libwebsocket_write(wsi, (unsigned char *)buf, p - buf, + LWS_WRITE_HTTP); + + return -1; + } + + fstat(fd, &stat_buf); + p += sprintf(p, "HTTP/1.0 200 OK\x0d\x0a" + "Server: libwebsockets\x0d\x0a" + "Content-Type: %s\x0d\x0a" + "Content-Length: %u\x0d\x0a" + "\x0d\x0a", content_type, + (unsigned int)stat_buf.st_size); + + libwebsocket_write(wsi, (unsigned char *)buf, p - buf, LWS_WRITE_HTTP); + + n = 1; + while (n > 0) { + n = read(fd, buf, 512); + if (n <= 0) + continue; + libwebsocket_write(wsi, (unsigned char *)buf, n, + LWS_WRITE_HTTP); + } + + close(fd); + + return 0; +} + + +/** + * libwebsockets_remaining_packet_payload() - Bytes to come before "overall" + * rx packet is complete + * @wsi: Websocket instance (available from user callback) + * + * This function is intended to be called from the callback if the + * user code is interested in "complete packets" from the client. + * libwebsockets just passes through payload as it comes and issues a buffer + * additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE + * callback handler can use this API to find out if the buffer it has just + * been given is the last piece of a "complete packet" from the client -- + * when that is the case libwebsockets_remaining_packet_payload() will return + * 0. + * + * Many protocols won't care becuse their packets are always small. + */ + +size_t +libwebsockets_remaining_packet_payload(struct libwebsocket *wsi) +{ + return wsi->rx_packet_length; +} diff --git a/libs/libwebsockets/lib/private-libwebsockets.h b/libs/libwebsockets/lib/private-libwebsockets.h new file mode 100644 index 0000000000..3c9776fd86 --- /dev/null +++ b/libs/libwebsockets/lib/private-libwebsockets.h @@ -0,0 +1,445 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __MINGW64__ +#else +#ifdef __MINGW32__ +#else +#include +#endif +#endif +#include + +#include + +#ifdef WIN32 +#ifdef __MINGW64__ +#else +#ifdef __MINGW32__ +#else +#include +#endif +#endif +#include +#include +#include + +#else + +#include +#include +#ifndef LWS_NO_FORK +#ifdef HAVE_SYS_PRCTL_H +#include +#endif +#endif +#include +#include +#include + +#include +#include +#include + +#endif + +#ifdef LWS_OPENSSL_SUPPORT +#include +#include +#include +#include +#include +#endif + + +#include "libwebsockets.h" + +#if 0 +#define DEBUG +#endif + +#ifdef DEBUG +#ifdef WIN32 +static +#else +static inline +#endif +void debug(const char *format, ...) +{ + va_list ap; + va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); +} +#else +#ifdef WIN32 +static +#else +static inline +#endif +void debug(const char *format, ...) +{ +} +#endif + + +/* + * Mac OSX as well as iOS do not define the MSG_NOSIGNAL flag, + * but happily have something equivalent in the SO_NOSIGPIPE flag. + */ +#ifdef __APPLE__ +#define MSG_NOSIGNAL SO_NOSIGPIPE +#endif + + +#define FD_HASHTABLE_MODULUS 32 +#define MAX_CLIENTS 100 +#define LWS_MAX_HEADER_NAME_LENGTH 64 +#define LWS_MAX_HEADER_LEN 4096 +#define LWS_INITIAL_HDR_ALLOC 256 +#define LWS_ADDITIONAL_HDR_ALLOC 64 +#define MAX_USER_RX_BUFFER 4096 +#define MAX_BROADCAST_PAYLOAD 2048 +#define LWS_MAX_PROTOCOLS 10 +#define LWS_MAX_EXTENSIONS_ACTIVE 10 +#define SPEC_LATEST_SUPPORTED 13 + +#define MAX_WEBSOCKET_04_KEY_LEN 128 +#define SYSTEM_RANDOM_FILEPATH "/dev/urandom" + +enum lws_websocket_opcodes_04 { + LWS_WS_OPCODE_04__CONTINUATION = 0, + LWS_WS_OPCODE_04__CLOSE = 1, + LWS_WS_OPCODE_04__PING = 2, + LWS_WS_OPCODE_04__PONG = 3, + LWS_WS_OPCODE_04__TEXT_FRAME = 4, + LWS_WS_OPCODE_04__BINARY_FRAME = 5, + + LWS_WS_OPCODE_04__RESERVED_6 = 6, + LWS_WS_OPCODE_04__RESERVED_7 = 7, + LWS_WS_OPCODE_04__RESERVED_8 = 8, + LWS_WS_OPCODE_04__RESERVED_9 = 9, + LWS_WS_OPCODE_04__RESERVED_A = 0xa, + LWS_WS_OPCODE_04__RESERVED_B = 0xb, + LWS_WS_OPCODE_04__RESERVED_C = 0xc, + LWS_WS_OPCODE_04__RESERVED_D = 0xd, + LWS_WS_OPCODE_04__RESERVED_E = 0xe, + LWS_WS_OPCODE_04__RESERVED_F = 0xf, +}; + +enum lws_websocket_opcodes_07 { + LWS_WS_OPCODE_07__CONTINUATION = 0, + LWS_WS_OPCODE_07__TEXT_FRAME = 1, + LWS_WS_OPCODE_07__BINARY_FRAME = 2, + + LWS_WS_OPCODE_07__NOSPEC__MUX = 7, + + /* control extensions 8+ */ + + LWS_WS_OPCODE_07__CLOSE = 8, + LWS_WS_OPCODE_07__PING = 9, + LWS_WS_OPCODE_07__PONG = 0xa, +}; + + +enum lws_connection_states { + WSI_STATE_HTTP, + WSI_STATE_HTTP_HEADERS, + WSI_STATE_DEAD_SOCKET, + WSI_STATE_ESTABLISHED, + WSI_STATE_CLIENT_UNCONNECTED, + WSI_STATE_RETURNED_CLOSE_ALREADY, + WSI_STATE_AWAITING_CLOSE_ACK, +}; + +enum lws_rx_parse_state { + LWS_RXPS_NEW, + + LWS_RXPS_SEEN_76_FF, + LWS_RXPS_PULLING_76_LENGTH, + LWS_RXPS_EAT_UNTIL_76_FF, + + LWS_RXPS_04_MASK_NONCE_1, + LWS_RXPS_04_MASK_NONCE_2, + LWS_RXPS_04_MASK_NONCE_3, + + LWS_RXPS_04_FRAME_HDR_1, + LWS_RXPS_04_FRAME_HDR_LEN, + LWS_RXPS_04_FRAME_HDR_LEN16_2, + LWS_RXPS_04_FRAME_HDR_LEN16_1, + LWS_RXPS_04_FRAME_HDR_LEN64_8, + LWS_RXPS_04_FRAME_HDR_LEN64_7, + LWS_RXPS_04_FRAME_HDR_LEN64_6, + LWS_RXPS_04_FRAME_HDR_LEN64_5, + LWS_RXPS_04_FRAME_HDR_LEN64_4, + LWS_RXPS_04_FRAME_HDR_LEN64_3, + LWS_RXPS_04_FRAME_HDR_LEN64_2, + LWS_RXPS_04_FRAME_HDR_LEN64_1, + + LWS_RXPS_07_COLLECT_FRAME_KEY_1, + LWS_RXPS_07_COLLECT_FRAME_KEY_2, + LWS_RXPS_07_COLLECT_FRAME_KEY_3, + LWS_RXPS_07_COLLECT_FRAME_KEY_4, + + LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED +}; + + +enum connection_mode { + LWS_CONNMODE_WS_SERVING, + LWS_CONNMODE_WS_CLIENT, + + /* transient modes */ + LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY, + LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE, + LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY, + LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT, + LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD, + + /* special internal types */ + LWS_CONNMODE_SERVER_LISTENER, + LWS_CONNMODE_BROADCAST_PROXY_LISTENER, + LWS_CONNMODE_BROADCAST_PROXY +}; + + +#define LWS_FD_HASH(fd) ((fd ^ (fd >> 8) ^ (fd >> 16)) % FD_HASHTABLE_MODULUS) + +struct libwebsocket_fd_hashtable { + struct libwebsocket *wsi[MAX_CLIENTS + 1]; + int length; +}; + +struct libwebsocket_protocols; + +struct libwebsocket_context { + struct libwebsocket_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS]; + struct pollfd fds[MAX_CLIENTS * FD_HASHTABLE_MODULUS + 1]; + int fds_count; + int listen_port; + char http_proxy_address[256]; + char canonical_hostname[1024]; + unsigned int http_proxy_port; + unsigned int options; + unsigned long last_timeout_check_s; + + int fd_random; + +#ifdef LWS_OPENSSL_SUPPORT + int use_ssl; + SSL_CTX *ssl_ctx; + SSL_CTX *ssl_client_ctx; +#endif + struct libwebsocket_protocols *protocols; + int count_protocols; + struct libwebsocket_extension *extensions; +}; + + +enum pending_timeout { + NO_PENDING_TIMEOUT = 0, + PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE, + PENDING_TIMEOUT_ESTABLISH_WITH_SERVER, + PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE, + PENDING_TIMEOUT_AWAITING_PING, + PENDING_TIMEOUT_CLOSE_ACK, + PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE, +}; + + +/* + * This is totally opaque to code using the library. It's exported as a + * forward-reference pointer-only declaration; the user can use the pointer with + * other APIs to get information out of it. + */ + +struct libwebsocket { + const struct libwebsocket_protocols *protocol; + struct libwebsocket_extension * + active_extensions[LWS_MAX_EXTENSIONS_ACTIVE]; + void *active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE]; + int count_active_extensions; + + enum lws_connection_states state; + + char name_buffer[LWS_MAX_HEADER_NAME_LENGTH]; + int name_buffer_pos; + int current_alloc_len; + enum lws_token_indexes parser_state; + struct lws_tokens utf8_token[WSI_TOKEN_COUNT]; + int ietf_spec_revision; + char rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING + MAX_USER_RX_BUFFER + + LWS_SEND_BUFFER_POST_PADDING]; + int rx_user_buffer_head; + enum libwebsocket_write_protocol rx_frame_type; + int protocol_index_for_broadcast_proxy; + enum pending_timeout pending_timeout; + unsigned long pending_timeout_limit; + + int sock; + + enum lws_rx_parse_state lws_rx_parse_state; + char extension_data_pending; + struct libwebsocket *candidate_children_list; + struct libwebsocket *extension_handles; + + /* 04 protocol specific */ + + char key_b64[150]; + unsigned char masking_key_04[20]; + unsigned char frame_masking_nonce_04[4]; + unsigned char frame_mask_04[20]; + unsigned char frame_mask_index; + size_t rx_packet_length; + unsigned char opcode; + unsigned char final; + + int pings_vs_pongs; + unsigned char (*xor_mask)(struct libwebsocket *, unsigned char); + char all_zero_nonce; + + enum lws_close_status close_reason; + + /* 07 specific */ + char this_frame_masked; + + /* client support */ + char initial_handshake_hash_base64[30]; + enum connection_mode mode; + char *c_path; + char *c_host; + char *c_origin; + char *c_protocol; + callback_function *c_callback; + + char *c_address; + int c_port; + + +#ifdef LWS_OPENSSL_SUPPORT + SSL *ssl; + BIO *client_bio; + int use_ssl; +#endif + + void *user_space; +}; + +extern int +libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c); + +extern int +libwebsocket_parse(struct libwebsocket *wsi, unsigned char c); + +extern int +libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi, + unsigned char *buf, size_t len); + +extern int +libwebsocket_read(struct libwebsocket_context *context, + struct libwebsocket *wsi, + unsigned char *buf, size_t len); + +extern int +lws_b64_selftest(void); + +extern unsigned char +xor_no_mask(struct libwebsocket *wsi, unsigned char c); + +extern unsigned char +xor_mask_04(struct libwebsocket *wsi, unsigned char c); + +extern unsigned char +xor_mask_05(struct libwebsocket *wsi, unsigned char c); + +extern struct libwebsocket * +wsi_from_fd(struct libwebsocket_context *context, int fd); + +extern int +insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi); + +extern int +delete_from_fd(struct libwebsocket_context *context, int fd); + +extern void +libwebsocket_set_timeout(struct libwebsocket *wsi, + enum pending_timeout reason, int secs); + +extern int +lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len); + + +extern void +libwebsocket_service_timeout_check(struct libwebsocket_context *context, + struct libwebsocket *wsi, unsigned int sec); + +extern struct libwebsocket * +__libwebsocket_client_connect_2(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +extern struct libwebsocket * +libwebsocket_create_new_server_wsi(struct libwebsocket_context *context); + +extern char * +libwebsockets_generate_client_handshake(struct libwebsocket_context *context, + struct libwebsocket *wsi, char *pkt); + +extern int +lws_handle_POLLOUT_event(struct libwebsocket_context *context, + struct libwebsocket *wsi, struct pollfd *pollfd); + +extern int +lws_any_extension_handled(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons r, + void *v, size_t len); + +extern void * +lws_get_extension_user_matching_ext(struct libwebsocket *wsi, + struct libwebsocket_extension *ext); + +extern int +lws_client_interpret_server_handshake(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +extern int +libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c); + +extern int +lws_issue_raw_ext_access(struct libwebsocket *wsi, + unsigned char *buf, size_t len); + +#ifndef LWS_OPENSSL_SUPPORT + +unsigned char * +SHA1(const unsigned char *d, size_t n, unsigned char *md); + +void +MD5(const unsigned char *input, int ilen, unsigned char *output); + +#endif diff --git a/libs/libwebsockets/lib/sha-1.c b/libs/libwebsockets/lib/sha-1.c new file mode 100644 index 0000000000..f30f3ed63b --- /dev/null +++ b/libs/libwebsockets/lib/sha-1.c @@ -0,0 +1,326 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE 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. Neither the name of the project 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 PROJECT 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 PROJECT 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. + */ +/* + * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) + * based on: http://csrc.nist.gov/fips/fip180-1.txt + * implemented by Jun-ichiro itojun Itoh + */ + +#include +#ifdef WIN32 + +#ifndef BIG_ENDIAN +#define BIG_ENDIAN 4321 /* to show byte order (taken from gcc) */ +#endif +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN 1234 +#endif +#ifndef BYTE_ORDER +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +typedef unsigned __int64 u_int64_t; + +#undef __P +#ifndef __P +#if __STDC__ +#define __P(protos) protos +#else +#define __P(protos) () +#endif +#endif + +#define bzero(b, len) (memset((b), '\0', (len)), (void) 0) + +#else +#include +#include +#include +#endif + +#include + +struct sha1_ctxt { + union { + unsigned char b8[20]; + unsigned int b32[5]; + } h; + union { + unsigned char b8[8]; + u_int64_t b64[1]; + } c; + union { + unsigned char b8[64]; + unsigned int b32[16]; + } m; + unsigned char count; +}; + +/* sanity check */ +#if BYTE_ORDER != BIG_ENDIAN +# if BYTE_ORDER != LITTLE_ENDIAN +# define unsupported 1 +# endif +#endif + +#ifndef unsupported + +/* constant table */ +static unsigned int _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 }; +#define K(t) _K[(t) / 20] + +#define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d))) +#define F1(b, c, d) (((b) ^ (c)) ^ (d)) +#define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) +#define F3(b, c, d) (((b) ^ (c)) ^ (d)) + +#define S(n, x) (((x) << (n)) | ((x) >> (32 - n))) + +#define H(n) (ctxt->h.b32[(n)]) +#define COUNT (ctxt->count) +#define BCOUNT (ctxt->c.b64[0] / 8) +#define W(n) (ctxt->m.b32[(n)]) + +#define PUTBYTE(x) { \ + ctxt->m.b8[(COUNT % 64)] = (x); \ + COUNT++; \ + COUNT %= 64; \ + ctxt->c.b64[0] += 8; \ + if (COUNT % 64 == 0) \ + sha1_step(ctxt); \ + } + +#define PUTPAD(x) { \ + ctxt->m.b8[(COUNT % 64)] = (x); \ + COUNT++; \ + COUNT %= 64; \ + if (COUNT % 64 == 0) \ + sha1_step(ctxt); \ + } + +static void sha1_step __P((struct sha1_ctxt *)); + +static void +sha1_step(struct sha1_ctxt *ctxt) +{ + unsigned int a, b, c, d, e, tmp; + size_t t, s; + +#if BYTE_ORDER == LITTLE_ENDIAN + struct sha1_ctxt tctxt; + + memcpy(&tctxt.m.b8[0], &ctxt->m.b8[0], 64); + ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2]; + ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[3] = tctxt.m.b8[0]; + ctxt->m.b8[4] = tctxt.m.b8[7]; ctxt->m.b8[5] = tctxt.m.b8[6]; + ctxt->m.b8[6] = tctxt.m.b8[5]; ctxt->m.b8[7] = tctxt.m.b8[4]; + ctxt->m.b8[8] = tctxt.m.b8[11]; ctxt->m.b8[9] = tctxt.m.b8[10]; + ctxt->m.b8[10] = tctxt.m.b8[9]; ctxt->m.b8[11] = tctxt.m.b8[8]; + ctxt->m.b8[12] = tctxt.m.b8[15]; ctxt->m.b8[13] = tctxt.m.b8[14]; + ctxt->m.b8[14] = tctxt.m.b8[13]; ctxt->m.b8[15] = tctxt.m.b8[12]; + ctxt->m.b8[16] = tctxt.m.b8[19]; ctxt->m.b8[17] = tctxt.m.b8[18]; + ctxt->m.b8[18] = tctxt.m.b8[17]; ctxt->m.b8[19] = tctxt.m.b8[16]; + ctxt->m.b8[20] = tctxt.m.b8[23]; ctxt->m.b8[21] = tctxt.m.b8[22]; + ctxt->m.b8[22] = tctxt.m.b8[21]; ctxt->m.b8[23] = tctxt.m.b8[20]; + ctxt->m.b8[24] = tctxt.m.b8[27]; ctxt->m.b8[25] = tctxt.m.b8[26]; + ctxt->m.b8[26] = tctxt.m.b8[25]; ctxt->m.b8[27] = tctxt.m.b8[24]; + ctxt->m.b8[28] = tctxt.m.b8[31]; ctxt->m.b8[29] = tctxt.m.b8[30]; + ctxt->m.b8[30] = tctxt.m.b8[29]; ctxt->m.b8[31] = tctxt.m.b8[28]; + ctxt->m.b8[32] = tctxt.m.b8[35]; ctxt->m.b8[33] = tctxt.m.b8[34]; + ctxt->m.b8[34] = tctxt.m.b8[33]; ctxt->m.b8[35] = tctxt.m.b8[32]; + ctxt->m.b8[36] = tctxt.m.b8[39]; ctxt->m.b8[37] = tctxt.m.b8[38]; + ctxt->m.b8[38] = tctxt.m.b8[37]; ctxt->m.b8[39] = tctxt.m.b8[36]; + ctxt->m.b8[40] = tctxt.m.b8[43]; ctxt->m.b8[41] = tctxt.m.b8[42]; + ctxt->m.b8[42] = tctxt.m.b8[41]; ctxt->m.b8[43] = tctxt.m.b8[40]; + ctxt->m.b8[44] = tctxt.m.b8[47]; ctxt->m.b8[45] = tctxt.m.b8[46]; + ctxt->m.b8[46] = tctxt.m.b8[45]; ctxt->m.b8[47] = tctxt.m.b8[44]; + ctxt->m.b8[48] = tctxt.m.b8[51]; ctxt->m.b8[49] = tctxt.m.b8[50]; + ctxt->m.b8[50] = tctxt.m.b8[49]; ctxt->m.b8[51] = tctxt.m.b8[48]; + ctxt->m.b8[52] = tctxt.m.b8[55]; ctxt->m.b8[53] = tctxt.m.b8[54]; + ctxt->m.b8[54] = tctxt.m.b8[53]; ctxt->m.b8[55] = tctxt.m.b8[52]; + ctxt->m.b8[56] = tctxt.m.b8[59]; ctxt->m.b8[57] = tctxt.m.b8[58]; + ctxt->m.b8[58] = tctxt.m.b8[57]; ctxt->m.b8[59] = tctxt.m.b8[56]; + ctxt->m.b8[60] = tctxt.m.b8[63]; ctxt->m.b8[61] = tctxt.m.b8[62]; + ctxt->m.b8[62] = tctxt.m.b8[61]; ctxt->m.b8[63] = tctxt.m.b8[60]; +#endif + + a = H(0); b = H(1); c = H(2); d = H(3); e = H(4); + + for (t = 0; t < 20; t++) { + s = t & 0x0f; + if (t >= 16) + W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ + W((s+2) & 0x0f) ^ W(s)); + + tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t); + e = d; d = c; c = S(30, b); b = a; a = tmp; + } + for (t = 20; t < 40; t++) { + s = t & 0x0f; + W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ + W((s+2) & 0x0f) ^ W(s)); + tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t); + e = d; d = c; c = S(30, b); b = a; a = tmp; + } + for (t = 40; t < 60; t++) { + s = t & 0x0f; + W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ + W((s+2) & 0x0f) ^ W(s)); + tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t); + e = d; d = c; c = S(30, b); b = a; a = tmp; + } + for (t = 60; t < 80; t++) { + s = t & 0x0f; + W(s) = S(1, W((s+13) & 0x0f) ^ W((s+8) & 0x0f) ^ + W((s+2) & 0x0f) ^ W(s)); + tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t); + e = d; d = c; c = S(30, b); b = a; a = tmp; + } + + H(0) = H(0) + a; + H(1) = H(1) + b; + H(2) = H(2) + c; + H(3) = H(3) + d; + H(4) = H(4) + e; + + bzero(&ctxt->m.b8[0], 64); +} + +/*------------------------------------------------------------*/ + +void +sha1_init(struct sha1_ctxt *ctxt) +{ + bzero(ctxt, sizeof(struct sha1_ctxt)); + H(0) = 0x67452301; + H(1) = 0xefcdab89; + H(2) = 0x98badcfe; + H(3) = 0x10325476; + H(4) = 0xc3d2e1f0; +} + +void +sha1_pad(struct sha1_ctxt *ctxt) +{ + size_t padlen; /*pad length in bytes*/ + size_t padstart; + + PUTPAD(0x80); + + padstart = COUNT % 64; + padlen = 64 - padstart; + if (padlen < 8) { + bzero(&ctxt->m.b8[padstart], padlen); + COUNT += padlen; + COUNT %= 64; + sha1_step(ctxt); + padstart = COUNT % 64; /* should be 0 */ + padlen = 64 - padstart; /* should be 64 */ + } + bzero(&ctxt->m.b8[padstart], padlen - 8); + COUNT += (padlen - 8); + COUNT %= 64; +#if BYTE_ORDER == BIG_ENDIAN + PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]); + PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]); + PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]); + PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]); +#else + PUTPAD(ctxt->c.b8[7]); PUTPAD(ctxt->c.b8[6]); + PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[4]); + PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[2]); + PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[0]); +#endif +} + +void +sha1_loop(struct sha1_ctxt *ctxt, const unsigned char *input, size_t len) +{ + size_t gaplen; + size_t gapstart; + size_t off; + size_t copysiz; + + off = 0; + + while (off < len) { + gapstart = COUNT % 64; + gaplen = 64 - gapstart; + + copysiz = (gaplen < len - off) ? gaplen : len - off; + memcpy(&ctxt->m.b8[gapstart], &input[off], copysiz); + COUNT += copysiz; + COUNT %= 64; + ctxt->c.b64[0] += copysiz * 8; + if (COUNT % 64 == 0) + sha1_step(ctxt); + off += copysiz; + } +} + +void +sha1_result(struct sha1_ctxt *ctxt, void *digest0) +{ + unsigned char *digest; + + digest = (unsigned char *)digest0; + sha1_pad(ctxt); +#if BYTE_ORDER == BIG_ENDIAN + memcpy(digest, &ctxt->h.b8[0], 20); +#else + digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2]; + digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0]; + digest[4] = ctxt->h.b8[7]; digest[5] = ctxt->h.b8[6]; + digest[6] = ctxt->h.b8[5]; digest[7] = ctxt->h.b8[4]; + digest[8] = ctxt->h.b8[11]; digest[9] = ctxt->h.b8[10]; + digest[10] = ctxt->h.b8[9]; digest[11] = ctxt->h.b8[8]; + digest[12] = ctxt->h.b8[15]; digest[13] = ctxt->h.b8[14]; + digest[14] = ctxt->h.b8[13]; digest[15] = ctxt->h.b8[12]; + digest[16] = ctxt->h.b8[19]; digest[17] = ctxt->h.b8[18]; + digest[18] = ctxt->h.b8[17]; digest[19] = ctxt->h.b8[16]; +#endif +} + +/* + * This should look and work like the libcrypto implementation + */ + +unsigned char * +SHA1(const unsigned char *d, size_t n, unsigned char *md) +{ + struct sha1_ctxt ctx; + + sha1_init(&ctx); + sha1_loop(&ctx, d, n); + sha1_result(&ctx, (void *)md); + + return md; +} + +#endif /*unsupported*/ diff --git a/libs/libwebsockets/libwebsockets-api-doc.html b/libs/libwebsockets/libwebsockets-api-doc.html new file mode 100644 index 0000000000..18b1620e50 --- /dev/null +++ b/libs/libwebsockets/libwebsockets-api-doc.html @@ -0,0 +1,933 @@ +

libwebsockets_hangup_on_client - Server calls to terminate client connection

+void +libwebsockets_hangup_on_client +(struct libwebsocket_context * context, +int fd) +

Arguments

+
+
context +
libwebsockets context +
fd +
Connection socket descriptor +
+
+

libwebsockets_get_peer_addresses - Get client address information

+void +libwebsockets_get_peer_addresses +(int fd, +char * name, +int name_len, +char * rip, +int rip_len) +

Arguments

+
+
fd +
Connection socket descriptor +
name +
Buffer to take client address name +
name_len +
Length of client address name buffer +
rip +
Buffer to take client address IP qotted quad +
rip_len +
Length of client address IP buffer +
+

Description

+
+This function fills in name and rip with the name and IP of +the client connected with socket descriptor fd. Names may be +truncated if there is not enough room. If either cannot be +determined, they will be returned as valid zero-length strings. +
+
+

libwebsocket_service_fd - Service polled socket with something waiting

+int +libwebsocket_service_fd +(struct libwebsocket_context * context, +struct pollfd * pollfd) +

Arguments

+
+
context +
Websocket context +
pollfd +
The pollfd entry describing the socket fd and which events +happened. +
+

Description

+
+This function closes any active connections and then frees the +context. After calling this, any further use of the context is +undefined. +
+
+

libwebsocket_context_destroy - Destroy the websocket context

+void +libwebsocket_context_destroy +(struct libwebsocket_context * context) +

Arguments

+
+
context +
Websocket context +
+

Description

+
+This function closes any active connections and then frees the +context. After calling this, any further use of the context is +undefined. +
+
+

libwebsocket_service - Service any pending websocket activity

+int +libwebsocket_service +(struct libwebsocket_context * context, +int timeout_ms) +

Arguments

+
+
context +
Websocket context +
timeout_ms +
Timeout for poll; 0 means return immediately if nothing needed +service otherwise block and service immediately, returning +after the timeout if nothing needed service. +
+

Description

+
+This function deals with any pending websocket traffic, for three +kinds of event. It handles these events on both server and client +types of connection the same. +

+1) Accept new connections to our context's server +

+2) Perform pending broadcast writes initiated from other forked +processes (effectively serializing asynchronous broadcasts) +

+3) Call the receive callback for incoming frame data received by +server or client connections. +

+You need to call this service function periodically to all the above +functions to happen; if your application is single-threaded you can +just call it in your main event loop. +

+Alternatively you can fork a new process that asynchronously handles +calling this service in a loop. In that case you are happy if this +call blocks your thread until it needs to take care of something and +would call it with a large nonzero timeout. Your loop then takes no +CPU while there is nothing happening. +

+If you are calling it in a single-threaded app, you don't want it to +wait around blocking other things in your loop from happening, so you +would call it with a timeout_ms of 0, so it returns immediately if +nothing is pending, or as soon as it services whatever was pending. +

+
+

libwebsocket_callback_on_writable - Request a callback when this socket becomes able to be written to without blocking

+int +libwebsocket_callback_on_writable +(struct libwebsocket_context * context, +struct libwebsocket * wsi) +

Arguments

+
+
context +
libwebsockets context +
wsi +
Websocket connection instance to get callback for +
+
+

libwebsocket_callback_on_writable_all_protocol - Request a callback for all connections using the given protocol when it becomes possible to write to each socket without blocking in turn.

+int +libwebsocket_callback_on_writable_all_protocol +(const struct libwebsocket_protocols * protocol) +

Arguments

+
+
protocol +
Protocol whose connections will get callbacks +
+
+

libwebsocket_set_timeout - marks the wsi as subject to a timeout

+void +libwebsocket_set_timeout +(struct libwebsocket * wsi, +enum pending_timeout reason, +int secs) +

Arguments

+
+
wsi +
Websocket connection instance +
reason +
timeout reason +
secs +
how many seconds +
+

Description

+
+

+You will not need this unless you are doing something special +

+
+

libwebsocket_get_socket_fd - returns the socket file descriptor

+int +libwebsocket_get_socket_fd +(struct libwebsocket * wsi) +

Arguments

+
+
wsi +
Websocket connection instance +
+

Description

+
+

+You will not need this unless you are doing something special +

+
+

libwebsocket_rx_flow_control - Enable and disable socket servicing for receieved packets.

+int +libwebsocket_rx_flow_control +(struct libwebsocket * wsi, +int enable) +

Arguments

+
+
wsi +
Websocket connection instance to get callback for +
enable +
0 = disable read servicing for this connection, 1 = enable +
+

Description

+
+

+If the output side of a server process becomes choked, this allows flow +control for the input side. +

+
+

libwebsocket_canonical_hostname - returns this host's hostname

+const char * +libwebsocket_canonical_hostname +(struct libwebsocket_context * context) +

Arguments

+
+
context +
Websocket context +
+

Description

+
+

+This is typically used by client code to fill in the host parameter +when making a client connection. You can only call it after the context +has been created. +

+
+

libwebsocket_create_context - Create the websocket handler

+struct libwebsocket_context * +libwebsocket_create_context +(int port, +const char * interf, +struct libwebsocket_protocols * protocols, +struct libwebsocket_extension * extensions, +const char * ssl_cert_filepath, +const char * ssl_private_key_filepath, +int gid, +int uid, +unsigned int options) +

Arguments

+
+
port +
Port to listen on... you can use 0 to suppress listening on +any port, that's what you want if you are not running a +websocket server at all but just using it as a client +
interf +
NULL to bind the listen socket to all interfaces, or the +interface name, eg, "eth2" +
protocols +
Array of structures listing supported protocols and a protocol- +specific callback for each one. The list is ended with an +entry that has a NULL callback pointer. +It's not const because we write the owning_server member +
extensions +
NULL or array of libwebsocket_extension structs listing the +extensions this context supports +
ssl_cert_filepath +
If libwebsockets was compiled to use ssl, and you want +to listen using SSL, set to the filepath to fetch the +server cert from, otherwise NULL for unencrypted +
ssl_private_key_filepath +
filepath to private key if wanting SSL mode, +else ignored +
gid +
group id to change to after setting listen socket, or -1. +
uid +
user id to change to after setting listen socket, or -1. +
options +
0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK +
+

Description

+
+This function creates the listening socket and takes care +of all initialization in one step. +

+After initialization, it returns a struct libwebsocket_context * that +represents this server. After calling, user code needs to take care +of calling libwebsocket_service with the context pointer to get the +server's sockets serviced. This can be done in the same process context +or a forked process, or another thread, +

+The protocol callback functions are called for a handful of events +including http requests coming in, websocket connections becoming +established, and data arriving; it's also called periodically to allow +async transmission. +

+HTTP requests are sent always to the FIRST protocol in protocol, since +at that time websocket protocol has not been negotiated. Other +protocols after the first one never see any HTTP callack activity. +

+The server created is a simple http server by default; part of the +websocket standard is upgrading this http connection to a websocket one. +

+This allows the same server to provide files like scripts and favicon / +images or whatever over http and dynamic data over websockets all in +one place; they're all handled in the user callback. +

+
+

libwebsockets_fork_service_loop - Optional helper function forks off a process for the websocket server loop. You don't have to use this but if not, you have to make sure you are calling libwebsocket_service periodically to service the websocket traffic

+int +libwebsockets_fork_service_loop +(struct libwebsocket_context * context) +

Arguments

+
+
context +
server context returned by creation function +
+
+

libwebsockets_get_protocol - Returns a protocol pointer from a websocket connection.

+const struct libwebsocket_protocols * +libwebsockets_get_protocol +(struct libwebsocket * wsi) +

Arguments

+
+
wsi +
pointer to struct websocket you want to know the protocol of +
+

Description

+
+

+This is useful to get the protocol to broadcast back to from inside +the callback. +

+
+

libwebsockets_broadcast - Sends a buffer to the callback for all active connections of the given protocol.

+int +libwebsockets_broadcast +(const struct libwebsocket_protocols * protocol, +unsigned char * buf, +size_t len) +

Arguments

+
+
protocol +
pointer to the protocol you will broadcast to all members of +
buf +
buffer containing the data to be broadcase. NOTE: this has to be +allocated with LWS_SEND_BUFFER_PRE_PADDING valid bytes before +the pointer and LWS_SEND_BUFFER_POST_PADDING afterwards in the +case you are calling this function from callback context. +
len +
length of payload data in buf, starting from buf. +
+

Description

+
+This function allows bulk sending of a packet to every connection using +the given protocol. It does not send the data directly; instead it calls +the callback with a reason type of LWS_CALLBACK_BROADCAST. If the callback +wants to actually send the data for that connection, the callback itself +should call libwebsocket_write. +

+libwebsockets_broadcast can be called from another fork context without +having to take any care about data visibility between the processes, it'll +"just work". +

+
+

libwebsocket_write - Apply protocol then write data to client

+int +libwebsocket_write +(struct libwebsocket * wsi, +unsigned char * buf, +size_t len, +enum libwebsocket_write_protocol protocol) +

Arguments

+
+
wsi +
Websocket instance (available from user callback) +
buf +
The data to send. For data being sent on a websocket +connection (ie, not default http), this buffer MUST have +LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE the pointer +and an additional LWS_SEND_BUFFER_POST_PADDING bytes valid +in the buffer after (buf + len). This is so the protocol +header and trailer data can be added in-situ. +
len +
Count of the data bytes in the payload starting from buf +
protocol +
Use LWS_WRITE_HTTP to reply to an http connection, and one +of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate +data on a websockets connection. Remember to allow the extra +bytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT +are used. +
+

Description

+
+This function provides the way to issue data back to the client +for both http and websocket protocols. +

+In the case of sending using websocket protocol, be sure to allocate +valid storage before and after buf as explained above. This scheme +allows maximum efficiency of sending data and protocol in a single +packet while not burdening the user code with any protocol knowledge. +

+
+

libwebsockets_serve_http_file - Send a file back to the client using http

+int +libwebsockets_serve_http_file +(struct libwebsocket * wsi, +const char * file, +const char * content_type) +

Arguments

+
+
wsi +
Websocket instance (available from user callback) +
file +
The file to issue over http +
content_type +
The http content type, eg, text/html +
+

Description

+
+This function is intended to be called from the callback in response +to http requests from the client. It allows the callback to issue +local files down the http link in a single step. +
+
+

libwebsockets_remaining_packet_payload - Bytes to come before "overall" rx packet is complete

+size_t +libwebsockets_remaining_packet_payload +(struct libwebsocket * wsi) +

Arguments

+
+
wsi +
Websocket instance (available from user callback) +
+

Description

+
+This function is intended to be called from the callback if the +user code is interested in "complete packets" from the client. +libwebsockets just passes through payload as it comes and issues a buffer +additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE +callback handler can use this API to find out if the buffer it has just +been given is the last piece of a "complete packet" from the client -- +when that is the case libwebsockets_remaining_packet_payload will return +0. +

+Many protocols won't care becuse their packets are always small. +

+
+

libwebsocket_client_connect - Connect to another websocket server

+struct libwebsocket * +libwebsocket_client_connect +(struct libwebsocket_context * context, +const char * address, +int port, +int ssl_connection, +const char * path, +const char * host, +const char * origin, +const char * protocol, +int ietf_version_or_minus_one) +

Arguments

+
+
context +
Websocket context +
address +
Remote server address, eg, "myserver.com" +
port +
Port to connect to on the remote server, eg, 80 +
ssl_connection +
0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self +signed certs +
path +
Websocket path on server +
host +
Hostname on server +
origin +
Socket origin name +
protocol +
Comma-separated list of protocols being asked for from +the server, or just one. The server will pick the one it +likes best. +
ietf_version_or_minus_one +
-1 to ask to connect using the default, latest +protocol supported, or the specific protocol ordinal +
+

Description

+
+This function creates a connection to a remote server +
+
+

libwebsocket_client_connect_extended - Connect to another websocket server

+struct libwebsocket * +libwebsocket_client_connect_extended +(struct libwebsocket_context * context, +const char * address, +int port, +int ssl_connection, +const char * path, +const char * host, +const char * origin, +const char * protocol, +int ietf_version_or_minus_one, +void * userdata) +

Arguments

+
+
context +
Websocket context +
address +
Remote server address, eg, "myserver.com" +
port +
Port to connect to on the remote server, eg, 80 +
ssl_connection +
0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self +signed certs +
path +
Websocket path on server +
host +
Hostname on server +
origin +
Socket origin name +
protocol +
Comma-separated list of protocols being asked for from +the server, or just one. The server will pick the one it +likes best. +
ietf_version_or_minus_one +
-1 to ask to connect using the default, latest +protocol supported, or the specific protocol ordinal +
userdata +
Pre-allocated user data +
+

Description

+
+This function creates a connection to a remote server +
+
+

callback - User server actions

+LWS_EXTERN int +callback +(struct libwebsocket_context * context, +struct libwebsocket * wsi, +enum libwebsocket_callback_reasons reason, +void * user, +void * in, +size_t len) +

Arguments

+
+
context +
Websockets context +
wsi +
Opaque websocket instance pointer +
reason +
The reason for the call +
user +
Pointer to per-session user data allocated by library +
in +
Pointer used for some callback reasons +
len +
Length set for some callback reasons +
+

Description

+
+This callback is the way the user controls what is served. All the +protocol detail is hidden and handled by the library. +

+For each connection / session there is user data allocated that is +pointed to by "user". You set the size of this user data area when +the library is initialized with libwebsocket_create_server. +

+You get an opportunity to initialize user data when called back with +LWS_CALLBACK_ESTABLISHED reason. +

+

LWS_CALLBACK_ESTABLISHED

+
+after the server completes a handshake with +an incoming client +
+

LWS_CALLBACK_CLIENT_CONNECTION_ERROR

+
+the request client connection has +been unable to complete a handshake with the remote server +
+

LWS_CALLBACK_CLIENT_ESTABLISHED

+
+after your client connection completed +a handshake with the remote server +
+

LWS_CALLBACK_CLOSED

+
+when the websocket session ends +
+

LWS_CALLBACK_BROADCAST

+
+signal to send to client (you would use +libwebsocket_write taking care about the +special buffer requirements +
+

LWS_CALLBACK_RECEIVE

+
+data has appeared for this server endpoint from a +remote client, it can be found at *in and is +len bytes long +
+

LWS_CALLBACK_CLIENT_RECEIVE_PONG

+
+if you elected to see PONG packets, +they appear with this callback reason. PONG +packets only exist in 04+ protocol +
+

LWS_CALLBACK_CLIENT_RECEIVE

+
+data has appeared from the server for the +client connection, it can be found at *in and +is len bytes long +
+

LWS_CALLBACK_HTTP

+
+an http request has come from a client that is not +asking to upgrade the connection to a websocket +one. This is a chance to serve http content, +for example, to send a script to the client +which will then open the websockets connection. +in points to the URI path requested and +libwebsockets_serve_http_file makes it very +simple to send back a file to the client. +
+

LWS_CALLBACK_SERVER_WRITEABLE

+
+If you call +libwebsocket_callback_on_writable on a connection, you will +get one of these callbacks coming when the connection socket +is able to accept another write packet without blocking. +If it already was able to take another packet without blocking, +you'll get this callback at the next call to the service loop +function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE +and servers get LWS_CALLBACK_SERVER_WRITEABLE. +
+

LWS_CALLBACK_FILTER_NETWORK_CONNECTION

+
+called when a client connects to +the server at network level; the connection is accepted but then +passed to this callback to decide whether to hang up immediately +or not, based on the client IP. user contains the connection +socket's descriptor. Return non-zero to terminate +the connection before sending or receiving anything. +Because this happens immediately after the network connection +from the client, there's no websocket protocol selected yet so +this callback is issued only to protocol 0. +
+

LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION

+
+called when the handshake has +been received and parsed from the client, but the response is +not sent yet. Return non-zero to disallow the connection. +user is a pointer to an array of struct lws_tokens, you can +use the header enums lws_token_indexes from libwebsockets.h +to check for and read the supported header presence and +content before deciding to allow the handshake to proceed or +to kill the connection. +
+

LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS

+
+if configured for +including OpenSSL support, this callback allows your user code +to perform extra SSL_CTX_load_verify_locations or similar +calls to direct OpenSSL where to find certificates the client +can use to confirm the remote server identity. user is the +OpenSSL SSL_CTX* +
+

LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS

+
+if configured for +including OpenSSL support, this callback allows your user code +to load extra certifcates into the server which allow it to +verify the validity of certificates returned by clients. user +is the server's OpenSSL SSL_CTX* +
+

LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION

+
+if the +libwebsockets context was created with the option +LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this +callback is generated during OpenSSL verification of the cert +sent from the client. It is sent to protocol[0] callback as +no protocol has been negotiated on the connection yet. +Notice that the libwebsockets context and wsi are both NULL +during this callback. See +
+

http

+
+//www.openssl.org/docs/ssl/SSL_CTX_set_verify.html +to understand more detail about the OpenSSL callback that +generates this libwebsockets callback and the meanings of the +arguments passed. In this callback, user is the x509_ctx, +in is the ssl pointer and len is preverify_ok +Notice that this callback maintains libwebsocket return +conventions, return 0 to mean the cert is OK or 1 to fail it. +This also means that if you don't handle this callback then +the default callback action of returning 0 allows the client +certificates. +
+

LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER

+
+this callback happens +when a client handshake is being compiled. user is NULL, +in is a char **, it's pointing to a char * which holds the +next location in the header buffer where you can add +headers, and len is the remaining space in the header buffer, +which is typically some hundreds of bytes. So, to add a canned +cookie, your handler code might look similar to: +

+char **p = (char **)in; +

+if (len < 100) +return 1; +

+*p += sprintf(*p, "Cookie: a=b\x0d\x0a"); +

+return 0; +

+Notice if you add anything, you just have to take care about +the CRLF on the line you added. Obviously this callback is +optional, if you don't handle it everything is fine. +

+Notice the callback is coming to protocols[0] all the time, +because there is no specific protocol handshook yet. +

+

LWS_CALLBACK_CONFIRM_EXTENSION_OKAY

+
+When the server handshake code +sees that it does support a requested extension, before +accepting the extension by additing to the list sent back to +the client it gives this callback just to check that it's okay +to use that extension. It calls back to the requested protocol +and with in being the extension name, len is 0 and user is +valid. Note though at this time the ESTABLISHED callback hasn't +happened yet so if you initialize user content there, user +content during this callback might not be useful for anything. +Notice this callback comes to protocols[0]. +
+

LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED

+
+When a client +connection is being prepared to start a handshake to a server, +each supported extension is checked with protocols[0] callback +with this reason, giving the user code a chance to suppress the +claim to support that extension by returning non-zero. If +unhandled, by default 0 will be returned and the extension +support included in the header to the server. Notice this +callback comes to protocols[0]. +

+The next four reasons are optional and only need taking care of if you +will be integrating libwebsockets sockets into an external polling +array. +

+

LWS_CALLBACK_ADD_POLL_FD

+
+libwebsocket deals with its poll loop +internally, but in the case you are integrating with another +server you will need to have libwebsocket sockets share a +polling array with the other server. This and the other +POLL_FD related callbacks let you put your specialized +poll array interface code in the callback for protocol 0, the +first protocol you support, usually the HTTP protocol in the +serving case. This callback happens when a socket needs to be +
+

added to the polling loop

+
+user contains the fd, and +len is the events bitmap (like, POLLIN). If you are using the +internal polling loop (the "service" callback), you can just +ignore these callbacks. +
+

LWS_CALLBACK_DEL_POLL_FD

+
+This callback happens when a socket descriptor +needs to be removed from an external polling array. user is +the socket desricptor. If you are using the internal polling +loop, you can just ignore it. +
+

LWS_CALLBACK_SET_MODE_POLL_FD

+
+This callback happens when libwebsockets +wants to modify the events for the socket descriptor in user. +The handler should OR len on to the events member of the pollfd +struct for this socket descriptor. If you are using the +internal polling loop, you can just ignore it. +
+

LWS_CALLBACK_CLEAR_MODE_POLL_FD

+
+This callback occurs when libwebsockets +wants to modify the events for the socket descriptor in user. +The handler should AND ~len on to the events member of the +pollfd struct for this socket descriptor. If you are using the +internal polling loop, you can just ignore it. +
+
+

extension_callback - Hooks to allow extensions to operate

+LWS_EXTERN int +extension_callback +(struct libwebsocket_context * context, +struct libwebsocket_extension * ext, +struct libwebsocket * wsi, +enum libwebsocket_extension_callback_reasons reason, +void * user, +void * in, +size_t len) +

Arguments

+
+
context +
Websockets context +
ext +
This extension +
wsi +
Opaque websocket instance pointer +
reason +
The reason for the call +
user +
Pointer to per-session user data allocated by library +
in +
Pointer used for some callback reasons +
len +
Length set for some callback reasons +
+

Description

+
+Each extension that is active on a particular connection receives +callbacks during the connection lifetime to allow the extension to +operate on websocket data and manage itself. +

+Libwebsockets takes care of allocating and freeing "user" memory for +each active extension on each connection. That is what is pointed to +by the user parameter. +

+

LWS_EXT_CALLBACK_CONSTRUCT

+
+called when the server has decided to +select this extension from the list provided by the client, +just before the server will send back the handshake accepting +the connection with this extension active. This gives the +extension a chance to initialize its connection context found +in user. +
+

LWS_EXT_CALLBACK_CLIENT_CONSTRUCT

+
+same as LWS_EXT_CALLBACK_CONSTRUCT +but called when client is instantiating this extension. Some +extensions will work the same on client and server side and then +you can just merge handlers for both CONSTRUCTS. +
+

LWS_EXT_CALLBACK_DESTROY

+
+called when the connection the extension was +being used on is about to be closed and deallocated. It's the +last chance for the extension to deallocate anything it has +allocated in the user data (pointed to by user) before the +user data is deleted. This same callback is used whether you +are in client or server instantiation context. +
+

LWS_EXT_CALLBACK_PACKET_RX_PREPARSE

+
+when this extension was active on +a connection, and a packet of data arrived at the connection, +it is passed to this callback to give the extension a chance to +change the data, eg, decompress it. user is pointing to the +extension's private connection context data, in is pointing +to an lws_tokens struct, it consists of a char * pointer called +token, and an int called token_len. At entry, these are +set to point to the received buffer and set to the content +length. If the extension will grow the content, it should use +a new buffer allocated in its private user context data and +set the pointed-to lws_tokens members to point to its buffer. +
+

LWS_EXT_CALLBACK_PACKET_TX_PRESEND

+
+this works the same way as +LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the +extension a chance to change websocket data just before it will +be sent out. Using the same lws_token pointer scheme in in, +the extension can change the buffer and the length to be +transmitted how it likes. Again if it wants to grow the +buffer safely, it should copy the data into its own buffer and +set the lws_tokens token pointer to it. +
+
+

struct libwebsocket_protocols - List of protocols and handlers server supports.

+struct libwebsocket_protocols {
+    const char * name;
+    callback_function * callback;
+    size_t per_session_data_size;
+    struct libwebsocket_context * owning_server;
+    int broadcast_socket_port;
+    int broadcast_socket_user_fd;
+    int protocol_index;
+};
+

Members

+
+
name +
Protocol name that must match the one given in the client +Javascript new WebSocket(url, 'protocol') name +
callback +
The service callback used for this protocol. It allows the +service action for an entire protocol to be encapsulated in +the protocol-specific callback +
per_session_data_size +
Each new connection using this protocol gets +this much memory allocated on connection establishment and +freed on connection takedown. A pointer to this per-connection +allocation is passed into the callback in the 'user' parameter +
owning_server +
the server init call fills in this opaque pointer when +registering this protocol with the server. +
broadcast_socket_port +
the server init call fills this in with the +localhost port number used to forward broadcasts for this +protocol +
broadcast_socket_user_fd +
the server init call fills this in ... the main +process context can write to this socket to perform broadcasts +(use the libwebsockets_broadcast api to do this instead, +it works from any process context) +
protocol_index +
which protocol we are starting from zero +
+

Description

+
+This structure represents one protocol supported by the server. An +array of these structures is passed to libwebsocket_create_server +allows as many protocols as you like to be handled by one server. +
+
+

struct libwebsocket_extension - An extension we know how to cope with

+struct libwebsocket_extension {
+    const char * name;
+    extension_callback_function * callback;
+    size_t per_session_data_size;
+    void * per_context_private_data;
+};
+

Members

+
+
name +
Formal extension name, eg, "deflate-stream" +
callback +
Service callback +
per_session_data_size +
Libwebsockets will auto-malloc this much +memory for the use of the extension, a pointer +to it comes in the user callback parameter +
per_context_private_data +
Optional storage for this externsion that +is per-context, so it can track stuff across +all sessions, etc, if it wants +
+
diff --git a/libs/libwebsockets/libwebsockets.spec b/libs/libwebsockets/libwebsockets.spec new file mode 100644 index 0000000000..18e4b82f14 --- /dev/null +++ b/libs/libwebsockets/libwebsockets.spec @@ -0,0 +1,63 @@ +Name: libwebsockets +Version: 0.1 +Release: 45.gmaster_f1d2113d%{?dist} +Summary: Websocket Server Library + +Group: System +License: GPL +URL: http://warmcat.com +Source0: %{name}-%{version}.tar.gz +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +BuildRequires: openssl-devel +Requires: openssl-devel + +%description +Webserver server library + +%package devel +Summary: Development files for libwebsockets +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: openssl-devel + +%description devel +Development files for libwebsockets + +%prep +%setup -q + +%build +./configure --prefix=/usr --libdir=%{_libdir} --enable-openssl +make + + +%install +rm -rf $RPM_BUILD_ROOT +make install DESTDIR=$RPM_BUILD_ROOT + + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root,-) +%attr(755,root,root) /usr/bin/libwebsockets-test-server +%attr(755,root,root) +/%{_libdir}/libwebsockets.so.0.0.3 +/%{_libdir}/libwebsockets.so.0 +/%{_libdir}/libwebsockets.so +/%{_libdir}/libwebsockets.la +%attr(755,root,root) /usr/share/libwebsockets-test-server +%attr(755,root,root) /usr/share/libwebsockets-test-server-extpoll +%attr(755,root,root) /usr/share/libwebsockets-test-client +%attr(755,root,root) /usr/share/libwebsockets-test-ping +%doc +%files devel +%defattr(-,root,root,-) +/usr/include/* +%attr(755,root,root) +/%{_libdir}/libwebsockets.a + +%changelog + diff --git a/libs/libwebsockets/m4/.empty b/libs/libwebsockets/m4/.empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/scripts/kernel-doc b/libs/libwebsockets/scripts/kernel-doc new file mode 100755 index 0000000000..241310e59c --- /dev/null +++ b/libs/libwebsockets/scripts/kernel-doc @@ -0,0 +1,2238 @@ +#!/usr/bin/perl -w + +use strict; + +## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## +## Copyright (C) 2000, 1 Tim Waugh ## +## Copyright (C) 2001 Simon Huggins ## +## Copyright (C) 2005-2009 Randy Dunlap ## +## ## +## #define enhancements by Armin Kuster ## +## Copyright (c) 2000 MontaVista Software, Inc. ## +## ## +## This software falls under the GNU General Public License. ## +## Please read the COPYING file for more information ## + +# w.o. 03-11-2000: added the '-filelist' option. + +# 18/01/2001 - Cleanups +# Functions prototyped as foo(void) same as foo() +# Stop eval'ing where we don't need to. +# -- huggie@earth.li + +# 27/06/2001 - Allowed whitespace after initial "/**" and +# allowed comments before function declarations. +# -- Christian Kreibich + +# Still to do: +# - add perldoc documentation +# - Look more closely at some of the scarier bits :) + +# 26/05/2001 - Support for separate source and object trees. +# Return error code. +# Keith Owens + +# 23/09/2001 - Added support for typedefs, structs, enums and unions +# Support for Context section; can be terminated using empty line +# Small fixes (like spaces vs. \s in regex) +# -- Tim Jansen + + +# +# This will read a 'c' file and scan for embedded comments in the +# style of gnome comments (+minor extensions - see below). +# + +# Note: This only supports 'c'. + +# usage: +# kernel-doc [ -docbook | -html | -text | -man ] [ -no-doc-sections ] +# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile +# or +# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile +# +# Set output format using one of -docbook -html -text or -man. Default is man. +# +# -no-doc-sections +# Do not output DOC: sections +# +# -function funcname +# If set, then only generate documentation for the given function(s) or +# DOC: section titles. All other functions and DOC: sections are ignored. +# +# -nofunction funcname +# If set, then only generate documentation for the other function(s)/DOC: +# sections. Cannot be used together with -function (yes, that's a bug -- +# perl hackers can fix it 8)) +# +# c files - list of 'c' files to process +# +# All output goes to stdout, with errors to stderr. + +# +# format of comments. +# In the following table, (...)? signifies optional structure. +# (...)* signifies 0 or more structure elements +# /** +# * function_name(:)? (- short description)? +# (* @parameterx: (description of parameter x)?)* +# (* a blank line)? +# * (Description:)? (Description of function)? +# * (section header: (section description)? )* +# (*)?*/ +# +# So .. the trivial example would be: +# +# /** +# * my_function +# */ +# +# If the Description: header tag is omitted, then there must be a blank line +# after the last parameter specification. +# e.g. +# /** +# * my_function - does my stuff +# * @my_arg: its mine damnit +# * +# * Does my stuff explained. +# */ +# +# or, could also use: +# /** +# * my_function - does my stuff +# * @my_arg: its mine damnit +# * Description: Does my stuff explained. +# */ +# etc. +# +# Besides functions you can also write documentation for structs, unions, +# enums and typedefs. Instead of the function name you must write the name +# of the declaration; the struct/union/enum/typedef must always precede +# the name. Nesting of declarations is not supported. +# Use the argument mechanism to document members or constants. +# e.g. +# /** +# * struct my_struct - short description +# * @a: first member +# * @b: second member +# * +# * Longer description +# */ +# struct my_struct { +# int a; +# int b; +# /* private: */ +# int c; +# }; +# +# All descriptions can be multiline, except the short function description. +# +# You can also add additional sections. When documenting kernel functions you +# should document the "Context:" of the function, e.g. whether the functions +# can be called form interrupts. Unlike other sections you can end it with an +# empty line. +# Example-sections should contain the string EXAMPLE so that they are marked +# appropriately in DocBook. +# +# Example: +# /** +# * user_function - function that can only be called in user context +# * @a: some argument +# * Context: !in_interrupt() +# * +# * Some description +# * Example: +# * user_function(22); +# */ +# ... +# +# +# All descriptive text is further processed, scanning for the following special +# patterns, which are highlighted appropriately. +# +# 'funcname()' - function +# '$ENVVAR' - environmental variable +# '&struct_name' - name of a structure (up to two words including 'struct') +# '@parameter' - name of a parameter +# '%CONST' - name of a constant. + +my $errors = 0; +my $warnings = 0; +my $anon_struct_union = 0; + +# match expressions used to find embedded type information +my $type_constant = '\%([-_\w]+)'; +my $type_func = '(\w+)\(\)'; +my $type_param = '\@(\w+)'; +my $type_struct = '\&((struct\s*)*[_\w]+)'; +my $type_struct_xml = '\\&((struct\s*)*[_\w]+)'; +my $type_env = '(\$\w+)'; + +# Output conversion substitutions. +# One for each output format + +# these work fairly well +my %highlights_html = ( $type_constant, "\$1", + $type_func, "\$1", + $type_struct_xml, "\$1", + $type_env, "\$1", + $type_param, "\$1" ); +my $local_lt = "\\\\\\\\lt:"; +my $local_gt = "\\\\\\\\gt:"; +my $blankline_html = $local_lt . "p" . $local_gt; # was "

" + +# XML, docbook format +my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1\$2", + $type_constant, "\$1", + $type_func, "\$1", + $type_struct_xml, "\$1", + $type_env, "\$1", + $type_param, "\$1" ); +my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; + +# gnome, docbook format +my %highlights_gnome = ( $type_constant, "\$1", + $type_func, "\$1", + $type_struct, "\$1", + $type_env, "\$1", + $type_param, "\$1" ); +my $blankline_gnome = "\n"; + +# these are pretty rough +my %highlights_man = ( $type_constant, "\$1", + $type_func, "\\\\fB\$1\\\\fP", + $type_struct, "\\\\fI\$1\\\\fP", + $type_param, "\\\\fI\$1\\\\fP" ); +my $blankline_man = ""; + +# text-mode +my %highlights_text = ( $type_constant, "\$1", + $type_func, "\$1", + $type_struct, "\$1", + $type_param, "\$1" ); +my $blankline_text = ""; + + +sub usage { + print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ] [ -no-doc-sections ]\n"; + print " [ -function funcname [ -function funcname ...] ]\n"; + print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; + print " c source file(s) > outputfile\n"; + print " -v : verbose output, more warnings & other info listed\n"; + exit 1; +} + +# read arguments +if ($#ARGV == -1) { + usage(); +} + +my $verbose = 0; +my $output_mode = "man"; +my $no_doc_sections = 0; +my %highlights = %highlights_man; +my $blankline = $blankline_man; +my $modulename = "Kernel API"; +my $function_only = 0; +my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', + 'November', 'December')[(localtime)[4]] . + " " . ((localtime)[5]+1900); + +# Essentially these are globals +# They probably want to be tidied up, made more localised or something. +# CAVEAT EMPTOR! Some of the others I localised may not want to be, which +# could cause "use of undefined value" or other bugs. +my ($function, %function_table, %parametertypes, $declaration_purpose); +my ($type, $declaration_name, $return_type); +my ($newsection, $newcontents, $prototype, $filelist, $brcount, %source_map); + +if (defined($ENV{'KBUILD_VERBOSE'})) { + $verbose = "$ENV{'KBUILD_VERBOSE'}"; +} + +# Generated docbook code is inserted in a template at a point where +# docbook v3.1 requires a non-zero sequence of RefEntry's; see: +# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html +# We keep track of number of generated entries and generate a dummy +# if needs be to ensure the expanded template can be postprocessed +# into html. +my $section_counter = 0; + +my $lineprefix=""; + +# states +# 0 - normal code +# 1 - looking for function name +# 2 - scanning field start. +# 3 - scanning prototype. +# 4 - documentation block +my $state; +my $in_doc_sect; + +#declaration types: can be +# 'function', 'struct', 'union', 'enum', 'typedef' +my $decl_type; + +my $doc_special = "\@\%\$\&"; + +my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. +my $doc_end = '\*/'; +my $doc_com = '\s*\*\s*'; +my $doc_decl = $doc_com . '(\w+)'; +my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)'; +my $doc_content = $doc_com . '(.*)'; +my $doc_block = $doc_com . 'DOC:\s*(.*)?'; + +my %constants; +my %parameterdescs; +my @parameterlist; +my %sections; +my @sectionlist; +my $sectcheck; +my $struct_actual; + +my $contents = ""; +my $section_default = "Description"; # default section +my $section_intro = "Introduction"; +my $section = $section_default; +my $section_context = "Context"; + +my $undescribed = "-- undescribed --"; + +reset_state(); + +while ($ARGV[0] =~ m/^-(.*)/) { + my $cmd = shift @ARGV; + if ($cmd eq "-html") { + $output_mode = "html"; + %highlights = %highlights_html; + $blankline = $blankline_html; + } elsif ($cmd eq "-man") { + $output_mode = "man"; + %highlights = %highlights_man; + $blankline = $blankline_man; + } elsif ($cmd eq "-text") { + $output_mode = "text"; + %highlights = %highlights_text; + $blankline = $blankline_text; + } elsif ($cmd eq "-docbook") { + $output_mode = "xml"; + %highlights = %highlights_xml; + $blankline = $blankline_xml; + } elsif ($cmd eq "-gnome") { + $output_mode = "gnome"; + %highlights = %highlights_gnome; + $blankline = $blankline_gnome; + } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document + $modulename = shift @ARGV; + } elsif ($cmd eq "-function") { # to only output specific functions + $function_only = 1; + $function = shift @ARGV; + $function_table{$function} = 1; + } elsif ($cmd eq "-nofunction") { # to only output specific functions + $function_only = 2; + $function = shift @ARGV; + $function_table{$function} = 1; + } elsif ($cmd eq "-v") { + $verbose = 1; + } elsif (($cmd eq "-h") || ($cmd eq "--help")) { + usage(); + } elsif ($cmd eq '-filelist') { + $filelist = shift @ARGV; + } elsif ($cmd eq '-no-doc-sections') { + $no_doc_sections = 1; + } +} + +# get kernel version from env +sub get_kernel_version() { + my $version = 'unknown kernel version'; + + if (defined($ENV{'KERNELVERSION'})) { + $version = $ENV{'KERNELVERSION'}; + } + return $version; +} +my $kernelversion = get_kernel_version(); + +# generate a sequence of code that will splice in highlighting information +# using the s// operator. +my $dohighlight = ""; +foreach my $pattern (keys %highlights) { +# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n"; + $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; +} + +## +# dumps section contents to arrays/hashes intended for that purpose. +# +sub dump_section { + my $file = shift; + my $name = shift; + my $contents = join "\n", @_; + + if ($name =~ m/$type_constant/) { + $name = $1; +# print STDERR "constant section '$1' = '$contents'\n"; + $constants{$name} = $contents; + } elsif ($name =~ m/$type_param/) { +# print STDERR "parameter def '$1' = '$contents'\n"; + $name = $1; + $parameterdescs{$name} = $contents; + $sectcheck = $sectcheck . $name . " "; + } elsif ($name eq "@\.\.\.") { +# print STDERR "parameter def '...' = '$contents'\n"; + $name = "..."; + $parameterdescs{$name} = $contents; + $sectcheck = $sectcheck . $name . " "; + } else { +# print STDERR "other section '$name' = '$contents'\n"; + if (defined($sections{$name}) && ($sections{$name} ne "")) { + print STDERR "Error(${file}:$.): duplicate section name '$name'\n"; + ++$errors; + } + $sections{$name} = $contents; + push @sectionlist, $name; + } +} + +## +# dump DOC: section after checking that it should go out +# +sub dump_doc_section { + my $file = shift; + my $name = shift; + my $contents = join "\n", @_; + + if ($no_doc_sections) { + return; + } + + if (($function_only == 0) || + ( $function_only == 1 && defined($function_table{$name})) || + ( $function_only == 2 && !defined($function_table{$name}))) + { + dump_section($file, $name, $contents); + output_blockhead({'sectionlist' => \@sectionlist, + 'sections' => \%sections, + 'module' => $modulename, + 'content-only' => ($function_only != 0), }); + } +} + +## +# output function +# +# parameterdescs, a hash. +# function => "function name" +# parameterlist => @list of parameters +# parameterdescs => %parameter descriptions +# sectionlist => @list of sections +# sections => %section descriptions +# + +sub output_highlight { + my $contents = join "\n",@_; + my $line; + +# DEBUG +# if (!defined $contents) { +# use Carp; +# confess "output_highlight got called with no args?\n"; +# } + + if ($output_mode eq "html" || $output_mode eq "xml") { + $contents = local_unescape($contents); + # convert data read & converted thru xml_escape() into &xyz; format: + $contents =~ s/\\\\\\/&/g; + } +# print STDERR "contents b4:$contents\n"; + eval $dohighlight; + die $@ if $@; +# print STDERR "contents af:$contents\n"; + + foreach $line (split "\n", $contents) { + if ($line eq ""){ + print $lineprefix, local_unescape($blankline); + } else { + $line =~ s/\\\\\\/\&/g; + if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { + print "\\&$line"; + } else { + print $lineprefix, $line; + } + } + print "\n"; + } +} + +#output sections in html +sub output_section_html(%) { + my %args = %{$_[0]}; + my $section; + + foreach $section (@{$args{'sectionlist'}}) { + print "

$section

\n"; + print "
\n"; + output_highlight($args{'sections'}{$section}); + print "
\n"; + } +} + +# output enum in html +sub output_enum_html(%) { + my %args = %{$_[0]}; + my ($parameter); + my $count; + print "

enum " . $args{'enum'} . "

\n"; + + print "enum " . $args{'enum'} . " {
\n"; + $count = 0; + foreach $parameter (@{$args{'parameterlist'}}) { + print " " . $parameter . ""; + if ($count != $#{$args{'parameterlist'}}) { + $count++; + print ",\n"; + } + print "
"; + } + print "};
\n"; + + print "

Constants

\n"; + print "
\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + print "
" . $parameter . "\n"; + print "
"; + output_highlight($args{'parameterdescs'}{$parameter}); + } + print "
\n"; + output_section_html(@_); + print "
\n"; +} + +# output typedef in html +sub output_typedef_html(%) { + my %args = %{$_[0]}; + my ($parameter); + my $count; + print "

typedef " . $args{'typedef'} . "

\n"; + + print "typedef " . $args{'typedef'} . "\n"; + output_section_html(@_); + print "
\n"; +} + +# output struct in html +sub output_struct_html(%) { + my %args = %{$_[0]}; + my ($parameter); + + print "

" . $args{'type'} . " " . $args{'struct'} . " - " . $args{'purpose'} . "

\n"; + print "" . $args{'type'} . " " . $args{'struct'} . " {
\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + if ($parameter =~ /^#/) { + print "$parameter
\n"; + next; + } + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print "    $1$parameter) ($2);
\n"; + } elsif ($type =~ m/^(.*?)\s*(:.*)/) { + # bitfield + print "    $1 $parameter$2;
\n"; + } else { + print "    $type $parameter;
\n"; + } + } + print "};
\n"; + + print "

Members

\n"; + print "
\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + ($parameter =~ /^#/) && next; + + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + print "
" . $parameter . "\n"; + print "
"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + } + print "
\n"; + output_section_html(@_); + print "
\n"; +} + +# output function in html +sub output_function_html(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + + print "

" . $args{'function'} . " - " . $args{'purpose'} . "

\n"; + print "" . $args{'functiontype'} . "\n"; + print "" . $args{'function'} . "\n"; + print "("; + $count = 0; + foreach $parameter (@{$args{'parameterlist'}}) { + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print "$1$parameter) ($2)"; + } else { + print "" . $type . " " . $parameter . ""; + } + if ($count != $#{$args{'parameterlist'}}) { + $count++; + print ",\n"; + } + } + print ")\n"; + + print "

Arguments

\n"; + print "
\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + print "
" . $parameter . "\n"; + print "
"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + } + print "
\n"; + output_section_html(@_); + print "
\n"; +} + +# output DOC: block header in html +sub output_blockhead_html(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + + foreach $section (@{$args{'sectionlist'}}) { + print "

$section

\n"; + print "
    \n"; + output_highlight($args{'sections'}{$section}); + print "
\n"; + } + print "
\n"; +} + +sub output_section_xml(%) { + my %args = %{$_[0]}; + my $section; + # print out each section + $lineprefix=" "; + foreach $section (@{$args{'sectionlist'}}) { + print "\n"; + print "$section\n"; + if ($section =~ m/EXAMPLE/i) { + print "\n"; + } else { + print "\n"; + } + output_highlight($args{'sections'}{$section}); + if ($section =~ m/EXAMPLE/i) { + print "\n"; + } else { + print "\n"; + } + print "\n"; + } +} + +# output function in XML DocBook +sub output_function_xml(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + my $id; + + $id = "API-" . $args{'function'}; + $id =~ s/[^A-Za-z0-9]/-/g; + + print "\n"; + print "\n"; + print " LINUX\n"; + print " Kernel Hackers Manual\n"; + print " $man_date\n"; + print "\n"; + print "\n"; + print " " . $args{'function'} . "\n"; + print " 9\n"; + print " " . $kernelversion . "\n"; + print "\n"; + print "\n"; + print " " . $args{'function'} . "\n"; + print " \n"; + print " "; + output_highlight ($args{'purpose'}); + print " \n"; + print "\n"; + + print "\n"; + print " Synopsis\n"; + print " \n"; + print " " . $args{'functiontype'} . " "; + print "" . $args{'function'} . " \n"; + + $count = 0; + if ($#{$args{'parameterlist'}} >= 0) { + foreach $parameter (@{$args{'parameterlist'}}) { + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print " $1$parameter)\n"; + print " $2\n"; + } else { + print " " . $type; + print " $parameter\n"; + } + } + } else { + print " \n"; + } + print " \n"; + print "\n"; + + # print parameters + print "\n Arguments\n"; + if ($#{$args{'parameterlist'}} >= 0) { + print " \n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + print " \n $parameter\n"; + print " \n \n"; + $lineprefix=" "; + output_highlight($args{'parameterdescs'}{$parameter_name}); + print " \n \n \n"; + } + print " \n"; + } else { + print " \n None\n \n"; + } + print "\n"; + + output_section_xml(@_); + print "\n\n"; +} + +# output struct in XML DocBook +sub output_struct_xml(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $id; + + $id = "API-struct-" . $args{'struct'}; + $id =~ s/[^A-Za-z0-9]/-/g; + + print "\n"; + print "\n"; + print " LINUX\n"; + print " Kernel Hackers Manual\n"; + print " $man_date\n"; + print "\n"; + print "\n"; + print " " . $args{'type'} . " " . $args{'struct'} . "\n"; + print " 9\n"; + print " " . $kernelversion . "\n"; + print "\n"; + print "\n"; + print " " . $args{'type'} . " " . $args{'struct'} . "\n"; + print " \n"; + print " "; + output_highlight ($args{'purpose'}); + print " \n"; + print "\n"; + + print "\n"; + print " Synopsis\n"; + print " \n"; + print $args{'type'} . " " . $args{'struct'} . " {\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + if ($parameter =~ /^#/) { + print "$parameter\n"; + next; + } + + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + defined($args{'parameterdescs'}{$parameter_name}) || next; + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print " $1 $parameter) ($2);\n"; + } elsif ($type =~ m/^(.*?)\s*(:.*)/) { + # bitfield + print " $1 $parameter$2;\n"; + } else { + print " " . $type . " " . $parameter . ";\n"; + } + } + print "};"; + print " \n"; + print "\n"; + + print " \n"; + print " Members\n"; + + if ($#{$args{'parameterlist'}} >= 0) { + print " \n"; + foreach $parameter (@{$args{'parameterlist'}}) { + ($parameter =~ /^#/) && next; + + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + defined($args{'parameterdescs'}{$parameter_name}) || next; + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + print " "; + print " $parameter\n"; + print " \n"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + print " \n"; + print " \n"; + } + print " \n"; + } else { + print " \n None\n \n"; + } + print " \n"; + + output_section_xml(@_); + + print "\n\n"; +} + +# output enum in XML DocBook +sub output_enum_xml(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + my $id; + + $id = "API-enum-" . $args{'enum'}; + $id =~ s/[^A-Za-z0-9]/-/g; + + print "\n"; + print "\n"; + print " LINUX\n"; + print " Kernel Hackers Manual\n"; + print " $man_date\n"; + print "\n"; + print "\n"; + print " enum " . $args{'enum'} . "\n"; + print " 9\n"; + print " " . $kernelversion . "\n"; + print "\n"; + print "\n"; + print " enum " . $args{'enum'} . "\n"; + print " \n"; + print " "; + output_highlight ($args{'purpose'}); + print " \n"; + print "\n"; + + print "\n"; + print " Synopsis\n"; + print " \n"; + print "enum " . $args{'enum'} . " {\n"; + $count = 0; + foreach $parameter (@{$args{'parameterlist'}}) { + print " $parameter"; + if ($count != $#{$args{'parameterlist'}}) { + $count++; + print ","; + } + print "\n"; + } + print "};"; + print " \n"; + print "\n"; + + print "\n"; + print " Constants\n"; + print " \n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + print " "; + print " $parameter\n"; + print " \n"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + print " \n"; + print " \n"; + } + print " \n"; + print "\n"; + + output_section_xml(@_); + + print "\n\n"; +} + +# output typedef in XML DocBook +sub output_typedef_xml(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $id; + + $id = "API-typedef-" . $args{'typedef'}; + $id =~ s/[^A-Za-z0-9]/-/g; + + print "\n"; + print "\n"; + print " LINUX\n"; + print " Kernel Hackers Manual\n"; + print " $man_date\n"; + print "\n"; + print "\n"; + print " typedef " . $args{'typedef'} . "\n"; + print " 9\n"; + print "\n"; + print "\n"; + print " typedef " . $args{'typedef'} . "\n"; + print " \n"; + print " "; + output_highlight ($args{'purpose'}); + print " \n"; + print "\n"; + + print "\n"; + print " Synopsis\n"; + print " typedef " . $args{'typedef'} . ";\n"; + print "\n"; + + output_section_xml(@_); + + print "\n\n"; +} + +# output in XML DocBook +sub output_blockhead_xml(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + + my $id = $args{'module'}; + $id =~ s/[^A-Za-z0-9]/-/g; + + # print out each section + $lineprefix=" "; + foreach $section (@{$args{'sectionlist'}}) { + if (!$args{'content-only'}) { + print "\n $section\n"; + } + if ($section =~ m/EXAMPLE/i) { + print "\n"; + } else { + print "\n"; + } + output_highlight($args{'sections'}{$section}); + if ($section =~ m/EXAMPLE/i) { + print "\n"; + } else { + print ""; + } + if (!$args{'content-only'}) { + print "\n\n"; + } + } + + print "\n\n"; +} + +# output in XML DocBook +sub output_function_gnome { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + my $id; + + $id = $args{'module'} . "-" . $args{'function'}; + $id =~ s/[^A-Za-z0-9]/-/g; + + print "\n"; + print " " . $args{'function'} . "\n"; + + print " \n"; + print " " . $args{'functiontype'} . " "; + print "" . $args{'function'} . " "; + print "\n"; + + $count = 0; + if ($#{$args{'parameterlist'}} >= 0) { + foreach $parameter (@{$args{'parameterlist'}}) { + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print " $1 $parameter)\n"; + print " $2\n"; + } else { + print " " . $type; + print " $parameter\n"; + } + } + } else { + print " \n"; + } + print " \n"; + if ($#{$args{'parameterlist'}} >= 0) { + print " \n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + print " $parameter\n"; + print " \n"; + $lineprefix=" "; + output_highlight($args{'parameterdescs'}{$parameter_name}); + print " \n"; + } + print " \n"; + } else { + print " \n None\n \n"; + } + + # print out each section + $lineprefix=" "; + foreach $section (@{$args{'sectionlist'}}) { + print "\n $section\n"; + if ($section =~ m/EXAMPLE/i) { + print "\n"; + } else { + } + print "\n"; + output_highlight($args{'sections'}{$section}); + print "\n"; + if ($section =~ m/EXAMPLE/i) { + print "\n"; + } else { + } + print " \n"; + } + + print "\n\n"; +} + +## +# output function in man +sub output_function_man(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + + print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n"; + + print ".SH NAME\n"; + print $args{'function'} . " \\- " . $args{'purpose'} . "\n"; + + print ".SH SYNOPSIS\n"; + if ($args{'functiontype'} ne "") { + print ".B \"" . $args{'functiontype'} . "\" " . $args{'function'} . "\n"; + } else { + print ".B \"" . $args{'function'} . "\n"; + } + $count = 0; + my $parenth = "("; + my $post = ","; + foreach my $parameter (@{$args{'parameterlist'}}) { + if ($count == $#{$args{'parameterlist'}}) { + $post = ");"; + } + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print ".BI \"" . $parenth . $1 . "\" " . $parameter . " \") (" . $2 . ")" . $post . "\"\n"; + } else { + $type =~ s/([^\*])$/$1 /; + print ".BI \"" . $parenth . $type . "\" " . $parameter . " \"" . $post . "\"\n"; + } + $count++; + $parenth = ""; + } + + print ".SH ARGUMENTS\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + print ".IP \"" . $parameter . "\" 12\n"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + } + foreach $section (@{$args{'sectionlist'}}) { + print ".SH \"", uc $section, "\"\n"; + output_highlight($args{'sections'}{$section}); + } +} + +## +# output enum in man +sub output_enum_man(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + + print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n"; + + print ".SH NAME\n"; + print "enum " . $args{'enum'} . " \\- " . $args{'purpose'} . "\n"; + + print ".SH SYNOPSIS\n"; + print "enum " . $args{'enum'} . " {\n"; + $count = 0; + foreach my $parameter (@{$args{'parameterlist'}}) { + print ".br\n.BI \" $parameter\"\n"; + if ($count == $#{$args{'parameterlist'}}) { + print "\n};\n"; + last; + } + else { + print ", \n.br\n"; + } + $count++; + } + + print ".SH Constants\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + print ".IP \"" . $parameter . "\" 12\n"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + } + foreach $section (@{$args{'sectionlist'}}) { + print ".SH \"$section\"\n"; + output_highlight($args{'sections'}{$section}); + } +} + +## +# output struct in man +sub output_struct_man(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + + print ".TH \"$args{'module'}\" 9 \"" . $args{'type'} . " " . $args{'struct'} . "\" \"$man_date\" \"API Manual\" LINUX\n"; + + print ".SH NAME\n"; + print $args{'type'} . " " . $args{'struct'} . " \\- " . $args{'purpose'} . "\n"; + + print ".SH SYNOPSIS\n"; + print $args{'type'} . " " . $args{'struct'} . " {\n.br\n"; + + foreach my $parameter (@{$args{'parameterlist'}}) { + if ($parameter =~ /^#/) { + print ".BI \"$parameter\"\n.br\n"; + next; + } + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print ".BI \" " . $1 . "\" " . $parameter . " \") (" . $2 . ")" . "\"\n;\n"; + } elsif ($type =~ m/^(.*?)\s*(:.*)/) { + # bitfield + print ".BI \" " . $1 . "\ \" " . $parameter . $2 . " \"" . "\"\n;\n"; + } else { + $type =~ s/([^\*])$/$1 /; + print ".BI \" " . $type . "\" " . $parameter . " \"" . "\"\n;\n"; + } + print "\n.br\n"; + } + print "};\n.br\n"; + + print ".SH Members\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + ($parameter =~ /^#/) && next; + + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + print ".IP \"" . $parameter . "\" 12\n"; + output_highlight($args{'parameterdescs'}{$parameter_name}); + } + foreach $section (@{$args{'sectionlist'}}) { + print ".SH \"$section\"\n"; + output_highlight($args{'sections'}{$section}); + } +} + +## +# output typedef in man +sub output_typedef_man(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + + print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n"; + + print ".SH NAME\n"; + print "typedef " . $args{'typedef'} . " \\- " . $args{'purpose'} . "\n"; + + foreach $section (@{$args{'sectionlist'}}) { + print ".SH \"$section\"\n"; + output_highlight($args{'sections'}{$section}); + } +} + +sub output_blockhead_man(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $count; + + print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n"; + + foreach $section (@{$args{'sectionlist'}}) { + print ".SH \"$section\"\n"; + output_highlight($args{'sections'}{$section}); + } +} + +## +# output in text +sub output_function_text(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + my $start; + + print "Name:\n\n"; + print $args{'function'} . " - " . $args{'purpose'} . "\n"; + + print "\nSynopsis:\n\n"; + if ($args{'functiontype'} ne "") { + $start = $args{'functiontype'} . " " . $args{'function'} . " ("; + } else { + $start = $args{'function'} . " ("; + } + print $start; + + my $count = 0; + foreach my $parameter (@{$args{'parameterlist'}}) { + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print $1 . $parameter . ") (" . $2; + } else { + print $type . " " . $parameter; + } + if ($count != $#{$args{'parameterlist'}}) { + $count++; + print ",\n"; + print " " x length($start); + } else { + print ");\n\n"; + } + } + + print "Arguments:\n\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + print $parameter . "\n\t" . $args{'parameterdescs'}{$parameter_name} . "\n"; + } + output_section_text(@_); +} + +#output sections in text +sub output_section_text(%) { + my %args = %{$_[0]}; + my $section; + + print "\n"; + foreach $section (@{$args{'sectionlist'}}) { + print "$section:\n\n"; + output_highlight($args{'sections'}{$section}); + } + print "\n\n"; +} + +# output enum in text +sub output_enum_text(%) { + my %args = %{$_[0]}; + my ($parameter); + my $count; + print "Enum:\n\n"; + + print "enum " . $args{'enum'} . " - " . $args{'purpose'} . "\n\n"; + print "enum " . $args{'enum'} . " {\n"; + $count = 0; + foreach $parameter (@{$args{'parameterlist'}}) { + print "\t$parameter"; + if ($count != $#{$args{'parameterlist'}}) { + $count++; + print ","; + } + print "\n"; + } + print "};\n\n"; + + print "Constants:\n\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + print "$parameter\n\t"; + print $args{'parameterdescs'}{$parameter} . "\n"; + } + + output_section_text(@_); +} + +# output typedef in text +sub output_typedef_text(%) { + my %args = %{$_[0]}; + my ($parameter); + my $count; + print "Typedef:\n\n"; + + print "typedef " . $args{'typedef'} . " - " . $args{'purpose'} . "\n"; + output_section_text(@_); +} + +# output struct as text +sub output_struct_text(%) { + my %args = %{$_[0]}; + my ($parameter); + + print $args{'type'} . " " . $args{'struct'} . " - " . $args{'purpose'} . "\n\n"; + print $args{'type'} . " " . $args{'struct'} . " {\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + if ($parameter =~ /^#/) { + print "$parameter\n"; + next; + } + + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + $type = $args{'parametertypes'}{$parameter}; + if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { + # pointer-to-function + print "\t$1 $parameter) ($2);\n"; + } elsif ($type =~ m/^(.*?)\s*(:.*)/) { + # bitfield + print "\t$1 $parameter$2;\n"; + } else { + print "\t" . $type . " " . $parameter . ";\n"; + } + } + print "};\n\n"; + + print "Members:\n\n"; + foreach $parameter (@{$args{'parameterlist'}}) { + ($parameter =~ /^#/) && next; + + my $parameter_name = $parameter; + $parameter_name =~ s/\[.*//; + + ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; + print "$parameter\n\t"; + print $args{'parameterdescs'}{$parameter_name} . "\n"; + } + print "\n"; + output_section_text(@_); +} + +sub output_blockhead_text(%) { + my %args = %{$_[0]}; + my ($parameter, $section); + + foreach $section (@{$args{'sectionlist'}}) { + print " $section:\n"; + print " -> "; + output_highlight($args{'sections'}{$section}); + } +} + +## +# generic output function for all types (function, struct/union, typedef, enum); +# calls the generated, variable output_ function name based on +# functype and output_mode +sub output_declaration { + no strict 'refs'; + my $name = shift; + my $functype = shift; + my $func = "output_${functype}_$output_mode"; + if (($function_only==0) || + ( $function_only == 1 && defined($function_table{$name})) || + ( $function_only == 2 && !defined($function_table{$name}))) + { + &$func(@_); + $section_counter++; + } +} + +## +# generic output function - calls the right one based on current output mode. +sub output_blockhead { + no strict 'refs'; + my $func = "output_blockhead_" . $output_mode; + &$func(@_); + $section_counter++; +} + +## +# takes a declaration (struct, union, enum, typedef) and +# invokes the right handler. NOT called for functions. +sub dump_declaration($$) { + no strict 'refs'; + my ($prototype, $file) = @_; + my $func = "dump_" . $decl_type; + &$func(@_); +} + +sub dump_union($$) { + dump_struct(@_); +} + +sub dump_struct($$) { + my $x = shift; + my $file = shift; + my $nested; + + if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) { + #my $decl_type = $1; + $declaration_name = $2; + my $members = $3; + + # ignore embedded structs or unions + $members =~ s/({.*})//g; + $nested = $1; + + # ignore members marked private: + $members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gos; + $members =~ s/\/\*\s*private:.*//gos; + # strip comments: + $members =~ s/\/\*.*?\*\///gos; + $nested =~ s/\/\*.*?\*\///gos; + # strip kmemcheck_bitfield_{begin,end}.*; + $members =~ s/kmemcheck_bitfield_.*?;//gos; + + create_parameterlist($members, ';', $file); + check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); + + output_declaration($declaration_name, + 'struct', + {'struct' => $declaration_name, + 'module' => $modulename, + 'parameterlist' => \@parameterlist, + 'parameterdescs' => \%parameterdescs, + 'parametertypes' => \%parametertypes, + 'sectionlist' => \@sectionlist, + 'sections' => \%sections, + 'purpose' => $declaration_purpose, + 'type' => $decl_type + }); + } + else { + print STDERR "Error(${file}:$.): Cannot parse struct or union!\n"; + ++$errors; + } +} + +sub dump_enum($$) { + my $x = shift; + my $file = shift; + + $x =~ s@/\*.*?\*/@@gos; # strip comments. + if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { + $declaration_name = $1; + my $members = $2; + + foreach my $arg (split ',', $members) { + $arg =~ s/^\s*(\w+).*/$1/; + push @parameterlist, $arg; + if (!$parameterdescs{$arg}) { + $parameterdescs{$arg} = $undescribed; + print STDERR "Warning(${file}:$.): Enum value '$arg' ". + "not described in enum '$declaration_name'\n"; + } + + } + + output_declaration($declaration_name, + 'enum', + {'enum' => $declaration_name, + 'module' => $modulename, + 'parameterlist' => \@parameterlist, + 'parameterdescs' => \%parameterdescs, + 'sectionlist' => \@sectionlist, + 'sections' => \%sections, + 'purpose' => $declaration_purpose + }); + } + else { + print STDERR "Error(${file}:$.): Cannot parse enum!\n"; + ++$errors; + } +} + +sub dump_typedef($$) { + my $x = shift; + my $file = shift; + + $x =~ s@/\*.*?\*/@@gos; # strip comments. + while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) { + $x =~ s/\(*.\)\s*;$/;/; + $x =~ s/\[*.\]\s*;$/;/; + } + + if ($x =~ /typedef.*\s+(\w+)\s*;/) { + $declaration_name = $1; + + output_declaration($declaration_name, + 'typedef', + {'typedef' => $declaration_name, + 'module' => $modulename, + 'sectionlist' => \@sectionlist, + 'sections' => \%sections, + 'purpose' => $declaration_purpose + }); + } + else { + print STDERR "Error(${file}:$.): Cannot parse typedef!\n"; + ++$errors; + } +} + +sub save_struct_actual($) { + my $actual = shift; + + # strip all spaces from the actual param so that it looks like one string item + $actual =~ s/\s*//g; + $struct_actual = $struct_actual . $actual . " "; +} + +sub create_parameterlist($$$) { + my $args = shift; + my $splitter = shift; + my $file = shift; + my $type; + my $param; + + # temporarily replace commas inside function pointer definition + while ($args =~ /(\([^\),]+),/) { + $args =~ s/(\([^\),]+),/$1#/g; + } + + foreach my $arg (split($splitter, $args)) { + # strip comments + $arg =~ s/\/\*.*\*\///; + # strip leading/trailing spaces + $arg =~ s/^\s*//; + $arg =~ s/\s*$//; + $arg =~ s/\s+/ /; + + if ($arg =~ /^#/) { + # Treat preprocessor directive as a typeless variable just to fill + # corresponding data structures "correctly". Catch it later in + # output_* subs. + push_parameter($arg, "", $file); + } elsif ($arg =~ m/\(.+\)\s*\(/) { + # pointer-to-function + $arg =~ tr/#/,/; + $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/; + $param = $1; + $type = $arg; + $type =~ s/([^\(]+\(\*?)\s*$param/$1/; + save_struct_actual($param); + push_parameter($param, $type, $file); + } elsif ($arg) { + $arg =~ s/\s*:\s*/:/g; + $arg =~ s/\s*\[/\[/g; + + my @args = split('\s*,\s*', $arg); + if ($args[0] =~ m/\*/) { + $args[0] =~ s/(\*+)\s*/ $1/; + } + + my @first_arg; + if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) { + shift @args; + push(@first_arg, split('\s+', $1)); + push(@first_arg, $2); + } else { + @first_arg = split('\s+', shift @args); + } + + unshift(@args, pop @first_arg); + $type = join " ", @first_arg; + + foreach $param (@args) { + if ($param =~ m/^(\*+)\s*(.*)/) { + save_struct_actual($2); + push_parameter($2, "$type $1", $file); + } + elsif ($param =~ m/(.*?):(\d+)/) { + if ($type ne "") { # skip unnamed bit-fields + save_struct_actual($1); + push_parameter($1, "$type:$2", $file) + } + } + else { + save_struct_actual($param); + push_parameter($param, $type, $file); + } + } + } + } +} + +sub push_parameter($$$) { + my $param = shift; + my $type = shift; + my $file = shift; + + if (($anon_struct_union == 1) && ($type eq "") && + ($param eq "}")) { + return; # ignore the ending }; from anon. struct/union + } + + $anon_struct_union = 0; + my $param_name = $param; + $param_name =~ s/\[.*//; + + if ($type eq "" && $param =~ /\.\.\.$/) + { + if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") { + $parameterdescs{$param} = "variable arguments"; + } + } + elsif ($type eq "" && ($param eq "" or $param eq "void")) + { + $param="void"; + $parameterdescs{void} = "no arguments"; + } + elsif ($type eq "" && ($param eq "struct" or $param eq "union")) + # handle unnamed (anonymous) union or struct: + { + $type = $param; + $param = "{unnamed_" . $param . "}"; + $parameterdescs{$param} = "anonymous\n"; + $anon_struct_union = 1; + } + + # warn if parameter has no description + # (but ignore ones starting with # as these are not parameters + # but inline preprocessor statements); + # also ignore unnamed structs/unions; + if (!$anon_struct_union) { + if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { + + $parameterdescs{$param_name} = $undescribed; + + if (($type eq 'function') || ($type eq 'enum')) { + print STDERR "Warning(${file}:$.): Function parameter ". + "or member '$param' not " . + "described in '$declaration_name'\n"; + } + print STDERR "Warning(${file}:$.):" . + " No description found for parameter '$param'\n"; + ++$warnings; + } + } + + # strip spaces from $param so that it is one continous string + # on @parameterlist; + # this fixes a problem where check_sections() cannot find + # a parameter like "addr[6 + 2]" because it actually appears + # as "addr[6", "+", "2]" on the parameter list; + # but it's better to maintain the param string unchanged for output, + # so just weaken the string compare in check_sections() to ignore + # "[blah" in a parameter string; + ###$param =~ s/\s*//g; + push @parameterlist, $param; + $parametertypes{$param} = $type; +} + +sub check_sections($$$$$$) { + my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck, $nested) = @_; + my @sects = split ' ', $sectcheck; + my @prms = split ' ', $prmscheck; + my $err; + my ($px, $sx); + my $prm_clean; # strip trailing "[array size]" and/or beginning "*" + + foreach $sx (0 .. $#sects) { + $err = 1; + foreach $px (0 .. $#prms) { + $prm_clean = $prms[$px]; + $prm_clean =~ s/\[.*\]//; + $prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//; + # ignore array size in a parameter string; + # however, the original param string may contain + # spaces, e.g.: addr[6 + 2] + # and this appears in @prms as "addr[6" since the + # parameter list is split at spaces; + # hence just ignore "[..." for the sections check; + $prm_clean =~ s/\[.*//; + + ##$prm_clean =~ s/^\**//; + if ($prm_clean eq $sects[$sx]) { + $err = 0; + last; + } + } + if ($err) { + if ($decl_type eq "function") { + print STDERR "Warning(${file}:$.): " . + "Excess function parameter " . + "'$sects[$sx]' " . + "description in '$decl_name'\n"; + ++$warnings; + } else { + if ($nested !~ m/\Q$sects[$sx]\E/) { + print STDERR "Warning(${file}:$.): " . + "Excess struct/union/enum/typedef member " . + "'$sects[$sx]' " . + "description in '$decl_name'\n"; + ++$warnings; + } + } + } + } +} + +## +# takes a function prototype and the name of the current file being +# processed and spits out all the details stored in the global +# arrays/hashes. +sub dump_function($$) { + my $prototype = shift; + my $file = shift; + + $prototype =~ s/^static +//; + $prototype =~ s/^extern +//; + $prototype =~ s/^asmlinkage +//; + $prototype =~ s/^inline +//; + $prototype =~ s/^__inline__ +//; + $prototype =~ s/^__inline +//; + $prototype =~ s/^__always_inline +//; + $prototype =~ s/^noinline +//; + $prototype =~ s/__devinit +//; + $prototype =~ s/__init +//; + $prototype =~ s/^#\s*define\s+//; #ak added + $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; + + # Yes, this truly is vile. We are looking for: + # 1. Return type (may be nothing if we're looking at a macro) + # 2. Function name + # 3. Function parameters. + # + # All the while we have to watch out for function pointer parameters + # (which IIRC is what the two sections are for), C types (these + # regexps don't even start to express all the possibilities), and + # so on. + # + # If you mess with these regexps, it's a good idea to check that + # the following functions' documentation still comes out right: + # - parport_register_device (function pointer parameters) + # - atomic_set (macro) + # - pci_match_device, __copy_to_user (long return type) + + if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || + $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { + $return_type = $1; + $declaration_name = $2; + my $args = $3; + + create_parameterlist($args, ',', $file); + } else { + print STDERR "Error(${file}:$.): cannot understand prototype: '$prototype'\n"; + ++$errors; + return; + } + + my $prms = join " ", @parameterlist; + check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); + + output_declaration($declaration_name, + 'function', + {'function' => $declaration_name, + 'module' => $modulename, + 'functiontype' => $return_type, + 'parameterlist' => \@parameterlist, + 'parameterdescs' => \%parameterdescs, + 'parametertypes' => \%parametertypes, + 'sectionlist' => \@sectionlist, + 'sections' => \%sections, + 'purpose' => $declaration_purpose + }); +} + +sub process_file($); + +# Read the file that maps relative names to absolute names for +# separate source and object directories and for shadow trees. +if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { + my ($relname, $absname); + while() { + chop(); + ($relname, $absname) = (split())[0..1]; + $relname =~ s:^/+::; + $source_map{$relname} = $absname; + } + close(SOURCE_MAP); +} + +if ($filelist) { + open(FLIST,"<$filelist") or die "Can't open file list $filelist"; + while() { + chop; + process_file($_); + } +} + +foreach (@ARGV) { + chomp; + process_file($_); +} +if ($verbose && $errors) { + print STDERR "$errors errors\n"; +} +if ($verbose && $warnings) { + print STDERR "$warnings warnings\n"; +} + +exit($errors); + +sub reset_state { + $function = ""; + %constants = (); + %parameterdescs = (); + %parametertypes = (); + @parameterlist = (); + %sections = (); + @sectionlist = (); + $sectcheck = ""; + $struct_actual = ""; + $prototype = ""; + + $state = 0; +} + +sub tracepoint_munge($) { + my $file = shift; + my $tracepointname = 0; + my $tracepointargs = 0; + + if ($prototype =~ m/TRACE_EVENT\((.*?),/) { + $tracepointname = $1; + } + if ($prototype =~ m/DEFINE_SINGLE_EVENT\((.*?),/) { + $tracepointname = $1; + } + if ($prototype =~ m/DEFINE_EVENT\((.*?),(.*?),/) { + $tracepointname = $2; + } + $tracepointname =~ s/^\s+//; #strip leading whitespace + if ($prototype =~ m/TP_PROTO\((.*?)\)/) { + $tracepointargs = $1; + } + if (($tracepointname eq 0) || ($tracepointargs eq 0)) { + print STDERR "Warning(${file}:$.): Unrecognized tracepoint format: \n". + "$prototype\n"; + } else { + $prototype = "static inline void trace_$tracepointname($tracepointargs)"; + } +} + +sub syscall_munge() { + my $void = 0; + + $prototype =~ s@[\r\n\t]+@ @gos; # strip newlines/CR's/tabs +## if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) { + if ($prototype =~ m/SYSCALL_DEFINE0/) { + $void = 1; +## $prototype = "long sys_$1(void)"; + } + + $prototype =~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func name + if ($prototype =~ m/long (sys_.*?),/) { + $prototype =~ s/,/\(/; + } elsif ($void) { + $prototype =~ s/\)/\(void\)/; + } + + # now delete all of the odd-number commas in $prototype + # so that arg types & arg names don't have a comma between them + my $count = 0; + my $len = length($prototype); + if ($void) { + $len = 0; # skip the for-loop + } + for (my $ix = 0; $ix < $len; $ix++) { + if (substr($prototype, $ix, 1) eq ',') { + $count++; + if ($count % 2 == 1) { + substr($prototype, $ix, 1) = ' '; + } + } + } +} + +sub process_state3_function($$) { + my $x = shift; + my $file = shift; + + $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line + + if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#\s*define/)) { + # do nothing + } + elsif ($x =~ /([^\{]*)/) { + $prototype .= $1; + } + + if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) { + $prototype =~ s@/\*.*?\*/@@gos; # strip comments. + $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. + $prototype =~ s@^\s+@@gos; # strip leading spaces + if ($prototype =~ /SYSCALL_DEFINE/) { + syscall_munge(); + } + if ($prototype =~ /TRACE_EVENT/ || $prototype =~ /DEFINE_EVENT/ || + $prototype =~ /DEFINE_SINGLE_EVENT/) + { + tracepoint_munge($file); + } + dump_function($prototype, $file); + reset_state(); + } +} + +sub process_state3_type($$) { + my $x = shift; + my $file = shift; + + $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's. + $x =~ s@^\s+@@gos; # strip leading spaces + $x =~ s@\s+$@@gos; # strip trailing spaces + $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line + + if ($x =~ /^#/) { + # To distinguish preprocessor directive from regular declaration later. + $x .= ";"; + } + + while (1) { + if ( $x =~ /([^{};]*)([{};])(.*)/ ) { + $prototype .= $1 . $2; + ($2 eq '{') && $brcount++; + ($2 eq '}') && $brcount--; + if (($2 eq ';') && ($brcount == 0)) { + dump_declaration($prototype, $file); + reset_state(); + last; + } + $x = $3; + } else { + $prototype .= $x; + last; + } + } +} + +# xml_escape: replace <, >, and & in the text stream; +# +# however, formatting controls that are generated internally/locally in the +# kernel-doc script are not escaped here; instead, they begin life like +# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings +# are converted to their mnemonic-expected output, without the 4 * '\' & ':', +# just before actual output; (this is done by local_unescape()) +sub xml_escape($) { + my $text = shift; + if (($output_mode eq "text") || ($output_mode eq "man")) { + return $text; + } + $text =~ s/\&/\\\\\\amp;/g; + $text =~ s/\/\\\\\\gt;/g; + return $text; +} + +# convert local escape strings to html +# local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) +sub local_unescape($) { + my $text = shift; + if (($output_mode eq "text") || ($output_mode eq "man")) { + return $text; + } + $text =~ s/\\\\\\\\lt://g; + return $text; +} + +sub process_file($) { + my $file; + my $identifier; + my $func; + my $descr; + my $in_purpose = 0; + my $initial_section_counter = $section_counter; + + if (defined($ENV{'SRCTREE'})) { + $file = "$ENV{'SRCTREE'}" . "/" . "@_"; + } + else { + $file = "@_"; + } + if (defined($source_map{$file})) { + $file = $source_map{$file}; + } + + if (!open(IN,"<$file")) { + print STDERR "Error: Cannot open file $file\n"; + ++$errors; + return; + } + + $section_counter = 0; + while () { + if ($state == 0) { + if (/$doc_start/o) { + $state = 1; # next line is always the function name + $in_doc_sect = 0; + } + } elsif ($state == 1) { # this line is the function name (always) + if (/$doc_block/o) { + $state = 4; + $contents = ""; + if ( $1 eq "" ) { + $section = $section_intro; + } else { + $section = $1; + } + } + elsif (/$doc_decl/o) { + $identifier = $1; + if (/\s*([\w\s]+?)\s*-/) { + $identifier = $1; + } + + $state = 2; + if (/-(.*)/) { + # strip leading/trailing/multiple spaces + $descr= $1; + $descr =~ s/^\s*//; + $descr =~ s/\s*$//; + $descr =~ s/\s+/ /; + $declaration_purpose = xml_escape($descr); + $in_purpose = 1; + } else { + $declaration_purpose = ""; + } + + if (($declaration_purpose eq "") && $verbose) { + print STDERR "Warning(${file}:$.): missing initial short description on line:\n"; + print STDERR $_; + ++$warnings; + } + + if ($identifier =~ m/^struct/) { + $decl_type = 'struct'; + } elsif ($identifier =~ m/^union/) { + $decl_type = 'union'; + } elsif ($identifier =~ m/^enum/) { + $decl_type = 'enum'; + } elsif ($identifier =~ m/^typedef/) { + $decl_type = 'typedef'; + } else { + $decl_type = 'function'; + } + + if ($verbose) { + print STDERR "Info(${file}:$.): Scanning doc for $identifier\n"; + } + } else { + print STDERR "Warning(${file}:$.): Cannot understand $_ on line $.", + " - I thought it was a doc line\n"; + ++$warnings; + $state = 0; + } + } elsif ($state == 2) { # look for head: lines, and include content + if (/$doc_sect/o) { + $newsection = $1; + $newcontents = $2; + + if (($contents ne "") && ($contents ne "\n")) { + if (!$in_doc_sect && $verbose) { + print STDERR "Warning(${file}:$.): contents before sections\n"; + ++$warnings; + } + dump_section($file, $section, xml_escape($contents)); + $section = $section_default; + } + + $in_doc_sect = 1; + $in_purpose = 0; + $contents = $newcontents; + if ($contents ne "") { + while ((substr($contents, 0, 1) eq " ") || + substr($contents, 0, 1) eq "\t") { + $contents = substr($contents, 1); + } + $contents .= "\n"; + } + $section = $newsection; + } elsif (/$doc_end/) { + + if ($contents ne "") { + dump_section($file, $section, xml_escape($contents)); + $section = $section_default; + $contents = ""; + } + # look for doc_com + + doc_end: + if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') { + print STDERR "Warning(${file}:$.): suspicious ending line: $_"; + ++$warnings; + } + + $prototype = ""; + $state = 3; + $brcount = 0; +# print STDERR "end of doc comment, looking for prototype\n"; + } elsif (/$doc_content/) { + # miguel-style comment kludge, look for blank lines after + # @parameter line to signify start of description + if ($1 eq "") { + if ($section =~ m/^@/ || $section eq $section_context) { + dump_section($file, $section, xml_escape($contents)); + $section = $section_default; + $contents = ""; + } else { + $contents .= "\n"; + } + $in_purpose = 0; + } elsif ($in_purpose == 1) { + # Continued declaration purpose + chomp($declaration_purpose); + $declaration_purpose .= " " . xml_escape($1); + } else { + $contents .= $1 . "\n"; + } + } else { + # i dont know - bad line? ignore. + print STDERR "Warning(${file}:$.): bad line: $_"; + ++$warnings; + } + } elsif ($state == 3) { # scanning for function '{' (end of prototype) + if ($decl_type eq 'function') { + process_state3_function($_, $file); + } else { + process_state3_type($_, $file); + } + } elsif ($state == 4) { + # Documentation block + if (/$doc_block/) { + dump_doc_section($file, $section, xml_escape($contents)); + $contents = ""; + $function = ""; + %constants = (); + %parameterdescs = (); + %parametertypes = (); + @parameterlist = (); + %sections = (); + @sectionlist = (); + $prototype = ""; + if ( $1 eq "" ) { + $section = $section_intro; + } else { + $section = $1; + } + } + elsif (/$doc_end/) + { + dump_doc_section($file, $section, xml_escape($contents)); + $contents = ""; + $function = ""; + %constants = (); + %parameterdescs = (); + %parametertypes = (); + @parameterlist = (); + %sections = (); + @sectionlist = (); + $prototype = ""; + $state = 0; + } + elsif (/$doc_content/) + { + if ( $1 eq "" ) + { + $contents .= $blankline; + } + else + { + $contents .= $1 . "\n"; + } + } + } + } + if ($initial_section_counter == $section_counter) { + print STDERR "Warning(${file}): no structured comments found\n"; + if ($output_mode eq "xml") { + # The template wants at least one RefEntry here; make one. + print "\n"; + print " \n"; + print " \n"; + print " ${file}\n"; + print " \n"; + print " \n"; + print " Document generation inconsistency\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " Oops\n"; + print " \n"; + print " \n"; + print " \n"; + print " The template for this document tried to insert\n"; + print " the structured comment from the file\n"; + print " ${file} at this point,\n"; + print " but none was found.\n"; + print " This dummy section is inserted to allow\n"; + print " generation to continue.\n"; + print " \n"; + print " \n"; + print " \n"; + print "\n"; + } + } +} diff --git a/libs/libwebsockets/test-server/Makefile.am b/libs/libwebsockets/test-server/Makefile.am new file mode 100644 index 0000000000..77ee02c370 --- /dev/null +++ b/libs/libwebsockets/test-server/Makefile.am @@ -0,0 +1,61 @@ +bin_PROGRAMS=libwebsockets-test-server libwebsockets-test-client libwebsockets-test-server-extpoll libwebsockets-test-fraggle +libwebsockets_test_server_SOURCES=test-server.c +libwebsockets_test_server_LDADD=-L../lib -lwebsockets -lz +libwebsockets_test_client_SOURCES=test-client.c +libwebsockets_test_client_LDADD=-L../lib -lwebsockets -lz +libwebsockets_test_server_extpoll_SOURCES=test-server-extpoll.c +libwebsockets_test_server_extpoll_LDADD=-L../lib -lwebsockets -lz +libwebsockets_test_fraggle_SOURCES=test-fraggle.c +libwebsockets_test_fraggle_LDADD=-L../lib -lwebsockets -lz + +if MINGW +libwebsockets_test_server_CFLAGS= -w -I../win32port/win32helpers +libwebsockets_test_client_CFLAGS= -w -I../win32port/win32helpers +libwebsockets_test_server_extpoll_CFLAGS= -w -I../win32port/win32helpers +libwebsockets_test_fraggle_CFLAGS= -w -I../win32port/win32helpers + +libwebsockets_test_server_LDADD+= -lm -luser32 -ladvapi32 -lkernel32 -lgcc -lws2_32 -lz +libwebsockets_test_client_LDADD+= -lm -luser32 -ladvapi32 -lkernel32 -lgcc -lws2_32 -lz +libwebsockets_test_server_extpoll_LDADD+= -lm -luser32 -ladvapi32 -lkernel32 -lgcc -lws2_32 -lz +libwebsockets_test_fraggle_LDADD+= -lm -luser32 -ladvapi32 -lkernel32 -lgcc -lws2_32 -lz + +else +libwebsockets_test_server_CFLAGS= -Werror +libwebsockets_test_client_CFLAGS= -Werror +libwebsockets_test_server_extpoll_CFLAGS= -Werror +libwebsockets_test_fraggle_CFLAGS= -Werror +endif + +libwebsockets_test_server_CFLAGS+= -Wall -std=gnu99 -pedantic -DINSTALL_DATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" +libwebsockets_test_client_CFLAGS+= -Wall -std=gnu99 -pedantic -DINSTALL_DATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" +libwebsockets_test_server_extpoll_CFLAGS+= -Wall -std=gnu99 -pedantic -DINSTALL_DATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" +libwebsockets_test_fraggle_CFLAGS+= -Wall -std=gnu99 -pedantic -DINSTALL_DATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" + + +if NOPING +else +bin_PROGRAMS+=libwebsockets-test-ping +libwebsockets_test_ping_SOURCES=test-ping.c +libwebsockets_test_ping_LDADD=-L../lib -lwebsockets +libwebsockets_test_ping_CFLAGS= -Wall -Werror -std=gnu99 -pedantic -DINSTALL_DATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\" +endif + + +# +# cook a random test cert and key +# notice your real cert and key will want to be 0600 permissions +libwebsockets-test-server.pem libwebsockets-test-server.key.pem: + printf "GB\nErewhon\nAll around\nlibwebsockets-test\n\nlocalhost\nnone@invalid.org\n" | \ + openssl req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout \ + ./libwebsockets-test-server.key.pem -out ./libwebsockets-test-server.pem >/dev/null 2>&1 && \ + chmod 644 ./libwebsockets-test-server.key.pem \ + ./libwebsockets-test-server.pem + +clean-local: + rm -f ./libwebsockets-test-server.key.pem ./libwebsockets-test-server.pem + +install-data-local:libwebsockets-test-server.key.pem libwebsockets-test-server.pem + mkdir -p $(DESTDIR)$(datadir)/libwebsockets-test-server + cp -a test.html favicon.ico libwebsockets-test-server.key.pem libwebsockets-test-server.pem \ + $(DESTDIR)$(datadir)/libwebsockets-test-server + diff --git a/libs/libwebsockets/test-server/favicon.ico b/libs/libwebsockets/test-server/favicon.ico new file mode 100644 index 0000000000..c0cc2e3dff Binary files /dev/null and b/libs/libwebsockets/test-server/favicon.ico differ diff --git a/libs/libwebsockets/test-server/test-client.c b/libs/libwebsockets/test-server/test-client.c new file mode 100644 index 0000000000..ffd636569b --- /dev/null +++ b/libs/libwebsockets/test-server/test-client.c @@ -0,0 +1,341 @@ +/* + * libwebsockets-test-client - libwebsockets test implementation + * + * Copyright (C) 2011 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include + +#include "../lib/libwebsockets.h" + +static unsigned int opts; +static int was_closed; +static int deny_deflate; +static int deny_mux; +static struct libwebsocket *wsi_mirror; + +/* + * This demo shows how to connect multiple websockets simultaneously to a + * websocket server (there is no restriction on their having to be the same + * server just it simplifies the demo). + * + * dumb-increment-protocol: we connect to the server and print the number + * we are given + * + * lws-mirror-protocol: draws random circles, which are mirrored on to every + * client (see them being drawn in every browser + * session also using the test server) + */ + +enum demo_protocols { + + PROTOCOL_DUMB_INCREMENT, + PROTOCOL_LWS_MIRROR, + + /* always last */ + DEMO_PROTOCOL_COUNT +}; + + +/* dumb_increment protocol */ + +static int +callback_dumb_increment(struct libwebsocket_context *this, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + switch (reason) { + + case LWS_CALLBACK_CLOSED: + fprintf(stderr, "LWS_CALLBACK_CLOSED\n"); + was_closed = 1; + break; + + case LWS_CALLBACK_CLIENT_RECEIVE: + ((char *)in)[len] = '\0'; + fprintf(stderr, "rx %d '%s'\n", (int)len, (char *)in); + break; + + /* because we are protocols[0] ... */ + + case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: + if ((strcmp(in, "deflate-stream") == 0) && deny_deflate) { + fprintf(stderr, "denied deflate-stream extension\n"); + return 1; + } + if ((strcmp(in, "x-google-mux") == 0) && deny_mux) { + fprintf(stderr, "denied x-google-mux extension\n"); + return 1; + } + + break; + + default: + break; + } + + return 0; +} + + +/* lws-mirror_protocol */ + + +static int +callback_lws_mirror(struct libwebsocket_context *this, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 + + LWS_SEND_BUFFER_POST_PADDING]; + int l; + + switch (reason) { + + case LWS_CALLBACK_CLOSED: + fprintf(stderr, "mirror: LWS_CALLBACK_CLOSED\n"); + wsi_mirror = NULL; + break; + + case LWS_CALLBACK_CLIENT_ESTABLISHED: + + /* + * start the ball rolling, + * LWS_CALLBACK_CLIENT_WRITEABLE will come next service + */ + + libwebsocket_callback_on_writable(this, wsi); + break; + + case LWS_CALLBACK_CLIENT_RECEIVE: +/* fprintf(stderr, "rx %d '%s'\n", (int)len, (char *)in); */ + break; + + case LWS_CALLBACK_CLIENT_WRITEABLE: + + l = sprintf((char *)&buf[LWS_SEND_BUFFER_PRE_PADDING], + "c #%06X %d %d %d;", + (int)random() & 0xffffff, + (int)random() % 500, + (int)random() % 250, + (int)random() % 24); + + libwebsocket_write(wsi, + &buf[LWS_SEND_BUFFER_PRE_PADDING], l, opts | LWS_WRITE_TEXT); + + /* get notified as soon as we can write again */ + + libwebsocket_callback_on_writable(this, wsi); + + /* + * without at least this delay, we choke the browser + * and the connection stalls, despite we now take care about + * flow control + */ + + usleep(200); + break; + + default: + break; + } + + return 0; +} + + +/* list of supported protocols and callbacks */ + +static struct libwebsocket_protocols protocols[] = { + { + "dumb-increment-protocol", + callback_dumb_increment, + 0, + }, + { + "lws-mirror-protocol", + callback_lws_mirror, + 0, + }, + { /* end of list */ + NULL, + NULL, + 0 + } +}; + +static struct option options[] = { + { "help", no_argument, NULL, 'h' }, + { "port", required_argument, NULL, 'p' }, + { "ssl", no_argument, NULL, 's' }, + { "killmask", no_argument, NULL, 'k' }, + { "version", required_argument, NULL, 'v' }, + { "undeflated", no_argument, NULL, 'u' }, + { "nomux", no_argument, NULL, 'n' }, + { NULL, 0, 0, 0 } +}; + + +int main(int argc, char **argv) +{ + int n = 0; + int port = 7681; + int use_ssl = 0; + struct libwebsocket_context *context; + const char *address; + struct libwebsocket *wsi_dumb; + int ietf_version = -1; /* latest */ + int mirror_lifetime = 0; + + fprintf(stderr, "libwebsockets test client\n" + "(C) Copyright 2010 Andy Green " + "licensed under LGPL2.1\n"); + + if (argc < 2) + goto usage; + + while (n >= 0) { + n = getopt_long(argc, argv, "nuv:khsp:", options, NULL); + if (n < 0) + continue; + switch (n) { + case 's': + use_ssl = 2; /* 2 = allow selfsigned */ + break; + case 'p': + port = atoi(optarg); + break; + case 'k': + opts = LWS_WRITE_CLIENT_IGNORE_XOR_MASK; + break; + case 'v': + ietf_version = atoi(optarg); + break; + case 'u': + deny_deflate = 1; + break; + case 'n': + deny_mux = 1; + break; + case 'h': + goto usage; + } + } + + if (optind >= argc) + goto usage; + + address = argv[optind]; + + /* + * create the websockets context. This tracks open connections and + * knows how to route any traffic and which protocol version to use, + * and if each connection is client or server side. + * + * For this client-only demo, we tell it to not listen on any port. + */ + + context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL, + protocols, libwebsocket_internal_extensions, + NULL, NULL, -1, -1, 0); + if (context == NULL) { + fprintf(stderr, "Creating libwebsocket context failed\n"); + return 1; + } + + + /* create a client websocket using dumb increment protocol */ + + wsi_dumb = libwebsocket_client_connect(context, address, port, use_ssl, + "/", argv[optind], argv[optind], + protocols[PROTOCOL_DUMB_INCREMENT].name, ietf_version); + + if (wsi_dumb == NULL) { + fprintf(stderr, "libwebsocket dumb connect failed\n"); + return -1; + } + + fprintf(stderr, "Websocket connections opened\n"); + + /* + * sit there servicing the websocket context to handle incoming + * packets, and drawing random circles on the mirror protocol websocket + */ + + n = 0; + while (n >= 0 && !was_closed) { + n = libwebsocket_service(context, 1000); + + if (n < 0) + continue; + + if (wsi_mirror == NULL) { + + /* create a client websocket using mirror protocol */ + + wsi_mirror = libwebsocket_client_connect(context, + address, port, use_ssl, "/", + argv[optind], argv[optind], + protocols[PROTOCOL_LWS_MIRROR].name, + ietf_version); + + if (wsi_mirror == NULL) { + fprintf(stderr, "libwebsocket " + "dumb connect failed\n"); + return -1; + } + + mirror_lifetime = 10 + (random() & 1023); + + fprintf(stderr, "opened mirror connection with " + "%d lifetime\n", mirror_lifetime); + + } else { + + mirror_lifetime--; + if (mirror_lifetime == 0) { + fprintf(stderr, "closing mirror session\n"); + libwebsocket_close_and_free_session(context, + wsi_mirror, LWS_CLOSE_STATUS_GOINGAWAY); + + /* + * wsi_mirror will get set to NULL in + * callback when close completes + */ + } + } + } + + fprintf(stderr, "Exiting\n"); + + libwebsocket_context_destroy(context); + + return 0; + +usage: + fprintf(stderr, "Usage: libwebsockets-test-client " + " [--port=

] " + "[--ssl] [-k] [-v ]\n"); + return 1; +} diff --git a/libs/libwebsockets/test-server/test-fraggle.c b/libs/libwebsockets/test-server/test-fraggle.c new file mode 100644 index 0000000000..1c77d59fe8 --- /dev/null +++ b/libs/libwebsockets/test-server/test-fraggle.c @@ -0,0 +1,333 @@ +/* + * libwebsockets-test-fraggle - random fragmentation test + * + * Copyright (C) 2010-2011 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include + +#include "../lib/libwebsockets.h" + +#define LOCAL_RESOURCE_PATH INSTALL_DATADIR"/libwebsockets-test-server" + +static int client; +static int terminate; + +enum demo_protocols { + PROTOCOL_FRAGGLE, + + /* always last */ + DEMO_PROTOCOL_COUNT +}; + +/* fraggle protocol */ + +enum fraggle_states { + FRAGSTATE_START_MESSAGE, + FRAGSTATE_RANDOM_PAYLOAD, + FRAGSTATE_POST_PAYLOAD_SUM, +}; + +struct per_session_data__fraggle { + int packets_left; + int total_message; + unsigned long sum; + enum fraggle_states state; +}; + +static int +callback_fraggle(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + int n; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 2048 + + LWS_SEND_BUFFER_POST_PADDING]; + struct per_session_data__fraggle *psf = user; + int chunk; + int write_mode = LWS_WRITE_CONTINUATION; + unsigned long sum; + unsigned char *p = (unsigned char *)in; + unsigned char *bp = &buf[LWS_SEND_BUFFER_PRE_PADDING]; + + switch (reason) { + + case LWS_CALLBACK_ESTABLISHED: + + fprintf(stderr, "server sees client connect\n"); + psf->state = FRAGSTATE_START_MESSAGE; + /* start the ball rolling */ + libwebsocket_callback_on_writable(context, wsi); + break; + + case LWS_CALLBACK_CLIENT_ESTABLISHED: + + fprintf(stderr, "client connects to server\n"); + psf->state = FRAGSTATE_START_MESSAGE; + break; + + case LWS_CALLBACK_CLIENT_RECEIVE: + + switch (psf->state) { + + case FRAGSTATE_START_MESSAGE: + + psf->state = FRAGSTATE_RANDOM_PAYLOAD; + psf->sum = 0; + psf->total_message = 0; + psf->packets_left = 0; + + /* fallthru */ + + case FRAGSTATE_RANDOM_PAYLOAD: + + for (n = 0; n < len; n++) + psf->sum += p[n]; + + psf->total_message += len; + psf->packets_left++; + + if (libwebsocket_is_final_fragment(wsi)) + psf->state = FRAGSTATE_POST_PAYLOAD_SUM; + break; + + case FRAGSTATE_POST_PAYLOAD_SUM: + + sum = p[0] << 24; + sum |= p[1] << 16; + sum |= p[2] << 8; + sum |= p[3]; + if (sum == psf->sum) + fprintf(stderr, "EOM received %d correctly " + "from %d fragments\n", + psf->total_message, psf->packets_left); + else + fprintf(stderr, "**** ERROR at EOM: " + "length %d, rx sum = 0x%lX, " + "server says it sent 0x%lX\n", + psf->total_message, psf->sum, sum); + + psf->state = FRAGSTATE_START_MESSAGE; + break; + } + break; + + case LWS_CALLBACK_SERVER_WRITEABLE: + + switch (psf->state) { + + case FRAGSTATE_START_MESSAGE: + + psf->packets_left = (random() % 1024) + 1; + fprintf(stderr, "Spamming %d random fragments\n", + psf->packets_left); + psf->sum = 0; + psf->total_message = 0; + write_mode = LWS_WRITE_BINARY; + psf->state = FRAGSTATE_RANDOM_PAYLOAD; + + /* fallthru */ + + case FRAGSTATE_RANDOM_PAYLOAD: + + chunk = (random() % 2000) + 1; + psf->total_message += chunk; + + libwebsockets_get_random(context, bp, chunk); + for (n = 0; n < chunk; n++) + psf->sum += bp[n]; + + psf->packets_left--; + if (psf->packets_left) + write_mode |= LWS_WRITE_NO_FIN; + else + psf->state = FRAGSTATE_POST_PAYLOAD_SUM; + + n = libwebsocket_write(wsi, bp, chunk, write_mode); + + libwebsocket_callback_on_writable(context, wsi); + break; + + case FRAGSTATE_POST_PAYLOAD_SUM: + + fprintf(stderr, "Spamming session over, " + "len = %d. sum = 0x%lX\n", + psf->total_message, psf->sum); + + bp[0] = psf->sum >> 24; + bp[1] = psf->sum >> 16; + bp[2] = psf->sum >> 8; + bp[3] = psf->sum; + + n = libwebsocket_write(wsi, (unsigned char *)bp, + 4, LWS_WRITE_BINARY); + + psf->state = FRAGSTATE_START_MESSAGE; + + libwebsocket_callback_on_writable(context, wsi); + break; + } + break; + + case LWS_CALLBACK_CLOSED: + + terminate = 1; + break; + + /* because we are protocols[0] ... */ + + case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: + if (strcmp(in, "deflate-stream") == 0) { + fprintf(stderr, "denied deflate-stream extension\n"); + return 1; + } + break; + + default: + break; + } + + return 0; +} + + + +/* list of supported protocols and callbacks */ + +static struct libwebsocket_protocols protocols[] = { + { + "fraggle-protocol", + callback_fraggle, + sizeof(struct per_session_data__fraggle), + }, + { + NULL, NULL, 0 /* End of list */ + } +}; + +static struct option options[] = { + { "help", no_argument, NULL, 'h' }, + { "port", required_argument, NULL, 'p' }, + { "ssl", no_argument, NULL, 's' }, + { "killmask", no_argument, NULL, 'k' }, + { "interface", required_argument, NULL, 'i' }, + { "client", no_argument, NULL, 'c' }, + { NULL, 0, 0, 0 } +}; + +int main(int argc, char **argv) +{ + int n = 0; + const char *cert_path = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; + const char *key_path = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; + int port = 7681; + int use_ssl = 0; + struct libwebsocket_context *context; + int opts = 0; + char interface_name[128] = ""; + const char *interface = NULL; + struct libwebsocket *wsi; + const char *address; + int server_port = port; + + fprintf(stderr, "libwebsockets test fraggle\n" + "(C) Copyright 2010-2011 Andy Green " + "licensed under LGPL2.1\n"); + + while (n >= 0) { + n = getopt_long(argc, argv, "ci:khsp:", options, NULL); + if (n < 0) + continue; + switch (n) { + case 's': + use_ssl = 1; + break; + case 'k': + opts = LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK; + break; + case 'p': + port = atoi(optarg); + server_port = port; + break; + case 'i': + strncpy(interface_name, optarg, sizeof interface_name); + interface_name[(sizeof interface_name) - 1] = '\0'; + interface = interface_name; + break; + case 'c': + client = 1; + fprintf(stderr, " Client mode\n"); + break; + case 'h': + fprintf(stderr, "Usage: libwebsockets-test-fraggle " + "[--port=

] [--ssl] [--client]\n"); + exit(1); + } + } + + if (client) { + server_port = CONTEXT_PORT_NO_LISTEN; + if (optind >= argc) { + fprintf(stderr, "Must give address of server\n"); + return 1; + } + } + + if (!use_ssl) + cert_path = key_path = NULL; + + context = libwebsocket_create_context(server_port, interface, protocols, + libwebsocket_internal_extensions, + cert_path, key_path, -1, -1, opts); + if (context == NULL) { + fprintf(stderr, "libwebsocket init failed\n"); + return -1; + } + + if (client) { + address = argv[optind]; + fprintf(stderr, "Connecting to %s:%u\n", address, port); + wsi = libwebsocket_client_connect(context, address, + port, use_ssl, "/", address, + "origin", protocols[PROTOCOL_FRAGGLE].name, + -1); + if (wsi == NULL) { + fprintf(stderr, "Client connect to server failed\n"); + goto bail; + } + } + + n = 0; + while (!n && !terminate) + n = libwebsocket_service(context, 50); + + fprintf(stderr, "Terminating...\n"); + +bail: + libwebsocket_context_destroy(context); + + return 0; +} diff --git a/libs/libwebsockets/test-server/test-ping.c b/libs/libwebsockets/test-server/test-ping.c new file mode 100644 index 0000000000..672f62cc0d --- /dev/null +++ b/libs/libwebsockets/test-server/test-ping.c @@ -0,0 +1,512 @@ +/* + * libwebsockets-test-ping - libwebsockets floodping + * + * Copyright (C) 2011 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "../lib/libwebsockets.h" +#include + +/* + * this is specified in the 04 standard, control frames can only have small + * payload length styles + */ +#define MAX_PING_PAYLOAD 125 +#define MAX_MIRROR_PAYLOAD 4096 +#define MAX_PING_CLIENTS 256 +#define PING_RINGBUFFER_SIZE 256 + +static struct libwebsocket *ping_wsi[MAX_PING_CLIENTS]; +static unsigned int interval_us = 1000000; +static unsigned int size = 64; +static int flood; +static const char *address; +static unsigned char pingbuf[LWS_SEND_BUFFER_PRE_PADDING + MAX_MIRROR_PAYLOAD + + LWS_SEND_BUFFER_POST_PADDING]; +static char peer_name[128]; +static unsigned long started; +static int screen_width = 80; +static int use_mirror; +static unsigned int write_options; + +static unsigned long rtt_min = 100000000; +static unsigned long rtt_max; +static unsigned long rtt_avg; +static unsigned long global_rx_count; +static unsigned long global_tx_count; +static int clients = 1; +static unsigned long interrupted_time; + +struct ping { + unsigned long issue_timestamp; + unsigned long index; + unsigned int seen; +}; + +struct per_session_data__ping { + unsigned long ping_index; + + struct ping ringbuffer[PING_RINGBUFFER_SIZE]; + int ringbuffer_head; + int ringbuffer_tail; + + unsigned long rx_count; +}; + +/* + * uses the ping pong protocol features to provide an equivalent for the + * ping utility for 04+ websockets + */ + +enum demo_protocols { + + PROTOCOL_LWS_MIRROR, + + /* always last */ + DEMO_PROTOCOL_COUNT +}; + + +static int +callback_lws_mirror(struct libwebsocket_context * this, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + struct timeval tv; + unsigned char *p; + int shift; + unsigned long l; + unsigned long iv; + int n; + int match = 0; + struct per_session_data__ping *psd = user; + + switch (reason) { + case LWS_CALLBACK_CLOSED: + + fprintf(stderr, "LWS_CALLBACK_CLOSED on %p\n", (void *)wsi); + + /* remove closed guy */ + + for (n = 0; n < clients; n++) + if (ping_wsi[n] == wsi) { + clients--; + while (n < clients) { + ping_wsi[n] = ping_wsi[n + 1]; + n++; + } + } + + break; + + case LWS_CALLBACK_CLIENT_ESTABLISHED: + + psd->rx_count = 0; + psd->ping_index = 1; + psd->ringbuffer_head = 0; + psd->ringbuffer_tail = 0; + + /* + * start the ball rolling, + * LWS_CALLBACK_CLIENT_WRITEABLE will come next service + */ + + libwebsocket_callback_on_writable(this, wsi); + break; + + case LWS_CALLBACK_CLIENT_RECEIVE: + case LWS_CALLBACK_CLIENT_RECEIVE_PONG: + gettimeofday(&tv, NULL); + iv = (tv.tv_sec * 1000000) + tv.tv_usec; + + psd->rx_count++; + + shift = 56; + p = in; + l = 0; + + while (shift >= 0) { + l |= (*p++) << shift; + shift -= 8; + } + + /* find it in the ringbuffer, look backwards from head */ + n = psd->ringbuffer_head; + while (!match) { + + if (psd->ringbuffer[n].index == l) { + psd->ringbuffer[n].seen++; + match = 1; + continue; + } + + if (n == psd->ringbuffer_tail) { + match = -1; + continue; + } + + if (n == 0) + n = PING_RINGBUFFER_SIZE - 1; + else + n--; + } + + if (match < 1) { + + if (!flood) + fprintf(stderr, "%d bytes from %s: req=%ld " + "time=(unknown)\n", (int)len, address, l); + else + fprintf(stderr, "\b \b"); + + break; + } + + if (psd->ringbuffer[n].seen > 1) + fprintf(stderr, "DUP! "); + + if ((iv - psd->ringbuffer[n].issue_timestamp) < rtt_min) + rtt_min = iv - psd->ringbuffer[n].issue_timestamp; + + if ((iv - psd->ringbuffer[n].issue_timestamp) > rtt_max) + rtt_max = iv - psd->ringbuffer[n].issue_timestamp; + + rtt_avg += iv - psd->ringbuffer[n].issue_timestamp; + global_rx_count++; + + if (!flood) + fprintf(stderr, "%d bytes from %s: req=%ld " + "time=%lu.%lums\n", (int)len, address, l, + (iv - psd->ringbuffer[n].issue_timestamp) / 1000, + ((iv - psd->ringbuffer[n].issue_timestamp) / 100) % 10); + else + fprintf(stderr, "\b \b"); + break; + + case LWS_CALLBACK_CLIENT_WRITEABLE: + + shift = 56; + p = &pingbuf[LWS_SEND_BUFFER_PRE_PADDING]; + + /* 64-bit ping index in network byte order */ + + while (shift >= 0) { + *p++ = psd->ping_index >> shift; + shift -= 8; + } + + gettimeofday(&tv, NULL); + + psd->ringbuffer[psd->ringbuffer_head].issue_timestamp = + (tv.tv_sec * 1000000) + tv.tv_usec; + psd->ringbuffer[psd->ringbuffer_head].index = psd->ping_index++; + psd->ringbuffer[psd->ringbuffer_head].seen = 0; + + if (psd->ringbuffer_head == PING_RINGBUFFER_SIZE - 1) + psd->ringbuffer_head = 0; + else + psd->ringbuffer_head++; + + /* snip any re-used tail so we keep to the ring length */ + + if (psd->ringbuffer_tail == psd->ringbuffer_head) { + if (psd->ringbuffer_tail == PING_RINGBUFFER_SIZE - 1) + psd->ringbuffer_tail = 0; + else + psd->ringbuffer_tail++; + } + + global_tx_count++; + + if (use_mirror) + libwebsocket_write(wsi, + &pingbuf[LWS_SEND_BUFFER_PRE_PADDING], + size, write_options | LWS_WRITE_BINARY); + else + libwebsocket_write(wsi, + &pingbuf[LWS_SEND_BUFFER_PRE_PADDING], + size, write_options | LWS_WRITE_PING); + + if (flood && + (psd->ping_index - psd->rx_count) < (screen_width - 1)) + fprintf(stderr, "."); + break; + + default: + break; + } + + return 0; +} + + +/* list of supported protocols and callbacks */ + +static struct libwebsocket_protocols protocols[] = { + + [PROTOCOL_LWS_MIRROR] = { + .name = "lws-mirror-protocol", + .callback = callback_lws_mirror, + .per_session_data_size = sizeof (struct per_session_data__ping), + }, + [DEMO_PROTOCOL_COUNT] = { /* end of list */ + .callback = NULL + } +}; + +static struct option options[] = { + { "help", no_argument, NULL, 'h' }, + { "port", required_argument, NULL, 'p' }, + { "ssl", no_argument, NULL, 't' }, + { "interval", required_argument, NULL, 'i' }, + { "size", required_argument, NULL, 's' }, + { "protocol", required_argument, NULL, 'n' }, + { "flood", no_argument, NULL, 'f' }, + { "mirror", no_argument, NULL, 'm' }, + { "replicate", required_argument, NULL, 'r' }, + { "killmask", no_argument, NULL, 'k' }, + { "version", required_argument, NULL, 'v' }, + { NULL, 0, 0, 0 } +}; + + +static void +signal_handler(int sig, siginfo_t *si, void *v) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + interrupted_time = (tv.tv_sec * 1000000) + tv.tv_usec; +} + + +int main(int argc, char **argv) +{ + int n = 0; + int port = 7681; + int use_ssl = 0; + struct libwebsocket_context *context; + char protocol_name[256]; + char ip[30]; + struct sigaction sa; + struct timeval tv; + struct winsize w; + unsigned long oldus = 0; + unsigned long l; + int ietf_version = -1; + + if (argc < 2) + goto usage; + + address = argv[1]; + optind++; + + while (n >= 0) { + n = getopt_long(argc, argv, "v:kr:hmfts:n:i:p:", options, NULL); + if (n < 0) + continue; + switch (n) { + case 'm': + use_mirror = 1; + break; + case 't': + use_ssl = 2; /* 2 = allow selfsigned */ + break; + case 'p': + port = atoi(optarg); + break; + case 'n': + strncpy(protocol_name, optarg, sizeof protocol_name); + protocol_name[(sizeof protocol_name) - 1] = '\0'; + protocols[PROTOCOL_LWS_MIRROR].name = protocol_name; + break; + case 'i': + interval_us = 1000000.0 * atof(optarg); + break; + case 's': + size = atoi(optarg); + break; + case 'f': + flood = 1; + break; + case 'r': + clients = atoi(optarg); + if (clients > MAX_PING_CLIENTS || clients < 1) { + fprintf(stderr, "Max clients supportd = %d\n", + MAX_PING_CLIENTS); + return 1; + } + break; + case 'k': + write_options = LWS_WRITE_CLIENT_IGNORE_XOR_MASK; + break; + case 'v': + ietf_version = atoi(optarg); + break; + + case 'h': + goto usage; + } + } + + if (!use_mirror) { + if (size > MAX_PING_PAYLOAD) { + fprintf(stderr, "Max ping opcode payload size %d\n", + MAX_PING_PAYLOAD); + return 1; + } + } else { + if (size > MAX_MIRROR_PAYLOAD) { + fprintf(stderr, "Max mirror payload size %d\n", + MAX_MIRROR_PAYLOAD); + return 1; + } + } + + + if (isatty(STDOUT_FILENO)) + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1) + if (w.ws_col > 0) + screen_width = w.ws_col; + + context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL, + protocols, + libwebsocket_internal_extensions, + NULL, NULL, -1, -1, 0); + if (context == NULL) { + fprintf(stderr, "Creating libwebsocket context failed\n"); + return 1; + } + + /* create client websockets using dumb increment protocol */ + + for (n = 0; n < clients; n++) { + ping_wsi[n] = libwebsocket_client_connect(context, address, + port, use_ssl, "/", address, + "origin", protocols[PROTOCOL_LWS_MIRROR].name, + ietf_version); + if (ping_wsi[n] == NULL) { + fprintf(stderr, "client connnection %d failed to " + "connect\n", n); + return 1; + } + } + + libwebsockets_get_peer_addresses( + libwebsocket_get_socket_fd(ping_wsi[0]), + peer_name, sizeof peer_name, ip, sizeof ip); + + fprintf(stderr, "Websocket PING %s (%s) %d bytes of data.\n", + peer_name, ip, size); + + /* set the ^C handler */ + + sa.sa_sigaction = signal_handler; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + sigaction(SIGINT, &sa, NULL); + + gettimeofday(&tv, NULL); + started = (tv.tv_sec * 1000000) + tv.tv_usec; + + /* service loop */ + + n = 0; + while (n >= 0) { + + gettimeofday(&tv, NULL); + l = (tv.tv_sec * 1000000) + tv.tv_usec; + + /* servers can hang up on us */ + + if (clients == 0) { + n = -1; + continue; + } + + if (!interrupted_time) { + if ((l - oldus) > interval_us) { + for (n = 0; n < clients; n++) + libwebsocket_callback_on_writable( + context, ping_wsi[n]); + oldus = l; + } + } else + + /* allow time for in-flight pongs to come */ + + if ((l - interrupted_time) > 250000) { + n = -1; + continue; + } + + if (!interval_us) + n = libwebsocket_service(context, 0); + else + n = libwebsocket_service(context, 1); + } + + /* stats */ + + fprintf(stderr, "\n--- %s websocket ping statistics " + "using %d connections ---\n" + "%lu packets transmitted, %lu received, " + "%lu%% packet loss, time %ldms\n" + "rtt min/avg/max = %0.3f/%0.3f/%0.3f ms\n" + "payload bandwidth average %0.3f KiBytes/sec\n", + peer_name, clients, global_tx_count, global_rx_count, + ((global_tx_count - global_rx_count) * 100) / global_tx_count, + (l - started) / 1000, + ((double)rtt_min) / 1000.0, + ((double)rtt_avg / global_rx_count) / 1000.0, + ((double)rtt_max) / 1000.0, + ((double)global_rx_count * (double)size) / + ((double)(l - started) / 1000000.0) / 1024.0); + + libwebsocket_context_destroy(context); + + return 0; + +usage: + fprintf(stderr, "Usage: libwebsockets-test-ping " + " [--port=

] " + "[--ssl] [--interval=] " + "[--size=] " + "[--protocol=] " + "[--mirror] " + "[--replicate=clients>]" + "[--version ]" + "\n"); + return 1; +} diff --git a/libs/libwebsockets/test-server/test-server-extpoll.c b/libs/libwebsockets/test-server/test-server-extpoll.c new file mode 100644 index 0000000000..8131412fe3 --- /dev/null +++ b/libs/libwebsockets/test-server/test-server-extpoll.c @@ -0,0 +1,553 @@ +/* + * libwebsockets-test-server-extpoll - libwebsockets external poll loop sample + * + * This acts the same as libwebsockets-test-server but works with the poll + * loop taken out of libwebsockets and into this app. It's an example of how + * you can integrate libwebsockets polling into an app that already has its + * own poll loop. + * + * Copyright (C) 2010-2011 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include +#ifdef __MINGW32__ +#include "../win32port/win32helpers/websock-w32.h" +#else +#ifdef __MINGW64__ +#include "../win32port/win32helpers/websock-w32.h" +#else +#include +#endif +#endif + +#include "../lib/libwebsockets.h" + + +/* + * This demo server shows how to use libwebsockets for one or more + * websocket protocols in the same server + * + * It defines the following websocket protocols: + * + * dumb-increment-protocol: once the socket is opened, an incrementing + * ascii string is sent down it every 50ms. + * If you send "reset\n" on the websocket, then + * the incrementing number is reset to 0. + * + * lws-mirror-protocol: copies any received packet to every connection also + * using this protocol, including the sender + */ + +#define MAX_POLL_ELEMENTS 100 +struct pollfd pollfds[100]; +int count_pollfds = 0; + + + +enum demo_protocols { + /* always first */ + PROTOCOL_HTTP = 0, + + PROTOCOL_DUMB_INCREMENT, + PROTOCOL_LWS_MIRROR, + + /* always last */ + DEMO_PROTOCOL_COUNT +}; + + +#define LOCAL_RESOURCE_PATH INSTALL_DATADIR"/libwebsockets-test-server" + +/* this protocol server (always the first one) just knows how to do HTTP */ + +static int callback_http(struct libwebsocket_context * this, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, void *user, + void *in, size_t len) +{ + int n; + char client_name[128]; + char client_ip[128]; + + switch (reason) { + case LWS_CALLBACK_HTTP: + fprintf(stderr, "serving HTTP URI %s\n", (char *)in); + + if (in && strcmp(in, "/favicon.ico") == 0) { + if (libwebsockets_serve_http_file(wsi, + LOCAL_RESOURCE_PATH"/favicon.ico", "image/x-icon")) + fprintf(stderr, "Failed to send favicon\n"); + break; + } + + /* send the script... when it runs it'll start websockets */ + + if (libwebsockets_serve_http_file(wsi, + LOCAL_RESOURCE_PATH"/test.html", "text/html")) + fprintf(stderr, "Failed to send HTTP file\n"); + break; + + /* + * callback for confirming to continue with client IP appear in + * protocol 0 callback since no websocket protocol has been agreed + * yet. You can just ignore this if you won't filter on client IP + * since the default uhandled callback return is 0 meaning let the + * connection continue. + */ + + case LWS_CALLBACK_FILTER_NETWORK_CONNECTION: + + libwebsockets_get_peer_addresses((int)(long)user, client_name, + sizeof(client_name), client_ip, sizeof(client_ip)); + + fprintf(stderr, "Received network connect from %s (%s)\n", + client_name, client_ip); + + /* if we returned non-zero from here, we kill the connection */ + break; + + /* + * callbacks for managing the external poll() array appear in + * protocol 0 callback + */ + + case LWS_CALLBACK_ADD_POLL_FD: + pollfds[count_pollfds].fd = (int)(long)user; + pollfds[count_pollfds].events = (int)len; + pollfds[count_pollfds++].revents = 0; + break; + + case LWS_CALLBACK_DEL_POLL_FD: + for (n = 0; n < count_pollfds; n++) + if (pollfds[n].fd == (int)(long)user) + while (n < count_pollfds) { + pollfds[n] = pollfds[n + 1]; + n++; + } + count_pollfds--; + break; + + case LWS_CALLBACK_SET_MODE_POLL_FD: + for (n = 0; n < count_pollfds; n++) + if (pollfds[n].fd == (int)(long)user) + pollfds[n].events |= (int)(long)len; + break; + + case LWS_CALLBACK_CLEAR_MODE_POLL_FD: + for (n = 0; n < count_pollfds; n++) + if (pollfds[n].fd == (int)(long)user) + pollfds[n].events &= ~(int)(long)len; + break; + + default: + break; + } + + return 0; +} + +/* + * this is just an example of parsing handshake headers, you don't need this + * in your code unless you will filter allowing connections by the header + * content + */ + +static void +dump_handshake_info(struct lws_tokens *lwst) +{ + int n; + static const char *token_names[] = { + [WSI_TOKEN_GET_URI] = "GET URI", + [WSI_TOKEN_HOST] = "Host", + [WSI_TOKEN_CONNECTION] = "Connection", + [WSI_TOKEN_KEY1] = "key 1", + [WSI_TOKEN_KEY2] = "key 2", + [WSI_TOKEN_PROTOCOL] = "Protocol", + [WSI_TOKEN_UPGRADE] = "Upgrade", + [WSI_TOKEN_ORIGIN] = "Origin", + [WSI_TOKEN_DRAFT] = "Draft", + [WSI_TOKEN_CHALLENGE] = "Challenge", + + /* new for 04 */ + [WSI_TOKEN_KEY] = "Key", + [WSI_TOKEN_VERSION] = "Version", + [WSI_TOKEN_SWORIGIN] = "Sworigin", + + /* new for 05 */ + [WSI_TOKEN_EXTENSIONS] = "Extensions", + + /* client receives these */ + [WSI_TOKEN_ACCEPT] = "Accept", + [WSI_TOKEN_NONCE] = "Nonce", + [WSI_TOKEN_HTTP] = "Http", + [WSI_TOKEN_MUXURL] = "MuxURL", + }; + + for (n = 0; n < WSI_TOKEN_COUNT; n++) { + if (lwst[n].token == NULL) + continue; + + fprintf(stderr, " %s = %s\n", token_names[n], lwst[n].token); + } +} + +/* dumb_increment protocol */ + +/* + * one of these is auto-created for each connection and a pointer to the + * appropriate instance is passed to the callback in the user parameter + * + * for this example protocol we use it to individualize the count for each + * connection. + */ + +struct per_session_data__dumb_increment { + int number; +}; + +static int +callback_dumb_increment(struct libwebsocket_context * this, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + int n; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 + + LWS_SEND_BUFFER_POST_PADDING]; + unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING]; + struct per_session_data__dumb_increment *pss = user; + + switch (reason) { + + case LWS_CALLBACK_ESTABLISHED: + pss->number = 0; + break; + + /* + * in this protocol, we just use the broadcast action as the chance to + * send our own connection-specific data and ignore the broadcast info + * that is available in the 'in' parameter + */ + + case LWS_CALLBACK_BROADCAST: + n = sprintf((char *)p, "%d", pss->number++); + n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + return 1; + } + break; + + case LWS_CALLBACK_RECEIVE: + fprintf(stderr, "rx %d\n", (int)len); + if (len < 6) + break; + if (strcmp(in, "reset\n") == 0) + pss->number = 0; + break; + + /* + * this just demonstrates how to use the protocol filter. If you won't + * study and reject connections based on header content, you don't need + * to handle this callback + */ + + case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: + dump_handshake_info((struct lws_tokens *)(long)user); + /* you could return non-zero here and kill the connection */ + break; + + default: + break; + } + + return 0; +} + + +/* lws-mirror_protocol */ + +#define MAX_MESSAGE_QUEUE 64 + +struct per_session_data__lws_mirror { + struct libwebsocket *wsi; + int ringbuffer_tail; +}; + +struct a_message { + void *payload; + size_t len; +}; + +static struct a_message ringbuffer[MAX_MESSAGE_QUEUE]; +static int ringbuffer_head; + + +static int +callback_lws_mirror(struct libwebsocket_context * this, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + int n; + struct per_session_data__lws_mirror *pss = user; + + switch (reason) { + + case LWS_CALLBACK_ESTABLISHED: + pss->ringbuffer_tail = ringbuffer_head; + pss->wsi = wsi; + libwebsocket_callback_on_writable(this, wsi); + break; + + case LWS_CALLBACK_SERVER_WRITEABLE: + + if (pss->ringbuffer_tail != ringbuffer_head) { + + n = libwebsocket_write(wsi, (unsigned char *) + ringbuffer[pss->ringbuffer_tail].payload + + LWS_SEND_BUFFER_PRE_PADDING, + ringbuffer[pss->ringbuffer_tail].len, + LWS_WRITE_TEXT); + + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + exit(1); + } + + if (pss->ringbuffer_tail == (MAX_MESSAGE_QUEUE - 1)) + pss->ringbuffer_tail = 0; + else + pss->ringbuffer_tail++; + + if (((ringbuffer_head - pss->ringbuffer_tail) % + MAX_MESSAGE_QUEUE) < (MAX_MESSAGE_QUEUE - 15)) + libwebsocket_rx_flow_control(wsi, 1); + + libwebsocket_callback_on_writable(this, wsi); + + } + break; + + case LWS_CALLBACK_BROADCAST: + n = libwebsocket_write(wsi, in, len, LWS_WRITE_TEXT); + if (n < 0) + fprintf(stderr, "mirror write failed\n"); + break; + + case LWS_CALLBACK_RECEIVE: + + if (ringbuffer[ringbuffer_head].payload) + free(ringbuffer[ringbuffer_head].payload); + + ringbuffer[ringbuffer_head].payload = + malloc(LWS_SEND_BUFFER_PRE_PADDING + len + + LWS_SEND_BUFFER_POST_PADDING); + ringbuffer[ringbuffer_head].len = len; + memcpy((char *)ringbuffer[ringbuffer_head].payload + + LWS_SEND_BUFFER_PRE_PADDING, in, len); + if (ringbuffer_head == (MAX_MESSAGE_QUEUE - 1)) + ringbuffer_head = 0; + else + ringbuffer_head++; + + if (((ringbuffer_head - pss->ringbuffer_tail) % + MAX_MESSAGE_QUEUE) > (MAX_MESSAGE_QUEUE - 10)) + libwebsocket_rx_flow_control(wsi, 0); + + libwebsocket_callback_on_writable_all_protocol( + libwebsockets_get_protocol(wsi)); + break; + + /* + * this just demonstrates how to use the protocol filter. If you won't + * study and reject connections based on header content, you don't need + * to handle this callback + */ + + case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: + dump_handshake_info((struct lws_tokens *)(long)user); + /* you could return non-zero here and kill the connection */ + break; + + default: + break; + } + + return 0; +} + + +/* list of supported protocols and callbacks */ + +static struct libwebsocket_protocols protocols[] = { + /* first protocol must always be HTTP handler */ + + { + "http-only", /* name */ + callback_http, /* callback */ + 0 /* per_session_data_size */ + }, + { + "dumb-increment-protocol", + callback_dumb_increment, + sizeof(struct per_session_data__dumb_increment), + }, + { + "lws-mirror-protocol", + callback_lws_mirror, + sizeof(struct per_session_data__lws_mirror) + }, + { + NULL, NULL, 0 /* End of list */ + } +}; + +static struct option options[] = { + { "help", no_argument, NULL, 'h' }, + { "port", required_argument, NULL, 'p' }, + { "ssl", no_argument, NULL, 's' }, + { "killmask", no_argument, NULL, 'k' }, + { "interface", required_argument, NULL, 'i' }, + { NULL, 0, 0, 0 } +}; + +int main(int argc, char **argv) +{ + int n = 0; + const char *cert_path = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; + const char *key_path = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1024 + + LWS_SEND_BUFFER_POST_PADDING]; + int port = 7681; + int use_ssl = 0; + struct libwebsocket_context *context; + int opts = 0; + unsigned int oldus = 0; + char interface_name[128] = ""; + const char *interface_ptr = NULL; + + fprintf(stderr, "libwebsockets test server with external poll()\n" + "(C) Copyright 2010-2011 Andy Green " + "licensed under LGPL2.1\n"); + + while (n >= 0) { + n = getopt_long(argc, argv, "i:khsp:", options, NULL); + if (n < 0) + continue; + switch (n) { + case 's': + use_ssl = 1; + break; + case 'k': + opts = LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK; + break; + case 'p': + port = atoi(optarg); + break; + case 'i': + strncpy(interface_name, optarg, sizeof interface_name); + interface_name[(sizeof interface_name) - 1] = '\0'; + interface_ptr = interface_name; + break; + case 'h': + fprintf(stderr, "Usage: test-server " + "[--port=

] [--ssl]\n"); + exit(1); + } + } + + if (!use_ssl) + cert_path = key_path = NULL; + + context = libwebsocket_create_context(port, interface_ptr, protocols, + libwebsocket_internal_extensions, + cert_path, key_path, -1, -1, opts); + if (context == NULL) { + fprintf(stderr, "libwebsocket init failed\n"); + return -1; + } + + buf[LWS_SEND_BUFFER_PRE_PADDING] = 'x'; + + /* + * This is an example of an existing application's explicit poll() + * loop that libwebsockets can integrate with. + */ + + while (1) { + struct timeval tv; + + /* + * this represents an existing server's single poll action + * which also includes libwebsocket sockets + */ + + n = poll(pollfds, count_pollfds, 25); + if (n < 0) + goto done; + + if (n) + for (n = 0; n < count_pollfds; n++) + if (pollfds[n].revents) + /* + * returns immediately if the fd does not + * match anything under libwebsockets + * control + */ + if (libwebsocket_service_fd(context, + &pollfds[n])) + goto done; + + /* do our broadcast periodically */ + + gettimeofday(&tv, NULL); + + /* + * This broadcasts to all dumb-increment-protocol connections + * at 20Hz. + * + * We're just sending a character 'x', in these examples the + * callbacks send their own per-connection content. + * + * You have to send something with nonzero length to get the + * callback actions delivered. + * + * We take care of pre-and-post padding allocation. + */ + + if (((unsigned int)tv.tv_usec - oldus) > 50000) { + libwebsockets_broadcast( + &protocols[PROTOCOL_DUMB_INCREMENT], + &buf[LWS_SEND_BUFFER_PRE_PADDING], 1); + oldus = tv.tv_usec; + } + } + +done: + libwebsocket_context_destroy(context); + + return 0; +} diff --git a/libs/libwebsockets/test-server/test-server.c b/libs/libwebsockets/test-server/test-server.c new file mode 100644 index 0000000000..516deff7bd --- /dev/null +++ b/libs/libwebsockets/test-server/test-server.c @@ -0,0 +1,551 @@ +/* + * libwebsockets-test-server - libwebsockets test implementation + * + * Copyright (C) 2010-2011 Andy Green + * + * 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 the Free Software Foundation: + * version 2.1 of the License. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include + +#include "../lib/libwebsockets.h" + +static int close_testing; + +/* + * This demo server shows how to use libwebsockets for one or more + * websocket protocols in the same server + * + * It defines the following websocket protocols: + * + * dumb-increment-protocol: once the socket is opened, an incrementing + * ascii string is sent down it every 50ms. + * If you send "reset\n" on the websocket, then + * the incrementing number is reset to 0. + * + * lws-mirror-protocol: copies any received packet to every connection also + * using this protocol, including the sender + */ + +enum demo_protocols { + /* always first */ + PROTOCOL_HTTP = 0, + + PROTOCOL_DUMB_INCREMENT, + PROTOCOL_LWS_MIRROR, + + /* always last */ + DEMO_PROTOCOL_COUNT +}; + + +#define LOCAL_RESOURCE_PATH INSTALL_DATADIR"/libwebsockets-test-server" + +/* this protocol server (always the first one) just knows how to do HTTP */ + +static int callback_http(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, void *user, + void *in, size_t len) +{ + char client_name[128]; + char client_ip[128]; + + switch (reason) { + case LWS_CALLBACK_HTTP: + fprintf(stderr, "serving HTTP URI %s\n", (char *)in); + + if (in && strcmp(in, "/favicon.ico") == 0) { + if (libwebsockets_serve_http_file(wsi, + LOCAL_RESOURCE_PATH"/favicon.ico", "image/x-icon")) + fprintf(stderr, "Failed to send favicon\n"); + break; + } + + /* send the script... when it runs it'll start websockets */ + + if (libwebsockets_serve_http_file(wsi, + LOCAL_RESOURCE_PATH"/test.html", "text/html")) + fprintf(stderr, "Failed to send HTTP file\n"); + break; + + /* + * callback for confirming to continue with client IP appear in + * protocol 0 callback since no websocket protocol has been agreed + * yet. You can just ignore this if you won't filter on client IP + * since the default uhandled callback return is 0 meaning let the + * connection continue. + */ + + case LWS_CALLBACK_FILTER_NETWORK_CONNECTION: + + libwebsockets_get_peer_addresses((int)(long)user, client_name, + sizeof(client_name), client_ip, sizeof(client_ip)); + + fprintf(stderr, "Received network connect from %s (%s)\n", + client_name, client_ip); + + /* if we returned non-zero from here, we kill the connection */ + break; + + default: + break; + } + + return 0; +} + + +/* + * this is just an example of parsing handshake headers, you don't need this + * in your code unless you will filter allowing connections by the header + * content + */ + +static void +dump_handshake_info(struct lws_tokens *lwst) +{ + int n; + static const char *token_names[WSI_TOKEN_COUNT] = { + /*[WSI_TOKEN_GET_URI] =*/ "GET URI", + /*[WSI_TOKEN_HOST] =*/ "Host", + /*[WSI_TOKEN_CONNECTION] =*/ "Connection", + /*[WSI_TOKEN_KEY1] =*/ "key 1", + /*[WSI_TOKEN_KEY2] =*/ "key 2", + /*[WSI_TOKEN_PROTOCOL] =*/ "Protocol", + /*[WSI_TOKEN_UPGRADE] =*/ "Upgrade", + /*[WSI_TOKEN_ORIGIN] =*/ "Origin", + /*[WSI_TOKEN_DRAFT] =*/ "Draft", + /*[WSI_TOKEN_CHALLENGE] =*/ "Challenge", + + /* new for 04 */ + /*[WSI_TOKEN_KEY] =*/ "Key", + /*[WSI_TOKEN_VERSION] =*/ "Version", + /*[WSI_TOKEN_SWORIGIN] =*/ "Sworigin", + + /* new for 05 */ + /*[WSI_TOKEN_EXTENSIONS] =*/ "Extensions", + + /* client receives these */ + /*[WSI_TOKEN_ACCEPT] =*/ "Accept", + /*[WSI_TOKEN_NONCE] =*/ "Nonce", + /*[WSI_TOKEN_HTTP] =*/ "Http", + /*[WSI_TOKEN_MUXURL] =*/ "MuxURL", + }; + + for (n = 0; n < WSI_TOKEN_COUNT; n++) { + if (lwst[n].token == NULL) + continue; + + fprintf(stderr, " %s = %s\n", token_names[n], lwst[n].token); + } +} + +/* dumb_increment protocol */ + +/* + * one of these is auto-created for each connection and a pointer to the + * appropriate instance is passed to the callback in the user parameter + * + * for this example protocol we use it to individualize the count for each + * connection. + */ + +struct per_session_data__dumb_increment { + int number; +}; + +static int +callback_dumb_increment(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + int n; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 + + LWS_SEND_BUFFER_POST_PADDING]; + unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING]; + struct per_session_data__dumb_increment *pss = user; + + switch (reason) { + + case LWS_CALLBACK_ESTABLISHED: + fprintf(stderr, "callback_dumb_increment: " + "LWS_CALLBACK_ESTABLISHED\n"); + pss->number = 0; + break; + + /* + * in this protocol, we just use the broadcast action as the chance to + * send our own connection-specific data and ignore the broadcast info + * that is available in the 'in' parameter + */ + + case LWS_CALLBACK_BROADCAST: + n = sprintf((char *)p, "%d", pss->number++); + n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + return 1; + } + if (close_testing && pss->number == 50) { + fprintf(stderr, "close tesing limit, closing\n"); + libwebsocket_close_and_free_session(context, wsi, + LWS_CLOSE_STATUS_NORMAL); + } + break; + + case LWS_CALLBACK_RECEIVE: + fprintf(stderr, "rx %d\n", (int)len); + if (len < 6) + break; + if (strcmp(in, "reset\n") == 0) + pss->number = 0; + break; + /* + * this just demonstrates how to use the protocol filter. If you won't + * study and reject connections based on header content, you don't need + * to handle this callback + */ + + case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: + dump_handshake_info((struct lws_tokens *)(long)user); + /* you could return non-zero here and kill the connection */ + break; + + default: + break; + } + + return 0; +} + + +/* lws-mirror_protocol */ + +#define MAX_MESSAGE_QUEUE 64 + +struct per_session_data__lws_mirror { + struct libwebsocket *wsi; + int ringbuffer_tail; +}; + +struct a_message { + void *payload; + size_t len; +}; + +static struct a_message ringbuffer[MAX_MESSAGE_QUEUE]; +static int ringbuffer_head; + + +static int +callback_lws_mirror(struct libwebsocket_context *context, + struct libwebsocket *wsi, + enum libwebsocket_callback_reasons reason, + void *user, void *in, size_t len) +{ + int n; + struct per_session_data__lws_mirror *pss = user; + + switch (reason) { + + case LWS_CALLBACK_ESTABLISHED: + fprintf(stderr, "callback_lws_mirror: " + "LWS_CALLBACK_ESTABLISHED\n"); + pss->ringbuffer_tail = ringbuffer_head; + pss->wsi = wsi; + break; + + case LWS_CALLBACK_SERVER_WRITEABLE: + if (close_testing) + break; + if (pss->ringbuffer_tail != ringbuffer_head) { + + n = libwebsocket_write(wsi, (unsigned char *) + ringbuffer[pss->ringbuffer_tail].payload + + LWS_SEND_BUFFER_PRE_PADDING, + ringbuffer[pss->ringbuffer_tail].len, + LWS_WRITE_TEXT); + if (n < 0) { + fprintf(stderr, "ERROR writing to socket"); + exit(1); + } + + if (pss->ringbuffer_tail == (MAX_MESSAGE_QUEUE - 1)) + pss->ringbuffer_tail = 0; + else + pss->ringbuffer_tail++; + + if (((ringbuffer_head - pss->ringbuffer_tail) % + MAX_MESSAGE_QUEUE) < (MAX_MESSAGE_QUEUE - 15)) + libwebsocket_rx_flow_control(wsi, 1); + + libwebsocket_callback_on_writable(context, wsi); + + } + break; + + case LWS_CALLBACK_BROADCAST: + n = libwebsocket_write(wsi, in, len, LWS_WRITE_TEXT); + if (n < 0) + fprintf(stderr, "mirror write failed\n"); + break; + + case LWS_CALLBACK_RECEIVE: + + if (ringbuffer[ringbuffer_head].payload) + free(ringbuffer[ringbuffer_head].payload); + + ringbuffer[ringbuffer_head].payload = + malloc(LWS_SEND_BUFFER_PRE_PADDING + len + + LWS_SEND_BUFFER_POST_PADDING); + ringbuffer[ringbuffer_head].len = len; + memcpy((char *)ringbuffer[ringbuffer_head].payload + + LWS_SEND_BUFFER_PRE_PADDING, in, len); + if (ringbuffer_head == (MAX_MESSAGE_QUEUE - 1)) + ringbuffer_head = 0; + else + ringbuffer_head++; + + if (((ringbuffer_head - pss->ringbuffer_tail) % + MAX_MESSAGE_QUEUE) > (MAX_MESSAGE_QUEUE - 10)) + libwebsocket_rx_flow_control(wsi, 0); + + libwebsocket_callback_on_writable_all_protocol( + libwebsockets_get_protocol(wsi)); + break; + /* + * this just demonstrates how to use the protocol filter. If you won't + * study and reject connections based on header content, you don't need + * to handle this callback + */ + + case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: + dump_handshake_info((struct lws_tokens *)(long)user); + /* you could return non-zero here and kill the connection */ + break; + + default: + break; + } + + return 0; +} + + +/* list of supported protocols and callbacks */ + +static struct libwebsocket_protocols protocols[] = { + /* first protocol must always be HTTP handler */ + + { + "http-only", /* name */ + callback_http, /* callback */ + 0 /* per_session_data_size */ + }, + { + "dumb-increment-protocol", + callback_dumb_increment, + sizeof(struct per_session_data__dumb_increment), + }, + { + "lws-mirror-protocol", + callback_lws_mirror, + sizeof(struct per_session_data__lws_mirror) + }, + { + NULL, NULL, 0 /* End of list */ + } +}; + +static struct option options[] = { + { "help", no_argument, NULL, 'h' }, + { "port", required_argument, NULL, 'p' }, + { "ssl", no_argument, NULL, 's' }, + { "killmask", no_argument, NULL, 'k' }, + { "interface", required_argument, NULL, 'i' }, + { "closetest", no_argument, NULL, 'c' }, + { NULL, 0, 0, 0 } +}; + +int main(int argc, char **argv) +{ + int n = 0; + const char *cert_path = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem"; + const char *key_path = + LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem"; + unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1024 + + LWS_SEND_BUFFER_POST_PADDING]; + int port = 7681; + int use_ssl = 0; + struct libwebsocket_context *context; + int opts = 0; + char interface_name[128] = ""; + const char *interface = NULL; +#ifdef LWS_NO_FORK + unsigned int oldus = 0; +#endif + + fprintf(stderr, "libwebsockets test server\n" + "(C) Copyright 2010-2011 Andy Green " + "licensed under LGPL2.1\n"); + + while (n >= 0) { + n = getopt_long(argc, argv, "ci:khsp:", options, NULL); + if (n < 0) + continue; + switch (n) { + case 's': + use_ssl = 1; + break; + case 'k': + opts = LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK; + break; + case 'p': + port = atoi(optarg); + break; + case 'i': + strncpy(interface_name, optarg, sizeof interface_name); + interface_name[(sizeof interface_name) - 1] = '\0'; + interface = interface_name; + break; + case 'c': + close_testing = 1; + fprintf(stderr, " Close testing mode -- closes on " + "client after 50 dumb increments" + "and suppresses lws_mirror spam\n"); + break; + case 'h': + fprintf(stderr, "Usage: test-server " + "[--port=

] [--ssl]\n"); + exit(1); + } + } + + if (!use_ssl) + cert_path = key_path = NULL; + + context = libwebsocket_create_context(port, interface, protocols, + libwebsocket_internal_extensions, + cert_path, key_path, -1, -1, opts); + if (context == NULL) { + fprintf(stderr, "libwebsocket init failed\n"); + return -1; + } + + buf[LWS_SEND_BUFFER_PRE_PADDING] = 'x'; + +#ifdef LWS_NO_FORK + + /* + * This example shows how to work with no forked service loop + */ + + fprintf(stderr, " Using no-fork service loop\n"); + + n = 0; + while (n >= 0) { + struct timeval tv; + + gettimeofday(&tv, NULL); + + /* + * This broadcasts to all dumb-increment-protocol connections + * at 20Hz. + * + * We're just sending a character 'x', in these examples the + * callbacks send their own per-connection content. + * + * You have to send something with nonzero length to get the + * callback actions delivered. + * + * We take care of pre-and-post padding allocation. + */ + + if (((unsigned int)tv.tv_usec - oldus) > 50000) { + libwebsockets_broadcast( + &protocols[PROTOCOL_DUMB_INCREMENT], + &buf[LWS_SEND_BUFFER_PRE_PADDING], 1); + oldus = tv.tv_usec; + } + + /* + * This example server does not fork or create a thread for + * websocket service, it all runs in this single loop. So, + * we have to give the websockets an opportunity to service + * "manually". + * + * If no socket is needing service, the call below returns + * immediately and quickly. Negative return means we are + * in process of closing + */ + + n = libwebsocket_service(context, 50); + } + +#else + + /* + * This example shows how to work with the forked websocket service loop + */ + + fprintf(stderr, " Using forked service loop\n"); + + /* + * This forks the websocket service action into a subprocess so we + * don't have to take care about it. + */ + + n = libwebsockets_fork_service_loop(context); + if (n < 0) { + fprintf(stderr, "Unable to fork service loop %d\n", n); + return 1; + } + + while (1) { + + usleep(50000); + + /* + * This broadcasts to all dumb-increment-protocol connections + * at 20Hz. + * + * We're just sending a character 'x', in these examples the + * callbacks send their own per-connection content. + * + * You have to send something with nonzero length to get the + * callback actions delivered. + * + * We take care of pre-and-post padding allocation. + */ + + libwebsockets_broadcast(&protocols[PROTOCOL_DUMB_INCREMENT], + &buf[LWS_SEND_BUFFER_PRE_PADDING], 1); + } + +#endif + + libwebsocket_context_destroy(context); + + return 0; +} diff --git a/libs/libwebsockets/test-server/test.html b/libs/libwebsockets/test-server/test.html new file mode 100644 index 0000000000..99d6236b83 --- /dev/null +++ b/libs/libwebsockets/test-server/test.html @@ -0,0 +1,361 @@ + + + + + Minimal Websocket test app + + + +

Detected Browser:
...

+

libwebsockets "dumb-increment-protocol" test applet

+The incrementing number is coming from the server and is individual for +each connection to the server... try opening a second browser window. +Click the button to send the server a websocket message to +reset the number.

+ + + + + + + +
Not initialized
+ +

libwebsockets "lws-mirror-protocol" test applet

+Use the mouse to draw on the canvas below -- all other browser windows open +on this page see your drawing in realtime and you can see any of theirs as +well. +

+The lws-mirror protocol doesn't interpret what is being sent to it, it just +re-sends it to every other websocket it has a connection with using that +protocol, including the guy who sent the packet. +

libwebsockets-test-client spams circles on to this shared canvas when +run.

+

+ + + + + + + + + +
Drawing color: + +
Not initialized
+ + + + + diff --git a/libs/libwebsockets/win32port/client/client.vcxproj b/libs/libwebsockets/win32port/client/client.vcxproj new file mode 100644 index 0000000000..1192afc142 --- /dev/null +++ b/libs/libwebsockets/win32port/client/client.vcxproj @@ -0,0 +1,259 @@ + + + + + Debug static + Win32 + + + Debug + Win32 + + + Debug + x64 + + + Release DLL + Win32 + + + Release DLL + x64 + + + Release static + Win32 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + {332bf17e-fd30-4363-975a-aa731a827b4f} + + + {4156fc56-8443-2973-4fe2-a0bb2c621525} + + + + + + + + {6265650C-4799-451C-A687-94DE48759A8B} + Win32Proj + client + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + false + + + Console + true + ws2_32.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) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + MultiThreadedDebug + false + + + Console + true + ws2_32.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) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + + + Console + true + ws2_32.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) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + + + Console + true + ws2_32.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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + MultiThreaded + false + + + Console + true + true + true + ws2_32.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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + + + Console + true + true + true + ws2_32.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) + + + + + false + ../win32helpers + WIN32;_CONSOLE + MultiThreaded + + + Ws2_32.lib;%(AdditionalDependencies) + + + + + false + MultiThreaded + false + ../win32helpers + WIN32;_CONSOLE;LWS_DLL + + + + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/client/client.vcxproj.filters b/libs/libwebsockets/win32port/client/client.vcxproj.filters new file mode 100644 index 0000000000..76f11219e3 --- /dev/null +++ b/libs/libwebsockets/win32port/client/client.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {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 + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/libwebsocketswin32/libwebsocketswin32.vcxproj b/libs/libwebsockets/win32port/libwebsocketswin32/libwebsocketswin32.vcxproj new file mode 100644 index 0000000000..8c371f3ffe --- /dev/null +++ b/libs/libwebsockets/win32port/libwebsocketswin32/libwebsocketswin32.vcxproj @@ -0,0 +1,274 @@ + + + + + Debug static + Win32 + + + Debug + Win32 + + + Debug + x64 + + + Release DLL + Win32 + + + Release DLL + x64 + + + Release static + Win32 + + + Release + Win32 + + + Release + x64 + + + + {332BF17E-FD30-4363-975A-AA731A827B4F} + Win32Proj + libwebsocketswin32 + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + + + DynamicLibrary + true + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\output\ + D:\Libraries\libwebsockets\output\;$(LibraryPath) + libwebsockets_vc100-mt-sgd + + + D:\Libraries\libwebsockets\output\;$(LibraryPath) + + + D:\Libraries\libwebsockets\output\;$(LibraryPath) + + + libwebsockets_vc100-mt-s + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../win32helpers;../zlib + false + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../win32helpers;../zlib + MultiThreadedDebug + false + + + Windows + true + + + $(OutDir)libwebsockets_vc100-mt-sgd$(TargetExt) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../win32helpers;../zlib + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../win32helpers;../zlib + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ../win32helpers;../zlib + MultiThreaded + false + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ../win32helpers;../zlib + + + Windows + true + true + true + + + + + ../win32helpers;../zlib + WIN32 + false + MultiThreaded + + + $(OutDir)libwebsockets_vc100-mt-s.lib + + + + + ../win32helpers;../zlib + WIN32;LWS_INTERNAL;LWS_DLL + false + MultiThreaded + false + Speed + true + + + $(OutDir)libwebsockets_vc100-mt-s.lib + + + Ws2_32.lib;..\..\output\ZLib_vc100-mt-s.lib;%(AdditionalDependencies) + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/libwebsocketswin32/libwebsocketswin32.vcxproj.filters b/libs/libwebsockets/win32port/libwebsocketswin32/libwebsocketswin32.vcxproj.filters new file mode 100644 index 0000000000..3c6edbb327 --- /dev/null +++ b/libs/libwebsockets/win32port/libwebsocketswin32/libwebsocketswin32.vcxproj.filters @@ -0,0 +1,72 @@ + + + + + {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 + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Source Files + + + Header Files + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/server/server.vcxproj b/libs/libwebsockets/win32port/server/server.vcxproj new file mode 100644 index 0000000000..7fe50a8550 --- /dev/null +++ b/libs/libwebsockets/win32port/server/server.vcxproj @@ -0,0 +1,276 @@ + + + + + Debug static + Win32 + + + Debug + Win32 + + + Debug + x64 + + + Release DLL + Win32 + + + Release DLL + x64 + + + Release static + Win32 + + + Release + Win32 + + + Release + x64 + + + + + ../win32helpers + ../win32helpers + ../win32helpers + ../win32helpers + + + + + + + + + + + + + + + + {332bf17e-fd30-4363-975a-aa731a827b4f} + + + {4156fc56-8443-2973-4fe2-a0bb2c621525} + + + + {E585B64F-9365-4C58-9EF8-56393EB27F8B} + Win32Proj + server + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + false + + + Console + true + + + ws2_32.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) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + MultiThreadedDebug + false + + + Console + true + + + ws2_32.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) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + + + Console + true + + + ws2_32.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) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + + + Console + true + + + ws2_32.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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + MultiThreaded + false + + + Console + true + true + true + ws2_32.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) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../win32helpers + + + Console + true + true + true + ws2_32.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) + + + + + false + ../win32helpers + WIN32;_CONSOLE + MultiThreaded + + + Ws2_32.lib;%(AdditionalDependencies) + + + + + false + MultiThreaded + false + ../win32helpers + WIN32;_CONSOLE;LWS_DLL + + + + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/server/server.vcxproj.filters b/libs/libwebsockets/win32port/server/server.vcxproj.filters new file mode 100644 index 0000000000..d4a9c7da53 --- /dev/null +++ b/libs/libwebsockets/win32port/server/server.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + {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 + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/win32helpers/getopt.c b/libs/libwebsockets/win32port/win32helpers/getopt.c new file mode 100644 index 0000000000..2181f1cb12 --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/getopt.c @@ -0,0 +1,153 @@ +/* $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $ */ + +/* + * Copyright (c) 1987, 1993, 1994 + * The Regents of the University of California. 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 acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 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. + */ + +#if 0 +static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; +#endif + +#include +#include +#include +#include + +#define __P(x) x +#define _DIAGASSERT(x) assert(x) + +#ifdef __weak_alias +__weak_alias(getopt,_getopt); +#endif + + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +static char * _progname __P((char *)); +int getopt_internal __P((int, char * const *, const char *)); + +static char * +_progname(nargv0) + char * nargv0; +{ + char * tmp; + + _DIAGASSERT(nargv0 != NULL); + + tmp = strrchr(nargv0, '/'); + if (tmp) + tmp++; + else + tmp = nargv0; + return(tmp); +} + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt(nargc, nargv, ostr) + int nargc; + char * const nargv[]; + const char *ostr; +{ + static char *__progname = 0; + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + __progname = __progname?__progname:_progname(*nargv); + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-' /* found "--" */ + && place[1] == '\0') { + ++optind; + place = EMSG; + return (-1); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname, optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname, optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + diff --git a/libs/libwebsockets/win32port/win32helpers/getopt.h b/libs/libwebsockets/win32port/win32helpers/getopt.h new file mode 100644 index 0000000000..5a88c2df6b --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/getopt.h @@ -0,0 +1,33 @@ +#ifndef __GETOPT_H__ +#define __GETOPT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +struct option +{ + const char *name; + int has_arg; + int *flag; + int val; +}; + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +int getopt(int, char**, char*); +int getopt_long(int, char**, char*, struct option*, int*); + +#ifdef __cplusplus +} +#endif + +#endif /* __GETOPT_H__ */ diff --git a/libs/libwebsockets/win32port/win32helpers/getopt_long.c b/libs/libwebsockets/win32port/win32helpers/getopt_long.c new file mode 100644 index 0000000000..43a5cba79a --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/getopt_long.c @@ -0,0 +1,237 @@ + +/* + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. 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 acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 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. + */ +#include +#include +#include +#include +#include +#include "getopt.h" + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +#define __P(x) x +#define _DIAGASSERT(x) assert(x) + +static char * __progname __P((char *)); +int getopt_internal __P((int, char * const *, const char *)); + +static char * +__progname(nargv0) + char * nargv0; +{ + char * tmp; + + _DIAGASSERT(nargv0 != NULL); + + tmp = strrchr(nargv0, '/'); + if (tmp) + tmp++; + else + tmp = nargv0; + return(tmp); +} + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt_internal(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + /* ++optind; */ + place = EMSG; + return (-2); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname(nargv[0]), optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if ((opterr) && (*ostr != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname(nargv[0]), optopt); + return (BADARG); + } else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + +#if 0 +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt2(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + int retval; + + if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) { + retval = -1; + ++optind; + } + return(retval); +} +#endif + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(nargc, nargv, options, long_options, index) + int nargc; + char ** nargv; + char * options; + struct option * long_options; + int * index; +{ + int retval; + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(options != NULL); + _DIAGASSERT(long_options != NULL); + /* index may be NULL */ + + if ((retval = getopt_internal(nargc, nargv, options)) == -2) { + char *current_argv = nargv[optind++] + 2, *has_equal; + int i, current_argv_len, match = -1; + + if (*current_argv == '\0') { + return(-1); + } + if ((has_equal = strchr(current_argv, '=')) != NULL) { + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + if (strncmp(current_argv, long_options[i].name, current_argv_len)) + continue; + + if (strlen(long_options[i].name) == (unsigned)current_argv_len) { + match = i; + break; + } + if (match == -1) + match = i; + } + if (match != -1) { + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else + optarg = nargv[optind++]; + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument, leading : + * indicates no error should be generated + */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %s\n", + __progname(nargv[0]), current_argv); + return (BADARG); + } + } else { /* No matching argument */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: illegal option -- %s\n", __progname(nargv[0]), current_argv); + return (BADCH); + } + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + retval = 0; + } else + retval = long_options[match].val; + if (index) + *index = match; + } + return(retval); +} diff --git a/libs/libwebsockets/win32port/win32helpers/gettimeofday.c b/libs/libwebsockets/win32port/win32helpers/gettimeofday.c new file mode 100644 index 0000000000..a424db923b --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/gettimeofday.c @@ -0,0 +1,48 @@ +#include < time.h > +#include //I've ommited context line. +#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 +#else + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL +#endif + +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + unsigned __int64 tmpres = 0; + static int tzflag; + + if (NULL != tv) + { + GetSystemTimeAsFileTime(&ft); + + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + /*converting file time to unix epoch*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tmpres /= 10; /*convert into microseconds*/ + tv->tv_sec = (long)(tmpres / 1000000UL); + tv->tv_usec = (long)(tmpres % 1000000UL); + } + + if (NULL != tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} diff --git a/libs/libwebsockets/win32port/win32helpers/gettimeofday.h b/libs/libwebsockets/win32port/win32helpers/gettimeofday.h new file mode 100644 index 0000000000..223ceeed8b --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/gettimeofday.h @@ -0,0 +1,28 @@ +#ifndef _GET_TIME_OF_DAY_H +#define _GET_TIME_OF_DAY_H + +#ifdef __MINGW64__ +#else +#ifdef __MINGW32__ +#else +#include < time.h > +#endif +#endif + +#include //I've ommited context line. +#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 +#else + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL +#endif + +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +int gettimeofday(struct timeval *tv, struct timezone *tz); + + +#endif diff --git a/libs/libwebsockets/win32port/win32helpers/netdb.h b/libs/libwebsockets/win32port/win32helpers/netdb.h new file mode 100644 index 0000000000..45304b7673 --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/netdb.h @@ -0,0 +1 @@ +// Left blank for win32 \ No newline at end of file diff --git a/libs/libwebsockets/win32port/win32helpers/strings.h b/libs/libwebsockets/win32port/win32helpers/strings.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/win32port/win32helpers/sys/time.h b/libs/libwebsockets/win32port/win32helpers/sys/time.h new file mode 100644 index 0000000000..258af63bcd --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/sys/time.h @@ -0,0 +1 @@ +// left blank \ No newline at end of file diff --git a/libs/libwebsockets/win32port/win32helpers/unistd.h b/libs/libwebsockets/win32port/win32helpers/unistd.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libwebsockets/win32port/win32helpers/websock-w32.c b/libs/libwebsockets/win32port/win32helpers/websock-w32.c new file mode 100644 index 0000000000..bec150b179 --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/websock-w32.c @@ -0,0 +1,104 @@ +#define FD_SETSIZE 256 + +#ifdef __MINGW32__ +#include +#else +#ifdef __MINGW64__ +#include +#else +#include +#endif +#endif + +#include +#include +#include "websock-w32.h" + +PFNWSAPOLL poll = NULL; + +INT WSAAPI emulated_poll(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout) +{ + fd_set readfds; + fd_set writefds; + struct timeval tv; + struct timeval *ptv = &tv; + SOCKET max_socket = 0; + ULONG n = 0; + int waiting; + int pending = 0; + WSAPOLLFD * poll_fd = fdarray; + + if (NULL == fdarray) { + errno = EFAULT; + return -1; + } + + FD_ZERO(&readfds); + FD_ZERO(&writefds); + + tv.tv_sec = timeout / 1000; + tv.tv_usec = (timeout % 1000) * 1000; + + if (timeout < 0) + ptv = NULL; + + while (n < nfds) { + + poll_fd->revents = 0; + + if (poll_fd->fd < 0 || !poll_fd->events) + goto skip1; + + if (max_socket < poll_fd->fd) + max_socket = poll_fd->fd; + + if (poll_fd->events & POLLIN) + FD_SET(poll_fd->fd, &readfds); + + if (poll_fd->events & POLLOUT) + FD_SET(poll_fd->fd, &writefds); +skip1: + poll_fd++; + n++; + } + + waiting = select((int)max_socket + 1, &readfds, &writefds, NULL, ptv); + + if (waiting <= 0) + return waiting; + + poll_fd = fdarray; + + while (waiting && nfds--) { + + if (!poll_fd->events) + goto skip2; + + if (poll_fd->fd <= 0) { + poll_fd->revents = POLLNVAL; + goto skip2; + } + + if (FD_ISSET(poll_fd->fd, &readfds)) { + + /* defer POLLHUP / error detect to false read attempt */ + + poll_fd->revents |= POLLIN; + waiting--; + } + + if (FD_ISSET(poll_fd->fd, &writefds)) { + + poll_fd->revents |= poll_fd->events & POLLOUT; + waiting--; + } + + if (poll_fd->revents) + pending++; + +skip2: + poll_fd++; + } + + return pending; +} diff --git a/libs/libwebsockets/win32port/win32helpers/websock-w32.h b/libs/libwebsockets/win32port/win32helpers/websock-w32.h new file mode 100644 index 0000000000..dfd99ca917 --- /dev/null +++ b/libs/libwebsockets/win32port/win32helpers/websock-w32.h @@ -0,0 +1,64 @@ +#ifndef __WEB_SOCK_W32_H__ +#define __WEB_SOCK_W32_H__ + +// Windows uses _DEBUG and NDEBUG +#ifdef _DEBUG +#undef DEBUG +#define DEBUG 1 +#endif + +#pragma warning(disable : 4996) + +#define bzero(b,len) (memset((b), '\0', (len)), (void) 0) + +#define MSG_NOSIGNAL 0 +#define SHUT_RDWR SD_BOTH + +#define SOL_TCP IPPROTO_TCP + +#define random rand +#define usleep _sleep + +#ifdef __MINGW64__ +#define DEF_POLL_STUFF +#endif +#ifdef __MINGW32__ +#define DEF_POLL_STUFF +#endif + +#ifdef DEF_POLL_STUFF + +#include + +typedef struct pollfd { + SOCKET fd; + short events; + short revents; +} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; + +#define POLLIN 0x0001 /* any readable data available */ +#define POLLOUT 0x0004 /* file descriptor is writeable */ +#define POLLERR 0x0008 /* some poll error occurred */ +#define POLLHUP 0x0010 /* file descriptor was "hung up" */ +#define POLLNVAL 0x0020 /* requested events "invalid" */ + +#endif + +typedef INT (WSAAPI *PFNWSAPOLL)(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout); +extern PFNWSAPOLL poll; + +extern INT WSAAPI emulated_poll(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout); + +/* override configure because we are not using Makefiles */ + +#define LWS_NO_FORK + +/* windows can't cope with this idea, needs assets in cwd */ + +#ifdef INSTALL_DATADIR +#undef INSTALL_DATADIR +#endif + +#define INSTALL_DATADIR "." + +#endif diff --git a/libs/libwebsockets/win32port/win32port.sln b/libs/libwebsockets/win32port/win32port.sln new file mode 100644 index 0000000000..fc7ca7c2eb --- /dev/null +++ b/libs/libwebsockets/win32port/win32port.sln @@ -0,0 +1,100 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server\server.vcxproj", "{E585B64F-9365-4C58-9EF8-56393EB27F8B}" + ProjectSection(ProjectDependencies) = postProject + {332BF17E-FD30-4363-975A-AA731A827B4F} = {332BF17E-FD30-4363-975A-AA731A827B4F} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwebsocketswin32", "libwebsocketswin32\libwebsocketswin32.vcxproj", "{332BF17E-FD30-4363-975A-AA731A827B4F}" + ProjectSection(ProjectDependencies) = postProject + {4156FC56-8443-2973-4FE2-A0BB2C621525} = {4156FC56-8443-2973-4FE2-A0BB2C621525} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client\client.vcxproj", "{6265650C-4799-451C-A687-94DE48759A8B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "zlib\ZLib.vcxproj", "{4156FC56-8443-2973-4FE2-A0BB2C621525}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug static|Win32 = Debug static|Win32 + Debug static|x64 = Debug static|x64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release DLL|Win32 = Release DLL|Win32 + Release DLL|x64 = Release DLL|x64 + Release static|Win32 = Release static|Win32 + Release static|x64 = Release static|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {332BF17E-FD30-4363-975A-AA731A827B4F}.Debug static|Win32.ActiveCfg = Debug static|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Debug static|Win32.Build.0 = Debug static|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Debug static|x64.ActiveCfg = Debug static|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Debug|Win32.ActiveCfg = Debug|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Debug|Win32.Build.0 = Debug|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Debug|x64.ActiveCfg = Debug|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release DLL|x64.ActiveCfg = Release DLL|x64 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release DLL|x64.Build.0 = Release DLL|x64 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release static|Win32.ActiveCfg = Release static|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release static|Win32.Build.0 = Release static|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release static|x64.ActiveCfg = Release static|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release|Win32.ActiveCfg = Release|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release|Win32.Build.0 = Release|Win32 + {332BF17E-FD30-4363-975A-AA731A827B4F}.Release|x64.ActiveCfg = Release|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Debug static|Win32.ActiveCfg = Debug static|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Debug static|Win32.Build.0 = Debug static|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Debug static|x64.ActiveCfg = Debug static|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Debug|Win32.ActiveCfg = Debug|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Debug|Win32.Build.0 = Debug|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Debug|x64.ActiveCfg = Debug|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release DLL|x64.ActiveCfg = Release DLL|x64 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release DLL|x64.Build.0 = Release DLL|x64 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release static|Win32.ActiveCfg = Release static|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release static|Win32.Build.0 = Release static|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release static|x64.ActiveCfg = Release static|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release|Win32.ActiveCfg = Release|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release|Win32.Build.0 = Release|Win32 + {4156FC56-8443-2973-4FE2-A0BB2C621525}.Release|x64.ActiveCfg = Release|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Debug static|Win32.ActiveCfg = Debug static|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Debug static|Win32.Build.0 = Debug static|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Debug static|x64.ActiveCfg = Debug static|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Debug|Win32.ActiveCfg = Debug|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Debug|Win32.Build.0 = Debug|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Debug|x64.ActiveCfg = Debug|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release DLL|x64.ActiveCfg = Release DLL|x64 + {6265650C-4799-451C-A687-94DE48759A8B}.Release DLL|x64.Build.0 = Release DLL|x64 + {6265650C-4799-451C-A687-94DE48759A8B}.Release static|Win32.ActiveCfg = Release static|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release static|Win32.Build.0 = Release static|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release static|x64.ActiveCfg = Release static|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release|Win32.ActiveCfg = Release|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release|Win32.Build.0 = Release|Win32 + {6265650C-4799-451C-A687-94DE48759A8B}.Release|x64.ActiveCfg = Release|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Debug static|Win32.ActiveCfg = Debug static|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Debug static|Win32.Build.0 = Debug static|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Debug static|x64.ActiveCfg = Debug static|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Debug|Win32.ActiveCfg = Debug|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Debug|Win32.Build.0 = Debug|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Debug|x64.ActiveCfg = Debug|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release DLL|x64.ActiveCfg = Release DLL|x64 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release DLL|x64.Build.0 = Release DLL|x64 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release static|Win32.ActiveCfg = Release static|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release static|Win32.Build.0 = Release static|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release static|x64.ActiveCfg = Release static|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release|Win32.ActiveCfg = Release|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release|Win32.Build.0 = Release|Win32 + {E585B64F-9365-4C58-9EF8-56393EB27F8B}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/libwebsockets/win32port/zlib/ZLib.vcxproj b/libs/libwebsockets/win32port/zlib/ZLib.vcxproj new file mode 100644 index 0000000000..0afc43c923 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/ZLib.vcxproj @@ -0,0 +1,374 @@ + + + + + Debug static + Win32 + + + Debug + Win32 + + + Debug + x64 + + + Release DLL + Win32 + + + Release DLL + x64 + + + Release static + Win32 + + + Release + Win32 + + + Release + x64 + + + + {4156FC56-8443-2973-4FE2-A0BB2C621525} + + + + StaticLibrary + false + MultiByte + + + StaticLibrary + false + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + + + StaticLibrary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DebugV10\ + DebugV10\ + + + $(SolutionDir)..\output\ + DebugV10\ + ZLib_vc100-mt-sgd + + + DebugV10\ + DebugV10\ + + + DebugV10\ + DebugV10\ + + + .\Release\ + .\Release\ + + + .\Release\ + .\Release\ + + + $(SolutionDir)..\output\ + ZLib_vc100-mt-s + + + $(SolutionDir)..\output\ + ZLib_vc100-mt-s + + + + MultiThreadedDebugDLL + Default + false + Disabled + true + Level3 + true + EditAndContinue + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + DebugV10\ + DebugV10\ZLib.pch + DebugV10\ + DebugV10\ + EnableFastChecks + false + false + + + 0x1c09 + _DEBUG;%(PreprocessorDefinitions) + + + true + DebugV10\ZLib.bsc + + + true + DebugV10\ZLib.lib + + + + + MultiThreadedDebug + Default + false + Disabled + true + Level3 + true + EditAndContinue + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + DebugV10\ + DebugV10\ZLib.pch + DebugV10\ + DebugV10\ + EnableFastChecks + false + false + + + 0x1c09 + _DEBUG;%(PreprocessorDefinitions) + + + true + DebugV10\ZLib.bsc + + + true + $(OutDir)ZLib_vc100-mt-sgd.lib + + + + + MultiThreadedDebugDLL + Default + false + Disabled + true + Level3 + ProgramDatabase + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + DebugV10\ + DebugV10\ZLib.pch + DebugV10\ + DebugV10\ + EnableFastChecks + false + + + 0x1c09 + _DEBUG;%(PreprocessorDefinitions) + + + true + DebugV10\ZLib.bsc + + + true + DebugV10\ZLib.lib + + + + + MultiThreadedDebugDLL + Default + false + Disabled + true + Level3 + ProgramDatabase + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + DebugV10\ + DebugV10\ZLib.pch + DebugV10\ + DebugV10\ + EnableFastChecks + false + + + 0x1c09 + _DEBUG;%(PreprocessorDefinitions) + + + true + DebugV10\ZLib.bsc + + + true + DebugV10\ZLib.lib + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + .\Release\ + .\Release\ZLib.pch + .\Release\ + .\Release\ + false + false + + + 0x1c09 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\ZLib.bsc + + + true + .\Release\ZLib.lib + + + + + MultiThreadedDLL + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + .\Release\ + .\Release\ZLib.pch + .\Release\ + .\Release\ + false + + + 0x1c09 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\ZLib.bsc + + + true + .\Release\ZLib.lib + + + + + $(OutDir)ZLib_vc100-mt-s.lib + + + MultiThreaded + false + + + + + $(OutDir)ZLib_vc100-mt-s.lib + true + + + MultiThreaded + false + false + true + Speed + WIN32 + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/zlib/ZLib.vcxproj.filters b/libs/libwebsockets/win32port/zlib/ZLib.vcxproj.filters new file mode 100644 index 0000000000..3e6c18da25 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/ZLib.vcxproj.filters @@ -0,0 +1,95 @@ + + + + + {2e5deede-b2ef-40bd-950a-a7f7f0fc0413} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {85d35343-9068-43e8-875e-60b528a03c9b} + h;hpp;hxx;hm;inl + + + + + 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 + + + \ No newline at end of file diff --git a/libs/libwebsockets/win32port/zlib/adler32.c b/libs/libwebsockets/win32port/zlib/adler32.c new file mode 100644 index 0000000000..5f2bc6bf4f --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/adler32.c @@ -0,0 +1,169 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2007 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#define local static + +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); + +#define BASE 65521UL /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +/* use NO_DIVIDE if your processor does not do division in hardware */ +#ifdef NO_DIVIDE +# define MOD(a) \ + do { \ + if (a >= (BASE << 16)) a -= (BASE << 16); \ + if (a >= (BASE << 15)) a -= (BASE << 15); \ + if (a >= (BASE << 14)) a -= (BASE << 14); \ + if (a >= (BASE << 13)) a -= (BASE << 13); \ + if (a >= (BASE << 12)) a -= (BASE << 12); \ + if (a >= (BASE << 11)) a -= (BASE << 11); \ + if (a >= (BASE << 10)) a -= (BASE << 10); \ + if (a >= (BASE << 9)) a -= (BASE << 9); \ + if (a >= (BASE << 8)) a -= (BASE << 8); \ + if (a >= (BASE << 7)) a -= (BASE << 7); \ + if (a >= (BASE << 6)) a -= (BASE << 6); \ + if (a >= (BASE << 5)) a -= (BASE << 5); \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +# define MOD4(a) \ + do { \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ + if (a >= BASE) a -= BASE; \ + } while (0) +#else +# define MOD(a) a %= BASE +# define MOD4(a) a %= BASE +#endif + +/* ========================================================================= */ +uLong ZEXPORT adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +{ + unsigned long sum2; + unsigned n; + + /* split Adler-32 into component sums */ + sum2 = (adler >> 16) & 0xffff; + adler &= 0xffff; + + /* in case user likes doing a byte at a time, keep it fast */ + if (len == 1) { + adler += buf[0]; + if (adler >= BASE) + adler -= BASE; + sum2 += adler; + if (sum2 >= BASE) + sum2 -= BASE; + return adler | (sum2 << 16); + } + + /* initial Adler-32 value (deferred check for len == 1 speed) */ + if (buf == Z_NULL) + return 1L; + + /* in case short lengths are provided, keep it somewhat fast */ + if (len < 16) { + while (len--) { + adler += *buf++; + sum2 += adler; + } + if (adler >= BASE) + adler -= BASE; + MOD4(sum2); /* only added so many BASE's */ + return adler | (sum2 << 16); + } + + /* do length NMAX blocks -- requires just one modulo operation */ + while (len >= NMAX) { + len -= NMAX; + n = NMAX / 16; /* NMAX is divisible by 16 */ + do { + DO16(buf); /* 16 sums unrolled */ + buf += 16; + } while (--n); + MOD(adler); + MOD(sum2); + } + + /* do remaining bytes (less than NMAX, still just one modulo) */ + if (len) { /* avoid modulos if none remaining */ + while (len >= 16) { + len -= 16; + DO16(buf); + buf += 16; + } + while (len--) { + adler += *buf++; + sum2 += adler; + } + MOD(adler); + MOD(sum2); + } + + /* return recombined sums */ + return adler | (sum2 << 16); +} + +/* ========================================================================= */ +local uLong adler32_combine_(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off64_t len2; +{ + unsigned long sum1; + unsigned long sum2; + unsigned rem; + + /* the derivation of this formula is left as an exercise for the reader */ + rem = (unsigned)(len2 % BASE); + sum1 = adler1 & 0xffff; + sum2 = rem * sum1; + MOD(sum2); + sum1 += (adler2 & 0xffff) + BASE - 1; + sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; + if (sum1 >= BASE) sum1 -= BASE; + if (sum1 >= BASE) sum1 -= BASE; + if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); + if (sum2 >= BASE) sum2 -= BASE; + return sum1 | (sum2 << 16); +} + +/* ========================================================================= */ +uLong ZEXPORT adler32_combine(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off_t len2; +{ + return adler32_combine_(adler1, adler2, len2); +} + +uLong ZEXPORT adler32_combine64(adler1, adler2, len2) + uLong adler1; + uLong adler2; + z_off64_t len2; +{ + return adler32_combine_(adler1, adler2, len2); +} diff --git a/libs/libwebsockets/win32port/zlib/compress.c b/libs/libwebsockets/win32port/zlib/compress.c new file mode 100644 index 0000000000..c46727a416 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/compress.c @@ -0,0 +1,80 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; + int level; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} + +/* =========================================================================== + If the default memLevel or windowBits for deflateInit() is changed, then + this function needs to be updated. + */ +uLong ZEXPORT compressBound (sourceLen) + uLong sourceLen; +{ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + + (sourceLen >> 25) + 13; +} diff --git a/libs/libwebsockets/win32port/zlib/crc32.c b/libs/libwebsockets/win32port/zlib/crc32.c new file mode 100644 index 0000000000..8cb3d8fffd --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/crc32.c @@ -0,0 +1,442 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2006, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Thanks to Rodney Brown for his contribution of faster + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing + * tables for updating the shift register in one step with three exclusive-ors + * instead of four steps with four exclusive-ors. This results in about a + * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + */ + +/* @(#) $Id$ */ + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + +#include "zutil.h" /* for STDC and FAR definitions */ + +#define local static + +/* Find a four-byte integer type for crc32_little() and crc32_big(). */ +#ifndef NOBYFOUR +# ifdef STDC /* need ANSI C limits.h to determine sizes */ +# include +# define BYFOUR +# if (UINT_MAX == 0xffffffffUL) + typedef unsigned int u4; +# else +# if (ULONG_MAX == 0xffffffffUL) + typedef unsigned long u4; +# else +# if (USHRT_MAX == 0xffffffffUL) + typedef unsigned short u4; +# else +# undef BYFOUR /* can't find a four-byte integer type! */ +# endif +# endif +# endif +# endif /* STDC */ +#endif /* !NOBYFOUR */ + +/* Definitions for doing the crc four data bytes at a time. */ +#ifdef BYFOUR +# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ + (((w)&0xff00)<<8)+(((w)&0xff)<<24)) + local unsigned long crc32_little OF((unsigned long, + const unsigned char FAR *, unsigned)); + local unsigned long crc32_big OF((unsigned long, + const unsigned char FAR *, unsigned)); +# define TBLS 8 +#else +# define TBLS 1 +#endif /* BYFOUR */ + +/* Local functions for crc concatenation */ +local unsigned long gf2_matrix_times OF((unsigned long *mat, + unsigned long vec)); +local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); +local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); + + +#ifdef DYNAMIC_CRC_TABLE + +local volatile int crc_table_empty = 1; +local unsigned long FAR crc_table[TBLS][256]; +local void make_crc_table OF((void)); +#ifdef MAKECRCH + local void write_table OF((FILE *, const unsigned long FAR *)); +#endif /* MAKECRCH */ +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +local void make_crc_table() +{ + unsigned long c; + int n, k; + unsigned long poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320UL) */ + poly = 0UL; + for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) + poly |= 1UL << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (unsigned long)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + +#ifdef BYFOUR + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = REV(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = REV(c); + } + } +#endif /* BYFOUR */ + + crc_table_empty = 0; + } + else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + ; + } + +#ifdef MAKECRCH + /* write out CRC tables to crc32.h */ + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "local const unsigned long FAR "); + fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); + write_table(out, crc_table[0]); +# ifdef BYFOUR + fprintf(out, "#ifdef BYFOUR\n"); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k]); + } + fprintf(out, "#endif\n"); +# endif /* BYFOUR */ + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +local void write_table(out, table) + FILE *out; + const unsigned long FAR *table; +{ + int n; + + for (n = 0; n < 256; n++) + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const unsigned long FAR * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + return (const unsigned long FAR *)crc_table; +} + +/* ========================================================================= */ +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + uInt len; +{ + if (buf == Z_NULL) return 0UL; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + +#ifdef BYFOUR + if (sizeof(void *) == sizeof(ptrdiff_t)) { + u4 endian; + + endian = 1; + if (*((unsigned char *)(&endian))) + return crc32_little(crc, buf, len); + else + return crc32_big(crc, buf, len); + } +#endif /* BYFOUR */ + crc = crc ^ 0xffffffffUL; + while (len >= 8) { + DO8; + len -= 8; + } + if (len) do { + DO1; + } while (--len); + return crc ^ 0xffffffffUL; +} + +#ifdef BYFOUR + +/* ========================================================================= */ +#define DOLIT4 c ^= *buf4++; \ + c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ + crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 + +/* ========================================================================= */ +local unsigned long crc32_little(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = (u4)crc; + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + while (len >= 32) { + DOLIT32; + len -= 32; + } + while (len >= 4) { + DOLIT4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + } while (--len); + c = ~c; + return (unsigned long)c; +} + +/* ========================================================================= */ +#define DOBIG4 c ^= *++buf4; \ + c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ + crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 + +/* ========================================================================= */ +local unsigned long crc32_big(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = REV((u4)crc); + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4--; + while (len >= 32) { + DOBIG32; + len -= 32; + } + while (len >= 4) { + DOBIG4; + len -= 4; + } + buf4++; + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + } while (--len); + c = ~c; + return (unsigned long)(REV(c)); +} + +#endif /* BYFOUR */ + +#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ + +/* ========================================================================= */ +local unsigned long gf2_matrix_times(mat, vec) + unsigned long *mat; + unsigned long vec; +{ + unsigned long sum; + + sum = 0; + while (vec) { + if (vec & 1) + sum ^= *mat; + vec >>= 1; + mat++; + } + return sum; +} + +/* ========================================================================= */ +local void gf2_matrix_square(square, mat) + unsigned long *square; + unsigned long *mat; +{ + int n; + + for (n = 0; n < GF2_DIM; n++) + square[n] = gf2_matrix_times(mat, mat[n]); +} + +/* ========================================================================= */ +local uLong crc32_combine_(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off64_t len2; +{ + int n; + unsigned long row; + unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ + unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ + + /* degenerate case (also disallow negative lengths) */ + if (len2 <= 0) + return crc1; + + /* put operator for one zero bit in odd */ + odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ + row = 1; + for (n = 1; n < GF2_DIM; n++) { + odd[n] = row; + row <<= 1; + } + + /* put operator for two zero bits in even */ + gf2_matrix_square(even, odd); + + /* put operator for four zero bits in odd */ + gf2_matrix_square(odd, even); + + /* apply len2 zeros to crc1 (first square will put the operator for one + zero byte, eight zero bits, in even) */ + do { + /* apply zeros operator for this bit of len2 */ + gf2_matrix_square(even, odd); + if (len2 & 1) + crc1 = gf2_matrix_times(even, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + if (len2 == 0) + break; + + /* another iteration of the loop with odd and even swapped */ + gf2_matrix_square(odd, even); + if (len2 & 1) + crc1 = gf2_matrix_times(odd, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + } while (len2 != 0); + + /* return combined crc */ + crc1 ^= crc2; + return crc1; +} + +/* ========================================================================= */ +uLong ZEXPORT crc32_combine(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off_t len2; +{ + return crc32_combine_(crc1, crc2, len2); +} + +uLong ZEXPORT crc32_combine64(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off64_t len2; +{ + return crc32_combine_(crc1, crc2, len2); +} diff --git a/libs/libwebsockets/win32port/zlib/crc32.h b/libs/libwebsockets/win32port/zlib/crc32.h new file mode 100644 index 0000000000..5de49bc978 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/crc32.h @@ -0,0 +1,441 @@ +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c + */ + +local const unsigned long FAR crc_table[TBLS][256] = +{ + { + 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, + 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, + 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, + 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, + 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, + 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, + 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, + 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, + 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, + 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, + 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, + 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, + 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, + 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, + 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, + 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, + 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, + 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, + 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, + 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, + 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, + 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, + 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, + 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, + 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, + 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, + 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, + 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, + 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, + 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, + 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, + 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, + 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, + 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, + 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, + 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, + 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, + 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, + 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, + 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, + 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, + 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, + 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, + 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, + 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, + 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, + 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, + 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, + 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, + 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, + 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, + 0x2d02ef8dUL +#ifdef BYFOUR + }, + { + 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, + 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, + 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, + 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, + 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, + 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, + 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, + 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, + 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, + 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, + 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, + 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, + 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, + 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, + 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, + 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, + 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, + 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, + 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, + 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, + 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, + 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, + 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, + 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, + 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, + 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, + 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, + 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, + 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, + 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, + 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, + 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, + 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, + 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, + 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, + 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, + 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, + 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, + 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, + 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, + 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, + 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, + 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, + 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, + 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, + 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, + 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, + 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, + 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, + 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, + 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, + 0x9324fd72UL + }, + { + 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, + 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, + 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, + 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, + 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, + 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, + 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, + 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, + 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, + 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, + 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, + 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, + 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, + 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, + 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, + 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, + 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, + 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, + 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, + 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, + 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, + 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, + 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, + 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, + 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, + 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, + 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, + 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, + 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, + 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, + 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, + 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, + 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, + 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, + 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, + 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, + 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, + 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, + 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, + 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, + 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, + 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, + 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, + 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, + 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, + 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, + 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, + 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, + 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, + 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, + 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, + 0xbe9834edUL + }, + { + 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, + 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, + 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, + 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, + 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, + 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, + 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, + 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, + 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, + 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, + 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, + 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, + 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, + 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, + 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, + 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, + 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, + 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, + 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, + 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, + 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, + 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, + 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, + 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, + 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, + 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, + 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, + 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, + 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, + 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, + 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, + 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, + 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, + 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, + 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, + 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, + 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, + 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, + 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, + 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, + 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, + 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, + 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, + 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, + 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, + 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, + 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, + 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, + 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, + 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, + 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, + 0xde0506f1UL + }, + { + 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, + 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, + 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, + 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, + 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, + 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, + 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, + 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, + 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, + 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, + 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, + 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, + 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, + 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, + 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, + 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, + 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, + 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, + 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, + 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, + 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, + 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, + 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, + 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, + 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, + 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, + 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, + 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, + 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, + 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, + 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, + 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, + 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, + 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, + 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, + 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, + 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, + 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, + 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, + 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, + 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, + 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, + 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, + 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, + 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, + 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, + 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, + 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, + 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, + 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, + 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, + 0x8def022dUL + }, + { + 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, + 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, + 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, + 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, + 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, + 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, + 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, + 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, + 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, + 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, + 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, + 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, + 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, + 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, + 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, + 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, + 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, + 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, + 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, + 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, + 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, + 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, + 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, + 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, + 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, + 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, + 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, + 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, + 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, + 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, + 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, + 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, + 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, + 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, + 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, + 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, + 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, + 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, + 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, + 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, + 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, + 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, + 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, + 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, + 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, + 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, + 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, + 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, + 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, + 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, + 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, + 0x72fd2493UL + }, + { + 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, + 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, + 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, + 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, + 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, + 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, + 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, + 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, + 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, + 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, + 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, + 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, + 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, + 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, + 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, + 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, + 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, + 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, + 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, + 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, + 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, + 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, + 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, + 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, + 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, + 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, + 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, + 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, + 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, + 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, + 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, + 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, + 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, + 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, + 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, + 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, + 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, + 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, + 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, + 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, + 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, + 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, + 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, + 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, + 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, + 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, + 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, + 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, + 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, + 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, + 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, + 0xed3498beUL + }, + { + 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, + 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, + 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, + 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, + 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, + 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, + 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, + 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, + 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, + 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, + 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, + 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, + 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, + 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, + 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, + 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, + 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, + 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, + 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, + 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, + 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, + 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, + 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, + 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, + 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, + 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, + 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, + 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, + 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, + 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, + 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, + 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, + 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, + 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, + 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, + 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, + 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, + 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, + 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, + 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, + 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, + 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, + 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, + 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, + 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, + 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, + 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, + 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, + 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, + 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, + 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, + 0xf10605deUL +#endif + } +}; diff --git a/libs/libwebsockets/win32port/zlib/deflate.c b/libs/libwebsockets/win32port/zlib/deflate.c new file mode 100644 index 0000000000..fa00181166 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/deflate.c @@ -0,0 +1,1834 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in http://www.ietf.org/rfc/rfc1951.txt + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* @(#) $Id$ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +#ifndef FASTEST +local block_state deflate_slow OF((deflate_state *s, int flush)); +#endif +local block_state deflate_rle OF((deflate_state *s, int flush)); +local block_state deflate_huff OF((deflate_state *s, int flush)); +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif + +#ifdef DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +#ifdef FASTEST +local const config configuration_table[2] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ +#else +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ +#endif + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +#ifndef NO_DUMMY_DECL +struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ +#endif + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* ========================================================================= */ +int ZEXPORT deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; + int stream_size; +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; + int method; + int windowBits; + int memLevel; + int strategy; + const char *version; + int stream_size; +{ + deflate_state *s; + int wrap = 1; + static const char my_version[] = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + + if (windowBits < 0) { /* suppress zlib wrapper */ + wrap = 0; + windowBits = -windowBits; + } +#ifdef GZIP + else if (windowBits > 15) { + wrap = 2; /* write gzip wrapper instead */ + windowBits -= 16; + } +#endif + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->strm = strm; + + s->wrap = wrap; + s->gzhead = Z_NULL; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->high_water = 0; /* nothing written to s->window yet */ + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + s->status = FINISH_STATE; + strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +{ + deflate_state *s; + uInt length = dictLength; + uInt n; + IPos hash_head = 0; + + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || + strm->state->wrap == 2 || + (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) + return Z_STREAM_ERROR; + + s = strm->state; + if (s->wrap) + strm->adler = adler32(strm->adler, dictionary, dictLength); + + if (length < MIN_MATCH) return Z_OK; + if (length > s->w_size) { + length = s->w_size; + dictionary += dictLength - length; /* use the tail of the dictionary */ + } + zmemcpy(s->window, dictionary, length); + s->strstart = length; + s->block_start = (long)length; + + /* Insert all strings in the hash table (except for the last two bytes). + * s->lookahead stays null, so s->ins_h will be recomputed at the next + * call of fill_window. + */ + s->ins_h = s->window[0]; + UPDATE_HASH(s, s->ins_h, s->window[1]); + for (n = 0; n <= length - MIN_MATCH; n++) { + INSERT_STRING(s, n, hash_head); + } + if (hash_head) hash_head = 0; /* to make compiler happy */ + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { + return Z_STREAM_ERROR; + } + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->wrap < 0) { + s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ + } + s->status = s->wrap ? INIT_STATE : BUSY_STATE; + strm->adler = +#ifdef GZIP + s->wrap == 2 ? crc32(0L, Z_NULL, 0) : +#endif + adler32(0L, Z_NULL, 0); + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateSetHeader (strm, head) + z_streamp strm; + gz_headerp head; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (strm->state->wrap != 2) return Z_STREAM_ERROR; + strm->state->gzhead = head; + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflatePrime (strm, bits, value) + z_streamp strm; + int bits; + int value; +{ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + strm->state->bi_valid = bits; + strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +{ + deflate_state *s; + compress_func func; + int err = Z_OK; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + +#ifdef FASTEST + if (level != 0) level = 1; +#else + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#endif + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if ((strategy != s->strategy || func != configuration_table[level].func) && + strm->total_in != 0) { + /* Flush the last buffer: */ + err = deflate(strm, Z_BLOCK); + } + if (s->level != level) { + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return err; +} + +/* ========================================================================= */ +int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) + z_streamp strm; + int good_length; + int max_lazy; + int nice_length; + int max_chain; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + s->good_match = good_length; + s->max_lazy_match = max_lazy; + s->nice_match = nice_length; + s->max_chain_length = max_chain; + return Z_OK; +} + +/* ========================================================================= + * For the default windowBits of 15 and memLevel of 8, this function returns + * a close to exact, as well as small, upper bound on the compressed size. + * They are coded as constants here for a reason--if the #define's are + * changed, then this function needs to be changed as well. The return + * value for 15 and 8 only works for those exact settings. + * + * For any setting other than those defaults for windowBits and memLevel, + * the value returned is a conservative worst case for the maximum expansion + * resulting from using fixed blocks instead of stored blocks, which deflate + * can emit on compressed data for some combinations of the parameters. + * + * This function could be more sophisticated to provide closer upper bounds for + * every combination of windowBits and memLevel. But even the conservative + * upper bound of about 14% expansion does not seem onerous for output buffer + * allocation. + */ +uLong ZEXPORT deflateBound(strm, sourceLen) + z_streamp strm; + uLong sourceLen; +{ + deflate_state *s; + uLong complen, wraplen; + Bytef *str; + + /* conservative upper bound for compressed data */ + complen = sourceLen + + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; + + /* if can't get parameters, return conservative bound plus zlib wrapper */ + if (strm == Z_NULL || strm->state == Z_NULL) + return complen + 6; + + /* compute wrapper length */ + s = strm->state; + switch (s->wrap) { + case 0: /* raw deflate */ + wraplen = 0; + break; + case 1: /* zlib wrapper */ + wraplen = 6 + (s->strstart ? 4 : 0); + break; + case 2: /* gzip wrapper */ + wraplen = 18; + if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ + if (s->gzhead->extra != Z_NULL) + wraplen += 2 + s->gzhead->extra_len; + str = s->gzhead->name; + if (str != Z_NULL) + do { + wraplen++; + } while (*str++); + str = s->gzhead->comment; + if (str != Z_NULL) + do { + wraplen++; + } while (*str++); + if (s->gzhead->hcrc) + wraplen += 2; + } + break; + default: /* for compiler happiness */ + wraplen = 6; + } + + /* if not default parameters, return conservative bound */ + if (s->w_bits != 15 || s->hash_bits != 8 + 7) + return complen + wraplen; + + /* default settings: return tight bound for that case */ + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + + (sourceLen >> 25) + 13 - 6 + wraplen; +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB (s, b) + deflate_state *s; + uInt b; +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->next_out buffer and copying into it. + * (See also read_buf()). + */ +local void flush_pending(strm) + z_streamp strm; +{ + unsigned len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + if (strm->state->pending == 0) { + strm->state->pending_out = strm->state->pending_buf; + } +} + +/* ========================================================================= */ +int ZEXPORT deflate (strm, flush) + z_streamp strm; + int flush; +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + flush > Z_BLOCK || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + s->strm = strm; /* just in case */ + old_flush = s->last_flush; + s->last_flush = flush; + + /* Write the header */ + if (s->status == INIT_STATE) { +#ifdef GZIP + if (s->wrap == 2) { + strm->adler = crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (s->gzhead == Z_NULL) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); + s->status = BUSY_STATE; + } + else { + put_byte(s, (s->gzhead->text ? 1 : 0) + + (s->gzhead->hcrc ? 2 : 0) + + (s->gzhead->extra == Z_NULL ? 0 : 4) + + (s->gzhead->name == Z_NULL ? 0 : 8) + + (s->gzhead->comment == Z_NULL ? 0 : 16) + ); + put_byte(s, (Byte)(s->gzhead->time & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, s->gzhead->os & 0xff); + if (s->gzhead->extra != Z_NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); + } + if (s->gzhead->hcrc) + strm->adler = crc32(strm->adler, s->pending_buf, + s->pending); + s->gzindex = 0; + s->status = EXTRA_STATE; + } + } + else +#endif + { + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; + else + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + } + } +#ifdef GZIP + if (s->status == EXTRA_STATE) { + if (s->gzhead->extra != Z_NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + + while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) + break; + } + put_byte(s, s->gzhead->extra[s->gzindex]); + s->gzindex++; + } + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (s->gzindex == s->gzhead->extra_len) { + s->gzindex = 0; + s->status = NAME_STATE; + } + } + else + s->status = NAME_STATE; + } + if (s->status == NAME_STATE) { + if (s->gzhead->name != Z_NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + int val; + + do { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) { + val = 1; + break; + } + } + val = s->gzhead->name[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (val == 0) { + s->gzindex = 0; + s->status = COMMENT_STATE; + } + } + else + s->status = COMMENT_STATE; + } + if (s->status == COMMENT_STATE) { + if (s->gzhead->comment != Z_NULL) { + uInt beg = s->pending; /* start of bytes to update crc */ + int val; + + do { + if (s->pending == s->pending_buf_size) { + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + flush_pending(strm); + beg = s->pending; + if (s->pending == s->pending_buf_size) { + val = 1; + break; + } + } + val = s->gzhead->comment[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + if (s->gzhead->hcrc && s->pending > beg) + strm->adler = crc32(strm->adler, s->pending_buf + beg, + s->pending - beg); + if (val == 0) + s->status = HCRC_STATE; + } + else + s->status = HCRC_STATE; + } + if (s->status == HCRC_STATE) { + if (s->gzhead->hcrc) { + if (s->pending + 2 > s->pending_buf_size) + flush_pending(strm); + if (s->pending + 2 <= s->pending_buf_size) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + strm->adler = crc32(0L, Z_NULL, 0); + s->status = BUSY_STATE; + } + } + else + s->status = BUSY_STATE; + } +#endif + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && flush <= old_flush && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : + (s->strategy == Z_RLE ? deflate_rle(s, flush) : + (*(configuration_table[s->level].func))(s, flush)); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + if (s->lookahead == 0) { + s->strstart = 0; + s->block_start = 0L; + } + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + Assert(strm->avail_out > 0, "bug2"); + + if (flush != Z_FINISH) return Z_OK; + if (s->wrap <= 0) return Z_STREAM_END; + + /* Write the trailer */ +#ifdef GZIP + if (s->wrap == 2) { + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); + put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); + put_byte(s, (Byte)(strm->total_in & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); + put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); + } + else +#endif + { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd (strm) + z_streamp strm; +{ + int status; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && + status != EXTRA_STATE && + status != NAME_STATE && + status != COMMENT_STATE && + status != HCRC_STATE && + status != BUSY_STATE && + status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy (dest, source) + z_streamp dest; + z_streamp source; +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + zmemcpy(dest, source, sizeof(z_stream)); + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + zmemcpy(ds, ss, sizeof(deflate_state)); + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif /* MAXSEG_64K */ +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local int read_buf(strm, buf, size) + z_streamp strm; + Bytef *buf; + unsigned size; +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, strm->next_in, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, strm->next_in, len); + } +#endif + zmemcpy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init (s) + deflate_state *s; +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifndef FASTEST +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +#endif +} + +#ifndef FASTEST +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks below + * for insufficient lookahead only occur occasionally for performance + * reasons. Therefore uninitialized memory will be accessed, and + * conditional jumps will be made that depend on those values. + * However the length of the match is limited to the lookahead, so + * the output of deflate is not affected by the uninitialized values. + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} +#endif /* ASMV */ + +#else /* FASTEST */ + +/* --------------------------------------------------------------------------- + * Optimized version for FASTEST only + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; +} + +#endif /* FASTEST */ + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(s, start, match, length) + deflate_state *s; + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif /* DEBUG */ + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(s) + deflate_state *s; +{ + register unsigned n, m; + register Posf *p; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif + more += wsize; + } + if (s->strm->avail_in == 0) return; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead >= MIN_MATCH) { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, last) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (last)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, last) { \ + FLUSH_BLOCK_ONLY(s, last); \ + if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +local block_state deflate_stored(s, flush) + deflate_state *s; + int flush; +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + ulg max_block_size = 0xffff; + ulg max_start; + + if (max_block_size > s->pending_buf_size - 5) { + max_block_size = s->pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s->lookahead <= 1) { + + Assert(s->strstart < s->w_size+MAX_DIST(s) || + s->block_start >= (long)s->w_size, "slide too late"); + + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + + if (s->lookahead == 0) break; /* flush the current block */ + } + Assert(s->block_start >= 0L, "block gone"); + + s->strstart += s->lookahead; + s->lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; + FLUSH_BLOCK(s, 0); + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { + FLUSH_BLOCK(s, 0); + } + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match (s, hash_head); + /* longest_match() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +#ifndef FASTEST +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = NIL; + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s->match_length = longest_match (s, hash_head); + /* longest_match() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED +#if TOO_FAR <= 32767 + || (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR) +#endif + )) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} +#endif /* FASTEST */ + +/* =========================================================================== + * For Z_RLE, simply look for runs of bytes, generate matches only of distance + * one. Do not maintain a hash table. (It will be regenerated if this run of + * deflate switches away from Z_RLE.) + */ +local block_state deflate_rle(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + uInt prev; /* byte at distance one to match */ + Bytef *scan, *strend; /* scan goes up to strend for length of run */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the longest encodable run. + */ + if (s->lookahead < MAX_MATCH) { + fill_window(s); + if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* See how many times the previous byte repeats */ + s->match_length = 0; + if (s->lookahead >= MIN_MATCH && s->strstart > 0) { + scan = s->window + s->strstart - 1; + prev = *scan; + if (prev == *++scan && prev == *++scan && prev == *++scan) { + strend = s->window + s->strstart + MAX_MATCH; + do { + } while (prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + prev == *++scan && prev == *++scan && + scan < strend); + s->match_length = MAX_MATCH - (int)(strend - scan); + if (s->match_length > s->lookahead) + s->match_length = s->lookahead; + } + } + + /* Emit match if have run of MIN_MATCH or longer, else emit literal */ + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->strstart - 1, s->match_length); + + _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + s->strstart += s->match_length; + s->match_length = 0; + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. + * (It will be regenerated if this run of deflate switches away from Huffman.) + */ +local block_state deflate_huff(s, flush) + deflate_state *s; + int flush; +{ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we have a literal to write. */ + if (s->lookahead == 0) { + fill_window(s); + if (s->lookahead == 0) { + if (flush == Z_NO_FLUSH) + return need_more; + break; /* flush the current block */ + } + } + + /* Output a literal byte */ + s->match_length = 0; + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} diff --git a/libs/libwebsockets/win32port/zlib/deflate.h b/libs/libwebsockets/win32port/zlib/deflate.h new file mode 100644 index 0000000000..e9044c1da2 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/deflate.h @@ -0,0 +1,342 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2010 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define EXTRA_STATE 69 +#define NAME_STATE 73 +#define COMMENT_STATE 91 +#define HCRC_STATE 103 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + uInt pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + uInt gzindex; /* where in extra, name, or comment */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + + ulg high_water; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +#define WIN_INIT MAX_MATCH +/* Number of bytes after end of data in window to initialize in order to avoid + memory checker errors from longest match routines */ + + /* in trees.c */ +void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); +int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, + ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); +void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, + ulg stored_len, int last)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch ZLIB_INTERNAL _length_code[]; + extern uch ZLIB_INTERNAL _dist_code[]; +#else + extern const uch ZLIB_INTERNAL _length_code[]; + extern const uch ZLIB_INTERNAL _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ diff --git a/libs/libwebsockets/win32port/zlib/gzclose.c b/libs/libwebsockets/win32port/zlib/gzclose.c new file mode 100755 index 0000000000..cbf0db663b --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/gzclose.c @@ -0,0 +1,25 @@ +/* gzclose.c -- zlib gzclose() function + * Copyright (C) 2004, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +/* gzclose() is in a separate file so that it is linked in only if it is used. + That way the other gzclose functions can be used instead to avoid linking in + unneeded compression or decompression routines. */ +int ZEXPORT gzclose(file) + gzFile file; +{ +#ifndef NO_GZCOMPRESS + gz_statep state; + + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); +#else + return gzclose_r(file); +#endif +} diff --git a/libs/libwebsockets/win32port/zlib/gzguts.h b/libs/libwebsockets/win32port/zlib/gzguts.h new file mode 100755 index 0000000000..7ff93a8dd8 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/gzguts.h @@ -0,0 +1,132 @@ +/* gzguts.h -- zlib internal header definitions for gz* operations + * Copyright (C) 2004, 2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifdef _LARGEFILE64_SOURCE +# ifndef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# endif +# ifdef _FILE_OFFSET_BITS +# undef _FILE_OFFSET_BITS +# endif +#endif + +#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include +#include "zlib.h" +#ifdef STDC +# include +# include +# include +#endif +#include + +#ifdef NO_DEFLATE /* for compatibility with old definition */ +# define NO_GZCOMPRESS +#endif + +#ifdef _MSC_VER +# include +# define vsnprintf _vsnprintf +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +/* gz* functions always use library allocation functions */ +#ifndef STDC + extern voidp malloc OF((uInt size)); + extern void free OF((voidpf ptr)); +#endif + +/* get errno and strerror definition */ +#if defined UNDER_CE +# include +# define zstrerror() gz_strwinerror((DWORD)GetLastError()) +#else +# ifdef STDC +# include +# define zstrerror() strerror(errno) +# else +# define zstrerror() "stdio error (consult errno)" +# endif +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); +#endif + +/* default i/o buffer size -- double this for output when reading */ +#define GZBUFSIZE 8192 + +/* gzip modes, also provide a little integrity check on the passed structure */ +#define GZ_NONE 0 +#define GZ_READ 7247 +#define GZ_WRITE 31153 +#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ + +/* values for gz_state how */ +#define LOOK 0 /* look for a gzip header */ +#define COPY 1 /* copy input directly */ +#define GZIP 2 /* decompress a gzip stream */ + +/* internal gzip file state data structure */ +typedef struct { + /* used for both reading and writing */ + int mode; /* see gzip modes above */ + int fd; /* file descriptor */ + char *path; /* path or fd for error messages */ + z_off64_t pos; /* current position in uncompressed data */ + unsigned size; /* buffer size, zero if not allocated yet */ + unsigned want; /* requested buffer size, default is GZBUFSIZE */ + unsigned char *in; /* input buffer */ + unsigned char *out; /* output buffer (double-sized when reading) */ + unsigned char *next; /* next output data to deliver or write */ + /* just for reading */ + unsigned have; /* amount of output data unused at next */ + int eof; /* true if end of input file reached */ + z_off64_t start; /* where the gzip data started, for rewinding */ + z_off64_t raw; /* where the raw data started, for seeking */ + int how; /* 0: get header, 1: copy, 2: decompress */ + int direct; /* true if last read direct, false if gzip */ + /* just for writing */ + int level; /* compression level */ + int strategy; /* compression strategy */ + /* seek request */ + z_off64_t skip; /* amount to skip (already rewound if backwards) */ + int seek; /* true if seek request pending */ + /* error information */ + int err; /* error code */ + char *msg; /* error message */ + /* zlib inflate or deflate stream */ + z_stream strm; /* stream structure in-place (not a pointer) */ +} gz_state; +typedef gz_state FAR *gz_statep; + +/* shared functions */ +void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); +#if defined UNDER_CE +char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +#endif + +/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t + value -- needed when comparing unsigned to z_off64_t, which is signed + (possible z_off64_t types off_t, off64_t, and long are all signed) */ +#ifdef INT_MAX +# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) +#else +unsigned ZLIB_INTERNAL gz_intmax OF((void)); +# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) +#endif diff --git a/libs/libwebsockets/win32port/zlib/gzio.c b/libs/libwebsockets/win32port/zlib/gzio.c new file mode 100644 index 0000000000..26f2da1e97 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/gzio.c @@ -0,0 +1,1005 @@ +/* gzio.c -- IO on .gz files + * Copyright (C) 1995-2003 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. + */ + +/* @(#) $Id$ */ + +#include + +#include "zutil.h" + +#ifdef NO_DEFLATE /* for compatiblity with old definition */ +# define NO_GZCOMPRESS +#endif + +#ifndef NO_DUMMY_DECL +struct internal_state {int dummy;}; /* for buggy compilers */ +#endif + +#ifndef Z_BUFSIZE +# ifdef MAXSEG_64K +# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ +# else +# define Z_BUFSIZE 16384 +# endif +#endif +#ifndef Z_PRINTF_BUFSIZE +# define Z_PRINTF_BUFSIZE 4096 +#endif + +#ifdef __MVS__ +# pragma map (fdopen , "\174\174FDOPEN") + FILE *fdopen(int, const char *); +#endif + +#ifndef STDC +extern voidp malloc OF((uInt size)); +extern void free OF((voidpf ptr)); +#endif + +#define ALLOC(size) malloc(size) +#define TRYFREE(p) {if (p) free(p);} + +static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +typedef struct gz_stream { + z_stream stream; + int z_err; /* error code for last stream operation */ + int z_eof; /* set if end of input file */ + FILE *file; /* .gz file */ + Byte *inbuf; /* input buffer */ + Byte *outbuf; /* output buffer */ + uLong crc; /* crc32 of uncompressed data */ + char *msg; /* error message */ + char *path; /* path name for debugging only */ + int transparent; /* 1 if input file is not a .gz file */ + char mode; /* 'w' or 'r' */ + z_off_t start; /* start of compressed data in file (header skipped) */ + z_off_t in; /* bytes into deflate or inflate */ + z_off_t out; /* bytes out of deflate or inflate */ + int back; /* one character push-back */ + int last; /* true if push-back is last character */ +} gz_stream; + + +local gzFile gz_open OF((const char *path, const char *mode, int fd)); +local int do_flush OF((gzFile file, int flush)); +local int get_byte OF((gz_stream *s)); +local void check_header OF((gz_stream *s)); +local int destroy OF((gz_stream *s)); +local void putLong OF((FILE *file, uLong x)); +local uLong getLong OF((gz_stream *s)); + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb"). The file is given either by file descriptor + or path name (if fd == -1). + gz_open returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). +*/ +local gzFile gz_open (path, mode, fd) + const char *path; + const char *mode; + int fd; +{ + int err; + int level = Z_DEFAULT_COMPRESSION; /* compression level */ + int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ + char *p = (char*)mode; + gz_stream *s; + char fmode[80]; /* copy of mode, without the compression level */ + char *m = fmode; + + if (!path || !mode) return Z_NULL; + + s = (gz_stream *)ALLOC(sizeof(gz_stream)); + if (!s) return Z_NULL; + + s->stream.zalloc = (alloc_func)0; + s->stream.zfree = (free_func)0; + s->stream.opaque = (voidpf)0; + s->stream.next_in = s->inbuf = Z_NULL; + s->stream.next_out = s->outbuf = Z_NULL; + s->stream.avail_in = s->stream.avail_out = 0; + s->file = NULL; + s->z_err = Z_OK; + s->z_eof = 0; + s->in = 0; + s->out = 0; + s->back = EOF; + s->crc = crc32(0L, Z_NULL, 0); + s->msg = NULL; + s->transparent = 0; + + s->path = (char*)ALLOC(strlen(path)+1); + if (s->path == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + strcpy(s->path, path); /* do this early for debugging */ + + s->mode = '\0'; + do { + if (*p == 'r') s->mode = 'r'; + if (*p == 'w' || *p == 'a') s->mode = 'w'; + if (*p >= '0' && *p <= '9') { + level = *p - '0'; + } else if (*p == 'f') { + strategy = Z_FILTERED; + } else if (*p == 'h') { + strategy = Z_HUFFMAN_ONLY; + } else if (*p == 'R') { + strategy = Z_RLE; + } else { + *m++ = *p; /* copy the mode */ + } + } while (*p++ && m != fmode + sizeof(fmode)); + if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; + + if (s->mode == 'w') { +#ifdef NO_GZCOMPRESS + err = Z_STREAM_ERROR; +#else + err = deflateInit2(&(s->stream), level, + Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); + /* windowBits is passed < 0 to suppress zlib header */ + + s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); +#endif + if (err != Z_OK || s->outbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } else { + s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); + + err = inflateInit2(&(s->stream), -MAX_WBITS); + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are + * present after the compressed stream. + */ + if (err != Z_OK || s->inbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } + s->stream.avail_out = Z_BUFSIZE; + + errno = 0; + s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); + + if (s->file == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + if (s->mode == 'w') { + /* Write a very simple .gz header: + */ + fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], + Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); + s->start = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an + * fflush on some systems. This version of the library doesn't use + * start anyway in write mode, so this initialization is not + * necessary. + */ + } else { + check_header(s); /* skip the .gz header */ + s->start = ftell(s->file) - s->stream.avail_in; + } + + return (gzFile)s; +} + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. +*/ +gzFile ZEXPORT gzopen (path, mode) + const char *path; + const char *mode; +{ + return gz_open (path, mode, -1); +} + +/* =========================================================================== + Associate a gzFile with the file descriptor fd. fd is not dup'ed here + to mimic the behavio(u)r of fdopen. +*/ +gzFile ZEXPORT gzdopen (fd, mode) + int fd; + const char *mode; +{ + char name[20]; + + if (fd < 0) return (gzFile)Z_NULL; + sprintf(name, "", fd); /* for debugging */ + + return gz_open (name, mode, fd); +} + +/* =========================================================================== + * Update the compression level and strategy + */ +int ZEXPORT gzsetparams (file, level, strategy) + gzFile file; + int level; + int strategy; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + /* Make room to allow flushing */ + if (s->stream.avail_out == 0) { + + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + } + s->stream.avail_out = Z_BUFSIZE; + } + + return deflateParams (&(s->stream), level, strategy); +} + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ +local int get_byte(s) + gz_stream *s; +{ + if (s->z_eof) return EOF; + if (s->stream.avail_in == 0) { + errno = 0; + s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) s->z_err = Z_ERRNO; + return EOF; + } + s->stream.next_in = s->inbuf; + } + s->stream.avail_in--; + return *(s->stream.next_in)++; +} + +/* =========================================================================== + Check the gzip header of a gz_stream opened for reading. Set the stream + mode to transparent if the gzip magic header is not present; set s->err + to Z_DATA_ERROR if the magic header is present but the rest of the header + is incorrect. + IN assertion: the stream s has already been created sucessfully; + s->stream.avail_in is zero for the first time, but may be non-zero + for concatenated .gz files. +*/ +local void check_header(s) + gz_stream *s; +{ + int method; /* method byte */ + int flags; /* flags byte */ + uInt len; + int c; + + /* Assure two bytes in the buffer so we can peek ahead -- handle case + where first byte of header is at the end of the buffer after the last + gzip segment */ + len = s->stream.avail_in; + if (len < 2) { + if (len) s->inbuf[0] = s->stream.next_in[0]; + errno = 0; + len = fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); + if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; + s->stream.avail_in += len; + s->stream.next_in = s->inbuf; + if (s->stream.avail_in < 2) { + s->transparent = s->stream.avail_in; + return; + } + } + + /* Peek ahead to check the gzip magic header */ + if (s->stream.next_in[0] != gz_magic[0] || + s->stream.next_in[1] != gz_magic[1]) { + s->transparent = 1; + return; + } + s->stream.avail_in -= 2; + s->stream.next_in += 2; + + /* Check the rest of the gzip header */ + method = get_byte(s); + flags = get_byte(s); + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + s->z_err = Z_DATA_ERROR; + return; + } + + /* Discard time, xflags and OS code: */ + for (len = 0; len < 6; len++) (void)get_byte(s); + + if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ + len = (uInt)get_byte(s); + len += ((uInt)get_byte(s))<<8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(s) != EOF) ; + } + if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ + for (len = 0; len < 2; len++) (void)get_byte(s); + } + s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; +} + + /* =========================================================================== + * Cleanup then free the given gz_stream. Return a zlib error code. + Try freeing in the reverse order of allocations. + */ +local int destroy (s) + gz_stream *s; +{ + int err = Z_OK; + + if (!s) return Z_STREAM_ERROR; + + TRYFREE(s->msg); + + if (s->stream.state != NULL) { + if (s->mode == 'w') { +#ifdef NO_GZCOMPRESS + err = Z_STREAM_ERROR; +#else + err = deflateEnd(&(s->stream)); +#endif + } else if (s->mode == 'r') { + err = inflateEnd(&(s->stream)); + } + } + if (s->file != NULL && fclose(s->file)) { +#ifdef ESPIPE + if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ +#endif + err = Z_ERRNO; + } + if (s->z_err < 0) err = s->z_err; + + TRYFREE(s->inbuf); + TRYFREE(s->outbuf); + TRYFREE(s->path); + TRYFREE(s); + return err; +} + +/* =========================================================================== + Reads the given number of uncompressed bytes from the compressed file. + gzread returns the number of bytes actually read (0 for end of file). +*/ +int ZEXPORT gzread (file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + gz_stream *s = (gz_stream*)file; + Bytef *start = (Bytef*)buf; /* starting point for crc computation */ + Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ + + if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; + + if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; + if (s->z_err == Z_STREAM_END) return 0; /* EOF */ + + next_out = (Byte*)buf; + s->stream.next_out = (Bytef*)buf; + s->stream.avail_out = len; + + if (s->stream.avail_out && s->back != EOF) { + *next_out++ = s->back; + s->stream.next_out++; + s->stream.avail_out--; + s->back = EOF; + s->out++; + if (s->last) { + s->z_err = Z_STREAM_END; + return 1; + } + } + + while (s->stream.avail_out != 0) { + + if (s->transparent) { + /* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + if (n > s->stream.avail_out) n = s->stream.avail_out; + if (n > 0) { + zmemcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) { + s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, + s->file); + } + len -= s->stream.avail_out; + s->in += len; + s->out += len; + if (len == 0) s->z_eof = 1; + return (int)len; + } + if (s->stream.avail_in == 0 && !s->z_eof) { + + errno = 0; + s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) { + s->z_err = Z_ERRNO; + break; + } + } + s->stream.next_in = s->inbuf; + } + s->in += s->stream.avail_in; + s->out += s->stream.avail_out; + s->z_err = inflate(&(s->stream), Z_NO_FLUSH); + s->in -= s->stream.avail_in; + s->out -= s->stream.avail_out; + + if (s->z_err == Z_STREAM_END) { + /* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + start = s->stream.next_out; + + if (getLong(s) != s->crc) { + s->z_err = Z_DATA_ERROR; + } else { + (void)getLong(s); + /* The uncompressed length returned by above getlong() may be + * different from s->out in case of concatenated .gz files. + * Check for such files: + */ + check_header(s); + if (s->z_err == Z_OK) { + inflateReset(&(s->stream)); + s->crc = crc32(0L, Z_NULL, 0); + } + } + } + if (s->z_err != Z_OK || s->z_eof) break; + } + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + + return (int)(len - s->stream.avail_out); +} + + +/* =========================================================================== + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ +int ZEXPORT gzgetc(file) + gzFile file; +{ + unsigned char c; + + return gzread(file, &c, 1) == 1 ? c : -1; +} + + +/* =========================================================================== + Push one byte back onto the stream. +*/ +int ZEXPORT gzungetc(c, file) + int c; + gzFile file; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; + s->back = c; + s->out--; + s->last = (s->z_err == Z_STREAM_END); + if (s->last) s->z_err = Z_OK; + s->z_eof = 0; + return c; +} + + +/* =========================================================================== + Reads bytes from the compressed file until len-1 characters are + read, or a newline character is read and transferred to buf, or an + end-of-file condition is encountered. The string is then terminated + with a null character. + gzgets returns buf, or Z_NULL in case of error. + + The current implementation is not optimized at all. +*/ +char * ZEXPORT gzgets(file, buf, len) + gzFile file; + char *buf; + int len; +{ + char *b = buf; + if (buf == Z_NULL || len <= 0) return Z_NULL; + + while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; + *buf = '\0'; + return b == buf && len > 0 ? Z_NULL : b; +} + + +#ifndef NO_GZCOMPRESS +/* =========================================================================== + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of bytes actually written (0 in case of error). +*/ +int ZEXPORT gzwrite (file, buf, len) + gzFile file; + voidpc buf; + unsigned len; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.next_in = (Bytef*)buf; + s->stream.avail_in = len; + + while (s->stream.avail_in != 0) { + + if (s->stream.avail_out == 0) { + + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + break; + } + s->stream.avail_out = Z_BUFSIZE; + } + s->in += s->stream.avail_in; + s->out += s->stream.avail_out; + s->z_err = deflate(&(s->stream), Z_NO_FLUSH); + s->in -= s->stream.avail_in; + s->out -= s->stream.avail_out; + if (s->z_err != Z_OK) break; + } + s->crc = crc32(s->crc, (const Bytef *)buf, len); + + return (int)(len - s->stream.avail_in); +} + + +/* =========================================================================== + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ +#ifdef STDC +#include + +int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) +{ + char buf[Z_PRINTF_BUFSIZE]; + va_list va; + int len; + + buf[sizeof(buf) - 1] = 0; + va_start(va, format); +#ifdef NO_vsnprintf +# ifdef HAS_vsprintf_void + (void)vsprintf(buf, format, va); + va_end(va); + for (len = 0; len < sizeof(buf); len++) + if (buf[len] == 0) break; +# else + len = vsprintf(buf, format, va); + va_end(va); +# endif +#else +# ifdef HAS_vsnprintf_void + (void)vsnprintf(buf, sizeof(buf), format, va); + va_end(va); + len = strlen(buf); +# else + len = vsnprintf(buf, sizeof(buf), format, va); + va_end(va); +# endif +#endif + if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) + return 0; + return gzwrite(file, buf, (unsigned)len); +} +#else /* not ANSI C */ + +int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) + gzFile file; + const char *format; + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; +{ + char buf[Z_PRINTF_BUFSIZE]; + int len; + + buf[sizeof(buf) - 1] = 0; +#ifdef NO_snprintf +# ifdef HAS_sprintf_void + sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + for (len = 0; len < sizeof(buf); len++) + if (buf[len] == 0) break; +# else + len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +# endif +#else +# ifdef HAS_snprintf_void + snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = strlen(buf); +# else + len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +# endif +#endif + if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) + return 0; + return gzwrite(file, buf, len); +} +#endif + +/* =========================================================================== + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ +int ZEXPORT gzputc(file, c) + gzFile file; + int c; +{ + unsigned char cc = (unsigned char) c; /* required for big endian systems */ + + return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; +} + + +/* =========================================================================== + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ +int ZEXPORT gzputs(file, s) + gzFile file; + const char *s; +{ + return gzwrite(file, (char*)s, (unsigned)strlen(s)); +} + + +/* =========================================================================== + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. +*/ +local int do_flush (file, flush) + gzFile file; + int flush; +{ + uInt len; + int done = 0; + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.avail_in = 0; /* should be zero already anyway */ + + for (;;) { + len = Z_BUFSIZE - s->stream.avail_out; + + if (len != 0) { + if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { + s->z_err = Z_ERRNO; + return Z_ERRNO; + } + s->stream.next_out = s->outbuf; + s->stream.avail_out = Z_BUFSIZE; + } + if (done) break; + s->out += s->stream.avail_out; + s->z_err = deflate(&(s->stream), flush); + s->out -= s->stream.avail_out; + + /* Ignore the second of two consecutive flushes: */ + if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; + + /* deflate has finished flushing only when it hasn't used up + * all the available space in the output buffer: + */ + done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); + + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; + } + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; +} + +int ZEXPORT gzflush (file, flush) + gzFile file; + int flush; +{ + gz_stream *s = (gz_stream*)file; + int err = do_flush (file, flush); + + if (err) return err; + fflush(s->file); + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; +} +#endif /* NO_GZCOMPRESS */ + +/* =========================================================================== + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error. + SEEK_END is not implemented, returns error. + In this version of the library, gzseek can be extremely slow. +*/ +z_off_t ZEXPORT gzseek (file, offset, whence) + gzFile file; + z_off_t offset; + int whence; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || whence == SEEK_END || + s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { + return -1L; + } + + if (s->mode == 'w') { +#ifdef NO_GZCOMPRESS + return -1L; +#else + if (whence == SEEK_SET) { + offset -= s->in; + } + if (offset < 0) return -1L; + + /* At this point, offset is the number of zero bytes to write. */ + if (s->inbuf == Z_NULL) { + s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ + if (s->inbuf == Z_NULL) return -1L; + zmemzero(s->inbuf, Z_BUFSIZE); + } + while (offset > 0) { + uInt size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (uInt)offset; + + size = gzwrite(file, s->inbuf, size); + if (size == 0) return -1L; + + offset -= size; + } + return s->in; +#endif + } + /* Rest of function is for reading only */ + + /* compute absolute position */ + if (whence == SEEK_CUR) { + offset += s->out; + } + if (offset < 0) return -1L; + + if (s->transparent) { + /* map to fseek */ + s->back = EOF; + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; + if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; + + s->in = s->out = offset; + return offset; + } + + /* For a negative seek, rewind and use positive seek */ + if (offset >= s->out) { + offset -= s->out; + } else if (gzrewind(file) < 0) { + return -1L; + } + /* offset is now the number of bytes to skip. */ + + if (offset != 0 && s->outbuf == Z_NULL) { + s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); + if (s->outbuf == Z_NULL) return -1L; + } + if (offset && s->back != EOF) { + s->back = EOF; + s->out++; + offset--; + if (s->last) s->z_err = Z_STREAM_END; + } + while (offset > 0) { + int size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (int)offset; + + size = gzread(file, s->outbuf, (uInt)size); + if (size <= 0) return -1L; + offset -= size; + } + return s->out; +} + +/* =========================================================================== + Rewinds input file. +*/ +int ZEXPORT gzrewind (file) + gzFile file; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'r') return -1; + + s->z_err = Z_OK; + s->z_eof = 0; + s->back = EOF; + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; + s->crc = crc32(0L, Z_NULL, 0); + if (!s->transparent) (void)inflateReset(&s->stream); + s->in = 0; + s->out = 0; + return fseek(s->file, s->start, SEEK_SET); +} + +/* =========================================================================== + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. +*/ +z_off_t ZEXPORT gztell (file) + gzFile file; +{ + return gzseek(file, 0L, SEEK_CUR); +} + +/* =========================================================================== + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ +int ZEXPORT gzeof (file) + gzFile file; +{ + gz_stream *s = (gz_stream*)file; + + /* With concatenated compressed files that can have embedded + * crc trailers, z_eof is no longer the only/best indicator of EOF + * on a gz_stream. Handle end-of-stream error explicitly here. + */ + if (s == NULL || s->mode != 'r') return 0; + if (s->z_eof) return 1; + return s->z_err == Z_STREAM_END; +} + +/* =========================================================================== + Outputs a long in LSB order to the given file +*/ +local void putLong (file, x) + FILE *file; + uLong x; +{ + int n; + for (n = 0; n < 4; n++) { + fputc((int)(x & 0xff), file); + x >>= 8; + } +} + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets z_err in case + of error. +*/ +local uLong getLong (s) + gz_stream *s; +{ + uLong x = (uLong)get_byte(s); + int c; + + x += ((uLong)get_byte(s))<<8; + x += ((uLong)get_byte(s))<<16; + c = get_byte(s); + if (c == EOF) s->z_err = Z_DATA_ERROR; + x += ((uLong)c)<<24; + return x; +} + +/* =========================================================================== + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. +*/ +int ZEXPORT gzclose (file) + gzFile file; +{ + int err; + gz_stream *s = (gz_stream*)file; + + if (s == NULL) return Z_STREAM_ERROR; + + if (s->mode == 'w') { +#ifdef NO_GZCOMPRESS + return Z_STREAM_ERROR; +#else + err = do_flush (file, Z_FINISH); + if (err != Z_OK) return destroy((gz_stream*)file); + + putLong (s->file, s->crc); + putLong (s->file, (uLong)(s->in & 0xffffffff)); +#endif + } + return destroy((gz_stream*)file); +} + +/* =========================================================================== + Returns the error message for the last error which occured on the + given compressed file. errnum is set to zlib error number. If an + error occured in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ +const char * ZEXPORT gzerror (file, errnum) + gzFile file; + int *errnum; +{ + char *m; + gz_stream *s = (gz_stream*)file; + + if (s == NULL) { + *errnum = Z_STREAM_ERROR; + return (const char*)ERR_MSG(Z_STREAM_ERROR); + } + *errnum = s->z_err; + if (*errnum == Z_OK) return (const char*)""; + + m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); + + if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); + + TRYFREE(s->msg); + s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); + if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); + strcpy(s->msg, s->path); + strcat(s->msg, ": "); + strcat(s->msg, m); + return (const char*)s->msg; +} + +/* =========================================================================== + Clear the error and end-of-file flags, and do the same for the real file. +*/ +void ZEXPORT gzclearerr (file) + gzFile file; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL) return; + if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; + s->z_eof = 0; + clearerr(s->file); +} diff --git a/libs/libwebsockets/win32port/zlib/gzlib.c b/libs/libwebsockets/win32port/zlib/gzlib.c new file mode 100755 index 0000000000..65efced42a --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/gzlib.c @@ -0,0 +1,537 @@ +/* gzlib.c -- zlib functions common to reading and writing gzip files + * Copyright (C) 2004, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +# define LSEEK lseek64 +#else +# define LSEEK lseek +#endif + +/* Local functions */ +local void gz_reset OF((gz_statep)); +local gzFile gz_open OF((const char *, int, const char *)); + +#if defined UNDER_CE + +/* Map the Windows error number in ERROR to a locale-dependent error message + string and return a pointer to it. Typically, the values for ERROR come + from GetLastError. + + The string pointed to shall not be modified by the application, but may be + overwritten by a subsequent call to gz_strwinerror + + The gz_strwinerror function does not change the current setting of + GetLastError. */ +char ZLIB_INTERNAL *gz_strwinerror (error) + DWORD error; +{ + static char buf[1024]; + + wchar_t *msgbuf; + DWORD lasterr = GetLastError(); + DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_ALLOCATE_BUFFER, + NULL, + error, + 0, /* Default language */ + (LPVOID)&msgbuf, + 0, + NULL); + if (chars != 0) { + /* If there is an \r\n appended, zap it. */ + if (chars >= 2 + && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { + chars -= 2; + msgbuf[chars] = 0; + } + + if (chars > sizeof (buf) - 1) { + chars = sizeof (buf) - 1; + msgbuf[chars] = 0; + } + + wcstombs(buf, msgbuf, chars + 1); + LocalFree(msgbuf); + } + else { + sprintf(buf, "unknown win32 error (%ld)", error); + } + + SetLastError(lasterr); + return buf; +} + +#endif /* UNDER_CE */ + +/* Reset gzip file state */ +local void gz_reset(state) + gz_statep state; +{ + if (state->mode == GZ_READ) { /* for reading ... */ + state->have = 0; /* no output data available */ + state->eof = 0; /* not at end of file */ + state->how = LOOK; /* look for gzip header */ + state->direct = 1; /* default for empty file */ + } + state->seek = 0; /* no seek request pending */ + gz_error(state, Z_OK, NULL); /* clear error */ + state->pos = 0; /* no uncompressed data yet */ + state->strm.avail_in = 0; /* no input data yet */ +} + +/* Open a gzip file either by name or file descriptor. */ +local gzFile gz_open(path, fd, mode) + const char *path; + int fd; + const char *mode; +{ + gz_statep state; + + /* allocate gzFile structure to return */ + state = malloc(sizeof(gz_state)); + if (state == NULL) + return NULL; + state->size = 0; /* no buffers allocated yet */ + state->want = GZBUFSIZE; /* requested buffer size */ + state->msg = NULL; /* no error message yet */ + + /* interpret mode */ + state->mode = GZ_NONE; + state->level = Z_DEFAULT_COMPRESSION; + state->strategy = Z_DEFAULT_STRATEGY; + while (*mode) { + if (*mode >= '0' && *mode <= '9') + state->level = *mode - '0'; + else + switch (*mode) { + case 'r': + state->mode = GZ_READ; + break; +#ifndef NO_GZCOMPRESS + case 'w': + state->mode = GZ_WRITE; + break; + case 'a': + state->mode = GZ_APPEND; + break; +#endif + case '+': /* can't read and write at the same time */ + free(state); + return NULL; + case 'b': /* ignore -- will request binary anyway */ + break; + case 'f': + state->strategy = Z_FILTERED; + break; + case 'h': + state->strategy = Z_HUFFMAN_ONLY; + break; + case 'R': + state->strategy = Z_RLE; + break; + case 'F': + state->strategy = Z_FIXED; + default: /* could consider as an error, but just ignore */ + ; + } + mode++; + } + + /* must provide an "r", "w", or "a" */ + if (state->mode == GZ_NONE) { + free(state); + return NULL; + } + + /* save the path name for error messages */ + state->path = malloc(strlen(path) + 1); + if (state->path == NULL) { + free(state); + return NULL; + } + strcpy(state->path, path); + + /* open the file with the appropriate mode (or just use fd) */ + state->fd = fd != -1 ? fd : + open(path, +#ifdef O_LARGEFILE + O_LARGEFILE | +#endif +#ifdef O_BINARY + O_BINARY | +#endif + (state->mode == GZ_READ ? + O_RDONLY : + (O_WRONLY | O_CREAT | ( + state->mode == GZ_WRITE ? + O_TRUNC : + O_APPEND))), + 0666); + if (state->fd == -1) { + free(state->path); + free(state); + return NULL; + } + if (state->mode == GZ_APPEND) + state->mode = GZ_WRITE; /* simplify later checks */ + + /* save the current position for rewinding (only if reading) */ + if (state->mode == GZ_READ) { + state->start = LSEEK(state->fd, 0, SEEK_CUR); + if (state->start == -1) state->start = 0; + } + + /* initialize stream */ + gz_reset(state); + + /* return stream */ + return (gzFile)state; +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT gzopen(path, mode) + const char *path; + const char *mode; +{ + return gz_open(path, -1, mode); +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT gzopen64(path, mode) + const char *path; + const char *mode; +{ + return gz_open(path, -1, mode); +} + +/* -- see zlib.h -- */ +gzFile ZEXPORT gzdopen(fd, mode) + int fd; + const char *mode; +{ + char *path; /* identifier for error messages */ + gzFile gz; + + if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL) + return NULL; + sprintf(path, "", fd); /* for debugging */ + gz = gz_open(path, fd, mode); + free(path); + return gz; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzbuffer(file, size) + gzFile file; + unsigned size; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* make sure we haven't already allocated memory */ + if (state->size != 0) + return -1; + + /* check and set requested size */ + if (size == 0) + return -1; + state->want = size; + return 0; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzrewind(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no error */ + if (state->mode != GZ_READ || state->err != Z_OK) + return -1; + + /* back up and start over */ + if (LSEEK(state->fd, state->start, SEEK_SET) == -1) + return -1; + gz_reset(state); + return 0; +} + +/* -- see zlib.h -- */ +z_off64_t ZEXPORT gzseek64(file, offset, whence) + gzFile file; + z_off64_t offset; + int whence; +{ + unsigned n; + z_off64_t ret; + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* check that there's no error */ + if (state->err != Z_OK) + return -1; + + /* can only seek from start or relative to current position */ + if (whence != SEEK_SET && whence != SEEK_CUR) + return -1; + + /* normalize offset to a SEEK_CUR specification */ + if (whence == SEEK_SET) + offset -= state->pos; + else if (state->seek) + offset += state->skip; + state->seek = 0; + + /* if within raw area while reading, just go there */ + if (state->mode == GZ_READ && state->how == COPY && + state->pos + offset >= state->raw) { + ret = LSEEK(state->fd, offset - state->have, SEEK_CUR); + if (ret == -1) + return -1; + state->have = 0; + state->eof = 0; + state->seek = 0; + gz_error(state, Z_OK, NULL); + state->strm.avail_in = 0; + state->pos += offset; + return state->pos; + } + + /* calculate skip amount, rewinding if needed for back seek when reading */ + if (offset < 0) { + if (state->mode != GZ_READ) /* writing -- can't go backwards */ + return -1; + offset += state->pos; + if (offset < 0) /* before start of file! */ + return -1; + if (gzrewind(file) == -1) /* rewind, then skip to offset */ + return -1; + } + + /* if reading, skip what's in output buffer (one less gzgetc() check) */ + if (state->mode == GZ_READ) { + n = GT_OFF(state->have) || (z_off64_t)state->have > offset ? + (unsigned)offset : state->have; + state->have -= n; + state->next += n; + state->pos += n; + offset -= n; + } + + /* request skip (if not zero) */ + if (offset) { + state->seek = 1; + state->skip = offset; + } + return state->pos + offset; +} + +/* -- see zlib.h -- */ +z_off_t ZEXPORT gzseek(file, offset, whence) + gzFile file; + z_off_t offset; + int whence; +{ + z_off64_t ret; + + ret = gzseek64(file, (z_off64_t)offset, whence); + return ret == (z_off_t)ret ? (z_off_t)ret : -1; +} + +/* -- see zlib.h -- */ +z_off64_t ZEXPORT gztell64(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* return position */ + return state->pos + (state->seek ? state->skip : 0); +} + +/* -- see zlib.h -- */ +z_off_t ZEXPORT gztell(file) + gzFile file; +{ + z_off64_t ret; + + ret = gztell64(file); + return ret == (z_off_t)ret ? (z_off_t)ret : -1; +} + +/* -- see zlib.h -- */ +z_off64_t ZEXPORT gzoffset64(file) + gzFile file; +{ + z_off64_t offset; + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return -1; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return -1; + + /* compute and return effective offset in file */ + offset = LSEEK(state->fd, 0, SEEK_CUR); + if (offset == -1) + return -1; + if (state->mode == GZ_READ) /* reading */ + offset -= state->strm.avail_in; /* don't count buffered input */ + return offset; +} + +/* -- see zlib.h -- */ +z_off_t ZEXPORT gzoffset(file) + gzFile file; +{ + z_off64_t ret; + + ret = gzoffset64(file); + return ret == (z_off_t)ret ? (z_off_t)ret : -1; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzeof(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return 0; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return 0; + + /* return end-of-file state */ + return state->mode == GZ_READ ? + (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0; +} + +/* -- see zlib.h -- */ +const char * ZEXPORT gzerror(file, errnum) + gzFile file; + int *errnum; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return NULL; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return NULL; + + /* return error information */ + if (errnum != NULL) + *errnum = state->err; + return state->msg == NULL ? "" : state->msg; +} + +/* -- see zlib.h -- */ +void ZEXPORT gzclearerr(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure and check integrity */ + if (file == NULL) + return; + state = (gz_statep)file; + if (state->mode != GZ_READ && state->mode != GZ_WRITE) + return; + + /* clear error and end-of-file */ + if (state->mode == GZ_READ) + state->eof = 0; + gz_error(state, Z_OK, NULL); +} + +/* Create an error message in allocated memory and set state->err and + state->msg accordingly. Free any previous error message already there. Do + not try to free or allocate space if the error is Z_MEM_ERROR (out of + memory). Simply save the error message as a static string. If there is an + allocation failure constructing the error message, then convert the error to + out of memory. */ +void ZLIB_INTERNAL gz_error(state, err, msg) + gz_statep state; + int err; + const char *msg; +{ + /* free previously allocated message and clear */ + if (state->msg != NULL) { + if (state->err != Z_MEM_ERROR) + free(state->msg); + state->msg = NULL; + } + + /* set error code, and if no message, then done */ + state->err = err; + if (msg == NULL) + return; + + /* for an out of memory error, save as static string */ + if (err == Z_MEM_ERROR) { + state->msg = (char *)msg; + return; + } + + /* construct error message with path */ + if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) { + state->err = Z_MEM_ERROR; + state->msg = (char *)"out of memory"; + return; + } + strcpy(state->msg, state->path); + strcat(state->msg, ": "); + strcat(state->msg, msg); + return; +} + +#ifndef INT_MAX +/* portably return maximum value for an int (when limits.h presumed not + available) -- we need to do this to cover cases where 2's complement not + used, since C standard permits 1's complement and sign-bit representations, + otherwise we could just use ((unsigned)-1) >> 1 */ +unsigned ZLIB_INTERNAL gz_intmax() +{ + unsigned p, q; + + p = 1; + do { + q = p; + p <<= 1; + p++; + } while (p > q); + return q >> 1; +} +#endif diff --git a/libs/libwebsockets/win32port/zlib/gzread.c b/libs/libwebsockets/win32port/zlib/gzread.c new file mode 100755 index 0000000000..0f8649b32f --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/gzread.c @@ -0,0 +1,653 @@ +/* gzread.c -- zlib functions for reading gzip files + * Copyright (C) 2004, 2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +/* Local functions */ +local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); +local int gz_avail OF((gz_statep)); +local int gz_next4 OF((gz_statep, unsigned long *)); +local int gz_head OF((gz_statep)); +local int gz_decomp OF((gz_statep)); +local int gz_make OF((gz_statep)); +local int gz_skip OF((gz_statep, z_off64_t)); + +/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from + state->fd, and update state->eof, state->err, and state->msg as appropriate. + This function needs to loop on read(), since read() is not guaranteed to + read the number of bytes requested, depending on the type of descriptor. */ +local int gz_load(state, buf, len, have) + gz_statep state; + unsigned char *buf; + unsigned len; + unsigned *have; +{ + int ret; + + *have = 0; + do { + ret = read(state->fd, buf + *have, len - *have); + if (ret <= 0) + break; + *have += ret; + } while (*have < len); + if (ret < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + if (ret == 0) + state->eof = 1; + return 0; +} + +/* Load up input buffer and set eof flag if last data loaded -- return -1 on + error, 0 otherwise. Note that the eof flag is set when the end of the input + file is reached, even though there may be unused data in the buffer. Once + that data has been used, no more attempts will be made to read the file. + gz_avail() assumes that strm->avail_in == 0. */ +local int gz_avail(state) + gz_statep state; +{ + z_streamp strm = &(state->strm); + + if (state->err != Z_OK) + return -1; + if (state->eof == 0) { + if (gz_load(state, state->in, state->size, + (unsigned *)&(strm->avail_in)) == -1) + return -1; + strm->next_in = state->in; + } + return 0; +} + +/* Get next byte from input, or -1 if end or error. */ +#define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \ + (strm->avail_in == 0 ? -1 : \ + (strm->avail_in--, *(strm->next_in)++))) + +/* Get a four-byte little-endian integer and return 0 on success and the value + in *ret. Otherwise -1 is returned and *ret is not modified. */ +local int gz_next4(state, ret) + gz_statep state; + unsigned long *ret; +{ + int ch; + unsigned long val; + z_streamp strm = &(state->strm); + + val = NEXT(); + val += (unsigned)NEXT() << 8; + val += (unsigned long)NEXT() << 16; + ch = NEXT(); + if (ch == -1) + return -1; + val += (unsigned long)ch << 24; + *ret = val; + return 0; +} + +/* Look for gzip header, set up for inflate or copy. state->have must be zero. + If this is the first time in, allocate required memory. state->how will be + left unchanged if there is no more input data available, will be set to COPY + if there is no gzip header and direct copying will be performed, or it will + be set to GZIP for decompression, and the gzip header will be skipped so + that the next available input data is the raw deflate stream. If direct + copying, then leftover input data from the input buffer will be copied to + the output buffer. In that case, all further file reads will be directly to + either the output buffer or a user buffer. If decompressing, the inflate + state and the check value will be initialized. gz_head() will return 0 on + success or -1 on failure. Failures may include read errors or gzip header + errors. */ +local int gz_head(state) + gz_statep state; +{ + z_streamp strm = &(state->strm); + int flags; + unsigned len; + + /* allocate read buffers and inflate memory */ + if (state->size == 0) { + /* allocate buffers */ + state->in = malloc(state->want); + state->out = malloc(state->want << 1); + if (state->in == NULL || state->out == NULL) { + if (state->out != NULL) + free(state->out); + if (state->in != NULL) + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + state->size = state->want; + + /* allocate inflate memory */ + state->strm.zalloc = Z_NULL; + state->strm.zfree = Z_NULL; + state->strm.opaque = Z_NULL; + state->strm.avail_in = 0; + state->strm.next_in = Z_NULL; + if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */ + free(state->out); + free(state->in); + state->size = 0; + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + } + + /* get some data in the input buffer */ + if (strm->avail_in == 0) { + if (gz_avail(state) == -1) + return -1; + if (strm->avail_in == 0) + return 0; + } + + /* look for the gzip magic header bytes 31 and 139 */ + if (strm->next_in[0] == 31) { + strm->avail_in--; + strm->next_in++; + if (strm->avail_in == 0 && gz_avail(state) == -1) + return -1; + if (strm->avail_in && strm->next_in[0] == 139) { + /* we have a gzip header, woo hoo! */ + strm->avail_in--; + strm->next_in++; + + /* skip rest of header */ + if (NEXT() != 8) { /* compression method */ + gz_error(state, Z_DATA_ERROR, "unknown compression method"); + return -1; + } + flags = NEXT(); + if (flags & 0xe0) { /* reserved flag bits */ + gz_error(state, Z_DATA_ERROR, "unknown header flags set"); + return -1; + } + NEXT(); /* modification time */ + NEXT(); + NEXT(); + NEXT(); + NEXT(); /* extra flags */ + NEXT(); /* operating system */ + if (flags & 4) { /* extra field */ + len = (unsigned)NEXT(); + len += (unsigned)NEXT() << 8; + while (len--) + if (NEXT() < 0) + break; + } + if (flags & 8) /* file name */ + while (NEXT() > 0) + ; + if (flags & 16) /* comment */ + while (NEXT() > 0) + ; + if (flags & 2) { /* header crc */ + NEXT(); + NEXT(); + } + /* an unexpected end of file is not checked for here -- it will be + noticed on the first request for uncompressed data */ + + /* set up for decompression */ + inflateReset(strm); + strm->adler = crc32(0L, Z_NULL, 0); + state->how = GZIP; + state->direct = 0; + return 0; + } + else { + /* not a gzip file -- save first byte (31) and fall to raw i/o */ + state->out[0] = 31; + state->have = 1; + } + } + + /* doing raw i/o, save start of raw data for seeking, copy any leftover + input to output -- this assumes that the output buffer is larger than + the input buffer, which also assures space for gzungetc() */ + state->raw = state->pos; + state->next = state->out; + if (strm->avail_in) { + memcpy(state->next + state->have, strm->next_in, strm->avail_in); + state->have += strm->avail_in; + strm->avail_in = 0; + } + state->how = COPY; + state->direct = 1; + return 0; +} + +/* Decompress from input to the provided next_out and avail_out in the state. + If the end of the compressed data is reached, then verify the gzip trailer + check value and length (modulo 2^32). state->have and state->next are set + to point to the just decompressed data, and the crc is updated. If the + trailer is verified, state->how is reset to LOOK to look for the next gzip + stream or raw data, once state->have is depleted. Returns 0 on success, -1 + on failure. Failures may include invalid compressed data or a failed gzip + trailer verification. */ +local int gz_decomp(state) + gz_statep state; +{ + int ret; + unsigned had; + unsigned long crc, len; + z_streamp strm = &(state->strm); + + /* fill output buffer up to end of deflate stream */ + had = strm->avail_out; + do { + /* get more input for inflate() */ + if (strm->avail_in == 0 && gz_avail(state) == -1) + return -1; + if (strm->avail_in == 0) { + gz_error(state, Z_DATA_ERROR, "unexpected end of file"); + return -1; + } + + /* decompress and handle errors */ + ret = inflate(strm, Z_NO_FLUSH); + if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { + gz_error(state, Z_STREAM_ERROR, + "internal error: inflate stream corrupt"); + return -1; + } + if (ret == Z_MEM_ERROR) { + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ + gz_error(state, Z_DATA_ERROR, + strm->msg == NULL ? "compressed data error" : strm->msg); + return -1; + } + } while (strm->avail_out && ret != Z_STREAM_END); + + /* update available output and crc check value */ + state->have = had - strm->avail_out; + state->next = strm->next_out - state->have; + strm->adler = crc32(strm->adler, state->next, state->have); + + /* check gzip trailer if at end of deflate stream */ + if (ret == Z_STREAM_END) { + if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) { + gz_error(state, Z_DATA_ERROR, "unexpected end of file"); + return -1; + } + if (crc != strm->adler) { + gz_error(state, Z_DATA_ERROR, "incorrect data check"); + return -1; + } + if (len != (strm->total_out & 0xffffffffL)) { + gz_error(state, Z_DATA_ERROR, "incorrect length check"); + return -1; + } + state->how = LOOK; /* ready for next stream, once have is 0 (leave + state->direct unchanged to remember how) */ + } + + /* good decompression */ + return 0; +} + +/* Make data and put in the output buffer. Assumes that state->have == 0. + Data is either copied from the input file or decompressed from the input + file depending on state->how. If state->how is LOOK, then a gzip header is + looked for (and skipped if found) to determine wither to copy or decompress. + Returns -1 on error, otherwise 0. gz_make() will leave state->have as COPY + or GZIP unless the end of the input file has been reached and all data has + been processed. */ +local int gz_make(state) + gz_statep state; +{ + z_streamp strm = &(state->strm); + + if (state->how == LOOK) { /* look for gzip header */ + if (gz_head(state) == -1) + return -1; + if (state->have) /* got some data from gz_head() */ + return 0; + } + if (state->how == COPY) { /* straight copy */ + if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1) + return -1; + state->next = state->out; + } + else if (state->how == GZIP) { /* decompress */ + strm->avail_out = state->size << 1; + strm->next_out = state->out; + if (gz_decomp(state) == -1) + return -1; + } + return 0; +} + +/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ +local int gz_skip(state, len) + gz_statep state; + z_off64_t len; +{ + unsigned n; + + /* skip over len bytes or reach end-of-file, whichever comes first */ + while (len) + /* skip over whatever is in output buffer */ + if (state->have) { + n = GT_OFF(state->have) || (z_off64_t)state->have > len ? + (unsigned)len : state->have; + state->have -= n; + state->next += n; + state->pos += n; + len -= n; + } + + /* output buffer empty -- return if we're at the end of the input */ + else if (state->eof && state->strm.avail_in == 0) + break; + + /* need more data to skip -- load up output buffer */ + else { + /* get more output, looking for header if required */ + if (gz_make(state) == -1) + return -1; + } + return 0; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzread(file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + unsigned got, n; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're reading and that there's no error */ + if (state->mode != GZ_READ || state->err != Z_OK) + return -1; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids the flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_BUF_ERROR, "requested length does not fit in int"); + return -1; + } + + /* if len is zero, avoid unnecessary operations */ + if (len == 0) + return 0; + + /* process a skip request */ + if (state->seek) { + state->seek = 0; + if (gz_skip(state, state->skip) == -1) + return -1; + } + + /* get len bytes to buf, or less than len if at the end */ + got = 0; + do { + /* first just try copying data from the output buffer */ + if (state->have) { + n = state->have > len ? len : state->have; + memcpy(buf, state->next, n); + state->next += n; + state->have -= n; + } + + /* output buffer empty -- return if we're at the end of the input */ + else if (state->eof && strm->avail_in == 0) + break; + + /* need output data -- for small len or new stream load up our output + buffer */ + else if (state->how == LOOK || len < (state->size << 1)) { + /* get more output, looking for header if required */ + if (gz_make(state) == -1) + return -1; + continue; /* no progress yet -- go back to memcpy() above */ + /* the copy above assures that we will leave with space in the + output buffer, allowing at least one gzungetc() to succeed */ + } + + /* large len -- read directly into user buffer */ + else if (state->how == COPY) { /* read directly */ + if (gz_load(state, buf, len, &n) == -1) + return -1; + } + + /* large len -- decompress directly into user buffer */ + else { /* state->how == GZIP */ + strm->avail_out = len; + strm->next_out = buf; + if (gz_decomp(state) == -1) + return -1; + n = state->have; + state->have = 0; + } + + /* update progress */ + len -= n; + buf = (char *)buf + n; + got += n; + state->pos += n; + } while (len); + + /* return number of bytes read into user buffer (will fit in int) */ + return (int)got; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzgetc(file) + gzFile file; +{ + int ret; + unsigned char buf[1]; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no error */ + if (state->mode != GZ_READ || state->err != Z_OK) + return -1; + + /* try output buffer (no need to check for skip request) */ + if (state->have) { + state->have--; + state->pos++; + return *(state->next)++; + } + + /* nothing there -- try gzread() */ + ret = gzread(file, buf, 1); + return ret < 1 ? -1 : buf[0]; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzungetc(c, file) + int c; + gzFile file; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no error */ + if (state->mode != GZ_READ || state->err != Z_OK) + return -1; + + /* process a skip request */ + if (state->seek) { + state->seek = 0; + if (gz_skip(state, state->skip) == -1) + return -1; + } + + /* can't push EOF */ + if (c < 0) + return -1; + + /* if output buffer empty, put byte at end (allows more pushing) */ + if (state->have == 0) { + state->have = 1; + state->next = state->out + (state->size << 1) - 1; + state->next[0] = c; + state->pos--; + return c; + } + + /* if no room, give up (must have already done a gzungetc()) */ + if (state->have == (state->size << 1)) { + gz_error(state, Z_BUF_ERROR, "out of room to push characters"); + return -1; + } + + /* slide output data if needed and insert byte before existing data */ + if (state->next == state->out) { + unsigned char *src = state->out + state->have; + unsigned char *dest = state->out + (state->size << 1); + while (src > state->out) + *--dest = *--src; + state->next = dest; + } + state->have++; + state->next--; + state->next[0] = c; + state->pos--; + return c; +} + +/* -- see zlib.h -- */ +char * ZEXPORT gzgets(file, buf, len) + gzFile file; + char *buf; + int len; +{ + unsigned left, n; + char *str; + unsigned char *eol; + gz_statep state; + + /* check parameters and get internal structure */ + if (file == NULL || buf == NULL || len < 1) + return NULL; + state = (gz_statep)file; + + /* check that we're reading and that there's no error */ + if (state->mode != GZ_READ || state->err != Z_OK) + return NULL; + + /* process a skip request */ + if (state->seek) { + state->seek = 0; + if (gz_skip(state, state->skip) == -1) + return NULL; + } + + /* copy output bytes up to new line or len - 1, whichever comes first -- + append a terminating zero to the string (we don't check for a zero in + the contents, let the user worry about that) */ + str = buf; + left = (unsigned)len - 1; + if (left) do { + /* assure that something is in the output buffer */ + if (state->have == 0) { + if (gz_make(state) == -1) + return NULL; /* error */ + if (state->have == 0) { /* end of file */ + if (buf == str) /* got bupkus */ + return NULL; + break; /* got something -- return it */ + } + } + + /* look for end-of-line in current output buffer */ + n = state->have > left ? left : state->have; + eol = memchr(state->next, '\n', n); + if (eol != NULL) + n = (unsigned)(eol - state->next) + 1; + + /* copy through end-of-line, or remainder if not found */ + memcpy(buf, state->next, n); + state->have -= n; + state->next += n; + state->pos += n; + left -= n; + buf += n; + } while (left && eol == NULL); + + /* found end-of-line or out of space -- terminate string and return it */ + buf[0] = 0; + return str; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzdirect(file) + gzFile file; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're reading */ + if (state->mode != GZ_READ) + return 0; + + /* if the state is not known, but we can find out, then do so (this is + mainly for right after a gzopen() or gzdopen()) */ + if (state->how == LOOK && state->have == 0) + (void)gz_head(state); + + /* return 1 if reading direct, 0 if decompressing a gzip stream */ + return state->direct; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzclose_r(file) + gzFile file; +{ + int ret; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + /* check that we're reading */ + if (state->mode != GZ_READ) + return Z_STREAM_ERROR; + + /* free memory and close file */ + if (state->size) { + inflateEnd(&(state->strm)); + free(state->out); + free(state->in); + } + gz_error(state, Z_OK, NULL); + free(state->path); + ret = close(state->fd); + free(state); + return ret ? Z_ERRNO : Z_OK; +} diff --git a/libs/libwebsockets/win32port/zlib/gzwrite.c b/libs/libwebsockets/win32port/zlib/gzwrite.c new file mode 100755 index 0000000000..e2bcf9d2b8 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/gzwrite.c @@ -0,0 +1,531 @@ +/* gzwrite.c -- zlib functions for writing gzip files + * Copyright (C) 2004, 2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "gzguts.h" + +/* Local functions */ +local int gz_init OF((gz_statep)); +local int gz_comp OF((gz_statep, int)); +local int gz_zero OF((gz_statep, z_off64_t)); + +/* Initialize state for writing a gzip file. Mark initialization by setting + state->size to non-zero. Return -1 on failure or 0 on success. */ +local int gz_init(state) + gz_statep state; +{ + int ret; + z_streamp strm = &(state->strm); + + /* allocate input and output buffers */ + state->in = malloc(state->want); + state->out = malloc(state->want); + if (state->in == NULL || state->out == NULL) { + if (state->out != NULL) + free(state->out); + if (state->in != NULL) + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + + /* allocate deflate memory, set up for gzip compression */ + strm->zalloc = Z_NULL; + strm->zfree = Z_NULL; + strm->opaque = Z_NULL; + ret = deflateInit2(strm, state->level, Z_DEFLATED, + 15 + 16, 8, state->strategy); + if (ret != Z_OK) { + free(state->in); + gz_error(state, Z_MEM_ERROR, "out of memory"); + return -1; + } + + /* mark state as initialized */ + state->size = state->want; + + /* initialize write buffer */ + strm->avail_out = state->size; + strm->next_out = state->out; + state->next = strm->next_out; + return 0; +} + +/* Compress whatever is at avail_in and next_in and write to the output file. + Return -1 if there is an error writing to the output file, otherwise 0. + flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH, + then the deflate() state is reset to start a new gzip stream. */ +local int gz_comp(state, flush) + gz_statep state; + int flush; +{ + int ret, got; + unsigned have; + z_streamp strm = &(state->strm); + + /* allocate memory if this is the first time through */ + if (state->size == 0 && gz_init(state) == -1) + return -1; + + /* run deflate() on provided input until it produces no more output */ + ret = Z_OK; + do { + /* write out current buffer contents if full, or if flushing, but if + doing Z_FINISH then don't write until we get to Z_STREAM_END */ + if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && + (flush != Z_FINISH || ret == Z_STREAM_END))) { + have = (unsigned)(strm->next_out - state->next); + if (have && ((got = write(state->fd, state->next, have)) < 0 || + (unsigned)got != have)) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + if (strm->avail_out == 0) { + strm->avail_out = state->size; + strm->next_out = state->out; + } + state->next = strm->next_out; + } + + /* compress */ + have = strm->avail_out; + ret = deflate(strm, flush); + if (ret == Z_STREAM_ERROR) { + gz_error(state, Z_STREAM_ERROR, + "internal error: deflate stream corrupt"); + return -1; + } + have -= strm->avail_out; + } while (have); + + /* if that completed a deflate stream, allow another to start */ + if (flush == Z_FINISH) + deflateReset(strm); + + /* all done, no errors */ + return 0; +} + +/* Compress len zeros to output. Return -1 on error, 0 on success. */ +local int gz_zero(state, len) + gz_statep state; + z_off64_t len; +{ + int first; + unsigned n; + z_streamp strm = &(state->strm); + + /* consume whatever's left in the input buffer */ + if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + return -1; + + /* compress len zeros (len guaranteed > 0) */ + first = 1; + while (len) { + n = GT_OFF(state->size) || (z_off64_t)state->size > len ? + (unsigned)len : state->size; + if (first) { + memset(state->in, 0, n); + first = 0; + } + strm->avail_in = n; + strm->next_in = state->in; + state->pos += n; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return -1; + len -= n; + } + return 0; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzwrite(file, buf, len) + gzFile file; + voidpc buf; + unsigned len; +{ + unsigned put = len; + unsigned n; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids the flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_BUF_ERROR, "requested length does not fit in int"); + return 0; + } + + /* if len is zero, avoid unnecessary operations */ + if (len == 0) + return 0; + + /* allocate memory if this is the first time through */ + if (state->size == 0 && gz_init(state) == -1) + return 0; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return 0; + } + + /* for small len, copy to input buffer, otherwise compress directly */ + if (len < state->size) { + /* copy to input buffer, compress when full */ + do { + if (strm->avail_in == 0) + strm->next_in = state->in; + n = state->size - strm->avail_in; + if (n > len) + n = len; + memcpy(strm->next_in + strm->avail_in, buf, n); + strm->avail_in += n; + state->pos += n; + buf = (char *)buf + n; + len -= n; + if (len && gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + } while (len); + } + else { + /* consume whatever's left in the input buffer */ + if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + + /* directly compress user buffer to file */ + strm->avail_in = len; + strm->next_in = (voidp)buf; + state->pos += len; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + } + + /* input was all buffered or compressed (put will fit in int) */ + return (int)put; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzputc(file, c) + gzFile file; + int c; +{ + unsigned char buf[1]; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return -1; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return -1; + } + + /* try writing to input buffer for speed (state->size == 0 if buffer not + initialized) */ + if (strm->avail_in < state->size) { + if (strm->avail_in == 0) + strm->next_in = state->in; + strm->next_in[strm->avail_in++] = c; + state->pos++; + return c; + } + + /* no room in buffer or not initialized, use gz_write() */ + buf[0] = c; + if (gzwrite(file, buf, 1) != 1) + return -1; + return c; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzputs(file, str) + gzFile file; + const char *str; +{ + int ret; + unsigned len; + + /* write string */ + len = (unsigned)strlen(str); + ret = gzwrite(file, str, len); + return ret == 0 && len != 0 ? -1 : ret; +} + +#ifdef STDC +#include + +/* -- see zlib.h -- */ +int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) +{ + int size, len; + gz_statep state; + z_streamp strm; + va_list va; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* make sure we have some buffer space */ + if (state->size == 0 && gz_init(state) == -1) + return 0; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return 0; + } + + /* consume whatever's left in the input buffer */ + if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + + /* do the printf() into the input buffer, put length in len */ + size = (int)(state->size); + state->in[size - 1] = 0; + va_start(va, format); +#ifdef NO_vsnprintf +# ifdef HAS_vsprintf_void + (void)vsprintf(state->in, format, va); + va_end(va); + for (len = 0; len < size; len++) + if (state->in[len] == 0) break; +# else + len = vsprintf(state->in, format, va); + va_end(va); +# endif +#else +# ifdef HAS_vsnprintf_void + (void)vsnprintf(state->in, size, format, va); + va_end(va); + len = strlen(state->in); +# else + len = vsnprintf((char *)(state->in), size, format, va); + va_end(va); +# endif +#endif + + /* check that printf() results fit in buffer */ + if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) + return 0; + + /* update buffer and position, defer compression until needed */ + strm->avail_in = (unsigned)len; + strm->next_in = state->in; + state->pos += len; + return len; +} + +#else /* !STDC */ + +/* -- see zlib.h -- */ +int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) + gzFile file; + const char *format; + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; +{ + int size, len; + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* make sure we have some buffer space */ + if (state->size == 0 && gz_init(state) == -1) + return 0; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return 0; + } + + /* consume whatever's left in the input buffer */ + if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + + /* do the printf() into the input buffer, put length in len */ + size = (int)(state->size); + state->in[size - 1] = 0; +#ifdef NO_snprintf +# ifdef HAS_sprintf_void + sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + for (len = 0; len < size; len++) + if (state->in[len] == 0) break; +# else + len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +# endif +#else +# ifdef HAS_snprintf_void + snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = strlen(state->in); +# else + len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +# endif +#endif + + /* check that printf() results fit in buffer */ + if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) + return 0; + + /* update buffer and position, defer compression until needed */ + strm->avail_in = (unsigned)len; + strm->next_in = state->in; + state->pos += len; + return len; +} + +#endif + +/* -- see zlib.h -- */ +int ZEXPORT gzflush(file, flush) + gzFile file; + int flush; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; + + /* check flush parameter */ + if (flush < 0 || flush > Z_FINISH) + return Z_STREAM_ERROR; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return -1; + } + + /* compress remaining data with requested flush */ + gz_comp(state, flush); + return state->err; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzsetparams(file, level, strategy) + gzFile file; + int level; + int strategy; +{ + gz_statep state; + z_streamp strm; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + strm = &(state->strm); + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; + + /* if no change is requested, then do nothing */ + if (level == state->level && strategy == state->strategy) + return Z_OK; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + if (gz_zero(state, state->skip) == -1) + return -1; + } + + /* change compression parameters for subsequent input */ + if (state->size) { + /* flush previous input with previous parameters before changing */ + if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1) + return state->err; + deflateParams(strm, level, strategy); + } + state->level = level; + state->strategy = strategy; + return Z_OK; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzclose_w(file) + gzFile file; +{ + int ret = 0; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return Z_STREAM_ERROR; + state = (gz_statep)file; + + /* check that we're writing */ + if (state->mode != GZ_WRITE) + return Z_STREAM_ERROR; + + /* check for seek request */ + if (state->seek) { + state->seek = 0; + ret += gz_zero(state, state->skip); + } + + /* flush, free memory, and close file */ + ret += gz_comp(state, Z_FINISH); + (void)deflateEnd(&(state->strm)); + free(state->out); + free(state->in); + gz_error(state, Z_OK, NULL); + free(state->path); + ret += close(state->fd); + free(state); + return ret ? Z_ERRNO : Z_OK; +} diff --git a/libs/libwebsockets/win32port/zlib/infback.c b/libs/libwebsockets/win32port/zlib/infback.c new file mode 100644 index 0000000000..14770c5635 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/infback.c @@ -0,0 +1,632 @@ +/* infback.c -- inflate using a call-back interface + * Copyright (C) 1995-2009 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + This code is largely copied from inflate.c. Normally either infback.o or + inflate.o would be linked into an application--not both. The interface + with inffast.c is retained so that optimized assembler-coded versions of + inflate_fast() can be used with either inflate.c or infback.c. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); + +/* + strm provides memory allocation functions in zalloc and zfree, or + Z_NULL to use the library memory allocation functions. + + windowBits is in the range 8..15, and window is a user-supplied + window and output buffer that is 2**windowBits bytes. + */ +int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) +z_streamp strm; +int windowBits; +unsigned char FAR *window; +const char *version; +int stream_size; +{ + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL || window == Z_NULL || + windowBits < 8 || windowBits > 15) + return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *)ZALLOC(strm, 1, + sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + state->dmax = 32768U; + state->wbits = windowBits; + state->wsize = 1U << windowBits; + state->window = window; + state->wnext = 0; + state->whave = 0; + return Z_OK; +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +/* Macros for inflateBack(): */ + +/* Load returned state from inflate_fast() */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Set state from registers for inflate_fast() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Assure that some input is available. If input is requested, but denied, + then return a Z_BUF_ERROR from inflateBack(). */ +#define PULL() \ + do { \ + if (have == 0) { \ + have = in(in_desc, &next); \ + if (have == 0) { \ + next = Z_NULL; \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflateBack() + with an error if there is no input available. */ +#define PULLBYTE() \ + do { \ + PULL(); \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflateBack() with + an error. */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Assure that some output space is available, by writing out the window + if it's full. If the write fails, return from inflateBack() with a + Z_BUF_ERROR. */ +#define ROOM() \ + do { \ + if (left == 0) { \ + put = state->window; \ + left = state->wsize; \ + state->whave = left; \ + if (out(out_desc, put, left)) { \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + +/* + strm provides the memory allocation functions and window buffer on input, + and provides information on the unused input on return. For Z_DATA_ERROR + returns, strm will also provide an error message. + + in() and out() are the call-back input and output functions. When + inflateBack() needs more input, it calls in(). When inflateBack() has + filled the window with output, or when it completes with data in the + window, it calls out() to write out the data. The application must not + change the provided input until in() is called again or inflateBack() + returns. The application must not change the window/output buffer until + inflateBack() returns. + + in() and out() are called with a descriptor parameter provided in the + inflateBack() call. This parameter can be a structure that provides the + information required to do the read or write, as well as accumulated + information on the input and output such as totals and check values. + + in() should return zero on failure. out() should return non-zero on + failure. If either in() or out() fails, than inflateBack() returns a + Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it + was in() or out() that caused in the error. Otherwise, inflateBack() + returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format + error, or Z_MEM_ERROR if it could not allocate memory for the state. + inflateBack() can also return Z_STREAM_ERROR if the input parameters + are not correct, i.e. strm is Z_NULL or the state was not initialized. + */ +int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) +z_streamp strm; +in_func in; +void FAR *in_desc; +out_func out; +void FAR *out_desc; +{ + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + /* Check that the strm exists and that the state was initialized */ + if (strm == Z_NULL || strm->state == Z_NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* Reset the state */ + strm->msg = Z_NULL; + state->mode = TYPE; + state->last = 0; + state->whave = 0; + next = strm->next_in; + have = next != Z_NULL ? strm->avail_in : 0; + hold = 0; + bits = 0; + put = state->window; + left = state->wsize; + + /* Inflate until end of block marked as last */ + for (;;) + switch (state->mode) { + case TYPE: + /* determine and dispatch block type */ + if (state->last) { + BYTEBITS(); + state->mode = DONE; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + + case STORED: + /* get and verify stored block length */ + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + + /* copy stored block from input to output */ + while (state->length != 0) { + copy = state->length; + PULL(); + ROOM(); + if (copy > have) copy = have; + if (copy > left) copy = left; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + + case TABLE: + /* get dynamic table entries descriptor */ + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + + /* get code length code lengths (not a typo) */ + state->have = 0; + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + + /* get length and distance code code lengths */ + state->have = 0; + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + NEEDBITS(here.bits); + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = (unsigned)(state->lens[state->have - 1]); + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN; + + case LEN: + /* use inflate_fast() if we have enough input and output */ + if (have >= 6 && left >= 258) { + RESTORE(); + if (state->whave < state->wsize) + state->whave = state->wsize - left; + inflate_fast(strm, state->wsize); + LOAD(); + break; + } + + /* get a literal, length, or end-of-block code */ + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + state->length = (unsigned)here.val; + + /* process literal */ + if (here.op == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + ROOM(); + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + } + + /* process end of block */ + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + + /* invalid code */ + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + + /* length code -- get extra bits, if any */ + state->extra = (unsigned)(here.op) & 15; + if (state->extra != 0) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + + /* get distance code */ + for (;;) { + here = state->distcode[BITS(state->distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(here.bits); + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)here.val; + + /* get distance extra bits, if any */ + state->extra = (unsigned)(here.op) & 15; + if (state->extra != 0) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + } + if (state->offset > state->wsize - (state->whave < state->wsize ? + left : 0)) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + + /* copy match from window to output */ + do { + ROOM(); + copy = state->wsize - state->offset; + if (copy < left) { + from = put + copy; + copy = left - copy; + } + else { + from = put - state->offset; + copy = left; + } + if (copy > state->length) copy = state->length; + state->length -= copy; + left -= copy; + do { + *put++ = *from++; + } while (--copy); + } while (state->length != 0); + break; + + case DONE: + /* inflate stream terminated properly -- write leftover output */ + ret = Z_STREAM_END; + if (left < state->wsize) { + if (out(out_desc, state->window, state->wsize - left)) + ret = Z_BUF_ERROR; + } + goto inf_leave; + + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + + default: /* can't happen, but makes compilers happy */ + ret = Z_STREAM_ERROR; + goto inf_leave; + } + + /* Return unused input */ + inf_leave: + strm->next_in = next; + strm->avail_in = have; + return ret; +} + +int ZEXPORT inflateBackEnd(strm) +z_streamp strm; +{ + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} diff --git a/libs/libwebsockets/win32port/zlib/inffast.c b/libs/libwebsockets/win32port/zlib/inffast.c new file mode 100644 index 0000000000..2dfd4127db --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inffast.c @@ -0,0 +1,340 @@ +/* inffast.c -- fast decoding + * Copyright (C) 1995-2008, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifndef ASMINF + +/* Allow machine dependent optimization for post-increment or pre-increment. + Based on testing to date, + Pre-increment preferred for: + - PowerPC G3 (Adler) + - MIPS R5000 (Randers-Pehrson) + Post-increment preferred for: + - none + No measurable difference: + - Pentium III (Anderson) + - M68060 (Nikl) + */ +#ifdef POSTINC +# define OFF 0 +# define PUP(a) *(a)++ +#else +# define OFF 1 +# define PUP(a) *++(a) +#endif + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ +void ZLIB_INTERNAL inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + unsigned char FAR *in; /* local strm->next_in */ + unsigned char FAR *last; /* while in < last, enough input available */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ +#ifdef INFLATE_STRICT + unsigned dmax; /* maximum distance from zlib header */ +#endif + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code here; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in - OFF; + last = in + (strm->avail_in - 5); + out = strm->next_out - OFF; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); +#ifdef INFLATE_STRICT + dmax = state->dmax; +#endif + wsize = state->wsize; + whave = state->whave; + wnext = state->wnext; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op == 0) { /* literal */ + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + PUP(out) = (unsigned char)(here.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, "inflate: length %u\n", len)); + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); +#ifdef INFLATE_STRICT + if (dist > dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + hold >>= op; + bits -= op; + Tracevv((stderr, "inflate: distance %u\n", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + if (state->sane) { + strm->msg = + (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (len <= op - whave) { + do { + PUP(out) = 0; + } while (--len); + continue; + } + len -= op - whave; + do { + PUP(out) = 0; + } while (--op > whave); + if (op == 0) { + from = out - dist; + do { + PUP(out) = PUP(from); + } while (--len); + continue; + } +#endif + } + from = window - OFF; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = window - OFF; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } while (len > 2); + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + here = dcode[here.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + here = lcode[here.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, "inflate: end of block\n")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in + OFF; + strm->next_out = out + OFF; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} + +/* + inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): + - Using bit fields for code structure + - Different op definition to avoid & for extra bits (do & for table bits) + - Three separate decoding do-loops for direct, window, and wnext == 0 + - Special case for distance > 1 copies to do overlapped load and store copy + - Explicit branch predictions (based on measured branch probabilities) + - Deferring match copy and interspersed it with decoding subsequent codes + - Swapping literal/length else + - Swapping window/direct else + - Larger unrolled copy loops (three is about right) + - Moving len -= 3 statement into middle of loop + */ + +#endif /* !ASMINF */ diff --git a/libs/libwebsockets/win32port/zlib/inffast.h b/libs/libwebsockets/win32port/zlib/inffast.h new file mode 100644 index 0000000000..e1e6db4ac5 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inffast.h @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/libs/libwebsockets/win32port/zlib/inffixed.h b/libs/libwebsockets/win32port/zlib/inffixed.h new file mode 100644 index 0000000000..423d5c5b50 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. It + is part of the implementation of the compression library and + is subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/libs/libwebsockets/win32port/zlib/inflate.c b/libs/libwebsockets/win32port/zlib/inflate.c new file mode 100644 index 0000000000..5bec31e2ec --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inflate.c @@ -0,0 +1,1480 @@ +/* inflate.c -- zlib decompression + * Copyright (C) 1995-2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * Change history: + * + * 1.2.beta0 24 Nov 2002 + * - First version -- complete rewrite of inflate to simplify code, avoid + * creation of window when not needed, minimize use of window when it is + * needed, make inffast.c even faster, implement gzip decoding, and to + * improve code readability and style over the previous zlib inflate code + * + * 1.2.beta1 25 Nov 2002 + * - Use pointers for available input and output checking in inffast.c + * - Remove input and output counters in inffast.c + * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 + * - Remove unnecessary second byte pull from length extra in inffast.c + * - Unroll direct copy to three copies per loop in inffast.c + * + * 1.2.beta2 4 Dec 2002 + * - Change external routine names to reduce potential conflicts + * - Correct filename to inffixed.h for fixed tables in inflate.c + * - Make hbuf[] unsigned char to match parameter type in inflate.c + * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) + * to avoid negation problem on Alphas (64 bit) in inflate.c + * + * 1.2.beta3 22 Dec 2002 + * - Add comments on state->bits assertion in inffast.c + * - Add comments on op field in inftrees.h + * - Fix bug in reuse of allocated window after inflateReset() + * - Remove bit fields--back to byte structure for speed + * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths + * - Change post-increments to pre-increments in inflate_fast(), PPC biased? + * - Add compile time option, POSTINC, to use post-increments instead (Intel?) + * - Make MATCH copy in inflate() much faster for when inflate_fast() not used + * - Use local copies of stream next and avail values, as well as local bit + * buffer and bit count in inflate()--for speed when inflate_fast() not used + * + * 1.2.beta4 1 Jan 2003 + * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings + * - Move a comment on output buffer sizes from inffast.c to inflate.c + * - Add comments in inffast.c to introduce the inflate_fast() routine + * - Rearrange window copies in inflate_fast() for speed and simplification + * - Unroll last copy for window match in inflate_fast() + * - Use local copies of window variables in inflate_fast() for speed + * - Pull out common wnext == 0 case for speed in inflate_fast() + * - Make op and len in inflate_fast() unsigned for consistency + * - Add FAR to lcode and dcode declarations in inflate_fast() + * - Simplified bad distance check in inflate_fast() + * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new + * source file infback.c to provide a call-back interface to inflate for + * programs like gzip and unzip -- uses window as output buffer to avoid + * window copying + * + * 1.2.beta5 1 Jan 2003 + * - Improved inflateBack() interface to allow the caller to provide initial + * input in strm. + * - Fixed stored blocks bug in inflateBack() + * + * 1.2.beta6 4 Jan 2003 + * - Added comments in inffast.c on effectiveness of POSTINC + * - Typecasting all around to reduce compiler warnings + * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * make compilers happy + * - Changed type of window in inflateBackInit() to unsigned char * + * + * 1.2.beta7 27 Jan 2003 + * - Changed many types to unsigned or unsigned short to avoid warnings + * - Added inflateCopy() function + * + * 1.2.0 9 Mar 2003 + * - Changed inflateBack() interface to provide separate opaque descriptors + * for the in() and out() functions + * - Changed inflateBack() argument and in_func typedef to swap the length + * and buffer address return values for the input function + * - Check next_in and next_out for Z_NULL on entry to inflate() + * + * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. + */ + +#include "zutil.h" +#include "inftrees.h" +#include "inflate.h" +#include "inffast.h" + +#ifdef MAKEFIXED +# ifndef BUILDFIXED +# define BUILDFIXED +# endif +#endif + +/* function prototypes */ +local void fixedtables OF((struct inflate_state FAR *state)); +local int updatewindow OF((z_streamp strm, unsigned out)); +#ifdef BUILDFIXED + void makefixed OF((void)); +#endif +local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, + unsigned len)); + +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + strm->total_in = strm->total_out = state->total = 0; + strm->msg = Z_NULL; + strm->adler = 1; /* to support ill-conceived Java test suite */ + state->mode = HEAD; + state->last = 0; + state->havedict = 0; + state->dmax = 32768U; + state->head = Z_NULL; + state->wsize = 0; + state->whave = 0; + state->wnext = 0; + state->hold = 0; + state->bits = 0; + state->lencode = state->distcode = state->next = state->codes; + state->sane = 1; + state->back = -1; + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +int ZEXPORT inflateReset2(strm, windowBits) +z_streamp strm; +int windowBits; +{ + int wrap; + struct inflate_state FAR *state; + + /* get the state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* extract wrap request from windowBits parameter */ + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } + else { + wrap = (windowBits >> 4) + 1; +#ifdef GUNZIP + if (windowBits < 48) + windowBits &= 15; +#endif + } + + /* set number of window bits, free window if different */ + if (windowBits && (windowBits < 8 || windowBits > 15)) + return Z_STREAM_ERROR; + if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { + ZFREE(strm, state->window); + state->window = Z_NULL; + } + + /* update state and reset the rest of it */ + state->wrap = wrap; + state->wbits = (unsigned)windowBits; + return inflateReset(strm); +} + +int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) +z_streamp strm; +int windowBits; +const char *version; +int stream_size; +{ + int ret; + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL) return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *) + ZALLOC(strm, 1, sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (struct internal_state FAR *)state; + state->window = Z_NULL; + ret = inflateReset2(strm, windowBits); + if (ret != Z_OK) { + ZFREE(strm, state); + strm->state = Z_NULL; + } + return ret; +} + +int ZEXPORT inflateInit_(strm, version, stream_size) +z_streamp strm; +const char *version; +int stream_size; +{ + return inflateInit2_(strm, DEF_WBITS, version, stream_size); +} + +int ZEXPORT inflatePrime(strm, bits, value) +z_streamp strm; +int bits; +int value; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (bits < 0) { + state->hold = 0; + state->bits = 0; + return Z_OK; + } + if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; + value &= (1L << bits) - 1; + state->hold += value << state->bits; + state->bits += bits; + return Z_OK; +} + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +local void fixedtables(state) +struct inflate_state FAR *state; +{ +#ifdef BUILDFIXED + static int virgin = 1; + static code *lenfix, *distfix; + static code fixed[544]; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + unsigned sym, bits; + static code *next; + + /* literal/length table */ + sym = 0; + while (sym < 144) state->lens[sym++] = 8; + while (sym < 256) state->lens[sym++] = 9; + while (sym < 280) state->lens[sym++] = 7; + while (sym < 288) state->lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); + + /* distance table */ + sym = 0; + while (sym < 32) state->lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); + + /* do this just once */ + virgin = 0; + } +#else /* !BUILDFIXED */ +# include "inffixed.h" +#endif /* BUILDFIXED */ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +#ifdef MAKEFIXED +#include + +/* + Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also + defines BUILDFIXED, so the tables are built on the fly. makefixed() writes + those tables to stdout, which would be piped to inffixed.h. A small program + can simply call makefixed to do this: + + void makefixed(void); + + int main(void) + { + makefixed(); + return 0; + } + + Then that can be linked with zlib built with MAKEFIXED defined and run: + + a.out > inffixed.h + */ +void makefixed() +{ + unsigned low, size; + struct inflate_state state; + + fixedtables(&state); + puts(" /* inffixed.h -- table for decoding fixed codes"); + puts(" * Generated automatically by makefixed()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 7) == 0) printf("\n "); + printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, + state.lencode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, + state.distcode[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); +} +#endif /* MAKEFIXED */ + +/* + Update the window with the last wsize (normally 32K) bytes written before + returning. If window does not exist yet, create it. This is only called + when a window is already in use, or when output has been written during this + inflate call, but the end of the deflate stream has not been reached yet. + It is also called to create a window for dictionary data when a dictionary + is loaded. + + Providing output buffers larger than 32K to inflate() should provide a speed + advantage, since only the last 32K of output is copied to the sliding window + upon return from inflate(), and since all distances after the first 32K of + output will fall in the output data, making match copies simpler and faster. + The advantage may be dependent on the size of the processor's data caches. + */ +local int updatewindow(strm, out) +z_streamp strm; +unsigned out; +{ + struct inflate_state FAR *state; + unsigned copy, dist; + + state = (struct inflate_state FAR *)strm->state; + + /* if it hasn't been done already, allocate space for the window */ + if (state->window == Z_NULL) { + state->window = (unsigned char FAR *) + ZALLOC(strm, 1U << state->wbits, + sizeof(unsigned char)); + if (state->window == Z_NULL) return 1; + } + + /* if window not in use yet, initialize */ + if (state->wsize == 0) { + state->wsize = 1U << state->wbits; + state->wnext = 0; + state->whave = 0; + } + + /* copy state->wsize or less output bytes into the circular window */ + copy = out - strm->avail_out; + if (copy >= state->wsize) { + zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); + state->wnext = 0; + state->whave = state->wsize; + } + else { + dist = state->wsize - state->wnext; + if (dist > copy) dist = copy; + zmemcpy(state->window + state->wnext, strm->next_out - copy, dist); + copy -= dist; + if (copy) { + zmemcpy(state->window, strm->next_out - copy, copy); + state->wnext = copy; + state->whave = state->wsize; + } + else { + state->wnext += dist; + if (state->wnext == state->wsize) state->wnext = 0; + if (state->whave < state->wsize) state->whave += dist; + } + } + return 0; +} + +/* Macros for inflate(): */ + +/* check function to use adler32() for zlib or crc32() for gzip */ +#ifdef GUNZIP +# define UPDATE(check, buf, len) \ + (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) +#else +# define UPDATE(check, buf, len) adler32(check, buf, len) +#endif + +/* check macros for header crc */ +#ifdef GUNZIP +# define CRC2(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + check = crc32(check, hbuf, 2); \ + } while (0) + +# define CRC4(check, word) \ + do { \ + hbuf[0] = (unsigned char)(word); \ + hbuf[1] = (unsigned char)((word) >> 8); \ + hbuf[2] = (unsigned char)((word) >> 16); \ + hbuf[3] = (unsigned char)((word) >> 24); \ + check = crc32(check, hbuf, 4); \ + } while (0) +#endif + +/* Load registers with state in inflate() for speed */ +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +/* Restore state from registers in inflate() */ +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +/* Clear the input bit accumulator */ +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +/* Get a byte of input into the bit accumulator, or return from inflate() + if there is no input available. */ +#define PULLBYTE() \ + do { \ + if (have == 0) goto inf_leave; \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +/* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflate(). */ +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +/* Return the low n bits of the bit accumulator (n < 16) */ +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +/* Remove n bits from the bit accumulator */ +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +/* Remove zero to seven bits as needed to go to a byte boundary */ +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +/* Reverse the bytes in a 32-bit value */ +#define REVERSE(q) \ + ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +/* + inflate() uses a state machine to process as much input data and generate as + much output data as possible before returning. The state machine is + structured roughly as follows: + + for (;;) switch (state) { + ... + case STATEn: + if (not enough input data or output space to make progress) + return; + ... make progress ... + state = STATEm; + break; + ... + } + + so when inflate() is called again, the same case is attempted again, and + if the appropriate resources are provided, the machine proceeds to the + next state. The NEEDBITS() macro is usually the way the state evaluates + whether it can proceed or should return. NEEDBITS() does the return if + the requested bits are not available. The typical use of the BITS macros + is: + + NEEDBITS(n); + ... do something with BITS(n) ... + DROPBITS(n); + + where NEEDBITS(n) either returns from inflate() if there isn't enough + input left to load n bits into the accumulator, or it continues. BITS(n) + gives the low n bits in the accumulator. When done, DROPBITS(n) drops + the low n bits off the accumulator. INITBITS() clears the accumulator + and sets the number of available bits to zero. BYTEBITS() discards just + enough bits to put the accumulator on a byte boundary. After BYTEBITS() + and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. + + NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return + if there is no input available. The decoding of variable length codes uses + PULLBYTE() directly in order to pull just enough bytes to decode the next + code, and no more. + + Some states loop until they get enough input, making sure that enough + state information is maintained to continue the loop where it left off + if NEEDBITS() returns in the loop. For example, want, need, and keep + would all have to actually be part of the saved state in case NEEDBITS() + returns: + + case STATEw: + while (want < need) { + NEEDBITS(n); + keep[want++] = BITS(n); + DROPBITS(n); + } + state = STATEx; + case STATEx: + + As shown above, if the next state is also the next case, then the break + is omitted. + + A state may also return if there is not enough output space available to + complete that state. Those states are copying stored data, writing a + literal byte, and copying a matching string. + + When returning, a "goto inf_leave" is used to update the total counters, + update the check value, and determine whether any progress has been made + during that inflate() call in order to return the proper return code. + Progress is defined as a change in either strm->avail_in or strm->avail_out. + When there is a window, goto inf_leave will update the window with the last + output written. If a goto inf_leave occurs in the middle of decompression + and there is no window currently, goto inf_leave will create one and copy + output to the window for the next call of inflate(). + + In this implementation, the flush parameter of inflate() only affects the + return code (per zlib.h). inflate() always writes as much as possible to + strm->next_out, given the space available and the provided input--the effect + documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers + the allocation of and copying into a sliding window until necessary, which + provides the effect documented in zlib.h for Z_FINISH when the entire input + stream available. So the only thing the flush parameter actually does is: + when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + will return Z_BUF_ERROR if it has not reached the end of the stream. + */ + +int ZEXPORT inflate(strm, flush) +z_streamp strm; +int flush; +{ + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned in, out; /* save starting available input and output */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code here; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ +#ifdef GUNZIP + unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ +#endif + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0)) + return Z_STREAM_ERROR; + + state = (struct inflate_state FAR *)strm->state; + if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ + LOAD(); + in = have; + out = left; + ret = Z_OK; + for (;;) + switch (state->mode) { + case HEAD: + if (state->wrap == 0) { + state->mode = TYPEDO; + break; + } + NEEDBITS(16); +#ifdef GUNZIP + if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + state->check = crc32(0L, Z_NULL, 0); + CRC2(state->check, hold); + INITBITS(); + state->mode = FLAGS; + break; + } + state->flags = 0; /* expect zlib header */ + if (state->head != Z_NULL) + state->head->done = -1; + if (!(state->wrap & 1) || /* check if zlib header allowed */ +#else + if ( +#endif + ((BITS(8) << 8) + (hold >> 8)) % 31) { + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; + break; + } + if (BITS(4) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + DROPBITS(4); + len = BITS(4) + 8; + if (state->wbits == 0) + state->wbits = len; + else if (len > state->wbits) { + strm->msg = (char *)"invalid window size"; + state->mode = BAD; + break; + } + state->dmax = 1U << len; + Tracev((stderr, "inflate: zlib header ok\n")); + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = hold & 0x200 ? DICTID : TYPE; + INITBITS(); + break; +#ifdef GUNZIP + case FLAGS: + NEEDBITS(16); + state->flags = (int)(hold); + if ((state->flags & 0xff) != Z_DEFLATED) { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + if (state->flags & 0xe000) { + strm->msg = (char *)"unknown header flags set"; + state->mode = BAD; + break; + } + if (state->head != Z_NULL) + state->head->text = (int)((hold >> 8) & 1); + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = TIME; + case TIME: + NEEDBITS(32); + if (state->head != Z_NULL) + state->head->time = hold; + if (state->flags & 0x0200) CRC4(state->check, hold); + INITBITS(); + state->mode = OS; + case OS: + NEEDBITS(16); + if (state->head != Z_NULL) { + state->head->xflags = (int)(hold & 0xff); + state->head->os = (int)(hold >> 8); + } + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + state->mode = EXLEN; + case EXLEN: + if (state->flags & 0x0400) { + NEEDBITS(16); + state->length = (unsigned)(hold); + if (state->head != Z_NULL) + state->head->extra_len = (unsigned)hold; + if (state->flags & 0x0200) CRC2(state->check, hold); + INITBITS(); + } + else if (state->head != Z_NULL) + state->head->extra = Z_NULL; + state->mode = EXTRA; + case EXTRA: + if (state->flags & 0x0400) { + copy = state->length; + if (copy > have) copy = have; + if (copy) { + if (state->head != Z_NULL && + state->head->extra != Z_NULL) { + len = state->head->extra_len - state->length; + zmemcpy(state->head->extra + len, next, + len + copy > state->head->extra_max ? + state->head->extra_max - len : copy); + } + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + state->length -= copy; + } + if (state->length) goto inf_leave; + } + state->length = 0; + state->mode = NAME; + case NAME: + if (state->flags & 0x0800) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->name != Z_NULL && + state->length < state->head->name_max) + state->head->name[state->length++] = len; + } while (len && copy < have); + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->name = Z_NULL; + state->length = 0; + state->mode = COMMENT; + case COMMENT: + if (state->flags & 0x1000) { + if (have == 0) goto inf_leave; + copy = 0; + do { + len = (unsigned)(next[copy++]); + if (state->head != Z_NULL && + state->head->comment != Z_NULL && + state->length < state->head->comm_max) + state->head->comment[state->length++] = len; + } while (len && copy < have); + if (state->flags & 0x0200) + state->check = crc32(state->check, next, copy); + have -= copy; + next += copy; + if (len) goto inf_leave; + } + else if (state->head != Z_NULL) + state->head->comment = Z_NULL; + state->mode = HCRC; + case HCRC: + if (state->flags & 0x0200) { + NEEDBITS(16); + if (hold != (state->check & 0xffff)) { + strm->msg = (char *)"header crc mismatch"; + state->mode = BAD; + break; + } + INITBITS(); + } + if (state->head != Z_NULL) { + state->head->hcrc = (int)((state->flags >> 9) & 1); + state->head->done = 1; + } + strm->adler = state->check = crc32(0L, Z_NULL, 0); + state->mode = TYPE; + break; +#endif + case DICTID: + NEEDBITS(32); + strm->adler = state->check = REVERSE(hold); + INITBITS(); + state->mode = DICT; + case DICT: + if (state->havedict == 0) { + RESTORE(); + return Z_NEED_DICT; + } + strm->adler = state->check = adler32(0L, Z_NULL, 0); + state->mode = TYPE; + case TYPE: + if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; + case TYPEDO: + if (state->last) { + BYTEBITS(); + state->mode = CHECK; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + state->last ? " (last)" : "")); + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + Tracev((stderr, "inflate: fixed codes block%s\n", + state->last ? " (last)" : "")); + state->mode = LEN_; /* decode codes */ + if (flush == Z_TREES) { + DROPBITS(2); + goto inf_leave; + } + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + state->last ? " (last)" : "")); + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + case STORED: + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %u\n", + state->length)); + INITBITS(); + state->mode = COPY_; + if (flush == Z_TREES) goto inf_leave; + case COPY_: + state->mode = COPY; + case COPY: + copy = state->length; + if (copy) { + if (copy > have) copy = have; + if (copy > left) copy = left; + if (copy == 0) goto inf_leave; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + break; + } + Tracev((stderr, "inflate: stored end\n")); + state->mode = TYPE; + break; + case TABLE: + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); +#ifndef PKZIP_BUG_WORKAROUND + if (state->nlen > 286 || state->ndist > 30) { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } +#endif + Tracev((stderr, "inflate: table sizes ok\n")); + state->have = 0; + state->mode = LENLENS; + case LENLENS: + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + state->have = 0; + state->mode = CODELENS; + case CODELENS: + while (state->have < state->nlen + state->ndist) { + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.val < 16) { + NEEDBITS(here.bits); + DROPBITS(here.bits); + state->lens[state->have++] = here.val; + } + else { + if (here.val == 16) { + NEEDBITS(here.bits + 2); + DROPBITS(here.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = state->lens[state->have - 1]; + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (here.val == 17) { + NEEDBITS(here.bits + 3); + DROPBITS(here.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(here.bits + 7); + DROPBITS(here.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* handle error breaks in while */ + if (state->mode == BAD) break; + + /* check for end-of-block code (better have one) */ + if (state->lens[256] == 0) { + strm->msg = (char *)"invalid code -- missing end-of-block"; + state->mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state->next = state->codes; + state->lencode = (code const FAR *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), + &(state->lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const FAR *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, + &(state->next), &(state->distbits), state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + state->mode = LEN_; + if (flush == Z_TREES) goto inf_leave; + case LEN_: + state->mode = LEN; + case LEN: + if (have >= 6 && left >= 258) { + RESTORE(); + inflate_fast(strm, out); + LOAD(); + if (state->mode == TYPE) + state->back = -1; + break; + } + state->back = 0; + for (;;) { + here = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if (here.op && (here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + state->back += last.bits; + } + DROPBITS(here.bits); + state->back += here.bits; + state->length = (unsigned)here.val; + if ((int)(here.op) == 0) { + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here.val)); + state->mode = LIT; + break; + } + if (here.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + state->back = -1; + state->mode = TYPE; + break; + } + if (here.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + state->extra = (unsigned)(here.op) & 15; + state->mode = LENEXT; + case LENEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + state->back += state->extra; + } + Tracevv((stderr, "inflate: length %u\n", state->length)); + state->was = state->length; + state->mode = DIST; + case DIST: + for (;;) { + here = state->distcode[BITS(state->distbits)]; + if ((unsigned)(here.bits) <= bits) break; + PULLBYTE(); + } + if ((here.op & 0xf0) == 0) { + last = here; + for (;;) { + here = state->distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + here.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + state->back += last.bits; + } + DROPBITS(here.bits); + state->back += here.bits; + if (here.op & 64) { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)here.val; + state->extra = (unsigned)(here.op) & 15; + state->mode = DISTEXT; + case DISTEXT: + if (state->extra) { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + state->back += state->extra; + } +#ifdef INFLATE_STRICT + if (state->offset > state->dmax) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#endif + Tracevv((stderr, "inflate: distance %u\n", state->offset)); + state->mode = MATCH; + case MATCH: + if (left == 0) goto inf_leave; + copy = out - left; + if (state->offset > copy) { /* copy from window */ + copy = state->offset - copy; + if (copy > state->whave) { + if (state->sane) { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + Trace((stderr, "inflate.c too far\n")); + copy -= state->whave; + if (copy > state->length) copy = state->length; + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = 0; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; +#endif + } + if (copy > state->wnext) { + copy -= state->wnext; + from = state->window + (state->wsize - copy); + } + else + from = state->window + (state->wnext - copy); + if (copy > state->length) copy = state->length; + } + else { /* copy from output */ + from = put - state->offset; + copy = state->length; + } + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do { + *put++ = *from++; + } while (--copy); + if (state->length == 0) state->mode = LEN; + break; + case LIT: + if (left == 0) goto inf_leave; + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + case CHECK: + if (state->wrap) { + NEEDBITS(32); + out -= left; + strm->total_out += out; + state->total += out; + if (out) + strm->adler = state->check = + UPDATE(state->check, put - out, out); + out = left; + if (( +#ifdef GUNZIP + state->flags ? hold : +#endif + REVERSE(hold)) != state->check) { + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: check matches trailer\n")); + } +#ifdef GUNZIP + state->mode = LENGTH; + case LENGTH: + if (state->wrap && state->flags) { + NEEDBITS(32); + if (hold != (state->total & 0xffffffffUL)) { + strm->msg = (char *)"incorrect length check"; + state->mode = BAD; + break; + } + INITBITS(); + Tracev((stderr, "inflate: length matches trailer\n")); + } +#endif + state->mode = DONE; + case DONE: + ret = Z_STREAM_END; + goto inf_leave; + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: + return Z_STREAM_ERROR; + } + + /* + Return from inflate(), updating the total counts and the check value. + If there was no progress during the inflate() call, return a buffer + error. Call updatewindow() to create and/or update the window state. + Note: a memory error from inflate() is non-recoverable. + */ + inf_leave: + RESTORE(); + if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) + if (updatewindow(strm, out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + state->total += out; + if (state->wrap && out) + strm->adler = state->check = + UPDATE(state->check, strm->next_out - out, out); + strm->data_type = state->bits + (state->last ? 64 : 0) + + (state->mode == TYPE ? 128 : 0) + + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); + if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) + ret = Z_BUF_ERROR; + return ret; +} + +int ZEXPORT inflateEnd(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->window != Z_NULL) ZFREE(strm, state->window); + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + +int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) +z_streamp strm; +const Bytef *dictionary; +uInt dictLength; +{ + struct inflate_state FAR *state; + unsigned long id; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (state->wrap != 0 && state->mode != DICT) + return Z_STREAM_ERROR; + + /* check for correct dictionary id */ + if (state->mode == DICT) { + id = adler32(0L, Z_NULL, 0); + id = adler32(id, dictionary, dictLength); + if (id != state->check) + return Z_DATA_ERROR; + } + + /* copy dictionary to window */ + if (updatewindow(strm, strm->avail_out)) { + state->mode = MEM; + return Z_MEM_ERROR; + } + if (dictLength > state->wsize) { + zmemcpy(state->window, dictionary + dictLength - state->wsize, + state->wsize); + state->whave = state->wsize; + } + else { + zmemcpy(state->window + state->wsize - dictLength, dictionary, + dictLength); + state->whave = dictLength; + } + state->havedict = 1; + Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} + +int ZEXPORT inflateGetHeader(strm, head) +z_streamp strm; +gz_headerp head; +{ + struct inflate_state FAR *state; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; + + /* save header structure */ + state->head = head; + head->done = 0; + return Z_OK; +} + +/* + Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found + or when out of input. When called, *have is the number of pattern bytes + found in order so far, in 0..3. On return *have is updated to the new + state. If on return *have equals four, then the pattern was found and the + return value is how many bytes were read including the last byte of the + pattern. If *have is less than four, then the pattern has not been found + yet and the return value is len. In the latter case, syncsearch() can be + called again with more data and the *have state. *have is initialized to + zero for the first call. + */ +local unsigned syncsearch(have, buf, len) +unsigned FAR *have; +unsigned char FAR *buf; +unsigned len; +{ + unsigned got; + unsigned next; + + got = *have; + next = 0; + while (next < len && got < 4) { + if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) + got++; + else if (buf[next]) + got = 0; + else + got = 4 - got; + next++; + } + *have = got; + return next; +} + +int ZEXPORT inflateSync(strm) +z_streamp strm; +{ + unsigned len; /* number of bytes to look at or looked at */ + unsigned long in, out; /* temporary to save total_in and total_out */ + unsigned char buf[4]; /* to restore bit buffer to byte string */ + struct inflate_state FAR *state; + + /* check parameters */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; + + /* if first time, start search in bit buffer */ + if (state->mode != SYNC) { + state->mode = SYNC; + state->hold <<= state->bits & 7; + state->bits -= state->bits & 7; + len = 0; + while (state->bits >= 8) { + buf[len++] = (unsigned char)(state->hold); + state->hold >>= 8; + state->bits -= 8; + } + state->have = 0; + syncsearch(&(state->have), buf, len); + } + + /* search available input */ + len = syncsearch(&(state->have), strm->next_in, strm->avail_in); + strm->avail_in -= len; + strm->next_in += len; + strm->total_in += len; + + /* return no joy or set up to restart inflate() on a new block */ + if (state->have != 4) return Z_DATA_ERROR; + in = strm->total_in; out = strm->total_out; + inflateReset(strm); + strm->total_in = in; strm->total_out = out; + state->mode = TYPE; + return Z_OK; +} + +/* + Returns true if inflate is currently at the end of a block generated by + Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + implementation to provide an additional safety check. PPP uses + Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored + block. When decompressing, PPP checks that at the end of input packet, + inflate is waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + return state->mode == STORED && state->bits == 0; +} + +int ZEXPORT inflateCopy(dest, source) +z_streamp dest; +z_streamp source; +{ + struct inflate_state FAR *state; + struct inflate_state FAR *copy; + unsigned char FAR *window; + unsigned wsize; + + /* check input */ + if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || + source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)source->state; + + /* allocate space */ + copy = (struct inflate_state FAR *) + ZALLOC(source, 1, sizeof(struct inflate_state)); + if (copy == Z_NULL) return Z_MEM_ERROR; + window = Z_NULL; + if (state->window != Z_NULL) { + window = (unsigned char FAR *) + ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); + if (window == Z_NULL) { + ZFREE(source, copy); + return Z_MEM_ERROR; + } + } + + /* copy state */ + zmemcpy(dest, source, sizeof(z_stream)); + zmemcpy(copy, state, sizeof(struct inflate_state)); + if (state->lencode >= state->codes && + state->lencode <= state->codes + ENOUGH - 1) { + copy->lencode = copy->codes + (state->lencode - state->codes); + copy->distcode = copy->codes + (state->distcode - state->codes); + } + copy->next = copy->codes + (state->next - state->codes); + if (window != Z_NULL) { + wsize = 1U << state->wbits; + zmemcpy(window, state->window, wsize); + } + copy->window = window; + dest->state = (struct internal_state FAR *)copy; + return Z_OK; +} + +int ZEXPORT inflateUndermine(strm, subvert) +z_streamp strm; +int subvert; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + state->sane = !subvert; +#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + return Z_OK; +#else + state->sane = 1; + return Z_DATA_ERROR; +#endif +} + +long ZEXPORT inflateMark(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; + state = (struct inflate_state FAR *)strm->state; + return ((long)(state->back) << 16) + + (state->mode == COPY ? state->length : + (state->mode == MATCH ? state->was - state->length : 0)); +} diff --git a/libs/libwebsockets/win32port/zlib/inflate.h b/libs/libwebsockets/win32port/zlib/inflate.h new file mode 100644 index 0000000000..a8ef4287df --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inflate.h @@ -0,0 +1,122 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2009 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD, /* i: waiting for magic header */ + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY_, /* i/o: same as COPY below, but only first time in */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN_, /* i: same as LEN below, but only first time in */ + LEN, /* i: waiting for length/lit/eob code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ + LENGTH, /* i: waiting for 32-bit length (gzip) */ + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to BAD or MEM on error -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) or (raw) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> + HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + (raw) -> TYPEDO + Read deflate blocks: + TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK + STORED -> COPY_ -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN_ + LEN_ -> LEN + Read deflate codes in fixed or dynamic block: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* state maintained between inflate() calls. Approximately 10K bytes. */ +struct inflate_state { + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags (0 if zlib) */ + unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + gz_headerp head; /* where to save gzip header information */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ + int sane; /* if false, allow invalid distance too far */ + int back; /* bits back of last unprocessed length/lit */ + unsigned was; /* initial length of match */ +}; diff --git a/libs/libwebsockets/win32port/zlib/inftrees.c b/libs/libwebsockets/win32port/zlib/inftrees.c new file mode 100644 index 0000000000..9dbaec3368 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inftrees.c @@ -0,0 +1,330 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#define MAXBITS 15 + +const char inflate_copyright[] = + " inflate 1.2.5 Copyright 1995-2010 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ +int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) +codetype type; +unsigned short FAR *lens; +unsigned codes; +code FAR * FAR *table; +unsigned FAR *bits; +unsigned short FAR *work; +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code here; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195}; + static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 0, 0}; + static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 28, 28, 29, 29, 64, 64}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) { /* no symbols to code at all */ + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)1; + here.val = (unsigned short)0; + *(*table)++ = here; /* make a table to force an error */ + *(*table)++ = here; + *bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min < max; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || max != 1)) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked for LENS and DIST tables against + the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in + the initial root table size constants. See the comments in inftrees.h + for more information. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if ((type == LENS && used >= ENOUGH_LENS) || + (type == DISTS && used >= ENOUGH_DISTS)) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + here.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) { + here.op = (unsigned char)0; + here.val = work[sym]; + } + else if ((int)(work[sym]) > end) { + here.op = (unsigned char)(extra[work[sym]]); + here.val = base[work[sym]]; + } + else { + here.op = (unsigned char)(32 + 64); /* end of block */ + here.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + min = fill; /* save offset to next table */ + do { + fill -= incr; + next[(huff >> drop) + fill] = here; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += min; /* here min is 1 << curr */ + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if ((type == LENS && used >= ENOUGH_LENS) || + (type == DISTS && used >= ENOUGH_DISTS)) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* + Fill in rest of table for incomplete codes. This loop is similar to the + loop above in incrementing huff for table indices. It is assumed that + len is equal to curr + drop, so there is no loop needed to increment + through high index bits. When the current sub-table is filled, the loop + drops back to the root table to fill in any remaining entries there. + */ + here.op = (unsigned char)64; /* invalid code marker */ + here.bits = (unsigned char)(len - drop); + here.val = (unsigned short)0; + while (huff != 0) { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) { + drop = 0; + len = root; + next = *table; + here.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = here; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; +} diff --git a/libs/libwebsockets/win32port/zlib/inftrees.h b/libs/libwebsockets/win32port/zlib/inftrees.h new file mode 100644 index 0000000000..a685d8c6ea --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/inftrees.h @@ -0,0 +1,62 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1444, which is the sum of 852 for literal/length codes and 592 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribtution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns returns 852, and "enough 30 6 15" for distance codes returns 592. + The initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in inflate.c and infback.c. If the root table size is + changed, then these maximum sizes would be need to be recalculated and + updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 592 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); diff --git a/libs/libwebsockets/win32port/zlib/trees.c b/libs/libwebsockets/win32port/zlib/trees.c new file mode 100644 index 0000000000..b4a317aced --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/trees.c @@ -0,0 +1,1244 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-2010 Jean-loup Gailly + * detect_data_type() function provided freely by Cosmin Truta, 2006 + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, ct_data *ltree, + ct_data *dtree)); +local int detect_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); +local void copy_block OF((deflate_state *s, charf *buf, unsigned len, + int header)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits(s, value, length) + deflate_state *s; + int value; /* value to send */ + int length; /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (ush)value << s->bi_valid; + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= (ush)value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = value;\ + s->bi_buf |= (ush)val << s->bi_valid;\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (ush)(value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* DEBUG */ + + +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ +#ifdef NO_INIT_GLOBAL_POINTERS + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; +#endif + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, + "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void ZLIB_INTERNAL _tr_init(s) + deflate_state *s; +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ +#ifdef DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(s) + deflate_state *s; +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(s, tree, k) + deflate_state *s; + ct_data *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (bits + xbits); + if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if ((unsigned) tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((long)bits - (long)tree[m].Len) + *(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code, bl_count) + ct_data *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ + ushf *bl_count; /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? + s->depth[n] : s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree(s) + deflate_state *s; +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(s, lcodes, dcodes, blcodes) + deflate_state *s; + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) + deflate_state *s; + charf *buf; /* input block */ + ulg stored_len; /* length of input block */ + int last; /* one if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ +#ifdef DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; +#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + * The current inflate code requires 9 bits of lookahead. If the + * last two codes for the previous block (real code plus EOB) were coded + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + * the last real code. In this case we send two empty static blocks instead + * of one. (There are no problems if the previous block is stored or fixed.) + * To simplify the code, we assume the worst case of last real code encoded + * on one bit only. + */ +void ZLIB_INTERNAL _tr_align(s) + deflate_state *s; +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); + /* Of the 10 bits for the empty block, we have already sent + * (10 - bi_valid) bits. The lookahead for the last real code (before + * the EOB of the previous block) was thus at least one plus the length + * of the EOB plus what we have just sent of the empty static block. + */ + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; +#endif + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) + deflate_state *s; + charf *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int last; /* one if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is binary or text */ + if (s->strm->data_type == Z_UNKNOWN) + s->strm->data_type = detect_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute the block lengths in bytes. */ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, last); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+last, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+last, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (last) { + bi_windup(s); +#ifdef DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*last)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int ZLIB_INTERNAL _tr_tally (s, dist, lc) + deflate_state *s; + unsigned dist; /* distance of matched string */ + unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(s, ltree, dtree) + deflate_state *s; + ct_data *ltree; /* literal tree */ + ct_data *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, + "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); + s->last_eob_len = ltree[END_BLOCK].Len; +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "black list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(s) + deflate_state *s; +{ + /* black_mask is the bit mask of black-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long black_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("black-listed") bytes. */ + for (n = 0; n <= 31; n++, black_mask >>= 1) + if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("white-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "black-listed" or "white-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(s) + deflate_state *s; +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(s) + deflate_state *s; +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +local void copy_block(s, buf, len, header) + deflate_state *s; + charf *buf; /* the input data */ + unsigned len; /* its length */ + int header; /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) { + put_short(s, (ush)len); + put_short(s, (ush)~len); +#ifdef DEBUG + s->bits_sent += 2*16; +#endif + } +#ifdef DEBUG + s->bits_sent += (ulg)len<<3; +#endif + while (len--) { + put_byte(s, *buf++); + } +} diff --git a/libs/libwebsockets/win32port/zlib/trees.h b/libs/libwebsockets/win32port/zlib/trees.h new file mode 100644 index 0000000000..ce8f620444 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/libs/libwebsockets/win32port/zlib/uncompr.c b/libs/libwebsockets/win32port/zlib/uncompr.c new file mode 100644 index 0000000000..f07773c9de --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/uncompr.c @@ -0,0 +1,59 @@ +/* uncompr.c -- decompress a memory buffer + * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#define ZLIB_INTERNAL +#include "zlib.h" + +/* =========================================================================== + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ +int ZEXPORT uncompress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; + + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + err = inflateInit(&stream); + if (err != Z_OK) return err; + + err = inflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + inflateEnd(&stream); + if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) + return Z_DATA_ERROR; + return err; + } + *destLen = stream.total_out; + + err = inflateEnd(&stream); + return err; +} diff --git a/libs/libwebsockets/win32port/zlib/zconf.h b/libs/libwebsockets/win32port/zlib/zconf.h new file mode 100644 index 0000000000..88f90f90f4 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/zconf.h @@ -0,0 +1,428 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# define uncompress z_uncompress +# define zError z_zError +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# define gzFile z_gzFile +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef STDC +# include /* for off_t */ +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +#endif + +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +# define z_off64_t off64_t +#else +# define z_off64_t z_off_t +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/libs/libwebsockets/win32port/zlib/zlib.h b/libs/libwebsockets/win32port/zlib/zlib.h new file mode 100644 index 0000000000..cba7ab2fb3 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/zlib.h @@ -0,0 +1,1613 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.5, April 19th, 2010 + + Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.5" +#define ZLIB_VERNUM 0x1250 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all the uncompressed data. (The size + of the uncompressed data may have been saved by the compressor for this + purpose.) The next operation on this stream must be inflateEnd to deallocate + the decompression state. The use of Z_FINISH is never required, but can be + used to inform inflate that a faster approach may be used for the single + inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK or Z_TREES is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any call + of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been + found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the + success case, the application may save the current current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef voidp gzFile; /* opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) Also "a" + can be used instead of "w" to request that the gzip stream that will be + written be appended to the file. "+" will result in an error, since reading + and writing to the same gzip file is not supported. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file was not in gzip format, gzread copies the given number of + bytes into the buffer. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream, or failing that, reading the rest + of the input file directly without decompression. The entire input file + will be read if gzread is called until it returns less than the requested + len. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. This state can change from + false to true while reading the input file if the end of a gzip stream is + reached, but is followed by data that is not another gzip stream. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the for the crc. Pre- and post-conditioning (one's + complement) is performed within this function so it shouldn't be done by the + application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# ifdef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +/* hack for buggy compilers */ +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; +#endif + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/libs/libwebsockets/win32port/zlib/zutil.c b/libs/libwebsockets/win32port/zlib/zutil.c new file mode 100644 index 0000000000..e33ae8bb5a --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/zutil.c @@ -0,0 +1,318 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2005, 2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#ifndef NO_DUMMY_DECL +struct internal_state {int dummy;}; /* for buggy compilers */ +#endif + +const char * const z_errmsg[10] = { +"need dictionary", /* Z_NEED_DICT 2 */ +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ +"incompatible version",/* Z_VERSION_ERROR (-6) */ +""}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +uLong ZEXPORT zlibCompileFlags() +{ + uLong flags; + + flags = 0; + switch ((int)(sizeof(uInt))) { + case 2: break; + case 4: flags += 1; break; + case 8: flags += 2; break; + default: flags += 3; + } + switch ((int)(sizeof(uLong))) { + case 2: break; + case 4: flags += 1 << 2; break; + case 8: flags += 2 << 2; break; + default: flags += 3 << 2; + } + switch ((int)(sizeof(voidpf))) { + case 2: break; + case 4: flags += 1 << 4; break; + case 8: flags += 2 << 4; break; + default: flags += 3 << 4; + } + switch ((int)(sizeof(z_off_t))) { + case 2: break; + case 4: flags += 1 << 6; break; + case 8: flags += 2 << 6; break; + default: flags += 3 << 6; + } +#ifdef DEBUG + flags += 1 << 8; +#endif +#if defined(ASMV) || defined(ASMINF) + flags += 1 << 9; +#endif +#ifdef ZLIB_WINAPI + flags += 1 << 10; +#endif +#ifdef BUILDFIXED + flags += 1 << 12; +#endif +#ifdef DYNAMIC_CRC_TABLE + flags += 1 << 13; +#endif +#ifdef NO_GZCOMPRESS + flags += 1L << 16; +#endif +#ifdef NO_GZIP + flags += 1L << 17; +#endif +#ifdef PKZIP_BUG_WORKAROUND + flags += 1L << 20; +#endif +#ifdef FASTEST + flags += 1L << 21; +#endif +#ifdef STDC +# ifdef NO_vsnprintf + flags += 1L << 25; +# ifdef HAS_vsprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1L << 26; +# endif +# endif +#else + flags += 1L << 24; +# ifdef NO_snprintf + flags += 1L << 25; +# ifdef HAS_sprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1L << 26; +# endif +# endif +#endif + return flags; +} + +#ifdef DEBUG + +# ifndef verbose +# define verbose 0 +# endif +int ZLIB_INTERNAL z_verbose = verbose; + +void ZLIB_INTERNAL z_error (m) + char *m; +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError(err) + int err; +{ + return ERR_MSG(err); +} + +#if defined(_WIN32_WCE) + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. + */ + int errno = 0; +#endif + +#ifndef HAVE_MEMCPY + +void ZLIB_INTERNAL zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int ZLIB_INTERNAL zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void ZLIB_INTERNAL zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + + +#ifdef SYS16BIT + +#ifdef __TURBOC__ +/* Turbo C in 16-bit mode */ + +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} + +#endif /* __TURBOC__ */ + + +#ifdef M_I86 +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* M_I86 */ + +#endif /* SYS16BIT */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp malloc OF((uInt size)); +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + if (opaque) items += size - size; /* make compiler happy */ + return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + (voidpf)calloc(items, size); +} + +void ZLIB_INTERNAL zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + free(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/libs/libwebsockets/win32port/zlib/zutil.h b/libs/libwebsockets/win32port/zlib/zutil.h new file mode 100644 index 0000000000..a36a406ed9 --- /dev/null +++ b/libs/libwebsockets/win32port/zlib/zutil.h @@ -0,0 +1,274 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include "zlib.h" + +#ifdef STDC +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +# include +# include +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +# ifdef M_I86 +# include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + +#if defined(__BORLANDC__) + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +#endif +#ifdef VMS +# define NO_vsnprintf +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, + unsigned size)); +void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* ZUTIL_H */ diff --git a/libs/libzrtp/AUTHORS b/libs/libzrtp/AUTHORS index 471f0148b3..6a435669c0 100644 --- a/libs/libzrtp/AUTHORS +++ b/libs/libzrtp/AUTHORS @@ -23,6 +23,7 @@ Thanks to: Colin Plumb Sagar Pai Werner Dittmann + Travis Cross L. Amber Wilcox-O'Hearn Ariel Boston Donovan Preston diff --git a/libs/libzrtp/include/zrtp_types.h b/libs/libzrtp/include/zrtp_types.h index a38d118591..c5c7654d68 100644 --- a/libs/libzrtp/include/zrtp_types.h +++ b/libs/libzrtp/include/zrtp_types.h @@ -527,7 +527,12 @@ typedef struct zrtp_stream_mescache_t zrtp_retry_task_t errorack_task; zrtp_retry_task_t sasrelay_task; - zrtp_string16_t signaling_hash; + /*! + * Hash pre-image of the remote party Hello retrieved from Signaling. When + * user calls zrtp_signaling_hash_set() libzrtp stores hash value in this + * variable and checks all incoming Hello-s to prevent DOS attacks. + */ + zrtp_string64_t signaling_hash; } zrtp_stream_mescache_t; @@ -722,14 +727,7 @@ struct zrtp_stream_t * crypto sources and performs traffic encryption/decryption. */ zrtp_protocol_t *protocol; - - /*! - * Hash pre-image of the remote party Hello retrieved from Signaling. When - * user calls zrtp_signaling_hash_set() libzrtp stores hash value in this - * variable and checks all incoming Hellos to prevent DOS attacks. - */ - zrtp_string128_t signaling_hash; - + /*!< Holder for RTP/ZRTP media stream options. */ zrtp_media_context_t media_ctx; diff --git a/libs/libzrtp/include/zrtp_version.h b/libs/libzrtp/include/zrtp_version.h index 5afc3b76af..e666e42cb9 100644 --- a/libs/libzrtp/include/zrtp_version.h +++ b/libs/libzrtp/include/zrtp_version.h @@ -12,8 +12,8 @@ #define LIBZRTP_VERSION_MAJOR 1 -#define LIBZRTP_VERSION_MINOR 13 -#define LIBZRTP_VERSION_BUILD 604 -#define LIBZRTP_VERSION_STR "v1.13 604" +#define LIBZRTP_VERSION_MINOR 15 +#define LIBZRTP_VERSION_BUILD 607 +#define LIBZRTP_VERSION_STR "v1.15 607" #endif /*__ZRTP_VERSION_H__*/ diff --git a/libs/libzrtp/projects/gnu/bootstrap.sh b/libs/libzrtp/projects/gnu/bootstrap.sh index df9bb21e30..1559388ad1 100755 --- a/libs/libzrtp/projects/gnu/bootstrap.sh +++ b/libs/libzrtp/projects/gnu/bootstrap.sh @@ -9,6 +9,6 @@ reconf () { automake --no-force --add-missing --copy } -(cd ../../third_party/bnlib && reconf) +(cd ../../third_party/bnlib && ./bootstrap.sh) reconf diff --git a/libs/libzrtp/projects/gnu/configure.in b/libs/libzrtp/projects/gnu/configure.in index d25d41771a..7d97319a76 100644 --- a/libs/libzrtp/projects/gnu/configure.in +++ b/libs/libzrtp/projects/gnu/configure.in @@ -32,7 +32,7 @@ case $target_os in esac -AM_INIT_AUTOMAKE([libzrtp], [1.14]) +AM_INIT_AUTOMAKE([libzrtp], [1.15]) AX_PREFIX_CONFIG_H(../../include/zrtp_config_unix.h,ZRTP,config/config.h) CFLAGS="$CFLAGS -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" diff --git a/libs/libzrtp/projects/win/libzrtp.2010.vcxproj b/libs/libzrtp/projects/win/libzrtp.2010.vcxproj new file mode 100644 index 0000000000..3306611920 --- /dev/null +++ b/libs/libzrtp/projects/win/libzrtp.2010.vcxproj @@ -0,0 +1,250 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C13CC324-0032-4492-9A30-310A6BD64FF5} + libzrtp.x32 + Win32Proj + libzrtp + + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Default + + + Level3 + ProgramDatabase + CompileAsC + + + + if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" + + + + + Disabled + ../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Default + + + Level3 + ProgramDatabase + CompileAsC + + + + if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" + + + + + ../../include;../../third_party/bnlib;../../third_party/bgaes;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) + + + MultiThreadedDLL + Default + false + + + Level3 + ProgramDatabase + CompileAsC + + + + if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" + + + + + ../../include;../../third_party/bnlib;../../third_party/bgaes;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) + + + MultiThreadedDLL + Default + false + + + Level3 + ProgramDatabase + CompileAsC + + + + if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp.2010.vcxproj.filters b/libs/libzrtp/projects/win/libzrtp.2010.vcxproj.filters new file mode 100644 index 0000000000..4bae11a1dd --- /dev/null +++ b/libs/libzrtp/projects/win/libzrtp.2010.vcxproj.filters @@ -0,0 +1,256 @@ + + + + + {c0e76076-0032-445d-8c07-32b6c762622b} + + + {a03c0d83-0032-4848-9704-22cdce5ab144} + + + {dbe8a34e-0032-495e-8df7-e82218921e60} + + + {96d1a5c9-0032-4230-a764-a0ed11f434a7} + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bnlib + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + bgaes + + + + + + + \ No newline at end of file diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index d0002a7d3d..c69b5e9692 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -418,8 +418,6 @@ zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream return zrtp_status_alloc_fail; } - ZSTR_SET_EMPTY(new_stream->signaling_hash); - /* * Initialize the private data stream with default initial values */ @@ -437,6 +435,8 @@ zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream ZSTR_SET_EMPTY(new_stream->cc.zrtp_key); ZSTR_SET_EMPTY(new_stream->cc.peer_zrtp_key); + ZSTR_SET_EMPTY(new_stream->messages.signaling_hash); + new_stream->dh_cc.initialized_with = ZRTP_COMP_UNKN; bnBegin(&new_stream->dh_cc.peer_pv); ZSTR_SET_EMPTY(new_stream->dh_cc.dhss); @@ -638,8 +638,8 @@ zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* ctx, ctx->messages.signaling_hash.length = ZRTP_MESSAGE_HASH_SIZE; { - char buff[66]; - ZRTP_LOG(3, (_ZTU_,"SIGNALLING HAS was ADDED for the comparing. ID=%u\n", ctx->id)); + char buff[64]; + ZRTP_LOG(3, (_ZTU_,"SIGNALLING HAS was ADDED for the comparision. ID=%u\n", ctx->id)); ZRTP_LOG(3, (_ZTU_,"Hash=%s.\n", hex2str(hash_buff, hash_buff_length, buff, sizeof(buff)))); } diff --git a/libs/libzrtp/src/zrtp_pbx.c b/libs/libzrtp/src/zrtp_pbx.c index f4f5a906c4..cc25c46b3e 100644 --- a/libs/libzrtp/src/zrtp_pbx.c +++ b/libs/libzrtp/src/zrtp_pbx.c @@ -128,13 +128,15 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf zrtp_status_t s = zrtp_status_fail; zrtp_string128_t hmac = ZSTR_INIT_EMPTY(hmac); char zerosashash[32]; + unsigned sas_scheme_did_change = 0; + unsigned sas_hash_did_change = 0; /* (padding + sig_len + flags) + SAS scheme and SAS hash */ const uint8_t encrypted_body_size = (2 + 1 + 1) + 4 + 32; zrtp_memset(zerosashash, 0, sizeof(zerosashash)); - /* Check if the remote endpoint is assiggneed to relay the SAS values */ + /* Check if the remote endpoint is assigned to relay the SAS values */ if (!stream->peer_mitm_flag) { ZRTP_LOG(2,(_ZTU_, ZRTP_RELAYED_SAS_FROM_NONMITM_STR)); return zrtp_status_fail; @@ -157,7 +159,7 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf return zrtp_status_fail; } - ZRTP_LOG(3,(_ZTU_, "\tHMAC value for the SASRELAY is correct - decryptiong...\n")); + ZRTP_LOG(3,(_ZTU_, "\tHMAC value for the SASRELAY is correct - decrypting...\n")); /* Then we need to decrypt Confirm body */ do @@ -217,9 +219,14 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); return zrtp_status_fail; } - session->sasscheme = zrtp_comp_find(ZRTP_CC_SAS, rendering_id, session->zrtp ); - ZRTP_LOG(3,(_ZTU_,"\tSasrelay: New Rendering scheme %.4s.\n", session->sasscheme->base.type)); + /* Check is SAS rendering did change */ + if (rendering_id != session->sasscheme->base.id) { + session->sasscheme = zrtp_comp_find(ZRTP_CC_SAS, rendering_id, session->zrtp ); + + sas_scheme_did_change = 1; + ZRTP_LOG(3,(_ZTU_,"\tSasrelay: Rendering scheme was updated to %.4s.\n", session->sasscheme->base.type)); + } if (session->secrets.matches & ZRTP_BIT_PBX) { if ( ( ((uint32_t) *sasrelay->sas_scheme) != (uint32_t)0x0L ) && @@ -231,7 +238,8 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf zrtp_memcpy(session->sasbin.buffer, sasrelay->sashash, session->sasbin.length); stream->mitm_mode = ZRTP_MITM_MODE_RECONFIRM_CLIENT; - ZRTP_LOG(3,(_ZTU_,"\tSasRelay: SAS value was updated bin=%s.\n", + sas_hash_did_change = 1; + ZRTP_LOG(3,(_ZTU_,"\tSasRelay: SAS value was updated to bin=%s.\n", hex2str(buff, sizeof(buff), session->sasbin.buffer, session->sasbin.length))); } } else if (0 != zrtp_memcmp(sasrelay->sashash, zerosashash, sizeof(sasrelay->sashash))) { @@ -242,16 +250,24 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf ZRTP_LOG(1,(_ZTU_, "\rERROR! For SasRelay Other secret doesn't match. ID=%u\n", stream->id)); } - s = session->sasscheme->compute(session->sasscheme, stream, session->hash, 1); - if (zrtp_status_ok != s) { - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - return s; - } - ZRTP_LOG(3,(_ZTU_,"\tSasRelay: Updated SAS is <%s> <%s>.\n", session->sas1.buffer, session->sas2.buffer)); + /* Generate new SAS if hash or rendering scheme did change. + * Note: latest libzrtp may send "empty" SasRelay with the same SAS rendering + * scheme and empty Hello hash for consistency reasons, we should ignore + * such packets. + */ + if (sas_scheme_did_change || sas_hash_did_change) { + s = session->sasscheme->compute(session->sasscheme, stream, session->hash, 1); + if (zrtp_status_ok != s) { + _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); + return s; + } - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_LOCAL_SAS_UPDATED); + ZRTP_LOG(3,(_ZTU_,"\tSasRelay: Updated SAS is <%s> <%s>.\n", session->sas1.buffer, session->sas2.buffer)); + + if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { + session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_LOCAL_SAS_UPDATED); + } } return zrtp_status_ok; @@ -356,8 +372,8 @@ zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream) /* Passive Client endpoint should NOT generate PBX Secret. */ if ((stream->mitm_mode == ZRTP_MITM_MODE_REG_CLIENT) && - (ZRTP_LICENSE_MODE_PASSIVE != stream->zrtp->lic_mode)) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Passive Client endpoint should NOT generate PBX Secert.\n")); + (ZRTP_LICENSE_MODE_PASSIVE == stream->zrtp->lic_mode)) { + ZRTP_LOG(2,(_ZTU_,"WARNING: Passive Client endpoint should NOT generate PBX Secret.\n")); return zrtp_status_bad_param; } @@ -492,7 +508,7 @@ zrtp_status_t zrtp_update_remote_options( zrtp_stream_t* stream, return zrtp_status_bad_param; } - /* Don't allow to transfer the SAS if the library wasn't initalized as MiTM endpoint */ + /* Don't allow to transfer the SAS if the library wasn't initialized as MiTM endpoint */ if (!stream->zrtp->is_mitm) { ZRTP_LOG(3,(_ZTU_,"\tERROR! The endpoint can't transfer SAS values to other endpoints" " without introducing itself by M-flag in Hello. see zrtp_init().\n")); diff --git a/libs/libzrtp/src/zrtp_utils.c b/libs/libzrtp/src/zrtp_utils.c index 7b61aac146..45b5290d85 100644 --- a/libs/libzrtp/src/zrtp_utils.c +++ b/libs/libzrtp/src/zrtp_utils.c @@ -488,7 +488,7 @@ zrtp_status_t _zrtp_packet_preparse( zrtp_stream_t* stream, (const char*) info->message, zrtp_ntoh16(((zrtp_packet_Hello_t*) info->message)->hdr.length)*4, ZSTR_GV(hash_str) ); - if (!zrtp_memcmp(stream->messages.signaling_hash.buffer, hash_str.buffer, ZRTP_MESSAGE_HASH_SIZE)) { + if (zrtp_memcmp(stream->messages.signaling_hash.buffer, hash_str.buffer, ZRTP_MESSAGE_HASH_SIZE)) { if (stream->zrtp->cb.event_cb.on_zrtp_security_event) { stream->zrtp->cb.event_cb.on_zrtp_security_event(stream, ZRTP_EVENT_WRONG_SIGNALING_HASH); } diff --git a/libs/libzrtp/third_party/bnlib/bignum-ARM/bntest16.c b/libs/libzrtp/third_party/bnlib/bignum-ARM/bntest16.c index ccb5f2504e..c220d6e683 100644 --- a/libs/libzrtp/third_party/bnlib/bignum-ARM/bntest16.c +++ b/libs/libzrtp/third_party/bnlib/bignum-ARM/bntest16.c @@ -31,9 +31,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #include @@ -48,9 +45,6 @@ long strtol(const char *, char **, int); #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "cputime.h" #include "lbn16.h" diff --git a/libs/libzrtp/third_party/bnlib/bignum-ARM/config.h b/libs/libzrtp/third_party/bnlib/bignum-ARM/config.h index 671be5c7fc..27e128c8d9 100644 --- a/libs/libzrtp/third_party/bnlib/bignum-ARM/config.h +++ b/libs/libzrtp/third_party/bnlib/bignum-ARM/config.h @@ -27,7 +27,6 @@ #define NO_STRING_H !HAVE_STRING_H #define HAVE_STRINGS_H 0 -#define NEED_MEMORY_H 0 /* We go to some trouble to find accurate times... */ @@ -51,20 +50,6 @@ /* Defines for various kinds of library brokenness */ -/* Define if is missing prototypes (= lots of warnings!) */ -#define NO_STDIO_PROTOS 0 - -/* Define if depends on and breaks without it */ -#define ASSERT_NEEDS_STDIO 0 -/* Define if depends on and complains without it */ -#define ASSERT_NEEDS_STDLIB 0 - -/* - * Define if delcares the mem* functions to take char * - * instead of void * parameters (= lots of warnings) - */ -#define MEM_PROTOS_BROKEN 0 - /* If not available, bcopy() is substituted */ #define HAVE_MEMMOVE 1 #define NO_MEMMOVE !HAVE_MEMMOVE diff --git a/libs/libzrtp/third_party/bnlib/bignum-ARM/kludge.h b/libs/libzrtp/third_party/bnlib/bignum-ARM/kludge.h index 023c8905d7..6c5340e789 100644 --- a/libs/libzrtp/third_party/bnlib/bignum-ARM/kludge.h +++ b/libs/libzrtp/third_party/bnlib/bignum-ARM/kludge.h @@ -11,28 +11,10 @@ * Some compilers complain about #if FOO if FOO isn't defined, * so do the ANSI-mandated thing explicitly... */ -#ifndef ASSERT_NEEDS_STDIO -#define ASSERT_NEEDS_STDIO 0 -#endif -#ifndef ASSERT_NEEDS_STDLIB -#define ASSERT_NEEDS_STDLIB 0 -#endif #ifndef NO_STDLIB_H #define NO_STDLIB_H 0 #endif -/* SunOS 4.1.x needs "stderr" defined, and "exit" declared... */ -#ifdef assert -#if ASSERT_NEEDS_STDIO -#include -#endif -#if ASSERT_NEEDS_STDLIB -#if !NO_STDLIB_H -#include -#endif -#endif -#endif - #ifndef NO_MEMMOVE #define NO_MEMMOVE 0 #endif @@ -47,43 +29,6 @@ #define memcpy(dest,src,len) bcopy(src,dest,len) #endif -#ifndef MEM_PROTOS_BROKEN -#define MEM_PROTOS_BROKEN 0 -#endif -#if MEM_PROTOS_BROKEN -#define memcpy(d,s,l) memcpy((void *)(d), (void const *)(s), l) -#define memmove(d,s,l) memmove((void *)(d), (void const *)(s), l) -#define memcmp(d,s,l) memcmp((void const *)(d), (void const *)(s), l) -#define memset(d,v,l) memset((void *)(d), v, l) -#endif - -/* - * If there are no prototypes for the stdio functions, use these to - * reduce compiler warnings. Uses EOF as a giveaway to indicate - * that was #included. - */ -#ifndef NO_STDIO_PROTOS -#define NO_STDIO_PROTOS 0 -#endif -#if NO_STDIO_PROTOS /* Missing prototypes for "simple" functions */ -#ifdef EOF -#ifdef __cplusplus -extern "C" { -#endif -int (puts)(char const *); -int (fputs)(char const *, FILE *); -int (fflush)(FILE *); -int (printf)(char const *, ...); -int (fprintf)(FILE *, char const *, ...); -/* If we have a sufficiently old-fashioned stdio, it probably uses these... */ -int (_flsbuf)(int, FILE *); -int (_filbuf)(FILE *); -#ifdef __cplusplus -} -#endif -#endif /* EOF */ -#endif /* NO_STDIO_PROTOS */ - /* * Borland C seems to think that it's a bad idea to decleare a * structure tag and not declare the contents. I happen to think diff --git a/libs/libzrtp/third_party/bnlib/bignum-ARM/lbn16.c b/libs/libzrtp/third_party/bnlib/bignum-ARM/lbn16.c index c28e9f2fc0..0b8d52e021 100644 --- a/libs/libzrtp/third_party/bnlib/bignum-ARM/lbn16.c +++ b/libs/libzrtp/third_party/bnlib/bignum-ARM/lbn16.c @@ -84,9 +84,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -99,9 +96,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn.h" #include "lbn16.h" diff --git a/libs/libzrtp/third_party/bnlib/bignum-ARM/lbnmem.c b/libs/libzrtp/third_party/bnlib/bignum-ARM/lbnmem.c index a25844c4c7..70094d5f31 100644 --- a/libs/libzrtp/third_party/bnlib/bignum-ARM/lbnmem.c +++ b/libs/libzrtp/third_party/bnlib/bignum-ARM/lbnmem.c @@ -31,9 +31,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_STDLIB_H #include /* For malloc() & co. */ @@ -48,9 +45,6 @@ void free(); #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #ifndef DBMALLOC #define DBMALLOC 0 diff --git a/libs/libzrtp/third_party/bnlib/bn16.c b/libs/libzrtp/third_party/bnlib/bn16.c index c783827b08..d81ac6acaa 100644 --- a/libs/libzrtp/third_party/bnlib/bn16.c +++ b/libs/libzrtp/third_party/bnlib/bn16.c @@ -29,9 +29,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -44,9 +41,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif /* * This was useful during debugging, so it's left in here. diff --git a/libs/libzrtp/third_party/bnlib/bn32.c b/libs/libzrtp/third_party/bnlib/bn32.c index d7fd51ea2e..d9daca0c97 100644 --- a/libs/libzrtp/third_party/bnlib/bn32.c +++ b/libs/libzrtp/third_party/bnlib/bn32.c @@ -29,9 +29,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -44,9 +41,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif /* * This was useful during debugging, so it's left in here. diff --git a/libs/libzrtp/third_party/bnlib/bn64.c b/libs/libzrtp/third_party/bnlib/bn64.c index 2c98b4b07d..841a277a48 100644 --- a/libs/libzrtp/third_party/bnlib/bn64.c +++ b/libs/libzrtp/third_party/bnlib/bn64.c @@ -29,9 +29,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -44,9 +41,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif /* * This was useful during debugging, so it's left in here. diff --git a/libs/libzrtp/third_party/bnlib/bnconfig.hin b/libs/libzrtp/third_party/bnlib/bnconfig.hin index c526b8e359..1b5e5986f9 100644 --- a/libs/libzrtp/third_party/bnlib/bnconfig.hin +++ b/libs/libzrtp/third_party/bnlib/bnconfig.hin @@ -29,7 +29,6 @@ #define NO_STRING_H !HAVE_STRING_H #define HAVE_STRINGS_H 0 -#define NEED_MEMORY_H 0 /* We go to some trouble to find accurate times... */ @@ -53,20 +52,6 @@ /* Defines for various kinds of library brokenness */ -/* Define if is missing prototypes (= lots of warnings!) */ -#define NO_STDIO_PROTOS 0 - -/* Define if depends on and breaks without it */ -#define ASSERT_NEEDS_STDIO 0 -/* Define if depends on and complains without it */ -#define ASSERT_NEEDS_STDLIB 0 - -/* - * Define if delcares the mem* functions to take char * - * instead of void * parameters (= lots of warnings) - */ -#define MEM_PROTOS_BROKEN 0 - /* If not available, bcopy() is substituted */ #define HAVE_MEMMOVE 0 #define NO_MEMMOVE !HAVE_MEMMOVE diff --git a/libs/libzrtp/third_party/bnlib/bnconfig.win b/libs/libzrtp/third_party/bnlib/bnconfig.win new file mode 100644 index 0000000000..2e36938835 --- /dev/null +++ b/libs/libzrtp/third_party/bnlib/bnconfig.win @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1995 Colin Plumb. All rights reserved. + * For licensing and other legal details, see the file legal.c. + * + * bnconfig.h -- Configuration file for BigNum library. + * + * This file is automatically filled in by configure. + * Everything must start out turned *off*, because configure + * (or, more properly, config.status) only knows how to turn them + * *on*. + */ +#ifndef CONFIG_H +#define CONFIG_H + +/* Define to empty if the compiler does not support 'const' variables. */ +#undef const + +/* Define to `unsigned' if doesn't define it. */ +#undef size_t + +/* Checks for the presence and absence of various header files */ +#define HAVE_ASSERT_H 1 +#define NO_ASSERT_H !HAVE_ASSERT_H +#define HAVE_LIMITS_H 1 +#define NO_LIMITS_H !HAVE_LIMITS_H +#define HAVE_STDLIB_H 1 +#define NO_STDLIB_H !HAVE_STDLIB_H +#define HAVE_STRING_H 1 +#define NO_STRING_H !HAVE_STRING_H + +#define HAVE_STRINGS_H 0 + +/* We go to some trouble to find accurate times... */ + +/* Define if you have Posix.4 glock_gettime() */ +#define HAVE_CLOCK_GETTIME 0 +/* Define if you have Solaris-style gethrvtime() */ +#define HAVE_GETHRVTIME 0 +/* Define if you have getrusage() */ +#define HAVE_GETRUSAGE 0 +/* Define if you have clock() */ +#define HAVE_CLOCK 0 +/* Define if you have time() */ +#define HAVE_TIME 0 + +/* + * Define as 0 if #including automatically + * #includes , and doing so explicitly causes an + * error. + */ +#define TIME_WITH_SYS_TIME 0 + +/* Defines for various kinds of library brokenness */ + +/* If not available, bcopy() is substituted */ +#define HAVE_MEMMOVE 1 +#define NO_MEMMOVE !HAVE_MEMMOVE +#define HAVE_MEMCPY 1 +#define NO_MEMCPY !HAVE_MEMCPY + +#endif /* CONFIG_H */ diff --git a/libs/libzrtp/third_party/bnlib/bntest16.c b/libs/libzrtp/third_party/bnlib/bntest16.c index 9068f0fbb9..19ccbd0ac9 100644 --- a/libs/libzrtp/third_party/bnlib/bntest16.c +++ b/libs/libzrtp/third_party/bnlib/bntest16.c @@ -38,9 +38,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #include @@ -55,9 +52,6 @@ long strtol(const char *, char **, int); #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn16.h" #include "kludge.h" diff --git a/libs/libzrtp/third_party/bnlib/bntest32.c b/libs/libzrtp/third_party/bnlib/bntest32.c index 987dc77f34..6cc9ff27c5 100644 --- a/libs/libzrtp/third_party/bnlib/bntest32.c +++ b/libs/libzrtp/third_party/bnlib/bntest32.c @@ -38,9 +38,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #include @@ -55,9 +52,6 @@ long strtol(const char *, char **, int); #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn32.h" #include "kludge.h" diff --git a/libs/libzrtp/third_party/bnlib/bntest64.c b/libs/libzrtp/third_party/bnlib/bntest64.c index 01fda81891..dbc4fd6c0d 100644 --- a/libs/libzrtp/third_party/bnlib/bntest64.c +++ b/libs/libzrtp/third_party/bnlib/bntest64.c @@ -38,9 +38,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #include @@ -55,9 +52,6 @@ long strtol(const char *, char **, int); #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn64.h" #include "kludge.h" diff --git a/libs/libzrtp/third_party/bnlib/bootstrap.sh b/libs/libzrtp/third_party/bnlib/bootstrap.sh new file mode 100755 index 0000000000..93030be3f6 --- /dev/null +++ b/libs/libzrtp/third_party/bnlib/bootstrap.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +aclocal +autoconf + diff --git a/libs/libzrtp/third_party/bnlib/configure.in b/libs/libzrtp/third_party/bnlib/configure.in index 917762ec4e..a51e304359 100644 --- a/libs/libzrtp/third_party/bnlib/configure.in +++ b/libs/libzrtp/third_party/bnlib/configure.in @@ -7,7 +7,7 @@ dnl Anything which is not an m4 macro is copied directly to the output. dnl dnl Start things up. If the specified file doesn't exist, configure dnl will complain. -AC_INIT(lbn16.c) +AC_INIT([libbn], [0.1]) dnl The following tests need to know that we intend to produce a config.h dnl file, even though this won't expand to any shell script code until @@ -219,64 +219,9 @@ else # If non-ANSI, check for other brokenness. AC_CHECK_HEADERS(assert.h limits.h stdlib.h string.h) -# Do we want to include memory.h? -if test $ac_cv_header_string_h = no; then -AC_CHECK_HEADERS(strings.h) -ac_found=no -else -AC_MSG_CHECKING(whether string.h declares mem functions) -AC_EGREP_HEADER(memset, string.h, ac_found=yes, ac_found=no) -AC_MSG_RESULT($ac_found) -fi -# ac_found is now "yes" if string.h exists and declares the mem* -# functions. If not, see if memory.h exists and include that -# as well. -if test $ac_found = no; then -AC_CHECK_HEADER(memory,h. [AC_DEFINE(NEED_MEMORY_H)]) -fi - -AC_CACHE_CHECK(whether provides prototypes, -bn_cv_header_stdio_protos, -[AC_EGREP_HEADER(printf, stdio.h, bn_cv_header_stdio_protos=yes, bn_cv_header_stdio_protos=no) -]) -if test $bn_cv_header_stdio_protos = no; then - AC_DEFINE(NO_STDIO_PROTOS) -fi - fi # ^^ End of non-ANSI header brokenness tests (first part) -AC_CACHE_CHECK(whether declares mem* wrong., -bn_cv_header_mem_broken, -[AC_EGREP_HEADER(memcpy.*char, string.h, bn_cv_header_mem_broken=yes, bn_cv_header_mem_broken=no) -]) -if test $bn_cv_header_mem_broken = yes; then - AC_DEFINE(MEM_PROTOS_BROKEN) -fi - -# SunOS 4.1.x acc's is broken -AC_CACHE_CHECK(whether is broken and needs , -bn_cv_header_assert_needs_stdio, -[AC_EGREP_CPP(stderr, -[#include -assert(foo) -], bn_cv_header_assert_needs_stdio=yes, bn_cv_header_assert_needs_stdio=no) -]) -if test $bn_cv_header_assert_needs_stdio = yes; then - AC_DEFINE(ASSERT_NEEDS_STDIO) -fi - -AC_CACHE_CHECK(whether is broken and needs , -bn_cv_header_assert_needs_stdlib, -[AC_EGREP_CPP(exit, -[#include -assert(foo) -], bn_cv_header_assert_needs_stdlib=yes, bn_cv_header_assert_needs_stdlib=no) -]) -if test $bn_cv_header_assert_needs_stdlib = yes; then - AC_DEFINE(ASSERT_NEEDS_STDLIB) -fi - # Check that we have explicitly. AC_CHECK_HEADERS(sys/time.h) AC_HEADER_TIME diff --git a/libs/libzrtp/third_party/bnlib/germtest.c b/libs/libzrtp/third_party/bnlib/germtest.c index 71873a1a22..826de77174 100644 --- a/libs/libzrtp/third_party/bnlib/germtest.c +++ b/libs/libzrtp/third_party/bnlib/germtest.c @@ -22,9 +22,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include /* For malloc() */ diff --git a/libs/libzrtp/third_party/bnlib/kludge.h b/libs/libzrtp/third_party/bnlib/kludge.h index 184a24eef5..3d84a1f346 100644 --- a/libs/libzrtp/third_party/bnlib/kludge.h +++ b/libs/libzrtp/third_party/bnlib/kludge.h @@ -15,28 +15,10 @@ * Some compilers complain about #if FOO if FOO isn't defined, * so do the ANSI-mandated thing explicitly... */ -#ifndef ASSERT_NEEDS_STDIO -#define ASSERT_NEEDS_STDIO 0 -#endif -#ifndef ASSERT_NEEDS_STDLIB -#define ASSERT_NEEDS_STDLIB 0 -#endif #ifndef NO_STDLIB_H #define NO_STDLIB_H 0 #endif -/* SunOS 4.1.x needs "stderr" defined, and "exit" declared... */ -#ifdef assert -#if ASSERT_NEEDS_STDIO -#include -#endif -#if ASSERT_NEEDS_STDLIB -#if !NO_STDLIB_H -#include -#endif -#endif -#endif - #ifndef NO_MEMMOVE #define NO_MEMMOVE 0 #endif @@ -51,43 +33,6 @@ #define memcpy(dest,src,len) bcopy(src,dest,len) #endif -#ifndef MEM_PROTOS_BROKEN -#define MEM_PROTOS_BROKEN 0 -#endif -#if MEM_PROTOS_BROKEN -#define memcpy(d,s,l) memcpy((void *)(d), (void const *)(s), l) -#define memmove(d,s,l) memmove((void *)(d), (void const *)(s), l) -#define memcmp(d,s,l) memcmp((void const *)(d), (void const *)(s), l) -#define memset(d,v,l) memset((void *)(d), v, l) -#endif - -/* - * If there are no prototypes for the stdio functions, use these to - * reduce compiler warnings. Uses EOF as a giveaway to indicate - * that was #included. - */ -#ifndef NO_STDIO_PROTOS -#define NO_STDIO_PROTOS 0 -#endif -#if NO_STDIO_PROTOS /* Missing prototypes for "simple" functions */ -#ifdef EOF -#ifdef __cplusplus -extern "C" { -#endif -int (puts)(char const *); -int (fputs)(char const *, FILE *); -int (fflush)(FILE *); -int (printf)(char const *, ...); -int (fprintf)(FILE *, char const *, ...); -/* If we have a sufficiently old-fashioned stdio, it probably uses these... */ -int (_flsbuf)(int, FILE *); -int (_filbuf)(FILE *); -#ifdef __cplusplus -} -#endif -#endif /* EOF */ -#endif /* NO_STDIO_PROTOS */ - /* * Borland C seems to think that it's a bad idea to decleare a * structure tag and not declare the contents. I happen to think diff --git a/libs/libzrtp/third_party/bnlib/lbn.h b/libs/libzrtp/third_party/bnlib/lbn.h index b0fd21cfb5..43fc7c91dc 100644 --- a/libs/libzrtp/third_party/bnlib/lbn.h +++ b/libs/libzrtp/third_party/bnlib/lbn.h @@ -145,6 +145,12 @@ typedef unsigned long long bnword64; #define BNWORD64 bnword64 #endif +/*Workaround for windows for now. */ +#ifdef WIN32 +typedef unsigned long long bnword64; +#define BNWORD64 bnword64 +#endif + /* We don't even try to find a 128-bit type at the moment */ #endif /* !LBN_H */ diff --git a/libs/libzrtp/third_party/bnlib/lbn16.c b/libs/libzrtp/third_party/bnlib/lbn16.c index 36c98b8e73..6e00a020e8 100644 --- a/libs/libzrtp/third_party/bnlib/lbn16.c +++ b/libs/libzrtp/third_party/bnlib/lbn16.c @@ -85,9 +85,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -100,9 +97,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn.h" #include "lbn16.h" diff --git a/libs/libzrtp/third_party/bnlib/lbn32.c b/libs/libzrtp/third_party/bnlib/lbn32.c index 6d3cd35454..996cccdc61 100644 --- a/libs/libzrtp/third_party/bnlib/lbn32.c +++ b/libs/libzrtp/third_party/bnlib/lbn32.c @@ -85,9 +85,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -100,9 +97,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn.h" #include "lbn32.h" diff --git a/libs/libzrtp/third_party/bnlib/lbn64.c b/libs/libzrtp/third_party/bnlib/lbn64.c index 3eb3cee596..c0f659ee3c 100644 --- a/libs/libzrtp/third_party/bnlib/lbn64.c +++ b/libs/libzrtp/third_party/bnlib/lbn64.c @@ -85,9 +85,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -100,9 +97,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "lbn.h" #include "lbn64.h" diff --git a/libs/libzrtp/third_party/bnlib/lbnmem.c b/libs/libzrtp/third_party/bnlib/lbnmem.c index a2194c09ae..06ab8a2ce5 100644 --- a/libs/libzrtp/third_party/bnlib/lbnmem.c +++ b/libs/libzrtp/third_party/bnlib/lbnmem.c @@ -32,9 +32,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_STDLIB_H #include /* For malloc() & co. */ @@ -49,9 +46,6 @@ void free(); #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #ifndef DBMALLOC #define DBMALLOC 0 diff --git a/libs/libzrtp/third_party/bnlib/sieve.c b/libs/libzrtp/third_party/bnlib/sieve.c index 033cb117df..697e62652f 100644 --- a/libs/libzrtp/third_party/bnlib/sieve.c +++ b/libs/libzrtp/third_party/bnlib/sieve.c @@ -108,9 +108,6 @@ #ifndef HAVE_STRINGS_H #define HAVE_STRINGS_H 0 #endif -#ifndef NEED_MEMORY_H -#define NEED_MEMORY_H 0 -#endif #if !NO_ASSERT_H #include @@ -127,9 +124,6 @@ #elif HAVE_STRINGS_H #include #endif -#if NEED_MEMORY_H -#include -#endif #include "bn.h" #include "sieve.h" diff --git a/libs/libzrtp/third_party/bnlib/test/kludge.h b/libs/libzrtp/third_party/bnlib/test/kludge.h index 779e5aa1fe..695db0b653 100644 --- a/libs/libzrtp/third_party/bnlib/test/kludge.h +++ b/libs/libzrtp/third_party/bnlib/test/kludge.h @@ -24,40 +24,6 @@ #define raise(sig) kill(getpid(),sig) #endif -/* - * If there are no prototypes for the stdio functions, to reduce - * compiler warnings include these... conditional on EOF being - * defined (a giveaway that was #included). - */ -#if defined(EOF) - -#if NO_STDIO_PROTOS /* Missing prototypes for "simple" functions */ -int (puts)(char const *); -int (fputs)(char const *, FILE *); -void (rewind)(FILE *); -int (fflush)(FILE *); -int (fclose)(FILE *); -int (printf)(char const *, ...); -int (fprintf)(FILE *, char const *, ...); -int (fseek)(FILE *, long, int); -int (remove)(char const *); -int (rename)(char const *, char const *); -void (perror)(char const *); -int (system)(char const *); /* Really in , but this'll do... */ -int (pclose)(FILE *); -/* If we have a sufficiently old-fashioned stdio, it probably uses these... */ -int (_flsbuf)(int, FILE *); -int (_filbuf)(FILE *); -int (ungetc)(int, FILE *); -size_t (fread)(char *, size_t, size_t, FILE *); -size_t (fwrite)(char const *, size_t, size_t, FILE *); -#if defined(va_start) || defined(va_arg) || defined(va_end) -int (vfprintf)(FILE *, char const *, ...); -#endif -#endif /* NO_STDIO_PROTOS */ - -#endif /* EOF */ - /* * Make Microsoft Visual C shut the hell up about a few things... * Warning 4116 complains about the alignof() macro, saying: diff --git a/libs/openzap/Makefile.am b/libs/openzap/Makefile.am index e8c9fbf3db..52af5e3082 100644 --- a/libs/openzap/Makefile.am +++ b/libs/openzap/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2007, Anthony Minessale II +# Copyright (c) 2007-2012, Anthony Minessale II # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c index ea10ab5cd4..e67d71e15e 100644 --- a/libs/openzap/mod_openzap/mod_openzap.c +++ b/libs/openzap/mod_openzap/mod_openzap.c @@ -297,7 +297,7 @@ static void cycle_foreground(zap_channel_t *zchan, int flash, const char *bcast) const char *buuid; tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); - buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + buuid = switch_channel_get_partner_uuid(channel); if (zchan->token_count == 1 && flash) { @@ -1663,19 +1663,19 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal) if ((session_a = switch_core_session_locate(sigmsg->channel->tokens[0]))) { channel_a = switch_core_session_get_channel(session_a); - br_a_uuid = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE); + br_a_uuid = switch_channel_get_partner_uuid(channel_a); tech_pvt = switch_core_session_get_private(session_a); - stop_hold(session_a, switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE)); + stop_hold(session_a, switch_channel_get_partner_uuid(channel_a)); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); } if ((session_b = switch_core_session_locate(sigmsg->channel->tokens[1]))) { channel_b = switch_core_session_get_channel(session_b); - br_b_uuid = switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE); + br_b_uuid = switch_channel_get_partner_uuid(channel_b); tech_pvt = switch_core_session_get_private(session_b); - stop_hold(session_a, switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE)); + stop_hold(session_a, switch_channel_get_partner_uuid(channel_b)); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); } @@ -1738,7 +1738,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal) tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); - buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + buuid = switch_channel_get_partner_uuid(channel); zap_set_state_locked(sigmsg->channel, ZAP_CHANNEL_STATE_UP); stop_hold(session, buuid); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); diff --git a/libs/openzap/src/include/libteletone.h b/libs/openzap/src/include/libteletone.h index b54098c8ee..4fb3d9975d 100644 --- a/libs/openzap/src/include/libteletone.h +++ b/libs/openzap/src/include/libteletone.h @@ -1,6 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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) 2007, Anthony Minessale II + * Copyright (c) 2005-2012, 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 c8c667d282..173f2b563b 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 1b774206ff..212dbbb19b 100644 --- a/libs/openzap/src/include/libteletone_generate.h +++ b/libs/openzap/src/include/libteletone_generate.h @@ -1,8 +1,6 @@ /* * libteletone - * Copyright (C) 2005-2011, Anthony Minessale II - * - * Copyright (c) 2007, Anthony Minessale II + * Copyright (C) 2005-2012, 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 32cce92c69..ab33b00bf4 100644 --- a/libs/openzap/src/include/openzap.h +++ b/libs/openzap/src/include/openzap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 9a05420979..ed23ce4dd7 100644 --- a/libs/openzap/src/include/zap_buffer.h +++ b/libs/openzap/src/include/zap_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 f2f2e374bf..6345750821 100644 --- a/libs/openzap/src/include/zap_config.h +++ b/libs/openzap/src/include/zap_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 165533ff22..0b65ea865a 100644 --- a/libs/openzap/src/include/zap_types.h +++ b/libs/openzap/src/include/zap_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 2c4253b314..758142f53e 100644 --- a/libs/openzap/src/libteletone_detect.c +++ b/libs/openzap/src/libteletone_detect.c @@ -10,7 +10,7 @@ * * libteletone_detect.c Tone Detection Code * - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 1d5d696af2..e40c8f5729 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 b80309017c..7d9834f1b4 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, Anthony Minessale II, Nenad Corbic + * Copyright (c) 2007-2012, 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 d878b9195e..5a36a23359 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 3ffa422ead..f1ae31cc14 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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_em/ozmod_analog_em.c b/libs/openzap/src/ozmod/ozmod_analog_em/ozmod_analog_em.c index 581c6dd45a..9d4573f3a6 100644 --- a/libs/openzap/src/ozmod/ozmod_analog_em/ozmod_analog_em.c +++ b/libs/openzap/src/ozmod/ozmod_analog_em/ozmod_analog_em.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Anthony Minessale II + * Copyright (c) 2008-2012, 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_em/zap_analog_em.h b/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h index eb9f9f3d20..1a0e355106 100644 --- a/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h +++ b/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Anthony Minessale II + * Copyright (c) 2008-2012, 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 fc998b126f..529e87d10d 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 c5e0e5a711..3542a550ab 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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/lpwrap_pri.c b/libs/openzap/src/ozmod/ozmod_libpri/lpwrap_pri.c index 3df1d54d89..bd8f72202d 100644 --- a/libs/openzap/src/ozmod/ozmod_libpri/lpwrap_pri.c +++ b/libs/openzap/src/ozmod/ozmod_libpri/lpwrap_pri.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, 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/lpwrap_pri.h b/libs/openzap/src/ozmod/ozmod_libpri/lpwrap_pri.h index 4c79526b9e..bd63db15c2 100644 --- a/libs/openzap/src/ozmod/ozmod_libpri/lpwrap_pri.h +++ b/libs/openzap/src/ozmod/ozmod_libpri/lpwrap_pri.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, 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 f18aa1fc54..511746afa8 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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.h b/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.h index 8c929516ba..f31671735c 100644 --- a/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.h +++ b/libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Anthony Minessale II + * Copyright (c) 2009-2012, 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 154c1618ff..2084848235 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 27c455a429..758ea32763 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 dc2218012e..a1bdaa77b1 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 5b3e5b87ad..96e2ae72ec 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, Anthony Minessale II, Nenad Corbic + * Copyright (c) 2007-2012, 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 861f941ceb..8ae6e74101 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, Anthony Minessale II, Nenad Corbic + * Copyright (c) 2007-2012, 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 a48060812b..10ac69d63d 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 949e0fbf31..b4bc8676ee 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 8423aac34b..109e34cd9c 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 ca42c2c578..4b2836d5b2 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 687269a983..c496df9bae 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, Anthony Minessale II + * Copyright (c) 2007-2012, 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 080e5d4cef..fddec03e5b 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 Anthony Minessale II + * Copyright: (c) 2005-2012 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 c160eedd28..9da5c951af 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 Anthony Minessale II + * Copyright: (c) 2005-2012 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 880fc85cea..5829a699ea 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 Anthony Minessale II + * Copyright: (c) 2005-2012 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 0e2279d7e3..1a3b6a8311 100644 --- a/libs/openzap/src/zap_buffer.c +++ b/libs/openzap/src/zap_buffer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 ca0315594b..54119e1e8c 100644 --- a/libs/openzap/src/zap_config.c +++ b/libs/openzap/src/zap_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 283a9fe332..6235f92392 100644 --- a/libs/openzap/src/zap_io.c +++ b/libs/openzap/src/zap_io.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Anthony Minessale II + * Copyright (c) 2007-2012, 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 50736b75e4..e5bc4cdd38 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, Anthony Minessale II, Nenad Corbic * + * Copyright (c) 2007-2012, 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/sofia-sip/.update b/libs/sofia-sip/.update index cf78cb49ef..142a1e1a97 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Tue Apr 10 16:19:10 CDT 2012 +Wed Aug 15 22:51:21 CDT 2012 diff --git a/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c b/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c index 830603f169..087810ebc7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c +++ b/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c @@ -535,8 +535,6 @@ void auth_method_basic(auth_mod_t *am, if (!au->au_params) continue; n = base64_d(userpass, upsize - 1, au->au_params[0]); - if (n < 0 || n >= INT_MAX) - continue; if (n >= upsize) { void *b = realloc(userpass == buffer ? NULL : userpass, upsize = n + 1); if (b == NULL) @@ -963,6 +961,7 @@ int auth_readdb_internal(auth_mod_t *am, int always) FILE *f; char *data, *s; size_t len, i, n, N; + ssize_t slen; auth_passwd_t *apw; if (!am->am_stat) @@ -1004,7 +1003,7 @@ int auth_readdb_internal(auth_mod_t *am, int always) if (am->am_stat) stat(am->am_db, am->am_stat); /* too bad if this fails */ - len = readfile(am->am_home, f, &buffer, 1); + slen = readfile(am->am_home, f, &buffer, 1); #if HAVE_FLOCK /* Release shared lock on the database file */ @@ -1018,8 +1017,9 @@ int auth_readdb_internal(auth_mod_t *am, int always) fclose(f); - if (len < 0) + if (slen < 0) return -1; + len = (size_t)slen; /* Count number of entries in new buffer */ for (i = am->am_anonymous, s = data = buffer; @@ -1210,7 +1210,7 @@ ssize_t readfile(su_home_t *home, buffer[len] = '\0'; *contents = buffer; - return len; + return (ssize_t)len; } /* ====================================================================== */ diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/msg.c b/libs/sofia-sip/libsofia-sip-ua/msg/msg.c index 264ca267f8..385188835d 100644 --- a/libs/sofia-sip/libsofia-sip-ua/msg/msg.c +++ b/libs/sofia-sip/libsofia-sip-ua/msg/msg.c @@ -242,8 +242,8 @@ msg_mclass_t const *msg_mclass(msg_t const *msg) */ void msg_addr_zero(msg_t *msg) { - memset(&msg->m_addr, 0, sizeof(&msg->m_addr)); - memset(&msg->m_addrinfo, 0, sizeof(&msg->m_addrinfo)); + memset(&msg->m_addr, 0, sizeof(msg->m_addr)); + memset(&msg->m_addrinfo, 0, sizeof(msg->m_addrinfo)); msg->m_addrinfo.ai_addrlen = sizeof(msg->m_addr); msg->m_addrinfo.ai_addr = &msg->m_addr->su_sa; diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c index 5dd574b88f..e690b424e7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c +++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c @@ -4165,7 +4165,7 @@ nta_leg_t *nta_leg_tcreate(nta_agent_t *agent, if (i == NONE) /* Magic value, used for compatibility */ no_dialog = 1; - if (!(leg = su_home_clone(agent->sa_home, sizeof(*leg)))) + if (!(leg = su_home_clone(NULL, sizeof(*leg)))) return NULL; home = leg->leg_home; @@ -4394,7 +4394,8 @@ void nta_leg_destroy(nta_leg_t *leg) static void leg_free(nta_agent_t *sa, nta_leg_t *leg) { - su_free(sa->sa_home, leg); + //su_free(sa->sa_home, leg); + su_home_unref((su_home_t *)leg); } /** Return application context for the leg */ @@ -5327,7 +5328,7 @@ nta_incoming_t *incoming_create(nta_agent_t *agent, } irq->irq_branch = sip->sip_via->v_branch; irq->irq_reliable_tp = tport_is_reliable(tport); - irq->irq_extra_100 = 1; /* Sending extra 100 trying true by default */ + irq->irq_extra_100 = 0; /* Sending extra 100 trying false by default */ if (sip->sip_timestamp) irq->irq_timestamp = sip_timestamp_copy(home, sip->sip_timestamp); @@ -6068,7 +6069,7 @@ incoming_recv(nta_incoming_t *irq, msg_t *msg, sip_t *sip, tport_t *tport) if (irq->irq_status >= 100) { SU_DEBUG_5(("nta: re-received %s request, retransmitting %u reply\n", sip->sip_request->rq_method_name, irq->irq_status)); - incoming_retransmit_reply(irq, tport); + incoming_retransmit_reply(irq, tport); } else if (irq->irq_agent->sa_extra_100 && irq->irq_extra_100) { diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c index bc842c242d..661a18b1d2 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c @@ -109,8 +109,8 @@ nua_handle_t *nh_create_handle(nua_t *nua, assert(nua->nua_home); - if ((nh = su_home_clone(nua->nua_home, sizeof(*nh)))) { - //if ((nh = su_home_new(sizeof(*nh)))) { + //if ((nh = su_home_clone(nua->nua_home, sizeof(*nh)))) { + if ((nh = su_home_new(sizeof(*nh)))) { nh->nh_valid = nua_valid_handle_cookie; nh->nh_nua = nua; nh->nh_magic = hmagic; diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c index 96a8059c21..0ddecd95f3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c @@ -199,7 +199,7 @@ void authorize_watcher(nea_server_t *nes, int substate = sn->sn_state; int status; char const *phrase; - SET_STATUS1(SIP_200_OK); + SET_STATUS(200, sip_200_OK); /* OK. In nhp (nua_handle_preferences_t) structure we have the current default action (or state) for incoming @@ -218,10 +218,10 @@ void authorize_watcher(nea_server_t *nes, substate = nua_substate_pending; if (substate == nua_substate_terminated) { - what = "rejected"; SET_STATUS1(SIP_403_FORBIDDEN); + what = "rejected"; SET_STATUS(403, sip_403_Forbidden); } else if (substate == nua_substate_pending) { - what = "pending"; SET_STATUS1(SIP_202_ACCEPTED); + what = "pending"; SET_STATUS(202, sip_202_Accepted); } else { what = "active"; diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c index e7d3d7470f..8ef6747aff 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c @@ -1000,13 +1000,14 @@ int nua_refer_server_respond(nua_server_request_t *sr, tagi_t const *tags) static int nua_refer_server_report(nua_server_request_t *sr, tagi_t const *tags) { - nua_handle_t *nh = sr->sr_owner; + //nua_handle_t *nh = sr->sr_owner; struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage); sip_t const *sip = sr->sr_request.sip; sip_referred_by_t *by = sip->sip_referred_by, default_by[1]; sip_event_t const *o = sr->sr_usage->du_event; enum nua_substate substate = nua_substate_terminated; - int initial = sr->sr_initial, retval; + //int initial = sr->sr_initial, retval; + int retval; if (nu) { if (!sr->sr_terminating) @@ -1029,13 +1030,14 @@ int nua_refer_server_report(nua_server_request_t *sr, tagi_t const *tags) if (retval >= 2 || nu == NULL) return retval; +#if 0 if (initial) nua_stack_post_signal(nh, nua_r_notify, SIPTAG_EVENT(o), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"), - TAG_END()); - + TAG_END()); +#endif return retval; } diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c index 58b480440a..0f6a491dff 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c @@ -139,6 +139,7 @@ int nua_stack_set_defaults(nua_handle_t *nh, NHP_SET(nhp, only183_100rel, 0); NHP_SET(nhp, auto_answer, 0); NHP_SET(nhp, auto_ack, 1); + NHP_SET(nhp, timer_autorequire, 1); NHP_SET(nhp, invite_timeout, 120); nhp->nhp_session_timer = 1800; @@ -741,6 +742,10 @@ static int nhp_set_tags(su_home_t *home, else if (tag == nutag_autoack) { NHP_SET(nhp, auto_ack, value != 0); } + /* NUTAG_TIMER_AUTOREQUIRE(timer_autorequire) */ + else if (tag == nutag_timer_autorequire) { + NHP_SET(nhp, timer_autorequire, value != 0); + } /* NUTAG_INVITE_TIMER(invite_timeout) */ else if (tag == nutag_invite_timer) { NHP_SET(nhp, invite_timeout, (unsigned)value); @@ -1647,6 +1652,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e, TIF(NUTAG_ONLY183_100REL, only183_100rel), TIF(NUTAG_AUTOANSWER, auto_answer), TIF(NUTAG_AUTOACK, auto_ack), + TIF(NUTAG_TIMER_AUTOREQUIRE, timer_autorequire), TIF(NUTAG_INVITE_TIMER, invite_timeout), TIFD(NUTAG_SESSION_TIMER, session_timer), diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h b/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h index 1904a080c5..9fe4a98652 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h @@ -109,6 +109,8 @@ struct nua_handle_preferences /** Always include id with Event: refer */ unsigned nhp_refer_with_id:1; + + unsigned nhp_timer_autorequire:1; unsigned:0; /* Default lifetime for implicit subscriptions created by REFER */ @@ -207,6 +209,7 @@ struct nua_handle_preferences unsigned nhb_appl_method:1; unsigned nhb_initial_route:1; unsigned nhb_proxy:1; + unsigned nhb_timer_autorequire:1; unsigned :0; } set_bits; unsigned set_unsigned[2]; diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c index dbe588cc8e..2a55c345a7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c @@ -413,7 +413,7 @@ static int nua_publish_client_response(nua_client_request_t *cr, if (!ex || ex->ex_delta == 0) SET_STATUS(900, "Received Invalid Expiration Time"); else - SET_STATUS1(NUA_ERROR_AT(__FILE__, __LINE__)); + SET_STATUS(900, _NUA_INTERNAL_ERROR_AT(__FILE__, __LINE__)); } else nua_dialog_usage_set_refresh(du, ex->ex_delta); diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c index 50150a3a42..deae102ca2 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c @@ -261,11 +261,12 @@ int nua_stack_process_request(nua_handle_t *nh, } if (sr->sr_status <= 100) { - SR_STATUS1(sr, SIP_100_TRYING); + SR_STATUS1(sr, SIP_100_TRYING); if (method == sip_method_invite || sip->sip_timestamp) { - nta_incoming_treply(irq, SIP_100_TRYING, - SIPTAG_USER_AGENT_STR(user_agent), - TAG_END()); + nta_incoming_treply(irq, SIP_100_TRYING, + SIPTAG_USER_AGENT_STR(user_agent), + TAG_END()); + } } else { @@ -294,31 +295,43 @@ int nua_base_server_preprocess(nua_server_request_t *sr) void nua_server_request_destroy(nua_server_request_t *sr) { + nua_server_request_t *sr0 = NULL; + if (sr == NULL) return; if (SR_HAS_SAVED_SIGNAL(sr)) nua_destroy_signal(sr->sr_signal); - if (sr->sr_irq) { - if (sr->sr_method == sip_method_bye && sr->sr_status < 200) { - nta_incoming_treply(sr->sr_irq, SIP_200_OK, TAG_END()); - } - nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL; - } - - if (sr->sr_request.msg) - msg_destroy(sr->sr_request.msg), sr->sr_request.msg = NULL; - - if (sr->sr_response.msg) - msg_destroy(sr->sr_response.msg), sr->sr_response.msg = NULL; - if (sr->sr_prev) { /* Allocated from heap */ if ((*sr->sr_prev = sr->sr_next)) sr->sr_next->sr_prev = sr->sr_prev; - su_free(sr->sr_owner->nh_home, sr); + sr0 = sr; } + + if (sr->sr_irq) { + nta_incoming_t *irq = sr->sr_irq; + if (sr->sr_method == sip_method_bye && sr->sr_status < 200) { + nta_incoming_treply(sr->sr_irq, SIP_200_OK, TAG_END()); + } + sr->sr_irq = NULL; + nta_incoming_destroy(irq); + } + + if (sr->sr_request.msg) { + msg_t *msg = sr->sr_request.msg; + sr->sr_request.msg = NULL; + msg_destroy(msg); + } + + if (sr->sr_response.msg) { + msg_t *msg = sr->sr_response.msg; + sr->sr_response.msg = NULL; + msg_destroy(msg); + } + + if (sr0) su_free(sr->sr_owner->nh_home, sr0); } /**@fn void nua_respond(nua_handle_t *nh, int status, char const *phrase, tag_type_t tag, tag_value_t value, ...); 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 1958b5645a..c17b7b9bb0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c @@ -370,7 +370,8 @@ static int session_timer_check_min_se(msg_t *msg, sip_t *sip, static int session_timer_add_headers(struct session_timer *t, int initial, - msg_t *msg, sip_t *sip); + msg_t *msg, sip_t *sip, + nua_handle_t *nh); static void session_timer_negotiate(struct session_timer *t, int uas); @@ -791,7 +792,7 @@ static int nua_invite_client_request(nua_client_request_t *cr, /* Add session timer headers */ if (session_timer_is_supported(ss->ss_timer)) session_timer_add_headers(ss->ss_timer, ss->ss_state == nua_callstate_init, - msg, sip); + msg, sip, nh); ss->ss_100rel = NH_PGET(nh, early_media); ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition"); @@ -2146,7 +2147,7 @@ nua_session_server_init(nua_server_request_t *sr) if (request->sip_multipart) { mp = request->sip_multipart; } else { - mp = msg_multipart_parse(msg_home(msg), + mp = msg_multipart_parse(nua_handle_home(nh), request->sip_content_type, (sip_payload_t *)request->sip_payload); request->sip_multipart = mp; @@ -2161,13 +2162,13 @@ nua_session_server_init(nua_server_request_t *sr) mpp->mp_payload && mpp->mp_payload->pl_data && su_casenmatch(mpp->mp_content_type->c_type, "application/sdp", 15)) { - request->sip_content_type = msg_content_type_dup(msg_home(msg), mpp->mp_content_type); + request->sip_content_type = msg_content_type_dup(nua_handle_home(nh), mpp->mp_content_type); if (request->sip_content_length) { request->sip_content_length->l_length = mpp->mp_payload->pl_len; } - request->sip_payload->pl_data = su_strdup(msg_home(msg), mpp->mp_payload->pl_data); + request->sip_payload->pl_data = su_strdup(nua_handle_home(nh), mpp->mp_payload->pl_data); request->sip_payload->pl_len = mpp->mp_payload->pl_len; sdp++; @@ -2436,7 +2437,7 @@ int nua_invite_server_respond(nua_server_request_t *sr, tagi_t const *tags) NH_PGET(nh, min_se)); if (session_timer_is_supported(ss->ss_timer)) - session_timer_add_headers(ss->ss_timer, 0, msg, sip); + session_timer_add_headers(ss->ss_timer, 0, msg, sip, nh); } return nua_base_server_respond(sr, tags); @@ -3354,7 +3355,7 @@ static int nua_update_client_request(nua_client_request_t *cr, if (session_timer_is_supported(ss->ss_timer)) session_timer_add_headers(ss->ss_timer, ss->ss_state < nua_callstate_ready, - msg, sip); + msg, sip, nh); retval = nua_base_client_request(cr, msg, sip, NULL); @@ -3610,7 +3611,7 @@ int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags) nua_server_request_t *sr0; int uas; - session_timer_add_headers(ss->ss_timer, 0, msg, sip); + session_timer_add_headers(ss->ss_timer, 0, msg, sip, nh); for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) if (sr0->sr_method == sip_method_invite) @@ -4426,18 +4427,24 @@ static int session_timer_add_headers(struct session_timer *t, int initial, msg_t *msg, - sip_t *sip) + sip_t *sip, + nua_handle_t *nh) { unsigned long expires, min; sip_min_se_t min_se[1]; sip_session_expires_t x[1]; int uas; + int autorequire = 1; enum nua_session_refresher refresher = nua_any_refresher; static sip_param_t const x_params_uac[] = {"refresher=uac", NULL}; static sip_param_t const x_params_uas[] = {"refresher=uas", NULL}; + if ( !NH_PGET(nh, timer_autorequire) && NH_PISSET(nh, timer_autorequire)) { + autorequire = 0; + } + if (!t->local.supported) return 0; @@ -4491,7 +4498,7 @@ session_timer_add_headers(struct session_timer *t, /* Min-SE: 0 is optional with initial INVITE */ || !initial, SIPTAG_MIN_SE(min_se)), - //TAG_IF(refresher == nua_remote_refresher && expires != 0, SIPTAG_REQUIRE_STR("timer")), + TAG_IF(autorequire && refresher == nua_remote_refresher && expires != 0, SIPTAG_REQUIRE_STR("timer")), TAG_END()); return 1; diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c index 96ca20baee..491d485731 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c @@ -1329,6 +1329,8 @@ tag_typedef_t nutag_autoanswer = BOOLTAG_TYPEDEF(autoAnswer); */ tag_typedef_t nutag_autoack = BOOLTAG_TYPEDEF(autoACK); +tag_typedef_t nutag_timer_autorequire = BOOLTAG_TYPEDEF(timerAutorequire); + /**@def NUTAG_AUTOACK_REF(x) * Reference tag for NUTAG_AUTOACK(). */ diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h b/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h index 9e710d052d..813e0d757a 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h +++ b/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h @@ -199,6 +199,11 @@ SOFIAPUBVAR tag_typedef_t nutag_autoack; #define NUTAG_AUTOACK_REF(x) nutag_autoack_ref, tag_bool_vr(&(x)) SOFIAPUBVAR tag_typedef_t nutag_autoack_ref; +#define NUTAG_TIMER_AUTOREQUIRE(x) nutag_timer_autorequire, tag_bool_v(x) +SOFIAPUBVAR tag_typedef_t nutag_timer_autorequire; +#define NUTAG_TIMER_AUTOREQUIRE_REF(x) nutag_timer_autorequire_ref, tag_bool_vr(&(x)) +SOFIAPUBVAR tag_typedef_t nutag_timer_autorequire_ref; + #define NUTAG_AUTOANSWER(x) nutag_autoanswer, tag_bool_v(x) SOFIAPUBVAR tag_typedef_t nutag_autoanswer; #define NUTAG_AUTOANSWER_REF(x) nutag_autoanswer_ref, tag_bool_vr(&(x)) diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c index ceb7d0f601..009ba80695 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c @@ -1372,7 +1372,7 @@ sres_cached_answers_sockaddr(sres_resolver_t *res, return NULL; if (!sres_cache_get(res->res_cache, type, name, &result)) - su_seterrno(ENOENT), (void *)NULL; + return su_seterrno(ENOENT), (void *)NULL; return result; } diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c index 5dfbc3098f..3d74f66644 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c @@ -1625,7 +1625,7 @@ sres_sip_append_result(sres_sip_t *srs, break; } - if ((srs->srs_canonname && srs->srs_numeric) || (SU_LOG->log_level >= 0)) { + { unsigned port = 0; char const *lb = "", *rb = ""; diff --git a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_errno.h b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_errno.h index c11570c4eb..223f7cf018 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_errno.h +++ b/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_errno.h @@ -53,11 +53,6 @@ SOFIAPUBFUN int su_errno(void); /** Set the su error. */ SOFIAPUBFUN int su_seterrno(int); -#if !SU_HAVE_WINSOCK -#define su_errno() (errno) -#define su_seterrno(n) ((errno = (n)), -1) -#endif - #if defined(__APPLE_CC__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) #ifndef EBADMSG #define EBADMSG EFAULT 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 cc0b9603f5..0369e08b5c 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c @@ -209,9 +209,14 @@ void (*_su_home_destroy_mutexes)(void *mutex); su_inline void safefree(void *b) { b ? free(b) : (void)0; } #endif -#define MEMLOCK(h) \ - ((void)((h) && (h)->suh_lock ? _su_home_locker((h)->suh_lock) : 0), (h)->suh_blocks) -#define UNLOCK(h) ((void)((h) && (h)->suh_lock ? _su_home_unlocker((h)->suh_lock) : 0), NULL) +static inline su_block_t* MEMLOCK(const su_home_t *h) { + if (h && h->suh_lock) _su_home_locker(h->suh_lock); + return h->suh_blocks; +} +static inline void* UNLOCK(const su_home_t *h) { + if (h && h->suh_lock) _su_home_unlocker(h->suh_lock); + return NULL; +} #ifdef NDEBUG #define MEMCHECK 0 diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_errno.c b/libs/sofia-sip/libsofia-sip-ua/su/su_errno.c index 7b888bbacc..3ab183edc0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_errno.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_errno.c @@ -157,4 +157,7 @@ const char *su_strerror(int errcode) return strerror(errcode); } +int su_errno(void) { return errno; } +int su_seterrno(int n) { errno = n; return -1; } + #endif /* SU_HAVE_WINSOCK */ diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_root.c b/libs/sofia-sip/libsofia-sip-ua/su/su_root.c index e2179714e0..47198948f3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_root.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_root.c @@ -152,7 +152,7 @@ _su_task_r su_task_init(su_task_r task) { assert(task); - memset(task, 0, sizeof(task)); + memset(task, 0, sizeof(su_task_r)); return task; } 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 6745cff1af..3abbbcbac4 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 @@ -198,6 +198,12 @@ enum tport_tls_verify_policy { TPTLS_VERIFY_SUBJECTS_ALL = 0xF, }; +TPORT_DLL extern tag_typedef_t tptag_tls_timeout; +#define TPTAG_TLS_TIMEOUT(x) tptag_tls_timeout, tag_uint_v((x)) + +TPORT_DLL extern tag_typedef_t tptag_tls_timeout_ref; +#define TPTAG_TLS_TIMEOUT_REF(x) tptag_tls_timeout_ref, tag_uint_vr(&(x)) + TPORT_DLL extern tag_typedef_t tptag_tls_passphrase; #define TPTAG_TLS_PASSPHRASE(x) tptag_tls_passphrase, tag_str_v(x) 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 c10958a41f..495eaaf997 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c @@ -280,6 +280,19 @@ tag_typedef_t tptag_compartment = PTRTAG_TYPEDEF(compartment); */ tag_typedef_t tptag_tls_version = UINTTAG_TYPEDEF(tls_version); +/**@def TPTAG_TLS_TIMEOUT(x) + * + * Sets the maximum TLS session lifetime in seconds. + * + * The default value is 300 seconds. + * + * Use with tport_tbind(), nua_create(), nta_agent_create(), + * nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create(). + * + * @NEW_UNRELEASED. + */ +tag_typedef_t tptag_tls_timeout = UINTTAG_TYPEDEF(tls_timeout); + /**@def TPTAG_TLS_VERIFY_PEER(x) * @par Depreciated: * Alias for TPTAG_TLS_VERIFY_POLICY(TPTLS_VERIFY_IN|TPTLS_VERIFY_OUT) 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 2fffbde110..2facb30d0d 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c @@ -311,6 +311,8 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti) return -1; } + SSL_CTX_set_timeout(tls->ctx, ti->timeout); + /* Set callback if we have a passphrase */ if (ti->passphrase != NULL) { SSL_CTX_set_default_passwd_cb(tls->ctx, passwd_cb); 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 dbf6517196..702dcc9040 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.h @@ -65,6 +65,7 @@ typedef struct tls_issues_s { */ int version; /* For tls1, version is 1. When ssl3/ssl2 is * used, it is 0. */ + unsigned timeout; /* Maximum session lifetime in seconds */ } tls_issues_t; typedef struct tport_tls_s { 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 24f5d1b0fb..cd2ac9a9b6 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 @@ -181,6 +181,7 @@ static int tport_tls_init_master(tport_primary_t *pri, char *tbf = NULL; char const *path = NULL; unsigned tls_version = 1; + unsigned tls_timeout = 300; unsigned tls_verify = 0; char const *passphrase = NULL; unsigned tls_policy = TPTLS_VERIFY_NONE; @@ -198,6 +199,7 @@ static int tport_tls_init_master(tport_primary_t *pri, tl_gets(tags, TPTAG_CERTIFICATE_REF(path), TPTAG_TLS_VERSION_REF(tls_version), + TPTAG_TLS_TIMEOUT_REF(tls_timeout), TPTAG_TLS_VERIFY_PEER_REF(tls_verify), TPTAG_TLS_PASSPHRASE_REF(passphrase), TPTAG_TLS_VERIFY_POLICY_REF(tls_policy), @@ -224,6 +226,7 @@ static int tport_tls_init_master(tport_primary_t *pri, ti.cert = ti.key; ti.CAfile = su_sprintf(autohome, "%s/%s", path, "cafile.pem"); ti.version = tls_version; + ti.timeout = tls_timeout; ti.CApath = su_strdup(autohome, path); SU_DEBUG_9(("%s(%p): tls key = %s\n", __func__, (void *)pri, ti.key)); diff --git a/libs/spandsp/Makefile.am b/libs/spandsp/Makefile.am index 193c108c6b..ccc9240240 100644 --- a/libs/spandsp/Makefile.am +++ b/libs/spandsp/Makefile.am @@ -16,6 +16,8 @@ ## License along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +ACLOCAL_AMFLAGS = -I m4 + AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) diff --git a/libs/spandsp/autogen.sh b/libs/spandsp/autogen.sh index 2d9a0670da..c3cc88b04a 100755 --- a/libs/spandsp/autogen.sh +++ b/libs/spandsp/autogen.sh @@ -106,32 +106,19 @@ version_compare() # Check for required version and die if unhappy +mkdir config + if [ "x$UNAME" = "xFreeBSD" ]; then version_compare libtoolize 1 5 16 || exit 1 version_compare automake19 1 9 5 || exit 1 version_compare autoconf259 2 59 || exit 1 -ACLOCAL=aclocal19 -AUTOHEADER=autoheader259 -AUTOMAKE=automake19 -AUTOCONF=autoconf259 else version_compare libtoolize 1 5 16 || exit 1 version_compare automake 1 9 5 || exit 1 version_compare autoconf 2 59 || exit 1 -ACLOCAL=aclocal -AUTOHEADER=autoheader -AUTOMAKE=automake -AUTOCONF=autoconf fi -libtoolize --copy --force --ltdl -#NetBSD seems to need this file writable -chmod u+w libltdl/configure - -$ACLOCAL -$AUTOHEADER --force -$AUTOMAKE --copy --add-missing -$AUTOCONF --force +autoreconf -fi #chmod ug+x debian/rules diff --git a/libs/spandsp/config/.empty b/libs/spandsp/config/.empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/spandsp/configure.ac b/libs/spandsp/configure.ac index 7914885d79..22fccd6d25 100644 --- a/libs/spandsp/configure.ac +++ b/libs/spandsp/configure.ac @@ -18,34 +18,25 @@ # @start 1 -AC_INIT +AC_PREREQ([2.59]) +AC_INIT([spandsp], [0.0.7]) -m4_include(config/ax_compiler_vendor.m4) -m4_include(config/ax_check_real_file.m4) -m4_include(config/ax_fixed_point_machine.m4) -m4_include(config/ax_misaligned_access_fails.m4) -m4_include(config/ax_c99_features.m4) -m4_include(config/ax_check_export_capability.m4) - -SPANDSP_MAJOR_VERSION=0 -SPANDSP_MINOR_VERSION=0 -SPANDSP_MICRO_VERSION=6 - -SPANDSP_LT_CURRENT=2 +SPANDSP_LT_CURRENT=3 SPANDSP_LT_REVISION=0 SPANDSP_LT_AGE=0 -VERSION=$SPANDSP_MAJOR_VERSION.$SPANDSP_MINOR_VERSION.$SPANDSP_MICRO_VERSION -PACKAGE=spandsp - -AC_SUBST(SPANDSP_LT_CURRENT) -AC_SUBST(SPANDSP_LT_REVISION) -AC_SUBST(SPANDSP_LT_AGE) +m4_include(m4/ax_compiler_vendor.m4) +m4_include(m4/ax_check_real_file.m4) +m4_include(m4/ax_fixed_point_machine.m4) +m4_include(m4/ax_misaligned_access_fails.m4) +m4_include(m4/ax_c99_features.m4) +m4_include(m4/ax_check_export_capability.m4) AC_CONFIG_SRCDIR([src/tone_generate.c]) -AC_CONFIG_AUX_DIR(config) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([src/config.h:config-h.in]) -AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AM_INIT_AUTOMAKE([1.9.5]) AC_CANONICAL_HOST #AC_CANONICAL_BUILD @@ -59,51 +50,51 @@ AX_COMPILER_VENDOR if test "${build}" != "${host}" then - # If we are doing a Canadian Cross, in which the host and build systems - # are not the same, we set reasonable default values for the tools. + # If we are doing a Canadian Cross, in which the host and build systems + # are not the same, we set reasonable default values for the tools. - CC_FOR_BUILD=${CC_FOR_BUILD-gcc} - CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" - CC=${CC-${host_alias}-gcc} - CFLAGS=${CFLAGS-"-g -O2"} - CXX=${CXX-${host_alias}-c++} - CXXFLAGS=${CXXFLAGS-"-g -O2"} + CC_FOR_BUILD=${CC_FOR_BUILD-gcc} + CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" + CC=${CC-${host_alias}-gcc} + CFLAGS=${CFLAGS-"-g -O2"} + CXX=${CXX-${host_alias}-c++} + CXXFLAGS=${CXXFLAGS-"-g -O2"} else - # Set reasonable default values for some tools even if not Canadian. - # Of course, these are different reasonable default values, originally - # specified directly in the Makefile. - # We don't export, so that autoconf can do its job. - # Note that all these settings are above the fragment inclusion point - # in Makefile.in, so can still be overridden by fragments. - # This is all going to change when we autoconfiscate... - CC_FOR_BUILD="\$(CC)" - CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" - AC_PROG_CC + # Set reasonable default values for some tools even if not Canadian. + # Of course, these are different reasonable default values, originally + # specified directly in the Makefile. + # We don't export, so that autoconf can do its job. + # Note that all these settings are above the fragment inclusion point + # in Makefile.in, so can still be overridden by fragments. + # This is all going to change when we autoconfiscate... + CC_FOR_BUILD="\$(CC)" + CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" + AC_PROG_CC - # We must set the default linker to the linker used by gcc for the correct - # operation of libtool. If LD is not defined and we are using gcc, try to - # set the LD default to the ld used by gcc. - if test -z "$LD" - then - if test "$GCC" = yes + # We must set the default linker to the linker used by gcc for the correct + # operation of libtool. If LD is not defined and we are using gcc, try to + # set the LD default to the ld used by gcc. + if test -z "$LD" then - case $build in - *-*-mingw*) - gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;; - *) - gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;; - esac - case $gcc_prog_ld in - # Accept absolute paths. - [[\\/]* | [A-Za-z]:[\\/]*)] - LD="$gcc_prog_ld" ;; - esac + if test "$GCC" = yes + then + case $build in + *-*-mingw*) + gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;; + *) + gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;; + esac + case $gcc_prog_ld in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + LD="$gcc_prog_ld" ;; + esac + fi fi - fi - CXX=${CXX-"c++"} - CFLAGS=${CFLAGS-"-g -O2"} - CXXFLAGS=${CXXFLAGS-"-g -O2"} + CXX=${CXX-"c++"} + CFLAGS=${CFLAGS-"-g -O2"} + CXXFLAGS=${CXXFLAGS-"-g -O2"} fi AC_DEFUN([REMOVE_FROM_VAR],[ @@ -143,6 +134,7 @@ AC_ARG_ENABLE(sse4_1, [ --enable-sse4-1 Enable SSE4.1 support]) AC_ARG_ENABLE(sse4_2, [ --enable-sse4-2 Enable SSE4.2 support]) AC_ARG_ENABLE(sse4a, [ --enable-sse4a Enable SSE4A support]) AC_ARG_ENABLE(sse5, [ --enable-sse5 Enable SSE5 support]) +AC_ARG_ENABLE(avx, [ --enable-avx Enable AVX support]) AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support]) # The following is for MSVC, where we may be using a local copy of libtiff, built alongside spandsp AC_ARG_ENABLE(builtin_tiff, @@ -207,9 +199,9 @@ AC_CHECK_HEADERS([fenv.h]) AC_CHECK_HEADERS([fftw3.h], , [AC_CHECK_HEADERS([fftw.h])]) AC_CHECK_HEADERS([pcap.h]) AC_CHECK_HEADERS([pthread.h]) -if test "${build}" = "${host}" +if test "${build}" == "${host}" then - AC_CHECK_HEADERS([X11/X.h]) + AC_CHECK_HEADERS([X11/X.h]) fi # Determine XML2 include path @@ -246,19 +238,17 @@ AC_CHECK_HEADERS([FL/Fl.H]) AC_CHECK_HEADERS([FL/Fl_Overlay_Window.H]) AC_CHECK_HEADERS([FL/Fl_Light_Button.H]) AC_CHECK_HEADERS([FL/fl_draw.H]) -AC_CHECK_HEADERS([FL/Fl_Cartesian.H], [], [], [],[[#include -]]) -AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H], [], [], [],[[#include -]]) +AC_CHECK_HEADERS([FL/Fl_Cartesian.H]) +AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H]) AC_LANG([C]) -if test "${build}" = "${host}" +if test "${build}" == "${host}" then case "${host}" in x86_64-*) # X86_64 Linux machines may have both 64 bit and 32 bit libraries. We need to choose the right set - AX_CHECK_REAL_FILE([${prefix}/lib64], libdir='$(exec_prefix)/lib64') + AX_CHECK_REAL_FILE([${prefix}/lib64], libdir='${exec_prefix}/lib64') AX_CHECK_REAL_FILE([/usr/X11R6/lib64], [TESTLIBS="$TESTLIBS -L/usr/X11R6/lib64"], AC_CHECK_FILE([/usr/X11R6/lib], [TESTLIBS="$TESTLIBS -L/usr/X11R6/lib"])) # The very oldest AMD 64 bit chips support SSE2, SSE and MMX enable_sse2="yes" @@ -266,8 +256,10 @@ then esac fi -#AC_DEFINE([SPANDSP_SUPPORT_T85], [1], [Support T.85 JBIG compression]) -SPANDSP_SUPPORT_T85="#undef SPANDSP_SUPPORT_T85" +#AC_DEFINE([SPANDSP_SUPPORT_T42], [1], [Support T.42 JPEG compression]) +SPANDSP_SUPPORT_T42="#undef SPANDSP_SUPPORT_T42" +#AC_DEFINE([SPANDSP_SUPPORT_T43], [1], [Support T.43 JBIG gray and colour compression]) +SPANDSP_SUPPORT_T43="#undef SPANDSP_SUPPORT_T43" #AC_DEFINE([SPANDSP_SUPPORT_V34], [1], [Support the V.34 FAX modem]) SPANDSP_SUPPORT_V34="#undef SPANDSP_SUPPORT_V34" @@ -287,14 +279,27 @@ AC_SEARCH_LIBS([expf], [m], AC_DEFINE([HAVE_EXPF], [1], [Define to 1 if you have AC_SEARCH_LIBS([logf], [m], AC_DEFINE([HAVE_LOGF], [1], [Define to 1 if you have the logf() function.])) AC_SEARCH_LIBS([log10f], [m], AC_DEFINE([HAVE_LOG10F], [1], [Define to 1 if you have the log10f() function.])) -# Checks for libraries. -AC_CHECK_LIB([xml2], [xmlParseFile], [AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have the 'libxml2' library (-lxml2).]) SIMLIBS="$SIMLIBS -lxml2"]) +AC_SEARCH_LIBS([open_memstream], [m], AC_DEFINE([HAVE_OPEN_MEMSTREAM], [1], [Define to 1 if you have the open_memstream() function.])) if test -n "$enable_tests" ; then + AC_CHECK_PROG([HAVE_SOX], [sox], yes) + if test "x$HAVE_SOX" != "xyes" ; then + AC_MSG_ERROR("Cannot make tests without sox installed") + fi + AC_CHECK_PROG([HAVE_PBMTOG3], [pbmtog3], yes) + if test "x$HAVE_PBMTOG3" != "xyes" ; then + AC_MSG_ERROR("Cannot make tests without pbmtog3 installed (does your system require a netpbm-progs package?)") + fi + AC_CHECK_PROG([HAVE_FAX2TIFF], [fax2tiff], yes) + if test "x$HAVE_FAX2TIFF" != "xyes" ; then + AC_MSG_ERROR("Cannot make tests without fax2tiff installed (does your system require a libtiff-tools package?)") + fi AC_LANG([C]) - AC_CHECK_LIB([sndfile], [sf_open], SIMLIBS="$SIMLIBS -lsndfile", AC_MSG_ERROR("Can't make tests without libsndfile (does your system require a libsndfile-devel package?)")) - AC_CHECK_LIB([fftw3], [fftw_plan_dft_1d], SIMLIBS="$SIMLIBS -lfftw3", [AC_CHECK_LIB([fftw], [fftw_create_plan], SIMLIBS="$SIMLIBS -lfftw", AC_MSG_ERROR("Can't make tests without FFTW 2 or 3 (does your system require an fftw?-devel package?)"))]) - AC_CHECK_LIB([pcap], [pcap_open_offline], TESTLIBS="$TESTLIBS -lpcap", AC_MSG_ERROR("Can't make tests without libpcap (does your system require a libpcap-devel package?)")) + # Checks for libraries. + AC_CHECK_LIB([sndfile], [sf_open], SIMLIBS="$SIMLIBS -lsndfile", AC_MSG_ERROR("Cannot make tests without libsndfile (does your system require a libsndfile-devel package?)")) + AC_CHECK_LIB([fftw3], [fftw_plan_dft_1d], SIMLIBS="$SIMLIBS -lfftw3", [AC_CHECK_LIB([fftw], [fftw_create_plan], SIMLIBS="$SIMLIBS -lfftw", AC_MSG_ERROR("Cannot make tests without FFTW 2 or 3 (does your system require an fftw?-devel package?)"))]) + AC_CHECK_LIB([xml2], [xmlParseFile], TESTLIBS="$TESTLIBS -lxml2", AC_MSG_ERROR("Cannot make tests without libxml2 (does your system require a libxml2-devel package?)")) + AC_CHECK_LIB([pcap], [pcap_open_offline], TESTLIBS="$TESTLIBS -lpcap", [AC_CHECK_LIB([wpcap], [pcap_open_offline], TESTLIBS="$TESTLIBS -lwpcap", AC_MSG_ERROR("Cannot make tests without libpcap (does your system require an libpcap-devel package?)"))]) AC_CHECK_LIB([pthread], [pthread_attr_init], TESTLIBS="$TESTLIBS -lpthread") AC_CHECK_LIB([dl], [dlopen], TESTLIBS="$TESTLIBS -ldl") AC_CHECK_LIB([Xft], [XftFontOpen], TESTLIBS="$TESTLIBS -lXft",, $TESTLIBS) @@ -307,14 +312,35 @@ if test -n "$enable_tests" ; then AC_LANG([C]) fi + +saved_CFLAGS="$CFLAGS" AX_CHECK_EXPORT_CAPABILITY([$host], [AC_DEFINE([SPANDSP_USE_EXPORT_CAPABILITY], [1], [Use the library symbol export capability of the compiler]) SPANDSP_USE_EXPORT_CAPABILITY="#define SPANDSP_USE_EXPORT_CAPABILITY 1"], [SPANDSP_USE_EXPORT_CAPABILITY="#undef SPANDSP_USE_EXPORT_CAPABILITY"]) +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]) +]) +AC_MSG_RESULT($ac_cv_gcc_unused_but_set_variable) +CFLAGS="$saved_CFLAGS" + + case "${ax_cv_c_compiler_vendor}" in gnu) COMP_VENDOR_CFLAGS="-std=gnu99 -ffast-math -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS" + + + if test x"$ac_cv_gcc_unused_but_set_variable" = xyes; then + COMP_VENDOR_CFLAGS="-Wunused-but-set-variable $COMP_VENDOR_CFLAGS" + + fi + + + if test "$enable_avx" = "yes" ; then + COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS" + fi if test "$enable_sse5" = "yes" ; then COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS" fi @@ -343,9 +369,12 @@ gnu) COMP_VENDOR_CFLAGS="-mmmx $COMP_VENDOR_CFLAGS" fi case $host_os in - mingw* | cygwin*) + cygwin*) COMP_VENDOR_LDFLAGS="-no-undefined" ;; + mingw*) + COMP_VENDOR_LDFLAGS="-no-undefined -lws2_32" + ;; *) COMP_VENDOR_LDFLAGS= ;; @@ -370,6 +399,15 @@ sun) ;; intel) COMP_VENDOR_CFLAGS="-std=c99 -D_POSIX_C_SOURCE=2 -D_GNU_SOURCE=1 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS" + + if test x"$ac_cv_gcc_unused_but_set_variable" = xyes; then + COMP_VENDOR_CFLAGS="-Wunused-but-set-variable $COMP_VENDOR_CFLAGS" + + fi + + if test "$enable_avx" = "yes" ; then + COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS" + fi if test "$enable_sse5" = "yes" ; then COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS" fi @@ -400,25 +438,13 @@ intel) COMP_VENDOR_LDFLAGS= ;; *) - COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS" + COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wunused-but-set-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS" COMP_VENDOR_LDFLAGS= ;; esac COMP_VENDOR_CFLAGS="-DNDEBUG $COMP_VENDOR_CFLAGS" -AM_CONDITIONAL([COND_DOC], [test "$enable_doc" = yes]) -AM_CONDITIONAL([COND_TESTS], [test "$enable_tests" = yes]) -AM_CONDITIONAL([COND_TESTDATA], [test "$enable_test_data" = yes]) -AM_CONDITIONAL([COND_MMX], [test "$enable_mmx" = yes]) -AM_CONDITIONAL([COND_SSE], [test "$enable_sse" = yes]) -AM_CONDITIONAL([COND_SSE2], [test "$enable_sse2" = yes]) -AM_CONDITIONAL([COND_SSE3], [test "$enable_sse3" = yes]) -AM_CONDITIONAL([COND_SSSE3], [test "$enable_ssse3" = yes]) -AM_CONDITIONAL([COND_SSE4_1], [test "$enable_sse4_1" = yes]) -AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes]) -AM_CONDITIONAL([COND_SSE4A], [test "$enable_sse4a" = yes]) -AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes]) if test "$enable_fixed_point" = "yes" ; then AC_DEFINE([SPANDSP_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point]) SPANDSP_USE_FIXED_POINT="#define SPANDSP_USE_FIXED_POINT 1" @@ -433,6 +459,10 @@ AX_MISALIGNED_ACCESS_FAILS([$host], SPANDSP_MISALIGNED_ACCESS_FAILS="#define SPANDSP_MISALIGNED_ACCESS_FAILS 1"], [SPANDSP_MISALIGNED_ACCESS_FAILS="#undef SPANDSP_MISALIGNED_ACCESS_FAILS"]) +if test "$enable_avx" = "yes" ; then + AC_DEFINE([SPANDSP_USE_AVX], [1], [Use the AVX instruction set (i386 and x86_64 only).]) + enable_sse5"yes" +fi if test "$enable_sse5" = "yes" ; then AC_DEFINE([SPANDSP_USE_SSE5], [1], [Use the SSE5 instruction set (i386 and x86_64 only).]) enable_sse4a="yes" @@ -469,23 +499,56 @@ if test "$enable_mmx" = "yes" ; then AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).]) fi +AM_CONDITIONAL([COND_DOC], [test "$enable_doc" = yes]) +AM_CONDITIONAL([COND_TESTS], [test "$enable_tests" = yes]) +AM_CONDITIONAL([COND_TESTDATA], [test "$enable_test_data" = yes]) +AM_CONDITIONAL([COND_MMX], [test "$enable_mmx" = yes]) +AM_CONDITIONAL([COND_SSE], [test "$enable_sse" = yes]) +AM_CONDITIONAL([COND_SSE2], [test "$enable_sse2" = yes]) +AM_CONDITIONAL([COND_SSE3], [test "$enable_sse3" = yes]) +AM_CONDITIONAL([COND_SSSE3], [test "$enable_ssse3" = yes]) +AM_CONDITIONAL([COND_SSE4_1], [test "$enable_sse4_1" = yes]) +AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes]) +AM_CONDITIONAL([COND_SSE4A], [test "$enable_sse4a" = yes]) +AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes]) +AM_CONDITIONAL([COND_AVX], [test "$enable_avx" = yes]) + if test "$enable_builtin_tiff" = "yes" ; then - abs_tiffdir="`cd $srcdir/../tiff-3.8.2/ && pwd`" - save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -I$abs_tiffdir/libtiff" - AC_CHECK_HEADERS([tiffio.h]) - CFLAGS="$save_CFLAGS" - COMP_VENDOR_CFLAGS="-I$abs_tiffdir/libtiff $COMP_VENDOR_CFLAGS" - COMP_VENDOR_LDFLAGS="-L$abs_tiffdir/libtiff $COMP_VENDOR_LDFLAGS" - LIBS="$LIBS $abs_tiffdir/libtiff/libtiff.la" - AC_DEFINE([HAVE_LIBTIFF], [1], [Define to 1 if you have the `tiff' library (-ltiff).]) + abs_tiffdir="`cd $srcdir/../tiff-4.0.2/ && pwd`" + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -I$abs_tiffdir/libtiff" + AC_CHECK_HEADERS([tiffio.h]) + AC_CHECK_HEADERS([tif_dir.h], [], [], [#include +]) + CFLAGS="$save_CFLAGS" + COMP_VENDOR_CFLAGS="-I$abs_tiffdir/libtiff $COMP_VENDOR_CFLAGS" + COMP_VENDOR_LDFLAGS="-L$abs_tiffdir/libtiff $COMP_VENDOR_LDFLAGS" + TIFF_LIBS="$abs_tiffdir/libtiff/libtiff.la" + AC_DEFINE([HAVE_LIBTIFF], [1], [Define to 1 if you have the `tiff' library (-ltiff).]) else - AC_CHECK_HEADERS([tiffio.h]) - AC_CHECK_LIB([tiff], [TIFFOpen], , AC_MSG_ERROR("Can't build without libtiff (does your system require a libtiff-devel package?)"), -lm) + AC_CHECK_HEADERS([tiffio.h]) + AC_CHECK_HEADERS([tif_dir.h], [], [], [#include +]) + AC_CHECK_LIB([tiff], [TIFFOpen], [TIFF_LIBS="-ltiff"], AC_MSG_ERROR("Cannot build without libtiff (does your system require a libtiff-devel package?)"), -lm) fi +if test "$ac_cv_header_tif_dir_h" = "yes" ; then + AC_DEFINE([SPANDSP_SUPPORT_TIFF_FX], [1], [Support TIFF/FX in TIFF file handling]) + SPANDSP_SUPPORT_TIFF_FX="#define SPANDSP_SUPPORT_TIFF_FX" +else + SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_TIFF_FX" +fi + +AC_CHECK_HEADERS([jpeglib.h]) +AC_CHECK_LIB([jpeg], [jpeg_start_compress], [JPEG_LIBS="-ljpeg"]) + +LIBS="$LIBS $TIFF_LIBS $JPEG_LIBS" + TESTLIBS="$SIMLIBS $TESTLIBS" +AC_SUBST(SPANDSP_LT_CURRENT) +AC_SUBST(SPANDSP_LT_REVISION) +AC_SUBST(SPANDSP_LT_AGE) AC_SUBST(CC_FOR_BUILD) AC_SUBST(CPPFLAGS_FOR_BUILD) AC_SUBST(COMP_VENDOR_CFLAGS) @@ -495,8 +558,10 @@ AC_SUBST(TESTLIBS) AC_SUBST(SPANDSP_USE_FIXED_POINT) AC_SUBST(SPANDSP_MISALIGNED_ACCESS_FAILS) AC_SUBST(SPANDSP_USE_EXPORT_CAPABILITY) -AC_SUBST(SPANDSP_SUPPORT_T85) +AC_SUBST(SPANDSP_SUPPORT_T42) +AC_SUBST(SPANDSP_SUPPORT_T43) AC_SUBST(SPANDSP_SUPPORT_V34) +AC_SUBST(SPANDSP_SUPPORT_TIFF_FX) AC_SUBST(INSERT_INTTYPES_HEADER) AC_SUBST(INSERT_STDINT_HEADER) AC_SUBST(INSERT_TGMATH_HEADER) diff --git a/libs/spandsp/doc/doxygen.in b/libs/spandsp/doc/doxygen.in index 87c3c34572..38af500c1a 100644 --- a/libs/spandsp/doc/doxygen.in +++ b/libs/spandsp/doc/doxygen.in @@ -357,12 +357,6 @@ MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is YES. - -SHOW_DIRECTORIES = YES - # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via @@ -635,12 +629,6 @@ HTML_FOOTER = HTML_STYLESHEET = css.css -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) @@ -1123,7 +1111,7 @@ CALL_GRAPH = NO GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. diff --git a/libs/spandsp/doc/t38_manual.xml b/libs/spandsp/doc/t38_manual.xml index 7edcd9583c..e49afcdbd8 100644 --- a/libs/spandsp/doc/t38_manual.xml +++ b/libs/spandsp/doc/t38_manual.xml @@ -257,7 +257,7 @@ The file dither1d.tif is a whole page of dense checkerboard pattern, which does Expect some very poor timing decisions in various designs. -The preamble for V.21 HDLC data is specified as being 1s ±15%. This should mean 850ms of preamble is within spec, and many modern FAX machines only send that much. A number of T.38 implementations choke on this. They require at least 1s between the v21-preamble message and the first HDLC data, for reliable operation. This is very poor design. Even if there is 1s between these events at the source, jitter on the network can make them arrive less than 1s apart. It appears the best a tolerant implementation can really do is impose a 1s minimum between sending these T.38 messages, and accept that things might still go wrong when there is some jitter. +The preamble for V.21 HDLC data is specified as being 1s+-15%. This should mean 850ms of preamble is within spec, and many modern FAX machines only send that much. A number of T.38 implementations choke on this. They require at least 1s between the v21-preamble message and the first HDLC data, for reliable operation. This is very poor design. Even if there is 1s between these events at the source, jitter on the network can make them arrive less than 1s apart. It appears the best a tolerant implementation can really do is impose a 1s minimum between sending these T.38 messages, and accept that things might still go wrong when there is some jitter. There is similar intolerance with the timing of the start of training messages for the fast image data modems. Most implementations do not impose a minimum which is above that permitted by the T.30 specification. Some do, however, make no allowance for network jitter reducing the interval at the receiver. You should expect the far end to be using TEP, when sizing the required delay between the start of training, and the first data. Also, for ECM data, make sure the delay allows for the specified minimum 200ms of preamble. diff --git a/libs/spandsp/config/ax_c99_features.m4 b/libs/spandsp/m4/ax_c99_features.m4 similarity index 100% rename from libs/spandsp/config/ax_c99_features.m4 rename to libs/spandsp/m4/ax_c99_features.m4 diff --git a/libs/spandsp/config/ax_check_export_capability.m4 b/libs/spandsp/m4/ax_check_export_capability.m4 similarity index 100% rename from libs/spandsp/config/ax_check_export_capability.m4 rename to libs/spandsp/m4/ax_check_export_capability.m4 diff --git a/libs/spandsp/config/ax_check_real_file.m4 b/libs/spandsp/m4/ax_check_real_file.m4 similarity index 100% rename from libs/spandsp/config/ax_check_real_file.m4 rename to libs/spandsp/m4/ax_check_real_file.m4 diff --git a/libs/spandsp/config/ax_compiler_vendor.m4 b/libs/spandsp/m4/ax_compiler_vendor.m4 similarity index 100% rename from libs/spandsp/config/ax_compiler_vendor.m4 rename to libs/spandsp/m4/ax_compiler_vendor.m4 diff --git a/libs/spandsp/config/ax_fixed_point_machine.m4 b/libs/spandsp/m4/ax_fixed_point_machine.m4 similarity index 100% rename from libs/spandsp/config/ax_fixed_point_machine.m4 rename to libs/spandsp/m4/ax_fixed_point_machine.m4 diff --git a/libs/spandsp/config/ax_misaligned_access_fails.m4 b/libs/spandsp/m4/ax_misaligned_access_fails.m4 similarity index 100% rename from libs/spandsp/config/ax_misaligned_access_fails.m4 rename to libs/spandsp/m4/ax_misaligned_access_fails.m4 diff --git a/libs/spandsp/spandsp-sim/libspandsp_sim.2005.vcproj b/libs/spandsp/spandsp-sim/libspandsp_sim.2005.vcproj index ae79ad9862..2cceaf6683 100644 --- a/libs/spandsp/spandsp-sim/libspandsp_sim.2005.vcproj +++ b/libs/spandsp/spandsp-sim/libspandsp_sim.2005.vcproj @@ -27,7 +27,7 @@ 0.0.6-1 +- Converge with what Fedora do + * Wed Sep 24 2008 Tzafrir Cohen 0.0.5-1 - Preparing for 0.0.5pre4 release - License: LGPL diff --git a/libs/spandsp/spandsp.spec.in b/libs/spandsp/spandsp.spec.in index 7b8406fa7c..759dd17c07 100644 --- a/libs/spandsp/spandsp.spec.in +++ b/libs/spandsp/spandsp.spec.in @@ -1,19 +1,22 @@ -Summary: A DSP library for telephony. -Name: @PACKAGE@ -Version: @VERSION@ -Release: 1 -License: LGPL -Group: System Environment/Libraries -URL: http://www.soft-switch.org/spandsp -BuildRoot: %{_tmppath}/%{name}-%{version}-root -Source: http://www.soft-switch.org/downloads/spandsp/@PACKAGE@-@VERSION@.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +%global pre 21 -BuildRequires: libtiff-devel -BuildRequires: audiofile-devel +Summary: A DSP library for telephony. +Name: @PACKAGE@ +Version: @VERSION@ +Release: 1 +License: LGPLv2 and GPLv2 +Group: System Environment/Libraries +URL: http://www.soft-switch.org/spandsp +Source: http://www.soft-switch.org/downloads/spandsp/@PACKAGE@-@VERSION@.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: libtiff-devel%{?_isa} +BuildRequires: libjpeg-turbo-devel%{?_isa} +BuildRequires: libxml2-devel%{?_isa} +BuildRequires: libsndfile-devel%{?_isa} BuildRequires: doxygen -# for xsltproc: BuildRequires: libxslt +BuildRequires: docbook-style-xsl %description SpanDSP is a library of DSP functions for telephony, in the 8000 @@ -26,49 +29,66 @@ relevant patents have expired. See the file DueDiligence for important information about these intellectual property issues. %package devel -Summary: SpanDSP development files -Group: Development/Libraries -Requires: spandsp = %{version} -Requires: libtiff-devel -PreReq: /sbin/install-info +Summary: SpanDSP development files +Group: Development/Libraries +Requires: spandsp%{?_isa} = %{version}-%{release} +Requires: libtiff-devel%{?_isa} +Requires: libjpeg-turbo-devel%{?_isa} %description devel SpanDSP development files. +%package apidoc +Summary: SpanDSP API documentation +Group: Development/Libraries + +%description apidoc +SpanDSP API documentation. + %prep %setup -q %build %configure --enable-doc --disable-static --disable-rpath make +find doc/api -type f | xargs touch -r configure %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} rm %{buildroot}%{_libdir}/libspandsp.la +mkdir -p %{buildroot}%{_datadir}/spandsp %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) -%doc DueDiligence ChangeLog AUTHORS COPYING NEWS README +%doc DueDiligence ChangeLog AUTHORS COPYING NEWS README %{_libdir}/libspandsp.so.* +%{_datadir}/spandsp + %files devel %defattr(-,root,root,-) -%doc doc/api %{_includedir}/spandsp.h %{_includedir}/spandsp %{_libdir}/libspandsp.so %{_libdir}/pkgconfig/spandsp.pc +%files apidoc +%defattr(-,root,root,-) +%doc doc/api/html/* + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %changelog +* Mon Oct 03 2011 Steve Underwood 0.0.6-1 +- Converge with what Fedora do + * Wed Sep 24 2008 Tzafrir Cohen 0.0.5-1 - Preparing for 0.0.5pre4 release - License: LGPL diff --git a/libs/spandsp/spandsp/tones.dtd b/libs/spandsp/spandsp/tones.dtd index 6f0fe46ba6..023f8d0783 100644 --- a/libs/spandsp/spandsp/tones.dtd +++ b/libs/spandsp/spandsp/tones.dtd @@ -35,6 +35,7 @@ diff --git a/libs/spandsp/spandsp/tsb85.xml b/libs/spandsp/spandsp/tsb85.xml index cd0d5db807..af38a9a3fe 100644 --- a/libs/spandsp/spandsp/tsb85.xml +++ b/libs/spandsp/spandsp/tsb85.xml @@ -13,7 +13,7 @@ - @@ -1253,7 +1253,7 @@ - + @@ -1265,7 +1265,7 @@ - + @@ -1287,7 +1287,7 @@ - + @@ -1335,7 +1335,7 @@ - + @@ -1347,7 +1347,7 @@ - + @@ -1359,7 +1359,7 @@ - + @@ -1371,7 +1371,7 @@ - + @@ -1384,7 +1384,7 @@ - + @@ -1396,7 +1396,7 @@ - + @@ -1440,7 +1440,7 @@ - + @@ -1462,7 +1462,7 @@ - + @@ -1484,7 +1484,7 @@ - + @@ -1506,7 +1506,7 @@ - + @@ -1536,7 +1536,7 @@ - + @@ -1583,7 +1583,7 @@ - + @@ -1605,7 +1605,7 @@ - + @@ -1627,7 +1627,7 @@ - + @@ -1649,7 +1649,7 @@ - + @@ -1679,7 +1679,7 @@ - + @@ -1726,7 +1726,7 @@ - + @@ -1748,11 +1748,11 @@ - + - + @@ -1765,16 +1765,16 @@ - + - + - + @@ -1787,16 +1787,16 @@ - + - + - + @@ -1809,16 +1809,16 @@ - + - + - + @@ -1831,7 +1831,7 @@ - + @@ -1869,7 +1869,7 @@ - + @@ -1891,7 +1891,7 @@ - + @@ -1913,7 +1913,7 @@ - + @@ -1935,7 +1935,7 @@ - + @@ -1965,7 +1965,7 @@ - + @@ -2011,7 +2011,7 @@ - + @@ -2033,7 +2033,7 @@ - + @@ -2055,7 +2055,7 @@ - + @@ -2077,7 +2077,7 @@ - + @@ -2132,7 +2132,7 @@ - + @@ -2154,7 +2154,7 @@ - + @@ -2201,7 +2201,7 @@ - + @@ -2213,7 +2213,7 @@ - + @@ -4982,7 +4982,7 @@ - + @@ -4990,7 +4990,7 @@ - + @@ -4998,7 +4998,7 @@ - + @@ -5028,15 +5028,17 @@ - + + - + + - + @@ -5044,15 +5046,16 @@ - + + - + - + @@ -5060,15 +5063,16 @@ - + + - + - + @@ -5098,7 +5102,7 @@ - + @@ -5290,7 +5294,7 @@ - + @@ -5299,7 +5303,7 @@ - + @@ -5308,7 +5312,7 @@ - + @@ -5317,7 +5321,7 @@ - + @@ -5334,7 +5338,7 @@ - + @@ -5343,7 +5347,7 @@ - + @@ -5352,7 +5356,7 @@ - + @@ -5361,7 +5365,7 @@ - + @@ -5402,7 +5406,7 @@ - + @@ -5411,7 +5415,7 @@ - + @@ -5420,7 +5424,7 @@ - + @@ -5429,7 +5433,7 @@ - + @@ -5446,7 +5450,7 @@ - + @@ -5476,7 +5480,7 @@ - + diff --git a/libs/spandsp/src/Makefile.am b/libs/spandsp/src/Makefile.am index 96924bfe4c..95e9932c3c 100644 --- a/libs/spandsp/src/Makefile.am +++ b/libs/spandsp/src/Makefile.am @@ -19,9 +19,8 @@ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) -MAINTAINERCLEANFILES = Makefile.in - DISTCLEANFILES = $(srcdir)/at_interpreter_dictionary.h \ + $(srcdir)/cielab_luts.h \ $(srcdir)/math_fixed_tables.h \ $(srcdir)/v17_v32bis_rx_fixed_rrc.h \ $(srcdir)/v17_v32bis_rx_floating_rrc.h \ @@ -46,6 +45,10 @@ DISTCLEANFILES = $(srcdir)/at_interpreter_dictionary.h \ $(srcdir)/v29tx_fixed_rrc.h \ $(srcdir)/v29tx_floating_rrc.h +CLEANFILES = ${DISTCLEANFILES} +MOSTLYCLEANFILES = ${DISTCLEANFILES} +MAINTAINERCLEANFILES = ${DISTCLEANFILES} + EXTRA_DIST = floating_fudge.h \ libspandsp.dsp \ libspandsp.2005.sln \ @@ -56,6 +59,7 @@ EXTRA_DIST = floating_fudge.h \ libtiff.2008.vcproj \ filter_tools.c \ make_at_dictionary.c \ + make_cielab_luts.c \ make_math_fixed_tables.c \ make_modem_filter.c \ msvc/config.h \ @@ -87,7 +91,8 @@ INCLUDES = -I$(top_builddir) lib_LTLIBRARIES = libspandsp.la -libspandsp_la_SOURCES = adsi.c \ +libspandsp_la_SOURCES = ademco_contactid.c \ + adsi.c \ async.c \ at_interpreter.c \ awgn.c \ @@ -140,8 +145,6 @@ libspandsp_la_SOURCES = adsi.c \ super_tone_rx.c \ super_tone_tx.c \ swept_tone.c \ - t4_rx.c \ - t4_tx.c \ t30.c \ t30_api.c \ t30_logging.c \ @@ -151,6 +154,14 @@ libspandsp_la_SOURCES = adsi.c \ t38_gateway.c \ t38_non_ecm_buffer.c \ t38_terminal.c \ + t4_t6_decode.c \ + t4_t6_encode.c \ + t4_rx.c \ + t4_tx.c \ + t42.c \ + t81_t82_arith_coding.c \ + t85_decode.c \ + t85_encode.c \ testcpuid.c \ time_scale.c \ timezone.c \ @@ -173,7 +184,8 @@ libspandsp_la_SOURCES = adsi.c \ libspandsp_la_LDFLAGS = -version-info @SPANDSP_LT_CURRENT@:@SPANDSP_LT_REVISION@:@SPANDSP_LT_AGE@ $(COMP_VENDOR_LDFLAGS) -nobase_include_HEADERS = spandsp/adsi.h \ +nobase_include_HEADERS = spandsp/ademco_contactid.h \ + spandsp/adsi.h \ spandsp/async.h \ spandsp/arctan2.h \ spandsp/at_interpreter.h \ @@ -237,6 +249,9 @@ nobase_include_HEADERS = spandsp/adsi.h \ spandsp/t4_tx.h \ spandsp/t4_t6_decode.h \ spandsp/t4_t6_encode.h \ + spandsp/t42.h \ + spandsp/t81_t82_arith_coding.h \ + spandsp/t85.h \ spandsp/telephony.h \ spandsp/time_scale.h \ spandsp/timezone.h \ @@ -257,6 +272,7 @@ nobase_include_HEADERS = spandsp/adsi.h \ spandsp/vector_float.h \ spandsp/vector_int.h \ spandsp/version.h \ + spandsp/private/ademco_contactid.h \ spandsp/private/adsi.h \ spandsp/private/async.h \ spandsp/private/at_interpreter.h \ @@ -300,6 +316,9 @@ nobase_include_HEADERS = spandsp/adsi.h \ spandsp/private/t4_tx.h \ spandsp/private/t4_t6_decode.h \ spandsp/private/t4_t6_encode.h \ + spandsp/private/t42.h \ + spandsp/private/t81_t82_arith_coding.h \ + spandsp/private/t85.h \ spandsp/private/time_scale.h \ spandsp/private/timezone.h \ spandsp/private/tone_detect.h \ @@ -319,13 +338,15 @@ nobase_include_HEADERS = spandsp/adsi.h \ nodist_include_HEADERS = spandsp.h -noinst_HEADERS = faxfont.h \ +noinst_HEADERS = cielab_luts.h \ + faxfont.h \ filter_tools.h \ gsm0610_local.h \ lpc10_encdecs.h \ mmx_sse_decs.h \ t30_local.h \ t4_t6_decode_states.h \ + t42_t43_local.h \ v17_v32bis_rx_constellation_maps.h \ v17_v32bis_tx_constellation_maps.h \ v29tx_constellation_maps.h @@ -333,6 +354,9 @@ noinst_HEADERS = faxfont.h \ make_at_dictionary$(EXEEXT): $(top_srcdir)/src/make_at_dictionary.c $(CC_FOR_BUILD) -o make_at_dictionary$(EXEEXT) $(top_srcdir)/src/make_at_dictionary.c -DHAVE_CONFIG_H -I$(top_builddir)/src +make_cielab_luts$(EXEEXT): $(top_srcdir)/src/make_cielab_luts.c + $(CC_FOR_BUILD) -o make_cielab_luts$(EXEEXT) $(top_srcdir)/src/make_cielab_luts.c -DHAVE_CONFIG_H -I$(top_builddir)/src -lm + make_math_fixed_tables$(EXEEXT): $(top_srcdir)/src/make_math_fixed_tables.c $(CC_FOR_BUILD) -o make_math_fixed_tables$(EXEEXT) $(top_srcdir)/src/make_math_fixed_tables.c -DHAVE_CONFIG_H -I$(top_builddir)/src -lm @@ -360,6 +384,13 @@ t4_rx.$(OBJEXT): spandsp/version.h t4_rx.lo: spandsp/version.h +t42.$(OBJEXT): cielab_luts.h + +t42.lo: cielab_luts.h + +cielab_luts.h: make_cielab_luts$(EXEEXT) + ./make_cielab_luts$(EXEEXT) >cielab_luts.h + V17_V32BIS_RX_INCL = v17_v32bis_rx_fixed_rrc.h \ v17_v32bis_rx_floating_rrc.h diff --git a/libs/spandsp/src/ademco_contactid.c b/libs/spandsp/src/ademco_contactid.c new file mode 100644 index 0000000000..39ce670bde --- /dev/null +++ b/libs/spandsp/src/ademco_contactid.c @@ -0,0 +1,1062 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * ademco_contactid.c - Ademco ContactID alarm protocol + * + * Written by Steve Underwood + * + * Copyright (C) 2012 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#if defined(HAVE_TGMATH_H) +#include +#endif +#if defined(HAVE_MATH_H) +#include +#endif +#include "floating_fudge.h" +#include +#include +#include +#include + +#include "spandsp/telephony.h" +#include "spandsp/fast_convert.h" +#include "spandsp/logging.h" +#include "spandsp/queue.h" +#include "spandsp/complex.h" +#include "spandsp/dds.h" +#include "spandsp/power_meter.h" +#include "spandsp/async.h" +#include "spandsp/vector_float.h" +#include "spandsp/complex_vector_float.h" +#include "spandsp/vector_int.h" +#include "spandsp/complex_vector_int.h" +#include "spandsp/tone_detect.h" +#include "spandsp/tone_generate.h" +#include "spandsp/super_tone_rx.h" +#include "spandsp/dtmf.h" +#include "spandsp/ademco_contactid.h" + +#include "spandsp/private/logging.h" +#include "spandsp/private/queue.h" +#include "spandsp/private/tone_detect.h" +#include "spandsp/private/tone_generate.h" +#include "spandsp/private/dtmf.h" +#include "spandsp/private/ademco_contactid.h" + +/* +Ademco ContactID Protocol + +Answer +Wait 0.5s to 2s for the line to settle +Send 1400Hz for 100ms +Send silence for 100ms +Send 2300Hz for 100ms +Receiver now waits + +(both timing and frequency errors specified as 3%, but sender side should accept these tones with 5% frequency error.) + +Sender waits 250-300ms after end of 2300Hz tone + +Send ACCT MT QXYZ GG CCC + +ACCT = 4 digit account code (0-9, B-F) +MT = 2 digit message type (18 preferred, 98 optional) +Q = 1 digit event qualifier. 1 = New event or opening. 3 = New restore or closing. 6 = Previous condition still present +XYZ = 3 digit event code (0-9, B-F) +GG = 2 digit group or partition number (0-9, B-F). 00=no specific group +CCC = 3 digit zone number (event reports) or user number (open/close reports). 000=no specific zone or user information +S = 1 digit hex checksum (sum all message digits + S) mod 15 == 0 + +DTMF tones are 50-60ms on 50-60ms off + +0 10 (counted as 10 in checksum calculations) +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +B (*) 11 +C (#) 12 +D (A) 13 +E (B) 14 +F (C) 15 + +DTMF D is not used + +Wait 1.25s for a kiss-off tone +Detect at least 400ms of kissoff to be valid, then wait for end of tone + +Wait 250-300ms before sending the next DTMF message + +If kissoff doesn't start within 1.25s of the end of the DTMF, repeat the DTMF message + +Receiver sends 750-1000ms of 1400Hz as the kissoff tone + +Sender shall make 4 attempts before giving up. One successful kissoff resets the attempt counter +*/ + +struct ademco_code_s +{ + int code; + const char *name; + int data_type; +}; + +static const struct ademco_code_s ademco_codes[] = +{ + {0x100, "Medical", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x101, "Personal emergency", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x102, "Fail to report in", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x110, "Fire", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x111, "Smoke", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x112, "Combustion", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x113, "Water flow", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x114, "Heat", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x115, "Pull station", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x116, "Duct", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x117, "Flame", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x118, "Near alarm", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x120, "Panic", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x121, "Duress", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x122, "Silent", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x123, "Audible", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x124, "Duress - Access granted", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x125, "Duress - Egress granted", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x130, "Burglary", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x131, "Perimeter", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x132, "Interior", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x133, "24 hour (safe)", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x134, "Entry/Exit", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x135, "Day/Night", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x136, "Outdoor", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x137, "Tamper", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x138, "Near alarm", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x139, "Intrusion verifier", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x140, "General alarm", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x141, "Polling loop open", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x142, "Polling loop short", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x143, "Expansion module failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x144, "Sensor tamper", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x145, "Expansion module tamper", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x146, "Silent burglary", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x147, "Sensor supervision failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x150, "24 hour non-burglary", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x151, "Gas detected", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x152, "Refrigeration", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x153, "Loss of heat", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x154, "Water leakage", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x155, "Foil break", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x156, "Day trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x157, "Low bottled gas level", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x158, "High temp", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x159, "Low temp", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x161, "Loss of air flow", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x162, "Carbon monoxide detected", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x163, "Tank level", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x200, "Fire supervisory", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x201, "Low water pressure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x202, "Low CO2", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x203, "Gate valve sensor", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x204, "Low water level", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x205, "Pump activated", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x206, "Pump failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x300, "System trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x301, "AC loss", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x302, "Low system battery", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x303, "RAM checksum bad", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x304, "ROM checksum bad", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x305, "System reset", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x306, "Panel programming changed", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x307, "Self-test failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x308, "System shutdown", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x309, "Battery test failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x310, "Ground fault", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x311, "Battery missing/dead", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x312, "Power supply overcurrent", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x313, "Engineer reset", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x320, "Sounder/relay", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x321, "Bell 1", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x322, "Bell 2", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x323, "Alarm relay", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x324, "Trouble relay", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x325, "Reversing relay", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x326, "Notification appliance ckt. #3", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x327, "Notification appliance ckt. #4", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x330, "System peripheral trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x331, "Polling loop open", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x332, "Polling loop short", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x333, "Expansion module failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x334, "Repeater failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x335, "Local printer out of paper", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x336, "Local printer failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x337, "Exp. module DC loss", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x338, "Exp. module low battery", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x339, "Exp. module reset", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x341, "Exp. module tamper", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x342, "Exp. module AC loss", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x343, "Exp. module self-test fail", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x344, "RF receiver jam detect", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x350, "Communication trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x351, "Telco 1 fault", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x352, "Telco 2 fault", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x353, "Long range radio transmitter fault", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x354, "Failure to communicate event", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x355, "Loss of radio supervision", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x356, "Loss of central polling", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x357, "Long range radio VSWR problem", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x370, "Protection loop", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x371, "Protection loop open", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x372, "Protection loop short", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x373, "Fire trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x374, "Exit error alarm (zone)", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x375, "Panic zone trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x376, "Hold-up zone trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x377, "Swinger trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x378, "Cross-zone trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x380, "Sensor trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x381, "Loss of supervision - RF", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x382, "Loss of supervision - RPM", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x383, "Sensor tamper", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x384, "RF low battery", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x385, "Smoke detector high sensitivity", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x386, "Smoke detector low sensitivity", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x387, "Intrusion detector high sensitivity", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x388, "Intrusion detector low sensitivity", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x389, "Sensor self-test failure", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x391, "Sensor Watch trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x392, "Drift compensation error", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x393, "Maintenance alert", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x400, "Open/Close", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x401, "O/C by user", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x402, "Group O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x403, "Automatic O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x404, "Late to O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x405, "Deferred O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x406, "Cancel", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x407, "Remote arm/disarm", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x408, "Quick arm", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x409, "Keyswitch O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x441, "Armed STAY", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x442, "Keyswitch Armed STAY", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x450, "Exception O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x451, "Early O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x452, "Late O/C", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x453, "Failed to open", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x454, "Failed to close", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x455, "Auto-arm failed", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x456, "Partial arm", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x457, "Exit error (user)", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x458, "User on Premises", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x459, "Recent close", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x461, "Wrong code entry", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x462, "Legal code entry", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x463, "Re-arm after alarm", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x464, "Auto-arm time extended", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x465, "Panic alarm reset", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x466, "Service on/off premises", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x411, "Callback request made", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x412, "Successful download/access", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x413, "Unsuccessful access", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x414, "System shutdown command received", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x415, "Dialer shutdown command received", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x416, "Successful Upload", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x421, "Access denied", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x422, "Access report by user", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x423, "Forced Access", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x424, "Egress Denied", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x425, "Egress Granted", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x426, "Access Door propped open", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x427, "Access point door status monitor trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x428, "Access point request to exit trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x429, "Access program mode entry", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x430, "Access program mode exit", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x431, "Access threat level change", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x432, "Access relay/trigger fail", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x433, "Access RTE shunt", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x434, "Access DSM shunt", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x501, "Access reader disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x520, "Sounder/Relay disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x521, "Bell 1 disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x522, "Bell 2 disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x523, "Alarm relay disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x524, "Trouble relay disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x525, "Reversing relay disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x526, "Notification appliance ckt. #3 disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x527, "Notification appliance ckt. #4 disable", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x531, "Module added", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x532, "Module removed", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x551, "Dialer disabled", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x552, "Radio transmitter disabled", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x553, "Remote upload/download disabled", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x570, "Zone/Sensor bypass", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x571, "Fire bypass", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x572, "24 hour zone bypass", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x573, "Burg. bypass", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x574, "Group bypass", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x575, "Swinger bypass", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x576, "Access zone shunt", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x577, "Access point bypass", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x601, "Manual trigger test report", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x602, "Periodic test report", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x603, "Periodic RF transmission", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x604, "Fire test", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x605, "Status report to follow", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x606, "Listen-in to follow", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x607, "Walk test mode", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x608, "Periodic test - system trouble present", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x609, "Video transmitter active", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x611, "Point tested OK", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x612, "Point not tested", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x613, "Intrusion zone walk tested", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x614, "Fire zone walk tested", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x615, "Panic zone walk tested", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x616, "Service request", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x621, "Event log reset", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x622, "Event log 50% full", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x623, "Event log 90% full", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x624, "Event log overflow", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x625, "Time/Date reset", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x626, "Time/Date inaccurate", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x627, "Program mode entry", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x628, "Program mode exit", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x629, "32 hour event log marker", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x630, "Schedule change", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x631, "Exception schedule change", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x632, "Access schedule change", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x641, "Senior watch trouble", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x642, "Latch-key supervision", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x651, "Reserved for Ademco use", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x652, "Reserved for Ademco use", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x653, "Reserved for Ademco use", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x654, "System inactivity", ADEMCO_CONTACTID_DATA_IS_ZONE}, + {0x900, "Download abort", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x901, "Download start/end", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x902, "Download interrupted", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x910, "Auto-close with bypass", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x911, "Bypass closing", ADEMCO_CONTACTID_DATA_IS_USER}, + {0x999, "32 hour no read of event log", ADEMCO_CONTACTID_DATA_IS_USER}, + {-1, "???"} +}; + +#if defined(SPANDSP_USE_FIXED_POINT) +#define GOERTZEL_SAMPLES_PER_BLOCK 55 /* We need to detect over a +-5% range */ +#define DETECTION_THRESHOLD 16439 /* -42dBm0 [((GOERTZEL_SAMPLES_PER_BLOCK*GOERTZEL_SAMPLES_PER_BLOCK*32768.0/(1.4142*128.0))*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */ +#define TONE_TWIST 4 /* 6dB */ +#define TONE_TO_TOTAL_ENERGY 64 /* -3dB */ +#else +#define GOERTZEL_SAMPLES_PER_BLOCK 55 /* We need to detect over a +-5% range */ +#define DETECTION_THRESHOLD 2104205.6f /* -42dBm0 [((GOERTZEL_SAMPLES_PER_BLOCK*GOERTZEL_SAMPLES_PER_BLOCK*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */ +#define TONE_TWIST 3.981f /* 6dB */ +#define TONE_TO_TOTAL_ENERGY 1.995f /* 3dB */ +#endif + +static goertzel_descriptor_t tone_1400_desc; +static goertzel_descriptor_t tone_2300_desc; + +SPAN_DECLARE(int) encode_msg(char buf[], const ademco_contactid_report_t *report) +{ + char *s; + int sum; + int x; + static const char remap[] = {'D', '*', '#', 'A', 'B', 'C'}; + + sprintf(buf, "%04X%02X%1X%03X%02X%03X", report->acct, report->mt, report->q, report->xyz, report->gg, report->ccc); + for (sum = 0, s = buf; *s; s++) + { + if (*s == 'A') + return -1; + if (*s > '9') + { + x = *s - ('A' - 10); + /* Remap the Ademco B-F digits to normal DTMF *#ABC digits */ + *s = remap[x - 10]; + } + else + { + x = *s - '0'; + if (x == 0) + x = 10; + } + sum += x; + } + sum = ((sum + 15)/15)*15 - sum; + if (sum == 0) + sum = 'C'; + else if (sum <= 9) + sum += '0'; + else + sum = remap[sum - 10]; + *s++ = sum; + *s = '\0'; + return s - buf; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) decode_msg(ademco_contactid_report_t *report, const char buf[]) +{ + const char *s; + char *t; + int sum; + 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) + and calculate the checksum */ + for (sum = 0, s = buf, t = buf2; *s; s++, t++) + { + x = *s; + switch (x) + { + case '*': + x = 'B'; + break; + case '#': + x = 'C'; + break; + case 'A': + x = 'D'; + break; + case 'B': + x = 'E'; + break; + case 'C': + x = 'F'; + break; + case 'D': + /* This should not happen in the Ademco protocol */ + x = 'A'; + break; + default: + x = *s; + break; + } + *t = x; + if (x > '9') + { + x -= ('B' - 11); + } + else + { + if (x == '0') + x = 10; + else + x -= '0'; + } + sum += x; + } + *t = '\0'; + if (sum%15 != 0) + return -1; + if (sscanf(buf2, "%04x%02x%1x%03x%02x%03x", &report->acct, &report->mt, &report->q, &report->xyz, &report->gg, &report->ccc) != 6) + return -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(const char *) ademco_contactid_msg_qualifier_to_str(int q) +{ + switch (q) + { + case ADEMCO_CONTACTID_QUALIFIER_NEW_EVENT: + return "New event"; + case ADEMCO_CONTACTID_QUALIFIER_NEW_RESTORE: + return "New restore"; + case ADEMCO_CONTACTID_QUALIFIER_STATUS_REPORT: + return "Status report"; + } + return "???"; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(const char *) ademco_contactid_event_to_str(int xyz) +{ + int entry; + + for (entry = 0; ademco_codes[entry].code >= 0; entry++) + { + if (xyz == ademco_codes[entry].code) + return ademco_codes[entry].name; + } + return "???"; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_receiver_log_msg(ademco_contactid_receiver_state_t *s, const ademco_contactid_report_t *report) +{ + const char *t; + + span_log(&s->logging, SPAN_LOG_FLOW, "Ademco Contact ID message:\n"); + span_log(&s->logging, SPAN_LOG_FLOW, " Account %X\n", report->acct); + switch (report->mt) + { + case ADEMCO_CONTACTID_MESSAGE_TYPE_18: + case ADEMCO_CONTACTID_MESSAGE_TYPE_98: + t = "Contact ID"; + break; + default: + t = "???"; + break; + } + span_log(&s->logging, SPAN_LOG_FLOW, " Message type %s (%X)\n", t, report->mt); + t = ademco_contactid_msg_qualifier_to_str(report->q); + span_log(&s->logging, SPAN_LOG_FLOW, " Qualifier %s (%X)\n", t, report->q); + t = ademco_contactid_event_to_str(report->xyz); + span_log(&s->logging, SPAN_LOG_FLOW, " Event %s (%X)\n", t, report->xyz); + span_log(&s->logging, SPAN_LOG_FLOW, " Group/partition %X\n", report->gg); + span_log(&s->logging, SPAN_LOG_FLOW, " User/Zone information %X\n", report->ccc); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_receiver_tx(ademco_contactid_receiver_state_t *s, int16_t amp[], int max_samples) +{ + int i; + int samples; + + switch (s->step) + { + case 0: + samples = (s->remaining_samples > max_samples) ? max_samples : s->remaining_samples; + vec_zeroi16(amp, samples); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "Initial silence finished\n"); + s->step++; + s->tone_phase_rate = dds_phase_rate(1400.0); + s->tone_level = dds_scaling_dbm0(-11); + s->tone_phase = 0; + s->remaining_samples = ms_to_samples(100); + return samples; + case 1: + samples = (s->remaining_samples > max_samples) ? max_samples : s->remaining_samples; + for (i = 0; i < samples; i++) + amp[i] = dds_mod(&s->tone_phase, s->tone_phase_rate, s->tone_level, 0); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "1400Hz tone finished\n"); + s->step++; + s->remaining_samples = ms_to_samples(100); + return samples; + case 2: + samples = (s->remaining_samples > max_samples) ? max_samples : s->remaining_samples; + vec_zeroi16(amp, samples); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "Second silence finished\n"); + s->step++; + s->tone_phase_rate = dds_phase_rate(2300.0); + s->tone_level = dds_scaling_dbm0(-11); + s->tone_phase = 0; + s->remaining_samples = ms_to_samples(100); + return samples; + case 3: + samples = (s->remaining_samples > max_samples) ? max_samples : s->remaining_samples; + for (i = 0; i < samples; i++) + amp[i] = dds_mod(&s->tone_phase, s->tone_phase_rate, s->tone_level, 0); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "2300Hz tone finished\n"); + s->step++; + s->remaining_samples = ms_to_samples(100); + return samples; + case 4: + /* Idle here, waiting for a response */ + return 0; + case 5: + samples = (s->remaining_samples > max_samples) ? max_samples : s->remaining_samples; + vec_zeroi16(amp, samples); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "Sending kissoff\n"); + s->step++; + s->tone_phase_rate = dds_phase_rate(1400.0); + s->tone_level = dds_scaling_dbm0(-11); + s->tone_phase = 0; + s->remaining_samples = ms_to_samples(850); + return samples; + case 6: + samples = (s->remaining_samples > max_samples) ? max_samples : s->remaining_samples; + for (i = 0; i < samples; i++) + amp[i] = dds_mod(&s->tone_phase, s->tone_phase_rate, s->tone_level, 0); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "1400Hz tone finished\n"); + s->step = 4; + s->remaining_samples = ms_to_samples(100); + return samples; + } + return max_samples; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_receiver_rx(ademco_contactid_receiver_state_t *s, const int16_t amp[], int samples) +{ + return dtmf_rx(&s->dtmf, amp, samples); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_receiver_fillin(ademco_contactid_receiver_state_t *s, int samples) +{ + return dtmf_rx_fillin(&s->dtmf, samples); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(logging_state_t *) ademco_contactid_receiver_get_logging_state(ademco_contactid_receiver_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + +static void dtmf_digit_delivery(void *user_data, const char *digits, int len) +{ + ademco_contactid_receiver_state_t *s; + ademco_contactid_report_t report; + + s = (ademco_contactid_receiver_state_t *) user_data; + memcpy(&s->rx_digits[s->rx_digits_len], digits, len); + s->rx_digits_len += len; + if (s->rx_digits_len == 16) + { + s->rx_digits[16] = '\0'; + if (decode_msg(&report, s->rx_digits) == 0) + { + ademco_contactid_receiver_log_msg(s, &report); + if (s->callback) + s->callback(s->callback_user_data, &report); + s->step++; + } + s->rx_digits_len = 0; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) ademco_contactid_receiver_set_realtime_callback(ademco_contactid_receiver_state_t *s, + ademco_contactid_report_func_t callback, + void *user_data) +{ + s->callback = callback; + s->callback_user_data = user_data; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(ademco_contactid_receiver_state_t *) ademco_contactid_receiver_init(ademco_contactid_receiver_state_t *s, + ademco_contactid_report_func_t callback, + void *user_data) +{ + if (s == NULL) + { + if ((s = (ademco_contactid_receiver_state_t *) malloc(sizeof (*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "Ademco"); + + dtmf_rx_init(&s->dtmf, dtmf_digit_delivery, (void *) s); + s->rx_digits_len = 0; + + s->callback = callback; + s->callback_user_data = user_data; + + s->step = 0; + s->remaining_samples = ms_to_samples(500); + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_receiver_release(ademco_contactid_receiver_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_receiver_free(ademco_contactid_receiver_state_t *s) +{ + free(s); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_sender_tx(ademco_contactid_sender_state_t *s, int16_t amp[], int max_samples) +{ + int sample; + int samples; + + for (sample = 0; sample < max_samples; sample += samples) + { + switch (s->step) + { + case 0: + if (!s->clear_to_send) + return 0; + s->clear_to_send = FALSE; + s->step++; + s->remaining_samples = ms_to_samples(250); + /* Fall through */ + case 1: + samples = (s->remaining_samples > (max_samples - sample)) ? (max_samples - sample) : s->remaining_samples; + vec_zeroi16(&[sample], samples); + s->remaining_samples -= samples; + if (s->remaining_samples > 0) + return samples; + span_log(&s->logging, SPAN_LOG_FLOW, "Pre-send silence finished\n"); + s->step++; + break; + case 2: + samples = dtmf_tx(&s->dtmf, &[sample], max_samples - sample); + if (samples == 0) + { + s->clear_to_send = FALSE; + s->step = 0; + return sample; + } + break; + default: + return sample; + } + } + return sample; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_sender_rx(ademco_contactid_sender_state_t *s, const int16_t amp[], int samples) +{ +#if defined(SPANDSP_USE_FIXED_POINT) + int32_t energy_1400; + int32_t energy_2300; + int16_t xamp; +#else + float energy_1400; + float energy_2300; + float xamp; +#endif + int sample; + int limit; + int hit; + int j; + + for (sample = 0; sample < samples; sample = limit) + { + if ((samples - sample) >= (GOERTZEL_SAMPLES_PER_BLOCK - s->current_sample)) + limit = sample + (GOERTZEL_SAMPLES_PER_BLOCK - s->current_sample); + else + limit = samples; + for (j = sample; j < limit; j++) + { + xamp = amp[j]; + xamp = goertzel_preadjust_amp(xamp); +#if defined(SPANDSP_USE_FIXED_POINT) + s->energy += ((int32_t) xamp*xamp); +#else + s->energy += xamp*xamp; +#endif + goertzel_samplex(&s->tone_1400, xamp); + goertzel_samplex(&s->tone_2300, xamp); + } + s->current_sample += (limit - sample); + if (s->current_sample < GOERTZEL_SAMPLES_PER_BLOCK) + continue; + + energy_1400 = goertzel_result(&s->tone_1400); + energy_2300 = goertzel_result(&s->tone_2300); + hit = 0; + if (energy_1400 > DETECTION_THRESHOLD || energy_2300 > DETECTION_THRESHOLD) + { + if (energy_1400 > energy_2300) + { + if (energy_1400 > TONE_TO_TOTAL_ENERGY*s->energy) + hit = 1; + } + else + { + if (energy_2300 > TONE_TO_TOTAL_ENERGY*s->energy) + hit = 2; + } + } + if (hit != s->in_tone && hit == s->last_hit) + { + /* We have two successive indications that something has changed to a + specific new state. */ + switch (s->tone_state) + { + case 0: + if (hit == 1) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Receiving initial 1400Hz\n"); + s->in_tone = hit; + s->tone_state = 1; + s->duration = 0; + } + break; + case 1: + /* We are looking for a burst of 1400Hz which is 100ms +- 5% long */ + if (hit == 0) + { + if (s->duration < ms_to_samples(70) || s->duration > ms_to_samples(130)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Bad initial 1400Hz tone duration\n"); + s->tone_state = 0; + } + else + { + span_log(&s->logging, SPAN_LOG_FLOW, "Received 1400Hz tone\n"); + s->tone_state = 2; + } + s->in_tone = hit; + s->duration = 0; + } + break; + case 2: + /* We are looking for 100ms +-5% of silence after the 1400Hz tone */ + if (s->duration < ms_to_samples(70) || s->duration > ms_to_samples(130)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Bad silence length\n"); + s->tone_state = 0; + s->in_tone = hit; + } + else if (hit == 2) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Received silence\n"); + s->tone_state = 3; + s->in_tone = hit; + } + else + { + s->tone_state = 0; + s->in_tone = 0; + } + s->duration = 0; + break; + case 3: + /* We are looking for a burst of 2300Hz which is 100ms +- 5% long */ + if (hit == 0) + { + if (s->duration < ms_to_samples(70) || s->duration > ms_to_samples(130)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Bad initial 2300Hz tone duration\n"); + s->tone_state = 0; + } + else + { + span_log(&s->logging, SPAN_LOG_FLOW, "Received 2300Hz\n"); + if (s->callback) + s->callback(s->callback_user_data, -1, 0, 0); + s->tone_state = 4; + /* Release the transmit side, and it will time the 250ms post tone delay */ + s->clear_to_send = TRUE; + s->tries = 0; + if (s->tx_digits_len) + s->timer = ms_to_samples(3000); + } + s->in_tone = hit; + s->duration = 0; + } + break; + case 4: + if (hit == 1) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Receiving kissoff\n"); + s->tone_state = 5; + s->in_tone = hit; + s->duration = 0; + } + break; + case 5: + if (hit == 0) + { + s->busy = FALSE; + if (s->duration < ms_to_samples(400) || s->duration > ms_to_samples(1500)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Bad kissoff duration %d\n", s->duration); + if (++s->tries < 4) + { + dtmf_tx_put(&s->dtmf, s->tx_digits, s->tx_digits_len); + s->timer = ms_to_samples(3000); + s->tone_state = 4; + } + else + { + s->timer = 0; + if (s->callback) + s->callback(s->callback_user_data, FALSE, 0, 0); + } + } + else + { + span_log(&s->logging, SPAN_LOG_FLOW, "Received good kissoff\n"); + s->clear_to_send = TRUE; + s->tx_digits_len = 0; + if (s->callback) + s->callback(s->callback_user_data, TRUE, 0, 0); + s->tone_state = 4; + s->clear_to_send = TRUE; + s->tries = 0; + if (s->tx_digits_len) + s->timer = ms_to_samples(3000); + } + s->in_tone = hit; + s->duration = 0; + } + break; + } + } + s->last_hit = hit; + s->duration += GOERTZEL_SAMPLES_PER_BLOCK; + if (s->timer > 0) + { + s->timer -= GOERTZEL_SAMPLES_PER_BLOCK; + if (s->timer <= 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Timer expired\n"); + if (s->tone_state == 4 && s->tx_digits_len) + { + if (++s->tries < 4) + { + dtmf_tx_put(&s->dtmf, s->tx_digits, s->tx_digits_len); + s->timer = ms_to_samples(3000); + } + else + { + s->timer = 0; + if (s->callback) + s->callback(s->callback_user_data, FALSE, 0, 0); + } + } + } + } + s->energy = 0; + s->current_sample = 0; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_sender_fillin(ademco_contactid_sender_state_t *s, int samples) +{ + /* Restart any Goertzel and energy gathering operation we might be in the middle of. */ + goertzel_reset(&s->tone_1400); + goertzel_reset(&s->tone_2300); +#if defined(SPANDSP_USE_FIXED_POINT) + s->energy = 0; +#else + s->energy = 0.0f; +#endif + s->current_sample = 0; + /* Don't update the hit detection. Pretend it never happened. */ + /* TODO: Surely we can be cleverer than this. */ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_sender_put(ademco_contactid_sender_state_t *s, const ademco_contactid_report_t *report) +{ + if (s->busy) + return -1; + if ((s->tx_digits_len = encode_msg(s->tx_digits, report)) < 0) + return -1; + s->busy = TRUE; + return dtmf_tx_put(&s->dtmf, s->tx_digits, s->tx_digits_len); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(logging_state_t *) ademco_contactid_sender_get_logging_state(ademco_contactid_sender_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) ademco_contactid_sender_set_realtime_callback(ademco_contactid_sender_state_t *s, + tone_report_func_t callback, + void *user_data) +{ + s->callback = callback; + s->callback_user_data = user_data; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(ademco_contactid_sender_state_t *) ademco_contactid_sender_init(ademco_contactid_sender_state_t *s, + tone_report_func_t callback, + void *user_data) +{ + static int initialised = FALSE; + + if (s == NULL) + { + if ((s = (ademco_contactid_sender_state_t *) malloc(sizeof (*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "Ademco"); + + if (!initialised) + { + make_goertzel_descriptor(&tone_1400_desc, 1400.0f, GOERTZEL_SAMPLES_PER_BLOCK); + make_goertzel_descriptor(&tone_2300_desc, 2300.0f, GOERTZEL_SAMPLES_PER_BLOCK); + } + goertzel_init(&s->tone_1400, &tone_1400_desc); + goertzel_init(&s->tone_2300, &tone_2300_desc); + s->current_sample = 0; + + s->callback = callback; + s->callback_user_data = user_data; + + s->step = 0; + s->remaining_samples = ms_to_samples(100); + dtmf_tx_init(&s->dtmf); + /* The specified timing is 50-60ms on, 50-60ms off */ + dtmf_tx_set_timing(&s->dtmf, 55, 55); + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_sender_release(ademco_contactid_sender_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) ademco_contactid_sender_free(ademco_contactid_sender_state_t *s) +{ + free(s); + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/async.c b/libs/spandsp/src/async.c index 518642111e..3552d644ee 100644 --- a/libs/spandsp/src/async.c +++ b/libs/spandsp/src/async.c @@ -179,27 +179,30 @@ SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data, int bit) { /* Align the received value */ if (s->data_bits < 8) - s->byte_in_progress >>= (8 - s->data_bits); + s->byte_in_progress = (s->byte_in_progress & 0xFF) >> (8 - s->data_bits); s->put_byte(s->user_data, s->byte_in_progress); s->bitpos = 0; } - else if (s->use_v14) - { - /* This is actually the start bit for the next character, and - the stop bit has been dropped from the stream. This is the - rate adaption specified in V.14 */ - /* Align the received value */ - if (s->data_bits < 8) - s->byte_in_progress >>= (8 - s->data_bits); - s->put_byte(s->user_data, s->byte_in_progress); - s->bitpos = 1; - s->parity_bit = 0; - s->byte_in_progress = 0; - } else { - s->framing_errors++; - s->bitpos = 0; + if (s->use_v14) + { + /* This is actually the start bit for the next character, and + the stop bit has been dropped from the stream. This is the + rate adaption specified in V.14 */ + /* Align the received value */ + if (s->data_bits < 8) + s->byte_in_progress = (s->byte_in_progress & 0xFF) >> (8 - s->data_bits); + s->put_byte(s->user_data, s->byte_in_progress); + s->bitpos = 1; + s->parity_bit = 0; + s->byte_in_progress = 0; + } + else + { + s->framing_errors++; + s->bitpos = 0; + } } } } diff --git a/libs/spandsp/src/at_interpreter.c b/libs/spandsp/src/at_interpreter.c index 73625ef8d7..9342cfc58d 100644 --- a/libs/spandsp/src/at_interpreter.c +++ b/libs/spandsp/src/at_interpreter.c @@ -434,13 +434,13 @@ static int match_element(const char **variant, const char *variants) if (len == (int) strlen(*variant) && memcmp(*variant, s, len) == 0) { *variant += len; - return i; + return i; } s += len; if (*s == ',') s++; } - return -1; + return -1; } /*- End of function --------------------------------------------------------*/ @@ -804,7 +804,7 @@ static int process_class1_cmd(at_state_t *s, const char **t) if (val < 0) { /* It was just a query */ - return TRUE; + return TRUE; } /* All class 1 FAX commands are supposed to give an ERROR response, if the phone is on-hook. */ @@ -5501,9 +5501,9 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(at_state_t *) at_init(at_state_t *s, - at_tx_handler_t *at_tx_handler, + at_tx_handler_t at_tx_handler, void *at_tx_user_data, - at_modem_control_handler_t *modem_control_handler, + at_modem_control_handler_t modem_control_handler, void *modem_control_user_data) { if (s == NULL) diff --git a/libs/spandsp/src/awgn.c b/libs/spandsp/src/awgn.c index e97dd6be0b..b432901bb2 100644 --- a/libs/spandsp/src/awgn.c +++ b/libs/spandsp/src/awgn.c @@ -101,7 +101,7 @@ SPAN_DECLARE(awgn_state_t *) awgn_init_dbov(awgn_state_t *s, int idum, float lev if (s == NULL) { if ((s = (awgn_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; + return NULL; } if (idum < 0) idum = -idum; diff --git a/libs/spandsp/src/bell_r2_mf.c b/libs/spandsp/src/bell_r2_mf.c index 1487a821f5..76b0049453 100644 --- a/libs/spandsp/src/bell_r2_mf.c +++ b/libs/spandsp/src/bell_r2_mf.c @@ -46,7 +46,6 @@ #include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/queue.h" -#include "spandsp/dc_restore.h" #include "spandsp/complex.h" #include "spandsp/dds.h" #include "spandsp/tone_detect.h" @@ -621,7 +620,7 @@ SPAN_DECLARE(size_t) bell_mf_rx_get(bell_mf_rx_state_t *s, char *buf, int max) s->current_digits -= max; } buf[max] = '\0'; - return max; + return max; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/bert.c b/libs/spandsp/src/bert.c index c697b39a7a..4ba0c335f7 100644 --- a/libs/spandsp/src/bert.c +++ b/libs/spandsp/src/bert.c @@ -491,7 +491,7 @@ SPAN_DECLARE(bert_state_t *) bert_init(bert_state_t *s, int limit, int pattern, span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "BERT"); - return s; + return s; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/cielab_luts.h b/libs/spandsp/src/cielab_luts.h new file mode 100644 index 0000000000..0a3c697915 --- /dev/null +++ b/libs/spandsp/src/cielab_luts.h @@ -0,0 +1,4358 @@ +static const float srgb_to_linear[256] = +{ + 0.000000, + 0.000302, + 0.000605, + 0.000907, + 0.001209, + 0.001512, + 0.001814, + 0.002116, + 0.002419, + 0.002721, + 0.003023, + 0.003333, + 0.003661, + 0.004007, + 0.004371, + 0.004754, + 0.005156, + 0.005577, + 0.006017, + 0.006477, + 0.006957, + 0.007457, + 0.007977, + 0.008518, + 0.009080, + 0.009663, + 0.010267, + 0.010893, + 0.011540, + 0.012209, + 0.012900, + 0.013614, + 0.014350, + 0.015109, + 0.015890, + 0.016695, + 0.017523, + 0.018375, + 0.019250, + 0.020149, + 0.021072, + 0.022019, + 0.022991, + 0.023987, + 0.025008, + 0.026054, + 0.027125, + 0.028221, + 0.029343, + 0.030490, + 0.031663, + 0.032862, + 0.034087, + 0.035338, + 0.036616, + 0.037920, + 0.039250, + 0.040608, + 0.041993, + 0.043404, + 0.044844, + 0.046310, + 0.047804, + 0.049326, + 0.050876, + 0.052454, + 0.054060, + 0.055694, + 0.057357, + 0.059049, + 0.060769, + 0.062518, + 0.064296, + 0.066103, + 0.067940, + 0.069806, + 0.071701, + 0.073626, + 0.075581, + 0.077566, + 0.079581, + 0.081627, + 0.083702, + 0.085808, + 0.087945, + 0.090112, + 0.092311, + 0.094540, + 0.096800, + 0.099092, + 0.101414, + 0.103769, + 0.106155, + 0.108572, + 0.111021, + 0.113503, + 0.116016, + 0.118562, + 0.121139, + 0.123750, + 0.126392, + 0.129068, + 0.131776, + 0.134517, + 0.137291, + 0.140098, + 0.142938, + 0.145812, + 0.148719, + 0.151659, + 0.154633, + 0.157641, + 0.160683, + 0.163758, + 0.166868, + 0.170012, + 0.173190, + 0.176403, + 0.179650, + 0.182932, + 0.186248, + 0.189599, + 0.192985, + 0.196407, + 0.199863, + 0.203354, + 0.206881, + 0.210443, + 0.214041, + 0.217675, + 0.221344, + 0.225049, + 0.228789, + 0.232566, + 0.236379, + 0.240229, + 0.244114, + 0.248036, + 0.251995, + 0.255990, + 0.260022, + 0.264090, + 0.268196, + 0.272338, + 0.276518, + 0.280734, + 0.284988, + 0.289280, + 0.293609, + 0.297975, + 0.302379, + 0.306821, + 0.311301, + 0.315818, + 0.320374, + 0.324967, + 0.329599, + 0.334269, + 0.338978, + 0.343725, + 0.348510, + 0.353334, + 0.358197, + 0.363099, + 0.368040, + 0.373019, + 0.378038, + 0.383096, + 0.388193, + 0.393329, + 0.398505, + 0.403721, + 0.408976, + 0.414270, + 0.419605, + 0.424979, + 0.430393, + 0.435848, + 0.441342, + 0.446877, + 0.452452, + 0.458067, + 0.463722, + 0.469419, + 0.475156, + 0.480933, + 0.486751, + 0.492610, + 0.498510, + 0.504452, + 0.510434, + 0.516457, + 0.522522, + 0.528628, + 0.534775, + 0.540964, + 0.547194, + 0.553466, + 0.559780, + 0.566136, + 0.572533, + 0.578973, + 0.585455, + 0.591978, + 0.598544, + 0.605152, + 0.611803, + 0.618496, + 0.625232, + 0.632010, + 0.638831, + 0.645694, + 0.652600, + 0.659550, + 0.666542, + 0.673577, + 0.680656, + 0.687777, + 0.694942, + 0.702151, + 0.709402, + 0.716698, + 0.724036, + 0.731419, + 0.738845, + 0.746315, + 0.753829, + 0.761386, + 0.768988, + 0.776634, + 0.784324, + 0.792058, + 0.799837, + 0.807660, + 0.815527, + 0.823439, + 0.831396, + 0.839397, + 0.847443, + 0.855534, + 0.863669, + 0.871850, + 0.880075, + 0.888346, + 0.896662, + 0.905023, + 0.913429, + 0.921881, + 0.930378, + 0.938921, + 0.947509, + 0.956143, + 0.964823, + 0.973548, + 0.982319, + 0.991137 +}; +static const uint8_t linear_to_srgb[4096] = +{ + 0, + 0, + 1, + 2, + 3, + 4, + 4, + 5, + 6, + 7, + 8, + 8, + 9, + 10, + 11, + 12, + 12, + 13, + 14, + 14, + 15, + 15, + 16, + 17, + 17, + 18, + 18, + 19, + 19, + 20, + 20, + 21, + 21, + 22, + 22, + 23, + 23, + 23, + 24, + 24, + 25, + 25, + 25, + 26, + 26, + 27, + 27, + 27, + 28, + 28, + 28, + 29, + 29, + 30, + 30, + 30, + 31, + 31, + 31, + 32, + 32, + 32, + 33, + 33, + 33, + 33, + 34, + 34, + 34, + 35, + 35, + 35, + 36, + 36, + 36, + 36, + 37, + 37, + 37, + 38, + 38, + 38, + 38, + 39, + 39, + 39, + 39, + 40, + 40, + 40, + 40, + 41, + 41, + 41, + 41, + 42, + 42, + 42, + 42, + 43, + 43, + 43, + 43, + 44, + 44, + 44, + 44, + 45, + 45, + 45, + 45, + 45, + 46, + 46, + 46, + 46, + 47, + 47, + 47, + 47, + 47, + 48, + 48, + 48, + 48, + 49, + 49, + 49, + 49, + 49, + 50, + 50, + 50, + 50, + 50, + 51, + 51, + 51, + 51, + 51, + 52, + 52, + 52, + 52, + 52, + 53, + 53, + 53, + 53, + 53, + 54, + 54, + 54, + 54, + 54, + 54, + 55, + 55, + 55, + 55, + 55, + 56, + 56, + 56, + 56, + 56, + 56, + 57, + 57, + 57, + 57, + 57, + 57, + 58, + 58, + 58, + 58, + 58, + 59, + 59, + 59, + 59, + 59, + 59, + 60, + 60, + 60, + 60, + 60, + 60, + 61, + 61, + 61, + 61, + 61, + 61, + 62, + 62, + 62, + 62, + 62, + 62, + 62, + 63, + 63, + 63, + 63, + 63, + 63, + 64, + 64, + 64, + 64, + 64, + 64, + 65, + 65, + 65, + 65, + 65, + 65, + 65, + 66, + 66, + 66, + 66, + 66, + 66, + 66, + 67, + 67, + 67, + 67, + 67, + 67, + 68, + 68, + 68, + 68, + 68, + 68, + 68, + 69, + 69, + 69, + 69, + 69, + 69, + 69, + 70, + 70, + 70, + 70, + 70, + 70, + 70, + 70, + 71, + 71, + 71, + 71, + 71, + 71, + 71, + 72, + 72, + 72, + 72, + 72, + 72, + 72, + 73, + 73, + 73, + 73, + 73, + 73, + 73, + 73, + 74, + 74, + 74, + 74, + 74, + 74, + 74, + 75, + 75, + 75, + 75, + 75, + 75, + 75, + 75, + 76, + 76, + 76, + 76, + 76, + 76, + 76, + 76, + 77, + 77, + 77, + 77, + 77, + 77, + 77, + 77, + 78, + 78, + 78, + 78, + 78, + 78, + 78, + 78, + 79, + 79, + 79, + 79, + 79, + 79, + 79, + 79, + 80, + 80, + 80, + 80, + 80, + 80, + 80, + 80, + 80, + 81, + 81, + 81, + 81, + 81, + 81, + 81, + 81, + 82, + 82, + 82, + 82, + 82, + 82, + 82, + 82, + 82, + 83, + 83, + 83, + 83, + 83, + 83, + 83, + 83, + 83, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 85, + 85, + 85, + 85, + 85, + 85, + 85, + 85, + 85, + 86, + 86, + 86, + 86, + 86, + 86, + 86, + 86, + 86, + 87, + 87, + 87, + 87, + 87, + 87, + 87, + 87, + 87, + 88, + 88, + 88, + 88, + 88, + 88, + 88, + 88, + 88, + 89, + 89, + 89, + 89, + 89, + 89, + 89, + 89, + 89, + 89, + 90, + 90, + 90, + 90, + 90, + 90, + 90, + 90, + 90, + 90, + 91, + 91, + 91, + 91, + 91, + 91, + 91, + 91, + 91, + 92, + 92, + 92, + 92, + 92, + 92, + 92, + 92, + 92, + 92, + 93, + 93, + 93, + 93, + 93, + 93, + 93, + 93, + 93, + 93, + 94, + 94, + 94, + 94, + 94, + 94, + 94, + 94, + 94, + 94, + 95, + 95, + 95, + 95, + 95, + 95, + 95, + 95, + 95, + 95, + 95, + 96, + 96, + 96, + 96, + 96, + 96, + 96, + 96, + 96, + 96, + 97, + 97, + 97, + 97, + 97, + 97, + 97, + 97, + 97, + 97, + 97, + 98, + 98, + 98, + 98, + 98, + 98, + 98, + 98, + 98, + 98, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 101, + 101, + 101, + 101, + 101, + 101, + 101, + 101, + 101, + 101, + 101, + 102, + 102, + 102, + 102, + 102, + 102, + 102, + 102, + 102, + 102, + 102, + 103, + 103, + 103, + 103, + 103, + 103, + 103, + 103, + 103, + 103, + 103, + 103, + 104, + 104, + 104, + 104, + 104, + 104, + 104, + 104, + 104, + 104, + 104, + 105, + 105, + 105, + 105, + 105, + 105, + 105, + 105, + 105, + 105, + 105, + 105, + 106, + 106, + 106, + 106, + 106, + 106, + 106, + 106, + 106, + 106, + 106, + 106, + 107, + 107, + 107, + 107, + 107, + 107, + 107, + 107, + 107, + 107, + 107, + 107, + 108, + 108, + 108, + 108, + 108, + 108, + 108, + 108, + 108, + 108, + 108, + 108, + 109, + 109, + 109, + 109, + 109, + 109, + 109, + 109, + 109, + 109, + 109, + 109, + 110, + 110, + 110, + 110, + 110, + 110, + 110, + 110, + 110, + 110, + 110, + 110, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 111, + 112, + 112, + 112, + 112, + 112, + 112, + 112, + 112, + 112, + 112, + 112, + 112, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 113, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 114, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 115, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 116, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 117, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 118, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 119, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 120, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 121, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 122, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 123, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 124, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 125, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 126, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 127, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 128, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 129, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 130, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 131, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 132, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 133, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 134, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 135, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 136, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 137, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 138, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 139, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 140, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 141, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 142, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 143, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 144, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 145, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 146, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 147, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 148, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 149, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 150, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 151, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 152, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 153, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 154, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 155, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 156, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 157, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 158, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 159, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 160, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 161, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 162, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 163, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 164, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 165, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 166, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 167, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 168, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 169, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 170, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 171, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 172, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 173, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 174, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 175, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 176, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 177, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 178, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 179, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 180, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 181, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 182, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 183, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 184, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 185, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 186, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 187, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 188, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 189, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 190, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 191, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 192, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 193, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 194, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 195, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 196, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 197, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 198, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 199, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 200, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 201, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 202, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 203, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 204, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 205, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 206, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 207, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 208, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 209, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 210, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 211, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 214, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 215, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 216, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 217, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 218, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 219, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 220, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 221, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 222, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 223, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 224, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 225, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 226, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 227, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 228, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 229, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 230, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 231, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 232, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 233, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 234, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 235, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 236, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 237, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 238, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 239, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 240, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 241, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 242, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 243, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 244, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 245, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 246, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 247, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 248, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 249, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 250, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 251, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 252, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 253, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255 +}; diff --git a/libs/spandsp/src/dtmf.c b/libs/spandsp/src/dtmf.c index 35dc6c9dd1..ee61f0095c 100644 --- a/libs/spandsp/src/dtmf.c +++ b/libs/spandsp/src/dtmf.c @@ -258,45 +258,42 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples) Note this is only relevant to VoIP using A-law, u-law or similar. Low bit rate codecs scramble DTMF too much for it to be recognised, and often slip in units larger than a sample. */ - if (hit != s->in_digit) + if (hit != s->in_digit && s->last_hit != s->in_digit) { - if (s->last_hit != s->in_digit) + /* We have two successive indications that something has changed. */ + /* To declare digit on, the hits must agree. Otherwise we declare tone off. */ + hit = (hit && hit == s->last_hit) ? hit : 0; + if (s->realtime_callback) { - /* We have two successive indications that something has changed. */ - /* To declare digit on, the hits must agree. Otherwise we declare tone off. */ - hit = (hit && hit == s->last_hit) ? hit : 0; - if (s->realtime_callback) + /* Avoid reporting multiple no digit conditions on flaky hits */ + if (s->in_digit || hit) { - /* Avoid reporting multiple no digit conditions on flaky hits */ - if (s->in_digit || hit) - { - i = (s->in_digit && !hit) ? -99 : lfastrintf(log10f(s->energy)*10.0f - DTMF_POWER_OFFSET + DBM0_MAX_POWER); - s->realtime_callback(s->realtime_callback_data, hit, i, s->duration); - s->duration = 0; - } + i = (s->in_digit && !hit) ? -99 : lfastrintf(log10f(s->energy)*10.0f - DTMF_POWER_OFFSET + DBM0_MAX_POWER); + s->realtime_callback(s->realtime_callback_data, hit, i, s->duration); + s->duration = 0; } - else - { - if (hit) - { - if (s->current_digits < MAX_DTMF_DIGITS) - { - s->digits[s->current_digits++] = (char) hit; - s->digits[s->current_digits] = '\0'; - if (s->digits_callback) - { - s->digits_callback(s->digits_callback_data, s->digits, s->current_digits); - s->current_digits = 0; - } - } - else - { - s->lost_digits++; - } - } - } - s->in_digit = hit; } + else + { + if (hit) + { + if (s->current_digits < MAX_DTMF_DIGITS) + { + s->digits[s->current_digits++] = (char) hit; + s->digits[s->current_digits] = '\0'; + if (s->digits_callback) + { + s->digits_callback(s->digits_callback_data, s->digits, s->current_digits); + s->current_digits = 0; + } + } + else + { + s->lost_digits++; + } + } + } + s->in_digit = hit; } s->last_hit = hit; #if defined(SPANDSP_USE_FIXED_POINT) @@ -333,7 +330,7 @@ SPAN_DECLARE(int) dtmf_rx_fillin(dtmf_rx_state_t *s, int samples) #endif s->current_sample = 0; /* Don't update the hit detection. Pretend it never happened. */ - /* TODO: Surely we can be a cleverer than this. */ + /* TODO: Surely we can be cleverer than this. */ return 0; } /*- End of function --------------------------------------------------------*/ @@ -359,7 +356,7 @@ SPAN_DECLARE(size_t) dtmf_rx_get(dtmf_rx_state_t *s, char *buf, int max) s->current_digits -= max; } buf[max] = '\0'; - return max; + return max; } /*- End of function --------------------------------------------------------*/ @@ -375,9 +372,9 @@ SPAN_DECLARE(void) dtmf_rx_set_realtime_callback(dtmf_rx_state_t *s, SPAN_DECLARE(void) dtmf_rx_parms(dtmf_rx_state_t *s, int filter_dialtone, - int twist, - int reverse_twist, - int threshold) + float twist, + float reverse_twist, + float threshold) { float x; @@ -417,7 +414,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s, if (s == NULL) { if ((s = (dtmf_rx_state_t *) malloc(sizeof (*s))) == NULL) - return NULL; + return NULL; } memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); @@ -570,7 +567,7 @@ SPAN_DECLARE(dtmf_tx_state_t *) dtmf_tx_init(dtmf_tx_state_t *s) if (s == NULL) { if ((s = (dtmf_tx_state_t *) malloc(sizeof (*s))) == NULL) - return NULL; + return NULL; } memset(s, 0, sizeof(*s)); if (!dtmf_tx_inited) diff --git a/libs/spandsp/src/echo.c b/libs/spandsp/src/echo.c index 13a685d316..0b1aaac2aa 100644 --- a/libs/spandsp/src/echo.c +++ b/libs/spandsp/src/echo.c @@ -245,7 +245,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode) int j; if ((ec = (echo_can_state_t *) malloc(sizeof(*ec))) == NULL) - return NULL; + return NULL; memset(ec, 0, sizeof(*ec)); ec->taps = len; ec->curr_pos = ec->taps - 1; @@ -253,7 +253,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode) if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL) { free(ec); - return NULL; + return NULL; } memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t)); for (i = 0; i < 4; i++) @@ -264,7 +264,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode) free(ec->fir_taps16[j]); free(ec->fir_taps32); free(ec); - return NULL; + return NULL; } memset(ec->fir_taps16[i], 0, ec->taps*sizeof(int16_t)); } diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index c5422e7a52..2849745987 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -74,15 +74,10 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -112,20 +107,15 @@ #include "spandsp/private/hdlc.h" #include "spandsp/private/fax_modems.h" #include "spandsp/private/timezone.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" #include "spandsp/private/t30.h" @@ -133,16 +123,6 @@ #define HDLC_FRAMING_OK_THRESHOLD 8 -static void fax_send_hdlc(void *user_data, const uint8_t *msg, int len) -{ - fax_state_t *s; - - s = (fax_state_t *) user_data; - - hdlc_tx_frame(&s->modems.hdlc_tx, msg, len); -} -/*- End of function --------------------------------------------------------*/ - static void tone_detected(void *user_data, int tone, int level, int delay) { t30_state_t *s; @@ -152,7 +132,6 @@ static void tone_detected(void *user_data, int tone, int level, int delay) } /*- End of function --------------------------------------------------------*/ -#if 0 static void v8_handler(void *user_data, v8_parms_t *result) { fax_state_t *s; @@ -161,7 +140,6 @@ static void v8_handler(void *user_data, v8_parms_t *result) span_log(&s->logging, SPAN_LOG_FLOW, "V.8 report received\n"); } /*- End of function --------------------------------------------------------*/ -#endif static void hdlc_underflow_handler(void *user_data) { @@ -172,157 +150,6 @@ static void hdlc_underflow_handler(void *user_data) } /*- End of function --------------------------------------------------------*/ -static void set_rx_handler(fax_state_t *s, - span_rx_handler_t *rx_handler, - span_rx_fillin_handler_t *fillin_handler, - void *user_data) -{ - s->modems.rx_handler = rx_handler; - s->modems.rx_fillin_handler = fillin_handler; - s->modems.rx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void fax_modems_set_tx_handler(fax_state_t *s, span_tx_handler_t *handler, void *user_data) -{ - s->modems.tx_handler = handler; - s->modems.tx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void fax_modems_set_next_tx_handler(fax_state_t *s, span_tx_handler_t *handler, void *user_data) -{ - s->modems.next_tx_handler = handler; - s->modems.next_tx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static int v17_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v17_rx(&s->fast_modems.v17_rx, amp, len); - if (t->t30.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v17_rx, (span_rx_fillin_handler_t *) &v17_rx_fillin, &s->fast_modems.v17_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (t->t30.rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v17_v21_rx_fillin(void *user_data, int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v17_rx_fillin(&s->fast_modems.v17_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); - if (t->t30.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v27ter_rx, (span_rx_fillin_handler_t *) &v27ter_rx_fillin, &s->fast_modems.v27ter_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (t->t30.rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx_fillin(void *user_data, int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v27ter_rx_fillin(&s->fast_modems.v27ter_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx(void *user_data, const int16_t amp[], int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v29_rx(&s->fast_modems.v29_rx, amp, len); - if (t->t30.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v29_rx, (span_rx_fillin_handler_t *) &v29_rx_fillin, &s->fast_modems.v29_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (t->t30.rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx_fillin(void *user_data, int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v29_rx_fillin(&s->fast_modems.v29_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len) { int i; @@ -361,7 +188,7 @@ SPAN_DECLARE_NONSTD(int) fax_rx_fillin(fax_state_t *s, int len) } #endif /* Call the fillin function of the current modem (if there is one). */ - s->modems.rx_fillin_handler(s->modems.rx_user_data, len); + s->modems.rx_fillin_handler(s->modems.rx_fillin_user_data, len); t30_timer_update(&s->t30, len); return 0; } @@ -374,14 +201,14 @@ static int set_next_tx_type(fax_state_t *s) t = &s->modems; if (t->next_tx_handler) { - fax_modems_set_tx_handler(s, t->next_tx_handler, t->next_tx_user_data); + fax_modems_set_tx_handler(t, t->next_tx_handler, t->next_tx_user_data); t->next_tx_handler = NULL; return 0; } /* If there is nothing else to change to, so use zero length silence */ silence_gen_alter(&t->silence_gen, 0); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); t->transmit = FALSE; return -1; } @@ -439,8 +266,6 @@ SPAN_DECLARE_NONSTD(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len) static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc) { fax_state_t *s; - put_bit_func_t put_bit_func; - void *put_bit_user_data; fax_modems_state_t *t; s = (fax_state_t *) user_data; @@ -451,42 +276,27 @@ static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_t t->current_rx_type = type; t->rx_bit_rate = bit_rate; if (use_hdlc) - { - put_bit_func = (put_bit_func_t) hdlc_rx_put_bit; - put_bit_user_data = (void *) &t->hdlc_rx; hdlc_rx_init(&t->hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, t30_hdlc_accept, &s->t30); - } - else - { - put_bit_func = t30_non_ecm_put_bit; - put_bit_user_data = (void *) &s->t30; - } + switch (type) { case T30_MODEM_V21: - fsk_rx_init(&t->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data); - fsk_rx_signal_cutoff(&t->v21_rx, -45.5f); - set_rx_handler(s, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &t->v21_rx); - break; - case T30_MODEM_V27TER: - v27ter_rx_restart(&t->fast_modems.v27ter_rx, bit_rate, FALSE); - v27ter_rx_set_put_bit(&t->fast_modems.v27ter_rx, put_bit_func, put_bit_user_data); - set_rx_handler(s, &v27ter_v21_rx, &v27ter_v21_rx_fillin, s); - break; - case T30_MODEM_V29: - v29_rx_restart(&t->fast_modems.v29_rx, bit_rate, FALSE); - v29_rx_set_put_bit(&t->fast_modems.v29_rx, put_bit_func, put_bit_user_data); - set_rx_handler(s, &v29_v21_rx, &v29_v21_rx_fillin, s); + fax_modems_start_slow_modem(t, FAX_MODEM_V21_RX); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &t->v21_rx); break; case T30_MODEM_V17: - v17_rx_restart(&t->fast_modems.v17_rx, bit_rate, short_train); - v17_rx_set_put_bit(&t->fast_modems.v17_rx, put_bit_func, put_bit_user_data); - set_rx_handler(s, &v17_v21_rx, &v17_v21_rx_fillin, s); + fax_modems_start_fast_modem(t, FAX_MODEM_V17_RX, bit_rate, short_train, use_hdlc); + break; + case T30_MODEM_V27TER: + fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_RX, bit_rate, short_train, use_hdlc); + break; + case T30_MODEM_V29: + fax_modems_start_fast_modem(t, FAX_MODEM_V29_RX, bit_rate, short_train, use_hdlc); break; case T30_MODEM_DONE: span_log(&s->logging, SPAN_LOG_FLOW, "FAX exchange complete\n"); default: - set_rx_handler(s, (span_rx_handler_t *) &span_dummy_rx, (span_rx_fillin_handler_t *) &span_dummy_rx_fillin, s); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &span_dummy_rx, s, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, s); break; } } @@ -495,8 +305,6 @@ static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_t static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc) { fax_state_t *s; - get_bit_func_t get_bit_func; - void *get_bit_user_data; fax_modems_state_t *t; int tone; @@ -505,22 +313,12 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t span_log(&s->logging, SPAN_LOG_FLOW, "Set tx type %d\n", type); if (t->current_tx_type == type) return; - if (use_hdlc) - { - get_bit_func = (get_bit_func_t) hdlc_tx_get_bit; - get_bit_user_data = (void *) &t->hdlc_tx; - } - else - { - get_bit_func = t30_non_ecm_get_bit; - get_bit_user_data = (void *) &s->t30; - } switch (type) { case T30_MODEM_PAUSE: silence_gen_alter(&t->silence_gen, ms_to_samples(short_train)); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); t->transmit = TRUE; break; case T30_MODEM_CED: @@ -530,51 +328,48 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t else tone = MODEM_CONNECT_TONES_FAX_CNG; modem_connect_tones_tx_init(&t->connect_tx, tone); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &modem_connect_tones_tx, &t->connect_tx); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &modem_connect_tones_tx, &t->connect_tx); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); t->transmit = TRUE; break; case T30_MODEM_V21: - fsk_tx_init(&t->v21_tx, &preset_fsk_specs[FSK_V21CH2], get_bit_func, get_bit_user_data); + fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); /* The spec says 1s +-15% of preamble. So, the minimum is 32 octets. */ - hdlc_tx_flags(&t->hdlc_tx, 32); + fax_modems_hdlc_tx_flags(t, 32); /* Pause before switching from phase C, as per T.30 5.3.2.2. If we omit this, the receiver might not see the carrier fall between the high speed and low speed sections. In practice, a 75ms gap before any V.21 transmission is harmless, adds little to the overall length of a call, and ensures the receiving end is ready. */ silence_gen_alter(&t->silence_gen, ms_to_samples(75)); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) &fsk_tx, &t->v21_tx); - t->transmit = TRUE; - break; - case T30_MODEM_V27TER: - silence_gen_alter(&t->silence_gen, ms_to_samples(75)); - /* For any fast modem, set 200ms of preamble flags */ - hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); - v27ter_tx_restart(&t->fast_modems.v27ter_tx, bit_rate, t->use_tep); - v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, get_bit_func, get_bit_user_data); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) &v27ter_tx, &t->fast_modems.v27ter_tx); - t->transmit = TRUE; - break; - case T30_MODEM_V29: - silence_gen_alter(&t->silence_gen, ms_to_samples(75)); - /* For any fast modem, set 200ms of preamble flags */ - hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); - v29_tx_restart(&t->fast_modems.v29_tx, bit_rate, t->use_tep); - v29_tx_set_get_bit(&t->fast_modems.v29_tx, get_bit_func, get_bit_user_data); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) &v29_tx, &t->fast_modems.v29_tx); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &fsk_tx, &t->v21_tx); t->transmit = TRUE; break; case T30_MODEM_V17: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); /* For any fast modem, set 200ms of preamble flags */ - hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); - v17_tx_restart(&t->fast_modems.v17_tx, bit_rate, t->use_tep, short_train); - v17_tx_set_get_bit(&t->fast_modems.v17_tx, get_bit_func, get_bit_user_data); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) &v17_tx, &t->fast_modems.v17_tx); + fax_modems_hdlc_tx_flags(t, bit_rate/(8*5)); + fax_modems_start_fast_modem(t, FAX_MODEM_V17_TX, bit_rate, short_train, use_hdlc); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); + t->transmit = TRUE; + break; + case T30_MODEM_V27TER: + silence_gen_alter(&t->silence_gen, ms_to_samples(75)); + /* For any fast modem, set 200ms of preamble flags */ + fax_modems_hdlc_tx_flags(t, bit_rate/(8*5)); + fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_TX, bit_rate, short_train, use_hdlc); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); + t->transmit = TRUE; + break; + case T30_MODEM_V29: + silence_gen_alter(&t->silence_gen, ms_to_samples(75)); + /* For any fast modem, set 200ms of preamble flags */ + fax_modems_hdlc_tx_flags(t, bit_rate/(8*5)); + fax_modems_start_fast_modem(t, FAX_MODEM_V29_TX, bit_rate, short_train, use_hdlc); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); t->transmit = TRUE; break; case T30_MODEM_DONE: @@ -582,8 +377,8 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t /* Fall through */ default: silence_gen_alter(&t->silence_gen, 0); - fax_modems_set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - fax_modems_set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); t->transmit = FALSE; break; } @@ -600,7 +395,7 @@ SPAN_DECLARE(void) fax_set_transmit_on_idle(fax_state_t *s, int transmit_on_idle SPAN_DECLARE(void) fax_set_tep_mode(fax_state_t *s, int use_tep) { - s->modems.use_tep = use_tep; + fax_modems_set_tep_mode(&s->modems, use_tep); } /*- End of function --------------------------------------------------------*/ @@ -618,12 +413,9 @@ SPAN_DECLARE(logging_state_t *) fax_get_logging_state(fax_state_t *s) SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party) { -#if 0 v8_parms_t v8_parms; -#endif fax_modems_restart(&s->modems); -#if 0 v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; v8_parms.call_function = V8_CALL_T30_RX; v8_parms.modulations = V8_MOD_V21; @@ -641,7 +433,6 @@ SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party) v8_parms.nsf = -1; v8_parms.t66 = -1; v8_restart(&s->v8, calling_party, &v8_parms); -#endif t30_restart(&s->t30); #if defined(LOG_FAX_AUDIO) { @@ -679,9 +470,7 @@ SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party) SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) { -#if 0 v8_parms_t v8_parms; -#endif if (s == NULL) { @@ -705,10 +494,9 @@ SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) (void *) s, fax_set_tx_type, (void *) s, - fax_send_hdlc, - (void *) s); + fax_modems_hdlc_tx_frame, + (void *) &s->modems); t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); -#if 0 v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; v8_parms.call_function = V8_CALL_T30_RX; v8_parms.modulations = V8_MOD_V21; @@ -726,7 +514,6 @@ SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) v8_parms.nsf = -1; v8_parms.t66 = -1; v8_init(&s->v8, calling_party, &v8_parms, v8_handler, s); -#endif fax_restart(s, calling_party); return s; } diff --git a/libs/spandsp/src/fax_modems.c b/libs/spandsp/src/fax_modems.c index cad8594592..d2510a4909 100644 --- a/libs/spandsp/src/fax_modems.c +++ b/libs/spandsp/src/fax_modems.c @@ -86,6 +86,52 @@ #define HDLC_FRAMING_OK_THRESHOLD 5 +static 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 = TRUE; + if (s->hdlc_accept) + s->hdlc_accept(s->hdlc_accept_user_data, msg, len, ok); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE_NONSTD(void) fax_modems_hdlc_tx_frame(void *user_data, const uint8_t *msg, int len) +{ + fax_modems_state_t *s; + + s = (fax_modems_state_t *) user_data; + + hdlc_tx_frame(&s->hdlc_tx, msg, len); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_hdlc_tx_flags(fax_modems_state_t *s, int flags) +{ + hdlc_tx_flags(&s->hdlc_tx, flags); +} +/*- End of function --------------------------------------------------------*/ + +static void v17_rx_status_handler(void *user_data, int status) +{ + fax_modems_state_t *s; + + s = (fax_modems_state_t *) user_data; + switch (status) + { + case SIG_STATUS_TRAINING_SUCCEEDED: + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &v17_rx, &s->fast_modems.v17_rx, (span_rx_fillin_handler_t) &v17_rx_fillin, &s->fast_modems.v17_rx); + v17_rx_set_modem_status_handler(&s->fast_modems.v17_rx, NULL, s); + break; + } + /*endswitch*/ + s->fast_modems.v17_rx.put_bit(s->fast_modems.v17_rx.put_bit_user_data, status); +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len) { fax_modems_state_t *s; @@ -95,13 +141,11 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx(void *user_data, const int16_t am fsk_rx(&s->v21_rx, amp, len); if (s->rx_frame_received) { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ + /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - s->rx_handler = (span_rx_handler_t *) &fsk_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &fsk_rx_fillin; - s->rx_user_data = &s->v21_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); } + /*endif*/ return 0; } /*- End of function --------------------------------------------------------*/ @@ -117,6 +161,24 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len) } /*- End of function --------------------------------------------------------*/ +static void v27ter_rx_status_handler(void *user_data, int status) +{ + fax_modems_state_t *s; + + s = (fax_modems_state_t *) user_data; + switch (status) + { + case SIG_STATUS_TRAINING_SUCCEEDED: + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &v27ter_rx, &s->fast_modems.v27ter_rx, (span_rx_fillin_handler_t) &v27ter_rx_fillin, &s->fast_modems.v27ter_rx); + v27ter_rx_set_modem_status_handler(&s->fast_modems.v27ter_rx, NULL, s); + break; + } + /*endswitch*/ + s->fast_modems.v27ter_rx.put_bit(s->fast_modems.v27ter_rx.put_bit_user_data, status); +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len) { fax_modems_state_t *s; @@ -126,13 +188,11 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t fsk_rx(&s->v21_rx, amp, len); if (s->rx_frame_received) { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ + /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - s->rx_handler = (span_rx_handler_t *) &fsk_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &fsk_rx_fillin; - s->rx_user_data = &s->v21_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); } + /*endif*/ return 0; } /*- End of function --------------------------------------------------------*/ @@ -148,6 +208,24 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int le } /*- End of function --------------------------------------------------------*/ +static void v29_rx_status_handler(void *user_data, int status) +{ + fax_modems_state_t *s; + + s = (fax_modems_state_t *) user_data; + switch (status) + { + case SIG_STATUS_TRAINING_SUCCEEDED: + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &v29_rx, &s->fast_modems.v29_rx, (span_rx_fillin_handler_t) &v29_rx_fillin, &s->fast_modems.v29_rx); + v29_rx_set_modem_status_handler(&s->fast_modems.v29_rx, NULL, s); + break; + } + /*endswitch*/ + s->fast_modems.v29_rx.put_bit(s->fast_modems.v29_rx.put_bit_user_data, status); +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len) { fax_modems_state_t *s; @@ -157,13 +235,11 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx(void *user_data, const int16_t am fsk_rx(&s->v21_rx, amp, len); if (s->rx_frame_received) { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ + /* We have received something, and the fast modem has not trained. We must be receiving valid V.21 */ span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - s->rx_handler = (span_rx_handler_t *) &fsk_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &fsk_rx_fillin; - s->rx_user_data = &s->v21_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); } + /*endif*/ return 0; } /*- End of function --------------------------------------------------------*/ @@ -179,80 +255,202 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len) } /*- End of function --------------------------------------------------------*/ -static void v21_rx_status_handler(void *user_data, int status) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void v17_rx_status_handler(void *user_data, int status) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; - switch (status) - { - case SIG_STATUS_TRAINING_SUCCEEDED: - span_log(&s->logging, SPAN_LOG_FLOW, "Switching to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - s->rx_handler = (span_rx_handler_t *) &v17_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &v17_rx_fillin; - s->rx_user_data = &s->fast_modems.v17_rx; - break; - } -} -/*- End of function --------------------------------------------------------*/ - -static void v27ter_rx_status_handler(void *user_data, int status) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; - switch (status) - { - case SIG_STATUS_TRAINING_SUCCEEDED: - span_log(&s->logging, SPAN_LOG_FLOW, "Switching to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - s->rx_handler = (span_rx_handler_t *) &v27ter_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &v27ter_rx_fillin; - s->rx_user_data = &s->fast_modems.v27ter_rx; - break; - } -} -/*- End of function --------------------------------------------------------*/ - -static void v29_rx_status_handler(void *user_data, int status) -{ - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; - switch (status) - { - case SIG_STATUS_TRAINING_SUCCEEDED: - span_log(&s->logging, SPAN_LOG_FLOW, "Switching to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - s->rx_handler = (span_rx_handler_t *) &v29_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &v29_rx_fillin; - s->rx_user_data = &s->fast_modems.v29_rx; - break; - } -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) fax_modems_start_rx_modem(fax_modems_state_t *s, int which) +SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which) { switch (which) { - case FAX_MODEM_V17_RX: - v17_rx_set_modem_status_handler(&s->fast_modems.v17_rx, v17_rx_status_handler, s); + case FAX_MODEM_V21_RX: + 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); + fsk_rx_signal_cutoff(&s->v21_rx, -39.09f); + //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); + s->rx_frame_received = FALSE; break; - case FAX_MODEM_V27TER_RX: - v27ter_rx_set_modem_status_handler(&s->fast_modems.v27ter_rx, v27ter_rx_status_handler, s); - break; - case FAX_MODEM_V29_RX: - v29_rx_set_modem_status_handler(&s->fast_modems.v29_rx, v29_rx_status_handler, s); + case FAX_MODEM_V21_TX: + fsk_tx_init(&s->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &s->hdlc_tx); break; } - fsk_rx_set_modem_status_handler(&s->v21_rx, v21_rx_status_handler, s); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, int bit_rate, int short_train, int hdlc_mode) +{ + put_bit_func_t put_bit; + get_bit_func_t get_bit; + void *get_bit_user_data; + void *put_bit_user_data; + + s->bit_rate = bit_rate; + if (hdlc_mode) + { + get_bit = (get_bit_func_t) hdlc_tx_get_bit; + 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; + } + else + { + get_bit = s->get_bit; + get_bit_user_data = s->get_bit_user_data; + put_bit = s->put_bit; + put_bit_user_data = s->put_bit_user_data; + } + /*endif*/ + + /* If we change modems we need to do a complete reinitialisation of the modem, because + the modems use overlapping memory. */ + if (s->fast_modem != 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: + v27ter_rx_init(&s->fast_modems.v27ter_rx, s->bit_rate, put_bit, put_bit_user_data); + v27ter_rx_set_modem_status_handler(&s->fast_modems.v27ter_rx, v27ter_rx_status_handler, s); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v27ter_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v27ter_v21_rx_fillin, s); + break; + case FAX_MODEM_V29_RX: + v29_rx_init(&s->fast_modems.v29_rx, s->bit_rate, put_bit, put_bit_user_data); + v29_rx_signal_cutoff(&s->fast_modems.v29_rx, -45.5f); + v29_rx_set_modem_status_handler(&s->fast_modems.v29_rx, v29_rx_status_handler, s); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v29_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v29_v21_rx_fillin, s); + break; + case FAX_MODEM_V17_RX: + v17_rx_init(&s->fast_modems.v17_rx, s->bit_rate, put_bit, put_bit_user_data); + v17_rx_set_modem_status_handler(&s->fast_modems.v17_rx, v17_rx_status_handler, s); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v17_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v17_v21_rx_fillin, s); + break; + case FAX_MODEM_V27TER_TX: + v27ter_tx_init(&s->fast_modems.v27ter_tx, s->bit_rate, s->use_tep, get_bit, get_bit_user_data); + fax_modems_set_tx_handler(s, (span_tx_handler_t) &v27ter_tx, &s->fast_modems.v27ter_tx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; + case FAX_MODEM_V29_TX: + v29_tx_init(&s->fast_modems.v29_tx, s->bit_rate, s->use_tep, get_bit, get_bit_user_data); + fax_modems_set_tx_handler(s, (span_tx_handler_t) &v29_tx, &s->fast_modems.v29_tx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; + case FAX_MODEM_V17_TX: + v17_tx_init(&s->fast_modems.v17_tx, s->bit_rate, s->use_tep, get_bit, get_bit_user_data); + 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; + } + /*endswitch*/ + } + else + { + s->short_train = short_train; + switch (s->fast_modem) + { + case FAX_MODEM_V27TER_RX: + v27ter_rx_restart(&s->fast_modems.v27ter_rx, s->bit_rate, FALSE); + v27ter_rx_set_put_bit(&s->fast_modems.v27ter_rx, put_bit, put_bit_user_data); + v27ter_rx_set_modem_status_handler(&s->fast_modems.v27ter_rx, v27ter_rx_status_handler, s); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v27ter_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v27ter_v21_rx_fillin, s); + break; + case FAX_MODEM_V29_RX: + v29_rx_restart(&s->fast_modems.v29_rx, s->bit_rate, FALSE); + v29_rx_set_put_bit(&s->fast_modems.v29_rx, put_bit, put_bit_user_data); + v29_rx_set_modem_status_handler(&s->fast_modems.v29_rx, v29_rx_status_handler, s); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v29_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v29_v21_rx_fillin, s); + break; + case FAX_MODEM_V17_RX: + v17_rx_restart(&s->fast_modems.v17_rx, s->bit_rate, s->short_train); + v17_rx_set_put_bit(&s->fast_modems.v17_rx, put_bit, put_bit_user_data); + v17_rx_set_modem_status_handler(&s->fast_modems.v17_rx, v17_rx_status_handler, s); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fax_modems_v17_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v17_v21_rx_fillin, s); + break; + case FAX_MODEM_V27TER_TX: + v27ter_tx_restart(&s->fast_modems.v27ter_tx, s->bit_rate, s->use_tep); + v27ter_tx_set_get_bit(&s->fast_modems.v27ter_tx, get_bit, get_bit_user_data); + fax_modems_set_tx_handler(s, (span_tx_handler_t) &v27ter_tx, &s->fast_modems.v27ter_tx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; + case FAX_MODEM_V29_TX: + v29_tx_restart(&s->fast_modems.v29_tx, s->bit_rate, s->use_tep); + v29_tx_set_get_bit(&s->fast_modems.v29_tx, get_bit, get_bit_user_data); + fax_modems_set_tx_handler(s, (span_tx_handler_t) &v29_tx, &s->fast_modems.v29_tx); + fax_modems_set_next_tx_handler(s, (span_tx_handler_t) NULL, NULL); + break; + case FAX_MODEM_V17_TX: + v17_tx_restart(&s->fast_modems.v17_tx, s->bit_rate, s->use_tep, s->short_train); + v17_tx_set_get_bit(&s->fast_modems.v17_tx, get_bit, get_bit_user_data); + 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; + } + /*endswitch*/ + } + /*endif*/ +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_set_put_bit(fax_modems_state_t *s, put_bit_func_t put_bit, void *user_data) +{ + s->put_bit = put_bit; + s->put_bit_user_data = user_data; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_set_get_bit(fax_modems_state_t *s, get_bit_func_t get_bit, void *user_data) +{ + s->get_bit = get_bit; + s->get_bit_user_data = user_data; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_set_rx_handler(fax_modems_state_t *s, + span_rx_handler_t rx_handler, + void *rx_user_data, + span_rx_fillin_handler_t rx_fillin_handler, + void *rx_fillin_user_data) +{ + if (s->deferred_rx_handler_updates) + { + /* Only update the actual handlers if they are not currently sidelined to dummy targets */ + if (s->rx_handler != span_dummy_rx) + s->rx_handler = rx_handler; + /*endif*/ + s->base_rx_handler = rx_handler; + + if (s->rx_fillin_handler != span_dummy_rx_fillin) + s->rx_fillin_handler = rx_fillin_handler; + /*endif*/ + s->base_rx_fillin_handler = rx_fillin_handler; + } + else + { + s->rx_handler = rx_handler; + s->rx_fillin_handler = rx_fillin_handler; + } + /*endif*/ + s->rx_user_data = rx_user_data; + s->rx_fillin_user_data = rx_fillin_user_data; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_set_rx_active(fax_modems_state_t *s, int active) +{ + s->rx_handler = (active) ? s->base_rx_handler : span_dummy_rx; + s->rx_fillin_handler = (active) ? s->base_rx_fillin_handler : span_dummy_rx_fillin; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_set_tx_handler(fax_modems_state_t *s, span_tx_handler_t handler, void *user_data) +{ + s->tx_handler = handler; + s->tx_user_data = user_data; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) fax_modems_set_next_tx_handler(fax_modems_state_t *s, span_tx_handler_t handler, void *user_data) +{ + s->next_tx_handler = handler; + s->next_tx_user_data = user_data; } /*- End of function --------------------------------------------------------*/ @@ -288,22 +486,10 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s, if ((s = (fax_modems_state_t *) malloc(sizeof(*s))) == NULL) return NULL; } + /*endif*/ memset(s, 0, sizeof(*s)); s->use_tep = use_tep; - hdlc_rx_init(&s->hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, user_data); - hdlc_tx_init(&s->hdlc_tx, FALSE, 2, FALSE, hdlc_tx_underflow, user_data); - 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); - fsk_rx_signal_cutoff(&s->v21_rx, -39.09f); - fsk_tx_init(&s->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &s->hdlc_tx); - v17_rx_init(&s->fast_modems.v17_rx, 14400, non_ecm_put_bit, user_data); - v17_tx_init(&s->fast_modems.v17_tx, 14400, s->use_tep, non_ecm_get_bit, user_data); - v29_rx_init(&s->fast_modems.v29_rx, 9600, non_ecm_put_bit, user_data); - v29_rx_signal_cutoff(&s->fast_modems.v29_rx, -45.5f); - v29_tx_init(&s->fast_modems.v29_tx, 9600, s->use_tep, non_ecm_get_bit, user_data); - v27ter_rx_init(&s->fast_modems.v27ter_rx, 4800, non_ecm_put_bit, user_data); - v27ter_tx_init(&s->fast_modems.v27ter_tx, 4800, s->use_tep, non_ecm_get_bit, user_data); - silence_gen_init(&s->silence_gen, 0); modem_connect_tones_tx_init(&s->connect_tx, MODEM_CONNECT_TONES_FAX_CNG); if (tone_callback) { @@ -312,13 +498,34 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s, tone_callback, user_data); } + /*endif*/ + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "FAX modems"); + dc_restore_init(&s->dc_restore); + s->get_bit = non_ecm_get_bit; + s->get_bit_user_data = user_data; + s->put_bit = non_ecm_put_bit; + s->put_bit_user_data = user_data; + + s->hdlc_accept = hdlc_accept; + s->hdlc_accept_user_data = user_data; + + hdlc_rx_init(&s->hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s); + hdlc_tx_init(&s->hdlc_tx, FALSE, 2, FALSE, hdlc_tx_underflow, user_data); + + fax_modems_start_slow_modem(s, FAX_MODEM_V21_RX); + fsk_tx_init(&s->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &s->hdlc_tx); + + silence_gen_init(&s->silence_gen, 0); + s->rx_signal_present = FALSE; - s->rx_handler = (span_rx_handler_t *) &span_dummy_rx; - s->rx_fillin_handler = (span_rx_fillin_handler_t *) &span_dummy_rx; + s->rx_handler = (span_rx_handler_t) &span_dummy_rx; + s->rx_fillin_handler = (span_rx_fillin_handler_t) &span_dummy_rx; s->rx_user_data = NULL; - s->tx_handler = (span_tx_handler_t *) &silence_gen; + s->rx_fillin_user_data = NULL; + s->tx_handler = (span_tx_handler_t) &silence_gen; s->tx_user_data = &s->silence_gen; return s; } @@ -334,6 +541,7 @@ SPAN_DECLARE(int) fax_modems_free(fax_modems_state_t *s) { if (s) free(s); + /*endif*/ return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/fsk.c b/libs/spandsp/src/fsk.c index 19941637c0..3f53aa7bc8 100644 --- a/libs/spandsp/src/fsk.c +++ b/libs/spandsp/src/fsk.c @@ -70,16 +70,16 @@ const fsk_spec_t preset_fsk_specs[] = }, { "V23 ch 1", - 2100, - 1300, + 1700 + 400, + 1700 - 400, -14, -30, 1200*100 }, { "V23 ch 2", - 450, - 390, + 420 + 30, + 420 - 30, -14, -30, 75*100 @@ -102,27 +102,35 @@ const fsk_spec_t preset_fsk_specs[] = }, { "Bell202", - 2200, - 1200, + 1700 + 500, + 1700 - 500, -14, -30, 1200*100 }, { - "Weitbrecht 45.45", /* Used for TDD (Telecoms Device for the Deaf) */ - 1800, - 1400, + "Weitbrecht 45.45", /* Used for US TDD (Telecoms Device for the Deaf) */ + 1600 + 200, + 1600 - 200, -14, -30, 4545 }, { - "Weitbrecht 50", /* Used for TDD (Telecoms Device for the Deaf) */ - 1800, - 1400, + "Weitbrecht 50", /* Used for Internatioal TDD (Telecoms Device for the Deaf) */ + 1600 + 200, + 1600 - 200, -14, -30, - 5000 + 50*100 + }, + { + "V21 (110bps) ch 1", + 1080 + 100, + 1080 - 100, + -14, + -30, + 110*100 } }; @@ -476,6 +484,10 @@ SPAN_DECLARE_NONSTD(int) fsk_rx(fsk_rx_state_t *s, const int16_t *amp, int len) s->put_bit(s->put_bit_user_data, baudstate); } break; + case FSK_FRAME_MODE_5N1_FRAMES: + case FSK_FRAME_MODE_7N1_FRAMES: + case FSK_FRAME_MODE_7E1_FRAMES: + case FSK_FRAME_MODE_7E2_FRAMES: default: /* Gather the specified number of bits, with robust checking to ensure reasonable voice immunity. The first bit should be a start bit (0), and the last bit should be a stop bit (1) */ @@ -527,24 +539,22 @@ SPAN_DECLARE_NONSTD(int) fsk_rx(fsk_rx_state_t *s, const int16_t *amp, int len) state as the next bit */ if (s->last_bit == baudstate) { - s->frame_bits |= (baudstate << s->framing_mode); - s->frame_bits >>= 1; - s->baud_phase -= (SAMPLE_RATE*100); if (++s->frame_state > s->framing_mode) { - /* Check we have a stop bit */ - if (baudstate == 1) + /* Check we have a stop bit and a start bit */ + if (baudstate == 1 && (s->frame_bits & 0x02) == 0) { - /* Check we have a start bit */ - if ((s->frame_bits & 1) == 0) - { - /* Drop the start bit, and pass the rest back */ - s->frame_bits >>= 1; - s->put_bit(s->put_bit_user_data, s->frame_bits); - } + /* Drop the start bit, and pass the rest back */ + s->put_bit(s->put_bit_user_data, s->frame_bits >> 2); } s->frame_state = 0; } + else + { + s->frame_bits |= (baudstate << s->framing_mode); + s->frame_bits >>= 1; + } + s->baud_phase -= (SAMPLE_RATE*100); } else { diff --git a/libs/spandsp/src/g711.c b/libs/spandsp/src/g711.c index 17403d8f92..173bd2ae53 100644 --- a/libs/spandsp/src/g711.c +++ b/libs/spandsp/src/g711.c @@ -172,7 +172,7 @@ SPAN_DECLARE(g711_state_t *) g711_init(g711_state_t *s, int mode) if (s == NULL) { if ((s = (g711_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; + return NULL; } s->mode = mode; return s; diff --git a/libs/spandsp/src/g726.c b/libs/spandsp/src/g726.c index 2bf1236d80..f4a9127a92 100644 --- a/libs/spandsp/src/g726.c +++ b/libs/spandsp/src/g726.c @@ -67,7 +67,6 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" -#include "spandsp/dc_restore.h" #include "spandsp/bitstream.h" #include "spandsp/bit_operations.h" #include "spandsp/g711.h" @@ -1004,7 +1003,7 @@ SPAN_DECLARE(g726_state_t *) g726_init(g726_state_t *s, int bit_rate, int ext_co if (s == NULL) { if ((s = (g726_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; + return NULL; } s->yl = 34816; s->yu = 544; diff --git a/libs/spandsp/src/gsm0610_encode.c b/libs/spandsp/src/gsm0610_encode.c index 10a27540df..c49ed1e93b 100644 --- a/libs/spandsp/src/gsm0610_encode.c +++ b/libs/spandsp/src/gsm0610_encode.c @@ -116,7 +116,7 @@ SPAN_DECLARE(gsm0610_state_t *) gsm0610_init(gsm0610_state_t *s, int packing) if (s == NULL) { if ((s = (gsm0610_state_t *) malloc(sizeof (*s))) == NULL) - return NULL; + return NULL; /*endif*/ } /*endif*/ diff --git a/libs/spandsp/src/gsm0610_long_term.c b/libs/spandsp/src/gsm0610_long_term.c index d257832526..32d4ab39b7 100644 --- a/libs/spandsp/src/gsm0610_long_term.c +++ b/libs/spandsp/src/gsm0610_long_term.c @@ -321,10 +321,10 @@ static int16_t evaluate_ltp_parameters(int16_t d[40], /* Normalization of L_max and L_power */ if (L_max <= 0) - return 0; + return 0; /*endif*/ if (L_max >= L_power) - return 3; + return 3; /*endif*/ temp = gsm0610_norm(L_power); diff --git a/libs/spandsp/src/gsm0610_lpc.c b/libs/spandsp/src/gsm0610_lpc.c index 4b2c553d87..aa1ab08e86 100644 --- a/libs/spandsp/src/gsm0610_lpc.c +++ b/libs/spandsp/src/gsm0610_lpc.c @@ -78,7 +78,7 @@ int16_t gsm0610_norm(int32_t x) if (x < 0) { if (x <= -1073741824) - return 0; + return 0; /*endif*/ x = ~x; } @@ -108,7 +108,7 @@ static int16_t gsm_div(int16_t num, int16_t denom) assert(num >= 0 && denom >= num); if (num == 0) - return 0; + return 0; /*endif*/ num32 = num; denom32 = denom; @@ -128,7 +128,7 @@ static int16_t gsm_div(int16_t num, int16_t denom) } /*endwhile*/ - return div; + return div; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/hdlc.c b/libs/spandsp/src/hdlc.c index fc401fb5d1..951b44eb7c 100644 --- a/libs/spandsp/src/hdlc.c +++ b/libs/spandsp/src/hdlc.c @@ -154,7 +154,8 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) s->rx_frames++; s->rx_bytes += s->len - s->crc_bytes; s->len -= s->crc_bytes; - s->frame_handler(s->frame_user_data, s->buffer, s->len, TRUE); + if (s->frame_handler) + s->frame_handler(s->frame_user_data, s->buffer, s->len, TRUE); } else { @@ -162,7 +163,8 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) if (s->report_bad_frames) { s->len -= s->crc_bytes; - s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE); + if (s->frame_handler) + s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE); } } } @@ -177,7 +179,8 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s) s->len -= s->crc_bytes; else s->len = 0; - s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE); + if (s->frame_handler) + s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE); } s->rx_length_errors++; } @@ -555,7 +558,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_bit(hdlc_tx_state_t *s) } s->bits--; txbit = (s->byte >> s->bits) & 0x01; - return txbit; + return txbit; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/ima_adpcm.c b/libs/spandsp/src/ima_adpcm.c index 299d0d1137..6c4cc16370 100644 --- a/libs/spandsp/src/ima_adpcm.c +++ b/libs/spandsp/src/ima_adpcm.c @@ -283,13 +283,13 @@ SPAN_DECLARE(ima_adpcm_state_t *) ima_adpcm_init(ima_adpcm_state_t *s, if (s == NULL) { if ((s = (ima_adpcm_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; + return NULL; } /*endif*/ memset(s, 0, sizeof(*s)); s->variant = variant; s->chunk_size = chunk_size; - return s; + return s; } /*- End of function --------------------------------------------------------*/ @@ -503,7 +503,7 @@ SPAN_DECLARE(int) ima_adpcm_encode(ima_adpcm_state_t *s, break; } /*endswitch*/ - return bytes; + return bytes; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/image_translate.c b/libs/spandsp/src/image_translate.c index beba3dab07..e07421269a 100644 --- a/libs/spandsp/src/image_translate.c +++ b/libs/spandsp/src/image_translate.c @@ -2,8 +2,9 @@ * SpanDSP - a series of DSP components for telephony * * image_translate.c - Image translation routines for reworking colour - * and gray scale images to be bi-level images of an - * appropriate size to be FAX compatible. + * and gray scale images to be colour, gray scale or + * bi-level images of an appropriate size to be FAX + * compatible. * * Written by Steve Underwood * @@ -57,15 +58,9 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -74,104 +69,270 @@ #include "spandsp/image_translate.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" -#include "spandsp/private/image_translate.h" -static int image_colour16_to_gray8_row(uint8_t mono[], uint16_t colour[], int pixels) +static int image_colour16_to_colour8_row(uint8_t colour8[], uint16_t colour16[], int pixels) +{ + int i; + + for (i = 0; i < 3*pixels; i++) + colour8[i] = colour16[i] >> 8; + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_colour16_to_gray16_row(uint16_t gray16[], uint16_t colour16[], int pixels) { int i; uint32_t gray; for (i = 0; i < pixels; i++) { - gray = colour[3*i]*19595 + colour[3*i + 1]*38469 + colour[3*i + 2]*7472; - mono[i] = saturateu8(gray >> 24); + gray = colour16[3*i]*19595 + colour16[3*i + 1]*38469 + colour16[3*i + 2]*7472; + gray16[i] = saturateu16(gray >> 16); } return pixels; } /*- End of function --------------------------------------------------------*/ -static int image_colour8_to_gray8_row(uint8_t mono[], uint8_t colour[], int pixels) +static int image_colour16_to_gray8_row(uint8_t gray8[], uint16_t colour16[], int pixels) { int i; uint32_t gray; for (i = 0; i < pixels; i++) { - gray = colour[3*i]*19595 + colour[3*i + 1]*38469 + colour[3*i + 2]*7472; - mono[i] = saturateu8(gray >> 16); + gray = colour16[3*i]*19595 + colour16[3*i + 1]*38469 + colour16[3*i + 2]*7472; + gray8[i] = saturateu8(gray >> 24); } return pixels; } /*- End of function --------------------------------------------------------*/ -static int image_gray16_to_gray8_row(uint8_t mono[], uint16_t gray[], int pixels) +static int image_colour8_to_gray16_row(uint16_t gray16[], uint8_t colour8[], int pixels) { int i; + uint32_t gray; for (i = 0; i < pixels; i++) - mono[i] = gray[i] >> 8; + { + gray = colour8[3*i]*19595 + colour8[3*i + 1]*38469 + colour8[3*i + 2]*7472; + gray16[i] = saturateu16(gray >> 8); + } return pixels; } /*- End of function --------------------------------------------------------*/ -static int get_and_scrunch_row(image_translate_state_t *s, uint8_t buf[], size_t len) +static int image_colour8_to_gray8_row(uint8_t gray8[], uint8_t colour8[], int pixels) { - int row_len; + int i; + uint32_t gray; - row_len = (*s->row_read_handler)(s->row_read_user_data, buf, s->input_width*s->bytes_per_pixel); - if (row_len != s->input_width*s->bytes_per_pixel) + for (i = 0; i < pixels; i++) + { + gray = colour8[3*i]*19595 + colour8[3*i + 1]*38469 + colour8[3*i + 2]*7472; + gray8[i] = saturateu8(gray >> 16); + } + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_colour8_to_colour16_row(uint16_t colour16[], uint8_t colour8[], int pixels) +{ + int i; + + for (i = 3*pixels - 1; i >= 0; i--) + colour16[i] = colour8[i] << 8; + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_gray16_to_colour16_row(uint16_t colour16[], uint16_t gray16[], int pixels) +{ + int i; + + for (i = pixels - 1; i >= 0; i--) + { + colour16[3*i] = saturateu16((gray16[i]*36532U) >> 15); + colour16[3*i + 1] = saturateu16((gray16[i]*37216U) >> 16); + colour16[3*i + 2] = saturateu16((gray16[i]*47900U) >> 14); + } + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_gray16_to_colour8_row(uint8_t colour8[], uint16_t gray16[], int pixels) +{ + int i; + + for (i = pixels - 1; i >= 0; i--) + { + colour8[3*i] = saturateu8((gray16[i]*36532U) >> 23); + colour8[3*i + 1] = saturateu8((gray16[i]*37216U) >> 24); + colour8[3*i + 2] = saturateu8((gray16[i]*47900U) >> 22); + } + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_gray16_to_gray8_row(uint8_t gray8[], uint16_t gray16[], int pixels) +{ + int i; + + for (i = 0; i < pixels; i++) + gray8[i] = gray16[i] >> 8; + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_gray8_to_colour16_row(uint16_t colour16[], uint8_t gray8[], int pixels) +{ + int i; + + for (i = pixels - 1; i >= 0; i--) + { + /* TODO: need to balance the colours */ + colour16[3*i] = gray8[i] << 8; + colour16[3*i + 1] = gray8[i] << 8; + colour16[3*i + 2] = gray8[i] << 8; + } + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_gray8_to_colour8_row(uint8_t colour8[], uint8_t gray8[], int pixels) +{ + int i; + + for (i = pixels - 1; i >= 0; i--) + { + /* TODO: need to balance the colours */ + colour8[3*i] = gray8[i]; + colour8[3*i + 1] = gray8[i]; + colour8[3*i + 2] = gray8[i]; + } + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int image_gray8_to_gray16_row(uint16_t gray16[], uint8_t gray8[], int pixels) +{ + int i; + + for (i = pixels - 1; i >= 0; i--) + gray16[i] = gray8[i] << 8; + return pixels; +} +/*- End of function --------------------------------------------------------*/ + +static int get_and_scrunch_row(image_translate_state_t *s, uint8_t buf[]) +{ + int input_row_len; + + input_row_len = (*s->row_read_handler)(s->row_read_user_data, buf, s->input_width*s->input_bytes_per_pixel); + if (input_row_len != s->input_width*s->input_bytes_per_pixel) return 0; - /* Scrunch colour down to gray, and scrunch 16 bit pixels down to 8 bit pixels */ + /* Scrunch colour down to gray, vice versa. Scrunch 16 bit pixels down to 8 bit pixels, or vice versa. */ switch (s->input_format) { - case IMAGE_TRANSLATE_FROM_GRAY_16: - image_gray16_to_gray8_row(buf, (uint16_t *) buf, s->input_width); + case T4_IMAGE_TYPE_GRAY_12BIT: + switch (s->output_format) + { + case T4_IMAGE_TYPE_BILEVEL: + case T4_IMAGE_TYPE_GRAY_8BIT: + image_gray16_to_gray8_row(buf, (uint16_t *) buf, s->input_width); + break; + case T4_IMAGE_TYPE_COLOUR_12BIT: + image_gray16_to_colour16_row((uint16_t *) buf, (uint16_t *) buf, s->input_width); + break; + case T4_IMAGE_TYPE_COLOUR_8BIT: + image_gray16_to_colour8_row(buf, (uint16_t *) buf, s->input_width); + break; + } break; - case IMAGE_TRANSLATE_FROM_COLOUR_16: - image_colour16_to_gray8_row(buf, (uint16_t *) buf, s->input_width); + case T4_IMAGE_TYPE_GRAY_8BIT: + switch (s->output_format) + { + case T4_IMAGE_TYPE_GRAY_12BIT: + image_gray8_to_gray16_row((uint16_t *) buf, buf, s->input_width); + break; + case T4_IMAGE_TYPE_COLOUR_12BIT: + image_gray8_to_colour16_row((uint16_t *) buf, buf, s->input_width); + break; + case T4_IMAGE_TYPE_COLOUR_8BIT: + image_gray8_to_colour8_row(buf, buf, s->input_width); + break; + } break; - case IMAGE_TRANSLATE_FROM_COLOUR_8: - image_colour8_to_gray8_row(buf, buf, s->input_width); + case T4_IMAGE_TYPE_COLOUR_12BIT: + switch (s->output_format) + { + case T4_IMAGE_TYPE_GRAY_12BIT: + image_colour16_to_gray16_row((uint16_t *) buf, (uint16_t *) buf, s->input_width); + break; + case T4_IMAGE_TYPE_BILEVEL: + case T4_IMAGE_TYPE_GRAY_8BIT: + image_colour16_to_gray8_row(buf, (uint16_t *) buf, s->input_width); + break; + case T4_IMAGE_TYPE_COLOUR_8BIT: + image_colour16_to_colour8_row(buf, (uint16_t *) buf, s->input_width); + break; + } + break; + case T4_IMAGE_TYPE_COLOUR_8BIT: + switch (s->output_format) + { + case T4_IMAGE_TYPE_GRAY_12BIT: + image_colour8_to_gray16_row((uint16_t *) buf, buf, s->input_width); + break; + case T4_IMAGE_TYPE_BILEVEL: + case T4_IMAGE_TYPE_GRAY_8BIT: + image_colour8_to_gray8_row(buf, buf, s->input_width); + break; + case T4_IMAGE_TYPE_COLOUR_12BIT: + image_colour8_to_colour16_row((uint16_t *) buf, buf, s->input_width); + break; + } break; } - return row_len; + return s->output_width; } /*- End of function --------------------------------------------------------*/ -static int image_resize_row(image_translate_state_t *s, uint8_t buf[], size_t len) +static int image_resize_row(image_translate_state_t *s, uint8_t buf[]) { int i; + int j; int output_width; int output_length; int input_width; int input_length; int x; - double c1; - double c2; #if defined(SPANDSP_USE_FIXED_POINT) + int c1; + int c2; int frac_row; int frac_col; #else + double c1; + double c2; double int_part; double frac_row; double frac_col; #endif + uint8_t *row8[2]; + uint16_t *row16[2]; + uint16_t *buf16; int row_len; int skip; uint8_t *p; @@ -194,8 +355,8 @@ static int image_resize_row(image_translate_state_t *s, uint8_t buf[], size_t le s->raw_output_row = -1; break; } - row_len = get_and_scrunch_row(s, s->raw_pixel_row[0], s->input_width*s->bytes_per_pixel); - if (row_len != s->input_width*s->bytes_per_pixel) + row_len = get_and_scrunch_row(s, s->raw_pixel_row[0]); + if (row_len != s->output_width) { s->raw_output_row = -1; return 0; @@ -208,30 +369,118 @@ static int image_resize_row(image_translate_state_t *s, uint8_t buf[], size_t le } #if defined(SPANDSP_USE_FIXED_POINT) - frac_row = s->raw_output_row*input_length/output_length; - frac_row = s->raw_output_row*input_length - frac_row*output_length; - for (i = 0; i < output_width; i++) - { - x = i*input_width/output_width; - frac_col = x - x*output_width; - c1 = s->raw_pixel_row[0][x] + (s->raw_pixel_row[0][x + 1] - s->raw_pixel_row[0][x])*frac_col; - c2 = s->raw_pixel_row[1][x] + (s->raw_pixel_row[1][x + 1] - s->raw_pixel_row[1][x])*frac_col; - buf[i] = saturateu8(c1 + (c2 - c1)*frac_row); - } + frac_row = ((s->raw_output_row*256*input_length)/output_length) & 0xFF; #else frac_row = modf((double) s->raw_output_row*input_length/output_length, &int_part); - for (i = 0; i < output_width; i++) - { - frac_col = modf((double) i*input_width/output_width, &int_part); - x = int_part; - c1 = s->raw_pixel_row[0][x] + (s->raw_pixel_row[0][x + 1] - s->raw_pixel_row[0][x])*frac_col; - c2 = s->raw_pixel_row[1][x] + (s->raw_pixel_row[1][x + 1] - s->raw_pixel_row[1][x])*frac_col; - buf[i] = saturateu8(c1 + (c2 - c1)*frac_row); - } #endif + + switch (s->output_format) + { + case T4_IMAGE_TYPE_COLOUR_8BIT: + row8[0] = s->raw_pixel_row[0]; + row8[1] = s->raw_pixel_row[1]; + for (i = 0; i < output_width; i++) + { +#if defined(SPANDSP_USE_FIXED_POINT) + x = i*256*input_width/output_width; + frac_col = x & 0xFF; + x >>= 8; + x = 3*x; + for (j = 0; j < 3; j++) + { + c1 = row8[0][x + j] + (((row8[0][x + j + 3] - row8[0][x + j])*frac_col) >> 8); + c2 = row8[1][x + j] + (((row8[1][x + j + 3] - row8[1][x + j])*frac_col) >> 8); + buf[3*i + j] = saturateu8(c1 + (((c2 - c1)*frac_row) >> 8)); + } +#else + frac_col = modf((double) i*input_width/output_width, &int_part); + x = 3*int_part; + for (j = 0; j < 3; j++) + { + c1 = row8[0][x + j] + (row8[0][x + j + 3] - row8[0][x + j])*frac_col; + c2 = row8[1][x + j] + (row8[1][x + j + 3] - row8[1][x + j])*frac_col; + buf[3*i + j] = saturateu8(c1 + (c2 - c1)*frac_row); + } +#endif + } + break; + case T4_IMAGE_TYPE_COLOUR_12BIT: + row16[0] = (uint16_t *) s->raw_pixel_row[0]; + row16[1] = (uint16_t *) s->raw_pixel_row[1]; + buf16 = (uint16_t *) buf; + for (i = 0; i < output_width; i++) + { +#if defined(SPANDSP_USE_FIXED_POINT) + x = i*256*input_width/output_width; + frac_col = x & 0xFF; + x >>= 8; + x = 3*x; + for (j = 0; j < 3; j++) + { + c1 = row16[0][x + j] + (((row16[0][x + j + 3] - row16[0][x + j])*frac_col) >> 8); + c2 = row16[1][x + j] + (((row16[1][x + j + 3] - row16[1][x + j])*frac_col) >> 8); + buf16[3*i + j] = saturateu16(c1 + (((c2 - c1)*frac_row) >> 8)); + } +#else + frac_col = modf((double) i*input_width/output_width, &int_part); + x = 3*int_part; + for (j = 0; j < 3; j++) + { + c1 = row16[0][x + j] + (row16[0][x + j + 3] - row16[0][x + j])*frac_col; + c2 = row16[1][x + j] + (row16[1][x + j + 3] - row16[1][x + j])*frac_col; + buf16[3*i + j] = saturateu16(c1 + (c2 - c1)*frac_row); + } +#endif + } + break; + case T4_IMAGE_TYPE_BILEVEL: + case T4_IMAGE_TYPE_GRAY_8BIT: + row8[0] = s->raw_pixel_row[0]; + row8[1] = s->raw_pixel_row[1]; + for (i = 0; i < output_width; i++) + { +#if defined(SPANDSP_USE_FIXED_POINT) + x = i*256*input_width/output_width; + frac_col = x & 0xFF; + x >>= 8; + c1 = row8[0][x] + (((row8[0][x + 1] - row8[0][x])*frac_col) >> 8); + c2 = row8[1][x] + (((row8[1][x + 1] - row8[1][x])*frac_col) >> 8); + buf[i] = saturateu8(c1 + (((c2 - c1)*frac_row) >> 8)); +#else + frac_col = modf((double) i*input_width/output_width, &int_part); + x = int_part; + c1 = row8[0][x] + (row8[0][x + 1] - row8[0][x])*frac_col; + c2 = row8[1][x] + (row8[1][x + 1] - row8[1][x])*frac_col; + buf[i] = saturateu8(c1 + (c2 - c1)*frac_row); +#endif + } + break; + case T4_IMAGE_TYPE_GRAY_12BIT: + row16[0] = (uint16_t *) s->raw_pixel_row[0]; + row16[1] = (uint16_t *) s->raw_pixel_row[1]; + buf16 = (uint16_t *) buf; + for (i = 0; i < output_width; i++) + { +#if defined(SPANDSP_USE_FIXED_POINT) + x = i*256*input_width/output_width; + frac_col = x & 0xFF; + x >>= 8; + c1 = row16[0][x] + (((row16[0][x + 1] - row16[0][x])*frac_col) >> 8); + c2 = row16[1][x] + (((row16[1][x + 1] - row16[1][x])*frac_col) >> 8); + buf[i] = saturateu8(c1 + (((c2 - c1)*frac_row) >> 8)); +#else + frac_col = modf((double) i*input_width/output_width, &int_part); + x = int_part; + c1 = row16[0][x] + (row16[0][x + 1] - row16[0][x])*frac_col; + c2 = row16[1][x] + (row16[1][x + 1] - row16[1][x])*frac_col; + buf[i] = saturateu8(c1 + (c2 - c1)*frac_row); +#endif + } + break; + } if (++s->raw_output_row >= s->output_length) s->raw_output_row = -1; - return len; + return s->output_width; } /*- End of function --------------------------------------------------------*/ @@ -241,7 +490,7 @@ static __inline__ uint8_t find_closest_palette_color(int in) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], size_t len) +static int floyd_steinberg_dither_row(image_translate_state_t *s, uint8_t buf[]) { int x; int y; @@ -251,11 +500,9 @@ SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], int old_pixel; int new_pixel; int quant_error; - uint8_t *p; uint8_t xx; + uint8_t *p; - if (s->output_row < 0) - return 0; y = s->output_row++; /* This algorithm works over two rows, and outputs the earlier of the two. To make this work: @@ -264,6 +511,7 @@ SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], - At the last row we dither and output, without getting an extra row in. */ for (i = (y == 0) ? 0 : 1; i < 2; i++) { + /* Swap the row buffers */ p = s->pixel_row[0]; s->pixel_row[0] = s->pixel_row[1]; s->pixel_row[1] = p; @@ -273,12 +521,12 @@ SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], will fail, with the end of image condition (i.e. returning zero length) */ if (s->resize) { - if (image_resize_row(s, s->pixel_row[1], s->output_width*s->bytes_per_pixel) != s->output_width*s->bytes_per_pixel) + if (image_resize_row(s, s->pixel_row[1]) != s->output_width) s->output_row = -1; } else { - if (get_and_scrunch_row(s, s->pixel_row[1], s->output_width*s->bytes_per_pixel) != s->output_width*s->bytes_per_pixel) + if (get_and_scrunch_row(s, s->pixel_row[1]) != s->output_width) s->output_row = -1; } } @@ -359,6 +607,37 @@ SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], size_t len) +{ + int i; + + if (s->output_row < 0) + return 0; + if (s->output_format == T4_IMAGE_TYPE_BILEVEL) + { + i = floyd_steinberg_dither_row(s, buf); + } + else + { + s->output_row++; + if (s->resize) + { + if (image_resize_row(s, buf) != s->output_width) + s->output_row = -1; + } + else + { + if (get_and_scrunch_row(s, buf) != s->output_width) + s->output_row = -1; + } + if (s->output_row < 0) + return 0; + i = s->output_width*s->output_bytes_per_pixel; + } + return i; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(int) image_translate_get_output_width(image_translate_state_t *s) { return s->output_width; @@ -375,11 +654,15 @@ SPAN_DECLARE(image_translate_state_t *) image_translate_init(image_translate_sta int input_format, int input_width, int input_length, + int output_format, int output_width, + int output_length, t4_row_read_handler_t row_read_handler, void *row_read_user_data) { int i; + int raw_row_size; + int row_size; if (s == NULL) { @@ -389,53 +672,86 @@ SPAN_DECLARE(image_translate_state_t *) image_translate_init(image_translate_sta memset(s, 0, sizeof(*s)); s->input_format = input_format; - s->input_width = input_width; s->input_length = input_length; - s->resize = (output_width > 0); - s->output_width = (s->resize) ? output_width : s->input_width; - s->output_length = (s->resize) ? s->input_length*s->output_width/s->input_width : s->input_length; + s->output_format = output_format; + + if ((s->resize = (output_width > 0))) + { + s->output_width = output_width; + if (output_length > 0) + s->output_length = output_length; + else + s->output_length = (s->input_length*s->output_width)/s->input_width; + } + else + { + s->output_width = s->input_width; + s->output_length = s->input_length; + } switch (s->input_format) { - case IMAGE_TRANSLATE_FROM_GRAY_8: - s->bytes_per_pixel = 1; + case T4_IMAGE_TYPE_GRAY_8BIT: + s->input_bytes_per_pixel = 1; break; - case IMAGE_TRANSLATE_FROM_GRAY_16: - s->bytes_per_pixel = 2; + case T4_IMAGE_TYPE_GRAY_12BIT: + s->input_bytes_per_pixel = 2; break; - case IMAGE_TRANSLATE_FROM_COLOUR_8: - s->bytes_per_pixel = 3; + case T4_IMAGE_TYPE_COLOUR_8BIT: + s->input_bytes_per_pixel = 3; break; - case IMAGE_TRANSLATE_FROM_COLOUR_16: - s->bytes_per_pixel = 6; + case T4_IMAGE_TYPE_COLOUR_12BIT: + s->input_bytes_per_pixel = 6; break; default: - s->bytes_per_pixel = 1; + s->input_bytes_per_pixel = 1; + break; + } + + switch (s->output_format) + { + case T4_IMAGE_TYPE_GRAY_8BIT: + s->output_bytes_per_pixel = 1; + break; + case T4_IMAGE_TYPE_GRAY_12BIT: + s->output_bytes_per_pixel = 2; + break; + case T4_IMAGE_TYPE_COLOUR_8BIT: + s->output_bytes_per_pixel = 3; + break; + case T4_IMAGE_TYPE_COLOUR_12BIT: + s->output_bytes_per_pixel = 6; + break; + default: + s->output_bytes_per_pixel = 1; break; } /* Allocate the two row buffers we need, using the space requirements we now have */ + raw_row_size = s->input_width*s->input_bytes_per_pixel; + row_size = s->output_width*s->output_bytes_per_pixel; + if (raw_row_size < row_size) + raw_row_size = row_size; if (s->resize) { for (i = 0; i < 2; i++) { - if ((s->raw_pixel_row[i] = (uint8_t *) malloc(s->input_width*s->bytes_per_pixel)) == NULL) + if ((s->raw_pixel_row[i] = (uint8_t *) malloc(raw_row_size)) == NULL) return NULL; - memset(s->raw_pixel_row[i], 0, s->input_width*s->bytes_per_pixel); - if ((s->pixel_row[i] = (uint8_t *) malloc(s->output_width*sizeof(uint8_t))) == NULL) - return NULL; - memset(s->pixel_row[i], 0, s->output_width*sizeof(uint8_t)); + memset(s->raw_pixel_row[i], 0, raw_row_size); } } - else + if (s->output_format == T4_IMAGE_TYPE_BILEVEL) { + if (s->resize) + raw_row_size = row_size; for (i = 0; i < 2; i++) { - if ((s->pixel_row[i] = (uint8_t *) malloc(s->output_width*s->bytes_per_pixel)) == NULL) + if ((s->pixel_row[i] = (uint8_t *) malloc(raw_row_size)) == NULL) return NULL; - memset(s->pixel_row[i], 0, s->output_width*s->bytes_per_pixel); + memset(s->pixel_row[i], 0, raw_row_size); } } diff --git a/libs/spandsp/src/libspandsp.2005.vcproj b/libs/spandsp/src/libspandsp.2005.vcproj index 695840c9be..4ed3af322a 100644 --- a/libs/spandsp/src/libspandsp.2005.vcproj +++ b/libs/spandsp/src/libspandsp.2005.vcproj @@ -27,7 +27,7 @@ - - + - - - - - - + + + + - + + + + + - + + + - - - - - - + + + + + + - + + + + + - + + + - - + + + + + + + + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/src/libspandsp.2010.vcxproj b/libs/spandsp/src/libspandsp.2010.vcxproj index bb2ae97878..5f48082eb1 100644 --- a/libs/spandsp/src/libspandsp.2010.vcxproj +++ b/libs/spandsp/src/libspandsp.2010.vcxproj @@ -76,7 +76,7 @@ Disabled - .;..\..\src\spandsp;..\..\src;..\..\src\msvc;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + .;..\..\src\spandsp;..\..\src;..\..\src\msvc;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;..\..\jpeg-8d;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions) true EnableFastChecks @@ -97,7 +97,7 @@ $(IntDir)BuildLog $(ProjectName).htm - .;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;..\..\jpeg-8d;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions) MultiThreadedDLL Level4 @@ -118,7 +118,7 @@ Disabled - .;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;..\..\jpeg-8d;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions) true EnableFastChecks @@ -139,7 +139,7 @@ $(IntDir)BuildLog $(ProjectName).htm - .;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;..\..\jpeg-8d;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions) MultiThreadedDLL Level4 @@ -155,6 +155,7 @@ + @@ -185,6 +186,7 @@ + @@ -206,7 +208,10 @@ + + + @@ -217,6 +222,9 @@ + + + @@ -239,6 +247,7 @@ + @@ -269,6 +278,7 @@ + @@ -279,6 +289,11 @@ + + + + + @@ -287,6 +302,7 @@ + @@ -301,6 +317,8 @@ + + @@ -392,6 +410,14 @@ + + {019dbd2a-273d-4ba4-bf86-b5efe2ed76b1} + true + false + false + true + false + {401a40cd-5db4-4e34-ac68-fa99e9fac014} false diff --git a/libs/spandsp/src/libspandsp.2010.vcxproj.filters b/libs/spandsp/src/libspandsp.2010.vcxproj.filters index 2a6d60a9d4..c7d1210235 100644 --- a/libs/spandsp/src/libspandsp.2010.vcxproj.filters +++ b/libs/spandsp/src/libspandsp.2010.vcxproj.filters @@ -253,6 +253,33 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -660,6 +687,38 @@ 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/spandsp/src/libtiff.2005.vcproj b/libs/spandsp/src/libtiff.2005.vcproj index 47200e45de..94594bb42d 100644 --- a/libs/spandsp/src/libtiff.2005.vcproj +++ b/libs/spandsp/src/libtiff.2005.vcproj @@ -25,7 +25,7 @@ > @@ -302,47 +302,47 @@ Name="Header Files" > diff --git a/libs/spandsp/src/libtiff.2008.vcproj b/libs/spandsp/src/libtiff.2008.vcproj index 4bcf9340b6..a83dc87027 100644 --- a/libs/spandsp/src/libtiff.2008.vcproj +++ b/libs/spandsp/src/libtiff.2008.vcproj @@ -16,8 +16,8 @@ Name="x64" /> - - + + @@ -223,7 +223,7 @@ > - + - - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - + - - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - + - + diff --git a/libs/spandsp/src/libtiff.2010.vcxproj b/libs/spandsp/src/libtiff.2010.vcxproj index 03d2d0b78e..429031840e 100644 --- a/libs/spandsp/src/libtiff.2010.vcxproj +++ b/libs/spandsp/src/libtiff.2010.vcxproj @@ -75,8 +75,8 @@ $(IntDir)BuildLog $(ProjectName).htm - if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h" /Y -if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h" /Y + if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.h" /Y +if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.h" /Y @@ -92,8 +92,8 @@ if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(Projec - if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h" /Y -if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h" /Y + if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.h" /Y +if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.h" /Y @@ -115,8 +115,8 @@ if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(Projec $(IntDir)BuildLog $(ProjectName).htm - if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h" /Y -if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h" /Y + if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.h" /Y +if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.h" /Y @@ -128,8 +128,8 @@ if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(Projec - if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tiffconf.h" /Y -if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h.vc" "$(ProjectDir)..\..\tiff-3.8.2\libtiff\tif_config.h" /Y + if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tiffconf.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tiffconf.h" /Y +if not exist "$(ProjectDir)../../tiff-4.0.2/libtiff/tif_config.h" copy "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.vc.h" "$(ProjectDir)..\..\tiff-4.0.2\libtiff\tif_config.h" /Y @@ -143,55 +143,55 @@ if not exist "$(ProjectDir)../../tiff-3.8.2/libtiff/tif_config.h" copy "$(Projec - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/libs/spandsp/src/libtiff.2010.vcxproj.filters b/libs/spandsp/src/libtiff.2010.vcxproj.filters index f5377c79e9..adb3ae4c27 100644 --- a/libs/spandsp/src/libtiff.2010.vcxproj.filters +++ b/libs/spandsp/src/libtiff.2010.vcxproj.filters @@ -10,147 +10,147 @@ - + 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 diff --git a/libs/spandsp/src/logging.c b/libs/spandsp/src/logging.c index 589a746106..3f9aa58f17 100644 --- a/libs/spandsp/src/logging.c +++ b/libs/spandsp/src/logging.c @@ -144,10 +144,10 @@ SPAN_DECLARE(int) span_log(logging_state_t *s, int level, const char *format, .. __span_message(s->user_data, level, msg); /*endif*/ va_end(arg_ptr); - return 1; + return 1; } /*endif*/ - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -175,7 +175,7 @@ SPAN_DECLARE(int) span_log_set_level(logging_state_t *s, int level) { s->level = level; - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -183,7 +183,7 @@ SPAN_DECLARE(int) span_log_set_tag(logging_state_t *s, const char *tag) { s->tag = tag; - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -191,7 +191,7 @@ SPAN_DECLARE(int) span_log_set_protocol(logging_state_t *s, const char *protocol { s->protocol = protocol; - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -199,7 +199,7 @@ SPAN_DECLARE(int) span_log_set_sample_rate(logging_state_t *s, int samples_per_s { s->samples_per_second = samples_per_second; - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -207,7 +207,7 @@ SPAN_DECLARE(int) span_log_bump_samples(logging_state_t *s, int samples) { s->elapsed_samples += samples; - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/lpc10_analyse.c b/libs/spandsp/src/lpc10_analyse.c index 0e9341fa04..0db0f5ad21 100644 --- a/libs/spandsp/src/lpc10_analyse.c +++ b/libs/spandsp/src/lpc10_analyse.c @@ -44,7 +44,6 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" -#include "spandsp/dc_restore.h" #include "spandsp/lpc10.h" #include "spandsp/private/lpc10.h" diff --git a/libs/spandsp/src/lpc10_decode.c b/libs/spandsp/src/lpc10_decode.c index 3ccee7c18c..6746d2ceae 100644 --- a/libs/spandsp/src/lpc10_decode.c +++ b/libs/spandsp/src/lpc10_decode.c @@ -45,7 +45,6 @@ #include "spandsp/telephony.h" #include "spandsp/fast_convert.h" -#include "spandsp/dc_restore.h" #include "spandsp/lpc10.h" #include "spandsp/private/lpc10.h" diff --git a/libs/spandsp/src/lpc10_encode.c b/libs/spandsp/src/lpc10_encode.c index 1a080b65c0..0ab0874a31 100644 --- a/libs/spandsp/src/lpc10_encode.c +++ b/libs/spandsp/src/lpc10_encode.c @@ -44,7 +44,6 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" -#include "spandsp/dc_restore.h" #include "spandsp/lpc10.h" #include "spandsp/private/lpc10.h" diff --git a/libs/spandsp/src/lpc10_placev.c b/libs/spandsp/src/lpc10_placev.c index 78723dd6cf..982b1d7c4e 100644 --- a/libs/spandsp/src/lpc10_placev.c +++ b/libs/spandsp/src/lpc10_placev.c @@ -44,7 +44,6 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" -#include "spandsp/dc_restore.h" #include "spandsp/lpc10.h" #include "lpc10_encdecs.h" diff --git a/libs/spandsp/src/lpc10_voicing.c b/libs/spandsp/src/lpc10_voicing.c index c4754b46b1..162fc3ea51 100644 --- a/libs/spandsp/src/lpc10_voicing.c +++ b/libs/spandsp/src/lpc10_voicing.c @@ -45,7 +45,6 @@ #include "spandsp/telephony.h" #include "spandsp/fast_convert.h" -#include "spandsp/dc_restore.h" #include "spandsp/lpc10.h" #include "spandsp/private/lpc10.h" diff --git a/libs/spandsp/src/make_cielab_luts.c b/libs/spandsp/src/make_cielab_luts.c new file mode 100644 index 0000000000..905005674f --- /dev/null +++ b/libs/spandsp/src/make_cielab_luts.c @@ -0,0 +1,92 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * make_cielab_luts.c - Create the look up tables for CIELab colour management + * + * Written by Steve Underwood + * + * Copyright (C) 2011 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#if defined(HAVE_TGMATH_H) +#include +#endif +#if defined(HAVE_MATH_H) +#include +#endif + +typedef struct +{ + float L; + float a; + float b; +} cielab_t; + +int main(int argc, char *argv[]) +{ + float r; + uint8_t srgb; + int i; + + printf("static const float srgb_to_linear[256] =\n"); + printf("{\n"); + for (i = 0; i < 256; i++) + { + /* Start with "i" as the sRGB value */ + r = i/256.0f; + + /* sRGB to Linear RGB */ + r = (r > 0.04045f) ? powf((r + 0.055f)/1.055f, 2.4f) : r/12.92f; + + printf((i < 255) ? " %f,\n" : " %f\n", r); + } + printf("};\n"); + + printf("static const uint8_t linear_to_srgb[4096] =\n"); + printf("{\n"); + for (i = 0; i < 4096; i++) + { + /* Start with "i" as the linear RGB value */ + /* Linear RGB to sRGB */ + r = i/4096.0f; + + r = (r > 0.0031308f) ? (1.055f*powf(r, 1.0f/2.4f) - 0.055f) : r*12.92f; + + r = floorf(r*256.0f); + + srgb = (r < 0) ? 0 : (r <= 255) ? r : 255; + + printf((i < 4095) ? " %d,\n" : " %d\n", srgb); + } + printf("};\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/make_modem_filter.c b/libs/spandsp/src/make_modem_filter.c index aa58ac301b..9bf49eb0aa 100644 --- a/libs/spandsp/src/make_modem_filter.c +++ b/libs/spandsp/src/make_modem_filter.c @@ -450,6 +450,151 @@ int main(int argc, char **argv) rx_tag = ""; tx_tag = ""; } + else if (strcmp(modem, "V.34_2400") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 10; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1600.0; + baud_rate = 2400.0; + rx_tag = "_2400_low_carrier"; + tx_tag = "_2400"; + } + else if (strcmp(modem, "V.34_2400_high") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 10; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1800.0; + baud_rate = 2400.0; + rx_tag = "_2400_high_carrier"; + tx_tag = "_2400"; + } + else if (strcmp(modem, "V.34_2743") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 35; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1646.0; + baud_rate = 2400.0*8.0/7.0; + rx_tag = "_2743_low_carrier"; + tx_tag = "_2743"; + } + else if (strcmp(modem, "V.34_2743_high") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 35; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1829.0; + baud_rate = 2400.0*8.0/7.0; + rx_tag = "_2743_high_carrier"; + tx_tag = "_2743"; + } + else if (strcmp(modem, "V.34_2800") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 20; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1680.0; + baud_rate = 2400.0*7.0/6.0; + rx_tag = "_2800_low_carrier"; + tx_tag = "_2800"; + } + else if (strcmp(modem, "V.34_2800_high") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 20; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1867.0; + baud_rate = 2400.0*7.0/6.0; + rx_tag = "_2800_high_carrier"; + tx_tag = "_2800"; + } + else if (strcmp(modem, "V.34_3000") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 8; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1800.0; + baud_rate = 2400.0*5.0/4.0; + rx_tag = "_3000_low_carrier"; + tx_tag = "_3000"; + } + else if (strcmp(modem, "V.34_3000_high") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 8; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 2000.0; + baud_rate = 2400.0*5.0/4.0; + rx_tag = "_3000_high_carrier"; + tx_tag = "_3000"; + } + else if (strcmp(modem, "V.34_3200") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 5; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1829.0; + baud_rate = 2400.0*4.0/3.0; + rx_tag = "_3200_low_carrier"; + tx_tag = "_3200"; + } + else if (strcmp(modem, "V.34_3200_high") == 0) + { + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 5; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + carrier = 1920.0; + baud_rate = 2400.0*4.0/3.0; + rx_tag = "_3200_high_carrier"; + tx_tag = "_3200"; + } + else if (strcmp(modem, "V.34_3429") == 0) + { + /* There is only one carrier frequency defined for this baud rate */ + rx_coeff_sets = 192; + rx_coeffs_per_filter = 27; + rx_excess_bandwidth = 0.25; + tx_coeff_sets = 7; + tx_coeffs_per_filter = 9; + tx_excess_bandwidth = 0.12; + //carrier = 1959.0; + carrier = 1959.0; + baud_rate = 2400.0*10.0/7.0; + rx_tag = "_3429"; + tx_tag = "_3429"; + } else { usage(); diff --git a/libs/spandsp/src/modem_connect_tones.c b/libs/spandsp/src/modem_connect_tones.c index 25e96b04d2..6bd7de8dac 100644 --- a/libs/spandsp/src/modem_connect_tones.c +++ b/libs/spandsp/src/modem_connect_tones.c @@ -29,9 +29,11 @@ /* CNG is 0.5s+-15% of 1100+-38Hz, 3s+-15% off, repeating. CED is 0.2s silence, 3.3+-0.7s of 2100+-15Hz, and 75+-20ms of silence. - + + Calling tone is 0.5s-0.7s of 1300Hz+-15Hz, 1.5s-2.0s off, repeating. + ANS is 3.3+-0.7s of 2100+-15Hz. - + ANS/ is 3.3+-0.7s of 2100+-15Hz, with phase reversals (180+-10 degrees, hopping in <1ms) every 450+-25ms. ANSam/ is 2100+-1Hz, with phase reversals (180+-10 degrees, hopping in <1ms) every 450+-25ms, and AM with a sinewave of 15+-0.1Hz. @@ -92,6 +94,10 @@ SPAN_DECLARE(const char *) modem_connect_tone_to_str(int tone) return "FAX preamble"; case MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE: return "FAX CED or preamble"; + case MODEM_CONNECT_TONES_BELL_ANS: + return "Bell ANS"; + case MODEM_CONNECT_TONES_CALLING_TONE: + return "Calling tone"; } return "???"; } @@ -202,6 +208,43 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_tx(modem_connect_tones_tx_state_t * } s->duration_timer -= len; break; + case MODEM_CONNECT_TONES_BELL_ANS: + if (s->duration_timer < len) + len = s->duration_timer; + if (s->duration_timer > ms_to_samples(2600)) + { + /* There is some initial silence to be generated. */ + if ((i = s->duration_timer - ms_to_samples(2600)) > len) + i = len; + memset(amp, 0, sizeof(int16_t)*i); + } + for ( ; i < len; i++) + amp[i] = dds_mod(&s->tone_phase, s->tone_phase_rate, s->level, 0); + s->duration_timer -= len; + break; + case MODEM_CONNECT_TONES_CALLING_TONE: + for ( ; i < len; i++) + { + if (s->duration_timer > ms_to_samples(2000)) + { + if ((xlen = i + s->duration_timer - ms_to_samples(2000)) > len) + xlen = len; + s->duration_timer -= (xlen - i); + for ( ; i < xlen; i++) + amp[i] = dds_mod(&s->tone_phase, s->tone_phase_rate, s->level, 0); + } + if (s->duration_timer > 0) + { + if ((xlen = i + s->duration_timer) > len) + xlen = len; + s->duration_timer -= (xlen - i); + memset(amp + i, 0, sizeof(int16_t)*(xlen - i)); + i = xlen; + } + if (s->duration_timer == 0) + s->duration_timer = ms_to_samples(600 + 2000); + } + break; } return len; } @@ -274,6 +317,28 @@ SPAN_DECLARE(modem_connect_tones_tx_state_t *) modem_connect_tones_tx_init(modem s->mod_phase = 0; s->hop_timer = ms_to_samples(450); break; + case MODEM_CONNECT_TONES_BELL_ANS: + /* 0.2s of silence, then 2.6s to 4s of 2225Hz+-15Hz tone, then 75ms of silence. */ + s->tone_phase_rate = dds_phase_rate(2225.0); + s->level = dds_scaling_dbm0(-11); + s->mod_phase_rate = 0; + s->mod_level = 0; + s->duration_timer = ms_to_samples(200 + 2600); + s->tone_phase = 0; + s->mod_phase = 0; + s->hop_timer = 0; + break; + case MODEM_CONNECT_TONES_CALLING_TONE: + /* 0.6s of 1300Hz+-15Hz + 2.0s of silence repeating. */ + s->tone_phase_rate = dds_phase_rate(1300.0); + s->level = dds_scaling_dbm0(-11); + s->duration_timer = ms_to_samples(600 + 2000); + s->mod_phase_rate = 0; + s->tone_phase = 0; + s->mod_phase = 0; + s->mod_level = 0; + s->hop_timer = 0; + break; default: if (alloced) free(s); @@ -402,6 +467,8 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * famp = amp[i]; /* A Cauer notch at 1100Hz, spread just wide enough to meet our detection bandwidth criteria. */ + /* Poles 0.736618498*exp(+-1047/4000 * PI * j) + Zeroes exp(+-1099.5/4000 * PI * j) */ v1 = 0.792928f*famp + 1.0018744927985f*s->znotch_1 - 0.54196833412465f*s->znotch_2; famp = v1 - 1.2994747954630f*s->znotch_1 + s->znotch_2; s->znotch_2 = s->znotch_1; @@ -446,6 +513,8 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * { famp = amp[i]; /* A Cauer bandpass at 15Hz, with which we demodulate the AM signal. */ + /* Poles 0.9983989*exp(+-15/4000 * PI * j) + Zeroes exp(0/4000 * PI * j) */ v1 = fabs(famp) + 1.996667f*s->z15hz_1 - 0.9968004f*s->z15hz_2; filtered = 0.001599787f*(v1 - s->z15hz_2); s->z15hz_2 = s->z15hz_1; @@ -454,9 +523,9 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * //printf("%9.1f %10.4f %9d %9d\n", famp, filtered, s->am_level, s->channel_level); /* A Cauer notch at 2100Hz, spread just wide enough to meet our detection bandwidth criteria. */ - /* This is actually centred at 2095Hz, but gets the balance we want, due - to the asymmetric walls of the notch */ - v1 = 0.76000f*famp - 0.1183852f*s->znotch_1 - 0.5104039f*s->znotch_2; + /* Poles 0.7144255*exp(+-2105.612/4000 * PI * j) + Zeroes exp(+-2099.9/4000 * PI * j) */ + v1 = 0.7552f*famp - 0.1183852f*s->znotch_1 - 0.5104039f*s->znotch_2; famp = v1 + 0.1567596f*s->znotch_1 + s->znotch_2; s->znotch_2 = s->znotch_1; s->znotch_1 = v1; @@ -543,6 +612,82 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t * } } break; + case MODEM_CONNECT_TONES_BELL_ANS: + for (i = 0; i < len; i++) + { + famp = amp[i]; + /* A Cauer notch at 2225Hz, spread just wide enough to meet our detection bandwidth + criteria. */ + /* Poles 0.7144255*exp(+-2230.612/4000 * PI * j) + Zeroes exp(+-2224.9/4000 * PI * j) */ + v1 = 0.739651f*famp - 0.257384f*s->znotch_1 - 0.510404f*s->znotch_2; + famp = v1 + 0.351437f*s->znotch_1 + s->znotch_2; + s->znotch_2 = s->znotch_1; + s->znotch_1 = v1; + notched = (int16_t) lfastrintf(famp); + + /* Estimate the overall energy in the channel, and the energy in + the notch (i.e. overall channel energy - tone energy => noise). + Use abs instead of multiply for speed (is it really faster?). */ + s->channel_level += ((abs(amp[i]) - s->channel_level) >> 5); + s->notch_level += ((abs(notched) - s->notch_level) >> 5); + if (s->channel_level > 70 && s->notch_level*6 < s->channel_level) + { + /* There is adequate energy in the channel, and it is mostly at 2225Hz. */ + if (s->tone_present != MODEM_CONNECT_TONES_BELL_ANS) + { + if (++s->tone_cycle_duration >= ms_to_samples(415)) + report_tone_state(s, MODEM_CONNECT_TONES_BELL_ANS, lfastrintf(log10f(s->channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f)); + } + } + else + { + /* If the signal looks wrong, even for a moment, we consider this the + end of the tone. */ + if (s->tone_present == MODEM_CONNECT_TONES_BELL_ANS) + report_tone_state(s, MODEM_CONNECT_TONES_NONE, -99); + s->tone_cycle_duration = 0; + } + } + break; + case MODEM_CONNECT_TONES_CALLING_TONE: + for (i = 0; i < len; i++) + { + famp = amp[i]; + /* A Cauer notch at 1300Hz, spread just wide enough to meet our detection bandwidth + criteria. */ + /* Poles 0.736618498*exp(+-1247/4000 * PI * j) + Zeroes exp(+-1299.5/4000 * PI * j) */ + v1 = 0.755582f*famp + 0.820887174515f*s->znotch_1 - 0.541968324778f*s->znotch_2; + famp = v1 - 1.0456667108f*s->znotch_1 + s->znotch_2; + s->znotch_2 = s->znotch_1; + s->znotch_1 = v1; + notched = (int16_t) lfastrintf(famp); + + /* Estimate the overall energy in the channel, and the energy in + the notch (i.e. overall channel energy - tone energy => noise). + Use abs instead of multiply for speed (is it really faster?). */ + s->channel_level += ((abs(amp[i]) - s->channel_level) >> 5); + s->notch_level += ((abs(notched) - s->notch_level) >> 5); + if (s->channel_level > 70 && s->notch_level*6 < s->channel_level) + { + /* There is adequate energy in the channel, and it is mostly at 1300Hz. */ + if (s->tone_present != MODEM_CONNECT_TONES_CALLING_TONE) + { + if (++s->tone_cycle_duration >= ms_to_samples(415)) + report_tone_state(s, MODEM_CONNECT_TONES_CALLING_TONE, lfastrintf(log10f(s->channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f)); + } + } + else + { + /* If the signal looks wrong, even for a moment, we consider this the + end of the tone. */ + if (s->tone_present == MODEM_CONNECT_TONES_CALLING_TONE) + report_tone_state(s, MODEM_CONNECT_TONES_NONE, -99); + s->tone_cycle_duration = 0; + } + } + break; } return 0; } diff --git a/libs/spandsp/src/modem_echo.c b/libs/spandsp/src/modem_echo.c index e4203e15e5..14257c7eb7 100644 --- a/libs/spandsp/src/modem_echo.c +++ b/libs/spandsp/src/modem_echo.c @@ -67,21 +67,21 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len) modem_echo_can_state_t *ec; if ((ec = (modem_echo_can_state_t *) malloc(sizeof(*ec))) == NULL) - return NULL; + return NULL; memset(ec, 0, sizeof(*ec)); ec->taps = len; ec->curr_pos = ec->taps - 1; if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL) { free(ec); - return NULL; + return NULL; } memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t)); if ((ec->fir_taps16 = (int16_t *) malloc(ec->taps*sizeof(int16_t))) == NULL) { free(ec->fir_taps32); free(ec); - return NULL; + return NULL; } memset(ec->fir_taps16, 0, ec->taps*sizeof(int16_t)); if (fir16_create(&ec->fir_state, ec->fir_taps16, ec->taps) == NULL) @@ -89,9 +89,9 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len) free(ec->fir_taps16); free(ec->fir_taps32); free(ec); - return NULL; + return NULL; } - return ec; + return ec; } /*- End of function --------------------------------------------------------*/ @@ -170,7 +170,7 @@ SPAN_DECLARE(int16_t) modem_echo_can_update(modem_echo_can_state_t *ec, int16_t if (ec->curr_pos <= 0) ec->curr_pos = ec->taps; ec->curr_pos--; - return (int16_t) clean_rx; + return (int16_t) clean_rx; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj b/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj index 73fb96458b..ce78ce0d6c 100644 --- a/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj +++ b/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj @@ -1,4 +1,4 @@ - +tiff-4.0.2 diff --git a/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj b/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj index 5b8327a7b7..2b59b47d76 100644 --- a/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj +++ b/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj @@ -38,8 +38,8 @@ diff --git a/libs/spandsp/src/msvc/config.h b/libs/spandsp/src/msvc/config.h index a1eaae16a6..42494d345f 100644 --- a/libs/spandsp/src/msvc/config.h +++ b/libs/spandsp/src/msvc/config.h @@ -74,6 +74,8 @@ #define _MMX_H_ + #define cbrtf(value) pow((float)value, (float).333) + #include // To get alloca #endif diff --git a/libs/spandsp/src/msvc/inttypes.h b/libs/spandsp/src/msvc/inttypes.h index 81ab70dec4..beb93cae10 100644 --- a/libs/spandsp/src/msvc/inttypes.h +++ b/libs/spandsp/src/msvc/inttypes.h @@ -43,6 +43,9 @@ typedef __int64 int64_t; #if !defined(UINT16_MAX) #define UINT16_MAX 0xFFFF #endif +#if !defined(UINT32_MAX) +#define UINT32_MAX 0xFFFFFFFF +#endif #if !defined(INT16_MAX) #define INT16_MAX 0x7FFF diff --git a/libs/spandsp/src/msvc/make_at_dictionary.2005.vcproj b/libs/spandsp/src/msvc/make_at_dictionary.2005.vcproj index 15680cf5eb..61c5c14c34 100644 --- a/libs/spandsp/src/msvc/make_at_dictionary.2005.vcproj +++ b/libs/spandsp/src/msvc/make_at_dictionary.2005.vcproj @@ -41,7 +41,7 @@ Disabled - .;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;.\generated;%(AdditionalIncludeDirectories) + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;.\generated;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;%(PreprocessorDefinitions) true EnableFastChecks diff --git a/libs/spandsp/src/msvc/make_modem_filter.2005.vcproj b/libs/spandsp/src/msvc/make_modem_filter.2005.vcproj index 6b2acb004d..43efd4bdfb 100644 --- a/libs/spandsp/src/msvc/make_modem_filter.2005.vcproj +++ b/libs/spandsp/src/msvc/make_modem_filter.2005.vcproj @@ -41,7 +41,7 @@ Disabled - .;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;.\generated;%(AdditionalIncludeDirectories) + .;.\spandsp;.\msvc;..\..\tiff-4.0.2\libtiff;.\generated;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;%(PreprocessorDefinitions) true EnableFastChecks diff --git a/libs/spandsp/src/msvc/spandsp.h b/libs/spandsp/src/msvc/spandsp.h index 95ee8bf11b..6ba0b82cec 100644 --- a/libs/spandsp/src/msvc/spandsp.h +++ b/libs/spandsp/src/msvc/spandsp.h @@ -21,8 +21,6 @@ * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: spandsp.h.in,v 1.19.4.1 2009/12/19 09:47:56 steveu Exp $ */ /*! \file */ @@ -38,6 +36,10 @@ #define SPANDSP_USE_EXPORT_CAPABILITY 1 +#undef SPANDSP_SUPPORT_T42 +#undef SPANDSP_SUPPORT_T43 +#undef SPANDSP_SUPPORT_V34 + #include #include #include @@ -56,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +91,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -95,15 +101,19 @@ #include #include #include -#include #include -#include -#include #include #include #include -#include +#include +#include #include +#include +#include +#include +#if defined(SPANDSP_SUPPORT_T43) +#include +#endif #include #include #include @@ -118,6 +128,7 @@ #include #include #include +#include #include #include #include diff --git a/libs/spandsp/src/msvc/vc8proj.head b/libs/spandsp/src/msvc/vc8proj.head index a258d54e34..d7757339d1 100644 --- a/libs/spandsp/src/msvc/vc8proj.head +++ b/libs/spandsp/src/msvc/vc8proj.head @@ -27,7 +27,7 @@ bit_rate = bit_rate; - return s; + return s; } /*- End of function --------------------------------------------------------*/ @@ -318,7 +318,7 @@ SPAN_DECLARE(int) oki_adpcm_decode(oki_adpcm_state_t *s, /*endfor*/ } /*endif*/ - return samples; + return samples; } /*- End of function --------------------------------------------------------*/ @@ -379,7 +379,7 @@ SPAN_DECLARE(int) oki_adpcm_encode(oki_adpcm_state_t *s, /*endfor*/ } /*endif*/ - return bytes; + return bytes; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/sig_tone.c b/libs/spandsp/src/sig_tone.c index 6aaecdb211..ed6b2fa523 100644 --- a/libs/spandsp/src/sig_tone.c +++ b/libs/spandsp/src/sig_tone.c @@ -45,7 +45,6 @@ #include "spandsp/telephony.h" #include "spandsp/fast_convert.h" -#include "spandsp/dc_restore.h" #include "spandsp/saturated.h" #include "spandsp/vector_int.h" #include "spandsp/complex.h" @@ -647,9 +646,9 @@ SPAN_DECLARE(sig_tone_rx_state_t *) sig_tone_rx_init(sig_tone_rx_state_t *s, int } memset(s, 0, sizeof(*s)); #if !defined(SPANDSP_USE_FIXED_POINT) - for (j = 0; j < 2; j++) + for (j = 0; j < 3; j++) { - for (i = 0; i < 3; i++) + for (i = 0; i < 2; i++) { s->tone[j].notch_z1[i] = 0.0f; s->tone[j].notch_z2[i] = 0.0f; diff --git a/libs/spandsp/src/spandsp.h.in b/libs/spandsp/src/spandsp.h.in index acb8a18ed5..8dcafa50e8 100644 --- a/libs/spandsp/src/spandsp.h.in +++ b/libs/spandsp/src/spandsp.h.in @@ -33,15 +33,19 @@ @SPANDSP_USE_EXPORT_CAPABILITY@ +@SPANDSP_SUPPORT_T42@ +@SPANDSP_SUPPORT_T43@ +@SPANDSP_SUPPORT_V34@ +@SPANDSP_SUPPORT_TIFF_FX@ + #include @INSERT_INTTYPES_HEADER@ #include #include #include @INSERT_MATH_HEADER@ -#if !defined(SPANDSP_NO_TIFF) #include -#endif + #include #include #include @@ -104,8 +108,10 @@ #include #include #include -/*#include */ -/*#include */ +#include +#include +#include +/*#include */ #include #include #include @@ -120,6 +126,7 @@ #include #include #include +#include #include #include #include diff --git a/libs/spandsp/src/spandsp/ademco_contactid.h b/libs/spandsp/src/spandsp/ademco_contactid.h new file mode 100644 index 0000000000..8e42d70256 --- /dev/null +++ b/libs/spandsp/src/spandsp/ademco_contactid.h @@ -0,0 +1,365 @@ +/* + * SpanDSP a series of DSP components for telephony + * + * ademco_contactid.h Ademco ContactID alarm protocol + * + * Written by Steve Underwood + * + * Copyright (C) 2012 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_SPANDSP_ADEMCO_CONTACTID_H_) +#define _SPANDSP_ADEMCO_CONTACTID_H_ + +enum +{ + ADEMCO_CONTACTID_MESSAGE_TYPE_18 = 0x18, + ADEMCO_CONTACTID_MESSAGE_TYPE_98 = 0x98 +}; + +enum +{ + ADEMCO_CONTACTID_QUALIFIER_NEW_EVENT = 1, + ADEMCO_CONTACTID_QUALIFIER_NEW_RESTORE = 3, + ADEMCO_CONTACTID_QUALIFIER_STATUS_REPORT = 6 +}; + +enum +{ + ADEMCO_CONTACTID_DATA_IS_ZONE = 0, + ADEMCO_CONTACTID_DATA_IS_USER = 1 +}; + +enum +{ + ADEMCO_CONTACTID_MEDICAL = 0x100, + ADEMCO_CONTACTID_PERSONAL_EMERGENCY = 0x101, + ADEMCO_CONTACTID_FAIL_TO_REPORT_IN = 0x102, + ADEMCO_CONTACTID_FIRE = 0x110, + ADEMCO_CONTACTID_SMOKE = 0x111, + ADEMCO_CONTACTID_COMBUSTION = 0x112, + ADEMCO_CONTACTID_WATER_FLOW = 0x113, + ADEMCO_CONTACTID_HEAT = 0x114, + ADEMCO_CONTACTID_PULL_STATION = 0x115, + ADEMCO_CONTACTID_DUCT = 0x116, + ADEMCO_CONTACTID_FLAME = 0x117, + ADEMCO_CONTACTID_NEAR_ALARM_A = 0x118, + ADEMCO_CONTACTID_PANIC = 0x120, + ADEMCO_CONTACTID_DURESS = 0x121, + ADEMCO_CONTACTID_SILENT = 0x122, + ADEMCO_CONTACTID_AUDIBLE = 0x123, + ADEMCO_CONTACTID_DURESS_ACCESS_GRANTED = 0x124, + ADEMCO_CONTACTID_DURESS_EGRESS_GRANTED = 0x125, + ADEMCO_CONTACTID_BURGLARY = 0x130, + ADEMCO_CONTACTID_PERIMETER = 0x131, + ADEMCO_CONTACTID_INTERIOR = 0x132, + ADEMCO_CONTACTID_24_HOUR_SAFE = 0x133, + ADEMCO_CONTACTID_ENTRY_EXIT = 0x134, + ADEMCO_CONTACTID_DAY_NIGHT = 0x135, + ADEMCO_CONTACTID_OUTDOOR = 0x136, + ADEMCO_CONTACTID_TAMPER = 0x137, + ADEMCO_CONTACTID_NEAR_ALARM_B = 0x138, + ADEMCO_CONTACTID_INTRUSION_VERIFIER = 0x139, + ADEMCO_CONTACTID_GENERAL_ALARM = 0x140, + ADEMCO_CONTACTID_POLLING_LOOP_OPEN_A = 0x141, + ADEMCO_CONTACTID_POLLING_LOOP_SHORT_A = 0x142, + ADEMCO_CONTACTID_EXPANSION_MODULE_FAILURE_A = 0x143, + ADEMCO_CONTACTID_SENSOR_TAMPER_A = 0x144, + ADEMCO_CONTACTID_EXPANSION_MODULE_TAMPER = 0x145, + ADEMCO_CONTACTID_SILENT_BURGLARY = 0x146, + ADEMCO_CONTACTID_SENSOR_SUPERVISION_FAILURE = 0x147, + ADEMCO_CONTACTID_24_HOUR_NONBURGLARY = 0x150, + ADEMCO_CONTACTID_GAS_DETECTED = 0x151, + ADEMCO_CONTACTID_REFRIGERATION = 0x152, + ADEMCO_CONTACTID_LOSS_OF_HEAT = 0x153, + ADEMCO_CONTACTID_WATER_LEAKAGE = 0x154, + ADEMCO_CONTACTID_FOIL_BREAK = 0x155, + ADEMCO_CONTACTID_DAY_TROUBLE = 0x156, + ADEMCO_CONTACTID_LOW_BOTTLED_GAS_LEVEL = 0x157, + ADEMCO_CONTACTID_HIGH_TEMP = 0x158, + ADEMCO_CONTACTID_LOW_TEMP = 0x159, + ADEMCO_CONTACTID_LOSS_OF_AIR_FLOW = 0x161, + ADEMCO_CONTACTID_CARBON_MONOXIDE_DETECTED = 0x162, + ADEMCO_CONTACTID_TANK_LEVEL = 0x163, + ADEMCO_CONTACTID_FIRE_SUPERVISORY = 0x200, + ADEMCO_CONTACTID_LOW_WATER_PRESSURE = 0x201, + ADEMCO_CONTACTID_LOW_CO2 = 0x202, + ADEMCO_CONTACTID_GATE_VALVE_SENSOR = 0x203, + ADEMCO_CONTACTID_LOW_WATER_LEVEL = 0x204, + ADEMCO_CONTACTID_PUMP_ACTIVATED = 0x205, + ADEMCO_CONTACTID_PUMP_FAILURE = 0x206, + ADEMCO_CONTACTID_SYSTEM_TROUBLE = 0x300, + ADEMCO_CONTACTID_AC_LOSS = 0x301, + ADEMCO_CONTACTID_LOW_SYSTEM_BATTERY = 0x302, + ADEMCO_CONTACTID_RAM_CHECKSUM_BAD = 0x303, + ADEMCO_CONTACTID_ROM_CHECKSUM_BAD = 0x304, + ADEMCO_CONTACTID_SYSTEM_RESET = 0x305, + ADEMCO_CONTACTID_PANEL_PROGRAMMING_CHANGED = 0x306, + ADEMCO_CONTACTID_SELFTEST_FAILURE = 0x307, + ADEMCO_CONTACTID_SYSTEM_SHUTDOWN = 0x308, + ADEMCO_CONTACTID_BATTERY_TEST_FAILURE = 0x309, + ADEMCO_CONTACTID_GROUND_FAULT = 0x310, + ADEMCO_CONTACTID_BATTERY_MISSING_DEAD = 0x311, + ADEMCO_CONTACTID_POWER_SUPPLY_OVERCURRENT = 0x312, + ADEMCO_CONTACTID_ENGINEER_RESET = 0x313, + ADEMCO_CONTACTID_SOUNDER_RELAY = 0x320, + ADEMCO_CONTACTID_BELL_1 = 0x321, + ADEMCO_CONTACTID_BELL_2 = 0x322, + ADEMCO_CONTACTID_ALARM_RELAY = 0x323, + ADEMCO_CONTACTID_TROUBLE_RELAY = 0x324, + ADEMCO_CONTACTID_REVERSING_RELAY = 0x325, + ADEMCO_CONTACTID_NOTIFICATION_APPLIANCE_CKT_3 = 0x326, + ADEMCO_CONTACTID_NOTIFICATION_APPLIANCE_CKT_4 = 0x327, + ADEMCO_CONTACTID_SYSTEM_PERIPHERAL_TROUBLE = 0x330, + ADEMCO_CONTACTID_POLLING_LOOP_OPEN_B = 0x331, + ADEMCO_CONTACTID_POLLING_LOOP_SHORT_B = 0x332, + ADEMCO_CONTACTID_EXPANSION_MODULE_FAILURE_B = 0x333, + ADEMCO_CONTACTID_REPEATER_FAILURE = 0x334, + ADEMCO_CONTACTID_LOCAL_PRINTER_OUT_OF_PAPER = 0x335, + ADEMCO_CONTACTID_LOCAL_PRINTER_FAILURE = 0x336, + ADEMCO_CONTACTID_EXP_MODULE_DC_LOSS = 0x337, + ADEMCO_CONTACTID_EXP_MODULE_LOW_BATTERY = 0x338, + ADEMCO_CONTACTID_EXP_MODULE_RESET = 0x339, + ADEMCO_CONTACTID_EXP_MODULE_TAMPER = 0x341, + ADEMCO_CONTACTID_EXP_MODULE_AC_LOSS = 0x342, + ADEMCO_CONTACTID_EXP_MODULE_SELFTEST_FAIL = 0x343, + ADEMCO_CONTACTID_RF_RECEIVER_JAM_DETECT = 0x344, + ADEMCO_CONTACTID_COMMUNICATION_TROUBLE = 0x350, + ADEMCO_CONTACTID_TELCO_1_FAULT = 0x351, + ADEMCO_CONTACTID_TELCO_2_FAULT = 0x352, + ADEMCO_CONTACTID_LONG_RANGE_RADIO_TRANSMITTER_FAULT = 0x353, + ADEMCO_CONTACTID_FAILURE_TO_COMMUNICATE_EVENT = 0x354, + ADEMCO_CONTACTID_LOSS_OF_RADIO_SUPERVISION = 0x355, + ADEMCO_CONTACTID_LOSS_OF_CENTRAL_POLLING = 0x356, + ADEMCO_CONTACTID_LONG_RANGE_RADIO_VSWR_PROBLEM = 0x357, + ADEMCO_CONTACTID_PROTECTION_LOOP = 0x370, + ADEMCO_CONTACTID_PROTECTION_LOOP_OPEN = 0x371, + ADEMCO_CONTACTID_PROTECTION_LOOP_SHORT = 0x372, + ADEMCO_CONTACTID_FIRE_TROUBLE = 0x373, + ADEMCO_CONTACTID_EXIT_ERROR_ALARM_ZONE = 0x374, + ADEMCO_CONTACTID_PANIC_ZONE_TROUBLE = 0x375, + ADEMCO_CONTACTID_HOLDUP_ZONE_TROUBLE = 0x376, + ADEMCO_CONTACTID_SWINGER_TROUBLE = 0x377, + ADEMCO_CONTACTID_CROSSZONE_TROUBLE = 0x378, + ADEMCO_CONTACTID_SENSOR_TROUBLE = 0x380, + ADEMCO_CONTACTID_LOSS_OF_SUPERVISION__RF = 0x381, + ADEMCO_CONTACTID_LOSS_OF_SUPERVISION__RPM = 0x382, + ADEMCO_CONTACTID_SENSOR_TAMPER_B = 0x383, + ADEMCO_CONTACTID_RF_LOW_BATTERY = 0x384, + ADEMCO_CONTACTID_SMOKE_DETECTOR_HIGH_SENSITIVITY = 0x385, + ADEMCO_CONTACTID_SMOKE_DETECTOR_LOW_SENSITIVITY = 0x386, + ADEMCO_CONTACTID_INTRUSION_DETECTOR_HIGH_SENSITIVITY = 0x387, + ADEMCO_CONTACTID_INTRUSION_DETECTOR_LOW_SENSITIVITY = 0x388, + ADEMCO_CONTACTID_SENSOR_SELFTEST_FAILURE = 0x389, + ADEMCO_CONTACTID_SENSOR_WATCH_TROUBLE = 0x391, + ADEMCO_CONTACTID_DRIFT_COMPENSATION_ERROR = 0x392, + ADEMCO_CONTACTID_MAINTENANCE_ALERT = 0x393, + ADEMCO_CONTACTID_OPEN_CLOSE = 0x400, + ADEMCO_CONTACTID_OC_BY_USER = 0x401, + ADEMCO_CONTACTID_GROUP_OC = 0x402, + ADEMCO_CONTACTID_AUTOMATIC_OC = 0x403, + ADEMCO_CONTACTID_LATE_TO_OC = 0x404, + ADEMCO_CONTACTID_DEFERRED_OC = 0x405, + ADEMCO_CONTACTID_CANCEL = 0x406, + ADEMCO_CONTACTID_REMOTE_ARM_DISARM = 0x407, + ADEMCO_CONTACTID_QUICK_ARM = 0x408, + ADEMCO_CONTACTID_KEYSWITCH_OC = 0x409, + ADEMCO_CONTACTID_ARMED_STAY = 0x441, + ADEMCO_CONTACTID_KEYSWITCH_ARMED_STAY = 0x442, + ADEMCO_CONTACTID_EXCEPTION_OC = 0x450, + ADEMCO_CONTACTID_EARLY_OC = 0x451, + ADEMCO_CONTACTID_LATE_OC = 0x452, + ADEMCO_CONTACTID_FAILED_TO_OPEN = 0x453, + ADEMCO_CONTACTID_FAILED_TO_CLOSE = 0x454, + ADEMCO_CONTACTID_AUTOARM_FAILED = 0x455, + ADEMCO_CONTACTID_PARTIAL_ARM = 0x456, + ADEMCO_CONTACTID_EXIT_ERROR_USER = 0x457, + ADEMCO_CONTACTID_USER_ON_PREMISES = 0x458, + ADEMCO_CONTACTID_RECENT_CLOSE = 0x459, + ADEMCO_CONTACTID_WRONG_CODE_ENTRY = 0x461, + ADEMCO_CONTACTID_LEGAL_CODE_ENTRY = 0x462, + ADEMCO_CONTACTID_REARM_AFTER_ALARM = 0x463, + ADEMCO_CONTACTID_AUTOARM_TIME_EXTENDED = 0x464, + ADEMCO_CONTACTID_PANIC_ALARM_RESET = 0x465, + ADEMCO_CONTACTID_SERVICE_ON_OFF_PREMISES = 0x466, + ADEMCO_CONTACTID_CALLBACK_REQUEST_MADE = 0x411, + ADEMCO_CONTACTID_SUCCESSFUL_DOWNLOAD_ACCESS = 0x412, + ADEMCO_CONTACTID_UNSUCCESSFUL_ACCESS = 0x413, + ADEMCO_CONTACTID_SYSTEM_SHUTDOWN_COMMAND_RECEIVED = 0x414, + ADEMCO_CONTACTID_DIALER_SHUTDOWN_COMMAND_RECEIVED = 0x415, + ADEMCO_CONTACTID_SUCCESSFUL_UPLOAD = 0x416, + ADEMCO_CONTACTID_ACCESS_DENIED = 0x421, + ADEMCO_CONTACTID_ACCESS_REPORT_BY_USER = 0x422, + ADEMCO_CONTACTID_FORCED_ACCESS = 0x423, + ADEMCO_CONTACTID_EGRESS_DENIED = 0x424, + ADEMCO_CONTACTID_EGRESS_GRANTED = 0x425, + ADEMCO_CONTACTID_ACCESS_DOOR_PROPPED_OPEN = 0x426, + ADEMCO_CONTACTID_ACCESS_POINT_DOOR_STATUS_MONITOR_TROUBLE = 0x427, + ADEMCO_CONTACTID_ACCESS_POINT_REQUEST_TO_EXIT_TROUBLE = 0x428, + ADEMCO_CONTACTID_ACCESS_PROGRAM_MODE_ENTRY = 0x429, + ADEMCO_CONTACTID_ACCESS_PROGRAM_MODE_EXIT = 0x430, + ADEMCO_CONTACTID_ACCESS_THREAT_LEVEL_CHANGE = 0x431, + ADEMCO_CONTACTID_ACCESS_RELAY_TRIGGER_FAIL = 0x432, + ADEMCO_CONTACTID_ACCESS_RTE_SHUNT = 0x433, + ADEMCO_CONTACTID_ACCESS_DSM_SHUNT = 0x434, + ADEMCO_CONTACTID_ACCESS_READER_DISABLE = 0x501, + ADEMCO_CONTACTID_SOUNDER_RELAY_DISABLE = 0x520, + ADEMCO_CONTACTID_BELL_1_DISABLE = 0x521, + ADEMCO_CONTACTID_BELL_2_DISABLE = 0x522, + ADEMCO_CONTACTID_ALARM_RELAY_DISABLE = 0x523, + ADEMCO_CONTACTID_TROUBLE_RELAY_DISABLE = 0x524, + ADEMCO_CONTACTID_REVERSING_RELAY_DISABLE = 0x525, + ADEMCO_CONTACTID_NOTIFICATION_APPLIANCE_CKT_3_DISABLE = 0x526, + ADEMCO_CONTACTID_NOTIFICATION_APPLIANCE_CKT_4_DISABLE = 0x527, + ADEMCO_CONTACTID_MODULE_ADDED = 0x531, + ADEMCO_CONTACTID_MODULE_REMOVED = 0x532, + ADEMCO_CONTACTID_DIALER_DISABLED = 0x551, + ADEMCO_CONTACTID_RADIO_TRANSMITTER_DISABLED = 0x552, + ADEMCO_CONTACTID_REMOTE_UPLOAD_DOWNLOAD_DISABLED = 0x553, + ADEMCO_CONTACTID_ZONE_SENSOR_BYPASS = 0x570, + ADEMCO_CONTACTID_FIRE_BYPASS = 0x571, + ADEMCO_CONTACTID_24_HOUR_ZONE_BYPASS = 0x572, + ADEMCO_CONTACTID_BURG_BYPASS = 0x573, + ADEMCO_CONTACTID_GROUP_BYPASS = 0x574, + ADEMCO_CONTACTID_SWINGER_BYPASS = 0x575, + ADEMCO_CONTACTID_ACCESS_ZONE_SHUNT = 0x576, + ADEMCO_CONTACTID_ACCESS_POINT_BYPASS = 0x577, + ADEMCO_CONTACTID_MANUAL_TRIGGER_TEST_REPORT = 0x601, + ADEMCO_CONTACTID_PERIODIC_TEST_REPORT = 0x602, + ADEMCO_CONTACTID_PERIODIC_RF_TRANSMISSION = 0x603, + ADEMCO_CONTACTID_FIRE_TEST = 0x604, + ADEMCO_CONTACTID_STATUS_REPORT_TO_FOLLOW = 0x605, + ADEMCO_CONTACTID_LISTENIN_TO_FOLLOW = 0x606, + ADEMCO_CONTACTID_WALK_TEST_MODE = 0x607, + ADEMCO_CONTACTID_PERIODIC_TEST__SYSTEM_TROUBLE_PRESENT = 0x608, + ADEMCO_CONTACTID_VIDEO_TRANSMITTER_ACTIVE = 0x609, + ADEMCO_CONTACTID_POINT_TESTED_OK = 0x611, + ADEMCO_CONTACTID_POINT_NOT_TESTED = 0x612, + ADEMCO_CONTACTID_INTRUSION_ZONE_WALK_TESTED = 0x613, + ADEMCO_CONTACTID_FIRE_ZONE_WALK_TESTED = 0x614, + ADEMCO_CONTACTID_PANIC_ZONE_WALK_TESTED = 0x615, + ADEMCO_CONTACTID_SERVICE_REQUEST = 0x616, + ADEMCO_CONTACTID_EVENT_LOG_RESET = 0x621, + ADEMCO_CONTACTID_EVENT_LOG_50PC_FULL = 0x622, + ADEMCO_CONTACTID_EVENT_LOG_90PC_FULL = 0x623, + ADEMCO_CONTACTID_EVENT_LOG_OVERFLOW = 0x624, + ADEMCO_CONTACTID_TIME_DATE_RESET = 0x625, + ADEMCO_CONTACTID_TIME_DATE_INACCURATE = 0x626, + ADEMCO_CONTACTID_PROGRAM_MODE_ENTRY = 0x627, + ADEMCO_CONTACTID_PROGRAM_MODE_EXIT = 0x628, + ADEMCO_CONTACTID_32_HOUR_EVENT_LOG_MARKER = 0x629, + ADEMCO_CONTACTID_SCHEDULE_CHANGE = 0x630, + ADEMCO_CONTACTID_EXCEPTION_SCHEDULE_CHANGE = 0x631, + ADEMCO_CONTACTID_ACCESS_SCHEDULE_CHANGE = 0x632, + ADEMCO_CONTACTID_SENIOR_WATCH_TROUBLE = 0x641, + ADEMCO_CONTACTID_LATCHKEY_SUPERVISION = 0x642, + ADEMCO_CONTACTID_RESERVED_FOR_ADEMCO_USE_1 = 0x651, + ADEMCO_CONTACTID_RESERVED_FOR_ADEMCO_USE_2 = 0x652, + ADEMCO_CONTACTID_RESERVED_FOR_ADEMCO_USE_3 = 0x653, + ADEMCO_CONTACTID_SYSTEM_INACTIVITY = 0x654, + ADEMCO_CONTACTID_DOWNLOAD_ABORT = 0x900, + ADEMCO_CONTACTID_DOWNLOAD_START_END = 0x901, + ADEMCO_CONTACTID_DOWNLOAD_INTERRUPTED = 0x902, + ADEMCO_CONTACTID_AUTOCLOSE_WITH_BYPASS = 0x910, + ADEMCO_CONTACTID_BYPASS_CLOSING = 0x911, + ADEMCO_CONTACTID_32_HOUR_NO_READ_OF_EVENT_LOG = 0x999 +}; + +typedef struct ademco_contactid_sender_state_s ademco_contactid_sender_state_t; + +typedef struct ademco_contactid_receiver_state_s ademco_contactid_receiver_state_t; + +typedef struct +{ + int acct; + int mt; + int q; + int xyz; + int gg; + int ccc; +} ademco_contactid_report_t; + +typedef void (*ademco_contactid_report_func_t)(void *user_data, const ademco_contactid_report_t *report); + +#if defined(__cplusplus) +extern "C" +{ +#endif + +SPAN_DECLARE(const char *) ademco_contactid_msg_qualifier_to_str(int q); + +SPAN_DECLARE(const char *) ademco_contactid_event_to_str(int xyz); + +SPAN_DECLARE(int) encode_msg(char buf[], const ademco_contactid_report_t *report); + +SPAN_DECLARE(int) decode_msg(ademco_contactid_report_t *report, const char buf[]); + +SPAN_DECLARE(int) ademco_contactid_receiver_log_msg(ademco_contactid_receiver_state_t *s, const ademco_contactid_report_t *report); + +SPAN_DECLARE(int) ademco_contactid_receiver_tx(ademco_contactid_receiver_state_t *s, int16_t amp[], int max_samples); + +SPAN_DECLARE(int) ademco_contactid_receiver_rx(ademco_contactid_receiver_state_t *s, const int16_t amp[], int samples); + +SPAN_DECLARE(int) ademco_contactid_receiver_fillin(ademco_contactid_receiver_state_t *s, int samples); + +SPAN_DECLARE(logging_state_t *) ademco_contactid_receiver_get_logging_state(ademco_contactid_receiver_state_t *s); + +SPAN_DECLARE(void) ademco_contactid_receiver_set_realtime_callback(ademco_contactid_receiver_state_t *s, + ademco_contactid_report_func_t callback, + void *user_data); + +SPAN_DECLARE(ademco_contactid_receiver_state_t *) ademco_contactid_receiver_init(ademco_contactid_receiver_state_t *s, + ademco_contactid_report_func_t callback, + void *user_data); + +SPAN_DECLARE(int) ademco_contactid_receiver_release(ademco_contactid_receiver_state_t *s); + +SPAN_DECLARE(int) ademco_contactid_receiver_free(ademco_contactid_receiver_state_t *s); + + + +SPAN_DECLARE(int) ademco_contactid_sender_tx(ademco_contactid_sender_state_t *s, int16_t amp[], int max_samples); + +SPAN_DECLARE(int) ademco_contactid_sender_rx(ademco_contactid_sender_state_t *s, const int16_t amp[], int samples); + +SPAN_DECLARE(int) ademco_contactid_sender_fillin(ademco_contactid_sender_state_t *s, int samples); + +SPAN_DECLARE(int) ademco_contactid_sender_put(ademco_contactid_sender_state_t *s, const ademco_contactid_report_t *report); + +SPAN_DECLARE(logging_state_t *) ademco_contactid_sender_get_logging_state(ademco_contactid_sender_state_t *s); + +SPAN_DECLARE(void) ademco_contactid_sender_set_realtime_callback(ademco_contactid_sender_state_t *s, + tone_report_func_t callback, + void *user_data); + +SPAN_DECLARE(ademco_contactid_sender_state_t *) ademco_contactid_sender_init(ademco_contactid_sender_state_t *s, + tone_report_func_t callback, + void *user_data); + +SPAN_DECLARE(int) ademco_contactid_sender_release(ademco_contactid_sender_state_t *s); + +SPAN_DECLARE(int) ademco_contactid_sender_free(ademco_contactid_sender_state_t *s); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/async.h b/libs/spandsp/src/spandsp/async.h index 4324264042..8d643dd720 100644 --- a/libs/spandsp/src/spandsp/async.h +++ b/libs/spandsp/src/spandsp/async.h @@ -107,9 +107,6 @@ typedef void (*put_bit_func_t)(void *user_data, int bit); /*! Bit get function for data pumps */ typedef int (*get_bit_func_t)(void *user_data); -#define modem_rx_status_func_t modem_status_func_t -#define modem_tx_status_func_t modem_status_func_t - /*! Status change callback function for data pumps */ typedef void (*modem_status_func_t)(void *user_data, int status); diff --git a/libs/spandsp/src/spandsp/at_interpreter.h b/libs/spandsp/src/spandsp/at_interpreter.h index 6f844599f0..d4c8f0018e 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)(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); enum at_rx_mode_e { @@ -172,9 +172,9 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand \param modem_control_user_data x. \return A pointer to the AT context, or NULL if there was a problem. */ SPAN_DECLARE(at_state_t *) at_init(at_state_t *s, - at_tx_handler_t *at_tx_handler, + at_tx_handler_t at_tx_handler, void *at_tx_user_data, - at_modem_control_handler_t *modem_control_handler, + at_modem_control_handler_t modem_control_handler, void *modem_control_user_data); /*! Release an AT interpreter context. diff --git a/libs/spandsp/src/spandsp/dtmf.h b/libs/spandsp/src/spandsp/dtmf.h index 161131355f..a9aeb64ef9 100644 --- a/libs/spandsp/src/spandsp/dtmf.h +++ b/libs/spandsp/src/spandsp/dtmf.h @@ -152,15 +152,15 @@ SPAN_DECLARE(void) dtmf_rx_set_realtime_callback(dtmf_rx_state_t *s, \param s The DTMF receiver context. \param filter_dialtone TRUE to enable filtering of dialtone, FALSE to disable, < 0 to leave unchanged. - \param twist Acceptable twist, in dB. < 0 to leave unchanged. - \param reverse_twist Acceptable reverse twist, in dB. < 0 to leave unchanged. + \param twist Acceptable twist, in dB. < 0.0 to leave unchanged. + \param reverse_twist Acceptable reverse twist, in dB. < 0.0 to leave unchanged. \param threshold The minimum acceptable tone level for detection, in dBm0. - <= -99 to leave unchanged. */ + <= -99.0 to leave unchanged. */ SPAN_DECLARE(void) dtmf_rx_parms(dtmf_rx_state_t *s, int filter_dialtone, - int twist, - int reverse_twist, - int threshold); + float twist, + float reverse_twist, + float threshold); /*! Process a block of received DTMF audio samples. \brief Process a block of received DTMF audio samples. diff --git a/libs/spandsp/src/spandsp/expose.h b/libs/spandsp/src/spandsp/expose.h index ac10084535..2f90c7f2d4 100644 --- a/libs/spandsp/src/spandsp/expose.h +++ b/libs/spandsp/src/spandsp/expose.h @@ -78,9 +78,9 @@ #include #include #include -/*#include */ -/*#include */ -/*#include */ +#include +#include +#include /*#include */ #include #include @@ -93,6 +93,7 @@ #include #include #include +#include #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/fax_modems.h b/libs/spandsp/src/spandsp/fax_modems.h index 100e57eb5c..db9b998449 100644 --- a/libs/spandsp/src/spandsp/fax_modems.h +++ b/libs/spandsp/src/spandsp/fax_modems.h @@ -64,10 +64,33 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx(void *user_data, const int16_t am SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len); SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len); SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len); -SPAN_DECLARE(void) fax_modems_start_rx_modem(fax_modems_state_t *s, int which); + +SPAN_DECLARE_NONSTD(void) fax_modems_hdlc_tx_frame(void *user_data, const uint8_t *msg, int len); + +SPAN_DECLARE(void) fax_modems_hdlc_tx_flags(fax_modems_state_t *s, int flags); + +SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, int bit_rate, int short_train, int hdlc_mode); + +SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which); SPAN_DECLARE(void) fax_modems_set_tep_mode(fax_modems_state_t *s, int use_tep); +SPAN_DECLARE(void) fax_modems_set_put_bit(fax_modems_state_t *s, put_bit_func_t put_bit, void *user_data); + +SPAN_DECLARE(void) fax_modems_set_get_bit(fax_modems_state_t *s, get_bit_func_t get_bit, void *user_data); + +SPAN_DECLARE(void) fax_modems_set_rx_handler(fax_modems_state_t *s, + span_rx_handler_t rx_handler, + void *rx_user_data, + span_rx_fillin_handler_t rx_fillin_handler, + void *rx_fillin_user_data); + +SPAN_DECLARE(void) fax_modems_set_rx_active(fax_modems_state_t *s, int active); + +SPAN_DECLARE(void) fax_modems_set_tx_handler(fax_modems_state_t *s, span_tx_handler_t handler, void *user_data); + +SPAN_DECLARE(void) fax_modems_set_next_tx_handler(fax_modems_state_t *s, span_tx_handler_t handler, void *user_data); + SPAN_DECLARE(int) fax_modems_restart(fax_modems_state_t *s); /*! Get a pointer to the logging context associated with a FAX modems context. diff --git a/libs/spandsp/src/spandsp/fsk.h b/libs/spandsp/src/spandsp/fsk.h index 03082ce3d0..9358b565cb 100644 --- a/libs/spandsp/src/spandsp/fsk.h +++ b/libs/spandsp/src/spandsp/fsk.h @@ -110,7 +110,8 @@ enum FSK_BELL103CH2, FSK_BELL202, FSK_WEITBRECHT, /* 45.45 baud version, used for TDD (Telecom Device for the Deaf) */ - FSK_WEITBRECHT50 /* 50 baud version, used for TDD (Telecom Device for the Deaf) */ + FSK_WEITBRECHT50, /* 50 baud version, used for TDD (Telecom Device for the Deaf) */ + FSK_V21CH1_110 /* 110 bps version of V.21 channel 1, as used by V.18 */ }; enum @@ -119,7 +120,8 @@ enum FSK_FRAME_MODE_SYNC = 1, FSK_FRAME_MODE_5N1_FRAMES = 7, /* 5 bits of data + start bit + stop bit */ FSK_FRAME_MODE_7N1_FRAMES = 9, /* 7 bits of data + start bit + stop bit */ - FSK_FRAME_MODE_8N1_FRAMES = 10 /* 8 bits of data + start bit + stop bit */ + FSK_FRAME_MODE_7E1_FRAMES = 10, /* 7 bits of data + even parity + start bit + stop bit */ + FSK_FRAME_MODE_7E2_FRAMES = 11 /* 7 bits of data + even parity + start bit + 2 stop bits */ }; SPAN_DECLARE_DATA extern const fsk_spec_t preset_fsk_specs[]; diff --git a/libs/spandsp/src/spandsp/ima_adpcm.h b/libs/spandsp/src/spandsp/ima_adpcm.h index 27be7ec736..2942efa859 100644 --- a/libs/spandsp/src/spandsp/ima_adpcm.h +++ b/libs/spandsp/src/spandsp/ima_adpcm.h @@ -1,8 +1,8 @@ /* * SpanDSP - a series of DSP components for telephony * - * ima_adpcm.c - Conversion routines between linear 16 bit PCM data and - * IMA/DVI/Intel ADPCM format. + * ima_adpcm.h - Conversion routines between linear 16 bit PCM data and + * IMA/DVI/Intel ADPCM format. * * Written by Steve Underwood * diff --git a/libs/spandsp/src/spandsp/image_translate.h b/libs/spandsp/src/spandsp/image_translate.h index b795c705af..d98848f369 100644 --- a/libs/spandsp/src/spandsp/image_translate.h +++ b/libs/spandsp/src/spandsp/image_translate.h @@ -2,8 +2,9 @@ * SpanDSP - a series of DSP components for telephony * * image_translate.h - Image translation routines for reworking colour - * and gray scale images to be bi-level images of an - * appropriate size to be FAX compatible. + * and gray scale images to be colour, gray scale or + * bi-level images of an appropriate size to be FAX + * compatible. * * Written by Steve Underwood * @@ -33,6 +34,11 @@ /*! \page image_translate_page Image translation \section image_translate_page_sec_1 What does it do? +The image translate functions allow an image to be translated and resized between +various colour an monochrome formats. It also allows a colour or gray-scale image +to be reduced to a bi-level monochrome image. This is useful for preparing images +to be sent as traditional bi-level FAX pages. + \section image_translate_page_sec_2 How does it work? \section image_translate_page_sec_3 How do I use it? @@ -40,15 +46,6 @@ typedef struct image_translate_state_s image_translate_state_t; -enum -{ - IMAGE_TRANSLATE_FROM_MONO = 1, - IMAGE_TRANSLATE_FROM_GRAY_8 = 2, - IMAGE_TRANSLATE_FROM_GRAY_16 = 3, - IMAGE_TRANSLATE_FROM_COLOUR_8 = 4, - IMAGE_TRANSLATE_FROM_COLOUR_16 = 5 -}; - #if defined(__cplusplus) extern "C" { @@ -75,9 +72,12 @@ SPAN_DECLARE(int) image_translate_get_output_length(image_translate_state_t *s); \param input_format x \param input_width The width of the source image, in pixels. \param input_length The length of the source image, in pixels. - \param output_width The width of the output image, in pixels. The length of the output image - will be derived automatically from this and the source image dimension, to main the - geometry of the original image. + \param output_format x + \param output_width The width of the output image, in pixels. If this is set <= 0 the image + will not be resized. + \param output_length The length of the output image, in pixels. If this is set to <= 0 the + output length will be derived automatically from the width, to maintain the geometry + of the original image. \param row_read_handler A callback routine used to pull rows of pixels from the source image into the translation process. \param row_read_user_data An opaque point passed to read_row_handler @@ -86,7 +86,9 @@ SPAN_DECLARE(image_translate_state_t *) image_translate_init(image_translate_sta int input_format, int input_width, int input_length, + int output_format, int output_width, + int output_length, t4_row_read_handler_t row_read_handler, void *row_read_user_data); diff --git a/libs/spandsp/src/spandsp/modem_connect_tones.h b/libs/spandsp/src/spandsp/modem_connect_tones.h index db3831bf28..7c0219f8a9 100644 --- a/libs/spandsp/src/spandsp/modem_connect_tones.h +++ b/libs/spandsp/src/spandsp/modem_connect_tones.h @@ -75,7 +75,12 @@ enum /*! \brief CED tone is the same as ANS tone. FAX preamble in a string of V.21 HDLC flag octets. This is only valid as a tone type to receive. It is never reported as a detected tone type. The report will either be for FAX preamble or CED/ANS tone. */ - MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE = 7 + MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE = 7, + /*! \brief Bell ANS tone is a pure continuous 2225Hz+-15Hz tone for 3.3s+-0.7s. */ + MODEM_CONNECT_TONES_BELL_ANS = 8, + /*! \brief Calling tone is a pure 1300Hz tone, in 0.6s bursts, with 2s silences in between. The + bursts repeat for as long as is required. */ + MODEM_CONNECT_TONES_CALLING_TONE = 9 }; /*! \brief FAX CED tone is the same as ANS tone. */ diff --git a/libs/spandsp/src/spandsp/private/ademco_contactid.h b/libs/spandsp/src/spandsp/private/ademco_contactid.h new file mode 100644 index 0000000000..bada9193a1 --- /dev/null +++ b/libs/spandsp/src/spandsp/private/ademco_contactid.h @@ -0,0 +1,95 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * private/ademco_contactid.h - Ademco ContactID alarm protocol + * + * Written by Steve Underwood + * + * Copyright (C) 2012 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_SPANDSP_PRIVATE_ADEMCO_CONTACTID_H_) +#define _SPANDSP_PRIVATE_ADEMCO_CONTACTID_H_ + +struct ademco_contactid_receiver_state_s +{ + ademco_contactid_report_func_t callback; + void *callback_user_data; + + int step; + int remaining_samples; + uint32_t tone_phase; + int32_t tone_phase_rate; + int16_t tone_level; + dtmf_rx_state_t dtmf; + + char rx_digits[16 + 1]; + int rx_digits_len; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; + +struct ademco_contactid_sender_state_s +{ + tone_report_func_t callback; + void *callback_user_data; + + int step; + int remaining_samples; + + dtmf_tx_state_t dtmf; +#if defined(SPANDSP_USE_FIXED_POINT) + /*! Minimum acceptable tone level for detection. */ + int32_t threshold; + /*! The accumlating total energy on the same period over which the Goertzels work. */ + int32_t energy; +#else + /*! Minimum acceptable tone level for detection. */ + float threshold; + /*! The accumlating total energy on the same period over which the Goertzels work. */ + float energy; +#endif + goertzel_state_t tone_1400; + goertzel_state_t tone_2300; + /*! The current sample number within a processing block. */ + int current_sample; + + /*! \brief A buffer to save the sent message, in case we need to retry. */ + char tx_digits[16 + 1]; + int tx_digits_len; + /*! \brief The number of consecutive retries. */ + int tries; + + int tone_state; + int duration; + int last_hit; + int in_tone; + int clear_to_send; + int timer; + + int busy; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/async.h b/libs/spandsp/src/spandsp/private/async.h index c3837641df..715d659d9e 100644 --- a/libs/spandsp/src/spandsp/private/async.h +++ b/libs/spandsp/src/spandsp/private/async.h @@ -45,7 +45,7 @@ struct async_tx_state_s void *user_data; /*! \brief A current, partially transmitted, character. */ - int byte_in_progress; + unsigned int byte_in_progress; /*! \brief The current bit position within a partially transmitted character. */ int bitpos; /*! \brief Parity bit. */ @@ -73,7 +73,7 @@ struct async_rx_state_s void *user_data; /*! \brief A current, partially complete, character. */ - int byte_in_progress; + unsigned int byte_in_progress; /*! \brief The current bit position within a partially complete character. */ int bitpos; /*! \brief Parity bit. */ diff --git a/libs/spandsp/src/spandsp/private/at_interpreter.h b/libs/spandsp/src/spandsp/private/at_interpreter.h index da13b5a2bb..a99dea9a35 100644 --- a/libs/spandsp/src/spandsp/private/at_interpreter.h +++ b/libs/spandsp/src/spandsp/private/at_interpreter.h @@ -113,11 +113,11 @@ struct at_state_s char line[256]; int line_ptr; - at_modem_control_handler_t *modem_control_handler; + at_modem_control_handler_t modem_control_handler; void *modem_control_user_data; - at_tx_handler_t *at_tx_handler; + at_tx_handler_t at_tx_handler; void *at_tx_user_data; - at_class1_handler_t *class1_handler; + at_class1_handler_t class1_handler; void *class1_user_data; /*! \brief Error and flow logging control */ diff --git a/libs/spandsp/src/spandsp/private/fax_modems.h b/libs/spandsp/src/spandsp/private/fax_modems.h index 4250198ded..280be1d1cf 100644 --- a/libs/spandsp/src/spandsp/private/fax_modems.h +++ b/libs/spandsp/src/spandsp/private/fax_modems.h @@ -52,7 +52,7 @@ struct fax_modems_state_s /*! \brief A V.21 FSK modem context used when receiving HDLC over V.21 messages. */ fsk_rx_state_t v21_rx; - struct + union { /*! \brief A V.17 modem context used when sending FAXes at 7200bps, 9600bps 12000bps or 14400bps */ @@ -82,11 +82,30 @@ struct fax_modems_state_s /*! \brief */ dc_restore_state_t dc_restore; + /*! \brief The fast modem type currently in use */ + int fast_modem; + /*! \brief The currently selected receiver type */ int current_rx_type; /*! \brief The currently selected transmitter type */ int current_tx_type; + int bit_rate; + int short_train; + + /*! \brief The callback function used to put each bit received. */ + put_bit_func_t put_bit; + /*! \brief A user specified opaque pointer passed to the put_bit routine. */ + void *put_bit_user_data; + + /*! \brief The callback function used to get the next bit to be transmitted. */ + get_bit_func_t get_bit; + /*! \brief A user specified opaque pointer passed to the get_bit function. */ + void *get_bit_user_data; + + hdlc_frame_handler_t hdlc_accept; + void *hdlc_accept_user_data; + /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ int rx_signal_present; /*! \brief TRUE if a modem has trained correctly. */ @@ -94,27 +113,35 @@ struct fax_modems_state_s /*! \brief TRUE if an HDLC frame has been received correctly. */ int rx_frame_received; + int deferred_rx_handler_updates; /*! \brief The current receive signal handler */ - span_rx_handler_t *rx_handler; - /*! \brief The current receive missing signal fill-in handler */ - span_rx_fillin_handler_t *rx_fillin_handler; + span_rx_handler_t rx_handler; + /*! \brief The current receive signal handler. Actual receiving hops between this + and a dummy receive routine. */ + span_rx_handler_t base_rx_handler; void *rx_user_data; + /*! \brief The current receive missing signal fill-in handler */ + span_rx_fillin_handler_t rx_fillin_handler; + /*! \brief The current receive signal fillin handler. Actual receiving hops between this + and a dummy receive routine. */ + span_rx_fillin_handler_t base_rx_fillin_handler; + void *rx_fillin_user_data; /*! \brief The current transmit signal handler */ - span_tx_handler_t *tx_handler; + span_tx_handler_t tx_handler; void *tx_user_data; /*! The next transmit signal handler, for two stage transmit operations. E.g. a short silence followed by a modem signal. */ - span_tx_handler_t *next_tx_handler; + span_tx_handler_t next_tx_handler; void *next_tx_user_data; - /*! The current bit rate of the transmitter. */ + /*! \brief The current bit rate of the transmitter. */ int tx_bit_rate; - /*! The current bit rate of the receiver. */ + /*! \brief The current bit rate of the receiver. */ int rx_bit_rate; - /*! If TRUE, transmission is in progress */ + /*! \brief If TRUE, transmission is in progress */ int transmit; /*! \brief Audio logging file handle for received audio. */ int audio_rx_log; diff --git a/libs/spandsp/src/spandsp/private/fsk.h b/libs/spandsp/src/spandsp/private/fsk.h index c1c1720157..3d3a5333b1 100644 --- a/libs/spandsp/src/spandsp/private/fsk.h +++ b/libs/spandsp/src/spandsp/private/fsk.h @@ -88,7 +88,7 @@ struct fsk_rx_state_s int buf_ptr; int frame_state; - int frame_bits; + unsigned int frame_bits; int baud_phase; int last_bit; int scaling_shift; diff --git a/libs/spandsp/src/spandsp/private/ima_adpcm.h b/libs/spandsp/src/spandsp/private/ima_adpcm.h index 1685906c28..2fc7d2c114 100644 --- a/libs/spandsp/src/spandsp/private/ima_adpcm.h +++ b/libs/spandsp/src/spandsp/private/ima_adpcm.h @@ -1,8 +1,8 @@ /* * SpanDSP - a series of DSP components for telephony * - * private/ima_adpcm.c - Conversion routines between linear 16 bit PCM data - * and IMA/DVI/Intel ADPCM format. + * private/ima_adpcm.h - Conversion routines between linear 16 bit PCM data + * and IMA/DVI/Intel ADPCM format. * * Written by Steve Underwood * diff --git a/libs/spandsp/src/spandsp/private/image_translate.h b/libs/spandsp/src/spandsp/private/image_translate.h index a4f7daa81f..02a13506df 100644 --- a/libs/spandsp/src/spandsp/private/image_translate.h +++ b/libs/spandsp/src/spandsp/private/image_translate.h @@ -1,7 +1,7 @@ /* * SpanDSP - a series of DSP components for telephony * - * private/image_translate.c - Image translation routines for reworking colour + * private/image_translate.h - Image translation routines for reworking colour * and gray scale images to be bi-level images of an * appropriate size to be FAX compatible. * @@ -33,10 +33,12 @@ struct image_translate_state_s int input_format; int input_width; int input_length; + int input_bytes_per_pixel; + int output_format; int output_width; int output_length; + int output_bytes_per_pixel; int resize; - int bytes_per_pixel; int raw_input_row; int raw_output_row; int output_row; diff --git a/libs/spandsp/src/spandsp/private/super_tone_rx.h b/libs/spandsp/src/spandsp/private/super_tone_rx.h index 1f0fd98564..e62d455d47 100644 --- a/libs/spandsp/src/spandsp/private/super_tone_rx.h +++ b/libs/spandsp/src/spandsp/private/super_tone_rx.h @@ -26,7 +26,7 @@ #if !defined(_SPANDSP_PRIVATE_SUPER_TONE_RX_H_) #define _SPANDSP_PRIVATE_SUPER_TONE_RX_H_ -#define BINS 128 +#define SUPER_TONE_BINS 128 struct super_tone_rx_segment_s { @@ -41,7 +41,7 @@ struct super_tone_rx_descriptor_s { int used_frequencies; int monitored_frequencies; - int pitches[BINS/2][2]; + int pitches[SUPER_TONE_BINS/2][2]; int tones; super_tone_rx_segment_t **tone_list; int *tone_segs; @@ -55,7 +55,7 @@ struct super_tone_rx_state_s int detected_tone; int rotation; tone_report_func_t tone_callback; - void (*segment_callback)(void *data, int f1, int f2, int duration); + tone_segment_func_t segment_callback; void *callback_data; super_tone_rx_segment_t segments[11]; goertzel_state_t state[]; diff --git a/libs/spandsp/src/spandsp/private/t30.h b/libs/spandsp/src/spandsp/private/t30.h index 8cd890b9e0..1fede6ed79 100644 --- a/libs/spandsp/src/spandsp/private/t30.h +++ b/libs/spandsp/src/spandsp/private/t30.h @@ -37,8 +37,8 @@ struct t30_state_s /*! \brief T.4 context for reading or writing image data. */ union { - t4_state_t rx; - t4_state_t tx; + t4_rx_state_t rx; + t4_tx_state_t tx; } t4; /*! \brief The type of FAX operation currently in progress */ int operation_in_progress; @@ -94,42 +94,42 @@ struct t30_state_s /*! \brief A pointer to a callback routine to be called when phase B events occur. */ - t30_phase_b_handler_t *phase_b_handler; + t30_phase_b_handler_t phase_b_handler; /*! \brief An opaque pointer supplied in event B callbacks. */ void *phase_b_user_data; /*! \brief A pointer to a callback routine to be called when phase D events occur. */ - t30_phase_d_handler_t *phase_d_handler; + t30_phase_d_handler_t phase_d_handler; /*! \brief An opaque pointer supplied in event D callbacks. */ void *phase_d_user_data; /*! \brief A pointer to a callback routine to be called when phase E events occur. */ - t30_phase_e_handler_t *phase_e_handler; + t30_phase_e_handler_t phase_e_handler; /*! \brief An opaque pointer supplied in event E callbacks. */ void *phase_e_user_data; /*! \brief A pointer to a callback routine to be called when frames are exchanged. */ - t30_real_time_frame_handler_t *real_time_frame_handler; + t30_real_time_frame_handler_t real_time_frame_handler; /*! \brief An opaque pointer supplied in real time frame callbacks. */ void *real_time_frame_user_data; /*! \brief A pointer to a callback routine to be called when document events (e.g. end of transmitted document) occur. */ - t30_document_handler_t *document_handler; + t30_document_handler_t document_handler; /*! \brief An opaque pointer supplied in document callbacks. */ void *document_user_data; /*! \brief The handler for changes to the receive mode */ - t30_set_handler_t *set_rx_type_handler; + t30_set_handler_t set_rx_type_handler; /*! \brief An opaque pointer passed to the handler for changes to the receive mode */ void *set_rx_type_user_data; /*! \brief The handler for changes to the transmit mode */ - t30_set_handler_t *set_tx_type_handler; + t30_set_handler_t set_tx_type_handler; /*! \brief An opaque pointer passed to the handler for changes to the transmit mode */ void *set_tx_type_user_data; /*! \brief The transmitted HDLC frame handler. */ - t30_send_hdlc_handler_t *send_hdlc_handler; + t30_send_hdlc_handler_t send_hdlc_handler; /*! \brief An opaque pointer passed to the transmitted HDLC frame handler. */ void *send_hdlc_user_data; diff --git a/libs/spandsp/src/spandsp/private/t31.h b/libs/spandsp/src/spandsp/private/t31.h index ee481c5151..fafdf72341 100644 --- a/libs/spandsp/src/spandsp/private/t31.h +++ b/libs/spandsp/src/spandsp/private/t31.h @@ -36,7 +36,7 @@ typedef struct v8_state_t v8; /*! The transmit signal handler to be used when the current one has finished sending. */ - span_tx_handler_t *next_tx_handler; + span_tx_handler_t next_tx_handler; void *next_tx_user_data; /*! \brief No of data bits in current_byte. */ @@ -136,7 +136,7 @@ typedef struct struct t31_state_s { at_state_t at_state; - t31_modem_control_handler_t *modem_control_handler; + t31_modem_control_handler_t modem_control_handler; void *modem_control_user_data; t31_audio_front_end_state_t audio; diff --git a/libs/spandsp/src/spandsp/private/t38_core.h b/libs/spandsp/src/spandsp/private/t38_core.h index de0aac9d60..e965ca6f40 100644 --- a/libs/spandsp/src/spandsp/private/t38_core.h +++ b/libs/spandsp/src/spandsp/private/t38_core.h @@ -32,16 +32,16 @@ struct t38_core_state_s { /*! \brief Handler routine to transmit IFP packets generated by the T.38 protocol engine */ - t38_tx_packet_handler_t *tx_packet_handler; + t38_tx_packet_handler_t tx_packet_handler; /*! \brief An opaque pointer passed to tx_packet_handler */ void *tx_packet_user_data; /*! \brief Handler routine to process received indicator packets */ - t38_rx_indicator_handler_t *rx_indicator_handler; + t38_rx_indicator_handler_t rx_indicator_handler; /*! \brief Handler routine to process received data packets */ - t38_rx_data_handler_t *rx_data_handler; + t38_rx_data_handler_t rx_data_handler; /*! \brief Handler routine to process the missing packet condition */ - t38_rx_missing_handler_t *rx_missing_handler; + t38_rx_missing_handler_t rx_missing_handler; /*! \brief An opaque pointer passed to any of the above receive handling routines */ void *rx_user_data; diff --git a/libs/spandsp/src/spandsp/private/t38_gateway.h b/libs/spandsp/src/spandsp/private/t38_gateway.h index 54a935a270..fbe1409322 100644 --- a/libs/spandsp/src/spandsp/private/t38_gateway.h +++ b/libs/spandsp/src/spandsp/private/t38_gateway.h @@ -59,10 +59,6 @@ typedef struct { /*! \brief The FAX modem set for the audio side fo the gateway. */ fax_modems_state_t modems; - /*! \brief The current receive signal handler. Actual receiving hops between this - and a dummy receive routine. */ - span_rx_handler_t *base_rx_handler; - span_rx_fillin_handler_t *base_rx_fillin_handler; } t38_gateway_audio_state_t; /*! @@ -86,8 +82,8 @@ typedef struct uint16_t crc; /*! \brief TRUE if non-ECM fill bits are to be stripped when sending image data. */ int fill_bit_removal; - /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current - rate and the current specified packet interval. */ + /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at + the current rate and the current specified packet interval. */ int octets_per_data_packet; /*! \brief Bits into the non-ECM buffer */ @@ -183,7 +179,7 @@ typedef struct /*! \brief A pointer to a callback routine to be called when frames are exchanged. */ - t38_gateway_real_time_frame_handler_t *real_time_frame_handler; + t38_gateway_real_time_frame_handler_t real_time_frame_handler; /*! \brief An opaque pointer supplied in real time frame callbacks. */ void *real_time_frame_user_data; } t38_gateway_core_state_t; diff --git a/libs/spandsp/src/spandsp/private/t42.h b/libs/spandsp/src/spandsp/private/t42.h new file mode 100644 index 0000000000..bfdae884eb --- /dev/null +++ b/libs/spandsp/src/spandsp/private/t42.h @@ -0,0 +1,97 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * private/t42.h - ITU T.42 JPEG for FAX image processing + * + * Written by Steve Underwood + * + * Copyright (C) 2011 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#if !defined(_SPANDSP_PRIVATE_T42_H_) +#define _SPANDSP_PRIVATE_T42_H_ + +struct lab_params_s +{ + /* Lab gamut */ + float range_L; + float range_a; + float range_b; + float offset_L; + float offset_a; + float offset_b; + int ab_are_signed; + + /* Illuminant */ + float x_n; + float y_n; + float z_n; +}; + +/* State of a working instance of the T.42 JPEG FAX encoder */ +struct t42_encode_state_s +{ + /*! \brief Callback function to read a row of pixels from the image source. */ + t4_row_read_handler_t row_read_handler; + /*! \brief Opaque pointer passed to row_read_handler. */ + void *row_read_user_data; + + lab_params_t lab_params; + + /*! \brief The size of the compressed image, in bytes. */ + int compressed_image_size; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; + +/* State of a working instance of the T.42 JPEG FAX decoder */ +struct t42_decode_state_s +{ + /*! A callback routine to handle decoded pixel rows */ + t4_row_write_handler_t row_write_handler; + /*! An opaque pointer passed to row_write_handler() */ + void *row_write_user_data; + /*! A callback routine to handle decoded comments */ + t4_row_write_handler_t comment_handler; + /*! An opaque pointer passed to comment_handler() */ + void *comment_user_data; + /*! The maximum length of comment to be passed to the comment handler */ + uint32_t max_comment_len; + + lab_params_t lab_params; + + /*! The contents for a COMMENT marker segment, to be added to the + image at the next opportunity. This is set to NULL when nothing is + pending. */ + uint8_t *comment; + /*! Length of data pointed to by comment */ + size_t comment_len; + + /*! \brief The size of the compressed image, in bytes. */ + int compressed_image_size; + + int buf_size; + uint8_t *compressed_buf; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/t4_rx.h b/libs/spandsp/src/spandsp/private/t4_rx.h index 10ed0cf983..44eb2d2664 100644 --- a/libs/spandsp/src/spandsp/private/t4_rx.h +++ b/libs/spandsp/src/spandsp/private/t4_rx.h @@ -36,37 +36,95 @@ typedef struct /*! \brief The libtiff context for the current TIFF file */ TIFF *tiff_file; + /*! Image type - bilevel, gray, colour */ + int image_type; /*! \brief The compression type for output to the TIFF file. */ - int32_t output_compression; + int output_encoding; /*! \brief The TIFF photometric setting for the current page. */ uint16_t photo_metric; /*! \brief The TIFF fill order setting for the current page. */ uint16_t fill_order; - /*! \brief The TIFF G3 FAX options. */ - int32_t output_t4_options; /*! \brief The number of pages in the current image file. */ int pages_in_file; + /*! \brief The time at which handling of the current page began. */ + time_t page_start_time; + + /*! \brief A point to the image buffer. */ + uint8_t *image_buffer; + /*! \brief The size of the image in the image buffer, in bytes. */ + int image_size; + /*! \brief The current size of the image buffer. */ + int image_buffer_size; +} t4_rx_tiff_state_t; + +/*! + T.4 FAX decompression metadata descriptor. This contains information about the image + which may be relevant to the backend, but is not relevant to the image decoding process. +*/ +typedef struct +{ + /*! \brief Column-to-column (X) resolution in pixels per metre. */ + int x_resolution; + /*! \brief Row-to-row (Y) resolution in pixels per metre. */ + int y_resolution; + /* "Background" information about the FAX, which can be stored in the image file. */ /*! \brief The vendor of the machine which produced the file. */ const char *vendor; /*! \brief The model of machine which produced the file. */ const char *model; - /*! \brief The local ident string. */ - const char *local_ident; /*! \brief The remote end's ident string. */ const char *far_ident; /*! \brief The FAX sub-address. */ const char *sub_address; /*! \brief The FAX DCS information, as an ASCII hex string. */ const char *dcs; +} t4_rx_metadata_t; - /*! \brief The first page to transfer. -1 to start at the beginning of the file. */ - int start_page; - /*! \brief The last page to transfer. -1 to continue to the end of the file. */ - int stop_page; -} t4_tiff_state_t; +/*! + T.4 FAX decompression descriptor. This defines the working state + for a single instance of a T.4 FAX decompression channel. +*/ +struct t4_rx_state_s +{ + /*! \brief Callback function to write a row of pixels to the image destination. */ + t4_row_write_handler_t row_handler; + /*! \brief Opaque pointer passed to row_write_handler. */ + void *row_handler_user_data; + + /*! \brief The number of pages transferred to date. */ + int current_page; + + /*! \brief The size of the compressed image on the line side, in bits. */ + int line_image_size; + + /*! \brief The type of compression used between the FAX machines. */ + int line_encoding; + + /*! \brief The width of the current page, in pixels. */ + uint32_t image_width; + + union + { + t4_t6_decode_state_t t4_t6; + t42_decode_state_t t42; +#if defined(SPANDSP_SUPPORT_T43) + t43_decode_state_t t43; +#endif + t85_decode_state_t t85; + } decoder; + + /* Supporting information, like resolutions, which the backend may want. */ + t4_rx_metadata_t metadata; + + /*! \brief All TIFF file specific state information for the T.4 context. */ + t4_rx_tiff_state_t tiff; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/t4_t6_decode.h b/libs/spandsp/src/spandsp/private/t4_t6_decode.h index 1b15fc7f61..90b4e72d66 100644 --- a/libs/spandsp/src/spandsp/private/t4_t6_decode.h +++ b/libs/spandsp/src/spandsp/private/t4_t6_decode.h @@ -31,18 +31,36 @@ */ struct t4_t6_decode_state_s { - /*! \brief The type of compression used between the FAX machines. */ - //int encoding; - /*! \brief Width of the current page, in pixels. */ - //int image_width; - /*! \brief Callback function to write a row of pixels to the image destination. */ t4_row_write_handler_t row_write_handler; /*! \brief Opaque pointer passed to row_write_handler. */ void *row_write_user_data; - /*! \brief A pointer into the image buffer indicating where the last row begins */ - int last_row_starts_at; + /*! \brief The type of compression used between the FAX machines. */ + int encoding; + /*! \brief Width of the current page, in pixels. */ + int image_width; + + /*! \brief Length of the current page, in pixels. */ + int image_length; + /*! \brief The current number of bytes per row of uncompressed image data. */ + int bytes_per_row; + + /*! \brief The current number of bits in the current encoded row. */ + int row_bits; + /*! \brief Pointer to the buffer for the current pixel row. */ + uint8_t *row_buf; + + /*! \brief This variable is set if we are treating the current row as a 2D encoded + one. */ + int row_is_2d; + /*! \brief The current length of the current row. */ + int row_len; + + /*! \brief Black and white run-lengths for the current row. */ + uint32_t *cur_runs; + /*! \brief Black and white run-lengths for the reference row. */ + uint32_t *ref_runs; /*! \brief This variable is used to count the consecutive EOLS we have seen. If it reaches six, this is the end of the image. It is initially set to -1 for @@ -64,7 +82,7 @@ struct t4_t6_decode_state_s /*! \brief 2D horizontal mode control. */ int black_white; /*! \brief TRUE if the current run is black */ - int its_black; + int in_black; /*! \brief The current step into the current row run-lengths buffer. */ int a_cursor; @@ -78,14 +96,18 @@ struct t4_t6_decode_state_s /*! \brief The number of bits to be skipped before trying to match the next code word. */ int rx_skip_bits; - /*! \brief Decoded pixel buffer. */ - //uint32_t pixel_stream; - /*! \brief The number of bits currently in pixel_stream. */ - //int tx_bits; + /*! \brief Decoded pixel stream buffer. */ + uint32_t pixel_stream; + /*! \brief The number of pixels currently in pixel_stream. */ + int pixels; - /*! \brief Current pixel row number. */ - //int row; + /*! \brief The minimum bits in any row of the current page. For monitoring only. */ + int min_row_bits; + /*! \brief The maximum bits in any row of the current page. For monitoring only. */ + int max_row_bits; + /*! \brief The size of the compressed image, in bits. */ + int compressed_image_size; /*! \brief The current number of consecutive bad rows. */ int curr_bad_row_run; /*! \brief The longest run of consecutive bad rows seen in the current page. */ @@ -94,7 +116,7 @@ struct t4_t6_decode_state_s int bad_rows; /*! \brief Error and flow logging control */ - //logging_state_t logging; + logging_state_t logging; }; #endif diff --git a/libs/spandsp/src/spandsp/private/t4_t6_encode.h b/libs/spandsp/src/spandsp/private/t4_t6_encode.h index 40d750b732..ea080109aa 100644 --- a/libs/spandsp/src/spandsp/private/t4_t6_encode.h +++ b/libs/spandsp/src/spandsp/private/t4_t6_encode.h @@ -31,28 +31,66 @@ */ struct t4_t6_encode_state_s { + /*! \brief Callback function to read a row of pixels from the image source. */ + t4_row_read_handler_t row_read_handler; + /*! \brief Opaque pointer passed to row_read_handler. */ + void *row_read_user_data; + + /*! \brief The type of compression used. */ + int encoding; + /*! \brief Width of the current page, in pixels. */ + int image_width; /*! \brief The minimum number of encoded bits per row. This is a timing thing for hardware FAX machines. */ int min_bits_per_row; /*! \brief The current maximum contiguous rows that may be 2D encoded. */ int max_rows_to_next_1d_row; + /*! \brief Length of the current page, in pixels. */ + int image_length; + /*! \brief The current number of bytes per row of uncompressed image data. */ + int bytes_per_row; + /*! \brief Number of rows left that can be 2D encoded, before a 1D encoded row must be used. */ int rows_to_next_1d_row; + /*! \brief The current number of bits in the current encoded row. */ + int row_bits; + /*! \brief This variable is set if we are treating the current row as a 2D encoded + one. */ + int row_is_2d; + + /*! \brief Encoded data bits buffer. */ + uint32_t tx_bitstream; + /*! \brief The number of bits currently in tx_bitstream. */ + int tx_bits; + /*! \brief The working chunk of the output bit stream */ + uint8_t *bitstream; + /*! \brief Input pointer to the output bit stream buffer. */ + int bitstream_iptr; + /*! \brief Output pointer to the output bit stream buffer. */ + int bitstream_optr; + /*! \brief Pointer to the bit within the byte containing the next image bit to transmit. */ + int bit_pos; + + /*! \brief Black and white run-lengths for the current row. */ + uint32_t *cur_runs; + /*! \brief Black and white run-lengths for the reference row. */ + uint32_t *ref_runs; /*! \brief The number of runs currently in the reference row. */ int ref_steps; - /*! \brief Pointer to the byte containing the next image bit to transmit. */ - int bit_pos; - /*! \brief Pointer to the bit within the byte containing the next image bit to transmit. */ - int bit_ptr; + /*! \brief The minimum bits in any row of the current page. For monitoring only. */ + int min_row_bits; + /*! \brief The maximum bits in any row of the current page. For monitoring only. */ + int max_row_bits; - /*! \brief Callback function to read a row of pixels from the image source. */ - t4_row_read_handler_t row_read_handler; - /*! \brief Opaque pointer passed to row_read_handler. */ - void *row_read_user_data; + /*! \brief The size of the compressed image, in bits. */ + int compressed_image_size; + + /*! \brief Error and flow logging control */ + logging_state_t logging; }; #endif diff --git a/libs/spandsp/src/spandsp/private/t4_tx.h b/libs/spandsp/src/spandsp/private/t4_tx.h index d56c392afc..dee5f84b92 100644 --- a/libs/spandsp/src/spandsp/private/t4_tx.h +++ b/libs/spandsp/src/spandsp/private/t4_tx.h @@ -27,20 +27,87 @@ #define _SPANDSP_PRIVATE_T4_TX_H_ /*! - T.4 FAX compression/decompression descriptor. This defines the working state - for a single instance of a T.4 FAX compression or decompression channel. + TIFF specific state information to go with T.4 compression or decompression handling. */ -struct t4_state_s +typedef struct { - /*! \brief The same structure is used for T.4 transmit and receive. This variable - records which mode is in progress. */ - int rx; + /*! \brief The current file name. */ + const char *file; + /*! \brief The libtiff context for the current TIFF file */ + TIFF *tiff_file; + + /*! \brief The compression type used in the TIFF file */ + uint16_t compression; + /*! \brief Image type - bilevel, gray, colour */ + int image_type; + /*! \brief The TIFF photometric setting for the current page. */ + uint16_t photo_metric; + /*! \brief The TIFF fill order setting for the current page. */ + uint16_t fill_order; + + /*! \brief The number of pages in the current image file. */ + int pages_in_file; + + /*! \brief A pointer to the image buffer. */ + uint8_t *image_buffer; + /*! \brief The size of the image in the image buffer, in bytes. */ + int image_size; + /*! \brief The current size of the image buffer. */ + int image_buffer_size; + /*! \brief Row counter for playing out the rows of the image. */ + int row; + + /*! \brief Image length of the image in the file. This is used when the + image is resized or dithered flat. */ + int image_length; + /*! \brief Row counter used when the image is resized or dithered flat. */ + int raw_row; +} t4_tx_tiff_state_t; + +/*! + T.4 FAX compression metadata descriptor. This contains information about the image + which may be relevant to the backend, but is not generally relevant to the image + encoding process. The exception here is the y-resolution, which is used in T.4 2-D + encoding for non-ECM applications, to optimise the balance of density and robustness. +*/ +typedef struct +{ + /*! \brief Column-to-column (X) resolution in pixels per metre. */ + int x_resolution; + /*! \brief Row-to-row (Y) resolution in pixels per metre. */ + int y_resolution; +} t4_tx_metadata_t; + +/*! + T.4 FAX compression descriptor. This defines the working state + for a single instance of a T.4 FAX compression channel. +*/ +struct t4_tx_state_s +{ + /*! \brief Callback function to read a row of pixels from the image source. */ + t4_row_read_handler_t row_handler; + /*! \brief Opaque pointer passed to row_read_handler. */ + void *row_handler_user_data; /*! \brief The type of compression used between the FAX machines. */ int line_encoding; - /*! \brief The time at which handling of the current page began. */ - time_t page_start_time; + int line_encoding_bilevel; + int line_encoding_gray; + int line_encoding_colour; + + /*! \brief The width of the current page, in pixels. */ + uint32_t image_width; + /*! \brief The length of the current page, in pixels. */ + uint32_t image_length; + + /*! \brief The size of the compressed image on the line side, in bits. */ + int line_image_size; + + /*! \brief The first page to transfer. -1 to start at the beginning of the file. */ + int start_page; + /*! \brief The last page to transfer. -1 to continue to the end of the file. */ + int stop_page; /*! \brief TRUE for FAX page headers to overlay (i.e. replace) the beginning of the page image. FALSE for FAX page headers to add to the overall length of @@ -49,66 +116,47 @@ struct t4_state_s /*! \brief The text which will be used in FAX page header. No text results in no header line. */ const char *header_info; - /*! \brief Optional per instance time zone for the FAX page header timestamp. */ - struct tz_s *tz; - - /*! \brief The size of the compressed image on the line side, in bits. */ - int line_image_size; - - /*! \brief The current number of bytes per row of uncompressed image data. */ - int bytes_per_row; - /*! \brief The size of the image in the image buffer, in bytes. */ - int image_size; - /*! \brief The current size of the image buffer. */ - int image_buffer_size; - /*! \brief A point to the image buffer. */ - uint8_t *image_buffer; - - /*! \brief The number of pages transferred to date. */ + /*! \brief The local ident string. This is used with header_info to form a + page header line. */ + const char *local_ident; + /*! \brief The page number of current page. The first page is zero. If FAX page + headers are used, the page number in the header will be one more than + this value (i.e. they start from 1). */ int current_page; - /*! \brief Column-to-column (X) resolution in pixels per metre. */ - int x_resolution; - /*! \brief Row-to-row (Y) resolution in pixels per metre. */ - int y_resolution; - /*! \brief Width of the current page, in pixels. */ - int image_width; - /*! \brief Length of the current page, in pixels. */ - int image_length; - /*! \brief Current pixel row number. */ - int row; - /*! \brief This variable is set if we are treating the current row as a 2D encoded - one. */ - int row_is_2d; - /*! \brief The current length of the current row. */ - int row_len; + /*! \brief The composed text of the FAX page header, if there is one. */ + char *header_text; + /*! \brief Optional per instance time zone for the FAX page header timestamp. */ + tz_t *tz; - /*! \brief Black and white run-lengths for the current row. */ - uint32_t *cur_runs; - /*! \brief Black and white run-lengths for the reference row. */ - uint32_t *ref_runs; - /*! \brief Pointer to the buffer for the current pixel row. */ - uint8_t *row_buf; + /*! \brief Row counter for playing out the rows of the header line. */ + int header_row; - /*! \brief Encoded data bits buffer. */ - uint32_t tx_bitstream; - /*! \brief The number of bits currently in tx_bitstream. */ - int tx_bits; + union + { + t4_t6_encode_state_t t4_t6; + t42_encode_state_t t42; +#if defined(SPANDSP_SUPPORT_T43) + t43_encode_state_t t43; +#endif + t85_encode_state_t t85; + } encoder; - /*! \brief The current number of bits in the current encoded row. */ - int row_bits; - /*! \brief The minimum bits in any row of the current page. For monitoring only. */ - int min_row_bits; - /*! \brief The maximum bits in any row of the current page. For monitoring only. */ - int max_row_bits; + image_translate_state_t translator; + + int apply_lab; + lab_params_t lab_params; + uint8_t *colour_map; + int colour_map_entries; + + /* Supporting information, like resolutions, which the backend may want. */ + t4_tx_metadata_t metadata; + + /*! \brief All TIFF file specific state information for the T.4 context. */ + t4_tx_tiff_state_t tiff; /*! \brief Error and flow logging control */ logging_state_t logging; - - /*! \brief All TIFF file specific state information for the T.4 context. */ - t4_tiff_state_t tiff; - t4_t6_decode_state_t t4_t6_rx; - t4_t6_encode_state_t t4_t6_tx; }; #endif diff --git a/libs/spandsp/src/spandsp/private/t81_t82_arith_coding.h b/libs/spandsp/src/spandsp/private/t81_t82_arith_coding.h new file mode 100644 index 0000000000..0efe3f00ca --- /dev/null +++ b/libs/spandsp/src/spandsp/private/t81_t82_arith_coding.h @@ -0,0 +1,79 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t81_t82_arith_coding.h - ITU T.81 and T.82 QM-coder arithmetic encoding + * and decoding + * + * Written by Steve Underwood + * + * Copyright (C) 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_SPANDSP_PRIVATE_T81_T82_ARITH_CODING_H_) +#define _SPANDSP_PRIVATE_T81_T82_ARITH_CODING_H_ + +/* State of a working instance of the QM-coder arithmetic encoder */ +struct t81_t82_arith_encode_state_s +{ + /*! A register - see T.82 Table 23 */ + uint32_t a; + /*! C register - see T.82 Table 23 */ + uint32_t c; + /*! Probability status for contexts. MSB = MPS */ + uint8_t st[4096]; + /*! Number of buffered 0xFF values that might still overflow */ + int32_t sc; + /*! Bit shift counter. This determines when the next byte will be written */ + int ct; + /*! Buffer for the most recent output byte which is not 0xFF */ + int buffer; + /*! Callback function to deliver the encoded data, byte by byte */ + void (*output_byte_handler)(void *, int); + /*! Opaque pointer passed to byte_out */ + void *user_data; +}; + +/* State of a working instance of the QM-coder arithmetic decoder */ +struct t81_t82_arith_decode_state_s +{ + /*! A register - see T.82 Table 25 */ + uint32_t a; + /*! C register - see T.82 Table 25 */ + uint32_t c; + /*! Probability status for contexts. MSB = MPS */ + uint8_t st[4096]; + /*! Bit-shift counter. Determines when next byte will be read. + Special value -1 signals that zero-padding has started */ + int ct; + /*! Pointer to next PSCD data byte */ + const uint8_t *pscd_ptr; + /*! Pointer to byte after PSCD */ + const uint8_t *pscd_end; + /*! Boolean flag that controls initial fill of s->c */ + int startup; + /*! Boolean flag that triggers return -2 between reaching PSCD end + and decoding the first symbol that might never have been encoded + in the first place */ + int nopadding; +}; + +#endif + +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/t85.h b/libs/spandsp/src/spandsp/private/t85.h new file mode 100644 index 0000000000..c3e62e8c83 --- /dev/null +++ b/libs/spandsp/src/spandsp/private/t85.h @@ -0,0 +1,212 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * private/t85.h - ITU T.85 JBIG for FAX image processing + * + * Written by Steve Underwood + * + * Copyright (C) 2008, 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#if !defined(_SPANDSP_PRIVATE_T85_H_) +#define _SPANDSP_PRIVATE_T85_H_ + +/* Maximum number of ATMOVEs per stripe that the decoder can handle */ +#define T85_ATMOVES_MAX 1 + +/* TP special pixels */ +#define TPB2CX 0x195 +#define TPB3CX 0x0E5 + +/* T.82 table 2 - symbolic constants */ +enum +{ + T82_STUFF = 0x00, + T82_RESERVE = 0x01, + T82_SDNORM = 0x02, + T82_SDRST = 0x03, + T82_ABORT = 0x04, + T82_NEWLEN = 0x05, + T82_ATMOVE = 0x06, + T82_COMMENT = 0x07, + T82_ESC = 0xFF +}; + +/* State of a working instance of the T.85 JBIG FAX encoder */ +struct t85_encode_state_s +{ + /*! \brief Callback function to read a row of pixels from the image source. */ + t4_row_read_handler_t row_read_handler; + /*! \brief Opaque pointer passed to row_read_handler. */ + void *row_read_user_data; + + /*! The number of bit planes. Always 1 for true T.85 */ + uint8_t bit_planes; + uint8_t current_bit_plane; + /*! The width of the full image, in pixels */ + uint32_t xd; + /*! The height of the full image, in pixels */ + uint32_t yd; + /*! The number of rows per stripe */ + uint32_t l0; + /*! Maximum ATMOVE window size (0 - 127) */ + int mx; + /*! Encoding parameters */ + int options; + /*! The contents for a COMMENT marker segment, to be added to the + image at the next opportunity. This is set to NULL when nothing is + pending. */ + const uint8_t *comment; + /*! Length of data pointed to by comment */ + size_t comment_len; + + /*! Next row number to be encoded */ + uint32_t y; + /*! Next row within current stripe */ + uint32_t i; + /*! Flag for handling NEWLEN processing. */ + int newlen; + /*! X-offset of adaptive template pixel */ + int32_t tx; + /*! Adaptive template algorithm variables */ + uint32_t c_all; + /*! Adaptive template algorithm variables */ + uint32_t c[128]; + /*! New TX value, or <0 for analysis in progress */ + int32_t new_tx; + /*! TRUE if previous row was typical */ + int prev_ltp; + /*! Pointers to the 3 row buffers */ + uint8_t *prev_row[3]; + /*! Pointer to a block of allocated memory 3 rows long, which + we divide up for the 3 row buffers. */ + uint8_t *row_buf; + uint8_t *bitstream; + int bitstream_len; + int bitstream_iptr; + int bitstream_optr; + int fill_with_white; + + /*! \brief The size of the compressed image, in bytes. */ + int compressed_image_size; + + /*! Arithmetic encoder state */ + t81_t82_arith_encode_state_t s; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; + +/* State of a working instance of the T.85 JBIG FAX decoder */ +struct t85_decode_state_s +{ + /*! A callback routine to handle decoded pixel rows */ + t4_row_write_handler_t row_write_handler; + /*! An opaque pointer passed to row_write_handler() */ + void *row_write_user_data; + /*! A callback routine to handle decoded comments */ + t4_row_write_handler_t comment_handler; + /*! An opaque pointer passed to comment_handler() */ + void *comment_user_data; + /*! The maximum length of comment to be passed to the comment handler */ + uint32_t max_comment_len; + + uint8_t min_bit_planes; + uint8_t max_bit_planes; + /*! The maximum permitted width of the full image, in pixels */ + uint32_t max_xd; + /*! The maximum permitted height of the full image, in pixels */ + uint32_t max_yd; + + /*! The number of bit planes expected, according to the header. Always 1 for true T.85 */ + uint8_t bit_planes; + uint8_t current_bit_plane; + + /*! The width of the full image, in pixels */ + uint32_t xd; + /*! The height of the full image, in pixels */ + uint32_t yd; + /*! The number of rows per stripe */ + uint32_t l0; + /*! Maximum ATMOVE window size */ + int mx; + /*! Encoding parameters */ + int options; + + /*! The current row and the previous 2 rows of image data */ + int p[3]; + /*! Pointers to the 3 row buffers */ + uint8_t *prev_row[3]; + /*! Pointer to a block of allocated memory 3 rows long, which + we divide up for the 3 row buffers. */ + uint8_t *row_buf; + /*! The length of the row buffer */ + int row_buf_len; + /*! Bytes per pixel row */ + size_t bytes_per_row; + /*! X-offset of AT pixel */ + int32_t tx; + /*! Number of bytes read so far */ + uint32_t bie_len; + /*! Buffer space for the BIH or marker segments fragments */ + uint8_t buffer[20]; + /*! Number of bytes in buffer. */ + int buf_len; + /*! Required number of bytes in buffer to proceed with processing + its contents. */ + int buf_needed; + /*! The content of a decoded COMMENT marker segment. */ + uint8_t *comment; + /*! The expected length of a decoded COMMENT segment */ + uint32_t comment_len; + /*! The length of COMMENT decoded to date */ + uint32_t comment_progress; + /*! Current column */ + uint32_t x; + /*! Current row */ + uint32_t y; + /*! Current row within the current stripe */ + uint32_t i; + /*! Number of AT moves in the current stripe */ + int at_moves; + /*! Rows at which an AT move will happen */ + uint32_t at_row[T85_ATMOVES_MAX]; + /*! ATMOVE x-offsets in current stripe */ + int at_tx[T85_ATMOVES_MAX]; + /*! Working data for decode_pscd() */ + uint32_t row_h[3]; + /*! Flag for TPBON/TPDON: next pixel is a pseudo pixel */ + int pseudo; + /*! Line is not typical flag. */ + int lntp; + /*! Flag that row_write_handler() requested an interrupt. */ + int interrupt; + /*! Flag that the data to be decoded has run out. */ + int end_of_data; + /*! Arithmetic decoder state */ + t81_t82_arith_decode_state_t s; + + /*! \brief The size of the compressed image, in bytes. */ + int compressed_image_size; + + /*! \brief Error and flow logging control */ + logging_state_t logging; +}; + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/private/v17rx.h b/libs/spandsp/src/spandsp/private/v17rx.h index 8da0967a4a..a968290010 100644 --- a/libs/spandsp/src/spandsp/private/v17rx.h +++ b/libs/spandsp/src/spandsp/private/v17rx.h @@ -73,13 +73,13 @@ struct v17_rx_state_s void *qam_user_data; #if defined(SPANDSP_USE_FIXED_POINTx) - /*! \brief The scaling factor accessed by the AGC algorithm. */ - float agc_scaling; + /*! \brief The scaling factor assessed by the AGC algorithm. */ + int16_t agc_scaling; /*! \brief The previous value of agc_scaling, needed to reuse old training. */ - float agc_scaling_save; + int16_t agc_scaling_save; /*! \brief The current delta factor for updating the equalizer coefficients. */ - float eq_delta; + int16_t eq_delta; /*! \brief The adaptive equalizer coefficients. */ complexi16_t eq_coeff[V17_EQUALIZER_LEN]; /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ @@ -98,19 +98,19 @@ struct v17_rx_state_s /*! \brief A measure of how much mismatch there is between the real constellation, and the decoded symbol positions. */ - float training_error; + int32_t training_error; /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; + int32_t carrier_track_p; /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; + int32_t carrier_track_i; /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ int16_t rrc_filter[V17_RX_FILTER_STEPS]; /*! \brief A pointer to the current constellation. */ const complexi16_t *constellation; #else - /*! \brief The scaling factor accessed by the AGC algorithm. */ + /*! \brief The scaling factor assessed by the AGC algorithm. */ float agc_scaling; /*! \brief The previous value of agc_scaling, needed to reuse old training. */ float agc_scaling_save; @@ -150,7 +150,7 @@ struct v17_rx_state_s /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; - /*! \brief The state of the differential decoder */ + /*! \brief The current state of the differential decoder */ int diff; /*! \brief The register for the data scrambler. */ uint32_t scramble_reg; @@ -228,7 +228,6 @@ struct v17_rx_state_s from the last states of the trellis. */ float distances[8]; #endif - /*! \brief Error and flow logging control */ logging_state_t logging; }; diff --git a/libs/spandsp/src/spandsp/private/v18.h b/libs/spandsp/src/spandsp/private/v18.h index 6f7d987bea..b51a899ec6 100644 --- a/libs/spandsp/src/spandsp/private/v18.h +++ b/libs/spandsp/src/spandsp/private/v18.h @@ -56,6 +56,7 @@ struct v18_state_s int rx_msg_len; int bit_pos; int in_progress; + int repeat_shifts; /*! \brief Error and flow logging control */ logging_state_t logging; diff --git a/libs/spandsp/src/spandsp/private/v22bis.h b/libs/spandsp/src/spandsp/private/v22bis.h index d5016430e9..b601b0c02d 100644 --- a/libs/spandsp/src/spandsp/private/v22bis.h +++ b/libs/spandsp/src/spandsp/private/v22bis.h @@ -26,10 +26,10 @@ #if !defined(_SPANDSP_PRIVATE_V22BIS_H_) #define _SPANDSP_PRIVATE_V22BIS_H_ -/*! The number of steps to the left and to the right of the target position in the equalizer buffer. */ -#define V22BIS_EQUALIZER_LEN 7 -/*! One less than a power of 2 >= (2*V22BIS_EQUALIZER_LEN + 1) */ -#define V22BIS_EQUALIZER_MASK 15 +/*! The length of the equalizer buffer */ +#define V22BIS_EQUALIZER_LEN 17 +/*! Samples before the target position in the equalizer buffer */ +#define V22BIS_EQUALIZER_PRE_LEN 8 /*! The number of taps in the transmit pulse shaping filter */ #define V22BIS_TX_FILTER_STEPS 9 @@ -65,6 +65,12 @@ enum V22BIS_TX_TRAINING_STAGE_PARKED }; +#if defined(SPANDSP_USE_FIXED_POINT) +extern const complexi16_t v22bis_constellation[16]; +#else +extern const complexf_t v22bis_constellation[16]; +#endif + /*! V.22bis modem descriptor. This defines the working state for a single instance of a V.22bis modem. @@ -93,12 +99,6 @@ struct v22bis_state_s /* Receive section */ struct { - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ -#if defined(SPANDSP_USE_FIXED_POINTx) - int16_t rrc_filter[V22BIS_RX_FILTER_STEPS]; -#else - float rrc_filter[V22BIS_RX_FILTER_STEPS]; -#endif /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; @@ -116,20 +116,11 @@ struct v22bis_state_s /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.22bis signal. */ int signal_present; - /*! \brief A measure of how much mismatch there is between the real constellation, - and the decoded symbol positions. */ - float training_error; - /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ uint32_t carrier_phase; /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ int32_t carrier_phase_rate; - /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; - /*! \brief A callback function which may be enabled to report every symbol's constellation position. */ qam_report_handler_t qam_report; @@ -143,21 +134,49 @@ struct v22bis_state_s int32_t carrier_on_power; /*! \brief The power meter level at which carrier off is declared. */ int32_t carrier_off_power; + + int constellation_state; + +#if defined(SPANDSP_USE_FIXED_POINT) + /*! \brief The scaling factor accessed by the AGC algorithm. */ + int16_t agc_scaling; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + int16_t rrc_filter[V22BIS_RX_FILTER_STEPS]; + + /*! \brief The current delta factor for updating the equalizer coefficients. */ + int16_t eq_delta; + /*! \brief The adaptive equalizer coefficients. */ + complexi16_t eq_coeff[V22BIS_EQUALIZER_LEN]; + /*! \brief The equalizer signal buffer. */ + complexi16_t eq_buf[V22BIS_EQUALIZER_LEN]; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + int32_t training_error; + /*! \brief The proportional part of the carrier tracking filter. */ + int32_t carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + int32_t carrier_track_i; +#else /*! \brief The scaling factor accessed by the AGC algorithm. */ float agc_scaling; - - int constellation_state; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + float rrc_filter[V22BIS_RX_FILTER_STEPS]; /*! \brief The current delta factor for updating the equalizer coefficients. */ float eq_delta; -#if defined(SPANDSP_USE_FIXED_POINTx) /*! \brief The adaptive equalizer coefficients. */ - complexi_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; + complexf_t eq_coeff[V22BIS_EQUALIZER_LEN]; /*! \brief The equalizer signal buffer. */ - complexi_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; -#else - complexf_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; - complexf_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; + complexf_t eq_buf[V22BIS_EQUALIZER_LEN]; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; #endif /*! \brief Current offset into the equalizer buffer. */ int eq_step; @@ -183,11 +202,24 @@ struct v22bis_state_s /* Transmit section */ struct { +#if defined(SPANDSP_USE_FIXED_POINT) + /*! \brief The guard tone level. */ + int16_t guard_tone_gain; + /*! \brief The gain factor needed to achieve the specified output power. */ + int16_t gain; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + int16_t rrc_filter_re[V22BIS_TX_FILTER_STEPS]; + int16_t rrc_filter_im[V22BIS_TX_FILTER_STEPS]; +#else + /*! \brief The guard tone level. */ + float guard_tone_gain; /*! \brief The gain factor needed to achieve the specified output power. */ float gain; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + float rrc_filter_re[V22BIS_TX_FILTER_STEPS]; + float rrc_filter_im[V22BIS_TX_FILTER_STEPS]; +#endif - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ - complexf_t rrc_filter[2*V22BIS_TX_FILTER_STEPS]; /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; @@ -209,7 +241,6 @@ struct v22bis_state_s uint32_t guard_phase; /*! \brief The update rate for the phase of the guard tone (i.e. the DDS increment). */ int32_t guard_phase_rate; - float guard_level; /*! \brief The current fractional phase of the baud timing. */ int baud_phase; /*! \brief The code number for the current position in the constellation. */ diff --git a/libs/spandsp/src/spandsp/private/v27ter_rx.h b/libs/spandsp/src/spandsp/private/v27ter_rx.h index 4a991ba3f5..92bf937d83 100644 --- a/libs/spandsp/src/spandsp/private/v27ter_rx.h +++ b/libs/spandsp/src/spandsp/private/v27ter_rx.h @@ -70,32 +70,32 @@ struct v27ter_rx_state_s void *qam_user_data; #if defined(SPANDSP_USE_FIXED_POINT) - /*! \brief The scaling factor accessed by the AGC algorithm. */ + /*! \brief The scaling factor assessed by the AGC algorithm. */ int16_t agc_scaling; /*! \brief The previous value of agc_scaling, needed to reuse old training. */ int16_t agc_scaling_save; /*! \brief The current delta factor for updating the equalizer coefficients. */ - float eq_delta; + int16_t eq_delta; /*! \brief The adaptive equalizer coefficients. */ - /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_LEN]; + complexi16_t eq_coeff[V27TER_EQUALIZER_LEN]; /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ - /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN]; + complexi16_t eq_coeff_save[V27TER_EQUALIZER_LEN]; /*! \brief The equalizer signal buffer. */ - /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_LEN]; + complexi16_t eq_buf[V27TER_EQUALIZER_LEN]; /*! \brief A measure of how much mismatch there is between the real constellation, and the decoded symbol positions. */ - float training_error; + int32_t training_error; /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; + int32_t carrier_track_p; /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; + int32_t carrier_track_i; /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ int16_t rrc_filter[V27TER_RX_FILTER_STEPS]; #else - /*! \brief The scaling factor accessed by the AGC algorithm. */ + /*! \brief The scaling factor assessed by the AGC algorithm. */ float agc_scaling; /*! \brief The previous value of agc_scaling, needed to reuse old training. */ float agc_scaling_save; diff --git a/libs/spandsp/src/spandsp/private/v27ter_tx.h b/libs/spandsp/src/spandsp/private/v27ter_tx.h index 18e27e1277..5d8d41f842 100644 --- a/libs/spandsp/src/spandsp/private/v27ter_tx.h +++ b/libs/spandsp/src/spandsp/private/v27ter_tx.h @@ -53,15 +53,18 @@ struct v27ter_tx_state_s /*! \brief The gain factor needed to achieve the specified output power at 4800bps. */ int16_t gain_4800; /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ - complexi16_t rrc_filter[2*V27TER_TX_FILTER_STEPS]; + int16_t rrc_filter_re[V27TER_TX_FILTER_STEPS]; + int16_t rrc_filter_im[V27TER_TX_FILTER_STEPS]; #else /*! \brief The gain factor needed to achieve the specified output power at 2400bps. */ float gain_2400; /*! \brief The gain factor needed to achieve the specified output power at 4800bps. */ float gain_4800; /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ - complexf_t rrc_filter[2*V27TER_TX_FILTER_STEPS]; + float rrc_filter_re[V27TER_TX_FILTER_STEPS]; + float rrc_filter_im[V27TER_TX_FILTER_STEPS]; #endif + /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; diff --git a/libs/spandsp/src/spandsp/private/v29rx.h b/libs/spandsp/src/spandsp/private/v29rx.h index ee7cd9932c..17e900582e 100644 --- a/libs/spandsp/src/spandsp/private/v29rx.h +++ b/libs/spandsp/src/spandsp/private/v29rx.h @@ -61,82 +61,8 @@ struct v29_rx_state_s routine. */ void *qam_user_data; - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ #if defined(SPANDSP_USE_FIXED_POINT) - int16_t rrc_filter[V29_RX_FILTER_STEPS]; -#else - float rrc_filter[V29_RX_FILTER_STEPS]; -#endif - /*! \brief Current offset into the RRC pulse shaping filter buffer. */ - int rrc_filter_step; - - /*! \brief The register for the data scrambler. */ - uint32_t scramble_reg; - /*! \brief The register for the training scrambler. */ - uint8_t training_scramble_reg; - /*! \brief The current step in the table of CD constellation positions. */ - int training_cd; - /*! \brief TRUE if the previous trained values are to be reused. */ - int old_train; - /*! \brief The section of the training data we are currently in. */ - int training_stage; - /*! \brief A count of how far through the current training step we are. */ - int training_count; - /*! \brief A measure of how much mismatch there is between the real constellation, - and the decoded symbol positions. */ - float training_error; - /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ - int16_t last_sample; - /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */ - int signal_present; - /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ - int carrier_drop_pending; - /*! \brief A count of the current consecutive samples below the carrier off threshold. */ - int low_samples; - /*! \brief A highest magnitude sample seen. */ - int16_t high_sample; - - /*! \brief The position of the current symbol in the constellation, used for - differential decoding. */ - int constellation_state; - - /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ - uint32_t carrier_phase; - /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ - int32_t carrier_phase_rate; - /*! \brief The carrier update rate saved for reuse when using short training. */ - int32_t carrier_phase_rate_save; -#if defined(SPANDSP_USE_FIXED_POINT) - /*! \brief The proportional part of the carrier tracking filter. */ - int32_t carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - int32_t carrier_track_i; -#else - /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; -#endif - - /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ - power_meter_t power; - /*! \brief The power meter level at which carrier on is declared. */ - int32_t carrier_on_power; - /*! \brief The power meter level at which carrier off is declared. */ - int32_t carrier_off_power; - - /*! \brief Current read offset into the equalizer buffer. */ - int eq_step; - /*! \brief Current write offset into the equalizer buffer. */ - int eq_put_step; - /*! \brief Symbol counter to the next equalizer update. */ - int eq_skip; - - /*! \brief The current half of the baud. */ - int baud_half; - -#if defined(SPANDSP_USE_FIXED_POINT) - /*! \brief The scaling factor accessed by the AGC algorithm. */ + /*! \brief The scaling factor assessed by the AGC algorithm. */ int16_t agc_scaling; /*! \brief The previous value of agc_scaling, needed to reuse old training. */ int16_t agc_scaling_save; @@ -158,8 +84,19 @@ struct v29_rx_state_s int32_t symbol_sync_dc_filter[2]; /*! Baud phase for symbol sync. */ int32_t baud_phase; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + int32_t training_error; + + /*! \brief The proportional part of the carrier tracking filter. */ + int32_t carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + int32_t carrier_track_i; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + int16_t rrc_filter[V29_RX_FILTER_STEPS]; #else - /*! \brief The scaling factor accessed by the AGC algorithm. */ + /*! \brief The scaling factor assessed by the AGC algorithm. */ float agc_scaling; /*! \brief The previous value of agc_scaling, needed to reuse old training. */ float agc_scaling_save; @@ -181,7 +118,67 @@ struct v29_rx_state_s float symbol_sync_dc_filter[2]; /*! Baud phase for symbol sync. */ float baud_phase; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + float rrc_filter[V29_RX_FILTER_STEPS]; #endif + /*! \brief Current offset into the RRC pulse shaping filter buffer. */ + int rrc_filter_step; + + /*! \brief The register for the data scrambler. */ + uint32_t scramble_reg; + /*! \brief The register for the training scrambler. */ + uint8_t training_scramble_reg; + /*! \brief The current step in the table of CD constellation positions. */ + int training_cd; + /*! \brief TRUE if the previous trained values are to be reused. */ + int old_train; + /*! \brief The section of the training data we are currently in. */ + int training_stage; + /*! \brief A count of how far through the current training step we are. */ + int training_count; + /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ + int16_t last_sample; + /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */ + int signal_present; + /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ + int carrier_drop_pending; + /*! \brief A count of the current consecutive samples below the carrier off threshold. */ + int low_samples; + /*! \brief A highest magnitude sample seen. */ + int16_t high_sample; + + /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ + uint32_t carrier_phase; + /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ + int32_t carrier_phase_rate; + /*! \brief The carrier update rate saved for reuse when using short training. */ + int32_t carrier_phase_rate_save; + + /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ + power_meter_t power; + /*! \brief The power meter level at which carrier on is declared. */ + int32_t carrier_on_power; + /*! \brief The power meter level at which carrier off is declared. */ + int32_t carrier_off_power; + + /*! \brief Current read offset into the equalizer buffer. */ + int eq_step; + /*! \brief Current write offset into the equalizer buffer. */ + int eq_put_step; + /*! \brief Symbol counter to the next equalizer update. */ + int eq_skip; + + /*! \brief The current half of the baud. */ + int baud_half; /*! \brief The total symbol timing correction since the carrier came up. This is only for performance analysis purposes. */ @@ -191,6 +188,11 @@ struct v29_rx_state_s int32_t start_angles[2]; /*! \brief History list of phase angles for the coarse carrier aquisition step. */ int32_t angles[16]; + + /*! \brief The position of the current symbol in the constellation, used for + differential decoding. */ + int constellation_state; + /*! \brief Error and flow logging control */ logging_state_t logging; }; diff --git a/libs/spandsp/src/spandsp/private/v29tx.h b/libs/spandsp/src/spandsp/private/v29tx.h index 062ef7ee5c..67c2b7098d 100644 --- a/libs/spandsp/src/spandsp/private/v29tx.h +++ b/libs/spandsp/src/spandsp/private/v29tx.h @@ -47,23 +47,28 @@ struct v29_tx_state_s /*! \brief A user specified opaque pointer passed to the status function. */ void *status_user_data; +#if defined(SPANDSP_USE_FIXED_POINT) + /*! \brief Gain required to achieve the specified output power, not allowing + for the size of the current constellation. */ + int16_t base_gain; + /*! \brief Gain required to achieve the specified output power, allowing + for the size of the current constellation. */ + int16_t gain; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + int16_t rrc_filter_re[V29_TX_FILTER_STEPS]; + int16_t rrc_filter_im[V29_TX_FILTER_STEPS]; +#else /*! \brief Gain required to achieve the specified output power, not allowing for the size of the current constellation. */ float base_gain; /*! \brief Gain required to achieve the specified output power, allowing for the size of the current constellation. */ -#if defined(SPANDSP_USE_FIXED_POINT) - int32_t gain; -#else float gain; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + float rrc_filter_re[V29_TX_FILTER_STEPS]; + float rrc_filter_im[V29_TX_FILTER_STEPS]; #endif - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ -#if defined(SPANDSP_USE_FIXED_POINT) - complexi16_t rrc_filter[2*V29_TX_FILTER_STEPS]; -#else - complexf_t rrc_filter[2*V29_TX_FILTER_STEPS]; -#endif /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; diff --git a/libs/spandsp/src/spandsp/private/v8.h b/libs/spandsp/src/spandsp/private/v8.h index 2fb481d0b2..77dd55eea0 100644 --- a/libs/spandsp/src/spandsp/private/v8.h +++ b/libs/spandsp/src/spandsp/private/v8.h @@ -32,7 +32,7 @@ struct v8_state_s int calling_party; /*! \brief A handler to process the V.8 signals */ - v8_result_handler_t *result_handler; + v8_result_handler_t result_handler; /*! \brief An opaque pointer passed to result_handler */ void *result_handler_user_data; diff --git a/libs/spandsp/src/spandsp/t30.h b/libs/spandsp/src/spandsp/t30.h index 2f97729859..a954be1c36 100644 --- a/libs/spandsp/src/spandsp/t30.h +++ b/libs/spandsp/src/spandsp/t30.h @@ -158,7 +158,7 @@ typedef struct t30_state_s t30_state_t; \param result The phase B event code. \return The new status. Normally, T30_ERR_OK is returned. */ -typedef int (t30_phase_b_handler_t)(t30_state_t *s, void *user_data, int result); +typedef int (*t30_phase_b_handler_t)(t30_state_t *s, void *user_data, int result); /*! T.30 phase D callback handler. @@ -168,7 +168,7 @@ typedef int (t30_phase_b_handler_t)(t30_state_t *s, void *user_data, int result) \param result The phase D event code. \return The new status. Normally, T30_ERR_OK is returned. */ -typedef int (t30_phase_d_handler_t)(t30_state_t *s, void *user_data, int result); +typedef int (*t30_phase_d_handler_t)(t30_state_t *s, void *user_data, int result); /*! T.30 phase E callback handler. @@ -177,7 +177,7 @@ typedef int (t30_phase_d_handler_t)(t30_state_t *s, void *user_data, int result) \param user_data An opaque pointer. \param completion_code The phase E completion code. */ -typedef void (t30_phase_e_handler_t)(t30_state_t *s, void *user_data, int completion_code); +typedef void (*t30_phase_e_handler_t)(t30_state_t *s, void *user_data, int completion_code); /*! T.30 real time frame handler. @@ -188,11 +188,11 @@ typedef void (t30_phase_e_handler_t)(t30_state_t *s, void *user_data, int comple \param msg The HDLC message. \param len The length of the message. */ -typedef void (t30_real_time_frame_handler_t)(t30_state_t *s, - void *user_data, - int direction, - const uint8_t msg[], - int len); +typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s, + void *user_data, + int direction, + const uint8_t msg[], + int len); /*! T.30 document handler. @@ -201,7 +201,7 @@ typedef void (t30_real_time_frame_handler_t)(t30_state_t *s, \param user_data An opaque pointer. \param result The document event code. */ -typedef int (t30_document_handler_t)(t30_state_t *s, void *user_data, int status); +typedef int (*t30_document_handler_t)(t30_state_t *s, void *user_data, int status); /*! T.30 set a receive or transmit type handler. @@ -212,7 +212,7 @@ typedef int (t30_document_handler_t)(t30_state_t *s, void *user_data, int status \param short_train TRUE if the short training sequence should be used (where one exists). \param use_hdlc FALSE for bit stream, TRUE for HDLC framing. */ -typedef void (t30_set_handler_t)(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); +typedef void (*t30_set_handler_t)(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); /*! T.30 send HDLC handler. @@ -221,7 +221,7 @@ typedef void (t30_set_handler_t)(void *user_data, int type, int bit_rate, int sh \param msg The HDLC message. \param len The length of the message. */ -typedef void (t30_send_hdlc_handler_t)(void *user_data, const uint8_t msg[], int len); +typedef void (*t30_send_hdlc_handler_t)(void *user_data, const uint8_t msg[], int len); /*! T.30 protocol completion codes, at phase E. @@ -373,7 +373,11 @@ enum /*! T.81 + T.30 Annex K colour sYCC-JPEG compression */ T30_SUPPORT_SYCC_T81_COMPRESSION = 0x200, /*! T.88 monochrome JBIG2 compression */ - T30_SUPPORT_T88_COMPRESSION = 0x400 + T30_SUPPORT_T88_COMPRESSION = 0x400, + /*! Dither a gray scale image down a simple bilevel image, with rescaling to fit a FAX page */ + T30_SUPPORT_GRAY_TO_BILEVEL = 0x10000000, + /*! Dither a colour image down a simple bilevel image, with rescaling to fit a FAX page */ + T30_SUPPORT_COLOUR_TO_BILEVEL = 0x20000000 }; enum @@ -572,11 +576,11 @@ extern "C" \return A pointer to the context, or NULL if there was a problem. */ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s, int calling_party, - t30_set_handler_t *set_rx_type_handler, + t30_set_handler_t set_rx_type_handler, void *set_rx_type_user_data, - t30_set_handler_t *set_tx_type_handler, + t30_set_handler_t set_tx_type_handler, void *set_tx_type_user_data, - t30_send_hdlc_handler_t *send_hdlc_handler, + t30_send_hdlc_handler_t send_hdlc_handler, void *send_hdlc_user_data); /*! Release a T.30 context. @@ -621,19 +625,13 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status); \return The next bit to transmit. */ SPAN_DECLARE_NONSTD(int) t30_non_ecm_get_bit(void *user_data); -/*! Get a byte of received non-ECM image data. - \brief Get a byte of received non-ECM image data. - \param user_data An opaque pointer, which must point to the T.30 context. - \return The next byte to transmit. */ -SPAN_DECLARE(int) t30_non_ecm_get_byte(void *user_data); - /*! Get a chunk of received non-ECM image data. \brief Get a bit of received non-ECM image data. \param user_data An opaque pointer, which must point to the T.30 context. \param buf The buffer to contain the data. \param max_len The maximum length of the chunk. \return The actual length of the chunk. */ -SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_len); +SPAN_DECLARE(int) t30_non_ecm_get(void *user_data, uint8_t buf[], int max_len); /*! Process a bit of received non-ECM image data. \brief Process a bit of received non-ECM image data @@ -641,18 +639,12 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_ \param bit The received bit. */ SPAN_DECLARE_NONSTD(void) t30_non_ecm_put_bit(void *user_data, int bit); -/*! Process a byte of received non-ECM image data. - \brief Process a byte of received non-ECM image data - \param user_data An opaque pointer, which must point to the T.30 context. - \param byte The received byte. */ -SPAN_DECLARE(void) t30_non_ecm_put_byte(void *user_data, int byte); - /*! Process a chunk of received non-ECM image data. \brief Process a chunk of received non-ECM image data \param user_data An opaque pointer, which must point to the T.30 context. \param buf The buffer containing the received data. \param len The length of the data in buf. */ -SPAN_DECLARE(void) t30_non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len); +SPAN_DECLARE(void) t30_non_ecm_put(void *user_data, const uint8_t buf[], int len); /*! Process a received HDLC frame. \brief Process a received HDLC frame. diff --git a/libs/spandsp/src/spandsp/t30_api.h b/libs/spandsp/src/spandsp/t30_api.h index d758c8e871..08a0383634 100644 --- a/libs/spandsp/src/spandsp/t30_api.h +++ b/libs/spandsp/src/spandsp/t30_api.h @@ -507,28 +507,28 @@ SPAN_DECLARE(int) t30_set_receiver_not_ready(t30_state_t *s, int count); \param s The T.30 context. \param handler The callback function. \param user_data An opaque pointer passed to the callback function. */ -SPAN_DECLARE(void) t30_set_phase_b_handler(t30_state_t *s, t30_phase_b_handler_t *handler, void *user_data); +SPAN_DECLARE(void) t30_set_phase_b_handler(t30_state_t *s, t30_phase_b_handler_t handler, void *user_data); /*! Set a callback function for T.30 phase D handling. \brief Set a callback function for T.30 phase D handling. \param s The T.30 context. \param handler The callback function. \param user_data An opaque pointer passed to the callback function. */ -SPAN_DECLARE(void) t30_set_phase_d_handler(t30_state_t *s, t30_phase_d_handler_t *handler, void *user_data); +SPAN_DECLARE(void) t30_set_phase_d_handler(t30_state_t *s, t30_phase_d_handler_t handler, void *user_data); /*! Set a callback function for T.30 phase E handling. \brief Set a callback function for T.30 phase E handling. \param s The T.30 context. \param handler The callback function. \param user_data An opaque pointer passed to the callback function. */ -SPAN_DECLARE(void) t30_set_phase_e_handler(t30_state_t *s, t30_phase_e_handler_t *handler, void *user_data); +SPAN_DECLARE(void) t30_set_phase_e_handler(t30_state_t *s, t30_phase_e_handler_t handler, void *user_data); /*! Set a callback function for T.30 end of document handling. \brief Set a callback function for T.30 end of document handling. \param s The T.30 context. \param handler The callback function. \param user_data An opaque pointer passed to the callback function. */ -SPAN_DECLARE(void) t30_set_document_handler(t30_state_t *s, t30_document_handler_t *handler, void *user_data); +SPAN_DECLARE(void) t30_set_document_handler(t30_state_t *s, t30_document_handler_t handler, void *user_data); /*! Set a callback function for T.30 frame exchange monitoring. This is called from the heart of the signal processing, so don't take too long in the handler routine. @@ -536,7 +536,7 @@ SPAN_DECLARE(void) t30_set_document_handler(t30_state_t *s, t30_document_handler \param s The T.30 context. \param handler The callback function. \param user_data An opaque pointer passed to the callback function. */ -SPAN_DECLARE(void) t30_set_real_time_frame_handler(t30_state_t *s, t30_real_time_frame_handler_t *handler, void *user_data); +SPAN_DECLARE(void) t30_set_real_time_frame_handler(t30_state_t *s, t30_real_time_frame_handler_t handler, void *user_data); /*! Get a pointer to the logging context associated with a T.30 context. \brief Get a pointer to the logging context associated with a T.30 context. diff --git a/libs/spandsp/src/spandsp/t30_fcf.h b/libs/spandsp/src/spandsp/t30_fcf.h index 7414497247..763627e435 100644 --- a/libs/spandsp/src/spandsp/t30_fcf.h +++ b/libs/spandsp/src/spandsp/t30_fcf.h @@ -114,6 +114,7 @@ enum /*! Information frame types used for error correction mode, in T.4 */ T4_FCD = 0x06, /*! [0110 0000] Facsimile coded data */ + T4_CCD = 0x46, /*! [0110 0010] Character coded data */ T4_RCP = 0x86 /*! [0110 0001] Return to control for partial page */ }; diff --git a/libs/spandsp/src/spandsp/t31.h b/libs/spandsp/src/spandsp/t31.h index 25f826d42c..df842b0972 100644 --- a/libs/spandsp/src/spandsp/t31.h +++ b/libs/spandsp/src/spandsp/t31.h @@ -42,7 +42,7 @@ modems in spandsp. */ typedef struct t31_state_s t31_state_t; -typedef int (t31_modem_control_handler_t)(t31_state_t *s, void *user_data, int op, const char *num); +typedef int (*t31_modem_control_handler_t)(t31_state_t *s, void *user_data, int op, const char *num); #define T31_TX_BUF_LEN (4096) #define T31_TX_BUF_HIGH_TIDE (4096 - 1024) @@ -57,6 +57,12 @@ extern "C" SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event); +/*! Return the amount of free space in the AT COMMAND BUFFER. + \brief Return the amount of free space in the AT COMMAND BUFFER. + \param s The T.31 modem context. + \return The number of bytes of free space. */ +SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s); + SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len); /*! Process a block of received T.31 modem audio samples. @@ -133,11 +139,11 @@ SPAN_DECLARE(t38_core_state_t *) t31_get_t38_core_state(t31_state_t *s); \param tx_t38_packet_user_data ??? \return A pointer to the T.31 context. */ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, - at_tx_handler_t *at_tx_handler, + at_tx_handler_t at_tx_handler, void *at_tx_user_data, - t31_modem_control_handler_t *modem_control_handler, + t31_modem_control_handler_t modem_control_handler, void *modem_control_user_data, - t38_tx_packet_handler_t *tx_t38_packet_handler, + t38_tx_packet_handler_t tx_t38_packet_handler, void *tx_t38_packet_user_data); /*! Release a T.31 context. diff --git a/libs/spandsp/src/spandsp/t38_core.h b/libs/spandsp/src/spandsp/t38_core.h index cda7a19b52..662cf8d37e 100644 --- a/libs/spandsp/src/spandsp/t38_core.h +++ b/libs/spandsp/src/spandsp/t38_core.h @@ -201,11 +201,11 @@ typedef struct */ typedef struct t38_core_state_s t38_core_state_t; -typedef int (t38_tx_packet_handler_t)(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count); +typedef int (*t38_tx_packet_handler_t)(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count); -typedef int (t38_rx_indicator_handler_t)(t38_core_state_t *s, void *user_data, int indicator); -typedef int (t38_rx_data_handler_t)(t38_core_state_t *s, void *user_data, int data_type, int field_type, const uint8_t *buf, int len); -typedef int (t38_rx_missing_handler_t)(t38_core_state_t *s, void *user_data, int rx_seq_no, int expected_seq_no); +typedef int (*t38_rx_indicator_handler_t)(t38_core_state_t *s, void *user_data, int indicator); +typedef int (*t38_rx_data_handler_t)(t38_core_state_t *s, void *user_data, int data_type, int field_type, const uint8_t *buf, int len); +typedef int (*t38_rx_missing_handler_t)(t38_core_state_t *s, void *user_data, int rx_seq_no, int expected_seq_no); #if defined(__cplusplus) extern "C" @@ -398,11 +398,11 @@ SPAN_DECLARE(int) t38_core_restart(t38_core_state_t *s); \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler. \return A pointer to the T.38 context, or NULL if there was a problem. */ SPAN_DECLARE(t38_core_state_t *) t38_core_init(t38_core_state_t *s, - t38_rx_indicator_handler_t *rx_indicator_handler, - t38_rx_data_handler_t *rx_data_handler, - t38_rx_missing_handler_t *rx_missing_handler, + t38_rx_indicator_handler_t rx_indicator_handler, + t38_rx_data_handler_t rx_data_handler, + t38_rx_missing_handler_t rx_missing_handler, void *rx_user_data, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data); /*! Release a signaling tone transmitter context. diff --git a/libs/spandsp/src/spandsp/t38_gateway.h b/libs/spandsp/src/spandsp/t38_gateway.h index fa6db4bec5..d6bfc39555 100644 --- a/libs/spandsp/src/spandsp/t38_gateway.h +++ b/libs/spandsp/src/spandsp/t38_gateway.h @@ -56,11 +56,11 @@ typedef struct t38_gateway_state_s t38_gateway_state_t; \param msg The HDLC message. \param len The length of the message. */ -typedef void (t38_gateway_real_time_frame_handler_t)(t38_gateway_state_t *s, - void *user_data, - int direction, - const uint8_t *msg, - int len); +typedef void (*t38_gateway_real_time_frame_handler_t)(t38_gateway_state_t *s, + void *user_data, + int direction, + const uint8_t *msg, + int len); /*! T.38 gateway results. @@ -86,7 +86,7 @@ extern "C" \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler routine. \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */ SPAN_DECLARE(t38_gateway_state_t *) t38_gateway_init(t38_gateway_state_t *s, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data); /*! Release a gateway mode T.38 context. @@ -212,7 +212,7 @@ SPAN_DECLARE(logging_state_t *) t38_gateway_get_logging_state(t38_gateway_state_ \param handler The callback function. \param user_data An opaque pointer passed to the callback function. */ SPAN_DECLARE(void) t38_gateway_set_real_time_frame_handler(t38_gateway_state_t *s, - t38_gateway_real_time_frame_handler_t *handler, + t38_gateway_real_time_frame_handler_t handler, void *user_data); #if defined(__cplusplus) diff --git a/libs/spandsp/src/spandsp/t38_terminal.h b/libs/spandsp/src/spandsp/t38_terminal.h index 2307f765f7..a847d96cf3 100644 --- a/libs/spandsp/src/spandsp/t38_terminal.h +++ b/libs/spandsp/src/spandsp/t38_terminal.h @@ -123,7 +123,7 @@ SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s, \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */ SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s, int calling_party, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data); /*! Release a termination mode T.38 context. diff --git a/libs/spandsp/src/spandsp/t42.h b/libs/spandsp/src/spandsp/t42.h new file mode 100644 index 0000000000..3e9540e966 --- /dev/null +++ b/libs/spandsp/src/spandsp/t42.h @@ -0,0 +1,165 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t42.h - ITU T.42 JPEG for FAX image processing + * + * Written by Steve Underwood + * + * Copyright (C) 2011 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_SPANDSP_T42_H_) +#define _SPANDSP_T42_H_ + +/*! \page t42_page T.42 (JPEG for FAX) image compression and decompression + +\section t42_page_sec_1 What does it do? + +\section t42_page_sec_1 How does it work? +*/ + +/*! State of a working instance of the T.42 encoder */ +typedef struct t42_encode_state_s t42_encode_state_t; + +/*! State of a working instance of the T.42 decoder */ +typedef struct t42_decode_state_s t42_decode_state_t; + +typedef struct lab_params_s lab_params_t; + +#if defined(__cplusplus) +extern "C" +{ +#endif + +SPAN_DECLARE(void) srgb_to_lab(lab_params_t *s, uint8_t lab[], const uint8_t srgb[], int pixels); + +SPAN_DECLARE(void) lab_to_srgb(lab_params_t *s, uint8_t srgb[], const uint8_t lab[], int pixels); + +SPAN_DECLARE(void) set_lab_illuminant(lab_params_t *s, float new_xn, float new_yn, float new_zn); + +SPAN_DECLARE(void) set_lab_gamut(lab_params_t *s, int L_min, int L_max, int a_min, int a_max, int b_min, int b_max, int ab_are_signed); + +SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *s, int L_P, int L_Q, int a_P, int a_Q, int b_P, int b_Q); + +SPAN_DECLARE(int) t42_itulab_to_itulab(logging_state_t *logging, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height); + +SPAN_DECLARE(int) t42_itulab_to_jpeg(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen); + +SPAN_DECLARE(int) t42_jpeg_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen); + +SPAN_DECLARE(int) t42_srgb_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height); + +SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s, tdata_t dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t *width, uint32_t *height); + +SPAN_DECLARE(void) t42_encode_set_options(t42_encode_state_t *s, + uint32_t l0, + int mx, + int options); + +SPAN_DECLARE(int) t42_encode_set_image_width(t42_encode_state_t *s, uint32_t image_width); + +SPAN_DECLARE(int) t42_encode_set_image_length(t42_encode_state_t *s, uint32_t length); + +SPAN_DECLARE(void) t42_encode_abort(t42_encode_state_t *s); + +SPAN_DECLARE(void) t42_encode_comment(t42_encode_state_t *s, const uint8_t comment[], size_t len); + +/*! \brief Check if we are at the end of the current document page. + \param s The T.42 context. + \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */ +SPAN_DECLARE(int) t42_encode_image_complete(t42_encode_state_t *s); + +SPAN_DECLARE(int) t42_encode_get(t42_encode_state_t *s, uint8_t buf[], size_t max_len); + +SPAN_DECLARE(uint32_t) t42_encode_get_image_width(t42_encode_state_t *s); + +SPAN_DECLARE(uint32_t) t42_encode_get_image_length(t42_encode_state_t *s); + +SPAN_DECLARE(int) t42_encode_get_compressed_image_size(t42_encode_state_t *s); + +SPAN_DECLARE(int) t42_encode_set_row_read_handler(t42_encode_state_t *s, + t4_row_read_handler_t handler, + void *user_data); + +/*! Get the logging context associated with a T.42 encode context. + \brief Get the logging context associated with a T.42 encode context. + \param s The T.42 encode context. + \return A pointer to the logging context */ +SPAN_DECLARE(logging_state_t *) t42_encode_get_logging_state(t42_encode_state_t *s); + +SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length); + +SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s, + uint32_t image_width, + uint32_t image_length, + t4_row_read_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t42_encode_release(t42_encode_state_t *s); + +SPAN_DECLARE(int) t42_encode_free(t42_encode_state_t *s); + +SPAN_DECLARE(void) t42_decode_rx_status(t42_decode_state_t *s, int status); + +SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], size_t len); + +SPAN_DECLARE(int) t42_decode_set_row_write_handler(t42_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t42_decode_set_comment_handler(t42_decode_state_t *s, + uint32_t max_comment_len, + t4_row_write_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t42_decode_set_image_size_constraints(t42_decode_state_t *s, + uint32_t max_xd, + uint32_t max_yd); + +SPAN_DECLARE(uint32_t) t42_decode_get_image_width(t42_decode_state_t *s); + +SPAN_DECLARE(uint32_t) t42_decode_get_image_length(t42_decode_state_t *s); + +SPAN_DECLARE(int) t42_decode_get_compressed_image_size(t42_decode_state_t *s); + +SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s); + +/*! Get the logging context associated with a T.42 decode context. + \brief Get the logging context associated with a T.42 decode context. + \param s The T.42 decode context. + \return A pointer to the logging context */ +SPAN_DECLARE(logging_state_t *) t42_decode_get_logging_state(t42_decode_state_t *s); + +SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s); + +SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s); + +SPAN_DECLARE(int) t42_decode_free(t42_decode_state_t *s); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/t4_rx.h b/libs/spandsp/src/spandsp/t4_rx.h index 004c75c840..c88cebb78d 100644 --- a/libs/spandsp/src/spandsp/t4_rx.h +++ b/libs/spandsp/src/spandsp/t4_rx.h @@ -74,10 +74,11 @@ typedef enum typedef enum { T4_IMAGE_TYPE_BILEVEL = 0, - T4_IMAGE_TYPE_GRAY_8BIT = 1, - T4_IMAGE_TYPE_GRAY_12BIT = 2, - T4_IMAGE_TYPE_COLOUR_8BIT = 3, - T4_IMAGE_TYPE_COLOUR_12BIT = 4 + T4_IMAGE_TYPE_COLOUR_BILEVEL = 1, + T4_IMAGE_TYPE_GRAY_8BIT = 2, + T4_IMAGE_TYPE_GRAY_12BIT = 3, + T4_IMAGE_TYPE_COLOUR_8BIT = 4, + T4_IMAGE_TYPE_COLOUR_12BIT = 5 } t4_image_types_t; /*! Supported X resolutions, in pixels per metre. */ @@ -199,11 +200,28 @@ typedef enum T4_LENGTH_1200_US_LEGAL = 0 } t4_image_length_t; +/*! Return values from the T.85 decoder */ +typedef enum +{ + /*! More image data is needed */ + T4_DECODE_MORE_DATA = 0, + /*! Image completed successfully */ + T4_DECODE_OK = -1, + /*! The decoder has interrupted */ + T4_DECODE_INTERRUPT = -2, + /*! An abort was found in the image data */ + T4_DECODE_ABORTED = -3, + /*! A memory allocation error occurred */ + T4_DECODE_NOMEM = -4, + /*! The image data is invalid. */ + T4_DECODE_INVALID_DATA = -5 +} t4_decoder_status_t; + /*! T.4 FAX compression/decompression descriptor. This defines the working state for a single instance of a T.4 FAX compression or decompression channel. */ -typedef struct t4_state_s t4_state_t; +typedef struct t4_rx_state_s t4_rx_state_t; /*! T.4 FAX compression/decompression statistics. @@ -241,108 +259,103 @@ extern "C" { \param file The name of the file to be received. \param output_encoding The output encoding. \return A pointer to the context, or NULL if there was a problem. */ -SPAN_DECLARE(t4_state_t *) t4_rx_init(t4_state_t *s, const char *file, int output_encoding); +SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int output_encoding); /*! \brief Prepare to receive the next page of the current document. \param s The T.4 context. \return zero for success, -1 for failure. */ -SPAN_DECLARE(int) t4_rx_start_page(t4_state_t *s); +SPAN_DECLARE(int) t4_rx_start_page(t4_rx_state_t *s); /*! \brief Put a bit of the current document page. \param s The T.4 context. \param bit The data bit. \return TRUE when the bit ends the document page, otherwise FALSE. */ -SPAN_DECLARE(int) t4_rx_put_bit(t4_state_t *s, int bit); - -/*! \brief Put a byte of the current document page. - \param s The T.4 context. - \param byte The data byte. - \return TRUE when the byte ends the document page, otherwise FALSE. */ -SPAN_DECLARE(int) t4_rx_put_byte(t4_state_t *s, uint8_t byte); +SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit); /*! \brief Put a byte of the current document page. \param s The T.4 context. \param buf The buffer containing the chunk. \param len The length of the chunk. \return TRUE when the byte ends the document page, otherwise FALSE. */ -SPAN_DECLARE(int) t4_rx_put_chunk(t4_state_t *s, const uint8_t buf[], int len); +SPAN_DECLARE(int) t4_rx_put(t4_rx_state_t *s, const uint8_t buf[], size_t len); /*! \brief Complete the reception of a page. \param s The T.4 receive context. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_rx_end_page(t4_state_t *s); +SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s); /*! \brief End reception of a document. Tidy up and close the file. This should be used to end T.4 reception started with t4_rx_init. \param s The T.4 receive context. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_rx_release(t4_state_t *s); +SPAN_DECLARE(int) t4_rx_release(t4_rx_state_t *s); /*! \brief End reception of a document. Tidy up, close the file and free the context. This should be used to end T.4 reception started with t4_rx_init. \param s The T.4 receive context. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_rx_free(t4_state_t *s); +SPAN_DECLARE(int) t4_rx_free(t4_rx_state_t *s); /*! \brief Set the row write handler for a T.4 receive context. \param s The T.4 receive context. \param handler A pointer to the handler routine. \param user_data An opaque pointer passed to the handler routine. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_state_t *s, t4_row_write_handler_t handler, void *user_data); +SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_rx_state_t *s, t4_row_write_handler_t handler, void *user_data); /*! \brief Set the encoding for the received data. \param s The T.4 context. - \param encoding The encoding. */ -SPAN_DECLARE(void) t4_rx_set_rx_encoding(t4_state_t *s, int encoding); + \param encoding The encoding. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding); /*! \brief Set the expected width of the received image, in pixel columns. \param s The T.4 context. \param width The number of pixels across the image. */ -SPAN_DECLARE(void) t4_rx_set_image_width(t4_state_t *s, int width); +SPAN_DECLARE(void) t4_rx_set_image_width(t4_rx_state_t *s, int width); /*! \brief Set the row-to-row (y) resolution to expect for a received image. \param s The T.4 context. \param resolution The resolution, in pixels per metre. */ -SPAN_DECLARE(void) t4_rx_set_y_resolution(t4_state_t *s, int resolution); +SPAN_DECLARE(void) t4_rx_set_y_resolution(t4_rx_state_t *s, int resolution); /*! \brief Set the column-to-column (x) resolution to expect for a received image. \param s The T.4 context. \param resolution The resolution, in pixels per metre. */ -SPAN_DECLARE(void) t4_rx_set_x_resolution(t4_state_t *s, int resolution); +SPAN_DECLARE(void) t4_rx_set_x_resolution(t4_rx_state_t *s, int resolution); /*! \brief Set the DCS information of the fax, for inclusion in the file. \param s The T.4 context. \param dcs The DCS information, formatted as an ASCII string. */ -SPAN_DECLARE(void) t4_rx_set_dcs(t4_state_t *s, const char *dcs); +SPAN_DECLARE(void) t4_rx_set_dcs(t4_rx_state_t *s, const char *dcs); /*! \brief Set the sub-address of the fax, for inclusion in the file. \param s The T.4 context. \param sub_address The sub-address string. */ -SPAN_DECLARE(void) t4_rx_set_sub_address(t4_state_t *s, const char *sub_address); +SPAN_DECLARE(void) t4_rx_set_sub_address(t4_rx_state_t *s, const char *sub_address); /*! \brief Set the identity of the remote machine, for inclusion in the file. \param s The T.4 context. \param ident The identity string. */ -SPAN_DECLARE(void) t4_rx_set_far_ident(t4_state_t *s, const char *ident); +SPAN_DECLARE(void) t4_rx_set_far_ident(t4_rx_state_t *s, const char *ident); /*! \brief Set the vendor of the remote machine, for inclusion in the file. \param s The T.4 context. \param vendor The vendor string, or NULL. */ -SPAN_DECLARE(void) t4_rx_set_vendor(t4_state_t *s, const char *vendor); +SPAN_DECLARE(void) t4_rx_set_vendor(t4_rx_state_t *s, const char *vendor); /*! \brief Set the model of the remote machine, for inclusion in the file. \param s The T.4 context. \param model The model string, or NULL. */ -SPAN_DECLARE(void) t4_rx_set_model(t4_state_t *s, const char *model); +SPAN_DECLARE(void) t4_rx_set_model(t4_rx_state_t *s, const char *model); /*! Get the current image transfer statistics. \brief Get the current transfer statistics. \param s The T.4 context. \param t A pointer to a statistics structure. */ -SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t); +SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t); /*! Get the short text name of an encoding format. \brief Get the short text name of an encoding format. diff --git a/libs/spandsp/src/spandsp/t4_t6_decode.h b/libs/spandsp/src/spandsp/t4_t6_decode.h index 860d4ecea9..fd101d3b8f 100644 --- a/libs/spandsp/src/spandsp/t4_t6_decode.h +++ b/libs/spandsp/src/spandsp/t4_t6_decode.h @@ -45,6 +45,66 @@ typedef struct t4_t6_decode_state_s t4_t6_decode_state_t; extern "C" { #endif +/*! \brief Put a bit of the current document page. + \param s The T.4/T.6 context. + \param bit The data bit. + \return TRUE when the bit ends the document page, otherwise FALSE. */ +SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit); + +/*! \brief Put a byte of the current document page. + \param s The T.4/T.6 context. + \param buf The buffer containing the chunk. + \param len The length of the chunk. + \return T4_DECODE_MORE_DATA when the image is still in progress. T4_DECODE_OK when the image is complete. */ +SPAN_DECLARE(int) t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len); + +/*! \brief Set the row write handler for a T.4/T.6 decode context. + \param s The T.4/T.6 context. + \param handler A pointer to the handler routine. + \param user_data An opaque pointer passed to the handler routine. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_decode_set_row_write_handler(t4_t6_decode_state_t *s, t4_row_write_handler_t handler, void *user_data); + +/*! \brief Set the encoding for the encoded data. + \param s The T.4/T.6 context. + \param encoding The encoding. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_decode_set_encoding(t4_t6_decode_state_t *s, int encoding); + +/*! \brief Get the width of the image. + \param s The T.4/T.6 context. + \return The width of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_width(t4_t6_decode_state_t *s); + +/*! \brief Get the length of the image. + \param s The T.4/T.6 context. + \return The length of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_length(t4_t6_decode_state_t *s); + +/*! \brief Get the size of the compressed image, in bits. + \param s The T.4/T.6 context. + \return The size of the compressed image, in bits. */ +SPAN_DECLARE(int) t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s); + +SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width); + +/*! \brief Prepare to decode an image in T.4 or T.6 format. + \param s The T.4/T.6 context. + \param encoding The encoding mode. + \param image width The image width, in pixels. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ +SPAN_DECLARE(t4_t6_decode_state_t *) t4_t6_decode_init(t4_t6_decode_state_t *s, + int encoding, + int image_width, + t4_row_write_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t4_t6_decode_release(t4_t6_decode_state_t *s); + +SPAN_DECLARE(int) t4_t6_decode_free(t4_t6_decode_state_t *s); + #if defined(__cplusplus) } #endif diff --git a/libs/spandsp/src/spandsp/t4_t6_encode.h b/libs/spandsp/src/spandsp/t4_t6_encode.h index 72a3598bcb..4d64c8cf97 100644 --- a/libs/spandsp/src/spandsp/t4_t6_encode.h +++ b/libs/spandsp/src/spandsp/t4_t6_encode.h @@ -34,6 +34,101 @@ typedef struct t4_t6_encode_state_s t4_t6_encode_state_t; extern "C" { #endif +/*! \brief Return the next bit of the current document page, without actually + moving forward in the buffer. The document will be padded for the + current minimum scan line time. + \param s The T.4/T.6 context. + \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */ +SPAN_DECLARE(int) t4_t6_encode_image_complete(t4_t6_encode_state_t *s); + +/*! \brief Get the next bit of the current image. The image will + be padded for the current minimum scan line time. + \param s The T.4/T.6 context. + \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */ +SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s); + +/*! \brief Get the next chunk of the current document page. The document will + be padded for the current minimum scan line time. + \param s The T.4/T.6 context. + \param buf The buffer into which the chunk is to written. + \param max_len The maximum length of the chunk. + \return The actual length of the chunk. If this is less than max_len it + indicates that the end of the document has been reached. */ +SPAN_DECLARE(int) t4_t6_encode_get(t4_t6_encode_state_t *s, uint8_t buf[], int max_len); + +/*! \brief Set the row read handler for a T.4/T.6 encode context. + \param s The T.4/T.6 context. + \param handler A pointer to the handler routine. + \param user_data An opaque pointer passed to the handler routine. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_encode_set_row_read_handler(t4_t6_encode_state_t *s, + t4_row_read_handler_t handler, + void *user_data); + +/*! \brief Set the encoding for the encoded data. + \param s The T.4/T.6 context. + \param encoding The encoding. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_encode_set_encoding(t4_t6_encode_state_t *s, int encoding); + +/*! \brief Set the width of the image. + \param s The T.4/T.6 context. + \param image_width The image width, in pixels. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int image_width); + +/*! \brief Get the width of the image. + \param s The T.4/T.6 context. + \return The width of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_width(t4_t6_encode_state_t *s); + +/*! \brief Get the length of the image. + \param s The T.4/T.6 context. + \return The length of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_length(t4_t6_encode_state_t *s); + +/*! \brief Get the size of the compressed image, in bits. + \param s The T.4/T.6 context. + \return The size of the compressed image, in bits. */ +SPAN_DECLARE(int) t4_t6_encode_get_compressed_image_size(t4_t6_encode_state_t *s); + +/*! \brief Set the minimum number of encoded bits per row. This allows the + makes the encoding process to be set to comply with the minimum row + time specified by a remote receiving machine. + \param s The T.4/T.6 context. + \param bits The minimum number of bits per row. */ +SPAN_DECLARE(void) t4_t6_encode_set_min_bits_per_row(t4_t6_encode_state_t *s, int bits); + +/*! \brief Set the maximum number of 2D encoded rows between 1D encoded rows. This + is only valid for T.4 2D encoding. + \param s The T.4/T.6 context. + \param max The "K" parameter defined in the T.4 specification. This means the value is one + greater than the maximum number of 2D rows between each 1D row. */ +SPAN_DECLARE(void) t4_t6_encode_set_max_2d_rows_per_1d_row(t4_t6_encode_state_t *s, int max); + +/*! \brief Restart a T.4 or T.6 encode context. + \param s The T.4/T.6 context. + \param image width The image width, in pixels. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_t6_encode_restart(t4_t6_encode_state_t *s, int image_width); + +/*! \brief Prepare to encode an image in T.4 or T.6 format. + \param s The T.4/T.6 context. + \param encoding The encoding mode. + \param image width The image width, in pixels. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ +SPAN_DECLARE(t4_t6_encode_state_t *) t4_t6_encode_init(t4_t6_encode_state_t *s, + int encoding, + int image_width, + t4_row_read_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t4_t6_encode_release(t4_t6_encode_state_t *s); + +SPAN_DECLARE(int) t4_t6_encode_free(t4_t6_encode_state_t *s); + #if defined(__cplusplus) } #endif diff --git a/libs/spandsp/src/spandsp/t4_tx.h b/libs/spandsp/src/spandsp/t4_tx.h index 6a10588e3e..3eccc679c8 100644 --- a/libs/spandsp/src/spandsp/t4_tx.h +++ b/libs/spandsp/src/spandsp/t4_tx.h @@ -28,15 +28,18 @@ #if !defined(_SPANDSP_T4_TX_H_) #define _SPANDSP_T4_TX_H_ -//#define SPANDSP_SUPPORT_TIFF_FX - /*! This function is a callback from the image decoders, to read the unencoded bi-level image, row by row. It is called for each row, with len set to the number of bytes per row expected. \return len for OK, or zero to indicate the end of the image data. */ typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len); -#if defined(SPANDSP_SUPPORT_TIFF_FX) -/* TIFF-FX related extensions to the tag set supported by libtiff */ +/*! + T.4 FAX compression/decompression descriptor. This defines the working state + for a single instance of a T.4 FAX compression or decompression channel. +*/ +typedef struct t4_tx_state_s t4_tx_state_t; + +/* TIFF-FX related extensions to the TIFF tag set */ /* Indexed(346) = 0, 1. SHORT @@ -49,7 +52,7 @@ Indexed(346) = 0, 1. SHORT profile supports palette-color images with the ITULAB encoding. The SamplesPerPixel value must be 1. -GlobalParametersIFD (400) IFD +GlobalParametersIFD (400) IFD/LONG An IFD containing global parameters. It is recommended that a TIFF writer place this field in the first IFD, where a TIFF reader would find it quickly. @@ -171,6 +174,9 @@ ImageLayer(34732) LONG 3: ... */ +/* Define the TIFF/FX tags to extend libtiff, when using a version of libtiff where this + stuff has not been merged. */ +#if defined(SPANDSP_SUPPORT_TIFF_FX) && !defined(TIFFTAG_FAXPROFILE) #define TIFFTAG_INDEXED 346 #define TIFFTAG_GLOBALPARAMETERSIFD 400 #define TIFFTAG_PROFILETYPE 401 @@ -217,17 +223,17 @@ SPAN_DECLARE(void) TIFF_FX_init(void); \param start_page The first page to send. -1 for no restriction. \param stop_page The last page to send. -1 for no restriction. \return A pointer to the context, or NULL if there was a problem. */ -SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page); +SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int start_page, int stop_page); /*! \brief Prepare to send the next page of the current document. \param s The T.4 context. \return zero for success, -1 for failure. */ -SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s); /*! \brief Prepare the current page for a resend. \param s The T.4 context. \return zero for success, -1 for failure. */ -SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_restart_page(t4_tx_state_t *s); /*! \brief Check for the existance of the next page, and whether its format is like the current one. This information can be needed before it is determined that the current @@ -236,35 +242,25 @@ SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s); \return 0 for next page found with the same format as the current page. 1 for next page found with different format from the current page. -1 for no page found, or file failure. */ -SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_tx_state_t *s); /*! \brief Complete the sending of a page. \param s The T.4 context. \return zero for success, -1 for failure. */ -SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_end_page(t4_tx_state_t *s); /*! \brief Return the next bit of the current document page, without actually moving forward in the buffer. The document will be padded for the current minimum scan line time. \param s The T.4 context. - \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is - set (i.e. the returned value is 2 or 3). */ -SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s); + \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */ +SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s); /*! \brief Get the next bit of the current document page. The document will be padded for the current minimum scan line time. \param s The T.4 context. - \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is - set (i.e. the returned value is 2 or 3). */ -SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s); - -/*! \brief Get the next byte of the current document page. The document will - be padded for the current minimum scan line time. - \param s The T.4 context. - \return The next byte. For the last byte of data, bit 8 is - set. In this case, one or more bits of the byte may be padded with - zeros, to complete the byte. */ -SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s); + \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */ +SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s); /*! \brief Get the next chunk of the current document page. The document will be padded for the current minimum scan line time. @@ -273,37 +269,49 @@ SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s); \param max_len The maximum length of the chunk. \return The actual length of the chunk. If this is less than max_len it indicates that the end of the document has been reached. */ -SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len); +SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len); /*! \brief End the transmission of a document. Tidy up and close the file. This should be used to end T.4 transmission started with t4_tx_init. \param s The T.4 context. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_tx_release(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s); /*! \brief End the transmission of a document. Tidy up, close the file and free the context. This should be used to end T.4 transmission started with t4_tx_init. \param s The T.4 context. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_tx_free(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_free(t4_tx_state_t *s); /*! \brief Set the encoding for the encoded data. \param s The T.4 context. - \param encoding The encoding. */ -SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding); + \param encoding The encoding. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding); /*! \brief Set the minimum number of encoded bits per row. This allows the makes the encoding process to be set to comply with the minimum row time specified by a remote receiving machine. \param s The T.4 context. \param bits The minimum number of bits per row. */ -SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits); +SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits); + +/*! \brief Set the width of the image. + \param s The T.4 context. + \param image_width The image width, in pixels. */ +SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width); + +/*! \brief Set the maximum number of 2D encoded rows between 1D encoded rows. This + is only valid for T.4 2D encoding. + \param s The T.4 context. + \param max The maximum number of 2D rows. */ +SPAN_DECLARE(void) t4_tx_set_max_2d_rows_per_1d_row(t4_tx_state_t *s, int max); /*! \brief Set the identity of the local machine, for inclusion in page headers. \param s The T.4 context. \param ident The identity string. */ -SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident); +SPAN_DECLARE(void) t4_tx_set_local_ident(t4_tx_state_t *s, const char *ident); /*! Set the info field, included in the header line included in each page of an encoded FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.) @@ -312,58 +320,58 @@ SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident); \brief Set the header info. \param s The T.4 context. \param info A string, of up to 50 bytes, which will form the info field. */ -SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info); +SPAN_DECLARE(void) t4_tx_set_header_info(t4_tx_state_t *s, const char *info); /*! Set the time zone for the time stamp in page header lines. If this function is not used the current time zone of the program's environment is used. \brief Set the header timezone. \param s The T.4 context. \param tz A time zone descriptor. */ -SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, tz_t *tz); +SPAN_DECLARE(void) t4_tx_set_header_tz(t4_tx_state_t *s, tz_t *tz); /*! Set page header extends or overlays the image mode. \brief Set page header overlay mode. \param s The T.4 context. \param header_overlays_image TRUE for overlay, or FALSE for extend the page. */ -SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_state_t *s, int header_overlays_image); +SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, int header_overlays_image); /*! \brief Set the row read handler for a T.4 transmit context. \param s The T.4 transmit context. \param handler A pointer to the handler routine. \param user_data An opaque pointer passed to the handler routine. \return 0 for success, otherwise -1. */ -SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data); +SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, void *user_data); /*! \brief Get the row-to-row (y) resolution of the current page. \param s The T.4 context. \return The resolution, in pixels per metre. */ -SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_tx_state_t *s); /*! \brief Get the column-to-column (x) resolution of the current page. \param s The T.4 context. \return The resolution, in pixels per metre. */ -SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_tx_state_t *s); /*! \brief Get the width of the current page, in pixel columns. \param s The T.4 context. \return The number of columns. */ -SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_get_image_width(t4_tx_state_t *s); /*! \brief Get the number of pages in the file. \param s The T.4 context. \return The number of pages, or -1 if there is an error. */ -SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_tx_state_t *s); /*! \brief Get the currnet page number in the file. \param s The T.4 context. \return The page number, or -1 if there is an error. */ -SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s); +SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_tx_state_t *s); /*! Get the current image transfer statistics. \brief Get the current transfer statistics. \param s The T.4 context. \param t A pointer to a statistics structure. */ -SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t); +SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t); #if defined(__cplusplus) } diff --git a/libs/spandsp/src/spandsp/t81_t82_arith_coding.h b/libs/spandsp/src/spandsp/t81_t82_arith_coding.h new file mode 100644 index 0000000000..905e0491be --- /dev/null +++ b/libs/spandsp/src/spandsp/t81_t82_arith_coding.h @@ -0,0 +1,82 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t81_t82_arith_coding.h - ITU T.81 and T.82 QM-coder arithmetic encoding + * and decoding + * + * Written by Steve Underwood + * + * Copyright (C) 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_SPANDSP_T81_T82_ARITH_CODING_H_) +#define _SPANDSP_T81_T82_ARITH_CODING_H_ + +/*! \page t81_t82_arith_coding_page T.81 and T.82 QM-coder arithmetic encoding and decoding + +\section t81_t82_arith_coding_page_sec_1 What does it do? +A similar arithmetic coder, called the QM-coder, is used by several image compression +schemes. These routines implement this coder in a (hopefully) reusable way. + +\section t81_t82_arith_coding_page_sec_1 How does it work? +*/ + +/* State of a working instance of the arithmetic encoder */ +typedef struct t81_t82_arith_encode_state_s t81_t82_arith_encode_state_t; + +/* State of a working instance of the arithmetic decoder */ +typedef struct t81_t82_arith_decode_state_s t81_t82_arith_decode_state_t; + +#if defined(__cplusplus) +extern "C" +{ +#endif + +SPAN_DECLARE(t81_t82_arith_encode_state_t *) t81_t82_arith_encode_init(t81_t82_arith_encode_state_t *s, + void (*output_byte_handler)(void *, int), + void *user_data); + +SPAN_DECLARE(int) t81_t82_arith_encode_restart(t81_t82_arith_encode_state_t *s, int reuse_st); + +SPAN_DECLARE(int) t81_t82_arith_encode_release(t81_t82_arith_encode_state_t *s); + +SPAN_DECLARE(int) t81_t82_arith_encode_free(t81_t82_arith_encode_state_t *s); + +SPAN_DECLARE(void) t81_t82_arith_encode(t81_t82_arith_encode_state_t *s, int cx, int pix); + +SPAN_DECLARE(void) t81_t82_arith_encode_flush(t81_t82_arith_encode_state_t *s); + + +SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_arith_decode_state_t *s); + +SPAN_DECLARE(int) t81_t82_arith_decode_restart(t81_t82_arith_decode_state_t *s, int reuse_st); + +SPAN_DECLARE(int) t81_t82_arith_decode_release(t81_t82_arith_decode_state_t *s); + +SPAN_DECLARE(int) t81_t82_arith_decode_free(t81_t82_arith_decode_state_t *s); + +SPAN_DECLARE(int) t81_t82_arith_decode(t81_t82_arith_decode_state_t *s, int cx); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/t85.h b/libs/spandsp/src/spandsp/t85.h new file mode 100644 index 0000000000..07dd88931f --- /dev/null +++ b/libs/spandsp/src/spandsp/t85.h @@ -0,0 +1,271 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t85.h - ITU T.85 JBIG for FAX image processing + * + * Written by Steve Underwood + * + * Copyright (C) 2008, 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_SPANDSP_T85_H_) +#define _SPANDSP_T85_H_ + +/*! \page t85_page T.85 (JBIG for FAX) image compression and decompression + +\section t85_page_sec_1 What does it do? +The T.85 image compression and decompression routines implement the variant of the +JBIG encoding method defined in ITU specification T.85. This is an image compression +algorithm used for black and white FAX transmission. T.85 defines a subset of the +full JBIG spec (T.82), which only handled a single progressively scanned bit plane. +This results in a great deal of simplification, and results in the ability to +compress or decompress progressively, while only buffering the latest 3 pixel rows +of the image. + +\section t85_page_sec_1 How does it work? +*/ + +/*! Bits in the option byte of the T.82 BIH which are valid for T.85 */ +enum +{ + /*! Enable typical prediction (bottom) */ + T85_TPBON = 0x08, + /*! Variable length image */ + T85_VLENGTH = 0x20, + /*! Lowest-resolution-layer is a two-line template */ + T85_LRLTWO = 0x40 +}; + +/*! State of a working instance of the T.85 encoder */ +typedef struct t85_encode_state_s t85_encode_state_t; + +/*! State of a working instance of the T.85 decoder */ +typedef struct t85_decode_state_s t85_decode_state_t; + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/*! \brief Check if we are at the end of the current document page. + \param s The T.85 context. + \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */ +SPAN_DECLARE(int) t85_encode_image_complete(t85_encode_state_t *s); + +/*! \brief Get the next chunk of the current document page. The document will + be padded for the current minimum scan line time. + \param s The T.85 context. + \param buf The buffer into which the chunk is to written. + \param max_len The maximum length of the chunk. + \return The actual length of the chunk. If this is less than max_len it + indicates that the end of the document has been reached. */ +SPAN_DECLARE(int) t85_encode_get(t85_encode_state_t *s, uint8_t buf[], size_t max_len); + +/*! \brief Set the row read handler for a T.85 encode context. + \param s The T.85 context. + \param handler A pointer to the handler routine. + \param user_data An opaque pointer passed to the handler routine. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t85_encode_set_row_read_handler(t85_encode_state_t *s, + t4_row_read_handler_t handler, + void *user_data); + +/*! Get the logging context associated with a T.85 encode context. + \brief Get the logging context associated with a T.85 encode context. + \param s The T.85 encode context. + \return A pointer to the logging context */ +SPAN_DECLARE(logging_state_t *) t85_encode_get_logging_state(t85_encode_state_t *s); + +/*! \brief Prepare to encode an image in T.85 format. + \param s The T.85 context. + \param image_width Image width, in pixels. + \param image_length Image length, in pixels. + \param handler A callback routine to handle encoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ +SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s, + uint32_t image_width, + uint32_t image_length, + t4_row_read_handler_t handler, + void *user_data); + +/*! \brief Restart a T.85 encode context. + \param s The T.85 context. + \param image width The image width, in pixels. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s, + uint32_t image_width, + uint32_t image_length); + +SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s); + +SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s); + +/*! \brief Set the T.85 options + \param s The T.85 context. + \brief l0 ??? + \brief mx ??? + \brief options ???. */ +SPAN_DECLARE(void) t85_encode_set_options(t85_encode_state_t *s, + uint32_t l0, + int mx, + int options); + +/*! \brief Insert a comment in the encoded file. + \param s The T.85 context. + \param comment The comment. Note that this is not a C string, and may contain any bytes. + \param len The length of the comment. */ +SPAN_DECLARE(void) t85_encode_comment(t85_encode_state_t *s, + const uint8_t comment[], + size_t len); + +/*! \brief Set the image width. + \param s The T.85 context. + \param width The width of the image. + \return 0 for success, otherwise -1. */ +SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t image_width); + +/*! \brief Alter the length of a T.85 encoded image. The new length cannot be greater than the + originally specified length. If the new length is less than the current length it + will be silently adjusted to the current length. Therefore, adjust the length to 1 + will make the currently encoded length the final length. + \param s The T.85 context. + \param length The new image length, in pixels. + \return 0 if OK, or -1 if the request was not valid. */ +SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t length); + +/*! \brief Get the width of the image. + \param s The T.85 context. + \return The width of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t85_encode_get_image_width(t85_encode_state_t *s); + +/*! \brief Get the length of the image. + \param s The T.85 context. + \return The length of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t85_encode_get_image_length(t85_encode_state_t *s); + +/*! \brief Get the size of the compressed image, in bits. + \param s The T.85 context. + \return The size of the compressed image, in bits. */ +SPAN_DECLARE(int) t85_encode_get_compressed_image_size(t85_encode_state_t *s); + +/*! \brief Stop image encoding prematurely. + \param s The T.85 context. */ +SPAN_DECLARE(void) t85_encode_abort(t85_encode_state_t *s); + +/*! Get the logging context associated with a T.85 decode context. + \brief Get the logging context associated with a T.85 decode context. + \param s The T.85 decode context. + \return A pointer to the logging context */ +SPAN_DECLARE(logging_state_t *) t85_decode_get_logging_state(t85_decode_state_t *s); + +/*! \brief Prepare to decode an image in T.85 format. + \param s The T.85 context. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return A pointer to the context, or NULL if there was a problem. */ +SPAN_DECLARE(t85_decode_state_t *) t85_decode_init(t85_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data); + +SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s); + +SPAN_DECLARE(int) t85_decode_restart(t85_decode_state_t *s); + +SPAN_DECLARE(int) t85_decode_release(t85_decode_state_t *s); + +SPAN_DECLARE(int) t85_decode_free(t85_decode_state_t *s); + +/*! \brief Get the width of the image. + \param s The T.85 context. + \return The width of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t85_decode_get_image_width(t85_decode_state_t *s); + +/*! \brief Get the length of the image. + \param s The T.85 context. + \return The length of the image, in pixels. */ +SPAN_DECLARE(uint32_t) t85_decode_get_image_length(t85_decode_state_t *s); + +/*! \brief Get the size of the compressed image, in bits. + \param s The T.85 context. + \return The size of the compressed image, in bits. */ +SPAN_DECLARE(int) t85_decode_get_compressed_image_size(t85_decode_state_t *s); + +/*! \brief Set the row handler routine. + \param s The T.85 context. + \param handler A callback routine to handle decoded image rows. + \param user_data An opaque pointer passed to handler. + \return 0 for OK. */ +SPAN_DECLARE(int) t85_decode_set_row_write_handler(t85_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data); + +/*! \brief Set the comment handler routine. + \param s The T.85 context. + \param max_comment_len The maximum length of comment to be passed to the handler. + \param handler A callback routine to handle decoded comment. + \param user_data An opaque pointer passed to handler. + \return 0 for OK. */ +SPAN_DECLARE(int) t85_decode_set_comment_handler(t85_decode_state_t *s, + uint32_t max_comment_len, + t4_row_write_handler_t handler, + void *user_data); + +/*! A maliciously constructed T.85 image could consume too much memory, and constitute + a denial of service attack on the system. This function allows constraints to be + applied. + \brief Set constraints on the received image size. + \param s The T.85 context. + \param max_xd The maximum permitted width of the full image, in pixels + \param max_yd The maximum permitted height of the full image, in pixels + \return 0 for OK */ +SPAN_DECLARE(int) t85_decode_set_image_size_constraints(t85_decode_state_t *s, + uint32_t max_xd, + uint32_t max_yd); + +/*! After the final BIE byte has been delivered to t85_decode_put_xx(), it may still + return T85_MORE_DATA when the T85_VLENGTH option was used, and no NEWLEN + marker section has appeared yet. This is because such a BIE is not + self-terminating (i.e. there could still be a NEWLEN followed by an SDNORM + or SDRST at the very end of the final stripe, which needs to be processed + before the final row is output. See ITU-T Recommendation T.85, Appendix I). + Therefore, after the last byte has been delivered, call this routine to + signal the end of the BIE. This is necessary to allow the routine to finish + processing BIEs with option T85_VLENGTH that do not actually contain any + NEWLEN marker section. + \brief Inform the T.85 decode engine of a status change in the signal source (end + of tx, rx signal change, etc.). + \param s The T.85 context. + \param status The type of status change which occured. */ +SPAN_DECLARE(void) t85_decode_rx_status(t85_decode_state_t *s, int status); + +/*! \brief Decode a chunk of T.85 data. + \param s The T.85 context. + \param data The data to be decoded. + \param len The length of the data to be decoded. + \return 0 for OK. */ +SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], size_t len); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/telephony.h b/libs/spandsp/src/spandsp/telephony.h index 49d7200e83..7a09bbe044 100644 --- a/libs/spandsp/src/spandsp/telephony.h +++ b/libs/spandsp/src/spandsp/telephony.h @@ -56,16 +56,16 @@ #define DBOV_MAX_SINE_POWER (-3.02f) /*! \brief A handler for pure receive. The buffer cannot be altered. */ -typedef int (span_rx_handler_t)(void *s, const int16_t amp[], int len); +typedef int (*span_rx_handler_t)(void *s, const int16_t amp[], int len); /*! \brief A handler for receive, where the buffer can be altered. */ -typedef int (span_mod_handler_t)(void *s, int16_t amp[], int len); +typedef int (*span_mod_handler_t)(void *s, int16_t amp[], int len); /*! \brief A handler for missing receive data fill-in. */ -typedef int (span_rx_fillin_handler_t)(void *s, int len); +typedef int (*span_rx_fillin_handler_t)(void *s, int len); /*! \brief A handler for transmit, where the buffer will be filled. */ -typedef int (span_tx_handler_t)(void *s, int16_t amp[], int max_len); +typedef int (*span_tx_handler_t)(void *s, int16_t amp[], int max_len); #define ms_to_samples(t) ((t)*(SAMPLE_RATE/1000)) #define us_to_samples(t) ((t)/(1000000/SAMPLE_RATE)) diff --git a/libs/spandsp/src/spandsp/tone_generate.h b/libs/spandsp/src/spandsp/tone_generate.h index 545335af51..d6ed8f2bc3 100644 --- a/libs/spandsp/src/spandsp/tone_generate.h +++ b/libs/spandsp/src/spandsp/tone_generate.h @@ -86,9 +86,6 @@ SPAN_DECLARE(tone_gen_descriptor_t *) tone_gen_descriptor_init(tone_gen_descript int d4, int repeat); -/* For backwards compatibility */ -#define make_tone_gen_descriptor tone_gen_descriptor_init - SPAN_DECLARE(void) tone_gen_descriptor_free(tone_gen_descriptor_t *s); SPAN_DECLARE_NONSTD(int) tone_gen(tone_gen_state_t *s, int16_t amp[], int max_samples); diff --git a/libs/spandsp/src/spandsp/v17rx.h b/libs/spandsp/src/spandsp/v17rx.h index d6ac46caa1..935d542853 100644 --- a/libs/spandsp/src/spandsp/v17rx.h +++ b/libs/spandsp/src/spandsp/v17rx.h @@ -209,6 +209,12 @@ working only on the most optimal lines, and being widely usable across most phon TCM absolutely transformed the phone line modem business. */ +#if defined(SPANDSP_USE_FIXED_POINT) +#define V17_CONSTELLATION_SCALING_FACTOR 1024.0 +#else +#define V17_CONSTELLATION_SCALING_FACTOR 1.0 +#endif + /*! V.17 modem receive side descriptor. This defines the working state for a single instance of a V.17 modem receiver. @@ -292,8 +298,8 @@ SPAN_DECLARE_NONSTD(int) v17_rx_fillin(v17_rx_state_t *s, int len); \param s The modem context. \param coeffs The vector of complex coefficients. \return The number of coefficients in the vector. */ -#if defined(SPANDSP_USE_FIXED_POINTx) -SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexi_t **coeffs); +#if defined(SPANDSP_USE_FIXED_POINT) +SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexi16_t **coeffs); #else SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs); #endif diff --git a/libs/spandsp/src/spandsp/v18.h b/libs/spandsp/src/spandsp/v18.h index 53da9d099f..bc73c7e619 100644 --- a/libs/spandsp/src/spandsp/v18.h +++ b/libs/spandsp/src/spandsp/v18.h @@ -39,24 +39,59 @@ typedef struct v18_state_s v18_state_t; enum { V18_MODE_NONE = 0, - /* V.18 Annex A - Weitbrecht TDD at 45.45bps, half-duplex, 5 bit baudot. */ + /* V.18 Annex A - Weitbrecht TDD at 45.45bps (US TTY), half-duplex, 5 bit baudot (USA). */ V18_MODE_5BIT_45 = 1, - /* V.18 Annex A - Weitbrecht TDD at 50bps, half-duplex, 5 bit baudot. */ + /* V.18 Annex A - Weitbrecht TDD at 50bps (International TTY), half-duplex, 5 bit baudot (UK, Australia and others). */ V18_MODE_5BIT_50 = 2, - /* V.18 Annex B - DTMF encoding of ASCII. */ + /* V.18 Annex B - DTMF encoding of ASCII (Denmark, Holland and others). */ V18_MODE_DTMF = 3, - /* V.18 Annex C - EDT 110bps, V.21, half-duplex, ASCII. */ + /* V.18 Annex C - EDT (European Deaf Telephone) 110bps, V.21, half-duplex, ASCII (Germany, Austria, Switzerland and others). */ V18_MODE_EDT = 4, - /* V.18 Annex D - 300bps, Bell 103, duplex, ASCII. */ + /* V.18 Annex D - 300bps, Bell 103, duplex, ASCII (USA). */ V18_MODE_BELL103 = 5, - /* V.18 Annex E - 1200bps Videotex terminals, ASCII. */ + /* V.18 Annex E - 1200bps Videotex terminals, ASCII (France). */ V18_MODE_V23VIDEOTEX = 6, - /* V.18 Annex F - V.21 text telephone, V.21, duplex, ASCII. */ + /* V.18 Annex F - V.21 text telephone, V.21, duplex, ASCII (Sweden, Norway and Finland). */ V18_MODE_V21TEXTPHONE = 7, /* V.18 Annex G - V.18 text telephone mode. */ V18_MODE_V18TEXTPHONE = 8 }; +/* Automoding sequences for different countries */ +enum +{ + /* 5-bit, V.21, V.23, EDT, DTMF, Bell 103 */ + V18_AUTOMODING_AUSTRALIA, + V18_AUTOMODING_IRELAND, + + /* EDT, V.21, V.23, 5-bit, DTMF, Bell 103 */ + V18_AUTOMODING_GERMANY, + V18_AUTOMODING_SWITZERLAND, + V18_AUTOMODING_ITALY, + V18_AUTOMODING_SPAIN, + V18_AUTOMODING_AUSTRIA, + + /* DTMF, V.21, V.23, 5-bit, EDT, Bell 103 */ + V18_AUTOMODING_NETHERLANDS, + + /* V.21, DTMF, 5-bit, EDT, V.23, Bell 103 */ + V18_AUTOMODING_ICELAND, + V18_AUTOMODING_NORWAY, + V18_AUTOMODING_SWEDEN, + V18_AUTOMODING_FINALND, + V18_AUTOMODING_DENMARK, + + /* V.21, 5-bit, V.23, EDT, DTMF, Bell 103 */ + V18_AUTOMODING_UK, + + /* 5-bit, Bell 103, V.21, V.23, EDT, DTMF */ + V18_AUTOMODING_USA, + + /* V.23, EDT, DTMF, 5-bit, V.21, Bell 103 */ + V18_AUTOMODING_FRANCE, + V18_AUTOMODING_BELGIUM +}; + #if defined(__cplusplus) extern "C" { diff --git a/libs/spandsp/src/spandsp/v22bis.h b/libs/spandsp/src/spandsp/v22bis.h index 073fb7135a..6361c05841 100644 --- a/libs/spandsp/src/spandsp/v22bis.h +++ b/libs/spandsp/src/spandsp/v22bis.h @@ -48,6 +48,12 @@ or 1200bps if one or both ends to not acknowledge that 2400bps is OK. #if !defined(_SPANDSP_V22BIS_H_) #define _SPANDSP_V22BIS_H_ +#if defined(SPANDSP_USE_FIXED_POINT) +#define V22BIS_CONSTELLATION_SCALING_FACTOR 1024.0 +#else +#define V22BIS_CONSTELLATION_SCALING_FACTOR 1.0 +#endif + enum { V22BIS_GUARD_TONE_NONE, @@ -61,8 +67,6 @@ enum */ typedef struct v22bis_state_s v22bis_state_t; -extern const complexf_t v22bis_constellation[16]; - #if defined(__cplusplus) extern "C" { @@ -88,7 +92,11 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx_fillin(v22bis_state_t *s, int len); \brief Get a snapshot of the current equalizer coefficients. \param coeffs The vector of complex coefficients. \return The number of coefficients in the vector. */ +#if defined(SPANDSP_USE_FIXED_POINT) +SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexi16_t **coeffs); +#else SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs); +#endif /*! Get the current received carrier frequency. \param s The modem context. diff --git a/libs/spandsp/src/spandsp/v27ter_rx.h b/libs/spandsp/src/spandsp/v27ter_rx.h index bb12801b50..a6055844d6 100644 --- a/libs/spandsp/src/spandsp/v27ter_rx.h +++ b/libs/spandsp/src/spandsp/v27ter_rx.h @@ -44,6 +44,12 @@ at the start of transmission, which makes the design of a V.27ter receiver relat straightforward. */ +#if defined(SPANDSP_USE_FIXED_POINT) +#define V27TER_CONSTELLATION_SCALING_FACTOR 1024.0 +#else +#define V27TER_CONSTELLATION_SCALING_FACTOR 1.0 +#endif + /*! V.27ter modem receive side descriptor. This defines the working state for a single instance of a V.27ter modem receiver. @@ -126,7 +132,11 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len); \brief Get a snapshot of the current equalizer coefficients. \param coeffs The vector of complex coefficients. \return The number of coefficients in the vector. */ +#if defined(SPANDSP_USE_FIXED_POINT) +SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexi16_t **coeffs); +#else SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs); +#endif /*! Get the current received carrier frequency. \param s The modem context. diff --git a/libs/spandsp/src/spandsp/v29rx.h b/libs/spandsp/src/spandsp/v29rx.h index d7874b68dc..bb52e624dc 100644 --- a/libs/spandsp/src/spandsp/v29rx.h +++ b/libs/spandsp/src/spandsp/v29rx.h @@ -118,7 +118,17 @@ scrambler register) cannot be trusted for the test. The receive modem, therefore, only tests that bits starting at bit 24 are really ones. */ +#if defined(SPANDSP_USE_FIXED_POINT) +#define V29_CONSTELLATION_SCALING_FACTOR 4096.0 +#else +#define V29_CONSTELLATION_SCALING_FACTOR 1.0 +#endif + +#if defined(SPANDSP_USE_FIXED_POINT) +typedef void (*qam_report_handler_t)(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol); +#else typedef void (*qam_report_handler_t)(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol); +#endif /*! V.29 modem receive side descriptor. This defines the working state for a diff --git a/libs/spandsp/src/spandsp/v8.h b/libs/spandsp/src/spandsp/v8.h index 25449fb6c1..fa9df4a0c5 100644 --- a/libs/spandsp/src/spandsp/v8.h +++ b/libs/spandsp/src/spandsp/v8.h @@ -43,7 +43,7 @@ being negotiating and training with their chosen modem standard. typedef struct v8_parms_s v8_parms_t; -typedef void (v8_result_handler_t)(void *user_data, v8_parms_t *result); +typedef void (*v8_result_handler_t)(void *user_data, v8_parms_t *result); enum v8_call_function_e { @@ -118,6 +118,8 @@ struct v8_parms_s { int status; int modem_connect_tone; + int send_ci; + int v92; int call_function; unsigned int modulations; int protocol; @@ -147,7 +149,7 @@ SPAN_DECLARE(int) v8_restart(v8_state_t *s, SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s, int calling_party, v8_parms_t *parms, - v8_result_handler_t *result_handler, + v8_result_handler_t result_handler, void *user_data); /*! Release a V.8 context. diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index a07f2f061d..469cd37b08 100644 --- a/libs/spandsp/src/spandsp/version.h +++ b/libs/spandsp/src/spandsp/version.h @@ -28,9 +28,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20100724 +#define SPANDSP_RELEASE_DATE 20120902 #define SPANDSP_RELEASE_TIME 163333 -#define SPANDSP_RELEASE_DATETIME_STRING "20100724 163333" +#define SPANDSP_RELEASE_DATETIME_STRING "20120902 163333" #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/super_tone_rx.c b/libs/spandsp/src/super_tone_rx.c index 87934669ab..e46faa8148 100644 --- a/libs/spandsp/src/super_tone_rx.c +++ b/libs/spandsp/src/super_tone_rx.c @@ -56,11 +56,11 @@ #include "spandsp/private/super_tone_rx.h" #if defined(SPANDSP_USE_FIXED_POINT) -#define DETECTION_THRESHOLD 16439 /* -42dBm0 [((BINS*BINS*32768.0/(1.4142*128.0))*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */ +#define DETECTION_THRESHOLD 16439 /* -42dBm0 [((SUPER_TONE_BINS*SUPER_TONE_BINS*32768.0/(1.4142*128.0))*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */ #define TONE_TWIST 4 /* 6dB */ #define TONE_TO_TOTAL_ENERGY 64 /* -3dB */ #else -#define DETECTION_THRESHOLD 2104205.6f /* -42dBm0 [((BINS*BINS*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */ +#define DETECTION_THRESHOLD 2104205.6f /* -42dBm0 [((SUPER_TONE_BINS*SUPER_TONE_BINS*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */ #define TONE_TWIST 3.981f /* 6dB */ #define TONE_TO_TOTAL_ENERGY 1.995f /* 3dB */ #endif @@ -86,7 +86,7 @@ static int add_super_tone_freq(super_tone_rx_descriptor_t *desc, int freq) /* Merge these two */ desc->pitches[desc->used_frequencies][0] = freq; desc->pitches[desc->used_frequencies][1] = i; - make_goertzel_descriptor(&desc->desc[desc->pitches[i][1]], (float) (freq + desc->pitches[i][0])/2, BINS); + make_goertzel_descriptor(&desc->desc[desc->pitches[i][1]], (float) (freq + desc->pitches[i][0])/2, SUPER_TONE_BINS); desc->used_frequencies++; return desc->pitches[i][1]; } @@ -97,7 +97,7 @@ static int add_super_tone_freq(super_tone_rx_descriptor_t *desc, int freq) { desc->desc = (goertzel_descriptor_t *) realloc(desc->desc, (desc->monitored_frequencies + 5)*sizeof(goertzel_descriptor_t)); } - make_goertzel_descriptor(&desc->desc[desc->monitored_frequencies++], (float) freq, BINS); + make_goertzel_descriptor(&desc->desc[desc->monitored_frequencies++], (float) freq, SUPER_TONE_BINS); desc->used_frequencies++; return desc->pitches[i][1]; } @@ -161,19 +161,19 @@ static int test_cadence(super_tone_rx_segment_t *pattern, steps = -steps; j = (rotation + steps - 2)%steps; if (pattern[j].f1 != test[8].f1 || pattern[j].f2 != test[8].f2) - return 0; - if (pattern[j].min_duration > test[8].min_duration*BINS + return 0; + if (pattern[j].min_duration > test[8].min_duration*SUPER_TONE_BINS || - pattern[j].max_duration < test[8].min_duration*BINS) + pattern[j].max_duration < test[8].min_duration*SUPER_TONE_BINS) { - return 0; + return 0; } } j = (rotation + steps - 1)%steps; if (pattern[j].f1 != test[9].f1 || pattern[j].f2 != test[9].f2) - return 0; - if (pattern[j].max_duration < test[9].min_duration*BINS) - return 0; + return 0; + if (pattern[j].max_duration < test[9].min_duration*SUPER_TONE_BINS) + return 0; } else { @@ -182,16 +182,16 @@ static int test_cadence(super_tone_rx_segment_t *pattern, { j = i + 10 - steps; if (pattern[i].f1 != test[j].f1 || pattern[i].f2 != test[j].f2) - return 0; - if (pattern[i].min_duration > test[j].min_duration*BINS + return 0; + if (pattern[i].min_duration > test[j].min_duration*SUPER_TONE_BINS || - pattern[i].max_duration < test[j].min_duration*BINS) + pattern[i].max_duration < test[j].min_duration*SUPER_TONE_BINS) { - return 0; + return 0; } } } - return 1; + return 1; } /*- End of function --------------------------------------------------------*/ @@ -288,7 +288,7 @@ SPAN_DECLARE(super_tone_rx_state_t *) super_tone_rx_init(super_tone_rx_state_t * #endif for (i = 0; i < desc->monitored_frequencies; i++) goertzel_init(&s->state[i], &s->desc->desc[i]); - return s; + return s; } /*- End of function --------------------------------------------------------*/ @@ -313,9 +313,9 @@ static void super_tone_chunk(super_tone_rx_state_t *s) int k1; int k2; #if defined(SPANDSP_USE_FIXED_POINT) - int32_t res[BINS/2]; + int32_t res[SUPER_TONE_BINS/2]; #else - float res[BINS/2]; + float res[SUPER_TONE_BINS/2]; #endif for (i = 0; i < s->desc->monitored_frequencies; i++) @@ -397,7 +397,7 @@ static void super_tone_chunk(super_tone_rx_state_t *s) s->segment_callback(s->callback_data, s->segments[9].f1, s->segments[9].f2, - s->segments[9].min_duration*BINS/8); + s->segments[9].min_duration*SUPER_TONE_BINS/8); } memcpy (&s->segments[0], &s->segments[1], 9*sizeof(s->segments[0])); s->segments[9].f1 = k1; @@ -467,7 +467,7 @@ SPAN_DECLARE(int) super_tone_rx(super_tone_rx_state_t *s, const int16_t amp[], i s->energy += xamp*xamp; #endif } - if (s->state[0].current_sample >= BINS) + if (s->state[0].current_sample >= SUPER_TONE_BINS) { /* We have finished a Goertzel block. */ super_tone_chunk(s); diff --git a/libs/spandsp/src/super_tone_tx.c b/libs/spandsp/src/super_tone_tx.c index 7725858f5d..b43f20628e 100644 --- a/libs/spandsp/src/super_tone_tx.c +++ b/libs/spandsp/src/super_tone_tx.c @@ -170,7 +170,7 @@ SPAN_DECLARE(int) super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max super_tone_tx_step_t *tree; if (s->level < 0 || s->level > 3) - return 0; + return 0; samples = 0; tree = s->levels[s->level]; while (tree && samples < max_samples) @@ -280,7 +280,7 @@ SPAN_DECLARE(int) super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max } } - return samples; + return samples; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index 68a5c901c3..e22f60b01f 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -61,15 +61,10 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -83,20 +78,15 @@ #include "spandsp/private/logging.h" #include "spandsp/private/timezone.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" #include "spandsp/private/t30.h" @@ -398,8 +388,9 @@ static const struct static void queue_phase(t30_state_t *s, int phase); static void set_phase(t30_state_t *s, int phase); static void set_state(t30_state_t *s, int state); -static void send_simple_frame(t30_state_t *s, int type); +static void shut_down_hdlc_tx(t30_state_t *s); static void send_frame(t30_state_t *s, const uint8_t *fr, int frlen); +static void send_simple_frame(t30_state_t *s, int type); static void send_dcn(t30_state_t *s); static void repeat_last_command(t30_state_t *s); static void disconnect(t30_state_t *s); @@ -738,7 +729,7 @@ static int get_partial_ecm_page(t30_state_t *s) /* These frames contain a frame sequence number within the partial page (one octet) followed by some image data. */ s->ecm_data[i][3] = (uint8_t) i; - if ((len = t4_tx_get_chunk(&s->t4.tx, &s->ecm_data[i][4], s->octets_per_ecm_frame)) < s->octets_per_ecm_frame) + if ((len = t4_tx_get(&s->t4.tx, &s->ecm_data[i][4], s->octets_per_ecm_frame)) < s->octets_per_ecm_frame) { /* The image is not big enough to fill the entire buffer */ /* We need to pad to a full frame, as most receivers expect that. */ @@ -757,7 +748,7 @@ static int get_partial_ecm_page(t30_state_t *s) /* We filled the entire buffer */ s->ecm_frames = 256; span_log(&s->logging, SPAN_LOG_FLOW, "Partial page buffer full (%d per frame)\n", s->octets_per_ecm_frame); - s->ecm_at_page_end = ((t4_tx_check_bit(&s->t4.tx) & 2) != 0); + s->ecm_at_page_end = (t4_tx_image_complete(&s->t4.tx) == SIG_STATUS_END_OF_DATA); return 256; } /*- End of function --------------------------------------------------------*/ @@ -834,6 +825,13 @@ static void print_frame(t30_state_t *s, const char *io, const uint8_t *msg, int } /*- End of function --------------------------------------------------------*/ +static void shut_down_hdlc_tx(t30_state_t *s) +{ + if (s->send_hdlc_handler) + s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); +} +/*- End of function --------------------------------------------------------*/ + static void send_frame(t30_state_t *s, const uint8_t *msg, int len) { print_frame(s, "Tx: ", msg, len); @@ -1179,9 +1177,11 @@ int t30_build_dis_or_dtc(t30_state_t *s) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_SYCC_T81_CAPABLE); if ((s->supported_compressions & T30_SUPPORT_T85_COMPRESSION)) { - set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE); + /* Bit 79 set with bit 78 clear is invalid, so only check for L0 + support here. */ if ((s->supported_compressions & T30_SUPPORT_T85_L0_COMPRESSION)) set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE); + set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE); } //if ((s->supported_compressions & T30_SUPPORT_T89_COMPRESSION)) // set_ctrl_bit(s->local_dis_dtc_frame, T30_DIS_BIT_T89_CAPABLE); @@ -1332,30 +1332,24 @@ static int build_dcs(t30_state_t *s) /* Select the compression to use. */ switch (s->line_encoding) { -#if defined(SPANDSP_SUPPORT_T42) case T4_COMPRESSION_ITU_T42: set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_FULL_COLOUR_MODE); set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21); break; -#endif #if defined(SPANDSP_SUPPORT_T43) case T4_COMPRESSION_ITU_T43: set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T43_MODE); set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21); break; #endif -#if defined(SPANDSP_SUPPORT_T85) - case T4_COMPRESSION_ITU_T85: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE); - clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE); - set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21); - break; case T4_COMPRESSION_ITU_T85_L0: - set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE); set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE); set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21); break; -#endif + case T4_COMPRESSION_ITU_T85: + set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE); + set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21); + break; case T4_COMPRESSION_ITU_T6: set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T6_MODE); set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21); @@ -1750,9 +1744,7 @@ static int send_dis_or_dtc_sequence(t30_state_t *s, int start) break; case 3: s->step++; - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); break; default: return -1; @@ -1805,9 +1797,7 @@ static int send_dis_or_dtc_sequence(t30_state_t *s, int start) break; case 8: s->step++; - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); break; default: return -1; @@ -1866,9 +1856,7 @@ static int send_dcs_sequence(t30_state_t *s, int start) break; case 7: s->step++; - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); break; default: return -1; @@ -1980,8 +1968,6 @@ static int start_sending_document(t30_state_t *s) if (s->use_own_tz) t4_tx_set_header_tz(&s->t4.tx, &s->tz); - s->x_resolution = t4_tx_get_x_resolution(&s->t4.tx); - s->y_resolution = t4_tx_get_y_resolution(&s->t4.tx); /* The minimum scan time to be used can't be evaluated until we know the Y resolution, and must be evaluated before the minimum scan row bits can be evaluated. */ if ((min_row_bits = set_min_scan_time_code(s)) < 0) @@ -1994,6 +1980,8 @@ static int start_sending_document(t30_state_t *s) if (tx_start_page(s)) return -1; + s->x_resolution = t4_tx_get_x_resolution(&s->t4.tx); + s->y_resolution = t4_tx_get_y_resolution(&s->t4.tx); s->image_width = t4_tx_get_image_width(&s->t4.tx); if (s->error_correcting_mode) { @@ -2078,42 +2066,62 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len) s->error_correcting_mode = (s->ecm_allowed && (s->far_dis_dtc_frame[6] & DISBIT3) != 0); /* 256 octets per ECM frame */ s->octets_per_ecm_frame = 256; - /* Select the compression to use. */ - if (s->error_correcting_mode - && - (s->supported_compressions & T30_SUPPORT_T85_COMPRESSION) - && - test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE)) + /* Now we know if we are going to use ECM, select the compression to use. */ + if (!s->error_correcting_mode) { - if (s->supported_compressions & T30_SUPPORT_T85_L0_COMPRESSION + /* Without error correction our choices are very limited */ + if ((s->supported_compressions & T30_SUPPORT_T4_2D_COMPRESSION) && - test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE)) + test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T4_2D; + } + else + { + s->line_encoding = T4_COMPRESSION_ITU_T4_1D; + } + } + else + { +#if defined(SPANDSP_SUPPORT_T42x) || defined(SPANDSP_SUPPORT_T43) + /* With error correction colour may be possible/required */ + if ((0 & (T30_SUPPORT_T43_COMPRESSION | T30_SUPPORT_T45_COMPRESSION | T30_SUPPORT_T81_COMPRESSION | T30_SUPPORT_SYCC_T81_COMPRESSION))) { s->line_encoding = T4_COMPRESSION_ITU_T85_L0; } else +#endif { - s->line_encoding = T4_COMPRESSION_ITU_T85; + if ((s->supported_compressions & T30_SUPPORT_T85_L0_COMPRESSION) + && + test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T85_L0; + } + else if ((s->supported_compressions & T30_SUPPORT_T85_COMPRESSION) + && + test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T85; + } + else if ((s->supported_compressions & T30_SUPPORT_T6_COMPRESSION) + && + test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T6; + } + else if ((s->supported_compressions & T30_SUPPORT_T4_2D_COMPRESSION) + && + test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T4_2D; + } + else + { + s->line_encoding = T4_COMPRESSION_ITU_T4_1D; + } } } - else if (s->error_correcting_mode - && - (s->supported_compressions & T30_SUPPORT_T6_COMPRESSION) - && - test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE)) - { - s->line_encoding = T4_COMPRESSION_ITU_T6; - } - else if ((s->supported_compressions & T30_SUPPORT_T4_2D_COMPRESSION) - && - test_ctrl_bit(s->far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE)) - { - s->line_encoding = T4_COMPRESSION_ITU_T4_2D; - } - else - { - s->line_encoding = T4_COMPRESSION_ITU_T4_1D; - } span_log(&s->logging, SPAN_LOG_FLOW, "Selected compression %s (%d)\n", t4_encoding_to_str(s->line_encoding), s->line_encoding); switch (s->far_dis_dtc_frame[4] & (DISBIT6 | DISBIT5 | DISBIT4 | DISBIT3)) { @@ -2367,13 +2375,28 @@ static int process_rx_dcs(t30_state_t *s, const uint8_t *msg, int len) s->image_width = widths[i][dcs_frame[5] & (DISBIT2 | DISBIT1)]; - /* Check which compression we will use. */ - if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_MODE)) + /* Check which compression the far end has decided to use. */ +#if defined(SPANDSP_SUPPORT_T42) + if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_FULL_COLOUR_MODE)) { - if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_L0_MODE)) - s->line_encoding = T4_COMPRESSION_ITU_T85_L0; - else - s->line_encoding = T4_COMPRESSION_ITU_T85; + s->line_encoding = T4_COMPRESSION_ITU_T42; + } + else +#endif +#if defined(SPANDSP_SUPPORT_T43) + if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T43_MODE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T43; + } + else +#endif + if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_L0_MODE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T85_L0; + } + else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_MODE)) + { + s->line_encoding = T4_COMPRESSION_ITU_T85; } else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE)) { @@ -2534,7 +2557,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) we sent - which would have been a T30_MCF - If the block is for the previous page, or the previous block of the current page, we can assume we have hit this condition. */ - if (((s->rx_page_number & 0xFF) == page && (s->ecm_block & 0xFF) == block) + if (((s->rx_page_number & 0xFF) == page && ((s->ecm_block - 1) & 0xFF) == block) || (((s->rx_page_number - 1) & 0xFF) == page && s->ecm_block == 0)) { @@ -2568,7 +2591,6 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) for (j = 0; j < 8; j++) { frame_no = (i << 3) + j; -#if defined(VET_ALL_FCD_FRAMES) if (s->ecm_len[frame_no] >= 0) { /* The correct pattern of frame lengths is they will all be 64 or 256 octets long, except the @@ -2598,7 +2620,6 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) } } } -#endif if (s->ecm_len[frame_no] < 0) { s->ecm_frame_map[i + 3] |= (1 << j); @@ -2615,7 +2636,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len) span_log(&s->logging, SPAN_LOG_FLOW, "Partial page OK - committing block %d, %d frames\n", s->ecm_block, s->ecm_frames); for (i = 0; i < s->ecm_frames; i++) { - if (t4_rx_put_chunk(&s->t4.rx, s->ecm_data[i], s->ecm_len[i])) + if (t4_rx_put(&s->t4.rx, s->ecm_data[i], s->ecm_len[i])) { /* This is the end of the document */ break; @@ -2685,10 +2706,14 @@ static void process_rx_ppr(t30_state_t *s, const uint8_t *msg, int len) int frame_no; uint8_t frame[4]; - if (len != 3 + 32) + if (len != 3 + 256/8) { - span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for PPR bits - %d\n", len); - /* TODO: probably should send DCN */ + span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for PPR bits - %d\n", (len - 3)*8); + /* This frame didn't get corrupted in transit, because its CRC is OK. It was sent bad + and there is little possibility that causing a retransmission will help. It is best + to just give up. */ + t30_set_status(s, T30_ERR_TX_ECMPHD); + disconnect(s); return; } /* Check which frames are OK, and mark them as OK. */ @@ -5448,7 +5473,7 @@ SPAN_DECLARE_NONSTD(void) t30_non_ecm_put_bit(void *user_data, int bit) break; case T30_STATE_F_DOC_NON_ECM: /* Document transfer */ - if (t4_rx_put_bit(&s->t4.rx, bit)) + if (t4_rx_put_bit(&s->t4.rx, bit) == T4_DECODE_OK) { /* That is the end of the document */ set_state(s, T30_STATE_F_POST_DOC_NON_ECM); @@ -5460,48 +5485,7 @@ SPAN_DECLARE_NONSTD(void) t30_non_ecm_put_bit(void *user_data, int bit) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_non_ecm_put_byte(void *user_data, int byte) -{ - t30_state_t *s; - - if (byte < 0) - { - t30_non_ecm_rx_status(user_data, byte); - return; - } - s = (t30_state_t *) user_data; - switch (s->state) - { - case T30_STATE_F_TCF: - /* Trainability test */ - /* This makes counting zeros fast, but approximate. That really doesn't matter */ - s->tcf_test_bits += 8; - if (byte) - { - if (s->tcf_current_zeros > s->tcf_most_zeros) - s->tcf_most_zeros = s->tcf_current_zeros; - s->tcf_current_zeros = 0; - } - else - { - s->tcf_current_zeros += 8; - } - break; - case T30_STATE_F_DOC_NON_ECM: - /* Document transfer */ - if (t4_rx_put_byte(&s->t4.rx, (uint8_t) byte)) - { - /* That is the end of the document */ - set_state(s, T30_STATE_F_POST_DOC_NON_ECM); - queue_phase(s, T30_PHASE_D_RX); - timer_t2_start(s); - } - break; - } -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t30_non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len) +SPAN_DECLARE(void) t30_non_ecm_put(void *user_data, const uint8_t buf[], int len) { t30_state_t *s; int i; @@ -5529,7 +5513,7 @@ SPAN_DECLARE(void) t30_non_ecm_put_chunk(void *user_data, const uint8_t buf[], i break; case T30_STATE_F_DOC_NON_ECM: /* Document transfer */ - if (t4_rx_put_chunk(&s->t4.rx, buf, len)) + if (t4_rx_put(&s->t4.rx, buf, len)) { /* That is the end of the document */ set_state(s, T30_STATE_F_POST_DOC_NON_ECM); @@ -5576,42 +5560,7 @@ SPAN_DECLARE_NONSTD(int) t30_non_ecm_get_bit(void *user_data) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t30_non_ecm_get_byte(void *user_data) -{ - int byte; - t30_state_t *s; - - s = (t30_state_t *) user_data; - switch (s->state) - { - case T30_STATE_D_TCF: - /* Trainability test. */ - byte = 0; - if ((s->tcf_test_bits -= 8) < 0) - { - /* Finished sending training test. */ - byte = 0x100; - } - break; - case T30_STATE_I: - /* Transferring real data. */ - byte = t4_tx_get_byte(&s->t4.tx); - break; - case T30_STATE_D_POST_TCF: - case T30_STATE_II_Q: - /* We should be padding out a block of samples if we are here */ - byte = 0; - break; - default: - span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get_byte in bad state %d\n", s->state); - byte = 0x100; - break; - } - return byte; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_len) +SPAN_DECLARE(int) t30_non_ecm_get(void *user_data, uint8_t buf[], int max_len) { int len; t30_state_t *s; @@ -5630,7 +5579,7 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_ break; case T30_STATE_I: /* Transferring real data. */ - len = t4_tx_get_chunk(&s->t4.tx, buf, max_len); + len = t4_tx_get(&s->t4.tx, buf, max_len); break; case T30_STATE_D_POST_TCF: case T30_STATE_II_Q: @@ -5638,8 +5587,8 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_ len = 0; break; default: - span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get_chunk in bad state %d\n", s->state); - len = 0; + span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get in bad state %d\n", s->state); + len = -1; break; } return len; @@ -5868,9 +5817,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) case T30_STATE_F_CFR: if (s->step == 0) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } else @@ -5892,9 +5839,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) case T30_STATE_F_FTT: if (s->step == 0) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } else @@ -5910,9 +5855,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) case T30_STATE_F_POST_RCP_MCF: if (s->step == 0) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } else @@ -5964,9 +5907,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) case T30_STATE_IV_CTC: if (s->step == 0) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } else @@ -5989,9 +5930,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) case T30_STATE_C: if (s->step == 0) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } else @@ -6049,9 +5988,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) { if (send_next_ecm_frame(s)) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } } @@ -6070,9 +6007,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status) /* This should be the end of a CTR being sent. */ if (s->step == 0) { - /* Shut down HDLC transmission. */ - if (s->send_hdlc_handler) - s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0); + shut_down_hdlc_tx(s); s->step++; } else @@ -6347,11 +6282,11 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s) SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s, int calling_party, - t30_set_handler_t *set_rx_type_handler, + t30_set_handler_t set_rx_type_handler, void *set_rx_type_user_data, - t30_set_handler_t *set_tx_type_handler, + t30_set_handler_t set_tx_type_handler, void *set_tx_type_user_data, - t30_send_hdlc_handler_t *send_hdlc_handler, + t30_send_hdlc_handler_t send_hdlc_handler, void *send_hdlc_user_data) { if (s == NULL) diff --git a/libs/spandsp/src/t30_api.c b/libs/spandsp/src/t30_api.c index 8ba35e5732..495ba6f9b1 100644 --- a/libs/spandsp/src/t30_api.c +++ b/libs/spandsp/src/t30_api.c @@ -61,15 +61,10 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -83,20 +78,15 @@ #include "spandsp/private/logging.h" #include "spandsp/private/timezone.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" #include "spandsp/private/t30.h" @@ -707,16 +697,12 @@ SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_c mask = T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION -#if defined(SPANDSP_SUPPORT_T42) - | T30_SUPPORT_T42_COMPRESSION -#endif + //| T30_SUPPORT_T81_COMPRESSION #if defined(SPANDSP_SUPPORT_T43) | T30_SUPPORT_T43_COMPRESSION #endif -#if defined(SPANDSP_SUPPORT_T85) | T30_SUPPORT_T85_COMPRESSION | T30_SUPPORT_T85_L0_COMPRESSION -#endif | 0; s->supported_compressions = supported_compressions & mask; t30_build_dis_or_dtc(s); @@ -765,35 +751,35 @@ SPAN_DECLARE(int) t30_set_receiver_not_ready(t30_state_t *s, int count) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_set_phase_b_handler(t30_state_t *s, t30_phase_b_handler_t *handler, void *user_data) +SPAN_DECLARE(void) t30_set_phase_b_handler(t30_state_t *s, t30_phase_b_handler_t handler, void *user_data) { s->phase_b_handler = handler; s->phase_b_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_set_phase_d_handler(t30_state_t *s, t30_phase_d_handler_t *handler, void *user_data) +SPAN_DECLARE(void) t30_set_phase_d_handler(t30_state_t *s, t30_phase_d_handler_t handler, void *user_data) { s->phase_d_handler = handler; s->phase_d_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_set_phase_e_handler(t30_state_t *s, t30_phase_e_handler_t *handler, void *user_data) +SPAN_DECLARE(void) t30_set_phase_e_handler(t30_state_t *s, t30_phase_e_handler_t handler, void *user_data) { s->phase_e_handler = handler; s->phase_e_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_set_document_handler(t30_state_t *s, t30_document_handler_t *handler, void *user_data) +SPAN_DECLARE(void) t30_set_document_handler(t30_state_t *s, t30_document_handler_t handler, void *user_data) { s->document_handler = handler; s->document_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t30_set_real_time_frame_handler(t30_state_t *s, t30_real_time_frame_handler_t *handler, void *user_data) +SPAN_DECLARE(void) t30_set_real_time_frame_handler(t30_state_t *s, t30_real_time_frame_handler_t handler, void *user_data) { s->real_time_frame_handler = handler; s->real_time_frame_user_data = user_data; diff --git a/libs/spandsp/src/t30_logging.c b/libs/spandsp/src/t30_logging.c index 52ab767dfc..8347a2615d 100644 --- a/libs/spandsp/src/t30_logging.c +++ b/libs/spandsp/src/t30_logging.c @@ -61,15 +61,10 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -82,20 +77,15 @@ #include "spandsp/private/logging.h" #include "spandsp/private/timezone.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" #include "spandsp/private/t30.h" @@ -416,6 +406,8 @@ SPAN_DECLARE(const char *) t30_frametype(uint8_t x) return "NULL"; case T4_FCD: return "FCD"; + case T4_CCD: + return "CCD"; case T4_RCP: return "RCP"; } diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index bc18a72e59..8e747c4d0f 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -186,20 +186,11 @@ enum static int restart_modem(t31_state_t *s, int new_modem); static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int ok); -static void set_rx_handler(t31_state_t *s, span_rx_handler_t *rx_handler, span_rx_fillin_handler_t *fillin_handler, void *user_data); -static void set_tx_handler(t31_state_t *s, span_tx_handler_t *handler, void *user_data); -static void set_next_tx_handler(t31_state_t *s, span_tx_handler_t *handler, void *user_data); -static int v17_v21_rx(void *user_data, const int16_t amp[], int len); -static int v17_v21_rx_fillin(void *user_data, int len); -static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len); -static int v27ter_v21_rx_fillin(void *user_data, int len); -static int v29_v21_rx(void *user_data, const int16_t amp[], int len); -static int v29_v21_rx_fillin(void *user_data, int len); static int silence_rx(void *user_data, const int16_t amp[], int len); static int cng_rx(void *user_data, const int16_t amp[], int len); static void non_ecm_put_bit(void *user_data, int bit); -static void non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len); -static int non_ecm_get_chunk(void *user_data, uint8_t buf[], int len); +static void non_ecm_put(void *user_data, const uint8_t buf[], int len); +static int non_ecm_get(void *user_data, uint8_t buf[], int len); static void non_ecm_rx_status(void *user_data, int status); static void hdlc_rx_status(void *user_data, int status); @@ -600,7 +591,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (len > 0) { bit_reverse(buf2, buf, len); - non_ecm_put_chunk(s, buf, len); + non_ecm_put(s, buf, len); } fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT); break; @@ -618,7 +609,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, s->at_state.rx_signal_present = TRUE; } bit_reverse(buf2, buf, len); - non_ecm_put_chunk(s, buf, len); + non_ecm_put(s, buf, len); } /* WORKAROUND: At least some Mediatrix boxes have a bug, where they can send HDLC signal end where they should send non-ECM signal end. It is possible they also do the opposite. @@ -724,13 +715,21 @@ static int stream_non_ecm(t31_state_t *s) case T38_TIMED_STEP_NON_ECM_MODEM: /* Create a 75ms silence */ if (fe->t38.current_tx_indicator != T38_IND_NO_SIGNAL) - delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); + { + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0) + { + /* ???????? */ + } + } fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_2; fe->next_tx_samples = fe->samples; break; case T38_TIMED_STEP_NON_ECM_MODEM_2: /* Switch on a fast modem, and give the training time to complete */ - delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator); + if ((delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator)) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_3; break; case T38_TIMED_STEP_NON_ECM_MODEM_3: @@ -739,7 +738,7 @@ static int stream_non_ecm(t31_state_t *s) However, I think the early versions of T.38 said the signal end message should not contain data. Hopefully, following the current spec will not cause compatibility issues. */ - len = non_ecm_get_chunk(s, buf, fe->octets_per_data_packet); + len = non_ecm_get(s, buf, fe->octets_per_data_packet); if (len > 0) bit_reverse(buf, buf, len); if (len < fe->octets_per_data_packet) @@ -762,12 +761,18 @@ static int stream_non_ecm(t31_state_t *s) else { /* If we are sending quickly there seems no point in doing any padding */ - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5; delay = 0; } } - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA) < 0) + { + /* ???????? */ + } delay = bits_to_us(s, 8*len); break; case T38_TIMED_STEP_NON_ECM_MODEM_4: @@ -778,7 +783,10 @@ static int stream_non_ecm(t31_state_t *s) { len += fe->non_ecm_trailer_bytes; memset(buf, 0, len); - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5; /* Allow a bit more time than the data will take to play out, to ensure the far ATA does not cut things short. */ @@ -789,13 +797,19 @@ static int stream_non_ecm(t31_state_t *s) break; } memset(buf, 0, len); - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA) < 0) + { + /* ???????? */ + } delay = bits_to_us(s, 8*len); break; case T38_TIMED_STEP_NON_ECM_MODEM_5: /* This should not be needed, since the message above indicates the end of the signal, but it seems like it can improve compatibility with quirky implementations. */ - delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_NONE; return delay; } @@ -822,13 +836,21 @@ static int stream_hdlc(t31_state_t *s) case T38_TIMED_STEP_HDLC_MODEM: /* Create a 75ms silence */ if (fe->t38.current_tx_indicator != T38_IND_NO_SIGNAL) - delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); + { + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0) + { + /* ???????? */ + } + } fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_2; fe->next_tx_samples = fe->samples + ms_to_samples(75); break; case T38_TIMED_STEP_HDLC_MODEM_2: /* Send HDLC preambling */ - delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator); + if ((delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator)) < 0) + { + /* ???????? */ + } delay += t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3; @@ -864,7 +886,10 @@ static int stream_hdlc(t31_state_t *s) data_fields[1].field = NULL; data_fields[1].field_len = 0; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END; - t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category); + if (t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_5; /* We add a bit of extra time here, as with some implementations the carrier falling too abruptly causes data loss. */ @@ -880,7 +905,10 @@ static int stream_hdlc(t31_state_t *s) data_fields[1].field = NULL; data_fields[1].field_len = 0; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; - t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category); + if (t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3; delay = bits_to_us(s, i*8 + fe->hdlc_tx.extra_bits); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); @@ -888,14 +916,20 @@ static int stream_hdlc(t31_state_t *s) break; } category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_4; } else { i = fe->octets_per_data_packet; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category) < 0) + { + /* ???????? */ + } s->hdlc_tx.ptr += i; } delay = bits_to_us(s, i*8); @@ -911,7 +945,10 @@ static int stream_hdlc(t31_state_t *s) s->hdlc_tx.len = 0; s->hdlc_tx.final = FALSE; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; - t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category); + if (t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_5; /* We add a bit of extra time here, as with some implementations the carrier falling too abruptly causes data loss. */ @@ -923,7 +960,10 @@ static int stream_hdlc(t31_state_t *s) } /* Finish the current frame off, and prepare for the next one. */ category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; - t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category); + if (t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3; at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); /* We should now wait enough time for everything to clear through an analogue modem at the far end. */ @@ -935,8 +975,14 @@ static int stream_hdlc(t31_state_t *s) /* Note that some boxes do not like us sending a T38_FIELD_HDLC_SIG_END at this point. A T38_IND_NO_SIGNAL should always be OK. */ category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END; - t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_SIG_END, NULL, 0, category); - delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); + if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_SIG_END, NULL, 0, category) < 0) + { + /* ???????? */ + } + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0) + { + /* ???????? */ + } fe->timed_step = T38_TIMED_STEP_NONE; at_put_response_code(&s->at_state, AT_RESPONSE_CODE_OK); t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); @@ -963,14 +1009,20 @@ static int stream_ced(t31_state_t *s) of silence, starting the delay with a no signal indication makes sense. We do need a 200ms delay, as that is a specification requirement. */ fe->timed_step = T38_TIMED_STEP_CED_2; - delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0) + { + /* ???????? */ + } delay = 200000; fe->next_tx_samples = fe->samples; break; case T38_TIMED_STEP_CED_2: /* Initial 200ms delay over. Send the CED indicator */ fe->timed_step = T38_TIMED_STEP_CED_3; - delay = t38_core_send_indicator(&fe->t38, T38_IND_CED); + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_CED)) < 0) + { + /* ???????? */ + } fe->current_tx_data_type = T38_DATA_NONE; break; case T38_TIMED_STEP_CED_3: @@ -1000,7 +1052,10 @@ static int stream_cng(t31_state_t *s) be sending 200ms of silence, according to T.30, starting that delay with a no signal indication makes sense. */ fe->timed_step = T38_TIMED_STEP_CNG_2; - delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0) + { + /* ???????? */ + } delay = 200000; fe->next_tx_samples = fe->samples; break; @@ -1009,7 +1064,10 @@ static int stream_cng(t31_state_t *s) coming the other way interrupts it, or a long timeout controlled by the T.30 engine expires. */ fe->timed_step = T38_TIMED_STEP_NONE; - delay = t38_core_send_indicator(&fe->t38, T38_IND_CNG); + if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_CNG)) < 0) + { + /* ???????? */ + } fe->current_tx_data_type = T38_DATA_NONE; return delay; } @@ -1127,12 +1185,14 @@ static void non_ecm_rx_status(void *user_data, int status) break; case SIG_STATUS_TRAINING_FAILED: s->at_state.rx_trained = FALSE; + s->audio.modems.rx_trained = FALSE; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); s->at_state.rx_signal_present = TRUE; s->at_state.rx_trained = TRUE; + s->audio.modems.rx_trained = TRUE; break; case SIG_STATUS_CARRIER_UP: break; @@ -1151,6 +1211,7 @@ static void non_ecm_rx_status(void *user_data, int status) } s->at_state.rx_signal_present = FALSE; s->at_state.rx_trained = FALSE; + s->audio.modems.rx_trained = FALSE; break; default: if (s->at_state.p.result_code_format) @@ -1190,7 +1251,7 @@ static void non_ecm_put_bit(void *user_data, int bit) } /*- End of function --------------------------------------------------------*/ -static void non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len) +static void non_ecm_put(void *user_data, const uint8_t buf[], int len) { t31_state_t *s; int i; @@ -1268,7 +1329,7 @@ static int non_ecm_get_bit(void *user_data) } /*- End of function --------------------------------------------------------*/ -static int non_ecm_get_chunk(void *user_data, uint8_t buf[], int len) +static int non_ecm_get(void *user_data, uint8_t buf[], int len) { t31_state_t *s; int i; @@ -1366,17 +1427,20 @@ static void hdlc_rx_status(void *user_data, int status) break; case SIG_STATUS_TRAINING_FAILED: s->at_state.rx_trained = FALSE; + s->audio.modems.rx_trained = FALSE; break; case SIG_STATUS_TRAINING_SUCCEEDED: /* The modem is now trained */ s->at_state.rx_signal_present = TRUE; s->at_state.rx_trained = TRUE; + s->audio.modems.rx_trained = TRUE; break; case SIG_STATUS_CARRIER_UP: if (s->modem == FAX_MODEM_CNG_TONE || s->modem == FAX_MODEM_NOCNG_TONE || s->modem == FAX_MODEM_V21_RX) { s->at_state.rx_signal_present = TRUE; s->rx_frame_received = FALSE; + s->audio.modems.rx_frame_received = FALSE; } break; case SIG_STATUS_CARRIER_DOWN: @@ -1404,6 +1468,7 @@ static void hdlc_rx_status(void *user_data, int status) } s->at_state.rx_signal_present = FALSE; s->at_state.rx_trained = FALSE; + s->audio.modems.rx_trained = FALSE; break; case SIG_STATUS_FRAMING_OK: if (s->modem == FAX_MODEM_CNG_TONE || s->modem == FAX_MODEM_NOCNG_TONE) @@ -1423,6 +1488,7 @@ static void hdlc_rx_status(void *user_data, int status) { s->at_state.rx_signal_present = TRUE; s->rx_frame_received = TRUE; + s->audio.modems.rx_frame_received = TRUE; s->modem = FAX_MODEM_V21_RX; s->at_state.transmit = FALSE; s->at_state.dte_is_waiting = TRUE; @@ -1434,6 +1500,7 @@ static void hdlc_rx_status(void *user_data, int status) s->modem = FAX_MODEM_SILENCE_TX; t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); s->rx_frame_received = FALSE; + s->audio.modems.rx_frame_received = FALSE; at_put_response_code(&s->at_state, AT_RESPONSE_CODE_FCERROR); } } @@ -1446,6 +1513,7 @@ static void hdlc_rx_status(void *user_data, int status) /* Report CONNECT as soon as possible to avoid a timeout. */ at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); s->rx_frame_received = TRUE; + s->audio.modems.rx_frame_received = TRUE; } else { @@ -1484,6 +1552,7 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int /* Report CONNECT as soon as possible to avoid a timeout. */ at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); s->rx_frame_received = TRUE; + s->audio.modems.rx_frame_received = TRUE; } else { @@ -1520,6 +1589,7 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int at_put_response_code(&s->at_state, (ok) ? AT_RESPONSE_CODE_OK : AT_RESPONSE_CODE_ERROR); s->at_state.dte_is_waiting = FALSE; s->rx_frame_received = FALSE; + s->audio.modems.rx_frame_received = FALSE; } } else @@ -1543,8 +1613,7 @@ static void t31_v21_rx(t31_state_t *s) s->hdlc_tx.len = 0; s->dled = FALSE; hdlc_rx_init(&s->audio.modems.hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s); - fsk_rx_init(&s->audio.modems.v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &s->audio.modems.hdlc_rx); - fsk_rx_signal_cutoff(&s->audio.modems.v21_rx, -39.09f); + fax_modems_start_slow_modem(&s->audio.modems, FAX_MODEM_V21_RX); s->at_state.transmit = TRUE; } /*- End of function --------------------------------------------------------*/ @@ -1563,8 +1632,10 @@ static int restart_modem(t31_state_t *s, int new_modem) s->tx.final = FALSE; s->at_state.rx_signal_present = FALSE; s->at_state.rx_trained = FALSE; + s->audio.modems.rx_trained = FALSE; s->rx_frame_received = FALSE; - set_rx_handler(s, (span_rx_handler_t *) &span_dummy_rx, (span_rx_fillin_handler_t *) &span_dummy_rx_fillin, NULL); + s->audio.modems.rx_frame_received = FALSE; + fax_modems_set_rx_handler(t, (span_rx_handler_t) &span_dummy_rx, NULL, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); use_hdlc = FALSE; switch (s->modem) { @@ -1583,10 +1654,10 @@ static int restart_modem(t31_state_t *s, int new_modem) /* Do V.21/HDLC receive in parallel. The other end may send its first message at any time. The CNG tone will continue until we get a valid preamble. */ - set_rx_handler(s, (span_rx_handler_t *) &cng_rx, (span_rx_fillin_handler_t *) &span_dummy_rx_fillin, s); t31_v21_rx(s); - set_tx_handler(s, (span_tx_handler_t *) &modem_connect_tones_tx, &t->connect_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &cng_rx, s, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &modem_connect_tones_tx, &t->connect_tx); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } s->at_state.transmit = TRUE; break; @@ -1596,10 +1667,10 @@ static int restart_modem(t31_state_t *s, int new_modem) } else { - set_rx_handler(s, (span_rx_handler_t *) &cng_rx, (span_rx_fillin_handler_t *) &span_dummy_rx_fillin, s); t31_v21_rx(s); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &cng_rx, s, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); silence_gen_set(&t->silence_gen, 0); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); } s->at_state.transmit = FALSE; break; @@ -1613,8 +1684,8 @@ static int restart_modem(t31_state_t *s, int new_modem) else { modem_connect_tones_tx_init(&t->connect_tx, MODEM_CONNECT_TONES_FAX_CED); - set_tx_handler(s, (span_tx_handler_t *) &modem_connect_tones_tx, &t->connect_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &modem_connect_tones_tx, &t->connect_tx); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } s->at_state.transmit = TRUE; break; @@ -1632,9 +1703,9 @@ static int restart_modem(t31_state_t *s, int new_modem) hdlc_tx_init(&t->hdlc_tx, FALSE, 2, FALSE, hdlc_tx_underflow, s); /* The spec says 1s +-15% of preamble. So, the minimum is 32 octets. */ hdlc_tx_flags(&t->hdlc_tx, 32); - fsk_tx_init(&t->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &t->hdlc_tx); - set_tx_handler(s, (span_tx_handler_t *) &fsk_tx, &t->v21_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &fsk_tx, &t->v21_tx); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } s->hdlc_tx.final = FALSE; s->hdlc_tx.len = 0; @@ -1647,8 +1718,8 @@ static int restart_modem(t31_state_t *s, int new_modem) } else { - set_rx_handler(s, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &t->v21_rx); t31_v21_rx(s); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &t->v21_rx); } break; case FAX_MODEM_V17_TX: @@ -1678,19 +1749,18 @@ static int restart_modem(t31_state_t *s, int new_modem) } else { - v17_tx_restart(&t->fast_modems.v17_tx, s->bit_rate, FALSE, s->short_train); - set_tx_handler(s, (span_tx_handler_t *) &v17_tx, &t->fast_modems.v17_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); } s->tx.out_bytes = 0; s->tx.data_started = FALSE; s->at_state.transmit = TRUE; break; case FAX_MODEM_V17_RX: + case FAX_MODEM_V27TER_RX: + case FAX_MODEM_V29_RX: if (!s->t38_mode) { - set_rx_handler(s, (span_rx_handler_t *) &v17_v21_rx, (span_rx_fillin_handler_t *) &v17_v21_rx_fillin, s); - v17_rx_restart(&t->fast_modems.v17_rx, s->bit_rate, s->short_train); + fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); /* Allow for +FCERROR/+FRH:3 */ t31_v21_rx(s); } @@ -1715,24 +1785,12 @@ static int restart_modem(t31_state_t *s, int new_modem) } else { - v27ter_tx_restart(&t->fast_modems.v27ter_tx, s->bit_rate, FALSE); - set_tx_handler(s, (span_tx_handler_t *) &v27ter_tx, &t->fast_modems.v27ter_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); } s->tx.out_bytes = 0; s->tx.data_started = FALSE; s->at_state.transmit = TRUE; break; - case FAX_MODEM_V27TER_RX: - if (!s->t38_mode) - { - set_rx_handler(s, (span_rx_handler_t *) &v27ter_v21_rx, (span_rx_fillin_handler_t *) &v27ter_v21_rx_fillin, s); - v27ter_rx_restart(&t->fast_modems.v27ter_rx, s->bit_rate, FALSE); - /* Allow for +FCERROR/+FRH:3 */ - t31_v21_rx(s); - } - s->at_state.transmit = FALSE; - break; case FAX_MODEM_V29_TX: if (s->t38_mode) { @@ -1752,28 +1810,19 @@ static int restart_modem(t31_state_t *s, int new_modem) } else { - v29_tx_restart(&t->fast_modems.v29_tx, s->bit_rate, FALSE); - set_tx_handler(s, (span_tx_handler_t *) &v29_tx, &t->fast_modems.v29_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc); } s->tx.out_bytes = 0; s->tx.data_started = FALSE; s->at_state.transmit = TRUE; break; - case FAX_MODEM_V29_RX: - if (!s->t38_mode) - { - set_rx_handler(s, (span_rx_handler_t *) &v29_v21_rx, (span_rx_fillin_handler_t *) &v29_v21_rx_fillin, s); - v29_rx_restart(&t->fast_modems.v29_rx, s->bit_rate, FALSE); - /* Allow for +FCERROR/+FRH:3 */ - t31_v21_rx(s); - } - s->at_state.transmit = FALSE; - break; case FAX_MODEM_SILENCE_TX: if (s->t38_mode) { - t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL); + if (t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL) < 0) + { + /* ???????? */ + } s->t38_fe.next_tx_samples = s->t38_fe.samples + ms_to_samples(700); s->t38_fe.timed_step = T38_TIMED_STEP_PAUSE; s->t38_fe.current_tx_data_type = T38_DATA_NONE; @@ -1781,18 +1830,18 @@ static int restart_modem(t31_state_t *s, int new_modem) else { silence_gen_set(&t->silence_gen, 0); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } s->at_state.transmit = FALSE; break; case FAX_MODEM_SILENCE_RX: if (!s->t38_mode) { - set_rx_handler(s, (span_rx_handler_t *) &silence_rx, (span_rx_fillin_handler_t *) &span_dummy_rx_fillin, s); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &silence_rx, s, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); silence_gen_set(&t->silence_gen, 0); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); } s->at_state.transmit = FALSE; break; @@ -1800,14 +1849,17 @@ static int restart_modem(t31_state_t *s, int new_modem) /* Send 200ms of silence to "push" the last audio out */ if (s->t38_mode) { - t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL); + if (t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL) < 0) + { + /* ???????? */ + } } else { s->modem = FAX_MODEM_SILENCE_TX; silence_gen_alter(&t->silence_gen, ms_to_samples(200)); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); s->at_state.transmit = TRUE; } break; @@ -1980,6 +2032,7 @@ static int process_class1_cmd(at_state_t *t, void *user_data, int direction, int /* Send straight away, if there is something queued. */ t31_set_at_rx_mode(s, AT_MODE_DELIVERY); s->rx_frame_received = FALSE; + s->audio.modems.rx_frame_received = FALSE; do { if (!queue_empty(s->rx_queue)) @@ -2127,6 +2180,12 @@ SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event) } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s) +{ + return T31_TX_BUF_LEN - (s->tx.in_bytes - s->tx.out_bytes) - 1; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) { if (s->dte_data_timeout) @@ -2150,7 +2209,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) s->at_state.rx_data_bytes = 0; s->at_state.transmit = FALSE; s->modem = FAX_MODEM_SILENCE_TX; - set_rx_handler(s, (span_rx_handler_t *) &span_dummy_rx, (span_rx_fillin_handler_t *) &span_dummy_rx_fillin, NULL); + fax_modems_set_rx_handler(&s->audio.modems, (span_rx_handler_t) &span_dummy_rx, NULL, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_OK); } @@ -2162,7 +2221,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) if (s->tx.out_bytes) { /* Make room for new data in existing data buffer. */ - s->tx.in_bytes = &s->tx.data[s->tx.in_bytes] - &s->tx.data[s->tx.out_bytes]; + s->tx.in_bytes -= s->tx.out_bytes; memmove(&s->tx.data[0], &s->tx.data[s->tx.out_bytes], s->tx.in_bytes); s->tx.out_bytes = 0; } @@ -2176,31 +2235,6 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) } /*- End of function --------------------------------------------------------*/ -static void set_rx_handler(t31_state_t *s, - span_rx_handler_t *rx_handler, - span_rx_fillin_handler_t *fillin_handler, - void *user_data) -{ - s->audio.modems.rx_handler = rx_handler; - s->audio.modems.rx_fillin_handler = fillin_handler; - s->audio.modems.rx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void set_tx_handler(t31_state_t *s, span_tx_handler_t *handler, void *user_data) -{ - s->audio.modems.tx_handler = handler; - s->audio.modems.tx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void set_next_tx_handler(t31_state_t *s, span_tx_handler_t *handler, void *user_data) -{ - s->audio.modems.next_tx_handler = handler; - s->audio.modems.next_tx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - static int silence_rx(void *user_data, const int16_t amp[], int len) { t31_state_t *s; @@ -2239,135 +2273,6 @@ static int cng_rx(void *user_data, const int16_t amp[], int len) } /*- End of function --------------------------------------------------------*/ -static int v17_v21_rx(void *user_data, const int16_t amp[], int len) -{ - t31_state_t *t; - fax_modems_state_t *s; - - t = (t31_state_t *) user_data; - s = &t->audio.modems; - v17_rx(&s->fast_modems.v17_rx, amp, len); - if (t->at_state.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow - one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v17_rx, (span_rx_fillin_handler_t *) &v17_rx_fillin, &s->fast_modems.v17_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (t->rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - } - return len; -} -/*- End of function --------------------------------------------------------*/ - -static int v17_v21_rx_fillin(void *user_data, int len) -{ - t31_state_t *t; - fax_modems_state_t *s; - - t = (t31_state_t *) user_data; - s = &t->audio.modems; - v17_rx_fillin(&s->fast_modems.v17_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) -{ - t31_state_t *t; - fax_modems_state_t *s; - - t = (t31_state_t *) user_data; - s = &t->audio.modems; - v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); - if (t->at_state.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow - one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v27ter_rx, (span_rx_fillin_handler_t *) &v27ter_rx_fillin, &s->fast_modems.v27ter_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (t->rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - } - return len; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx_fillin(void *user_data, int len) -{ - t31_state_t *t; - fax_modems_state_t *s; - - t = (t31_state_t *) user_data; - s = &t->audio.modems; - v27ter_rx_fillin(&s->fast_modems.v27ter_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx(void *user_data, const int16_t amp[], int len) -{ - t31_state_t *t; - fax_modems_state_t *s; - - t = (t31_state_t *) user_data; - s = &t->audio.modems; - v29_rx(&s->fast_modems.v29_rx, amp, len); - if (t->at_state.rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow - one in parallel. */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v29_rx, (span_rx_fillin_handler_t *) &v29_rx_fillin, &s->fast_modems.v29_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (t->rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - } - return len; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx_fillin(void *user_data, int len) -{ - t31_state_t *t; - fax_modems_state_t *s; - - t = (t31_state_t *) user_data; - s = &t->audio.modems; - v29_rx_fillin(&s->fast_modems.v29_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE_NONSTD(int) t31_rx(t31_state_t *s, int16_t amp[], int len) { int i; @@ -2408,8 +2313,7 @@ SPAN_DECLARE_NONSTD(int) t31_rx(t31_state_t *s, int16_t amp[], int len) restart_modem(s, FAX_MODEM_SILENCE_TX); } - if (!s->at_state.transmit || s->modem == FAX_MODEM_CNG_TONE) - s->audio.modems.rx_handler(s->audio.modems.rx_user_data, amp, len); + s->audio.modems.rx_handler(s->audio.modems.rx_user_data, amp, len); return 0; } /*- End of function --------------------------------------------------------*/ @@ -2433,25 +2337,8 @@ SPAN_DECLARE_NONSTD(int) t31_rx_fillin(t31_state_t *s, int len) at_put_response_code(&s->at_state, AT_RESPONSE_CODE_ERROR); restart_modem(s, FAX_MODEM_SILENCE_TX); } - /* Call the fillin function of the current modem (if there is one). */ - switch (s->modem) - { - case FAX_MODEM_V21_RX: - len = fsk_rx_fillin(&s->audio.modems.v21_rx, len); - break; - case FAX_MODEM_V27TER_RX: - /* TODO: what about FSK in the early stages */ - len = v27ter_rx_fillin(&s->audio.modems.fast_modems.v27ter_rx, len); - break; - case FAX_MODEM_V29_RX: - /* TODO: what about FSK in the early stages */ - len = v29_rx_fillin(&s->audio.modems.fast_modems.v29_rx, len); - break; - case FAX_MODEM_V17_RX: - /* TODO: what about FSK in the early stages */ - len = v17_rx_fillin(&s->audio.modems.fast_modems.v17_rx, len); - break; - } + + s->audio.modems.rx_fillin_handler(s->audio.modems.rx_fillin_user_data, len); return 0; } /*- End of function --------------------------------------------------------*/ @@ -2460,14 +2347,14 @@ static int set_next_tx_type(t31_state_t *s) { if (s->audio.next_tx_handler) { - set_tx_handler(s, s->audio.next_tx_handler, s->audio.next_tx_user_data); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(&s->audio.modems, s->audio.next_tx_handler, s->audio.next_tx_user_data); + fax_modems_set_next_tx_handler(&s->audio.modems, (span_tx_handler_t) NULL, NULL); return 0; } /* There is nothing else to change to, so use zero length silence */ silence_gen_alter(&s->audio.modems.silence_gen, 0); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &s->audio.modems.silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); + fax_modems_set_tx_handler(&s->audio.modems, (span_tx_handler_t) &silence_gen, &s->audio.modems.silence_gen); + fax_modems_set_next_tx_handler(&s->audio.modems, (span_tx_handler_t) NULL, NULL); return -1; } /*- End of function --------------------------------------------------------*/ @@ -2556,7 +2443,7 @@ SPAN_DECLARE(t38_core_state_t *) t31_get_t38_core_state(t31_state_t *s) /*- End of function --------------------------------------------------------*/ static int t31_t38_fe_init(t31_state_t *t, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { t31_t38_front_end_state_t *s; @@ -2589,16 +2476,14 @@ static int t31_t38_fe_init(t31_state_t *t, /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, - at_tx_handler_t *at_tx_handler, + at_tx_handler_t at_tx_handler, void *at_tx_user_data, - t31_modem_control_handler_t *modem_control_handler, + t31_modem_control_handler_t modem_control_handler, void *modem_control_user_data, - t38_tx_packet_handler_t *tx_t38_packet_handler, + t38_tx_packet_handler_t tx_t38_packet_handler, void *tx_t38_packet_user_data) { -#if 0 v8_parms_t v8_parms; -#endif int alloced; if (at_tx_handler == NULL || modem_control_handler == NULL) @@ -2625,7 +2510,7 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, non_ecm_get_bit, tone_detected, (void *) s); -#if 0 + fax_modems_set_rx_handler(&s->audio.modems, (span_rx_handler_t) &span_dummy_rx, NULL, (span_rx_fillin_handler_t) &span_dummy_rx_fillin, NULL); v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; v8_parms.call_function = V8_CALL_T30_RX; v8_parms.modulations = V8_MOD_V21 @@ -2642,12 +2527,12 @@ SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s, v8_parms.t66 = -1; v8_init(&s->audio.v8, FALSE, &v8_parms, v8_handler, s); -#endif power_meter_init(&s->audio.rx_power, 4); s->audio.last_sample = 0; s->audio.silence_threshold_power = power_meter_level_dbm0(-36); s->at_state.rx_signal_present = FALSE; s->at_state.rx_trained = FALSE; + s->audio.modems.rx_trained = FALSE; s->at_state.do_hangup = FALSE; s->at_state.line_ptr = 0; diff --git a/libs/spandsp/src/t38_core.c b/libs/spandsp/src/t38_core.c index 67a53ae707..4a81b0eda1 100644 --- a/libs/spandsp/src/t38_core.c +++ b/libs/spandsp/src/t38_core.c @@ -1100,11 +1100,11 @@ SPAN_DECLARE(int) t38_core_restart(t38_core_state_t *s) /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(t38_core_state_t *) t38_core_init(t38_core_state_t *s, - t38_rx_indicator_handler_t *rx_indicator_handler, - t38_rx_data_handler_t *rx_data_handler, - t38_rx_missing_handler_t *rx_missing_handler, + t38_rx_indicator_handler_t rx_indicator_handler, + t38_rx_data_handler_t rx_data_handler, + t38_rx_missing_handler_t rx_missing_handler, void *rx_user_data, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { if (s == NULL) diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 03552efc41..e3993609cc 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -74,15 +74,10 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -110,20 +105,15 @@ #include "spandsp/private/hdlc.h" #include "spandsp/private/fax_modems.h" #include "spandsp/private/timezone.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" #include "spandsp/private/t30.h" @@ -206,170 +196,6 @@ static void non_ecm_remove_fill_and_put_bit(void *user_data, int bit); static void non_ecm_push_residue(t38_gateway_state_t *s); static void tone_detected(void *user_data, int tone, int level, int delay); -static void set_rx_handler(t38_gateway_state_t *s, span_rx_handler_t *handler, span_rx_fillin_handler_t *fillin_handler, void *user_data) -{ - if (s->audio.modems.rx_handler != span_dummy_rx) - { - s->audio.modems.rx_handler = handler; - s->audio.modems.rx_fillin_handler = fillin_handler; - } - /*endif*/ - s->audio.base_rx_handler = handler; - s->audio.base_rx_fillin_handler = fillin_handler; - s->audio.modems.rx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void set_tx_handler(t38_gateway_state_t *s, span_tx_handler_t *handler, void *user_data) -{ - s->audio.modems.tx_handler = handler; - s->audio.modems.tx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void set_next_tx_handler(t38_gateway_state_t *s, span_tx_handler_t *handler, void *user_data) -{ - s->audio.modems.next_tx_handler = handler; - s->audio.modems.next_tx_user_data = user_data; -} -/*- End of function --------------------------------------------------------*/ - -static void set_rx_active(t38_gateway_state_t *s, int active) -{ - s->audio.modems.rx_handler = (active) ? s->audio.base_rx_handler : span_dummy_rx; - s->audio.modems.rx_fillin_handler = (active) ? s->audio.base_rx_fillin_handler : span_dummy_rx_fillin; -} -/*- End of function --------------------------------------------------------*/ - -static int v17_v21_rx_fillin(void *user_data, int len) -{ - t38_gateway_state_t *t; - fax_modems_state_t *s; - - t = (t38_gateway_state_t *) user_data; - s = &t->audio.modems; - v17_rx_fillin(&s->fast_modems.v17_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v17_v21_rx(void *user_data, const int16_t amp[], int len) -{ - t38_gateway_state_t *t; - fax_modems_state_t *s; - - t = (t38_gateway_state_t *) user_data; - s = &t->audio.modems; - v17_rx(&s->fast_modems.v17_rx, amp, len); - if (s->rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow - one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v17_rx, (span_rx_fillin_handler_t *) &v17_rx_fillin, &s->fast_modems.v17_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (s->rx_signal_present) - { - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx_fillin(void *user_data, int len) -{ - t38_gateway_state_t *t; - fax_modems_state_t *s; - - t = (t38_gateway_state_t *) user_data; - s = &t->audio.modems; - v27ter_rx_fillin(&s->fast_modems.v27ter_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) -{ - t38_gateway_state_t *t; - fax_modems_state_t *s; - - t = (t38_gateway_state_t *) user_data; - s = &t->audio.modems; - v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); - if (s->rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow - one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v27ter_rx, (span_rx_fillin_handler_t *) &v27ter_v21_rx_fillin, &s->fast_modems.v27ter_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (s->rx_signal_present) - { - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx_fillin(void *user_data, int len) -{ - t38_gateway_state_t *t; - fax_modems_state_t *s; - - t = (t38_gateway_state_t *) user_data; - s = &t->audio.modems; - v29_rx_fillin(&s->fast_modems.v29_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int v29_v21_rx(void *user_data, const int16_t amp[], int len) -{ - t38_gateway_state_t *t; - fax_modems_state_t *s; - - t = (t38_gateway_state_t *) user_data; - s = &t->audio.modems; - v29_rx(&s->fast_modems.v29_rx, amp, len); - if (s->rx_trained) - { - /* The fast modem has trained, so we no longer need to run the slow - one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - set_rx_handler(t, (span_rx_handler_t *) &v29_rx, (span_rx_fillin_handler_t *) &v29_rx_fillin, &s->fast_modems.v29_rx); - } - else - { - fsk_rx(&s->v21_rx, amp, len); - if (s->rx_signal_present) - { - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - set_rx_handler(t, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &s->v21_rx); - } - /*endif*/ - } - /*endif*/ - return 0; -} -/*- End of function --------------------------------------------------------*/ - static void tone_detected(void *user_data, int tone, int level, int delay) { t38_gateway_state_t *s; @@ -383,7 +209,6 @@ static void hdlc_underflow_handler(void *user_data) { t38_gateway_state_t *s; t38_gateway_hdlc_state_t *t; - int old_data_type; s = (t38_gateway_state_t *) user_data; t = &s->core.hdlc_to_modem; @@ -392,7 +217,6 @@ static void hdlc_underflow_handler(void *user_data) underflow must be an end of preamble condition. */ if ((t->buf[t->out].flags & HDLC_FLAG_PROCEED_WITH_OUTPUT)) { - old_data_type = t->buf[t->out].contents; t->buf[t->out].len = 0; t->buf[t->out].flags = 0; t->buf[t->out].contents = 0; @@ -428,29 +252,29 @@ static void hdlc_underflow_handler(void *user_data) static int set_next_tx_type(t38_gateway_state_t *s) { - get_bit_func_t get_bit_func; - void *get_bit_user_data; int indicator; - int short_train; fax_modems_state_t *t; t38_gateway_hdlc_state_t *u; + int bit_rate; + int short_train; + int use_hdlc; t = &s->audio.modems; t38_non_ecm_buffer_report_output_status(&s->core.non_ecm_to_modem, &s->logging); if (t->next_tx_handler) { /* There is a handler queued, so that is the next one. */ - set_tx_handler(s, t->next_tx_handler, t->next_tx_user_data); - set_next_tx_handler(s, NULL, NULL); - if (t->tx_handler == (span_tx_handler_t *) &(silence_gen) + fax_modems_set_tx_handler(t, t->next_tx_handler, t->next_tx_user_data); + fax_modems_set_next_tx_handler(t, NULL, NULL); + if (t->tx_handler == (span_tx_handler_t) &silence_gen || - t->tx_handler == (span_tx_handler_t *) &(tone_gen)) + t->tx_handler == (span_tx_handler_t) &tone_gen) { - set_rx_active(s, TRUE); + fax_modems_set_rx_active(t, TRUE); } else { - set_rx_active(s, FALSE); + fax_modems_set_rx_active(t, FALSE); } /*endif*/ return TRUE; @@ -475,14 +299,14 @@ static int set_next_tx_type(t38_gateway_state_t *s) { span_log(&s->logging, SPAN_LOG_FLOW, "HDLC mode\n"); hdlc_tx_init(&t->hdlc_tx, FALSE, 2, TRUE, hdlc_underflow_handler, s); - get_bit_func = (get_bit_func_t) hdlc_tx_get_bit; - get_bit_user_data = (void *) &t->hdlc_tx; + fax_modems_set_get_bit(t, (get_bit_func_t) hdlc_tx_get_bit, &t->hdlc_tx); + use_hdlc = TRUE; } else { span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM mode\n"); - get_bit_func = t38_non_ecm_buffer_get_bit; - get_bit_user_data = (void *) &s->core.non_ecm_to_modem; + fax_modems_set_get_bit(t, (get_bit_func_t) t38_non_ecm_buffer_get_bit, &s->core.non_ecm_to_modem); + use_hdlc = FALSE; } /*endif*/ switch (indicator) @@ -491,24 +315,24 @@ static int set_next_tx_type(t38_gateway_state_t *s) t->tx_bit_rate = 0; /* Impose 75ms minimum on transmitted silence */ //silence_gen_set(&t->silence_gen, ms_to_samples(75)); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); - set_rx_active(s, TRUE); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_CNG: t->tx_bit_rate = 0; modem_connect_tones_tx_init(&t->connect_tx, MODEM_CONNECT_TONES_FAX_CNG); - set_tx_handler(s, (span_tx_handler_t *) &modem_connect_tones_tx, &t->connect_tx); silence_gen_set(&t->silence_gen, 0); - set_next_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_rx_active(s, TRUE); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &modem_connect_tones_tx, &t->connect_tx); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_CED: t->tx_bit_rate = 0; modem_connect_tones_tx_init(&t->connect_tx, MODEM_CONNECT_TONES_FAX_CED); - set_tx_handler(s, (span_tx_handler_t *) &modem_connect_tones_tx, &t->connect_tx); - set_next_tx_handler(s, (span_tx_handler_t *) NULL, NULL); - set_rx_active(s, TRUE); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &modem_connect_tones_tx, &t->connect_tx); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) NULL, NULL); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_V21_PREAMBLE: t->tx_bit_rate = 300; @@ -516,48 +340,30 @@ static int set_next_tx_type(t38_gateway_state_t *s) hdlc_tx_flags(&t->hdlc_tx, 32); silence_gen_alter(&t->silence_gen, ms_to_samples(75)); u->buf[u->in].len = 0; - fsk_tx_init(&t->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &t->hdlc_tx); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) &fsk_tx, &t->v21_tx); - set_rx_active(s, TRUE); + fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &fsk_tx, &t->v21_tx); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_V27TER_2400_TRAINING: case T38_IND_V27TER_4800_TRAINING: - switch (indicator) - { - case T38_IND_V27TER_2400_TRAINING: - t->tx_bit_rate = 2400; - break; - case T38_IND_V27TER_4800_TRAINING: - t->tx_bit_rate = 4800; - break; - } - /*endswitch*/ + bit_rate = + t->tx_bit_rate = (indicator == T38_IND_V27TER_4800_TRAINING) ? 4800 : 2400; silence_gen_alter(&t->silence_gen, ms_to_samples(75)); - v27ter_tx_restart(&t->fast_modems.v27ter_tx, t->tx_bit_rate, t->use_tep); - v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, get_bit_func, get_bit_user_data); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) &v27ter_tx, &t->fast_modems.v27ter_tx); - set_rx_active(s, TRUE); + fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_TX, bit_rate, s->core.short_train, use_hdlc); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_V29_7200_TRAINING: case T38_IND_V29_9600_TRAINING: - switch (indicator) - { - case T38_IND_V29_7200_TRAINING: - t->tx_bit_rate = 7200; - break; - case T38_IND_V29_9600_TRAINING: - t->tx_bit_rate = 9600; - break; - } - /*endswitch*/ + bit_rate = + t->tx_bit_rate = (indicator == T38_IND_V29_9600_TRAINING) ? 9600 : 7200; silence_gen_alter(&t->silence_gen, ms_to_samples(75)); - v29_tx_restart(&t->fast_modems.v29_tx, t->tx_bit_rate, t->use_tep); - v29_tx_set_get_bit(&t->fast_modems.v29_tx, get_bit_func, get_bit_user_data); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) &v29_tx, &t->fast_modems.v29_tx); - set_rx_active(s, TRUE); + fax_modems_start_fast_modem(t, FAX_MODEM_V29_TX, bit_rate, s->core.short_train, use_hdlc); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_V17_7200_SHORT_TRAINING: case T38_IND_V17_7200_LONG_TRAINING: @@ -572,40 +378,40 @@ static int set_next_tx_type(t38_gateway_state_t *s) { case T38_IND_V17_7200_SHORT_TRAINING: short_train = TRUE; - t->tx_bit_rate = 7200; + bit_rate = 7200; break; case T38_IND_V17_7200_LONG_TRAINING: - t->tx_bit_rate = 7200; + bit_rate = 7200; break; case T38_IND_V17_9600_SHORT_TRAINING: short_train = TRUE; - t->tx_bit_rate = 9600; + bit_rate = 9600; break; case T38_IND_V17_9600_LONG_TRAINING: - t->tx_bit_rate = 9600; + bit_rate = 9600; break; case T38_IND_V17_12000_SHORT_TRAINING: short_train = TRUE; - t->tx_bit_rate = 12000; + bit_rate = 12000; break; case T38_IND_V17_12000_LONG_TRAINING: - t->tx_bit_rate = 12000; + bit_rate = 12000; break; case T38_IND_V17_14400_SHORT_TRAINING: short_train = TRUE; - t->tx_bit_rate = 14400; + bit_rate = 14400; break; case T38_IND_V17_14400_LONG_TRAINING: - t->tx_bit_rate = 14400; + bit_rate = 14400; break; } /*endswitch*/ + t->tx_bit_rate = bit_rate; silence_gen_alter(&t->silence_gen, ms_to_samples(75)); - v17_tx_restart(&t->fast_modems.v17_tx, t->tx_bit_rate, t->use_tep, short_train); - v17_tx_set_get_bit(&t->fast_modems.v17_tx, get_bit_func, get_bit_user_data); - set_tx_handler(s, (span_tx_handler_t *) &silence_gen, &t->silence_gen); - set_next_tx_handler(s, (span_tx_handler_t *) &v17_tx, &t->fast_modems.v17_tx); - set_rx_active(s, TRUE); + fax_modems_start_fast_modem(t, FAX_MODEM_V17_TX, bit_rate, short_train, use_hdlc); + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); + fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); + fax_modems_set_rx_active(t, TRUE); break; case T38_IND_V8_ANSAM: t->tx_bit_rate = 300; @@ -1099,7 +905,7 @@ static int process_rx_indicator(t38_core_state_t *t, void *user_data, int indica span_log(&s->logging, SPAN_LOG_FLOW, "Changing - (%d) %s -> %s\n", - silence_gen_remainder(&(s->audio.modems.silence_gen)), + silence_gen_remainder(&s->audio.modems.silence_gen), t38_indicator_to_str(t->current_rx_indicator), t38_indicator_to_str(indicator)); switch (s->t38x.current_rx_field_class) @@ -1119,7 +925,7 @@ static int process_rx_indicator(t38_core_state_t *t, void *user_data, int indica span_log(&s->logging, SPAN_LOG_FLOW, "Queued change - (%d) %s -> %s\n", - silence_gen_remainder(&(s->audio.modems.silence_gen)), + silence_gen_remainder(&s->audio.modems.silence_gen), t38_indicator_to_str(t->current_rx_indicator), t38_indicator_to_str(indicator)); } @@ -1577,8 +1383,7 @@ static void set_octets_per_data_packet(t38_gateway_state_t *s, int bit_rate) { int octets; - //octets = s->core.ms_per_tx_chunk*bit_rate/(8*1000); - octets = DEFAULT_MS_PER_TX_CHUNK*bit_rate/(8*1000); + octets = s->core.ms_per_tx_chunk*bit_rate/(8*1000); if (octets < 1) octets = 1; /*endif*/ @@ -2117,8 +1922,7 @@ static void t38_hdlc_rx_put_bit(hdlc_rx_state_t *t, int new_bit) static int restart_rx_modem(t38_gateway_state_t *s) { - put_bit_func_t put_bit_func; - void *put_bit_user_data; + fax_modems_state_t *t; if (s->core.to_t38.in_bits || s->core.to_t38.out_octets) { @@ -2138,54 +1942,44 @@ static int restart_rx_modem(t38_gateway_state_t *s) s->core.short_train, s->core.ecm_mode); - hdlc_rx_init(&(s->audio.modems.hdlc_rx), FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, NULL, s); - s->audio.modems.rx_signal_present = FALSE; - s->audio.modems.rx_trained = FALSE; + t = &s->audio.modems; + hdlc_rx_init(&t->hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, NULL, s); + t->rx_signal_present = FALSE; + t->rx_trained = FALSE; /* Default to the transmit data being V.21, unless a faster modem pops up trained. */ s->t38x.current_tx_data_type = T38_DATA_V21; - fsk_rx_init(&(s->audio.modems.v21_rx), &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) t38_hdlc_rx_put_bit, &(s->audio.modems.hdlc_rx)); + //fax_modems_start_slow_modem(t, FAX_MODEM_V21_RX); + fsk_rx_init(&t->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) t38_hdlc_rx_put_bit, &t->hdlc_rx); #if 0 - fsk_rx_signal_cutoff(&(s->audio.modems.v21_rx), -45.5f); + fsk_rx_signal_cutoff(&t->v21_rx, -39.09f); #endif if (s->core.image_data_mode && s->core.ecm_mode) { - put_bit_func = (put_bit_func_t) t38_hdlc_rx_put_bit; - put_bit_user_data = (void *) &(s->audio.modems.hdlc_rx); + fax_modems_set_put_bit(t, (put_bit_func_t) t38_hdlc_rx_put_bit, &t->hdlc_rx); } else { if (s->core.image_data_mode && s->core.to_t38.fill_bit_removal) - put_bit_func = non_ecm_remove_fill_and_put_bit; + fax_modems_set_put_bit(t, (put_bit_func_t) non_ecm_remove_fill_and_put_bit, s); else - put_bit_func = non_ecm_put_bit; + fax_modems_set_put_bit(t, (put_bit_func_t) non_ecm_put_bit, s); /*endif*/ - put_bit_user_data = (void *) s; } /*endif*/ to_t38_buffer_init(&s->core.to_t38); s->core.to_t38.octets_per_data_packet = 1; + t->deferred_rx_handler_updates = TRUE; switch (s->core.fast_rx_modem) { - case FAX_MODEM_V17_RX: - v17_rx_restart(&s->audio.modems.fast_modems.v17_rx, s->core.fast_bit_rate, s->core.short_train); - v17_rx_set_put_bit(&s->audio.modems.fast_modems.v17_rx, put_bit_func, put_bit_user_data); - set_rx_handler(s, &v17_v21_rx, &v17_v21_rx_fillin, s); - s->core.fast_rx_active = FAX_MODEM_V17_RX; - break; case FAX_MODEM_V27TER_RX: - v27ter_rx_restart(&s->audio.modems.fast_modems.v27ter_rx, s->core.fast_bit_rate, FALSE); - v27ter_rx_set_put_bit(&s->audio.modems.fast_modems.v27ter_rx, put_bit_func, put_bit_user_data); - set_rx_handler(s, &v27ter_v21_rx, &v27ter_v21_rx_fillin, s); - s->core.fast_rx_active = FAX_MODEM_V27TER_RX; - break; case FAX_MODEM_V29_RX: - v29_rx_restart(&s->audio.modems.fast_modems.v29_rx, s->core.fast_bit_rate, FALSE); - v29_rx_set_put_bit(&s->audio.modems.fast_modems.v29_rx, put_bit_func, put_bit_user_data); - set_rx_handler(s, &v29_v21_rx, &v29_v21_rx_fillin, s); - s->core.fast_rx_active = FAX_MODEM_V29_RX; + case FAX_MODEM_V17_RX: + fax_modems_start_fast_modem(t, s->core.fast_rx_modem, s->core.fast_bit_rate, s->core.short_train, FALSE); + s->core.fast_rx_active = s->core.fast_rx_modem; break; default: - set_rx_handler(s, (span_rx_handler_t *) &fsk_rx, (span_rx_fillin_handler_t *) &fsk_rx_fillin, &(s->audio.modems.v21_rx)); + //fax_modems_start_slow_modem(t, FAX_MODEM_V21_RX); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &t->v21_rx); s->core.fast_rx_active = FAX_MODEM_NONE; break; } @@ -2243,7 +2037,7 @@ SPAN_DECLARE_NONSTD(int) t38_gateway_rx(t38_gateway_state_t *s, int16_t amp[], i #endif update_rx_timing(s, len); for (i = 0; i < len; i++) - amp[i] = dc_restore(&(s->audio.modems.dc_restore), amp[i]); + amp[i] = dc_restore(&s->audio.modems.dc_restore, amp[i]); /*endfor*/ s->audio.modems.rx_handler(s->audio.modems.rx_user_data, amp, len); return 0; @@ -2268,12 +2062,12 @@ SPAN_DECLARE_NONSTD(int) t38_gateway_rx_fillin(t38_gateway_state_t *s, int len) #endif vec_zeroi16(amp, len); - write(s->modems.audio_rx_log, amp, len*sizeof(int16_t)); + write(s->audio.modems.audio_rx_log, amp, len*sizeof(int16_t)); } #endif update_rx_timing(s, len); /* TODO: handle the modems properly */ - s->audio.modems.rx_fillin_handler(s->audio.modems.rx_user_data, len); + s->audio.modems.rx_fillin_handler(s->audio.modems.rx_fillin_user_data, len); return 0; } /*- End of function --------------------------------------------------------*/ @@ -2294,7 +2088,7 @@ SPAN_DECLARE_NONSTD(int) t38_gateway_tx(t38_gateway_state_t *s, int16_t amp[], i len += s->audio.modems.tx_handler(s->audio.modems.tx_user_data, amp + len, max_len - len); if (len < max_len) { - silence_gen_set(&(s->audio.modems.silence_gen), 0); + silence_gen_set(&s->audio.modems.silence_gen, 0); set_next_tx_type(s); } /*endif*/ @@ -2382,7 +2176,7 @@ SPAN_DECLARE(void) t38_gateway_set_nsx_suppression(t38_gateway_state_t *s, SPAN_DECLARE(void) t38_gateway_set_tep_mode(t38_gateway_state_t *s, int use_tep) { - s->audio.modems.use_tep = use_tep; + fax_modems_set_tep_mode(&s->audio.modems, use_tep); } /*- End of function --------------------------------------------------------*/ @@ -2393,7 +2187,7 @@ SPAN_DECLARE(void) t38_gateway_set_fill_bit_removal(t38_gateway_state_t *s, int /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(void) t38_gateway_set_real_time_frame_handler(t38_gateway_state_t *s, - t38_gateway_real_time_frame_handler_t *handler, + t38_gateway_real_time_frame_handler_t handler, void *user_data) { s->core.real_time_frame_handler = handler; @@ -2418,13 +2212,12 @@ static int t38_gateway_audio_init(t38_gateway_state_t *s) /* TODO: Don't use the very low cutoff levels we would like to. We get some quirks if we do. We need to sort this out. */ fsk_rx_signal_cutoff(&s->audio.modems.v21_rx, -30.0f); - v29_rx_signal_cutoff(&s->audio.modems.fast_modems.v29_rx, -28.5f); return 0; } /*- End of function --------------------------------------------------------*/ static int t38_gateway_t38_init(t38_gateway_state_t *t, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { t38_gateway_t38_state_t *s; @@ -2447,7 +2240,7 @@ static int t38_gateway_t38_init(t38_gateway_state_t *t, /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(t38_gateway_state_t *) t38_gateway_init(t38_gateway_state_t *s, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { if (tx_packet_handler == NULL) @@ -2466,14 +2259,14 @@ SPAN_DECLARE(t38_gateway_state_t *) t38_gateway_init(t38_gateway_state_t *s, t38_gateway_audio_init(s); t38_gateway_t38_init(s, tx_packet_handler, tx_packet_user_data); - - set_rx_active(s, TRUE); + + fax_modems_set_rx_active(&s->audio.modems, TRUE); t38_gateway_set_supported_modems(s, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); t38_gateway_set_nsx_suppression(s, (const uint8_t *) "\x00\x00\x00", 3, (const uint8_t *) "\x00\x00\x00", 3); s->core.to_t38.octets_per_data_packet = 1; s->core.ecm_allowed = TRUE; - //s->core.ms_per_tx_chunk = DEFAULT_MS_PER_TX_CHUNK; + s->core.ms_per_tx_chunk = DEFAULT_MS_PER_TX_CHUNK; t38_non_ecm_buffer_init(&s->core.non_ecm_to_modem, FALSE, 0); restart_rx_modem(s); s->core.timed_mode = TIMED_MODE_STARTUP; diff --git a/libs/spandsp/src/t38_terminal.c b/libs/spandsp/src/t38_terminal.c index 1a2c3eca2e..3a300ced9e 100644 --- a/libs/spandsp/src/t38_terminal.c +++ b/libs/spandsp/src/t38_terminal.c @@ -64,15 +64,10 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/t43.h" #endif @@ -88,20 +83,15 @@ #include "spandsp/private/logging.h" #include "spandsp/private/timezone.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" -#endif -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" -#endif -#if defined(SPANDSP_SUPPORT_T42) #include "spandsp/private/t42.h" -#endif #if defined(SPANDSP_SUPPORT_T43) #include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" #include "spandsp/private/t30.h" @@ -152,9 +142,12 @@ enum T38_TIMED_STEP_NO_SIGNAL = 0x60 }; -static __inline__ void front_end_status(t38_terminal_state_t *s, int status) +static __inline__ int front_end_status(t38_terminal_state_t *s, int status) { t30_front_end_status(&s->t30, status); + if (s->t38_fe.timed_step == T38_TIMED_STEP_NONE) + return -1; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -560,7 +553,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, if (len > 0) { bit_reverse(buf2, buf, len); - t30_non_ecm_put_chunk(&s->t30, buf2, len); + t30_non_ecm_put(&s->t30, buf2, len); } /*endif*/ fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT); @@ -580,7 +573,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, } /*endif*/ bit_reverse(buf2, buf, len); - t30_non_ecm_put_chunk(&s->t30, buf2, len); + t30_non_ecm_put(&s->t30, buf2, len); } /*endif*/ /* WORKAROUND: At least some Mediatrix boxes have a bug, where they can send HDLC signal end where @@ -748,7 +741,10 @@ static int stream_non_ecm(t38_terminal_state_t *s) However, I think the early versions of T.38 said the signal end message should not contain data. Hopefully, following the current spec will not cause compatibility issues. */ - len = t30_non_ecm_get_chunk(&s->t30, buf, fe->octets_per_data_packet); + len = t30_non_ecm_get(&s->t30, buf, fe->octets_per_data_packet); + if (len < 0) + return -1; + /*endif*/ if (len > 0) bit_reverse(buf, buf, len); /*endif*/ @@ -776,7 +772,8 @@ static int stream_non_ecm(t38_terminal_state_t *s) return res; /*endif*/ fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5; - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; break; } /*endif*/ @@ -806,7 +803,8 @@ static int stream_non_ecm(t38_terminal_state_t *s) if (fe->us_per_tx_chunk) delay = bits_to_us(s, 8*len) + 60000; /*endif*/ - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; break; } /*endif*/ @@ -910,7 +908,8 @@ static int stream_hdlc(t38_terminal_state_t *s) previous = fe->current_tx_data_type; fe->hdlc_tx.ptr = 0; fe->hdlc_tx.len = 0; - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; /* The above step should have got the next HDLC step ready - either another frame, or an instruction to stop transmission. */ if (fe->hdlc_tx.len >= 0) { @@ -940,7 +939,8 @@ static int stream_hdlc(t38_terminal_state_t *s) if (fe->us_per_tx_chunk) delay += 100000; /*endif*/ - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; } /*endif*/ break; @@ -969,7 +969,8 @@ static int stream_hdlc(t38_terminal_state_t *s) previous = fe->current_tx_data_type; fe->hdlc_tx.ptr = 0; fe->hdlc_tx.len = 0; - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; /* The above step should have got the next HDLC step ready - either another frame, or an instruction to stop transmission. */ if (fe->hdlc_tx.len >= 0) { @@ -1003,7 +1004,8 @@ static int stream_hdlc(t38_terminal_state_t *s) if (fe->us_per_tx_chunk) delay += 100000; /*endif*/ - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; } /*endif*/ break; @@ -1059,7 +1061,8 @@ static int stream_ced(t38_terminal_state_t *s) case T38_TIMED_STEP_CED_3: /* End of CED */ fe->timed_step = fe->queued_timed_step; - front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE); + if (front_end_status(s, T30_FRONT_END_SEND_STEP_COMPLETE) < 0) + return -1; return 0; } /*endswitch*/ @@ -1433,7 +1436,7 @@ static int t38_terminal_t38_fe_restart(t38_terminal_state_t *t) /*- End of function --------------------------------------------------------*/ static int t38_terminal_t38_fe_init(t38_terminal_state_t *t, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { t38_terminal_front_end_state_t *s; @@ -1482,7 +1485,7 @@ SPAN_DECLARE(int) t38_terminal_restart(t38_terminal_state_t *s, SPAN_DECLARE(t38_terminal_state_t *) t38_terminal_init(t38_terminal_state_t *s, int calling_party, - t38_tx_packet_handler_t *tx_packet_handler, + t38_tx_packet_handler_t tx_packet_handler, void *tx_packet_user_data) { if (tx_packet_handler == NULL) diff --git a/libs/spandsp/src/t42.c b/libs/spandsp/src/t42.c new file mode 100644 index 0000000000..0163ff52f5 --- /dev/null +++ b/libs/spandsp/src/t42.c @@ -0,0 +1,1422 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t42.c - ITU T.42 JPEG for FAX image processing + * + * Written by Steve Underwood + * + * Copyright (C) 2011 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(HAVE_TGMATH_H) +#include +#endif +#if defined(HAVE_MATH_H) +#include +#endif +#include "floating_fudge.h" +#include +#include +#include +#include + +#include "spandsp/telephony.h" +#include "spandsp/fast_convert.h" +#include "spandsp/logging.h" +#include "spandsp/saturated.h" +#include "spandsp/async.h" +#include "spandsp/timezone.h" +#include "spandsp/t4_rx.h" +#include "spandsp/t4_tx.h" +#include "spandsp/t81_t82_arith_coding.h" +#include "spandsp/t85.h" +#include "spandsp/t42.h" + +#include "spandsp/private/logging.h" +#include "spandsp/private/t81_t82_arith_coding.h" +#include "spandsp/private/t85.h" +#include "spandsp/private/t42.h" + +#define T42_USE_LUTS + +#include "t42_t43_local.h" +#if defined(T42_USE_LUTS) +#include "cielab_luts.h" +#endif + +typedef struct +{ + float L; + float a; + float b; +} cielab_t; + +typedef struct +{ + uint8_t tag[5]; + const char *name; + float xn; + float yn; + float zn; +} illuminant_t; + +typedef struct +{ + jmp_buf escape; + char error_message[JMSG_LENGTH_MAX]; +} escape_route_t; + +static const illuminant_t illuminants[] = +{ + {"\0D50", "CIE D50/2°", 96.422f, 100.000f, 82.521f}, + {"", "CIE D50/10°", 96.720f, 100.000f, 81.427f}, + {"", "CIE D55/2°", 95.682f, 100.000f, 92.149f}, + {"", "CIE D55/10°", 95.799f, 100.000f, 90.926f}, + {"\0D65", "CIE D65/2°", 95.047f, 100.000f, 108.883f}, + {"", "CIE D65/10°", 94.811f, 100.000f, 107.304f}, + {"\0D75", "CIE D75/2°", 94.972f, 100.000f, 122.638f}, + {"", "CIE D75/10°", 94.416f, 100.000f, 120.641f}, + {"\0\0F2", "F02/2°", 99.186f, 100.000f, 67.393f}, + {"", "F02/10°", 103.279f, 100.000f, 69.027f}, + {"\0\0F7", "F07/2°", 95.041f, 100.000f, 108.747f}, + {"", "F07/10°", 95.792f, 100.000f, 107.686f}, + {"\0F11", "F11/2°", 100.962f, 100.000f, 64.350f}, + {"", "F11/10°", 103.863f, 100.000f, 65.607f}, + {"\0\0SA", "A/2°", 109.850f, 100.000f, 35.585f}, + {"", "A/10°", 111.144f, 100.000f, 35.200f}, + {"\0\0SC", "C/2°", 98.074f, 100.000f, 118.232f}, + {"", "C/10°", 97.285f, 100.000f, 116.145f}, + {"", "", 0.000f, 0.000f, 0.000f} +}; + +/* This is the error catcher */ +static struct jpeg_error_mgr error_handler; + +static __inline__ uint16_t pack_16(const uint8_t *s) +{ + uint16_t value; + + value = ((uint16_t) s[0] << 8) | (uint16_t) s[1]; + return value; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ uint32_t pack_32(const uint8_t *s) +{ + uint32_t value; + + value = ((uint32_t) s[0] << 24) | ((uint32_t) s[1] << 16) | ((uint32_t) s[2] << 8) | (uint32_t) s[3]; + return value; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ int unpack_16(uint8_t *s, uint16_t value) +{ + s[0] = (value >> 8) & 0xFF; + s[1] = value & 0xFF; + return sizeof(uint16_t); +} +/*- End of function --------------------------------------------------------*/ + +/* Error handler for IJG library */ +static void jpg_error_exit(j_common_ptr cinfo) +{ + escape_route_t *escape; + + escape = (escape_route_t *) cinfo->client_data; + (*cinfo->err->format_message)(cinfo, escape->error_message); + longjmp(escape->escape, 1); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) set_lab_illuminant(lab_params_t *s, float new_xn, float new_yn, float new_zn) +{ + if (new_yn > 10.0f) + { + s->x_n = new_xn/100.0f; + s->y_n = new_yn/100.0f; + s->z_n = new_zn/100.0f; + } + else + { + s->x_n = new_xn; + s->y_n = new_yn; + s->z_n = new_zn; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) set_lab_gamut(lab_params_t *s, int L_min, int L_max, int a_min, int a_max, int b_min, int b_max, int ab_are_signed) +{ + s->range_L = L_max - L_min; + s->range_a = a_max - a_min; + s->range_b = b_max - b_min; + + s->offset_L = -256.0f*L_min/s->range_L; + s->offset_a = -256.0f*a_min/s->range_a; + s->offset_b = -256.0f*b_min/s->range_b; + + s->range_L /= (256.0f - 1.0f); + s->range_a /= (256.0f - 1.0f); + s->range_b /= (256.0f - 1.0f); + + s->ab_are_signed = ab_are_signed; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *s, int L_P, int L_Q, int a_P, int a_Q, int b_P, int b_Q) +{ + s->range_L = L_Q/(256.0f - 1.0f); + s->range_a = a_Q/(256.0f - 1.0f); + s->range_b = b_Q/(256.0f - 1.0f); + + s->offset_L = L_P; + s->offset_a = a_P; + s->offset_b = b_P; + + s->ab_are_signed = FALSE; +} +/*- End of function --------------------------------------------------------*/ + +void set_illuminant_from_code(logging_state_t *logging, lab_params_t *s, const uint8_t code[4]) +{ + int i; + int colour_temp; + + if (code[0] == 'C' && code[1] == 'T') + { + colour_temp = pack_16(&code[2]); + span_log(logging, SPAN_LOG_FLOW, "Illuminant colour temp %dK\n", colour_temp); + return; + } + for (i = 0; illuminants[i].name[0]; i++) + { + if (memcmp(code, illuminants[i].tag, 4) == 0) + { + span_log(logging, SPAN_LOG_FLOW, "Illuminant %s\n", illuminants[i].name); + set_lab_illuminant(s, illuminants[i].xn, illuminants[i].yn, illuminants[i].zn); + break; + } + } + if (illuminants[i].name[0] == '\0') + span_log(logging, SPAN_LOG_FLOW, "Unrecognised illuminant 0x%x 0x%x 0x%x 0x%x\n", code[0], code[1], code[2], code[3]); +} +/*- End of function --------------------------------------------------------*/ + +void set_gamut_from_code(logging_state_t *logging, lab_params_t *s, const uint8_t code[12]) +{ + int i; + int val[6]; + + for (i = 0; i < 6; i++) + val[i] = pack_16(&code[2*i]); + span_log(logging, + SPAN_LOG_FLOW, + "Gamut L=[%d,%d], a*=[%d,%d], b*=[%d,%d]\n", + val[0], + val[1], + val[2], + val[3], + val[4], + val[5]); + set_lab_gamut2(s, val[0], val[1], val[2], val[3], val[4], val[5]); +} +/*- End of function --------------------------------------------------------*/ + +static int is_itu_fax(logging_state_t *logging, lab_params_t *s, jpeg_saved_marker_ptr ptr) +{ + const uint8_t *data; + int ok; + int val[2]; + int i; + + ok = FALSE; + while (ptr) + { + if (ptr->marker == (JPEG_APP0 + 1) && ptr->data_length >= 6) + { + /* Markers are: + JPEG_RST0 + JPEG_EOI + JPEG_APP0 + JPEG_COM */ + data = (const uint8_t *) ptr->data; + if (strncmp((const char *) data, "G3FAX", 5) == 0) + { + switch (data[5]) + { + case 0: + for (i = 0; i < 2; i++) + val[i] = pack_16(&data[6 + 2*i]); + span_log(logging, SPAN_LOG_FLOW, "Version %d, resolution %d dpi\n", val[0], val[1]); + ok = TRUE; + break; + case 1: + span_log(logging, SPAN_LOG_FLOW, "Set gamut\n"); + if (ptr->data_length >= 6 + 12) + { + set_gamut_from_code(logging, s, &data[6]); + ok = TRUE; + } + else + { + span_log(logging, SPAN_LOG_FLOW, "Got bad G3FAX1 length - %d\n", ptr->data_length); + } + break; + case 2: + span_log(logging, SPAN_LOG_FLOW, "Set illuminant\n"); + if (ptr->data_length >= 6 + 4) + { + set_illuminant_from_code(logging, s, &data[6]); + ok = TRUE; + } + else + { + span_log(logging, SPAN_LOG_FLOW, "Got bad G3FAX2 length - %d\n", ptr->data_length); + } + break; + case 3: + /* Colour palette table */ + span_log(logging, SPAN_LOG_FLOW, "Set colour palette\n"); + if (ptr->data_length >= 6 + 2) + { + val[0] = pack_16(&data[6]); + span_log(logging, SPAN_LOG_FLOW, "Colour palette %d\n", val[0]); + } + else + { + span_log(logging, SPAN_LOG_FLOW, "Got bad G3FAX3 length - %d\n", ptr->data_length); + } + break; + default: + span_log(logging, SPAN_LOG_FLOW, "Got unexpected G3FAX%d length - %d\n", data[5], ptr->data_length); + break; + } + } + } + else + { + span_log(logging, SPAN_LOG_FLOW, "Got marker 0x%x, length %d\n", ptr->marker, ptr->data_length); + span_log_buf(logging, SPAN_LOG_FLOW, "Got marker", (const uint8_t *) ptr->data, ptr->data_length); + } + ptr = ptr->next; + } + + return ok; +} +/*- End of function --------------------------------------------------------*/ + +static void set_itu_fax(j_compress_ptr cinfo) +{ + uint8_t marker[10] = + { + 'G', '3', 'F', 'A', 'X', '\x00', '\x07', '\xCA', '\x00', '\x00' + }; + + unpack_16(marker + 8, 200); + + jpeg_write_marker(cinfo, (JPEG_APP0 + 1), marker, 10); +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void itu_to_lab(lab_params_t *s, cielab_t *lab, const uint8_t in[3]) +{ + uint8_t a; + uint8_t b; + + /* T.4 E.6.4 */ + lab->L = s->range_L*(in[0] - s->offset_L); + a = in[1]; + b = in[2]; + if (s->ab_are_signed) + { + a += 128; + b += 128; + } + lab->a = s->range_a*(a - s->offset_a); + lab->b = s->range_b*(b - s->offset_b); +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void lab_to_itu(lab_params_t *s, uint8_t out[3], const cielab_t *lab) +{ + /* T.4 E.6.4 */ + out[0] = saturateu8(floorf(lab->L/s->range_L + s->offset_L)); + out[1] = saturateu8(floorf(lab->a/s->range_a + s->offset_a)); + out[2] = saturateu8(floorf(lab->b/s->range_b + s->offset_b)); + if (s->ab_are_signed) + { + out[1] -= 128; + out[2] -= 128; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) srgb_to_lab(lab_params_t *s, uint8_t lab[], const uint8_t srgb[], int pixels) +{ + float x; + float y; + float z; + float r; + float g; + float b; + float xx; + float yy; + float zz; + cielab_t l; + int i; + + for (i = 0; i < 3*pixels; i += 3) + { +#if defined(T42_USE_LUTS) + r = srgb_to_linear[srgb[i]]; + g = srgb_to_linear[srgb[i + 1]]; + b = srgb_to_linear[srgb[i + 2]]; +#else + r = srgb[i]/256.0f; + g = srgb[i + 1]/256.0f; + b = srgb[i + 2]/256.0f; + + /* sRGB to linear RGB */ + r = (r > 0.04045f) ? powf((r + 0.055f)/1.055f, 2.4f) : r/12.92f; + g = (g > 0.04045f) ? powf((g + 0.055f)/1.055f, 2.4f) : g/12.92f; + b = (b > 0.04045f) ? powf((b + 0.055f)/1.055f, 2.4f) : b/12.92f; +#endif + + /* Linear RGB to XYZ */ + x = 0.4124f*r + 0.3576f*g + 0.1805f*b; + y = 0.2126f*r + 0.7152f*g + 0.0722f*b; + z = 0.0193f*r + 0.1192f*g + 0.9505f*b; + + /* Normalise for the illuminant */ + x /= s->x_n; + y /= s->y_n; + z /= s->z_n; + + /* XYZ to Lab */ + xx = (x <= 0.008856f) ? (7.787f*x + 0.1379f) : cbrtf(x); + yy = (y <= 0.008856f) ? (7.787f*y + 0.1379f) : cbrtf(y); + zz = (z <= 0.008856f) ? (7.787f*z + 0.1379f) : cbrtf(z); + l.L = 116.0f*yy - 16.0f; + l.a = 500.0f*(xx - yy); + l.b = 200.0f*(yy - zz); + + lab_to_itu(s, lab, &l); + + lab += 3; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) lab_to_srgb(lab_params_t *s, uint8_t srgb[], const uint8_t lab[], int pixels) +{ + float x; + float y; + float z; + float r; + float g; + float b; + float ll; + cielab_t l; + int val; + int i; + + for (i = 0; i < 3*pixels; i += 3) + { + itu_to_lab(s, &l, lab); + + /* Lab to XYZ */ + ll = (1.0f/116.0f)*(l.L + 16.0f); + y = ll; + y = (y <= 0.2068f) ? (0.1284f*(y - 0.1379f)) : y*y*y; + x = ll + (1.0f/500.0f)*l.a; + x = (x <= 0.2068f) ? (0.1284f*(x - 0.1379f)) : x*x*x; + z = ll - (1.0f/200.0f)*l.b; + z = (z <= 0.2068f) ? (0.1284f*(z - 0.1379f)) : z*z*z; + + /* Normalise for the illuminant */ + x *= s->x_n; + y *= s->y_n; + z *= s->z_n; + + /* XYZ to linear RGB */ + r = 3.2406f*x - 1.5372f*y - 0.4986f*z; + g = -0.9689f*x + 1.8758f*y + 0.0415f*z; + b = 0.0557f*x - 0.2040f*y + 1.0570f*z; + +#if defined(T42_USE_LUTS) + val = r*4096.0f; + srgb[i] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095]; + val = g*4096.0f; + srgb[i + 1] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095]; + val = b*4096.0f; + srgb[i + 2] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095]; +#else + /* Linear RGB to sRGB */ + r = (r > 0.0031308f) ? (1.055f*powf(r, 1.0f/2.4f) - 0.055f) : r*12.92f; + g = (g > 0.0031308f) ? (1.055f*powf(g, 1.0f/2.4f) - 0.055f) : g*12.92f; + b = (b > 0.0031308f) ? (1.055f*powf(b, 1.0f/2.4f) - 0.055f) : b*12.92f; + + srgb[i] = saturateu8(floorf(r*256.0f)); + srgb[i + 1] = saturateu8(floorf(g*256.0f)); + srgb[i + 2] = saturateu8(floorf(b*256.0f)); +#endif + lab += 3; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_itulab_to_jpeg(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen) +{ + struct jpeg_decompress_struct decompressor; + struct jpeg_compress_struct compressor; + FILE *in; + FILE *out; + int m; + JSAMPROW scan_line_in; + JSAMPROW scan_line_out; + escape_route_t escape; +#if defined(HAVE_OPEN_MEMSTREAM) + char *outptr; + size_t outsize; +#endif + + escape.error_message[0] = '\0'; + +#if defined(HAVE_OPEN_MEMSTREAM) + if ((in = fmemopen(src, srclen, "r")) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to fmemopen().\n"); + return FALSE; + } + outsize = 0; + if ((out = open_memstream(&outptr, &outsize)) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to open_memstream().\n"); + fclose(in); + return FALSE; + } + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(in); + fclose(out); + return FALSE; + } +#else + if ((in = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + return FALSE; + } + if (fwrite(src, 1, srclen, in) != srclen) + { + fclose(in); + return FALSE; + } + if (fseek(in, 0, SEEK_SET) != 0) + { + fclose(in); + return FALSE; + } + if ((out = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + fclose(in); + return FALSE; + } +#endif + scan_line_out = NULL; + + if (setjmp(escape.escape)) + { + if (escape.error_message[0]) + span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message); + else + span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); + if (scan_line_out) + free(scan_line_out); + fclose(in); + fclose(out); + return FALSE; + } + + /* Create input decompressor. */ + decompressor.err = jpeg_std_error(&error_handler); + decompressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_decompress(&decompressor); + jpeg_stdio_src(&decompressor, in); + + /* Needed in the case of ITU Lab input */ + for (m = 0; m < 16; m++) + jpeg_save_markers(&decompressor, JPEG_APP0 + m, 0xFFFF); + + /* Rewind the file */ + if (fseek(in, 0, SEEK_SET) != 0) + return FALSE; + + /* Take the header */ + jpeg_read_header(&decompressor, TRUE); + + /* Now we can force the input colour space. For ITULab, we use YCbCr as a "don't touch" marker */ + decompressor.out_color_space = JCS_YCbCr; + + /* Sanity check and parameter check */ + if (!is_itu_fax(logging, s, decompressor.marker_list)) + { + span_log(logging, SPAN_LOG_FLOW, "Is not an ITU FAX.\n"); + return FALSE; + } + + /* Create compressor */ + compressor.err = jpeg_std_error(&error_handler); + compressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_compress(&compressor); + jpeg_stdio_dest(&compressor, out); + + /* Force the destination colour space */ + compressor.in_color_space = JCS_RGB; + compressor.input_components = 3; + + jpeg_set_defaults(&compressor); + /* Limit to baseline-JPEG values */ + //jpeg_set_quality(&compressor, quality, TRUE); + + /* Copy size, resolution, etc */ + jpeg_copy_critical_parameters(&decompressor, &compressor); + + /* We need to keep these */ + compressor.density_unit = decompressor.density_unit; + compressor.X_density = decompressor.X_density; + compressor.Y_density = decompressor.Y_density; + + jpeg_start_decompress(&decompressor); + jpeg_start_compress(&compressor, TRUE); + + if ((scan_line_in = (JSAMPROW) malloc(decompressor.output_width*decompressor.num_components)) == NULL) + return FALSE; + + if ((scan_line_out = (JSAMPROW) malloc(compressor.image_width*compressor.num_components)) == NULL) + { + free(scan_line_in); + return FALSE; + } + + while (decompressor.output_scanline < decompressor.output_height) + { + jpeg_read_scanlines(&decompressor, &scan_line_in, 1); + lab_to_srgb(s, scan_line_out, scan_line_in, decompressor.output_width); + jpeg_write_scanlines(&compressor, &scan_line_out, 1); + } + free(scan_line_in); + free(scan_line_out); + jpeg_finish_decompress(&decompressor); + jpeg_finish_compress(&compressor); + jpeg_destroy_decompress(&decompressor); + jpeg_destroy_compress(&compressor); + fclose(in); + +#if defined(HAVE_OPEN_MEMSTREAM) + fclose(out); + *dst = outptr; + *dstlen = outsize; +#else + *dstlen = ftell(out); + *dst = malloc(*dstlen); + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(out); + return FALSE; + } + if (fread(*dst, 1, *dstlen, out) != *dstlen) + { + free(*dst); + fclose(out); + return FALSE; + } + fclose(out); +#endif + + return TRUE; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_jpeg_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen) +{ + struct jpeg_decompress_struct decompressor; + struct jpeg_compress_struct compressor; + FILE *in; + FILE *out; + int m; + JSAMPROW scan_line_in; + JSAMPROW scan_line_out; + escape_route_t escape; +#if defined(HAVE_OPEN_MEMSTREAM) + char *outptr; + size_t outsize; +#endif + + escape.error_message[0] = '\0'; + +#if defined(HAVE_OPEN_MEMSTREAM) + if ((in = fmemopen(src, srclen, "r")) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to fmemopen().\n"); + return FALSE; + } + outsize = 0; + if ((out = open_memstream(&outptr, &outsize)) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to open_memstream().\n"); + fclose(in); + return FALSE; + } + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(in); + fclose(out); + return FALSE; + } +#else + if ((in = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + return FALSE; + } + if (fwrite(src, 1, srclen, in) != srclen) + { + fclose(in); + return FALSE; + } + if (fseek(in, 0, SEEK_SET) != 0) + { + fclose(in); + return FALSE; + } + if ((out = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + fclose(in); + return FALSE; + } +#endif + scan_line_out = NULL; + + if (setjmp(escape.escape)) + { + if (escape.error_message[0]) + span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message); + else + span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); + if (scan_line_out) + free(scan_line_out); + fclose(in); + fclose(out); + return FALSE; + } + /* Create input decompressor. */ + decompressor.err = jpeg_std_error(&error_handler); + decompressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_decompress(&decompressor); + jpeg_stdio_src(&decompressor, in); + + /* Needed in the case of ITU Lab input */ + for (m = 0; m < 16; m++) + jpeg_save_markers(&decompressor, JPEG_APP0 + m, 0xFFFF); + + /* Rewind the file */ + if (fseek(in, 0, SEEK_SET) != 0) + return FALSE; + + /* Take the header */ + jpeg_read_header(&decompressor, TRUE); + + /* Now we can force the input colour space. For ITULab, we use YCbCr as a "don't touch" marker */ + decompressor.out_color_space = JCS_RGB; + + compressor.err = jpeg_std_error(&error_handler); + compressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_compress(&compressor); + jpeg_stdio_dest(&compressor, out); + + /* Force the destination colour space */ + compressor.in_color_space = JCS_YCbCr; + compressor.input_components = 3; + + jpeg_set_defaults(&compressor); + /* Limit to baseline-JPEG values */ + //jpeg_set_quality(&compressor, quality, TRUE); + + jpeg_copy_critical_parameters(&decompressor, &compressor); + + /* We need to keep these */ + compressor.density_unit = decompressor.density_unit; + compressor.X_density = decompressor.X_density; + compressor.Y_density = decompressor.Y_density; + + jpeg_start_decompress(&decompressor); + jpeg_start_compress(&compressor, TRUE); + + set_itu_fax(&compressor); + + if ((scan_line_in = (JSAMPROW) malloc(decompressor.output_width*decompressor.num_components)) == NULL) + return FALSE; + + if ((scan_line_out = (JSAMPROW) malloc(compressor.image_width*compressor.num_components)) == NULL) + { + free(scan_line_in); + return FALSE; + } + + while (decompressor.output_scanline < decompressor.output_height) + { + jpeg_read_scanlines(&decompressor, &scan_line_in, 1); + srgb_to_lab(s, scan_line_out, scan_line_in, decompressor.output_width); + jpeg_write_scanlines(&compressor, &scan_line_out, 1); + } + + free(scan_line_in); + free(scan_line_out); + jpeg_finish_decompress(&decompressor); + jpeg_finish_compress(&compressor); + jpeg_destroy_decompress(&decompressor); + jpeg_destroy_compress(&compressor); + fclose(in); + +#if defined(HAVE_OPEN_MEMSTREAM) + fclose(out); + *dst = outptr; + *dstlen = outsize; +#else + *dstlen = ftell(out); + *dst = malloc(*dstlen); + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(out); + return FALSE; + } + if (fread(*dst, 1, *dstlen, out) != *dstlen) + { + free(*dst); + fclose(out); + return FALSE; + } + fclose(out); +#endif + + return TRUE; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_srgb_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height) +{ + struct jpeg_compress_struct compressor; + FILE *out; + JSAMPROW scan_line_out; + JSAMPROW scan_line_in; + tsize_t pos; + escape_route_t escape; +#if defined(HAVE_OPEN_MEMSTREAM) + char *outptr; + size_t outsize; +#endif + + escape.error_message[0] = '\0'; + +#if defined(HAVE_OPEN_MEMSTREAM) + outsize = 0; + if ((out = open_memstream(&outptr, &outsize)) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to open_memstream().\n"); + return FALSE; + } + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(out); + return FALSE; + } +#else + if ((out = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + return FALSE; + } +#endif + scan_line_out = NULL; + + if (setjmp(escape.escape)) + { + if (escape.error_message[0]) + span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message); + else + span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); + if (scan_line_out) + free(scan_line_out); + fclose(out); + return FALSE; + } + + compressor.err = jpeg_std_error(&error_handler); + compressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_compress(&compressor); + jpeg_stdio_dest(&compressor, out); + + /* Force the destination colour space */ + compressor.in_color_space = JCS_YCbCr; + compressor.input_components = 3; + + jpeg_set_defaults(&compressor); + /* Limit to baseline-JPEG values */ + //jpeg_set_quality(&compressor, quality, TRUE); + + /* Size, resolution, etc */ + compressor.image_width = width; + compressor.image_height = height; + + jpeg_start_compress(&compressor, TRUE); + + set_itu_fax(&compressor); + + if ((scan_line_out = (JSAMPROW) malloc(compressor.image_width*compressor.num_components)) == NULL) + return FALSE; + + for (pos = 0; pos < srclen; pos += compressor.image_width*compressor.num_components) + { + scan_line_in = (JSAMPROW) src + pos; + srgb_to_lab(s, scan_line_out, scan_line_in, compressor.image_width); + jpeg_write_scanlines(&compressor, &scan_line_out, 1); + } + + free(scan_line_out); + jpeg_finish_compress(&compressor); + jpeg_destroy_compress(&compressor); + +#if defined(HAVE_OPEN_MEMSTREAM) + fclose(out); + *dst = outptr; + *dstlen = outsize; +#else + *dstlen = ftell(out); + *dst = malloc(*dstlen); + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(out); + return FALSE; + } + if (fread(*dst, 1, *dstlen, out) != *dstlen) + { + free(*dst); + fclose(out); + return FALSE; + } + fclose(out); +#endif + + return TRUE; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_itulab_to_itulab(logging_state_t *logging, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height) +{ + struct jpeg_compress_struct compressor; + FILE *out; + JSAMPROW scan_line_in; + tsize_t pos; + escape_route_t escape; +#if defined(HAVE_OPEN_MEMSTREAM) + char *outptr; + size_t outsize; +#endif + + escape.error_message[0] = '\0'; + +#if defined(HAVE_OPEN_MEMSTREAM) + outsize = 0; + if ((out = open_memstream(&outptr, &outsize)) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to open_memstream().\n"); + return FALSE; + } + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(out); + return FALSE; + } +#else + if ((out = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + return FALSE; + } +#endif + + if (setjmp(escape.escape)) + { + if (escape.error_message[0]) + span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message); + else + span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); + fclose(out); + return FALSE; + } + + compressor.err = jpeg_std_error(&error_handler); + compressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_compress(&compressor); + jpeg_stdio_dest(&compressor, out); + + /* Force the destination colour space */ + compressor.in_color_space = JCS_YCbCr; + compressor.input_components = 3; + + jpeg_set_defaults(&compressor); + /* Limit to baseline-JPEG values */ + //jpeg_set_quality(&compressor, quality, TRUE); + + /* Size, resolution, etc */ + compressor.image_width = width; + compressor.image_height = height; + + jpeg_start_compress(&compressor, TRUE); + + set_itu_fax(&compressor); + + for (pos = 0; pos < srclen; pos += compressor.image_width*compressor.num_components) + { + scan_line_in = (JSAMPROW) src + pos; + jpeg_write_scanlines(&compressor, &scan_line_in, 1); + } + + jpeg_finish_compress(&compressor); + jpeg_destroy_compress(&compressor); + +#if defined(HAVE_OPEN_MEMSTREAM) + fclose(out); + *dst = outptr; + *dstlen = outsize; +#else + *dstlen = ftell(out); + *dst = malloc(*dstlen); + if (fseek(out, 0, SEEK_SET) != 0) + { + fclose(out); + return FALSE; + } + if (fread(*dst, 1, *dstlen, out) != *dstlen) + { + free(*dst); + fclose(out); + return FALSE; + } + fclose(out); +#endif + + return TRUE; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s, tdata_t dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t *width, uint32_t *height) +{ + struct jpeg_decompress_struct decompressor; + JSAMPROW scan_line_out; + JSAMPROW scan_line_in; + tsize_t pos; + FILE *in; + int m; + escape_route_t escape; + + escape.error_message[0] = '\0'; + +#if defined(HAVE_OPEN_MEMSTREAM) + if ((in = fmemopen(src, srclen, "r")) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to fmemopen().\n"); + return FALSE; + } +#else + if ((in = tmpfile()) == NULL) + { + span_log(logging, SPAN_LOG_FLOW, "Failed to tmpfile().\n"); + return FALSE; + } + if (fwrite(src, 1, srclen, in) != srclen) + { + fclose(in); + return FALSE; + } + if (fseek(in, 0, SEEK_SET) != 0) + { + fclose(in); + return FALSE; + } +#endif + scan_line_out = NULL; + + if (setjmp(escape.escape)) + { + if (escape.error_message[0]) + span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message); + else + span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); + if (scan_line_out) + free(scan_line_out); + fclose(in); + return FALSE; + } + /* Create input decompressor. */ + decompressor.err = jpeg_std_error(&error_handler); + decompressor.client_data = (void *) &escape; + error_handler.error_exit = jpg_error_exit; + error_handler.output_message = jpg_error_exit; + + jpeg_create_decompress(&decompressor); + jpeg_stdio_src(&decompressor, in); + + /* Needed in the case of ITU Lab input */ + for (m = 0; m < 16; m++) + jpeg_save_markers(&decompressor, JPEG_APP0 + m, 0xFFFF); + + /* Rewind the file */ + if (fseek(in, 0, SEEK_SET) != 0) + return FALSE; + /* Take the header */ + jpeg_read_header(&decompressor, FALSE); + /* Now we can force the input colour space. For ITULab, we use YCbCr as a "don't touch" marker */ + decompressor.out_color_space = JCS_YCbCr; + /* Sanity check and parameter check */ + if (!is_itu_fax(logging, s, decompressor.marker_list)) + { + span_log(logging, SPAN_LOG_FLOW, "Is not an ITU FAX.\n"); + return FALSE; + } + /* Copy size, resolution, etc */ + *width = decompressor.image_width; + *height = decompressor.image_height; + + jpeg_start_decompress(&decompressor); + + if ((scan_line_in = (JSAMPROW) malloc(decompressor.output_width*decompressor.num_components)) == NULL) + return FALSE; + + for (pos = 0; decompressor.output_scanline < decompressor.output_height; pos += decompressor.output_width*decompressor.num_components) + { + scan_line_out = (JSAMPROW) dst + pos; + jpeg_read_scanlines(&decompressor, &scan_line_in, 1); + lab_to_srgb(s, scan_line_out, scan_line_in, decompressor.output_width); + } + + free(scan_line_in); + jpeg_finish_decompress(&decompressor); + jpeg_destroy_decompress(&decompressor); + fclose(in); + + *dstlen = pos; + + return TRUE; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t42_encode_set_options(t42_encode_state_t *s, + uint32_t l0, + int mx, + int options) +{ +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_set_image_width(t42_encode_state_t *s, uint32_t image_width) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_set_image_length(t42_encode_state_t *s, uint32_t length) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t42_encode_abort(t42_encode_state_t *s) +{ +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t42_encode_comment(t42_encode_state_t *s, const uint8_t comment[], size_t len) +{ +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_image_complete(t42_encode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_get(t42_encode_state_t *s, uint8_t buf[], size_t max_len) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t42_encode_get_image_width(t42_encode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t42_encode_get_image_length(t42_encode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_get_compressed_image_size(t42_encode_state_t *s) +{ + return s->compressed_image_size; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_set_row_read_handler(t42_encode_state_t *s, + t4_row_read_handler_t handler, + void *user_data) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(logging_state_t *) t42_encode_get_logging_state(t42_encode_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length) +{ + //s->image_width = image_width; + //s->image_length = image_length; + s->compressed_image_size = 0; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s, + uint32_t image_width, + uint32_t image_length, + t4_row_read_handler_t handler, + void *user_data) +{ + if (s == NULL) + { + if ((s = (t42_encode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.42"); + + s->row_read_handler = handler; + s->row_read_user_data = user_data; + t42_encode_restart(s, image_width, image_length); + + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_release(t42_encode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_encode_free(t42_encode_state_t *s) +{ + int ret; + + ret = t42_encode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t42_decode_rx_status(t42_decode_state_t *s, int status) +{ +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], size_t len) +{ + uint8_t *buf; + + if (s->compressed_image_size + len > s->buf_size) + { + if ((buf = (uint8_t *) realloc(s->compressed_buf, s->compressed_image_size + 1000)) == NULL) + return -1; + s->buf_size = s->compressed_image_size + 1000; + s->compressed_buf = buf; + } + memcpy(&s->compressed_buf[s->compressed_image_size], data, len); + s->compressed_image_size += len; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_set_row_write_handler(t42_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data) +{ + s->row_write_handler = handler; + s->row_write_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_set_comment_handler(t42_decode_state_t *s, + uint32_t max_comment_len, + t4_row_write_handler_t handler, + void *user_data) +{ + s->max_comment_len = max_comment_len; + s->comment_handler = handler; + s->comment_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_set_image_size_constraints(t42_decode_state_t *s, + uint32_t max_xd, + uint32_t max_yd) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t42_decode_get_image_width(t42_decode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t42_decode_get_image_length(t42_decode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_get_compressed_image_size(t42_decode_state_t *s) +{ + return s->compressed_image_size; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(logging_state_t *) t42_decode_get_logging_state(t42_decode_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s) +{ + s->compressed_image_size = 0; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data) +{ + if (s == NULL) + { + if ((s = (t42_decode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.42"); + + s->row_write_handler = handler; + s->row_write_user_data = user_data; + + s->buf_size = 0; + s->compressed_buf = NULL; + + t42_decode_restart(s); + + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_release(t42_decode_state_t *s) +{ + if (s->comment) + { + free(s->comment); + s->comment = NULL; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t42_decode_free(t42_decode_state_t *s) +{ + int ret; + + ret = t42_decode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t42_t43_local.h b/libs/spandsp/src/t42_t43_local.h new file mode 100644 index 0000000000..6eec67c6b9 --- /dev/null +++ b/libs/spandsp/src/t42_t43_local.h @@ -0,0 +1,44 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t42_t43_local.h - definitions for T.42 and T.43 shared processing + * + * Written by Steve Underwood + * + * Copyright (C) 2011 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if !defined(_T42_T43_LOCAL_H_) +#define _T42_T43_LOCAL_H_ + +#if defined(__cplusplus) +extern "C" +{ +#endif + +void set_illuminant_from_code(logging_state_t *logging, lab_params_t *s, const uint8_t code[4]); +void set_gamut_from_code(logging_state_t *logging, lab_params_t *s, const uint8_t code[12]); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_rx.c b/libs/spandsp/src/t4_rx.c index ccb78a7e55..f3b34167b2 100644 --- a/libs/spandsp/src/t4_rx.c +++ b/libs/spandsp/src/t4_rx.c @@ -1,4 +1,3 @@ -//#define T4_STATE_DEBUGGING /* * SpanDSP - a series of DSP components for telephony * @@ -6,7 +5,7 @@ * * Written by Steve Underwood * - * Copyright (C) 2003, 2007 Steve Underwood + * Copyright (C) 2003, 2007, 2010 Steve Underwood * * All rights reserved. * @@ -24,36 +23,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - * Much of this file is based on the T.4 and T.6 support in libtiff, which requires - * the following notice in any derived source code: - * - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * Decoder support is derived from code in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ - /*! \file */ #if defined(HAVE_CONFIG_H) @@ -85,1157 +54,36 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" #include "spandsp/t85.h" +#include "spandsp/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/t43.h" #endif #include "spandsp/t4_t6_decode.h" #include "spandsp/t4_t6_encode.h" #include "spandsp/version.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #include "spandsp/private/t85.h" +#include "spandsp/private/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" /*! The number of centimetres in one inch */ #define CM_PER_INCH 2.54f -/*! The number of EOLs to expect at the end of a T.4 page */ -#define EOLS_TO_END_ANY_RX_PAGE 6 -/*! The number of EOLs to check at the end of a T.4 page */ -#define EOLS_TO_END_T4_RX_PAGE 5 -/*! The number of EOLs to check at the end of a T.6 page */ -#define EOLS_TO_END_T6_RX_PAGE 2 - -#include "t4_t6_decode_states.h" - -#if defined(T4_STATE_DEBUGGING) -static void STATE_TRACE(const char *format, ...) -{ - va_list arg_ptr; - - va_start(arg_ptr, format); - vprintf(format, arg_ptr); - va_end(arg_ptr); -} -/*- End of function --------------------------------------------------------*/ -#else -#define STATE_TRACE(...) /**/ -#endif - -#if defined(HAVE_LIBTIFF) -static int set_tiff_directory_info(t4_state_t *s) -{ - time_t now; - struct tm *tm; - char buf[256 + 1]; - uint16_t resunit; - float x_resolution; - float y_resolution; - t4_tiff_state_t *t; - - t = &s->tiff; - /* Prepare the directory entry fully before writing the image, or libtiff complains */ - TIFFSetField(t->tiff_file, TIFFTAG_COMPRESSION, t->output_compression); #if defined(SPANDSP_SUPPORT_TIFF_FX) - TIFFSetField(t->tiff_file, TIFFTAG_PROFILETYPE, PROFILETYPE_G3_FAX); - TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, FAXPROFILE_S); - TIFFSetField(t->tiff_file, TIFFTAG_CODINGMETHODS, CODINGMETHODS_T4_1D | CODINGMETHODS_T4_2D | CODINGMETHODS_T6); - TIFFSetField(t->tiff_file, TIFFTAG_VERSIONYEAR, "1998"); - /* TIFFSetField(t->tiff_file, TIFFTAG_MODENUMBER, 0); */ +extern TIFFFieldArray tiff_fx_field_array; #endif - if (t->output_compression == COMPRESSION_CCITT_T4) - { - TIFFSetField(t->tiff_file, TIFFTAG_T4OPTIONS, t->output_t4_options); - TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); - } - TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width); - TIFFSetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, 1); - TIFFSetField(t->tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); - if (t->output_compression == COMPRESSION_CCITT_T4 - || - t->output_compression == COMPRESSION_CCITT_T6) - { - TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); - } - else - { - TIFFSetField(t->tiff_file, - TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(t->tiff_file, 0)); - } - TIFFSetField(t->tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); - TIFFSetField(t->tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); - - x_resolution = s->x_resolution/100.0f; - y_resolution = s->y_resolution/100.0f; - /* Metric seems the sane thing to use in the 21st century, but a lot of lousy software - gets FAX resolutions wrong, and more get it wrong using metric than using inches. */ -#if 0 - TIFFSetField(t->tiff_file, TIFFTAG_XRESOLUTION, x_resolution); - TIFFSetField(t->tiff_file, TIFFTAG_YRESOLUTION, y_resolution); - resunit = RESUNIT_CENTIMETER; - TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit); -#else - TIFFSetField(t->tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*CM_PER_INCH + 0.5f)); - TIFFSetField(t->tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*CM_PER_INCH + 0.5f)); - resunit = RESUNIT_INCH; - TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit); -#endif - /* TODO: add the version of spandsp */ - TIFFSetField(t->tiff_file, TIFFTAG_SOFTWARE, "Spandsp " SPANDSP_RELEASE_DATETIME_STRING); - if (gethostname(buf, sizeof(buf)) == 0) - TIFFSetField(t->tiff_file, TIFFTAG_HOSTCOMPUTER, buf); - -#if defined(TIFFTAG_FAXDCS) - if (t->dcs) - TIFFSetField(t->tiff_file, TIFFTAG_FAXDCS, t->dcs); -#endif - if (t->sub_address) - TIFFSetField(t->tiff_file, TIFFTAG_FAXSUBADDRESS, t->sub_address); - if (t->far_ident) - TIFFSetField(t->tiff_file, TIFFTAG_IMAGEDESCRIPTION, t->far_ident); - if (t->vendor) - TIFFSetField(t->tiff_file, TIFFTAG_MAKE, t->vendor); - if (t->model) - TIFFSetField(t->tiff_file, TIFFTAG_MODEL, t->model); - - time(&now); - tm = localtime(&now); - sprintf(buf, - "%4d/%02d/%02d %02d:%02d:%02d", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); - TIFFSetField(t->tiff_file, TIFFTAG_DATETIME, buf); - TIFFSetField(t->tiff_file, TIFFTAG_FAXRECVTIME, now - s->page_start_time); - - TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, s->image_length); - /* Set the total pages to 1. For any one page document we will get this - right. For multi-page documents we will need to come back and fill in - the right answer when we know it. */ - TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, s->current_page++, 1); - s->tiff.pages_in_file = s->current_page; - if (t->output_compression == COMPRESSION_CCITT_T4) - { - if (s->t4_t6_rx.bad_rows) - { - TIFFSetField(t->tiff_file, TIFFTAG_BADFAXLINES, s->t4_t6_rx.bad_rows); - TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED); - TIFFSetField(t->tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s->t4_t6_rx.longest_bad_row_run); - } - else - { - TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); - } - } - TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int open_tiff_output_file(t4_state_t *s, const char *file) -{ - if ((s->tiff.tiff_file = TIFFOpen(file, "w")) == NULL) - return -1; - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static void write_tiff_image(t4_state_t *s) -{ - /* Set up the TIFF directory info... */ - set_tiff_directory_info(s); - /* ..and then write the image... */ - if (TIFFWriteEncodedStrip(s->tiff.tiff_file, 0, s->image_buffer, s->image_length*s->bytes_per_row) < 0) - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", s->tiff.file); - /* ...then the directory entry, and libtiff is happy. */ - TIFFWriteDirectory(s->tiff.tiff_file); -} -/*- End of function --------------------------------------------------------*/ - -static int close_tiff_output_file(t4_state_t *s) -{ - int i; - t4_tiff_state_t *t; - - t = &s->tiff; - /* Perform any operations needed to tidy up a written TIFF file before - closure. */ - if (s->current_page > 1) - { - /* We need to edit the TIFF directories. Until now we did not know - the total page count, so the TIFF file currently says one. Now we - need to set the correct total page count associated with each page. */ - for (i = 0; i < s->current_page; i++) - { - TIFFSetDirectory(t->tiff_file, (tdir_t) i); - TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, i, s->current_page); - TIFFWriteDirectory(t->tiff_file); - } - } - TIFFClose(t->tiff_file); - t->tiff_file = NULL; - if (t->file) - { - /* Try not to leave a file behind, if we didn't receive any pages to - put in it. */ - if (s->current_page == 0) - remove(t->file); - free((char *) t->file); - t->file = NULL; - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -#else - -static int set_tiff_directory_info(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int get_tiff_directory_info(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int test_tiff_directory_info(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int open_tiff_input_file(t4_state_t *s, const char *file) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int read_tiff_image(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int close_tiff_input_file(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int open_tiff_output_file(t4_state_t *s, const char *file) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static void write_tiff_image(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int close_tiff_output_file(t4_state_t *s) -{ - return 0; -} -/*- End of function --------------------------------------------------------*/ -#endif - -static void update_row_bit_info(t4_state_t *s) -{ - if (s->row_bits > s->max_row_bits) - s->max_row_bits = s->row_bits; - if (s->row_bits < s->min_row_bits) - s->min_row_bits = s->row_bits; - s->row_bits = 0; -} -/*- End of function --------------------------------------------------------*/ - -#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__powerpc__) -static __inline__ int run_length(unsigned int bits) -{ - return 7 - top_bit(bits); -} -/*- End of function --------------------------------------------------------*/ -#else -static __inline__ int run_length(unsigned int bits) -{ - static const uint8_t run_len[256] = - { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0F */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1F */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2F */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xAF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 - 0xBF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xCF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xDF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0 - 0xEF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xF0 - 0xFF */ - }; - - return run_len[bits]; -} -/*- End of function --------------------------------------------------------*/ -#endif - -static int free_buffers(t4_state_t *s) -{ - if (s->image_buffer) - { - free(s->image_buffer); - s->image_buffer = NULL; - s->image_buffer_size = 0; - } - if (s->cur_runs) - { - free(s->cur_runs); - s->cur_runs = NULL; - } - if (s->ref_runs) - { - free(s->ref_runs); - s->ref_runs = NULL; - } - if (s->row_buf) - { - free(s->row_buf); - s->row_buf = NULL; - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static __inline__ void add_run_to_row(t4_state_t *s) -{ - if (s->t4_t6_rx.run_length >= 0) - { - s->row_len += s->t4_t6_rx.run_length; - /* Don't allow rows to grow too long, and overflow the buffers */ - if (s->row_len <= s->image_width) - s->cur_runs[s->t4_t6_rx.a_cursor++] = s->t4_t6_rx.run_length; - } - s->t4_t6_rx.run_length = 0; -} -/*- End of function --------------------------------------------------------*/ - -static int put_decoded_row(t4_state_t *s) -{ - static const int msbmask[9] = - { - 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff - }; - uint8_t *t; - uint32_t i; - uint32_t *p; - int fudge; - int row_starts_at; - int x; - int j; - - if (s->t4_t6_rx.run_length) - add_run_to_row(s); -#if defined(T4_STATE_DEBUGGING) - /* Dump the runs of black and white for analysis */ - { - int total; - - total = 0; - for (x = 0; x < s->t4_t6_rx.b_cursor; x++) - total += s->ref_runs[x]; - printf("Ref (%d)", total); - for (x = 0; x < s->t4_t6_rx.b_cursor; x++) - printf(" %" PRIu32, s->ref_runs[x]); - printf("\n"); - total = 0; - for (x = 0; x < s->t4_t6_rx.a_cursor; x++) - total += s->cur_runs[x]; - printf("Cur (%d)", total); - for (x = 0; x < s->t4_t6_rx.a_cursor; x++) - printf(" %" PRIu32, s->cur_runs[x]); - printf("\n"); - } -#endif - row_starts_at = s->image_size; - /* Make sure there is enough room for another row */ - if (s->image_size + s->bytes_per_row >= s->image_buffer_size) - { - if ((t = realloc(s->image_buffer, s->image_buffer_size + 100*s->bytes_per_row)) == NULL) - return -1; - s->image_buffer_size += 100*s->bytes_per_row; - s->image_buffer = t; - } - if (s->row_len == s->image_width) - { - STATE_TRACE("%d Good row - %d %s\n", s->image_length, s->row_len, (s->row_is_2d) ? "2D" : "1D"); - if (s->t4_t6_rx.curr_bad_row_run) - { - if (s->t4_t6_rx.curr_bad_row_run > s->t4_t6_rx.longest_bad_row_run) - s->t4_t6_rx.longest_bad_row_run = s->t4_t6_rx.curr_bad_row_run; - s->t4_t6_rx.curr_bad_row_run = 0; - } - /* Convert the runs to a bit image of the row */ - /* White/black/white... runs, always starting with white. That means the first run could be - zero length. */ - for (x = 0, fudge = 0; x < s->t4_t6_rx.a_cursor; x++, fudge ^= 0xFF) - { - i = s->cur_runs[x]; - if ((int) i >= s->tx_bits) - { - s->tx_bitstream = (s->tx_bitstream << s->tx_bits) | (msbmask[s->tx_bits] & fudge); - for (i += (8 - s->tx_bits); i >= 8; i -= 8) - { - s->tx_bits = 8; - s->image_buffer[s->image_size++] = (uint8_t) s->tx_bitstream; - s->tx_bitstream = fudge; - } - } - s->tx_bitstream = (s->tx_bitstream << i) | (msbmask[i] & fudge); - s->tx_bits -= i; - } - s->image_length++; - } - else - { - STATE_TRACE("%d Bad row - %d %s\n", s->image_length, s->row_len, (s->row_is_2d) ? "2D" : "1D"); - /* Try to clean up the bad runs, and produce something reasonable as the reference - row for the next row. Use a copy of the previous good row as the actual current - row. If the row only fell apart near the end, reusing it might be the best - solution. */ - for (j = 0, fudge = 0; j < s->t4_t6_rx.a_cursor && fudge < s->image_width; j++) - fudge += s->cur_runs[j]; - if (fudge < s->image_width) - { - /* Try to pad with white, and avoid black, to minimise mess on the image. */ - if ((s->t4_t6_rx.a_cursor & 1)) - { - /* We currently finish in white. We could extend that, but it is probably of - the right length. Changing it would only further mess up what happens in the - next row. It seems better to add a black spot, and an extra white run. */ - s->cur_runs[s->t4_t6_rx.a_cursor++] = 1; - fudge++; - if (fudge < s->image_width) - s->cur_runs[s->t4_t6_rx.a_cursor++] = s->image_width - fudge; - } - else - { - /* We currently finish on black, so we add an extra white run to fill out the line. */ - s->cur_runs[s->t4_t6_rx.a_cursor++] = s->image_width - fudge; - } - } - else - { - /* Trim the last element to align with the proper image width */ - s->cur_runs[s->t4_t6_rx.a_cursor] += (s->image_width - fudge); - } - /* Ensure there is a previous line to copy from. */ - if (s->image_size != s->t4_t6_rx.last_row_starts_at) - { - /* Copy the previous row over this one */ - memcpy(s->image_buffer + s->image_size, s->image_buffer + s->t4_t6_rx.last_row_starts_at, s->bytes_per_row); - s->image_size += s->bytes_per_row; - s->image_length++; - } - s->t4_t6_rx.bad_rows++; - s->t4_t6_rx.curr_bad_row_run++; - } - - /* Pad the row as it becomes the reference row, so there are no odd runs to pick up if we - step off the end of the list. */ - s->cur_runs[s->t4_t6_rx.a_cursor] = 0; - s->cur_runs[s->t4_t6_rx.a_cursor + 1] = 0; - - /* Prepare the buffers for the next row. */ - s->t4_t6_rx.last_row_starts_at = row_starts_at; - /* Swap the buffers */ - p = s->cur_runs; - s->cur_runs = s->ref_runs; - s->ref_runs = p; - - s->t4_t6_rx.b_cursor = 1; - s->t4_t6_rx.a_cursor = 0; - s->t4_t6_rx.b1 = s->ref_runs[0]; - s->t4_t6_rx.a0 = 0; - - s->t4_t6_rx.run_length = 0; - - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_end_page(t4_state_t *s) -{ - int row; - int i; - - if (s->line_encoding == T4_COMPRESSION_ITU_T6) - { - /* Push enough zeros through the decoder to flush out any remaining codes */ - for (i = 0; i < 13; i++) - t4_rx_put_bit(s, 0); - } - if (s->t4_t6_rx.curr_bad_row_run) - { - if (s->t4_t6_rx.curr_bad_row_run > s->t4_t6_rx.longest_bad_row_run) - s->t4_t6_rx.longest_bad_row_run = s->t4_t6_rx.curr_bad_row_run; - s->t4_t6_rx.curr_bad_row_run = 0; - } - - if (s->image_size == 0) - return -1; - - if (s->t4_t6_rx.row_write_handler) - { - for (row = 0; row < s->image_length; row++) - { - if (s->t4_t6_rx.row_write_handler(s->t4_t6_rx.row_write_user_data, s->image_buffer + row*s->bytes_per_row, s->bytes_per_row) < 0) - { - span_log(&s->logging, SPAN_LOG_WARNING, "Write error at row %d.\n", row); - break; - } - } - /* Write a blank row to indicate the end of the image. */ - if (s->t4_t6_rx.row_write_handler(s->t4_t6_rx.row_write_user_data, NULL, 0) < 0) - span_log(&s->logging, SPAN_LOG_WARNING, "Write error at row %d.\n", row); - } - else - { - write_tiff_image(s); - } - s->t4_t6_rx.rx_bits = 0; - s->t4_t6_rx.rx_skip_bits = 0; - s->t4_t6_rx.rx_bitstream = 0; - s->t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; - - s->image_size = 0; - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static __inline__ void drop_rx_bits(t4_state_t *s, int bits) -{ - /* Only remove one bit right now. The rest need to be removed step by step, - checking for a misaligned EOL along the way. This is time consuming, but - if we don't do it a single bit error can severely damage an image. */ - s->row_bits += bits; - s->t4_t6_rx.rx_skip_bits += (bits - 1); - s->t4_t6_rx.rx_bits--; - s->t4_t6_rx.rx_bitstream >>= 1; -} -/*- End of function --------------------------------------------------------*/ - -static __inline__ void force_drop_rx_bits(t4_state_t *s, int bits) -{ - /* This should only be called to drop the bits of an EOL, as that is the - only place where it is safe to drop them all at once. */ - s->row_bits += bits; - s->t4_t6_rx.rx_skip_bits = 0; - s->t4_t6_rx.rx_bits -= bits; - s->t4_t6_rx.rx_bitstream >>= bits; -} -/*- End of function --------------------------------------------------------*/ - -static int rx_put_bits(t4_state_t *s, uint32_t bit_string, int quantity) -{ - int bits; - int old_a0; - - /* We decompress bit by bit, as the data stream is received. We need to - scan continuously for EOLs, so we might as well work this way. */ - s->line_image_size += quantity; - s->t4_t6_rx.rx_bitstream |= (bit_string << s->t4_t6_rx.rx_bits); - /* The longest item we need to scan for is 13 bits long (a 2D EOL), so we - need a minimum of 13 bits in the buffer to proceed with any bit stream - analysis. */ - if ((s->t4_t6_rx.rx_bits += quantity) < 13) - return FALSE; - if (s->t4_t6_rx.consecutive_eols) - { - /* Check if the image has already terminated. */ - if (s->t4_t6_rx.consecutive_eols >= EOLS_TO_END_ANY_RX_PAGE) - return TRUE; - /* Check if the image hasn't even started. */ - if (s->t4_t6_rx.consecutive_eols < 0) - { - /* We are waiting for the very first EOL (1D or 2D only). */ - /* We need to take this bit by bit, as the EOL could be anywhere, - and any junk could preceed it. */ - while ((s->t4_t6_rx.rx_bitstream & 0xFFF) != 0x800) - { - s->t4_t6_rx.rx_bitstream >>= 1; - if (--s->t4_t6_rx.rx_bits < 13) - return FALSE; - } - /* We have an EOL, so now the page begins and we can proceed to - process the bit stream as image data. */ - s->t4_t6_rx.consecutive_eols = 0; - if (s->line_encoding == T4_COMPRESSION_ITU_T4_1D) - { - s->row_is_2d = FALSE; - force_drop_rx_bits(s, 12); - } - else - { - s->row_is_2d = !(s->t4_t6_rx.rx_bitstream & 0x1000); - force_drop_rx_bits(s, 13); - } - } - } - - while (s->t4_t6_rx.rx_bits >= 13) - { - /* We need to check for EOLs bit by bit through the whole stream. If - we just try looking between code words, we will miss an EOL when a bit - error has throw the code words completely out of step. The can mean - recovery takes many lines, and the image gets really messed up. */ - /* Although EOLs are not inserted at the end of each row of a T.6 image, - they are still perfectly valid, and can terminate an image. */ - if ((s->t4_t6_rx.rx_bitstream & 0x0FFF) == 0x0800) - { - STATE_TRACE("EOL\n"); - if (s->row_len == 0) - { - /* A zero length row - i.e. 2 consecutive EOLs - is distinctly - the end of page condition. That's all we actually get on a - T.6 page. However, there are a minimum of 6 EOLs at the end of - any T.4 page. We can look for more than 2 EOLs in case bit - errors simulate the end of page condition at the wrong point. - Such robust checking is irrelevant for a T.6 page, as it should - be error free. */ - /* Note that for a T.6 page we should get here on the very first - EOL, as the row length should be zero at that point. Therefore - we should count up both EOLs, unless there is some bogus partial - row ahead of them. */ - s->t4_t6_rx.consecutive_eols++; - if (s->line_encoding == T4_COMPRESSION_ITU_T6) - { - if (s->t4_t6_rx.consecutive_eols >= EOLS_TO_END_T6_RX_PAGE) - { - s->t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; - return TRUE; - } - } - else - { - if (s->t4_t6_rx.consecutive_eols >= EOLS_TO_END_T4_RX_PAGE) - { - s->t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; - return TRUE; - } - } - } - else - { - /* The EOLs are not back-to-back, so they are not part of the - end of page condition. */ - if (s->t4_t6_rx.run_length > 0) - add_run_to_row(s); - s->t4_t6_rx.consecutive_eols = 0; - if (put_decoded_row(s)) - return TRUE; - update_row_bit_info(s); - } - if (s->line_encoding == T4_COMPRESSION_ITU_T4_2D) - { - s->row_is_2d = !(s->t4_t6_rx.rx_bitstream & 0x1000); - force_drop_rx_bits(s, 13); - } - else - { - force_drop_rx_bits(s, 12); - } - s->t4_t6_rx.its_black = FALSE; - s->t4_t6_rx.black_white = 0; - s->t4_t6_rx.run_length = 0; - s->row_len = 0; - continue; - } - if (s->t4_t6_rx.rx_skip_bits) - { - /* We are clearing out the remaining bits of the last code word we - absorbed. */ - s->t4_t6_rx.rx_skip_bits--; - s->t4_t6_rx.rx_bits--; - s->t4_t6_rx.rx_bitstream >>= 1; - continue; - } - if (s->row_is_2d && s->t4_t6_rx.black_white == 0) - { - bits = s->t4_t6_rx.rx_bitstream & 0x7F; - STATE_TRACE("State %d, %d - ", - t4_2d_table[bits].state, - t4_2d_table[bits].width); - if (s->row_len >= s->image_width) - { - drop_rx_bits(s, t4_2d_table[bits].width); - continue; - } - if (s->t4_t6_rx.a_cursor) - { - /* Move past a0, always staying on the current colour */ - for ( ; s->t4_t6_rx.b1 <= s->t4_t6_rx.a0; s->t4_t6_rx.b_cursor += 2) - s->t4_t6_rx.b1 += (s->ref_runs[s->t4_t6_rx.b_cursor] + s->ref_runs[s->t4_t6_rx.b_cursor + 1]); - } - switch (t4_2d_table[bits].state) - { - case S_Horiz: - STATE_TRACE("Horiz %d %d %d\n", - s->image_width, - s->t4_t6_rx.a0, - s->t4_t6_rx.a_cursor); - /* We now need to extract a white/black or black/white pair of runs, using the 1D - method. If the first of the pair takes us exactly to the end of the row, there - should still be a zero length element for the second of the pair. */ - s->t4_t6_rx.its_black = s->t4_t6_rx.a_cursor & 1; - s->t4_t6_rx.black_white = 2; - break; - case S_Vert: - STATE_TRACE("Vert[%d] %d %d %d %d\n", - t4_2d_table[bits].param, - s->image_width, - s->t4_t6_rx.a0, - s->t4_t6_rx.b1, - s->t4_t6_rx.run_length); - old_a0 = s->t4_t6_rx.a0; - s->t4_t6_rx.a0 = s->t4_t6_rx.b1 + t4_2d_table[bits].param; - /* We need to check if a bad or malicious image is failing to move forward along the row. - Going back is obviously bad. We also need to avoid a stall on the spot, except for the - special case of the start of the row. Zero movement as the very first element in the - row is perfectly normal. */ - if (s->t4_t6_rx.a0 <= old_a0) - { - if (s->t4_t6_rx.a0 < old_a0 || s->t4_t6_rx.b_cursor > 1) - { - /* Undo the update we just started, and carry on as if this code does not exist */ - /* TODO: we really should record that something wasn't right at this point. */ - s->t4_t6_rx.a0 = old_a0; - break; - } - } - s->t4_t6_rx.run_length += (s->t4_t6_rx.a0 - old_a0); - add_run_to_row(s); - /* We need to move one step in one direction or the other, to change to the - opposite colour */ - if (t4_2d_table[bits].param >= 0) - { - s->t4_t6_rx.b1 += s->ref_runs[s->t4_t6_rx.b_cursor++]; - } - else - { - if (s->t4_t6_rx.b_cursor) - s->t4_t6_rx.b1 -= s->ref_runs[--s->t4_t6_rx.b_cursor]; - } - break; - case S_Pass: - STATE_TRACE("Pass %d %d %d %d %d\n", - s->image_width, - s->t4_t6_rx.a0, - s->t4_t6_rx.b1, - s->ref_runs[s->t4_t6_rx.b_cursor], - s->ref_runs[s->t4_t6_rx.b_cursor + 1]); - s->t4_t6_rx.b1 += s->ref_runs[s->t4_t6_rx.b_cursor++]; - old_a0 = s->t4_t6_rx.a0; - s->t4_t6_rx.a0 = s->t4_t6_rx.b1; - s->t4_t6_rx.run_length += (s->t4_t6_rx.a0 - old_a0); - s->t4_t6_rx.b1 += s->ref_runs[s->t4_t6_rx.b_cursor++]; - break; - case S_Ext: - /* We do not currently handle any kind of extension */ - STATE_TRACE("Ext %d %d %d 0x%x\n", - s->image_width, - s->t4_t6_rx.a0, - ((s->t4_t6_rx.rx_bitstream >> t4_2d_table[bits].width) & 0x7), - s->t4_t6_rx.rx_bitstream); - /* TODO: The uncompressed option should be implemented. */ - break; - case S_Null: - STATE_TRACE("Null\n"); - break; - default: - STATE_TRACE("Unexpected T.4 state\n"); - span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected T.4 state %d\n", t4_2d_table[bits].state); - break; - } - drop_rx_bits(s, t4_2d_table[bits].width); - } - else - { - if (s->t4_t6_rx.its_black) - { - bits = s->t4_t6_rx.rx_bitstream & 0x1FFF; - STATE_TRACE("State %d, %d - Black %d %d %d\n", - t4_1d_black_table[bits].state, - t4_1d_black_table[bits].width, - s->image_width, - s->t4_t6_rx.a0, - t4_1d_black_table[bits].param); - switch (t4_1d_black_table[bits].state) - { - case S_MakeUpB: - case S_MakeUp: - s->t4_t6_rx.run_length += t4_1d_black_table[bits].param; - s->t4_t6_rx.a0 += t4_1d_black_table[bits].param; - break; - case S_TermB: - s->t4_t6_rx.its_black = FALSE; - if (s->row_len < s->image_width) - { - s->t4_t6_rx.run_length += t4_1d_black_table[bits].param; - s->t4_t6_rx.a0 += t4_1d_black_table[bits].param; - add_run_to_row(s); - } - if (s->t4_t6_rx.black_white) - s->t4_t6_rx.black_white--; - break; - default: - /* Bad black */ - s->t4_t6_rx.black_white = 0; - break; - } - drop_rx_bits(s, t4_1d_black_table[bits].width); - } - else - { - bits = s->t4_t6_rx.rx_bitstream & 0xFFF; - STATE_TRACE("State %d, %d - White %d %d %d\n", - t4_1d_white_table[bits].state, - t4_1d_white_table[bits].width, - s->image_width, - s->t4_t6_rx.a0, - t4_1d_white_table[bits].param); - switch (t4_1d_white_table[bits].state) - { - case S_MakeUpW: - case S_MakeUp: - s->t4_t6_rx.run_length += t4_1d_white_table[bits].param; - s->t4_t6_rx.a0 += t4_1d_white_table[bits].param; - break; - case S_TermW: - s->t4_t6_rx.its_black = TRUE; - if (s->row_len < s->image_width) - { - s->t4_t6_rx.run_length += t4_1d_white_table[bits].param; - s->t4_t6_rx.a0 += t4_1d_white_table[bits].param; - add_run_to_row(s); - } - if (s->t4_t6_rx.black_white) - s->t4_t6_rx.black_white--; - break; - default: - /* Bad white */ - s->t4_t6_rx.black_white = 0; - break; - } - drop_rx_bits(s, t4_1d_white_table[bits].width); - } - } - if (s->t4_t6_rx.a0 >= s->image_width) - s->t4_t6_rx.a0 = s->image_width - 1; - - if (s->line_encoding == T4_COMPRESSION_ITU_T6) - { - /* T.6 has no EOL markers. We sense the end of a line by its length alone. */ - /* The last test here is a backstop protection, so a corrupt image cannot - cause us to do bad things. Bad encoders have actually been seen, which - demand such protection. */ - if (s->t4_t6_rx.black_white == 0 && s->row_len >= s->image_width) - { - STATE_TRACE("EOL T.6\n"); - if (s->t4_t6_rx.run_length > 0) - add_run_to_row(s); - update_row_bit_info(s); - if (put_decoded_row(s)) - return TRUE; - s->t4_t6_rx.its_black = FALSE; - s->t4_t6_rx.black_white = 0; - s->t4_t6_rx.run_length = 0; - s->row_len = 0; - } - } - } - return FALSE; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_put_bit(t4_state_t *s, int bit) -{ - return rx_put_bits(s, bit & 1, 1); -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_put_byte(t4_state_t *s, uint8_t byte) -{ - return rx_put_bits(s, byte & 0xFF, 8); -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_put_chunk(t4_state_t *s, const uint8_t buf[], int len) -{ - int i; - uint8_t byte; - - for (i = 0; i < len; i++) - { - byte = buf[i]; - if (rx_put_bits(s, byte & 0xFF, 8)) - return TRUE; - } - return FALSE; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_state_t *s, t4_row_write_handler_t handler, void *user_data) -{ - s->t4_t6_rx.row_write_handler = handler; - s->t4_t6_rx.row_write_user_data = user_data; - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(t4_state_t *) t4_rx_init(t4_state_t *s, const char *file, int output_encoding) -{ - if (s == NULL) - { - if ((s = (t4_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; - } - memset(s, 0, sizeof(*s)); -#if defined(SPANDSP_SUPPORT_TIFF_FX) - TIFF_FX_init(); -#endif - span_log_init(&s->logging, SPAN_LOG_NONE, NULL); - span_log_set_protocol(&s->logging, "T.4"); - s->rx = TRUE; - - span_log(&s->logging, SPAN_LOG_FLOW, "Start rx document\n"); - - if (open_tiff_output_file(s, file) < 0) - return NULL; - - /* Save the file name for logging reports. */ - s->tiff.file = strdup(file); - /* Only provide for one form of coding throughout the file, even though the - coding on the wire could change between pages. */ - switch (output_encoding) - { - case T4_COMPRESSION_ITU_T4_1D: - s->tiff.output_compression = COMPRESSION_CCITT_T4; - s->tiff.output_t4_options = GROUP3OPT_FILLBITS; - break; - case T4_COMPRESSION_ITU_T4_2D: - s->tiff.output_compression = COMPRESSION_CCITT_T4; - s->tiff.output_t4_options = GROUP3OPT_FILLBITS | GROUP3OPT_2DENCODING; - break; - case T4_COMPRESSION_ITU_T6: - s->tiff.output_compression = COMPRESSION_CCITT_T6; - s->tiff.output_t4_options = 0; - break; - } - - /* Until we have a valid figure for the bytes per row, we need it to be set to a suitable - value to ensure it will be seen as changing when the real value is used. */ - s->bytes_per_row = 0; - - s->current_page = 0; - s->tiff.pages_in_file = 0; - s->tiff.start_page = 0; - s->tiff.stop_page = INT_MAX; - - s->image_buffer = NULL; - s->image_buffer_size = 0; - - /* Set some default values */ - s->x_resolution = T4_X_RESOLUTION_R8; - s->y_resolution = T4_Y_RESOLUTION_FINE; - s->image_width = T4_WIDTH_R8_A4; - - return s; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_start_page(t4_state_t *s) -{ - int bytes_per_row; - int run_space; - uint32_t *bufptr; - - span_log(&s->logging, SPAN_LOG_FLOW, "Start rx page - compression %d\n", s->line_encoding); - if (s->tiff.tiff_file == NULL) - return -1; - - /* Calculate the scanline/tile width. */ - bytes_per_row = (s->image_width + 7)/8; - run_space = (s->image_width + 4)*sizeof(uint32_t); - if (bytes_per_row != s->bytes_per_row) - { - /* Allocate the space required for decoding the new row length. */ - s->bytes_per_row = bytes_per_row; - if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) - return -1; - s->cur_runs = bufptr; - if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL) - return -1; - s->ref_runs = bufptr; - } - memset(s->cur_runs, 0, run_space); - memset(s->ref_runs, 0, run_space); - - s->t4_t6_rx.rx_bits = 0; - s->t4_t6_rx.rx_skip_bits = 0; - s->t4_t6_rx.rx_bitstream = 0; - s->row_bits = 0; - s->min_row_bits = INT_MAX; - s->max_row_bits = 0; - - s->row_is_2d = (s->line_encoding == T4_COMPRESSION_ITU_T6); - /* We start at -1 EOLs for 1D and 2D decoding, as an indication we are waiting for the - first EOL. T.6 coding starts without any preamble. */ - s->t4_t6_rx.consecutive_eols = (s->line_encoding == T4_COMPRESSION_ITU_T6) ? 0 : -1; - - s->t4_t6_rx.bad_rows = 0; - s->t4_t6_rx.longest_bad_row_run = 0; - s->t4_t6_rx.curr_bad_row_run = 0; - s->image_length = 0; - s->tx_bitstream = 0; - s->tx_bits = 8; - s->image_size = 0; - s->line_image_size = 0; - s->t4_t6_rx.last_row_starts_at = 0; - - s->row_len = 0; - s->t4_t6_rx.its_black = FALSE; - s->t4_t6_rx.black_white = 0; - - /* Initialise the reference line to all white */ - s->ref_runs[0] = - s->ref_runs[1] = - s->ref_runs[2] = - s->ref_runs[3] = s->image_width; - - s->t4_t6_rx.b_cursor = 1; - s->t4_t6_rx.a_cursor = 0; - s->t4_t6_rx.b1 = s->ref_runs[0]; - s->t4_t6_rx.a0 = 0; - - s->t4_t6_rx.run_length = 0; - - time (&s->page_start_time); - - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_release(t4_state_t *s) -{ - if (!s->rx) - return -1; - if (s->tiff.tiff_file) - close_tiff_output_file(s); - free_buffers(s); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_rx_free(t4_state_t *s) -{ - int ret; - - ret = t4_rx_release(s); - free(s); - return ret; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_rx_encoding(t4_state_t *s, int encoding) -{ - s->line_encoding = encoding; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_image_width(t4_state_t *s, int width) -{ - s->image_width = width; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_y_resolution(t4_state_t *s, int resolution) -{ - s->y_resolution = resolution; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_x_resolution(t4_state_t *s, int resolution) -{ - s->x_resolution = resolution; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_dcs(t4_state_t *s, const char *dcs) -{ - s->tiff.dcs = (dcs && dcs[0]) ? dcs : NULL; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_sub_address(t4_state_t *s, const char *sub_address) -{ - s->tiff.sub_address = (sub_address && sub_address[0]) ? sub_address : NULL; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_far_ident(t4_state_t *s, const char *ident) -{ - s->tiff.far_ident = (ident && ident[0]) ? ident : NULL; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_vendor(t4_state_t *s, const char *vendor) -{ - s->tiff.vendor = vendor; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_set_model(t4_state_t *s, const char *model) -{ - s->tiff.model = model; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t) -{ - t->pages_transferred = s->current_page - s->tiff.start_page; - t->pages_in_file = s->tiff.pages_in_file; - t->width = s->image_width; - t->length = s->image_length; - t->bad_rows = s->t4_t6_rx.bad_rows; - t->longest_bad_row_run = s->t4_t6_rx.longest_bad_row_run; - t->x_resolution = s->x_resolution; - t->y_resolution = s->y_resolution; - t->encoding = s->line_encoding; - t->line_image_size = s->line_image_size/8; -} -/*- End of function --------------------------------------------------------*/ SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding) { @@ -1265,4 +113,681 @@ SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding) return "???"; } /*- End of function --------------------------------------------------------*/ + +static int set_tiff_directory_info(t4_rx_state_t *s) +{ + time_t now; + struct tm *tm; + char buf[256 + 1]; + uint16_t resunit; + float x_resolution; + float y_resolution; + t4_rx_tiff_state_t *t; + int32_t output_compression; + int32_t output_t4_options; + + t = &s->tiff; + /* Prepare the directory entry fully before writing the image, or libtiff complains */ + switch (t->output_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + default: + output_compression = COMPRESSION_CCITT_T4; + output_t4_options = GROUP3OPT_FILLBITS; + break; + case T4_COMPRESSION_ITU_T4_2D: + output_compression = COMPRESSION_CCITT_T4; + output_t4_options = GROUP3OPT_FILLBITS | GROUP3OPT_2DENCODING; + break; + case T4_COMPRESSION_ITU_T6: + output_compression = COMPRESSION_CCITT_T6; + break; + case T4_COMPRESSION_ITU_T85: + output_compression = COMPRESSION_T85; + break; + } + + TIFFSetField(t->tiff_file, TIFFTAG_COMPRESSION, output_compression); + switch (output_compression) + { + case COMPRESSION_CCITT_T4: + TIFFSetField(t->tiff_file, TIFFTAG_T4OPTIONS, output_t4_options); + TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); + break; + case COMPRESSION_CCITT_T6: + TIFFSetField(t->tiff_file, TIFFTAG_T6OPTIONS, 0); + TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); + break; + case COMPRESSION_T85: + TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); + break; + default: + TIFFSetField(t->tiff_file, + TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(t->tiff_file, 0)); + break; + } +#if defined(SPANDSP_SUPPORT_TIFF_FX) + TIFFSetField(t->tiff_file, TIFFTAG_PROFILETYPE, PROFILETYPE_G3_FAX); + TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, FAXPROFILE_S); + TIFFSetField(t->tiff_file, TIFFTAG_CODINGMETHODS, CODINGMETHODS_T4_1D | CODINGMETHODS_T4_2D | CODINGMETHODS_T6); + TIFFSetField(t->tiff_file, TIFFTAG_VERSIONYEAR, "1998"); + /* TIFFSetField(t->tiff_file, TIFFTAG_MODENUMBER, 0); */ +#endif + TIFFSetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(t->tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(t->tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); + TIFFSetField(t->tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); + /* TIFFTAG_STRIPBYTECOUNTS and TIFFTAG_STRIPOFFSETS are added automatically */ + + x_resolution = s->metadata.x_resolution/100.0f; + y_resolution = s->metadata.y_resolution/100.0f; + /* Metric seems the sane thing to use in the 21st century, but a lot of lousy software + gets FAX resolutions wrong, and more get it wrong using metric than using inches. */ +#if 0 + TIFFSetField(t->tiff_file, TIFFTAG_XRESOLUTION, x_resolution); + TIFFSetField(t->tiff_file, TIFFTAG_YRESOLUTION, y_resolution); + resunit = RESUNIT_CENTIMETER; + TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit); +#else + TIFFSetField(t->tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*CM_PER_INCH + 0.5f)); + TIFFSetField(t->tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*CM_PER_INCH + 0.5f)); + resunit = RESUNIT_INCH; + TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit); +#endif + TIFFSetField(t->tiff_file, TIFFTAG_SOFTWARE, "Spandsp " SPANDSP_RELEASE_DATETIME_STRING); + if (gethostname(buf, sizeof(buf)) == 0) + TIFFSetField(t->tiff_file, TIFFTAG_HOSTCOMPUTER, buf); + +#if defined(TIFFTAG_FAXDCS) + if (s->metadata.dcs) + TIFFSetField(t->tiff_file, TIFFTAG_FAXDCS, s->metadata.dcs); +#endif + if (s->metadata.sub_address) + TIFFSetField(t->tiff_file, TIFFTAG_FAXSUBADDRESS, s->metadata.sub_address); + if (s->metadata.far_ident) + TIFFSetField(t->tiff_file, TIFFTAG_IMAGEDESCRIPTION, s->metadata.far_ident); + if (s->metadata.vendor) + TIFFSetField(t->tiff_file, TIFFTAG_MAKE, s->metadata.vendor); + if (s->metadata.model) + TIFFSetField(t->tiff_file, TIFFTAG_MODEL, s->metadata.model); + + time(&now); + tm = localtime(&now); + sprintf(buf, + "%4d/%02d/%02d %02d:%02d:%02d", + tm->tm_year + 1900, + tm->tm_mon + 1, + tm->tm_mday, + tm->tm_hour, + tm->tm_min, + tm->tm_sec); + TIFFSetField(t->tiff_file, TIFFTAG_DATETIME, buf); + TIFFSetField(t->tiff_file, TIFFTAG_FAXRECVTIME, now - s->tiff.page_start_time); + + TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width); + /* Set the total pages to 1. For any one page document we will get this + right. For multi-page documents we will need to come back and fill in + the right answer when we know it. */ + TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, s->current_page, 1); + /* TIFF page numbers start from zero, so the number of pages in the file + is always one greater than the highest page number in the file. */ + s->tiff.pages_in_file = s->current_page + 1; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + /* We only get bad row info from pages received in non-ECM mode. */ + if (output_compression == COMPRESSION_CCITT_T4) + { + if (s->decoder.t4_t6.bad_rows) + { + TIFFSetField(t->tiff_file, TIFFTAG_BADFAXLINES, s->decoder.t4_t6.bad_rows); + TIFFSetField(t->tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s->decoder.t4_t6.longest_bad_row_run); + TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED); + } + else + { + TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); + } + } + /* Fall through */ + case T4_COMPRESSION_ITU_T6: + TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, t4_t6_decode_get_image_length(&s->decoder.t4_t6)); + break; + case T4_COMPRESSION_ITU_T42: + TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, t42_decode_get_image_length(&s->decoder.t42)); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, t43_decode_get_image_length(&s->decoder.t43)); + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, t85_decode_get_image_length(&s->decoder.t85)); + break; + } +#if defined(SPANDSP_SUPPORT_TIFF_FX) + if (s->current_page == 0) + { + /* Create a placeholder for the global parameters IFD, to be filled in later */ + TIFFSetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, 0); + } +#endif + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int open_tiff_output_file(t4_rx_state_t *s, const char *file) +{ + if ((s->tiff.tiff_file = TIFFOpen(file, "w")) == NULL) + return -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int write_tiff_image(t4_rx_state_t *s) +{ + t4_rx_tiff_state_t *t; +#if defined(SPANDSP_SUPPORT_TIFF_FX) + uint64_t offset; +#endif + + t = &s->tiff; + if (t->image_buffer == NULL || t->image_size <= 0) + return -1; + /* Set up the TIFF directory info... */ + set_tiff_directory_info(s); + /* ...and then write the image... */ + if (TIFFWriteEncodedStrip(t->tiff_file, 0, t->image_buffer, t->image_size) < 0) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", t->file); + /* ...then the directory entry, and libtiff is happy. */ + if (!TIFFWriteDirectory(t->tiff_file)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page); +#if defined(SPANDSP_SUPPORT_TIFF_FX) + if (s->current_page == 0) + { + if (!TIFFCreateCustomDirectory(t->tiff_file, &tiff_fx_field_array)) + { + TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, PROFILETYPE_G3_FAX); + TIFFSetField(t->tiff_file, TIFFTAG_PROFILETYPE, FAXPROFILE_S); + TIFFSetField(t->tiff_file, TIFFTAG_VERSIONYEAR, "1998"); + + offset = 0; + if (!TIFFWriteCustomDirectory(t->tiff_file, &offset)) + printf("Failed to write custom directory.\n"); + + /* Now go back and patch in the pointer to the new IFD */ + if (!TIFFSetDirectory(t->tiff_file, s->current_page)) + printf("Failed to set directory.\n"); + if (!TIFFSetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, offset)) + printf("Failed to set field.\n"); + if (!TIFFWriteDirectory(t->tiff_file)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page); + } + } +#endif + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int close_tiff_output_file(t4_rx_state_t *s) +{ + int i; + t4_rx_tiff_state_t *t; + + t = &s->tiff; + /* Perform any operations needed to tidy up a written TIFF file before + closure. */ + if (s->current_page > 1) + { + /* We need to edit the TIFF directories. Until now we did not know + the total page count, so the TIFF file currently says one. Now we + need to set the correct total page count associated with each page. */ + for (i = 0; i < s->current_page; i++) + { + if (!TIFFSetDirectory(t->tiff_file, (tdir_t) i)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to set directory to page %d.\n", s->tiff.file, i); + TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, i, s->current_page); + if (!TIFFWriteDirectory(t->tiff_file)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", s->tiff.file, i); + } + } + TIFFClose(t->tiff_file); + t->tiff_file = NULL; + if (s->tiff.file) + { + /* Try not to leave a file behind, if we didn't receive any pages to + put in it. */ + if (s->current_page == 0) + remove(s->tiff.file); + free((char *) s->tiff.file); + } + s->tiff.file = NULL; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static void tiff_rx_release(t4_rx_state_t *s) +{ + if (s->tiff.tiff_file) + close_tiff_output_file(s); + if (s->tiff.image_buffer) + { + free(s->tiff.image_buffer); + s->tiff.image_buffer = NULL; + s->tiff.image_size = 0; + s->tiff.image_buffer_size = 0; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit) +{ + /* We only put bit by bit for T.4-1D and T.4-2D */ + s->line_image_size += 1; + return t4_t6_decode_put_bit(&s->decoder.t4_t6, bit); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_put(t4_rx_state_t *s, const uint8_t buf[], size_t len) +{ + s->line_image_size += 8*len; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_decode_put(&s->decoder.t4_t6, buf, len); + case T4_COMPRESSION_ITU_T42: + return t42_decode_put(&s->decoder.t42, buf, len); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_decode_put(&s->decoder.t43, buf, len); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_decode_put(&s->decoder.t85, buf, len); + } + return T4_DECODE_OK; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_y_resolution(t4_rx_state_t *s, int resolution) +{ + s->metadata.y_resolution = resolution; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_x_resolution(t4_rx_state_t *s, int resolution) +{ + s->metadata.x_resolution = resolution; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_dcs(t4_rx_state_t *s, const char *dcs) +{ + s->metadata.dcs = (dcs && dcs[0]) ? dcs : NULL; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_sub_address(t4_rx_state_t *s, const char *sub_address) +{ + s->metadata.sub_address = (sub_address && sub_address[0]) ? sub_address : NULL; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_far_ident(t4_rx_state_t *s, const char *ident) +{ + s->metadata.far_ident = (ident && ident[0]) ? ident : NULL; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_vendor(t4_rx_state_t *s, const char *vendor) +{ + s->metadata.vendor = vendor; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_model(t4_rx_state_t *s, const char *model) +{ + s->metadata.model = model; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding) +{ + switch (encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + break; + default: + t4_t6_decode_init(&s->decoder.t4_t6, encoding, s->image_width, s->row_handler, s->row_handler_user_data); + break; + } + s->line_encoding = encoding; + return t4_t6_decode_set_encoding(&s->decoder.t4_t6, encoding); + case T4_COMPRESSION_ITU_T42: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T42: + break; + default: + t42_decode_init(&s->decoder.t42, s->row_handler, s->row_handler_user_data); + /* Constrain received images to the maximum width of any FAX. This will + avoid one potential cause of trouble, where a bad received image has + a gigantic dimension that sucks our memory dry. */ + t42_decode_set_image_size_constraints(&s->decoder.t42, T4_WIDTH_1200_A3, 0); + break; + } + s->line_encoding = encoding; + return 0; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T43: + break; + default: + t43_decode_init(&s->decoder.t43, s->row_handler, s->row_handler_user_data); + /* Constrain received images to the maximum width of any FAX. This will + avoid one potential cause of trouble, where a bad received image has + a gigantic dimension that sucks our memory dry. */ + t43_decode_set_image_size_constraints(&s->decoder.t43, T4_WIDTH_1200_A3, 0); + break; + } + s->line_encoding = encoding; + return 0; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + break; + default: + t85_decode_init(&s->decoder.t85, s->row_handler, s->row_handler_user_data); + /* Constrain received images to the maximum width of any FAX. This will + avoid one potential cause of trouble, where a bad received image has + a gigantic dimension that sucks our memory dry. */ + t85_decode_set_image_size_constraints(&s->decoder.t85, T4_WIDTH_1200_A3, 0); + break; + } + s->line_encoding = encoding; + return 0; + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_set_image_width(t4_rx_state_t *s, int width) +{ + s->image_width = width; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_rx_state_t *s, t4_row_write_handler_t handler, void *user_data) +{ + s->row_handler = handler; + s->row_handler_user_data = user_data; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_decode_set_row_write_handler(&s->decoder.t4_t6, handler, user_data); + case T4_COMPRESSION_ITU_T42: + return t42_decode_set_row_write_handler(&s->decoder.t42, handler, user_data); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_decode_set_row_write_handler(&s->decoder.t43, handler, user_data); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_decode_set_row_write_handler(&s->decoder.t85, handler, user_data); + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t) +{ + memset(t, 0, sizeof(*t)); + t->pages_transferred = s->current_page; + t->pages_in_file = s->tiff.pages_in_file; + t->x_resolution = s->metadata.x_resolution; + t->y_resolution = s->metadata.y_resolution; + t->encoding = s->line_encoding; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t->width = t4_t6_decode_get_image_width(&s->decoder.t4_t6); + t->length = t4_t6_decode_get_image_length(&s->decoder.t4_t6); + t->line_image_size = t4_t6_decode_get_compressed_image_size(&s->decoder.t4_t6)/8; + t->bad_rows = s->decoder.t4_t6.bad_rows; + t->longest_bad_row_run = s->decoder.t4_t6.longest_bad_row_run; + break; + case T4_COMPRESSION_ITU_T42: + t->width = t42_decode_get_image_width(&s->decoder.t42); + t->length = t42_decode_get_image_length(&s->decoder.t42); + t->line_image_size = t42_decode_get_compressed_image_size(&s->decoder.t42)/8; + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t->width = t43_decode_get_image_width(&s->decoder.t43); + t->length = t43_decode_get_image_length(&s->decoder.t43); + t->line_image_size = t43_decode_get_compressed_image_size(&s->decoder.t43)/8; + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t->width = t85_decode_get_image_width(&s->decoder.t85); + t->length = t85_decode_get_image_length(&s->decoder.t85); + t->line_image_size = t85_decode_get_compressed_image_size(&s->decoder.t85)/8; + break; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_start_page(t4_rx_state_t *s) +{ + span_log(&s->logging, SPAN_LOG_FLOW, "Start rx page %d - compression %s\n", s->current_page, t4_encoding_to_str(s->line_encoding)); + + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t4_t6_decode_restart(&s->decoder.t4_t6, s->image_width); + break; + case T4_COMPRESSION_ITU_T42: + t42_decode_restart(&s->decoder.t42); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t43_decode_restart(&s->decoder.t43); + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t85_decode_restart(&s->decoder.t85); + break; + } + s->line_image_size = 0; + s->tiff.image_size = 0; + + time (&s->tiff.page_start_time); + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int tiff_row_write_handler(void *user_data, const uint8_t buf[], size_t len) +{ + t4_rx_state_t *s; + uint8_t *t; + + s = (t4_rx_state_t *) user_data; + if (buf && len > 0) + { + if (s->tiff.image_size + len >= s->tiff.image_buffer_size) + { + if ((t = realloc(s->tiff.image_buffer, s->tiff.image_buffer_size + 100*len)) == NULL) + return -1; + s->tiff.image_buffer_size += 100*len; + s->tiff.image_buffer = t; + } + memcpy(&s->tiff.image_buffer[s->tiff.image_size], buf, len); + s->tiff.image_size += len; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s) +{ + int length; + + length = 0; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t4_t6_decode_put(&s->decoder.t4_t6, NULL, 0); + length = t4_t6_decode_get_image_length(&s->decoder.t4_t6); + break; + case T4_COMPRESSION_ITU_T42: + t42_decode_put(&s->decoder.t42, NULL, 0); + length = t42_decode_get_image_length(&s->decoder.t42); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t43_decode_put(&s->decoder.t43, NULL, 0); + length = t43_decode_get_image_length(&s->decoder.t43); + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t85_decode_put(&s->decoder.t85, NULL, 0); + length = t85_decode_get_image_length(&s->decoder.t85); + break; + } + + if (length == 0) + return -1; + + if (s->tiff.tiff_file) + { + if (write_tiff_image(s) == 0) + s->current_page++; + s->tiff.image_size = 0; + } + else + { + s->current_page++; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int output_encoding) +{ + int allocated; + + allocated = FALSE; + if (s == NULL) + { + if ((s = (t4_rx_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + allocated = TRUE; + } +#if defined(SPANDSP_SUPPORT_TIFF_FX) + TIFF_FX_init(); +#endif + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.4"); + + span_log(&s->logging, SPAN_LOG_FLOW, "Start rx document\n"); + + /* Only provide for one form of coding throughout the file, even though the + coding on the wire could change between pages. */ + s->tiff.output_encoding = output_encoding; + + /* Set some default values */ + s->metadata.x_resolution = T4_X_RESOLUTION_R8; + s->metadata.y_resolution = T4_Y_RESOLUTION_FINE; + + s->current_page = 0; + + /* Default handler */ + s->row_handler = tiff_row_write_handler; + s->row_handler_user_data = s; + + if (file) + { + s->tiff.pages_in_file = 0; + if (open_tiff_output_file(s, file) < 0) + { + if (allocated) + free(s); + return NULL; + } + /* Save the file name for logging reports. */ + s->tiff.file = strdup(file); + } + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_release(t4_rx_state_t *s) +{ + if (s->tiff.file) + tiff_rx_release(s); + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_decode_release(&s->decoder.t4_t6); + case T4_COMPRESSION_ITU_T42: + return t42_decode_release(&s->decoder.t42); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_decode_release(&s->decoder.t43); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_decode_release(&s->decoder.t85); + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_rx_free(t4_rx_state_t *s) +{ + int ret; + + ret = t4_rx_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_t6_decode.c b/libs/spandsp/src/t4_t6_decode.c new file mode 100644 index 0000000000..f866c98cae --- /dev/null +++ b/libs/spandsp/src/t4_t6_decode.c @@ -0,0 +1,920 @@ +//#define T4_STATE_DEBUGGING +/* + * SpanDSP - a series of DSP components for telephony + * + * t4_t6_encode.c - ITU T.4 and T.6 FAX image decompression + * + * Written by Steve Underwood + * + * Copyright (C) 2003, 2007 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * This file has origins in the T.4 and T.6 support in libtiff, which requires + * the following notice in any derived source code: + * + * Copyright (c) 1990-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + * Decoder support is derived from code in Frank Cringle's viewfax program; + * Copyright (C) 1990, 1995 Frank D. Cringle. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(HAVE_TGMATH_H) +#include +#endif +#if defined(HAVE_MATH_H) +#include +#endif +#include "floating_fudge.h" +#include + +#include "spandsp/telephony.h" +#include "spandsp/logging.h" +#include "spandsp/bit_operations.h" +#include "spandsp/async.h" +#include "spandsp/timezone.h" +#include "spandsp/t4_rx.h" +#include "spandsp/t4_tx.h" +#include "spandsp/image_translate.h" +#include "spandsp/t81_t82_arith_coding.h" +#include "spandsp/t85.h" +#include "spandsp/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/t43.h" +#endif +#include "spandsp/t4_t6_decode.h" +#include "spandsp/t4_t6_encode.h" + +#include "spandsp/private/logging.h" +#include "spandsp/private/t81_t82_arith_coding.h" +#include "spandsp/private/t85.h" +#include "spandsp/private/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/private/t43.h" +#endif +#include "spandsp/private/t4_t6_decode.h" +#include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" +#include "spandsp/private/t4_rx.h" +#include "spandsp/private/t4_tx.h" + +/*! The number of centimetres in one inch */ +#define CM_PER_INCH 2.54f + +/*! The number of EOLs to expect at the end of a T.4 page */ +#define EOLS_TO_END_ANY_RX_PAGE 6 +/*! The number of EOLs to check at the end of a T.4 page */ +#define EOLS_TO_END_T4_RX_PAGE 5 +/*! The number of EOLs to check at the end of a T.6 page */ +#define EOLS_TO_END_T6_RX_PAGE 2 + +#include "t4_t6_decode_states.h" + +#if defined(T4_STATE_DEBUGGING) +static void STATE_TRACE(const char *format, ...) +{ + va_list arg_ptr; + + va_start(arg_ptr, format); + vprintf(format, arg_ptr); + va_end(arg_ptr); +} +/*- End of function --------------------------------------------------------*/ +#else +#define STATE_TRACE(...) /**/ +#endif + +static int free_buffers(t4_t6_decode_state_t *s) +{ + if (s->cur_runs) + { + free(s->cur_runs); + s->cur_runs = NULL; + } + if (s->ref_runs) + { + free(s->ref_runs); + s->ref_runs = NULL; + } + if (s->row_buf) + { + free(s->row_buf); + s->row_buf = NULL; + } + s->bytes_per_row = 0; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__powerpc__) +static __inline__ int run_length(unsigned int bits) +{ + return 7 - top_bit(bits); +} +/*- End of function --------------------------------------------------------*/ +#else +static __inline__ int run_length(unsigned int bits) +{ + static const uint8_t run_len[256] = + { + 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0F */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1F */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2F */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3F */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4F */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5F */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6F */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7F */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8F */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9F */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xAF */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 - 0xBF */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xCF */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xDF */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0 - 0xEF */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xF0 - 0xFF */ + }; + + return run_len[bits]; +} +/*- End of function --------------------------------------------------------*/ +#endif + +static __inline__ void add_run_to_row(t4_t6_decode_state_t *s) +{ + if (s->run_length >= 0) + { + s->row_len += s->run_length; + /* Don't allow rows to grow too long, and overflow the buffers */ + if (s->row_len <= s->image_width) + s->cur_runs[s->a_cursor++] = s->run_length; + } + s->run_length = 0; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void update_row_bit_info(t4_t6_decode_state_t *s) +{ + if (s->row_bits > s->max_row_bits) + s->max_row_bits = s->row_bits; + if (s->row_bits < s->min_row_bits) + s->min_row_bits = s->row_bits; + s->row_bits = 0; +} +/*- End of function --------------------------------------------------------*/ + +static int put_decoded_row(t4_t6_decode_state_t *s) +{ + static const int msbmask[9] = + { + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff + }; + uint32_t i; + uint32_t *p; + int fudge; + int x; + int j; + int row_pos; + + if (s->run_length) + add_run_to_row(s); + update_row_bit_info(s); +#if defined(T4_STATE_DEBUGGING) + /* Dump the runs of black and white for analysis */ + { + int total; + + total = 0; + for (x = 0; x < s->b_cursor; x++) + total += s->ref_runs[x]; + printf("Ref (%d)", total); + for (x = 0; x < s->b_cursor; x++) + printf(" %" PRIu32, s->ref_runs[x]); + printf("\n"); + total = 0; + for (x = 0; x < s->a_cursor; x++) + total += s->cur_runs[x]; + printf("Cur (%d)", total); + for (x = 0; x < s->a_cursor; x++) + printf(" %" PRIu32, s->cur_runs[x]); + printf("\n"); + } +#endif + row_pos = 0; + if (s->row_len == s->image_width) + { + STATE_TRACE("%d Good row - %d %s\n", s->image_length, s->row_len, (s->row_is_2d) ? "2D" : "1D"); + if (s->curr_bad_row_run) + { + if (s->curr_bad_row_run > s->longest_bad_row_run) + s->longest_bad_row_run = s->curr_bad_row_run; + s->curr_bad_row_run = 0; + } + /* Convert the runs to a bit image of the row */ + /* White/black/white... runs, always starting with white. That means the first run could be + zero length. */ + for (x = 0, fudge = 0; x < s->a_cursor; x++, fudge ^= 0xFF) + { + i = s->cur_runs[x]; + if ((int) i >= s->pixels) + { + s->pixel_stream = (s->pixel_stream << s->pixels) | (msbmask[s->pixels] & fudge); + for (i += (8 - s->pixels); i >= 8; i -= 8) + { + s->pixels = 8; + s->row_buf[row_pos++] = (uint8_t) s->pixel_stream; + s->pixel_stream = fudge; + } + } + s->pixel_stream = (s->pixel_stream << i) | (msbmask[i] & fudge); + s->pixels -= i; + } + s->image_length++; + } + else + { + STATE_TRACE("%d Bad row - %d %s\n", s->image_length, s->row_len, (s->row_is_2d) ? "2D" : "1D"); + /* Try to clean up the bad runs, and produce something reasonable as the reference + row for the next row. Use a copy of the previous good row as the actual current + row. If the row only fell apart near the end, reusing it might be the best + solution. */ + for (j = 0, fudge = 0; j < s->a_cursor && fudge < s->image_width; j++) + fudge += s->cur_runs[j]; + if (fudge < s->image_width) + { + /* Try to pad with white, and avoid black, to minimise mess on the image. */ + if ((s->a_cursor & 1)) + { + /* We currently finish in white. We could extend that, but it is probably of + the right length. Changing it would only further mess up what happens in the + next row. It seems better to add a black spot, and an extra white run. */ + s->cur_runs[s->a_cursor++] = 1; + fudge++; + if (fudge < s->image_width) + s->cur_runs[s->a_cursor++] = s->image_width - fudge; + } + else + { + /* We currently finish on black, so we add an extra white run to fill out the line. */ + s->cur_runs[s->a_cursor++] = s->image_width - fudge; + } + } + else + { + /* Trim the last element to align with the proper image width */ + s->cur_runs[s->a_cursor] += (s->image_width - fudge); + } + /* Ensure there is a previous line to copy from. */ + /* Reuse the previous row as the current one. If this is the first row + the row buffer will already contain a suitable white row */ + s->image_length++; + s->bad_rows++; + s->curr_bad_row_run++; + } + + /* Pad the row as it becomes the reference row, so there are no odd runs to pick up if we + step off the end of the list. */ + s->cur_runs[s->a_cursor] = 0; + s->cur_runs[s->a_cursor + 1] = 0; + + /* Swap the buffers */ + p = s->cur_runs; + s->cur_runs = s->ref_runs; + s->ref_runs = p; + + s->b_cursor = 1; + s->a_cursor = 0; + s->b1 = s->ref_runs[0]; + s->a0 = 0; + + s->run_length = 0; + if (s->row_write_handler) + return s->row_write_handler(s->row_write_user_data, s->row_buf, s->bytes_per_row); + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void drop_rx_bits(t4_t6_decode_state_t *s, int bits) +{ + /* Only remove one bit right now. The rest need to be removed step by step, + checking for a misaligned EOL along the way. This is time consuming, but + if we don't do it a single bit error can severely damage an image. */ + s->row_bits += bits; + s->rx_skip_bits += (bits - 1); + s->rx_bits--; + s->rx_bitstream >>= 1; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void force_drop_rx_bits(t4_t6_decode_state_t *s, int bits) +{ + /* This should only be called to drop the bits of an EOL, as that is the + only place where it is safe to drop them all at once. */ + s->row_bits += bits; + s->rx_skip_bits = 0; + s->rx_bits -= bits; + s->rx_bitstream >>= bits; +} +/*- End of function --------------------------------------------------------*/ + +static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity) +{ + int bits; + int old_a0; + + /* We decompress bit by bit, as the data stream is received. We need to + scan continuously for EOLs, so we might as well work this way. */ + s->rx_bitstream |= (bit_string << s->rx_bits); + /* The longest item we need to scan for is 13 bits long (a 2D EOL), so we + need a minimum of 13 bits in the buffer to proceed with any bit stream + analysis. */ + if ((s->rx_bits += quantity) < 13) + return FALSE; + if (s->consecutive_eols) + { + /* Check if the image has already terminated. */ + if (s->consecutive_eols >= EOLS_TO_END_ANY_RX_PAGE) + return TRUE; + /* Check if the image hasn't even started. */ + if (s->consecutive_eols < 0) + { + /* We are waiting for the very first EOL (1D or 2D only). */ + /* We need to take this bit by bit, as the EOL could be anywhere, + and any junk could preceed it. */ + while ((s->rx_bitstream & 0xFFF) != 0x800) + { + s->rx_bitstream >>= 1; + if (--s->rx_bits < 13) + return FALSE; + } + /* We have an EOL, so now the page begins and we can proceed to + process the bit stream as image data. */ + s->consecutive_eols = 0; + if (s->encoding == T4_COMPRESSION_ITU_T4_1D) + { + s->row_is_2d = FALSE; + force_drop_rx_bits(s, 12); + } + else + { + s->row_is_2d = !(s->rx_bitstream & 0x1000); + force_drop_rx_bits(s, 13); + } + } + } + + while (s->rx_bits >= 13) + { + /* We need to check for EOLs bit by bit through the whole stream. If + we just try looking between code words, we will miss an EOL when a bit + error has throw the code words completely out of step. The can mean + recovery takes many lines, and the image gets really messed up. */ + /* Although EOLs are not inserted at the end of each row of a T.6 image, + they are still perfectly valid, and can terminate an image. */ + if ((s->rx_bitstream & 0x0FFF) == 0x0800) + { + STATE_TRACE("EOL\n"); + if (s->row_len == 0) + { + /* A zero length row - i.e. 2 consecutive EOLs - is distinctly + the end of page condition. That's all we actually get on a + T.6 page. However, there are a minimum of 6 EOLs at the end of + any T.4 page. We can look for more than 2 EOLs in case bit + errors simulate the end of page condition at the wrong point. + Such robust checking is irrelevant for a T.6 page, as it should + be error free. */ + /* Note that for a T.6 page we should get here on the very first + EOL, as the row length should be zero at that point. Therefore + we should count up both EOLs, unless there is some bogus partial + row ahead of them. */ + s->consecutive_eols++; + if (s->encoding == T4_COMPRESSION_ITU_T6) + { + if (s->consecutive_eols >= EOLS_TO_END_T6_RX_PAGE) + { + s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; + return TRUE; + } + } + else + { + if (s->consecutive_eols >= EOLS_TO_END_T4_RX_PAGE) + { + s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; + return TRUE; + } + } + } + else + { + /* The EOLs are not back-to-back, so they are not part of the + end of page condition. */ + if (s->run_length > 0) + add_run_to_row(s); + s->consecutive_eols = 0; + if (put_decoded_row(s)) + return TRUE; + } + if (s->encoding == T4_COMPRESSION_ITU_T4_2D) + { + s->row_is_2d = !(s->rx_bitstream & 0x1000); + force_drop_rx_bits(s, 13); + } + else + { + force_drop_rx_bits(s, 12); + } + s->in_black = FALSE; + s->black_white = 0; + s->run_length = 0; + s->row_len = 0; + continue; + } + if (s->rx_skip_bits) + { + /* We are clearing out the remaining bits of the last code word we + absorbed. */ + s->rx_skip_bits--; + s->rx_bits--; + s->rx_bitstream >>= 1; + continue; + } + if (s->row_is_2d && s->black_white == 0) + { + bits = s->rx_bitstream & 0x7F; + STATE_TRACE("State %d, %d - ", + t4_2d_table[bits].state, + t4_2d_table[bits].width); + if (s->row_len >= s->image_width) + { + drop_rx_bits(s, t4_2d_table[bits].width); + continue; + } + if (s->a_cursor) + { + /* Move past a0, always staying on the current colour */ + for ( ; s->b1 <= s->a0; s->b_cursor += 2) + s->b1 += (s->ref_runs[s->b_cursor] + s->ref_runs[s->b_cursor + 1]); + } + switch (t4_2d_table[bits].state) + { + case S_Horiz: + STATE_TRACE("Horiz %d %d %d\n", + s->image_width, + s->a0, + s->a_cursor); + /* We now need to extract a white/black or black/white pair of runs, using the 1D + method. If the first of the pair takes us exactly to the end of the row, there + should still be a zero length element for the second of the pair. */ + s->in_black = s->a_cursor & 1; + s->black_white = 2; + break; + case S_Vert: + STATE_TRACE("Vert[%d] %d %d %d %d\n", + t4_2d_table[bits].param, + s->image_width, + s->a0, + s->b1, + s->run_length); + old_a0 = s->a0; + s->a0 = s->b1 + t4_2d_table[bits].param; + /* We need to check if a bad or malicious image is failing to move forward along the row. + Going back is obviously bad. We also need to avoid a stall on the spot, except for the + special case of the start of the row. Zero movement as the very first element in the + row is perfectly normal. */ + if (s->a0 <= old_a0) + { + if (s->a0 < old_a0 || s->b_cursor > 1) + { + /* Undo the update we just started, and carry on as if this code does not exist */ + /* TODO: we really should record that something wasn't right at this point. */ + s->a0 = old_a0; + break; + } + } + s->run_length += (s->a0 - old_a0); + add_run_to_row(s); + /* We need to move one step in one direction or the other, to change to the + opposite colour */ + if (t4_2d_table[bits].param >= 0) + { + s->b1 += s->ref_runs[s->b_cursor++]; + } + else + { + if (s->b_cursor) + s->b1 -= s->ref_runs[--s->b_cursor]; + } + break; + case S_Pass: + STATE_TRACE("Pass %d %d %d %d %d\n", + s->image_width, + s->a0, + s->b1, + s->ref_runs[s->b_cursor], + s->ref_runs[s->b_cursor + 1]); + s->b1 += s->ref_runs[s->b_cursor++]; + old_a0 = s->a0; + s->a0 = s->b1; + s->run_length += (s->a0 - old_a0); + s->b1 += s->ref_runs[s->b_cursor++]; + break; + case S_Ext: + /* We do not currently handle any kind of extension */ + STATE_TRACE("Ext %d %d %d 0x%x\n", + s->image_width, + s->a0, + ((s->rx_bitstream >> t4_2d_table[bits].width) & 0x7), + s->rx_bitstream); + /* TODO: The uncompressed option should be implemented. */ + break; + case S_Null: + STATE_TRACE("Null\n"); + break; + default: + STATE_TRACE("Unexpected T.4 state\n"); + span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected T.4 state %d\n", t4_2d_table[bits].state); + break; + } + drop_rx_bits(s, t4_2d_table[bits].width); + } + else + { + if (s->in_black) + { + bits = s->rx_bitstream & 0x1FFF; + STATE_TRACE("State %d, %d - Black %d %d %d\n", + t4_1d_black_table[bits].state, + t4_1d_black_table[bits].width, + s->image_width, + s->a0, + t4_1d_black_table[bits].param); + switch (t4_1d_black_table[bits].state) + { + case S_MakeUpB: + case S_MakeUp: + s->run_length += t4_1d_black_table[bits].param; + s->a0 += t4_1d_black_table[bits].param; + break; + case S_TermB: + s->in_black = FALSE; + if (s->row_len < s->image_width) + { + s->run_length += t4_1d_black_table[bits].param; + s->a0 += t4_1d_black_table[bits].param; + add_run_to_row(s); + } + if (s->black_white) + s->black_white--; + break; + default: + /* Bad black */ + s->black_white = 0; + break; + } + drop_rx_bits(s, t4_1d_black_table[bits].width); + } + else + { + bits = s->rx_bitstream & 0xFFF; + STATE_TRACE("State %d, %d - White %d %d %d\n", + t4_1d_white_table[bits].state, + t4_1d_white_table[bits].width, + s->image_width, + s->a0, + t4_1d_white_table[bits].param); + switch (t4_1d_white_table[bits].state) + { + case S_MakeUpW: + case S_MakeUp: + s->run_length += t4_1d_white_table[bits].param; + s->a0 += t4_1d_white_table[bits].param; + break; + case S_TermW: + s->in_black = TRUE; + if (s->row_len < s->image_width) + { + s->run_length += t4_1d_white_table[bits].param; + s->a0 += t4_1d_white_table[bits].param; + add_run_to_row(s); + } + if (s->black_white) + s->black_white--; + break; + default: + /* Bad white */ + s->black_white = 0; + break; + } + drop_rx_bits(s, t4_1d_white_table[bits].width); + } + } + if (s->a0 >= s->image_width) + s->a0 = s->image_width - 1; + + if (s->encoding == T4_COMPRESSION_ITU_T6) + { + /* T.6 has no EOL markers. We sense the end of a line by its length alone. */ + /* The last test here is a backstop protection, so a corrupt image cannot + cause us to do bad things. Bad encoders have actually been seen, which + demand such protection. */ + if (s->black_white == 0 && s->row_len >= s->image_width) + { + STATE_TRACE("EOL T.6\n"); + if (s->run_length > 0) + add_run_to_row(s); + if (put_decoded_row(s)) + return TRUE; + s->in_black = FALSE; + s->black_white = 0; + s->run_length = 0; + s->row_len = 0; + } + } + } + return FALSE; +} +/*- End of function --------------------------------------------------------*/ + +static void t4_t6_decode_rx_status(t4_t6_decode_state_t *s, int status) +{ + span_log(&s->logging, SPAN_LOG_FLOW, "Signal status is %s (%d)\n", signal_status_to_str(status), status); + switch (status) + { + case SIG_STATUS_TRAINING_IN_PROGRESS: + case SIG_STATUS_TRAINING_FAILED: + case SIG_STATUS_TRAINING_SUCCEEDED: + case SIG_STATUS_CARRIER_UP: + /* Ignore these */ + break; + case SIG_STATUS_CARRIER_DOWN: + case SIG_STATUS_END_OF_DATA: + t4_t6_decode_put(s, NULL, 0); + break; + default: + span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected rx status - %d!\n", status); + break; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit) +{ + if (bit < 0) + { + t4_t6_decode_rx_status(s, bit); + return TRUE; + } + s->compressed_image_size++; + if (put_bits(s, bit & 1, 1)) + return T4_DECODE_OK; + return T4_DECODE_MORE_DATA; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len) +{ + int i; + uint8_t byte; + + if (len == 0) + { + /* Finalise the image */ + if (s->consecutive_eols != EOLS_TO_END_ANY_RX_PAGE) + { + /* Push enough zeros (13) through the decoder to flush out any remaining codes */ + put_bits(s, 0, 8); + put_bits(s, 0, 5); + } + if (s->curr_bad_row_run) + { + if (s->curr_bad_row_run > s->longest_bad_row_run) + s->longest_bad_row_run = s->curr_bad_row_run; + s->curr_bad_row_run = 0; + } + /* Don't worry about the return value here. We are finishing anyway. */ + if (s->row_write_handler) + s->row_write_handler(s->row_write_user_data, NULL, 0); + s->rx_bits = 0; + s->rx_skip_bits = 0; + s->rx_bitstream = 0; + s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE; + return T4_DECODE_OK; + } + + for (i = 0; i < len; i++) + { + s->compressed_image_size += 8; + byte = buf[i]; + if (put_bits(s, byte & 0xFF, 8)) + return T4_DECODE_OK; + } + return T4_DECODE_MORE_DATA; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_set_row_write_handler(t4_t6_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data) +{ + s->row_write_handler = handler; + s->row_write_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_set_encoding(t4_t6_decode_state_t *s, int encoding) +{ + switch (encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + s->encoding = encoding; + return 0; + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_width(t4_t6_decode_state_t *s) +{ + return s->image_width; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_length(t4_t6_decode_state_t *s) +{ + return s->image_length; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s) +{ + return s->compressed_image_size; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width) +{ + int bytes_per_row; + int run_space; + uint32_t *bufptr; + uint8_t *bufptr8; + + /* Calculate the scanline/tile width. */ + run_space = (image_width + 4)*sizeof(uint32_t); + if (s->bytes_per_row == 0 || image_width != s->image_width) + { + /* Allocate the space required for decoding the new row length. */ + if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) + return -1; + s->cur_runs = bufptr; + if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL) + return -1; + s->ref_runs = bufptr; + s->image_width = image_width; + } + bytes_per_row = (image_width + 7)/8; + if (bytes_per_row != s->bytes_per_row) + { + if ((bufptr8 = (uint8_t *) realloc(s->row_buf, bytes_per_row)) == NULL) + return -1; + s->row_buf = bufptr8; + s->bytes_per_row = bytes_per_row; + } + + s->rx_bits = 0; + s->rx_skip_bits = 0; + s->rx_bitstream = 0; + s->row_bits = 0; + s->min_row_bits = INT_MAX; + s->max_row_bits = 0; + + s->compressed_image_size = 0; + s->bad_rows = 0; + s->longest_bad_row_run = 0; + s->curr_bad_row_run = 0; + s->image_length = 0; + s->pixel_stream = 0; + s->pixels = 8; + + s->row_len = 0; + s->in_black = FALSE; + s->black_white = 0; + s->b_cursor = 1; + s->a_cursor = 0; + s->b1 = s->image_width; + s->a0 = 0; + s->run_length = 0; + s->row_is_2d = (s->encoding == T4_COMPRESSION_ITU_T6); + /* We start at -1 EOLs for 1D and 2D decoding, as an indication we are waiting for the + first EOL. T.6 coding starts without any preamble. */ + s->consecutive_eols = (s->encoding == T4_COMPRESSION_ITU_T6) ? 0 : -1; + + if (s->cur_runs) + memset(s->cur_runs, 0, run_space); + /* Initialise the reference line to all white */ + if (s->ref_runs) + { + memset(s->ref_runs, 0, run_space); + s->ref_runs[0] = s->image_width; + } + if (s->row_buf) + memset(s->row_buf, 0, s->bytes_per_row); + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t4_t6_decode_state_t *) t4_t6_decode_init(t4_t6_decode_state_t *s, + int encoding, + int image_width, + t4_row_write_handler_t handler, + void *user_data) +{ + if (s == NULL) + { + if ((s = (t4_t6_decode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.4/T.6"); + + s->encoding = encoding; + s->row_write_handler = handler; + s->row_write_user_data = user_data; + t4_t6_decode_restart(s, image_width); + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_release(t4_t6_decode_state_t *s) +{ + free_buffers(s); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_decode_free(t4_t6_decode_state_t *s) +{ + int ret; + + ret = t4_t6_decode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_t6_encode.c b/libs/spandsp/src/t4_t6_encode.c new file mode 100644 index 0000000000..845c113527 --- /dev/null +++ b/libs/spandsp/src/t4_t6_encode.c @@ -0,0 +1,1161 @@ +//#define T4_STATE_DEBUGGING +/* + * SpanDSP - a series of DSP components for telephony + * + * t4_t6_encode.c - ITU T.4 and T.6 FAX image compression + * + * Written by Steve Underwood + * + * Copyright (C) 2003, 2007 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * This file has origins in the T.4 and T.6 support in libtiff, which requires + * the following notice in any derived source code: + * + * Copyright (c) 1990-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(HAVE_TGMATH_H) +#include +#endif +#if defined(HAVE_MATH_H) +#include +#endif +#include "floating_fudge.h" +#include + +#include "spandsp/telephony.h" +#include "spandsp/logging.h" +#include "spandsp/bit_operations.h" +#include "spandsp/async.h" +#include "spandsp/timezone.h" +#include "spandsp/t4_rx.h" +#include "spandsp/t4_tx.h" +#include "spandsp/image_translate.h" +#include "spandsp/t81_t82_arith_coding.h" +#include "spandsp/t85.h" +#include "spandsp/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/t43.h" +#endif +#include "spandsp/t4_t6_decode.h" +#include "spandsp/t4_t6_encode.h" + +#include "spandsp/private/logging.h" +#include "spandsp/private/t81_t82_arith_coding.h" +#include "spandsp/private/t85.h" +#include "spandsp/private/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/private/t43.h" +#endif +#include "spandsp/private/t4_t6_decode.h" +#include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" +#include "spandsp/private/t4_rx.h" +#include "spandsp/private/t4_tx.h" + +/*! The number of EOLs to be sent at the end of a T.4 page */ +#define EOLS_TO_END_T4_TX_PAGE 6 +/*! The number of EOLs to be sent at the end of a T.6 page */ +#define EOLS_TO_END_T6_TX_PAGE 2 + +#if defined(T4_STATE_DEBUGGING) +static void STATE_TRACE(const char *format, ...) +{ + va_list arg_ptr; + + va_start(arg_ptr, format); + vprintf(format, arg_ptr); + va_end(arg_ptr); +} +/*- End of function --------------------------------------------------------*/ +#else +#define STATE_TRACE(...) /**/ +#endif + +/*! T.4 run length table entry */ +typedef struct +{ + /*! Length of T.4 code, in bits */ + uint16_t length; + /*! T.4 code */ + uint16_t code; + /*! Run length, in bits */ + int16_t run_length; +} t4_run_table_entry_t; + +/* Legitimate runs of zero bits which are the tail end of one code + plus the start of the next code do not exceed 10 bits. */ + +/* + * Note that these tables are ordered such that the index into the table + * is known to be either the run length, or (run length / 64) + a fixed + * offset. + */ +static const t4_run_table_entry_t t4_white_codes[] = +{ + { 8, 0x00AC, 0}, /* 0011 0101 */ + { 6, 0x0038, 1}, /* 0001 11 */ + { 4, 0x000E, 2}, /* 0111 */ + { 4, 0x0001, 3}, /* 1000 */ + { 4, 0x000D, 4}, /* 1011 */ + { 4, 0x0003, 5}, /* 1100 */ + { 4, 0x0007, 6}, /* 1110 */ + { 4, 0x000F, 7}, /* 1111 */ + { 5, 0x0019, 8}, /* 1001 1 */ + { 5, 0x0005, 9}, /* 1010 0 */ + { 5, 0x001C, 10}, /* 0011 1 */ + { 5, 0x0002, 11}, /* 0100 0 */ + { 6, 0x0004, 12}, /* 0010 00 */ + { 6, 0x0030, 13}, /* 0000 11 */ + { 6, 0x000B, 14}, /* 1101 00 */ + { 6, 0x002B, 15}, /* 1101 01 */ + { 6, 0x0015, 16}, /* 1010 10 */ + { 6, 0x0035, 17}, /* 1010 11 */ + { 7, 0x0072, 18}, /* 0100 111 */ + { 7, 0x0018, 19}, /* 0001 100 */ + { 7, 0x0008, 20}, /* 0001 000 */ + { 7, 0x0074, 21}, /* 0010 111 */ + { 7, 0x0060, 22}, /* 0000 011 */ + { 7, 0x0010, 23}, /* 0000 100 */ + { 7, 0x000A, 24}, /* 0101 000 */ + { 7, 0x006A, 25}, /* 0101 011 */ + { 7, 0x0064, 26}, /* 0010 011 */ + { 7, 0x0012, 27}, /* 0100 100 */ + { 7, 0x000C, 28}, /* 0011 000 */ + { 8, 0x0040, 29}, /* 0000 0010 */ + { 8, 0x00C0, 30}, /* 0000 0011 */ + { 8, 0x0058, 31}, /* 0001 1010 */ + { 8, 0x00D8, 32}, /* 0001 1011 */ + { 8, 0x0048, 33}, /* 0001 0010 */ + { 8, 0x00C8, 34}, /* 0001 0011 */ + { 8, 0x0028, 35}, /* 0001 0100 */ + { 8, 0x00A8, 36}, /* 0001 0101 */ + { 8, 0x0068, 37}, /* 0001 0110 */ + { 8, 0x00E8, 38}, /* 0001 0111 */ + { 8, 0x0014, 39}, /* 0010 1000 */ + { 8, 0x0094, 40}, /* 0010 1001 */ + { 8, 0x0054, 41}, /* 0010 1010 */ + { 8, 0x00D4, 42}, /* 0010 1011 */ + { 8, 0x0034, 43}, /* 0010 1100 */ + { 8, 0x00B4, 44}, /* 0010 1101 */ + { 8, 0x0020, 45}, /* 0000 0100 */ + { 8, 0x00A0, 46}, /* 0000 0101 */ + { 8, 0x0050, 47}, /* 0000 1010 */ + { 8, 0x00D0, 48}, /* 0000 1011 */ + { 8, 0x004A, 49}, /* 0101 0010 */ + { 8, 0x00CA, 50}, /* 0101 0011 */ + { 8, 0x002A, 51}, /* 0101 0100 */ + { 8, 0x00AA, 52}, /* 0101 0101 */ + { 8, 0x0024, 53}, /* 0010 0100 */ + { 8, 0x00A4, 54}, /* 0010 0101 */ + { 8, 0x001A, 55}, /* 0101 1000 */ + { 8, 0x009A, 56}, /* 0101 1001 */ + { 8, 0x005A, 57}, /* 0101 1010 */ + { 8, 0x00DA, 58}, /* 0101 1011 */ + { 8, 0x0052, 59}, /* 0100 1010 */ + { 8, 0x00D2, 60}, /* 0100 1011 */ + { 8, 0x004C, 61}, /* 0011 0010 */ + { 8, 0x00CC, 62}, /* 0011 0011 */ + { 8, 0x002C, 63}, /* 0011 0100 */ + { 5, 0x001B, 64}, /* 1101 1 */ + { 5, 0x0009, 128}, /* 1001 0 */ + { 6, 0x003A, 192}, /* 0101 11 */ + { 7, 0x0076, 256}, /* 0110 111 */ + { 8, 0x006C, 320}, /* 0011 0110 */ + { 8, 0x00EC, 384}, /* 0011 0111 */ + { 8, 0x0026, 448}, /* 0110 0100 */ + { 8, 0x00A6, 512}, /* 0110 0101 */ + { 8, 0x0016, 576}, /* 0110 1000 */ + { 8, 0x00E6, 640}, /* 0110 0111 */ + { 9, 0x0066, 704}, /* 0110 0110 0 */ + { 9, 0x0166, 768}, /* 0110 0110 1 */ + { 9, 0x0096, 832}, /* 0110 1001 0 */ + { 9, 0x0196, 896}, /* 0110 1001 1 */ + { 9, 0x0056, 960}, /* 0110 1010 0 */ + { 9, 0x0156, 1024}, /* 0110 1010 1 */ + { 9, 0x00D6, 1088}, /* 0110 1011 0 */ + { 9, 0x01D6, 1152}, /* 0110 1011 1 */ + { 9, 0x0036, 1216}, /* 0110 1100 0 */ + { 9, 0x0136, 1280}, /* 0110 1100 1 */ + { 9, 0x00B6, 1344}, /* 0110 1101 0 */ + { 9, 0x01B6, 1408}, /* 0110 1101 1 */ + { 9, 0x0032, 1472}, /* 0100 1100 0 */ + { 9, 0x0132, 1536}, /* 0100 1100 1 */ + { 9, 0x00B2, 1600}, /* 0100 1101 0 */ + { 6, 0x0006, 1664}, /* 0110 00 */ + { 9, 0x01B2, 1728}, /* 0100 1101 1 */ + {11, 0x0080, 1792}, /* 0000 0001 000 */ + {11, 0x0180, 1856}, /* 0000 0001 100 */ + {11, 0x0580, 1920}, /* 0000 0001 101 */ + {12, 0x0480, 1984}, /* 0000 0001 0010 */ + {12, 0x0C80, 2048}, /* 0000 0001 0011 */ + {12, 0x0280, 2112}, /* 0000 0001 0100 */ + {12, 0x0A80, 2176}, /* 0000 0001 0101 */ + {12, 0x0680, 2240}, /* 0000 0001 0110 */ + {12, 0x0E80, 2304}, /* 0000 0001 0111 */ + {12, 0x0380, 2368}, /* 0000 0001 1100 */ + {12, 0x0B80, 2432}, /* 0000 0001 1101 */ + {12, 0x0780, 2496}, /* 0000 0001 1110 */ + {12, 0x0F80, 2560}, /* 0000 0001 1111 */ +}; + +static const t4_run_table_entry_t t4_black_codes[] = +{ + {10, 0x03B0, 0}, /* 0000 1101 11 */ + { 3, 0x0002, 1}, /* 010 */ + { 2, 0x0003, 2}, /* 11 */ + { 2, 0x0001, 3}, /* 10 */ + { 3, 0x0006, 4}, /* 011 */ + { 4, 0x000C, 5}, /* 0011 */ + { 4, 0x0004, 6}, /* 0010 */ + { 5, 0x0018, 7}, /* 0001 1 */ + { 6, 0x0028, 8}, /* 0001 01 */ + { 6, 0x0008, 9}, /* 0001 00 */ + { 7, 0x0010, 10}, /* 0000 100 */ + { 7, 0x0050, 11}, /* 0000 101 */ + { 7, 0x0070, 12}, /* 0000 111 */ + { 8, 0x0020, 13}, /* 0000 0100 */ + { 8, 0x00E0, 14}, /* 0000 0111 */ + { 9, 0x0030, 15}, /* 0000 1100 0 */ + {10, 0x03A0, 16}, /* 0000 0101 11 */ + {10, 0x0060, 17}, /* 0000 0110 00 */ + {10, 0x0040, 18}, /* 0000 0010 00 */ + {11, 0x0730, 19}, /* 0000 1100 111 */ + {11, 0x00B0, 20}, /* 0000 1101 000 */ + {11, 0x01B0, 21}, /* 0000 1101 100 */ + {11, 0x0760, 22}, /* 0000 0110 111 */ + {11, 0x00A0, 23}, /* 0000 0101 000 */ + {11, 0x0740, 24}, /* 0000 0010 111 */ + {11, 0x00C0, 25}, /* 0000 0011 000 */ + {12, 0x0530, 26}, /* 0000 1100 1010 */ + {12, 0x0D30, 27}, /* 0000 1100 1011 */ + {12, 0x0330, 28}, /* 0000 1100 1100 */ + {12, 0x0B30, 29}, /* 0000 1100 1101 */ + {12, 0x0160, 30}, /* 0000 0110 1000 */ + {12, 0x0960, 31}, /* 0000 0110 1001 */ + {12, 0x0560, 32}, /* 0000 0110 1010 */ + {12, 0x0D60, 33}, /* 0000 0110 1011 */ + {12, 0x04B0, 34}, /* 0000 1101 0010 */ + {12, 0x0CB0, 35}, /* 0000 1101 0011 */ + {12, 0x02B0, 36}, /* 0000 1101 0100 */ + {12, 0x0AB0, 37}, /* 0000 1101 0101 */ + {12, 0x06B0, 38}, /* 0000 1101 0110 */ + {12, 0x0EB0, 39}, /* 0000 1101 0111 */ + {12, 0x0360, 40}, /* 0000 0110 1100 */ + {12, 0x0B60, 41}, /* 0000 0110 1101 */ + {12, 0x05B0, 42}, /* 0000 1101 1010 */ + {12, 0x0DB0, 43}, /* 0000 1101 1011 */ + {12, 0x02A0, 44}, /* 0000 0101 0100 */ + {12, 0x0AA0, 45}, /* 0000 0101 0101 */ + {12, 0x06A0, 46}, /* 0000 0101 0110 */ + {12, 0x0EA0, 47}, /* 0000 0101 0111 */ + {12, 0x0260, 48}, /* 0000 0110 0100 */ + {12, 0x0A60, 49}, /* 0000 0110 0101 */ + {12, 0x04A0, 50}, /* 0000 0101 0010 */ + {12, 0x0CA0, 51}, /* 0000 0101 0011 */ + {12, 0x0240, 52}, /* 0000 0010 0100 */ + {12, 0x0EC0, 53}, /* 0000 0011 0111 */ + {12, 0x01C0, 54}, /* 0000 0011 1000 */ + {12, 0x0E40, 55}, /* 0000 0010 0111 */ + {12, 0x0140, 56}, /* 0000 0010 1000 */ + {12, 0x01A0, 57}, /* 0000 0101 1000 */ + {12, 0x09A0, 58}, /* 0000 0101 1001 */ + {12, 0x0D40, 59}, /* 0000 0010 1011 */ + {12, 0x0340, 60}, /* 0000 0010 1100 */ + {12, 0x05A0, 61}, /* 0000 0101 1010 */ + {12, 0x0660, 62}, /* 0000 0110 0110 */ + {12, 0x0E60, 63}, /* 0000 0110 0111 */ + {10, 0x03C0, 64}, /* 0000 0011 11 */ + {12, 0x0130, 128}, /* 0000 1100 1000 */ + {12, 0x0930, 192}, /* 0000 1100 1001 */ + {12, 0x0DA0, 256}, /* 0000 0101 1011 */ + {12, 0x0CC0, 320}, /* 0000 0011 0011 */ + {12, 0x02C0, 384}, /* 0000 0011 0100 */ + {12, 0x0AC0, 448}, /* 0000 0011 0101 */ + {13, 0x06C0, 512}, /* 0000 0011 0110 0 */ + {13, 0x16C0, 576}, /* 0000 0011 0110 1 */ + {13, 0x0A40, 640}, /* 0000 0010 0101 0 */ + {13, 0x1A40, 704}, /* 0000 0010 0101 1 */ + {13, 0x0640, 768}, /* 0000 0010 0110 0 */ + {13, 0x1640, 832}, /* 0000 0010 0110 1 */ + {13, 0x09C0, 896}, /* 0000 0011 1001 0 */ + {13, 0x19C0, 960}, /* 0000 0011 1001 1 */ + {13, 0x05C0, 1024}, /* 0000 0011 1010 0 */ + {13, 0x15C0, 1088}, /* 0000 0011 1010 1 */ + {13, 0x0DC0, 1152}, /* 0000 0011 1011 0 */ + {13, 0x1DC0, 1216}, /* 0000 0011 1011 1 */ + {13, 0x0940, 1280}, /* 0000 0010 1001 0 */ + {13, 0x1940, 1344}, /* 0000 0010 1001 1 */ + {13, 0x0540, 1408}, /* 0000 0010 1010 0 */ + {13, 0x1540, 1472}, /* 0000 0010 1010 1 */ + {13, 0x0B40, 1536}, /* 0000 0010 1101 0 */ + {13, 0x1B40, 1600}, /* 0000 0010 1101 1 */ + {13, 0x04C0, 1664}, /* 0000 0011 0010 0 */ + {13, 0x14C0, 1728}, /* 0000 0011 0010 1 */ + {11, 0x0080, 1792}, /* 0000 0001 000 */ + {11, 0x0180, 1856}, /* 0000 0001 100 */ + {11, 0x0580, 1920}, /* 0000 0001 101 */ + {12, 0x0480, 1984}, /* 0000 0001 0010 */ + {12, 0x0C80, 2048}, /* 0000 0001 0011 */ + {12, 0x0280, 2112}, /* 0000 0001 0100 */ + {12, 0x0A80, 2176}, /* 0000 0001 0101 */ + {12, 0x0680, 2240}, /* 0000 0001 0110 */ + {12, 0x0E80, 2304}, /* 0000 0001 0111 */ + {12, 0x0380, 2368}, /* 0000 0001 1100 */ + {12, 0x0B80, 2432}, /* 0000 0001 1101 */ + {12, 0x0780, 2496}, /* 0000 0001 1110 */ + {12, 0x0F80, 2560}, /* 0000 0001 1111 */ +}; + +static void update_row_bit_info(t4_t6_encode_state_t *s) +{ + if (s->row_bits > s->max_row_bits) + s->max_row_bits = s->row_bits; + if (s->row_bits < s->min_row_bits) + s->min_row_bits = s->row_bits; + s->row_bits = 0; +} +/*- End of function --------------------------------------------------------*/ + +static int free_buffers(t4_t6_encode_state_t *s) +{ + if (s->cur_runs) + { + free(s->cur_runs); + s->cur_runs = NULL; + } + if (s->ref_runs) + { + free(s->ref_runs); + s->ref_runs = NULL; + } + if (s->bitstream) + { + free(s->bitstream); + s->bitstream = NULL; + } + s->bytes_per_row = 0; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ int put_encoded_bits(t4_t6_encode_state_t *s, uint32_t bits, int length) +{ + /* We might be called with a large length value, to spew out a mass of zero bits for + minimum row length padding. */ + s->tx_bitstream |= (bits << s->tx_bits); + s->tx_bits += length; + s->row_bits += length; + while (s->tx_bits >= 8) + { + s->bitstream[s->bitstream_iptr++] = (uint8_t) s->tx_bitstream; + s->tx_bitstream >>= 8; + s->tx_bits -= 8; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +/* + * Write the sequence of codes that describes the specified span of zero's or one's. + * The appropriate table that holds the make-up and terminating codes is supplied. + */ +static __inline__ int put_1d_span(t4_t6_encode_state_t *s, int32_t span, const t4_run_table_entry_t *tab) +{ + const t4_run_table_entry_t *te; + + te = &tab[63 + (2560 >> 6)]; + while (span >= 2560 + 64) + { + if (put_encoded_bits(s, te->code, te->length)) + return -1; + span -= te->run_length; + } + te = &tab[63 + (span >> 6)]; + if (span >= 64) + { + if (put_encoded_bits(s, te->code, te->length)) + return -1; + span -= te->run_length; + } + if (put_encoded_bits(s, tab[span].code, tab[span].length)) + return -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int row_to_run_lengths(uint32_t list[], const uint8_t row[], int width) +{ + uint32_t flip; + uint32_t x; + int span; + int entry; + int frag; + int rem; + int limit; + int i; + int pos; + + /* Deal with whole words first. We know we are starting on a word boundary. */ + entry = 0; + flip = 0; + limit = (width >> 3) & ~3; + span = 0; + pos = 0; + for (i = 0; i < limit; i += sizeof(uint32_t)) + { + x = *((uint32_t *) &row[i]); + if (x != flip) + { + x = ((uint32_t) row[i] << 24) + | ((uint32_t) row[i + 1] << 16) + | ((uint32_t) row[i + 2] << 8) + | ((uint32_t) row[i + 3]); + /* We know we are going to find at least one transition. */ + frag = 31 - top_bit(x ^ flip); + pos += ((i << 3) - span + frag); + list[entry++] = pos; + x <<= frag; + flip ^= 0xFFFFFFFF; + rem = 32 - frag; + /* Now see if there are any more */ + while ((frag = 31 - top_bit(x ^ flip)) < rem) + { + pos += frag; + list[entry++] = pos; + x <<= frag; + flip ^= 0xFFFFFFFF; + rem -= frag; + } + /* Save the remainder of the word */ + span = (i << 3) + 32 - rem; + } + } + /* Now deal with some whole bytes, if there are any left. */ + limit = width >> 3; + flip &= 0xFF000000; + if (i < limit) + { + for ( ; i < limit; i++) + { + x = (uint32_t) row[i] << 24; + if (x != flip) + { + /* We know we are going to find at least one transition. */ + frag = 31 - top_bit(x ^ flip); + pos += ((i << 3) - span + frag); + list[entry++] = pos; + x <<= frag; + flip ^= 0xFF000000; + rem = 8 - frag; + /* Now see if there are any more */ + while ((frag = 31 - top_bit(x ^ flip)) < rem) + { + pos += frag; + list[entry++] = pos; + x <<= frag; + flip ^= 0xFF000000; + rem -= frag; + } + /* Save the remainder of the word */ + span = (i << 3) + 8 - rem; + } + } + } + /* Deal with any left over fractional byte. */ + span = (i << 3) - span; + if ((rem = width & 7)) + { + x = row[i]; + x <<= 24; + do + { + frag = 31 - top_bit(x ^ flip); + if (frag > rem) + frag = rem; + pos += (span + frag); + list[entry++] = pos; + x <<= frag; + span = 0; + flip ^= 0xFF000000; + rem -= frag; + } + while (rem > 0); + } + else + { + if (span) + { + pos += span; + list[entry++] = pos; + } + } +#if defined(T4_STATE_DEBUGGING) + /* Dump the runs of black and white for analysis */ + { + int prev; + int x; + + printf("Runs (%d)", list[entry - 1]); + prev = 0; + for (x = 0; x < entry; x++) + { + printf(" %" PRIu32, list[x] - prev); + prev = list[x]; + } + printf("\n"); + } +#endif + return entry; +} +/*- End of function --------------------------------------------------------*/ + +#define pixel_is_black(x,bit) (((x)[(bit) >> 3] << ((bit) & 7)) & 0x80) + +/* + * Write an EOL code to the output stream. We also handle writing the tag + * bit for the next scanline when doing 2D encoding. + */ +static void encode_eol(t4_t6_encode_state_t *s) +{ + uint32_t code; + int length; + + if (s->encoding == T4_COMPRESSION_ITU_T4_2D) + { + code = 0x0800 | ((!s->row_is_2d) << 12); + length = 13; + } + else + { + /* T.4 1D EOL, or T.6 EOFB */ + code = 0x800; + length = 12; + } + if (s->row_bits) + { + /* We may need to pad the row to a minimum length, unless we are in T.6 mode. + In T.6 we only come here at the end of the page to add the EOFB marker, which + is like two 1D EOLs. */ + if (s->encoding != T4_COMPRESSION_ITU_T6) + { + if (s->row_bits + length < s->min_bits_per_row) + put_encoded_bits(s, 0, s->min_bits_per_row - (s->row_bits + length)); + } + put_encoded_bits(s, code, length); + update_row_bit_info(s); + } + else + { + /* We don't pad zero length rows. They are the consecutive EOLs which end a page. */ + put_encoded_bits(s, code, length); + /* Don't do the full update row bit info, or the minimum suddenly drops to the + length of an EOL. Just clear the row bits, so we treat the next EOL as an + end of page EOL, with no padding. */ + s->row_bits = 0; + } +} +/*- End of function --------------------------------------------------------*/ + +/* + * 2D-encode a row of pixels. Consult ITU specification T.4 for the algorithm. + */ +static void encode_2d_row(t4_t6_encode_state_t *s, const uint8_t *row_buf) +{ + static const t4_run_table_entry_t codes[] = + { + {7, 0x60, 0}, /* VR3 0000 011 */ + {6, 0x30, 0}, /* VR2 0000 11 */ + {3, 0x06, 0}, /* VR1 011 */ + {1, 0x01, 0}, /* V0 1 */ + {3, 0x02, 0}, /* VL1 010 */ + {6, 0x10, 0}, /* VL2 0000 10 */ + {7, 0x20, 0}, /* VL3 0000 010 */ + {3, 0x04, 0}, /* horizontal 001 */ + {4, 0x08, 0} /* pass 0001 */ + }; + + /* The reference or starting changing element on the coding line. At the start of the coding + line, a0 is set on an imaginary white changing element situated just before the first element + on the line. During the coding of the coding line, the position of a0 is defined by the + previous coding mode. (See T.4/4.2.1.3.2.) */ + int a0; + /* The next changing element to the right of a0 on the coding line. */ + int a1; + /* The next changing element to the right of a1 on the coding line. */ + int a2; + /* The first changing element on the reference line to the right of a0 and of opposite colour to a0. */ + int b1; + /* The next changing element to the right of b1 on the reference line. */ + int b2; + int diff; + int a_cursor; + int b_cursor; + int cur_steps; + uint32_t *p; + + /* + b1 b2 + XX XX XX XX XX -- -- -- -- -- XX XX XX -- -- -- -- -- + XX XX XX -- -- -- -- -- XX XX XX XX XX XX -- -- -- -- + a0 a1 a2 + + + a) Pass mode + This mode is identified when the position of b2 lies to the left of a1. When this mode + has been coded, a0 is set on the element of the coding line below b2 in preparation for + the next coding (i.e. on a0'). + + b1 b2 + XX XX XX XX -- -- XX XX XX -- -- -- -- -- + XX XX -- -- -- -- -- -- -- -- -- -- XX XX + a0 a0' a1 + Pass mode + + + However, the state where b2 occurs just above a1, as shown in the figure below, is not + considered as a pass mode. + + b1 b2 + XX XX XX XX -- -- XX XX XX -- -- -- -- -- + XX XX -- -- -- -- -- -- -- XX XX XX XX XX + a0 a1 + Not pass mode + + + b) Vertical mode + When this mode is identified, the position of a1 is coded relative to the position of b1. + The relative distance a1b1 can take on one of seven values V(0), VR(1), VR(2), VR(3), + VL(1), VL(2) and VL(3), each of which is represented by a separate code word. The + subscripts R and L indicate that a1 is to the right or left respectively of b1, and the + number in brackets indicates the value of the distance a1b1. After vertical mode coding + has occurred, the position of a0 is set on a1 (see figure below). + + c) Horizontal mode + When this mode is identified, both the run-lengths a0a1 and a1a2 are coded using the code + words H + M(a0a1) + M(a1a2). H is the flag code word 001 taken from the two-dimensional + code table. M(a0a1) and M(a1a2) are code words which represent the length and "colour" + of the runs a0a1 and a1a2 respectively and are taken from the appropriate white or black + one-dimensional code tables. After a horizontal mode coding, the position of a0 is set on + a2 (see figure below). + + Vertical + + b1 b2 + -- XX XX XX XX XX -- -- -- -- -- -- -- -- XX XX XX XX -- -- -- + -- -- -- -- -- -- -- -- -- -- -- -- XX XX XX XX XX XX XX -- -- + a0 a1 a2 + <-------- a0a1 --------><-------- a1a2 ------------> + Horizontal mode + Vertical and horizontal modes + */ + /* The following implements the 2-D encoding section of the flow chart in Figure7/T.4 */ + cur_steps = row_to_run_lengths(s->cur_runs, row_buf, s->image_width); + /* Stretch the row a little, so when we step by 2 we are guaranteed to + hit an entry showing the row length. */ + s->cur_runs[cur_steps] = + s->cur_runs[cur_steps + 1] = + s->cur_runs[cur_steps + 2] = s->cur_runs[cur_steps - 1]; + + a0 = 0; + a1 = s->cur_runs[0]; + b1 = s->ref_runs[0]; + a_cursor = 0; + b_cursor = 0; + for (;;) + { + b2 = s->ref_runs[b_cursor + 1]; + if (b2 >= a1) + { + diff = b1 - a1; + if (abs(diff) <= 3) + { + /* Vertical mode coding */ + put_encoded_bits(s, codes[diff + 3].code, codes[diff + 3].length); + a0 = a1; + a_cursor++; + } + else + { + /* Horizontal mode coding */ + a2 = s->cur_runs[a_cursor + 1]; + put_encoded_bits(s, codes[7].code, codes[7].length); + if (a0 + a1 == 0 || pixel_is_black(row_buf, a0) == 0) + { + put_1d_span(s, a1 - a0, t4_white_codes); + put_1d_span(s, a2 - a1, t4_black_codes); + } + else + { + put_1d_span(s, a1 - a0, t4_black_codes); + put_1d_span(s, a2 - a1, t4_white_codes); + } + a0 = a2; + a_cursor += 2; + } + if (a0 >= s->image_width) + break; + if (a_cursor >= cur_steps) + a_cursor = cur_steps - 1; + a1 = s->cur_runs[a_cursor]; + } + else + { + /* Pass mode coding */ + put_encoded_bits(s, codes[8].code, codes[8].length); + /* We now set a0 to somewhere in the middle of its current run, + but we know are aren't moving beyond that run. */ + a0 = b2; + if (a0 >= s->image_width) + break; + } + /* We need to hunt for the correct position in the reference row, as the + runs there have no particular alignment with the runs in the current + row. */ + if (pixel_is_black(row_buf, a0)) + b_cursor |= 1; + else + b_cursor &= ~1; + if (a0 < (int) s->ref_runs[b_cursor]) + { + for ( ; b_cursor >= 0; b_cursor -= 2) + { + if (a0 >= (int) s->ref_runs[b_cursor]) + break; + } + b_cursor += 2; + } + else + { + for ( ; b_cursor < s->ref_steps; b_cursor += 2) + { + if (a0 < (int) s->ref_runs[b_cursor]) + break; + } + if (b_cursor >= s->ref_steps) + b_cursor = s->ref_steps - 1; + } + b1 = s->ref_runs[b_cursor]; + } + /* Swap the buffers */ + s->ref_steps = cur_steps; + p = s->cur_runs; + s->cur_runs = s->ref_runs; + s->ref_runs = p; +} +/*- End of function --------------------------------------------------------*/ + +/* + * 1D-encode a row of pixels. The encoding is a sequence of all-white or + * all-black spans of pixels encoded with Huffman codes. + */ +static void encode_1d_row(t4_t6_encode_state_t *s, const uint8_t *row_buf) +{ + int i; + + /* Do our work in the reference row buffer, and it is already in place if + we need a reference row for a following 2D encoded row. */ + s->ref_steps = row_to_run_lengths(s->ref_runs, row_buf, s->image_width); + put_1d_span(s, s->ref_runs[0], t4_white_codes); + for (i = 1; i < s->ref_steps; i++) + put_1d_span(s, s->ref_runs[i] - s->ref_runs[i - 1], (i & 1) ? t4_black_codes : t4_white_codes); + /* Stretch the row a little, so when we step by 2 we are guaranteed to + hit an entry showing the row length */ + s->ref_runs[s->ref_steps] = + s->ref_runs[s->ref_steps + 1] = + s->ref_runs[s->ref_steps + 2] = s->ref_runs[s->ref_steps - 1]; +} +/*- End of function --------------------------------------------------------*/ + +static int encode_row(t4_t6_encode_state_t *s, const uint8_t *row_buf, size_t len) +{ + switch (s->encoding) + { + case T4_COMPRESSION_ITU_T6: + /* T.6 compression is a trivial step up from T.4 2D, so we just + throw it in here. T.6 is only used with error correction, + so it does not need independantly compressed (i.e. 1D) lines + to recover from data errors. It doesn't need EOLs, either. */ + encode_2d_row(s, row_buf); + break; + case T4_COMPRESSION_ITU_T4_2D: + encode_eol(s); + if (s->row_is_2d) + { + encode_2d_row(s, row_buf); + s->rows_to_next_1d_row--; + } + else + { + encode_1d_row(s, row_buf); + s->row_is_2d = TRUE; + } + if (s->rows_to_next_1d_row <= 0) + { + /* Insert a row of 1D encoding */ + s->row_is_2d = FALSE; + s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1; + } + break; + default: + case T4_COMPRESSION_ITU_T4_1D: + encode_eol(s); + encode_1d_row(s, row_buf); + break; + } + s->image_length++; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int finalise_page(t4_t6_encode_state_t *s) +{ + int i; + + if (s->encoding == T4_COMPRESSION_ITU_T6) + { + /* Attach an EOFB (end of facsimile block == 2 x EOLs) to the end of the page */ + for (i = 0; i < EOLS_TO_END_T6_TX_PAGE; i++) + encode_eol(s); + } + else + { + /* Attach an RTC (return to control == 6 x EOLs) to the end of the page */ + s->row_is_2d = FALSE; + for (i = 0; i < EOLS_TO_END_T4_TX_PAGE; i++) + encode_eol(s); + } + /* Force any partial byte in progress to flush using ones. Any post EOL padding when + sending is normally ones, so this is consistent. */ + put_encoded_bits(s, 0xFF, 7); + /* Flag that page generation has finished */ + s->row_bits = -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int get_next_row(t4_t6_encode_state_t *s) +{ + int len; +#if defined(_MSC_VER) + uint8_t *row_buf = (uint8_t *) _alloca(s->bytes_per_row); +#else + uint8_t row_buf[s->bytes_per_row]; +#endif + + if (s->row_bits < 0 || s->row_read_handler == NULL) + return -1; + len = -1; + s->bitstream_iptr = 0; + s->bitstream_optr = 0; + s->bit_pos = 7; + /* A row may not actually fill a byte of output buffer space in T.6 mode, + so we loop here until we have at least one byte of output bit stream, + and can continue outputting. */ + do + { + len = s->row_read_handler(s->row_read_user_data, row_buf, s->bytes_per_row); + if (len == s->bytes_per_row) + encode_row(s, row_buf, len); + else + finalise_page(s); + } + while (len > 0 && s->bitstream_iptr == 0); + s->compressed_image_size += 8*s->bitstream_iptr; + return len; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_image_complete(t4_t6_encode_state_t *s) +{ + if (s->bitstream_optr >= s->bitstream_iptr) + { + if (get_next_row(s) < 0) + return SIG_STATUS_END_OF_DATA; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s) +{ + int bit; + + if (s->bitstream_optr >= s->bitstream_iptr) + { + if (get_next_row(s) < 0) + return SIG_STATUS_END_OF_DATA; + } + bit = (s->bitstream[s->bitstream_optr] >> (7 - s->bit_pos)) & 1; + if (--s->bit_pos < 0) + { + s->bitstream_optr++; + s->bit_pos = 7; + } + return bit; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_get(t4_t6_encode_state_t *s, uint8_t buf[], int max_len) +{ + int len; + int n; + + for (len = 0; len < max_len; len += n) + { + if (s->bitstream_optr >= s->bitstream_iptr) + { + if (get_next_row(s) < 0) + return len; + } + n = s->bitstream_iptr - s->bitstream_optr; + if (n > max_len - len) + n = max_len - len; + memcpy(&buf[len], &s->bitstream[s->bitstream_optr], n); + s->bitstream_optr += n; + } + return len; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_set_row_read_handler(t4_t6_encode_state_t *s, t4_row_read_handler_t handler, void *user_data) +{ + s->row_read_handler = handler; + s->row_read_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_set_encoding(t4_t6_encode_state_t *s, int encoding) +{ + switch (encoding) + { + case T4_COMPRESSION_ITU_T6: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T4_1D: + s->encoding = encoding; + /* Set this to the default value for the lowest resolution in the T.4 spec. */ + s->max_rows_to_next_1d_row = 2; + s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1; + s->row_is_2d = FALSE; + return 0; + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_t6_encode_set_min_bits_per_row(t4_t6_encode_state_t *s, int bits) +{ + s->min_bits_per_row = bits; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int image_width) +{ + int run_space; + uint32_t *bufptr; + uint8_t *bufptr8; + + /* TODO: Are we too late to change the width */ + if (s->bytes_per_row == 0 || image_width != s->image_width) + { + s->image_width = image_width; + s->bytes_per_row = (s->image_width + 7)/8; + run_space = (s->image_width + 4)*sizeof(uint32_t); + + if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) + return -1; + s->cur_runs = bufptr; + if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL) + return -1; + s->ref_runs = bufptr; + if ((bufptr8 = (uint8_t *) realloc(s->bitstream, (s->image_width + 1)*sizeof(uint16_t))) == NULL) + return -1; + s->bitstream = bufptr8; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_width(t4_t6_encode_state_t *s) +{ + return s->image_width; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_length(t4_t6_encode_state_t *s) +{ + return s->image_length; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_get_compressed_image_size(t4_t6_encode_state_t *s) +{ + return s->compressed_image_size; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_t6_encode_set_max_2d_rows_per_1d_row(t4_t6_encode_state_t *s, int max) +{ + static const struct + { + int code; + int max_rows; + } y_res_table[] = + { + {T4_Y_RESOLUTION_STANDARD, 2}, + {T4_Y_RESOLUTION_FINE, 4}, + {T4_Y_RESOLUTION_300, 6}, + {T4_Y_RESOLUTION_SUPERFINE, 8}, + {T4_Y_RESOLUTION_600, 12}, + {T4_Y_RESOLUTION_800, 16}, + {T4_Y_RESOLUTION_1200, 24}, + {-1, -1} + }; + int i; + int res; + + if (max < 0) + { + /* Its actually a resolution code we need to translate into an appropriate + number of rows. Note that we only hit on exact known resolutions. */ + res = -max; + max = 2; + for (i = 0; y_res_table[i].code > 0; i++) + { + if (res == y_res_table[i].code) + { + max = y_res_table[i].max_rows; + break; + } + } + } + s->max_rows_to_next_1d_row = max; + s->rows_to_next_1d_row = max - 1; + s->row_is_2d = FALSE; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_restart(t4_t6_encode_state_t *s, int image_width) +{ + /* Allow for pages being of different width. */ + t4_t6_encode_set_image_width(s, image_width); + s->row_is_2d = (s->encoding == T4_COMPRESSION_ITU_T6); + s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1; + + s->tx_bitstream = 0; + s->bitstream_iptr = 0; + s->bitstream_optr = 0; + s->bit_pos = 7; + s->tx_bits = 0; + s->row_bits = 0; + s->min_row_bits = INT_MAX; + s->max_row_bits = 0; + s->image_length = 0; + s->compressed_image_size = 0; + + s->ref_runs[0] = + s->ref_runs[1] = + s->ref_runs[2] = + s->ref_runs[3] = s->image_width; + s->ref_steps = 1; + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t4_t6_encode_state_t *) t4_t6_encode_init(t4_t6_encode_state_t *s, + int encoding, + int image_width, + t4_row_read_handler_t handler, + void *user_data) +{ + if (s == NULL) + { + if ((s = (t4_t6_encode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.4/T.6"); + + s->encoding = encoding; + s->row_read_handler = handler; + s->row_read_user_data = user_data; + + s->max_rows_to_next_1d_row = 2; + t4_t6_encode_restart(s, image_width); + + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_release(t4_t6_encode_state_t *s) +{ + free_buffers(s); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_t6_encode_free(t4_t6_encode_state_t *s) +{ + int ret; + + ret = t4_t6_encode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index 1c9f9a2b5e..6aeef44d22 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -1,4 +1,3 @@ -//#define T4_STATE_DEBUGGING /* * SpanDSP - a series of DSP components for telephony * @@ -6,7 +5,7 @@ * * Written by Steve Underwood * - * Copyright (C) 2003, 2007 Steve Underwood + * Copyright (C) 2003, 2007, 2010 Steve Underwood * * All rights reserved. * @@ -24,33 +23,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - * Much of this file is based on the T.4 and T.6 support in libtiff, which requires - * the following notice in any derived source code: - * - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - /*! \file */ #if defined(HAVE_CONFIG_H) @@ -82,44 +54,39 @@ #include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T85) +#include "spandsp/image_translate.h" #include "spandsp/t81_t82_arith_coding.h" #include "spandsp/t85.h" +#include "spandsp/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/t43.h" #endif #include "spandsp/t4_t6_decode.h" #include "spandsp/t4_t6_encode.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #include "spandsp/private/t85.h" +#include "spandsp/private/t42.h" +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/private/t43.h" #endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" +#include "spandsp/private/image_translate.h" #include "spandsp/private/t4_rx.h" #include "spandsp/private/t4_tx.h" +#include "faxfont.h" + +#if defined(SPANDSP_SUPPORT_TIFF_FX) +#include +#endif + /*! The number of centimetres in one inch */ #define CM_PER_INCH 2.54f -/*! The number of EOLs to be sent at the end of a T.4 page */ -#define EOLS_TO_END_T4_TX_PAGE 6 -/*! The number of EOLs to be sent at the end of a T.6 page */ -#define EOLS_TO_END_T6_TX_PAGE 2 - -#if defined(T4_STATE_DEBUGGING) -static void STATE_TRACE(const char *format, ...) -{ - va_list arg_ptr; - - va_start(arg_ptr, format); - vprintf(format, arg_ptr); - va_end(arg_ptr); -} -/*- End of function --------------------------------------------------------*/ -#else -#define STATE_TRACE(...) /**/ -#endif +static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length); #if defined(SPANDSP_SUPPORT_TIFF_FX) /* TIFF-FX related extensions to the tag set supported by libtiff */ @@ -132,19 +99,37 @@ static const TIFFFieldInfo tiff_fx_tiff_field_info[] = {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "CodingMethods"}, {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "VersionYear"}, {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, FIELD_CUSTOM, FALSE, FALSE, (char *) "ModeNumber"}, - {TIFFTAG_DECODE, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SRATIONAL, FIELD_CUSTOM, FALSE, FALSE, (char *) "Decode"}, - {TIFFTAG_IMAGEBASECOLOR, TIFF_SPP, TIFF_SPP, TIFF_SHORT, FIELD_CUSTOM, FALSE, FALSE, (char *) "ImageBaseColor"}, + {TIFFTAG_DECODE, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SRATIONAL, FIELD_CUSTOM, FALSE, TRUE, (char *) "Decode"}, + {TIFFTAG_IMAGEBASECOLOR, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SHORT, FIELD_CUSTOM, FALSE, TRUE, (char *) "ImageBaseColor"}, {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "T82Options"}, {TIFFTAG_STRIPROWCOUNTS, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_LONG, FIELD_CUSTOM, FALSE, TRUE, (char *) "StripRowCounts"}, {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "ImageLayer"}, }; +static TIFFField tiff_fx_tiff_fields[] = +{ + { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "Indexed" }, + { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "GlobalParametersIFD", NULL }, + { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "ProfileType", NULL }, + { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "FaxProfile", NULL }, + { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "CodingMethods", NULL }, + { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "VersionYear", NULL }, + { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "ModeNumber", NULL }, + { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, (char *) "Decode", NULL }, + { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, (char *) "ImageBaseColor", NULL }, + { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "T82Options", NULL }, + { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, (char *) "StripRowCounts", NULL }, + { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "ImageLayer", NULL }, +}; + +TIFFFieldArray tiff_fx_field_array = { tfiatOther, 0, 12, tiff_fx_tiff_fields }; + static TIFFExtendProc _ParentExtender = NULL; static void TIFFFXDefaultDirectory(TIFF *tif) { /* Install the extended tag field info */ - TIFFMergeFieldInfo(tif, tiff_fx_tiff_field_info, 11); + TIFFMergeFieldInfo(tif, tiff_fx_tiff_field_info, 12); /* Since we may have overriddden another directory method, we call it now to allow it to set up the rest of its own methods. */ @@ -167,271 +152,517 @@ SPAN_DECLARE(void) TIFF_FX_init(void) /*- End of function --------------------------------------------------------*/ #endif -/*! T.4 run length table entry */ -typedef struct +static int test_resolution(int res_unit, float actual, float expected) { - /*! Length of T.4 code, in bits */ - uint16_t length; - /*! T.4 code */ - uint16_t code; - /*! Run length, in bits */ - int16_t run_length; -} t4_run_table_entry_t; + if (res_unit == RESUNIT_INCH) + actual *= 1.0f/CM_PER_INCH; + return (expected*0.95f <= actual && actual <= expected*1.05f); +} +/*- End of function --------------------------------------------------------*/ -#include "faxfont.h" - -/* Legitimate runs of zero bits which are the tail end of one code - plus the start of the next code do not exceed 10 bits. */ - -/* - * Note that these tables are ordered such that the index into the table - * is known to be either the run length, or (run length / 64) + a fixed - * offset. - */ -static const t4_run_table_entry_t t4_white_codes[] = +#if defined(SPANDSP_SUPPORT_TIFF_FX) +static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) { - { 8, 0x00AC, 0}, /* 0011 0101 */ - { 6, 0x0038, 1}, /* 0001 11 */ - { 4, 0x000E, 2}, /* 0111 */ - { 4, 0x0001, 3}, /* 1000 */ - { 4, 0x000D, 4}, /* 1011 */ - { 4, 0x0003, 5}, /* 1100 */ - { 4, 0x0007, 6}, /* 1110 */ - { 4, 0x000F, 7}, /* 1111 */ - { 5, 0x0019, 8}, /* 1001 1 */ - { 5, 0x0005, 9}, /* 1010 0 */ - { 5, 0x001C, 10}, /* 0011 1 */ - { 5, 0x0002, 11}, /* 0100 0 */ - { 6, 0x0004, 12}, /* 0010 00 */ - { 6, 0x0030, 13}, /* 0000 11 */ - { 6, 0x000B, 14}, /* 1101 00 */ - { 6, 0x002B, 15}, /* 1101 01 */ - { 6, 0x0015, 16}, /* 1010 10 */ - { 6, 0x0035, 17}, /* 1010 11 */ - { 7, 0x0072, 18}, /* 0100 111 */ - { 7, 0x0018, 19}, /* 0001 100 */ - { 7, 0x0008, 20}, /* 0001 000 */ - { 7, 0x0074, 21}, /* 0010 111 */ - { 7, 0x0060, 22}, /* 0000 011 */ - { 7, 0x0010, 23}, /* 0000 100 */ - { 7, 0x000A, 24}, /* 0101 000 */ - { 7, 0x006A, 25}, /* 0101 011 */ - { 7, 0x0064, 26}, /* 0010 011 */ - { 7, 0x0012, 27}, /* 0100 100 */ - { 7, 0x000C, 28}, /* 0011 000 */ - { 8, 0x0040, 29}, /* 0000 0010 */ - { 8, 0x00C0, 30}, /* 0000 0011 */ - { 8, 0x0058, 31}, /* 0001 1010 */ - { 8, 0x00D8, 32}, /* 0001 1011 */ - { 8, 0x0048, 33}, /* 0001 0010 */ - { 8, 0x00C8, 34}, /* 0001 0011 */ - { 8, 0x0028, 35}, /* 0001 0100 */ - { 8, 0x00A8, 36}, /* 0001 0101 */ - { 8, 0x0068, 37}, /* 0001 0110 */ - { 8, 0x00E8, 38}, /* 0001 0111 */ - { 8, 0x0014, 39}, /* 0010 1000 */ - { 8, 0x0094, 40}, /* 0010 1001 */ - { 8, 0x0054, 41}, /* 0010 1010 */ - { 8, 0x00D4, 42}, /* 0010 1011 */ - { 8, 0x0034, 43}, /* 0010 1100 */ - { 8, 0x00B4, 44}, /* 0010 1101 */ - { 8, 0x0020, 45}, /* 0000 0100 */ - { 8, 0x00A0, 46}, /* 0000 0101 */ - { 8, 0x0050, 47}, /* 0000 1010 */ - { 8, 0x00D0, 48}, /* 0000 1011 */ - { 8, 0x004A, 49}, /* 0101 0010 */ - { 8, 0x00CA, 50}, /* 0101 0011 */ - { 8, 0x002A, 51}, /* 0101 0100 */ - { 8, 0x00AA, 52}, /* 0101 0101 */ - { 8, 0x0024, 53}, /* 0010 0100 */ - { 8, 0x00A4, 54}, /* 0010 0101 */ - { 8, 0x001A, 55}, /* 0101 1000 */ - { 8, 0x009A, 56}, /* 0101 1001 */ - { 8, 0x005A, 57}, /* 0101 1010 */ - { 8, 0x00DA, 58}, /* 0101 1011 */ - { 8, 0x0052, 59}, /* 0100 1010 */ - { 8, 0x00D2, 60}, /* 0100 1011 */ - { 8, 0x004C, 61}, /* 0011 0010 */ - { 8, 0x00CC, 62}, /* 0011 0011 */ - { 8, 0x002C, 63}, /* 0011 0100 */ - { 5, 0x001B, 64}, /* 1101 1 */ - { 5, 0x0009, 128}, /* 1001 0 */ - { 6, 0x003A, 192}, /* 0101 11 */ - { 7, 0x0076, 256}, /* 0110 111 */ - { 8, 0x006C, 320}, /* 0011 0110 */ - { 8, 0x00EC, 384}, /* 0011 0111 */ - { 8, 0x0026, 448}, /* 0110 0100 */ - { 8, 0x00A6, 512}, /* 0110 0101 */ - { 8, 0x0016, 576}, /* 0110 1000 */ - { 8, 0x00E6, 640}, /* 0110 0111 */ - { 9, 0x0066, 704}, /* 0110 0110 0 */ - { 9, 0x0166, 768}, /* 0110 0110 1 */ - { 9, 0x0096, 832}, /* 0110 1001 0 */ - { 9, 0x0196, 896}, /* 0110 1001 1 */ - { 9, 0x0056, 960}, /* 0110 1010 0 */ - { 9, 0x0156, 1024}, /* 0110 1010 1 */ - { 9, 0x00D6, 1088}, /* 0110 1011 0 */ - { 9, 0x01D6, 1152}, /* 0110 1011 1 */ - { 9, 0x0036, 1216}, /* 0110 1100 0 */ - { 9, 0x0136, 1280}, /* 0110 1100 1 */ - { 9, 0x00B6, 1344}, /* 0110 1101 0 */ - { 9, 0x01B6, 1408}, /* 0110 1101 1 */ - { 9, 0x0032, 1472}, /* 0100 1100 0 */ - { 9, 0x0132, 1536}, /* 0100 1100 1 */ - { 9, 0x00B2, 1600}, /* 0100 1101 0 */ - { 6, 0x0006, 1664}, /* 0110 00 */ - { 9, 0x01B2, 1728}, /* 0100 1101 1 */ - {11, 0x0080, 1792}, /* 0000 0001 000 */ - {11, 0x0180, 1856}, /* 0000 0001 100 */ - {11, 0x0580, 1920}, /* 0000 0001 101 */ - {12, 0x0480, 1984}, /* 0000 0001 0010 */ - {12, 0x0C80, 2048}, /* 0000 0001 0011 */ - {12, 0x0280, 2112}, /* 0000 0001 0100 */ - {12, 0x0A80, 2176}, /* 0000 0001 0101 */ - {12, 0x0680, 2240}, /* 0000 0001 0110 */ - {12, 0x0E80, 2304}, /* 0000 0001 0111 */ - {12, 0x0380, 2368}, /* 0000 0001 1100 */ - {12, 0x0B80, 2432}, /* 0000 0001 1101 */ - {12, 0x0780, 2496}, /* 0000 0001 1110 */ - {12, 0x0F80, 2560}, /* 0000 0001 1111 */ -}; + int i; + uint16_t *map_L; + uint16_t *map_a; + uint16_t *map_b; + uint16_t *map_z; -static const t4_run_table_entry_t t4_black_codes[] = + map_L = NULL; + map_a = NULL; + map_b = NULL; + map_z = NULL; + if (!TIFFGetField(s->tiff.tiff_file, TIFFTAG_COLORMAP, &map_L, &map_a, &map_b, &map_z)) + return -1; + + /* TODO: This only allows for 8 bit deep maps */ + if ((s->colour_map = realloc(s->colour_map, 3*256)) == NULL) + return -1; + span_log(&s->logging, SPAN_LOG_FLOW, "Got a colour map\n"); +#if 0 + /* Sweep the colormap in the proper order */ + for (i = 0; i < (1 << bits_per_sample); i++) + { + s->colour_map[3*i + 0] = (map_L[i] >> 8) & 0xFF; + s->colour_map[3*i + 1] = (map_a[i] >> 8) & 0xFF; + s->colour_map[3*i + 2] = (map_b[i] >> 8) & 0xFF; + span_log(&s->logging, SPAN_LOG_FLOW, "Map %3d - %5d %5d %5d\n", i, s->colour_map[3*i], s->colour_map[3*i + 1], s->colour_map[3*i + 2]); + } +#else + /* Sweep the colormap in the order that seems to work for l04x_02x.tif */ + for (i = 0; i < (1 << bits_per_sample); i++) + { + s->colour_map[0*256 + i] = (map_L[i] >> 8) & 0xFF; + s->colour_map[1*256 + i] = (map_a[i] >> 8) & 0xFF; + s->colour_map[2*256 + i] = (map_b[i] >> 8) & 0xFF; + } +#endif + lab_to_srgb(&s->lab_params, s->colour_map, s->colour_map, 256); + for (i = 0; i < (1 << bits_per_sample); i++) + span_log(&s->logging, SPAN_LOG_FLOW, "Map %3d - %5d %5d %5d\n", i, s->colour_map[3*i], s->colour_map[3*i + 1], s->colour_map[3*i + 2]); + return 0; +} +/*- End of function --------------------------------------------------------*/ +#endif + +static int get_tiff_directory_info(t4_tx_state_t *s) { - {10, 0x03B0, 0}, /* 0000 1101 11 */ - { 3, 0x0002, 1}, /* 010 */ - { 2, 0x0003, 2}, /* 11 */ - { 2, 0x0001, 3}, /* 10 */ - { 3, 0x0006, 4}, /* 011 */ - { 4, 0x000C, 5}, /* 0011 */ - { 4, 0x0004, 6}, /* 0010 */ - { 5, 0x0018, 7}, /* 0001 1 */ - { 6, 0x0028, 8}, /* 0001 01 */ - { 6, 0x0008, 9}, /* 0001 00 */ - { 7, 0x0010, 10}, /* 0000 100 */ - { 7, 0x0050, 11}, /* 0000 101 */ - { 7, 0x0070, 12}, /* 0000 111 */ - { 8, 0x0020, 13}, /* 0000 0100 */ - { 8, 0x00E0, 14}, /* 0000 0111 */ - { 9, 0x0030, 15}, /* 0000 1100 0 */ - {10, 0x03A0, 16}, /* 0000 0101 11 */ - {10, 0x0060, 17}, /* 0000 0110 00 */ - {10, 0x0040, 18}, /* 0000 0010 00 */ - {11, 0x0730, 19}, /* 0000 1100 111 */ - {11, 0x00B0, 20}, /* 0000 1101 000 */ - {11, 0x01B0, 21}, /* 0000 1101 100 */ - {11, 0x0760, 22}, /* 0000 0110 111 */ - {11, 0x00A0, 23}, /* 0000 0101 000 */ - {11, 0x0740, 24}, /* 0000 0010 111 */ - {11, 0x00C0, 25}, /* 0000 0011 000 */ - {12, 0x0530, 26}, /* 0000 1100 1010 */ - {12, 0x0D30, 27}, /* 0000 1100 1011 */ - {12, 0x0330, 28}, /* 0000 1100 1100 */ - {12, 0x0B30, 29}, /* 0000 1100 1101 */ - {12, 0x0160, 30}, /* 0000 0110 1000 */ - {12, 0x0960, 31}, /* 0000 0110 1001 */ - {12, 0x0560, 32}, /* 0000 0110 1010 */ - {12, 0x0D60, 33}, /* 0000 0110 1011 */ - {12, 0x04B0, 34}, /* 0000 1101 0010 */ - {12, 0x0CB0, 35}, /* 0000 1101 0011 */ - {12, 0x02B0, 36}, /* 0000 1101 0100 */ - {12, 0x0AB0, 37}, /* 0000 1101 0101 */ - {12, 0x06B0, 38}, /* 0000 1101 0110 */ - {12, 0x0EB0, 39}, /* 0000 1101 0111 */ - {12, 0x0360, 40}, /* 0000 0110 1100 */ - {12, 0x0B60, 41}, /* 0000 0110 1101 */ - {12, 0x05B0, 42}, /* 0000 1101 1010 */ - {12, 0x0DB0, 43}, /* 0000 1101 1011 */ - {12, 0x02A0, 44}, /* 0000 0101 0100 */ - {12, 0x0AA0, 45}, /* 0000 0101 0101 */ - {12, 0x06A0, 46}, /* 0000 0101 0110 */ - {12, 0x0EA0, 47}, /* 0000 0101 0111 */ - {12, 0x0260, 48}, /* 0000 0110 0100 */ - {12, 0x0A60, 49}, /* 0000 0110 0101 */ - {12, 0x04A0, 50}, /* 0000 0101 0010 */ - {12, 0x0CA0, 51}, /* 0000 0101 0011 */ - {12, 0x0240, 52}, /* 0000 0010 0100 */ - {12, 0x0EC0, 53}, /* 0000 0011 0111 */ - {12, 0x01C0, 54}, /* 0000 0011 1000 */ - {12, 0x0E40, 55}, /* 0000 0010 0111 */ - {12, 0x0140, 56}, /* 0000 0010 1000 */ - {12, 0x01A0, 57}, /* 0000 0101 1000 */ - {12, 0x09A0, 58}, /* 0000 0101 1001 */ - {12, 0x0D40, 59}, /* 0000 0010 1011 */ - {12, 0x0340, 60}, /* 0000 0010 1100 */ - {12, 0x05A0, 61}, /* 0000 0101 1010 */ - {12, 0x0660, 62}, /* 0000 0110 0110 */ - {12, 0x0E60, 63}, /* 0000 0110 0111 */ - {10, 0x03C0, 64}, /* 0000 0011 11 */ - {12, 0x0130, 128}, /* 0000 1100 1000 */ - {12, 0x0930, 192}, /* 0000 1100 1001 */ - {12, 0x0DA0, 256}, /* 0000 0101 1011 */ - {12, 0x0CC0, 320}, /* 0000 0011 0011 */ - {12, 0x02C0, 384}, /* 0000 0011 0100 */ - {12, 0x0AC0, 448}, /* 0000 0011 0101 */ - {13, 0x06C0, 512}, /* 0000 0011 0110 0 */ - {13, 0x16C0, 576}, /* 0000 0011 0110 1 */ - {13, 0x0A40, 640}, /* 0000 0010 0101 0 */ - {13, 0x1A40, 704}, /* 0000 0010 0101 1 */ - {13, 0x0640, 768}, /* 0000 0010 0110 0 */ - {13, 0x1640, 832}, /* 0000 0010 0110 1 */ - {13, 0x09C0, 896}, /* 0000 0011 1001 0 */ - {13, 0x19C0, 960}, /* 0000 0011 1001 1 */ - {13, 0x05C0, 1024}, /* 0000 0011 1010 0 */ - {13, 0x15C0, 1088}, /* 0000 0011 1010 1 */ - {13, 0x0DC0, 1152}, /* 0000 0011 1011 0 */ - {13, 0x1DC0, 1216}, /* 0000 0011 1011 1 */ - {13, 0x0940, 1280}, /* 0000 0010 1001 0 */ - {13, 0x1940, 1344}, /* 0000 0010 1001 1 */ - {13, 0x0540, 1408}, /* 0000 0010 1010 0 */ - {13, 0x1540, 1472}, /* 0000 0010 1010 1 */ - {13, 0x0B40, 1536}, /* 0000 0010 1101 0 */ - {13, 0x1B40, 1600}, /* 0000 0010 1101 1 */ - {13, 0x04C0, 1664}, /* 0000 0011 0010 0 */ - {13, 0x14C0, 1728}, /* 0000 0011 0010 1 */ - {11, 0x0080, 1792}, /* 0000 0001 000 */ - {11, 0x0180, 1856}, /* 0000 0001 100 */ - {11, 0x0580, 1920}, /* 0000 0001 101 */ - {12, 0x0480, 1984}, /* 0000 0001 0010 */ - {12, 0x0C80, 2048}, /* 0000 0001 0011 */ - {12, 0x0280, 2112}, /* 0000 0001 0100 */ - {12, 0x0A80, 2176}, /* 0000 0001 0101 */ - {12, 0x0680, 2240}, /* 0000 0001 0110 */ - {12, 0x0E80, 2304}, /* 0000 0001 0111 */ - {12, 0x0380, 2368}, /* 0000 0001 1100 */ - {12, 0x0B80, 2432}, /* 0000 0001 1101 */ - {12, 0x0780, 2496}, /* 0000 0001 1110 */ - {12, 0x0F80, 2560}, /* 0000 0001 1111 */ -}; + static const struct + { + float resolution; + int code; + } x_res_table[] = + { + { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4}, + { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8}, + { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300}, + { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16}, + { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600}, + { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800}, + {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200}, + { -1.00f, -1} + }; + static const struct + { + float resolution; + int code; + } y_res_table[] = + { + { 38.50f, T4_Y_RESOLUTION_STANDARD}, + { 77.00f, T4_Y_RESOLUTION_FINE}, + { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300}, + { 154.00f, T4_Y_RESOLUTION_SUPERFINE}, + { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600}, + { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800}, + {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200}, + { -1.00f, -1} + }; +#if defined(SPANDSP_SUPPORT_TIFF_FX) + static const char *tiff_fx_fax_profiles[] = + { + "???", + "profile S", + "profile F", + "profile J", + "profile C", + "profile L", + "profile M" + }; + char *u; + char uu[10]; + uint8_t parm8; + uint16_t parm16; +#endif + uint32_t parm32; + float x_resolution; + float y_resolution; + int i; + t4_tx_tiff_state_t *t; + uint16_t bits_per_sample; + uint16_t samples_per_pixel; + uint16_t res_unit; -static int encode_row(t4_state_t *s); + t = &s->tiff; + bits_per_sample = 1; + TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); + samples_per_pixel = 1; + TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); + if (samples_per_pixel == 1 && bits_per_sample == 1) + t->image_type = T4_IMAGE_TYPE_BILEVEL; + else if (samples_per_pixel == 3 && bits_per_sample == 1) + t->image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL; + else if (samples_per_pixel == 1 && bits_per_sample == 8) + t->image_type = T4_IMAGE_TYPE_GRAY_8BIT; + else if (samples_per_pixel == 1 && bits_per_sample > 8) + t->image_type = T4_IMAGE_TYPE_GRAY_12BIT; + else if (samples_per_pixel == 3 && bits_per_sample == 8) + t->image_type = T4_IMAGE_TYPE_COLOUR_8BIT; + else if (samples_per_pixel == 3 && bits_per_sample > 8) + t->image_type = T4_IMAGE_TYPE_COLOUR_12BIT; + else + return -1; +#if 0 + /* Limit ourselves to plain black and white pages */ + if (t->image_type != T4_IMAGE_TYPE_BILEVEL) + return -1; +#endif + parm32 = 0; + TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32); + s->image_width = parm32; + parm32 = 0; + TIFFGetField(t->tiff_file, TIFFTAG_IMAGELENGTH, &parm32); + s->tiff.image_length = + s->image_length = parm32; + x_resolution = 0.0f; + TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); + y_resolution = 0.0f; + TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); + res_unit = RESUNIT_INCH; + TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); + t->photo_metric = PHOTOMETRIC_MINISWHITE; + TIFFGetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, &t->photo_metric); -static void make_header(t4_state_t *s, char *header) + set_lab_illuminant(&s->lab_params, 0.9638f, 1.0f, 0.8245f); + set_lab_gamut(&s->lab_params, 0, 100, -85, 85, -75, 125, FALSE); + + t->compression = -1; + TIFFGetField(t->tiff_file, TIFFTAG_COMPRESSION, &t->compression); + t->fill_order = FILLORDER_LSB2MSB; + + /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the + precise value. The other value should be exact. */ + /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ + s->metadata.x_resolution = T4_X_RESOLUTION_R8; + for (i = 0; x_res_table[i].code > 0; i++) + { + if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution)) + { + s->metadata.x_resolution = x_res_table[i].code; + break; + } + } + + s->metadata.y_resolution = T4_Y_RESOLUTION_STANDARD; + for (i = 0; y_res_table[i].code > 0; i++) + { + if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution)) + { + s->metadata.y_resolution = y_res_table[i].code; + break; + } + } + t4_tx_set_image_width(s, s->image_width); + t4_tx_set_image_length(s, s->image_length); + t4_tx_set_max_2d_rows_per_1d_row(s, -s->metadata.y_resolution); +#if defined(SPANDSP_SUPPORT_TIFF_FX) + if (TIFFGetField(t->tiff_file, TIFFTAG_PROFILETYPE, &parm32)) + span_log(&s->logging, SPAN_LOG_FLOW, "Profile type %u\n", parm32); + if (TIFFGetField(t->tiff_file, TIFFTAG_FAXPROFILE, &parm8)) + span_log(&s->logging, SPAN_LOG_FLOW, "FAX profile %s (%u)\n", tiff_fx_fax_profiles[parm8], parm8); + if (TIFFGetField(t->tiff_file, TIFFTAG_CODINGMETHODS, &parm32)) + span_log(&s->logging, SPAN_LOG_FLOW, "Coding methods 0x%x\n", parm32); + if (TIFFGetField(t->tiff_file, TIFFTAG_VERSIONYEAR, &u)) + { + memcpy(uu, u, 4); + uu[4] = '\0'; + span_log(&s->logging, SPAN_LOG_FLOW, "Version year \"%s\"\n", uu); + } + if (TIFFGetField(t->tiff_file, TIFFTAG_MODENUMBER, &parm8)) + span_log(&s->logging, SPAN_LOG_FLOW, "Mode number %u\n", parm8); +#endif + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int test_tiff_directory_info(t4_tx_state_t *s) +{ + static const struct + { + float resolution; + int code; + } x_res_table[] = + { + { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4}, + { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8}, + { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300}, + { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16}, + { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600}, + { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800}, + {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200}, + { -1.00f, -1} + }; + static const struct + { + float resolution; + int code; + } y_res_table[] = + { + { 38.50f, T4_Y_RESOLUTION_STANDARD}, + { 77.00f, T4_Y_RESOLUTION_FINE}, + { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300}, + { 154.00f, T4_Y_RESOLUTION_SUPERFINE}, + { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600}, + { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800}, + {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200}, + { -1.00f, -1} + }; + uint16_t res_unit; + uint32_t parm32; + float x_resolution; + float y_resolution; + uint16_t bits_per_sample; + uint16_t samples_per_pixel; + int image_type; + int i; + t4_tx_tiff_state_t *t; + + t = &s->tiff; + bits_per_sample = 1; + TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); + samples_per_pixel = 1; + TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); + if (samples_per_pixel == 1 && bits_per_sample == 1) + image_type = T4_IMAGE_TYPE_BILEVEL; + else if (samples_per_pixel == 3 && bits_per_sample == 1) + image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL; + else if (samples_per_pixel == 1 && bits_per_sample == 8) + image_type = T4_IMAGE_TYPE_GRAY_8BIT; + else if (samples_per_pixel == 1 && bits_per_sample > 8) + image_type = T4_IMAGE_TYPE_GRAY_12BIT; + else if (samples_per_pixel == 3 && bits_per_sample == 8) + image_type = T4_IMAGE_TYPE_COLOUR_8BIT; + else if (samples_per_pixel == 3 && bits_per_sample > 8) + image_type = T4_IMAGE_TYPE_COLOUR_12BIT; + else + image_type = -1; +#if 0 + /* Limit ourselves to plain black and white pages */ + if (t->image_type != T4_IMAGE_TYPE_BILEVEL) + return -1; +#endif + if (s->tiff.image_type != image_type) + return 1; + + parm32 = 0; + TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32); + if (s->image_width != (int) parm32) + return 1; + x_resolution = 0.0f; + TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); + y_resolution = 0.0f; + TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); + res_unit = RESUNIT_INCH; + TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); + + /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the + precise value. The other value should be exact. */ + /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ + for (i = 0; x_res_table[i].code > 0; i++) + { + if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution)) + break; + } + if (s->metadata.x_resolution != x_res_table[i].code) + return 1; + for (i = 0; y_res_table[i].code > 0; i++) + { + if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution)) + break; + } + if (s->metadata.y_resolution != y_res_table[i].code) + return 1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int get_tiff_total_pages(t4_tx_state_t *s) +{ + int max; + + /* Each page *should* contain the total number of pages, but can this be + trusted? Some files say 0. Actually searching for the last page is + more reliable. */ + max = 0; + while (TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) max)) + max++; + /* Back to the previous page */ + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) + return -1; + return max; +} +/*- End of function --------------------------------------------------------*/ + +static int open_tiff_input_file(t4_tx_state_t *s, const char *file) +{ + if ((s->tiff.tiff_file = TIFFOpen(file, "r")) == NULL) + return -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int tiff_row_read_handler(void *user_data, uint8_t buf[], size_t len) +{ + t4_tx_state_t *s; + + s = (t4_tx_state_t *) user_data; + if (s->tiff.row >= s->image_length) + return 0; + memcpy(buf, &s->tiff.image_buffer[s->tiff.row*len], len); + s->tiff.row++; + return len; +} +/*- End of function --------------------------------------------------------*/ + +static int row_read(void *user_data, uint8_t buf[], size_t len) +{ + t4_tx_state_t *s; + + s = (t4_tx_state_t *) user_data; + + if (s->tiff.raw_row >= s->tiff.image_length) + return 0; + if (TIFFReadScanline(s->tiff.tiff_file, buf, s->tiff.raw_row, 0) < 0) + return 0; + if (s->apply_lab) + lab_to_srgb(&s->lab_params, buf, buf, len/3); + s->tiff.raw_row++; + return len; +} +/*- End of function --------------------------------------------------------*/ + +static int read_tiff_image(t4_tx_state_t *s) +{ + int total_len; + int len; + int i; + uint8_t *t; + image_translate_state_t *translator; + + if (s->tiff.image_type != T4_IMAGE_TYPE_BILEVEL) + { + /* We need to dither this image down to pure black and white, possibly resizing it + along the way. */ + if ((translator = image_translate_init(NULL, s->tiff.image_type, s->image_width, s->image_length, T4_IMAGE_TYPE_BILEVEL, 1728, -1, row_read, s)) == NULL) + return -1; + s->image_width = image_translate_get_output_width(translator); + s->image_length = image_translate_get_output_length(translator); + s->metadata.x_resolution = T4_X_RESOLUTION_R8; + s->metadata.y_resolution = T4_Y_RESOLUTION_FINE; + s->tiff.image_size = (s->image_width*s->image_length + 7)/8; + if (s->tiff.image_size >= s->tiff.image_buffer_size) + { + if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + return -1; + s->tiff.image_buffer_size = s->tiff.image_size; + s->tiff.image_buffer = t; + } + s->tiff.raw_row = 0; + switch (s->tiff.photo_metric) + { + case PHOTOMETRIC_CIELAB: + /* The default luminant is D50 */ + set_lab_illuminant(&s->lab_params, 0.96422f, 1.0f, 0.82521f); + set_lab_gamut(&s->lab_params, 0, 100, -128, 127, -128, 127, TRUE); + s->apply_lab = TRUE; + break; + case PHOTOMETRIC_ITULAB: + set_lab_illuminant(&s->lab_params, 0.9638f, 1.0f, 0.8245f); + set_lab_gamut(&s->lab_params, 0, 100, -85, 85, -75, 125, FALSE); + s->apply_lab = TRUE; + break; + default: + s->apply_lab = FALSE; + break; + } + total_len = 0; + for (i = 0; i < s->image_length; i++) + total_len += image_translate_row(translator, &s->tiff.image_buffer[total_len], s->image_width/8); + image_translate_free(translator); + } + else + { + s->tiff.image_size = s->image_length*TIFFScanlineSize(s->tiff.tiff_file); + if (s->tiff.image_size >= s->tiff.image_buffer_size) + { + if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL) + return -1; + s->tiff.image_buffer_size = s->tiff.image_size; + s->tiff.image_buffer = t; + } + + for (i = 0, total_len = 0; total_len < s->tiff.image_size; i++, total_len += len) + { + if ((len = TIFFReadEncodedStrip(s->tiff.tiff_file, i, &s->tiff.image_buffer[total_len], s->tiff.image_size - total_len)) < 0) + { + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Read error.\n", s->tiff.file); + return -1; + } + } + if (s->tiff.photo_metric != PHOTOMETRIC_MINISWHITE) + { + span_log(&s->logging, SPAN_LOG_FLOW, "%s: Photometric needs swapping.\n", s->tiff.file); + for (i = 0; i < s->tiff.image_size; i++) + s->tiff.image_buffer[i] = ~s->tiff.image_buffer[i]; + } + if (s->tiff.fill_order != FILLORDER_LSB2MSB) + bit_reverse(s->tiff.image_buffer, s->tiff.image_buffer, s->tiff.image_size); + } + s->tiff.row = 0; + return s->image_length; +} +/*- End of function --------------------------------------------------------*/ + +static void tiff_tx_release(t4_tx_state_t *s) +{ + if (s->tiff.tiff_file) + { + TIFFClose(s->tiff.tiff_file); + s->tiff.tiff_file = NULL; + if (s->tiff.file) + free((char *) s->tiff.file); + s->tiff.file = NULL; + } + if (s->tiff.image_buffer) + { + free(s->tiff.image_buffer); + s->tiff.image_buffer = NULL; + s->tiff.image_size = 0; + s->tiff.image_buffer_size = 0; + } +} +/*- End of function --------------------------------------------------------*/ + +static int set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, void *user_data) +{ + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_encode_set_row_read_handler(&s->encoder.t4_t6, handler, user_data); + case T4_COMPRESSION_ITU_T42: + return t42_encode_set_row_read_handler(&s->encoder.t42, handler, user_data); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_encode_set_row_read_handler(&s->encoder.t43, handler, user_data); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_encode_set_row_read_handler(&s->encoder.t85, handler, user_data); + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + +static int make_header(t4_tx_state_t *s) { time_t now; struct tm tm; static const char *months[] = { - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + if (s->header_text == NULL) + { + if ((s->header_text = malloc(132 + 1)) == NULL) + return -1; + } + /* This is very English oriented, but then most FAX machines are, too. Some + measure of i18n in the time and date, and even the header_info string, is + entirely possible, although the font area would need some serious work to + properly deal with East Asian script. There is no spec for what the header + should contain, or how much of the page it might occupy. The present format + follows the common practice of a few FAX machines. Nothing more. */ time(&now); if (s->tz) tz_localtime(s->tz, &tm, now); else tm = *localtime(&now); - snprintf(header, + + snprintf(s->header_text, 132, " %2d-%s-%d %02d:%02d %-50s %-21s p.%d", tm.tm_mday, @@ -439,25 +670,24 @@ static void make_header(t4_state_t *s, char *header) tm.tm_year + 1900, tm.tm_hour, tm.tm_min, - s->header_info, - (s->tiff.local_ident) ? s->tiff.local_ident : "", + (s->header_info) ? s->header_info : "", + (s->local_ident) ? s->local_ident : "", s->current_page + 1); + return 0; } /*- End of function --------------------------------------------------------*/ -static int t4_tx_put_fax_header(t4_state_t *s, int *rows) +static int header_row_read_handler(void *user_data, uint8_t buf[], size_t len) { - int row; - int i; int repeats; int pattern; - int row_bufptr; + int pos; + int row; char *t; - char header[132 + 1]; + t4_tx_state_t *s; - /* Modify the resulting image to include a header line, typical of hardware FAX machines */ - make_header(s, header); - switch (s->y_resolution) + s = (t4_tx_state_t *) user_data; + switch (s->metadata.y_resolution) { case T4_Y_RESOLUTION_1200: repeats = 12; @@ -481,1051 +711,497 @@ static int t4_tx_put_fax_header(t4_state_t *s, int *rows) repeats = 1; break; } - *rows = 16*repeats; - for (row = 0; row < 16; row++) + if (s->header_overlays_image) { - t = header; - row_bufptr = 0; - for (t = header; *t && row_bufptr <= s->bytes_per_row - 2; t++) + /* Read and dump a row of the real image, allowing for the possibility + that the real image might end within the header itself */ + if (len != s->row_handler(s->row_handler_user_data, buf, len)) { - pattern = header_font[(uint8_t) *t][row]; - s->row_buf[row_bufptr++] = (uint8_t) (pattern >> 8); - s->row_buf[row_bufptr++] = (uint8_t) (pattern & 0xFF); - } - for ( ; row_bufptr < s->bytes_per_row; ) - s->row_buf[row_bufptr++] = 0; - for (i = 0; i < repeats; i++) - { - if (encode_row(s)) - return -1; + set_row_read_handler(s, s->row_handler, s->row_handler_user_data); + return len; } } - return 0; + row = s->header_row/repeats; + pos = 0; + for (t = s->header_text; *t && pos <= len - 2; t++) + { + pattern = header_font[(uint8_t) *t][row]; + buf[pos++] = (uint8_t) (pattern >> 8); + buf[pos++] = (uint8_t) (pattern & 0xFF); + } + while (pos < len) + buf[pos++] = 0; + s->header_row++; + if (s->header_row >= 16*repeats) + set_row_read_handler(s, s->row_handler, s->row_handler_user_data); + return len; } /*- End of function --------------------------------------------------------*/ -static int test_resolution(int res_unit, float actual, float expected) +SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_tx_state_t *s) { - if (res_unit == RESUNIT_INCH) - actual *= 1.0f/CM_PER_INCH; - return (expected*0.95f <= actual && actual <= expected*1.05f); + span_log(&s->logging, SPAN_LOG_FLOW, "Checking for the existence of page %d\n", s->current_page + 1); + if (s->current_page >= s->stop_page) + return -1; + if (s->tiff.file) + { + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page + 1)) + return -1; + return test_tiff_directory_info(s); + } + return -1; } /*- End of function --------------------------------------------------------*/ -static int get_tiff_directory_info(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, void *user_data) { - static const struct - { - float resolution; - int code; - } x_res_table[] = - { - { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4}, - { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8}, - { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300}, - { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16}, - { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600}, - { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800}, - {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200}, - { -1.00f, -1} - }; - static const struct - { - float resolution; - int code; - int max_rows_to_next_1d_row; - } y_res_table[] = - { - { 38.50f, T4_Y_RESOLUTION_STANDARD, 2}, - { 77.00f, T4_Y_RESOLUTION_FINE, 4}, - { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300, 6}, - { 154.00f, T4_Y_RESOLUTION_SUPERFINE, 8}, - { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600, 12}, - { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800, 16}, - {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200, 24}, - { -1.00f, -1, -1} - }; - uint16_t res_unit; - uint16_t parm16; - uint32_t parm32; - float x_resolution; - float y_resolution; - int i; - t4_tiff_state_t *t; + s->row_handler = handler; + s->row_handler_user_data = user_data; + return set_row_read_handler(s, handler, user_data); +} +/*- End of function --------------------------------------------------------*/ - t = &s->tiff; - parm16 = 0; - TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm16); - if (parm16 != 1) - return -1; - TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &parm16); - if (parm16 != 1) - return -1; - parm32 = 0; - TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32); - s->image_width = parm32; - s->bytes_per_row = (s->image_width + 7)/8; - parm32 = 0; - TIFFGetField(t->tiff_file, TIFFTAG_IMAGELENGTH, &parm32); - s->image_length = parm32; - x_resolution = 0.0f; - TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); - y_resolution = 0.0f; - TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); - res_unit = RESUNIT_INCH; - TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); - t->photo_metric = PHOTOMETRIC_MINISWHITE; - TIFFGetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, &t->photo_metric); - if (t->photo_metric != PHOTOMETRIC_MINISWHITE) - span_log(&s->logging, SPAN_LOG_FLOW, "%s: Photometric needs swapping.\n", t->file); - t->fill_order = FILLORDER_LSB2MSB; -#if 0 - TIFFGetField(t->tiff_file, TIFFTAG_FILLORDER, &t->fill_order); - if (t->fill_order != FILLORDER_LSB2MSB) - span_log(&s->logging, SPAN_LOG_FLOW, "%s: Fill order needs swapping.\n", t->file); +SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding) +{ + switch (encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + break; + default: + t4_t6_encode_init(&s->encoder.t4_t6, encoding, s->image_width, s->row_handler, s->row_handler_user_data); + t4_t6_encode_set_max_2d_rows_per_1d_row(&s->encoder.t4_t6, -s->metadata.y_resolution); + break; + } + s->line_encoding = encoding; + return t4_t6_encode_set_encoding(&s->encoder.t4_t6, encoding); + case T4_COMPRESSION_ITU_T42: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T42: + break; + default: + t42_encode_init(&s->encoder.t42, s->image_width, s->image_length, s->row_handler, s->row_handler_user_data); + break; + } + s->line_encoding = encoding; + return 0; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T43: + break; + default: + t43_encode_init(&s->encoder.t43, s->image_width, s->image_length, s->row_handler, s->row_handler_user_data); + break; + } + s->line_encoding = encoding; + return 0; #endif - - /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the - precise value. The other value should be exact. */ - /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ - s->x_resolution = T4_X_RESOLUTION_R8; - for (i = 0; x_res_table[i].code > 0; i++) - { - if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution)) + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + switch (s->line_encoding) { - s->x_resolution = x_res_table[i].code; + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + break; + default: + t85_encode_init(&s->encoder.t85, s->image_width, s->image_length, s->row_handler, s->row_handler_user_data); break; } + s->line_encoding = encoding; + return 0; } - - s->y_resolution = T4_Y_RESOLUTION_STANDARD; - s->t4_t6_tx.max_rows_to_next_1d_row = 2; - for (i = 0; y_res_table[i].code > 0; i++) - { - if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution)) - { - s->y_resolution = y_res_table[i].code; - s->t4_t6_tx.max_rows_to_next_1d_row = y_res_table[i].max_rows_to_next_1d_row; - break; - } - } - - return 0; + return -1; } /*- End of function --------------------------------------------------------*/ -static int test_tiff_directory_info(t4_state_t *s) +SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits) { - static const struct + switch (s->line_encoding) { - float resolution; - int code; - } x_res_table[] = - { - { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4}, - { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8}, - { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300}, - { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16}, - { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600}, - { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800}, - {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200}, - { -1.00f, -1} - }; - static const struct - { - float resolution; - int code; - int max_rows_to_next_1d_row; - } y_res_table[] = - { - { 38.50f, T4_Y_RESOLUTION_STANDARD, 2}, - { 77.00f, T4_Y_RESOLUTION_FINE, 4}, - { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300, 6}, - { 154.00f, T4_Y_RESOLUTION_SUPERFINE, 8}, - { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600, 12}, - { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800, 16}, - {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200, 24}, - { -1.00f, -1, -1} - }; - uint16_t res_unit; - uint16_t parm16; - uint32_t parm32; - float x_resolution; - float y_resolution; - int i; - t4_tiff_state_t *t; - - t = &s->tiff; - parm16 = 0; - TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm16); - if (parm16 != 1) - return -1; - parm32 = 0; - TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32); - if (s->image_width != (int) parm32) - return 1; - x_resolution = 0.0f; - TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution); - y_resolution = 0.0f; - TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution); - res_unit = RESUNIT_INCH; - TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); - - /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the - precise value. The other value should be exact. */ - /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */ - for (i = 0; x_res_table[i].code > 0; i++) - { - if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution)) - break; + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t4_t6_encode_set_min_bits_per_row(&s->encoder.t4_t6, bits); + break; } - if (s->x_resolution != x_res_table[i].code) - return 1; - for (i = 0; y_res_table[i].code > 0; i++) - { - if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution)) - break; - } - if (s->y_resolution != y_res_table[i].code) - return 1; - return 0; } /*- End of function --------------------------------------------------------*/ -static int get_tiff_total_pages(t4_state_t *s) +SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width) +{ + s->image_width = image_width; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t4_t6_encode_set_image_width(&s->encoder.t4_t6, image_width); + break; + case T4_COMPRESSION_ITU_T42: + t42_encode_set_image_width(&s->encoder.t42, image_width); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t43_encode_set_image_width(&s->encoder.t43, image_width); + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t85_encode_set_image_width(&s->encoder.t85, image_width); + break; + } +} +/*- End of function --------------------------------------------------------*/ + +static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length) +{ + s->image_length = image_length; + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T42: + t42_encode_set_image_length(&s->encoder.t42, image_length); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t43_encode_set_image_length(&s->encoder.t43, image_length); + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t85_encode_set_image_length(&s->encoder.t85, image_length); + break; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_tx_set_max_2d_rows_per_1d_row(t4_tx_state_t *s, int max) +{ + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t4_t6_encode_set_max_2d_rows_per_1d_row(&s->encoder.t4_t6, max); + break; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_image_width(t4_tx_state_t *s) +{ + return s->image_width; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_tx_state_t *s, int header_overlays_image) +{ + s->header_overlays_image = header_overlays_image; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_tx_set_local_ident(t4_tx_state_t *s, const char *ident) +{ + s->local_ident = (ident && ident[0]) ? ident : NULL; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_tx_set_header_info(t4_tx_state_t *s, const char *info) +{ + s->header_info = (info && info[0]) ? info : NULL; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t4_tx_set_header_tz(t4_tx_state_t *s, struct tz_s *tz) +{ + s->tz = tz; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_tx_state_t *s) +{ + return s->metadata.y_resolution; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_tx_state_t *s) +{ + return s->metadata.x_resolution; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_tx_state_t *s) { int max; - /* Each page *should* contain the total number of pages, but can this be - trusted? Some files say 0. Actually searching for the last page is - more reliable. */ - max = 0; - while (TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) max)) - max++; - /* Back to the previous page */ - if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) - return -1; + if (s->tiff.file) + max = get_tiff_total_pages(s); + else + max = 1; + if (max >= 0) + s->tiff.pages_in_file = max; return max; } /*- End of function --------------------------------------------------------*/ -static int open_tiff_input_file(t4_state_t *s, const char *file) +SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_tx_state_t *s) { - if ((s->tiff.tiff_file = TIFFOpen(file, "r")) == NULL) - return -1; - return 0; + return s->current_page; } /*- End of function --------------------------------------------------------*/ -static int read_tiff_image(t4_state_t *s) +SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t) { - int row; - int image_length; - int i; - - image_length = 0; - TIFFGetField(s->tiff.tiff_file, TIFFTAG_IMAGELENGTH, &image_length); - for (row = 0; row < image_length; row++) + memset(t, 0, sizeof(*t)); + t->pages_transferred = s->current_page - s->start_page; + t->pages_in_file = s->tiff.pages_in_file; + t->x_resolution = s->metadata.x_resolution; + t->y_resolution = s->metadata.y_resolution; + t->encoding = s->line_encoding; + switch (s->line_encoding) { - if (TIFFReadScanline(s->tiff.tiff_file, s->row_buf, row, 0) <= 0) - { - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Read error at row %d.\n", s->tiff.file, row); - break; - } - if (s->tiff.photo_metric != PHOTOMETRIC_MINISWHITE) - { - for (i = 0; i < s->bytes_per_row; i++) - s->row_buf[i] = ~s->row_buf[i]; - } - if (s->tiff.fill_order != FILLORDER_LSB2MSB) - bit_reverse(s->row_buf, s->row_buf, s->bytes_per_row); - if (encode_row(s)) - return -1; - } - return image_length; -} -/*- End of function --------------------------------------------------------*/ - -static int close_tiff_input_file(t4_state_t *s) -{ - TIFFClose(s->tiff.tiff_file); - s->tiff.tiff_file = NULL; - if (s->tiff.file) - free((char *) s->tiff.file); - s->tiff.file = NULL; - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static void update_row_bit_info(t4_state_t *s) -{ - if (s->row_bits > s->max_row_bits) - s->max_row_bits = s->row_bits; - if (s->row_bits < s->min_row_bits) - s->min_row_bits = s->row_bits; - s->row_bits = 0; -} -/*- End of function --------------------------------------------------------*/ - -static int free_buffers(t4_state_t *s) -{ - if (s->image_buffer) - { - free(s->image_buffer); - s->image_buffer = NULL; - s->image_buffer_size = 0; - } - if (s->cur_runs) - { - free(s->cur_runs); - s->cur_runs = NULL; - } - if (s->ref_runs) - { - free(s->ref_runs); - s->ref_runs = NULL; - } - if (s->row_buf) - { - free(s->row_buf); - s->row_buf = NULL; - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -static int row_to_run_lengths(uint32_t list[], const uint8_t row[], int width) -{ - uint32_t flip; - uint32_t x; - int span; - int entry; - int frag; - int rem; - int limit; - int i; - int pos; - - /* Deal with whole words first. We know we are starting on a word boundary. */ - entry = 0; - flip = 0; - limit = (width >> 3) & ~3; - span = 0; - pos = 0; - for (i = 0; i < limit; i += sizeof(uint32_t)) - { - x = *((uint32_t *) &row[i]); - if (x != flip) - { - x = ((uint32_t) row[i] << 24) | ((uint32_t) row[i + 1] << 16) | ((uint32_t) row[i + 2] << 8) | ((uint32_t) row[i + 3]); - /* We know we are going to find at least one transition. */ - frag = 31 - top_bit(x ^ flip); - pos += ((i << 3) - span + frag); - list[entry++] = pos; - x <<= frag; - flip ^= 0xFFFFFFFF; - rem = 32 - frag; - /* Now see if there are any more */ - while ((frag = 31 - top_bit(x ^ flip)) < rem) - { - pos += frag; - list[entry++] = pos; - x <<= frag; - flip ^= 0xFFFFFFFF; - rem -= frag; - } - /* Save the remainder of the word */ - span = (i << 3) + 32 - rem; - } - } - /* Now deal with some whole bytes, if there are any left. */ - limit = width >> 3; - flip &= 0xFF000000; - if (i < limit) - { - for ( ; i < limit; i++) - { - x = (uint32_t) row[i] << 24; - if (x != flip) - { - /* We know we are going to find at least one transition. */ - frag = 31 - top_bit(x ^ flip); - pos += ((i << 3) - span + frag); - list[entry++] = pos; - x <<= frag; - flip ^= 0xFF000000; - rem = 8 - frag; - /* Now see if there are any more */ - while ((frag = 31 - top_bit(x ^ flip)) < rem) - { - pos += frag; - list[entry++] = pos; - x <<= frag; - flip ^= 0xFF000000; - rem -= frag; - } - /* Save the remainder of the word */ - span = (i << 3) + 8 - rem; - } - } - } - /* Deal with any left over fractional byte. */ - span = (i << 3) - span; - if ((rem = width & 7)) - { - x = row[i]; - x <<= 24; - do - { - frag = 31 - top_bit(x ^ flip); - if (frag > rem) - frag = rem; - pos += (span + frag); - list[entry++] = pos; - x <<= frag; - span = 0; - flip ^= 0xFF000000; - rem -= frag; - } - while (rem > 0); - } - else - { - if (span) - { - pos += span; - list[entry++] = pos; - } - } - return entry; -} -/*- End of function --------------------------------------------------------*/ - -static __inline__ int put_encoded_bits(t4_state_t *s, uint32_t bits, int length) -{ - uint8_t *t; - - /* We might be called with a large length value, to spew out a mass of zero bits for - minimum row length padding. */ - s->tx_bitstream |= (bits << s->tx_bits); - s->tx_bits += length; - s->row_bits += length; - if ((s->image_size + (s->tx_bits + 7)/8) >= s->image_buffer_size) - { - if ((t = realloc(s->image_buffer, s->image_buffer_size + 100*s->bytes_per_row)) == NULL) - return -1; - s->image_buffer = t; - s->image_buffer_size += 100*s->bytes_per_row; - } - while (s->tx_bits >= 8) - { - s->image_buffer[s->image_size++] = (uint8_t) (s->tx_bitstream & 0xFF); - s->tx_bitstream >>= 8; - s->tx_bits -= 8; - } - return 0; -} -/*- End of function --------------------------------------------------------*/ - -/* - * Write the sequence of codes that describes - * the specified span of zero's or one's. The - * appropriate table that holds the make-up and - * terminating codes is supplied. - */ -static __inline__ int put_1d_span(t4_state_t *s, int32_t span, const t4_run_table_entry_t *tab) -{ - const t4_run_table_entry_t *te; - - te = &tab[63 + (2560 >> 6)]; - while (span >= 2560 + 64) - { - if (put_encoded_bits(s, te->code, te->length)) - return -1; - span -= te->run_length; - } - te = &tab[63 + (span >> 6)]; - if (span >= 64) - { - if (put_encoded_bits(s, te->code, te->length)) - return -1; - span -= te->run_length; - } - if (put_encoded_bits(s, tab[span].code, tab[span].length)) - return -1; - return 0; -} -/*- End of function --------------------------------------------------------*/ - -#define pixel_is_black(x,bit) (((x)[(bit) >> 3] << ((bit) & 7)) & 0x80) - -/* - * Write an EOL code to the output stream. We also handle writing the tag - * bit for the next scanline when doing 2D encoding. - */ -static void encode_eol(t4_state_t *s) -{ - uint32_t code; - int length; - - if (s->line_encoding == T4_COMPRESSION_ITU_T4_2D) - { - code = 0x0800 | ((!s->row_is_2d) << 12); - length = 13; - } - else - { - /* T.4 1D EOL, or T.6 EOFB */ - code = 0x800; - length = 12; - } - if (s->row_bits) - { - /* We may need to pad the row to a minimum length, unless we are in T.6 mode. - In T.6 we only come here at the end of the page to add the EOFB marker, which - is like two 1D EOLs. */ - if (s->line_encoding != T4_COMPRESSION_ITU_T6) - { - if (s->row_bits + length < s->t4_t6_tx.min_bits_per_row) - put_encoded_bits(s, 0, s->t4_t6_tx.min_bits_per_row - (s->row_bits + length)); - } - put_encoded_bits(s, code, length); - update_row_bit_info(s); - } - else - { - /* We don't pad zero length rows. They are the consecutive EOLs which end a page. */ - put_encoded_bits(s, code, length); - /* Don't do the full update row bit info, or the minimum suddenly drops to the - length of an EOL. Just clear the row bits, so we treat the next EOL as an - end of page EOL, with no padding. */ - s->row_bits = 0; + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t->width = t4_t6_encode_get_image_width(&s->encoder.t4_t6); + t->length = t4_t6_encode_get_image_length(&s->encoder.t4_t6); + t->line_image_size = t4_t6_encode_get_compressed_image_size(&s->encoder.t4_t6)/8; + break; + case T4_COMPRESSION_ITU_T42: + t->width = t42_encode_get_image_width(&s->encoder.t42); + t->length = t42_encode_get_image_length(&s->encoder.t42); + t->line_image_size = t42_encode_get_compressed_image_size(&s->encoder.t42)/8; + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t->width = t43_encode_get_image_width(&s->encoder.t43); + t->length = t43_encode_get_image_length(&s->encoder.t43); + t->line_image_size = t43_encode_get_compressed_image_size(&s->encoder.t43)/8; + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t->width = t85_encode_get_image_width(&s->encoder.t85); + t->length = t85_encode_get_image_length(&s->encoder.t85); + t->line_image_size = t85_encode_get_compressed_image_size(&s->encoder.t85)/8; + break; } } /*- End of function --------------------------------------------------------*/ -/* - * 2D-encode a row of pixels. Consult ITU specification T.4 for the algorithm. - */ -static void encode_2d_row(t4_state_t *s) -{ - static const t4_run_table_entry_t codes[] = - { - { 7, 0x60, 0 }, /* VR3 0000 011 */ - { 6, 0x30, 0 }, /* VR2 0000 11 */ - { 3, 0x06, 0 }, /* VR1 011 */ - { 1, 0x01, 0 }, /* V0 1 */ - { 3, 0x02, 0 }, /* VL1 010 */ - { 6, 0x10, 0 }, /* VL2 0000 10 */ - { 7, 0x20, 0 }, /* VL3 0000 010 */ - { 3, 0x04, 0 }, /* horizontal 001 */ - { 4, 0x08, 0 } /* pass 0001 */ - }; - - /* The reference or starting changing element on the coding line. At the start of the coding - line, a0 is set on an imaginary white changing element situated just before the first element - on the line. During the coding of the coding line, the position of a0 is defined by the - previous coding mode. (See T.4/4.2.1.3.2.) */ - int a0; - /* The next changing element to the right of a0 on the coding line. */ - int a1; - /* The next changing element to the right of a1 on the coding line. */ - int a2; - /* The first changing element on the reference line to the right of a0 and of opposite colour to a0. */ - int b1; - /* The next changing element to the right of b1 on the reference line. */ - int b2; - int diff; - int a_cursor; - int b_cursor; - int cur_steps; - uint32_t *p; - - /* - b1 b2 - XX XX XX XX XX -- -- -- -- -- XX XX XX -- -- -- -- -- - XX XX XX -- -- -- -- -- XX XX XX XX XX XX -- -- -- -- - a0 a1 a2 - - - a) Pass mode - This mode is identified when the position of b2 lies to the left of a1. When this mode - has been coded, a0 is set on the element of the coding line below b2 in preparation for - the next coding (i.e. on a0'). - - b1 b2 - XX XX XX XX -- -- XX XX XX -- -- -- -- -- - XX XX -- -- -- -- -- -- -- -- -- -- XX XX - a0 a0' a1 - Pass mode - - - However, the state where b2 occurs just above a1, as shown in the figure below, is not - considered as a pass mode. - - b1 b2 - XX XX XX XX -- -- XX XX XX -- -- -- -- -- - XX XX -- -- -- -- -- -- -- XX XX XX XX XX - a0 a1 - Not pass mode - - - b) Vertical mode - When this mode is identified, the position of a1 is coded relative to the position of b1. - The relative distance a1b1 can take on one of seven values V(0), VR(1), VR(2), VR(3), - VL(1), VL(2) and VL(3), each of which is represented by a separate code word. The - subscripts R and L indicate that a1 is to the right or left respectively of b1, and the - number in brackets indicates the value of the distance a1b1. After vertical mode coding - has occurred, the position of a0 is set on a1 (see figure below). - - c) Horizontal mode - When this mode is identified, both the run-lengths a0a1 and a1a2 are coded using the code - words H + M(a0a1) + M(a1a2). H is the flag code word 001 taken from the two-dimensional - code table. M(a0a1) and M(a1a2) are code words which represent the length and "colour" - of the runs a0a1 and a1a2 respectively and are taken from the appropriate white or black - one-dimensional code tables. After a horizontal mode coding, the position of a0 is set on - a2 (see figure below). - - Vertical - - b1 b2 - -- XX XX XX XX XX -- -- -- -- -- -- -- -- XX XX XX XX -- -- -- - -- -- -- -- -- -- -- -- -- -- -- -- XX XX XX XX XX XX XX -- -- - a0 a1 a2 - <-------- a0a1 --------><-------- a1a2 ------------> - Horizontal mode - Vertical and horizontal modes - */ - /* The following implements the 2-D encoding section of the flow chart in Figure7/T.4 */ - cur_steps = row_to_run_lengths(s->cur_runs, s->row_buf, s->image_width); - /* Stretch the row a little, so when we step by 2 we are guaranteed to - hit an entry showing the row length */ - s->cur_runs[cur_steps] = - s->cur_runs[cur_steps + 1] = - s->cur_runs[cur_steps + 2] = s->cur_runs[cur_steps - 1]; - - a0 = 0; - a1 = s->cur_runs[0]; - b1 = s->ref_runs[0]; - a_cursor = 0; - b_cursor = 0; - for (;;) - { - b2 = s->ref_runs[b_cursor + 1]; - if (b2 >= a1) - { - diff = b1 - a1; - if (abs(diff) <= 3) - { - /* Vertical mode coding */ - put_encoded_bits(s, codes[diff + 3].code, codes[diff + 3].length); - a0 = a1; - a_cursor++; - } - else - { - /* Horizontal mode coding */ - a2 = s->cur_runs[a_cursor + 1]; - put_encoded_bits(s, codes[7].code, codes[7].length); - if (a0 + a1 == 0 || pixel_is_black(s->row_buf, a0) == 0) - { - put_1d_span(s, a1 - a0, t4_white_codes); - put_1d_span(s, a2 - a1, t4_black_codes); - } - else - { - put_1d_span(s, a1 - a0, t4_black_codes); - put_1d_span(s, a2 - a1, t4_white_codes); - } - a0 = a2; - a_cursor += 2; - } - if (a0 >= s->image_width) - break; - if (a_cursor >= cur_steps) - a_cursor = cur_steps - 1; - a1 = s->cur_runs[a_cursor]; - } - else - { - /* Pass mode coding */ - put_encoded_bits(s, codes[8].code, codes[8].length); - /* We now set a0 to somewhere in the middle of its current run, - but we know are aren't moving beyond that run. */ - a0 = b2; - if (a0 >= s->image_width) - break; - } - /* We need to hunt for the correct position in the reference row, as the - runs there have no particular alignment with the runs in the current - row. */ - if (pixel_is_black(s->row_buf, a0)) - b_cursor |= 1; - else - b_cursor &= ~1; - if (a0 < (int) s->ref_runs[b_cursor]) - { - for ( ; b_cursor >= 0; b_cursor -= 2) - { - if (a0 >= (int) s->ref_runs[b_cursor]) - break; - } - b_cursor += 2; - } - else - { - for ( ; b_cursor < s->t4_t6_tx.ref_steps; b_cursor += 2) - { - if (a0 < (int) s->ref_runs[b_cursor]) - break; - } - if (b_cursor >= s->t4_t6_tx.ref_steps) - b_cursor = s->t4_t6_tx.ref_steps - 1; - } - b1 = s->ref_runs[b_cursor]; - } - /* Swap the buffers */ - s->t4_t6_tx.ref_steps = cur_steps; - p = s->cur_runs; - s->cur_runs = s->ref_runs; - s->ref_runs = p; -} -/*- End of function --------------------------------------------------------*/ - -/* - * 1D-encode a row of pixels. The encoding is a sequence of all-white or - * all-black spans of pixels encoded with Huffman codes. - */ -static void encode_1d_row(t4_state_t *s) -{ - int i; - - /* Do our work in the reference row buffer, and it is already in place if - we need a reference row for a following 2D encoded row. */ - s->t4_t6_tx.ref_steps = row_to_run_lengths(s->ref_runs, s->row_buf, s->image_width); - put_1d_span(s, s->ref_runs[0], t4_white_codes); - for (i = 1; i < s->t4_t6_tx.ref_steps; i++) - put_1d_span(s, s->ref_runs[i] - s->ref_runs[i - 1], (i & 1) ? t4_black_codes : t4_white_codes); - /* Stretch the row a little, so when we step by 2 we are guaranteed to - hit an entry showing the row length */ - s->ref_runs[s->t4_t6_tx.ref_steps] = - s->ref_runs[s->t4_t6_tx.ref_steps + 1] = - s->ref_runs[s->t4_t6_tx.ref_steps + 2] = s->ref_runs[s->t4_t6_tx.ref_steps - 1]; -} -/*- End of function --------------------------------------------------------*/ - -static int encode_row(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s) { switch (s->line_encoding) { - case T4_COMPRESSION_ITU_T6: - /* T.6 compression is a trivial step up from T.4 2D, so we just - throw it in here. T.6 is only used with error correction, - so it does not need independantly compressed (i.e. 1D) lines - to recover from data errors. It doesn't need EOLs, either. */ - if (s->row_bits) - update_row_bit_info(s); - encode_2d_row(s); - break; - case T4_COMPRESSION_ITU_T4_2D: - encode_eol(s); - if (s->row_is_2d) - { - encode_2d_row(s); - s->t4_t6_tx.rows_to_next_1d_row--; - } - else - { - encode_1d_row(s); - s->row_is_2d = TRUE; - } - if (s->t4_t6_tx.rows_to_next_1d_row <= 0) - { - /* Insert a row of 1D encoding */ - s->row_is_2d = FALSE; - s->t4_t6_tx.rows_to_next_1d_row = s->t4_t6_tx.max_rows_to_next_1d_row - 1; - } - break; - default: case T4_COMPRESSION_ITU_T4_1D: - encode_eol(s); - encode_1d_row(s); - break; + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_encode_image_complete(&s->encoder.t4_t6); + case T4_COMPRESSION_ITU_T42: + return t42_encode_image_complete(&s->encoder.t42); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_encode_image_complete(&s->encoder.t43); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_encode_image_complete(&s->encoder.t85); + } + return SIG_STATUS_END_OF_DATA; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s) +{ + /* We only get bit by bit for T.4 1D and T.4 2-D. */ + return t4_t6_encode_get_bit(&s->encoder.t4_t6); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len) +{ + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_encode_get(&s->encoder.t4_t6, buf, max_len); + case T4_COMPRESSION_ITU_T42: + return t42_encode_get(&s->encoder.t42, buf, max_len); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_encode_get(&s->encoder.t43, buf, max_len); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_encode_get(&s->encoder.t85, buf, max_len); } - s->row++; return 0; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data) +SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s) { - s->t4_t6_tx.row_read_handler = handler; - s->t4_t6_tx.row_read_user_data = user_data; - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page) -{ - int run_space; - - if (s == NULL) - { - if ((s = (t4_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; - } - memset(s, 0, sizeof(*s)); - span_log_init(&s->logging, SPAN_LOG_NONE, NULL); - span_log_set_protocol(&s->logging, "T.4"); - s->rx = FALSE; - - span_log(&s->logging, SPAN_LOG_FLOW, "Start tx document\n"); - - if (open_tiff_input_file(s, file) < 0) - return NULL; - s->tiff.file = strdup(file); - s->current_page = - s->tiff.start_page = (start_page >= 0) ? start_page : 0; - s->tiff.stop_page = (stop_page >= 0) ? stop_page : INT_MAX; - - if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) - return NULL; - if (get_tiff_directory_info(s)) - { - close_tiff_input_file(s); - return NULL; - } - - s->t4_t6_tx.rows_to_next_1d_row = s->t4_t6_tx.max_rows_to_next_1d_row - 1; - - s->tiff.pages_in_file = -1; - - run_space = (s->image_width + 4)*sizeof(uint32_t); - if ((s->cur_runs = (uint32_t *) malloc(run_space)) == NULL) - return NULL; - if ((s->ref_runs = (uint32_t *) malloc(run_space)) == NULL) - { - free_buffers(s); - close_tiff_input_file(s); - return NULL; - } - if ((s->row_buf = malloc(s->bytes_per_row)) == NULL) - { - free_buffers(s); - close_tiff_input_file(s); - return NULL; - } - s->ref_runs[0] = - s->ref_runs[1] = - s->ref_runs[2] = - s->ref_runs[3] = s->image_width; - s->t4_t6_tx.ref_steps = 1; - s->image_buffer_size = 0; - return s; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s) -{ - int row; - int i; - int run_space; - int len; - int old_image_width; - int header_rows; - uint8_t *bufptr8; - uint32_t *bufptr; - - span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d\n", s->current_page); - if (s->current_page > s->tiff.stop_page) + span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d - compression %s\n", s->current_page, t4_encoding_to_str(s->line_encoding)); + if (s->current_page > s->stop_page) return -1; - if (s->tiff.tiff_file == NULL) - return -1; - old_image_width = s->image_width; - if (s->t4_t6_tx.row_read_handler == NULL) + if (s->tiff.file) { -#if defined(HAVE_LIBTIFF) if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page)) return -1; get_tiff_directory_info(s); -#endif - } - s->image_size = 0; - s->tx_bitstream = 0; - s->tx_bits = 0; - s->row_is_2d = (s->line_encoding == T4_COMPRESSION_ITU_T6); - s->t4_t6_tx.rows_to_next_1d_row = s->t4_t6_tx.max_rows_to_next_1d_row - 1; - - /* Allow for pages being of different width. */ - run_space = (s->image_width + 4)*sizeof(uint32_t); - if (old_image_width != s->image_width) - { - s->bytes_per_row = (s->image_width + 7)/8; - - if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL) + if (read_tiff_image(s) < 0) return -1; - s->cur_runs = bufptr; - if ((bufptr = (uint32_t *) realloc(s->ref_runs, run_space)) == NULL) - return -1; - s->ref_runs = bufptr; - if ((bufptr8 = realloc(s->row_buf, s->bytes_per_row)) == NULL) - return -1; - s->row_buf = bufptr8; - } - s->ref_runs[0] = - s->ref_runs[1] = - s->ref_runs[2] = - s->ref_runs[3] = s->image_width; - s->t4_t6_tx.ref_steps = 1; - - s->row_bits = 0; - s->min_row_bits = INT_MAX; - s->max_row_bits = 0; - - if (s->header_info && s->header_info[0]) - { - if (t4_tx_put_fax_header(s, &header_rows)) - return -1; - } - if (s->t4_t6_tx.row_read_handler) - { - for (row = 0; ; row++) - { - if ((len = s->t4_t6_tx.row_read_handler(s->t4_t6_tx.row_read_user_data, s->row_buf, s->bytes_per_row)) < 0) - { - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Read error at row %d.\n", s->tiff.file, row); - break; - } - if (len == 0) - break; - if (encode_row(s)) - return -1; - } - s->image_length = row; } else { - if ((s->image_length = read_tiff_image(s)) < 0) - return -1; + s->image_length = UINT32_MAX; } - if (s->line_encoding == T4_COMPRESSION_ITU_T6) + + switch (s->line_encoding) { - /* Attach an EOFB (end of facsimile block == 2 x EOLs) to the end of the page */ - for (i = 0; i < EOLS_TO_END_T6_TX_PAGE; i++) - encode_eol(s); + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + t4_t6_encode_restart(&s->encoder.t4_t6, s->image_width); + break; + case T4_COMPRESSION_ITU_T42: + t42_encode_restart(&s->encoder.t42, s->image_width, s->image_length); + break; +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + t43_encode_restart(&s->encoder.t43, s->image_width, s->image_length); + break; +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + t85_encode_restart(&s->encoder.t85, s->image_width, s->image_length); + break; + } + /* If there is a page header, create that first */ + if (s->header_info && s->header_info[0] && make_header(s) == 0) + { + s->header_row = 0; + set_row_read_handler(s, header_row_read_handler, (void *) s); } else { - /* Attach an RTC (return to control == 6 x EOLs) to the end of the page */ - s->row_is_2d = FALSE; - for (i = 0; i < EOLS_TO_END_T4_TX_PAGE; i++) - encode_eol(s); - } - - /* Force any partial byte in progress to flush using ones. Any post EOL padding when - sending is normally ones, so this is consistent. */ - put_encoded_bits(s, 0xFF, 7); - s->t4_t6_tx.bit_pos = 7; - s->t4_t6_tx.bit_ptr = 0; - s->line_image_size = s->image_size*8; - - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s) -{ - span_log(&s->logging, SPAN_LOG_FLOW, "Checking for the existance of page %d\n", s->current_page + 1); - if (s->current_page >= s->tiff.stop_page) - return -1; - if (s->t4_t6_tx.row_read_handler == NULL) - { -#if defined(HAVE_LIBTIFF) - if (s->tiff.tiff_file == NULL) - return -1; - if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page + 1)) - return -1; - return test_tiff_directory_info(s); -#endif + set_row_read_handler(s, s->row_handler, s->row_handler_user_data); } return 0; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_restart_page(t4_tx_state_t *s) { - s->t4_t6_tx.bit_pos = 7; - s->t4_t6_tx.bit_ptr = 0; - return 0; + /* This is currently the same as starting a page, but keep it a separate call, + as the two things might diverge a little in the future. */ + return t4_tx_start_page(s); } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_end_page(t4_tx_state_t *s) { s->current_page++; return 0; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s) +SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int start_page, int stop_page) { - int bit; + int allocated; - if (s->t4_t6_tx.bit_ptr >= s->image_size) - return SIG_STATUS_END_OF_DATA; - bit = (s->image_buffer[s->t4_t6_tx.bit_ptr] >> (7 - s->t4_t6_tx.bit_pos)) & 1; - if (--s->t4_t6_tx.bit_pos < 0) + allocated = FALSE; + if (s == NULL) { - s->t4_t6_tx.bit_pos = 7; - s->t4_t6_tx.bit_ptr++; + if ((s = (t4_tx_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + allocated = TRUE; } - return bit; + memset(s, 0, sizeof(*s)); +#if defined(SPANDSP_SUPPORT_TIFF_FX) + TIFF_FX_init(); +#endif + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.4"); + + span_log(&s->logging, SPAN_LOG_FLOW, "Start tx document\n"); + + s->current_page = + s->start_page = (start_page >= 0) ? start_page : 0; + s->stop_page = (stop_page >= 0) ? stop_page : INT_MAX; + s->line_encoding = T4_COMPRESSION_NONE; + + s->row_handler = tiff_row_read_handler; + s->row_handler_user_data = (void *) s; + + if (file) + { + if (open_tiff_input_file(s, file) < 0) + { + if (allocated) + free(s); + return NULL; + } + s->tiff.file = strdup(file); + s->tiff.pages_in_file = -1; + if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->current_page) + || + get_tiff_directory_info(s)) + { + tiff_tx_release(s); + if (allocated) + free(s); + return NULL; + } + } + return s; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s) { - if (s->t4_t6_tx.bit_ptr >= s->image_size) - return 0x100; - return s->image_buffer[s->t4_t6_tx.bit_ptr++]; + if (s->tiff.file) + tiff_tx_release(s); + if (s->header_text) + { + free(s->header_text); + s->header_text = NULL; + } + if (s->colour_map) + { + free(s->colour_map); + s->colour_map = NULL; + } + switch (s->line_encoding) + { + case T4_COMPRESSION_ITU_T4_1D: + case T4_COMPRESSION_ITU_T4_2D: + case T4_COMPRESSION_ITU_T6: + return t4_t6_encode_release(&s->encoder.t4_t6); + case T4_COMPRESSION_ITU_T42: + return t42_encode_release(&s->encoder.t42); +#if defined(SPANDSP_SUPPORT_T43) + case T4_COMPRESSION_ITU_T43: + return t43_encode_release(&s->encoder.t43); +#endif + case T4_COMPRESSION_ITU_T85: + case T4_COMPRESSION_ITU_T85_L0: + return t85_encode_release(&s->encoder.t85); + } + return -1; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len) -{ - if (s->t4_t6_tx.bit_ptr >= s->image_size) - return 0; - if (s->t4_t6_tx.bit_ptr + max_len > s->image_size) - max_len = s->image_size - s->t4_t6_tx.bit_ptr; - memcpy(buf, &s->image_buffer[s->t4_t6_tx.bit_ptr], max_len); - s->t4_t6_tx.bit_ptr += max_len; - return max_len; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s) -{ - int bit; - - if (s->t4_t6_tx.bit_ptr >= s->image_size) - return SIG_STATUS_END_OF_DATA; - bit = (s->image_buffer[s->t4_t6_tx.bit_ptr] >> s->t4_t6_tx.bit_pos) & 1; - return bit; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_release(t4_state_t *s) -{ - if (s->rx) - return -1; - if (s->tiff.tiff_file) - close_tiff_input_file(s); - free_buffers(s); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_free(t4_state_t *s) +SPAN_DECLARE(int) t4_tx_free(t4_tx_state_t *s) { int ret; @@ -1534,94 +1210,4 @@ SPAN_DECLARE(int) t4_tx_free(t4_state_t *s) return ret; } /*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding) -{ - s->line_encoding = encoding; - s->t4_t6_tx.rows_to_next_1d_row = s->t4_t6_tx.max_rows_to_next_1d_row - 1; - s->row_is_2d = FALSE; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits) -{ - s->t4_t6_tx.min_bits_per_row = bits; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_header_overlays_image(t4_state_t *s, int header_overlays_image) -{ - s->header_overlays_image = header_overlays_image; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident) -{ - s->tiff.local_ident = (ident && ident[0]) ? ident : NULL; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info) -{ - s->header_info = (info && info[0]) ? info : NULL; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, tz_t *tz) -{ - s->tz = tz; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_state_t *s) -{ - return s->y_resolution; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s) -{ - return s->x_resolution; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s) -{ - return s->image_width; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s) -{ - int max; - - max = 0; - if (s->t4_t6_tx.row_read_handler == NULL) - max = get_tiff_total_pages(s); - if (max >= 0) - s->tiff.pages_in_file = max; - return max; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s) -{ - return s->current_page; -} -/*- End of function --------------------------------------------------------*/ - -SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t) -{ - t->pages_transferred = s->current_page - s->tiff.start_page; - t->pages_in_file = s->tiff.pages_in_file; - t->width = s->image_width; - t->length = s->image_length; - t->bad_rows = s->t4_t6_rx.bad_rows; - t->longest_bad_row_run = s->t4_t6_rx.longest_bad_row_run; - t->x_resolution = s->x_resolution; - t->y_resolution = s->y_resolution; - t->encoding = s->line_encoding; - t->line_image_size = s->line_image_size/8; -} -/*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t81_t82_arith_coding.c b/libs/spandsp/src/t81_t82_arith_coding.c new file mode 100644 index 0000000000..86e7e0271f --- /dev/null +++ b/libs/spandsp/src/t81_t82_arith_coding.c @@ -0,0 +1,509 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t81_t82_arith_coding.c - ITU T.81 and T.82 QM-coder arithmetic encoding + * and decoding + * + * Written by Steve Underwood + * + * Copyright (C) 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include + +#include "spandsp/telephony.h" +#include "spandsp/t81_t82_arith_coding.h" + +#include "spandsp/private/t81_t82_arith_coding.h" + +/* T.82 defines the QM-coder at a level very close to actual code. Therefore + this file closely mirrors the routine names, variable names, and flow + described in T.82. QM-Coder is supposed to be the same in some other image + compression schemes, such as T.81. However, this code has not been checked + to see if it follows the letter of any spec other than T.82. */ + +#define FALSE 0 +#define TRUE (!FALSE) + +/* Code bytes which must trigger stuffing */ +enum +{ + T81_T82_STUFF = 0x00, + T81_T82_ESC = 0xFF +}; + +/* This table is from T.82 table 24 - Probability estimation table */ +static const struct probability_estimation_s +{ + uint16_t lsz; + uint8_t nlps; /* The SWITCH bit is packed into the top of this byte */ + uint8_t nmps; +} prob[113] = +{ + {0x5A1D, 1 + 128, 1}, + {0x2586, 14, 2}, + {0x1114, 16, 3}, + {0x080B, 18, 4}, + {0x03D8, 20, 5}, + {0x01DA, 23, 6}, + {0x00E5, 25, 7}, + {0x006F, 28, 8}, + {0x0036, 30, 9}, + {0x001A, 33, 10}, + {0x000D, 35, 11}, + {0x0006, 9, 12}, + {0x0003, 10, 13}, + {0x0001, 12, 13}, + {0x5A7F, 15 + 128, 15}, + {0x3F25, 36, 16}, + {0x2CF2, 38, 17}, + {0x207C, 39, 18}, + {0x17B9, 40, 19}, + {0x1182, 42, 20}, + {0x0CEF, 43, 21}, + {0x09A1, 45, 22}, + {0x072F, 46, 23}, + {0x055C, 48, 24}, + {0x0406, 49, 25}, + {0x0303, 51, 26}, + {0x0240, 52, 27}, + {0x01B1, 54, 28}, + {0x0144, 56, 29}, + {0x00F5, 57, 30}, + {0x00B7, 59, 31}, + {0x008A, 60, 32}, + {0x0068, 62, 33}, + {0x004E, 63, 34}, + {0x003B, 32, 35}, + {0x002C, 33, 9}, + {0x5AE1, 37 + 128, 37}, + {0x484C, 64, 38}, + {0x3A0D, 65, 39}, + {0x2EF1, 67, 40}, + {0x261F, 68, 41}, + {0x1F33, 69, 42}, + {0x19A8, 70, 43}, + {0x1518, 72, 44}, + {0x1177, 73, 45}, + {0x0E74, 74, 46}, + {0x0BFB, 75, 47}, + {0x09F8, 77, 48}, + {0x0861, 78, 49}, + {0x0706, 79, 50}, + {0x05CD, 48, 51}, + {0x04DE, 50, 52}, + {0x040F, 50, 53}, + {0x0363, 51, 54}, + {0x02D4, 52, 55}, + {0x025C, 53, 56}, + {0x01F8, 54, 57}, + {0x01A4, 55, 58}, + {0x0160, 56, 59}, + {0x0125, 57, 60}, + {0x00F6, 58, 61}, + {0x00CB, 59, 62}, + {0x00AB, 61, 63}, + {0x008F, 61, 32}, + {0x5B12, 65 + 128, 65}, + {0x4D04, 80, 66}, + {0x412C, 81, 67}, + {0x37D8, 82, 68}, + {0x2FE8, 83, 69}, + {0x293C, 84, 70}, + {0x2379, 86, 71}, + {0x1EDF, 87, 72}, + {0x1AA9, 87, 73}, + {0x174E, 72, 74}, + {0x1424, 72, 75}, + {0x119C, 74, 76}, + {0x0F6B, 74, 77}, + {0x0D51, 75, 78}, + {0x0BB6, 77, 79}, + {0x0A40, 77, 48}, + {0x5832, 80 + 128, 81}, + {0x4D1C, 88, 82}, + {0x438E, 89, 83}, + {0x3BDD, 90, 84}, + {0x34EE, 91, 85}, + {0x2EAE, 92, 86}, + {0x299A, 93, 87}, + {0x2516, 86, 71}, + {0x5570, 88 + 128, 89}, + {0x4CA9, 95, 90}, + {0x44D9, 96, 91}, + {0x3E22, 97, 92}, + {0x3824, 99, 93}, + {0x32B4, 99, 94}, + {0x2E17, 93, 86}, + {0x56A8, 95 + 128, 96}, + {0x4F46, 101, 97}, + {0x47E5, 102, 98}, + {0x41CF, 103, 99}, + {0x3C3D, 104, 100}, + {0x375E, 99, 93}, + {0x5231, 105, 102}, + {0x4C0F, 106, 103}, + {0x4639, 107, 104}, + {0x415E, 103, 99}, + {0x5627, 105 + 128, 106}, + {0x50E7, 108, 107}, + {0x4B85, 109, 103}, + {0x5597, 110, 109}, + {0x504F, 111, 107}, + {0x5A10, 110 + 128, 111}, + {0x5522, 112, 109}, + {0x59EB, 112 + 128, 111} +}; + +static __inline__ void output_stuffed_byte(t81_t82_arith_encode_state_t *s, int byte) +{ + s->output_byte_handler(s->user_data, byte); + if (byte == T81_T82_ESC) + s->output_byte_handler(s->user_data, T81_T82_STUFF); +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void byteout(t81_t82_arith_encode_state_t *s) +{ + uint32_t temp; + + /* T.30 figure 26 - BYTEOUT */ + temp = s->c >> 19; + if (temp > 0xFF) + { + if (s->buffer >= 0) + output_stuffed_byte(s, s->buffer + 1); + while (s->sc) + { + s->output_byte_handler(s->user_data, 0x00); + s->sc--; + } + s->buffer = temp & 0xFF; + } + else if (temp == 0xFF) + { + s->sc++; + } + else + { + if (s->buffer >= 0) + output_stuffed_byte(s, s->buffer); + while (s->sc) + { + output_stuffed_byte(s, T81_T82_ESC); + s->sc--; + } + s->buffer = temp; + } + s->c &= 0x7FFFF; + s->ct = 8; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void renorme(t81_t82_arith_encode_state_t *s) +{ + /* T.82 figure 25 - RENORME */ + do + { + s->a <<= 1; + s->c <<= 1; + s->ct--; + if (s->ct == 0) + byteout(s); + } + while (s->a < 0x8000); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t81_t82_arith_encode(t81_t82_arith_encode_state_t *s, int cx, int pix) +{ + uint32_t ss; + + /* T.82 figure 22 - ENCODE */ + ss = s->st[cx] & 0x7F; + if (((pix << 7) ^ s->st[cx]) & 0x80) + { + /* T.82 figure 23 - CODELPS */ + s->a -= prob[ss].lsz; + if (s->a >= prob[ss].lsz) + { + s->c += s->a; + s->a = prob[ss].lsz; + } + s->st[cx] = (s->st[cx] & 0x80) ^ prob[ss].nlps; + renorme(s); + } + else + { + /* T.82 figure 24 - CODEMPS */ + s->a -= prob[ss].lsz; + if (s->a < 0x8000) + { + if (s->a < prob[ss].lsz) + { + s->c += s->a; + s->a = prob[ss].lsz; + } + s->st[cx] = (s->st[cx] & 0x80) | prob[ss].nmps; + renorme(s); + } + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t81_t82_arith_encode_flush(t81_t82_arith_encode_state_t *s) +{ + uint32_t temp; + + /* T.82 figure 28 - FLUSH */ + /* T.82 figure 29 - CLEARBITS */ + temp = (s->c + s->a - 1) & 0xFFFF0000; + s->c = (temp < s->c) ? (temp + 0x8000) : temp; + /* T.82 figure 30 - FINALWRITES */ + s->c <<= s->ct; + if ((s->c > 0x7FFFFFF)) + { + if (s->buffer >= 0) + output_stuffed_byte(s, s->buffer + 1); + /* Only output 0x00 bytes if something non-0x00 will follow */ + if ((s->c & 0x7FFF800)) + { + while (s->sc) + { + output_stuffed_byte(s, 0x00); + s->sc--; + } + } + } + else + { + /* The next bit says s->buffer + 1 in T.82, but that makes no sense. It doesn't + agree with how we code things away from the flush condition, and it gives + answers which don't seem to match other JBIG coders. */ + if (s->buffer >= 0) + output_stuffed_byte(s, s->buffer); + while (s->sc) + { + output_stuffed_byte(s, 0xFF); + s->sc--; + } + } + /* Only output final bytes if they are not 0x00 */ + if ((s->c & 0x7FFF800)) + { + output_stuffed_byte(s, (s->c >> 19) & 0xFF); + if ((s->c & 0x7F800)) + output_stuffed_byte(s, (s->c >> 11) & 0xFF); + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_encode_restart(t81_t82_arith_encode_state_t *s, int reuse_st) +{ + /* T.82 figure 27 - INITENC */ + if (!reuse_st) + memset(s->st, 0, sizeof(s->st)); + s->c = 0; + s->a = 0x10000; + s->sc = 0; + s->ct = 11; + s->buffer = -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t81_t82_arith_encode_state_t *) t81_t82_arith_encode_init(t81_t82_arith_encode_state_t *s, + void (*output_byte_handler)(void *, int), + void *user_data) +{ + if (s == NULL) + { + if ((s = (t81_t82_arith_encode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + s->output_byte_handler = output_byte_handler; + s->user_data = user_data; + + t81_t82_arith_encode_restart(s, FALSE); + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_encode_release(t81_t82_arith_encode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_encode_free(t81_t82_arith_encode_state_t *s) +{ + int ret; + + ret = t81_t82_arith_encode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_decode(t81_t82_arith_decode_state_t *s, int cx) +{ + uint32_t ss; + int pix; + + /* T.82 figure 35 - RENORMD */ + while (s->a < 0x8000 || s->startup) + { + while (s->ct <= 8 && s->ct >= 0) + { + /* First we can move a new byte into s->c */ + if (s->pscd_ptr >= s->pscd_end) + return -1; + if (s->pscd_ptr[0] == T81_T82_ESC) + { + if (s->pscd_ptr + 1 >= s->pscd_end) + return -1; + if (s->pscd_ptr[1] == T81_T82_STUFF) + { + s->c |= (0xFF << (8 - s->ct)); + s->ct += 8; + s->pscd_ptr += 2; + } + else + { + /* Start padding with zero bytes */ + s->ct = -1; + if (s->nopadding) + { + /* Subsequent symbols might depend on zero padding */ + s->nopadding = FALSE; + return -2; + } + } + } + else + { + s->c |= (int32_t) *(s->pscd_ptr++) << (8 - s->ct); + s->ct += 8; + } + } + s->a <<= 1; + s->c <<= 1; + if (s->ct >= 0) + s->ct--; + if (s->a == 0x10000) + s->startup = FALSE; + } + + /* T.82 figure 32 - DECODE */ + ss = s->st[cx] & 0x7F; + if ((s->c >> 16) >= (s->a -= prob[ss].lsz)) + { + /* T.82 figure 33 - LPS_EXCHANGE */ + if (s->a < prob[ss].lsz) + { + s->c -= (s->a << 16); + s->a = prob[ss].lsz; + pix = s->st[cx] >> 7; + s->st[cx] = (s->st[cx] & 0x80) | prob[ss].nmps; + } + else + { + s->c -= (s->a << 16); + s->a = prob[ss].lsz; + pix = 1 - (s->st[cx] >> 7); + s->st[cx] = (s->st[cx]& 0x80) ^ prob[ss].nlps; + } + } + else + { + if (s->a < 0x8000) + { + /* T.82 figure 34 - MPS_EXCHANGE */ + if (s->a < prob[ss].lsz) + { + pix = 1 - (s->st[cx] >> 7); + s->st[cx] = (s->st[cx] & 0x80) ^ prob[ss].nlps; + } + else + { + pix = s->st[cx] >> 7; + s->st[cx] = (s->st[cx] & 0x80) | prob[ss].nmps; + } + } + else + { + pix = s->st[cx] >> 7; + } + } + + return pix; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_decode_restart(t81_t82_arith_decode_state_t *s, int reuse_st) +{ + if (!reuse_st) + memset(s->st, 0, sizeof(s->st)); + s->c = 0; + s->a = 1; + s->ct = 0; + s->startup = TRUE; + s->nopadding = FALSE; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_arith_decode_state_t *s) +{ + if (s == NULL) + { + if ((s = (t81_t82_arith_decode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + + t81_t82_arith_decode_restart(s, FALSE); + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_decode_release(t81_t82_arith_decode_state_t *s) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t81_t82_arith_decode_free(t81_t82_arith_decode_state_t *s) +{ + int ret; + + ret = t81_t82_arith_decode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t85_decode.c b/libs/spandsp/src/t85_decode.c new file mode 100644 index 0000000000..8193c10a0d --- /dev/null +++ b/libs/spandsp/src/t85_decode.c @@ -0,0 +1,861 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t85_decode.c - ITU T.85 JBIG for FAX image decompression + * + * Written by Steve Underwood + * + * Copyright (C) 2009, 2010 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "spandsp/telephony.h" +#include "spandsp/logging.h" +#include "spandsp/async.h" +#include "spandsp/timezone.h" +#include "spandsp/t4_rx.h" +#include "spandsp/t4_tx.h" +#include "spandsp/t81_t82_arith_coding.h" +#include "spandsp/t85.h" + +#include "spandsp/private/logging.h" +#include "spandsp/private/t81_t82_arith_coding.h" +#include "spandsp/private/t85.h" + +#define FALSE 0 +#define TRUE (!FALSE) + +static __inline__ int32_t pack_32(uint8_t *s) +{ + int32_t value; + + value = (((int32_t) s[0] << 24) | ((int32_t) s[1] << 16) | ((int32_t) s[2] << 8) | (int32_t) s[3]); + return value; +} +/*- End of function --------------------------------------------------------*/ + +/* Decode some PSCD bytes, output the decoded rows as they are completed. Return + the number of bytes which have actually been read. This will be less than len + if a marker segment was part of the data or if the final byte was 0xFF, meaning + that this code can not determine whether we have a marker segment. */ +static size_t decode_pscd(t85_decode_state_t *s, const uint8_t data[], size_t len) +{ + uint8_t *hp[3]; + int32_t o; + int cx; + int i; + int pix; + int slntp; + int buffered_rows; + + buffered_rows = (s->options & T85_LRLTWO) ? 2 : 3; + /* Forward data to the arithmetic decoder */ + s->s.pscd_ptr = data; + s->s.pscd_end = data + len; + + for (s->interrupt = FALSE; s->i < s->l0 && s->y < s->yd && !s->interrupt; s->i++, s->y++) + { + /* Point to the current image bytes */ + for (i = 0; i < 3; i++) + hp[i] = s->row_buf + s->p[i]*s->bytes_per_row + (s->x >> 3); + + /* Adaptive template changes */ + if (s->x == 0 && s->pseudo) + { + for (i = 0; i < s->at_moves; i++) + { + if (s->at_row[i] == s->i) + s->tx = s->at_tx[i]; + } + } + + /* Typical prediction */ + if ((s->options & T85_TPBON) && s->pseudo) + { + slntp = t81_t82_arith_decode(&s->s, (s->options & T85_LRLTWO) ? TPB2CX : TPB3CX); + if (slntp < 0) + return s->s.pscd_ptr - data; + s->lntp = !(slntp ^ s->lntp); + if (!s->lntp) + { + /* This row is 'typical' (i.e. identical to the previous one) */ + if (s->p[1] < 0) + { + /* First row of page or (following SDRST) of stripe */ + for (i = 0; i < s->bytes_per_row; i++) + hp[0][i] = 0; + s->interrupt = s->row_write_handler(s->row_write_user_data, hp[0], s->bytes_per_row); + /* Rotate the ring buffer that holds the last few rows */ + s->p[2] = s->p[1]; + s->p[1] = s->p[0]; + if (++(s->p[0]) >= buffered_rows) + s->p[0] = 0; + } + else + { + s->interrupt = s->row_write_handler(s->row_write_user_data, hp[1], s->bytes_per_row); + /* Duplicate the last row in the ring buffer */ + s->p[2] = s->p[1]; + } + continue; + } + /* This row is 'not typical' and has to be coded completely */ + } + s->pseudo = FALSE; + + if (s->x == 0) + { + s->row_h[0] = 0; + s->row_h[1] = (s->p[1] >= 0) ? ((int32_t) hp[1][0] << 8) : 0; + s->row_h[2] = (s->p[2] >= 0) ? ((int32_t) hp[2][0] << 8) : 0; + } + + /* Decode row */ + while (s->x < s->xd) + { + if ((s->x & 7) == 0) + { + if (s->x < (s->bytes_per_row - 1)*8 && s->p[1] >= 0) + { + s->row_h[1] |= hp[1][1]; + if (s->p[2] >= 0) + s->row_h[2] |= hp[2][1]; + } + } + if ((s->options & T85_LRLTWO)) + { + /* Two row template */ + do + { + cx = (s->row_h[0] & 0x00F); + if (s->tx) + { + cx |= ((s->row_h[1] >> 9) & 0x3E0); + if (s->x >= (uint32_t) s->tx) + { + if (s->tx < 8) + { + cx |= ((s->row_h[0] >> (s->tx - 5)) & 0x010); + } + else + { + o = (s->x - s->tx) - (s->x & ~7); + cx |= (((hp[0][o >> 3] >> (7 - (o & 7))) & 1) << 4); + } + } + } + else + { + cx |= ((s->row_h[1] >> 9) & 0x3F0); + } + pix = t81_t82_arith_decode(&s->s, cx); + if (pix < 0) + return s->s.pscd_ptr - data; + s->row_h[0] = (s->row_h[0] << 1) | pix; + s->row_h[1] <<= 1; + } + while ((++s->x & 7) && s->x < s->xd); + } + else + { + /* Three row template */ + do + { + cx = ((s->row_h[2] >> 7) & 0x380) | (s->row_h[0] & 0x003); + if (s->tx) + { + cx |= ((s->row_h[1] >> 11) & 0x078); + if (s->x >= (uint32_t) s->tx) + { + if (s->tx < 8) + { + cx |= ((s->row_h[0] >> (s->tx - 3)) & 0x004); + } + else + { + o = (s->x - s->tx) - (s->x & ~7); + cx |= (((hp[0][o >> 3] >> (7 - (o & 7))) & 1) << 2); + } + } + } + else + { + cx |= ((s->row_h[1] >> 11) & 0x07C); + } + pix = t81_t82_arith_decode(&s->s, cx); + if (pix < 0) + return s->s.pscd_ptr - data; + s->row_h[0] = (s->row_h[0] << 1) | pix; + s->row_h[1] <<= 1; + s->row_h[2] <<= 1; + } + while ((++s->x & 7) && s->x < s->xd); + } + *hp[0]++ = s->row_h[0]; + hp[1]++; + hp[2]++; + } + *(hp[0] - 1) <<= (s->bytes_per_row*8 - s->xd); + s->interrupt = s->row_write_handler(s->row_write_user_data, &s->row_buf[s->p[0]*s->bytes_per_row], s->bytes_per_row); + s->x = 0; + s->pseudo = TRUE; + /* Shuffle the row buffers */ + s->p[2] = s->p[1]; + s->p[1] = s->p[0]; + if (++(s->p[0]) >= buffered_rows) + s->p[0] = 0; + } + return s->s.pscd_ptr - data; +} +/*- End of function --------------------------------------------------------*/ + +static int finish_sde(t85_decode_state_t *s) +{ + /* Decode final pixels based on trailing zero bytes */ + s->s.nopadding = FALSE; + if (decode_pscd(s, s->buffer, 2) != 2 && s->interrupt) + return 1; + + /* Prepare decoder for next SDE */ + t81_t82_arith_decode_restart(&s->s, s->buffer[1] == T82_SDNORM); + s->s.nopadding = s->options & T85_VLENGTH; + + s->x = 0; + s->i = 0; + s->pseudo = TRUE; + s->at_moves = 0; + if (s->buffer[1] == T82_SDRST) + { + s->tx = 0; + s->lntp = TRUE; + s->p[0] = 0; + s->p[1] = -1; + s->p[2] = -1; + } + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int check_bih(t85_decode_state_t *s) +{ + /* Check that the fixed parameters have the values they are expected to be + fixed at - see T.85/Table 1 */ + /* DL - Initial layer to be transmitted */ + /* D - Number of differential layers */ + /* Unspecified byte */ + /* MY - Maximum vertical offset allowed for AT pixel */ + /* Order byte */ + if (s->buffer[0] != 0 + || + s->buffer[1] != 0 + || + s->buffer[3] != 0 + || + s->buffer[17] != 0 + || +#if T85_STRICT_ORDER_BITS + s->buffer[18] != 0) +#else + (s->buffer[18] & 0xF0) != 0) +#endif + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Fixed bytes do not contain expected values.\n"); + return T4_DECODE_INVALID_DATA; + } + /* P - Number of bit planes */ + if (s->buffer[2] < s->min_bit_planes || s->buffer[2] > s->max_bit_planes) + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. %d bit planes. Should be %d to %d.\n", s->buffer[2], s->min_bit_planes, s->max_bit_planes); + return T4_DECODE_INVALID_DATA; + } + s->bit_planes = s->buffer[2]; + s->current_bit_plane = 0; + /* Now look at the stuff which actually counts in a T.85 header. */ + /* XD - Horizontal image size at layer D */ + s->xd = pack_32(&s->buffer[4]); + if (s->xd == 0 || (s->max_xd && s->xd > s->max_xd)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Width is %" PRIu32 "\n", s->xd); + return T4_DECODE_INVALID_DATA; + } + /* YD - Vertical image size at layer D */ + s->yd = pack_32(&s->buffer[8]); + if (s->yd == 0 || (s->max_yd && s->yd > s->max_yd)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Length is %" PRIu32 "\n", s->yd); + return T4_DECODE_INVALID_DATA; + } + /* L0 - Rows per stripe, at the lowest resolution */ + s->l0 = pack_32(&s->buffer[12]); + if (s->l0 == 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. L0 is %" PRIu32 "\n", s->l0); + return T4_DECODE_INVALID_DATA; + } + /* MX - Maximum horizontal offset allowed for AT pixel */ + s->mx = s->buffer[16]; + if (s->mx > 127) + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. MX is %d\n", s->mx); + return T4_DECODE_INVALID_DATA; + } + /* Options byte */ + s->options = s->buffer[19]; + if ((s->options & 0x97)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Options are 0x%X\n", s->options); + return T4_DECODE_INVALID_DATA; + } + span_log(&s->logging, SPAN_LOG_FLOW, "BIH is OK. Image is %" PRIu32 "x%" PRIu32 " pixels\n", s->xd, s->yd); + return T4_DECODE_OK; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t85_decode_rx_status(t85_decode_state_t *s, int status) +{ + span_log(&s->logging, SPAN_LOG_FLOW, "Signal status is %s (%d)\n", signal_status_to_str(status), status); + switch (status) + { + case SIG_STATUS_TRAINING_IN_PROGRESS: + case SIG_STATUS_TRAINING_FAILED: + case SIG_STATUS_TRAINING_SUCCEEDED: + case SIG_STATUS_CARRIER_UP: + /* Ignore these */ + break; + case SIG_STATUS_CARRIER_DOWN: + case SIG_STATUS_END_OF_DATA: + /* Finalise the image */ + t85_decode_put(s, NULL, 0); + break; + default: + span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected rx status - %d!\n", status); + break; + } +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], size_t len) +{ + int ret; + uint32_t y; + uint8_t *buf; + size_t bytes_per_row; + size_t min_len; + size_t chunk; + size_t cnt; + int i; + + if (len == 0) + { + if (s->y >= s->yd) + return T4_DECODE_OK; + /* This is the end of image condition */ + s->end_of_data = 1; + } + + s->compressed_image_size += len; + cnt = 0; + + if (s->bie_len < 20) + { + /* Read in the 20-byte BIH */ + i = (s->bie_len + len > 20) ? (20 - s->bie_len) : len; + memcpy(&s->buffer[s->bie_len], data, i); + s->bie_len += i; + cnt = i; + if (s->bie_len < 20) + return T4_DECODE_MORE_DATA; + if ((ret = check_bih(s)) != T4_DECODE_OK) + return ret; + /* Set up the two/three row buffer */ + bytes_per_row = (s->xd + 7) >> 3; + min_len = ((s->options & T85_LRLTWO) ? 2 : 3)*bytes_per_row; + if (min_len > s->row_buf_len) + { + /* We need to expand the 3 row buffer */ + if ((buf = (uint8_t *) realloc(s->row_buf, min_len)) == NULL) + return T4_DECODE_NOMEM; + s->row_buf = buf; + s->row_buf_len = min_len; + } + + t81_t82_arith_decode_init(&s->s); + s->s.nopadding = s->options & T85_VLENGTH; + if (s->comment) + { + free(s->comment); + s->comment = NULL; + } + s->comment_len = 0; + s->comment_progress = 0; + s->buf_len = 0; + s->buf_needed = 2; + s->x = 0; + s->y = 0; + s->i = 0; + s->pseudo = TRUE; + s->at_moves = 0; + s->tx = 0; + s->lntp = TRUE; + s->bytes_per_row = bytes_per_row; + s->p[0] = 0; + s->p[1] = -1; + s->p[2] = -1; + } + + /* BID processing loop */ + while (cnt < len || s->end_of_data == 1) + { + if (s->end_of_data == 1) + { + s->buf_needed = 2; + s->options &= ~T85_VLENGTH; + s->end_of_data = 2; + } + if (s->comment_len) + { + /* We are in a COMMENT. Absorb its contents */ + chunk = len - cnt; + if ((s->comment_progress + chunk) >= s->comment_len) + { + /* Finished */ + chunk = s->comment_len - s->comment_progress; + /* If the comment was too long to be passed to the handler, we still + call the handler with the buffer set to NULL, so it knows a large + comment has occurred. */ + if (s->comment) + memcpy(&s->comment[s->comment_progress], &data[cnt], chunk); + if (s->comment_handler) + s->interrupt = s->comment_handler(s->comment_user_data, s->comment, s->comment_len); + if (s->comment) + { + free(s->comment); + s->comment = NULL; + } + s->comment_len = 0; + s->comment_progress = 0; + } + else + { + if (s->comment) + memcpy(&s->comment[s->comment_progress], &data[cnt], chunk); + s->comment_progress += chunk; + } + cnt += chunk; + continue; + } + + /* Load marker segments into s->buffer for processing */ + if (s->buf_len > 0) + { + /* We are in a marker of some kind. Load the first 2 bytes of + the marker, so we can determine its type, and hence its full + length. */ + while (s->buf_len < s->buf_needed && cnt < len) + s->buffer[s->buf_len++] = data[cnt++]; + /* Check we have enough bytes to see the message type */ + if (s->buf_len < s->buf_needed) + continue; + switch (s->buffer[1]) + { + case T82_STUFF: + /* Forward stuffed 0xFF to arithmetic decoder. This is likely to be + the commonest thing for us to hit here. */ + decode_pscd(s, s->buffer, 2); + s->buf_len = 0; + + if (s->interrupt) + return T4_DECODE_INTERRUPT; + break; + case T82_ABORT: + s->buf_len = 0; + return T4_DECODE_ABORTED; + case T82_COMMENT: + s->buf_needed = 6; + if (s->buf_len < 6) + continue; + s->buf_needed = 2; + s->buf_len = 0; + + s->comment_len = pack_32(&s->buffer[2]); + /* Only try to buffer and process the comment's contents if we have + a defined callback routine to do something with it. */ + /* If this malloc fails we carry on working just fine, and don't try to + process the contents of the comment. That is fairly benign, as + the comments are not generally of critical importance, so let's + not worry. */ + if (s->comment_handler && s->comment_len > 0 && s->comment_len <= s->max_comment_len) + s->comment = malloc(s->comment_len); + s->comment_progress = 0; + continue; + case T82_ATMOVE: + s->buf_needed = 8; + if (s->buf_len < 8) + continue; + s->buf_needed = 2; + s->buf_len = 0; + + if (s->at_moves >= T85_ATMOVES_MAX) + return T4_DECODE_INVALID_DATA; + s->at_row[s->at_moves] = pack_32(&s->buffer[2]); + s->at_tx[s->at_moves] = s->buffer[6]; + if (s->at_tx[s->at_moves] > s->mx + || + (s->at_tx[s->at_moves] > 0 && s->at_tx[s->at_moves] < ((s->options & T85_LRLTWO) ? 5 : 3)) + || + s->buffer[7] != 0) + { + return T4_DECODE_INVALID_DATA; + } + s->at_moves++; + break; + case T82_NEWLEN: + s->buf_needed = 6; + if (s->buf_len < 6) + continue; + s->buf_needed = 2; + s->buf_len = 0; + + if (!(s->options & T85_VLENGTH)) + return T4_DECODE_INVALID_DATA; + s->options &= ~T85_VLENGTH; + y = pack_32(&s->buffer[2]); + /* An update to the image length is not allowed to stretch it. */ + if (y > s->yd) + return T4_DECODE_INVALID_DATA; + s->yd = y; + break; + case T82_SDNORM: + case T82_SDRST: + if (!(s->options & T85_VLENGTH)) + { + /* A plain SDNORM or SDRST with no peek ahead required */ + s->buf_len = 0; + if (finish_sde(s)) + return T4_DECODE_INTERRUPT; + /* Check whether this was the last SDE */ + if (s->y >= s->yd) + { + s->compressed_image_size -= (len - cnt); + return T4_DECODE_OK; + } + break; + } + /* This is the messy case. We need to peek ahead, as this element + might be immediately followed by a T82_NEWLEN which affects the + limit of what we decode here. */ + if (s->buf_needed < 3) + s->buf_needed = 3; + if (s->buf_len < 3) + continue; + /* Peek ahead to see whether a NEWLEN marker segment follows */ + if (s->buffer[2] != T82_ESC) + { + /* This is not an escape sequence, so push the single peek-ahead + byte back into the buffer. We should always have just grabbed + at least one byte, so this should be safe. */ + s->buf_needed = 2; + s->buf_len = 0; + cnt--; + /* Process the T82_SDNORM or T82_SDRST */ + if (finish_sde(s)) + return T4_DECODE_INTERRUPT; + /* Check whether this was the last SDE */ + if (s->y >= s->yd) + { + s->compressed_image_size -= (len - cnt); + return T4_DECODE_OK; + } + break; + } + if (s->buf_needed < 4) + s->buf_needed = 4; + if (s->buf_len < 4) + continue; + if (s->buffer[3] != T82_NEWLEN) + { + s->buf_needed = 2; + + /* Process the T82_SDNORM or T82_SDRST */ + if (finish_sde(s)) + return T4_DECODE_INTERRUPT; + /* Check whether this was the last SDE */ + if (s->y >= s->yd) + { + s->compressed_image_size -= (len - cnt); + return T4_DECODE_OK; + } + /* Recycle the two peek-ahead marker sequence bytes to + be processed later. */ + s->buffer[0] = s->buffer[2]; + s->buffer[1] = s->buffer[3]; + s->buf_len = 2; + break; + } + if (s->buf_needed < 8) + s->buf_needed = 8; + if (s->buf_len < 8) + continue; + s->buf_needed = 2; + s->buf_len = 0; + /* We must have a complete T82_NEWLEN to be here, which we need + to process immediately. */ + s->options &= ~T85_VLENGTH; + y = pack_32(&s->buffer[4]); + /* An update to the image length is not allowed to stretch it. */ + if (y > s->yd) + return T4_DECODE_INVALID_DATA; + /* Things look OK, so accept this new length, and proceed. */ + s->yd = y; + /* Now process the T82_SDNORM or T82_SDRST */ + if (finish_sde(s)) + return T4_DECODE_INTERRUPT; + /* We might be at the end of the image now, but even if we are + there should still be a final training T82_SDNORM or T82_SDRST + that we should pick up. When we do, we won't wait for further + T82_NEWLEN entries, so we should stop crisply on the last byte + of the image. */ + break; + default: + s->buf_len = 0; + return T4_DECODE_INVALID_DATA; + } + } + else if (cnt < len && data[cnt] == T82_ESC) + { + s->buffer[s->buf_len++] = data[cnt++]; + } + else + { + /* We have found PSCD bytes */ + cnt += decode_pscd(s, data + cnt, len - cnt); + if (s->interrupt) + return T4_DECODE_INTERRUPT; + /* We should only have stopped processing PSCD if + we ran out of data, or hit a T82_ESC */ + if (cnt < len && data[cnt] != T82_ESC) + return T4_DECODE_INVALID_DATA; + } + } + + return T4_DECODE_MORE_DATA; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_set_row_write_handler(t85_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data) +{ + s->row_write_handler = handler; + s->row_write_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_set_comment_handler(t85_decode_state_t *s, + uint32_t max_comment_len, + t4_row_write_handler_t handler, + void *user_data) +{ + s->max_comment_len = max_comment_len; + s->comment_handler = handler; + s->comment_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_set_image_size_constraints(t85_decode_state_t *s, + uint32_t max_xd, + uint32_t max_yd) +{ + s->max_xd = max_xd; + s->max_yd = max_yd; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t85_decode_get_image_width(t85_decode_state_t *s) +{ + return s->xd; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t85_decode_get_image_length(t85_decode_state_t *s) +{ + return s->yd; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_get_compressed_image_size(t85_decode_state_t *s) +{ + return s->compressed_image_size*8; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_new_plane(t85_decode_state_t *s) +{ + if (s->current_bit_plane >= s->bit_planes - 1) + return -1; + + s->current_bit_plane++; + s->tx = 0; + memset(s->buffer, 0, sizeof(s->buffer)); + s->buf_len = 0; + s->buf_needed = 0; + s->at_moves = 0; + memset(s->at_row, 0, sizeof(s->at_row)); + memset(s->at_tx, 0, sizeof(s->at_tx)); + memset(s->row_h, 0, sizeof(s->row_h)); + s->pseudo = FALSE; + s->lntp = FALSE; + s->interrupt = FALSE; + s->end_of_data = 0; + if (s->comment) + { + free(s->comment); + s->comment = NULL; + } + s->comment_len = 0; + s->comment_progress = 0; + s->compressed_image_size = 0; + + t81_t82_arith_decode_restart(&s->s, FALSE); + s->s.nopadding = s->options & T85_VLENGTH; + + s->buf_len = 0; + s->buf_needed = 2; + s->x = 0; + s->y = 0; + s->i = 0; + s->pseudo = TRUE; + s->at_moves = 0; + s->tx = 0; + s->lntp = TRUE; + s->p[0] = 0; + s->p[1] = -1; + s->p[2] = -1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_restart(t85_decode_state_t *s) +{ + s->xd = 0; + s->yd = 0; + s->l0 = 0; + s->mx = 0; + s->bytes_per_row = 0; + s->tx = 0; + s->bie_len = 0; + memset(s->buffer, 0, sizeof(s->buffer)); + s->buf_len = 0; + s->buf_needed = 0; + s->at_moves = 0; + memset(s->at_row, 0, sizeof(s->at_row)); + memset(s->at_tx, 0, sizeof(s->at_tx)); + memset(s->row_h, 0, sizeof(s->row_h)); + s->pseudo = FALSE; + s->lntp = FALSE; + s->interrupt = FALSE; + s->end_of_data = 0; + if (s->comment) + { + free(s->comment); + s->comment = NULL; + } + s->comment_len = 0; + s->comment_progress = 0; + s->compressed_image_size = 0; + + t81_t82_arith_decode_restart(&s->s, FALSE); + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(logging_state_t *) t85_decode_get_logging_state(t85_decode_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t85_decode_state_t *) t85_decode_init(t85_decode_state_t *s, + t4_row_write_handler_t handler, + void *user_data) +{ + if (s == NULL) + { + if ((s = (t85_decode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.85"); + + s->row_write_handler = handler; + s->row_write_user_data = user_data; + + s->min_bit_planes = 1; + s->max_bit_planes = 1; + + s->max_xd = 0; + s->max_yd = 0; + + t81_t82_arith_decode_init(&s->s); + t85_decode_restart(s); + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_release(t85_decode_state_t *s) +{ + if (s->row_buf) + { + free(s->row_buf); + s->row_buf = NULL; + } + if (s->comment) + { + free(s->comment); + s->comment = NULL; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_decode_free(t85_decode_state_t *s) +{ + int ret; + + ret = t85_decode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t85_encode.c b/libs/spandsp/src/t85_encode.c new file mode 100644 index 0000000000..d9c4d200e2 --- /dev/null +++ b/libs/spandsp/src/t85_encode.c @@ -0,0 +1,747 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t85_encode.c - ITU T.85 JBIG for FAX image compression + * + * Written by Steve Underwood + * + * Copyright (C) 2009, 2010 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "spandsp/telephony.h" +#include "spandsp/logging.h" +#include "spandsp/async.h" +#include "spandsp/timezone.h" +#include "spandsp/t4_rx.h" +#include "spandsp/t4_tx.h" +#include "spandsp/t81_t82_arith_coding.h" +#include "spandsp/t85.h" + +#include "spandsp/private/logging.h" +#include "spandsp/private/t81_t82_arith_coding.h" +#include "spandsp/private/t85.h" + +/* Image length update status */ +enum +{ + NEWLEN_NONE = 0, + NEWLEN_PENDING = 1, + NEWLEN_HANDLED = 2 +}; + +static __inline__ void unpack_32(uint8_t *s, int32_t value) +{ + s[3] = value & 0xFF; + value >>= 8; + s[2] = value & 0xFF; + value >>= 8; + s[1] = value & 0xFF; + value >>= 8; + s[0] = value & 0xFF; +} +/*- End of function --------------------------------------------------------*/ + +static void put_stuff(t85_encode_state_t *s, const uint8_t buf[], int len) +{ + uint8_t *new_buf; + uint32_t bytes_per_row; + + if (s->bitstream_iptr + len >= s->bitstream_len) + { + /* TODO: Handle memory allocation errors properly */ + /* The number of uncompressed bytes per row seems like a reasonable measure + of what to expect as a poor case for a compressed row. */ + bytes_per_row = (s->xd + 7) >> 3; + if ((new_buf = realloc(s->bitstream, s->bitstream_len + len + bytes_per_row)) == NULL) + return; + s->bitstream = new_buf; + s->bitstream_len += (len + bytes_per_row); + } + memcpy(&s->bitstream[s->bitstream_iptr], buf, len); + s->bitstream_iptr += len; + s->compressed_image_size += len; +} +/*- End of function --------------------------------------------------------*/ + +/* Callback function for the arithmetic encoder */ +static void output_byte(void *user_data, int byte) +{ + t85_encode_state_t *s; + uint8_t c = byte; + + s = (t85_encode_state_t *) user_data; + c = (uint8_t) byte; + put_stuff(s, &c, 1); +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void output_esc_code(t85_encode_state_t *s, int code) +{ + uint8_t buf[2]; + + buf[0] = T82_ESC; + buf[1] = code; + put_stuff(s, buf, 2); +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void output_newlen(t85_encode_state_t *s) +{ + uint8_t buf[6]; + + if (s->newlen == NEWLEN_PENDING) + { + buf[0] = T82_ESC; + buf[1] = T82_NEWLEN; + unpack_32(&buf[2], s->yd); + put_stuff(s, buf, 6); + if (s->y == s->yd) + { + /* See T.82/6.2.6.2 */ + output_esc_code(s, T82_SDNORM); + } + s->newlen = NEWLEN_HANDLED; + } +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void output_comment(t85_encode_state_t *s) +{ + uint8_t buf[6]; + + if (s->comment) + { + buf[0] = T82_ESC; + buf[1] = T82_COMMENT; + unpack_32(&buf[2], s->comment_len); + put_stuff(s, buf, 6); + put_stuff(s, s->comment, s->comment_len); + s->comment = NULL; + s->comment_len = 0; + } +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ void output_atmove(t85_encode_state_t *s) +{ + uint8_t buf[8]; + + if (s->new_tx >= 0 && s->new_tx != s->tx) + { + s->tx = s->new_tx; + buf[0] = T82_ESC; + buf[1] = T82_ATMOVE; + unpack_32(&buf[2], 0); + buf[6] = s->tx; + buf[7] = 0; + put_stuff(s, buf, 8); + } +} +/*- End of function --------------------------------------------------------*/ + +static void generate_bih(t85_encode_state_t *s, uint8_t *buf) +{ + /* DL - Initial layer to be transmitted */ + buf[0] = 0; + /* D - Number of differential layers */ + buf[1] = 0; + /* P - Number of bit planes */ + buf[2] = s->bit_planes; + /* Unspecified */ + buf[3] = 0; + /* XD - Horizontal image size at layer D */ + unpack_32(&buf[4], s->xd); + /* YD - Vertical image size at layer D */ + unpack_32(&buf[8], s->yd); + /* L0 - Rows per stripe, at the lowest resolution */ + unpack_32(&buf[12], s->l0); + /* MX - Maximum horizontal offset allowed for AT pixel */ + buf[16] = s->mx; + /* MY - Maximum vertical offset allowed for AT pixel */ + buf[17] = 0; + /* Order byte: */ + /* 4 unused bits */ + /* HITOLO - transmission order of differential layers */ + /* SEQ - indication of progressive-compatible sequential coding */ + /* ILEAVE - interleaved transmission order of multiple bit plane */ + /* SMID - transmission order of stripes */ + /* Note that none of these are relevant to T.85 */ + buf[18] = 0; + /* Options byte: */ + /* 1 unused bit */ + /* LRLTWO - number of reference rows */ + /* VLENGTH - indication of possible use of NEWLEN marker segment */ + /* TPDON - use of TP for Typical Prediction for differential layers */ + /* TPBON - use of TP for base layer */ + /* DPON - use of Deterministic Prediction */ + /* DPPRIV - use of private DP table */ + /* DPLAST - use of last DP table */ + /* Note that only T85_TPBON, T85_VLENGTH, and T85_LRLTWO are relevant to T.85 */ + buf[19] = s->options; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t85_encode_set_options(t85_encode_state_t *s, + uint32_t l0, + int mx, + int options) +{ + if (s->y > 0) + return; + + /* Its still OK to change things */ + if (l0 >= 1 && l0 <= s->yd) + s->l0 = l0; + if (mx >= 0 && mx <= 127) + s->mx = mx; + if (options >= 0) + s->options = options & (T85_TPBON | T85_VLENGTH | T85_LRLTWO); +} +/*- End of function --------------------------------------------------------*/ + +static int get_next_row(t85_encode_state_t *s) +{ + uint8_t buf[20]; + uint32_t bytes_per_row; + const uint8_t *hp[3]; + uint8_t *z; + uint32_t row_h[3]; + uint32_t j; + int32_t o; + uint32_t a; + uint32_t p; + uint32_t t; + uint32_t c_min; + uint32_t c_max; + uint32_t cl_min; + uint32_t cl_max; + int ltp; + int cx; + int t_max; + int i; + + if (s->y >= s->yd) + { + /* We have already finished pumping out the image */ + return -1; + } + + s->bitstream_iptr = 0; + s->bitstream_optr = 0; + bytes_per_row = (s->xd + 7) >> 3; + /* Rotate the three rows which we buffer */ + z = s->prev_row[2]; + s->prev_row[2] = s->prev_row[1]; + s->prev_row[1] = s->prev_row[0]; + s->prev_row[0] = z; + + /* Copy the new row to our buffer, and ensure the last byte of the row is + zero padded. The need to tweak this is actually the only reason for + storing a third row. We do not want to tamper with the source buffer. */ + if (s->fill_with_white) + { + memset(s->prev_row[0], 0, bytes_per_row); + } + else + { + if (s->row_read_handler(s->row_read_user_data, s->prev_row[0], bytes_per_row) <= 0) + { + /* The source has stopped feeding us rows early. Try to clip the image + to the current size. */ + if (t85_encode_set_image_length(s, 1) == 0) + return 0; + /* We can't clip the image to the current length. We will have to + continue up to the original length with blank (all white) rows. */ + s->fill_with_white = TRUE; + memset(s->prev_row[0], 0, bytes_per_row); + } + } + if ((s->xd & 7)) + s->prev_row[0][bytes_per_row - 1] &= ~((1 << (8 - (s->xd & 7))) - 1); + + if (s->current_bit_plane == 0 && s->y == 0) + { + /* Things that need to be done before the first row is encoded */ + generate_bih(s, buf); + put_stuff(s, buf, 20); + } + + if (s->i == 0) + { + /* Things that need to be done before the next SDE is encoded */ + output_newlen(s); + output_comment(s); + output_atmove(s); + if (s->mx == 0) + { + /* Disable ATMOVE analysis */ + s->new_tx = 0; + } + else + { + /* Enable ATMOVE analysis */ + s->new_tx = -1; + s->c_all = 0; + for (i = 0; i <= s->mx; i++) + s->c[i] = 0; + } + t81_t82_arith_encode_restart(&s->s, TRUE); + } + + /* Typical prediction */ + ltp = FALSE; + if ((s->options & T85_TPBON)) + { + /* Look for a match between the rows */ + ltp = (memcmp(s->prev_row[0], s->prev_row[1], bytes_per_row) == 0); + t81_t82_arith_encode(&s->s, + (s->options & T85_LRLTWO) ? TPB2CX : TPB3CX, + (ltp == s->prev_ltp)); + s->prev_ltp = ltp; + } + + if (!ltp) + { + /* Pointer to the first image byte in each the three rows of interest */ + hp[0] = s->prev_row[0]; + hp[1] = s->prev_row[1]; + hp[2] = s->prev_row[2]; + + row_h[0] = 0; + row_h[1] = (uint32_t) hp[1][0] << 8; + row_h[2] = (uint32_t) hp[2][0] << 8; + + /* Encode row */ + for (j = 0; j < s->xd; ) + { + row_h[0] |= hp[0][0]; + if (j < (bytes_per_row - 1)*8) + { + row_h[1] |= hp[1][1]; + row_h[2] |= hp[2][1]; + } + if ((s->options & T85_LRLTWO)) + { + /* Two row template */ + do + { + row_h[0] <<= 1; + row_h[1] <<= 1; + row_h[2] <<= 1; + cx = (row_h[0] >> 9) & 0x00F; + if (s->tx) + { + cx |= ((row_h[1] >> 10) & 0x3E0); + if (j >= (uint32_t) s->tx) + { + o = (j - s->tx) - (j & ~7); + cx |= (((hp[0][o >> 3] >> (7 - (o & 7))) & 1) << 4); + } + } + else + { + cx |= ((row_h[1] >> 10) & 0x3F0); + } + p = (row_h[0] >> 8) & 1; + t81_t82_arith_encode(&s->s, cx, p); + + /* Update the statistics for adaptive template changes, + if this analysis is in progress. */ + if (s->new_tx < 0 && j >= s->mx && j < s->xd - 2) + { + if (p == ((row_h[1] >> 14) & 1)) + s->c[0]++; + for (t = 5; t <= s->mx && t <= j; t++) + { + o = (j - t) - (j & ~7); + a = (hp[0][o >> 3] >> (7 - (o & 7))) & 1; + if (a == p) + s->c[t]++; + } + if (p == 0) + { + for ( ; t <= s->mx; t++) + s->c[t]++; + } + ++s->c_all; + } + } + while ((++j & 7) && j < s->xd); + } + else + { + /* Three row template */ + do + { + row_h[0] <<= 1; + row_h[1] <<= 1; + row_h[2] <<= 1; + cx = ((row_h[2] >> 8) & 0x380) | ((row_h[0] >> 9) & 0x003); + if (s->tx) + { + cx |= ((row_h[1] >> 12) & 0x078); + if (j >= (uint32_t) s->tx) + { + o = (j - s->tx) - (j & ~7); + cx |= (((hp[0][o >> 3] >> (7 - (o & 7))) & 1) << 2); + } + } + else + { + cx |= ((row_h[1] >> 12) & 0x07C); + } + p = (row_h[0] >> 8) & 1; + t81_t82_arith_encode(&s->s, cx, p); + + /* Update the statistics for adaptive template changes, + if this analysis is in progress. */ + if (s->new_tx < 0 && j >= s->mx && j < s->xd - 2) + { + if (p == ((row_h[1] >> 14) & 1)) + s->c[0]++; + for (t = 3; t <= s->mx && t <= j; t++) + { + o = (j - t) - (j & ~7); + a = (hp[0][o >> 3] >> (7 - (o & 7))) & 1; + if (a == p) + s->c[t]++; + } + if (p == 0) + { + for ( ; t <= s->mx; t++) + s->c[t]++; + } + ++s->c_all; + } + } + while ((++j & 7) && j < s->xd); + } + hp[0]++; + hp[1]++; + hp[2]++; + } + } + + s->i++; + s->y++; + if (s->i == s->l0 || s->y == s->yd) + { + /* We are at the end of the stripe */ + t81_t82_arith_encode_flush(&s->s); + output_esc_code(s, T82_SDNORM); + s->i = 0; + output_newlen(s); + } + + /* T.82/Annex C - is it time for an adaptive template change? */ + if (s->new_tx < 0 && s->c_all > 2048) + { + c_min = + cl_min = UINT32_MAX; + c_max = + cl_max = 0; + t_max = 0; + for (i = (s->options & T85_LRLTWO) ? 5 : 3; i <= s->mx; i++) + { + if (s->c[i] > c_max) + c_max = s->c[i]; + if (s->c[i] < c_min) + c_min = s->c[i]; + if (s->c[i] > s->c[t_max]) + t_max = i; + } + cl_min = (s->c[0] < c_min) ? s->c[0] : c_min; + cl_max = (s->c[0] > c_max) ? s->c[0] : c_max; + /* This test is straight from T.82/Figure C.2 */ + if ((s->c_all - c_max) < (s->c_all >> 3) + && + (c_max - s->c[s->tx]) > (s->c_all - c_max) + && + (c_max - s->c[s->tx]) > (s->c_all >> 4) + && + (c_max - (s->c_all - s->c[s->tx])) > (s->c_all - c_max) + && + (c_max - (s->c_all - s->c[s->tx])) > (s->c_all >> 4) + && + (c_max - c_min) > (s->c_all >> 2) + && + (s->tx || (cl_max - cl_min) > (s->c_all >> 3))) + { + /* It is time to perform an ATMOVE */ + s->new_tx = t_max; + } + else + { + /* Disable further analysis */ + s->new_tx = s->tx; + } + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_set_image_width(t85_encode_state_t *s, uint32_t image_width) +{ + int bytes_per_row; + uint8_t *t; + + if (s->xd == image_width) + return 0; + /* Are we too late to change the width for this page? */ + if (s->y > 0) + return -1; + s->xd = image_width; + bytes_per_row = (s->xd + 7) >> 3; + if ((t = (uint8_t *) realloc(s->row_buf, 3*bytes_per_row)) == NULL) + return -1; + s->row_buf = t; + memset(s->row_buf, 0, 3*bytes_per_row); + s->prev_row[0] = s->row_buf; + s->prev_row[1] = s->row_buf + bytes_per_row; + s->prev_row[2] = s->row_buf + 2*bytes_per_row; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_set_image_length(t85_encode_state_t *s, uint32_t length) +{ + /* We must have variable length enabled. + We do not allow the length to be changed multiple times. + We only allow an image to be shrunk, and not stretched. + We do not allow the length to become zero. */ + if (!(s->options & T85_VLENGTH) || s->newlen == NEWLEN_HANDLED || length >= s->yd || length < 1) + { + /* Invalid parameter */ + return -1; + } + if (s->y > 0) + { + /* TODO: If we are already beyond the new length, we scale back the new length silently. + Is there any downside to this? */ + if (length < s->y) + length = s->y; + if (s->yd != length) + s->newlen = NEWLEN_PENDING; + } + s->yd = length; + if (s->y == s->yd) + { + /* We are already at the end of the image, so finish it off. */ + if (s->i > 0) + { + t81_t82_arith_encode_flush(&s->s); + output_esc_code(s, T82_SDNORM); + s->i = 0; + } + output_newlen(s); + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t85_encode_abort(t85_encode_state_t *s) +{ + output_esc_code(s, T82_ABORT); + /* Make the image appear to be complete, so the encoder stops outputting. + Take care, as this means s->y is now telling lies. */ + s->y = s->yd; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(void) t85_encode_comment(t85_encode_state_t *s, const uint8_t comment[], size_t len) +{ + s->comment = comment; + s->comment_len = len; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_image_complete(t85_encode_state_t *s) +{ + if (s->y >= s->yd) + return SIG_STATUS_END_OF_DATA; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_get(t85_encode_state_t *s, uint8_t buf[], size_t max_len) +{ + int len; + int n; + + for (len = 0; len < max_len; len += n) + { + if (s->bitstream_optr >= s->bitstream_iptr) + { + if (get_next_row(s) < 0) + return len; + } + n = s->bitstream_iptr - s->bitstream_optr; + if (n > max_len - len) + n = max_len - len; + memcpy(&buf[len], &s->bitstream[s->bitstream_optr], n); + s->bitstream_optr += n; + } + return len; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t85_encode_get_image_width(t85_encode_state_t *s) +{ + return s->xd; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(uint32_t) t85_encode_get_image_length(t85_encode_state_t *s) +{ + return s->yd; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_get_compressed_image_size(t85_encode_state_t *s) +{ + return s->compressed_image_size*8; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_set_row_read_handler(t85_encode_state_t *s, + t4_row_read_handler_t handler, + void *user_data) +{ + s->row_read_handler = handler; + s->row_read_user_data = user_data; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_restart(t85_encode_state_t *s, uint32_t image_width, uint32_t image_length) +{ + int bytes_per_row; + + /* Allow the image width to be anything, although only a few values are actually + permitted by the T.85 and T.4 specs. Higher levels in the stack need to impose + these restrictions. */ + t85_encode_set_image_width(s, image_width); + bytes_per_row = (s->xd + 7) >> 3; + memset(s->row_buf, 0, 3*bytes_per_row); + s->yd = image_length; + + s->comment = NULL; + s->comment_len = 0; + s->y = 0; + s->i = 0; + s->newlen = NEWLEN_NONE; + s->new_tx = -1; + s->tx = 0; + s->prev_ltp = FALSE; + s->bitstream_iptr = 0; + s->bitstream_optr = 0; + if (s->bitstream) + { + free(s->bitstream); + s->bitstream = NULL; + } + s->bitstream_len = 0; + s->fill_with_white = FALSE; + s->compressed_image_size = 0; + + t81_t82_arith_encode_init(&s->s, output_byte, s); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(logging_state_t *) t85_encode_get_logging_state(t85_encode_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(t85_encode_state_t *) t85_encode_init(t85_encode_state_t *s, + uint32_t image_width, + uint32_t image_length, + t4_row_read_handler_t handler, + void *user_data) +{ + if (s == NULL) + { + if ((s = (t85_encode_state_t *) malloc(sizeof(*s))) == NULL) + return NULL; + } + memset(s, 0, sizeof(*s)); + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "T.85"); + + s->row_read_handler = handler; + s->row_read_user_data = user_data; + + /* T.85 BASIC setting for L0. In T.85 this may only be changed if T.30 negotiation permits. */ + s->l0 = 128; + /* No ATMOVE pending */ + s->mx = 127; + /* Default options */ + s->options = T85_TPBON | T85_VLENGTH; + + s->bitstream = NULL; + s->bitstream_len = 0; + + s->bit_planes = 1; + s->current_bit_plane = 0; + + t85_encode_restart(s, image_width, image_length); + + return s; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_release(t85_encode_state_t *s) +{ + if (s->row_buf) + { + free(s->row_buf); + s->row_buf = NULL; + } + if (s->bitstream) + { + free(s->bitstream); + s->bitstream = NULL; + s->bitstream_len = 0; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) t85_encode_free(t85_encode_state_t *s) +{ + int ret; + + ret = t85_encode_release(s); + free(s); + return ret; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/testcpuid.c b/libs/spandsp/src/testcpuid.c index 2344c59079..248f7b8d1c 100644 --- a/libs/spandsp/src/testcpuid.c +++ b/libs/spandsp/src/testcpuid.c @@ -92,7 +92,7 @@ int has_MMX(void) int result; if (!have_cpuid_p()) - return 0; + return 0; /*endif*/ __asm__ __volatile__ ( " push %%ebx;\n" @@ -107,7 +107,7 @@ int has_MMX(void) : "=a" (result) : : "ecx", "edx"); - return result; + return result; } /*- End of function --------------------------------------------------------*/ @@ -116,7 +116,7 @@ int has_SIMD(void) int result; if (!have_cpuid_p()) - return 0; + return 0; /*endif*/ __asm__ __volatile__ ( " push %%ebx;\n" @@ -131,7 +131,7 @@ int has_SIMD(void) : "=a" (result) : : "ecx", "edx"); - return result; + return result; } /*- End of function --------------------------------------------------------*/ @@ -140,7 +140,7 @@ int has_SIMD2(void) int result; if (!have_cpuid_p()) - return 0; + return 0; /*endif*/ __asm__ __volatile__ ( " push %%ebx;\n" @@ -155,7 +155,7 @@ int has_SIMD2(void) : "=a" (result) : : "ecx", "edx"); - return result; + return result; } /*- End of function --------------------------------------------------------*/ @@ -164,7 +164,7 @@ int has_3DNow(void) int result; if (!have_cpuid_p()) - return 0; + return 0; /*endif*/ __asm__ __volatile__ ( " push %%ebx;\n" @@ -184,7 +184,7 @@ int has_3DNow(void) : "=c" (result) : : "eax", "edx"); - return result; + return result; } /*- End of function --------------------------------------------------------*/ @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) printf("SIMD2 is %x\n", result); result = has_3DNow(); printf("3DNow is %x\n", result); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ #endif diff --git a/libs/spandsp/src/time_scale.c b/libs/spandsp/src/time_scale.c index 3a85cae71c..605e1c5fb5 100644 --- a/libs/spandsp/src/time_scale.c +++ b/libs/spandsp/src/time_scale.c @@ -133,7 +133,7 @@ SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sa if (s == NULL) { if ((s = (time_scale_state_t *) malloc(sizeof (*s))) == NULL) - return NULL; + return NULL; /*endif*/ alloced = TRUE; } diff --git a/libs/spandsp/src/timezone.c b/libs/spandsp/src/timezone.c index 04dfa51daf..79966f1d4c 100644 --- a/libs/spandsp/src/timezone.c +++ b/libs/spandsp/src/timezone.c @@ -112,9 +112,11 @@ static const int year_lengths[2] = DAYS_PER_LEAP_YEAR }; -static int increment_overflow(int *number, int delta) +static int add_with_overflow_detection(int *number, int delta) { - int last_number; + /* This needs to be considered volatile, or clever optimisation destroys + the effect of the the rollover detection logic */ + volatile int last_number; last_number = *number; *number += delta; @@ -209,7 +211,7 @@ static struct tm *time_sub(const time_t * const timep, const long int offset, co if (idelta == 0) idelta = (tdays < 0) ? -1 : 1; newy = y; - if (increment_overflow(&newy, idelta)) + if (add_with_overflow_detection(&newy, idelta)) return NULL; leapdays = leaps_thru_end_of(newy - 1) - leaps_thru_end_of(y - 1); tdays -= ((time_t) newy - y)*DAYS_PER_NON_LEAP_YEAR; @@ -234,18 +236,18 @@ static struct tm *time_sub(const time_t * const timep, const long int offset, co } while (idays < 0) { - if (increment_overflow(&y, -1)) + if (add_with_overflow_detection(&y, -1)) return NULL; idays += year_lengths[isleap(y)]; } while (idays >= year_lengths[isleap(y)]) { idays -= year_lengths[isleap(y)]; - if (increment_overflow(&y, 1)) + if (add_with_overflow_detection(&y, 1)) return NULL; } tmp->tm_year = y; - if (increment_overflow(&tmp->tm_year, -TM_YEAR_BASE)) + if (add_with_overflow_detection(&tmp->tm_year, -TM_YEAR_BASE)) return NULL; tmp->tm_yday = idays; /* The "extra" mods below avoid overflow problems. */ diff --git a/libs/spandsp/src/tone_generate.c b/libs/spandsp/src/tone_generate.c index 437865b3d3..487bb69833 100644 --- a/libs/spandsp/src/tone_generate.c +++ b/libs/spandsp/src/tone_generate.c @@ -45,7 +45,6 @@ #include "spandsp/telephony.h" #include "spandsp/fast_convert.h" -#include "spandsp/dc_restore.h" #include "spandsp/complex.h" #include "spandsp/dds.h" #include "spandsp/tone_generate.h" @@ -131,7 +130,7 @@ SPAN_DECLARE_NONSTD(int) tone_gen(tone_gen_state_t *s, int16_t amp[], int max_sa int i; if (s->current_section < 0) - return 0; + return 0; for (samples = 0; samples < max_samples; ) { diff --git a/libs/spandsp/src/v17_v32bis_tx_constellation_maps.h b/libs/spandsp/src/v17_v32bis_tx_constellation_maps.h index 4abe80d93d..8044ad1e32 100644 --- a/libs/spandsp/src/v17_v32bis_tx_constellation_maps.h +++ b/libs/spandsp/src/v17_v32bis_tx_constellation_maps.h @@ -31,134 +31,134 @@ static const complexi16_t v17_v32bis_14400_constellation[128] = static const complexf_t v17_v32bis_14400_constellation[128] = #endif { - {-8, -3}, /* 0x00 */ - { 9, 2}, /* 0x01 */ - { 2, -9}, /* 0x02 */ - {-3, 8}, /* 0x03 */ - { 8, 3}, /* 0x04 */ - {-9, -2}, /* 0x05 */ - {-2, 9}, /* 0x06 */ - { 3, -8}, /* 0x07 */ - {-8, 1}, /* 0x08 */ - { 9, -2}, /* 0x09 */ - {-2, -9}, /* 0x0A */ - { 1, 8}, /* 0x0B */ - { 8, -1}, /* 0x0C */ - {-9, 2}, /* 0x0D */ - { 2, 9}, /* 0x0E */ - {-1, -8}, /* 0x0F */ - {-4, -3}, /* 0x10 */ - { 5, 2}, /* 0x11 */ - { 2, -5}, /* 0x12 */ - {-3, 4}, /* 0x13 */ - { 4, 3}, /* 0x14 */ - {-5, -2}, /* 0x15 */ - {-2, 5}, /* 0x16 */ - { 3, -4}, /* 0x17 */ - {-4, 1}, /* 0x18 */ - { 5, -2}, /* 0x19 */ - {-2, -5}, /* 0x1A */ - { 1, 4}, /* 0x1B */ - { 4, -1}, /* 0x1C */ - {-5, 2}, /* 0x1D */ - { 2, 5}, /* 0x1E */ - {-1, -4}, /* 0x1F */ - { 4, -3}, /* 0x20 */ - {-3, 2}, /* 0x21 */ - { 2, 3}, /* 0x22 */ - {-3, -4}, /* 0x23 */ - {-4, 3}, /* 0x24 */ - { 3, -2}, /* 0x25 */ - {-2, -3}, /* 0x26 */ - { 3, 4}, /* 0x27 */ - { 4, 1}, /* 0x28 */ - {-3, -2}, /* 0x29 */ - {-2, 3}, /* 0x2A */ - { 1, -4}, /* 0x2B */ - {-4, -1}, /* 0x2C */ - { 3, 2}, /* 0x2D */ - { 2, -3}, /* 0x2E */ - {-1, 4}, /* 0x2F */ - { 0, -3}, /* 0x30 */ - { 1, 2}, /* 0x31 */ - { 2, -1}, /* 0x32 */ - {-3, 0}, /* 0x33 */ - { 0, 3}, /* 0x34 */ - {-1, -2}, /* 0x35 */ - {-2, 1}, /* 0x36 */ - { 3, 0}, /* 0x37 */ - { 0, 1}, /* 0x38 */ - { 1, -2}, /* 0x39 */ - {-2, -1}, /* 0x3A */ - { 1, 0}, /* 0x3B */ - { 0, -1}, /* 0x3C */ - {-1, 2}, /* 0x3D */ - { 2, 1}, /* 0x3E */ - {-1, 0}, /* 0x3F */ - { 8, -3}, /* 0x40 */ - {-7, 2}, /* 0x41 */ - { 2, 7}, /* 0x42 */ - {-3, -8}, /* 0x43 */ - {-8, 3}, /* 0x44 */ - { 7, -2}, /* 0x45 */ - {-2, -7}, /* 0x46 */ - { 3, 8}, /* 0x47 */ - { 8, 1}, /* 0x48 */ - {-7, -2}, /* 0x49 */ - {-2, 7}, /* 0x4A */ - { 1, -8}, /* 0x4B */ - {-8, -1}, /* 0x4C */ - { 7, 2}, /* 0x4D */ - { 2, -7}, /* 0x4E */ - {-1, 8}, /* 0x4F */ - {-4, -7}, /* 0x50 */ - { 5, 6}, /* 0x51 */ - { 6, -5}, /* 0x52 */ - {-7, 4}, /* 0x53 */ - { 4, 7}, /* 0x54 */ - {-5, -6}, /* 0x55 */ - {-6, 5}, /* 0x56 */ - { 7, -4}, /* 0x57 */ - {-4, 5}, /* 0x58 */ - { 5, -6}, /* 0x59 */ - {-6, -5}, /* 0x5A */ - { 5, 4}, /* 0x5B */ - { 4, -5}, /* 0x5C */ - {-5, 6}, /* 0x5D */ - { 6, 5}, /* 0x5E */ - {-5, -4}, /* 0x5F */ - { 4, -7}, /* 0x60 */ - {-3, 6}, /* 0x61 */ - { 6, 3}, /* 0x62 */ - {-7, -4}, /* 0x63 */ - {-4, 7}, /* 0x64 */ - { 3, -6}, /* 0x65 */ - {-6, -3}, /* 0x66 */ - { 7, 4}, /* 0x67 */ - { 4, 5}, /* 0x68 */ - {-3, -6}, /* 0x69 */ - {-6, 3}, /* 0x6A */ - { 5, -4}, /* 0x6B */ - {-4, -5}, /* 0x6C */ - { 3, 6}, /* 0x6D */ - { 6, -3}, /* 0x6E */ - {-5, 4}, /* 0x6F */ - { 0, -7}, /* 0x70 */ - { 1, 6}, /* 0x71 */ - { 6, -1}, /* 0x72 */ - {-7, 0}, /* 0x73 */ - { 0, 7}, /* 0x74 */ - {-1, -6}, /* 0x75 */ - {-6, 1}, /* 0x76 */ - { 7, 0}, /* 0x77 */ - { 0, 5}, /* 0x78 */ - { 1, -6}, /* 0x79 */ - {-6, -1}, /* 0x7A */ - { 5, 0}, /* 0x7B */ - { 0, -5}, /* 0x7C */ - {-1, 6}, /* 0x7D */ - { 6, 1}, /* 0x7E */ - {-5, 0} /* 0x7F */ + {FP_SCALE(-8.0f), FP_SCALE(-3.0f)}, /* 0x00 */ + {FP_SCALE( 9.0f), FP_SCALE( 2.0f)}, /* 0x01 */ + {FP_SCALE( 2.0f), FP_SCALE(-9.0f)}, /* 0x02 */ + {FP_SCALE(-3.0f), FP_SCALE( 8.0f)}, /* 0x03 */ + {FP_SCALE( 8.0f), FP_SCALE( 3.0f)}, /* 0x04 */ + {FP_SCALE(-9.0f), FP_SCALE(-2.0f)}, /* 0x05 */ + {FP_SCALE(-2.0f), FP_SCALE( 9.0f)}, /* 0x06 */ + {FP_SCALE( 3.0f), FP_SCALE(-8.0f)}, /* 0x07 */ + {FP_SCALE(-8.0f), FP_SCALE( 1.0f)}, /* 0x08 */ + {FP_SCALE( 9.0f), FP_SCALE(-2.0f)}, /* 0x09 */ + {FP_SCALE(-2.0f), FP_SCALE(-9.0f)}, /* 0x0A */ + {FP_SCALE( 1.0f), FP_SCALE( 8.0f)}, /* 0x0B */ + {FP_SCALE( 8.0f), FP_SCALE(-1.0f)}, /* 0x0C */ + {FP_SCALE(-9.0f), FP_SCALE( 2.0f)}, /* 0x0D */ + {FP_SCALE( 2.0f), FP_SCALE( 9.0f)}, /* 0x0E */ + {FP_SCALE(-1.0f), FP_SCALE(-8.0f)}, /* 0x0F */ + {FP_SCALE(-4.0f), FP_SCALE(-3.0f)}, /* 0x10 */ + {FP_SCALE( 5.0f), FP_SCALE( 2.0f)}, /* 0x11 */ + {FP_SCALE( 2.0f), FP_SCALE(-5.0f)}, /* 0x12 */ + {FP_SCALE(-3.0f), FP_SCALE( 4.0f)}, /* 0x13 */ + {FP_SCALE( 4.0f), FP_SCALE( 3.0f)}, /* 0x14 */ + {FP_SCALE(-5.0f), FP_SCALE(-2.0f)}, /* 0x15 */ + {FP_SCALE(-2.0f), FP_SCALE( 5.0f)}, /* 0x16 */ + {FP_SCALE( 3.0f), FP_SCALE(-4.0f)}, /* 0x17 */ + {FP_SCALE(-4.0f), FP_SCALE( 1.0f)}, /* 0x18 */ + {FP_SCALE( 5.0f), FP_SCALE(-2.0f)}, /* 0x19 */ + {FP_SCALE(-2.0f), FP_SCALE(-5.0f)}, /* 0x1A */ + {FP_SCALE( 1.0f), FP_SCALE( 4.0f)}, /* 0x1B */ + {FP_SCALE( 4.0f), FP_SCALE(-1.0f)}, /* 0x1C */ + {FP_SCALE(-5.0f), FP_SCALE( 2.0f)}, /* 0x1D */ + {FP_SCALE( 2.0f), FP_SCALE( 5.0f)}, /* 0x1E */ + {FP_SCALE(-1.0f), FP_SCALE(-4.0f)}, /* 0x1F */ + {FP_SCALE( 4.0f), FP_SCALE(-3.0f)}, /* 0x20 */ + {FP_SCALE(-3.0f), FP_SCALE( 2.0f)}, /* 0x21 */ + {FP_SCALE( 2.0f), FP_SCALE( 3.0f)}, /* 0x22 */ + {FP_SCALE(-3.0f), FP_SCALE(-4.0f)}, /* 0x23 */ + {FP_SCALE(-4.0f), FP_SCALE( 3.0f)}, /* 0x24 */ + {FP_SCALE( 3.0f), FP_SCALE(-2.0f)}, /* 0x25 */ + {FP_SCALE(-2.0f), FP_SCALE(-3.0f)}, /* 0x26 */ + {FP_SCALE( 3.0f), FP_SCALE( 4.0f)}, /* 0x27 */ + {FP_SCALE( 4.0f), FP_SCALE( 1.0f)}, /* 0x28 */ + {FP_SCALE(-3.0f), FP_SCALE(-2.0f)}, /* 0x29 */ + {FP_SCALE(-2.0f), FP_SCALE( 3.0f)}, /* 0x2A */ + {FP_SCALE( 1.0f), FP_SCALE(-4.0f)}, /* 0x2B */ + {FP_SCALE(-4.0f), FP_SCALE(-1.0f)}, /* 0x2C */ + {FP_SCALE( 3.0f), FP_SCALE( 2.0f)}, /* 0x2D */ + {FP_SCALE( 2.0f), FP_SCALE(-3.0f)}, /* 0x2E */ + {FP_SCALE(-1.0f), FP_SCALE( 4.0f)}, /* 0x2F */ + {FP_SCALE( 0.0f), FP_SCALE(-3.0f)}, /* 0x30 */ + {FP_SCALE( 1.0f), FP_SCALE( 2.0f)}, /* 0x31 */ + {FP_SCALE( 2.0f), FP_SCALE(-1.0f)}, /* 0x32 */ + {FP_SCALE(-3.0f), FP_SCALE( 0.0f)}, /* 0x33 */ + {FP_SCALE( 0.0f), FP_SCALE( 3.0f)}, /* 0x34 */ + {FP_SCALE(-1.0f), FP_SCALE(-2.0f)}, /* 0x35 */ + {FP_SCALE(-2.0f), FP_SCALE( 1.0f)}, /* 0x36 */ + {FP_SCALE( 3.0f), FP_SCALE( 0.0f)}, /* 0x37 */ + {FP_SCALE( 0.0f), FP_SCALE( 1.0f)}, /* 0x38 */ + {FP_SCALE( 1.0f), FP_SCALE(-2.0f)}, /* 0x39 */ + {FP_SCALE(-2.0f), FP_SCALE(-1.0f)}, /* 0x3A */ + {FP_SCALE( 1.0f), FP_SCALE( 0.0f)}, /* 0x3B */ + {FP_SCALE( 0.0f), FP_SCALE(-1.0f)}, /* 0x3C */ + {FP_SCALE(-1.0f), FP_SCALE( 2.0f)}, /* 0x3D */ + {FP_SCALE( 2.0f), FP_SCALE( 1.0f)}, /* 0x3E */ + {FP_SCALE(-1.0f), FP_SCALE( 0.0f)}, /* 0x3F */ + {FP_SCALE( 8.0f), FP_SCALE(-3.0f)}, /* 0x40 */ + {FP_SCALE(-7.0f), FP_SCALE( 2.0f)}, /* 0x41 */ + {FP_SCALE( 2.0f), FP_SCALE( 7.0f)}, /* 0x42 */ + {FP_SCALE(-3.0f), FP_SCALE(-8.0f)}, /* 0x43 */ + {FP_SCALE(-8.0f), FP_SCALE( 3.0f)}, /* 0x44 */ + {FP_SCALE( 7.0f), FP_SCALE(-2.0f)}, /* 0x45 */ + {FP_SCALE(-2.0f), FP_SCALE(-7.0f)}, /* 0x46 */ + {FP_SCALE( 3.0f), FP_SCALE( 8.0f)}, /* 0x47 */ + {FP_SCALE( 8.0f), FP_SCALE( 1.0f)}, /* 0x48 */ + {FP_SCALE(-7.0f), FP_SCALE(-2.0f)}, /* 0x49 */ + {FP_SCALE(-2.0f), FP_SCALE( 7.0f)}, /* 0x4A */ + {FP_SCALE( 1.0f), FP_SCALE(-8.0f)}, /* 0x4B */ + {FP_SCALE(-8.0f), FP_SCALE(-1.0f)}, /* 0x4C */ + {FP_SCALE( 7.0f), FP_SCALE( 2.0f)}, /* 0x4D */ + {FP_SCALE( 2.0f), FP_SCALE(-7.0f)}, /* 0x4E */ + {FP_SCALE(-1.0f), FP_SCALE( 8.0f)}, /* 0x4F */ + {FP_SCALE(-4.0f), FP_SCALE(-7.0f)}, /* 0x50 */ + {FP_SCALE( 5.0f), FP_SCALE( 6.0f)}, /* 0x51 */ + {FP_SCALE( 6.0f), FP_SCALE(-5.0f)}, /* 0x52 */ + {FP_SCALE(-7.0f), FP_SCALE( 4.0f)}, /* 0x53 */ + {FP_SCALE( 4.0f), FP_SCALE( 7.0f)}, /* 0x54 */ + {FP_SCALE(-5.0f), FP_SCALE(-6.0f)}, /* 0x55 */ + {FP_SCALE(-6.0f), FP_SCALE( 5.0f)}, /* 0x56 */ + {FP_SCALE( 7.0f), FP_SCALE(-4.0f)}, /* 0x57 */ + {FP_SCALE(-4.0f), FP_SCALE( 5.0f)}, /* 0x58 */ + {FP_SCALE( 5.0f), FP_SCALE(-6.0f)}, /* 0x59 */ + {FP_SCALE(-6.0f), FP_SCALE(-5.0f)}, /* 0x5A */ + {FP_SCALE( 5.0f), FP_SCALE( 4.0f)}, /* 0x5B */ + {FP_SCALE( 4.0f), FP_SCALE(-5.0f)}, /* 0x5C */ + {FP_SCALE(-5.0f), FP_SCALE( 6.0f)}, /* 0x5D */ + {FP_SCALE( 6.0f), FP_SCALE( 5.0f)}, /* 0x5E */ + {FP_SCALE(-5.0f), FP_SCALE(-4.0f)}, /* 0x5F */ + {FP_SCALE( 4.0f), FP_SCALE(-7.0f)}, /* 0x60 */ + {FP_SCALE(-3.0f), FP_SCALE( 6.0f)}, /* 0x61 */ + {FP_SCALE( 6.0f), FP_SCALE( 3.0f)}, /* 0x62 */ + {FP_SCALE(-7.0f), FP_SCALE(-4.0f)}, /* 0x63 */ + {FP_SCALE(-4.0f), FP_SCALE( 7.0f)}, /* 0x64 */ + {FP_SCALE( 3.0f), FP_SCALE(-6.0f)}, /* 0x65 */ + {FP_SCALE(-6.0f), FP_SCALE(-3.0f)}, /* 0x66 */ + {FP_SCALE( 7.0f), FP_SCALE( 4.0f)}, /* 0x67 */ + {FP_SCALE( 4.0f), FP_SCALE( 5.0f)}, /* 0x68 */ + {FP_SCALE(-3.0f), FP_SCALE(-6.0f)}, /* 0x69 */ + {FP_SCALE(-6.0f), FP_SCALE( 3.0f)}, /* 0x6A */ + {FP_SCALE( 5.0f), FP_SCALE(-4.0f)}, /* 0x6B */ + {FP_SCALE(-4.0f), FP_SCALE(-5.0f)}, /* 0x6C */ + {FP_SCALE( 3.0f), FP_SCALE( 6.0f)}, /* 0x6D */ + {FP_SCALE( 6.0f), FP_SCALE(-3.0f)}, /* 0x6E */ + {FP_SCALE(-5.0f), FP_SCALE( 4.0f)}, /* 0x6F */ + {FP_SCALE( 0.0f), FP_SCALE(-7.0f)}, /* 0x70 */ + {FP_SCALE( 1.0f), FP_SCALE( 6.0f)}, /* 0x71 */ + {FP_SCALE( 6.0f), FP_SCALE(-1.0f)}, /* 0x72 */ + {FP_SCALE(-7.0f), FP_SCALE( 0.0f)}, /* 0x73 */ + {FP_SCALE( 0.0f), FP_SCALE( 7.0f)}, /* 0x74 */ + {FP_SCALE(-1.0f), FP_SCALE(-6.0f)}, /* 0x75 */ + {FP_SCALE(-6.0f), FP_SCALE( 1.0f)}, /* 0x76 */ + {FP_SCALE( 7.0f), FP_SCALE( 0.0f)}, /* 0x77 */ + {FP_SCALE( 0.0f), FP_SCALE( 5.0f)}, /* 0x78 */ + {FP_SCALE( 1.0f), FP_SCALE(-6.0f)}, /* 0x79 */ + {FP_SCALE(-6.0f), FP_SCALE(-1.0f)}, /* 0x7A */ + {FP_SCALE( 5.0f), FP_SCALE( 0.0f)}, /* 0x7B */ + {FP_SCALE( 0.0f), FP_SCALE(-5.0f)}, /* 0x7C */ + {FP_SCALE(-1.0f), FP_SCALE( 6.0f)}, /* 0x7D */ + {FP_SCALE( 6.0f), FP_SCALE( 1.0f)}, /* 0x7E */ + {FP_SCALE(-5.0f), FP_SCALE( 0.0f)} /* 0x7F */ }; #if defined(SPANDSP_USE_FIXED_POINTx) @@ -167,70 +167,70 @@ static const complexi16_t v17_v32bis_12000_constellation[64] = static const complexf_t v17_v32bis_12000_constellation[64] = #endif { - { 7, 1}, /* 0x00 */ - {-5, -1}, /* 0x01 */ - {-1, 5}, /* 0x02 */ - { 1, -7}, /* 0x03 */ - {-7, -1}, /* 0x04 */ - { 5, 1}, /* 0x05 */ - { 1, -5}, /* 0x06 */ - {-1, 7}, /* 0x07 */ - { 3, -3}, /* 0x08 */ - {-1, 3}, /* 0x09 */ - { 3, 1}, /* 0x0A */ - {-3, -3}, /* 0x0B */ - {-3, 3}, /* 0x0C */ - { 1, -3}, /* 0x0D */ - {-3, -1}, /* 0x0E */ - { 3, 3}, /* 0x0F */ - { 7, -7}, /* 0x10 */ - {-5, 7}, /* 0x11 */ - { 7, 5}, /* 0x12 */ - {-7, -7}, /* 0x13 */ - {-7, 7}, /* 0x14 */ - { 5, -7}, /* 0x15 */ - {-7, -5}, /* 0x16 */ - { 7, 7}, /* 0x17 */ - {-1, -7}, /* 0x18 */ - { 3, 7}, /* 0x19 */ - { 7, -3}, /* 0x1A */ - {-7, 1}, /* 0x1B */ - { 1, 7}, /* 0x1C */ - {-3, -7}, /* 0x1D */ - {-7, 3}, /* 0x1E */ - { 7, -1}, /* 0x1F */ - { 3, 5}, /* 0x20 */ - {-1, -5}, /* 0x21 */ - {-5, 1}, /* 0x22 */ - { 5, -3}, /* 0x23 */ - {-3, -5}, /* 0x24 */ - { 1, 5}, /* 0x25 */ - { 5, -1}, /* 0x26 */ - {-5, 3}, /* 0x27 */ - {-1, 1}, /* 0x28 */ - { 3, -1}, /* 0x29 */ - {-1, -3}, /* 0x2A */ - { 1, 1}, /* 0x2B */ - { 1, -1}, /* 0x2C */ - {-3, 1}, /* 0x2D */ - { 1, 3}, /* 0x2E */ - {-1, -1}, /* 0x2F */ - {-5, 5}, /* 0x30 */ - { 7, -5}, /* 0x31 */ - {-5, -7}, /* 0x32 */ - { 5, 5}, /* 0x33 */ - { 5, -5}, /* 0x34 */ - {-7, 5}, /* 0x35 */ - { 5, 7}, /* 0x36 */ - {-5, -5}, /* 0x37 */ - {-5, -3}, /* 0x38 */ - { 7, 3}, /* 0x39 */ - { 3, -7}, /* 0x3A */ - {-3, 5}, /* 0x3B */ - { 5, 3}, /* 0x3C */ - {-7, -3}, /* 0x3D */ - {-3, 7}, /* 0x3E */ - { 3, -5} /* 0x3F */ + {FP_SCALE( 7.0f), FP_SCALE( 1.0f)}, /* 0x00 */ + {FP_SCALE(-5.0f), FP_SCALE(-1.0f)}, /* 0x01 */ + {FP_SCALE(-1.0f), FP_SCALE( 5.0f)}, /* 0x02 */ + {FP_SCALE( 1.0f), FP_SCALE(-7.0f)}, /* 0x03 */ + {FP_SCALE(-7.0f), FP_SCALE(-1.0f)}, /* 0x04 */ + {FP_SCALE( 5.0f), FP_SCALE( 1.0f)}, /* 0x05 */ + {FP_SCALE( 1.0f), FP_SCALE(-5.0f)}, /* 0x06 */ + {FP_SCALE(-1.0f), FP_SCALE( 7.0f)}, /* 0x07 */ + {FP_SCALE( 3.0f), FP_SCALE(-3.0f)}, /* 0x08 */ + {FP_SCALE(-1.0f), FP_SCALE( 3.0f)}, /* 0x09 */ + {FP_SCALE( 3.0f), FP_SCALE( 1.0f)}, /* 0x0A */ + {FP_SCALE(-3.0f), FP_SCALE(-3.0f)}, /* 0x0B */ + {FP_SCALE(-3.0f), FP_SCALE( 3.0f)}, /* 0x0C */ + {FP_SCALE( 1.0f), FP_SCALE(-3.0f)}, /* 0x0D */ + {FP_SCALE(-3.0f), FP_SCALE(-1.0f)}, /* 0x0E */ + {FP_SCALE( 3.0f), FP_SCALE( 3.0f)}, /* 0x0F */ + {FP_SCALE( 7.0f), FP_SCALE(-7.0f)}, /* 0x10 */ + {FP_SCALE(-5.0f), FP_SCALE( 7.0f)}, /* 0x11 */ + {FP_SCALE( 7.0f), FP_SCALE( 5.0f)}, /* 0x12 */ + {FP_SCALE(-7.0f), FP_SCALE(-7.0f)}, /* 0x13 */ + {FP_SCALE(-7.0f), FP_SCALE( 7.0f)}, /* 0x14 */ + {FP_SCALE( 5.0f), FP_SCALE(-7.0f)}, /* 0x15 */ + {FP_SCALE(-7.0f), FP_SCALE(-5.0f)}, /* 0x16 */ + {FP_SCALE( 7.0f), FP_SCALE( 7.0f)}, /* 0x17 */ + {FP_SCALE(-1.0f), FP_SCALE(-7.0f)}, /* 0x18 */ + {FP_SCALE( 3.0f), FP_SCALE( 7.0f)}, /* 0x19 */ + {FP_SCALE( 7.0f), FP_SCALE(-3.0f)}, /* 0x1A */ + {FP_SCALE(-7.0f), FP_SCALE( 1.0f)}, /* 0x1B */ + {FP_SCALE( 1.0f), FP_SCALE( 7.0f)}, /* 0x1C */ + {FP_SCALE(-3.0f), FP_SCALE(-7.0f)}, /* 0x1D */ + {FP_SCALE(-7.0f), FP_SCALE( 3.0f)}, /* 0x1E */ + {FP_SCALE( 7.0f), FP_SCALE(-1.0f)}, /* 0x1F */ + {FP_SCALE( 3.0f), FP_SCALE( 5.0f)}, /* 0x20 */ + {FP_SCALE(-1.0f), FP_SCALE(-5.0f)}, /* 0x21 */ + {FP_SCALE(-5.0f), FP_SCALE( 1.0f)}, /* 0x22 */ + {FP_SCALE( 5.0f), FP_SCALE(-3.0f)}, /* 0x23 */ + {FP_SCALE(-3.0f), FP_SCALE(-5.0f)}, /* 0x24 */ + {FP_SCALE( 1.0f), FP_SCALE( 5.0f)}, /* 0x25 */ + {FP_SCALE( 5.0f), FP_SCALE(-1.0f)}, /* 0x26 */ + {FP_SCALE(-5.0f), FP_SCALE( 3.0f)}, /* 0x27 */ + {FP_SCALE(-1.0f), FP_SCALE( 1.0f)}, /* 0x28 */ + {FP_SCALE( 3.0f), FP_SCALE(-1.0f)}, /* 0x29 */ + {FP_SCALE(-1.0f), FP_SCALE(-3.0f)}, /* 0x2A */ + {FP_SCALE( 1.0f), FP_SCALE( 1.0f)}, /* 0x2B */ + {FP_SCALE( 1.0f), FP_SCALE(-1.0f)}, /* 0x2C */ + {FP_SCALE(-3.0f), FP_SCALE( 1.0f)}, /* 0x2D */ + {FP_SCALE( 1.0f), FP_SCALE( 3.0f)}, /* 0x2E */ + {FP_SCALE(-1.0f), FP_SCALE(-1.0f)}, /* 0x2F */ + {FP_SCALE(-5.0f), FP_SCALE( 5.0f)}, /* 0x30 */ + {FP_SCALE( 7.0f), FP_SCALE(-5.0f)}, /* 0x31 */ + {FP_SCALE(-5.0f), FP_SCALE(-7.0f)}, /* 0x32 */ + {FP_SCALE( 5.0f), FP_SCALE( 5.0f)}, /* 0x33 */ + {FP_SCALE( 5.0f), FP_SCALE(-5.0f)}, /* 0x34 */ + {FP_SCALE(-7.0f), FP_SCALE( 5.0f)}, /* 0x35 */ + {FP_SCALE( 5.0f), FP_SCALE( 7.0f)}, /* 0x36 */ + {FP_SCALE(-5.0f), FP_SCALE(-5.0f)}, /* 0x37 */ + {FP_SCALE(-5.0f), FP_SCALE(-3.0f)}, /* 0x38 */ + {FP_SCALE( 7.0f), FP_SCALE( 3.0f)}, /* 0x39 */ + {FP_SCALE( 3.0f), FP_SCALE(-7.0f)}, /* 0x3A */ + {FP_SCALE(-3.0f), FP_SCALE( 5.0f)}, /* 0x3B */ + {FP_SCALE( 5.0f), FP_SCALE( 3.0f)}, /* 0x3C */ + {FP_SCALE(-7.0f), FP_SCALE(-3.0f)}, /* 0x3D */ + {FP_SCALE(-3.0f), FP_SCALE( 7.0f)}, /* 0x3E */ + {FP_SCALE( 3.0f), FP_SCALE(-5.0f)} /* 0x3F */ }; #if defined(SPANDSP_USE_FIXED_POINTx) @@ -239,38 +239,38 @@ static const complexi16_t v17_v32bis_9600_constellation[32] = static const complexf_t v17_v32bis_9600_constellation[32] = #endif { - {-8, 2}, /* 0x00 */ - {-6, -4}, /* 0x01 */ - {-4, 6}, /* 0x02 */ - { 2, 8}, /* 0x03 */ - { 8, -2}, /* 0x04 */ - { 6, 4}, /* 0x05 */ - { 4, -6}, /* 0x06 */ - {-2, -8}, /* 0x07 */ - { 0, 2}, /* 0x08 */ - {-6, 4}, /* 0x09 */ - { 4, 6}, /* 0x0A */ - { 2, 0}, /* 0x0B */ - { 0, -2}, /* 0x0C */ - { 6, -4}, /* 0x0D */ - {-4, -6}, /* 0x0E */ - {-2, 0}, /* 0x0F */ - { 0, -6}, /* 0x10 */ - { 2, -4}, /* 0x11 */ - {-4, -2}, /* 0x12 */ - {-6, 0}, /* 0x13 */ - { 0, 6}, /* 0x14 */ - {-2, 4}, /* 0x15 */ - { 4, 2}, /* 0x16 */ - { 6, 0}, /* 0x17 */ - { 8, 2}, /* 0x18 */ - { 2, 4}, /* 0x19 */ - { 4, -2}, /* 0x1A */ - { 2, -8}, /* 0x1B */ - {-8, -2}, /* 0x1C */ - {-2, -4}, /* 0x1D */ - {-4, 2}, /* 0x1E */ - {-2, 8} /* 0x1F */ + {FP_SCALE(-8.0f), FP_SCALE( 2.0f)}, /* 0x00 */ + {FP_SCALE(-6.0f), FP_SCALE(-4.0f)}, /* 0x01 */ + {FP_SCALE(-4.0f), FP_SCALE( 6.0f)}, /* 0x02 */ + {FP_SCALE( 2.0f), FP_SCALE( 8.0f)}, /* 0x03 */ + {FP_SCALE( 8.0f), FP_SCALE(-2.0f)}, /* 0x04 */ + {FP_SCALE( 6.0f), FP_SCALE( 4.0f)}, /* 0x05 */ + {FP_SCALE( 4.0f), FP_SCALE(-6.0f)}, /* 0x06 */ + {FP_SCALE(-2.0f), FP_SCALE(-8.0f)}, /* 0x07 */ + {FP_SCALE( 0.0f), FP_SCALE( 2.0f)}, /* 0x08 */ + {FP_SCALE(-6.0f), FP_SCALE( 4.0f)}, /* 0x09 */ + {FP_SCALE( 4.0f), FP_SCALE( 6.0f)}, /* 0x0A */ + {FP_SCALE( 2.0f), FP_SCALE( 0.0f)}, /* 0x0B */ + {FP_SCALE( 0.0f), FP_SCALE(-2.0f)}, /* 0x0C */ + {FP_SCALE( 6.0f), FP_SCALE(-4.0f)}, /* 0x0D */ + {FP_SCALE(-4.0f), FP_SCALE(-6.0f)}, /* 0x0E */ + {FP_SCALE(-2.0f), FP_SCALE( 0.0f)}, /* 0x0F */ + {FP_SCALE( 0.0f), FP_SCALE(-6.0f)}, /* 0x10 */ + {FP_SCALE( 2.0f), FP_SCALE(-4.0f)}, /* 0x11 */ + {FP_SCALE(-4.0f), FP_SCALE(-2.0f)}, /* 0x12 */ + {FP_SCALE(-6.0f), FP_SCALE( 0.0f)}, /* 0x13 */ + {FP_SCALE( 0.0f), FP_SCALE( 6.0f)}, /* 0x14 */ + {FP_SCALE(-2.0f), FP_SCALE( 4.0f)}, /* 0x15 */ + {FP_SCALE( 4.0f), FP_SCALE( 2.0f)}, /* 0x16 */ + {FP_SCALE( 6.0f), FP_SCALE( 0.0f)}, /* 0x17 */ + {FP_SCALE( 8.0f), FP_SCALE( 2.0f)}, /* 0x18 */ + {FP_SCALE( 2.0f), FP_SCALE( 4.0f)}, /* 0x19 */ + {FP_SCALE( 4.0f), FP_SCALE(-2.0f)}, /* 0x1A */ + {FP_SCALE( 2.0f), FP_SCALE(-8.0f)}, /* 0x1B */ + {FP_SCALE(-8.0f), FP_SCALE(-2.0f)}, /* 0x1C */ + {FP_SCALE(-2.0f), FP_SCALE(-4.0f)}, /* 0x1D */ + {FP_SCALE(-4.0f), FP_SCALE( 2.0f)}, /* 0x1E */ + {FP_SCALE(-2.0f), FP_SCALE( 8.0f)} /* 0x1F */ }; #if defined(SPANDSP_USE_FIXED_POINTx) @@ -279,22 +279,22 @@ static const complexi16_t v17_v32bis_7200_constellation[16] = static const complexf_t v17_v32bis_7200_constellation[16] = #endif { - { 6, -6}, /* 0x00 */ - {-2, 6}, /* 0x01 */ - { 6, 2}, /* 0x02 */ - {-6, -6}, /* 0x03 */ - {-6, 6}, /* 0x04 */ - { 2, -6}, /* 0x05 */ - {-6, -2}, /* 0x06 */ - { 6, 6}, /* 0x07 */ - {-2, 2}, /* 0x08 */ - { 6, -2}, /* 0x09 */ - {-2, -6}, /* 0x0A */ - { 2, 2}, /* 0x0B */ - { 2, -2}, /* 0x0C */ - {-6, 2}, /* 0x0D */ - { 2, 6}, /* 0x0E */ - {-2, -2} /* 0x0F */ + {FP_SCALE( 6.0f), FP_SCALE(-6.0f)}, /* 0x00 */ + {FP_SCALE(-2.0f), FP_SCALE( 6.0f)}, /* 0x01 */ + {FP_SCALE( 6.0f), FP_SCALE( 2.0f)}, /* 0x02 */ + {FP_SCALE(-6.0f), FP_SCALE(-6.0f)}, /* 0x03 */ + {FP_SCALE(-6.0f), FP_SCALE( 6.0f)}, /* 0x04 */ + {FP_SCALE( 2.0f), FP_SCALE(-6.0f)}, /* 0x05 */ + {FP_SCALE(-6.0f), FP_SCALE(-2.0f)}, /* 0x06 */ + {FP_SCALE( 6.0f), FP_SCALE( 6.0f)}, /* 0x07 */ + {FP_SCALE(-2.0f), FP_SCALE( 2.0f)}, /* 0x08 */ + {FP_SCALE( 6.0f), FP_SCALE(-2.0f)}, /* 0x09 */ + {FP_SCALE(-2.0f), FP_SCALE(-6.0f)}, /* 0x0A */ + {FP_SCALE( 2.0f), FP_SCALE( 2.0f)}, /* 0x0B */ + {FP_SCALE( 2.0f), FP_SCALE(-2.0f)}, /* 0x0C */ + {FP_SCALE(-6.0f), FP_SCALE( 2.0f)}, /* 0x0D */ + {FP_SCALE( 2.0f), FP_SCALE( 6.0f)}, /* 0x0E */ + {FP_SCALE(-2.0f), FP_SCALE(-2.0f)} /* 0x0F */ }; /* This one does not exist in V.17 as a data constellation. It is only @@ -305,10 +305,10 @@ static const complexi16_t v17_v32bis_4800_constellation[4] = static const complexf_t v17_v32bis_4800_constellation[4] = #endif { - {-6, -2}, /* 0x00 */ - {-2, 6}, /* 0x01 */ - { 2, -6}, /* 0x02 */ - { 6, 2} /* 0x03 */ + {FP_SCALE(-6.0f), FP_SCALE(-2.0f)}, /* 0x00 */ + {FP_SCALE(-2.0f), FP_SCALE( 6.0f)}, /* 0x01 */ + {FP_SCALE( 2.0f), FP_SCALE(-6.0f)}, /* 0x02 */ + {FP_SCALE( 6.0f), FP_SCALE( 2.0f)} /* 0x03 */ }; #if defined(SPANDSP_USE_FIXED_POINTx) @@ -317,10 +317,10 @@ static const complexi16_t v17_v32bis_abcd_constellation[4] = static const complexf_t v17_v32bis_abcd_constellation[4] = #endif { - {-6, -2}, /* A */ - { 2, -6}, /* B */ - { 6, 2}, /* C */ - {-2, 6} /* D */ + {FP_SCALE(-6.0f), FP_SCALE(-2.0f)}, /* A */ + {FP_SCALE( 2.0f), FP_SCALE(-6.0f)}, /* B */ + {FP_SCALE( 6.0f), FP_SCALE( 2.0f)}, /* C */ + {FP_SCALE(-2.0f), FP_SCALE( 6.0f)} /* D */ }; /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/v17rx.c b/libs/spandsp/src/v17rx.c index 62256eb3b4..9d692a1548 100644 --- a/libs/spandsp/src/v17rx.c +++ b/libs/spandsp/src/v17rx.c @@ -65,9 +65,13 @@ #include "spandsp/private/logging.h" #include "spandsp/private/v17rx.h" -#if defined(SPANDSP_USE_FIXED_POINT) +#if defined(SPANDSP_USE_FIXED_POINTx) +#define FP_SCALE(x) FP_Q_6_10(x) +#define FP_FACTOR 1024 +#define FP_SHIFT_FACTOR 12 #include "v17_v32bis_rx_fixed_rrc.h" #else +#define FP_SCALE(x) (x) #include "v17_v32bis_rx_floating_rrc.h" #endif #include "v17_v32bis_tx_constellation_maps.h" @@ -144,22 +148,16 @@ enum #endif #if defined(SPANDSP_USE_FIXED_POINTx) -static const int constellation_spacing[4] = -{ - FP_Q_6_10(1.414f), - FP_Q_6_10(2.0f), - FP_Q_6_10(2.828f), - FP_Q_6_10(4.0f) -}; +static const int16_t constellation_spacing[4] = #else static const float constellation_spacing[4] = -{ - 1.414f, - 2.0f, - 2.828f, - 4.0f -}; #endif +{ + FP_SCALE(1.414f), + FP_SCALE(2.0f), + FP_SCALE(2.828f), + FP_SCALE(4.0f) +}; SPAN_DECLARE(float) v17_rx_carrier_frequency(v17_rx_state_t *s) { @@ -196,14 +194,19 @@ static void report_status_change(v17_rx_state_t *s, int status) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexi16_t **coeffs) #else SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs) #endif { +#if defined(SPANDSP_USE_FIXED_POINT) + *coeffs = NULL; + return 0; +#else *coeffs = s->eq_coeff; return V17_EQUALIZER_LEN; +#endif } /*- End of function --------------------------------------------------------*/ @@ -239,13 +242,17 @@ static void equalizer_reset(v17_rx_state_t *s) { /* Start with an equalizer based on everything being perfect */ #if defined(SPANDSP_USE_FIXED_POINTx) + static const complexi16_t x = {FP_SCALE(3.0f), FP_SCALE(0.0f)}; + cvec_zeroi16(s->eq_coeff, V17_EQUALIZER_LEN); - s->eq_coeff[V17_EQUALIZER_PRE_LEN] = complex_seti16(3*FP_FACTOR, 0); + s->eq_coeff[V17_EQUALIZER_PRE_LEN] = x; cvec_zeroi16(s->eq_buf, V17_EQUALIZER_LEN); s->eq_delta = 32768.0f*EQUALIZER_DELTA/V17_EQUALIZER_LEN; #else + static const complexf_t x = {3.0f, 0.0f}; + cvec_zerof(s->eq_coeff, V17_EQUALIZER_LEN); - s->eq_coeff[V17_EQUALIZER_PRE_LEN] = complex_setf(3.0f, 0.0f); + s->eq_coeff[V17_EQUALIZER_PRE_LEN] = x; cvec_zerof(s->eq_buf, V17_EQUALIZER_LEN); s->eq_delta = EQUALIZER_DELTA/V17_EQUALIZER_LEN; #endif @@ -258,12 +265,23 @@ static void equalizer_reset(v17_rx_state_t *s) #if defined(SPANDSP_USE_FIXED_POINTx) static __inline__ complexi16_t equalizer_get(v17_rx_state_t *s) +{ + complexi32_t zz; + complexi16_t z; + + /* Get the next equalized value. */ + zz = cvec_circular_dot_prodi16(s->eq_buf, s->eq_coeff, V17_EQUALIZER_LEN, s->eq_step); + z.re = zz.re >> FP_SHIFT_FACTOR; + z.im = zz.im >> FP_SHIFT_FACTOR; + return z; +} #else static __inline__ complexf_t equalizer_get(v17_rx_state_t *s) -#endif { + /* Get the next equalized value. */ return cvec_circular_dot_prodf(s->eq_buf, s->eq_coeff, V17_EQUALIZER_LEN, s->eq_step); } +#endif /*- End of function --------------------------------------------------------*/ #if defined(SPANDSP_USE_FIXED_POINTx) @@ -272,11 +290,9 @@ static void tune_equalizer(v17_rx_state_t *s, const complexi16_t *z, const compl complexi16_t err; /* Find the x and y mismatch from the exact constellation position. */ - err.re = target->re*FP_FACTOR - z->re; - err.im = target->im*FP_FACTOR - z->im; - //span_log(&s->logging, SPAN_LOG_FLOW, "Equalizer error %f\n", sqrt(err.re*err.re + err.im*err.im)); - err.re = ((int32_t) err.re*(int32_t) s->eq_delta) >> 15; - err.im = ((int32_t) err.im*(int32_t) s->eq_delta) >> 15; + err = complex_subi16(target, z); + err.re = ((int32_t) err.re*s->eq_delta) >> 15; + err.im = ((int32_t) err.im*s->eq_delta) >> 15; cvec_circular_lmsi16(s->eq_buf, s->eq_coeff, V17_EQUALIZER_LEN, s->eq_step, &err); } #else @@ -308,19 +324,31 @@ static int descramble(v17_rx_state_t *s, int in_bit) } /*- End of function --------------------------------------------------------*/ -static void track_carrier(v17_rx_state_t *s, const complexf_t *z, const complexf_t *target) +#if defined(SPANDSP_USE_FIXED_POINTx) +static __inline__ void track_carrier(v17_rx_state_t *s, const complexi16_t *z, const complexi16_t *target) +#else +static __inline__ void track_carrier(v17_rx_state_t *s, const complexf_t *z, const complexf_t *target) +#endif { +#if defined(SPANDSP_USE_FIXED_POINTx) + int32_t error; +#else float error; +#endif /* For small errors the imaginary part of the difference between the actual and the target positions is proportional to the phase error, for any particular target. However, the different amplitudes of the various target positions scale things. */ +#if defined(SPANDSP_USE_FIXED_POINTx) + error = z->im*(target->re >> FP_SHIFT_FACTOR) - z->re*(target->im >> FP_SHIFT_FACTOR); + s->carrier_phase_rate += ((s->carrier_track_i*error) >> FP_SHIFT_FACTOR); + s->carrier_phase += ((s->carrier_track_p*error) >> FP_SHIFT_FACTOR); +#else error = z->im*target->re - z->re*target->im; - s->carrier_phase_rate += (int32_t) (s->carrier_track_i*error); s->carrier_phase += (int32_t) (s->carrier_track_p*error); //span_log(&s->logging, SPAN_LOG_FLOW, "Im = %15.5f f = %15.5f\n", error, dds_frequencyf(s->carrier_phase_rate)); - //printf("XXX Im = %15.5f f = %15.5f %f %f %f %f (%f %f)\n", error, dds_frequencyf(s->carrier_phase_rate), target->re, target->im, z->re, z->im, s->carrier_track_i, s->carrier_track_p); +#endif } /*- End of function --------------------------------------------------------*/ @@ -347,7 +375,7 @@ static __inline__ void put_bit(v17_rx_state_t *s, int bit) /*- End of function --------------------------------------------------------*/ #if defined(SPANDSP_USE_FIXED_POINTx) -static __inline__ uint32_t dist_sq(const complexi_t *x, const complexi_t *y) +static __inline__ uint32_t dist_sq(const complexi32_t *x, const complexi32_t *y) { return (x->re - y->re)*(x->re - y->re) + (x->im - y->im)*(x->im - y->im); } @@ -360,7 +388,11 @@ static __inline__ float dist_sq(const complexf_t *x, const complexf_t *y) /*- End of function --------------------------------------------------------*/ #endif +#if defined(SPANDSP_USE_FIXED_POINTx) +static int decode_baud(v17_rx_state_t *s, complexi16_t *z) +#else static int decode_baud(v17_rx_state_t *s, complexf_t *z) +#endif { static const uint8_t v32bis_4800_differential_decoder[4][4] = { @@ -396,29 +428,33 @@ static int decode_baud(v17_rx_state_t *s, complexf_t *z) int raw; int constellation_state; #if defined(SPANDSP_USE_FIXED_POINTx) -#define DIST_FACTOR 2048 /* Something less than sqrt(0xFFFFFFFF/10)/10 */ - complexi_t zi; +#define DIST_FACTOR 1024 /* Something less than sqrt(0xFFFFFFFF/10)/10 */ + complexi32_t zi; uint32_t distances[8]; uint32_t new_distances[8]; uint32_t min; - complexi_t ci; + complexi32_t ci; #else float distances[8]; float new_distances[8]; float min; #endif +#if defined(SPANDSP_USE_FIXED_POINTx) + re = (z->re + 9*FP_FACTOR) >> (FP_SHIFT_FACTOR - 1); + im = (z->im + 9*FP_FACTOR) >> (FP_SHIFT_FACTOR - 1); +#else re = (int) ((z->re + 9.0f)*2.0f); + im = (int) ((z->im + 9.0f)*2.0f); +#endif if (re > 35) re = 35; else if (re < 0) re = 0; - im = (int) ((z->im + 9.0f)*2.0f); if (im > 35) im = 35; else if (im < 0) im = 0; - if (s->bits_per_symbol == 2) { /* 4800bps V.32bis mode, without trellis coding */ @@ -434,7 +470,7 @@ static int decode_baud(v17_rx_state_t *s, complexf_t *z) to the target, with different patterns in the last 3 bits. */ #if defined(SPANDSP_USE_FIXED_POINTx) min = 0xFFFFFFFF; - zi = complex_seti(z->re*DIST_FACTOR, z->im*DIST_FACTOR); + zi = complex_seti32(z->re*DIST_FACTOR, z->im*DIST_FACTOR); #else min = 9999999.0f; #endif @@ -443,8 +479,8 @@ static int decode_baud(v17_rx_state_t *s, complexf_t *z) { nearest = constel_maps[s->space_map][re][im][i]; #if defined(SPANDSP_USE_FIXED_POINTx) - ci = complex_seti(s->constellation[nearest].re*DIST_FACTOR, - s->constellation[nearest].im*DIST_FACTOR); + ci = complex_seti32(s->constellation[nearest].re*DIST_FACTOR, + s->constellation[nearest].im*DIST_FACTOR); distances[i] = dist_sq(&ci, &zi); #else distances[i] = dist_sq(&s->constellation[nearest], z); @@ -594,7 +630,7 @@ static __inline__ void symbol_sync(v17_rx_state_t *s) v = s->symbol_sync_low[1]*s->symbol_sync_high[0]*SYNC_LOW_BAND_EDGE_COEFF_2 - s->symbol_sync_low[0]*s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_2 + s->symbol_sync_low[1]*s->symbol_sync_high[1]*SYNC_MIXED_EDGES_COEFF_3; - /* Filter away any DC component */ + /* Filter away any DC component */ p = v - s->symbol_sync_dc_filter[1]; s->symbol_sync_dc_filter[1] = s->symbol_sync_dc_filter[0]; s->symbol_sync_dc_filter[0] = v; @@ -614,28 +650,40 @@ static __inline__ void symbol_sync(v17_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) -{ - static const complexf_t cdba[4] = - { - { 6.0f, 2.0f}, - {-2.0f, 6.0f}, - { 2.0f, -6.0f}, - {-6.0f, -2.0f} - }; - complexf_t z; - complexf_t zz; #if defined(SPANDSP_USE_FIXED_POINTx) - const complexi_t *target; +static void process_half_baud(v17_rx_state_t *s, const complexi16_t *sample) +#else +static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) +#endif +{ +#if defined(SPANDSP_USE_FIXED_POINTx) + static const complexi16_t cdba[4] = +#else + static const complexf_t cdba[4] = +#endif + { + {FP_SCALE( 6.0f), FP_SCALE( 2.0f)}, + {FP_SCALE(-2.0f), FP_SCALE( 6.0f)}, + {FP_SCALE( 2.0f), FP_SCALE(-6.0f)}, + {FP_SCALE(-6.0f), FP_SCALE(-2.0f)} + }; +#if defined(SPANDSP_USE_FIXED_POINTx) + uint16_t ip; + complexi16_t z; + complexi16_t z16; + const complexi16_t *target; static const complexi16_t zero = {0, 0}; #else - const complexf_t *target; - static const complexf_t zero = {0, 0}; -#endif float p; + complexf_t z; + complexf_t zz; + const complexf_t *target; + static const complexf_t zero = {0.0f, 0.0f}; +#endif int bit; int i; int j; + uint32_t phase_step; int32_t angle; int32_t ang; int constellation_state; @@ -673,8 +721,13 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) s->angles[0] = s->start_angles[0] = arctan2(z.im, z.re); s->training_stage = TRAINING_STAGE_LOG_PHASE; +#if defined(SPANDSP_USE_FIXED_POINTx) + if (s->agc_scaling_save == 0) + s->agc_scaling_save = s->agc_scaling; +#else if (s->agc_scaling_save == 0.0f) s->agc_scaling_save = s->agc_scaling; +#endif } break; case TRAINING_STAGE_LOG_PHASE: @@ -701,15 +754,23 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) /* Make a step shift in the phase, to pull it into line. We need to rotate the equalizer buffer, as well as the carrier phase, for this to play out nicely. */ /* angle is now the difference between where A is, and where it should be */ - p = 3.14159f + angle*2.0f*3.14159f/(65536.0f*65536.0f) - 0.321751f; + phase_step = 0x80000000 + angle - 219937506; +#if defined(SPANDSP_USE_FIXED_POINTx) + ip = phase_step >> 16; + span_log(&s->logging, SPAN_LOG_FLOW, "Spin (short) by %d\n", ip); + z16 = complex_seti16(fixed_cos(ip), -fixed_sin(ip)); + for (i = 0; i < V17_EQUALIZER_LEN; i++) + s->eq_buf[i] = complex_mul_q1_15(&s->eq_buf[i], &z16); + s->carrier_track_p = 500000; +#else + p = phase_step*2.0f*3.14159f/(65536.0f*65536.0f); span_log(&s->logging, SPAN_LOG_FLOW, "Spin (short) by %.5f rads\n", p); zz = complex_setf(cosf(p), -sinf(p)); for (i = 0; i < V17_EQUALIZER_LEN; i++) s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz); - s->carrier_phase += (0x80000000 + angle - 219937506); - s->carrier_track_p = 500000.0f; - +#endif + s->carrier_phase += phase_step; s->training_stage = TRAINING_STAGE_SHORT_WAIT_FOR_CDBA; } else @@ -776,7 +837,11 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) { span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (sequence failed)\n"); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINTx) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); break; @@ -785,12 +850,21 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) /* Make a step shift in the phase, to pull it into line. We need to rotate the equalizer buffer, as well as the carrier phase, for this to play out nicely. */ /* angle is now the difference between where C is, and where it should be */ - p = angle*2.0f*3.14159f/(65536.0f*65536.0f) - 0.321751f; + phase_step = angle - 219937506; +#if defined(SPANDSP_USE_FIXED_POINTx) + ip = phase_step >> 16; + span_log(&s->logging, SPAN_LOG_FLOW, "Spin (long) by %d\n", ip); + z16 = complex_seti16(fixed_cos(ip), -fixed_sin(ip)); + for (i = 0; i < V17_EQUALIZER_LEN; i++) + s->eq_buf[i] = complex_mul_q1_15(&s->eq_buf[i], &z16); +#else + p = phase_step*2.0f*3.14159f/(65536.0f*65536.0f); span_log(&s->logging, SPAN_LOG_FLOW, "Spin (long) by %.5f rads\n", p); zz = complex_setf(cosf(p), -sinf(p)); for (i = 0; i < V17_EQUALIZER_LEN; i++) s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz); - s->carrier_phase += (angle - 219937506); +#endif + s->carrier_phase += phase_step; /* We have just seen the first symbol of the scrambled sequence, so skip it. */ bit = descramble(s, 1); @@ -807,7 +881,11 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) of a real training sequence. Note that this might be TEP. */ span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (sequence failed)\n"); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINTx) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); } @@ -820,9 +898,15 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) track_carrier(s, &z, target); tune_equalizer(s, &z, target); #if defined(IAXMODEM_STUFF) +#if defined(SPANDSP_USE_FIXED_POINTx) + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); + if (++s->training_count == V17_TRAINING_SEG_2_LEN - 2000 || s->training_error < 1*FP_FACTOR*FP_FACTOR || s->training_error > 200*FP_FACTOR*FP_FACTOR) +#else zz = complex_subf(&z, target); s->training_error = powerf(&zz); if (++s->training_count == V17_TRAINING_SEG_2_LEN - 2000 || s->training_error < 1.0f || s->training_error > 200.0f) +#endif #else if (++s->training_count == V17_TRAINING_SEG_2_LEN - 2000) #endif @@ -830,7 +914,11 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) /* Now the equaliser adaption should be getting somewhere, slow it down, or it will never tune very well on a noisy signal. */ s->eq_delta *= EQUALIZER_SLOW_ADAPT_RATIO; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->carrier_track_i = 1000; +#else s->carrier_track_i = 1000.0f; +#endif s->training_stage = TRAINING_STAGE_FINE_TRAIN_ON_CDBA; } break; @@ -844,9 +932,15 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) tune_equalizer(s, &z, target); if (++s->training_count >= V17_TRAINING_SEG_2_LEN - 48) { +#if defined(SPANDSP_USE_FIXED_POINTx) + s->training_error = 0; + s->carrier_track_i = 100; + s->carrier_track_p = 500000; +#else s->training_error = 0.0f; s->carrier_track_i = 100.0f; s->carrier_track_p = 500000.0f; +#endif s->training_stage = TRAINING_STAGE_TRAIN_ON_CDBA_AND_TEST; } break; @@ -863,23 +957,39 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) track_carrier(s, &z, target); tune_equalizer(s, &z, target); /* Measure the training error */ - zz = complex_subf(&z, &cdba[bit]); +#if defined(SPANDSP_USE_FIXED_POINTx) + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); +#else + zz = complex_subf(&z, target); s->training_error += powerf(&zz); +#endif } else if (s->training_count >= V17_TRAINING_SEG_2_LEN) { +#if defined(SPANDSP_USE_FIXED_POINTx) + span_log(&s->logging, SPAN_LOG_FLOW, "Long training error %d\n", s->training_error); + if (s->training_error < 20.0f*1.414f*FP_FACTOR*FP_FACTOR*constellation_spacing[s->space_map]) + { + s->training_error = 0; +#else span_log(&s->logging, SPAN_LOG_FLOW, "Long training error %f\n", s->training_error); if (s->training_error < 20.0f*1.414f*constellation_spacing[s->space_map]) { - s->training_count = 0; s->training_error = 0.0f; +#endif + s->training_count = 0; s->training_stage = TRAINING_STAGE_BRIDGE; } else { span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (convergence failed)\n"); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINTx) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); } @@ -891,8 +1001,12 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) target = &z; if (++s->training_count >= V17_TRAINING_SEG_3_LEN) { - s->training_count = 0; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->training_error = 0; +#else s->training_error = 0.0f; +#endif + s->training_count = 0; if (s->bits_per_symbol == 2) { /* Restart the differential decoder */ @@ -919,8 +1033,12 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) bit = descramble(s, 1); bit = (bit << 1) | descramble(s, 1); target = &cdba[bit]; - s->training_count = 1; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->training_error = 0; +#else s->training_error = 0.0f; +#endif + s->training_count = 1; s->training_stage = TRAINING_STAGE_SHORT_TRAIN_ON_CDBA_AND_TEST; break; } @@ -947,18 +1065,33 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) /* Measure the training error */ if (s->training_count > 8) { +#if defined(SPANDSP_USE_FIXED_POINTx) + z16 = complex_subi16(&z, &cdba[bit]); + s->training_error += poweri16(&z16); +#else zz = complex_subf(&z, &cdba[bit]); s->training_error += powerf(&zz); +#endif } if (++s->training_count >= V17_TRAINING_SHORT_SEG_2_LEN) { +#if defined(SPANDSP_USE_FIXED_POINTx) + span_log(&s->logging, SPAN_LOG_FLOW, "Short training error %d\n", s->training_error); + s->carrier_track_i = 100; + s->carrier_track_p = 500000; +#else span_log(&s->logging, SPAN_LOG_FLOW, "Short training error %f\n", s->training_error); s->carrier_track_i = 100.0f; s->carrier_track_p = 500000.0f; +#endif /* TODO: This was increased by a factor of 10 after studying real world failures. However, it is not clear why this is an improvement, If something gives a huge training error, surely it shouldn't decode too well? */ +#if defined(SPANDSP_USE_FIXED_POINTx) + if (s->training_error < (V17_TRAINING_SHORT_SEG_2_LEN - 8)*4.0f*FP_FACTOR*FP_FACTOR*constellation_spacing[s->space_map]) +#else if (s->training_error < (V17_TRAINING_SHORT_SEG_2_LEN - 8)*4.0f*constellation_spacing[s->space_map]) +#endif { s->training_count = 0; if (s->bits_per_symbol == 2) @@ -966,7 +1099,11 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) /* There is no trellis, so go straight to processing decoded data */ /* Restart the differential decoder */ s->diff = (s->short_train) ? 0 : 1; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->training_error = 0; +#else s->training_error = 0.0f; +#endif s->training_stage = TRAINING_STAGE_TEST_ONES; } else @@ -991,12 +1128,21 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) constellation_state = decode_baud(s, &z); target = &s->constellation[constellation_state]; /* Measure the training error */ +#if defined(SPANDSP_USE_FIXED_POINTx) + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); +#else zz = complex_subf(&z, target); s->training_error += powerf(&zz); +#endif if (++s->training_count >= V17_TRAINING_SEG_4A_LEN) { - s->training_count = 0; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->training_error = 0; +#else s->training_error = 0.0f; +#endif + s->training_count = 0; /* Restart the differential decoder */ s->diff = (s->short_train) ? 0 : 1; s->training_stage = TRAINING_STAGE_TEST_ONES; @@ -1009,14 +1155,25 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) constellation_state = decode_baud(s, &z); target = &s->constellation[constellation_state]; /* Measure the training error */ +#if defined(SPANDSP_USE_FIXED_POINTx) + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); +#else zz = complex_subf(&z, target); s->training_error += powerf(&zz); +#endif if (++s->training_count >= V17_TRAINING_SEG_4_LEN) { +#if defined(SPANDSP_USE_FIXED_POINTx) + if (s->training_error < V17_TRAINING_SEG_4_LEN*FP_FACTOR*FP_FACTOR*constellation_spacing[s->space_map]) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Training succeeded at %dbps (constellation mismatch %d)\n", s->bit_rate, s->training_error); +#else if (s->training_error < V17_TRAINING_SEG_4_LEN*constellation_spacing[s->space_map]) { - /* We are up and running */ span_log(&s->logging, SPAN_LOG_FLOW, "Training succeeded at %dbps (constellation mismatch %f)\n", s->bit_rate, s->training_error); +#endif + /* We are up and running */ report_status_change(s, SIG_STATUS_TRAINING_SUCCEEDED); /* Apply some lag to the carrier off condition, to ensure the last few bits get pushed through the processing. */ @@ -1028,11 +1185,16 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) } else { - /* Training has failed */ + /* Training has failed. Park this modem. */ +#if defined(SPANDSP_USE_FIXED_POINTx) + span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %d)\n", s->training_error); + if (!s->short_train) + s->agc_scaling_save = 0; +#else span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %f)\n", s->training_error); - /* Park this modem */ if (!s->short_train) s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); } @@ -1046,7 +1208,20 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample) break; } if (s->qam_report) + { +#if defined(SPANDSP_USE_FIXED_POINT) + complexi16_t zi; + complexi16_t targeti; + + zi.re = z.re*1024.0f; + zi.im = z.im*1024.0f; + targeti.re = target->re*1024.0f; + targeti.im = target->im*1024.0f; + s->qam_report(s->qam_user_data, &zi, &targeti, constellation_state); +#else s->qam_report(s->qam_user_data, &z, target, constellation_state); +#endif + } } /*- End of function --------------------------------------------------------*/ @@ -1125,15 +1300,15 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len) { int i; int step; +#if defined(SPANDSP_USE_FIXED_POINTx) + complexi16_t z; + complexi16_t zz; + complexi16_t sample; + int32_t v; +#else complexf_t z; complexf_t zz; complexf_t sample; -#if defined(SPANDSP_USE_FIXED_POINT) - int32_t vi; -#endif -#if defined(SPANDSP_USE_FIXED_POINTx) - int32_t v; -#else float v; #endif int32_t power; @@ -1152,18 +1327,27 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len) parked, after training failure. */ s->eq_put_step -= RX_PULSESHAPER_COEFF_SETS; step = -s->eq_put_step; - if (step > RX_PULSESHAPER_COEFF_SETS - 1) - step = RX_PULSESHAPER_COEFF_SETS - 1; if (step < 0) step += RX_PULSESHAPER_COEFF_SETS; -#if defined(SPANDSP_USE_FIXED_POINT) - vi = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step); - //sample.re = (vi*(int32_t) s->agc_scaling) >> 15; - sample.re = vi*s->agc_scaling; + if (step < 0) + step = 0; + else if (step > RX_PULSESHAPER_COEFF_SETS - 1) + step = RX_PULSESHAPER_COEFF_SETS - 1; +#if defined(SPANDSP_USE_FIXED_POINTx) + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.re = (v*s->agc_scaling) >> 10; + /* Symbol timing synchronisation band edge filters */ + /* Low Nyquist band edge filter */ + v = ((s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0) >> 10) + ((s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1) >> 10) + sample.re; + s->symbol_sync_low[1] = s->symbol_sync_low[0]; + s->symbol_sync_low[0] = v; + /* High Nyquist band edge filter */ + v = ((s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0) >> 10) + ((s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1) >> 10) + sample.re; + s->symbol_sync_high[1] = s->symbol_sync_high[0]; + s->symbol_sync_high[0] = v; #else v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step); sample.re = v*s->agc_scaling; -#endif /* Symbol timing synchronisation band edge filters */ /* Low Nyquist band edge filter */ v = s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0 + s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1 + sample.re; @@ -1173,29 +1357,30 @@ SPAN_DECLARE_NONSTD(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len) v = s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0 + s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1 + sample.re; s->symbol_sync_high[1] = s->symbol_sync_high[0]; s->symbol_sync_high[0] = v; - - /* Put things into the equalization buffer at T/2 rate. The symbol sync. +#endif + /* Put things into the equalization buffer at T/2 rate. The symbol synchronisation will fiddle the step to align this with the symbols. */ if (s->eq_put_step <= 0) { /* Only AGC until we have locked down the setting. */ +#if defined(SPANDSP_USE_FIXED_POINTx) + if (s->agc_scaling_save == 0) + s->agc_scaling = saturate16(((int32_t) (1024.0f*FP_FACTOR*2.17f))/fixed_sqrt32(power)); +#else if (s->agc_scaling_save == 0.0f) s->agc_scaling = (1.0f/RX_PULSESHAPER_GAIN)*2.17f/sqrtf(power); +#endif /* Pulse shape while still at the carrier frequency, using a quadrature pair of filters. This results in a properly bandpass filtered complex signal, which can be brought directly to baseband by complex mixing. No further filtering, to remove mixer harmonics, is needed. */ - step = -s->eq_put_step; - if (step > RX_PULSESHAPER_COEFF_SETS - 1) - step = RX_PULSESHAPER_COEFF_SETS - 1; s->eq_put_step += RX_PULSESHAPER_COEFF_SETS*10/(3*2); -#if defined(SPANDSP_USE_FIXED_POINT) - vi = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V17_RX_FILTER_STEPS, s->rrc_filter_step); - //sample.im = (vi*(int32_t) s->agc_scaling) >> 15; - sample.im = vi*s->agc_scaling; - z = dds_lookup_complexf(s->carrier_phase); - zz.re = sample.re*z.re - sample.im*z.im; - zz.im = -sample.re*z.im - sample.im*z.re; +#if defined(SPANDSP_USE_FIXED_POINTx) + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V17_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.im = (v*s->agc_scaling) >> 10; + z = dds_lookup_complexi16(s->carrier_phase); + zz.re = ((int32_t) sample.re*z.re - (int32_t) sample.im*z.im) >> 15; + zz.im = ((int32_t) -sample.re*z.im - (int32_t) sample.im*z.re) >> 15; #else v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_im[step], V17_RX_FILTER_STEPS, s->rrc_filter_step); sample.im = v*s->agc_scaling; @@ -1301,10 +1486,12 @@ SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_trai return -1; } s->bit_rate = bit_rate; -#if defined(SPANDSP_USE_FIXED_POINT) +#if defined(SPANDSP_USE_FIXED_POINTx) vec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + s->training_error = 0; #else vec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + s->training_error = 0.0f; #endif s->rrc_filter_step = 0; @@ -1312,7 +1499,6 @@ SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_trai s->scramble_reg = 0x2ECDD5; s->training_stage = TRAINING_STAGE_SYMBOL_ACQUISITION; s->training_count = 0; - s->training_error = 0.0f; s->signal_present = 0; #if defined(IAXMODEM_STUFF) s->high_sample = 0; @@ -1362,18 +1548,21 @@ SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_trai equalizer_reset(s); #if defined(SPANDSP_USE_FIXED_POINTx) s->agc_scaling_save = 0; - s->agc_scaling = (float) FP_FACTOR*32768.0f*0.0017f/RX_PULSESHAPER_GAIN; + s->agc_scaling = (float) (1024.0f*FP_FACTOR)*2.17f/735.0f; +#else + s->agc_scaling_save = 0.0f; + s->agc_scaling = (1.0f/RX_PULSESHAPER_GAIN)*2.17f/735.0f; +#endif +#if defined(SPANDSP_USE_FIXED_POINTx) s->carrier_track_i = 5000; s->carrier_track_p = 40000; #else - s->agc_scaling_save = 0.0f; - s->agc_scaling = 0.0017f/RX_PULSESHAPER_GAIN; s->carrier_track_i = 5000.0f; s->carrier_track_p = 40000.0f; #endif } s->last_sample = 0; - span_log(&s->logging, SPAN_LOG_FLOW, "Gains %f %f\n", s->agc_scaling_save, s->agc_scaling); + span_log(&s->logging, SPAN_LOG_FLOW, "Gains %f %f\n", (float) s->agc_scaling_save, (float) s->agc_scaling); span_log(&s->logging, SPAN_LOG_FLOW, "Phase rates %f %f\n", dds_frequencyf(s->carrier_phase_rate), dds_frequencyf(s->carrier_phase_rate_save)); /* Initialise the working data for symbol timing synchronisation */ diff --git a/libs/spandsp/src/v17tx.c b/libs/spandsp/src/v17tx.c index ca4eba1c68..56d3fa13a0 100644 --- a/libs/spandsp/src/v17tx.c +++ b/libs/spandsp/src/v17tx.c @@ -53,13 +53,19 @@ #include "spandsp/dds.h" #include "spandsp/power_meter.h" +#if defined(SPANDSP_USE_FIXED_POINT) +#define SPANDSP_USE_FIXED_POINTx +#endif + #include "spandsp/v17tx.h" #include "spandsp/private/logging.h" #include "spandsp/private/v17tx.h" #if defined(SPANDSP_USE_FIXED_POINT) -#define SPANDSP_USE_FIXED_POINTx +#define FP_SCALE(x) ((int16_t) x) +#else +#define FP_SCALE(x) (x) #endif #include "v17_v32bis_tx_constellation_maps.h" @@ -229,6 +235,11 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s) int i; int bit; int bits; +#if defined(SPANDSP_USE_FIXED_POINT) + static const complexi16_t zero = {0, 0}; +#else + static const complexf_t zero = {0.0f, 0.0f}; +#endif if (s->in_training) { @@ -251,11 +262,7 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s) { /* The shutdown sequence is 32 bauds of all 1's, then 48 bauds of silence */ -#if defined(SPANDSP_USE_FIXED_POINT) - return complex_seti16(0, 0); -#else - return complex_setf(0.0f, 0.0f); -#endif + return zero; } if (s->training_step == V17_TRAINING_SHUTDOWN_END) { diff --git a/libs/spandsp/src/v18.c b/libs/spandsp/src/v18.c index bb26644b62..639ae0770c 100644 --- a/libs/spandsp/src/v18.c +++ b/libs/spandsp/src/v18.c @@ -69,6 +69,55 @@ #include +/* + Ways in which a V.18 call may start + ----------------------------------- + + Originate: + ANS + Silence for 0.5s then send TXP + DTMF + Proceed as Annex B + 1650Hz (V21 ch 2 low) + Proceed as Annex F in call mode + 1300Hz (Calling tone) + Proceed as Annex E in call mode + 1400Hz/1800Hz (Weitbrecht) + Detect rate and proceed as Annex A + 980Hz/1180Hz (V21 ch 1) + Start timer Tr + 2225Hz (Bell ANS) + Proceed as Annex D call mode + 1270Hz (Bell103 ch 2 high) + Proceed as Annex D answer mode + 390Hz (V23 ch 2 low) + Proceed as Annex E answer mode + + Answer: + ANS + Monitor as caller for 980Hz or 1300Hz + CI/XCI + Respond with ANSam + 1300Hz + Probe + Timer Ta (3s) + Probe + 1400Hz/1800Hz (Weitbrecht) + Detect rate and proceed as Annex A + DTMF + Proceed as Annex B + 980Hz (V21 ch 1 low) + Start timer Te + 1270Hz (Bell103 ch 2 high) + Proceed as Annex D answer mode + 2225Hz (Bell ANS) + Proceed as Annex D call mode + 1650Hz (V21 ch 2 low) + Proceed as Annex F answer mode + ANSam + Proceed as V.8 caller Annex G +*/ + /*! The baudot code to shift from alpha to digits and symbols */ #define BAUDOT_FIGURE_SHIFT 0x1B /*! The baudot code to shift from digits and symbols to alpha */ @@ -111,7 +160,7 @@ static const struct dtmf_to_ascii_s dtmf_to_ascii[] = {"##8", 'W'}, {"##9", 'Z'}, {"##0", ' '}, -#if defined(WIN32) || ( defined(__SVR4) && defined (__sun)) +#if defined(WIN32) || (defined(__SVR4) && defined (__sun)) {"#*1", 'X'}, // (Note 1) 111 1011 {"#*2", 'X'}, // (Note 1) 111 1100 {"#*3", 'X'}, // (Note 1) 111 1101 @@ -310,6 +359,20 @@ static const char *ascii_to_dtmf[128] = "*0" /* DEL >> BACK SPACE */ }; +static const uint8_t txp[] = "1111111111000101011100001101110000010101"; + +/* XCI is: + 400 ms mark; + XCI marker; + 800 ms mark; + XCI marker; + 800 ms mark; + XCI marker; + 800 ms mark; + XCI marker; + 100 ms mark. */ +static const uint8_t xci[] = "01111111110111111111"; + static int cmp(const void *s, const void *t) { const char *ss; @@ -319,6 +382,7 @@ static int cmp(const void *s, const void *t) tt = (struct dtmf_to_ascii_s *) t; return strncmp(ss, tt->dtmf, strlen(tt->dtmf)); } +/*- End of function --------------------------------------------------------*/ SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[]) { @@ -525,14 +589,14 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch) /* Need to allow for a possible character set change. */ if ((ch & 0x80)) { - if (s->baudot_tx_shift == 1) + if (!s->repeat_shifts && s->baudot_tx_shift == 1) return ch & 0x1F; s->baudot_tx_shift = 1; shift = BAUDOT_FIGURE_SHIFT; } else { - if (s->baudot_tx_shift == 0) + if (!s->repeat_shifts && s->baudot_tx_shift == 0) return ch & 0x1F; s->baudot_tx_shift = 0; shift = BAUDOT_LETTER_SHIFT; @@ -567,9 +631,11 @@ SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch) static void v18_rx_dtmf(void *user_data, const char digits[], int len) { +#if 0 v18_state_t *s; s = (v18_state_t *) user_data; +#endif } /*- End of function --------------------------------------------------------*/ @@ -590,13 +656,18 @@ static int v18_tdd_get_async_byte(void *user_data) } /*- End of function --------------------------------------------------------*/ +static int v18_edt_get_async_byte(void *user_data) +{ + return 0; +} +/*- End of function --------------------------------------------------------*/ + static void v18_tdd_put_async_byte(void *user_data, int byte) { v18_state_t *s; uint8_t octet; s = (v18_state_t *) user_data; - //printf("Rx byte %x\n", byte); if (byte < 0) { /* Special conditions */ @@ -624,7 +695,8 @@ static void v18_tdd_put_async_byte(void *user_data, int byte) } return; } - if ((octet = v18_decode_baudot(s, (uint8_t) (byte & 0x1F)))) + span_log(&s->logging, SPAN_LOG_FLOW, "Rx byte %x\n", byte); + if ((octet = v18_decode_baudot(s, byte))) s->rx_msg[s->rx_msg_len++] = octet; if (s->rx_msg_len >= 256) { @@ -635,24 +707,44 @@ static void v18_tdd_put_async_byte(void *user_data, int byte) } /*- End of function --------------------------------------------------------*/ +static void v18_edt_put_async_byte(void *user_data, int byte) +{ +} +/*- End of function --------------------------------------------------------*/ + +static void v18_bell103_put_async_byte(void *user_data, int byte) +{ +} +/*- End of function --------------------------------------------------------*/ + +static void v18_videotex_put_async_byte(void *user_data, int byte) +{ +} +/*- End of function --------------------------------------------------------*/ + +static void v18_textphone_put_async_byte(void *user_data, int byte) +{ +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE_NONSTD(int) v18_tx(v18_state_t *s, int16_t *amp, int max_len) { int len; int lenx; - len = tone_gen(&(s->alert_tone_gen), amp, max_len); + len = tone_gen(&s->alert_tone_gen, amp, max_len); if (s->tx_signal_on) { switch (s->mode) { case V18_MODE_DTMF: if (len < max_len) - len += dtmf_tx(&(s->dtmftx), amp, max_len - len); + len += dtmf_tx(&s->dtmftx, amp, max_len - len); break; default: if (len < max_len) { - if ((lenx = fsk_tx(&(s->fsktx), amp + len, max_len - len)) <= 0) + if ((lenx = fsk_tx(&s->fsktx, amp + len, max_len - len)) <= 0) s->tx_signal_on = FALSE; len += lenx; } @@ -672,10 +764,10 @@ SPAN_DECLARE_NONSTD(int) v18_rx(v18_state_t *s, const int16_t amp[], int len) s->in_progress -= len; if (s->in_progress <= 0) s->rx_msg_len = 0; - dtmf_rx(&(s->dtmfrx), amp, len); + dtmf_rx(&s->dtmfrx, amp, len); break; default: - fsk_rx(&(s->fskrx), amp, len); + fsk_rx(&s->fskrx, amp, len); break; } return 0; @@ -742,45 +834,62 @@ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s, } memset(s, 0, sizeof(*s)); s->calling_party = calling_party; - s->mode = mode; + s->mode = mode & 0xFF; s->put_msg = put_msg; s->user_data = user_data; switch (s->mode) { case V18_MODE_5BIT_45: - fsk_tx_init(&(s->fsktx), &preset_fsk_specs[FSK_WEITBRECHT], async_tx_get_bit, &(s->asynctx)); - async_tx_init(&(s->asynctx), 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s); + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_WEITBRECHT], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s); /* Schedule an explicit shift at the start of baudot transmission */ s->baudot_tx_shift = 2; /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and ride over the fraction. */ - fsk_rx_init(&(s->fskrx), &preset_fsk_specs[FSK_WEITBRECHT], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_WEITBRECHT], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); s->baudot_rx_shift = 0; + s->repeat_shifts = mode & 0x100; break; case V18_MODE_5BIT_50: - fsk_tx_init(&(s->fsktx), &preset_fsk_specs[FSK_WEITBRECHT50], async_tx_get_bit, &(s->asynctx)); - async_tx_init(&(s->asynctx), 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s); + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_WEITBRECHT50], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s); /* Schedule an explicit shift at the start of baudot transmission */ s->baudot_tx_shift = 2; /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and ride over the fraction. */ - fsk_rx_init(&(s->fskrx), &preset_fsk_specs[FSK_WEITBRECHT50], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_WEITBRECHT50], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s); s->baudot_rx_shift = 0; + s->repeat_shifts = mode & 0x100; break; case V18_MODE_DTMF: - dtmf_tx_init(&(s->dtmftx)); - dtmf_rx_init(&(s->dtmfrx), v18_rx_dtmf, s); + dtmf_tx_init(&s->dtmftx); + dtmf_rx_init(&s->dtmfrx, v18_rx_dtmf, s); break; case V18_MODE_EDT: + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V21CH1_110], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 2, FALSE, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V21CH1_110], FSK_FRAME_MODE_7E2_FRAMES, v18_edt_put_async_byte, s); break; case V18_MODE_BELL103: + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_BELL103CH1], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_BELL103CH2], FSK_FRAME_MODE_7E1_FRAMES, v18_bell103_put_async_byte, s); break; case V18_MODE_V23VIDEOTEX: + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V23CH1], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V23CH2], FSK_FRAME_MODE_7E1_FRAMES, v18_videotex_put_async_byte, s); break; case V18_MODE_V21TEXTPHONE: + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V21CH1], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V21CH1], FSK_FRAME_MODE_7E1_FRAMES, v18_textphone_put_async_byte, s); break; case V18_MODE_V18TEXTPHONE: + fsk_tx_init(&s->fsktx, &preset_fsk_specs[FSK_V21CH1], async_tx_get_bit, &s->asynctx); + async_tx_init(&s->asynctx, 7, ASYNC_PARITY_EVEN, 1, FALSE, v18_edt_get_async_byte, s); + fsk_rx_init(&s->fskrx, &preset_fsk_specs[FSK_V21CH1], FSK_FRAME_MODE_7E1_FRAMES, v18_textphone_put_async_byte, s); break; } queue_init(&s->queue.queue, 128, QUEUE_READ_ATOMIC | QUEUE_WRITE_ATOMIC); @@ -803,7 +912,7 @@ SPAN_DECLARE(int) v18_free(v18_state_t *s) SPAN_DECLARE(const char *) v18_mode_to_str(int mode) { - switch (mode) + switch (mode & 0xFF) { case V18_MODE_NONE: return "None"; diff --git a/libs/spandsp/src/v22bis_rx.c b/libs/spandsp/src/v22bis_rx.c index 55c540d53e..41e3076042 100644 --- a/libs/spandsp/src/v22bis_rx.c +++ b/libs/spandsp/src/v22bis_rx.c @@ -52,6 +52,9 @@ #include "spandsp/telephony.h" #include "spandsp/logging.h" +#include "spandsp/fast_convert.h" +#include "spandsp/math_fixed.h" +#include "spandsp/saturated.h" #include "spandsp/complex.h" #include "spandsp/vector_float.h" #include "spandsp/complex_vector_float.h" @@ -69,20 +72,23 @@ #include "spandsp/private/logging.h" #include "spandsp/private/v22bis.h" -#if defined(SPANDSP_USE_FIXED_POINTx) -#include "v22bis_rx_1200_floating_rrc.h" -#include "v22bis_rx_2400_floating_rrc.h" +#if defined(SPANDSP_USE_FIXED_POINT) +#define FP_SHIFT_FACTOR 10 +#define FP_SCALE FP_Q_6_10 +#include "v22bis_rx_1200_fixed_rrc.h" +#include "v22bis_rx_2400_fixed_rrc.h" #else +#define FP_SCALE(x) (x) #include "v22bis_rx_1200_floating_rrc.h" #include "v22bis_rx_2400_floating_rrc.h" #endif -#define ms_to_symbols(t) (((t)*600)/1000) +#define ms_to_symbols(t) (((t)*600)/1000) /*! The adaption rate coefficient for the equalizer */ -#define EQUALIZER_DELTA 0.25f +#define EQUALIZER_DELTA 0.25f /*! The number of phase shifted coefficient set for the pulse shaping/bandpass filter */ -#define PULSESHAPER_COEFF_SETS 12 +#define PULSESHAPER_COEFF_SETS 12 /* The basic method used by the V.22bis receiver is: @@ -167,24 +173,32 @@ void v22bis_report_status_change(v22bis_state_t *s, int status) } /*- End of function --------------------------------------------------------*/ +#if defined(SPANDSP_USE_FIXED_POINT) +SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexi16_t **coeffs) +#else SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs) +#endif { *coeffs = s->rx.eq_coeff; - return 2*V22BIS_EQUALIZER_LEN + 1; + return V22BIS_EQUALIZER_LEN; } /*- End of function --------------------------------------------------------*/ void v22bis_equalizer_coefficient_reset(v22bis_state_t *s) { /* Start with an equalizer based on everything being perfect */ -#if defined(SPANDSP_USE_FIXED_POINTx) - cvec_zeroi16(s->rx.eq_coeff, 2*V22BIS_EQUALIZER_LEN + 1); - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN] = complex_seti16(3*FP_FACTOR, 0*FP_FACTOR); - s->rx.eq_delta = 32768.0f*EQUALIZER_DELTA/(2*V22BIS_EQUALIZER_LEN + 1); +#if defined(SPANDSP_USE_FIXED_POINT) + static const complexi16_t x = {FP_Q_6_10(3.0f), FP_Q_6_10(0.0f)}; + + cvec_zeroi16(s->rx.eq_coeff, V22BIS_EQUALIZER_LEN); + s->rx.eq_coeff[V22BIS_EQUALIZER_PRE_LEN] = x; + s->rx.eq_delta = 32.0f*EQUALIZER_DELTA/V22BIS_EQUALIZER_LEN; #else - cvec_zerof(s->rx.eq_coeff, 2*V22BIS_EQUALIZER_LEN + 1); - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN] = complex_setf(3.0f, 0.0f); - s->rx.eq_delta = EQUALIZER_DELTA/(2*V22BIS_EQUALIZER_LEN + 1); + static const complexf_t x = {3.0f, 0.0f}; + + cvec_zerof(s->rx.eq_coeff, V22BIS_EQUALIZER_LEN); + s->rx.eq_coeff[V22BIS_EQUALIZER_PRE_LEN] = x; + s->rx.eq_delta = EQUALIZER_DELTA/V22BIS_EQUALIZER_LEN; #endif } /*- End of function --------------------------------------------------------*/ @@ -192,74 +206,100 @@ void v22bis_equalizer_coefficient_reset(v22bis_state_t *s) static void equalizer_reset(v22bis_state_t *s) { v22bis_equalizer_coefficient_reset(s); -#if defined(SPANDSP_USE_FIXED_POINTx) - cvec_zeroi16(s->rx.eq_buf, V22BIS_EQUALIZER_MASK + 1); +#if defined(SPANDSP_USE_FIXED_POINT) + cvec_zeroi16(s->rx.eq_buf, V22BIS_EQUALIZER_LEN); #else - cvec_zerof(s->rx.eq_buf, V22BIS_EQUALIZER_MASK + 1); + cvec_zerof(s->rx.eq_buf, V22BIS_EQUALIZER_LEN); #endif s->rx.eq_put_step = 20 - 1; s->rx.eq_step = 0; } /*- End of function --------------------------------------------------------*/ -static complexf_t equalizer_get(v22bis_state_t *s) +#if defined(SPANDSP_USE_FIXED_POINT) +static __inline__ complexi16_t equalizer_get(v22bis_state_t *s) { - int i; - int p; - complexf_t z; - complexf_t z1; + complexi32_t zz; + complexi16_t z; /* Get the next equalized value. */ - z = complex_setf(0.0f, 0.0f); - p = s->rx.eq_step - 1; - for (i = 0; i < 2*V22BIS_EQUALIZER_LEN + 1; i++) - { - p = (p - 1) & V22BIS_EQUALIZER_MASK; - z1 = complex_mulf(&s->rx.eq_coeff[i], &s->rx.eq_buf[p]); - z = complex_addf(&z, &z1); - } + zz = cvec_circular_dot_prodi16(s->rx.eq_buf, s->rx.eq_coeff, V22BIS_EQUALIZER_LEN, s->rx.eq_step); + z.re = zz.re >> FP_SHIFT_FACTOR; + z.im = zz.im >> FP_SHIFT_FACTOR; return z; } +#else +static __inline__ complexf_t equalizer_get(v22bis_state_t *s) +{ + /* Get the next equalized value. */ + return cvec_circular_dot_prodf(s->rx.eq_buf, s->rx.eq_coeff, V22BIS_EQUALIZER_LEN, s->rx.eq_step); +} +#endif /*- End of function --------------------------------------------------------*/ -static void tune_equalizer(v22bis_state_t *s, const complexf_t *z, const complexf_t *target) +#if defined(SPANDSP_USE_FIXED_POINT) +static void tune_equalizer(v22bis_state_t *s, const complexi16_t *z, const complexi16_t *target) { - int i; - int p; - complexf_t ez; - complexf_t z1; + complexi16_t err; /* Find the x and y mismatch from the exact constellation position. */ - ez = complex_subf(target, z); - ez.re *= s->rx.eq_delta; - ez.im *= s->rx.eq_delta; - - p = s->rx.eq_step - 1; - for (i = 0; i < 2*V22BIS_EQUALIZER_LEN + 1; i++) - { - p = (p - 1) & V22BIS_EQUALIZER_MASK; - z1 = complex_conjf(&s->rx.eq_buf[p]); - z1 = complex_mulf(&ez, &z1); - s->rx.eq_coeff[i] = complex_addf(&s->rx.eq_coeff[i], &z1); - /* If we don't leak a little bit we seem to get some wandering adaption */ - s->rx.eq_coeff[i].re *= 0.9999f; - s->rx.eq_coeff[i].im *= 0.9999f; - } + err = complex_subi16(target, z); + err.re = ((int32_t) err.re*s->rx.eq_delta) >> 5; + err.im = ((int32_t) err.im*s->rx.eq_delta) >> 5; + //cvec_circular_lmsi16(s->rx.eq_buf, s->rx.eq_coeff, V22BIS_EQUALIZER_LEN, s->rx.eq_step, &err); } +#else +static void tune_equalizer(v22bis_state_t *s, const complexf_t *z, const complexf_t *target) +{ + complexf_t err; + + /* Find the x and y mismatch from the exact constellation position. */ + err = complex_subf(target, z); + err.re *= s->rx.eq_delta; + err.im *= s->rx.eq_delta; + cvec_circular_lmsf(s->rx.eq_buf, s->rx.eq_coeff, V22BIS_EQUALIZER_LEN, s->rx.eq_step, &err); +} +#endif /*- End of function --------------------------------------------------------*/ +#if defined(SPANDSP_USE_FIXED_POINT) +static __inline__ void track_carrier(v22bis_state_t *s, const complexi16_t *z, const complexi16_t *target) +#else static __inline__ void track_carrier(v22bis_state_t *s, const complexf_t *z, const complexf_t *target) +#endif { +#if defined(SPANDSP_USE_FIXED_POINT) + int32_t error; +#else float error; +#endif /* For small errors the imaginary part of the difference between the actual and the target positions is proportional to the phase error, for any particular target. However, the different amplitudes of the various target positions scale things. */ +#if defined(SPANDSP_USE_FIXED_POINT) + error = ((int32_t) z->im*target->re - (int32_t) z->re*target->im) >> FP_SHIFT_FACTOR; + s->rx.carrier_phase_rate += (s->rx.carrier_track_i*error); + s->rx.carrier_phase += (s->rx.carrier_track_p*error); + //span_log(&s->logging, + // SPAN_LOG_FLOW, + // "CARR: Im = %15.5f f = %15.5f - %10d %10d\n", + // error/1024.0f, + // dds_frequency(s->rx.carrier_phase_rate), + // (s->rx.carrier_track_i*error), + // (s->rx.carrier_track_p*error)); +#else error = z->im*target->re - z->re*target->im; - s->rx.carrier_phase_rate += (int32_t) (s->rx.carrier_track_i*error); s->rx.carrier_phase += (int32_t) (s->rx.carrier_track_p*error); - //span_log(&s->logging, SPAN_LOG_FLOW, "Im = %15.5f f = %15.5f\n", error, dds_frequencyf(s->rx.carrier_phase_rate)); + //span_log(&s->logging, + // SPAN_LOG_FLOW, + // "CARR: Im = %15.5f f = %15.5f - %10d %10d\n", + // error, + // dds_frequencyf(s->rx.carrier_phase_rate), + // (int32_t) (s->rx.carrier_track_i*error), + // (int32_t) (s->rx.carrier_track_p*error)); +#endif } /*- End of function --------------------------------------------------------*/ @@ -336,40 +376,61 @@ static int decode_baudx(v22bis_state_t *s, int nearest) static __inline__ void symbol_sync(v22bis_state_t *s) { +#if defined(SPANDSP_USE_FIXED_POINT) + int32_t p; + int32_t q; + complexi16_t a; + complexi16_t b; + complexi16_t c; + static const complexi16_t x = {FP_Q_1_15(0.894427f), FP_Q_1_15(0.44721f)}; +#else float p; float q; - complexf_t zz; complexf_t a; complexf_t b; complexf_t c; + static const complexf_t x = {0.894427f, 0.44721f}; +#endif + int aa[3]; + int i; + int j; /* This routine adapts the position of the half baud samples entering the equalizer. */ /* Perform a Gardner test for baud alignment on the three most recent samples. */ + for (i = 0, j = s->rx.eq_step; i < 3; i++) + { + if (--j < 0) + j = V22BIS_EQUALIZER_LEN - 1; + aa[i] = j; + } if (s->rx.sixteen_way_decisions) { - p = s->rx.eq_buf[(s->rx.eq_step - 3) & V22BIS_EQUALIZER_MASK].re - - s->rx.eq_buf[(s->rx.eq_step - 1) & V22BIS_EQUALIZER_MASK].re; - p *= s->rx.eq_buf[(s->rx.eq_step - 2) & V22BIS_EQUALIZER_MASK].re; + p = s->rx.eq_buf[aa[2]].re - s->rx.eq_buf[aa[0]].re; + p *= s->rx.eq_buf[aa[1]].re; - q = s->rx.eq_buf[(s->rx.eq_step - 3) & V22BIS_EQUALIZER_MASK].im - - s->rx.eq_buf[(s->rx.eq_step - 1) & V22BIS_EQUALIZER_MASK].im; - q *= s->rx.eq_buf[(s->rx.eq_step - 2) & V22BIS_EQUALIZER_MASK].im; + q = s->rx.eq_buf[aa[2]].im - s->rx.eq_buf[aa[0]].im; + q *= s->rx.eq_buf[aa[1]].im; } else { /* Rotate the points to the 45 degree positions, to maximise the effectiveness of the Gardner algorithm. This is particularly significant at the start of operation to pull things in quickly. */ - zz = complex_setf(0.894427, 0.44721f); - a = complex_mulf(&s->rx.eq_buf[(s->rx.eq_step - 3) & V22BIS_EQUALIZER_MASK], &zz); - b = complex_mulf(&s->rx.eq_buf[(s->rx.eq_step - 2) & V22BIS_EQUALIZER_MASK], &zz); - c = complex_mulf(&s->rx.eq_buf[(s->rx.eq_step - 1) & V22BIS_EQUALIZER_MASK], &zz); +#if defined(SPANDSP_USE_FIXED_POINT) + a = complex_mul_q1_15(&s->rx.eq_buf[aa[2]], &x); + b = complex_mul_q1_15(&s->rx.eq_buf[aa[1]], &x); + c = complex_mul_q1_15(&s->rx.eq_buf[aa[0]], &x); +#else + a = complex_mulf(&s->rx.eq_buf[aa[2]], &x); + b = complex_mulf(&s->rx.eq_buf[aa[1]], &x); + c = complex_mulf(&s->rx.eq_buf[aa[0]], &x); +#endif p = (a.re - c.re)*b.re; q = (a.im - c.im)*b.im; } - s->rx.gardner_integrate += (p + q > 0.0f) ? s->rx.gardner_step : -s->rx.gardner_step; + s->rx.gardner_integrate += (p + q > 0) ? s->rx.gardner_step : -s->rx.gardner_step; if (abs(s->rx.gardner_integrate) >= 16) { @@ -386,11 +447,23 @@ static __inline__ void symbol_sync(v22bis_state_t *s) } /*- End of function --------------------------------------------------------*/ -static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) +#if defined(SPANDSP_USE_FIXED_POINT) +static __inline__ void process_half_baud(v22bis_state_t *s, const complexi16_t *sample) +#else +static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sample) +#endif { +#if defined(SPANDSP_USE_FIXED_POINT) + complexi16_t z; + complexi16_t zz; + const complexi16_t *target; + static const complexi16_t x = {FP_Q_1_15(0.894427f), FP_Q_1_15(0.44721f)}; +#else complexf_t z; complexf_t zz; const complexf_t *target; + static const complexf_t x = {0.894427f, 0.44721f}; +#endif int re; int im; int nearest; @@ -403,7 +476,8 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) /* Add a sample to the equalizer's circular buffer, but don't calculate anything at this time. */ s->rx.eq_buf[s->rx.eq_step] = z; - s->rx.eq_step = (s->rx.eq_step + 1) & V22BIS_EQUALIZER_MASK; + if (++s->rx.eq_step >= V22BIS_EQUALIZER_LEN) + s->rx.eq_step = 0; /* On alternate insertions we have a whole baud and must process it. */ if ((s->rx.baud_phase ^= 1)) @@ -416,12 +490,17 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) /* Find the constellation point */ if (s->rx.sixteen_way_decisions) { +#if defined(SPANDSP_USE_FIXED_POINT) + re = (z.re + FP_Q_6_10(3.0f)) >> FP_SHIFT_FACTOR; + im = (z.im + FP_Q_6_10(3.0f)) >> FP_SHIFT_FACTOR; +#else re = (int) (z.re + 3.0f); + im = (int) (z.im + 3.0f); +#endif if (re > 5) re = 5; else if (re < 0) re = 0; - im = (int) (z.im + 3.0f); if (im > 5) im = 5; else if (im < 0) @@ -430,13 +509,16 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) } else { - /* Rotate to 45 degrees, to make the slicing trivial */ - zz = complex_setf(0.894427, 0.44721f); - zz = complex_mulf(&z, &zz); + /* Rotate to 45 degrees, to make the slicing trivial. */ +#if defined(SPANDSP_USE_FIXED_POINT) + zz = complex_mul_q1_15(&z, &x); +#else + zz = complex_mulf(&z, &x); +#endif nearest = 0x01; - if (zz.re < 0.0f) + if (zz.re < 0) nearest |= 0x04; - if (zz.im < 0.0f) + if (zz.im < 0) { nearest ^= 0x04; nearest |= 0x08; @@ -490,10 +572,7 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) error could be higher. */ s->rx.gardner_step = 4; s->rx.pattern_repeats = 0; - if (s->calling_party) - s->rx.training = V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES; - else - s->rx.training = V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200; + s->rx.training = (s->calling_party) ? V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES : V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200; /* Be pessimistic and see what the handshake brings */ s->negotiated_bit_rate = 1200; break; @@ -609,7 +688,11 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; /* Normal reception starts immediately */ s->rx.training = V22BIS_RX_TRAINING_STAGE_NORMAL_OPERATION; +#if defined(SPANDSP_USE_FIXED_POINT) + s->rx.carrier_track_i = 8; +#else s->rx.carrier_track_i = 8000.0f; +#endif } else { @@ -633,7 +716,11 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) s->rx.sixteen_way_decisions = TRUE; s->rx.training = V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400; s->rx.pattern_repeats = 0; +#if defined(SPANDSP_USE_FIXED_POINT) + s->rx.carrier_track_i = 8; +#else s->rx.carrier_track_i = 8000.0f; +#endif } } else @@ -695,12 +782,20 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l { int i; int step; +#if defined(SPANDSP_USE_FIXED_POINT) + complexi16_t z; + complexi16_t zz; + complexi16_t sample; + int32_t ii; + int32_t qq; +#else complexf_t z; complexf_t zz; - int32_t power; complexf_t sample; float ii; float qq; +#endif + int32_t power; for (i = 0; i < len; i++) { @@ -717,7 +812,7 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l if (s->calling_party) { #if defined(SPANDSP_USE_FIXED_POINT) - ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); + ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step) >> 15; #else ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); #endif @@ -725,12 +820,12 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l else { #if defined(SPANDSP_USE_FIXED_POINT) - ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); + ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step) >> 15; #else ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_re[6], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); #endif } - power = power_meter_update(&(s->rx.rx_power), (int16_t) ii); + power = power_meter_update(&s->rx.rx_power, (int16_t) ii); if (s->rx.signal_present) { /* Look for power below the carrier off point */ @@ -749,58 +844,75 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int l s->rx.signal_present = TRUE; v22bis_report_status_change(s, SIG_STATUS_CARRIER_UP); } - if (s->rx.training != V22BIS_RX_TRAINING_STAGE_PARKED) + /* Only spend effort processing this data if the modem is not parked, after + a training failure. */ + if (s->rx.training == V22BIS_RX_TRAINING_STAGE_PARKED) + continue; + + /* Put things into the equalization buffer at T/2 rate. The Gardner algorithm + will fiddle the step to align this with the symbols. */ + if ((s->rx.eq_put_step -= PULSESHAPER_COEFF_SETS) <= 0) { - /* Only spend effort processing this data if the modem is not - parked, after a training failure. */ - z = dds_complexf(&s->rx.carrier_phase, s->rx.carrier_phase_rate); if (s->rx.training == V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION) { /* Only AGC during the initial symbol acquisition, and then lock the gain. */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->rx.agc_scaling = saturate16(((int32_t) (1024.0f*1024.0f*0.18f*3.60f))/fixed_sqrt32(power)); +#else s->rx.agc_scaling = 0.18f*3.60f/sqrtf(power); +#endif } - /* Put things into the equalization buffer at T/2 rate. The Gardner algorithm - will fiddle the step to align this with the symbols. */ - if ((s->rx.eq_put_step -= PULSESHAPER_COEFF_SETS) <= 0) + /* Pulse shape while still at the carrier frequency, using a quadrature + pair of filters. This results in a properly bandpass filtered complex + signal, which can be brought directly to bandband by complex mixing. + No further filtering, to remove mixer harmonics, is needed. */ + step = -s->rx.eq_put_step; + if (step > PULSESHAPER_COEFF_SETS - 1) + step = PULSESHAPER_COEFF_SETS - 1; + s->rx.eq_put_step += PULSESHAPER_COEFF_SETS*40/(3*2); + if (s->calling_party) { - /* Pulse shape while still at the carrier frequency, using a quadrature - pair of filters. This results in a properly bandpass filtered complex - signal, which can be brought directly to bandband by complex mixing. - No further filtering, to remove mixer harmonics, is needed. */ - step = -s->rx.eq_put_step; - if (step > PULSESHAPER_COEFF_SETS - 1) - step = PULSESHAPER_COEFF_SETS - 1; - s->rx.eq_put_step += PULSESHAPER_COEFF_SETS*40/(3*2); - if (s->calling_party) - { #if defined(SPANDSP_USE_FIXED_POINT) - ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); - qq = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); + ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step) >> 15; + qq = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_2400_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step) >> 15; #else - ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); - qq = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); + ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); + qq = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_2400_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); #endif - } - else - { -#if defined(SPANDSP_USE_FIXED_POINT) - ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); - qq = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); -#else - ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); - qq = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); -#endif - } - sample.re = ii*s->rx.agc_scaling; - sample.im = qq*s->rx.agc_scaling; - /* Shift to baseband - since this is done in a full complex form, the - result is clean, and requires no further filtering apart from the - equalizer. */ - zz.re = sample.re*z.re - sample.im*z.im; - zz.im = -sample.re*z.im - sample.im*z.re; - process_half_baud(s, &zz); } + else + { +#if defined(SPANDSP_USE_FIXED_POINT) + ii = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step) >> 15; + qq = vec_circular_dot_prodi16(s->rx.rrc_filter, rx_pulseshaper_1200_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step) >> 15; +#else + ii = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_re[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); + qq = vec_circular_dot_prodf(s->rx.rrc_filter, rx_pulseshaper_1200_im[step], V22BIS_RX_FILTER_STEPS, s->rx.rrc_filter_step); +#endif + } + /* Shift to baseband - since this is done in a full complex form, the + result is clean, and requires no further filtering apart from the + equalizer. */ +#if defined(SPANDSP_USE_FIXED_POINT) + sample.re = (ii*s->rx.agc_scaling) >> FP_SHIFT_FACTOR; + sample.im = (qq*s->rx.agc_scaling) >> FP_SHIFT_FACTOR; + z = dds_lookup_complexi16(s->rx.carrier_phase); + zz.re = ((int32_t) sample.re*z.re - (int32_t) sample.im*z.im) >> 15; + zz.im = ((int32_t) -sample.re*z.im - (int32_t) sample.im*z.re) >> 15; +#else + sample.re = ii*s->rx.agc_scaling; + sample.im = qq*s->rx.agc_scaling; + z = dds_lookup_complexf(s->rx.carrier_phase); + zz.re = sample.re*z.re - sample.im*z.im; + zz.im = -sample.re*z.im - sample.im*z.re; +#endif + process_half_baud(s, &zz); } +#if defined(SPANDSP_USE_FIXED_POINT) + dds_advance(&s->rx.carrier_phase, s->rx.carrier_phase_rate); +#else + dds_advancef(&s->rx.carrier_phase, s->rx.carrier_phase_rate); +#endif } return 0; } @@ -817,7 +929,7 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx_fillin(v22bis_state_t *s, int len) return 0; for (i = 0; i < len; i++) { -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) dds_advance(&s->rx.carrier_phase, s->rx.carrier_phase_rate); #else dds_advancef(&s->rx.carrier_phase, s->rx.carrier_phase_rate); @@ -830,10 +942,12 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx_fillin(v22bis_state_t *s, int len) int v22bis_rx_restart(v22bis_state_t *s) { -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) vec_zeroi16(s->rx.rrc_filter, sizeof(s->rx.rrc_filter)/sizeof(s->rx.rrc_filter[0])); + s->rx.training_error = 0; #else vec_zerof(s->rx.rrc_filter, sizeof(s->rx.rrc_filter)/sizeof(s->rx.rrc_filter[0])); + s->rx.training_error = 0.0f; #endif s->rx.rrc_filter_step = 0; s->rx.scramble_reg = 0; @@ -844,9 +958,13 @@ int v22bis_rx_restart(v22bis_state_t *s) s->rx.carrier_phase_rate = dds_phase_ratef((s->calling_party) ? 2400.0f : 1200.0f); s->rx.carrier_phase = 0; - power_meter_init(&(s->rx.rx_power), 5); + power_meter_init(&s->rx.rx_power, 5); v22bis_rx_signal_cutoff(s, -45.5f); +#if defined(SPANDSP_USE_FIXED_POINT) + s->rx.agc_scaling = (float) (1024.0f*1024.0f)*0.0005f*0.025f; +#else s->rx.agc_scaling = 0.0005f*0.025f; +#endif s->rx.constellation_state = 0; s->rx.sixteen_way_decisions = FALSE; @@ -858,11 +976,15 @@ int v22bis_rx_restart(v22bis_state_t *s) s->rx.gardner_integrate = 0; s->rx.gardner_step = 256; s->rx.baud_phase = 0; - s->rx.training_error = 0.0f; s->rx.total_baud_timing_correction = 0; /* We want the carrier to pull in faster on the answerer side, as it has very little time to adapt. */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->rx.carrier_track_i = (s->calling_party) ? 8 : 40; + s->rx.carrier_track_p = 8000; +#else s->rx.carrier_track_i = (s->calling_party) ? 8000.0f : 40000.0f; s->rx.carrier_track_p = 8000000.0f; +#endif s->negotiated_bit_rate = 1200; diff --git a/libs/spandsp/src/v22bis_tx.c b/libs/spandsp/src/v22bis_tx.c index 39ad4dd240..5cbef4d7d8 100644 --- a/libs/spandsp/src/v22bis_tx.c +++ b/libs/spandsp/src/v22bis_tx.c @@ -62,9 +62,11 @@ #include "spandsp/private/logging.h" #include "spandsp/private/v22bis.h" -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) +#define FP_SCALE FP_Q_6_10 #include "v22bis_tx_fixed_rrc.h" #else +#define FP_SCALE(x) (x) #include "v22bis_tx_floating_rrc.h" #endif @@ -246,24 +248,28 @@ static const int phase_steps[4] = 1, 0, 2, 3 }; +#if defined(SPANDSP_USE_FIXED_POINT) +const complexi16_t v22bis_constellation[16] = +#else const complexf_t v22bis_constellation[16] = +#endif { - { 1.0f, 1.0f}, - { 3.0f, 1.0f}, /* 1200bps 00 */ - { 1.0f, 3.0f}, - { 3.0f, 3.0f}, - {-1.0f, 1.0f}, - {-1.0f, 3.0f}, /* 1200bps 01 */ - {-3.0f, 1.0f}, - {-3.0f, 3.0f}, - {-1.0f, -1.0f}, - {-3.0f, -1.0f}, /* 1200bps 10 */ - {-1.0f, -3.0f}, - {-3.0f, -3.0f}, - { 1.0f, -1.0f}, - { 1.0f, -3.0f}, /* 1200bps 11 */ - { 3.0f, -1.0f}, - { 3.0f, -3.0f} + {FP_SCALE( 1.0f), FP_SCALE( 1.0f)}, + {FP_SCALE( 3.0f), FP_SCALE( 1.0f)}, /* 1200bps 00 */ + {FP_SCALE( 1.0f), FP_SCALE( 3.0f)}, + {FP_SCALE( 3.0f), FP_SCALE( 3.0f)}, + {FP_SCALE(-1.0f), FP_SCALE( 1.0f)}, + {FP_SCALE(-1.0f), FP_SCALE( 3.0f)}, /* 1200bps 01 */ + {FP_SCALE(-3.0f), FP_SCALE( 1.0f)}, + {FP_SCALE(-3.0f), FP_SCALE( 3.0f)}, + {FP_SCALE(-1.0f), FP_SCALE(-1.0f)}, + {FP_SCALE(-3.0f), FP_SCALE(-1.0f)}, /* 1200bps 10 */ + {FP_SCALE(-1.0f), FP_SCALE(-3.0f)}, + {FP_SCALE(-3.0f), FP_SCALE(-3.0f)}, + {FP_SCALE( 1.0f), FP_SCALE(-1.0f)}, + {FP_SCALE( 1.0f), FP_SCALE(-3.0f)}, /* 1200bps 11 */ + {FP_SCALE( 3.0f), FP_SCALE(-1.0f)}, + {FP_SCALE( 3.0f), FP_SCALE(-3.0f)} }; static int fake_get_bit(void *user_data) @@ -308,9 +314,17 @@ static __inline__ int get_scrambled_bit(v22bis_state_t *s) } /*- End of function --------------------------------------------------------*/ +#if defined(SPANDSP_USE_FIXED_POINT) +static complexi16_t training_get(v22bis_state_t *s) +#else static complexf_t training_get(v22bis_state_t *s) +#endif { - complexf_t z; +#if defined(SPANDSP_USE_FIXED_POINT) + static const complexi16_t zero = {0, 0}; +#else + static const complexf_t zero = {0.0f, 0.0f}; +#endif int bits; /* V.22bis training sequence */ @@ -329,20 +343,17 @@ static complexf_t training_get(v22bis_state_t *s) case V22BIS_TX_TRAINING_STAGE_INITIAL_SILENCE: /* Silence */ s->tx.constellation_state = 0; - z = complex_setf(0.0f, 0.0f); - break; + return zero; case V22BIS_TX_TRAINING_STAGE_U11: /* Send continuous unscrambled ones at 1200bps (i.e. 270 degree phase steps). */ /* Only the answering modem sends unscrambled ones. It is the first thing exchanged between the modems. */ s->tx.constellation_state = (s->tx.constellation_state + phase_steps[3]) & 3; - z = v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; - break; + return v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; case V22BIS_TX_TRAINING_STAGE_U0011: /* Continuous unscrambled double dibit 00 11 at 1200bps. This is termed the S1 segment in the V.22bis spec. It is only sent to request or accept 2400bps mode, and lasts 100+-3ms. After this timed burst, we unconditionally change to sending scrambled ones at 1200bps. */ s->tx.constellation_state = (s->tx.constellation_state + phase_steps[3*(s->tx.training_count & 1)]) & 3; - z = v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; if (++s->tx.training_count >= ms_to_symbols(100)) { span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S11 after U0011\n"); @@ -357,7 +368,7 @@ static complexf_t training_get(v22bis_state_t *s) s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; } } - break; + return v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; case V22BIS_TX_TRAINING_STAGE_TIMED_S11: /* A timed period of scrambled ones at 1200bps. */ if (++s->tx.training_count >= ms_to_symbols(756)) @@ -383,8 +394,7 @@ static complexf_t training_get(v22bis_state_t *s) bits = scramble(s, 1); bits = (bits << 1) | scramble(s, 1); s->tx.constellation_state = (s->tx.constellation_state + phase_steps[bits]) & 3; - z = v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; - break; + return v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; case V22BIS_TX_TRAINING_STAGE_S1111: /* Scrambled ones at 2400bps. We send a timed 200ms burst, and switch to normal operation at 2400bps */ bits = scramble(s, 1); @@ -392,7 +402,6 @@ static complexf_t training_get(v22bis_state_t *s) s->tx.constellation_state = (s->tx.constellation_state + phase_steps[bits]) & 3; bits = scramble(s, 1); bits = (bits << 1) | scramble(s, 1); - z = v22bis_constellation[(s->tx.constellation_state << 2) | bits]; if (++s->tx.training_count >= ms_to_symbols(200)) { /* We have completed training. Now handle some real work. */ @@ -402,18 +411,23 @@ static complexf_t training_get(v22bis_state_t *s) v22bis_report_status_change(s, SIG_STATUS_TRAINING_SUCCEEDED); s->tx.current_get_bit = s->get_bit; } - break; - case V22BIS_TX_TRAINING_STAGE_PARKED: - default: - z = complex_setf(0.0f, 0.0f); - break; + return v22bis_constellation[(s->tx.constellation_state << 2) | bits]; } - return z; + return zero; } /*- End of function --------------------------------------------------------*/ +#if defined(SPANDSP_USE_FIXED_POINT) +static complexi16_t getbaud(v22bis_state_t *s) +#else static complexf_t getbaud(v22bis_state_t *s) +#endif { +#if defined(SPANDSP_USE_FIXED_POINT) + static const complexi16_t zero = {0, 0}; +#else + static const complexf_t zero = {0.0f, 0.0f}; +#endif int bits; if (s->tx.training) @@ -428,7 +442,7 @@ static complexf_t getbaud(v22bis_state_t *s) if (s->tx.shutdown) { if (++s->tx.shutdown > 10) - return complex_setf(0.0f, 0.0f); + return zero; } /* The first two bits define the quadrant */ bits = get_scrambled_bit(s); @@ -450,11 +464,18 @@ static complexf_t getbaud(v22bis_state_t *s) SPAN_DECLARE_NONSTD(int) v22bis_tx(v22bis_state_t *s, int16_t amp[], int len) { +#if defined(SPANDSP_USE_FIXED_POINT) + complexi16_t v; + complexi32_t x; + complexi32_t z; + int16_t iamp; +#else + complexf_t v; complexf_t x; complexf_t z; - int i; - int sample; float famp; +#endif + int sample; if (s->tx.shutdown > 10) return 0; @@ -463,28 +484,42 @@ SPAN_DECLARE_NONSTD(int) v22bis_tx(v22bis_state_t *s, int16_t amp[], int len) if ((s->tx.baud_phase += 3) >= 40) { s->tx.baud_phase -= 40; - s->tx.rrc_filter[s->tx.rrc_filter_step] = - s->tx.rrc_filter[s->tx.rrc_filter_step + V22BIS_TX_FILTER_STEPS] = getbaud(s); + v = getbaud(s); + s->tx.rrc_filter_re[s->tx.rrc_filter_step] = v.re; + s->tx.rrc_filter_im[s->tx.rrc_filter_step] = v.im; if (++s->tx.rrc_filter_step >= V22BIS_TX_FILTER_STEPS) s->tx.rrc_filter_step = 0; } +#if defined(SPANDSP_USE_FIXED_POINT) /* Root raised cosine pulse shaping at baseband */ - x = complex_setf(0.0f, 0.0f); - for (i = 0; i < V22BIS_TX_FILTER_STEPS; i++) - { - x.re += tx_pulseshaper[39 - s->tx.baud_phase][i]*s->tx.rrc_filter[i + s->tx.rrc_filter_step].re; - x.im += tx_pulseshaper[39 - s->tx.baud_phase][i]*s->tx.rrc_filter[i + s->tx.rrc_filter_step].im; - } + x.re = vec_circular_dot_prodi16(s->tx.rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->tx.baud_phase], V22BIS_TX_FILTER_STEPS, s->tx.rrc_filter_step) >> 14; + x.im = vec_circular_dot_prodi16(s->tx.rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->tx.baud_phase], V22BIS_TX_FILTER_STEPS, s->tx.rrc_filter_step) >> 14; /* Now create and modulate the carrier */ - z = dds_complexf(&(s->tx.carrier_phase), s->tx.carrier_phase_rate); - famp = (x.re*z.re - x.im*z.im)*s->tx.gain; - if (s->tx.guard_phase_rate && (s->tx.rrc_filter[s->tx.rrc_filter_step].re != 0.0f || s->tx.rrc_filter[s->tx.rrc_filter_step].im != 0.0f)) + z = dds_complexi32(&s->tx.carrier_phase, s->tx.carrier_phase_rate); + iamp = (x.re*z.re - x.im*z.im) >> 15; + iamp = (int16_t) (((int32_t) iamp*s->tx.gain) >> 11); + if (s->tx.guard_phase_rate && (s->tx.rrc_filter_re[s->tx.rrc_filter_step] != 0 || s->tx.rrc_filter_im[s->tx.rrc_filter_step] != 0)) { /* Add the guard tone */ - famp += dds_modf(&(s->tx.guard_phase), s->tx.guard_phase_rate, s->tx.guard_level, 0); + iamp += dds_mod(&s->tx.guard_phase, s->tx.guard_phase_rate, s->tx.guard_tone_gain, 0); + } + /* Don't bother saturating. We should never clip. */ + amp[sample] = iamp; +#else + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodf(s->tx.rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->tx.baud_phase], V22BIS_TX_FILTER_STEPS, s->tx.rrc_filter_step); + x.im = vec_circular_dot_prodf(s->tx.rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->tx.baud_phase], V22BIS_TX_FILTER_STEPS, s->tx.rrc_filter_step); + /* Now create and modulate the carrier */ + z = dds_complexf(&s->tx.carrier_phase, s->tx.carrier_phase_rate); + famp = (x.re*z.re - x.im*z.im)*s->tx.gain; + if (s->tx.guard_phase_rate && (s->tx.rrc_filter_re[s->tx.rrc_filter_step] != 0.0f || s->tx.rrc_filter_im[s->tx.rrc_filter_step] != 0.0f)) + { + /* Add the guard tone */ + famp += dds_modf(&s->tx.guard_phase, s->tx.guard_phase_rate, s->tx.guard_tone_gain, 0); } /* Don't bother saturating. We should never clip. */ amp[sample] = (int16_t) lfastrintf(famp); +#endif } return sample; } @@ -492,34 +527,49 @@ SPAN_DECLARE_NONSTD(int) v22bis_tx(v22bis_state_t *s, int16_t amp[], int len) SPAN_DECLARE(void) v22bis_tx_power(v22bis_state_t *s, float power) { - float l; + float sig_power; + float guard_tone_power; + float sig_gain; + float guard_tone_gain; + /* If is there is a guard tone we need to scale down the signal power a bit, so the aggregate of the signal + and guard tone power is the specified power. */ if (s->tx.guard_phase_rate == dds_phase_ratef(550.0f)) { - l = 1.6f*powf(10.0f, (power - 1.0f - DBM0_MAX_POWER)/20.0f); - s->tx.gain = l*32768.0f/(TX_PULSESHAPER_GAIN*3.0f); - l = powf(10.0f, (power - 1.0f - 3.0f - DBM0_MAX_POWER)/20.0f); - s->tx.guard_level = l*32768.0f; + sig_power = power - 1.0f; + guard_tone_power = sig_power - 3.0f; } else if(s->tx.guard_phase_rate == dds_phase_ratef(1800.0f)) { - l = 1.6f*powf(10.0f, (power - 1.0f - 1.0f - DBM0_MAX_POWER)/20.0f); - s->tx.gain = l*32768.0f/(TX_PULSESHAPER_GAIN*3.0f); - l = powf(10.0f, (power - 1.0f - 6.0f - DBM0_MAX_POWER)/20.0f); - s->tx.guard_level = l*32768.0f; + sig_power = power - 0.55f; + guard_tone_power = sig_power - 6.0f; } else { - l = 1.6f*powf(10.0f, (power - DBM0_MAX_POWER)/20.0f); - s->tx.gain = l*32768.0f/(TX_PULSESHAPER_GAIN*3.0f); - s->tx.guard_level = 0; + sig_power = power; + guard_tone_power = -9999.0f; } + sig_gain = 0.4490f*powf(10.0f, (sig_power - DBM0_MAX_POWER)/20.0f)*32768.0f/TX_PULSESHAPER_GAIN; + guard_tone_gain = powf(10.0f, (guard_tone_power - DBM0_MAX_POWER)/20.0f)*32768.0f; +#if defined(SPANDSP_USE_FIXED_POINT) + s->tx.gain = (int16_t) sig_gain; + s->tx.guard_tone_gain = (int16_t) guard_tone_gain; +#else + s->tx.gain = sig_gain; + s->tx.guard_tone_gain = guard_tone_gain; +#endif } /*- End of function --------------------------------------------------------*/ static int v22bis_tx_restart(v22bis_state_t *s) { - cvec_zerof(s->tx.rrc_filter, sizeof(s->tx.rrc_filter)/sizeof(s->tx.rrc_filter[0])); +#if defined(SPANDSP_USE_FIXED_POINT) + vec_zeroi16(s->tx.rrc_filter_re, sizeof(s->tx.rrc_filter_re)/sizeof(s->tx.rrc_filter_re[0])); + vec_zeroi16(s->tx.rrc_filter_im, sizeof(s->tx.rrc_filter_im)/sizeof(s->tx.rrc_filter_im[0])); +#else + vec_zerof(s->tx.rrc_filter_re, sizeof(s->tx.rrc_filter_re)/sizeof(s->tx.rrc_filter_re[0])); + vec_zerof(s->tx.rrc_filter_im, sizeof(s->tx.rrc_filter_im)/sizeof(s->tx.rrc_filter_im[0])); +#endif s->tx.rrc_filter_step = 0; s->tx.scramble_reg = 0; s->tx.scrambler_pattern_count = 0; diff --git a/libs/spandsp/src/v27ter_rx.c b/libs/spandsp/src/v27ter_rx.c index 5ae87dc44d..b38481b87a 100644 --- a/libs/spandsp/src/v27ter_rx.c +++ b/libs/spandsp/src/v27ter_rx.c @@ -65,11 +65,13 @@ #include "spandsp/private/v27ter_rx.h" #if defined(SPANDSP_USE_FIXED_POINT) -#define FP_SCALE FP_Q_6_10 +#define FP_SCALE FP_Q_6_10 +#define FP_FACTOR 4096 +#define FP_SHIFT_FACTOR 12 #include "v27ter_rx_4800_fixed_rrc.h" #include "v27ter_rx_2400_fixed_rrc.h" #else -#define FP_SCALE(x) (x) +#define FP_SCALE(x) (x) #include "v27ter_rx_4800_floating_rrc.h" #include "v27ter_rx_2400_floating_rrc.h" #endif @@ -87,11 +89,6 @@ /*! The adaption rate coefficient for the equalizer */ #define EQUALIZER_DELTA 0.25f -#if defined(SPANDSP_USE_FIXED_POINT) -#define FP_FACTOR 4096 -#define FP_SHIFT_FACTOR 12 -#endif - /* Segments of the training sequence */ /* V.27ter defines a long and a short sequence. FAX doesn't use the short sequence, so it is not implemented here. */ @@ -113,7 +110,7 @@ enum TRAINING_STAGE_PARKED }; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static const complexi16_t v27ter_constellation[8] = #else static const complexf_t v27ter_constellation[8] = @@ -167,7 +164,7 @@ static void report_status_change(v27ter_rx_state_t *s, int status) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexi16_t **coeffs) #else SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs) @@ -180,7 +177,7 @@ SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **c static void equalizer_save(v27ter_rx_state_t *s) { -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V27TER_EQUALIZER_LEN); #else cvec_copyf(s->eq_coeff_save, s->eq_coeff, V27TER_EQUALIZER_LEN); @@ -190,7 +187,7 @@ static void equalizer_save(v27ter_rx_state_t *s) static void equalizer_restore(v27ter_rx_state_t *s) { -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_LEN); cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_LEN); s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN; @@ -208,7 +205,7 @@ static void equalizer_restore(v27ter_rx_state_t *s) static void equalizer_reset(v27ter_rx_state_t *s) { /* Start with an equalizer based on everything being perfect. */ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static const complexi16_t x = {FP_SCALE(1.414f), FP_SCALE(0.0f)}; cvec_zeroi16(s->eq_coeff, V27TER_EQUALIZER_LEN); @@ -229,50 +226,36 @@ static void equalizer_reset(v27ter_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) -static __inline__ complexi16_t complex_mul_q4_12(const complexi16_t *x, const complexi16_t *y) -{ - complexi16_t z; - - z.re = ((int32_t) x->re*(int32_t) y->re - (int32_t) x->im*(int32_t) y->im) >> 12; - z.im = ((int32_t) x->re*(int32_t) y->im + (int32_t) x->im*(int32_t) y->re) >> 12; - return z; -} -/*- End of function --------------------------------------------------------*/ -#endif - -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static __inline__ complexi16_t equalizer_get(v27ter_rx_state_t *s) -#else -static __inline__ complexf_t equalizer_get(v27ter_rx_state_t *s) -#endif { -#if defined(SPANDSP_USE_FIXED_POINTx) complexi32_t zz; complexi16_t z; /* Get the next equalized value. */ zz = cvec_circular_dot_prodi16(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step); - z.re = zz.re >> FP_SHIFT_FACTOR; - z.im = zz.im >> FP_SHIFT_FACTOR; + z.re = zz.re >> 14; + z.im = zz.im >> 14; return z; +} #else +static __inline__ complexf_t equalizer_get(v27ter_rx_state_t *s) +{ /* Get the next equalized value. */ return cvec_circular_dot_prodf(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step); -#endif } +#endif /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static void tune_equalizer(v27ter_rx_state_t *s, const complexi16_t *z, const complexi16_t *target) { complexi16_t err; /* Find the x and y mismatch from the exact constellation position. */ - err.re = target->re*FP_FACTOR - z->re; - err.im = target->im*FP_FACTOR - z->im; - err.re = ((int32_t) err.re*(int32_t) s->eq_delta) >> 15; - err.im = ((int32_t) err.im*(int32_t) s->eq_delta) >> 15; + err = complex_subi16(target, z); + err.re = ((int32_t) err.re*s->eq_delta) >> 13; + err.im = ((int32_t) err.im*s->eq_delta) >> 13; cvec_circular_lmsi16(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step, &err); } #else @@ -289,7 +272,7 @@ static void tune_equalizer(v27ter_rx_state_t *s, const complexf_t *z, const comp #endif /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static __inline__ int find_quadrant(const complexi16_t *z) #else static __inline__ int find_quadrant(const complexf_t *z) @@ -305,25 +288,36 @@ static __inline__ int find_quadrant(const complexf_t *z) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static __inline__ int find_octant(complexi16_t *z) #else static __inline__ int find_octant(complexf_t *z) #endif { +#if defined(SPANDSP_USE_FIXED_POINT) + int32_t abs_re; + int32_t abs_im; +#else float abs_re; float abs_im; +#endif int b1; int b2; int bits; /* Are we near an axis or a diagonal? */ +#if defined(SPANDSP_USE_FIXED_POINT) + abs_re = abs(z->re); + abs_im = abs(z->im); + if (abs_im*1000 > abs_re*414 && abs_im*1000 < abs_re*2414) +#else abs_re = fabsf(z->re); abs_im = fabsf(z->im); if (abs_im > abs_re*0.4142136f && abs_im < abs_re*2.4142136f) +#endif { /* Split the space along the two axes. */ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) b1 = (z->re < 0); b2 = (z->im < 0); #else @@ -343,13 +337,13 @@ static __inline__ int find_octant(complexf_t *z) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static __inline__ void track_carrier(v27ter_rx_state_t *s, const complexi16_t *z, const complexi16_t *target) #else static __inline__ void track_carrier(v27ter_rx_state_t *s, const complexf_t *z, const complexf_t *target) #endif { -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) int32_t error; #else float error; @@ -358,13 +352,12 @@ static __inline__ void track_carrier(v27ter_rx_state_t *s, const complexf_t *z, /* For small errors the imaginary part of the difference between the actual and the target positions is proportional to the phase error, for any particular target. However, the different amplitudes of the various target positions scale things. */ - error = z->im*target->re - z->re*target->im; - -#if defined(SPANDSP_USE_FIXED_POINTx) - error /= (float) FP_FACTOR; - s->carrier_phase_rate += (int32_t) (s->carrier_track_i*error); - s->carrier_phase += (int32_t) (s->carrier_track_p*error); +#if defined(SPANDSP_USE_FIXED_POINT) + error = ((int32_t) z->im*target->re - (int32_t) z->re*target->im) >> 10; + s->carrier_phase_rate += ((s->carrier_track_i*error) >> FP_SHIFT_FACTOR); + s->carrier_phase += ((s->carrier_track_p*error) >> FP_SHIFT_FACTOR); #else + error = z->im*target->re - z->re*target->im; s->carrier_phase_rate += (int32_t) (s->carrier_track_i*error); s->carrier_phase += (int32_t) (s->carrier_track_p*error); //span_log(&s->logging, SPAN_LOG_FLOW, "Im = %15.5f f = %15.5f\n", error, dds_frequencyf(s->carrier_phase_rate)); @@ -429,7 +422,7 @@ static __inline__ void put_bit(v27ter_rx_state_t *s, int bit) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static void decode_baud(v27ter_rx_state_t *s, complexi16_t *z) #else static void decode_baud(v27ter_rx_state_t *s, complexf_t *z) @@ -478,8 +471,13 @@ static void decode_baud(v27ter_rx_state_t *s, complexf_t *z) static __inline__ void symbol_sync(v27ter_rx_state_t *s) { +#if defined(SPANDSP_USE_FIXED_POINT) + int32_t p; + int32_t q; +#else float p; float q; +#endif /* This routine adapts the position of the half baud samples entering the equalizer. */ @@ -492,7 +490,7 @@ static __inline__ void symbol_sync(v27ter_rx_state_t *s) - s->eq_buf[(s->eq_step - 1) & (V27TER_EQUALIZER_LEN - 1)].im; q *= s->eq_buf[(s->eq_step - 2) & (V27TER_EQUALIZER_LEN - 1)].im; - s->gardner_integrate += (p + q > 0.0f) ? s->gardner_step : -s->gardner_step; + s->gardner_integrate += (p + q > 0) ? s->gardner_step : -s->gardner_step; if (abs(s->gardner_integrate) >= 256) { @@ -516,22 +514,19 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexi16_ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t *sample) #endif { - static const int abab_pos[2] = - { - 0, 4 - }; - complexf_t zz; -#if defined(SPANDSP_USE_FIXED_POINTx) - complexf_t z1; + static const int abab_pos[2] = {0, 4}; +#if defined(SPANDSP_USE_FIXED_POINT) complexi16_t z; + complexi16_t z16; const complexi16_t *target; static const complexi16_t zero = {0, 0}; #else + float p; complexf_t z; + complexf_t zz; const complexf_t *target; static const complexf_t zero = {0.0f, 0.0f}; #endif - float p; int i; int j; int32_t angle; @@ -540,12 +535,7 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t /* Add a sample to the equalizer's circular buffer, but don't calculate anything at this time. */ -#if defined(SPANDSP_USE_FIXED_POINT) - s->eq_buf[s->eq_step].re = sample->re/(float) FP_FACTOR; - s->eq_buf[s->eq_step].im = sample->im/(float) FP_FACTOR; -#else s->eq_buf[s->eq_step] = *sample; -#endif if (++s->eq_step >= V27TER_EQUALIZER_LEN) s->eq_step = 0; @@ -583,9 +573,8 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t case TRAINING_STAGE_LOG_PHASE: /* Record the current alternate phase angle */ target = &zero; - angle = arctan2(z.im, z.re); s->angles[1] = - s->start_angles[1] = angle; + s->start_angles[1] = arctan2(z.im, z.re); s->training_count = 1; s->training_stage = TRAINING_STAGE_WAIT_FOR_HOP; break; @@ -609,8 +598,7 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t if (i) { j = i & 0xF; - ang = (s->angles[j] - s->start_angles[0])/i - + (s->angles[j | 0x1] - s->start_angles[1])/i; + ang = (s->angles[j] - s->start_angles[0])/i + (s->angles[j | 0x1] - s->start_angles[1])/i; if (s->bit_rate == 4800) s->carrier_phase_rate += ang/10; else @@ -622,27 +610,22 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t || s->carrier_phase_rate > dds_phase_ratef(CARRIER_NOMINAL_FREQ + 20.0f)) { - span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (sequence failed)\n"); - /* Park this modem */ - s->training_stage = TRAINING_STAGE_PARKED; - report_status_change(s, SIG_STATUS_TRAINING_FAILED); - break; + span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (sequence failed)\n"); + /* Park this modem */ + s->training_stage = TRAINING_STAGE_PARKED; + report_status_change(s, SIG_STATUS_TRAINING_FAILED); + break; } /* Make a step shift in the phase, to pull it into line. We need to rotate the equalizer buffer, as well as the carrier phase, for this to play out nicely. */ angle += 0x80000000; - p = angle*2.0f*3.14159f/(65536.0f*65536.0f); -#if defined(SPANDSP_USE_FIXED_POINTx) - zz = complex_setf(cosf(p), -sinf(p)); +#if defined(SPANDSP_USE_FIXED_POINT) + z16 = complex_seti16(fixed_cos(angle >> 16), -fixed_sin(angle >> 16)); for (i = 0; i < V27TER_EQUALIZER_LEN; i++) - { - z1 = complex_setf(s->eq_buf[i].re, s->eq_buf[i].im); - z1 = complex_mulf(&z1, &zz); - s->eq_buf[i].re = z1.re; - s->eq_buf[i].im = z1.im; - } + s->eq_buf[i] = complex_mul_q1_15(&s->eq_buf[i], &z16); #else + p = angle*2.0f*3.14159f/(65536.0f*65536.0f); zz = complex_setf(cosf(p), -sinf(p)); for (i = 0; i < V27TER_EQUALIZER_LEN; i++) s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz); @@ -682,7 +665,7 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t track_carrier(s, &z, target); tune_equalizer(s, &z, target); -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) s->carrier_track_i = 400 + (200000 - 400)*(float) (V27TER_TRAINING_SEG_5_LEN - s->training_count)/(float) V27TER_TRAINING_SEG_5_LEN; s->carrier_track_p = 1000000 + (10000000 - 1000000)*(float) (V27TER_TRAINING_SEG_5_LEN - s->training_count)/(float) V27TER_TRAINING_SEG_5_LEN; #else @@ -702,13 +685,9 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t constellation_state = (s->bit_rate == 4800) ? s->constellation_state : (s->constellation_state << 1); target = &v27ter_constellation[constellation_state]; /* Measure the training error */ -#if defined(SPANDSP_USE_FIXED_POINTx) - z1.re = z.re/(float) FP_FACTOR; - z1.im = z.im/(float) FP_FACTOR; - zz.re = target->re; - zz.im = target->im; - zz = complex_subf(&z1, &zz); - s->training_error += powerf(&zz); +#if defined(SPANDSP_USE_FIXED_POINT) + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); #else zz = complex_subf(&z, target); s->training_error += powerf(&zz); @@ -717,12 +696,20 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t { /* At 4800bps the symbols are 1.08238 (Euclidian) apart. At 2400bps the symbols are 2.0 (Euclidian) apart. */ +#if defined(SPANDSP_USE_FIXED_POINT) + if ((s->bit_rate == 4800 && s->training_error < V27TER_TRAINING_SEG_6_LEN*FP_FACTOR*FP_FACTOR/4) + || + (s->bit_rate == 2400 && s->training_error < V27TER_TRAINING_SEG_6_LEN*FP_FACTOR*FP_FACTOR/2)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Training succeeded at %dbps (constellation mismatch %d)\n", s->bit_rate, s->training_error); +#else if ((s->bit_rate == 4800 && s->training_error < V27TER_TRAINING_SEG_6_LEN*0.25f) || (s->bit_rate == 2400 && s->training_error < V27TER_TRAINING_SEG_6_LEN*0.5f)) { - /* We are up and running */ span_log(&s->logging, SPAN_LOG_FLOW, "Training succeeded at %dbps (constellation mismatch %f)\n", s->bit_rate, s->training_error); +#endif + /* We are up and running */ report_status_change(s, SIG_STATUS_TRAINING_SUCCEEDED); /* Apply some lag to the carrier off condition, to ensure the last few bits get pushed through the processing. */ @@ -735,7 +722,11 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t else { /* Training has failed */ +#if defined(SPANDSP_USE_FIXED_POINT) + span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %d)\n", s->training_error); +#else span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %f)\n", s->training_error); +#endif /* Park this modem */ s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); @@ -750,17 +741,7 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t break; } if (s->qam_report) - { -#if defined(SPANDSP_USE_FIXED_POINTx) - z1.re = z.re/(float) FP_FACTOR; - z1.im = z.im/(float) FP_FACTOR; - zz.re = target->re; - zz.im = target->im; - s->qam_report(s->qam_user_data, &z1, &zz, s->constellation_state); -#else s->qam_report(s->qam_user_data, &z, target, s->constellation_state); -#endif - } } /*- End of function --------------------------------------------------------*/ @@ -777,7 +758,7 @@ static __inline__ int signal_detect(v27ter_rx_state_t *s, int16_t amp) /* There could be overflow here, but it isn't a problem in practice */ diff = x - s->last_sample; s->last_sample = x; - power = power_meter_update(&(s->power), diff); + power = power_meter_update(&s->power, diff); #if defined(IAXMODEM_STUFF) /* Quick power drop fudge */ diff = abs(diff); @@ -785,7 +766,7 @@ static __inline__ int signal_detect(v27ter_rx_state_t *s, int16_t amp) { if (++s->low_samples > 120) { - power_meter_init(&(s->power), 4); + power_meter_init(&s->power, 4); s->high_sample = 0; s->low_samples = 0; } @@ -797,7 +778,7 @@ static __inline__ int signal_detect(v27ter_rx_state_t *s, int16_t amp) s->high_sample = diff; } #endif - //span_log(&s->logging, SPAN_LOG_FLOW, "Power = %f\n", power_meter_current_dbm0(&(s->power))); + //span_log(&s->logging, SPAN_LOG_FLOW, "Power = %f\n", power_meter_current_dbm0(&s->power)); if (s->signal_present > 0) { /* Look for power below turn-off threshold to turn the carrier off */ @@ -867,7 +848,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in parked, after training failure. */ if (s->training_stage == TRAINING_STAGE_PARKED) continue; - + /* Put things into the equalization buffer at T/2 rate. The Gardner algorithm will fiddle the step to align this with the symbols. */ if ((s->eq_put_step -= RX_PULSESHAPER_4800_COEFF_SETS) <= 0) @@ -876,7 +857,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in { /* Only AGC during the initial training */ #if defined(SPANDSP_USE_FIXED_POINT) - s->agc_scaling = (float) FP_FACTOR*32768.0f*(1.0f/RX_PULSESHAPER_4800_GAIN)*1.414f/sqrtf(power); + s->agc_scaling = saturate16(((int32_t) (1024.0f*FP_FACTOR*1.414f))/fixed_sqrt32(power)); #else s->agc_scaling = (1.0f/RX_PULSESHAPER_4800_GAIN)*1.414f/sqrtf(power); #endif @@ -890,13 +871,13 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in step = RX_PULSESHAPER_4800_COEFF_SETS - 1; s->eq_put_step += RX_PULSESHAPER_4800_COEFF_SETS*5/2; #if defined(SPANDSP_USE_FIXED_POINT) - v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_4800_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step); - sample.re = (v*(int32_t) s->agc_scaling) >> 15; - v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_4800_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step); - sample.im = (v*(int32_t) s->agc_scaling) >> 15; + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_4800_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.re = (v*s->agc_scaling) >> 10; + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_4800_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.im = (v*s->agc_scaling) >> 10; z = dds_lookup_complexi16(s->carrier_phase); - zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15; - zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15; + zz.re = ((int32_t) sample.re*z.re - (int32_t) sample.im*z.im) >> 15; + zz.im = ((int32_t) -sample.re*z.im - (int32_t) sample.im*z.re) >> 15; #else v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_4800_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step); sample.re = v*s->agc_scaling; @@ -929,7 +910,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in parked, after training failure. */ if (s->training_stage == TRAINING_STAGE_PARKED) continue; - + /* Put things into the equalization buffer at T/2 rate. The Gardner algorithm will fiddle the step to align this with the symbols. */ if ((s->eq_put_step -= RX_PULSESHAPER_2400_COEFF_SETS) <= 0) @@ -938,7 +919,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in { /* Only AGC during the initial training */ #if defined(SPANDSP_USE_FIXED_POINT) - s->agc_scaling = (float) FP_FACTOR*32768.0f*(1.0f/RX_PULSESHAPER_2400_GAIN)*1.414f/sqrtf(power); + s->agc_scaling = saturate16(((int32_t) (1024.0f*FP_FACTOR*1.414f))/fixed_sqrt32(power)); #else s->agc_scaling = (1.0f/RX_PULSESHAPER_2400_GAIN)*1.414f/sqrtf(power); #endif @@ -952,13 +933,13 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], in step = RX_PULSESHAPER_2400_COEFF_SETS - 1; s->eq_put_step += RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2); #if defined(SPANDSP_USE_FIXED_POINT) - v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_2400_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step); - sample.re = (v*(int32_t) s->agc_scaling) >> 15; - v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_2400_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step); - sample.im = (v*(int32_t) s->agc_scaling) >> 15; + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_2400_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.re = (v*s->agc_scaling) >> 10; + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_2400_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.im = (v*s->agc_scaling) >> 10; z = dds_lookup_complexi16(s->carrier_phase); - zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15; - zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15; + zz.re = ((int32_t) sample.re*z.re - (int32_t) sample.im*z.im) >> 15; + zz.im = ((int32_t) -sample.re*z.im - (int32_t) sample.im*z.re) >> 15; #else v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_2400_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step); sample.re = v*s->agc_scaling; @@ -1045,8 +1026,10 @@ SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_ #if defined(SPANDSP_USE_FIXED_POINT) vec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + s->training_error = 0; #else vec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + s->training_error = 0.0f; #endif s->rrc_filter_step = 0; @@ -1055,7 +1038,6 @@ SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_ s->training_stage = TRAINING_STAGE_SYMBOL_ACQUISITION; s->training_bc = 0; s->training_count = 0; - s->training_error = 0.0f; s->signal_present = 0; #if defined(IAXMODEM_STUFF) s->high_sample = 0; @@ -1064,14 +1046,14 @@ SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_ #endif s->carrier_phase = 0; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) s->carrier_track_i = 200000; s->carrier_track_p = 10000000; #else s->carrier_track_i = 200000.0f; s->carrier_track_p = 10000000.0f; #endif - power_meter_init(&(s->power), 4); + power_meter_init(&s->power, 4); s->constellation_state = 0; @@ -1084,10 +1066,10 @@ SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_ else { s->carrier_phase_rate = dds_phase_ratef(CARRIER_NOMINAL_FREQ); -#if defined(SPANDSP_USE_FIXED_POINTx) - s->agc_scaling = (float) FP_FACTOR*32768.0f*0.005f/RX_PULSESHAPER_4800_GAIN; +#if defined(SPANDSP_USE_FIXED_POINT) + s->agc_scaling = (float) (1024.0f*FP_FACTOR)*1.414f/283.0f; #else - s->agc_scaling = 0.005f/RX_PULSESHAPER_4800_GAIN; + s->agc_scaling = (1.0f/RX_PULSESHAPER_4800_GAIN)*1.414f/283.0f; #endif equalizer_reset(s); } diff --git a/libs/spandsp/src/v27ter_tx.c b/libs/spandsp/src/v27ter_tx.c index f2673444ee..7c05aa2f6e 100644 --- a/libs/spandsp/src/v27ter_tx.c +++ b/libs/spandsp/src/v27ter_tx.c @@ -59,9 +59,11 @@ #include "spandsp/private/v27ter_tx.h" #if defined(SPANDSP_USE_FIXED_POINT) +#define FP_SCALE FP_Q_6_10 #include "v27ter_tx_4800_fixed_rrc.h" #include "v27ter_tx_2400_fixed_rrc.h" #else +#define FP_SCALE(x) (x) #include "v27ter_tx_4800_floating_rrc.h" #include "v27ter_tx_2400_floating_rrc.h" #endif @@ -149,32 +151,22 @@ static complexf_t getbaud(v27ter_tx_state_t *s) 0, 2, 6, 4 }; #if defined(SPANDSP_USE_FIXED_POINT) - static const complexi16_t constellation[8] = - { - {FP_Q_6_10( 1.414f), FP_Q_6_10( 0.0f)}, /* 0deg */ - {FP_Q_6_10( 1.0f), FP_Q_6_10( 1.0f)}, /* 45deg */ - {FP_Q_6_10( 0.0f), FP_Q_6_10( 1.414f)}, /* 90deg */ - {FP_Q_6_10(-1.0f), FP_Q_6_10( 1.0f)}, /* 135deg */ - {FP_Q_6_10(-1.414f), FP_Q_6_10( 0.0f)}, /* 180deg */ - {FP_Q_6_10(-1.0f), FP_Q_6_10(-1.0f)}, /* 225deg */ - {FP_Q_6_10( 0.0f), FP_Q_6_10(-1.414f)}, /* 270deg */ - {FP_Q_6_10( 1.0f), FP_Q_6_10(-1.0f)} /* 315deg */ - }; static const complexi16_t zero = {0, 0}; + static const complexi16_t constellation[8] = #else - static const complexf_t constellation[8] = - { - { 1.414f, 0.0f}, /* 0deg */ - { 1.0f, 1.0f}, /* 45deg */ - { 0.0f, 1.414f}, /* 90deg */ - {-1.0f, 1.0f}, /* 135deg */ - {-1.414f, 0.0f}, /* 180deg */ - {-1.0f, -1.0f}, /* 225deg */ - { 0.0f, -1.414f}, /* 270deg */ - { 1.0f, -1.0f} /* 315deg */ - }; static const complexf_t zero = {0.0f, 0.0f}; + static const complexf_t constellation[8] = #endif + { + {FP_SCALE( 1.414f), FP_SCALE( 0.0f)}, /* 0deg */ + {FP_SCALE( 1.0f), FP_SCALE( 1.0f)}, /* 45deg */ + {FP_SCALE( 0.0f), FP_SCALE( 1.414f)}, /* 90deg */ + {FP_SCALE(-1.0f), FP_SCALE( 1.0f)}, /* 135deg */ + {FP_SCALE(-1.414f), FP_SCALE( 0.0f)}, /* 180deg */ + {FP_SCALE(-1.0f), FP_SCALE(-1.0f)}, /* 225deg */ + {FP_SCALE( 0.0f), FP_SCALE(-1.414f)}, /* 270deg */ + {FP_SCALE( 1.0f), FP_SCALE(-1.0f)} /* 315deg */ + }; int bits; if (s->in_training) @@ -247,13 +239,16 @@ static complexf_t getbaud(v27ter_tx_state_t *s) SPAN_DECLARE_NONSTD(int) v27ter_tx(v27ter_tx_state_t *s, int16_t amp[], int len) { #if defined(SPANDSP_USE_FIXED_POINT) - complexi_t x; - complexi_t z; + complexi16_t v; + complexi32_t x; + complexi32_t z; + int16_t iamp; #else + complexf_t v; complexf_t x; complexf_t z; + float famp; #endif - int i; int sample; if (s->training_step >= V27TER_TRAINING_SHUTDOWN_END) @@ -271,37 +266,30 @@ SPAN_DECLARE_NONSTD(int) v27ter_tx(v27ter_tx_state_t *s, int16_t amp[], int len) if (++s->baud_phase >= 5) { s->baud_phase -= 5; - s->rrc_filter[s->rrc_filter_step] = - s->rrc_filter[s->rrc_filter_step + V27TER_TX_FILTER_STEPS] = getbaud(s); + v = getbaud(s);; + s->rrc_filter_re[s->rrc_filter_step] = v.re; + s->rrc_filter_im[s->rrc_filter_step] = v.im; if (++s->rrc_filter_step >= V27TER_TX_FILTER_STEPS) s->rrc_filter_step = 0; } - /* Root raised cosine pulse shaping at baseband */ #if defined(SPANDSP_USE_FIXED_POINT) - x = complex_seti(0, 0); - for (i = 0; i < V27TER_TX_FILTER_STEPS; i++) - { - x.re += (int32_t) tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].re; - x.im += (int32_t) tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].im; - } + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodi16(s->rrc_filter_re, tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step) >> (10 + 4); + x.im = vec_circular_dot_prodi16(s->rrc_filter_im, tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step) >> (10 + 4); /* Now create and modulate the carrier */ - x.re >>= 14; - x.im >>= 14; - z = dds_complexi(&(s->carrier_phase), s->carrier_phase_rate); + z = dds_complexi32(&s->carrier_phase, s->carrier_phase_rate); + iamp = ((int32_t) x.re*z.re - x.im*z.im) >> 15; /* Don't bother saturating. We should never clip. */ - i = (x.re*z.re - x.im*z.im) >> 15; - amp[sample] = (int16_t) ((i*s->gain_4800) >> 15); + amp[sample] = (int16_t) (((int32_t) iamp*s->gain_4800) >> 11); #else - x = complex_setf(0.0f, 0.0f); - for (i = 0; i < V27TER_TX_FILTER_STEPS; i++) - { - x.re += tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].re; - x.im += tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].im; - } + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodf(s->rrc_filter_re, tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step); + x.im = vec_circular_dot_prodf(s->rrc_filter_im, tx_pulseshaper_4800[TX_PULSESHAPER_4800_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step); /* Now create and modulate the carrier */ - z = dds_complexf(&(s->carrier_phase), s->carrier_phase_rate); + z = dds_complexf(&s->carrier_phase, s->carrier_phase_rate); + famp = x.re*z.re - x.im*z.im; /* Don't bother saturating. We should never clip. */ - amp[sample] = (int16_t) lfastrintf((x.re*z.re - x.im*z.im)*s->gain_4800); + amp[sample] = (int16_t) lfastrintf(famp*s->gain_4800); #endif } } @@ -312,37 +300,30 @@ SPAN_DECLARE_NONSTD(int) v27ter_tx(v27ter_tx_state_t *s, int16_t amp[], int len) if ((s->baud_phase += 3) >= 20) { s->baud_phase -= 20; - s->rrc_filter[s->rrc_filter_step] = - s->rrc_filter[s->rrc_filter_step + V27TER_TX_FILTER_STEPS] = getbaud(s); + v = getbaud(s); + s->rrc_filter_re[s->rrc_filter_step] = v.re; + s->rrc_filter_im[s->rrc_filter_step] = v.im; if (++s->rrc_filter_step >= V27TER_TX_FILTER_STEPS) s->rrc_filter_step = 0; } - /* Root raised cosine pulse shaping at baseband */ #if defined(SPANDSP_USE_FIXED_POINT) - x = complex_seti(0, 0); - for (i = 0; i < V27TER_TX_FILTER_STEPS; i++) - { - x.re += (int32_t) tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].re; - x.im += (int32_t) tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].im; - } + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodi16(s->rrc_filter_re, tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step) >> (10 + 4); + x.im = vec_circular_dot_prodi16(s->rrc_filter_im, tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step) >> (10 + 4); /* Now create and modulate the carrier */ - x.re >>= 14; - x.im >>= 14; - z = dds_complexi(&(s->carrier_phase), s->carrier_phase_rate); + z = dds_complexi32(&s->carrier_phase, s->carrier_phase_rate); + iamp = ((int32_t) x.re*z.re - x.im*z.im) >> 15; /* Don't bother saturating. We should never clip. */ - i = (x.re*z.re - x.im*z.im) >> 15; - amp[sample] = (int16_t) ((i*s->gain_2400) >> 15); + amp[sample] = (int16_t) (((int32_t) iamp*s->gain_2400) >> 11); #else - x = complex_setf(0.0f, 0.0f); - for (i = 0; i < V27TER_TX_FILTER_STEPS; i++) - { - x.re += tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].re; - x.im += tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].im; - } + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodf(s->rrc_filter_re, tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step); + x.im = vec_circular_dot_prodf(s->rrc_filter_im, tx_pulseshaper_2400[TX_PULSESHAPER_2400_COEFF_SETS - 1 - s->baud_phase], V27TER_TX_FILTER_STEPS, s->rrc_filter_step); /* Now create and modulate the carrier */ - z = dds_complexf(&(s->carrier_phase), s->carrier_phase_rate); + z = dds_complexf(&s->carrier_phase, s->carrier_phase_rate); + famp = x.re*z.re - x.im*z.im; /* Don't bother saturating. We should never clip. */ - amp[sample] = (int16_t) lfastrintf((x.re*z.re - x.im*z.im)*s->gain_2400); + amp[sample] = (int16_t) lfastrintf(famp*s->gain_2400); #endif } } @@ -352,15 +333,15 @@ SPAN_DECLARE_NONSTD(int) v27ter_tx(v27ter_tx_state_t *s, int16_t amp[], int len) SPAN_DECLARE(void) v27ter_tx_power(v27ter_tx_state_t *s, float power) { - float l; + float gain; - l = powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*32768.0f; + gain = powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*32768.0f; #if defined(SPANDSP_USE_FIXED_POINT) - s->gain_2400 = 16.0f*1.024f*(32767.0f/28828.51f)*l/TX_PULSESHAPER_2400_GAIN; - s->gain_4800 = 16.0f*1.024f*(32767.0f/28828.46f)*l/TX_PULSESHAPER_4800_GAIN; + s->gain_2400 = (int16_t) (gain/TX_PULSESHAPER_2400_GAIN); + s->gain_4800 = (int16_t) (gain/TX_PULSESHAPER_4800_GAIN); #else - s->gain_2400 = l/TX_PULSESHAPER_2400_GAIN; - s->gain_4800 = l/TX_PULSESHAPER_4800_GAIN; + s->gain_2400 = gain/TX_PULSESHAPER_2400_GAIN; + s->gain_4800 = gain/TX_PULSESHAPER_4800_GAIN; #endif } /*- End of function --------------------------------------------------------*/ @@ -393,9 +374,11 @@ SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep) return -1; s->bit_rate = bit_rate; #if defined(SPANDSP_USE_FIXED_POINT) - cvec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + vec_zeroi16(s->rrc_filter_re, sizeof(s->rrc_filter_re)/sizeof(s->rrc_filter_re[0])); + vec_zeroi16(s->rrc_filter_im, sizeof(s->rrc_filter_im)/sizeof(s->rrc_filter_im[0])); #else - cvec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + vec_zerof(s->rrc_filter_re, sizeof(s->rrc_filter_re)/sizeof(s->rrc_filter_re[0])); + vec_zerof(s->rrc_filter_im, sizeof(s->rrc_filter_im)/sizeof(s->rrc_filter_im[0])); #endif s->rrc_filter_step = 0; s->scramble_reg = 0x3C; diff --git a/libs/spandsp/src/v29rx.c b/libs/spandsp/src/v29rx.c index cfc60aeabb..a8a1ed9c94 100644 --- a/libs/spandsp/src/v29rx.c +++ b/libs/spandsp/src/v29rx.c @@ -63,10 +63,15 @@ #include "spandsp/private/logging.h" #include "spandsp/private/v29rx.h" -#include "v29tx_constellation_maps.h" #if defined(SPANDSP_USE_FIXED_POINT) +#define FP_SCALE FP_Q_4_12 +#define FP_FACTOR 4096 +#define FP_SHIFT_FACTOR 12 +#include "v29tx_constellation_maps.h" #include "v29rx_fixed_rrc.h" #else +#define FP_SCALE(x) (x) +#include "v29tx_constellation_maps.h" #include "v29rx_floating_rrc.h" #endif @@ -77,11 +82,6 @@ /*! The adaption rate coefficient for the equalizer */ #define EQUALIZER_DELTA 0.21f -#if defined(SPANDSP_USE_FIXED_POINT) -#define FP_FACTOR 4096 -#define FP_SHIFT_FACTOR 12 -#endif - /* Segments of the training sequence */ /*! The length of training segment 2, in symbols */ #define V29_TRAINING_SEG_2_LEN 128 @@ -136,13 +136,13 @@ static const uint8_t space_map_9600[20][20] = #define ALPHA 0.99f #if defined(SPANDSP_USE_FIXED_POINT) -#define SYNC_LOW_BAND_EDGE_COEFF_0 ((int)(FP_FACTOR*(2.0f*ALPHA*COS_LOW_BAND_EDGE))) -#define SYNC_LOW_BAND_EDGE_COEFF_1 ((int)(FP_FACTOR*(-ALPHA*ALPHA))) -#define SYNC_LOW_BAND_EDGE_COEFF_2 ((int)(FP_FACTOR*(-ALPHA*SIN_LOW_BAND_EDGE))) -#define SYNC_HIGH_BAND_EDGE_COEFF_0 ((int)(FP_FACTOR*(2.0f*ALPHA*COS_HIGH_BAND_EDGE))) -#define SYNC_HIGH_BAND_EDGE_COEFF_1 ((int)(FP_FACTOR*(-ALPHA*ALPHA))) -#define SYNC_HIGH_BAND_EDGE_COEFF_2 ((int)(FP_FACTOR*(-ALPHA*SIN_HIGH_BAND_EDGE))) -#define SYNC_MIXED_EDGES_COEFF_3 ((int)(FP_FACTOR*(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE)))) +#define SYNC_LOW_BAND_EDGE_COEFF_0 FP_Q_6_10(2.0f*ALPHA*COS_LOW_BAND_EDGE) +#define SYNC_LOW_BAND_EDGE_COEFF_1 FP_Q_6_10(-ALPHA*ALPHA) +#define SYNC_LOW_BAND_EDGE_COEFF_2 FP_Q_6_10(-ALPHA*SIN_LOW_BAND_EDGE) +#define SYNC_HIGH_BAND_EDGE_COEFF_0 FP_Q_6_10(2.0f*ALPHA*COS_HIGH_BAND_EDGE) +#define SYNC_HIGH_BAND_EDGE_COEFF_1 FP_Q_6_10(-ALPHA*ALPHA) +#define SYNC_HIGH_BAND_EDGE_COEFF_2 FP_Q_6_10(-ALPHA*SIN_HIGH_BAND_EDGE) +#define SYNC_MIXED_EDGES_COEFF_3 FP_Q_6_10(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE)) #else #define SYNC_LOW_BAND_EDGE_COEFF_0 (2.0f*ALPHA*COS_LOW_BAND_EDGE) #define SYNC_LOW_BAND_EDGE_COEFF_1 (-ALPHA*ALPHA) @@ -230,7 +230,7 @@ static void equalizer_reset(v29_rx_state_t *s) { /* Start with an equalizer based on everything being perfect */ #if defined(SPANDSP_USE_FIXED_POINT) - static const complexi16_t x = {3*FP_FACTOR, 0*FP_FACTOR}; + static const complexi16_t x = {FP_SCALE(3.0f), FP_SCALE(0.0f)}; cvec_zeroi16(s->eq_coeff, V29_EQUALIZER_LEN); s->eq_coeff[V29_EQUALIZER_PRE_LEN] = x; @@ -250,25 +250,9 @@ static void equalizer_reset(v29_rx_state_t *s) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINT) -static __inline__ complexi16_t complex_mul_q4_12(const complexi16_t *x, const complexi16_t *y) -{ - complexi16_t z; - - z.re = ((int32_t) x->re*(int32_t) y->re - (int32_t) x->im*(int32_t) y->im) >> FP_SHIFT_FACTOR; - z.im = ((int32_t) x->re*(int32_t) y->im + (int32_t) x->im*(int32_t) y->re) >> FP_SHIFT_FACTOR; - return z; -} -/*- End of function --------------------------------------------------------*/ -#endif - #if defined(SPANDSP_USE_FIXED_POINT) static __inline__ complexi16_t equalizer_get(v29_rx_state_t *s) -#else -static __inline__ complexf_t equalizer_get(v29_rx_state_t *s) -#endif { -#if defined(SPANDSP_USE_FIXED_POINT) complexi32_t zz; complexi16_t z; @@ -277,11 +261,14 @@ static __inline__ complexf_t equalizer_get(v29_rx_state_t *s) z.re = zz.re >> FP_SHIFT_FACTOR; z.im = zz.im >> FP_SHIFT_FACTOR; return z; +} #else +static __inline__ complexf_t equalizer_get(v29_rx_state_t *s) +{ /* Get the next equalized value. */ return cvec_circular_dot_prodf(s->eq_buf, s->eq_coeff, V29_EQUALIZER_LEN, s->eq_step); -#endif } +#endif /*- End of function --------------------------------------------------------*/ #if defined(SPANDSP_USE_FIXED_POINT) @@ -290,10 +277,9 @@ static void tune_equalizer(v29_rx_state_t *s, const complexi16_t *z, const compl complexi16_t err; /* Find the x and y mismatch from the exact constellation position. */ - err.re = target->re*FP_FACTOR - z->re; - err.im = target->im*FP_FACTOR - z->im; - err.re = ((int32_t) err.re*(int32_t) s->eq_delta) >> 15; - err.im = ((int32_t) err.im*(int32_t) s->eq_delta) >> 15; + err = complex_subi16(target, z); + err.re = ((int32_t) err.re*s->eq_delta) >> 15; + err.im = ((int32_t) err.im*s->eq_delta) >> 15; cvec_circular_lmsi16(s->eq_buf, s->eq_coeff, V29_EQUALIZER_LEN, s->eq_step, &err); } #else @@ -365,8 +351,11 @@ static __inline__ void track_carrier(v29_rx_state_t *s, const complexf_t *z, con different amplitudes of the various target positions scale things. This isn't all bad, as the angular error for the larger amplitude constellation points is probably a more reliable indicator, and we are weighting it as such. */ +#if defined(SPANDSP_USE_FIXED_POINT) + error = (((int32_t) z->im*target->re) >> FP_SHIFT_FACTOR) - (((int32_t) z->re*target->im) >> FP_SHIFT_FACTOR); +#else error = z->im*target->re - z->re*target->im; - +#endif /* Use a proportional-integral approach to tracking the carrier. The PI parameters are coarser at first, until we get precisely on target. Then, the filter will be damped more to keep us on target. */ @@ -562,18 +551,19 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) 0, 3, 0, 2 }; - complexf_t zz; #if defined(SPANDSP_USE_FIXED_POINT) - complexf_t z1; + uint16_t ip; complexi16_t z; + complexi16_t z16; const complexi16_t *target; static const complexi16_t zero = {0, 0}; #else + float p; complexf_t z; + complexf_t zz; const complexf_t *target; static const complexf_t zero = {0.0f, 0.0f}; #endif - float p; int bit; int i; int j; @@ -671,17 +661,15 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) } /* Make a step shift in the phase, to pull it into line. We need to rotate the equalizer buffer, as well as the carrier phase, for this to play out nicely. */ - p = angle*2.0f*3.14159f/(65536.0f*65536.0f); #if defined(SPANDSP_USE_FIXED_POINT) - zz = complex_setf(cosf(p), -sinf(p)); + ip = angle >> 16; + span_log(&s->logging, SPAN_LOG_FLOW, "Spin by %d\n", ip); + z16 = complex_seti16(fixed_cos(ip), -fixed_sin(ip)); for (i = 0; i < V29_EQUALIZER_LEN; i++) - { - z1 = complex_setf(s->eq_buf[i].re, s->eq_buf[i].im); - z1 = complex_mulf(&z1, &zz); - s->eq_buf[i].re = z1.re; - s->eq_buf[i].im = z1.im; - } + s->eq_buf[i] = complex_mul_q1_15(&s->eq_buf[i], &z16); #else + p = angle*2.0f*3.14159f/(65536.0f*65536.0f); + span_log(&s->logging, SPAN_LOG_FLOW, "Spin by %.5f rads\n", p); zz = complex_setf(cosf(p), -sinf(p)); for (i = 0; i < V29_EQUALIZER_LEN; i++) s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz); @@ -743,23 +731,26 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) tune_equalizer(s, &z, target); /* Measure the training error */ #if defined(SPANDSP_USE_FIXED_POINT) - z1.re = z.re/(float) FP_FACTOR; - z1.im = z.im/(float) FP_FACTOR; - zz.re = target->re; - zz.im = target->im; - zz = complex_subf(&z1, &zz); - s->training_error += powerf(&zz); + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); #else zz = complex_subf(&z, target); s->training_error += powerf(&zz); #endif if (++s->training_count >= V29_TRAINING_SEG_3_LEN) { +#if defined(SPANDSP_USE_FIXED_POINT) + span_log(&s->logging, SPAN_LOG_FLOW, "Constellation mismatch %d\n", s->training_error); + if (s->training_error < 48*2*FP_FACTOR*FP_FACTOR) + { + s->training_error = 0; +#else span_log(&s->logging, SPAN_LOG_FLOW, "Constellation mismatch %f\n", s->training_error); if (s->training_error < 48.0f*2.0f) { - s->training_count = 0; s->training_error = 0.0f; +#endif + s->training_count = 0; s->constellation_state = 0; s->training_stage = TRAINING_STAGE_TEST_ONES; } @@ -785,22 +776,26 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) target = &v29_9600_constellation[s->constellation_state]; /* Measure the training error */ #if defined(SPANDSP_USE_FIXED_POINT) - z1.re = z.re/(float) FP_FACTOR; - z1.im = z.im/(float) FP_FACTOR; - zz.re = target->re; - zz.im = target->im; - zz = complex_subf(&z1, &zz); - s->training_error += powerf(&zz); + z16 = complex_subi16(&z, target); + s->training_error += poweri16(&z16); #else zz = complex_subf(&z, target); s->training_error += powerf(&zz); #endif if (++s->training_count >= V29_TRAINING_SEG_4_LEN) { +#if defined(SPANDSP_USE_FIXED_POINT) + if (s->training_error < 48*FP_FACTOR*FP_FACTOR) +#else if (s->training_error < 48.0f) +#endif { /* We are up and running */ +#if defined(SPANDSP_USE_FIXED_POINT) + span_log(&s->logging, SPAN_LOG_FLOW, "Training succeeded at %dbps (constellation mismatch %d)\n", s->bit_rate, s->training_error); +#else span_log(&s->logging, SPAN_LOG_FLOW, "Training succeeded at %dbps (constellation mismatch %f)\n", s->bit_rate, s->training_error); +#endif report_status_change(s, SIG_STATUS_TRAINING_SUCCEEDED); /* Apply some lag to the carrier off condition, to ensure the last few bits get pushed through the processing. */ @@ -812,12 +807,12 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) } else { - /* Training has failed */ - span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %f)\n", s->training_error); - /* Park this modem */ + /* Training has failed. Park this modem */ #if defined(SPANDSP_USE_FIXED_POINT) + span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %d)\n", s->training_error); s->agc_scaling_save = 0; #else + span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %f)\n", s->training_error); s->agc_scaling_save = 0.0f; #endif s->training_stage = TRAINING_STAGE_PARKED; @@ -833,17 +828,7 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) break; } if (s->qam_report) - { -#if defined(SPANDSP_USE_FIXED_POINT) - z1.re = z.re/(float) FP_FACTOR; - z1.im = z.im/(float) FP_FACTOR; - zz.re = target->re; - zz.im = target->im; - s->qam_report(s->qam_user_data, &z1, &zz, s->constellation_state); -#else s->qam_report(s->qam_user_data, &z, target, s->constellation_state); -#endif - } } /*- End of function --------------------------------------------------------*/ @@ -860,7 +845,7 @@ static __inline__ int signal_detect(v29_rx_state_t *s, int16_t amp) /* There could be overflow here, but it isn't a problem in practice */ diff = x - s->last_sample; s->last_sample = x; - power = power_meter_update(&(s->power), diff); + power = power_meter_update(&s->power, diff); #if defined(IAXMODEM_STUFF) /* Quick power drop fudge */ diff = abs(diff); @@ -868,7 +853,7 @@ static __inline__ int signal_detect(v29_rx_state_t *s, int16_t amp) { if (++s->low_samples > 120) { - power_meter_init(&(s->power), 4); + power_meter_init(&s->power, 4); s->high_sample = 0; s->low_samples = 0; } @@ -957,21 +942,20 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) else if (step > RX_PULSESHAPER_COEFF_SETS - 1) step = RX_PULSESHAPER_COEFF_SETS - 1; #if defined(SPANDSP_USE_FIXED_POINT) - v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V29_RX_FILTER_STEPS, s->rrc_filter_step); - sample.re = (v*s->agc_scaling) >> 15; + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V29_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.re = (v*s->agc_scaling) >> 10; #else v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_re[step], V29_RX_FILTER_STEPS, s->rrc_filter_step); sample.re = v*s->agc_scaling; #endif - /* Symbol timing synchronisation band edge filters */ #if defined(SPANDSP_USE_FIXED_POINT) /* Low Nyquist band edge filter */ - v = ((s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0) >> FP_SHIFT_FACTOR) + ((s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1) >> FP_SHIFT_FACTOR) + sample.re; + v = ((s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0) >> 10) + ((s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1) >> 10) + sample.re; s->symbol_sync_low[1] = s->symbol_sync_low[0]; s->symbol_sync_low[0] = v; /* High Nyquist band edge filter */ - v = ((s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0) >> FP_SHIFT_FACTOR) + ((s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1) >> FP_SHIFT_FACTOR) + sample.re; + v = ((s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0) >> 10) + ((s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1) >> 10) + sample.re; s->symbol_sync_high[1] = s->symbol_sync_high[0]; s->symbol_sync_high[0] = v; #else @@ -991,10 +975,10 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) /* Only AGC until we have locked down the setting. */ #if defined(SPANDSP_USE_FIXED_POINT) if (s->agc_scaling_save == 0) - s->agc_scaling = (float) FP_FACTOR*32768.0f*(1.0f/RX_PULSESHAPER_GAIN)*5.0f*0.25f/sqrtf(power); + s->agc_scaling = saturate16(((int32_t) (1024.0f*FP_FACTOR*1.25f))/fixed_sqrt32(power)); #else if (s->agc_scaling_save == 0.0f) - s->agc_scaling = (1.0f/RX_PULSESHAPER_GAIN)*5.0f*0.25f/sqrtf(power); + s->agc_scaling = (1.0f/RX_PULSESHAPER_GAIN)*1.25f/sqrtf(power); #endif /* Pulse shape while still at the carrier frequency, using a quadrature pair of filters. This results in a properly bandpass filtered complex @@ -1002,11 +986,11 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) No further filtering, to remove mixer harmonics, is needed. */ s->eq_put_step += RX_PULSESHAPER_COEFF_SETS*10/(3*2); #if defined(SPANDSP_USE_FIXED_POINT) - v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V29_RX_FILTER_STEPS, s->rrc_filter_step); - sample.im = (v*s->agc_scaling) >> 15; + v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V29_RX_FILTER_STEPS, s->rrc_filter_step) >> 15; + sample.im = (v*s->agc_scaling) >> 10; z = dds_lookup_complexi16(s->carrier_phase); - zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15; - zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15; + zz.re = ((int32_t) sample.re*z.re - (int32_t) sample.im*z.im) >> 15; + zz.im = ((int32_t) -sample.re*z.im - (int32_t) sample.im*z.re) >> 15; #else v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_im[step], V29_RX_FILTER_STEPS, s->rrc_filter_step); sample.im = v*s->agc_scaling; @@ -1115,7 +1099,7 @@ SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) s->carrier_phase = 0; - power_meter_init(&(s->power), 4); + power_meter_init(&s->power, 4); s->constellation_state = 0; @@ -1131,10 +1115,10 @@ SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) equalizer_reset(s); #if defined(SPANDSP_USE_FIXED_POINT) s->agc_scaling_save = 0; - s->agc_scaling = (float) FP_FACTOR*32768.0f*0.0017f/RX_PULSESHAPER_GAIN; + s->agc_scaling = (float) (1024.0f*FP_FACTOR)*1.25f/735.0f; #else s->agc_scaling_save = 0.0f; - s->agc_scaling = 0.0017f/RX_PULSESHAPER_GAIN; + s->agc_scaling = (1.0f/RX_PULSESHAPER_GAIN)*1.25f/735.0f; #endif } #if defined(SPANDSP_USE_FIXED_POINT) @@ -1168,7 +1152,6 @@ SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) s->baud_half = 0; s->total_baud_timing_correction = 0; - return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v29tx.c b/libs/spandsp/src/v29tx.c index 10007a93fb..7604ae4ac1 100644 --- a/libs/spandsp/src/v29tx.c +++ b/libs/spandsp/src/v29tx.c @@ -205,13 +205,16 @@ static __inline__ complexf_t getbaud(v29_tx_state_t *s) SPAN_DECLARE_NONSTD(int) v29_tx(v29_tx_state_t *s, int16_t amp[], int len) { #if defined(SPANDSP_USE_FIXED_POINT) - complexi_t x; - complexi_t z; + complexi16_t v; + complexi32_t x; + complexi32_t z; + int16_t iamp; #else + complexf_t v; complexf_t x; complexf_t z; + float famp; #endif - int i; int sample; if (s->training_step >= V29_TRAINING_SHUTDOWN_END) @@ -224,37 +227,30 @@ SPAN_DECLARE_NONSTD(int) v29_tx(v29_tx_state_t *s, int16_t amp[], int len) if ((s->baud_phase += 3) >= 10) { s->baud_phase -= 10; - s->rrc_filter[s->rrc_filter_step] = - s->rrc_filter[s->rrc_filter_step + V29_TX_FILTER_STEPS] = getbaud(s); + v = getbaud(s); + s->rrc_filter_re[s->rrc_filter_step] = v.re; + s->rrc_filter_im[s->rrc_filter_step] = v.im; if (++s->rrc_filter_step >= V29_TX_FILTER_STEPS) s->rrc_filter_step = 0; } - /* Root raised cosine pulse shaping at baseband */ #if defined(SPANDSP_USE_FIXED_POINT) - x = complex_seti(0, 0); - for (i = 0; i < V29_TX_FILTER_STEPS; i++) - { - x.re += (int32_t) tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].re; - x.im += (int32_t) tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*(int32_t) s->rrc_filter[i + s->rrc_filter_step].im; - } + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodi16(s->rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V29_TX_FILTER_STEPS, s->rrc_filter_step) >> 4; + x.im = vec_circular_dot_prodi16(s->rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V29_TX_FILTER_STEPS, s->rrc_filter_step) >> 4; /* Now create and modulate the carrier */ - x.re >>= 4; - x.im >>= 4; - z = dds_complexi(&(s->carrier_phase), s->carrier_phase_rate); + z = dds_complexi32(&s->carrier_phase, s->carrier_phase_rate); + iamp = ((int32_t) x.re*z.re - x.im*z.im) >> 15; /* Don't bother saturating. We should never clip. */ - i = (x.re*z.re - x.im*z.im) >> 15; - amp[sample] = (int16_t) ((i*s->gain) >> 15); + amp[sample] = (int16_t) (((int32_t) iamp*s->gain) >> 11); #else - x = complex_setf(0.0f, 0.0f); - for (i = 0; i < V29_TX_FILTER_STEPS; i++) - { - x.re += tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].re; - x.im += tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase][i]*s->rrc_filter[i + s->rrc_filter_step].im; - } + /* Root raised cosine pulse shaping at baseband */ + x.re = vec_circular_dot_prodf(s->rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V29_TX_FILTER_STEPS, s->rrc_filter_step); + x.im = vec_circular_dot_prodf(s->rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->baud_phase], V29_TX_FILTER_STEPS, s->rrc_filter_step); /* Now create and modulate the carrier */ - z = dds_complexf(&(s->carrier_phase), s->carrier_phase_rate); + z = dds_complexf(&s->carrier_phase, s->carrier_phase_rate); + famp = x.re*z.re - x.im*z.im; /* Don't bother saturating. We should never clip. */ - amp[sample] = (int16_t) lfastrintf((x.re*z.re - x.im*z.im)*s->gain); + amp[sample] = (int16_t) lfastrintf(famp*s->gain); #endif } return sample; @@ -267,13 +263,13 @@ static void set_working_gain(v29_tx_state_t *s) switch (s->bit_rate) { case 9600: - s->gain = 0.387f*s->base_gain*16.0f*32767.0f/30672.52f; + s->gain = ((int32_t) FP_Q_4_12(0.387f)*s->base_gain) >> 12; break; case 7200: - s->gain = 0.605f*s->base_gain*16.0f*32767.0f/30672.52f; + s->gain = ((int32_t) FP_Q_4_12(0.605f)*s->base_gain) >> 12; break; case 4800: - s->gain = 0.470f*s->base_gain*16.0f*32767.0f/30672.52f; + s->gain = ((int32_t) FP_Q_4_12(0.470f)*s->base_gain) >> 12; break; default: break; @@ -299,10 +295,17 @@ static void set_working_gain(v29_tx_state_t *s) SPAN_DECLARE(void) v29_tx_power(v29_tx_state_t *s, float power) { + float gain; + /* The constellation does not maintain constant average power as we change bit rates. We need to scale the gain we get here by a bit rate specific scaling factor each time we restart the modem. */ - s->base_gain = powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*32768.0f/TX_PULSESHAPER_GAIN; + gain = powf(10.0f, (power - DBM0_MAX_POWER)/20.0f)*32768.0f/TX_PULSESHAPER_GAIN; +#if defined(SPANDSP_USE_FIXED_POINT) + s->base_gain = (int16_t) gain; +#else + s->base_gain = gain; +#endif set_working_gain(s); } /*- End of function --------------------------------------------------------*/ @@ -349,9 +352,11 @@ SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep) return -1; } #if defined(SPANDSP_USE_FIXED_POINT) - cvec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + vec_zeroi16(s->rrc_filter_re, sizeof(s->rrc_filter_re)/sizeof(s->rrc_filter_re[0])); + vec_zeroi16(s->rrc_filter_im, sizeof(s->rrc_filter_im)/sizeof(s->rrc_filter_im[0])); #else - cvec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0])); + vec_zerof(s->rrc_filter_re, sizeof(s->rrc_filter_re)/sizeof(s->rrc_filter_re[0])); + vec_zerof(s->rrc_filter_im, sizeof(s->rrc_filter_im)/sizeof(s->rrc_filter_im[0])); #endif s->rrc_filter_step = 0; s->scramble_reg = 0; diff --git a/libs/spandsp/src/v29tx_constellation_maps.h b/libs/spandsp/src/v29tx_constellation_maps.h index 01da53e71f..f141b336bb 100644 --- a/libs/spandsp/src/v29tx_constellation_maps.h +++ b/libs/spandsp/src/v29tx_constellation_maps.h @@ -24,18 +24,26 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#if !defined(FP_SCALE) +#if defined(SPANDSP_USE_FIXED_POINT) +#define FP_SCALE(x) ((int16_t) x) +#else +#define FP_SCALE(x) (x) +#endif +#endif + #if defined(SPANDSP_USE_FIXED_POINT) static const complexi16_t v29_abab_constellation[6] = #else static const complexf_t v29_abab_constellation[6] = #endif { - { 3, -3}, /* 315deg high 9600 */ - {-3, 0}, /* 180deg low */ - { 1, -1}, /* 315deg low 7200 */ - {-3, 0}, /* 180deg low */ - { 0, -3}, /* 270deg low 4800 */ - {-3, 0} /* 180deg low */ + {FP_SCALE( 3.0f), FP_SCALE(-3.0f)}, /* 315deg high 9600 */ + {FP_SCALE(-3.0f), FP_SCALE( 0.0f)}, /* 180deg low */ + {FP_SCALE( 1.0f), FP_SCALE(-1.0f)}, /* 315deg low 7200 */ + {FP_SCALE(-3.0f), FP_SCALE( 0.0f)}, /* 180deg low */ + {FP_SCALE( 0.0f), FP_SCALE(-3.0f)}, /* 270deg low 4800 */ + {FP_SCALE(-3.0f), FP_SCALE( 0.0f)} /* 180deg low */ }; #if defined(SPANDSP_USE_FIXED_POINT) @@ -44,12 +52,12 @@ static const complexi16_t v29_cdcd_constellation[6] = static const complexf_t v29_cdcd_constellation[6] = #endif { - { 3, 0}, /* 0deg low 9600 */ - {-3, 3}, /* 135deg high */ - { 3, 0}, /* 0deg low 7200 */ - {-1, 1}, /* 135deg low */ - { 3, 0}, /* 0deg low 4800 */ - { 0, 3} /* 90deg low */ + {FP_SCALE( 3.0f), FP_SCALE( 0.0f)}, /* 0deg low 9600 */ + {FP_SCALE(-3.0f), FP_SCALE( 3.0f)}, /* 135deg high */ + {FP_SCALE( 3.0f), FP_SCALE( 0.0f)}, /* 0deg low 7200 */ + {FP_SCALE(-1.0f), FP_SCALE( 1.0f)}, /* 135deg low */ + {FP_SCALE( 3.0f), FP_SCALE( 0.0f)}, /* 0deg low 4800 */ + {FP_SCALE( 0.0f), FP_SCALE( 3.0f)} /* 90deg low */ }; #if defined(SPANDSP_USE_FIXED_POINT) @@ -58,22 +66,22 @@ static const complexi16_t v29_9600_constellation[16] = static const complexf_t v29_9600_constellation[16] = #endif { - { 3, 0}, /* 0deg low */ - { 1, 1}, /* 45deg low */ - { 0, 3}, /* 90deg low */ - {-1, 1}, /* 135deg low */ - {-3, 0}, /* 180deg low */ - {-1, -1}, /* 225deg low */ - { 0, -3}, /* 270deg low */ - { 1, -1}, /* 315deg low */ - { 5, 0}, /* 0deg high */ - { 3, 3}, /* 45deg high */ - { 0, 5}, /* 90deg high */ - {-3, 3}, /* 135deg high */ - {-5, 0}, /* 180deg high */ - {-3, -3}, /* 225deg high */ - { 0, -5}, /* 270deg high */ - { 3, -3} /* 315deg high */ + {FP_SCALE( 3.0f), FP_SCALE( 0.0f)}, /* 0deg low */ + {FP_SCALE( 1.0f), FP_SCALE( 1.0f)}, /* 45deg low */ + {FP_SCALE( 0.0f), FP_SCALE( 3.0f)}, /* 90deg low */ + {FP_SCALE(-1.0f), FP_SCALE( 1.0f)}, /* 135deg low */ + {FP_SCALE(-3.0f), FP_SCALE( 0.0f)}, /* 180deg low */ + {FP_SCALE(-1.0f), FP_SCALE(-1.0f)}, /* 225deg low */ + {FP_SCALE( 0.0f), FP_SCALE(-3.0f)}, /* 270deg low */ + {FP_SCALE( 1.0f), FP_SCALE(-1.0f)}, /* 315deg low */ + {FP_SCALE( 5.0f), FP_SCALE( 0.0f)}, /* 0deg high */ + {FP_SCALE( 3.0f), FP_SCALE( 3.0f)}, /* 45deg high */ + {FP_SCALE( 0.0f), FP_SCALE( 5.0f)}, /* 90deg high */ + {FP_SCALE(-3.0f), FP_SCALE( 3.0f)}, /* 135deg high */ + {FP_SCALE(-5.0f), FP_SCALE( 0.0f)}, /* 180deg high */ + {FP_SCALE(-3.0f), FP_SCALE(-3.0f)}, /* 225deg high */ + {FP_SCALE( 0.0f), FP_SCALE(-5.0f)}, /* 270deg high */ + {FP_SCALE( 3.0f), FP_SCALE(-3.0f)} /* 315deg high */ }; /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/v8.c b/libs/spandsp/src/v8.c index 78f2904bac..37ef368a44 100644 --- a/libs/spandsp/src/v8.c +++ b/libs/spandsp/src/v8.c @@ -63,7 +63,8 @@ enum { - V8_WAIT_1S, + V8_WAIT_1S, /* Start point when sending CI */ + V8_AWAIT_ANSAM, /* Start point when sending initial silence */ V8_CI_ON, V8_CI_OFF, V8_HEARD_ANSAM, @@ -100,7 +101,8 @@ enum enum { V8_CI_SYNC_OCTET = 0x00, - V8_CM_JM_SYNC_OCTET = 0xE0 + V8_CM_JM_SYNC_OCTET = 0xE0, + V8_V92_SYNC_OCTET = 0x55 }; SPAN_DECLARE(const char *) v8_call_function_to_str(int call_function) @@ -124,7 +126,7 @@ SPAN_DECLARE(const char *) v8_call_function_to_str(int call_function) case V8_CALL_FUNCTION_EXTENSION: return "Call function is in extension octet"; } - return "???"; + return "Unknown call function"; } /*- End of function --------------------------------------------------------*/ @@ -199,7 +201,7 @@ SPAN_DECLARE(const char *) v8_pstn_access_to_str(int pstn_access) case V8_PSTN_ACCESS_DCE_ON_DIGITAL | V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR | V8_PSTN_ACCESS_CALL_DCE_CELLULAR: return "DCE on digital, and answering and calling modems on cellular"; } - return "???"; + return "PSTN access unknown"; } /*- End of function --------------------------------------------------------*/ @@ -235,7 +237,7 @@ SPAN_DECLARE(const char *) v8_pcm_modem_availability_to_str(int pcm_modem_availa case V8_PSTN_PCM_MODEM_V91 | V8_PSTN_PCM_MODEM_V90_V92_DIGITAL | V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE: return "V.91 and V.90/V.92 digital/analogue available"; } - return "???"; + return "PCM availability unknown"; } /*- End of function --------------------------------------------------------*/ @@ -374,6 +376,7 @@ static const uint8_t *process_pstn_access(v8_state_t *s, const uint8_t *p) static const uint8_t *process_non_standard_facilities(v8_state_t *s, const uint8_t *p) { + /* TODO: This is wrong */ s->result.nsf = (*p >> 5) & 0x07; span_log(&s->logging, SPAN_LOG_FLOW, "%s\n", v8_nsf_to_str(s->result.nsf)); return p; @@ -754,7 +757,24 @@ SPAN_DECLARE_NONSTD(int) v8_tx(v8_state_t *s, int16_t *amp, int max_len) } /*- End of function --------------------------------------------------------*/ -static void v8_send_ci(v8_state_t *s) +static void send_v92(v8_state_t *s) +{ + int i; + + if (s->result.v92 >= 0) + { + /* Send 2 V.92 packets */ + for (i = 0; i < 2; i++) + { + v8_put_preamble(s); + v8_put_byte(s, V8_V92_SYNC_OCTET); + v8_put_byte(s, s->result.v92); + } + } +} +/*- End of function --------------------------------------------------------*/ + +static void send_ci(v8_state_t *s) { int i; @@ -809,7 +829,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) if ((s->negotiation_timer -= len) > 0) break; fsk_tx_restart(&s->v21tx, &preset_fsk_specs[FSK_V21CH1]); - v8_send_ci(s); + send_ci(s); s->state = V8_CI_ON; s->fsk_tx_on = TRUE; break; @@ -850,12 +870,18 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) { /* Try again */ fsk_tx_restart(&s->v21tx, &preset_fsk_specs[FSK_V21CH1]); - v8_send_ci(s); + send_ci(s); s->state = V8_CI_ON; s->fsk_tx_on = TRUE; } } break; + case V8_AWAIT_ANSAM: + residual_samples = modem_connect_tones_rx(&s->ansam_rx, amp, len); + /* Check if an ANSam or ANSam/ tone has been detected */ + if ((tone = modem_connect_tones_rx_get(&s->ansam_rx)) != MODEM_CONNECT_TONES_NONE) + handle_modem_connect_tone(s, tone); + break; case V8_HEARD_ANSAM: /* We have heard the ANSam or ANSam/ signal, but we still need to wait for the end of the Te timeout period to comply with the spec. */ @@ -864,6 +890,7 @@ SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len) v8_decode_init(s); s->negotiation_timer = ms_to_samples(5000); fsk_tx_restart(&s->v21tx, &preset_fsk_specs[FSK_V21CH1]); + send_v92(s); send_cm_jm(s); s->state = V8_CM_ON; s->fsk_tx_on = TRUE; @@ -1014,9 +1041,16 @@ SPAN_DECLARE(int) v8_restart(v8_state_t *s, int calling_party, v8_parms_t *parms s->calling_party = calling_party; if (s->calling_party) { - s->state = V8_WAIT_1S; - s->negotiation_timer = ms_to_samples(1000); - s->ci_count = 0; + if (s->result.send_ci) + { + s->state = V8_WAIT_1S; + s->negotiation_timer = ms_to_samples(1000); + s->ci_count = 0; + } + else + { + s->state = V8_AWAIT_ANSAM; + } modem_connect_tones_rx_init(&s->ansam_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL); fsk_tx_init(&s->v21tx, &preset_fsk_specs[FSK_V21CH1], get_bit, s); } @@ -1039,7 +1073,7 @@ SPAN_DECLARE(int) v8_restart(v8_state_t *s, int calling_party, v8_parms_t *parms SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s, int calling_party, v8_parms_t *parms, - v8_result_handler_t *result_handler, + v8_result_handler_t result_handler, void *user_data) { if (s == NULL) diff --git a/libs/spandsp/src/vector_float.c b/libs/spandsp/src/vector_float.c index 7b5a7efa69..dd09e449e1 100644 --- a/libs/spandsp/src/vector_float.c +++ b/libs/spandsp/src/vector_float.c @@ -107,8 +107,8 @@ SPAN_DECLARE(void) vec_copyl(long double z[], const long double x[], int n) SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n) { int i; - static const uint32_t mask = 0x80000000; - static const float *fmask = (float *) &mask; + static const uint32_t mask = 0x80000000; + static const float *fmask = (float *) &mask; __m128 n1; __m128 n2; @@ -118,7 +118,7 @@ SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n) for (i -= 4; i >= 0; i -= 4) { n1 = _mm_loadu_ps(x + i); - n1 = _mm_xor_ps(n1, n2); + n1 = _mm_xor_ps(n1, n2); _mm_storeu_ps(z + i, n1); } } diff --git a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c index d7cefc6778..dda0d0fbc7 100644 --- a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c +++ b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c @@ -543,7 +543,6 @@ static int create_error_page(TIFF *tiff_file) int main(int argc, char *argv[]) { - int row; TIFF *tiff_file; struct tm *tm; time_t now; @@ -553,24 +552,13 @@ int main(int argc, char *argv[]) int i; int image_length; int opt; - int compression; - compression = T4_COMPRESSION_ITU_T6; photo_metric = PHOTOMETRIC_MINISWHITE; fill_order = FILLORDER_LSB2MSB; - while ((opt = getopt(argc, argv, "126ir")) != -1) + while ((opt = getopt(argc, argv, "ir")) != -1) { switch (opt) { - case '1': - compression = T4_COMPRESSION_ITU_T4_1D; - break; - case '2': - compression = T4_COMPRESSION_ITU_T4_2D; - break; - case '6': - compression = T4_COMPRESSION_ITU_T6; - break; case 'i': photo_metric = PHOTOMETRIC_MINISBLACK; break; @@ -637,7 +625,6 @@ int main(int argc, char *argv[]) image_length = sequence[i].length; /* Write the image first.... */ - row = 0; switch (sequence[i].type) { case 0: diff --git a/libs/spandsp/tests/Makefile.am b/libs/spandsp/tests/Makefile.am index 401e8f41e6..8a0503fe62 100644 --- a/libs/spandsp/tests/Makefile.am +++ b/libs/spandsp/tests/Makefile.am @@ -50,7 +50,8 @@ INCLUDES = -I$(top_builddir)/src -I$(top_builddir)/spandsp-sim -DDATADIR="\"$(pk LIBDIR = -L$(top_builddir)/src -noinst_PROGRAMS = adsi_tests \ +noinst_PROGRAMS = ademco_contactid_tests \ + adsi_tests \ async_tests \ at_interpreter_tests \ awgn_tests \ @@ -108,6 +109,10 @@ noinst_PROGRAMS = adsi_tests \ t38_decode \ t38_non_ecm_buffer_tests \ t4_tests \ + t4_t6_tests \ + t42_tests \ + t81_t82_arith_coding_tests \ + t85_tests \ time_scale_tests \ timezone_tests \ tone_detect_tests \ @@ -122,8 +127,7 @@ noinst_PROGRAMS = adsi_tests \ v42bis_tests \ v8_tests \ vector_float_tests \ - vector_int_tests \ - tsb85_tests + vector_int_tests noinst_HEADERS = echo_monitor.h \ fax_tester.h \ @@ -134,6 +138,9 @@ noinst_HEADERS = echo_monitor.h \ pcap_parse.h \ udptl.h +ademco_contactid_tests_SOURCES = ademco_contactid_tests.c +ademco_contactid_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp + adsi_tests_SOURCES = adsi_tests.c adsi_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp @@ -308,6 +315,18 @@ t38_non_ecm_buffer_tests_LDADD = $(LIBDIR) -lspandsp t4_tests_SOURCES = t4_tests.c t4_tests_LDADD = $(LIBDIR) -lspandsp +t4_t6_tests_SOURCES = t4_t6_tests.c +t4_t6_tests_LDADD = $(LIBDIR) -lspandsp + +t42_tests_SOURCES = t42_tests.c +t42_tests_LDADD = $(LIBDIR) -lspandsp + +t81_t82_arith_coding_tests_SOURCES = t81_t82_arith_coding_tests.c +t81_t82_arith_coding_tests_LDADD = $(LIBDIR) -lspandsp + +t85_tests_SOURCES = t85_tests.c +t85_tests_LDADD = $(LIBDIR) -lspandsp + time_scale_tests_SOURCES = time_scale_tests.c time_scale_tests_LDADD = $(LIBDIR) -lspandsp diff --git a/libs/spandsp/tests/ademco_contactid_tests.c b/libs/spandsp/tests/ademco_contactid_tests.c new file mode 100644 index 0000000000..c8e87f1fb8 --- /dev/null +++ b/libs/spandsp/tests/ademco_contactid_tests.c @@ -0,0 +1,391 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * ademco_contactid.c - Ademco ContactID alarm protocol + * + * Written by Steve Underwood + * + * Copyright (C) 2012 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \page ademco_contactid_tests_page Ademco ContactID tests +\section ademco_contactid_tests_page_sec_1 What does it do? + +\section ademco_contactid_tests_page_sec_2 How does it work? +*/ + +/* Enable the following definition to enable direct probing into the FAX structures */ +//#define WITH_SPANDSP_INTERNALS + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +//#if defined(WITH_SPANDSP_INTERNALS) +//#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES +//#endif + +#include "spandsp.h" +#include "spandsp-sim.h" + +#define SAMPLES_PER_CHUNK 160 + +#define OUTPUT_FILE_NAME "ademco_contactid.wav" + +#define MITEL_DIR "../test-data/mitel/" +#define BELLCORE_DIR "../test-data/bellcore/" + +const char *bellcore_files[] = +{ + MITEL_DIR "mitel-cm7291-talkoff.wav", + BELLCORE_DIR "tr-tsy-00763-1.wav", + BELLCORE_DIR "tr-tsy-00763-2.wav", + BELLCORE_DIR "tr-tsy-00763-3.wav", + BELLCORE_DIR "tr-tsy-00763-4.wav", + BELLCORE_DIR "tr-tsy-00763-5.wav", + BELLCORE_DIR "tr-tsy-00763-6.wav", + "" +}; + +static const ademco_contactid_report_t reports[] = +{ + {0x1234, 0x18, 0x1, 0x131, 0x1, 0x15}, + {0x1234, 0x18, 0x3, 0x131, 0x1, 0x15}, + {0x1234, 0x18, 0x1, 0x401, 0x2, 0x3}, + {0x1234, 0x18, 0x3, 0x401, 0x3, 0x5}, + {0x1234, 0x56, 0x7, 0x890, 0xBC, 0xDEF}, + {0x1234, 0x56, 0x7, 0x89A, 0xBC, 0xDEF} /* This one is bad, as it contains a hex 'A' */ +}; +static int reports_entry = 0; + +static int16_t amp[1000000]; + +int tx_callback_reported = FALSE; +int rx_callback_reported = FALSE; + +int sending_complete = FALSE; + +SNDFILE *outhandle; + +static void talkoff_tx_callback(void *user_data, int tone, int level, int duration) +{ + printf("Ademco sender report %d\n", tone); + tx_callback_reported = TRUE; +} + +static int mitel_cm7291_side_2_and_bellcore_tests(void) +{ + int j; + SNDFILE *inhandle; + int frames; + ademco_contactid_sender_state_t *sender; + logging_state_t *logging; + + if ((sender = ademco_contactid_sender_init(NULL, talkoff_tx_callback, NULL)) == NULL) + return -1; + logging = ademco_contactid_sender_get_logging_state(sender); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "Ademco-tx"); + + tx_callback_reported = FALSE; + + /* The remainder of the Mitel tape is the talk-off test */ + /* Here we use the Bellcore test tapes (much tougher), in six + files - 1 from each side of the original 3 cassette tapes */ + /* Bellcore say you should get no more than 470 false detections with + a good receiver. Dialogic claim 20. Of course, we can do better than + that, eh? */ + printf("Talk-off test\n"); + for (j = 0; bellcore_files[j][0]; j++) + { + if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL) + { + printf(" Cannot open speech file '%s'\n", bellcore_files[j]); + return -1; + } + while ((frames = sf_readf_short(inhandle, amp, SAMPLE_RATE))) + { + ademco_contactid_sender_rx(sender, amp, frames); + } + if (sf_close_telephony(inhandle)) + { + printf(" Cannot close speech file '%s'\n", bellcore_files[j]); + return -1; + } + printf(" File %d gave %d false hits.\n", j + 1, 0); + } + if (tx_callback_reported) + { + printf(" Failed\n"); + return -1; + } + printf(" Passed\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static void rx_callback(void *user_data, const ademco_contactid_report_t *report) +{ + printf("Ademco Contact ID message:\n"); + printf(" Account %X\n", report->acct); + printf(" Message type %X\n", report->mt); + printf(" Qualifier %X\n", report->q); + printf(" Event %X\n", report->xyz); + printf(" Group/partition %X\n", report->gg); + printf(" User/Zone information %X\n", report->ccc); + if (memcmp(&reports[reports_entry], report, sizeof (*report))) + { + printf("Report mismatch\n"); + exit(2); + } + rx_callback_reported = TRUE; +} +/*- End of function --------------------------------------------------------*/ + +static void tx_callback(void *user_data, int tone, int level, int duration) +{ + ademco_contactid_sender_state_t *sender; + + sender = (ademco_contactid_sender_state_t *) user_data; + printf("Ademco sender report %d\n", tone); + switch (tone) + { + case -1: + /* We are connected and ready to send */ + ademco_contactid_sender_put(sender, &reports[reports_entry]); + break; + case 1: + /* We have succeeded in sending, and are ready to send another message. */ + if (++reports_entry < 5) + ademco_contactid_sender_put(sender, &reports[reports_entry]); + else + sending_complete = TRUE; + break; + case 0: + /* Sending failed after retries */ + sending_complete = TRUE; + break; + } +} +/*- End of function --------------------------------------------------------*/ + +static int end_to_end_tests(void) +{ + ademco_contactid_receiver_state_t *receiver; + ademco_contactid_sender_state_t *sender; + logging_state_t *logging; + codec_munge_state_t *munge; + awgn_state_t noise_source; + int16_t amp[SAMPLES_PER_CHUNK]; + int16_t sndfile_buf[2*SAMPLES_PER_CHUNK]; + int samples; + int i; + int j; + + printf("End to end tests\n"); + + if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL) + { + fprintf(stderr, " Cannot open audio file '%s'\n", OUTPUT_FILE_NAME); + exit(2); + } + + if ((receiver = ademco_contactid_receiver_init(NULL, rx_callback, NULL)) == NULL) + return -1; + ademco_contactid_receiver_set_realtime_callback(receiver, rx_callback, receiver); + + logging = ademco_contactid_receiver_get_logging_state(receiver); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "Ademco-rx"); + + if ((sender = ademco_contactid_sender_init(NULL, tx_callback, NULL)) == NULL) + return -1; + ademco_contactid_sender_set_realtime_callback(sender, tx_callback, sender); + logging = ademco_contactid_sender_get_logging_state(sender); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "Ademco-tx"); + + awgn_init_dbm0(&noise_source, 1234567, -50); + munge = codec_munge_init(MUNGE_CODEC_ALAW, 0); + + sending_complete = FALSE; + rx_callback_reported = FALSE; + + for (i = 0; i < 1000; i++) + { + samples = ademco_contactid_sender_tx(sender, amp, SAMPLES_PER_CHUNK); + for (j = samples; j < SAMPLES_PER_CHUNK; j++) + amp[j] = 0; + for (j = 0; j < SAMPLES_PER_CHUNK; j++) + sndfile_buf[2*j] = amp[j]; + /* There is no point in impairing this signal. It is just DTMF tones, which + will work as wel as the DTMF detector beign used. */ + ademco_contactid_receiver_rx(receiver, amp, SAMPLES_PER_CHUNK); + + samples = ademco_contactid_receiver_tx(receiver, amp, SAMPLES_PER_CHUNK); + for (j = samples; j < SAMPLES_PER_CHUNK; j++) + amp[j] = 0; + + /* We add AWGN and codec impairments to the signal, to stress the tone detector. */ + codec_munge(munge, amp, SAMPLES_PER_CHUNK); + for (j = 0; j < SAMPLES_PER_CHUNK; j++) + { + sndfile_buf[2*j + 1] = amp[j]; + /* Add noise to the tones */ + amp[j] += awgn(&noise_source); + } + codec_munge(munge, amp, SAMPLES_PER_CHUNK); + ademco_contactid_sender_rx(sender, amp, SAMPLES_PER_CHUNK); + + sf_writef_short(outhandle, sndfile_buf, SAMPLES_PER_CHUNK); + } + if (!rx_callback_reported) + { + fprintf(stderr, " Report not received\n"); + return -1; + } + + if (sf_close_telephony(outhandle)) + { + fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME); + return -1; + } + printf(" Passed\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int encode_decode_tests(void) +{ + char buf[100]; + ademco_contactid_receiver_state_t *receiver; + ademco_contactid_sender_state_t *sender; + logging_state_t *logging; + ademco_contactid_report_t result; + int i; + + printf("Encode and decode tests\n"); + + if ((receiver = ademco_contactid_receiver_init(NULL, NULL, NULL)) == NULL) + return 2; + logging = ademco_contactid_receiver_get_logging_state(receiver); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "Ademco-rx"); + + if ((sender = ademco_contactid_sender_init(NULL, NULL, NULL)) == NULL) + return 2; + logging = ademco_contactid_sender_get_logging_state(sender); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "Ademco-tx"); + + for (i = 0; i < 5; i++) + { + if (encode_msg(buf, &reports[i]) < 0) + { + printf("Bad encode message\n"); + return -1; + } + printf("'%s'\n", buf); + if (decode_msg(&result, buf)) + { + printf("Bad decode message\n"); + return -1; + } + ademco_contactid_receiver_log_msg(receiver, &result); + printf("\n"); + if (memcmp(&reports[i], &result, sizeof(result))) + { + printf("Received message does not match the one sent\n"); + return -1; + } + } + + if (encode_msg(buf, &reports[5]) >= 0) + { + printf("Incorrectly good message\n"); + return -1; + } + printf("'%s'\n", buf); + printf("\n"); + printf(" Passed\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static void decode_file(const char *file) +{ + //SPAN_DECLARE(int) decode_msg(ademco_contactid_report_t *report, const char buf[]) +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + int opt; + const char *decode_test_file; + + decode_test_file = NULL; + while ((opt = getopt(argc, argv, "d:")) != -1) + { + switch (opt) + { + case 'd': + decode_test_file = optarg; + break; + default: + //usage(); + exit(2); + break; + } + } + + if (decode_test_file) + { + decode_file(decode_test_file); + return 0; + } + + if (encode_decode_tests()) + { + printf("Tests failed\n"); + return 2; + } + + if (mitel_cm7291_side_2_and_bellcore_tests()) + { + printf("Tests failed\n"); + return 2; + } + + if (end_to_end_tests()) + { + printf("Tests failed\n"); + return 2; + } + + printf("Tests passed\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/async_tests.c b/libs/spandsp/tests/async_tests.c index 98f3211e58..64639ecee4 100644 --- a/libs/spandsp/tests/async_tests.c +++ b/libs/spandsp/tests/async_tests.c @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/at_interpreter_tests.c b/libs/spandsp/tests/at_interpreter_tests.c index 84cb4b4f92..c69724876f 100644 --- a/libs/spandsp/tests/at_interpreter_tests.c +++ b/libs/spandsp/tests/at_interpreter_tests.c @@ -563,7 +563,7 @@ int main(int argc, char *argv[]) exit(2); } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/awgn_tests.c b/libs/spandsp/tests/awgn_tests.c index 556e01664f..9f4b8891cc 100644 --- a/libs/spandsp/tests/awgn_tests.c +++ b/libs/spandsp/tests/awgn_tests.c @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/bell_mf_tx_tests.c b/libs/spandsp/tests/bell_mf_tx_tests.c index c5b5867155..4e577d9c4e 100644 --- a/libs/spandsp/tests/bell_mf_tx_tests.c +++ b/libs/spandsp/tests/bell_mf_tx_tests.c @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) exit (2); } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/bert_tests.c b/libs/spandsp/tests/bert_tests.c index fce1eec16f..05fd6c10a8 100644 --- a/libs/spandsp/tests/bert_tests.c +++ b/libs/spandsp/tests/bert_tests.c @@ -451,7 +451,7 @@ int main(int argc, char *argv[]) } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/crc_tests.c b/libs/spandsp/tests/crc_tests.c index 2227d28805..a2d77ec3c4 100644 --- a/libs/spandsp/tests/crc_tests.c +++ b/libs/spandsp/tests/crc_tests.c @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) } } printf("Test passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/dc_restore_tests.c b/libs/spandsp/tests/dc_restore_tests.c index e18e16f1aa..a85638a233 100644 --- a/libs/spandsp/tests/dc_restore_tests.c +++ b/libs/spandsp/tests/dc_restore_tests.c @@ -89,7 +89,7 @@ int main (int argc, char *argv[]) exit(2); } printf("Test passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/dds_tests.c b/libs/spandsp/tests/dds_tests.c index 8bd7713195..27095b6108 100644 --- a/libs/spandsp/tests/dds_tests.c +++ b/libs/spandsp/tests/dds_tests.c @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/dtmf_rx_tests.c b/libs/spandsp/tests/dtmf_rx_tests.c index e160bbf4ef..bd0d81e083 100644 --- a/libs/spandsp/tests/dtmf_rx_tests.c +++ b/libs/spandsp/tests/dtmf_rx_tests.c @@ -154,8 +154,8 @@ int callback_ok; int callback_roll; int step; -int max_forward_twist; -int max_reverse_twist; +float max_forward_twist; +float max_reverse_twist; int use_dialtone_filter = FALSE; @@ -325,8 +325,8 @@ static void mitel_cm7291_side_1_tests(void) logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); - if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) - dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) + dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99.0f); logging = dtmf_rx_get_logging_state(dtmf_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "DTMF-rx"); @@ -635,8 +635,8 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void) logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); - if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) - dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) + dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99.0f); logging = dtmf_rx_get_logging_state(dtmf_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "DTMF-rx"); @@ -706,8 +706,8 @@ static void dial_tone_tolerance_tests(void) logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); - if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) - dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) + dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99.0f); logging = dtmf_rx_get_logging_state(dtmf_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "DTMF-rx"); @@ -763,8 +763,8 @@ static void callback_function_tests(void) callback_ok = TRUE; callback_roll = 0; dtmf_state = dtmf_rx_init(NULL, digit_delivery, (void *) 0x12345678); - if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) - dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) + dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99.0f); logging = dtmf_rx_get_logging_state(dtmf_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "DTMF-rx"); @@ -793,8 +793,8 @@ static void callback_function_tests(void) callback_roll = 0; dtmf_rx_init(dtmf_state, NULL, NULL); dtmf_rx_set_realtime_callback(dtmf_state, digit_status, (void *) 0x12345678); - if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) - dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) + dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99.0f); logging = dtmf_rx_get_logging_state(dtmf_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "DTMF-rx"); @@ -836,8 +836,8 @@ static void decode_test(const char *test_file) logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); - if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) - dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + if (use_dialtone_filter || max_forward_twist >= 0.0f || max_reverse_twist >= 0.0f) + dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99.0f); logging = dtmf_rx_get_logging_state(dtmf_state); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_tag(logging, "DTMF-rx"); @@ -874,8 +874,8 @@ int main(int argc, char *argv[]) use_dialtone_filter = FALSE; channel_codec = MUNGE_CODEC_NONE; decode_test_file = NULL; - max_forward_twist = -1; - max_reverse_twist = -1; + max_forward_twist = -1.0f; + max_reverse_twist = -1.0f; while ((opt = getopt(argc, argv, "c:d:F:fR:")) != -1) { switch (opt) @@ -887,13 +887,13 @@ int main(int argc, char *argv[]) decode_test_file = optarg; break; case 'F': - max_forward_twist = atoi(optarg); + max_forward_twist = atof(optarg); break; case 'f': use_dialtone_filter = TRUE; break; case 'R': - max_reverse_twist = atoi(optarg); + max_reverse_twist = atof(optarg); break; default: //usage(); diff --git a/libs/spandsp/tests/dtmf_tx_tests.c b/libs/spandsp/tests/dtmf_tx_tests.c index 43c8522c31..c108f38ed5 100644 --- a/libs/spandsp/tests/dtmf_tx_tests.c +++ b/libs/spandsp/tests/dtmf_tx_tests.c @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) exit(2); } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/echo_tests.c b/libs/spandsp/tests/echo_tests.c index 86b6cda961..4a94112df1 100644 --- a/libs/spandsp/tests/echo_tests.c +++ b/libs/spandsp/tests/echo_tests.c @@ -254,7 +254,7 @@ static level_measurement_device_t *level_measurement_device_create(int type) dev->factor = expf(-1.0f/((float) SAMPLE_RATE*0.035f)); dev->power = 0; dev->type = type; - return dev; + return dev; } /*- End of function --------------------------------------------------------*/ @@ -633,20 +633,20 @@ static int perform_test_sanity(void) int16_t tx; int16_t clean; int far_tx; - int16_t far_sound[SAMPLE_RATE]; + //int16_t far_sound[SAMPLE_RATE]; int16_t result_sound[64000]; int result_cur; int outframes; - int local_cur; - int far_cur; + //int local_cur; + //int far_cur; //int32_t coeffs[200][128]; //int coeff_index; print_test_title("Performing basic sanity test\n"); ctx = echo_can_init(TEST_EC_TAPS, 0); - local_cur = 0; - far_cur = 0; + //local_cur = 0; + //far_cur = 0; result_cur = 0; echo_can_flush(ctx); @@ -684,7 +684,7 @@ static int perform_test_sanity(void) far_tx = 0; } #else - far_sound[0] = 0; + //far_sound[0] = 0; far_tx = 0; #endif rx = channel_model(&chan_model, tx, far_tx); @@ -1720,7 +1720,7 @@ int main(int argc, char *argv[]) #endif printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/fax_decode.c b/libs/spandsp/tests/fax_decode.c index dd60fe9280..722f40681f 100644 --- a/libs/spandsp/tests/fax_decode.c +++ b/libs/spandsp/tests/fax_decode.c @@ -89,7 +89,7 @@ int decode_test = FALSE; int rx_bits = 0; t30_state_t t30_dummy; -t4_state_t t4_state; +t4_rx_state_t t4_rx_state; int t4_up = FALSE; hdlc_rx_state_t hdlcrx; @@ -291,12 +291,12 @@ static void t4_begin(void) int i; //printf("Begin T.4 - %d %d %d %d\n", line_encoding, x_resolution, y_resolution, image_width); - t4_rx_set_rx_encoding(&t4_state, line_encoding); - t4_rx_set_x_resolution(&t4_state, x_resolution); - t4_rx_set_y_resolution(&t4_state, y_resolution); - t4_rx_set_image_width(&t4_state, image_width); + t4_rx_set_rx_encoding(&t4_rx_state, line_encoding); + t4_rx_set_x_resolution(&t4_rx_state, x_resolution); + t4_rx_set_y_resolution(&t4_rx_state, y_resolution); + t4_rx_set_image_width(&t4_rx_state, image_width); - t4_rx_start_page(&t4_state); + t4_rx_start_page(&t4_rx_state); t4_up = TRUE; for (i = 0; i < 256; i++) @@ -316,13 +316,13 @@ static void t4_end(void) for (i = 0; i < 256; i++) { if (ecm_len[i] > 0) - t4_rx_put_chunk(&t4_state, ecm_data[i], ecm_len[i]); + t4_rx_put(&t4_rx_state, ecm_data[i], ecm_len[i]); fprintf(stderr, "%d", (ecm_len[i] <= 0) ? 0 : 1); } fprintf(stderr, "\n"); } - t4_rx_end_page(&t4_state); - t4_rx_get_transfer_statistics(&t4_state, &stats); + t4_rx_end_page(&t4_rx_state); + t4_rx_get_transfer_statistics(&t4_rx_state, &stats); fprintf(stderr, "Pages = %d\n", stats.pages_transferred); fprintf(stderr, "Image size = %dx%d\n", stats.width, stats.length); fprintf(stderr, "Image resolution = %dx%d\n", stats.x_resolution, stats.y_resolution); @@ -378,7 +378,7 @@ static void v17_put_bit(void *user_data, int bit) } else { - if (t4_rx_put_bit(&t4_state, bit)) + if (t4_rx_put_bit(&t4_rx_state, bit)) { t4_end(); fprintf(stderr, "End of page detected\n"); @@ -414,7 +414,7 @@ static void v29_put_bit(void *user_data, int bit) } else { - if (t4_rx_put_bit(&t4_state, bit)) + if (t4_rx_put_bit(&t4_rx_state, bit)) { t4_end(); fprintf(stderr, "End of page detected\n"); @@ -450,7 +450,7 @@ static void v27ter_put_bit(void *user_data, int bit) } else { - if (t4_rx_put_bit(&t4_state, bit)) + if (t4_rx_put_bit(&t4_rx_state, bit)) { t4_end(); fprintf(stderr, "End of page detected\n"); @@ -465,7 +465,8 @@ int main(int argc, char *argv[]) fsk_rx_state_t *fsk; v17_rx_state_t *v17; v29_rx_state_t *v29; - v27ter_rx_state_t *v27ter; + v27ter_rx_state_t *v27ter_4800; + v27ter_rx_state_t *v27ter_2400; int16_t amp[SAMPLES_PER_CHUNK]; SNDFILE *inhandle; SF_INFO info; @@ -504,11 +505,14 @@ int main(int argc, char *argv[]) v17 = v17_rx_init(NULL, 14400, v17_put_bit, NULL); v29 = v29_rx_init(NULL, 9600, v29_put_bit, NULL); //v29 = v29_rx_init(NULL, 7200, v29_put_bit, NULL); - v27ter = v27ter_rx_init(NULL, 4800, v27ter_put_bit, NULL); + v27ter_4800 = v27ter_rx_init(NULL, 4800, v27ter_put_bit, NULL); + v27ter_2400 = v27ter_rx_init(NULL, 2400, v27ter_put_bit, NULL); + fsk_rx_signal_cutoff(fsk, -45.5); v17_rx_signal_cutoff(v17, -45.5); v29_rx_signal_cutoff(v29, -45.5); - v27ter_rx_signal_cutoff(v27ter, -40.0); + v27ter_rx_signal_cutoff(v27ter_4800, -40.0); + v27ter_rx_signal_cutoff(v27ter_2400, -40.0); #if 1 logging = v17_rx_get_logging_state(v17); @@ -521,13 +525,18 @@ int main(int argc, char *argv[]) span_log_set_protocol(logging, "V.29"); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW); - logging = v27ter_rx_get_logging_state(v27ter); + logging = v27ter_rx_get_logging_state(v27ter_4800); span_log_init(logging, SPAN_LOG_FLOW, NULL); - span_log_set_protocol(logging, "V.27ter"); + span_log_set_protocol(logging, "V.27ter-4800"); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW); + + logging = v27ter_rx_get_logging_state(v27ter_2400); + span_log_init(logging, SPAN_LOG_FLOW, NULL); + span_log_set_protocol(logging, "V.27ter-2400"); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW); #endif - if (t4_rx_init(&t4_state, "fax_decode.tif", T4_COMPRESSION_ITU_T4_2D) == NULL) + if (t4_rx_init(&t4_rx_state, "fax_decode.tif", T4_COMPRESSION_ITU_T4_2D) == NULL) { fprintf(stderr, "Failed to init\n"); exit(0); @@ -541,16 +550,17 @@ int main(int argc, char *argv[]) fsk_rx(fsk, amp, len); v17_rx(v17, amp, len); v29_rx(v29, amp, len); - //v27ter_rx(v27ter, amp, len); + v27ter_rx(v27ter_4800, amp, len); + v27ter_rx(v27ter_2400, amp, len); } - t4_rx_release(&t4_state); + t4_rx_release(&t4_rx_state); if (sf_close(inhandle)) { fprintf(stderr, " Cannot close audio file '%s'\n", filename); exit(2); } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/fax_tester.c b/libs/spandsp/tests/fax_tester.c index 79e8a09ae8..57707aa1ea 100644 --- a/libs/spandsp/tests/fax_tester.c +++ b/libs/spandsp/tests/fax_tester.c @@ -86,15 +86,15 @@ static void front_end_step_complete(faxtester_state_t *s) void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags) { - hdlc_tx_flags(&(s->modems.hdlc_tx), flags); + hdlc_tx_flags(&s->modems.hdlc_tx, flags); } /*- End of function --------------------------------------------------------*/ void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok) { - hdlc_tx_frame(&(s->modems.hdlc_tx), msg, len); + hdlc_tx_frame(&s->modems.hdlc_tx, msg, len); if (!crc_ok) - hdlc_tx_corrupt_frame(&(s->modems.hdlc_tx)); + hdlc_tx_corrupt_frame(&s->modems.hdlc_tx); } /*- End of function --------------------------------------------------------*/ @@ -115,30 +115,24 @@ static void hdlc_underflow_handler(void *user_data) buf[2] = 0x06; buf[3] = s->image_ptr/s->ecm_frame_size; memcpy(buf + 4, &s->image_buffer[s->image_ptr], s->ecm_frame_size); - hdlc_tx_frame(&(s->modems.hdlc_tx), buf, 4 + s->ecm_frame_size); + hdlc_tx_frame(&s->modems.hdlc_tx, buf, 4 + s->ecm_frame_size); if (s->corrupt_crc >= 0 && s->corrupt_crc == s->image_ptr/s->ecm_frame_size) - hdlc_tx_corrupt_frame(&(s->modems.hdlc_tx)); + hdlc_tx_corrupt_frame(&s->modems.hdlc_tx); s->image_ptr += s->ecm_frame_size; return; } - else + /* The actual image is over. We are sending the final RCP frames. */ + if (s->image_bit_ptr > 2) { - /* The actual image is over. We are sending the final RCP frames. */ - if (s->image_bit_ptr > 2) - { - s->image_bit_ptr--; - buf[0] = 0xFF; - buf[1] = 0x03; - buf[2] = 0x86; - hdlc_tx_frame(&(s->modems.hdlc_tx), buf, 3); - return; - } - else - { - /* All done. */ - s->image_buffer = NULL; - } + s->image_bit_ptr--; + buf[0] = 0xFF; + buf[1] = 0x03; + buf[2] = 0x86; + hdlc_tx_frame(&s->modems.hdlc_tx, buf, 3); + return; } + /* All done. */ + s->image_buffer = NULL; } front_end_step_complete(s); } @@ -271,14 +265,11 @@ static void non_ecm_rx_status(void *user_data, int status) static void non_ecm_put_bit(void *user_data, int bit) { - faxtester_state_t *s; - if (bit < 0) { non_ecm_rx_status(user_data, bit); return; } - s = (faxtester_state_t *) user_data; } /*- End of function --------------------------------------------------------*/ @@ -325,20 +316,17 @@ static void hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok) static int v17_v21_rx(void *user_data, const int16_t amp[], int len) { - faxtester_state_t *t; fax_modems_state_t *s; - t = (faxtester_state_t *) user_data; - s = &t->modems; + s = (fax_modems_state_t *) user_data; v17_rx(&s->fast_modems.v17_rx, amp, len); fsk_rx(&s->v21_rx, amp, len); if (s->rx_trained) { /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); - s->rx_handler = (span_rx_handler_t *) &v17_rx; - s->rx_user_data = &s->fast_modems.v17_rx; + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &v17_rx, &s->fast_modems.v17_rx, NULL, NULL); } return 0; } @@ -346,20 +334,17 @@ static int v17_v21_rx(void *user_data, const int16_t amp[], int len) static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) { - faxtester_state_t *t; fax_modems_state_t *s; - t = (faxtester_state_t *) user_data; - s = &t->modems; + s = (fax_modems_state_t *) user_data; v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); fsk_rx(&s->v21_rx, amp, len); if (s->rx_trained) { /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); - s->rx_handler = (span_rx_handler_t *) &v27ter_rx; - s->rx_user_data = &s->fast_modems.v27ter_rx; + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &v27ter_rx, &s->fast_modems.v27ter_rx, NULL, NULL); } return 0; } @@ -367,20 +352,17 @@ static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) static int v29_v21_rx(void *user_data, const int16_t amp[], int len) { - faxtester_state_t *t; fax_modems_state_t *s; - t = (faxtester_state_t *) user_data; - s = &t->modems; + s = (fax_modems_state_t *) user_data; v29_rx(&s->fast_modems.v29_rx, amp, len); fsk_rx(&s->v21_rx, amp, len); if (s->rx_trained) { /* The fast modem has trained, so we no longer need to run the slow one in parallel. */ - span_log(&t->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); - s->rx_handler = (span_rx_handler_t *) &v29_rx; - s->rx_user_data = &s->fast_modems.v29_rx; + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &v29_rx, &s->fast_modems.v29_rx, NULL, NULL); } return 0; } @@ -391,7 +373,7 @@ int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len) int i; for (i = 0; i < len; i++) - amp[i] = dc_restore(&(s->modems.dc_restore), amp[i]); + amp[i] = dc_restore(&s->modems.dc_restore, amp[i]); s->modems.rx_handler(s->modems.rx_user_data, amp, len); timer_update(s, len); if (s->wait_for_silence) @@ -451,8 +433,6 @@ void faxtest_set_rx_silence(faxtester_state_t *s) void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc) { faxtester_state_t *s; - put_bit_func_t put_bit_func; - void *put_bit_user_data; fax_modems_state_t *t; int tone; @@ -463,63 +443,41 @@ void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_tr return; s->current_rx_type = type; if (use_hdlc) - { - put_bit_func = (put_bit_func_t) hdlc_rx_put_bit; - put_bit_user_data = (void *) &t->hdlc_rx; hdlc_rx_init(&t->hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, s); - } - else - { - put_bit_func = non_ecm_put_bit; - put_bit_user_data = (void *) s; - } switch (type) { case T30_MODEM_CED: case T30_MODEM_CNG: - if (type == T30_MODEM_CED) - tone = MODEM_CONNECT_TONES_FAX_CED; - else - tone = MODEM_CONNECT_TONES_FAX_CNG; + tone = (type == T30_MODEM_CED) ? MODEM_CONNECT_TONES_FAX_CED : MODEM_CONNECT_TONES_FAX_CNG; modem_connect_tones_rx_init(&t->connect_rx, tone, tone_detected, (void *) s); - t->rx_handler = (span_rx_handler_t *) &modem_connect_tones_rx; - t->rx_user_data = &t->connect_rx; + fax_modems_set_rx_handler(t, (span_rx_handler_t) &modem_connect_tones_rx, &t->connect_rx, NULL, NULL); s->tone_state = MODEM_CONNECT_TONES_NONE; break; case T30_MODEM_V21: if (s->flush_handler) s->flush_handler(s, s->flush_user_data, 3); - fsk_rx_init(&t->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data); - fsk_rx_signal_cutoff(&t->v21_rx, -45.5); - t->rx_handler = (span_rx_handler_t *) &fsk_rx; - t->rx_user_data = &t->v21_rx; + fax_modems_start_slow_modem(t, FAX_MODEM_V21_RX); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, NULL, NULL); break; case T30_MODEM_V27TER: - v27ter_rx_restart(&t->fast_modems.v27ter_rx, bit_rate, FALSE); - v27ter_rx_set_put_bit(&t->fast_modems.v27ter_rx, put_bit_func, put_bit_user_data); - t->rx_handler = (span_rx_handler_t *) &v27ter_v21_rx; - t->rx_user_data = s; + fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_RX, bit_rate, short_train, use_hdlc); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &v27ter_v21_rx, t, NULL, NULL); break; case T30_MODEM_V29: - v29_rx_restart(&t->fast_modems.v29_rx, bit_rate, FALSE); - v29_rx_set_put_bit(&t->fast_modems.v29_rx, put_bit_func, put_bit_user_data); - t->rx_handler = (span_rx_handler_t *) &v29_v21_rx; - t->rx_user_data = s; + fax_modems_start_fast_modem(t, FAX_MODEM_V29_RX, bit_rate, short_train, use_hdlc); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &v29_v21_rx, t, NULL, NULL); break; case T30_MODEM_V17: - v17_rx_restart(&t->fast_modems.v17_rx, bit_rate, short_train); - v17_rx_set_put_bit(&t->fast_modems.v17_rx, put_bit_func, put_bit_user_data); - t->rx_handler = (span_rx_handler_t *) &v17_v21_rx; - t->rx_user_data = s; + fax_modems_start_fast_modem(t, FAX_MODEM_V17_RX, bit_rate, short_train, use_hdlc); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &v17_v21_rx, t, NULL, NULL); break; case T30_MODEM_DONE: span_log(&s->logging, SPAN_LOG_FLOW, "FAX exchange complete\n"); default: - t->rx_handler = (span_rx_handler_t *) &span_dummy_rx; - t->rx_user_data = s; + fax_modems_set_rx_handler(t, (span_rx_handler_t) &span_dummy_rx, s, NULL, NULL); break; } } @@ -552,8 +510,7 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr { case T30_MODEM_PAUSE: silence_gen_alter(&t->silence_gen, ms_to_samples(short_train)); - t->tx_handler = (span_tx_handler_t *) &silence_gen; - t->tx_user_data = &t->silence_gen; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); s->transmit = TRUE; break; case T30_MODEM_CED: @@ -563,43 +520,38 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr else tone = MODEM_CONNECT_TONES_FAX_CNG; modem_connect_tones_tx_init(&t->connect_tx, tone); - t->tx_handler = (span_tx_handler_t *) &modem_connect_tones_tx; - t->tx_user_data = &t->connect_tx; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &modem_connect_tones_tx, &t->connect_tx); s->transmit = TRUE; break; case T30_MODEM_V21: - fsk_tx_init(&t->v21_tx, &preset_fsk_specs[FSK_V21CH2], get_bit_func, get_bit_user_data); + fax_modems_start_slow_modem(t, FAX_MODEM_V21_TX); fsk_tx_set_modem_status_handler(&t->v21_tx, modem_tx_status, (void *) s); - t->tx_handler = (span_tx_handler_t *) &fsk_tx; - t->tx_user_data = &t->v21_tx; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &fsk_tx, &t->v21_tx); s->transmit = TRUE; break; case T30_MODEM_V27TER: - v27ter_tx_restart(&t->fast_modems.v27ter_tx, bit_rate, t->use_tep); - v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, get_bit_func, get_bit_user_data); + fax_modems_set_get_bit(t, get_bit_func, get_bit_user_data); + fax_modems_start_fast_modem(t, FAX_MODEM_V27TER_TX, bit_rate, short_train, use_hdlc); v27ter_tx_set_modem_status_handler(&t->fast_modems.v27ter_tx, modem_tx_status, (void *) s); - t->tx_handler = (span_tx_handler_t *) &v27ter_tx; - t->tx_user_data = &t->fast_modems.v27ter_tx; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); /* For any fast modem, set 200ms of preamble flags */ hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); s->transmit = TRUE; break; case T30_MODEM_V29: - v29_tx_restart(&t->fast_modems.v29_tx, bit_rate, t->use_tep); - v29_tx_set_get_bit(&t->fast_modems.v29_tx, get_bit_func, get_bit_user_data); + fax_modems_set_get_bit(t, get_bit_func, get_bit_user_data); + fax_modems_start_fast_modem(t, FAX_MODEM_V29_TX, bit_rate, short_train, use_hdlc); v29_tx_set_modem_status_handler(&t->fast_modems.v29_tx, modem_tx_status, (void *) s); - t->tx_handler = (span_tx_handler_t *) &v29_tx; - t->tx_user_data = &t->fast_modems.v29_tx; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); /* For any fast modem, set 200ms of preamble flags */ hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); s->transmit = TRUE; break; case T30_MODEM_V17: - v17_tx_restart(&t->fast_modems.v17_tx, bit_rate, t->use_tep, short_train); - v17_tx_set_get_bit(&t->fast_modems.v17_tx, get_bit_func, get_bit_user_data); + fax_modems_set_get_bit(t, get_bit_func, get_bit_user_data); + fax_modems_start_fast_modem(t, FAX_MODEM_V17_TX, bit_rate, short_train, use_hdlc); v17_tx_set_modem_status_handler(&t->fast_modems.v17_tx, modem_tx_status, (void *) s); - t->tx_handler = (span_tx_handler_t *) &v17_tx; - t->tx_user_data = &t->fast_modems.v17_tx; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); /* For any fast modem, set 200ms of preamble flags */ hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); s->transmit = TRUE; @@ -609,8 +561,7 @@ void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_tr /* Fall through */ default: silence_gen_alter(&t->silence_gen, 0); - t->tx_handler = (span_tx_handler_t *) &silence_gen; - t->tx_user_data = &t->silence_gen; + fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); s->transmit = FALSE; break; } @@ -635,67 +586,31 @@ void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle) void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep) { - s->modems.use_tep = use_tep; + fax_modems_set_tep_mode(&s->modems, use_tep); } /*- End of function --------------------------------------------------------*/ -void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t *handler, void *user_data) +void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t handler, void *user_data) { s->real_time_frame_handler = handler; s->real_time_frame_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data) +void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t handler, void *user_data) { s->front_end_step_complete_handler = handler; s->front_end_step_complete_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data) +void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t handler, void *user_data) { s->front_end_step_timeout_handler = handler; s->front_end_step_timeout_user_data = user_data; } /*- End of function --------------------------------------------------------*/ -static void faxtester_fax_modems_init(fax_modems_state_t *s, int use_tep, void *user_data) -{ - s->use_tep = use_tep; - - hdlc_rx_init(&s->hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, user_data); - hdlc_tx_init(&s->hdlc_tx, FALSE, 2, FALSE, hdlc_underflow_handler, user_data); - 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); - fsk_rx_signal_cutoff(&s->v21_rx, -45.5); - fsk_tx_init(&s->v21_tx, &preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &s->hdlc_tx); - fsk_tx_set_modem_status_handler(&s->v21_tx, modem_tx_status, user_data); - v17_rx_init(&s->fast_modems.v17_rx, 14400, non_ecm_put_bit, user_data); - v17_tx_init(&s->fast_modems.v17_tx, 14400, s->use_tep, non_ecm_get_bit, user_data); - v17_tx_set_modem_status_handler(&s->fast_modems.v17_tx, modem_tx_status, user_data); - v29_rx_init(&s->fast_modems.v29_rx, 9600, non_ecm_put_bit, user_data); - v29_rx_signal_cutoff(&s->fast_modems.v29_rx, -45.5); - v29_tx_init(&s->fast_modems.v29_tx, 9600, s->use_tep, non_ecm_get_bit, user_data); - v29_tx_set_modem_status_handler(&s->fast_modems.v29_tx, modem_tx_status, user_data); - v27ter_rx_init(&s->fast_modems.v27ter_rx, 4800, non_ecm_put_bit, user_data); - v27ter_tx_init(&s->fast_modems.v27ter_tx, 4800, s->use_tep, non_ecm_get_bit, user_data); - v27ter_tx_set_modem_status_handler(&s->fast_modems.v27ter_tx, modem_tx_status, user_data); - silence_gen_init(&s->silence_gen, 0); - modem_connect_tones_tx_init(&s->connect_tx, MODEM_CONNECT_TONES_FAX_CNG); - modem_connect_tones_rx_init(&s->connect_rx, - MODEM_CONNECT_TONES_FAX_CNG, - tone_detected, - user_data); - dc_restore_init(&s->dc_restore); - - s->rx_signal_present = FALSE; - s->rx_handler = (span_rx_handler_t *) &span_dummy_rx; - s->rx_user_data = NULL; - s->tx_handler = (span_tx_handler_t *) &silence_gen; - s->tx_user_data = &s->silence_gen; -} -/*- End of function --------------------------------------------------------*/ - faxtester_state_t *faxtester_init(faxtester_state_t *s, int calling_party) { if (s == NULL) @@ -707,7 +622,16 @@ faxtester_state_t *faxtester_init(faxtester_state_t *s, int calling_party) memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "TST"); - faxtester_fax_modems_init(&s->modems, FALSE, s); + fax_modems_init(&s->modems, + FALSE, + NULL, + hdlc_underflow_handler, + non_ecm_put_bit, + t38_non_ecm_buffer_get_bit, + tone_detected, + s); + fax_modems_set_tep_mode(&s->modems, FALSE); + fax_modems_set_rx_active(&s->modems, TRUE); faxtester_set_timeout(s, -1); faxtester_set_tx_type(s, T30_MODEM_NONE, 0, FALSE, FALSE); @@ -728,7 +652,7 @@ int faxtester_free(faxtester_state_t *s) } /*- End of function --------------------------------------------------------*/ -void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t *handler, void *user_data) +void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t handler, void *user_data) { s->flush_handler = handler; s->flush_user_data = user_data; diff --git a/libs/spandsp/tests/fax_tester.h b/libs/spandsp/tests/fax_tester.h index 9735e0f2a5..3d64e2e6b7 100644 --- a/libs/spandsp/tests/fax_tester.h +++ b/libs/spandsp/tests/fax_tester.h @@ -37,7 +37,7 @@ typedef struct faxtester_state_s faxtester_state_t; -typedef void (faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which); +typedef void (*faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which); /*! FAX tester real time frame handler. @@ -48,13 +48,13 @@ typedef void (faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, \param msg The HDLC message. \param len The length of the message. */ -typedef void (faxtester_real_time_frame_handler_t)(faxtester_state_t *s, - void *user_data, - int direction, - const uint8_t *msg, - int len); +typedef void (*faxtester_real_time_frame_handler_t)(faxtester_state_t *s, + void *user_data, + int direction, + const uint8_t *msg, + int len); -typedef void (faxtester_front_end_step_complete_handler_t)(faxtester_state_t *s, void *user_data); +typedef void (*faxtester_front_end_step_complete_handler_t)(faxtester_state_t *s, void *user_data); /*! FAX tester descriptor. @@ -64,19 +64,19 @@ struct faxtester_state_s /*! \brief Pointer to our current step in the test. */ xmlNodePtr cur; - faxtester_flush_handler_t *flush_handler; + faxtester_flush_handler_t flush_handler; void *flush_user_data; /*! \brief A pointer to a callback routine to be called when frames are exchanged. */ - faxtester_real_time_frame_handler_t *real_time_frame_handler; + faxtester_real_time_frame_handler_t real_time_frame_handler; /*! \brief An opaque pointer supplied in real time frame callbacks. */ void *real_time_frame_user_data; - faxtester_front_end_step_complete_handler_t *front_end_step_complete_handler; + faxtester_front_end_step_complete_handler_t front_end_step_complete_handler; void *front_end_step_complete_user_data; - faxtester_front_end_step_complete_handler_t *front_end_step_timeout_handler; + faxtester_front_end_step_complete_handler_t front_end_step_timeout_handler; void *front_end_step_timeout_user_data; const uint8_t *image_buffer; @@ -149,7 +149,7 @@ void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags); void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok); -void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t *handler, void *user_data); +void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t handler, void *user_data); /*! Select whether silent audio will be sent when FAX transmit is idle. \brief Select whether silent audio will be sent when FAX transmit is idle. @@ -167,11 +167,11 @@ void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle); */ void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep); -void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t *handler, void *user_data); +void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t handler, void *user_data); -void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data); +void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t handler, void *user_data); -void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data); +void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t handler, void *user_data); void faxtester_set_timeout(faxtester_state_t *s, int timeout); diff --git a/libs/spandsp/tests/fax_tests.c b/libs/spandsp/tests/fax_tests.c index 2d92767533..7d6f445ad8 100644 --- a/libs/spandsp/tests/fax_tests.c +++ b/libs/spandsp/tests/fax_tests.c @@ -29,13 +29,15 @@ \section fax_tests_page_sec_1 What does it do? These tests exercise the following FAX to FAX paths: - +--Modems-+---------TDM/RTP---------+-Modems--+ - | \ / | - | \ / | -T.30 <---+ T.38 gateway T.38 gateway +--->T.30 - | \ / | - | \ / | - +---T.38--------+--UDPTL/RTP--+--------T.38---+ + +--Modems-+-----------TDM/RTP-----------+-Modems--+ + | \ / | + | \ / | +T.30 <---+ T.38 gateway T.38 gateway +--->T.30 + | \ / | + | \ / | + +---T.38---+----+----UDPTL/RTP----+----+---T.38---+ + \ / + +----------TCP----------+ T.30<->Modems<-------------------------TDM/RTP------------------------->Modems<->T.30 T.30<->Modems<-TDM/RTP->T.38 gateway<-UDPTL/RTP->T.38 gateway<-TDM/RTP->Modems<->T.30 @@ -863,10 +865,23 @@ int main(int argc, char *argv[]) | T30_SUPPORT_300_600_RESOLUTION | T30_SUPPORT_400_800_RESOLUTION | T30_SUPPORT_600_1200_RESOLUTION); - t30_set_ecm_capability(t30_state[i], use_ecm); if (use_ecm) - t30_set_supported_compressions(t30_state[i], T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); + { + t30_set_supported_compressions(t30_state[i], + T30_SUPPORT_T4_1D_COMPRESSION + | T30_SUPPORT_T4_2D_COMPRESSION + | T30_SUPPORT_T6_COMPRESSION + | T30_SUPPORT_T81_COMPRESSION + | T30_SUPPORT_T85_COMPRESSION + | T30_SUPPORT_T85_L0_COMPRESSION); + } + else + { + t30_set_supported_compressions(t30_state[i], + T30_SUPPORT_T4_1D_COMPRESSION + | T30_SUPPORT_T4_2D_COMPRESSION); + } t30_set_minimum_scan_line_time(t30_state[i], scan_line_time); if (mode[i] == T38_GATEWAY_FAX) @@ -1126,7 +1141,7 @@ int main(int argc, char *argv[]) exit(2); } printf("Tests passed\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/fax_tests.sh b/libs/spandsp/tests/fax_tests.sh index bd29f3bf34..e273968630 100755 --- a/libs/spandsp/tests/fax_tests.sh +++ b/libs/spandsp/tests/fax_tests.sh @@ -18,7 +18,7 @@ run_fax_test() { rm -f fax_tests_1.tif - echo -i ${FILE} ${OPTS} -i ${FILE} + echo ./fax_tests ${OPTS} -i ${FILE} ./fax_tests ${OPTS} -i ${FILE} >xyzzy 2>xyzzy2 RETVAL=$? if [ $RETVAL != 0 ] @@ -28,7 +28,7 @@ run_fax_test() fi # Now use tiffcmp to check the results. It will return non-zero if any page images differ. The -t # option means the normal differences in tags will be ignored. - tiffcmp -t ${FILE} fax_tests.tif #>/dev/null + tiffcmp -t ${FILE} fax_tests.tif >/dev/null RETVAL=$? if [ $RETVAL != 0 ] then @@ -142,3 +142,6 @@ do FILE="${ITUTESTS_DIR}/R1200_1200_A3.tif" run_fax_test done + +echo +echo All fax tests successfully completed diff --git a/libs/spandsp/tests/fax_utils.c b/libs/spandsp/tests/fax_utils.c index bd69917ef1..063f14b331 100644 --- a/libs/spandsp/tests/fax_utils.c +++ b/libs/spandsp/tests/fax_utils.c @@ -91,7 +91,7 @@ void fax_log_final_transfer_statistics(t30_state_t *s, const char *tag) t30_get_transfer_statistics(s, &t); printf("%s: Bit rate %d\n", tag, t.bit_rate); printf("%s: ECM %s\n", tag, (t.error_correcting_mode) ? "on" : "off"); - //printf("%s: RTP events %d. RTN events %d\n", tag, t.rtp_events, t.rtn_events); + printf("%s: RTP events %d. RTN events %d\n", tag, t.rtp_events, t.rtn_events); printf("%s: Tx pages %d, rx pages %d\n", tag, t.pages_tx, t.pages_rx); } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/fsk_tests.c b/libs/spandsp/tests/fsk_tests.c index 297322c09e..fa1da0df6f 100644 --- a/libs/spandsp/tests/fsk_tests.c +++ b/libs/spandsp/tests/fsk_tests.c @@ -525,7 +525,7 @@ int main(int argc, char *argv[]) exit(2); } } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/g168_tests.c b/libs/spandsp/tests/g168_tests.c index aaa233ba91..b1b8e776f4 100644 --- a/libs/spandsp/tests/g168_tests.c +++ b/libs/spandsp/tests/g168_tests.c @@ -316,7 +316,7 @@ int main(int argc, char *argv[]) printf("%d\n", css_c3[i]); signal_free(&local_css); signal_free(&far_css); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/g722_tests.c b/libs/spandsp/tests/g722_tests.c index c33d9e67b6..863ea3e63d 100644 --- a/libs/spandsp/tests/g722_tests.c +++ b/libs/spandsp/tests/g722_tests.c @@ -307,7 +307,7 @@ static void itu_compliance_tests(void) /* Get the upper reference output data */ len_comp_upper = get_test_vector(decode_test_files[file + 4], itu_ref_upper, MAX_TEST_VECTOR_LEN); - if (len_data != len_comp_lower || len_data != len_comp_lower) + if (len_data != len_comp_lower || len_data != len_comp_upper) { printf("Test data length mismatch\n"); exit(2); diff --git a/libs/spandsp/tests/hdlc_tests.c b/libs/spandsp/tests/hdlc_tests.c index bf7a63995d..a4a35dcf3c 100644 --- a/libs/spandsp/tests/hdlc_tests.c +++ b/libs/spandsp/tests/hdlc_tests.c @@ -862,7 +862,7 @@ int main(int argc, char *argv[]) decode_bitstream(in_file_name); else hdlc_tests(); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/image_translate_tests.c b/libs/spandsp/tests/image_translate_tests.c index be0f5ea18c..b39cb243d5 100644 --- a/libs/spandsp/tests/image_translate_tests.c +++ b/libs/spandsp/tests/image_translate_tests.c @@ -74,60 +74,131 @@ static void display_row(int row, int width, uint8_t buf[]) } /*- End of function --------------------------------------------------------*/ +static void create_undithered_50_by_50(image_descriptor_t *im, uint8_t buf[], int bytes_per_pixel) +{ + unsigned int i; + unsigned int j; + uint8_t *image8; + uint16_t *image16; + + im->image = (const uint8_t *) buf; + im->width = 50; + im->length = 50; + im->bytes_per_pixel = bytes_per_pixel; + im->current_row = 0; + + switch (bytes_per_pixel) + { + case 1: + image8 = buf; + for (i = 0; i < 50; i++) + { + for (j = 0; j < 50; j++) + image8[50*i + j] = ((i + j)*655) >> 8; + } + break; + case 2: + image16 = (uint16_t *) buf; + for (i = 0; i < 50; i++) + { + for (j = 0; j < 50; j++) + image16[50*i + j] = (i + j)*655; + } + break; + case 3: + image8 = buf; + for (i = 0; i < 50; i++) + { + for (j = 0; j < 50; j++) + { +#if 0 + image8[50*3*i + 3*j + 0] = ((i + j)*655) >> 8; + image8[50*3*i + 3*j + 1] = ((i + j)*655) >> 8; + image8[50*3*i + 3*j + 2] = ((i + j)*655) >> 8; +#else + image8[50*3*i + 3*j + 0] = saturateu8((((i + j)*655U)*36532U) >> 23); + image8[50*3*i + 3*j + 1] = saturateu8((((i + j)*655U)*37216U) >> 24); + image8[50*3*i + 3*j + 2] = saturateu8((((i + j)*655U)*47900U) >> 22); +#endif + } + } + break; + case 6: + image16 = (uint16_t *) buf; + for (i = 0; i < 50; i++) + { + for (j = 0; j < 50; j++) + { +#if 0 + image16[50*3*i + 3*j + 0] = (i + j)*655; + image16[50*3*i + 3*j + 1] = (i + j)*655; + image16[50*3*i + 3*j + 2] = (i + j)*655; +#else + image16[50*3*i + 3*j + 0] = saturateu16((((i + j)*655U)*36532U) >> 15); + image16[50*3*i + 3*j + 1] = saturateu16((((i + j)*655U)*37216U) >> 16); + image16[50*3*i + 3*j + 2] = saturateu16((((i + j)*655U)*47900U) >> 14); +#endif + } + } + break; + } +} +/*- End of function --------------------------------------------------------*/ + static int test_dithered_50_by_50(int row, int width, uint8_t buf[]) { static const char *image[50] = { - " 0: @ @ @ @ @ @ @ @@ @@@@@@@@@@@@@@", - " 1: @ @ @ @ @ @ @ @ @ @@ @@ @ @ @ @ @@@@", - " 2: @ @ @ @ @ @ @ @@ @ @ @@@ @@@@@@ @@", - " 3: @ @ @ @ @ @ @ @ @ @ @@@ @@@@ @@@@@@", - " 4: @ @ @ @ @ @ @ @ @ @@@ @ @@ @@@@ @@@@", - " 5: @ @ @ @ @ @ @ @ @ @ @ @ @@ @@@ @@@@@@", - " 6: @ @ @ @ @ @ @@ @@@@ @@@ @@@ @@ @", - " 7: @ @ @ @ @ @ @ @ @ @@ @@ @ @@ @@@@@@", - " 8: @ @ @ @ @ @ @ @ @@@ @@@@@@@@@ @@@", - " 9: @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @ @ @@@@@", - " 10: @ @ @ @ @ @@ @ @@ @@@@@@@@@@@@@", - " 11: @ @ @ @ @ @ @ @ @ @@ @@ @ @ @@ @@ @@", - " 12: @ @ @ @ @ @ @ @ @ @@ @@@@@@ @@@@@@@", - " 13: @ @ @ @ @ @ @ @ @@ @ @ @ @ @@@@@ @@@", - " 14: @ @ @ @ @ @ @ @@ @@@ @@@ @ @@@@@@", - " 15: @ @ @ @ @ @ @ @ @ @ @ @ @@ @@@@@@@ @@", - " 16: @ @ @ @ @ @ @ @ @@ @@ @@ @@ @@@@@", - " 17: @ @ @ @ @ @ @ @ @ @@ @@ @@ @@ @@@@@@@", - " 18: @ @ @ @ @ @ @ @ @ @ @ @@ @@@@@ @ @@@", - " 19: @ @ @ @ @ @ @ @ @@@ @@@ @ @@@@@@@", - " 20: @ @ @ @ @ @ @ @ @ @@ @ @@ @@@@@@ @@@ @", - " 21: @ @ @ @ @ @ @ @@ @@ @ @ @@@@@@@", - " 22: @ @ @ @ @ @@ @ @ @ @ @@ @@@@@@@ @@ @@", - " 23: @ @ @ @ @ @ @ @@ @@ @@ @ @ @@@@@@@", - " 24: @ @ @ @ @@ @ @ @@ @ @ @@@@@@ @@@@@", - " 25: @ @ @ @ @ @ @ @ @ @ @@@@@ @ @@@@ @@", - " 26: @ @ @ @ @ @ @ @ @ @@ @ @ @@@@ @@@@@", - " 27: @ @ @ @ @ @ @ @ @ @@ @ @@ @@@ @@@@@@@", - " 28: @ @ @ @ @ @ @ @ @@@ @@@ @@@ @@ @@", - " 29: @ @ @ @ @ @ @ @ @@ @ @@ @ @@ @@@@@@@", - " 30: @ @ @ @ @ @ @ @ @ @ @ @@@@@@@ @@@@@", - " 31: @ @ @ @ @ @ @ @ @ @@@@ @ @ @@@@ @@", - " 32: @ @ @ @ @ @ @ @ @ @@ @ @ @@@@@@@ @@@@@", - " 33: @ @ @ @ @ @ @ @@@ @@ @ @ @@@@@@@", - " 34: @ @ @ @ @ @ @ @ @ @ @ @ @@ @@@@@@ @ @@@", - " 35: @ @ @ @ @ @ @ @ @ @@ @ @ @@@@@@@", - " 36: @ @ @ @ @ @ @ @ @@ @@@ @@@@@@@ @@@ @", - " 37: @ @ @ @ @ @ @ @ @ @ @@ @ @ @@@@@@@", - " 38: @ @ @ @ @ @ @ @ @@ @@ @@@@@@@ @@ @@", - " 39: @ @ @ @ @ @ @ @ @ @ @@ @@ @ @ @@@@@@@", - " 40: @ @ @ @ @ @ @ @ @ @@ @@ @@@@ @@@@@", - " 41: @ @ @ @ @ @ @ @ @ @@ @ @@ @@@ @@@@ @@", - " 42: @ @ @ @ @ @ @@ @@ @@ @@ @@@ @@@@@", - " 43: @ @ @ @ @ @ @ @ @ @ @@ @@@ @@@@@@@", - " 44: @ @ @ @ @ @ @ @ @ @ @@@ @@@ @@@ @@ @@", - " 45: @ @ @ @ @ @ @@ @ @ @ @@ @@@@@@@", - " 46: @ @ @ @ @ @ @ @ @ @ @ @@ @@@@@@@@@ @@@@@", - " 47: @ @ @ @ @ @ @ @ @ @@ @ @ @ @@@@ @@", - " 48: @ @ @ @ @ @ @@ @ @@ @@@@@@ @@@@@", - " 49: @ @ @ @ @ @ @ @ @ @ @ @@ @@ @ @ @@@@@@@" + " 0: @ @ @ @ @ @ @ @ ", + " 1: @ @ @ @ @ @ @ @ @ @ @ @ @ @", + " 2: @ @ @ @ @ @ @ @ @ @ @ @ @", + " 3: @ @ @ @ @ @ @ @ @ @ @ @ @ @ ", + " 4: @ @ @ @ @ @ @ @ @ @ @ @ @ @", + " 5: @ @ @ @ @ @ @ @ @ @ @ @ @ ", + " 6: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@", + " 7: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ ", + " 8: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ ", + " 9: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @", + " 10: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @@", + " 11: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ ", + " 12: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @ @", + " 13: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @", + " 14: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @@", + " 15: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @@ ", + " 16: @ @ @ @ @ @ @ @ @ @ @@ @ @@@ @@", + " 17: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @", + " 18: @ @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@ @@@ ", + " 19: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @", + " 20: @ @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@@ @@@@@", + " 21: @ @ @ @ @ @ @ @ @ @@ @ @ @ @ @ @ @ @@ @ @", + " 22: @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@@ @ @@ @@", + " 23: @ @ @ @ @ @ @ @ @ @@ @ @ @ @ @ @ @@@ @@ @", + " 24: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@@ @ @ @@ @@", + " 25: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@@@@ @@@@", + " 26: @ @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@@ @ @ @@@ @ @", + " 27: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@@ @@ @@@@@", + " 28: @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @@ @ @ @@ @@ @ @", + " 29: @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@ @@@@@ @@@ @@@@", + " 30: @ @ @ @ @ @ @ @ @ @ @@ @@ @ @ @@ @ @@@ @@@ @@", + " 31: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @@@ @ @@ @@@ @@@@", + " 32: @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @@@@@ @@ @@@ @@", + " 33: @ @ @ @ @ @ @ @ @ @ @ @@ @@@ @@ @ @ @ @@@@@ @@@@", + " 34: @ @ @ @ @ @ @ @ @ @@ @ @ @ @@ @@@@@@@ @ @@@@ @@", + " 35: @ @ @ @ @ @ @ @ @ @@ @@ @@ @@ @ @ @@@@@@ @@@@", + " 36: @ @ @ @ @ @ @ @ @ @ @ @@ @@ @@ @@@ @@ @ @@@@@@ @", + " 37: @ @ @ @ @ @ @ @ @@ @@ @ @ @@ @@ @ @@@@@@@ @@ @@@", + " 38: @ @ @ @ @ @ @ @ @ @ @ @@@ @@ @@ @@@@ @ @@@@@@@@@@", + " 39: @ @ @ @ @ @ @ @@ @@ @@ @@ @@@@ @@@@ @@ @@ @@@", + " 40: @ @ @ @ @@ @ @ @@ @ @ @ @ @@ @@ @ @@ @@@@@@@@@@@@", + " 41: @ @ @ @ @ @ @ @@ @ @@@ @@@ @@@ @@@@@@@@@ @@ @@ @@", + " 42: @ @ @ @ @@ @ @ @ @@ @ @@ @@ @@@@ @ @ @@@@@@@@@@@@", + " 43: @ @ @ @ @ @ @@ @@ @ @@ @@ @@@ @ @@@@@@@ @@ @@@@@@", + " 44: @ @ @ @ @ @ @ @ @@ @@ @@ @@ @@@@@ @@ @@@@@@@@ @@@", + " 45: @ @ @ @ @ @ @@ @@ @@ @@ @@ @@@ @ @@@@@@@@ @@@@@@@@", + " 46: @ @ @ @ @ @ @@ @ @ @@ @@ @@ @@@@@ @ @@ @@@@@@@@@@", + " 47: @ @ @ @ @ @@ @ @ @@@@ @@@@ @@@@@ @@@@@@@@@@@ @@@@@", + " 48: @ @ @ @@ @ @@ @@ @ @@ @ @@@ @ @@@@@ @@@@@@@@@@@@@", + " 49: @ @ @ @ @ @@ @@ @@ @@ @@@@ @@@@@@@ @@@@@@ @@@@@@@@" }; int i; int match; @@ -159,7 +230,7 @@ static int row_read(void *user_data, uint8_t buf[], size_t len) } /*- End of function --------------------------------------------------------*/ -static void get_flattened_image(image_translate_state_t *s, int compare) +static void get_bilevel_image(image_translate_state_t *s, int compare) { int i; int len; @@ -178,8 +249,7 @@ static void get_flattened_image(image_translate_state_t *s, int compare) if (test_dithered_50_by_50(i, s->output_width, row_buf)) { printf("Dithered image mismatch at row %d\n", i); - printf("Test failed\n"); - exit(2); + //exit(2); } } } @@ -191,153 +261,338 @@ static void get_flattened_image(image_translate_state_t *s, int compare) } /*- End of function --------------------------------------------------------*/ -static void dither_tests_gray16(void) +static void get_gray8_image(image_translate_state_t *s, int compare) { - int i; - int j; - image_translate_state_t bw; - image_translate_state_t *s = &bw; + unsigned int i; + unsigned int j; + int len; + uint8_t row_buf[5000]; + + for (i = 0; i < s->output_length; i++) + { + if ((len = image_translate_row(s, row_buf, s->output_width)) != s->output_width) + { + printf("Image finished early - %d %d\n", len, s->output_width); + exit(2); + } + if (compare) + { + for (j = 0; j < 50; j++) + { + if (row_buf[j] != (((i + j)*655) >> 8)) + { + printf("Image mismatch - %dx%d - %d %d\n", j, i, ((i + j)*655) >> 8, row_buf[j]); + //exit(2); + } + } + } + } + if ((len = image_translate_row(s, row_buf, s->output_width)) != 0) + { + printf("Image finished late - %d %d\n", len, s->output_width); + exit(2); + } +} +/*- End of function --------------------------------------------------------*/ + +static void get_gray16_image(image_translate_state_t *s, int compare) +{ + unsigned int i; + unsigned int j; + int len; + uint16_t row_buf[5000]; + + for (i = 0; i < s->output_length; i++) + { + if ((len = image_translate_row(s, (uint8_t *) row_buf, 2*s->output_width)) != 2*s->output_width) + { + printf("Image finished early - %d %d\n", len, 2*s->output_width); + exit(2); + } + if (compare) + { + for (j = 0; j < 50; j++) + { + if (row_buf[j] != (i + j)*655) + { + printf("Image mismatch - %dx%d - %d %d\n", j, i, (i + j)*655, row_buf[j]); + //exit(2); + } + } + } + } + if ((len = image_translate_row(s, (uint8_t *) row_buf, 2*s->output_width)) != 0) + { + printf("Image finished late - %d %d\n", len, 2*s->output_width); + exit(2); + } +} +/*- End of function --------------------------------------------------------*/ + +static void get_colour8_image(image_translate_state_t *s, int compare) +{ + unsigned int i; + unsigned int j; + int len; + int r; + int g; + int b; + uint8_t row_buf[5000]; + + for (i = 0; i < s->output_length; i++) + { + if ((len = image_translate_row(s, row_buf, 3*s->output_width)) != 3*s->output_width) + { + printf("Image finished early - %d %d\n", len, 3*s->output_width); + exit(2); + } + if (compare) + { + for (j = 0; j < 50; j++) + { +#if 0 + r = ((i + j)*655) >> 8; + g = ((i + j)*655) >> 8; + b = ((i + j)*655) >> 8; +#else + r = saturateu8((((i + j)*655U)*36532U) >> 23); + g = saturateu8((((i + j)*655U)*37216U) >> 24); + b = saturateu8((((i + j)*655U)*47900U) >> 22); +#endif + if (row_buf[3*j + 0] != r || row_buf[3*j + 1] != g || row_buf[3*j + 2] != b) + { + printf("Image mismatch - %dx%d - (%d %d %d) (%d %d %d)\n", + j, i, + r, g, b, + row_buf[3*j + 0], row_buf[3*j + 1], row_buf[3*j + 2]); + //exit(2); + } + } + } + } + if ((len = image_translate_row(s, row_buf, 2*s->output_width)) != 0) + { + printf("Image finished late - %d %d\n", len, 3*s->output_width); + exit(2); + } +} +/*- End of function --------------------------------------------------------*/ + +static void get_colour16_image(image_translate_state_t *s, int compare) +{ + unsigned int i; + unsigned int j; + int len; + int r; + int g; + int b; + uint16_t row_buf[5000]; + + for (i = 0; i < s->output_length; i++) + { + if ((len = image_translate_row(s, (uint8_t *) row_buf, 6*s->output_width)) != 6*s->output_width) + { + printf("Image finished early - %d %d\n", len, 6*s->output_width); + exit(2); + } + if (compare) + { + for (j = 0; j < 50; j++) + { +#if 0 + r = (i + j)*655; + g = (i + j)*655; + b = (i + j)*655; +#else + r = saturateu16((((i + j)*655U)*36532U) >> 15); + g = saturateu16((((i + j)*655U)*37216U) >> 16); + b = saturateu16((((i + j)*655U)*47900U) >> 14); +#endif + if (row_buf[3*j + 0] != r || row_buf[3*j + 1] != g || row_buf[3*j + 2] != b) + { + printf("Image mismatch - %dx%d - (%d %d %d) (%d %d %d)\n", + j, i, + r, g, b, + row_buf[3*j + 0], row_buf[3*j + 1], row_buf[3*j + 2]); + //exit(2); + } + } + } + } + if ((len = image_translate_row(s, (uint8_t *) row_buf, 6*s->output_width)) != 0) + { + printf("Image finished late - %d %d\n", len, 6*s->output_width); + exit(2); + } +} +/*- End of function --------------------------------------------------------*/ + +static void translate_tests_gray16(void) +{ + image_translate_state_t *s; uint16_t image[50*50]; image_descriptor_t im; printf("Dithering from a 16 bit per sample gray scale to bi-level\n"); - im.image = (const uint8_t *) image; - im.width = 50; - im.length = 50; - im.bytes_per_pixel = 2; - im.current_row = 0; + create_undithered_50_by_50(&im, (uint8_t *) image, 2); + s = image_translate_init(NULL, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, T4_IMAGE_TYPE_BILEVEL, -1, -1, row_read, &im); + get_bilevel_image(s, TRUE); - for (i = 0; i < im.length; i++) - { - for (j = 0; j < im.width; j++) - image[i*im.width + j] = j*1200; - } + printf("Scrunching from a 16 bit per sample gray scale to 8 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 2); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, row_read, &im); + get_gray8_image(s, TRUE); - s = image_translate_init(s, IMAGE_TRANSLATE_FROM_GRAY_16, im.width, im.length, -1, row_read, &im); - get_flattened_image(s, TRUE); + printf("Scrunching from a 16 bit per sample gray scale to 16 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 2); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, row_read, &im); + get_gray16_image(s, TRUE); + + printf("Scrunching from a 16 bit per sample gray scale to 3x8 bit per sample colour\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 2); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, row_read, &im); + get_colour8_image(s, TRUE); + + printf("Scrunching from a 16 bit per sample gray scale to 3x16 bit per sample colour\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 2); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_12BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, row_read, &im); + get_colour16_image(s, TRUE); + + image_translate_free(s); } /*- End of function --------------------------------------------------------*/ -static void dither_tests_gray8(void) +static void translate_tests_gray8(void) { - int i; - int j; - image_translate_state_t bw; - image_translate_state_t *s = &bw; + image_translate_state_t *s; uint8_t image[50*50]; image_descriptor_t im; printf("Dithering from a 8 bit per sample gray scale to bi-level\n"); - im.image = image; - im.width = 50; - im.length = 50; - im.bytes_per_pixel = 1; - im.current_row = 0; + create_undithered_50_by_50(&im, image, 1); + s = image_translate_init(NULL, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, T4_IMAGE_TYPE_BILEVEL, -1, -1, row_read, &im); + get_bilevel_image(s, TRUE); - for (i = 0; i < im.length; i++) - { - for (j = 0; j < im.width; j++) - image[i*im.width + j] = j*1200/256; - } - s = image_translate_init(s, IMAGE_TRANSLATE_FROM_GRAY_8, im.width, im.length, -1, row_read, &im); - get_flattened_image(s, TRUE); + printf("Scrunching from a 8 bit per sample gray scale to 8 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, image, 1); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, row_read, &im); + get_gray8_image(s, TRUE); + + printf("Scrunching from a 8 bit per sample gray scale to 16 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, image, 1); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, row_read, &im); + get_gray16_image(s, TRUE); + + printf("Scrunching from a 8 bit per sample gray scale to 3x8 bit per sample colour\n"); + create_undithered_50_by_50(&im, image, 1); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, row_read, &im); + get_colour8_image(s, TRUE); + + printf("Scrunching from a 8 bit per sample gray scale to 3x16 bit per sample colour\n"); + create_undithered_50_by_50(&im, image, 1); + s = image_translate_init(s, T4_IMAGE_TYPE_GRAY_8BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, row_read, &im); + get_colour16_image(s, TRUE); + + image_translate_free(s); } /*- End of function --------------------------------------------------------*/ -static void dither_tests_colour16(void) +static void translate_tests_colour16(void) { - int i; - int j; - image_translate_state_t bw; - image_translate_state_t *s = &bw; + image_translate_state_t *s; uint16_t image[50*50*3]; image_descriptor_t im; printf("Dithering from a 3x16 bit per sample colour to bi-level\n"); - im.image = (const uint8_t *) image; - im.width = 50; - im.length = 50; - im.bytes_per_pixel = 6; - im.current_row = 0; + create_undithered_50_by_50(&im, (uint8_t *) image, 6); + s = image_translate_init(NULL, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, T4_IMAGE_TYPE_BILEVEL, -1, -1, row_read, &im); + get_bilevel_image(s, TRUE); - for (i = 0; i < im.length; i++) - { - for (j = 0; j < im.width; j++) - { - image[i*3*im.width + 3*j + 0] = j*1200; - image[i*3*im.width + 3*j + 1] = j*1200; - image[i*3*im.width + 3*j + 2] = j*1200; - } - } - s = image_translate_init(s, IMAGE_TRANSLATE_FROM_COLOUR_16, im.width, im.length, -1, row_read, &im); - get_flattened_image(s, TRUE); + printf("Scrunching from a 3x16 bit per sample colour to 8 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 6); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, row_read, &im); + get_gray8_image(s, TRUE); + + printf("Scrunching from a 3x16 bit per sample colour to 16 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 6); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, row_read, &im); + get_gray16_image(s, TRUE); + + printf("Scrunching from a 3x16 bit per sample colour to 3x8 bit per sample colour\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 6); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, row_read, &im); + get_colour8_image(s, TRUE); + + printf("Scrunching from a 3x16 bit per sample colour to 3x16 bit per sample colour\n"); + create_undithered_50_by_50(&im, (uint8_t *) image, 6); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_12BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, row_read, &im); + get_colour16_image(s, TRUE); + + image_translate_free(s); } /*- End of function --------------------------------------------------------*/ -static void dither_tests_colour8(void) +static void translate_tests_colour8(void) { - int i; - int j; - image_translate_state_t bw; - image_translate_state_t *s = &bw; + image_translate_state_t *s; uint8_t image[50*50*3]; image_descriptor_t im; printf("Dithering from a 3x8 bit per sample colour to bi-level\n"); - im.image = image; - im.width = 50; - im.length = 50; - im.bytes_per_pixel = 3; - im.current_row = 0; + create_undithered_50_by_50(&im, image, 3); + s = image_translate_init(NULL, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, T4_IMAGE_TYPE_BILEVEL, -1, -1, row_read, &im); + get_bilevel_image(s, TRUE); - for (i = 0; i < im.length; i++) - { - for (j = 0; j < im.width; j++) - { - image[i*3*im.width + 3*j + 0] = j*1200/256; - image[i*3*im.width + 3*j + 1] = j*1200/256; - image[i*3*im.width + 3*j + 2] = j*1200/256; - } - } + printf("Scrunching from a 3x8 bit per sample colour to 8 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, image, 3); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_8BIT, -1, -1, row_read, &im); + get_gray8_image(s, TRUE); - s = image_translate_init(s, IMAGE_TRANSLATE_FROM_COLOUR_8, im.width, im.length, -1, row_read, &im); - get_flattened_image(s, TRUE); + printf("Scrunching from a 3x8 bit per sample colour to 16 bit per sample gray scale\n"); + create_undithered_50_by_50(&im, image, 3); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, T4_IMAGE_TYPE_GRAY_12BIT, -1, -1, row_read, &im); + get_gray16_image(s, TRUE); + + printf("Scrunching from a 3x8 bit per sample colour to 3x8 bit per sample colour\n"); + create_undithered_50_by_50(&im, image, 3); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, row_read, &im); + get_colour8_image(s, TRUE); + + printf("Scrunching from a 3x8 bit per sample colour to 3x16 bit per sample colour\n"); + create_undithered_50_by_50(&im, image, 3); + s = image_translate_init(s, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, T4_IMAGE_TYPE_COLOUR_12BIT, -1, -1, row_read, &im); + get_colour16_image(s, TRUE); + + image_translate_free(s); } /*- End of function --------------------------------------------------------*/ static void grow_tests_colour8(void) { - int i; - int j; - image_translate_state_t resize; - image_translate_state_t *s1 = &resize; + image_translate_state_t *s; uint8_t image[50*50*3]; image_descriptor_t im; printf("Image growth tests\n"); - im.image = image; - im.width = 50; - im.length = 50; - im.bytes_per_pixel = 3; - im.current_row = 0; + create_undithered_50_by_50(&im, image, 3); - for (i = 0; i < im.length; i++) - { - for (j = 0; j < im.width; j++) - { - image[i*3*im.width + 3*j + 0] = j*1200/256; - image[i*3*im.width + 3*j + 1] = j*1200/256; - image[i*3*im.width + 3*j + 2] = j*1200/256; - } - } - - s1 = image_translate_init(s1, IMAGE_TRANSLATE_FROM_COLOUR_8, im.width, im.length, 200, row_read, &im); - - get_flattened_image(s1, FALSE); + s = image_translate_init(NULL, T4_IMAGE_TYPE_COLOUR_8BIT, im.width, im.length, T4_IMAGE_TYPE_BILEVEL, 200, -1, row_read, &im); + get_bilevel_image(s, FALSE); + image_translate_free(s); } /*- End of function --------------------------------------------------------*/ -static void lenna_tests(int output_width, const char *file) +static int row_read2(void *user_data, uint8_t buf[], size_t len) +{ + image_translate_state_t *s; + + s = (image_translate_state_t *) user_data; + image_translate_row(s, buf, len); + return len; +} +/*- End of function --------------------------------------------------------*/ + +static void lenna_tests(int output_width, int output_length_scaling, const char *file) { TIFF *in_file; TIFF *out_file; @@ -352,11 +607,17 @@ static void lenna_tests(int output_width, const char *file) int16_t samples_per_pixel; int i; int n; - image_translate_state_t bw; - image_translate_state_t *s = &bw; + image_translate_state_t *s; + image_translate_state_t *s2; image_descriptor_t im; + float x_resolution; + float y_resolution; + uint16_t res_unit; - printf("Dithering Lenna from colour to bi-level test\n"); + if (output_length_scaling >= 0) + printf("Dithering Lenna from colour to bi-level test\n"); + else + printf("Processing Lenna test\n"); if ((in_file = TIFFOpen(INPUT_TIFF_FILE_NAME, "r")) == NULL) return; image_width = 0; @@ -367,11 +628,17 @@ static void lenna_tests(int output_width, const char *file) TIFFGetField(in_file, TIFFTAG_IMAGELENGTH, &image_length); if (image_length <= 0) return; + x_resolution = 200.0; + TIFFGetField(in_file, TIFFTAG_XRESOLUTION, &x_resolution); + y_resolution = 200.0; + TIFFGetField(in_file, TIFFTAG_YRESOLUTION, &y_resolution); + res_unit = RESUNIT_INCH; + TIFFGetField(in_file, TIFFTAG_RESOLUTIONUNIT, &res_unit); bits_per_sample = 0; TIFFGetField(in_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); samples_per_pixel = 0; TIFFGetField(in_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); - printf("Original image is %d x %d, %d bits per sample, %d samples per pixel\n", image_width, image_length, bits_per_sample, samples_per_pixel); + printf("Original image is %d x %d, %.2f x %.2f resolution, %d bits per sample, %d samples per pixel\n", image_width, image_length, x_resolution, y_resolution, bits_per_sample, samples_per_pixel); if ((image = malloc(image_width*image_length*samples_per_pixel)) == NULL) return; for (total = 0, i = 0; i < 1000; i++) @@ -389,61 +656,124 @@ static void lenna_tests(int output_width, const char *file) printf("Image size %d %d\n", total, image_width*image_length*samples_per_pixel); TIFFClose(in_file); + if (output_length_scaling > 0) + output_length = (double) image_length*output_length_scaling*output_width/image_width; + else + output_length = -1; + im.image = image; im.width = image_width; im.length = image_length; im.current_row = 0; im.bytes_per_pixel = samples_per_pixel; - s = image_translate_init(s, IMAGE_TRANSLATE_FROM_COLOUR_8, image_width, image_length, output_width, row_read, &im); - output_width = image_translate_get_output_width(s); - output_length = image_translate_get_output_length(s); + switch (output_length_scaling) + { + case -2: + s = image_translate_init(NULL, T4_IMAGE_TYPE_COLOUR_8BIT, image_width, image_length, T4_IMAGE_TYPE_GRAY_8BIT, output_width, output_length, row_read, &im); + output_width = image_translate_get_output_width(s); + output_length = image_translate_get_output_length(s); + s2 = image_translate_init(NULL, T4_IMAGE_TYPE_GRAY_8BIT, output_width, output_length, T4_IMAGE_TYPE_COLOUR_8BIT, -1, -1, row_read2, s); + output_width = image_translate_get_output_width(s2); + output_length = image_translate_get_output_length(s2); + break; + case -1: + s = image_translate_init(NULL, T4_IMAGE_TYPE_COLOUR_8BIT, image_width, image_length, T4_IMAGE_TYPE_COLOUR_8BIT, output_width, output_length, row_read, &im); + output_width = image_translate_get_output_width(s); + output_length = image_translate_get_output_length(s); + break; + default: + s = image_translate_init(NULL, T4_IMAGE_TYPE_COLOUR_8BIT, image_width, image_length, T4_IMAGE_TYPE_BILEVEL, output_width, output_length, row_read, &im); + output_width = image_translate_get_output_width(s); + output_length = image_translate_get_output_length(s); + break; + } if ((out_file = TIFFOpen(file, "w")) == NULL) return; TIFFSetField(out_file, TIFFTAG_IMAGEWIDTH, output_width); TIFFSetField(out_file, TIFFTAG_IMAGELENGTH, output_length); - TIFFSetField(out_file, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(out_file, TIFFTAG_RESOLUTIONUNIT, res_unit); + + switch (output_length_scaling) + { + case -2: + case -1: + TIFFSetField(out_file, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(out_file, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField(out_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + break; + default: + TIFFSetField(out_file, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(out_file, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(out_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); + break; + } + if (output_length_scaling > 0) + y_resolution *= output_length_scaling; + TIFFSetField(out_file, TIFFTAG_XRESOLUTION, x_resolution); + TIFFSetField(out_file, TIFFTAG_YRESOLUTION, y_resolution); TIFFSetField(out_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out_file, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(out_file, TIFFTAG_ROWSPERSTRIP, -1); TIFFSetField(out_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(out_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); TIFFSetField(out_file, TIFFTAG_PAGENUMBER, 0, 1); - TIFFSetField(out_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); - TIFFSetField(out_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); printf("Input %d x %d, output %d x %d\n", image_width, image_length, output_width, output_length); - - if ((image2 = malloc(output_width*output_length/8)) == NULL) - return; - memset(image2, 0, output_width*output_length/8); - n = 0; - for (i = 0; i < output_length; i++) - n += image_translate_row(s, &image2[n], output_width/8); - - TIFFWriteEncodedStrip(out_file, 0, image2, output_width*output_length/8); + switch (output_length_scaling) + { + case -2: + if ((image2 = malloc(output_width*output_length*3)) == NULL) + return; + memset(image2, 0, output_width*output_length*3); + n = 0; + for (i = 0; i < output_length; i++) + n += image_translate_row(s2, &image2[n], output_width*3); + TIFFWriteEncodedStrip(out_file, 0, image2, n); + break; + case -1: + if ((image2 = malloc(output_width*output_length*3)) == NULL) + return; + memset(image2, 0, output_width*output_length*3); + n = 0; + for (i = 0; i < output_length; i++) + n += image_translate_row(s, &image2[n], output_width*3); + TIFFWriteEncodedStrip(out_file, 0, image2, n); + break; + default: + if ((image2 = malloc(output_width*output_length/8)) == NULL) + return; + memset(image2, 0, output_width*output_length/8); + n = 0; + for (i = 0; i < output_length; i++) + n += image_translate_row(s, &image2[n], output_width/8); + TIFFWriteEncodedStrip(out_file, 0, image2, n); + break; + } TIFFWriteDirectory(out_file); TIFFClose(out_file); + image_translate_free(s); } /*- End of function --------------------------------------------------------*/ int main(int argc, char **argv) { #if 1 - dither_tests_gray16(); - dither_tests_gray8(); - dither_tests_colour16(); - dither_tests_colour8(); + translate_tests_gray16(); + translate_tests_gray8(); + translate_tests_colour16(); + translate_tests_colour8(); #endif #if 1 grow_tests_colour8(); #endif #if 1 - lenna_tests(0, "lenna-bw.tif"); - lenna_tests(1728, "lenna-bw-1728.tif"); - lenna_tests(200, "lenna-bw-200.tif"); + lenna_tests(0, 0, "lenna-bw.tif"); + lenna_tests(200, 0, "lenna-bw-200.tif"); + lenna_tests(1728, 0, "lenna-bw-1728.tif"); + lenna_tests(1728, 2, "lenna-bw-1728-superfine.tif"); + lenna_tests(1728, -1, "lenna-colour-1728.tif"); + lenna_tests(1728, -2, "lenna-gray-1728.tif"); #endif printf("Tests passed.\n"); return 0; diff --git a/libs/spandsp/tests/make_g168_css.c b/libs/spandsp/tests/make_g168_css.c index 850eb7e223..ba0138e63e 100644 --- a/libs/spandsp/tests/make_g168_css.c +++ b/libs/spandsp/tests/make_g168_css.c @@ -427,7 +427,7 @@ int main(int argc, char *argv[]) } fftw_destroy_plan(p); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/modem_connect_tones_tests.c b/libs/spandsp/tests/modem_connect_tones_tests.c index fb063cbc54..bf60efe5f8 100644 --- a/libs/spandsp/tests/modem_connect_tones_tests.c +++ b/libs/spandsp/tests/modem_connect_tones_tests.c @@ -49,30 +49,38 @@ These tests... #include "spandsp.h" #include "spandsp-sim.h" -#define SAMPLES_PER_CHUNK 160 +#define SAMPLES_PER_CHUNK 160 -#define OUTPUT_FILE_NAME "modem_connect_tones.wav" +#define OUTPUT_FILE_NAME "modem_connect_tones.wav" -#define MITEL_DIR "../test-data/mitel/" -#define BELLCORE_DIR "../test-data/bellcore/" +#define MITEL_DIR "../test-data/mitel/" +#define BELLCORE_DIR "../test-data/bellcore/" #define FALSE 0 #define TRUE (!FALSE) -#define LEVEL_MAX -5 -#define LEVEL_MIN -48 -#define LEVEL_MIN_ACCEPT -43 -#define LEVEL_MIN_REJECT -44 +#define LEVEL_MAX -5 +#define LEVEL_MIN -48 +#define LEVEL_MIN_ACCEPT -43 +#define LEVEL_MIN_REJECT -44 /* The 1100Hz tone is supposed to be within 38Hz, according to T.30. Allow another 8Hz for FDM, even though you rarely see that used today. */ -#define CED_FREQ_TOLERANCE (38 + 8) -#define CED_FREQ_BLACKOUT (80) +#define CED_FREQ_TOLERANCE (38 + 8) +#define CED_FREQ_BLACKOUT (80) /* The 2100Hz tone is supposed to be within 15Hz, according to T.30. Allow another 8Hz for FDM, even though you rarely see that used today. */ -#define CNG_FREQ_TOLERANCE (15 + 8) -#define CNG_FREQ_BLACKOUT (80) -#define AM_FREQ_TOLERANCE (1) +#define CNG_FREQ_TOLERANCE (15 + 8) +#define CNG_FREQ_BLACKOUT (80) +#define AM_FREQ_TOLERANCE (1) +/* The 2225Hz tone is supposed to be within 15Hz. Allow another 8Hz for FDM, even though + you rarely see that used today. */ +#define BELL_ANS_FREQ_TOLERANCE (15 + 8) +#define BELL_ANS_FREQ_BLACKOUT (80) +/* The 1300Hz tone is supposed to be within 15Hz, according to V.25. Allow another 8Hz for FDM, even though + you rarely see that used today. */ +#define CALLING_TONE_FREQ_TOLERANCE (15 + 8) +#define CALLING_TONE_FREQ_BLACKOUT (80) const char *bellcore_files[] = { @@ -93,24 +101,30 @@ enum PERFORM_TEST_1C = (1 << 3), PERFORM_TEST_1D = (1 << 4), PERFORM_TEST_1E = (1 << 5), - PERFORM_TEST_2A = (1 << 6), - PERFORM_TEST_2B = (1 << 7), - PERFORM_TEST_2C = (1 << 8), - PERFORM_TEST_2D = (1 << 9), - PERFORM_TEST_2E = (1 << 10), - PERFORM_TEST_3A = (1 << 11), - PERFORM_TEST_3B = (1 << 12), - PERFORM_TEST_3C = (1 << 13), - PERFORM_TEST_3D = (1 << 14), - PERFORM_TEST_3E = (1 << 15), - PERFORM_TEST_4 = (1 << 16), - PERFORM_TEST_5A = (1 << 17), - PERFORM_TEST_5B = (1 << 18), - PERFORM_TEST_6A = (1 << 19), - PERFORM_TEST_6B = (1 << 20), - PERFORM_TEST_7A = (1 << 21), - PERFORM_TEST_7B = (1 << 22), - PERFORM_TEST_8 = (1 << 23) + PERFORM_TEST_1F = (1 << 6), + PERFORM_TEST_1G = (1 << 7), + PERFORM_TEST_2A = (1 << 8), + PERFORM_TEST_2B = (1 << 9), + PERFORM_TEST_2C = (1 << 10), + PERFORM_TEST_2D = (1 << 11), + PERFORM_TEST_2E = (1 << 12), + PERFORM_TEST_2F = (1 << 13), + PERFORM_TEST_2G = (1 << 14), + PERFORM_TEST_3A = (1 << 15), + PERFORM_TEST_3B = (1 << 16), + PERFORM_TEST_3C = (1 << 17), + PERFORM_TEST_3D = (1 << 18), + PERFORM_TEST_3E = (1 << 19), + PERFORM_TEST_3F = (1 << 20), + PERFORM_TEST_3G = (1 << 21), + PERFORM_TEST_4 = (1 << 22), + PERFORM_TEST_5A = (1 << 23), + PERFORM_TEST_5B = (1 << 24), + PERFORM_TEST_6A = (1 << 25), + PERFORM_TEST_6B = (1 << 26), + PERFORM_TEST_7A = (1 << 27), + PERFORM_TEST_7B = (1 << 28), + PERFORM_TEST_8 = (1 << 29) }; int preamble_count = 0; @@ -184,6 +198,22 @@ static void ans_pr_detected(void *user_data, int tone, int level, int delay) } /*- End of function --------------------------------------------------------*/ +static void bell_ans_detected(void *user_data, int tone, int level, int delay) +{ + printf("%s (%d) declared at %fs, delay %d (%ddBm0)\n", modem_connect_tone_to_str(tone), tone, (float) when/SAMPLE_RATE, delay, level); + if (tone == MODEM_CONNECT_TONES_BELL_ANS) + hits++; +} +/*- End of function --------------------------------------------------------*/ + +static void calling_tone_detected(void *user_data, int tone, int level, int delay) +{ + printf("%s (%d) declared at %fs, delay %d (%ddBm0)\n", modem_connect_tone_to_str(tone), tone, (float) when/SAMPLE_RATE, delay, level); + if (tone == MODEM_CONNECT_TONES_CALLING_TONE) + hits++; +} +/*- End of function --------------------------------------------------------*/ + int main(int argc, char *argv[]) { int i; @@ -198,6 +228,8 @@ int main(int argc, char *argv[]) modem_connect_tones_rx_state_t ced_rx; modem_connect_tones_rx_state_t ans_pr_rx; modem_connect_tones_tx_state_t modem_tone_tx; + modem_connect_tones_rx_state_t calling_tone_rx; + modem_connect_tones_rx_state_t bell_ans_rx; awgn_state_t chan_noise_source; SNDFILE *inhandle; SNDFILE *outhandle; @@ -207,9 +239,6 @@ int main(int argc, char *argv[]) int hit; int false_hit; int false_miss; - power_meter_t power_state; - int power; - int max_power; int level2; int max_level2; int tone_type; @@ -247,6 +276,10 @@ int main(int argc, char *argv[]) test_list |= PERFORM_TEST_1D; else if (strcasecmp(argv[i], "1e") == 0) test_list |= PERFORM_TEST_1E; + else if (strcasecmp(argv[i], "1f") == 0) + test_list |= PERFORM_TEST_1F; + else if (strcasecmp(argv[i], "1g") == 0) + test_list |= PERFORM_TEST_1G; else if (strcasecmp(argv[i], "2a") == 0) test_list |= PERFORM_TEST_2A; else if (strcasecmp(argv[i], "2b") == 0) @@ -257,6 +290,10 @@ int main(int argc, char *argv[]) test_list |= PERFORM_TEST_2D; else if (strcasecmp(argv[i], "2e") == 0) test_list |= PERFORM_TEST_2E; + else if (strcasecmp(argv[i], "2f") == 0) + test_list |= PERFORM_TEST_2F; + else if (strcasecmp(argv[i], "2g") == 0) + test_list |= PERFORM_TEST_2G; else if (strcasecmp(argv[i], "3a") == 0) test_list |= PERFORM_TEST_3A; else if (strcasecmp(argv[i], "3b") == 0) @@ -267,6 +304,10 @@ int main(int argc, char *argv[]) test_list |= PERFORM_TEST_3D; else if (strcasecmp(argv[i], "3e") == 0) test_list |= PERFORM_TEST_3E; + else if (strcasecmp(argv[i], "3f") == 0) + test_list |= PERFORM_TEST_3F; + else if (strcasecmp(argv[i], "3g") == 0) + test_list |= PERFORM_TEST_3G; else if (strcasecmp(argv[i], "4") == 0) test_list |= PERFORM_TEST_4; else if (strcasecmp(argv[i], "5a") == 0) @@ -316,7 +357,7 @@ int main(int argc, char *argv[]) /*endfor*/ } /*endif*/ - + if ((test_list & PERFORM_TEST_1B)) { printf("Test 1b: CED/ANS generation to a file\n"); @@ -375,7 +416,7 @@ int main(int argc, char *argv[]) /*endfor*/ } /*endif*/ - + if ((test_list & PERFORM_TEST_1E)) { printf("Test 1e: ANSam/ (Modulated EC-disable) generation to a file\n"); @@ -396,13 +437,51 @@ int main(int argc, char *argv[]) } /*endif*/ + if ((test_list & PERFORM_TEST_1F)) + { + printf("Test 1f: Bell answer tone generation to a file\n"); + modem_connect_tones_tx_init(&modem_tone_tx, MODEM_CONNECT_TONES_BELL_ANS); + for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK) + { + samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK); + outframes = sf_writef_short(outhandle, amp, samples); + if (outframes != samples) + { + fprintf(stderr, " Error writing audio file\n"); + exit(2); + } + /*endif*/ + } + /*endfor*/ + } + /*endif*/ + + if ((test_list & PERFORM_TEST_1G)) + { + printf("Test 1g: Calling tone generation to a file\n"); + modem_connect_tones_tx_init(&modem_tone_tx, MODEM_CONNECT_TONES_CALLING_TONE); + for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK) + { + samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK); + outframes = sf_writef_short(outhandle, amp, samples); + if (outframes != samples) + { + fprintf(stderr, " Error writing audio file\n"); + exit(2); + } + /*endif*/ + } + /*endfor*/ + } + /*endif*/ + if (sf_close_telephony(outhandle)) { printf(" Cannot close audio file '%s'\n", OUTPUT_FILE_NAME); exit(2); } /*endif*/ - + if ((test_list & PERFORM_TEST_2A)) { printf("Test 2a: CNG detection with frequency\n"); @@ -410,16 +489,13 @@ int main(int argc, char *argv[]) awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); false_hit = FALSE; false_miss = FALSE; - for (pitch = 600; pitch <= 1600; pitch++) + for (pitch = 1100 - 500; pitch <= 1100 + 500; pitch++) { /* Use the transmitter to test the receiver */ modem_connect_tones_tx_init(&modem_tone_tx, tone_type); /* Fudge things for the test */ modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch); modem_connect_tones_rx_init(&cng_rx, tone_type, NULL, NULL); - power_meter_init(&power_state, 5); - power = 0; - max_power = 0; level2 = 0; max_level2 = 0; for (i = 0; i < 10*SAMPLE_RATE; i += SAMPLES_PER_CHUNK) @@ -428,10 +504,6 @@ int main(int argc, char *argv[]) for (j = 0; j < samples; j++) { amp[j] += awgn(&chan_noise_source); - power = power_meter_update(&power_state, amp[j]); - if (power > max_power) - max_power = power; - /*endif*/ level2 += ((abs(amp[j]) - level2) >> 5); if (level2 > max_level2) max_level2 = level2; @@ -455,7 +527,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, cng_rx.channel_level, cng_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, cng_rx.channel_level, cng_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -475,7 +547,7 @@ int main(int argc, char *argv[]) awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); false_hit = FALSE; false_miss = FALSE; - for (pitch = 1600; pitch < 2600; pitch++) + for (pitch = 2100 - 500; pitch < 2100 + 500; pitch++) { /* Use the transmitter to test the receiver */ modem_connect_tones_tx_init(&modem_tone_tx, MODEM_CONNECT_TONES_ANS); @@ -506,7 +578,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ced_rx.channel_level, ced_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ced_rx.channel_level, ced_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } if (false_hit || false_miss) @@ -526,7 +598,7 @@ int main(int argc, char *argv[]) awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); false_hit = FALSE; false_miss = FALSE; - for (pitch = 2000; pitch <= 2200; pitch++) + for (pitch = 2100 - 100; pitch <= 2100 + 100; pitch++) { /* Use the transmitter to test the receiver */ modem_connect_tones_tx_init(&modem_tone_tx, tone_type); @@ -557,7 +629,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -578,7 +650,7 @@ int main(int argc, char *argv[]) awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); false_hit = FALSE; false_miss = FALSE; - for (pitch = 2000; pitch <= 2200; pitch++) + for (pitch = 2100 - 100; pitch <= 2100 + 100; pitch++) { /* Use the transmitter to test the receiver */ modem_connect_tones_tx_init(&modem_tone_tx, tone_type); @@ -609,7 +681,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -630,7 +702,7 @@ int main(int argc, char *argv[]) awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); false_hit = FALSE; false_miss = FALSE; - for (pitch = 2000; pitch <= 2200; pitch++) + for (pitch = 2100 - 100; pitch <= 2100 + 100; pitch++) { /* Use the transmitter to test the receiver */ modem_connect_tones_tx_init(&modem_tone_tx, tone_type); @@ -661,7 +733,125 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); + /*endif*/ + } + /*endfor*/ + if (false_hit || false_miss) + { + printf("Test failed.\n"); + exit(2); + } + /*endif*/ + printf("Test passed.\n"); + } + /*endif*/ + + if ((test_list & PERFORM_TEST_2F)) + { + printf("Test 2f: Bell answer tone detection with frequency\n"); + tone_type = MODEM_CONNECT_TONES_BELL_ANS; + awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); + false_hit = FALSE; + false_miss = FALSE; + for (pitch = 2225 - 500; pitch <= 2225 + 500; pitch++) + { + /* Use the transmitter to test the receiver */ + modem_connect_tones_tx_init(&modem_tone_tx, tone_type); + /* Fudge things for the test */ + modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch); + modem_connect_tones_rx_init(&bell_ans_rx, tone_type, NULL, NULL); + level2 = 0; + max_level2 = 0; + for (i = 0; i < 8000; i += SAMPLES_PER_CHUNK) + { + samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK); + for (j = 0; j < samples; j++) + { + amp[j] += awgn(&chan_noise_source); + level2 += ((abs(amp[j]) - level2) >> 5); + if (level2 > max_level2) + max_level2 = level2; + } + /*endfor*/ + modem_connect_tones_rx(&bell_ans_rx, amp, samples); + } + /*endfor*/ + hit = modem_connect_tones_rx_get(&bell_ans_rx); + if (pitch < (2225 - BELL_ANS_FREQ_BLACKOUT) || pitch > (2225 + BELL_ANS_FREQ_BLACKOUT)) + { + if (hit != MODEM_CONNECT_TONES_NONE) + false_hit = TRUE; + /*endif*/ + } + else if (pitch > (2225 - BELL_ANS_FREQ_TOLERANCE) && pitch < (2225 + BELL_ANS_FREQ_TOLERANCE)) + { + if (hit != tone_type) + false_miss = TRUE; + /*endif*/ + } + /*endif*/ + if (hit != MODEM_CONNECT_TONES_NONE) + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, bell_ans_rx.channel_level, bell_ans_rx.notch_level, modem_connect_tone_to_str(hit), hit); + /*endif*/ + } + /*endfor*/ + if (false_hit || false_miss) + { + printf("Test failed.\n"); + exit(2); + } + /*endif*/ + printf("Test passed.\n"); + } + /*endif*/ + + if ((test_list & PERFORM_TEST_2G)) + { + printf("Test 2g: Calling tone detection with frequency\n"); + tone_type = MODEM_CONNECT_TONES_CALLING_TONE; + awgn_init_dbm0(&chan_noise_source, 7162534, -50.0f); + false_hit = FALSE; + false_miss = FALSE; + for (pitch = 1300 - 500; pitch <= 1300 + 500; pitch++) + { + /* Use the transmitter to test the receiver */ + modem_connect_tones_tx_init(&modem_tone_tx, tone_type); + /* Fudge things for the test */ + modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch); + modem_connect_tones_rx_init(&calling_tone_rx, tone_type, NULL, NULL); + level2 = 0; + max_level2 = 0; + for (i = 0; i < 10*SAMPLE_RATE; i += SAMPLES_PER_CHUNK) + { + samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK); + for (j = 0; j < samples; j++) + { + amp[j] += awgn(&chan_noise_source); + level2 += ((abs(amp[j]) - level2) >> 5); + if (level2 > max_level2) + max_level2 = level2; + } + /*endfor*/ + modem_connect_tones_rx(&calling_tone_rx, amp, samples); + } + /*endfor*/ + hit = modem_connect_tones_rx_get(&calling_tone_rx); + if (pitch < (1300 - CALLING_TONE_FREQ_BLACKOUT) || pitch > (1300 + CALLING_TONE_FREQ_BLACKOUT)) + { + if (hit != MODEM_CONNECT_TONES_NONE) + false_hit = TRUE; + /*endif*/ + } + else if (pitch > (1300 - CALLING_TONE_FREQ_TOLERANCE) && pitch < (1300 + CALLING_TONE_FREQ_TOLERANCE)) + { + if (hit != tone_type) + false_miss = TRUE; + /*endif*/ + } + /*endif*/ + if (hit != MODEM_CONNECT_TONES_NONE) + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, calling_tone_rx.channel_level, calling_tone_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -716,7 +906,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %d\n", pitch, level, cng_rx.channel_level, cng_rx.notch_level, hit); + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, cng_rx.channel_level, cng_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -773,7 +963,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %d\n", pitch, level, ced_rx.channel_level, ced_rx.notch_level, hit); + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, ced_rx.channel_level, ced_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -831,8 +1021,8 @@ int main(int argc, char *argv[]) /*endif*/ } /*endif*/ - //if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %d\n", pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + if (hit != MODEM_CONNECT_TONES_NONE) + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -889,7 +1079,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %d\n", pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -947,7 +1137,121 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %d\n", pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); + /*endif*/ + } + /*endfor*/ + } + /*endfor*/ + if (false_hit || false_miss) + { + printf("Test failed.\n"); + exit(2); + } + /*endif*/ + printf("Test passed.\n"); + } + /*endif*/ + + if ((test_list & PERFORM_TEST_3F)) + { + printf("Test 3f: Bell answer tone detection with level\n"); + tone_type = MODEM_CONNECT_TONES_BELL_ANS; + awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); + false_hit = FALSE; + false_miss = FALSE; + for (pitch = 2225 - BELL_ANS_FREQ_TOLERANCE; pitch <= 2225 + BELL_ANS_FREQ_TOLERANCE; pitch += 2*BELL_ANS_FREQ_TOLERANCE) + { + for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) + { + /* Use the transmitter to test the receiver */ + modem_connect_tones_tx_init(&modem_tone_tx, tone_type); + /* Fudge things for the test */ + modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch); + modem_tone_tx.level = dds_scaling_dbm0(level); + modem_connect_tones_rx_init(&calling_tone_rx, tone_type, NULL, NULL); + for (i = 0; i < 10*SAMPLE_RATE; i += SAMPLES_PER_CHUNK) + { + samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK); + for (j = 0; j < samples; j++) + amp[j] += awgn(&chan_noise_source); + /*endfor*/ + modem_connect_tones_rx(&calling_tone_rx, amp, samples); + } + /*endfor*/ + hit = modem_connect_tones_rx_get(&calling_tone_rx); + if (level < LEVEL_MIN_REJECT) + { + if (hit != MODEM_CONNECT_TONES_NONE) + false_hit = TRUE; + /*endif*/ + } + else if (level > LEVEL_MIN_ACCEPT) + { + if (hit != tone_type) + false_miss = TRUE; + /*endif*/ + } + /*endif*/ + if (hit != MODEM_CONNECT_TONES_NONE) + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, calling_tone_rx.channel_level, calling_tone_rx.notch_level, modem_connect_tone_to_str(hit), hit); + /*endif*/ + } + /*endfor*/ + } + /*endfor*/ + if (false_hit || false_miss) + { + printf("Test failed.\n"); + exit(2); + } + /*endif*/ + printf("Test passed.\n"); + } + /*endif*/ + + if ((test_list & PERFORM_TEST_3G)) + { + printf("Test 3g: Calling tone detection with level\n"); + tone_type = MODEM_CONNECT_TONES_CALLING_TONE; + awgn_init_dbm0(&chan_noise_source, 7162534, -60.0f); + false_hit = FALSE; + false_miss = FALSE; + for (pitch = 1300 - CALLING_TONE_FREQ_TOLERANCE; pitch <= 1300 + CALLING_TONE_FREQ_TOLERANCE; pitch += 2*CALLING_TONE_FREQ_TOLERANCE) + { + for (level = LEVEL_MAX; level >= LEVEL_MIN; level--) + { + /* Use the transmitter to test the receiver */ + modem_connect_tones_tx_init(&modem_tone_tx, tone_type); + /* Fudge things for the test */ + modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch); + modem_tone_tx.level = dds_scaling_dbm0(level); + modem_connect_tones_rx_init(&calling_tone_rx, tone_type, NULL, NULL); + for (i = 0; i < 10*SAMPLE_RATE; i += SAMPLES_PER_CHUNK) + { + samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK); + for (j = 0; j < samples; j++) + amp[j] += awgn(&chan_noise_source); + /*endfor*/ + modem_connect_tones_rx(&calling_tone_rx, amp, samples); + } + /*endfor*/ + hit = modem_connect_tones_rx_get(&calling_tone_rx); + if (level < LEVEL_MIN_REJECT) + { + if (hit != MODEM_CONNECT_TONES_NONE) + false_hit = TRUE; + /*endif*/ + } + else if (level > LEVEL_MIN_ACCEPT) + { + if (hit != tone_type) + false_miss = TRUE; + /*endif*/ + } + /*endif*/ + if (hit != MODEM_CONNECT_TONES_NONE) + printf("Detected at %5dHz %4ddB %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, level, calling_tone_rx.channel_level, calling_tone_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -1146,7 +1450,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -1198,7 +1502,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -1251,7 +1555,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -1304,7 +1608,7 @@ int main(int argc, char *argv[]) } /*endif*/ if (hit != MODEM_CONNECT_TONES_NONE) - printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %d\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit); + printf("Detected at %5dHz %12" PRId32 " %12" PRId32 " %s (%d)\n", pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, modem_connect_tone_to_str(hit), hit); /*endif*/ } /*endfor*/ @@ -1331,6 +1635,8 @@ int main(int argc, char *argv[]) modem_connect_tones_rx_init(&cng_rx, MODEM_CONNECT_TONES_FAX_CNG, NULL, NULL); modem_connect_tones_rx_init(&ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, NULL, NULL); modem_connect_tones_rx_init(&ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL); + modem_connect_tones_rx_init(&bell_ans_rx, MODEM_CONNECT_TONES_BELL_ANS, NULL, NULL); + modem_connect_tones_rx_init(&calling_tone_rx, MODEM_CONNECT_TONES_CALLING_TONE, NULL, NULL); for (j = 0; bellcore_files[j][0]; j++) { if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL) @@ -1348,6 +1654,8 @@ int main(int argc, char *argv[]) modem_connect_tones_rx(&cng_rx, amp, frames); modem_connect_tones_rx(&ced_rx, amp, frames); modem_connect_tones_rx(&ans_pr_rx, amp, frames); + modem_connect_tones_rx(&bell_ans_rx, amp, frames); + modem_connect_tones_rx(&calling_tone_rx, amp, frames); if (modem_connect_tones_rx_get(&cng_rx) != MODEM_CONNECT_TONES_NONE) { /* This is not a true measure of hits, as there might be more @@ -1372,6 +1680,20 @@ int main(int argc, char *argv[]) modem_connect_tones_rx_init(&ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL); } /*endif*/ + if (modem_connect_tones_rx_get(&bell_ans_rx) != MODEM_CONNECT_TONES_NONE) + { + printf("Hit calling tone at %ds\n", when); + hits++; + modem_connect_tones_rx_init(&bell_ans_rx, MODEM_CONNECT_TONES_BELL_ANS, NULL, NULL); + } + /*endif*/ + if (modem_connect_tones_rx_get(&calling_tone_rx) != MODEM_CONNECT_TONES_NONE) + { + printf("Hit calling tone at %ds\n", when); + hits++; + modem_connect_tones_rx_init(&calling_tone_rx, MODEM_CONNECT_TONES_CALLING_TONE, NULL, NULL); + } + /*endif*/ } /*endwhile*/ if (sf_close_telephony(inhandle)) @@ -1399,6 +1721,8 @@ int main(int argc, char *argv[]) modem_connect_tones_rx_init(&cng_rx, MODEM_CONNECT_TONES_FAX_CNG, cng_detected, NULL); modem_connect_tones_rx_init(&ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, ced_detected, NULL); modem_connect_tones_rx_init(&ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, ans_pr_detected, NULL); + modem_connect_tones_rx_init(&bell_ans_rx, MODEM_CONNECT_TONES_BELL_ANS, bell_ans_detected, NULL); + modem_connect_tones_rx_init(&calling_tone_rx, MODEM_CONNECT_TONES_CALLING_TONE, calling_tone_detected, NULL); hits = 0; if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL) { @@ -1415,6 +1739,8 @@ int main(int argc, char *argv[]) modem_connect_tones_rx(&cng_rx, amp, frames); modem_connect_tones_rx(&ced_rx, amp, frames); modem_connect_tones_rx(&ans_pr_rx, amp, frames); + modem_connect_tones_rx(&bell_ans_rx, amp, frames); + modem_connect_tones_rx(&calling_tone_rx, amp, frames); } /*endwhile*/ if (sf_close_telephony(inhandle)) @@ -1426,7 +1752,7 @@ int main(int argc, char *argv[]) printf(" File gave %d hits.\n", hits); } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/modem_echo_tests.c b/libs/spandsp/tests/modem_echo_tests.c index 07ffa0e7ed..6b986d79da 100644 --- a/libs/spandsp/tests/modem_echo_tests.c +++ b/libs/spandsp/tests/modem_echo_tests.c @@ -246,7 +246,7 @@ static int16_t channel_model(int16_t local, int16_t far) /* This mixed echo and far end signal will have been through an A-law munging when it came back into the digital network. */ rx = codec_munger(rx); - return rx; + return rx; } /*- End of function --------------------------------------------------------*/ @@ -392,7 +392,7 @@ int main(int argc, char *argv[]) #endif printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/modem_monitor.cpp b/libs/spandsp/tests/modem_monitor.cpp index a5ba73289f..db8a31a22d 100644 --- a/libs/spandsp/tests/modem_monitor.cpp +++ b/libs/spandsp/tests/modem_monitor.cpp @@ -52,10 +52,10 @@ #define SYMBOL_TRACKER_POINTS 12000 #define CARRIER_TRACKER_POINTS 12000 -#define FP_FACTOR 4096 - struct qam_monitor_s { + float constel_scaling; + Fl_Double_Window *w; Fl_Group *c_const; Fl_Group *c_right; @@ -189,14 +189,14 @@ int qam_monitor_update_equalizer(qam_monitor_t *s, const complexf_t *coeffs, int for (i = 0; i < len; i++) { s->eq_re_plot[2*i] = (i - len/2)/2.0; - s->eq_re_plot[2*i + 1] = coeffs[i].re; + s->eq_re_plot[2*i + 1] = coeffs[i].re*s->constel_scaling; if (min > coeffs[i].re) min = coeffs[i].re; if (max < coeffs[i].re) max = coeffs[i].re; s->eq_im_plot[2*i] = (i - len/2)/2.0; - s->eq_im_plot[2*i + 1] = coeffs[i].im; + s->eq_im_plot[2*i + 1] = coeffs[i].im*s->constel_scaling; if (min > coeffs[i].im) min = coeffs[i].im; if (max < coeffs[i].im) @@ -235,22 +235,22 @@ int qam_monitor_update_int_equalizer(qam_monitor_t *s, const complexi16_t *coeff max = coeffs[i].im; for (i = 0; i < len; i++) { - s->eq_re_plot[2*i] = (i - len/2)/2.0f; - s->eq_re_plot[2*i + 1] = coeffs[i].re/(float) FP_FACTOR; if (min > coeffs[i].re) min = coeffs[i].re; if (max < coeffs[i].re) max = coeffs[i].re; + s->eq_re_plot[2*i] = (i - len/2)/2.0f; + s->eq_re_plot[2*i + 1] = coeffs[i].re*s->constel_scaling; - s->eq_im_plot[2*i] = (i - len/2)/2.0f; - s->eq_im_plot[2*i + 1] = coeffs[i].im/(float) FP_FACTOR; if (min > coeffs[i].im) min = coeffs[i].im; if (max < coeffs[i].im) max = coeffs[i].im; + s->eq_im_plot[2*i] = (i - len/2)/2.0f; + s->eq_im_plot[2*i + 1] = coeffs[i].im*s->constel_scaling; } - min /= (float) FP_FACTOR; - max /= (float) FP_FACTOR; + min *= s->constel_scaling; + max *= s->constel_scaling; s->eq_x->minimum(-len/4.0); s->eq_x->maximum(len/4.0); @@ -286,21 +286,21 @@ int qam_monitor_update_symbol_tracking(qam_monitor_t *s, float total_correction) max = s->symbol_tracker[0]; for (i = s->symbol_track_ptr, j = 0; i < s->symbol_track_points; i++, j++) { - s->symbol_track_plot[2*j] = j; - s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i]; if (min > s->symbol_tracker[i]) min = s->symbol_tracker[i]; if (max < s->symbol_tracker[i]) max = s->symbol_tracker[i]; + s->symbol_track_plot[2*j] = j; + s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i]; } for (i = 0; i < s->symbol_track_ptr; i++, j++) { - s->symbol_track_plot[2*j] = j; - s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i]; if (min > s->symbol_tracker[i]) min = s->symbol_tracker[i]; if (max < s->symbol_tracker[i]) max = s->symbol_tracker[i]; + s->symbol_track_plot[2*j] = j; + s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i]; } s->symbol_track_y->maximum((fabs(max - min) < 0.05) ? max + 0.05 : max); s->symbol_track_y->minimum(min); @@ -379,7 +379,7 @@ int qam_monitor_update_carrier_tracking(qam_monitor_t *s, float carrier_freq) } /*- End of function --------------------------------------------------------*/ -qam_monitor_t *qam_monitor_init(float constel_width, const char *tag) +qam_monitor_t *qam_monitor_init(float constel_width, float constel_scaling, const char *tag) { char buf[132 + 1]; float x; @@ -391,6 +391,8 @@ qam_monitor_t *qam_monitor_init(float constel_width, const char *tag) s->w = new Fl_Double_Window(905, 400, (tag) ? tag : "QAM monitor"); + s->constel_scaling = 1.0/constel_scaling; + s->c_const = new Fl_Group(0, 0, 380, 400); s->c_const->box(FL_DOWN_BOX); s->c_const->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE); diff --git a/libs/spandsp/tests/modem_monitor.h b/libs/spandsp/tests/modem_monitor.h index b1b79fda06..3a3f896b8a 100644 --- a/libs/spandsp/tests/modem_monitor.h +++ b/libs/spandsp/tests/modem_monitor.h @@ -50,7 +50,7 @@ extern "C" { #endif -qam_monitor_t *qam_monitor_init(float constel_width, const char *tag); +qam_monitor_t *qam_monitor_init(float constel_width, float constel_scaling, const char *tag); int qam_monitor_clear_constel(qam_monitor_t *s); int qam_monitor_update_constel(qam_monitor_t *s, const complexf_t *pt); int qam_monitor_update_equalizer(qam_monitor_t *s, const complexf_t *coeffs, int len); diff --git a/libs/spandsp/tests/msvc/adsi_tests.vcproj b/libs/spandsp/tests/msvc/adsi_tests.vcproj index c9f443cea2..b76e06ecbf 100644 --- a/libs/spandsp/tests/msvc/adsi_tests.vcproj +++ b/libs/spandsp/tests/msvc/adsi_tests.vcproj @@ -41,7 +41,7 @@ +tiff-4.0.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/spandsp/tests/msvc/v22bis_tests.vcproj b/libs/spandsp/tests/msvc/v22bis_tests.vcproj index eff603b122..fc69b38d46 100644 --- a/libs/spandsp/tests/msvc/v22bis_tests.vcproj +++ b/libs/spandsp/tests/msvc/v22bis_tests.vcproj @@ -41,7 +41,7 @@ $STDOUT_DEST 2>$STDERR_DEST - RETVAL=$? - if [ $RETVAL != 0 ] - then - echo fax_tests ${OPTS} -i ${FILE} failed! - exit $RETVAL - fi - # Now use tiffcmp to check the results. It will return non-zero if any page images differ. The -t - # option means the normal differences in tags will be ignored. - tiffcmp -t ${FILE} fax_tests.tif >/dev/null - RETVAL=$? - if [ $RETVAL != 0 ] - then - echo fax_tests ${OPTS} -i ${FILE} failed! - exit $RETVAL - fi - echo fax_tests ${OPTS} -i ${FILE} completed OK - done -done -echo fax_tests completed OK +./fax_tests.sh +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo fax_tests.sh failed! + exit $RETVAL +fi +echo fax_tests.sh completed OK ./fsk_tests >$STDOUT_DEST 2>$STDERR_DEST RETVAL=$? @@ -516,7 +499,23 @@ fi echo t38_non_ecm_buffer_tests completed OK rm -f t4_tests_receive.tif -./t4_tests >$STDOUT_DEST 2>$STDERR_DEST +./t4_tests -b 0 >$STDOUT_DEST 2>$STDERR_DEST +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo t4_tests failed! + exit $RETVAL +fi +rm -f t4_tests_receive.tif +./t4_tests -b 1 >$STDOUT_DEST 2>$STDERR_DEST +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo t4_tests failed! + exit $RETVAL +fi +rm -f t4_tests_receive.tif +./t4_tests -b 10 >$STDOUT_DEST 2>$STDERR_DEST RETVAL=$? if [ $RETVAL != 0 ] then @@ -525,38 +524,35 @@ then fi echo t4_tests completed OK -#rm -f t4_t6_tests_receive.tif -#./t4_t6_tests >$STDOUT_DEST 2>$STDERR_DEST -#RETVAL=$? -#if [ $RETVAL != 0 ] -#then -# echo t4_t6_tests failed! -# exit $RETVAL -#fi -#echo t4_t6_tests completed OK -echo t4_t6_tests not enabled +rm -f t4_t6_tests_receive.tif +./t4_t6_tests >$STDOUT_DEST 2>$STDERR_DEST +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo t4_t6_tests failed! + exit $RETVAL +fi +echo t4_t6_tests completed OK -#rm -f t81_t82_arith_coding_tests_receive.tif -#./t4_tests >$STDOUT_DEST 2>$STDERR_DEST -#RETVAL=$? -#if [ $RETVAL != 0 ] -#then -# echo t81_t82_arith_coding_tests failed! -# exit $RETVAL -#fi -#echo t81_t82_arith_coding_tests completed OK -echo t81_t82_arith_coding_tests not enabled +rm -f t81_t82_arith_coding_tests_receive.tif +./t81_t82_arith_coding_tests >$STDOUT_DEST 2>$STDERR_DEST +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo t81_t82_arith_coding_tests failed! + exit $RETVAL +fi +echo t81_t82_arith_coding_tests completed OK -#rm -f t85_tests_receive.tif -#./t85_tests >$STDOUT_DEST 2>$STDERR_DEST -#RETVAL=$? -#if [ $RETVAL != 0 ] -#then -# echo t85_tests failed! -# exit $RETVAL -#fi -#echo t85_tests completed OK -echo t85_tests not enabled +rm -f t85_tests_receive.tif +./t85_tests >$STDOUT_DEST 2>$STDERR_DEST +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo t85_tests failed! + exit $RETVAL +fi +echo t85_tests completed OK #./time_scale_tests >$STDOUT_DEST 2>$STDERR_DEST #RETVAL=$? @@ -597,6 +593,22 @@ echo tone_detect_tests not enabled #echo tone_generate_tests completed OK echo tone_generate_tests not enabled +./tsb85_tests.sh >/dev/null +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo ./tsb85_tests.sh failed! + exit $RETVAL +fi +./tsb85_extra_tests.sh +RETVAL=$? +if [ $RETVAL != 0 ] +then + echo ./tsb85_extra_tests.sh failed! + exit $RETVAL +fi +echo tsb85_tests.sh completed OK + for OPTS in "-b 14400 -s -42 -n -66" "-b 12000 -s -42 -n -61" "-b 9600 -s -42 -n -59" "-b 7200 -s -42 -n -56" do ./v17_tests ${OPTS} >$STDOUT_DEST 2>$STDERR_DEST @@ -634,7 +646,7 @@ do done echo v27ter_tests completed OK -for OPTS in "-b 9600 -s -42 -n -62" "-b 7200 -s -42 -n -58" "-b 4800 -s -42 -n -55" +for OPTS in "-b 9600 -s -42 -n -62" "-b 7200 -s -42 -n -59" "-b 4800 -s -42 -n -54" do ./v29_tests ${OPTS} >$STDOUT_DEST 2>$STDERR_DEST RETVAL=$? @@ -672,10 +684,10 @@ echo v42_tests completed OK RETVAL=$? if [ $RETVAL != 0 ] then - echo v42bis_tests failed! + echo v42bis_tests.sh failed! exit $RETVAL fi -echo v42bis_tests completed OK +echo v42bis_tests.sh completed OK ./v8_tests >$STDOUT_DEST 2>$STDERR_DEST RETVAL=$? diff --git a/libs/spandsp/tests/saturated_tests.c b/libs/spandsp/tests/saturated_tests.c index de2a40bcc2..419020cd1b 100644 --- a/libs/spandsp/tests/saturated_tests.c +++ b/libs/spandsp/tests/saturated_tests.c @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) exit(2); } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/schedule_tests.c b/libs/spandsp/tests/schedule_tests.c index 81c467c927..f1b19bc946 100644 --- a/libs/spandsp/tests/schedule_tests.c +++ b/libs/spandsp/tests/schedule_tests.c @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) int i; span_sched_state_t sched; uint64_t when; - + span_schedule_init(&sched); span_schedule_event(&sched, 500000, callback1, NULL); @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) span_schedule_release(&sched); printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/sig_tone_tests.c b/libs/spandsp/tests/sig_tone_tests.c index 7f1311a92a..b967fecabd 100644 --- a/libs/spandsp/tests/sig_tone_tests.c +++ b/libs/spandsp/tests/sig_tone_tests.c @@ -656,7 +656,7 @@ int main(int argc, char *argv[]) /*endfor*/ printf("Tests completed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/super_tone_rx_tests.c b/libs/spandsp/tests/super_tone_rx_tests.c index 717768d0c5..4e37a9961d 100644 --- a/libs/spandsp/tests/super_tone_rx_tests.c +++ b/libs/spandsp/tests/super_tone_rx_tests.c @@ -198,7 +198,7 @@ static int parse_tone(super_tone_rx_descriptor_t *desc, int tone_id, super_tone_ cur = cur->next; } /*endwhile*/ - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -410,7 +410,6 @@ static int detection_range_tests(super_tone_rx_state_t *super) int16_t amp[SAMPLES_PER_CHUNK]; int i; int j; - int x; uint32_t phase; int32_t phase_inc; int scale; @@ -427,7 +426,7 @@ static int detection_range_tests(super_tone_rx_state_t *super) { for (i = 0; i < SAMPLES_PER_CHUNK; i++) amp[i] = (dds(&phase, phase_inc)*scale) >> 15; - x = super_tone_rx(super, amp, SAMPLES_PER_CHUNK); + super_tone_rx(super, amp, SAMPLES_PER_CHUNK); } } return 0; diff --git a/libs/spandsp/tests/super_tone_tx_tests.c b/libs/spandsp/tests/super_tone_tx_tests.c index 2fabbbd7c9..51b6eeaeb7 100644 --- a/libs/spandsp/tests/super_tone_tx_tests.c +++ b/libs/spandsp/tests/super_tone_tx_tests.c @@ -177,7 +177,7 @@ static int parse_tone(super_tone_tx_step_t **tree, xmlDocPtr doc, xmlNsPtr ns, x cur = cur->next; } /*endwhile*/ - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/swept_tone_tests.c b/libs/spandsp/tests/swept_tone_tests.c index c806701afa..9ff6bc462f 100644 --- a/libs/spandsp/tests/swept_tone_tests.c +++ b/libs/spandsp/tests/swept_tone_tests.c @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) } printf("Tests passed.\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t31_tests.c b/libs/spandsp/tests/t31_tests.c index 7f5e7c00a8..a5a1293167 100644 --- a/libs/spandsp/tests/t31_tests.c +++ b/libs/spandsp/tests/t31_tests.c @@ -934,7 +934,7 @@ int main(int argc, char *argv[]) t30_tests(t38_mode, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no); printf("Tests passed\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t35_tests.c b/libs/spandsp/tests/t35_tests.c index d5edaf4f50..78ab3a1ca4 100644 --- a/libs/spandsp/tests/t35_tests.c +++ b/libs/spandsp/tests/t35_tests.c @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) printf("Decoded as %s %s %s\n", (country) ? country : "???", (vendor) ? vendor : "???", (model) ? model : "???"); printf("Tests passed\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t38_core_tests.c b/libs/spandsp/tests/t38_core_tests.c index c986d90c5d..b765e9805e 100644 --- a/libs/spandsp/tests/t38_core_tests.c +++ b/libs/spandsp/tests/t38_core_tests.c @@ -479,7 +479,7 @@ int main(int argc, char *argv[]) int attack_packets; int opt; - attack_packets = 10000000; + attack_packets = 100000; while ((opt = getopt(argc, argv, "a:")) != -1) { switch (opt) @@ -728,7 +728,7 @@ int main(int argc, char *argv[]) exit(2); } printf("Tests passed\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t38_non_ecm_buffer_tests.c b/libs/spandsp/tests/t38_non_ecm_buffer_tests.c index 1794cf6e6d..5248259b99 100644 --- a/libs/spandsp/tests/t38_non_ecm_buffer_tests.c +++ b/libs/spandsp/tests/t38_non_ecm_buffer_tests.c @@ -699,7 +699,7 @@ int main(int argc, char *argv[]) t38_non_ecm_buffer_report_output_status(&buffer, &logging); printf("Tests passed\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t42_tests.c b/libs/spandsp/tests/t42_tests.c new file mode 100644 index 0000000000..588bfdd3fe --- /dev/null +++ b/libs/spandsp/tests/t42_tests.c @@ -0,0 +1,600 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t42_tests.c - ITU T.42 JPEG for FAX image processing + * + * Written by Steve Underwood + * + * Copyright (C) 2011 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +/*! \page t42_tests_page T.42 tests +\section t42_tests_page_sec_1 What does it do +*/ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +//#if defined(WITH_SPANDSP_INTERNALS) +#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES +//#endif + +#include "spandsp.h" + +#if defined(SPANDSP_SUPPORT_TIFF_FX) +//#include +#endif + +//#define IN_FILE_NAME "../test-data/itu/t24/F21_200.TIF" +#define IN_FILE_NAME "../test-data/itu/t24/F21B400.TIF" +#define OUT_FILE_NAME "t42_tests_receive.tif" + +uint8_t data5[50000000]; +int data5_ptr = 0; +int plane = 0; +int bit_mask; + +uint8_t colour_map[3*256]; + +lab_params_t lab_param; + +int write_row = 0; + +static __inline__ uint16_t pack_16(uint8_t *s) +{ + uint16_t value; + + value = ((uint16_t) s[0] << 8) | (uint16_t) s[1]; + return value; +} +/*- End of function --------------------------------------------------------*/ + +static __inline__ uint32_t pack_32(uint8_t *s) +{ + uint32_t value; + + value = ((uint32_t) s[0] << 24) | ((uint32_t) s[1] << 16) | ((uint32_t) s[2] << 8) | (uint32_t) s[3]; + return value; +} +/*- End of function --------------------------------------------------------*/ + +static int t85_row_write_handler(void *user_data, const uint8_t buf[], size_t len) +{ + int i; + int j; + + for (i = 0; i < len; i++) + { + for (j = 0; j < 8; j++) + { + if ((buf[i] & (0x80 >> j))) + data5[data5_ptr + 3*(8*i + j)] |= bit_mask; + else + data5[data5_ptr + 3*(8*i + j)] &= ~bit_mask; + } + } + data5_ptr += 3*8*len; + write_row++; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int t85_comment_handler(void *user_data, const uint8_t buf[], size_t len) +{ + if (buf) + printf("Comment (%lu): %s\n", (unsigned long int) len, buf); + else + printf("Comment (%lu): ---\n", (unsigned long int) len); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + TIFF *tif; + uint32_t w; + uint32_t h; + tstrip_t nstrips; + uint32_t totdata; + tsize_t off; + uint8_t *data; + uint8_t *data2; + int row; + uint16_t compression; + int16_t photometric; + int16_t YCbCrSubsampleHoriz; + int16_t YCbCrSubsampleVert; + int16_t bits_per_pixel; + int16_t samples_per_pixel; + int16_t planar_config; + int bytes_per_row; + tsize_t outsize; + char *outptr; + const char *source_file; + int i; + int j; + int len; + tsize_t total_image_len; + tsize_t total_len; + int process_raw; + int result; + t85_decode_state_t t85_dec; + uint64_t start; + uint64_t end; + uint16_t *map_L; + uint16_t *map_a; + uint16_t *map_b; + uint16_t *map_z; + uint32_t jpeg_table_len; + logging_state_t *logging; + + printf("Demo of ITU/Lab library.\n"); + + logging = span_log_init(NULL, SPAN_LOG_FLOW, "T.42"); + + TIFF_FX_init(); + + set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + + source_file = (argc > 1) ? argv[1] : IN_FILE_NAME; + /* sRGB to ITU */ + if ((tif = TIFFOpen(source_file, "r")) == NULL) + { + printf("Unable to open '%s'!\n", source_file); + return 1; + } + if (TIFFSetDirectory(tif, (tdir_t) 0) < 0) + { + printf("Unable to set directory '%s'!\n", source_file); + return 1; + } + + w = 0; + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + h = 0; + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + bits_per_pixel = 0; + TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits_per_pixel); + samples_per_pixel = 0; + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); + compression = 0; + TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); + photometric = 0; + TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); + YCbCrSubsampleHoriz = 0; + YCbCrSubsampleVert = 0; + TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING, &YCbCrSubsampleHoriz, &YCbCrSubsampleVert); + planar_config = 0; + TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planar_config); + off = 0; + + map_L = NULL; + map_a = NULL; + map_b = NULL; + map_z = NULL; + if (TIFFGetField(tif, TIFFTAG_COLORMAP, &map_L, &map_a, &map_b, &map_z)) + { +#if 0 + /* Sweep the colormap in the proper order */ + for (i = 0; i < (1 << bits_per_pixel); i++) + { + colour_map[3*i] = (map_L[i] >> 8) & 0xFF; + colour_map[3*i + 1] = (map_a[i] >> 8) & 0xFF; + colour_map[3*i + 2] = (map_b[i] >> 8) & 0xFF; + printf("Map %3d - %5d %5d %5d\n", i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]); + } +#else + /* Sweep the colormap in the order that seems to work for l04x_02x.tif */ + for (i = 0; i < (1 << bits_per_pixel); i++) + { + colour_map[i] = (map_L[i] >> 8) & 0xFF; + colour_map[256 + i] = (map_a[i] >> 8) & 0xFF; + colour_map[2*256 + i] = (map_b[i] >> 8) & 0xFF; + } +#endif + lab_params_t lab; + + set_lab_illuminant(&lab, 0.9638f, 1.0f, 0.8245f); + set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, FALSE); + lab_to_srgb(&lab, colour_map, colour_map, 256); + for (i = 0; i < (1 << bits_per_pixel); i++) + printf("Map %3d - %5d %5d %5d\n", i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]); + } + else + { + printf("There is no colour map\n"); + } + process_raw = FALSE; + printf("Compression is "); + switch (compression) + { + case COMPRESSION_CCITT_T4: + printf("T.4\n"); + return 0; + case COMPRESSION_CCITT_T6: + printf("T.6\n"); + return 0; + case COMPRESSION_T85: + printf("T.85\n"); + process_raw = TRUE; + break; + case COMPRESSION_T43: + printf("T.43\n"); + process_raw = TRUE; + break; + case COMPRESSION_JPEG: + printf("JPEG"); + if (photometric == PHOTOMETRIC_ITULAB) + { + printf(" ITULAB"); + process_raw = TRUE; + } + printf("\n"); + break; + case COMPRESSION_NONE: + printf("No compression\n"); + break; + default: + printf("Unexpected compression %d\n", compression); + break; + } + + if (process_raw) + { + uint8_t *jpeg_table; + + nstrips = TIFFNumberOfStrips(tif); + + total_image_len = 0; + jpeg_table_len = 0; + if (TIFFGetField(tif, TIFFTAG_JPEGTABLES, &jpeg_table_len, &jpeg_table)) + { + total_image_len += (jpeg_table_len - 4); + printf("JPEG tables %u\n", jpeg_table_len); + printf("YYY %d - %x %x %x %x\n", jpeg_table_len, jpeg_table[0], jpeg_table[1], jpeg_table[2], jpeg_table[3]); + } + + for (i = 0, total_image_len = 0; i < nstrips; i++) + total_image_len += TIFFRawStripSize(tif, i); + data = malloc(total_image_len); + for (i = 0, total_len = 0; i < nstrips; i++, total_len += len) + { + if ((len = TIFFReadRawStrip(tif, i, &data[total_len], total_image_len - total_len)) < 0) + { + printf("TIFF read error.\n"); + return -1; + } + } + if (jpeg_table_len > 0) + memcpy(data, jpeg_table, jpeg_table_len - 2); + + if (total_len != total_image_len) + printf("Size mismatch %ld %ld\n", total_len, total_image_len); + off = total_len; + switch (compression) + { + case COMPRESSION_CCITT_T4: + break; + case COMPRESSION_CCITT_T6: + break; + case COMPRESSION_T85: + printf("T.85 image %ld bytes\n", total_len); + for (i = 0; i < 16; i++) + printf("0x%02x\n", data[i]); + t85_decode_init(&t85_dec, t85_row_write_handler, NULL); + t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL); + result = t85_decode_put(&t85_dec, data, total_len); + if (result == T4_DECODE_MORE_DATA) + result = t85_decode_put(&t85_dec, NULL, 0); + len = t85_decode_get_compressed_image_size(&t85_dec); + printf("Compressed image is %d bytes, %d rows\n", len/8, write_row); + t85_decode_release(&t85_dec); + return 0; + case COMPRESSION_T43: + printf("T.43 image %ld bytes\n", total_len); + if (pack_16(data) == 0xFFA8) + { + data += 2; + total_len -= 2; + for (;;) + { + if (pack_16(data) == 0xFFE1) + { + data += 2; + total_len -= 2; + len = pack_16(data); + data += len; + total_len -= len; + } + else if (pack_16(data) == 0xFFE3) + { + data += 2; + total_len -= 2; + len = pack_32(data); + data += len; + total_len -= len; + } + else + { + break; + } + } + } + + bit_mask = 0x80; + t85_decode_init(&t85_dec, t85_row_write_handler, NULL); + t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL); + t85_dec.min_bit_planes = 1; + t85_dec.max_bit_planes = 8; + data5_ptr = 0; + result = t85_decode_put(&t85_dec, data, total_len); + len = t85_decode_get_compressed_image_size(&t85_dec); + printf("Compressed image is %d bytes, %d rows\n", len/8, write_row); + + for (j = 1; j < t85_dec.bit_planes; j++) + { + bit_mask >>= 1; + data += len/8; + total_len -= len/8; + t85_decode_new_plane(&t85_dec); + data5_ptr = 0; + t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL); + result = t85_decode_put(&t85_dec, data, total_len); + len = t85_decode_get_compressed_image_size(&t85_dec); + printf("Compressed image is %d bytes, %d rows\n", len/8, write_row); + } + if (result == T4_DECODE_MORE_DATA) + { + printf("More\n"); + result = t85_decode_put(&t85_dec, NULL, 0); + } + len = t85_decode_get_compressed_image_size(&t85_dec); + printf("Compressed image is %d bytes, %d rows\n", len/8, write_row); + t85_decode_release(&t85_dec); + + for (j = 0; j < data5_ptr; j += 3) + { + i = data5[j] & 0xFF; +//printf("%d %d %d %d %d %d\n", data5_ptr, j, i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]); + data5[j] = colour_map[3*i]; + data5[j + 1] = colour_map[3*i + 1]; + data5[j + 2] = colour_map[3*i + 2]; + } + + if ((tif = TIFFOpen(OUT_FILE_NAME, "w")) == NULL) + { + printf("Unable to open '%s'!\n", OUT_FILE_NAME); + return 1; + } + TIFFSetField(tif, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE); + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w); + // libtiff requires IMAGELENGTH to be set before SAMPLESPERPIXEL, + // or StripOffsets and StripByteCounts will have SAMPLESPERPIXEL values + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h); + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, (uint32) -1); + TIFFSetField(tif, TIFFTAG_XRESOLUTION, 200.0f); + TIFFSetField(tif, TIFFTAG_YRESOLUTION, 200.0f); + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + TIFFSetField(tif, TIFFTAG_SOFTWARE, "spandsp"); + TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, "Test"); + TIFFSetField(tif, TIFFTAG_DATETIME, "2012/07/03 12:30:45"); + TIFFSetField(tif, TIFFTAG_MAKE, "soft-switch.org"); + TIFFSetField(tif, TIFFTAG_MODEL, "spandsp"); + TIFFSetField(tif, TIFFTAG_HOSTCOMPUTER, "i7.coppice.org"); + + for (off = 0, i = 0; i < h; off += w*3, i++) + { + TIFFWriteScanline(tif, data5 + off, i, 0); + } + TIFFWriteDirectory(tif); + TIFFClose(tif); + return 0; + case COMPRESSION_JPEG: + break; + } + } + else + { + printf("Width %d, height %d, bits %d, samples %d\n", w, h, bits_per_pixel, samples_per_pixel); + + bytes_per_row = (bits_per_pixel + 7)/8; + bytes_per_row *= w*samples_per_pixel; + totdata = h*bytes_per_row; + printf("total %d\n", totdata); + + /* Read the image into memory. */ + data = malloc(totdata); + off = 0; + for (row = 0; row < h; row++) + { + if (TIFFReadScanline(tif, data + off, row, 0) < 0) + return 1; + off += bytes_per_row; + } + printf("total %u, off %ld\n", totdata, off); + + /* We now have the image in memory in RGB form */ + + if (photometric == PHOTOMETRIC_ITULAB) + { + printf("YYY ITULAB\n"); + + if (!t42_itulab_to_itulab(logging, (tdata_t) &outptr, &outsize, data, off, w, h)) + { + printf("Failed to convert to ITULAB\n"); + return 1; + } + free(data); + data = (uint8_t *) outptr; + off = outsize; + } + else + { + start = rdtscll(); + switch (photometric) + { + case PHOTOMETRIC_CIELAB: + printf("CIELAB\n"); + /* The default luminant is D50 */ + set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f); + set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, TRUE); + lab_to_srgb(&lab_param, data, data, w*h); + break; + case PHOTOMETRIC_ITULAB: + set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); + break; + } + if (!t42_srgb_to_itulab(logging, &lab_param, (tdata_t) &outptr, &outsize, data, off, w, h)) + { + printf("Failed to convert to ITULAB\n"); + return 1; + } + end = rdtscll(); + printf("Duration %" PRIu64 "\n", end - start); + free(data); + data = (uint8_t *) outptr; + off = outsize; + } + } + TIFFClose(tif); + + printf("XXX - image is %d by %d, %ld bytes\n", w, h, off); + + /* We now have the image in memory in ITULAB form */ + + if ((tif = TIFFOpen(OUT_FILE_NAME, "w")) == NULL) + { + printf("Unable to open '%s'!\n", OUT_FILE_NAME); + return 1; + } + TIFFSetField(tif, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE); + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w); + /* libtiff requires IMAGELENGTH to be set before SAMPLESPERPIXEL, + or StripOffsets and StripByteCounts will have SAMPLESPERPIXEL values */ + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h); + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, (uint32) -1); + TIFFSetField(tif, TIFFTAG_XRESOLUTION, 200.0f); + TIFFSetField(tif, TIFFTAG_YRESOLUTION, 200.0f); + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + TIFFSetField(tif, TIFFTAG_SOFTWARE, "spandsp"); + TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, "Test"); + TIFFSetField(tif, TIFFTAG_DATETIME, "2012/07/03 12:30:45"); + TIFFSetField(tif, TIFFTAG_MAKE, "soft-switch.org"); + TIFFSetField(tif, TIFFTAG_MODEL, "spandsp"); + TIFFSetField(tif, TIFFTAG_HOSTCOMPUTER, "i7.coppice.org"); + + if (1) + { + /* Most image processors won't know what to do with the ITULAB colorspace. + So we'll be converting it to RGB for portability. */ +#if 1 + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); +#else + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); +#endif + if (YCbCrSubsampleHoriz || YCbCrSubsampleVert) + TIFFSetField(tif, TIFFTAG_YCBCRSUBSAMPLING, YCbCrSubsampleHoriz, YCbCrSubsampleVert); + bytes_per_row = (bits_per_pixel + 7)/8; + bytes_per_row *= w*samples_per_pixel; + totdata = h*bytes_per_row; + set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f); + set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE); +#if 0 + start = rdtscll(); + data2 = NULL; + totdata = 0; + t42_itulab_to_jpeg(logging, &lab_param, (void **) &data2, &totdata, data, off); + end = rdtscll(); + printf("Duration %" PRIu64 "\n", end - start); + printf("Compressed length %d (%p)\n", totdata, data2); + if (TIFFWriteRawStrip(tif, 0, data2, totdata) < 0) + { + printf("Failed to convert from ITULAB\n"); + return 1; + } + free(data); +#else + data2 = malloc(totdata); + start = rdtscll(); + if (!t42_itulab_to_srgb(logging, &lab_param, data2, &off, data, off, &w, &h)) + { + printf("Failed to convert from ITULAB\n"); + return 1; + } + end = rdtscll(); + printf("Duration %" PRIu64 "\n", end - start); + free(data); + + off = 0; + bytes_per_row = (8 + 7)/8; + bytes_per_row *= (w*3); + for (row = 0; row < h; row++) + { + if (TIFFWriteScanline(tif, data2 + off, row, 0) < 0) + return 1; + off += bytes_per_row; + } +#endif + free(data2); + } + else + { +#if 1 + /* If PHOTOMETRIC_ITULAB is not available the admin cannot enable color fax anyway. + This is done so that older libtiffs without it can build fine. */ + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_ITULAB); +#else + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); +#endif + if (YCbCrSubsampleHoriz || YCbCrSubsampleVert) + TIFFSetField(tif, TIFFTAG_YCBCRSUBSAMPLING, YCbCrSubsampleHoriz, YCbCrSubsampleVert); + if (TIFFWriteRawStrip(tif, 0, (tdata_t) data, off) == -1) + { + printf("Write error to TIFF file\n"); + return 1; + } + free(data); + } + TIFFWriteDirectory(tif); + TIFFClose(tif); + printf("Done!\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t4_t6_tests.c b/libs/spandsp/tests/t4_t6_tests.c new file mode 100644 index 0000000000..6df56303c1 --- /dev/null +++ b/libs/spandsp/tests/t4_t6_tests.c @@ -0,0 +1,427 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t4_t6_tests.c - ITU T.4 and T.6 FAX image compression and decompression tests + * + * Written by Steve Underwood + * + * Copyright (C) 2003, 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +/*! \page t4_t6_tests_page T.4 and T.6 image compress and decompression tests +\section t4_t6_tests_page_sec_1 What does it do +These tests exercise the image compression and decompression methods defined +in ITU specifications T.4 and T.6. +*/ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +//#if defined(WITH_SPANDSP_INTERNALS) +#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES +//#endif + +#include "spandsp.h" + +#define XSIZE 1728 + +t4_t6_encode_state_t send_state; +t4_t6_decode_state_t receive_state; + +/* The following are some test cases from T.4 */ +#define FILL_70 " " +#define FILL_80 " " +#define FILL_100 " " +#define FILL_670 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_70 +#define FILL_980 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_80 + +#define TEST_ROWS 16 +static const char t4_t6_test_patterns[TEST_ROWS][XSIZE + 1] = +{ + "XXXXXX " FILL_980 " XXX XXX X " FILL_670 " XXXX", + "XXXXXX " FILL_980 " XXX X " FILL_670 " XXXX", + /* Line start should code to V(0). Line middle codes to VR(3) VL(2) V(0). Line end should code to V(0) V(0). */ + + " XXXX " FILL_980 " XXXXXXX " FILL_670 " XX ", + "XXXXX " FILL_980 "XX XX " FILL_670 " XXXX", + /* Line start should code to VL(1). Line middle codes to H(7,2). Line end should code to V(0) VR(2) */ + + "XXX " FILL_980 " XX XX XX XXX " FILL_670 " X ", + " " FILL_980 " X XXX XXXX " FILL_670 " X XX", + /* Line start should code to P. Line middle codes to P VL(1) V(0) H(3,4) P. Line end codes to V(0) VL(2) V(0). */ + + "XXXXX " FILL_980 " " FILL_670 " XXXX", + " XXX " FILL_980 " " FILL_670 " XX ", + /* Line start should code to VR(2). Line end codes to V(0) VL(2) V(0). */ + + " XX " FILL_980 " " FILL_670 " X XXX", + "XXX X " FILL_980 " " FILL_670 " X ", + /* Line start should code to H(0,3) VR(1). Line end codes to V(0) VR(3). */ + + " " FILL_980 " " FILL_670 " XX ", + " " FILL_980 " " FILL_670 " ", + /* Line end codes to P V(0) a'0. */ + + " " FILL_980 " " FILL_670 " XXXXXXXXXX", + " " FILL_980 " " FILL_670 " XXXXXX XXXXXX", + /* Line end codes to H(2,6). */ + + " " FILL_980 " " FILL_670 " XX XXXXX", + " " FILL_980 " " FILL_670 " XX ", + /* Line end codes to V(0) H(7,0). */ +}; + +#if 0 +static void dump_image_as_xxx(const uint8_t buf[], int bytes_per_row, int len) +{ + const uint8_t *s; + int i; + int j; + int k; + + /* Dump the entire image as text 'X's and spaces */ + printf("Image (%d pixels x %d pixels):\n", bytes_per_row*8, len/bytes_per_row); + s = buf; + for (i = 0; i < len; i++) + { + for (j = 0; j < bytes_per_row; j++) + { + for (k = 0; k < 8; k++) + printf((buf[i*bytes_per_row + j] & (0x80 >> k)) ? "X" : " "); + } + printf("\n"); + } +} +/*- End of function --------------------------------------------------------*/ +#endif + +static int row_read_handler(void *user_data, uint8_t buf[], size_t len) +{ + int i; + int j; + const char *s; + static int row = 0; + + /* Send the test pattern. */ + if (row >= TEST_ROWS) + { + row = 0; + return 0; + } + s = t4_t6_test_patterns[row++]; + memset(buf, 0, len); + for (i = 0; i < len; i++) + { + for (j = 0; j < 8; j++) + { + if (*s++ != ' ') + buf[i] |= (0x80 >> j); + } + } + if (*s) + printf("Oops - '%c' at end of row %d\n", *s, row); + return len; +} +/*- End of function --------------------------------------------------------*/ + +static int row_write_handler(void *user_data, const uint8_t buf[], size_t len) +{ + int i; + int j; + const char *s; + static int row = 0; + uint8_t ref[8192]; + + /* Verify that what is received matches the test pattern. */ + //printf("Row %d\n", row); + if (len == 0) + return 0; + s = t4_t6_test_patterns[row++]; + if (row >= TEST_ROWS) + row = 0; + memset(ref, 0, len); + for (i = 0; i < len; i++) + { + for (j = 0; j < 8; j++) + { + if (*s++ != ' ') + ref[i] |= (0x80 >> j); + } + } + if (*s) + printf("Oops - '%c' at end of row %d\n", *s, row); + if (memcmp(buf, ref, len)) + { + printf("Test failed at row %d\n", row); + exit(2); + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int detect_page_end(int bit, int page_ended) +{ + static int consecutive_eols; + static int max_consecutive_eols; + static int consecutive_zeros; + static int consecutive_ones; + static int eol_zeros; + static int eol_ones; + static int expected_eols; + static int end_marks; + + /* Check the EOLs are added properly to the end of an image. We can't rely on the + decoder giving the right answer, as a full set of EOLs is not needed for the + decoder to work. */ + if (bit == -1000000) + { + /* Reset */ + consecutive_eols = 0; + max_consecutive_eols = 0; + consecutive_zeros = 0; + consecutive_ones = 0; + end_marks = 0; + + eol_zeros = 11; + eol_ones = (page_ended == T4_COMPRESSION_ITU_T4_2D) ? 2 : 1; + expected_eols = (page_ended == T4_COMPRESSION_ITU_T6) ? 2 : 6; + return 0; + } + + /* Monitor whether the EOLs are there in the correct amount */ + if (bit == 0) + { + consecutive_zeros++; + consecutive_ones = 0; + } + else if (bit == 1) + { + if (++consecutive_ones == eol_ones) + { + if (consecutive_eols == 0 && consecutive_zeros >= eol_zeros) + consecutive_eols++; + else if (consecutive_zeros == eol_zeros) + consecutive_eols++; + else + consecutive_eols = 0; + consecutive_zeros = 0; + consecutive_ones = 0; + } + if (max_consecutive_eols < consecutive_eols) + max_consecutive_eols = consecutive_eols; + } + else if (bit == SIG_STATUS_END_OF_DATA) + { + if (end_marks == 0) + { + if (max_consecutive_eols != expected_eols) + { + printf("Only %d EOLs (should be %d)\n", max_consecutive_eols, expected_eols); + return 2; + } + consecutive_zeros = 0; + consecutive_eols = 0; + max_consecutive_eols = 0; + } + if (!page_ended) + { + /* We might need to push a few bits to get the receiver to report the + end of page condition (at least with T.6). */ + if (++end_marks > 50) + { + printf("Receiver missed the end of page mark\n"); + return 2; + } + return 0; + } + return 1; + } + return 0; +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + static const int compression_sequence[] = + { + T4_COMPRESSION_ITU_T4_1D, + T4_COMPRESSION_ITU_T4_2D, + T4_COMPRESSION_ITU_T6, + -1 + }; + int bit; + int end_of_page; + int end_marks; + int compression; + int compression_step; + int min_row_bits; + int opt; + int tests_failed; + int block_size; + int len; + int res; + uint8_t chunk_buf[1024]; + + tests_failed = 0; + compression = -1; + compression_step = 0; + /* Use a non-zero default minimum row length to ensure we test the consecutive EOLs part + properly. */ + min_row_bits = 50; + block_size = 0; + while ((opt = getopt(argc, argv, "b:c:m:")) != -1) + { + switch (opt) + { + case 'b': + block_size = atoi(optarg); + if (block_size > 1024) + block_size = 1024; + break; + case 'c': + if (strcmp(optarg, "T41D") == 0) + { + compression = T4_COMPRESSION_ITU_T4_1D; + compression_step = -1; + } + else if (strcmp(optarg, "T42D") == 0) + { + compression = T4_COMPRESSION_ITU_T4_2D; + compression_step = -1; + } + else if (strcmp(optarg, "T6") == 0) + { + compression = T4_COMPRESSION_ITU_T6; + compression_step = -1; + } + break; + case 'm': + min_row_bits = atoi(optarg); + break; + default: + //usage(); + exit(2); + break; + } + } + /* Create a send and a receive end */ + memset(&send_state, 0, sizeof(send_state)); + memset(&receive_state, 0, sizeof(receive_state)); + + end_of_page = FALSE; +#if 1 + printf("Testing image_function->compress->decompress->image_function\n"); + /* Send end gets image from a function */ + if (t4_t6_encode_init(&send_state, compression, 1728, row_read_handler, NULL) == NULL) + { + printf("Failed to init T.4/T.6 encoder\n"); + exit(2); + } + span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); + t4_t6_encode_set_min_bits_per_row(&send_state, min_row_bits); + t4_t6_encode_set_max_2d_rows_per_1d_row(&send_state, 2); + + /* Receive end puts TIFF to a function. */ + if (t4_t6_decode_init(&receive_state, compression, 1728, row_write_handler, NULL) == NULL) + { + printf("Failed to init T.4/T.6 decoder\n"); + exit(2); + } + span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); + + /* Now send and receive the test data with all compression modes. */ + /* If we are stepping around the compression schemes, reset to the start of the sequence. */ + if (compression_step > 0) + compression_step = 0; + for (;;) + { + end_marks = 0; + if (compression_step >= 0) + { + compression = compression_sequence[compression_step++]; + if (compression < 0) + break; + } + t4_t6_encode_set_encoding(&send_state, compression); + t4_t6_decode_set_encoding(&receive_state, compression); + + if (t4_t6_encode_restart(&send_state, 1728)) + break; + if (t4_t6_decode_restart(&receive_state, 1728)) + break; + detect_page_end(-1000000, compression); + switch (block_size) + { + case 0: + end_of_page = FALSE; + for (;;) + { + bit = t4_t6_encode_get_bit(&send_state); + if ((res = detect_page_end(bit, end_of_page))) + { + if (res != 1) + { + printf("Test failed\n"); + exit(2); + } + break; + } + if (!end_of_page) + end_of_page = t4_t6_decode_put_bit(&receive_state, bit & 1); + } + break; + default: + do + { + len = t4_t6_encode_get(&send_state, chunk_buf, block_size); + if (len == 0) + { + if (++end_marks > 50) + { + printf("Receiver missed the end of page mark\n"); + tests_failed++; + break; + } + chunk_buf[0] = 0xFF; + len = 1; + } + end_of_page = t4_t6_decode_put(&receive_state, chunk_buf, len); + } + while (!end_of_page); + break; + } + if (compression_step < 0) + break; + } + t4_t6_encode_release(&send_state); + t4_t6_decode_release(&receive_state); +#endif + printf("Tests passed\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t4_tests.c b/libs/spandsp/tests/t4_tests.c index a2967948b7..b53c8f65be 100644 --- a/libs/spandsp/tests/t4_tests.c +++ b/libs/spandsp/tests/t4_tests.c @@ -52,8 +52,8 @@ in ITU specifications T.4 and T.6. #define XSIZE 1728 -t4_state_t send_state; -t4_state_t receive_state; +t4_tx_state_t send_state; +t4_rx_state_t receive_state; /* The following are some test cases from T.4 */ #define FILL_70 " " @@ -62,7 +62,7 @@ t4_state_t receive_state; #define FILL_670 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_70 #define FILL_980 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_100 FILL_80 -static const char t4_test_patterns[][1728 + 1] = +static const char t4_t6_test_patterns[][1728 + 1] = { "XXXXXX " FILL_980 " XXX XXX X " FILL_670 " XXXX", "XXXXXX " FILL_980 " XXX X " FILL_670 " XXXX", @@ -100,29 +100,31 @@ static const char t4_test_patterns[][1728 + 1] = int rows_written = 0; int rows_read = 0; -static void dump_image_as_xxx(t4_state_t *state) +static void dump_image_as_xxx(t4_rx_state_t *state) { +#if 0 uint8_t *s; int i; int j; int k; /* Dump the entire image as text 'X's and spaces */ - printf("Image (%d x %d):\n", receive_state.image_width, receive_state.image_length); + printf("Image (%d x %d):\n", state->t4_t6.image_width, state->t4_t6.image_length); s = state->image_buffer; - for (i = 0; i < state->image_length; i++) + for (i = 0; i < state->t4_t6.image_length; i++) { - for (j = 0; j < state->bytes_per_row; j++) + for (j = 0; j < state->t4_t6.bytes_per_row; j++) { for (k = 0; k < 8; k++) - printf((state->image_buffer[i*state->bytes_per_row + j] & (0x80 >> k)) ? "X" : " "); + printf((state->image_buffer[i*state->t4_t6.bytes_per_row + j] & (0x80 >> k)) ? "X" : " "); } printf("\n"); } +#endif } /*- End of function --------------------------------------------------------*/ -static void display_page_stats(t4_state_t *s) +static void display_page_stats(t4_rx_state_t *s) { t4_stats_t stats; @@ -134,7 +136,7 @@ static void display_page_stats(t4_state_t *s) printf("Image resolution = %d pels/m x %d pels/m\n", stats.x_resolution, stats.y_resolution); printf("Bad rows = %d\n", stats.bad_rows); printf("Longest bad row run = %d\n", stats.longest_bad_row_run); - printf("Bits per row - min %d, max %d\n", s->min_row_bits, s->max_row_bits); + printf("Bits per row - min %d, max %d\n", s->decoder.t4_t6.min_row_bits, s->decoder.t4_t6.max_row_bits); } /*- End of function --------------------------------------------------------*/ @@ -147,7 +149,7 @@ static int row_read_handler(void *user_data, uint8_t buf[], size_t len) /* Send the test pattern. */ if (rows_read >= 16) return 0; - s = t4_test_patterns[rows_read++]; + s = t4_t6_test_patterns[rows_read++]; memset(buf, 0, len); for (i = 0; i < len; i++) { @@ -173,7 +175,7 @@ static int row_write_handler(void *user_data, const uint8_t buf[], size_t len) /* Verify that what is received matches the test pattern. */ if (len == 0) return 0; - s = t4_test_patterns[rows_written++]; + s = t4_t6_test_patterns[rows_written++]; memset(ref, 0, len); for (i = 0; i < len; i++) { @@ -261,7 +263,7 @@ static int detect_page_end(int bit, int page_ended) if (!page_ended) { /* We might need to push a few bits to get the receiver to report the - end of page condition (at least with T.6). */ + end of page condition (at least with T.6). */ if (++end_marks > 50) { printf("Receiver missed the end of page mark\n"); @@ -290,10 +292,8 @@ int main(int argc, char *argv[]) #if defined(SPANDSP_SUPPORT_T43x) T4_COMPRESSION_ITU_T43, #endif -#if defined(SPANDSP_SUPPORT_T85) T4_COMPRESSION_ITU_T85, T4_COMPRESSION_ITU_T85_L0, -#endif //T4_COMPRESSION_ITU_T45, -1 }; @@ -316,6 +316,7 @@ int main(int argc, char *argv[]) const char *page_header_tz; tz_t tz; int opt; + int len; int i; int bit_error_rate; int dump_as_xxx; @@ -379,13 +380,11 @@ int main(int argc, char *argv[]) compression_step = -1; } #endif -#if defined(SPANDSP_SUPPORT_T85) else if (strcmp(optarg, "T85") == 0) { compression = T4_COMPRESSION_ITU_T85; compression_step = -1; } -#endif break; case 'd': decode_file_name = optarg; @@ -426,7 +425,7 @@ int main(int argc, char *argv[]) memset(&send_state, 0, sizeof(send_state)); memset(&receive_state, 0, sizeof(receive_state)); - end_of_page = FALSE; + end_of_page = T4_DECODE_MORE_DATA; if (decode_file_name) { if (compression < 0) @@ -456,9 +455,9 @@ int main(int argc, char *argv[]) { if (sscanf(&buf[18 + 3*i], "%x", (unsigned int *) &bit) != 1) break; - if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) - break; + block[i] = bit; } + end_of_page = t4_rx_put(&receive_state, block, i); } else if (sscanf(buf, "HDLC: %x", &pkt_no) == 1) { @@ -467,9 +466,9 @@ int main(int argc, char *argv[]) { if (sscanf(&buf[19 + 3*i], "%x", (unsigned int *) &bit) != 1) break; - if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) - break; + block[i] = bit; } + end_of_page = t4_rx_put(&receive_state, block, i); } else if (sscanf(buf, "%*d:%*d:%*d.%*d T.38 Rx %d: IFP %x %x", &pkt_no, (unsigned int *) &bit, (unsigned int *) &bit) == 3) { @@ -481,10 +480,9 @@ int main(int argc, char *argv[]) { if (sscanf(&buf[47 + 3*i], "%x", (unsigned int *) &bit) != 1) break; - bit = bit_reverse8(bit); - if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) - break; + block[i] = bit_reverse8(bit); } + end_of_page = t4_rx_put(&receive_state, block, i); } else if (strlen(buf) > 2 && sscanf(buf, "T.30 Rx: %x %x", (unsigned int *) &bit, (unsigned int *) &bit) == 2) { @@ -496,10 +494,9 @@ int main(int argc, char *argv[]) { if (sscanf(&buf[22 + 3*i], "%x", (unsigned int *) &bit) != 1) break; - bit = bit_reverse8(bit); - if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) - break; + block[i] = bit_reverse8(bit); } + end_of_page = t4_rx_put(&receive_state, block, i); } else if (sscanf(buf, "%04x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4) { @@ -507,10 +504,9 @@ int main(int argc, char *argv[]) { if (sscanf(&buf[6 + 3*i], "%x", (unsigned int *) &bit) != 1) break; - bit = bit_reverse8(bit); - if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) - break; + block[i] = bit_reverse8(bit); } + end_of_page = t4_rx_put(&receive_state, block, i); } else if (sscanf(buf, "%08x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4) { @@ -518,10 +514,9 @@ int main(int argc, char *argv[]) { if (sscanf(&buf[10 + 3*i], "%x", (unsigned int *) &bit) != 1) break; - bit = bit_reverse8(bit); - if ((end_of_page = t4_rx_put_byte(&receive_state, bit))) - break; + block[i] = bit_reverse8(bit); } + end_of_page = t4_rx_put(&receive_state, block, i); } else if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1) { @@ -544,18 +539,19 @@ int main(int argc, char *argv[]) #if 1 printf("Testing image_function->compress->decompress->image_function\n"); /* Send end gets image from a function */ - if (t4_tx_init(&send_state, in_file_name, -1, -1) == NULL) + if (t4_tx_init(&send_state, NULL, -1, -1) == NULL) { printf("Failed to init T.4 tx\n"); exit(2); } span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW); t4_tx_set_row_read_handler(&send_state, row_read_handler, NULL); + t4_tx_set_image_width(&send_state, 1728); t4_tx_set_min_bits_per_row(&send_state, min_row_bits); - t4_tx_set_local_ident(&send_state, "111 2222 3333"); + t4_tx_set_max_2d_rows_per_1d_row(&send_state, 2); /* Receive end puts TIFF to a function. */ - if (t4_rx_init(&receive_state, OUT_FILE_NAME, T4_COMPRESSION_ITU_T4_2D) == NULL) + if (t4_rx_init(&receive_state, NULL, T4_COMPRESSION_ITU_T4_2D) == NULL) { printf("Failed to init T.4 rx\n"); exit(2); @@ -576,7 +572,7 @@ int main(int argc, char *argv[]) if (compression_step >= 0) { compression = compression_sequence[compression_step++]; - if (compression < 0) + if (compression < 0 || (block_size == 0 && compression_step >= 3)) break; } t4_tx_set_tx_encoding(&send_state, compression); @@ -588,64 +584,66 @@ int main(int argc, char *argv[]) break; if (t4_rx_start_page(&receive_state)) break; + detect_page_end(-1000000, compression); + page_ended = FALSE; switch (block_size) { case 0: - do + while ((bit = t4_tx_get_bit(&send_state)) >= 0) { - bit = t4_tx_get_bit(&send_state); - if (bit == SIG_STATUS_END_OF_DATA) + /* Monitor whether the EOLs are there in the correct amount */ + if ((res = detect_page_end(bit, page_ended))) { - if (++end_marks > 50) - { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; - } + printf("Incorrect EOLs - %d\n", res); + tests_failed += (res - 1); + break; } - end_of_page = t4_rx_put_bit(&receive_state, bit & 1); - } - while (!end_of_page); - break; - case 1: - do - { - bit = t4_tx_get_byte(&send_state); - if ((bit & 0x100)) + if (bit >= 0) { - if (++end_marks > 50) + if (bit_error_rate) { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; + if ((rand() % bit_error_rate) == 0) + bit ^= 1; } + end_of_page = t4_rx_put_bit(&receive_state, bit); } - end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF); } - while (!end_of_page); - if ((t4_tx_get_byte(&send_state) & 0x100) == 0) + while (end_of_page != T4_DECODE_OK) { - printf("Page ended, but source is not reporting end of data\n"); - tests_failed++; + end_of_page = t4_rx_put_bit(&receive_state, 0); + if (++end_marks > 50) + { + printf("Receiver missed the end of page mark\n"); + tests_failed++; + break; + } } + /* Now throw junk at the receive context, to ensure stuff occuring + after the end of page condition has no bad effect. */ + for (i = 0; i < 1000; i++) + t4_rx_put_bit(&receive_state, (rand() >> 10) & 1); break; default: + /* Some decoders require a few extra bits before the recognise the end + of an image, so be prepared to offer it a few. */ do { - bit = t4_tx_get_chunk(&send_state, block, block_size); - if (bit > 0) - end_of_page = t4_rx_put_chunk(&receive_state, block, bit); - if (bit < block_size) + len = t4_tx_get(&send_state, block, block_size); + if (len > 0) + end_of_page = t4_rx_put(&receive_state, block, len); + } + while (len > 0); + while (end_of_page != T4_DECODE_OK) + { + block[0] = 0; + end_of_page = t4_rx_put(&receive_state, block, 1); + if (++end_marks > 5) { - if (++end_marks > 50) - { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; - } + printf("Receiver missed the end of page mark\n"); + tests_failed++; + break; } } - while (!end_of_page); break; } display_page_stats(&receive_state); @@ -681,9 +679,6 @@ int main(int argc, char *argv[]) exit(2); } span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW); - t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state)); - t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state)); - t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state)); /* Now send and receive all the pages in the source TIFF file */ sends = 0; @@ -703,7 +698,7 @@ int main(int argc, char *argv[]) if (tz_init(&tz, page_header_tz)) t4_tx_set_header_tz(&send_state, &tz); } - //t4_tx_set_header_overlays_image(&send_state, overlay_page_headers); + t4_tx_set_header_overlays_image(&send_state, overlay_page_headers); if (restart_pages && (sends & 1)) { /* Use restart, to send the page a second time */ @@ -715,7 +710,7 @@ int main(int argc, char *argv[]) if (compression_step >= 0) { compression = compression_sequence[compression_step++]; - if (compression < 0) + if (compression < 0 || (block_size == 0 && compression_step >= 3)) { compression_step = 0; compression = compression_sequence[compression_step++]; @@ -726,6 +721,9 @@ int main(int argc, char *argv[]) if (t4_tx_start_page(&send_state)) break; + t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state)); + t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state)); + t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state)); } t4_rx_start_page(&receive_state); detect_page_end(-1000000, compression); @@ -733,72 +731,58 @@ int main(int argc, char *argv[]) switch (block_size) { case 0: - for (;;) + while ((bit = t4_tx_get_bit(&send_state)) >= 0) { - bit = t4_tx_get_bit(&send_state); /* Monitor whether the EOLs are there in the correct amount */ if ((res = detect_page_end(bit, page_ended))) { + printf("Incorrect EOLs - %d\n", res); tests_failed += (res - 1); break; } - if (!page_ended) + if (bit_error_rate) { - if (bit_error_rate) - { - if ((rand() % bit_error_rate) == 0) - bit ^= 1; - } - if (t4_rx_put_bit(&receive_state, bit & 1)) - page_ended = TRUE; + if ((rand() % bit_error_rate) == 0) + bit ^= 1; + } + end_of_page = t4_rx_put_bit(&receive_state, bit); + } + while (end_of_page != T4_DECODE_OK) + { + end_of_page = t4_rx_put_bit(&receive_state, 0); + if (++end_marks > 50) + { + printf("Receiver missed the end of page mark\n"); + tests_failed++; + break; } } /* Now throw junk at the receive context, to ensure stuff occuring after the end of page condition has no bad effect. */ for (i = 0; i < 1000; i++) - { t4_rx_put_bit(&receive_state, (rand() >> 10) & 1); - } - break; - case 1: - do - { - bit = t4_tx_get_byte(&send_state); - if ((bit & 0x100)) - { - if (++end_marks > 50) - { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; - } - } - end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF); - } - while (!end_of_page); - if ((t4_tx_get_byte(&send_state) & 0x100) == 0) - { - printf("Page ended, but source is not reporting end of data\n"); - tests_failed++; - } break; default: do { - bit = t4_tx_get_chunk(&send_state, block, block_size); - if (bit > 0) - end_of_page = t4_rx_put_chunk(&receive_state, block, bit); - if (bit < block_size) + len = t4_tx_get(&send_state, block, block_size); + if (len > 0) + end_of_page = t4_rx_put(&receive_state, block, len); + } + while (len > 0); + /* Some decoders require a few extra bits before the recognise the end + of an image, so be prepared to offer it a few. */ + while (end_of_page != T4_DECODE_OK) + { + block[0] = 0; + end_of_page = t4_rx_put(&receive_state, block, 1); + if (++end_marks > 5) { - if (++end_marks > 50) - { - printf("Receiver missed the end of page mark\n"); - tests_failed++; - break; - } + printf("Receiver missed the end of page mark\n"); + tests_failed++; + break; } } - while (!end_of_page); break; } if (dump_as_xxx) diff --git a/libs/spandsp/tests/t81_t82_arith_coding_tests.c b/libs/spandsp/tests/t81_t82_arith_coding_tests.c new file mode 100644 index 0000000000..8d5bab5808 --- /dev/null +++ b/libs/spandsp/tests/t81_t82_arith_coding_tests.c @@ -0,0 +1,238 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t81_t82_arith_coding_tests.c - Tests for the ITU T.81 and T.82 arithmetic + * encoder/decoder, based on the test description + * in T.82 + * + * Written by Steve Underwood + * + * Copyright (C) 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*! \file */ + +/*! \page t81_t82_arith_coding_tests_page T.81 and T.82 Arithmetic encoder/decoder tests +\section t81_t82_arith_coding_tests_pagesec_1 What does it do +These tests exercise the arithmetic encoder and decoder for T.81 and T.82. As T.85 is based +on T.82, this is also the arithmetic coder for T.85. + +These tests are based on T.82 section 7. Nothing beyond the prescibed tests is performed at +the present time. +*/ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +//#if defined(WITH_SPANDSP_INTERNALS) +#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES +//#endif + +#include "spandsp.h" + +#define MSG_SIZE 10000 + +#define FALSE 0 +#define TRUE (!FALSE) + +uint8_t msg[MSG_SIZE]; + +int32_t msg_len; + +static void write_byte(void *user_data, int byte) +{ + if (msg_len < MSG_SIZE) + msg[msg_len++] = byte; +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + t81_t82_arith_encode_state_t *se; + t81_t82_arith_decode_state_t *sd; + int i; + int j; + int test_failed; + int pix; + const uint8_t *pp; + /* Test data from T.82 7.1 */ + static const uint16_t pix_7_1[16] = + { + 0x05E0, 0x0000, 0x8B00, 0x01C4, 0x1700, 0x0034, 0x7FFF, 0x1A3F, + 0x951B, 0x05D8, 0x1D17, 0xE770, 0x0000, 0x0000, 0x0656, 0x0E6A + }; + /* Test data from T.82 7.1 */ + static const uint16_t cx_7_1[16] = + { + 0x0FE0, 0x0000, 0x0F00, 0x00F0, 0xFF00, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 + }; + /* Test data from T.82 7.1 - scd with stuffing and SDNORM termination */ + static const uint8_t sde_7_1[32] = + { + 0x69, 0x89, 0x99, 0x5C, 0x32, 0xEA, 0xFA, 0xA0, + 0xD5, 0xFF, 0x00, 0x52, 0x7F, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x3F, + 0xFF, 0x00, 0x2D, 0x20, 0x82, 0x91, 0xFF, 0x02 + }; +#define SDE_7_1_LEN 30 /* Don't include the termination SDNORM */ +#define SDE_7_1_FULL_LEN 32 /* Include the termination SDNORM */ + + printf("T.81/T.82 arithmetic encoder tests, from ITU-T T.82\n\n"); + + printf("Arithmetic encoder tests from ITU-T T.82/7.1\n"); + if ((se = t81_t82_arith_encode_init(NULL, write_byte, NULL)) == NULL) + { + fprintf(stderr, "Failed to allocate arithmetic encoder!\n"); + exit(2); + } + msg_len = 0; + for (i = 0; i < 16; i++) + { + for (j = 0; j < 16; j++) + { + t81_t82_arith_encode(se, + (cx_7_1[i] >> (15 - j)) & 1, + (pix_7_1[i] >> (15 - j)) & 1); + } + } + t81_t82_arith_encode_flush(se); + if (msg_len != SDE_7_1_LEN || memcmp(msg, sde_7_1, SDE_7_1_LEN)) + { + printf("Encoded data: "); + for (i = 0; i < msg_len; i++) + printf("%02X", msg[i]); + printf("\n"); + printf("Expected data: "); + for (i = 0; i < SDE_7_1_LEN; i++) + printf("%02X", sde_7_1[i]); + printf("\n"); + printf("Test failed\n"); + exit(2); + } + printf("Test passed\n"); + + printf("Arithmetic decoder tests from ITU-T T.82/7.1\n"); + printf("Decoding byte by byte...\n"); + test_failed = FALSE; + if ((sd = t81_t82_arith_decode_init(NULL)) == NULL) + { + fprintf(stderr, "Failed to allocate arithmetic decoder!\n"); + exit(2); + } + pp = sde_7_1; + sd->pscd_ptr = pp; + sd->pscd_end = pp + 1; + for (i = 0; i < 16; i++) + { + for (j = 0; j < 16; j++) + { + for (;;) + { + pix = t81_t82_arith_decode(sd, (cx_7_1[i] >> (15 - j)) & 1); + if ((pix >= 0 || sd->pscd_end >= sde_7_1 + SDE_7_1_FULL_LEN)) + break; + pp++; + if (sd->pscd_ptr != pp - 1) + sd->pscd_ptr = pp; + sd->pscd_end = pp + 1; + } + if (pix < 0) + { + printf("Bad pixel %d, byte %" PRIdPTR ".\n\n", + i*16 + j + 1, + sd->pscd_ptr - sd->pscd_end); + test_failed = TRUE; + break; + } + if (pix != ((pix_7_1[i] >> (15 - j)) & 1)) + { + printf("Bad PIX (%d) at pixel %d.\n\n", + pix, + i*16 + j + 1); + test_failed = TRUE; + break; + } + } + } + if (sd->pscd_ptr != sd->pscd_end - 2) + { + printf("%" PRIdPTR " bytes left after decoder finished.\n\n", + sd->pscd_end - sd->pscd_ptr - 2); + test_failed = TRUE; + } + if (test_failed) + { + printf("Test failed\n"); + exit(2); + } + printf("Test passed\n"); + + printf("Decoding chunk by chunk...\n"); + test_failed = FALSE; + t81_t82_arith_decode_init(sd); + sd->pscd_ptr = sde_7_1; + sd->pscd_end = sde_7_1 + SDE_7_1_FULL_LEN; + for (i = 0; i < 16; i++) + { + for (j = 0; j < 16; j++) + { + pix = t81_t82_arith_decode(sd, (cx_7_1[i] >> (15 - j)) & 1); + if (pix < 0) + { + printf("Bad pixel %d, byte %" PRIdPTR ".\n\n", + i*16 + j + 1, + sd->pscd_ptr - sd->pscd_end); + test_failed = TRUE; + break; + } + if (pix != ((pix_7_1[i] >> (15 - j)) & 1)) + { + printf("Bad PIX (%d) at pixel %d.\n\n", + pix, + i*16 + j + 1); + test_failed = TRUE; + break; + } + } + } + if (sd->pscd_ptr != sd->pscd_end - 2) + { + printf("%" PRIdPTR " bytes left after decoder finished.\n\n", + sd->pscd_end - sd->pscd_ptr - 2); + test_failed = TRUE; + } + if (test_failed) + { + printf("Test failed\n"); + exit(2); + } + printf("Test passed\n"); + + printf("Tests passed\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/t85_tests.c b/libs/spandsp/tests/t85_tests.c new file mode 100644 index 0000000000..8820028aa6 --- /dev/null +++ b/libs/spandsp/tests/t85_tests.c @@ -0,0 +1,369 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * t85_tests.c - ITU T.85 FAX image compression and decompression tests + * + * Written by Steve Underwood + * + * Copyright (C) 2009 Steve Underwood + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * These tests are based on code from Markus Kuhn's jbigkit. See + * http://www.cl.cam.ac.uk/~mgk25/ + * + * jbigkit is GPL2 licenced. This file is also GPL2 licenced, and our + * T.85 code is LGPL2.1 licenced. There are no licence incompatibilities + * in this reuse of Markus's work. + */ + +/*! \file */ + +/*! \page t85_tests_page T.85 image compress and decompression tests +\section t85_tests_page_sec_1 What does it do +These tests exercise the image compression and decompression methods defined +in ITU specifications T.85. +*/ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +//#if defined(WITH_SPANDSP_INTERNALS) +#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES +//#endif + +#include "spandsp.h" + +#define TESTBUF_SIZE 400000 +#define TEST_IMAGE_SIZE (1951*1960/8) + +#define FALSE 0 +#define TRUE (!FALSE) + +uint8_t testbuf[TESTBUF_SIZE]; +uint8_t test_image[TEST_IMAGE_SIZE]; + +size_t testbuf_len; + +int read_row = 0; +int write_row = 0; + +int clip_to_row = 0; + +static int row_read_handler(void *user_data, uint8_t buf[], size_t len) +{ + //t85_encode_state_t *s; + + //s = (t85_encode_state_t *) user_data; + + memcpy(buf, &test_image[len*read_row], len); + //printf("Read row %d\n", read_row); + if (clip_to_row && read_row == clip_to_row) + { + clip_to_row = 0; + return 0; + } + read_row++; + return len; +} +/*- End of function --------------------------------------------------------*/ + +static int row_write_handler(void *user_data, const uint8_t buf[], size_t len) +{ + uint8_t *bitmap; + + bitmap = (uint8_t *) user_data; + memcpy(&bitmap[len*write_row], buf, len); + //printf("Write row %d\n", write_row); + write_row++; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int comment_handler(void *user_data, const uint8_t buf[], size_t len) +{ + if (buf) + printf("Comment (%lu): %s\n", (unsigned long int) len, buf); + else + printf("Comment (%lu): ---\n", (unsigned long int) len); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static void create_test_image(uint8_t *pic) +{ + int i; + int j; + uint32_t sum; + uint32_t prsg; + uint32_t repeat[8]; + uint8_t *p; + + /* Cook up the test image defined in T.82/7.2.1. This image is 1960 x 1951 + pixels, and occupies a single plane (which it has to for T.85). */ + memset(pic, 0, TEST_IMAGE_SIZE); + p = pic; + prsg = 1; + for (i = 0; i < 1951; i++) + { + for (j = 0; j < 1960; j++) + { + if (i >= 192) + { + if (i < 1023 || (j & (3 << 3)) == 0) + { + sum = (prsg & 1) + + ((prsg >> 2) & 1) + + ((prsg >> 11) & 1) + + ((prsg >> 15) & 1); + prsg = (prsg << 1) + (sum & 1); + if ((prsg & 3) == 0) + { + *p |= (1 << (7 - (j & 7))); + repeat[j & 7] = 1; + } + else + { + repeat[j & 7] = 0; + } + } + else + { + if (repeat[j & 7]) + *p |= 1 << (7 - (j & 7)); + } + } + if ((j & 7) == 7) + ++p; + } + } + + /* Verify the test image has been generated OK, by checking the number of set pixels */ + sum = 0; + for (i = 0; i < TEST_IMAGE_SIZE; i++) + { + for (j = 0; j < 8; j++) + sum += ((pic[i] >> j) & 1); + } + if (sum != 861965) + { + printf("WARNING: Test image has %" PRIu32 " foreground pixels. There should be 861965.\n", + sum); + } +} +/*- End of function --------------------------------------------------------*/ + +/* Perform a test cycle, as defined in T.82/7, with one set of parameters. */ +static int test_cycle(const char *test_id, + const uint8_t *image, + uint32_t width, + uint32_t height, + uint32_t l0, + int mx, + int options, + int optionsx, + const uint8_t *comment, + size_t correct_length) +{ + t85_encode_state_t t85_enc; + t85_decode_state_t t85_dec; + long int l; + size_t image_size; + int result; + int len; + int max_len; + size_t bytes_per_row; + size_t cnt_a; + size_t cnt_b; + uint8_t *decoded_image; + + printf("%s: TPBON=%d, LRLTWO=%d, Mx=%d, L0=%" PRIu32 "\n", + test_id, + (options & T85_TPBON) ? 1 : 0, + (options & T85_LRLTWO) ? 1 : 0, + mx, + l0); + + printf("%s.1: Encode\n", test_id); + bytes_per_row = (width + 7)/8; + image_size = bytes_per_row*height; + + if ((optionsx & T85_VLENGTH)) + { + t85_encode_init(&t85_enc, width, height + 10, row_read_handler, &t85_enc); + clip_to_row = height; + } + else + { + t85_encode_init(&t85_enc, width, height, row_read_handler, &t85_enc); + clip_to_row = 0; + } + read_row = 0; + t85_encode_set_options(&t85_enc, l0, mx, options); + /* A comment inserted here should always succeed. The later one, inserted some way + down the image, will only succeed if a new chunk is started afterwards. */ + if (comment) + t85_encode_comment(&t85_enc, comment, strlen((const char *) comment) + 1); + + testbuf_len = 0; + max_len = 100; + while ((len = t85_encode_get(&t85_enc, &testbuf[testbuf_len], max_len)) > 0) + { + testbuf_len += len; + max_len = 100; + if (testbuf_len + 100 > TESTBUF_SIZE) + max_len = TESTBUF_SIZE - testbuf_len; + if (comment && testbuf_len == 1000) + t85_encode_comment(&t85_enc, comment, strlen((const char *) comment) + 1); + } + t85_encode_release(&t85_enc); + printf("Encoded BIE has %lu bytes\n", (unsigned long int) testbuf_len); + if (correct_length > 0) + { + if (testbuf_len != correct_length) + { + printf("Incorrect encoded length. Should have been %lu\n", (unsigned long int) correct_length); + printf("Test failed\n"); + exit(2); + } + printf("Test passed\n"); + } + + printf("%s.2: Decode in one big chunk\n", test_id); + if ((decoded_image = (uint8_t *) malloc(image_size)) == NULL) + { + fprintf(stderr, "Out of memory!\n"); + exit(2); + } + t85_decode_init(&t85_dec, row_write_handler, decoded_image); + if (comment && comment[0] != 'X') + t85_decode_set_comment_handler(&t85_dec, 1000, comment_handler, NULL); + write_row = 0; + result = t85_decode_put(&t85_dec, testbuf, testbuf_len); + if (result == T4_DECODE_MORE_DATA) + result = t85_decode_put(&t85_dec, NULL, 0); + cnt_a = t85_encode_get_compressed_image_size(&t85_enc); + cnt_b = t85_decode_get_compressed_image_size(&t85_dec); + if (cnt_a != cnt_b || cnt_a != testbuf_len*8 || result != T4_DECODE_OK) + { + printf("Decode result %d\n", result); + printf("%ld/%ld bits of %ld bits of BIE read. %lu lines decoded.\n", + (long int) cnt_a, + (long int) cnt_b, + (unsigned long int) testbuf_len*8, + (unsigned long int) t85_dec.y); + printf("Test failed\n"); + exit(2); + } + if (memcmp(decoded_image, image, image_size)) + { + printf("Image mismatch\n"); + printf("Test failed\n"); + exit(2); + } + free(decoded_image); + t85_decode_release(&t85_dec); + printf("Test passed\n"); + + printf("%s.3: Decode byte by byte\n", test_id); + if ((decoded_image = (uint8_t *) malloc(image_size)) == NULL) + { + fprintf(stderr, "Out of memory!\n"); + exit(2); + } + t85_decode_init(&t85_dec, row_write_handler, decoded_image); + if (comment && comment[0] != 'X') + t85_decode_set_comment_handler(&t85_dec, 1000, comment_handler, NULL); + write_row = 0; + result = T4_DECODE_MORE_DATA; + for (l = 0; l < testbuf_len; l++) + { + result = t85_decode_put(&t85_dec, &testbuf[l], 1); + if (result != T4_DECODE_MORE_DATA) + { + l++; + break; + } + } + if (result == T4_DECODE_MORE_DATA) + result = t85_decode_put(&t85_dec, NULL, 0); + if (l != testbuf_len || result != T4_DECODE_OK) + { + printf("Decode result %d\n", result); + printf("%ld bytes of %ld bytes of BIE read. %lu lines decoded.\n", + (long int) l, + (unsigned long int) testbuf_len, + (unsigned long int) t85_dec.y); + printf("Test failed\n"); + exit(2); + } + if (memcmp(decoded_image, image, image_size)) + { + printf("Image mismatch\n"); + printf("Test failed\n"); + exit(2); + } + free(decoded_image); + t85_decode_release(&t85_dec); + printf("Test passed\n"); + + return 0; +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char **argv) +{ + printf("T.85 JBIG for FAX encoder and decoder tests, from ITU-T T.82\n\n"); + + printf("Generating the test image from T.82...\n"); + create_test_image(test_image); + + /* Run through the tests in T.82/7.2, which are applicable to T.85 */ + test_cycle("1", test_image, 1960, 1951, 1951, 0, 0, 0, NULL, 317384); + test_cycle("2", test_image, 1960, 1951, 1951, 0, T85_LRLTWO, 0, NULL, 317132); + test_cycle("3", test_image, 1960, 1951, 128, 8, T85_TPBON, 0, NULL, 253653); + /* Again with a comment added and handled */ + test_cycle("4", test_image, 1960, 1951, 1951, 0, 0, 0, (const uint8_t *) "Comment 4", 317384 + 16); + test_cycle("5", test_image, 1960, 1951, 1951, 0, T85_LRLTWO, 0, (const uint8_t *) "Comment 5", 317132 + 16); + test_cycle("6", test_image, 1960, 1951, 128, 8, T85_TPBON, 0, (const uint8_t *) "Comment 6", 253653 + 2*16); + /* Again with a comment added, but not handled */ + test_cycle("7", test_image, 1960, 1951, 1951, 0, 0, 0, (const uint8_t *) "Xomment 7", 317384 + 16); + test_cycle("8", test_image, 1960, 1951, 1951, 0, T85_LRLTWO, 0, (const uint8_t *) "Xomment 8", 317132 + 16); + test_cycle("9", test_image, 1960, 1951, 128, 8, T85_TPBON, 0, (const uint8_t *) "Xomment 9", 253653 + 2*16); + /* Again with the image variable length and prematurely terminated */ + test_cycle("10", test_image, 1960, 1951, 1951, 0, T85_VLENGTH, T85_VLENGTH, NULL, 317384 + 8); + test_cycle("11", test_image, 1960, 1951, 1951, 0, T85_VLENGTH | T85_LRLTWO, T85_VLENGTH, NULL, 317132 + 8); + test_cycle("12", test_image, 1960, 1951, 128, 8, T85_VLENGTH | T85_TPBON, T85_VLENGTH, NULL, 253653 + 8); + /* Again with the image variable length but not prematurely terminated */ + test_cycle("13", test_image, 1960, 1951, 1951, 0, T85_VLENGTH, 0, NULL, 317384); + test_cycle("14", test_image, 1960, 1951, 1951, 0, T85_VLENGTH | T85_LRLTWO, 0, NULL, 317132); + test_cycle("15", test_image, 1960, 1951, 128, 8, T85_VLENGTH | T85_TPBON, 0, NULL, 253653); + + printf("Tests passed\n"); + + return 0; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/tone_detect_tests.c b/libs/spandsp/tests/tone_detect_tests.c index 9375f157a2..d6dea2740c 100644 --- a/libs/spandsp/tests/tone_detect_tests.c +++ b/libs/spandsp/tests/tone_detect_tests.c @@ -127,7 +127,7 @@ static int periodogram_tests(void) } } } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) if (periodogram_tests()) exit(2); printf("Tests passed\n"); - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/tone_generate_tests.c b/libs/spandsp/tests/tone_generate_tests.c index f61753da37..2ece5a7377 100644 --- a/libs/spandsp/tests/tone_generate_tests.c +++ b/libs/spandsp/tests/tone_generate_tests.c @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) exit (2); } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/tsb85_tests.c b/libs/spandsp/tests/tsb85_tests.c index aa78e5dfba..300b8b6e62 100644 --- a/libs/spandsp/tests/tsb85_tests.c +++ b/libs/spandsp/tests/tsb85_tests.c @@ -80,6 +80,8 @@ int test_local_interrupt = FALSE; const char *output_tiff_file_name; +int log_audio = FALSE; + fax_state_t *fax; faxtester_state_t state; @@ -628,7 +630,7 @@ static int next_step(faxtester_state_t *s) int compression_type; int timer; int len; - t4_state_t t4_tx_state; + t4_tx_state_t t4_tx_state; t30_state_t *t30; if (s->cur == NULL) @@ -970,7 +972,6 @@ static int next_step(faxtester_state_t *s) printf("Test failed\n"); exit(2); } - t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits); t4_tx_set_header_info(&t4_tx_state, NULL); compression_type = T4_COMPRESSION_ITU_T4_1D; if (compression) @@ -981,20 +982,21 @@ static int next_step(faxtester_state_t *s) compression_type = T4_COMPRESSION_ITU_T6; } t4_tx_set_tx_encoding(&t4_tx_state, compression_type); + t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits); if (t4_tx_start_page(&t4_tx_state)) { span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n"); printf("Test failed\n"); exit(2); } - len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image)); + len = t4_tx_get(&t4_tx_state, image, sizeof(image)); if (bad_rows) { span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n"); corrupt_image(s, image, len, (const char *) bad_rows); } t4_tx_release(&t4_tx_state); - span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM image is %d bytes\n", len); + span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM image is %d bytes (min row bits %d)\n", len, min_row_bits); faxtester_set_non_ecm_image_buffer(s, image, len); } else if (strcasecmp((const char *) type, "PP") == 0) @@ -1010,7 +1012,6 @@ static int next_step(faxtester_state_t *s) printf("Test failed\n"); exit(2); } - t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits); t4_tx_set_header_info(&t4_tx_state, NULL); compression_type = T4_COMPRESSION_ITU_T4_1D; if (compression) @@ -1021,6 +1022,7 @@ static int next_step(faxtester_state_t *s) compression_type = T4_COMPRESSION_ITU_T6; } t4_tx_set_tx_encoding(&t4_tx_state, compression_type); + t4_tx_set_min_bits_per_row(&t4_tx_state, min_row_bits); if (t4_tx_start_page(&t4_tx_state)) { span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n"); @@ -1028,7 +1030,7 @@ static int next_step(faxtester_state_t *s) exit(2); } /*endif*/ - len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image)); + len = t4_tx_get(&t4_tx_state, image, sizeof(image)); if (bad_rows) { span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n"); @@ -1036,7 +1038,7 @@ static int next_step(faxtester_state_t *s) } /*endif*/ t4_tx_release(&t4_tx_state); - span_log(&s->logging, SPAN_LOG_FLOW, "ECM image is %d bytes\n", len); + span_log(&s->logging, SPAN_LOG_FLOW, "ECM image is %d bytes (min row bits %d)\n", len, min_row_bits); faxtester_set_ecm_image_buffer(s, image, len, ecm_block, ecm_frame_size, i); } else @@ -1058,10 +1060,8 @@ static void exchange(faxtester_state_t *s) int len; int i; int total_audio_time; - int log_audio; logging_state_t *logging; - log_audio = TRUE; output_tiff_file_name = OUTPUT_TIFF_FILE_NAME; if (log_audio) @@ -1295,10 +1295,14 @@ int main(int argc, char *argv[]) xml_file_name = "../spandsp/tsb85.xml"; test_name = "MRGN01"; - while ((opt = getopt(argc, argv, "x:")) != -1) + log_audio = FALSE; + while ((opt = getopt(argc, argv, "lx:")) != -1) { switch (opt) { + case 'l': + log_audio = TRUE; + break; case 'x': xml_file_name = optarg; break; diff --git a/libs/spandsp/tests/tsb85_tests.sh b/libs/spandsp/tests/tsb85_tests.sh index 5086904014..21634aa6ca 100755 --- a/libs/spandsp/tests/tsb85_tests.sh +++ b/libs/spandsp/tests/tsb85_tests.sh @@ -104,18 +104,12 @@ do run_tsb85_test done -#OTEN02 fails because ????? - -#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 -for TEST in OTEN01 OTEN03 OTEN04 OTEN05 OTEN06 +for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 do run_tsb85_test done -#MTGX02 fails because ????? - -#for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 -for TEST in MTGX01 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 +for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 do run_tsb85_test done diff --git a/libs/spandsp/tests/udptl.h b/libs/spandsp/tests/udptl.h index 23563ad484..ae555cd500 100644 --- a/libs/spandsp/tests/udptl.h +++ b/libs/spandsp/tests/udptl.h @@ -31,7 +31,7 @@ #define UDPTL_BUF_MASK 15 -typedef int (udptl_rx_packet_handler_t) (void *user_data, const uint8_t msg[], int len, int seq_no); +typedef int (*udptl_rx_packet_handler_t) (void *user_data, const uint8_t msg[], int len, int seq_no); typedef struct { @@ -51,7 +51,7 @@ typedef struct struct udptl_state_s { - udptl_rx_packet_handler_t *rx_packet_handler; + udptl_rx_packet_handler_t rx_packet_handler; void *user_data; /*! This option indicates the error correction scheme used in transmitted UDPTL diff --git a/libs/spandsp/tests/v17_tests.c b/libs/spandsp/tests/v17_tests.c index 33aef4d2ba..f366ab10eb 100644 --- a/libs/spandsp/tests/v17_tests.c +++ b/libs/spandsp/tests/v17_tests.c @@ -122,7 +122,7 @@ static void v17_rx_status(void *user_data, int status) v17_rx_state_t *s; int i; int len; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) complexi16_t *coeffs; #else complexf_t *coeffs; @@ -133,14 +133,17 @@ static void v17_rx_status(void *user_data, int status) switch (status) { case SIG_STATUS_TRAINING_SUCCEEDED: - len = v17_rx_equalizer_state(s, &coeffs); - printf("Equalizer:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f); + printf("Training succeeded\n"); + if ((len = v17_rx_equalizer_state(s, &coeffs))) + { + printf("Equalizer:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V17_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V17_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif + } break; } } @@ -173,7 +176,7 @@ static int v17getbit(void *user_data) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static void qam_report(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol) #else static void qam_report(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol) @@ -181,7 +184,13 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex { int i; int len; +#if defined(SPANDSP_USE_FIXED_POINT) + complexi16_t *coeffs; +#else complexf_t *coeffs; +#endif + complexf_t constel_point; + complexf_t target_point; float fpower; v17_rx_state_t *rx; static float smooth_power = 0.0f; @@ -190,49 +199,56 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex rx = (v17_rx_state_t *) user_data; if (constel) { + constel_point.re = constel->re/V17_CONSTELLATION_SCALING_FACTOR; + constel_point.im = constel->im/V17_CONSTELLATION_SCALING_FACTOR; + target_point.re = target->re/V17_CONSTELLATION_SCALING_FACTOR, + target_point.im = target->im/V17_CONSTELLATION_SCALING_FACTOR, + fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re) + + (constel_point.im - target_point.im)*(constel_point.im - target_point.im); + smooth_power = 0.95f*smooth_power + 0.05f*fpower; #if defined(ENABLE_GUI) if (use_gui) { - qam_monitor_update_constel(qam_monitor, constel); + qam_monitor_update_constel(qam_monitor, &constel_point); qam_monitor_update_carrier_tracking(qam_monitor, v17_rx_carrier_frequency(rx)); qam_monitor_update_symbol_tracking(qam_monitor, v17_rx_symbol_timing_correction(rx)); } #endif - fpower = (constel->re - target->re)*(constel->re - target->re) - + (constel->im - target->im)*(constel->im - target->im); - smooth_power = 0.95f*smooth_power + 0.05f*fpower; printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n", symbol_no, - constel->re, - constel->im, - target->re, - target->im, + constel_point.re, + constel_point.im, + target_point.re, + target_point.im, symbol, fpower, smooth_power, v17_rx_carrier_frequency(rx), v17_rx_signal_power(rx), v17_rx_symbol_timing_correction(rx)); - printf("Carrier %d %f %f\n", symbol_no, v17_rx_carrier_frequency(rx), v17_rx_symbol_timing_correction(rx)); symbol_no++; if (--update_interval <= 0) { - len = v17_rx_equalizer_state(rx, &coeffs); - printf("Equalizer A:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f); + if ((len = v17_rx_equalizer_state(rx, &coeffs))) + { + printf("Equalizer A:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V17_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V17_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif #if defined(ENABLE_GUI) - if (use_gui) -#if defined(SPANDSP_USE_FIXED_POINTx) - qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); + if (use_gui) + { +#if defined(SPANDSP_USE_FIXED_POINT) + qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); #else - qam_monitor_update_equalizer(qam_monitor, coeffs, len); + qam_monitor_update_equalizer(qam_monitor, coeffs, len); #endif + } #endif + } update_interval = 100; } } @@ -458,7 +474,7 @@ int main(int argc, char *argv[]) #if defined(ENABLE_GUI) if (use_gui) { - qam_monitor = qam_monitor_init(10.0f, NULL); + qam_monitor = qam_monitor_init(10.0f, V17_CONSTELLATION_SCALING_FACTOR, NULL); if (!decode_test_file) { start_line_model_monitor(129); @@ -584,7 +600,7 @@ int main(int argc, char *argv[]) exit(2); } } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/v17_tests.sh b/libs/spandsp/tests/v17_tests.sh new file mode 100755 index 0000000000..5657afd348 --- /dev/null +++ b/libs/spandsp/tests/v17_tests.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +STDOUT_DEST=xyzzy +STDERR_DEST=xyzzy2 + +for OPTS in "-b 14400 -s -42 -n -66" "-b 12000 -s -42 -n -61" "-b 9600 -s -42 -n -59" "-b 7200 -s -42 -n -56" +do + ./v17_tests ${OPTS} >$STDOUT_DEST 2>$STDERR_DEST + RETVAL=$? + if [ $RETVAL != 0 ] + then + echo v17_tests ${OPTS} failed! + exit $RETVAL + fi +done +echo v17_tests completed OK diff --git a/libs/spandsp/tests/v18_tests.c b/libs/spandsp/tests/v18_tests.c index 1666ce96a1..951fc88781 100644 --- a/libs/spandsp/tests/v18_tests.c +++ b/libs/spandsp/tests/v18_tests.c @@ -70,7 +70,6 @@ const char *full_baudot_rx = "XABCDEFGHIJKLMNOPQRSTUVWXYZ(/)' " "'ABCDEFGHIJKLMNOPQRSTUVWXYZ(!) "; -#if 1 static void put_text_msg(void *user_data, const uint8_t *msg, int len) { if (strcmp((const char *) msg, qbf_rx)) @@ -94,10 +93,17 @@ static void basic_tests(int mode) int i; v18_state_t *v18_a; v18_state_t *v18_b; + logging_state_t *logging; printf("Testing %s\n", v18_mode_to_str(mode)); v18_a = v18_init(NULL, TRUE, mode, put_text_msg, NULL); + logging = v18_get_logging_state(v18_a); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "A"); v18_b = v18_init(NULL, FALSE, mode, put_text_msg, NULL); + logging = v18_get_logging_state(v18_b); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "B"); /* Fake an OK condition for the first message test */ good_message_received = TRUE; @@ -153,11 +159,1353 @@ static void basic_tests(int mode) v18_free(v18_b); } /*- End of function --------------------------------------------------------*/ -#endif + +static int test_misc_01(void) +{ + /* + III.5.4.1.1 No disconnection test + Purpose: To verify that the DCE does not initiate a disconnection. + Preamble: N/A + Method: A call is made to the TUT from the tester which remains off hook for 10 minutes + without sending any signal. + Pass criteria: The TUT should answer the call and enter the probing state after 3 seconds. The + TUT should continue to probe until the test is terminated. + Comments: This feature should also be verified by observation during the automoding tests. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_02(void) +{ + /* + III.5.4.1.2 Automatic resumption of automoding + Purpose: To ensure that the DCE can be configured to automatically re-assume the automode + calling state after 10 s of no valid signal. + Preamble: The TUT should be configured to automatically re-assume the initial automoding + state. + Method: The tester should set up a call to the TUT in V.21 mode and then drop the carrier. + The tester will then transmit silence for 11 seconds followed by a 1300 Hz tone for + 5 seconds (i.e. V.23). + Pass criteria: 1) Ten seconds after dropping the carrier the TUT should return to state Monitor 1. + 2) After 2.7±0.3 seconds the TUT should select V.23 mode and send a 390 Hz tone. + Comments: The TUT should indicate that carrier has been lost at some time after the 1650 Hz + signal is lost. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_03(void) +{ + /* + III.5.4.1.3 Retention of selected mode on loss of signal + Purpose: To ensure that the DCE stays in the selected transmission mode if it is not + configured to automatically re-assume the initial automoding state. + Preamble: The TUT should be configured to remain in the selected transmission mode when + the carrier is lost. + Method: The tester should set up a call to the TUT in V.21 mode, for example. It will drop + the carrier for 9 seconds and then re-start transmission of the same carrier for + 1 second followed by a short message. + Pass criteria: The TUT should resume operation in V.21 mode and capture the entire test + message. + Comments: The TUT should indicate that carrier has been lost at some time after the carrier + signal is removed and not disconnect. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_04(void) +{ + /* + III.5.4.1.4 Detection of BUSY tone + Purpose: To ensure that the DCE provides the call progress indication "BUSY" in presence of + the national busy tone. + Preamble: N/A + Method: The TUT should be configured to dial out and then be presented with the + appropriate national busy tone. + Pass criteria: Detection of busy tone should be displayed by the TUT. + Comments: ITU-T V.18 specifies that the DCE should not hang up, but that is intended to apply + to the case where a connection is established and then lost. A terminal may + automatically hang up when busy tone is detected. PABX busy tones may differ in + frequency and cadence from national parameters. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_05(void) +{ + /* + III.5.4.1.5 Detection of RINGING + Purpose: To ensure that the DCE provides the call progress indication "RINGING" in + presence of the national ringing tone. + Preamble: N/A + Method: The tester will make a call to the TUT using the nationally recommended cadence + and the minimum recommended ring voltage/current. + Pass criteria: The RINGING condition should be visually indicated by the TUT. + Comments: This test should be repeated across a range of valid timings and ring voltages. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_06(void) +{ + /* + III.5.4.1.6 "LOSS OF CARRIER" indication + Purpose: To ensure that the DCE provides the call progress indication "LOSS OF CARRIER" + upon a loss of carrier in full duplex modes, i.e. V.21, V.23, Bell 103. + Preamble: N/A + Method: Set up a call in each of the full duplex modes and force a carrier failure to the TUT. + Pass criteria: Loss of carrier should be indicated and disappear when the carrier is restored. + Comments: The V.18 modem should not automatically disconnect when used in a manual + conversation mode. However, a V.18 equipped terminal may disconnect based on + operational decisions, e.g. when it is a terminal in automatic answering machine + mode. There may be other cases, e.g. where the V.18 DCE is used in a gateway, + when automatic disconnection is required. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_07(void) +{ + /* + III.5.4.1.7 Call progress indication + Purpose: To ensure that the DCE provides the call progress indication "CONNECT(x)" upon + a connection. + Preamble: N/A + Method: Correct CONNECT messages should be verified during the Automode tests that + follow. + Pass criteria: The relevant mode should be indicated by the DCE when automoding is complete. + However, this may possibly not be indicated by the DTE. + Comments: The possible modes are: V.21, V.23, Baudot 45, Baudot 50, EDT, Bell 103, DTMF. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_08(void) +{ + /* + III.5.4.1.8 Circuit 135 Test + Purpose: To ensure that the DCE implements circuit 135 or an equivalent way of indicating + presence of a signal. + Preamble: N/A + Method: A call from the TUT should be answered in voice mode after 20 seconds. The tester + will transmit sampled voice messages. V.24 circuit 135 or its equivalent should be + observed. + Pass criteria: The ring tone and speech shall be indicated by circuit 135. + Comment: The response times and signal level thresholds of Circuit 135 are not specified in + ITU-T V.18 or V.24 and therefore the pattern indicated may vary. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_misc_09(void) +{ + /* + III.5.4.1.9 Connection procedures + Purpose: To ensure that the TUT implements the call connect procedure described in + clause 6. + Preamble: N/A + Method: TBD + Pass criteria: TBD + Comment: TBD + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_01(void) +{ + /* + III.5.4.2.1 CI and XCI signal coding and cadence + Purpose: To verify that TUT correctly emits the CI and XCI signals with the ON/OFF + cadence defined in 5.1.1. + Preamble: N/A + Method: V.21 demodulator is used to decode the CI sequence and a timer to measure the + silence intervals between them. The XCI signal is also monitored and decoded to + check for correct coding and timing of the signal. + Pass criteria: 1) No signal should be transmitted for one second after connecting to the line. + 2) Four CI patterns are transmitted for each repetition. + 3) No signal is transmitted for two seconds after the end of each CI. + 4) Each CI must have the correct bit pattern. + 5) The CI patterns followed by two seconds of silence must be repeated twice. + 6) One second after every 3 blocks CI an XCI signal must be transmitted. + 7) The XCI should have the structure defined in 3.11. + 8) The whole sequence should be repeated until the call is cleared. + 9) When V.18 to V.18, the XCI must not force V.23 or Minitel mode. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_02(void) +{ + /* + III.5.4.2.2 ANS signal detection + Purpose: To verify that TUT correctly detects the ANS (2100 Hz) signal during the + two-second interval (Toff) between transmission of CI sequences. + Preamble: Make a V.18 call from the TUT. + Method: The Test System waits for the TUT to stop transmitting a CI and responds with an + ANS signal. The V.21 demodulator is used to decode the TXP sequence and a timer + measures the silence intervals between them. ANS should be transmitted for 2 + seconds. + Pass criteria: 1) No signal should be transmitted by TUT for 0.5 seconds from detection of ANS. + 2) The TUT should reply with transmission of TXP as defined in 5.1.2. + 3) Verify that TXP sequence has correct bit pattern. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_03(void) +{ + /* + III.5.4.2.3 End of ANS signal detection + Purpose: The TUT should stop sending TXP at the end of the current sequence when the ANS + tone ceases. + Preamble: Test ORG-02 should be successfully completed immediately prior to this test. + Method: The tester sends ANS for 2 seconds followed by silence. The tester will then + monitor for cessation of TXP at the end of the answer tone. + Pass criteria: The TUT should stop sending TXP at the end of the current sequence when ANS + tone ceases. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_04(void) +{ + /* + III.5.4.2.4 ANS tone followed by TXP + Purpose: To check correct detection of V.18 modem. + Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. + Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + 3 TXP sequences using V.21 (2) and starts a 1 s timer. It will then transmit 1650 Hz + for 5 seconds. + Pass criteria: 1) TUT should initially respond with TXP. + 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. + 3) TUT should respond with 980 Hz carrier within 1 second of end of 3 TXP sequences. + 4) Data should be transmitted and received according to ITU-T T.140 to comply + with the V.18 operational requirements. + Comments: The TUT should indicate that V.18 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_05(void) +{ + /* + III.5.4.2.5 ANS tone followed by 1650 Hz + Purpose: To check correct detection of V.21 modem upper channel when preceded by answer + tone and to confirm discrimination between V.21 and V.18 modes. + Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. + Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + 1650 Hz and starts a 0.7 second timer. + Pass criteria: 1) TUT should initially respond with TXP. + 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. + 3) TUT should respond with 980 Hz at 0.5(+0.2-0.0) seconds of start of 1650 Hz. + 4) Data should be transmitted and received at 300 bit/s complying with Annex F. + Comments: Selection of ITU-T V.21 as opposed to ITU-T V.18 should be confirmed by + examination of TUT. If there is no visual indication, verify by use of ITU-T T.50 for + ITU-T V.21 as opposed to UTF-8 coded ISO 10646 character set for ITU-T V.18. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_06(void) +{ + /* + III.5.4.2.6 ANS tone followed by 1300 Hz + Purpose: To check correct detection of V.23 modem upper channel when preceded by answer + tone. + Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. + Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + 1300 Hz and starts a 2.7 s timer. + Pass criteria: 1) TUT should initially respond with TXP. + 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. + 3) TUT should respond with 390 Hz after 1.7(+0.2-0.0) seconds of start of 1300 Hz. + 4) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively + by the TUT to comply with Annex E. + Comments: The TUT should indicate that V.23 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_07(void) +{ + /* + III.5.4.2.7 ANS tone followed by no tone + Purpose: To confirm that TUT does not lock up under this condition. + Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test. + Method: Tester transmits ANS for 2.5 seconds followed by no tone for 10 s. It then transmits + DTMF tones for 2 seconds. + Pass criteria: 1) TUT should initially respond with TXP. + 2) TUT should stop sending TXP within 0.2 seconds of end of ANS. + 3) TUT should return to Monitor 1 state and then connect in DTMF mode within + 12 seconds of the end of ANS tone. + Comments: This condition would cause the terminal to lock up if the V.18 standard is followed + literally. It may however, occur when connected to certain Swedish textphones if the + handset is lifted just after the start of an automatically answered incoming call. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_08(void) +{ + /* + III.5.4.2.8 Bell 103 (2225 Hz signal) detection + Purpose: To verify that the TUT correctly detects the Bell 103 upper channel signal during + the 2-second interval between transmission of CI sequences. + Preamble: N/A + Method: The tester waits for a CI and then sends a 2225 Hz signal for 5 seconds. + Pass criteria: 1) The TUT should respond with a 1270 Hz tone in 0.5±0.1 seconds. + 2) Data should be transmitted and received at 300 bit/s to comply with Annex D. + Comments: The TUT should indicate that Bell 103 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_09(void) +{ + /* + III.5.4.2.9 V.21 (1650 Hz signal) detection + Purpose: To verify that the TUT correctly detects the V.21 upper channel signal during the + 2-second interval between transmission of CI sequences. + Preamble: N/A + Method: The tester waits for a CI and then sends a 1650 Hz signal for 5 seconds. + Pass criteria: 1) The TUT should respond with a 980 Hz tone in 0.5±0.1 seconds. + 2) Data should be transmitted and received at 300 bit/s to comply with Annex F. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_10(void) +{ + /* + III.5.4.2.10 The TUT should indicate that V.21 mode has been selected. + V.23 (1300 Hz signal) detection + Purpose: To verify that the TUT correctly detects the V.23 upper channel signal during the + 2-second interval between transmission of CI sequences. + Preamble: N/A + Method: The tester waits for a CI and then sends a 1300 Hz signal for 5 seconds. + Pass criteria: 1) The TUT should respond with a 390 Hz tone in 1.7±0.1 seconds. + 2) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively + by the TUT to comply with Annex E. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_11(void) +{ + /* + III.5.4.2.11 The TUT should indicate that V.23 mode has been selected. + V.23 (390 Hz signal) detection + Purpose: To confirm correct selection of V.23 reverse mode during sending of XCI. + Preamble: N/A + Method: The tester should wait for the start of the XCI signal and then send 390 Hz to TUT + for 5 seconds. + Pass criteria: 1) The TUT should complete the XCI as normal. + 2) The TUT should then maintain the 1300 Hz tone while the 390 Hz test tone is + present. + 3) Data should be transmitted and received at 1200 bit/s and 75 bit/s respectively + by the TUT to comply with Annex E when connection is indicated. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_12(void) +{ + /* + III.5.4.2.12 The TUT should indicate that V.23 mode has been selected at least 3 seconds after + the start of the 390 Hz tone. + 5 bit mode (Baudot) detection tests + Purpose: To confirm detection of Baudot modulation at various bit rates that may be + encountered. + Preamble: N/A + Method: The tester transmits the 5-bit coded characters "0" to "9" followed by "abcdef" at + (a) 45.45, (b) 47.6, (c) 50 and (d) 100 bits per second. When TUT indicates a + connection, type at least 5 characters back to the tester so that correct selection of bit + rate can be confirmed. + Pass criteria: 1) TUT should select Baudot mode and the appropriate bit rate. + 2) The tester will analyse the bit rate of received characters, which should be at + either 45.45 or 50 bits per second as appropriate. + Comments: 45.45 and 50 bit/s are the commonly used Baudot bit rates. However, certain + textphones can operate at higher rates (e.g. 100 bit/s). Responding at either 45.45 or + 50 bit/s is acceptable to these devices which normally fall back to the selected rate. + 47.6 bit/s may possibly be encountered from another V.18 textphone in the + automode answer state. The TUT may then select either 45.45 or 50 bit/s for the + transmission. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_13(void) +{ + /* + III.5.4.2.13 DTMF signal detection + Purpose: To verify whether the TUT correctly recognizes DTMF signals during the 2-second + interval between transmission of CI. + Preamble: N/A + Method: The tester will send a single DTMF tone of 40 ms duration to TUT. When TUT + indicates a connection, type at least 5 characters back to the tester so that correct + selection of mode can be confirmed. + Pass criteria: The tester will analyse the received characters to confirm DTMF mode selection. + Comments: TUT should indicate that it has selected DTMF mode. The DTMF capabilities of the + TUT should comply with ITU-T Q.24 for the Danish Administration while + receiving for best possible performance. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_14(void) +{ + /* + III.5.4.2.14 EDT rate detection + Purpose: To confirm detection of EDT modems by detecting the transmission rate of received + characters. + Preamble: N/A + Method: The tester transmits EDT characters "abcdef" to TUT at 110 bit/s. When TUT + indicates that the connection is established, type characters "abcdef" back to + the tester. The same characters will then be transmitted back to the TUT. + Pass criteria: Ensure correct reception of characters by tester and TUT. + Comments: The TUT should be able to determine the rate on the six characters given. If it takes + more than this then performance is probably inadequate as too many characters + would be lost. Some characters may be lost during the detection process. However, + the number lost should be minimal. The data bits and parity are specified in + Annex C. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_15(void) +{ + /* + III.5.4.2.15 Rate detection test + Purpose: To verify the presence of 980/1180 Hz at a different signalling rate than 110 bit/s + returns the TUT modem to the "monitor A" state. + Preamble: N/A + Method: The tester transmits 980/1180 Hz signals at 300 bit/s for 2 seconds. + Pass criteria: The TUT should not select EDT or any other mode and should continue to transmit + the CI signal. + Comments: Echoes of the CI sequences may be detected at 300 bit/s. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_16(void) +{ + /* + III.5.4.2.16 980 Hz detection + Purpose: To confirm correct selection of V.21 reverse mode. + Preamble: N/A + Method: The tester sends 980 Hz to TUT for 5 seconds. + Pass criteria: 1) TUT should respond with 1650 Hz tone after 1.5±0.1 seconds after start of + 980 Hz tone. + 2) Data should be transmitted and received at 300 bit/s complying with Annex F. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_17(void) +{ + /* + III.5.4.2.17 The TUT should indicate that V.21 mode has been selected. + Loss of signal after 980 Hz + Purpose: To confirm that TUT returns to the Monitor 1 state if 980 Hz signal disappears. + Preamble: N/A + Method: The tester sends 980 Hz to TUT for 1.2 seconds followed by silence for 5 seconds. + Pass criteria: TUT should not respond to the 980 Hz tone and resume sending CI signals after a + maximum of 2.4 seconds from the end of the 980 Hz tone. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_18(void) +{ + /* + III.5.4.2.18 Tr timer + Purpose: To confirm that TUT returns to the Monitor 1 state if Timer Tr expires. + Preamble: N/A + Method: The tester sends 980 Hz to TUT for 1.2 seconds followed by 1650 Hz for 5 seconds + with no pause. + Pass criteria: TUT should respond with 980 Hz after 1.3±0.1 seconds of 1650 Hz. + Comments: This implies timer Tr has expired 2 seconds after the start of the 980 Hz tone and + then 1650 Hz has been detected for 0.5 seconds. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_19(void) +{ + /* + III.5.4.2.19 Bell 103 (1270 Hz signal) detection + Purpose: To confirm correct selection of Bell 103 reverse mode. + Preamble: N/A + Method: The tester sends 1270 Hz to TUT for 5 seconds. + Pass criteria: 1) TUT should respond with 2225 Hz tone after 0.7±0.1 s. + 2) Data should be transmitted and received at 300 bit/s complying with Annex D. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_20(void) +{ + /* + III.5.4.2.20 The TUT should indicate that Bell 103 mode has been selected. + Immunity to network tones + Purpose: To ensure that the TUT does not interpret network tones as valid signals. + Preamble: N/A + Method: The tester will first send a dial tone to the TUT, this will be followed by a ringing + tone and a network congestion tone. The frequencies and cadences of the tones will + vary according to the country setting. The tester must be configured for the same + country as the TUT. + Pass criteria: The countries supported by the TUT should be noted along with the response to + each tone. The tones should either be ignored or reported as the relevant network + tone to the user. + Comments: V.18 is required to recognize and report RINGING and BUSY tones. Other network + tones may be ignored. Some devices may only provide a visual indication of the + presence and cadence of the tones for instance by a flashing light. The TUT may + disconnect on reception of tones indicating a failed call attempt. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_21(void) +{ + /* + III.5.4.2.21 Immunity to non-textphone modems + Purpose: To ensure that the TUT does not interpret modem tones not supported by V.18 as + valid text telephone tones. + Preamble: N/A + Method: The tester will respond with an ANS tone (2100 Hz) followed by simulated (a) + V.32 bis and (b) V.34 modem training sequences. + Pass criteria: The tones should either be ignored or reported back to the user. No textphone + modem should be selected. + Comments: Some high speed modems may fall back to a compatibility mode, e.g. V.21 or V.23 + that should be correctly detected by the TUT. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_22(void) +{ + /* + III.5.4.2.22 Immunity to fax tones + Purpose: To ensure that the TUT will not interpret a called fax machine as being a textphone. + Preamble: N/A + Method: The tester will respond as if it were a typical group 3 fax machine in automatic + answer mode. It should send a CED tone (2100 Hz) plus Digital Identification + Signal (DIS) as defined in ITU-T T.30. + Pass criteria: The TUT should ignore the received tones. + Comments: Ideally the TUT should detect the presence of a fax machine and report it back to + the user. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_23(void) +{ + /* + III.5.4.2.23 Immunity to voice + Purpose: To ensure that the TUT does not misinterpret speech as a valid textphone signal. + Preamble: N/A + Method: The tester will respond with sampled speech. A number of phrases recorded from + typical male and female speakers will be transmitted. This will include a typical + network announcement. + Pass criteria: The TUT should ignore the speech. + Comments: Ideally the TUT should report the presence of speech back to the user, e.g. via + circuit 135. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_24(void) +{ + /* + III.5.4.2.24 ANSam signal detection + Purpose: To verify that TUT correctly detects the ANSam (2100 Hz modulated) signal during + the two-second interval (Toff) between transmission of CI sequences. + Preamble: Make a V.18 call from the TUT. + Method: The Test System waits for the TUT to stop transmitting a CI and responds with an + ANSam signal. The V.21 demodulator is used to decode the CM sequence. ANSam + should be transmitted for 2 seconds. + Pass criteria: 1) No signal should be transmitted by TUT for 0.5 seconds from detection of + ANSam. + 2) The TUT should reply with transmission of CM as defined in 5.2.13. + 3) Verify that CM sequence has correct bit pattern. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_org_25(void) +{ + /* + III.5.4.2.25 V.8 calling procedure + Purpose: To verify that TUT correctly performs a V.8 call negotiation. + Preamble: Make a V.18 call from the TUT. Answer with ANSam from the Tester and with JM + for V.21 on the CM. + Method: The Test System waits for the TUT to start transmitting V.21 carrier (1). + Pass criteria: The TUT should connect by sending V.21 carrier (1). + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_01(void) +{ + /* + III.5.4.3.1 Ta timer + Purpose: To ensure that on connecting the call, the DCE starts timer Ta (3 seconds) and on + expiry begins probing. + Preamble: N/A + Method: The tester makes a call to the TUT and attempts to determine when the TUT + answers the call. It will then monitor for any signal. + Pass criteria: The TUT should start probing 3 seconds after answering the call. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_02(void) +{ + /* + III.5.4.3.2 CI signal detection + Purpose: To confirm the correct detection and response to the V.18 CI signal. + Preamble: N/A + Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. It will + monitor for ANS and measure duration. + Pass criteria: 1) The TUT should respond after either the first or second CI with ANSam tone. + 2) ANSam tone should remain for 3 seconds ±0.5 s followed by silence. + Comments: The ANSam tone is a modulated 2100 Hz tone. It may have phase reversals. The + XCI signal is tested in a separate test. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_03(void) +{ + /* + III.5.4.3.3 Early termination of ANSam tone + Purpose: To confirm that the TUT will respond correctly to TXP signals, i.e. by stopping + ANSam tone on reception of TXP signal. + Preamble: N/A + Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. On + reception of the ANSam tone the tester will wait 0.5 seconds and then begin + transmitting the TXP signal in V.21 (1) mode. + Pass criteria: 1) On reception of the TXP signal, the TUT should remain silent for 75±5 ms. + 2) The TUT should then transmit 3 TXP sequences in V.21(2) mode. + 3) The 3 TXPs should be followed by continuous 1650 Hz. + 4) Correct transmission and reception of T.140 data should be verified after the + V.18 mode connection is completed. + Comments: The TUT should indicate V.18 mode. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_04(void) +{ + /* + III.5.4.3.4 Tt timer + Purpose: To ensure that after detection of ANSam the TUT will return to Monitor A after + timer Tt expires. + Preamble: Successful completion of test ANS-03. + Method: After completion of test ANS-03 the tester will continue to monitor for signals. + Pass criteria: The TUT should start probing 3 seconds after ANSam disappears. + Comments: It is assumed that timer Ta is restarted on return to Monitor A. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_05(void) +{ + /* + III.5.4.3.5 ANS tone followed by 980 Hz + Purpose: To check correct detection of V.21 modem lower channel when preceded by answer + tone. + Preamble: N/A + Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + 980 Hz and starts a 1 s timer. + Pass criteria: TUT should respond with 1650 Hz within 400±100 ms of start of 980 Hz. + Comments: The TUT should indicate that V.21 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_06(void) +{ + /* + III.5.4.3.6 ANS tone followed by 1300 Hz + Purpose: To check correct detection of V.23 modem upper channel when preceded by answer + tone. + Preamble: N/A + Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + 1300 Hz and starts a 2-s timer. + Pass criteria: TUT should respond with 390 Hz after 1.7(+0.2-0.0) seconds of start of 1300 Hz. + Comments: The TUT should indicate that V.23 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_07(void) +{ + /* + III.5.4.3.7 ANS tone followed by 1650 Hz + Purpose: To check correct detection of V.21 modem upper channel when preceded by answer + tone and to confirm discrimination between V.21 and V.18 modes. + Preamble: N/A + Method: Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits + 1650 Hz and starts a 1-second timer. + Pass criteria: TUT should respond with 980 Hz within 400±100 ms of start of 1650 Hz. + Comments: The TUT should indicate that V.21 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_08(void) +{ + /* + III.5.4.3.8 980 Hz followed by 1650 Hz + Purpose: To ensure the correct selection of V.21 modem channel when certain types of + Swedish textphones are encountered. + Preamble: N/A + Method: The tester will simulate a call from a Diatext2 textphone that alternates between + 980 Hz and 1650 Hz until a connection is made. + Pass criteria: The TUT should respond with the appropriate carrier depending on when it + connects. + Comments: The TUT should indicate a V.21 connection. The time for which each frequency is + transmitted is random and varies between 0.64 and 2.56 seconds. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_09(void) +{ + /* + III.5.4.3.9 980 Hz calling tone detection + Purpose: To confirm correct detection of 980 Hz calling tones as defined in V.25. + Preamble: N/A + Method: The tester will send bursts of 980 Hz signals (a) 400 ms, (b) 500 ms, (c) 700 ms and + (d) 800 ms followed by 1 second of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. + 2) The TUT should immediately begin probing after a burst of 980 Hz for 500 or + 700 ms followed by 1 second of silence. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_10(void) +{ + /* + III.5.4.3.10 The probe sent by the TUT will depend on the country setting. + V.21 detection by timer + Purpose: To confirm correct selection of V.21 calling modem when the received signal is not + modulated, i.e. there is no 1180 Hz. + Preamble: N/A + Method: The tester sends 980 Hz to TUT for 2 seconds. + Pass criteria: The TUT should respond with a 1650 Hz tone in 1.5±0.1 seconds. + Comments: The TUT should indicate that V.21 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_11(void) +{ + /* + III.5.4.3.11 EDT detection by rate + Purpose: To confirm detection of EDT modems by detecting the transmission rate of received + characters. + Preamble: N/A + Method: The tester transmits EDT characters "abcdef" to TUT at 110 bit/s. When TUT + indicates that the connection is established, type characters "abcdef" back to + the tester. The same characters will then be transmitted back to the TUT. + Pass criteria: Ensure correct reception of characters by tester and TUT. + Comments: The TUT should indicate that EDT mode has been selected. Some characters may + be lost during the detection process. However, the number lost should be minimal. + The data bits and parity are specified in Annex C. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_12(void) +{ + /* + III.5.4.3.12 V.21 Detection by rate + Purpose: To confirm detection of V.21 modem low channel by detecting the transmission rate + of received characters and to ensure correct discrimination between V.18 and V.21 + modes. + Preamble: N/A + Method: The tester transmits characters "abcdef" to TUT using V.21 (1) at 300 bit/s. When + TUT indicates that the connection is established, type characters "abcdef" + back to the tester. The same characters will then be transmitted back to the TUT. + Pass criteria: Ensure correct reception of characters by tester and TUT. + Comments: This situation is unlikely to occur in practice unless the DCE is sending a V.21 + (1650 Hz) probe. However, it is catered for in V.18. It is more likely that this is + where CI or TXP characters would be detected (see test ANS-02). + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_13(void) +{ + /* + III.5.4.3.13 Tr timer + Purpose: To ensure that the TUT returns to the Monitor A state on expiry of timer Tr + (2 seconds). Timer Tr is started when a modulated V.21 (1) signal is detected. + Preamble: N/A + Method: The tester will transmit 980 Hz for 200 ms followed by alternating 980 Hz/1180 Hz + at 110 bit/s for 100 ms followed by 980 Hz for 1 second. + Pass criteria: The TUT should begin probing 4±0.5 seconds after the 980 Hz signal is removed. + Comments: It is not possible to be precise on timings for this test since the definition of a + "modulated signal" as in 5.2.4.4 is not specified. Therefore it is not known exactly + when timer Tr will start. It is assumed that timer Ta is restarted on re-entering the + Monitor A state. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_14(void) +{ + /* + III.5.4.3.14 Te timer + Purpose: To ensure that the TUT returns to the Monitor A on expiry of timer Te + (2.7 seconds). Timer Te is started when a 980 Hz signal is detected. + Preamble: N/A + Method: The tester will transmit 980 Hz for 200 ms followed silence for 7 s. + Pass criteria: The TUT should begin probing 5.5±0.5 seconds after the 980 Hz signal is removed. + Comments: It is assumed that timer Ta (3 seconds) is restarted on re-entering the Monitor A + state. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_15(void) +{ + /* + III.5.4.3.15 5 Bit mode (Baudot) detection tests + Purpose: To confirm detection of Baudot modulation at various bit rates that may be + encountered. + Preamble: N/A + Method: The tester transmits the 5-bit coded characters "0" to "9" followed by "abcdef" at + (a) 45.45, (b) 47.6, (c) 50 and (d) 100 bits per second. When TUT indicates a + connection, type at least 5 characters back to the tester so that correct selection of bit + rate can be confirmed. + Pass criteria: 1) The TUT should select Baudot mode and the appropriate bit rate. + 2) The tester will analyse the bit rate of received characters, which should be at an + appropriate rate, and confirm the carrier on/off times before and after the + characters. + Comments: 45.45 and 50 bit/s are the commonly used Baudot bit rates. However, some + textphones can transmit at higher rates, e.g. 100 bit/s. Responding at either 45.45 or + 50 bit/s is acceptable to these devices which then fall back to the selected rate. + A rate of 47.6 bit/s may be encountered from another V.18 textphone in the + automode answer state. The TUT may then select either 45.45 or 50 bit/s for the + transmission. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_16(void) +{ + /* + III.5.4.3.16 DTMF signal detection + Purpose: To verify whether the TUT correctly recognizes DTMF signals. + Preamble: N/A + Method: The tester will send a single DTMF tone of 40 ms duration to TUT. When TUT + indicates a connection, type at least 5 characters back to the tester so that correct + selection of mode can be confirmed. + Pass criteria: Tester will analyse the received characters to confirm DTMF mode selection. + Comments: The TUT should indicate that it has selected DTMF mode. The DTMF capabilities + of the TUT should comply with ITU-T Q.24 for the Danish Administration. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_17(void) +{ + /* + III.5.4.3.17 Bell 103 (1270 Hz signal) detection + Purpose: To ensure correct detection and selection of Bell 103 modems. + Preamble: N/A + Method: The tester sends 1270 Hz to TUT for 5 seconds. + Pass criteria: TUT should respond with 2225 Hz tone after 0.7±0.1 s. + Comments: The TUT should indicate that Bell 103 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_18(void) +{ + /* + III.5.4.3.18 Bell 103 (2225 Hz signal) detection + Purpose: To ensure correct detection and selection of Bell 103 modems in reverse mode. + Preamble: N/A + Method: The tester sends 2225 Hz to TUT for 5 seconds. + Pass criteria: The TUT should respond with 1270 Hz after 1±0.2 seconds. + Comments: The TUT should indicate that Bell 103 mode has been selected. Bell 103 modems + use 2225 Hz as both answer tone and higher frequency of the upper channel. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_19(void) +{ + /* + III.5.4.3.19 V.21 Reverse mode (1650 Hz) detection + Purpose: To ensure correct detection and selection of V.21 reverse mode. + Preamble: N/A + Method: The tester sends 1650 Hz to TUT for 5 seconds. + Pass criteria: The TUT should respond with 980 Hz after 0.4±0.2 seconds. + Comments: The TUT should indicate that V.21 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_20(void) +{ + /* + III.5.4.3.20 1300 Hz calling tone discrimination + Purpose: To confirm correct detection of 1300 Hz calling tones as defined in ITU-T V.25. + Preamble: N/A + Method: The tester will send 1300 Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and + (d) 800 ms followed by 1 second of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. + 2) The TUT should immediately begin probing after a burst of 1300 Hz for 500 or + 700 ms followed by 1 second of silence. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_21(void) +{ + /* + III.5.4.3.21 The probe sent by the TUT will depend on the country setting. + V.23 Reverse mode (1300 Hz) detection + Purpose: To ensure correct detection and selection of V.23 reverse mode. + Preamble: N/A + Method: The tester sends 1300 Hz only, with no XCI signals, to TUT for 5 seconds. + Pass criteria: The TUT should respond with 390 Hz after 1.7±0.1 seconds. + Comments: The TUT should indicate that V.23 mode has been selected. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_22(void) +{ + /* + III.5.4.3.22 1300 Hz with XCI test + Purpose: To ensure correct detection of the XCI signal and selection of V.18 mode. + Preamble: N/A + Method: The tester sends XCI signal as defined in 3.11. On reception of ANS it will become + silent for 500 ms then transmit the TXP signal in V.21 (1) mode. + Pass criteria: The TUT should respond with TXP using V.21 (2) and select V.18 mode. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_23(void) +{ + /* + III.5.4.3.23 Stimulate mode country settings + Purpose: To ensure that the TUT steps through the probes in the specified order for the + country selected. + Preamble: The TUT should be configured for each of the possible probe orders specified in + Appendix I in turn. + Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent + by the TUT. + Pass criteria: The TUT should use the orders described in Appendix I. + Comments: The order of the probes is not mandatory. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_24(void) +{ + /* + III.5.4.3.24 Stimulate carrierless mode probe message + Purpose: To ensure that the TUT sends the correct probe message for each of the carrierless + modes. + Preamble: N/A + Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent + by the TUT. + Pass criteria: The TUT should send the user defined probe message for Annexes A, B, and C + modes followed by a pause of Tm (default 3) seconds. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_25(void) +{ + /* + III.5.4.3.25 The carrierless modes are those described in Annexes A, B and C. + Interrupted carrierless mode probe + Purpose: To ensure that the TUT continues probing from the point of interruption a maximum + of 20 s after a failed connect attempt. + Preamble: The TUT should be configured for the UK country setting. + Method: The tester will call the TUT, wait for Ta to expire and then during the pause after + the first Baudot probe it will send a 200 ms burst of 1270 Hz followed by silence + for 30 s. + Pass criteria: The TUT should transmit silence on detecting the 1270 Hz tone and then continue + probing starting with the V.23 probe 20 seconds after the end of the 1270 Hz signal. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_26(void) +{ + /* + III.5.4.3.26 Stimulate carrier mode probe time + Purpose: To ensure that the TUT sends each carrier mode for time Tc (default 6 seconds) + preceded by the correct answer tone. + Preamble: None. + Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent + by the TUT. + Pass criteria: The TUT should send the ANS tone (2100 Hz) for 1 second followed by silence for + 75±5 ms and then the 1650 Hz, 1300 Hz and 2225 Hz probes for time Tc. + Comments: The carrier modes are those described in Annexes D, E, and F. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_27(void) +{ + /* + III.5.4.3.27 V.23 mode (390 Hz) detection + Purpose: To confirm correct selection of V.23 mode. + Preamble: N/A + Method: The tester waits until the 1300 Hz probe is detected from the TUT and then + transmits 390 Hz for 11 seconds. + Pass criteria: 1) After 3 seconds of the 390 Hz signal the TUT should indicate that V.23 has + been selected. + 2) The tester will confirm that the 1300 Hz carrier is maintained for at least + 4 seconds beyond the normal probe duration, i.e. Tc (= 6 s default) + 4 s = + 10 seconds total. + Comments: + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_28(void) +{ + /* + III.5.4.3.28 All known V.23 devices need to receive 1300 Hz tone before they will respond with + 390 Hz. When the 1300 Hz probe is not being transmitted, a 390 Hz tone may be + interpreted as a 400 Hz network tone. + Interrupted carrier mode probe + Purpose: To ensure that the TUT continues probing from the point of interruption a maximum + of 4 s after a failed connect attempt. + Preamble: The TUT should be configured for the UK country setting. + Method: The tester will call the TUT, wait for Ta to expire and then during the first V.21 + probe it will send a 200 ms burst of 1270 Hz followed by silence for 30 s. + Pass criteria: The TUT should transmit silence on detecting the 1270 Hz tone and then continue + probing with the Baudot stored message 4 seconds after the end of the 1270 Hz + burst. + Comments: It is most likely that the TUT will return to probing time Ta (3 seconds) after the + 1270 Hz tone ceases. This condition needs further clarification. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_29(void) +{ + /* + III.5.4.3.29 Stimulate mode response during probe + Purpose: To ensure that the TUT is able to detect an incoming signal while transmitting a + carrier mode probe. + Preamble: N/A + Method: The tester will step through each possible response as defined in tests ANS-08 to + ANS-23 for each of the carrier mode probes and for each pause after a carrierless + mode probe message. + Pass criteria: The TUT should respond as described in the appropriate test above. + Comments: The TUT may not respond to any signals while a carrierless mode probe is being + sent since these modes are half duplex. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_30(void) +{ + /* + III.5.4.3.30 Immunity to network tones + Purpose: To ensure that the TUT does not interpret network tones as valid signals. + Preamble: N/A + Method: The tester will first send a busy tone to the TUT this will be followed by a number + unobtainable tone. The frequencies and cadences of the tones will vary according to + the country setting. The tester must be configured for the same country as the TUT. + Pass criteria: The countries supported by the TUT should be noted along with the response to + each tone. The tones should either be ignored or reported as the relevant network + tone to the user. + Comments: V.18 is required to recognize and report RINGING and BUSY tones. Other network + tones may be ignored. Some devices may only provide a visual indication of the + presence and cadence of the tones for instance by a flashing light. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_31(void) +{ + /* + III.5.4.3.31 Immunity to fax calling tones + Purpose: To determine whether the TUT can discriminate fax calling tones. + Preamble: N/A + Method: The tester will call the TUT and send the fax calling tone, CNG. This is an 1100 Hz + tone with cadence of 0.5 seconds ON and 3 seconds OFF as defined in ITU-T T.30. + Pass criteria: The TUT should not respond to this signal and may report it as being a calling fax + machine. + Comments: This is an optional test as detection of the fax calling tone is not required by + ITU-T V.18. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_32(void) +{ + /* + III.5.4.3.32 Immunity to voice + Purpose: To ensure that the TUT does not misinterpret speech as a valid textphone signal. + Preamble: N/A + Method: The tester will respond with sampled speech. A number of phrases recorded from + typical male and female speakers will be transmitted. This will include a typical + network announcement. + Pass criteria: The TUT should ignore the speech. + Comments: Ideally the TUT should report the presence of speech back to the user. This is an + optional test. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_ans_33(void) +{ + /* + III.5.4.3.33 CM detection and V.8 answering + Purpose: To confirm that the TUT will respond correctly to CM signals and connect + according to V.8 procedures. + Preamble: N/A + Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. On + reception of the ANSam tone the tester will wait 0.5 seconds and then begin + transmitting the CM signal with textphone and V.21 specified. + Pass criteria: 1) On reception of the CM signal, the TUT should transmit JM with textphone + and V.21. + 2) The TUT should then transmit in V.21 (2) mode. + 3) The JM should be followed by continuous 1650 Hz. + 4) Correct transmission and reception of T.140 data should be verified after the + V.18 mode connection is completed. + Comments: The TUT should indicate V.18 mode. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_mon_01(void) +{ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_mon_21(void) +{ + /* + III.5.4.4.1 Automode monitor Ta timer test + Purpose: To ensure that on entering monitor mode, timer Ta (3 seconds) is not active and that + the TUT does not enter the probing state. + Preamble: N/A + Method: The TUT should be put into monitor state. The tester will then monitor for signals + for 1 minute. + Pass criteria: The TUT should not start probing. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_mon_22(void) +{ + /* + III.5.4.4.2 Automode monitor 1300 Hz calling tone discrimination + Purpose: To confirm correct detection and reporting of 1300 Hz calling tones as defined in + ITU-T V.25. + Preamble: N/A + Method: The tester will send 1300 Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and + (d) 800 ms followed by 1 second of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. + 2) The TUT should report detection of calling tones to the DTE after a burst of + 1300 Hz for 500 or 700 ms followed by 1 second of silence. + Comments: In automode answer, the 1300 Hz calling causes the DCE to start probing. In + monitor mode it should only report detection to the DTE. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ + +static int test_mon_23(void) +{ + /* + III.5.4.4.3 Automode monitor 980 Hz calling tone discrimination + Purpose: To confirm correct detection and reporting of 980 Hz calling tones as defined in + ITU-T V.25. + Preamble: N/A + Method: The tester will send 980 Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and + (d) 800 ms followed by 1 second of silence. + Pass criteria: 1) The TUT should not respond to bursts of 400 or 800 ms. + 2) The TUT should report detection of calling tones to the DTE after a burst of + 980 Hz for 500 or 700 ms followed by 1 second of silence. + Comments: In automode answer, the 980 Hz calling causes the DCE to start probing. In monitor + mode it should only report detection to the DTE. + */ + printf("Test not yet implemented\n"); + return 1; +} +/*- End of function --------------------------------------------------------*/ static int test_x_01(void) { - /* III.5.4.5.1 Baudot carrier timing and receiver disabling */ + /* + III.5.4.5.1 Baudot carrier timing and receiver disabling + Purpose: To verify that the TUT sends unmodulated carrier for 150 ms before a new character + and disables its receiver for 300 ms after a character is transmitted. + Preamble: Establish a call between the tester and TUT in Baudot mode. + Method: The operator should send a single character from the TUT. The tester will + immediately start sending a unique character sequence. Examination of the TUT + display will show when its receiver is re-enabled. + Pass criteria: 1) The TUT should send unmodulated carrier for 150 ms before the beginning of + the start bit. + 2) The receiver should be re-enabled after 300 ms. + 3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used. + Comments: The carrier should be maintained during the 300 ms after a character. + */ printf("Test not yet implemented\n"); return 1; } @@ -165,7 +1513,15 @@ static int test_x_01(void) static int test_x_02(void) { - /* III.5.4.5.2 Baudot bit rate confirmation */ + /* + III.5.4.5.2 Baudot bit rate confirmation + Purpose: To verify that the TUT uses the correct bit rates in the Baudot mode. + Preamble: Establish a call between the tester and TUT in Baudot mode for each of the two + tests. + Method: The operator should select Baudot (a) 45 bit/s followed by (b) 50 bit/s modes and + transmit the string "abcdef" at each rate. + Pass criteria: The tester will measure the bit timings and confirm the rates. + */ printf("Test not yet implemented\n"); return 1; } @@ -173,7 +1529,18 @@ static int test_x_02(void) static int test_x_03(void) { - /* III.5.4.5.3 Baudot probe bit rate confirmation */ + /* + III.5.4.5.3 Baudot probe bit rate confirmation + Purpose: To verify that the TUT uses the correct bit rates in the Baudot mode probe during + automoding. + Preamble: Set the user defined carrierless mode probe message to the string "abcdef" if + possible. Set the TUT country setting to "United States". A call should be initiated + from the tester to the TUT. + Method: The tester will wait for the Baudot mode probe and measure the bit rate. + Pass criteria: The tester will measure the bit timings and confirm the rate of 47.6 bit/s. + Comments: The probe message must be long enough for the tester to establish the bit rate. "GA" + may not be sufficient. + */ printf("Test not yet implemented\n"); return 1; } @@ -188,9 +1555,31 @@ static int test_x_04(void) int yy; int i; v18_state_t *v18_state; + logging_state_t *logging; - /* III.5.4.5.4 5 Bit to T.50 character conversion */ + /* + III.5.4.5.4 5 Bit to T.50 character conversion + Purpose: To check that the character conversion tables in Annex A have been correctly + implemented. + Preamble: Establish a call between the tester and TUT in Baudot mode at 45 bit/s. + Method: The tester will send all possible characters preceded by the relevant case shift + command one at a time and wait for a response from the TUT operator. Each + character should be responded to at the TUT by typing the received character or + if the character is not available. + Pass criteria: 1) The tester will verify that each character is correctly echoed back by the TUT. + The operator should verify that each character is correctly displayed on the TUT. + 2) The TUT will send the LTRS symbol before its first character and the + appropriate mode character (either LTRS or FIGS) after every 72 subsequent + characters. + Comments: The tester should indicate which character has been sent in each case. Some of the + characters may not be available from the TUT keyboard and can be ignored. It is + assumed that the character conversion is the same for Baudot at 50 bit/s and any + other supported speed. + */ v18_state = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL); + logging = v18_get_logging_state(v18_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, ""); printf("Original:\n"); t = result; for (i = 0; i < 127; i++) @@ -222,6 +1611,24 @@ static int test_x_04(void) } /*- End of function --------------------------------------------------------*/ +static int test_x_05(void) +{ + /* + III.5.4.5.5 DTMF receiver disabling + Purpose: To verify that the TUT disables its DTMF receiver for 300 ms when a character is + transmitted. + Preamble: Establish a call between the tester and TUT in DTMF mode. + Method: The operator should send a single "e" character from the TUT which will result in + sending a single DTMF tone to the tester. The tester will immediately start sending a + unique character sequence using single DTMF tones. Examination of the TUT + display will show when its receiver is re-enabled. + Pass criteria: The receiver should be re-enabled after 300 ms. + */ + printf("Test not yet implemented\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + static int test_x_06(void) { char msg[128]; @@ -230,7 +1637,20 @@ static int test_x_06(void) const char *ref; int i; - /* III.5.4.5.6 DTMF character conversion */ + /* + III.5.4.5.6 DTMF character conversion + Purpose: To check that the character conversion tables in Annex B have been correctly + implemented. + Preamble: Establish a call between the tester and TUT in DTMF mode. + Method: The tester will send each character from the set in Annex B, waiting for a response + after each one. Each character should be responded to at the TUT by typing the + same character. + Pass criteria: The tester will verify that each character is correctly echoed back by the TUT. + Comments: The conversion table is specified in Annex B. The receiver at the tester may be re- + enabled 100 ms after transmission of each character to maximize likelihood of + receiving character from the TUT. It is assumed that the echo delay in the test + system is negligible. + */ for (i = 0; i < 127; i++) msg[i] = i + 1; msg[127] = '\0'; @@ -253,10 +1673,124 @@ static int test_x_06(void) } /*- End of function --------------------------------------------------------*/ -static int test_unimplemented(void) +static int test_x_07(void) { + /* + III.5.4.5.7 EDT carrier timing and receiver disabling + Purpose: To verify that the TUT sends unmodulated carrier for 300 ms before a character and + disables its receiver for 300 ms after a character is transmitted. + Preamble: Establish a call between the tester and TUT in EDT mode. + Method: The operator should send a single character from the TUT. The tester will + immediately start sending a unique character sequence. Examination of the TUT + display will show when its receiver is re-enabled. + Pass criteria: 1) The TUT should send unmodulated carrier for 300 ms before the beginning of + the start bit. + 2) The receiver should be re-enabled after 300 ms. + 3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used. + Comments: The carrier should be maintained during the 300 ms after a character. + */ printf("Test not yet implemented\n"); - return 1; + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int test_x_08(void) +{ + /* + III.5.4.5.8 EDT bit rate and character structure + Purpose: To verify that the TUT uses the correct bit rate and character structure in the EDT + mode. + Preamble: Establish a call between the tester and TUT in EDT mode. + Method: The operator should transmit the string "abcdef" from the TUT. + Pass criteria: 1) The tester should measure the bit timings and confirm that the rate is 110 bit/s. + 2) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop + bits are used. + */ + printf("Test not yet implemented\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int test_x_09(void) +{ + /* + III.5.4.5.9 V.23 calling mode character format + Purpose: To verify that the TUT uses the correct character format in the V.23 calling mode. + Preamble: Establish a call from the TUT to the tester in V.23 mode. + Method: The operator should transmit the string "abcdef" from the TUT. The tester will echo + characters back to the TUT as they are received. The tester will then transmit the + string "abcdef" with ODD parity to the TUT. + Pass criteria: 1) Confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop bits are + transmitted. + 2) The operator should confirm that there is no local echo at the TUT by checking + that there are no duplicate characters on the TUT display. + 3) The received string should be correctly displayed despite the incorrect parity. + */ + printf("Test not yet implemented\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int test_x_10(void) +{ + /* + III.5.4.5.10 V.23 answer mode character format + Purpose: To verify that the TUT uses the correct character format in the V.23 answer mode. + Preamble: Establish a call from the tester to the TUT in V.23 mode. + Method: The tester will transmit the string "abcdef" with ODD parity. The TUT should echo + characters back to the tester as they are received. The operator should then transmit + the string "abcdef" from the TUT. + Pass criteria: 1) The received string should be correctly displayed at the TUT despite the + incorrect parity. + 2) Confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop bits are + transmitted by the TUT. + 3) The tester should confirm that there is remote echo from TUT. + 4) The operator should confirm that there is local echo on the TUT. + Comments: + */ + printf("Test not yet implemented\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int test_x_11(void) +{ + /* + III.5.4.5.11 This test is only applicable to Minitel Dialogue terminals. Prestel and Minitel + Normal terminals cannot operate in this mode. + V.21 character structure + Purpose: To verify that the TUT uses the character structure in the V.21 mode. + Preamble: Establish a call from the TUT to the tester in V.21 mode. + Method: The operator should transmit a string from the TUT that is long enough to cause the + display to word wrap followed by "abcdef", new line (CR+LF). The tester will then + transmit the string "123456", BACKSPACE (0/8) with ODD parity to the TUT. + Pass criteria: 1) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 1 stop + bits are transmitted. + 2) The word wrap should not result in CR+LF. + 3) The forced new line should be indicated by CR+LF. + 4) The last five characters on the TUT display should be "12345" (no "6") + correctly displayed despite the incorrect parity. + */ + printf("Test not yet implemented\n"); + return 0; +} +/*- End of function --------------------------------------------------------*/ + +static int test_x_12(void) +{ + /* + III.5.4.5.12 V.18 mode + Purpose: To verify that the TUT uses the protocol defined in ITU-T T.140. + Preamble: Establish a call from the TUT to the tester in V.18 mode. + Method: The operator should transmit a string from the TUT that is long enough to cause the + display to word wrap followed by "abcdef", new line (CR+LF), new line + (UNICODE preferred). The tester will then transmit the string "123456", + BACKSPACE. + Pass criteria: The tester should confirm UTF8 encoded UNICODE characters are used with the + controls specified in ITU-T T.140. + */ + printf("Test not yet implemented\n"); + return 0; } /*- End of function --------------------------------------------------------*/ @@ -272,10 +1806,11 @@ static void put_v18_msg(void *user_data, const uint8_t *msg, int len) static int decode_test_data_file(int mode, const char *filename) { - v18_state_t *v18_state; int16_t amp[SAMPLES_PER_CHUNK]; SNDFILE *inhandle; int len; + v18_state_t *v18_state; + logging_state_t *logging; printf("Decoding as '%s'\n", v18_mode_to_str(mode)); /* We will decode the audio from a file. */ @@ -285,10 +1820,12 @@ static int decode_test_data_file(int mode, const char *filename) exit(2); } v18_state = v18_init(NULL, FALSE, mode, put_v18_msg, NULL); + logging = v18_get_logging_state(v18_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, ""); for (;;) { - len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK); - if (len == 0) + if ((len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)) <= 0) break; v18_rx(v18_state, amp, len); } @@ -309,97 +1846,97 @@ const struct } test_list[] = { {"III.3.2.1 Operational requirements tests", NULL}, - {"MISC-01 4 (1) No Disconnection Test", test_unimplemented}, - {"MISC-02 4 (2) Automatic resumption of automoding", test_unimplemented}, - {"MISC-03 4 (2) Retention of selected mode on loss of signal", test_unimplemented}, - {"MISC-04 4 (4) Detection of BUSY tone", test_unimplemented}, - {"MISC-05 4 (4) Detection of RINGING", test_unimplemented}, - {"MISC-06 4 (4) LOSS OF CARRIER indication", test_unimplemented}, - {"MISC-07 4 (4) Call progress indication", test_unimplemented}, - {"MISC-08 4 (5) Circuit 135 test", test_unimplemented}, - {"MISC-09 Connection Procedures", test_unimplemented}, + {"MISC-01 4 (1) No Disconnection Test", test_misc_01}, + {"MISC-02 4 (2) Automatic resumption of automoding", test_misc_02}, + {"MISC-03 4 (2) Retention of selected mode on loss of signal", test_misc_03}, + {"MISC-04 4 (4) Detection of BUSY tone", test_misc_04}, + {"MISC-05 4 (4) Detection of RINGING", test_misc_05}, + {"MISC-06 4 (4) LOSS OF CARRIER indication", test_misc_06}, + {"MISC-07 4 (4) Call progress indication", test_misc_07}, + {"MISC-08 4 (5) Circuit 135 test", test_misc_08}, + {"MISC-09 4 (6) Connection Procedures", test_misc_09}, {"III.3.2.2 Automode originate tests", NULL}, - {"ORG-01 5.1.1 CI & XCI Signal coding and cadence", test_unimplemented}, - {"ORG-02 5.1.3 ANS Signal Detection", test_unimplemented}, - {"ORG-03 5.2.3.1 End of ANS signal detection", test_unimplemented}, - {"ORG-04 5.1.3.2 ANS tone followed by TXP", test_unimplemented}, - {"ORG-05 5.1.3.3 ANS tone followed by 1650Hz", test_unimplemented}, - {"ORG-06 5.1.3.4 ANS tone followed by 1300Hz", test_unimplemented}, - {"ORG-07 5.1.3 ANS tone followed by no tone", test_unimplemented}, - {"ORG-08 5.1.4 Bell 103 (2225Hz Signal) Detection", test_unimplemented}, - {"ORG-09 5.1.5 V.21 (1650Hz Signal) Detection", test_unimplemented}, - {"ORG-10 5.1.6 V.23 (1300Hz Signal) Detection", test_unimplemented}, - {"ORG-11 5.1.7 V.23 (390Hz Signal) Detection", test_unimplemented}, - {"ORG-12a to d 5.1.8 5 Bit Mode (Baudot) Detection Tests", test_unimplemented}, - {"ORG-13 5.1.9 DTMF signal detection", test_unimplemented}, - {"ORG-14 5.1.10 EDT Rate Detection", test_unimplemented}, - {"ORG-15 5.1.10.1 Rate Detection Test", test_unimplemented}, - {"ORG-16 5.1.10.2 980Hz Detection", test_unimplemented}, - {"ORG-17 5.1.10.3 Loss of signal after 980Hz", test_unimplemented}, - {"ORG-18 5.1.10.3 Tr Timer", test_unimplemented}, - {"ORG-19 5.1.11 Bell 103 (1270Hz Signal) Detection", test_unimplemented}, - {"ORG-20 Immunity to Network Tones", test_unimplemented}, - {"ORG-21a to b Immunity to other non-textphone modems", test_unimplemented}, - {"ORG-22 Immunity to Fax Tones", test_unimplemented}, - {"ORG-23 Immunity to Voice", test_unimplemented}, - {"ORG-24 5.1.2 ANSam detection", test_unimplemented}, - {"ORG-25 6.1 V.8 originate call", test_unimplemented}, + {"ORG-01 5.1.1 CI & XCI Signal coding and cadence", test_org_01}, + {"ORG-02 5.1.3 ANS Signal Detection", test_org_02}, + {"ORG-03 5.2.3.1 End of ANS signal detection", test_org_03}, + {"ORG-04 5.1.3.2 ANS tone followed by TXP", test_org_04}, + {"ORG-05 5.1.3.3 ANS tone followed by 1650Hz", test_org_05}, + {"ORG-06 5.1.3.4 ANS tone followed by 1300Hz", test_org_06}, + {"ORG-07 5.1.3 ANS tone followed by no tone", test_org_07}, + {"ORG-08 5.1.4 Bell 103 (2225Hz Signal) Detection", test_org_08}, + {"ORG-09 5.1.5 V.21 (1650Hz Signal) Detection", test_org_09}, + {"ORG-10 5.1.6 V.23 (1300Hz Signal) Detection", test_org_10}, + {"ORG-11 5.1.7 V.23 (390Hz Signal) Detection", test_org_11}, + {"ORG-12a to d 5.1.8 5 Bit Mode (Baudot) Detection Tests", test_org_12}, + {"ORG-13 5.1.9 DTMF signal detection", test_org_13}, + {"ORG-14 5.1.10 EDT Rate Detection", test_org_14}, + {"ORG-15 5.1.10.1 Rate Detection Test", test_org_15}, + {"ORG-16 5.1.10.2 980Hz Detection", test_org_16}, + {"ORG-17 5.1.10.3 Loss of signal after 980Hz", test_org_17}, + {"ORG-18 5.1.10.3 Tr Timer", test_org_18}, + {"ORG-19 5.1.11 Bell 103 (1270Hz Signal) Detection", test_org_19}, + {"ORG-20 Immunity to Network Tones", test_org_20}, + {"ORG-21a to b Immunity to other non-textphone modems", test_org_21}, + {"ORG-22 Immunity to Fax Tones", test_org_22}, + {"ORG-23 Immunity to Voice", test_org_23}, + {"ORG-24 5.1.2 ANSam detection", test_org_24}, + {"ORG-25 6.1 V.8 originate call", test_org_25}, {"III.3.2.3 Automode answer tests", NULL}, - {"ANS-01 5.2.1 Ta timer", test_unimplemented}, - {"ANS-02 5.2.2 CI Signal Detection", test_unimplemented}, - {"ANS-03 5.2.2.1 Early Termination of ANS tone", test_unimplemented}, - {"ANS-04 5.2.2.2 Tt Timer", test_unimplemented}, - {"ANS-05 5.2.3.2 ANS tone followed by 980Hz", test_unimplemented}, - {"ANS-06 5.2.3.2 ANS tone followed by 1300Hz", test_unimplemented}, - {"ANS-07 5.2.3.3 ANS tone followed by 1650Hz", test_unimplemented}, - {"ANS-08 5.2.4.1 980Hz followed by 1650Hz", test_unimplemented}, - {"ANS-09a to d 5.2.4.2 980Hz calling tone detection", test_unimplemented}, - {"ANS-10 5.2.4.3 V.21 Detection by Timer", test_unimplemented}, - {"ANS-11 5.2.4.4.1 EDT Detection by Rate", test_unimplemented}, - {"ANS-12 5.2.4.4.2 V.21 Detection by Rate", test_unimplemented}, - {"ANS-13 5.2.4.4.3 Tr Timer", test_unimplemented}, - {"ANS-14 5.2.4.5 Te Timer", test_unimplemented}, - {"ANS-15a to d 5.2.5 5 Bit Mode (Baudot) Detection Tests", test_unimplemented}, - {"ANS-16 5.2.6 DTMF Signal Detection", test_unimplemented}, - {"ANS-17 5.2.7 Bell 103 (1270Hz signal) detection", test_unimplemented}, - {"ANS-18 5.2.8 Bell 103 (2225Hz signal) detection", test_unimplemented}, - {"ANS-19 5.2.9 V.21 Reverse Mode (1650Hz) Detection", test_unimplemented}, - {"ANS-20a to d 5.2.10 1300Hz Calling Tone Discrimination", test_unimplemented}, - {"ANS-21 5.2.11 V.23 Reverse Mode (1300Hz) Detection", test_unimplemented}, - {"ANS-22 1300Hz with XCI Test", test_unimplemented}, - {"ANS-23 5.2.12 Stimulate Mode Country Settings", test_unimplemented}, - {"ANS-24 5.2.12.1 Stimulate Carrierless Mode Probe Message", test_unimplemented}, - {"ANS-25 5.2.12.1.1 Interrupted Carrierless Mode Probe", test_unimplemented}, - {"ANS-26 5.2.12.2 Stimulate Carrier Mode Probe Time", test_unimplemented}, - {"ANS-27 5.2.12.2.1 V.23 Mode (390Hz) Detection", test_unimplemented}, - {"ANS-28 5.2.12.2.2 Interrupted Carrier Mode Probe", test_unimplemented}, - {"ANS-29 5.2.12.2.2 Stimulate Mode Response During Probe", test_unimplemented}, - {"ANS-30 Immunity to Network Tones", test_unimplemented}, - {"ANS-31 Immunity to Fax Calling Tones", test_unimplemented}, - {"ANS-32 Immunity to Voice", test_unimplemented}, - {"ANS-33 5.2.2.1 V.8 CM detection and V.8 Answering", test_unimplemented}, + {"ANS-01 5.2.1 Ta timer", test_ans_01}, + {"ANS-02 5.2.2 CI Signal Detection", test_ans_02}, + {"ANS-03 5.2.2.1 Early Termination of ANS tone", test_ans_03}, + {"ANS-04 5.2.2.2 Tt Timer", test_ans_04}, + {"ANS-05 5.2.3.2 ANS tone followed by 980Hz", test_ans_05}, + {"ANS-06 5.2.3.2 ANS tone followed by 1300Hz", test_ans_06}, + {"ANS-07 5.2.3.3 ANS tone followed by 1650Hz", test_ans_07}, + {"ANS-08 5.2.4.1 980Hz followed by 1650Hz", test_ans_08}, + {"ANS-09a to d 5.2.4.2 980Hz calling tone detection", test_ans_09}, + {"ANS-10 5.2.4.3 V.21 Detection by Timer", test_ans_10}, + {"ANS-11 5.2.4.4.1 EDT Detection by Rate", test_ans_11}, + {"ANS-12 5.2.4.4.2 V.21 Detection by Rate", test_ans_12}, + {"ANS-13 5.2.4.4.3 Tr Timer", test_ans_13}, + {"ANS-14 5.2.4.5 Te Timer", test_ans_14}, + {"ANS-15a to d 5.2.5 5 Bit Mode (Baudot) Detection Tests", test_ans_15}, + {"ANS-16 5.2.6 DTMF Signal Detection", test_ans_16}, + {"ANS-17 5.2.7 Bell 103 (1270Hz signal) detection", test_ans_17}, + {"ANS-18 5.2.8 Bell 103 (2225Hz signal) detection", test_ans_18}, + {"ANS-19 5.2.9 V.21 Reverse Mode (1650Hz) Detection", test_ans_19}, + {"ANS-20a to d 5.2.10 1300Hz Calling Tone Discrimination", test_ans_20}, + {"ANS-21 5.2.11 V.23 Reverse Mode (1300Hz) Detection", test_ans_21}, + {"ANS-22 1300Hz with XCI Test", test_ans_22}, + {"ANS-23 5.2.12 Stimulate Mode Country Settings", test_ans_23}, + {"ANS-24 5.2.12.1 Stimulate Carrierless Mode Probe Message", test_ans_24}, + {"ANS-25 5.2.12.1.1 Interrupted Carrierless Mode Probe", test_ans_25}, + {"ANS-26 5.2.12.2 Stimulate Carrier Mode Probe Time", test_ans_26}, + {"ANS-27 5.2.12.2.1 V.23 Mode (390Hz) Detection", test_ans_27}, + {"ANS-28 5.2.12.2.2 Interrupted Carrier Mode Probe", test_ans_28}, + {"ANS-29 5.2.12.2.2 Stimulate Mode Response During Probe", test_ans_29}, + {"ANS-30 Immunity to Network Tones", test_ans_30}, + {"ANS-31 Immunity to Fax Calling Tones", test_ans_31}, + {"ANS-32 Immunity to Voice", test_ans_32}, + {"ANS-33 5.2.2.1 V.8 CM detection and V.8 Answering", test_ans_33}, {"III.3.2.4 Automode monitor tests", NULL}, - {"MON-01 to -20 5.3 Repeat all answer mode tests excluding tests ANS-01, ANS-20 and ANS-23 to ANS-29", test_unimplemented}, - {"MON-21 5.3 Automode Monitor Ta timer", test_unimplemented}, - {"MON-22a to d 5.3 Automode Monitor 1300Hz Calling Tone Discrimination", test_unimplemented}, - {"MON-23a to d 5.3 Automode Monitor 980Hz Calling Tone Discrimination", test_unimplemented}, + {"MON-01 to -20 5.3 Repeat all answer mode tests excluding tests ANS-01, ANS-20 and ANS-23 to ANS-29", test_mon_01}, + {"MON-21 5.3 Automode Monitor Ta timer", test_mon_21}, + {"MON-22a to d 5.3 Automode Monitor 1300Hz Calling Tone Discrimination", test_mon_22}, + {"MON-23a to d 5.3 Automode Monitor 980Hz Calling Tone Discrimination", test_mon_23}, {"III.3.2.5 ITU-T V.18 annexes tests", NULL}, {"X-01 A.1 Baudot carrier timing and receiver disabling", test_x_01}, {"X-02 A.2 Baudot bit rate confirmation", test_x_02}, {"X-03 A.3 Baudot probe bit rate confirmation", test_x_03}, {"X-04 A.4 5 Bit to T.50 Character Conversion", test_x_04}, - {"X-05 B.1 DTMF receiver disabling", test_unimplemented}, + {"X-05 B.1 DTMF receiver disabling", test_x_05}, {"X-06 B.2 DTMF character conversion", test_x_06}, - {"X-07 C.1 EDT carrier timing and receiver disabling", test_unimplemented}, - {"X-08 C.2-3 EDT bit rate and character structure", test_unimplemented}, - {"X-09 E V.23 calling mode character format", test_unimplemented}, - {"X-10 E V.23 answer mode character format", test_unimplemented}, - {"X-11 F.4-5 V.21 character structure", test_unimplemented}, - {"X-12 G.1-3 V.18 mode", test_unimplemented}, + {"X-07 C.1 EDT carrier timing and receiver disabling", test_x_07}, + {"X-08 C.2-3 EDT bit rate and character structure", test_x_08}, + {"X-09 E V.23 calling mode character format", test_x_09}, + {"X-10 E V.23 answer mode character format", test_x_10}, + {"X-11 F.4-5 V.21 character structure", test_x_11}, + {"X-12 G.1-3 V.18 mode", test_x_12}, {"", NULL} }; @@ -490,6 +2027,7 @@ int main(int argc, char *argv[]) exit(2); } basic_tests(V18_MODE_5BIT_45); + basic_tests(V18_MODE_5BIT_45 | 0x100); if (log_audio) { if (sf_close_telephony(outhandle)) diff --git a/libs/spandsp/tests/v22bis_tests.c b/libs/spandsp/tests/v22bis_tests.c index f7d7ef7703..dd3564cdcb 100644 --- a/libs/spandsp/tests/v22bis_tests.c +++ b/libs/spandsp/tests/v22bis_tests.c @@ -115,7 +115,7 @@ static void v22bis_rx_status(void *user_data, int status) int bit_rate; int i; int len; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) complexi16_t *coeffs; #else complexf_t *coeffs; @@ -129,14 +129,16 @@ static void v22bis_rx_status(void *user_data, int status) case SIG_STATUS_TRAINING_SUCCEEDED: bit_rate = v22bis_get_current_bit_rate(s->v22bis); printf("Negotiated bit rate: %d\n", bit_rate); - len = v22bis_rx_equalizer_state(s->v22bis, &coeffs); - printf("Equalizer:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f); + if ((len = v22bis_rx_equalizer_state(s->v22bis, &coeffs))) + { + printf("Equalizer:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V22BIS_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V22BIS_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif + } break; } } @@ -171,7 +173,7 @@ static int v22bis_getbit(void *user_data) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static void qam_report(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol) #else static void qam_report(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol) @@ -179,22 +181,27 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex { int i; int len; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) complexi16_t *coeffs; - complexf_t constel_point; #else complexf_t *coeffs; #endif + complexf_t constel_point; + complexf_t target_point; float fpower; endpoint_t *s; s = (endpoint_t *) user_data; if (constel) { + constel_point.re = constel->re/V22BIS_CONSTELLATION_SCALING_FACTOR; + constel_point.im = constel->im/V22BIS_CONSTELLATION_SCALING_FACTOR; + target_point.re = target->re/V22BIS_CONSTELLATION_SCALING_FACTOR; + target_point.im = target->im/V22BIS_CONSTELLATION_SCALING_FACTOR; #if defined(ENABLE_GUI) if (use_gui) { - qam_monitor_update_constel(s->qam_monitor, constel); + qam_monitor_update_constel(s->qam_monitor, &constel_point); qam_monitor_update_carrier_tracking(s->qam_monitor, v22bis_rx_carrier_frequency(s->v22bis)); qam_monitor_update_symbol_tracking(s->qam_monitor, v22bis_rx_symbol_timing_correction(s->v22bis)); } @@ -205,10 +212,10 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %8.4f\n", s->symbol_no, - constel->re, - constel->im, - target->re, - target->im, + constel_point.re, + constel_point.im, + target_point.re, + target_point.im, symbol, fpower, s->smooth_power, @@ -218,22 +225,26 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex else { printf("Gardner step %d\n", symbol); - len = v22bis_rx_equalizer_state(s->v22bis, &coeffs); - printf("Equalizer A:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f); + if ((len = v22bis_rx_equalizer_state(s->v22bis, &coeffs))) + { + printf("Equalizer A:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V22BIS_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V22BIS_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif #if defined(ENABLE_GUI) - if (use_gui) -#if defined(SPANDSP_USE_FIXED_POINTx) - qam_monitor_update_int_equalizer(s->qam_monitor, coeffs, len); + if (use_gui) + { +#if defined(SPANDSP_USE_FIXED_POINT) + qam_monitor_update_int_equalizer(s->qam_monitor, coeffs, len); #else - qam_monitor_update_equalizer(s->qam_monitor, coeffs, len); + qam_monitor_update_equalizer(s->qam_monitor, coeffs, len); #endif + } #endif + } } } /*- End of function --------------------------------------------------------*/ @@ -366,8 +377,8 @@ int main(int argc, char *argv[]) #if defined(ENABLE_GUI) if (use_gui) { - endpoint[0].qam_monitor = qam_monitor_init(6.0f, "Calling modem"); - endpoint[1].qam_monitor = qam_monitor_init(6.0f, "Answering modem"); + endpoint[0].qam_monitor = qam_monitor_init(6.0f, V22BIS_CONSTELLATION_SCALING_FACTOR, "Calling modem"); + endpoint[1].qam_monitor = qam_monitor_init(6.0f, V22BIS_CONSTELLATION_SCALING_FACTOR, "Answering modem"); } #endif if ((model = both_ways_line_model_init(line_model_no, @@ -465,7 +476,7 @@ int main(int argc, char *argv[]) exit(2); } } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/v27ter_tests.c b/libs/spandsp/tests/v27ter_tests.c index cd05b13738..93bda4c815 100644 --- a/libs/spandsp/tests/v27ter_tests.c +++ b/libs/spandsp/tests/v27ter_tests.c @@ -118,7 +118,7 @@ static void v27ter_rx_status(void *user_data, int status) v27ter_rx_state_t *s; int i; int len; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) complexi16_t *coeffs; #else complexf_t *coeffs; @@ -129,14 +129,16 @@ static void v27ter_rx_status(void *user_data, int status) switch (status) { case SIG_STATUS_TRAINING_SUCCEEDED: - len = v27ter_rx_equalizer_state(s, &coeffs); - printf("Equalizer:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f); + if ((len = v27ter_rx_equalizer_state(s, &coeffs))) + { + printf("Equalizer:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V27TER_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V27TER_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif + } break; } } @@ -169,7 +171,7 @@ static int v27tergetbit(void *user_data) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static void qam_report(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol) #else static void qam_report(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol) @@ -177,95 +179,100 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex { int i; int len; -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) complexi16_t *coeffs; - complexf_t constel_point; #else complexf_t *coeffs; #endif + complexf_t constel_point; + complexf_t target_point; float fpower; float error; v27ter_rx_state_t *rx; static float smooth_power = 0.0f; -#if defined(ENABLE_GUI) - static int reports = 0; -#endif + static int update_interval = 100; rx = (v27ter_rx_state_t *) user_data; if (constel) { - fpower = (constel->re - target->re)*(constel->re - target->re) - + (constel->im - target->im)*(constel->im - target->im); + constel_point.re = constel->re/V27TER_CONSTELLATION_SCALING_FACTOR; + constel_point.im = constel->im/V27TER_CONSTELLATION_SCALING_FACTOR; + target_point.re = target->re/V27TER_CONSTELLATION_SCALING_FACTOR; + target_point.im = target->im/V27TER_CONSTELLATION_SCALING_FACTOR; + fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re) + + (constel_point.im - target_point.im)*(constel_point.im - target_point.im); smooth_power = 0.95f*smooth_power + 0.05f*fpower; #if defined(ENABLE_GUI) if (use_gui) { - qam_monitor_update_constel(qam_monitor, constel); + qam_monitor_update_constel(qam_monitor, &constel_point); qam_monitor_update_carrier_tracking(qam_monitor, v27ter_rx_carrier_frequency(rx)); qam_monitor_update_symbol_tracking(qam_monitor, v27ter_rx_symbol_timing_correction(rx)); } #endif error = constel->im*target->re - constel->re*target->im; - printf("Tracking error %f %f %f %f %f %f\n", error, v27ter_rx_carrier_frequency(rx), constel->re, constel->im, target->re, target->im); + printf("Tracking error %f %f %f %f %f %f\n", error, v27ter_rx_carrier_frequency(rx), constel_point.re, constel_point.im, target_point.re, target_point.im); printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n", symbol_no, - constel->re, - constel->im, - target->re, - target->im, + constel_point.re, + constel_point.im, + target_point.re, + target_point.im, symbol, fpower, smooth_power, v27ter_rx_carrier_frequency(rx), v27ter_rx_signal_power(rx), v27ter_rx_symbol_timing_correction(rx)); - len = v27ter_rx_equalizer_state(rx, &coeffs); - printf("Equalizer B:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f); -#else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); -#endif -#if defined(WITH_SPANDSP_INTERNALS) - printf("Gardtest %d %f %d\n", symbol_no, v27ter_rx_symbol_timing_correction(rx), rx->gardner_integrate); -#endif - printf("Carcar %d %f\n", symbol_no, v27ter_rx_carrier_frequency(rx)); -#if defined(ENABLE_GUI) - if (use_gui) - { - if (++reports >= 1000) - { -#if defined(SPANDSP_USE_FIXED_POINTx) - qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); -#else - qam_monitor_update_equalizer(qam_monitor, coeffs, len); -#endif - reports = 0; - } - } -#endif symbol_no++; + if (--update_interval <= 0) + { + if ((len = v27ter_rx_equalizer_state(rx, &coeffs))) + { + printf("Equalizer B:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V27TER_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V27TER_CONSTELLATION_SCALING_FACTOR); +#else + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); +#endif +#if defined(ENABLE_GUI) + if (use_gui) + { +#if defined(SPANDSP_USE_FIXED_POINT) + qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); +#else + qam_monitor_update_equalizer(qam_monitor, coeffs, len); +#endif + } +#endif + } + update_interval = 100; + } } else { printf("Gardner step %d\n", symbol); - len = v27ter_rx_equalizer_state(rx, &coeffs); - printf("Equalizer A:\n"); - for (i = 0; i < len; i++) -#if defined(SPANDSP_USE_FIXED_POINTx) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f); + if ((len = v27ter_rx_equalizer_state(rx, &coeffs))) + { + printf("Equalizer A:\n"); + for (i = 0; i < len; i++) +#if defined(SPANDSP_USE_FIXED_POINT) + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V27TER_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V27TER_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif #if defined(ENABLE_GUI) - if (use_gui) -#if defined(SPANDSP_USE_FIXED_POINTx) - qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); + if (use_gui) + { +#if defined(SPANDSP_USE_FIXED_POINT) + qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); #else - qam_monitor_update_equalizer(qam_monitor, coeffs, len); + qam_monitor_update_equalizer(qam_monitor, coeffs, len); #endif + } #endif + } } } /*- End of function --------------------------------------------------------*/ @@ -475,7 +482,7 @@ int main(int argc, char *argv[]) #if defined(ENABLE_GUI) if (use_gui) { - qam_monitor = qam_monitor_init(2.0f, NULL); + qam_monitor = qam_monitor_init(2.0f, V27TER_CONSTELLATION_SCALING_FACTOR, NULL); if (!decode_test_file) { start_line_model_monitor(129); @@ -598,7 +605,7 @@ int main(int argc, char *argv[]) exit(2); } } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/v27ter_tests.sh b/libs/spandsp/tests/v27ter_tests.sh new file mode 100755 index 0000000000..9e5d99d9b3 --- /dev/null +++ b/libs/spandsp/tests/v27ter_tests.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +STDOUT_DEST=xyzzy +STDERR_DEST=xyzzy2 + +for OPTS in "-g -b 4800 -s -42 -n -57" "-g -b 2400 -s -42 -n -51" +do + ./v27ter_tests ${OPTS} >$STDOUT_DEST 2>$STDERR_DEST + RETVAL=$? + if [ $RETVAL != 0 ] + then + echo v27ter_tests ${OPTS} failed! + exit $RETVAL + fi +done +echo v27ter_tests completed OK diff --git a/libs/spandsp/tests/v29_tests.c b/libs/spandsp/tests/v29_tests.c index 4b3b3858dc..6bab0d9a14 100644 --- a/libs/spandsp/tests/v29_tests.c +++ b/libs/spandsp/tests/v29_tests.c @@ -129,14 +129,16 @@ static void v29_rx_status(void *user_data, int status) { case SIG_STATUS_TRAINING_SUCCEEDED: printf("Training succeeded\n"); - len = v29_rx_equalizer_state(s, &coeffs); - printf("Equalizer:\n"); - for (i = 0; i < len; i++) + if ((len = v29_rx_equalizer_state(s, &coeffs))) + { + printf("Equalizer:\n"); + for (i = 0; i < len; i++) #if defined(SPANDSP_USE_FIXED_POINT) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f); + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V29_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V29_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif + } break; } } @@ -169,7 +171,7 @@ static int v29getbit(void *user_data) } /*- End of function --------------------------------------------------------*/ -#if defined(SPANDSP_USE_FIXED_POINTx) +#if defined(SPANDSP_USE_FIXED_POINT) static void qam_report(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol) #else static void qam_report(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol) @@ -179,10 +181,11 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex int len; #if defined(SPANDSP_USE_FIXED_POINT) complexi16_t *coeffs; - complexf_t constel_point; #else complexf_t *coeffs; #endif + complexf_t constel_point; + complexf_t target_point; float fpower; v29_rx_state_t *rx; static float smooth_power = 0.0f; @@ -191,22 +194,17 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex rx = (v29_rx_state_t *) user_data; if (constel) { - fpower = (constel->re - target->re)*(constel->re - target->re) - + (constel->im - target->im)*(constel->im - target->im); -#if defined(SPANDSP_USE_FIXED_POINT) - fpower /= 4096.0*4096.0; -#endif + constel_point.re = constel->re/V29_CONSTELLATION_SCALING_FACTOR; + constel_point.im = constel->im/V29_CONSTELLATION_SCALING_FACTOR; + target_point.re = target->re/V29_CONSTELLATION_SCALING_FACTOR, + target_point.im = target->im/V29_CONSTELLATION_SCALING_FACTOR, + fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re) + + (constel_point.im - target_point.im)*(constel_point.im - target_point.im); smooth_power = 0.95f*smooth_power + 0.05f*fpower; #if defined(ENABLE_GUI) if (use_gui) { -#if defined(SPANDSP_USE_FIXED_POINTx) - constel_point.re = constel->re/4096.0; - constel_point.im = constel->im/4096.0; qam_monitor_update_constel(qam_monitor, &constel_point); -#else - qam_monitor_update_constel(qam_monitor, constel); -#endif qam_monitor_update_carrier_tracking(qam_monitor, v29_rx_carrier_frequency(rx)); //qam_monitor_update_carrier_tracking(qam_monitor, (fpower) ? fpower : 0.001f); qam_monitor_update_symbol_tracking(qam_monitor, v29_rx_symbol_timing_correction(rx)); @@ -214,17 +212,10 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex #endif printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n", symbol_no, -#if defined(SPANDSP_USE_FIXED_POINTx) - constel->re/4096.0, - constel->im/4096.0, - target->re/4096.0, - target->im/4096.0, -#else - constel->re, - constel->im, - target->re, - target->im, -#endif + constel_point.re, + constel_point.im, + target_point.re, + target_point.im, symbol, fpower, smooth_power, @@ -234,22 +225,26 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex symbol_no++; if (--update_interval <= 0) { - len = v29_rx_equalizer_state(rx, &coeffs); - printf("Equalizer A:\n"); - for (i = 0; i < len; i++) + if ((len = v29_rx_equalizer_state(rx, &coeffs))) + { + printf("Equalizer A:\n"); + for (i = 0; i < len; i++) #if defined(SPANDSP_USE_FIXED_POINT) - printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f); + printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V29_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V29_CONSTELLATION_SCALING_FACTOR); #else - printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); + printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); #endif #if defined(ENABLE_GUI) - if (use_gui) + if (use_gui) + { #if defined(SPANDSP_USE_FIXED_POINT) - qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); + qam_monitor_update_int_equalizer(qam_monitor, coeffs, len); #else - qam_monitor_update_equalizer(qam_monitor, coeffs, len); + qam_monitor_update_equalizer(qam_monitor, coeffs, len); #endif + } #endif + } update_interval = 100; } } @@ -468,7 +463,7 @@ int main(int argc, char *argv[]) #if defined(ENABLE_GUI) if (use_gui) { - qam_monitor = qam_monitor_init(6.0f, NULL); + qam_monitor = qam_monitor_init(6.0f, V29_CONSTELLATION_SCALING_FACTOR, NULL); if (!decode_test_file) { start_line_model_monitor(129); @@ -590,7 +585,7 @@ int main(int argc, char *argv[]) exit(2); } } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/v29_tests.sh b/libs/spandsp/tests/v29_tests.sh new file mode 100755 index 0000000000..5c98d00619 --- /dev/null +++ b/libs/spandsp/tests/v29_tests.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +STDOUT_DEST=xyzzy +STDERR_DEST=xyzzy2 + +for OPTS in "-g -b 9600 -s -42 -n -62" "-g -b 7200 -s -42 -n -59" "-g -b 4800 -s -42 -n -54" +do + ./v29_tests ${OPTS} >$STDOUT_DEST 2>$STDERR_DEST + RETVAL=$? + if [ $RETVAL != 0 ] + then + echo v29_tests ${OPTS} failed! + exit $RETVAL + fi +done +echo v29_tests completed OK diff --git a/libs/spandsp/tests/v42_tests.c b/libs/spandsp/tests/v42_tests.c index c485fd17bb..2607d5a53f 100644 --- a/libs/spandsp/tests/v42_tests.c +++ b/libs/spandsp/tests/v42_tests.c @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) bit ^= 1; v42_rx_bit(&caller, bit); } - return 0; + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/tests/v8_tests.c b/libs/spandsp/tests/v8_tests.c index 4c48143099..ae59817232 100644 --- a/libs/spandsp/tests/v8_tests.c +++ b/libs/spandsp/tests/v8_tests.c @@ -206,6 +206,8 @@ static int v8_calls_v8_tests(SNDFILE *outhandle) negotiations_ok = 0; v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE; + v8_call_parms.send_ci = TRUE; + v8_call_parms.v92 = -1; v8_call_parms.call_function = V8_CALL_V_SERIES; v8_call_parms.modulations = caller_available_modulations; v8_call_parms.protocol = V8_PROTOCOL_LAPM_V42; @@ -219,6 +221,8 @@ static int v8_calls_v8_tests(SNDFILE *outhandle) handler, (void *) "caller"); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; + v8_answer_parms.send_ci = TRUE; + v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42; @@ -329,6 +333,8 @@ static int non_v8_calls_v8_tests(SNDFILE *outhandle) non_v8_caller_rx = modem_connect_tones_rx_init(NULL, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; + v8_answer_parms.send_ci = TRUE; + v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42; @@ -439,6 +445,8 @@ static int v8_calls_non_v8_tests(SNDFILE *outhandle) negotiations_ok = 0; v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE; + v8_call_parms.send_ci = TRUE; + v8_call_parms.v92 = -1; v8_call_parms.call_function = V8_CALL_V_SERIES; v8_call_parms.modulations = caller_available_modulations; v8_call_parms.protocol = V8_PROTOCOL_LAPM_V42; @@ -578,6 +586,8 @@ int main(int argc, char *argv[]) printf("Decode file '%s'\n", decode_test_file); v8_call_parms.modem_connect_tone = MODEM_CONNECT_TONES_NONE; + v8_call_parms.send_ci = TRUE; + v8_call_parms.v92 = -1; v8_call_parms.call_function = V8_CALL_V_SERIES; v8_call_parms.modulations = caller_available_modulations; v8_call_parms.protocol = V8_PROTOCOL_LAPM_V42; @@ -595,6 +605,8 @@ int main(int argc, char *argv[]) span_log_set_tag(logging, "caller"); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; + v8_answer_parms.send_ci = TRUE; + v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42; diff --git a/libs/sqlite/src/shell.c b/libs/sqlite/src/shell.c index b78b426ecb..f8fc854d82 100644 --- a/libs/sqlite/src/shell.c +++ b/libs/sqlite/src/shell.c @@ -414,7 +414,7 @@ static void output_csv(struct callback_data *p, const char *z, int bSep){ } } if( bSep ){ - fprintf(p->out, p->separator); + fprintf(p->out, "%s", p->separator); } } @@ -1085,7 +1085,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else if( c=='h' && strncmp(azArg[0], "help", n)==0 ){ - fprintf(stderr,zHelp); + fprintf(stderr,"%s",zHelp); }else if( c=='i' && strncmp(azArg[0], "import", n)==0 && nArg>=3 ){ diff --git a/libs/stfu/stfu.c b/libs/stfu/stfu.c index 0bd42a7d4a..787fd9c3d9 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 Anthony Minessale II + * Copyright (c) 2007-2012 Anthony Minessale II * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -461,7 +461,7 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void i->sync_in = 0; } else { - if ((ts && ts == i->last_rd_ts + i->samples_per_packet) || (i->last_rd_ts > 4294900000 && ts < 5000)) { + if ((ts && ts == i->last_rd_ts + i->samples_per_packet) || (i->last_rd_ts > 4294900000u && ts < 5000)) { good_ts = 1; } diff --git a/libs/stfu/stfu.h b/libs/stfu/stfu.h index 3e989b0a97..2b21419118 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 Anthony Minessale II + * Copyright (c) 2007-2012 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/tiff-3.8.2/.update b/libs/tiff-3.8.2/.update deleted file mode 100644 index ac5a7672b8..0000000000 --- a/libs/tiff-3.8.2/.update +++ /dev/null @@ -1 +0,0 @@ -Mon Oct 5 09:57:20 CDT 2009 diff --git a/libs/tiff-3.8.2/HOWTO-RELEASE b/libs/tiff-3.8.2/HOWTO-RELEASE deleted file mode 100644 index 97baedc679..0000000000 --- a/libs/tiff-3.8.2/HOWTO-RELEASE +++ /dev/null @@ -1,57 +0,0 @@ -HOWTO-RELEASE: - -Notes on releasing. You will need appropriate autoconf, automake and libtool -utilities to release a package. - -1. Commit any unsaved changes. - -2. "make clean" - -3. Create html/vX.X.html. Take ChangeLog entries and html-ify in there. - Easist thing to do is take html/vX.(X-1).html and use it as a template. - Add that file to the list of EXTRA_DIST files in the html/Makefile.am. - -3.5. Update html/index.html to refer to this new page as the current release. - -4. Increment version in configure.ac. Put 'alpha' or 'beta' after - the version, if applicable. - - eg. - 3.5.7 - or - 3.5.8beta - - Version should be updated in two places: in the second argument of the - AC_INIT macro and in LIBTIFF_xxx_VERSION variables. - -5. autoconf - -6. sh configure - -7. make release -- this will update "RELEASE-DATE" and "VERSION" in the top - level dir, and libtiff/tiffvers.h. - -8. Please verify that the version info in RELEASE-DATE, VERSION and - libtiff/tiffvers.h is right. - -9. make; make distcheck (to test). - -10. make distclean - -11. cvs commit - -12. cvs tag Release-v3-5-7 (or the appropriate name for the release) - -13. configure; make dist - Two files with names tiff-version.tar.gz and tiff-version.zip will - be created in the top level package directory. - -14. Copy to ftp.remotesensing.org ftp site. - scp tiff-*.tar.gz ftp.remotesensing.org:/var/ftp/libtiff/ - scp tiff-*.zip ftp.remotesensing.org:/var/ftp/libtiff/ - -15. Announce to list, tiff@lists.maptools.org - -16. Update libtiff page on freshmeat with new version announcement. - - diff --git a/libs/tiff-3.8.2/RELEASE-DATE b/libs/tiff-3.8.2/RELEASE-DATE deleted file mode 100644 index 14ad11c67d..0000000000 --- a/libs/tiff-3.8.2/RELEASE-DATE +++ /dev/null @@ -1 +0,0 @@ -20060323 diff --git a/libs/tiff-3.8.2/VERSION b/libs/tiff-3.8.2/VERSION deleted file mode 100644 index a08ffae0ca..0000000000 --- a/libs/tiff-3.8.2/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.8.2 diff --git a/libs/tiff-3.8.2/acinclude.m4 b/libs/tiff-3.8.2/acinclude.m4 deleted file mode 100644 index a213cde7ed..0000000000 --- a/libs/tiff-3.8.2/acinclude.m4 +++ /dev/null @@ -1,669 +0,0 @@ -dnl --------------------------------------------------------------------------- -dnl Message output -dnl --------------------------------------------------------------------------- -AC_DEFUN([LOC_MSG],[echo "$1"]) - -dnl --------------------------------------------------------------------------- -dnl Available from the GNU Autoconf Macro Archive at: -dnl http://www.gnu.org/software/ac-archive/vl_prog_cc_warnings.html -dnl --------------------------------------------------------------------------- - -dnl @synopsis VL_PROG_CC_WARNINGS([ANSI]) -dnl -dnl Enables a reasonable set of warnings for the C compiler. -dnl Optionally, if the first argument is nonempty, turns on flags which -dnl enforce and/or enable proper ANSI C if such are known with the -dnl compiler used. -dnl -dnl Currently this macro knows about GCC, Solaris C compiler, Digital -dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C -dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos -dnl 10.0.0.8) C compiler. -dnl -dnl @category C -dnl @author Ville Laurikari -dnl @version 2002-04-04 -dnl @license AllPermissive - -AC_DEFUN([VL_PROG_CC_WARNINGS], [ - ansi=$1 - if test -z "$ansi"; then - msg="for C compiler warning flags" - else - msg="for C compiler warning and ANSI conformance flags" - fi - AC_CACHE_CHECK($msg, vl_cv_prog_cc_warnings, [ - if test -n "$CC"; then - cat > conftest.c <&1 | grep -i "WorkShop" > /dev/null 2>&1 && - $CC -c -v -Xc conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="-v" - else - vl_cv_prog_cc_warnings="-v -Xc" - fi - - dnl Digital Unix C compiler - elif $CC -V 2>&1 | grep -i "Digital UNIX Compiler" > /dev/null 2>&1 && - $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos" - else - vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1" - fi - - dnl C for AIX Compiler - elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 && - $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" - else - vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi" - fi - - dnl IRIX C compiler - elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 && - $CC -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="-fullwarn" - else - vl_cv_prog_cc_warnings="-fullwarn -ansi -ansiE" - fi - - dnl HP-UX C compiler - elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 && - $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="+w1" - else - vl_cv_prog_cc_warnings="+w1 -Aa" - fi - - dnl The NEC SX-5 (Super-UX 10) C compiler - elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 && - $CC -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="-pvctl[,]fullmsg" - else - vl_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc" - fi - - dnl The Cray C compiler (Unicos) - elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 && - $CC -c -h msglevel 2 conftest.c > /dev/null 2>&1 && - test -f conftest.o; then - if test -z "$ansi"; then - vl_cv_prog_cc_warnings="-h msglevel 2" - else - vl_cv_prog_cc_warnings="-h msglevel 2 -h conform" - fi - - fi - rm -f conftest.* - fi - if test -n "$vl_cv_prog_cc_warnings"; then - CFLAGS="$CFLAGS $vl_cv_prog_cc_warnings" - else - vl_cv_prog_cc_warnings="unknown" - fi - ]) -])dnl - -dnl --------------------------------------------------------------------------- -dnl Available from the GNU Autoconf Macro Archive at: -dnl http://autoconf-archive.cryp.to/ax_lang_compiler_ms.html -dnl --------------------------------------------------------------------------- - -dnl @synopsis AX_LANG_COMPILER_MS -dnl -dnl Check whether the compiler for the current language is Microsoft. -dnl -dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU -dnl Autoconf implementation. -dnl -dnl @category InstalledPackages -dnl @author Braden McDaniel -dnl @version 2004-11-15 -dnl @license AllPermissive - -AC_DEFUN([AX_LANG_COMPILER_MS], -[AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler], - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms], -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER - choke me -#endif -]])], - [ax_compiler_ms=yes], - [ax_compiler_ms=no]) -ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms -])]) - -dnl --------------------------------------------------------------------------- -dnl Available from the GNU Autoconf Macro Archive at: -dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html -dnl --------------------------------------------------------------------------- - -dnl @synopsis AX_CHECK_GL -dnl -dnl Check for an OpenGL implementation. If GL is found, the required -dnl compiler and linker flags are included in the output variables -dnl "GL_CFLAGS" and "GL_LIBS", respectively. This macro adds the -dnl configure option "--with-apple-opengl-framework", which users can -dnl use to indicate that Apple's OpenGL framework should be used on Mac -dnl OS X. If Apple's OpenGL framework is used, the symbol -dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GL implementation -dnl is found, "no_gl" is set to "yes". -dnl -dnl @category InstalledPackages -dnl @author Braden McDaniel -dnl @version 2004-11-15 -dnl @license AllPermissive - -AC_DEFUN([AX_CHECK_GL], -[AC_REQUIRE([AC_PATH_X])dnl -AC_REQUIRE([ACX_PTHREAD])dnl - -# -# There isn't a reliable way to know we should use the Apple OpenGL framework -# without a configure option. A Mac OS X user may have installed an -# alternative GL implementation (e.g., Mesa), which may or may not depend on X. -# -AC_ARG_WITH([apple-opengl-framework], - [AC_HELP_STRING([--with-apple-opengl-framework], - [use Apple OpenGL framework (Mac OS X only)])]) -if test "X$with_apple_opengl_framework" = "Xyes"; then - AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1], - [Use the Apple OpenGL framework.]) - GL_LIBS="-framework OpenGL" -else - AC_LANG_PUSH(C) - - AX_LANG_COMPILER_MS - if test X$ax_compiler_ms = Xno; then - GL_CFLAGS="${PTHREAD_CFLAGS}" - GL_LIBS="${PTHREAD_LIBS} -lm" - fi - - # - # Use x_includes and x_libraries if they have been set (presumably by - # AC_PATH_X). - # - if test "X$no_x" != "Xyes"; then - if test -n "$x_includes"; then - GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}" - fi - if test -n "$x_libraries"; then - GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}" - fi - fi - - AC_CHECK_HEADERS([windows.h]) - - AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl], - [ax_cv_check_gl_libgl="no" - ax_save_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" - ax_save_LIBS="${LIBS}" - LIBS="" - ax_check_libs="-lopengl32 -lGL" - for ax_lib in ${ax_check_libs}; do - if test X$ax_compiler_ms = Xyes; then - ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` - else - ax_try_lib="${ax_lib}" - fi - LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[ -# if HAVE_WINDOWS_H && defined(_WIN32) -# include -# endif -# include ]], - [[glBegin(0)]])], - [ax_cv_check_gl_libgl="${ax_try_lib}"; break]) - done - LIBS=${ax_save_LIBS} - CPPFLAGS=${ax_save_CPPFLAGS}]) - - if test "X${ax_cv_check_gl_libgl}" = "Xno"; then - no_gl="yes" - GL_CFLAGS="" - GL_LIBS="" - else - GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}" - fi - AC_LANG_POP(C) -fi - -AC_SUBST([GL_CFLAGS]) -AC_SUBST([GL_LIBS]) -])dnl - -dnl --------------------------------------------------------------------------- -dnl Available from the GNU Autoconf Macro Archive at: -dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html -dnl --------------------------------------------------------------------------- - -dnl @synopsis AX_CHECK_GLU -dnl -dnl Check for GLU. If GLU is found, the required preprocessor and -dnl linker flags are included in the output variables "GLU_CFLAGS" and -dnl "GLU_LIBS", respectively. This macro adds the configure option -dnl "--with-apple-opengl-framework", which users can use to indicate -dnl that Apple's OpenGL framework should be used on Mac OS X. If -dnl Apple's OpenGL framework is used, the symbol -dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GLU implementation -dnl is found, "no_glu" is set to "yes". -dnl -dnl @category InstalledPackages -dnl @author Braden McDaniel -dnl @version 2004-11-15 -dnl @license AllPermissive - -AC_DEFUN([AX_CHECK_GLU], -[AC_REQUIRE([AX_CHECK_GL])dnl -AC_REQUIRE([AC_PROG_CXX])dnl -GLU_CFLAGS="${GL_CFLAGS}" -if test "X${with_apple_opengl_framework}" != "Xyes"; then - AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu], - [ax_cv_check_glu_libglu="no" - ax_save_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" - ax_save_LIBS="${LIBS}" - LIBS="" - ax_check_libs="-lglu32 -lGLU" - for ax_lib in ${ax_check_libs}; do - if test X$ax_compiler_ms = Xyes; then - ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` - else - ax_try_lib="${ax_lib}" - fi - LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" - # - # libGLU typically links with libstdc++ on POSIX platforms. However, - # setting the language to C++ means that test program source is named - # "conftest.cc"; and Microsoft cl doesn't know what to do with such a - # file. - # - AC_LANG_PUSH([C++]) - if test X$ax_compiler_ms = Xyes; then - AC_LANG_PUSH([C]) - fi - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[ -# if HAVE_WINDOWS_H && defined(_WIN32) -# include -# endif -# include ]], - [[gluBeginCurve(0)]])], - [ax_cv_check_glu_libglu="${ax_try_lib}"; break]) - if test X$ax_compiler_ms = Xyes; then - AC_LANG_POP([C]) - fi - AC_LANG_POP([C++]) - done - LIBS=${ax_save_LIBS} - CPPFLAGS=${ax_save_CPPFLAGS}]) - if test "X${ax_cv_check_glu_libglu}" = "Xno"; then - no_glu="yes" - GLU_CFLAGS="" - GLU_LIBS="" - else - GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}" - fi -fi -AC_SUBST([GLU_CFLAGS]) -AC_SUBST([GLU_LIBS]) -]) - -dnl --------------------------------------------------------------------------- -dnl Available from the GNU Autoconf Macro Archive at: -dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html -dnl --------------------------------------------------------------------------- - -dnl @synopsis AX_CHECK_GLUT -dnl -dnl Check for GLUT. If GLUT is found, the required compiler and linker -dnl flags are included in the output variables "GLUT_CFLAGS" and -dnl "GLUT_LIBS", respectively. This macro adds the configure option -dnl "--with-apple-opengl-framework", which users can use to indicate -dnl that Apple's OpenGL framework should be used on Mac OS X. If -dnl Apple's OpenGL framework is used, the symbol -dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If GLUT is not found, -dnl "no_glut" is set to "yes". -dnl -dnl @category InstalledPackages -dnl @author Braden McDaniel -dnl @version 2004-11-15 -dnl @license AllPermissive - -AC_DEFUN([AX_CHECK_GLUT], -[AC_REQUIRE([AX_CHECK_GLU])dnl -AC_REQUIRE([AC_PATH_XTRA])dnl - -if test "X$with_apple_opengl_framework" = "Xyes"; then - GLUT_CFLAGS="${GLU_CFLAGS}" - GLUT_LIBS="-framework GLUT -lobjc ${GL_LIBS}" -else - GLUT_CFLAGS=${GLU_CFLAGS} - GLUT_LIBS=${GLU_LIBS} - - # - # If X is present, assume GLUT depends on it. - # - if test "X${no_x}" != "Xyes"; then - GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}" - fi - - AC_LANG_PUSH(C) - - ax_save_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}" - - AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut], - [ax_cv_check_glut_libglut="no" - ax_save_LIBS="${LIBS}" - LIBS="" - ax_check_libs="-lglut32 -lglut" - for ax_lib in ${ax_check_libs}; do - if test X$ax_compiler_ms = Xyes; then - ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` - else - ax_try_lib="${ax_lib}" - fi - LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[ -# if HAVE_WINDOWS_H && defined(_WIN32) -# include -# endif -# include ]], - [[glutMainLoop()]])], - [ax_cv_check_glut_libglut="${ax_try_lib}"; break]) - - done - LIBS=${ax_save_LIBS} - ]) - CPPFLAGS="${ax_save_CPPFLAGS}" - AC_LANG_POP(C) - - if test "X${ax_cv_check_glut_libglut}" = "Xno"; then - no_glut="yes" - GLUT_CFLAGS="" - GLUT_LIBS="" - else - GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}" - fi -fi - -AC_SUBST([GLUT_CFLAGS]) -AC_SUBST([GLUT_LIBS]) -])dnl - -dnl --------------------------------------------------------------------------- -dnl Available from the GNU Autoconf Macro Archive at: -dnl http://www.gnu.org/software/ac-archive/acx_pthread.html -dnl --------------------------------------------------------------------------- - -dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl -dnl This macro figures out how to build C programs using POSIX threads. -dnl It sets the PTHREAD_LIBS output variable to the threads library and -dnl linker flags, and the PTHREAD_CFLAGS output variable to any special -dnl C compiler flags that are needed. (The user can also force certain -dnl compiler flags/libs to be tested by setting these environment -dnl variables.) -dnl -dnl Also sets PTHREAD_CC to any special C compiler that is needed for -dnl multi-threaded programs (defaults to the value of CC otherwise). -dnl (This is necessary on AIX to use the special cc_r compiler alias.) -dnl -dnl NOTE: You are assumed to not only compile your program with these -dnl flags, but also link it with them as well. e.g. you should link -dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS -dnl $LIBS -dnl -dnl If you are only building threads programs, you may wish to use -dnl these variables in your default LIBS, CFLAGS, and CC: -dnl -dnl LIBS="$PTHREAD_LIBS $LIBS" -dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -dnl CC="$PTHREAD_CC" -dnl -dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute -dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to -dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -dnl -dnl ACTION-IF-FOUND is a list of shell commands to run if a threads -dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to -dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the -dnl default action will define HAVE_PTHREAD. -dnl -dnl Please let the authors know if this macro fails on any platform, or -dnl if you have any other suggestions or comments. This macro was based -dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with -dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros -dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. -dnl We are also grateful for the helpful feedback of numerous users. -dnl -dnl @category InstalledPackages -dnl @author Steven G. Johnson -dnl @version 2005-01-14 -dnl @license GPLWithACException - -AC_DEFUN([ACX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG_C -acx_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) - AC_MSG_RESULT($acx_pthread_ok) - if test x"$acx_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case "${host_cpu}-${host_os}" in - *solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthread or - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" - ;; -esac - -if test x"$acx_pthread_ok" = xno; then -for flag in $acx_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CFLAGS="$flag" - ;; - - pthread-config) - AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) - if test x"$acx_pthread_config" = xno; then continue; fi - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - AC_MSG_RESULT($acx_pthread_ok) - if test "x$acx_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$acx_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - AC_MSG_CHECKING([for joinable pthread attribute]) - attr_name=unknown - for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_TRY_LINK([#include ], [int attr=$attr;], - [attr_name=$attr; break]) - done - AC_MSG_RESULT($attr_name) - if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then - AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, - [Define to necessary symbol if this constant - uses a non-standard name on your system.]) - fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: must compile with cc_r - AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) -else - PTHREAD_CC="$CC" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$acx_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - acx_pthread_ok=no - $2 -fi -AC_LANG_RESTORE -])dnl ACX_PTHREAD diff --git a/libs/tiff-3.8.2/contrib/Makefile.am b/libs/tiff-3.8.2/contrib/Makefile.am deleted file mode 100644 index af77f524bd..0000000000 --- a/libs/tiff-3.8.2/contrib/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2004, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Process this file with automake to produce Makefile.in. - -EXTRA_DIST = README - -SUBDIRS = acorn addtiffo dbs iptcutil mac-cw mac-mpw mfs ojpeg pds ras stream tags win_dib - diff --git a/libs/tiff-3.8.2/contrib/acorn/Makefile.acorn b/libs/tiff-3.8.2/contrib/acorn/Makefile.acorn deleted file mode 100644 index 8f01477841..0000000000 --- a/libs/tiff-3.8.2/contrib/acorn/Makefile.acorn +++ /dev/null @@ -1,165 +0,0 @@ -# Project: LibTIFF - - -# Toolflags: -CCflags = -c -zo -ffah -depend !Depend -IC: -C++flags = -c -depend !Depend -IC: -throwback -Linkflags = -aif -c++ -o $@ -DrLinkflags = -nounused -aif -c++ -o $@ -ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = -LibFileflags = -c -o $@ -Squeezeflags = -o $@ - - -# Final targets: -@.o.LIBTIFF: \ - @.o.tif_acorn \ - @.o.tif_aux \ - @.o.tif_close \ - @.o.tif_codec \ - @.o.tif_compress \ - @.o.tif_dir \ - @.o.tif_dirinfo \ - @.o.tif_dirread \ - @.o.tif_dirwrite \ - @.o.tif_dumpmode \ - @.o.tif_error \ - @.o.tif_fax3 \ - @.o.tif_flush \ - @.o.tif_getimage \ - @.o.tif_jpeg \ - @.o.tif_lzw \ - @.o.tif_next \ - @.o.tif_open \ - @.o.tif_packbits \ - @.o.tif_predict \ - @.o.tif_print \ - @.o.tif_read \ - @.o.tif_strip \ - @.o.tif_swab \ - @.o.tif_thunder \ - @.o.tif_tile \ - @.o.tif_version \ - @.o.tif_warning \ - @.o.tif_write \ - @.o.tif_zip \ - @.o.tif_fax3sm \ - @.h.version - LibFile $(LibFileflags) \ - @.o.tif_acorn \ - @.o.tif_aux \ - @.o.tif_close \ - @.o.tif_codec \ - @.o.tif_compress \ - @.o.tif_dir \ - @.o.tif_dirinfo \ - @.o.tif_dirread \ - @.o.tif_dirwrite \ - @.o.tif_dumpmode \ - @.o.tif_error \ - @.o.tif_fax3 \ - @.o.tif_flush \ - @.o.tif_getimage \ - @.o.tif_jpeg \ - @.o.tif_lzw \ - @.o.tif_next \ - @.o.tif_open \ - @.o.tif_packbits \ - @.o.tif_predict \ - @.o.tif_print \ - @.o.tif_read \ - @.o.tif_strip \ - @.o.tif_swab \ - @.o.tif_thunder \ - @.o.tif_tile \ - @.o.tif_version \ - @.o.tif_warning \ - @.o.tif_write \ - @.o.tif_zip \ - @.o.tif_fax3sm - - -# User-editable dependencies: -@.mkversion: @.o.mkversion C:o.Stubs - Link $(linkflags) @.o.mkversion C:o.Stubs -@.h.version: @.VERSION @.mkversion - .mkversion -v @.VERSION -a @.tiff/alpha @.h.version -@.mkg3states: @.o.mkg3states @.o.getopt C:o.Stubs - link $(linkflags) @.o.mkg3states C:o.Stubs @.o.getopt -@.c.tif_fax3sm: @.mkg3states - .mkg3states -c const @.c.tif_fax3sm - -# Static dependencies: -@.o.tif_acorn: @.c.tif_acorn - cc $(ccflags) -o @.o.tif_acorn @.c.tif_acorn -@.o.tif_aux: @.c.tif_aux - cc $(ccflags) -o @.o.tif_aux @.c.tif_aux -@.o.tif_close: @.c.tif_close - cc $(ccflags) -o @.o.tif_close @.c.tif_close -@.o.tif_codec: @.c.tif_codec - cc $(ccflags) -o @.o.tif_codec @.c.tif_codec -@.o.tif_compress: @.c.tif_compress - cc $(ccflags) -o @.o.tif_compress @.c.tif_compress -@.o.tif_dir: @.c.tif_dir - cc $(ccflags) -o @.o.tif_dir @.c.tif_dir -@.o.tif_dirinfo: @.c.tif_dirinfo - cc $(ccflags) -o @.o.tif_dirinfo @.c.tif_dirinfo -@.o.tif_dirread: @.c.tif_dirread - cc $(ccflags) -o @.o.tif_dirread @.c.tif_dirread -@.o.tif_dirwrite: @.c.tif_dirwrite - cc $(ccflags) -o @.o.tif_dirwrite @.c.tif_dirwrite -@.o.tif_dumpmode: @.c.tif_dumpmode - cc $(ccflags) -o @.o.tif_dumpmode @.c.tif_dumpmode -@.o.tif_error: @.c.tif_error - cc $(ccflags) -o @.o.tif_error @.c.tif_error -@.o.tif_fax3: @.c.tif_fax3 - cc $(ccflags) -o @.o.tif_fax3 @.c.tif_fax3 -@.o.tif_flush: @.c.tif_flush - cc $(ccflags) -o @.o.tif_flush @.c.tif_flush -@.o.tif_getimage: @.c.tif_getimage - cc $(ccflags) -o @.o.tif_getimage @.c.tif_getimage -@.o.tif_jpeg: @.c.tif_jpeg - cc $(ccflags) -o @.o.tif_jpeg @.c.tif_jpeg -@.o.tif_lzw: @.c.tif_lzw - cc $(ccflags) -o @.o.tif_lzw @.c.tif_lzw -@.o.tif_next: @.c.tif_next - cc $(ccflags) -o @.o.tif_next @.c.tif_next -@.o.tif_open: @.c.tif_open - cc $(ccflags) -o @.o.tif_open @.c.tif_open -@.o.tif_packbits: @.c.tif_packbits - cc $(ccflags) -o @.o.tif_packbits @.c.tif_packbits -@.o.tif_predict: @.c.tif_predict - cc $(ccflags) -o @.o.tif_predict @.c.tif_predict -@.o.tif_print: @.c.tif_print - cc $(ccflags) -o @.o.tif_print @.c.tif_print -@.o.tif_read: @.c.tif_read - cc $(ccflags) -o @.o.tif_read @.c.tif_read -@.o.tif_strip: @.c.tif_strip - cc $(ccflags) -o @.o.tif_strip @.c.tif_strip -@.o.tif_swab: @.c.tif_swab - cc $(ccflags) -o @.o.tif_swab @.c.tif_swab -@.o.tif_thunder: @.c.tif_thunder - cc $(ccflags) -o @.o.tif_thunder @.c.tif_thunder -@.o.tif_tile: @.c.tif_tile - cc $(ccflags) -o @.o.tif_tile @.c.tif_tile -@.o.tif_version: @.c.tif_version - cc $(ccflags) -o @.o.tif_version @.c.tif_version -@.o.tif_warning: @.c.tif_warning - cc $(ccflags) -o @.o.tif_warning @.c.tif_warning -@.o.tif_write: @.c.tif_write - cc $(ccflags) -o @.o.tif_write @.c.tif_write -@.o.tif_zip: @.c.tif_zip - cc $(ccflags) -o @.o.tif_zip @.c.tif_zip -@.o.mkg3states: @.c.mkg3states - cc $(ccflags) -o @.o.mkg3states @.c.mkg3states -@.o.getopt: @.c.getopt - cc $(ccflags) -o @.o.getopt @.c.getopt -@.o.mkspans: @.c.mkspans - cc $(ccflags) -o @.o.mkspans @.c.mkspans -@.o.tif_fax3sm: @.c.tif_fax3sm - cc $(ccflags) -o @.o.tif_fax3sm @.c.tif_fax3sm -@.o.mkversion: @.c.mkversion - cc $(ccflags) -o @.o.mkversion @.c.mkversion - -# Dynamic dependencies: diff --git a/libs/tiff-3.8.2/contrib/acorn/ReadMe b/libs/tiff-3.8.2/contrib/acorn/ReadMe deleted file mode 100644 index dc16a79d94..0000000000 --- a/libs/tiff-3.8.2/contrib/acorn/ReadMe +++ /dev/null @@ -1,79 +0,0 @@ -Building the Software on an Acorn RISC OS system - -The directory contrib/acorn contains support for compiling the library under -Acorn C/C++ under Acorn's RISC OS 3.10 or above. Subsequent pathnames will -use the Acorn format: The full-stop or period character is a pathname -delimeter, and the slash character is not interpreted; the reverse position -from Unix. Thus "libtiff/tif_acorn.c" becomes "libtiff.tif_acorn/c". - -This support was contributed by Peter Greenham. -(peterg@angmulti.demon.co.uk). - -Installing LibTIFF: - -LIBTIFF uses several files which have names longer than the normal RISC OS -maximum of ten characters. This complicates matters. Maybe one day Acorn will -address the problem and implement long filenames properly. Until then this -gets messy, especially as I'm trying to do this with obeyfiles and not have -to include binaries in this distribution. - -First of all, ensure you have Truncate configured on (type *Configure -Truncate On) Although it is, of course, preferable to have long filenames, -LIBTIFF can be installed with short filenames, and it will compile and link -without problems. However, getting it there is more problematic. -contrib.acorn.install is an installation obeyfile which will create a normal -Acorn-style library from the source (ie: with c, h and o folders etc.), but -needs the distribution library to have been unpacked into a location which is -capable of supporting long filenames, even if only temporarily. - -My recommendation, until Acorn address this problem properly, is to use Jason -Tribbeck's LongFilenames , or any other working system that gives you long -filenames, like a nearby NFS server for instance. - -If you are using Longfilenames, even if only temporarily to install LIBTIFF, -unpack the TAR into a RAMDisc which has been longfilenamed (ie: *addlongfs -ram) and then install from there to the hard disk. Unfortunately -Longfilenames seems a bit unhappy about copying a bunch of long-named files -across the same filing system, but is happy going between systems. You'll -need to create a ramdisk of about 2Mb. - -Now you can run the installation script I've supplied (in contrib.acorn), -which will automate the process of installing LIBTIFF as an Acorn-style -library. The syntax is as follows: - -install - -Install will then create and put the library in there. For -example, having used LongFilenames on the RAMDisk and unpacked the library -into there, you can then type: - -Obey RAM::RamDisc0.$.contrib.acorn.install RAM::RamDisc0.$ ADFS::4.$.LIBTIFF - -It doesn't matter if the destination location can cope with long filenames or -not. The filenames will be truncated if necessary (*Configure Truncate On if -you get errors) and all will be well. - -Compiling LibTIFF: - -Once the LibTIFF folder has been created and the files put inside, making the -library should be just a matter of running 'SetVars' to set the appropriate -system variables, then running 'Makefile'. - -OSLib - -OSLib is a comprehensive API for RISC OS machines, written by Jonathan -Coxhead of Acorn Computers (although OSLib is not an official Acorn product). -Using the OSLib SWI veneers produces code which is more compact and more -efficient than code written using _kernel_swi or _swi. The Acorn port of -LibTIFF can take advantage of this if present. Edit the Makefile and go to -the Static dependencies section. The first entry is: - -# Static dependencies: -@.o.tif_acorn: @.c.tif_acorn - cc $(ccflags) -o @.o.tif_acorn @.c.tif_acorn -Change the cc line to: - - cc $(ccflags) -DINCLUDE_OSLIB -o @.o.tif_acorn @.c.tif_acorn - -Remember, however, that OSLib is only recommended for efficiency's sake. It -is not required. diff --git a/libs/tiff-3.8.2/contrib/acorn/SetVars b/libs/tiff-3.8.2/contrib/acorn/SetVars deleted file mode 100755 index ea12d71d87..0000000000 --- a/libs/tiff-3.8.2/contrib/acorn/SetVars +++ /dev/null @@ -1,3 +0,0 @@ -Set LibTIFF$Dir -Set LibTIFF$Path . -Set C$Path ,LibTIFF: diff --git a/libs/tiff-3.8.2/contrib/acorn/cleanlib b/libs/tiff-3.8.2/contrib/acorn/cleanlib deleted file mode 100755 index 78a2d0342e..0000000000 --- a/libs/tiff-3.8.2/contrib/acorn/cleanlib +++ /dev/null @@ -1,5 +0,0 @@ -IfThere LibTIFF:o.* THEN Wipe LibTIFF:o.* ~CFR~V -IfThere LibTIFF:c.tif_fax3sm THEN Delete LibTIFF:c.tif_fax3sm -IfThere LibTIFF:mkg3states THEN Delete LibTIFF:mkg3states -IfThere LibTIFF:h.version THEN Delete LibTIFF:h.version -IfThere LibTIFF:mkversion THEN Delete LibTIFF:mkversion diff --git a/libs/tiff-3.8.2/contrib/acorn/convert b/libs/tiff-3.8.2/contrib/acorn/convert deleted file mode 100644 index 1f64ed20de..0000000000 --- a/libs/tiff-3.8.2/contrib/acorn/convert +++ /dev/null @@ -1,175 +0,0 @@ -RISC OS Conversion log -====================== - -mkversion.c -~~~~~~~~~~~ -The RISC OS command-line does not allow the direct creation of the version.h -file in the proper manner. To remedy this in such a way that the version -header is made at compiletime, I wrote this small program. It is fully -portable, so should work quite happily for any other platform that might need -it. - -msg3states.c -~~~~~~~~~~~~ -Needed getopt.c from the port folder, then compiled and worked fine. - - -tiff.h -~~~~~~ - -====1==== - -The symbol _MIPS_SZLONG, if not defined, causes a compiler error. Fixed by -ensuring it does exist. This looks to me like this wouldn't be an -Acorn-specific problem. The new code fragment is as follows: - -#ifndef _MIPS_SZLONG -#define _MIPS_SZLONG 32 -#endif -#if defined(__alpha) || _MIPS_SZLONG == 64 - - - -tiffcomp.h -~~~~~~~~~~ - -====1==== - -#if !defined(__MWERKS__) && !defined(THINK_C) -#include -#endif - -Acorn also doesn't have this header so: - -#if !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acorn) -#include -#endif - -====2==== - -#ifdef VMS -#include -#include -#else -#include -#endif - -This seems to indicate that fcntl.h is included on all systems except -VMS. Odd, because I've never heard of it before. Sure it's in the ANSI -definition? Anyway, following change: - -#ifdef VMS -#include -#include -#else -#ifndef __acorn -#include -#endif -#endif - -This will probably change when I find out what it wants from fcntl.h! - -====3==== - -#if defined(__MWERKS__) || defined(THINK_C) || defined(applec) -#include -#define BSDTYPES -#endif - -Added RISC OS to above thus: - -#if defined(__MWERKS__) || defined(THINK_C) || defined(applec) || defined(__acorn) -#include -#define BSDTYPES -#endif - -====4==== - -/* - * The library uses the ANSI C/POSIX SEEK_* - * definitions that should be defined in unistd.h - * (except on VMS where they are in stdio.h and - * there is no unistd.h). - */ -#ifndef SEEK_SET -#if !defined(VMS) && !defined (applec) && !defined(THINK_C) && !defined(__MWERKS__) -#include -#endif - -RISC OS is like VMS and Mac in this regard. So changed to: - -/* - * The library uses the ANSI C/POSIX SEEK_* - * definitions that should be defined in unistd.h - * (except on VMS or the Mac or RISC OS, where they are in stdio.h and - * there is no unistd.h). - */ -#ifndef SEEK_SET -#if !defined(VMS) && !defined (applec) && !defined(THINK_C) && !defined(__MWERKS__) && !defined(__acorn) -#include -#endif -#endif - -====5==== - -NB: HAVE_IEEEFP is defined in tiffconf.h, not tiffcomp.h as mentioned -in libtiff.README. (Note written on original port from 3.4beta004) - -Acorn C/C++ claims to accord with IEEE 754, so no change (yet) to -tiffconf.h. - -====6==== - -Unsure about whether this compiler supports inline functions. Will -leave it on for the time being and see if it works! (Likely if -everything else does.) - -... Seems to be OK ... - -====7==== - -Added to the end: - -/* - * osfcn.h is part of C++Lib on Acorn C/C++, and as such can't be used - * on C alone. For that reason, the relevant functions have been - * implemented by myself in tif_acorn.c, and the elements from the header - * included here. - */ - -#ifdef __acorn -#ifdef __cplusplus -#include -#else -#include "kernel.h" -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#define O_APPEND 8 -#define O_CREAT 0x200 -#define O_TRUNC 0x400 -typedef long off_t; -extern int open(const char *name, int flags, int mode); -extern int close(int fd); -extern int write(int fd, const char *buf, int nbytes); -extern int read(int fd, char *buf, int nbytes); -extern off_t lseek(int fd, off_t offset, int whence); -#endif -#endif - - -=============================================================================== - -tif_acorn.c -~~~~~~~~~~~ - -Created file tif_acorn.c, copied initially from tif_unix.c - -Documented internally where necessary. - -Note that I have implemented the low-level file-handling functions normally -found in osfcn.h in here, and put the header info at the bottom of -tiffcomp.h. This is further documented from a RISC OS perspective inside the -file. - -=============================================================================== diff --git a/libs/tiff-3.8.2/contrib/acorn/install b/libs/tiff-3.8.2/contrib/acorn/install deleted file mode 100755 index fa49d1ba84..0000000000 --- a/libs/tiff-3.8.2/contrib/acorn/install +++ /dev/null @@ -1,128 +0,0 @@ -If "%0" = "" Then Error Syntax: install | | -If "%1" = "" Then Error Syntax: install | | -Set LibTiffInstall$Dir %0 -Set LibTiff$Dir %1 -Set Alias$CPY Copy .%%0 .%%1 ~C~DF~NRV -CDir -CDir .c -CDir .h -CDir .o -CPY COPYRIGHT COPYRIGHT -CPY README README -CPY VERSION VERSION -CPY dist.tiff/alpha tiff/alpha -CPY contrib.acorn.SetVars SetVars -CPY contrib.acorn.Makefile Makefile -CPY contrib.acorn.cleanlib cleanlib -CPY port.getopt/c c.getopt -CPY libtiff.mkg3states/c c.mkg3states -CPY libtiff.mkspans/c c.mkspans -CPY libtiff.mkversion/c c.mkversion -CPY libtiff.tif_acorn/c c.tif_acorn -CPY libtiff.tif_aux/c c.tif_aux -CPY libtiff.tif_close/c c.tif_close -CPY libtiff.tif_codec/c c.tif_codec -CPY libtiff.tif_compress/c c.tif_compre -CPY libtiff.tif_dir/c c.tif_dir -CPY libtiff.tif_dirinfo/c c.tif_dirinf -CPY libtiff.tif_dirread/c c.tif_dirrea -CPY libtiff.tif_dirwrite/c c.tif_dirwri -CPY libtiff.tif_dumpmode/c c.tif_dumpmo -CPY libtiff.tif_error/c c.tif_error -CPY libtiff.tif_fax3/c c.tif_fax3 -CPY libtiff.tif_flush/c c.tif_flush -CPY libtiff.tif_getimage/c c.tif_getima -CPY libtiff.tif_jpeg/c c.tif_jpeg -CPY libtiff.tif_lzw/c c.tif_lzw -CPY libtiff.tif_next/c c.tif_next -CPY libtiff.tif_open/c c.tif_open -CPY libtiff.tif_packbits/c c.tif_packbi -CPY libtiff.tif_predict/c c.tif_predic -CPY libtiff.tif_print/c c.tif_print -CPY libtiff.tif_read/c c.tif_read -CPY libtiff.tif_strip/c c.tif_strip -CPY libtiff.tif_swab/c c.tif_swab -CPY libtiff.tif_thunder/c c.tif_thunde -CPY libtiff.tif_tile/c c.tif_tile -CPY libtiff.tif_version/c c.tif_versio -CPY libtiff.tif_warning/c c.tif_warnin -CPY libtiff.tif_write/c c.tif_write -CPY libtiff.tif_zip/c c.tif_zip -CPY libtiff.t4/h h.t4 -CPY libtiff.tiff/h h.tiff -CPY libtiff.tiffcomp/h h.tiffcomp -CPY libtiff.tiffconf/h h.tiffconf -CPY libtiff.tiffio/h h.tiffio -CPY libtiff.tiffiop/h h.tiffiop -CPY libtiff.tif_dir/h h.tif_dir -CPY libtiff.tif_fax3/h h.tif_fax3 -CPY libtiff.tif_predict/h h.tif_predic -SetType .COPYRIGHT Text -SetType .README Text -SetType .VERSION Text -SetType .tiff/alpha Text -SetType .SetVars Obey -SetType .Makefile fe1 -SetType .cleanlib Obey -SetType .c.getopt Text -SetType .c.mkg3states Text -SetType .c.mkspans Text -SetType .c.mkversion Text -SetType .c.tif_acorn Text -SetType .c.tif_aux Text -SetType .c.tif_close Text -SetType .c.tif_codec Text -SetType .c.tif_compre Text -SetType .c.tif_dir Text -SetType .c.tif_dirinf Text -SetType .c.tif_dirrea Text -SetType .c.tif_dirwri Text -SetType .c.tif_dumpmo Text -SetType .c.tif_error Text -SetType .c.tif_fax3 Text -SetType .c.tif_flush Text -SetType .c.tif_getima Text -SetType .c.tif_jpeg Text -SetType .c.tif_lzw Text -SetType .c.tif_next Text -SetType .c.tif_open Text -SetType .c.tif_packbi Text -SetType .c.tif_predic Text -SetType .c.tif_print Text -SetType .c.tif_read Text -SetType .c.tif_strip Text -SetType .c.tif_swab Text -SetType .c.tif_thunde Text -SetType .c.tif_tile Text -SetType .c.tif_versio Text -SetType .c.tif_warnin Text -SetType .c.tif_write Text -SetType .c.tif_zip Text -SetType .h.t4 Text -SetType .h.tiff Text -SetType .h.tiffcomp Text -SetType .h.tiffconf Text -SetType .h.tiffio Text -SetType .h.tiffiop Text -SetType .h.tif_dir Text -SetType .h.tif_fax3 Text -SetType .h.tif_predic Text -Unset Alias$CPY -Unset LibTiffInstall$Dir -| Now attempt to restore longfilename status. If it causes an error, OK. -Set Alias$RN Rename .%%0 .%%1 -Unset LibTiff$Dir -RN c.tif_compre c.tif_compress -RN c.tif_dirinf c.tif_dirinfo -RN c.tif_dirrea c.tif_dirread -RN c.tif_dirwri c.tif_dirwrite -RN c.tif_dumpmo c.tif_dumpmode -RN c.tif_getima c.tif_getimage -RN c.tif_packbi c.tif_packbits -RN c.tif_predic c.tif_predict -RN c.tif_thunde c.tif_thunder -RN c.tif_versio c.tif_version -RN c.tif_warnin c.tif_warning -RN h.tif_predic h.tif_predict -Unset Alias$RN -Echo All done! diff --git a/libs/tiff-3.8.2/contrib/dbs/xtiff/Imakefile b/libs/tiff-3.8.2/contrib/dbs/xtiff/Imakefile deleted file mode 100644 index 1aad45a4b4..0000000000 --- a/libs/tiff-3.8.2/contrib/dbs/xtiff/Imakefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# Imakefile -- to generate a Makefile for xtiff, use: -# /usr/local/X11/mit/config/imake \ -# -I/usr/local/X11/mit/config \ -# -DTOPDIR=/usr/local/X11/mit \ -# -DCURDIR=/usr/local/X11/mit \ -# -DDESTDIR=/usr/local/X11/mit -# - - SYS_LIBRARIES = -lm - LOCAL_LIBRARIES = XawClientLibs - DEPLIBS = XawClientDepLibs - TIFF = ../../../libtiff - EXTRA_LIBRARIES = $(TIFF)/libtiff.so -lm - EXTRA_INCLUDES = -I$(TIFF) - -SimpleProgramTarget(xtiff) diff --git a/libs/tiff-3.8.2/contrib/dbs/xtiff/patchlevel.h b/libs/tiff-3.8.2/contrib/dbs/xtiff/patchlevel.h deleted file mode 100644 index 935ec354b7..0000000000 --- a/libs/tiff-3.8.2/contrib/dbs/xtiff/patchlevel.h +++ /dev/null @@ -1 +0,0 @@ -#define PATCHLEVEL 0 diff --git a/libs/tiff-3.8.2/contrib/mac-cw/Makefile.am b/libs/tiff-3.8.2/contrib/mac-cw/Makefile.am deleted file mode 100644 index 827fa31915..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2004, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Process this file with automake to produce Makefile.in. - -EXTRA_DIST = Makefile.script README mac_main.c mac_main.h metrowerks.note mkg3_main.c version.h - diff --git a/libs/tiff-3.8.2/contrib/mac-cw/Makefile.script b/libs/tiff-3.8.2/contrib/mac-cw/Makefile.script deleted file mode 100644 index 85614c81d8..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/Makefile.script +++ /dev/null @@ -1,72 +0,0 @@ - -(* You must manually set the top-level PATHNAME here; everything else is automatic *) - -set PATHNAME to "ritter:tiff-v3.4beta028:" -set PRINTING to "NO" - -set MKG3STATES to PATHNAME & "mkg3states.mw" -set LIBTIFF to PATHNAME & "libtiff-68K.mw" -set TIFFINFO to PATHNAME & "tiffinfo.mw" - -with timeout of 60000 seconds - tell application "MW C/C++ 68K 1.2.2" - - activate - - - (* Create tif_fax3sm.c file *) - Create Project {file MKG3STATES} - Add Files {"mkg3states.c", "mkg3_main.c", "getopt.c"} - Add Files {"MacOS.lib"} To Segment 2 - Add Files {"ANSI (4i/8d) C.68K.Lib"} To Segment 3 - Add Files {"SIOUX.68K.Lib"} To Segment 4 - Add Files {"MathLib68K (4i/8d).Lib"} To Segment 5 - - Set Preferences To {Activate CPlusPlus:false, ARM Conformance:false, ANSI Keywords Only:false, Require Function Prototypes:false, Expand Trigraph Sequences:false, Enums Always Ints:false, MPW Pointer Type Rules:false, Prefix File:"mac_main.h"} - Set Preferences To {Illegal Pragmas:false, Empty Declarations:false, Possible Errors:false, Unused Variables:false, Unused Arguments:false, Extra Commas:false, Extended Error Checking:false} - Set Preferences To {Code Model:2, Struct Alignment:0, MC68020 CodeGen:false, MC68881 CodeGen:false, Four Bytes Ints:true, Eight Byte Double:true, Peephole Optimizer:true, CSE Optimizer:true, Optimize For Size:true, Far Data:true, Use Profiler:false, Far Virtual Function Tables:false, Far String Constants:true} - Set Preferences To {MacsBug Symbols:2, Generate SYM File:false, Full Path In Sym Files:true, Generate Link Map:false, Generate A6 Stack Frames:true, The Debugger Aware:false, Link Single Segment:false, Fast Link:true} - Set Preferences To {Project Type:0, File Name:"mkg3states", File Creator:"????", File Type:"APPL"} - - Make Project - Run Project - Remove Binaries - Close Project - - - (* Create LIBTIFF *) - Create Project {file LIBTIFF} - Add Files {"tif_apple.c", "tif_aux.c", "tif_close.c", "tif_codec.c", "tif_compress.c", "tif_dumpmode.c", "tif_error.c", "tif_flush.c", "tif_lzw.c", "tif_next.c", "tif_open.c", "tif_packbits.c"} - Add Files {"tif_fax3.c"} To Segment 2 - Add Files {"tif_dirinfo.c", "tif_dir.c", "tif_dirwrite.c", "tif_dirread.c"} To Segment 3 - Add Files {"tif_predict.c", "tif_print.c", "tif_read.c", "tif_strip.c", "tif_swab.c", "tif_thunder.c", "tif_tile.c", "tif_version.c", "tif_zip.c", "tif_jpeg.c", "tif_warning.c", "tif_write.c"} To Segment 4 - Add Files {"tif_fax3sm.c"} To Segment 5 - Add Files {"tif_getimage.c"} To Segment 6 - - Set Preferences To {Activate CPlusPlus:false, ARM Conformance:false, ANSI Keywords Only:false, Require Function Prototypes:false, Expand Trigraph Sequences:false, Enums Always Ints:false, MPW Pointer Type Rules:false, Prefix File:"MacHeaders68K"} - Set Preferences To {Illegal Pragmas:false, Empty Declarations:false, Possible Errors:false, Unused Variables:false, Unused Arguments:false, Extra Commas:false, Extended Error Checking:false} - Set Preferences To {Code Model:2, Struct Alignment:0, MC68020 CodeGen:false, MC68881 CodeGen:false, Four Bytes Ints:true, Eight Byte Double:true, Peephole Optimizer:true, CSE Optimizer:true, Optimize For Size:true, Far Data:true, Use Profiler:false, Far Virtual Function Tables:false, Far String Constants:true} - Set Preferences To {MacsBug Symbols:2, Generate SYM File:true, Full Path In Sym Files:true, Generate Link Map:false, Generate A6 Stack Frames:true, The Debugger Aware:false, Link Single Segment:false, Fast Link:true} - Set Preferences To {Project Type:2, File Name:"libtiff-68K", File Creator:"????", File Type:"APPL"} - Make Project - Close Project - - Create Project {file TIFFINFO} - Add Files {"tiffinfo.c", "mac_main.c", "getopt.c"} - Add Files {"MacOS.lib"} To Segment 2 - Add Files {"ANSI (4i/8d) C.68K.Lib"} To Segment 3 - Add Files {"SIOUX.68K.Lib"} To Segment 4 - Add Files {"MathLib68K (4i/8d).Lib"} To Segment 5 - Add Files {"libtiff-68K"} To Segment 6 - - Set Preferences To {Activate CPlusPlus:false, ARM Conformance:false, ANSI Keywords Only:false, Require Function Prototypes:false, Expand Trigraph Sequences:false, Enums Always Ints:false, MPW Pointer Type Rules:false, Prefix File:"mac_main.h"} - Set Preferences To {Illegal Pragmas:false, Empty Declarations:false, Possible Errors:false, Unused Variables:false, Unused Arguments:false, Extra Commas:false, Extended Error Checking:false} - Set Preferences To {Code Model:2, Struct Alignment:0, MC68020 CodeGen:false, MC68881 CodeGen:false, Four Bytes Ints:true, Eight Byte Double:true, Peephole Optimizer:true, CSE Optimizer:true, Optimize For Size:true, Far Data:true, Use Profiler:false, Far Virtual Function Tables:false, Far String Constants:true} - Set Preferences To {MacsBug Symbols:2, Generate SYM File:false, Full Path In Sym Files:true, Generate Link Map:false, Generate A6 Stack Frames:true, The Debugger Aware:false, Link Single Segment:false, Fast Link:true} - Set Preferences To {Project Type:0, File Name:"tiffinfo", File Creator:"????", File Type:"APPL"} - - Make Project - Close Project - - end tell -end timeout diff --git a/libs/tiff-3.8.2/contrib/mac-cw/README b/libs/tiff-3.8.2/contrib/mac-cw/README deleted file mode 100644 index a973469438..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/README +++ /dev/null @@ -1,18 +0,0 @@ ----------------------------------------------------- -Build instructions for LIBTIFF - CodeWarrior (6.1): ----------------------------------------------------- - -In this directory you will find a Makefile.script Applescript -file, which should be run in order to build the libtiff code -using MetroWerks CodeWarrior. - -Refer to the "metrowerks.note" instructions on building the -library for 68k and PowerPC native code, as well as building -some of the libtiff tools, which are rather unix-like, but -at least give an example of how to link everything together. - - Questions, comments, bug reports to Niles Ritter - (ndr@tazboy.jpl.nasa.gov). Sam Leffler takes no responsibility - for the viability of this stuff. - - -Niles. diff --git a/libs/tiff-3.8.2/contrib/mac-cw/mac_main.c b/libs/tiff-3.8.2/contrib/mac-cw/mac_main.c deleted file mode 100644 index 294655de1e..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/mac_main.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * mac_main.c -- The REAL entry point which - * calls the tools main code. For the tools - * the symbol "main" has been #defined to "tool_main" - * so that this entry point may be used to access - * the user-input first. - */ - -#undef main - -int -main() -{ - int argc; - char **argv; - - argc=ccommand(&argv); - - return tool_main(argc,argv); // Call the tool "main()" routine -} diff --git a/libs/tiff-3.8.2/contrib/mac-cw/mac_main.h b/libs/tiff-3.8.2/contrib/mac-cw/mac_main.h deleted file mode 100644 index 523300f707..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/mac_main.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * mac_main.h -- redefines main entry point - */ - -#ifndef _mac_main_h -#define _mac_main_h - -#undef main -#define main tool_main - -#endif /* _mac_main_h */ - diff --git a/libs/tiff-3.8.2/contrib/mac-cw/metrowerks.note b/libs/tiff-3.8.2/contrib/mac-cw/metrowerks.note deleted file mode 100644 index 9917cfd5f3..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/metrowerks.note +++ /dev/null @@ -1,84 +0,0 @@ ----------------------------------------------------- -Build instructions for LIBTIFF - CodeWarrior (6.1): ----------------------------------------------------- - -Note: there is a bug in CW earlier than 6.1 which will generate -16-bit offset link errors for any projects using libtiff; you must -download the CodeWarrior 6.1 patch located at: - - ftp://ftp.metrowerks.com/pub/updates/metro-patches-61.hqx - -unpack the archive, insert the files and recompile the libraries -using the AppleScript provided. - - -1. Make sure that the directory containing these files is under - the "contrib" directory of the tiff folder; otherwise, some - access path preferences will need to be updated. - -2. The instructions below are for the 68k platform build. - A similar script can be put together for the PPC version, - or you can just directly convert the projects. Be sure to - use the native libraries as well. NOTE: if anyone cooks - up an equivalent script for PPC, send it to me and I'll include - it with the rest of the package. - -3. Open the file Makefile.script with an AppleScript Editor - and change the PATHNAME variable to point to your - top-level TIFF directory - -4. Run the Script. It will do the following things: - - 4a. Prompt you for the current location of the CodeWarrior 68K - program. - - 4b. Create the source file "tif_fax3sm.c": - - i) Build the project CW project mkg3states.cw. It will - produce a small program called mkg3states. Only a - 68k version is provided, since you only have to run - this code once, and it only takes a few seconds. - - ii) Run the built mkg3states program: - - The program will temporarily take over ALL of the CPU, so - don't panic. After a few seconds it will produce a file called - "tif_fax3sm.c". - - 4c. Build the library project libtiff-68K.mw, producing library - called libtiff-68K. - - 4d. Build program project tiffinfo.mw; it will produce a - program called tiffinfo, which can dump the tiff tags of - a named file. Passing in no arguments will dump a help file - for the program. It is unix-flavored, but hey, it works. - -5 When the script finishes, you will have a usable libtiff-68K - library, a passable "tiffinfo" program, and the projects used - to build them. Note that to get tiffinfo to work I have put - an include file in the project that redefines main(), and - then have a mac_main.c program that calls ccommand() first - and passes that to the actual main code. A real mac app, - of course, would never use this stuff at all... - - . The tiffinfo.mw project may be used as a template to build - most of the other libtiff tools, or your own code. When - modifying a copy of the project, you will most likely need - to update the "Access Paths" directory if it is moved out of - the contrib folder. - -6. If you are going to create a project from scratch, be sure - to set up the preferences with - - 4-byte ints - 8-byte doubles - Far Code/Far Data - Large Linking model - - and everything should work fine. If the console-style error - reports bother you, you can always override the error and - warning mechanism with TIFFSetErrorHandler to do something - more Mac-like. - -Questions, comments to Niles Ritter (ndr@tazboy.jpl.nasa.gov). - diff --git a/libs/tiff-3.8.2/contrib/mac-cw/mkg3_main.c b/libs/tiff-3.8.2/contrib/mac-cw/mkg3_main.c deleted file mode 100644 index b31c8d1099..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/mkg3_main.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * mkg3_main.c -- passes fake arguments into main - */ - -#undef main - -int -main() -{ - static char *argv[4] = { - "mkg3states", "-c", "const", "tif_fax3sm.c" }; - - return tool_main(4,argv); // Call the tool "main()" routine -} diff --git a/libs/tiff-3.8.2/contrib/mac-cw/version.h b/libs/tiff-3.8.2/contrib/mac-cw/version.h deleted file mode 100644 index 3c5c56e18a..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-cw/version.h +++ /dev/null @@ -1,4 +0,0 @@ -#define VERSION \ -"LIBTIFF, Version 3.4beta028 \n"\ -"Copyright (c) 1988-1995 Sam Leffler\n"\ -"Copyright (c) 1991-1996 Silicon Graphics, Inc." diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/BUILD.mpw b/libs/tiff-3.8.2/contrib/mac-mpw/BUILD.mpw deleted file mode 100644 index 7abf83a2ac..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/BUILD.mpw +++ /dev/null @@ -1,47 +0,0 @@ -# BUILD.mpw: -# -# Full build for Apple Macintosh Programmer's Workshop (MPW). -# -# This is an executable MPW script which creates various -# utilities, sets up the MPW makefiles and runs the builds. -# This script should be run at the top level TIFF directory with: -# -# directory ::: -# :contrib:mac-mpw:BUILD.mpw -# -# NOTE: The full build requires that MPW have at least 6 MB -# allocated to it to compile the CCITT Fax codec tables. To -# deactivate CCITT compression edit the file :contrib:mac:libtiff.make -# first and follow the directions for disabling Fax decoding. -# -# All TIFF tools are built as MPW tools, executable from the -# MPW shell or other compatible tool server. -# -# Written by: Niles Ritter (ndr@tazboy.jpl.nasa.gov). -# - -echo "############# Full Scratch Build for MPW #############" - -# Create the ascii->mpw translation tool; this is used to -# convert standard ASCII files into ones using the special -# MPW characters, which don't live comfortably in unix tar files. -# -echo "######## Creating ASCII->MPW translator ########" -set contrib ':contrib:mac-mpw:' -directory {contrib} -createmake -tool mactrans mactrans.c > dev:null -make -f mactrans.make | streamedit -e "/CSANELib/||/Math/||/ToolLibs/ del" > mactrans.bld -execute mactrans.bld > dev:null -delete -y mactrans.make mactrans.bld mactrans.c.o || set status 0 -directory ::: #An mpw trick for going up two levels - -# Create the top-level Makefile and run it -echo "######## Creating Makefile ########" -catenate {contrib}top.make | {contrib}mactrans > Makefile - -echo "######## Running Makefile ########" -make > build.mpw -execute build.mpw -echo "############# MPW Build Complete #############" -exit 0 - diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/Makefile.am b/libs/tiff-3.8.2/contrib/mac-mpw/Makefile.am deleted file mode 100644 index fd1e663d19..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2004, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Process this file with automake to produce Makefile.in. - -EXTRA_DIST = BUILD.mpw README libtiff.make mactrans.c port.make tools.make top.make - diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/README b/libs/tiff-3.8.2/contrib/mac-mpw/README deleted file mode 100644 index 053b0d0ccf..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/README +++ /dev/null @@ -1,20 +0,0 @@ -###################### -About contrib:mac-mpw: -###################### - -This directory contains all of the utilities and makefile source -to build the LIBTIFF library and tools from the MPW Shell. The -file BUILD.mpw in this directory is an executable script -which uses all of these files to create the MPW makefiles and -run them. - -The .make files are not MPW makefiles as such, -but are when run through the "mactrans" program, which turns -the ascii "%nn" metacharacters into the standard weird MPW -make characters. - -This translation trick is necessary to protect the files when -they are put into unix tarfiles, which tend to mangle the -special characters. - - --Niles Ritter (ndr@tazboy.jpl.nasa.gov) diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/libtiff.make b/libs/tiff-3.8.2/contrib/mac-mpw/libtiff.make deleted file mode 100644 index ee5296e35b..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/libtiff.make +++ /dev/null @@ -1,202 +0,0 @@ -# -# Tag Image File Format Library -# -# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler -# Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# - -# -# Makefile for Mac using MPW 3.3.1 and MPW C 3.2.4 -# -# Note: This file must be run through "mactrans" before it can -# be recognized by MPW as a valid makefile. The problem is that MPW -# uses special non-ASCII characters, which tend to get mangled when stored -# in unix tar files, etc. "mactrans" is built as part of the TIFF MPW build. -# -# - -DEPTH = :: - -# FAX Options: If you do not wish to include the FAX options, uncomment -# the first four definitions and comment out the next four -# definitions. Note that to build programs with the FAX libraries you -# have to include "-model far" in your compile and link statements. -# -# Also, to build the fax code (including the tif_fax3sm.c file, which is -# created by the MPW tool "mkg3states", also built below), you will -# need to size the MPW program up to about 6 megabytes or so. - -#FAX_OPTIONS = -#FAX_OBJECTS = -#FAX_SOURCES = tif_fax3.c -#FAX_CONFIG = - -FAX_OPTIONS = -model far -FAX_OBJECTS = tif_fax3.c.o tif_fax3sm.c.o -FAX_SOURCES = tif_fax3.c tif_fax3sm.c -FAX_CONFIG = -d CCITT_SUPPORT - -NULL= - -RM = delete -y -i -COPTS = - -LIBPORT=::port:libport.o - -# -.c.o %c4 .c - {C} -model far {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o - - -CONF_LIBRARY= %b6 - -d HAVE_IEEEFP=1 %b6 - -d BSDTYPES - -CONF_COMPRESSION= %b6 - {FAX_CONFIG} %b6 - -d COMPRESSION_SUPPORT %b6 - -d PACKBITS_SUPPORT %b6 - -d LZW_SUPPORT %b6 - -d THUNDER_SUPPORT %b6 - -d NEXT_SUPPORT - -CFLAGS= {FAX_OPTIONS} {IPATH} {CONF_LIBRARY} {CONF_COMPRESSION} - -INCS= tiff.h tiffio.h - -SRCS= %b6 - {FAX_SOURCES} %b6 - tif_apple.c %b6 - tif_aux.c %b6 - tif_close.c %b6 - tif_codec.c %b6 - tif_compress.c %b6 - tif_dir.c %b6 - tif_dirinfo.c %b6 - tif_dirread.c %b6 - tif_dirwrite.c %b6 - tif_dumpmode.c %b6 - tif_error.c %b6 - tif_getimage.c %b6 - tif_jpeg.c %b6 - tif_flush.c %b6 - tif_lzw.c %b6 - tif_next.c %b6 - tif_open.c %b6 - tif_packbits.c %b6 - tif_predict.c %b6 - tif_print.c %b6 - tif_read.c %b6 - tif_swab.c %b6 - tif_strip.c %b6 - tif_thunder.c %b6 - tif_tile.c %b6 - tif_version.c %b6 - tif_warning.c %b6 - tif_write.c %b6 - tif_zip.c %b6 - {NULL} - -OBJS= %b6 - {FAX_OBJECTS} %b6 - tif_apple.c.o %b6 - tif_aux.c.o %b6 - tif_close.c.o %b6 - tif_codec.c.o %b6 - tif_compress.c.o %b6 - tif_dir.c.o %b6 - tif_dirinfo.c.o %b6 - tif_dirread.c.o %b6 - tif_dirwrite.c.o %b6 - tif_dumpmode.c.o %b6 - tif_error.c.o %b6 - tif_getimage.c.o %b6 - tif_jpeg.c.o %b6 - tif_flush.c.o %b6 - tif_lzw.c.o %b6 - tif_next.c.o %b6 - tif_open.c.o %b6 - tif_packbits.c.o %b6 - tif_predict.c.o %b6 - tif_print.c.o %b6 - tif_read.c.o %b6 - tif_swab.c.o %b6 - tif_strip.c.o %b6 - tif_thunder.c.o %b6 - tif_tile.c.o %b6 - tif_version.c.o %b6 - tif_warning.c.o %b6 - tif_write.c.o %b6 - tif_zip.c.o %b6 - {NULL} - -ALL=libtiff.o - -all %c4 {ALL} - -libtiff.o %c4 {OBJS} - Lib {OBJS} -o libtiff.o - - -{OBJS} %c4 tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h - -# -# The finite state machine tables used by the G3/G4 decoders -# are generated by the mkg3states program. On systems without -# make these rules have to be manually carried out. -# -tif_fax3sm.c %c4 mkg3states tif_fax3.h - {RM} tif_fax3sm.c || set status 0 - :mkg3states -c const tif_fax3sm.c - -mkg3states.c.o %c4 mkg3states.c - C -model far mkg3states.c -o mkg3states.c.o - -mkg3states %c4%c4 mkg3states.c.o - Link -model far -d -c 'MPS ' -t MPST %b6 - mkg3states.c.o %b6 - {LIBPORT} %b6 - "{CLibraries}"StdClib.o %b6 - "{Libraries}"Stubs.o %b6 - "{Libraries}"Runtime.o %b6 - "{Libraries}"Interface.o %b6 - -o mkg3states - -ALPHA = "{DEPTH}dist:tiff.alpha" -VERSION = "{DEPTH}VERSION" - -version.h %c4 {VERSION} {ALPHA} - Set VERSION1 `catenate {VERSION}` - Set VERSION2 "{VERSION1}`streamedit -e "1 rep /%a5%c5 %c5 (%c5)%a81/ %a81" {ALPHA}`" - delete -y -i version.h || set status 0 - echo '#define VERSION "LIBTIFF, Version' {VERSION2} '\nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."' >version.h - -tif_version.c.o %c4 version.h - -clean %c4 - {RM} {ALL} || set status 0 - {RM} {OBJS} || set status 0 - {RM} mkg3states || set status 0 - {RM} mkg3states.c.o || set status 0 - {RM} tif_fax3sm.c%c5 || set status 0 - {RM} version.h || set status 0 - diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/mactrans.c b/libs/tiff-3.8.2/contrib/mac-mpw/mactrans.c deleted file mode 100644 index 5e321b90ab..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/mactrans.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * mactrans.c -- Hack filter used to generate MPW files - * with special characters from pure ASCII, denoted "%nn" - * where nn is hex. (except for "%%", which is literal '%'). - * - * calling sequence: - * - * catenate file | mactrans [-toascii | -fromascii] > output - * - * Written by: Niles Ritter. - */ -#include -#include -#include - -void to_ascii(void); -void from_ascii(void); - -main(int argc, char *argv[]) -{ - if (argc<2 || argv[1][1]=='f') from_ascii(); - else to_ascii(); - exit (0); -} - -void from_ascii(void) -{ - char c; - int d; - while ((c=getchar())!=EOF) - { - if (c!='%' || (c=getchar())=='%') putchar(c); - else - { - ungetc(c,stdin); - scanf("%2x",&d); - *((unsigned char *)&c) = d; - putchar(c); - } - } -} - -void to_ascii(void) -{ - char c; - int d; - while ((c=getchar())!=EOF) - { - if (isascii(c)) putchar (c); - else - { - d = *((unsigned char *)&c); - printf("%%%2x",d); - } - } -} diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/port.make b/libs/tiff-3.8.2/contrib/mac-mpw/port.make deleted file mode 100644 index 492c527e4e..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/port.make +++ /dev/null @@ -1,53 +0,0 @@ -# -# Tag Image File Format Library -# -# Copyright (c) 1995 Sam Leffler -# Copyright (c) 1995 Silicon Graphics, Inc. -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# -DEPTH= :: -SRCDIR= : - -NULL = -CC = C -AR = Lib -AROPTS = -RM= delete -y - -IPATH = -I {DEPTH} -I {SRCDIR} -COPTS = -OPTIMIZER= -CFLAGS = {COPTS} {OPTIMIZER} {IPATH} - -CFILES = -OBJECTS = getopt.c.o -TARGETS = libport.o - -.c.o %c4 .c - {CC} -model far {COptions} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o - -all %c4 {TARGETS} - -libport.o %c4 {OBJECTS} - {AR} {OBJECTS} -o libport.o - -clean %c4 - {RM} {TARGETS} {OBJECTS} || set status 0 diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/tools.make b/libs/tiff-3.8.2/contrib/mac-mpw/tools.make deleted file mode 100644 index 13b14e42eb..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/tools.make +++ /dev/null @@ -1,138 +0,0 @@ -# -# Tag Image File Format Library -# -# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler -# Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Stanford and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# - -# -# Makefile for Mac using MPW 3.2.3 and MPW C 3.2.4 -# -COPTS = -model far - -.c.o %c4 .c - {C} {COPTS} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o - -RM = delete -y -i - -CONF_LIBRARY= %b6 - -d USE_CONST=0 %b6 - -d BSDTYPES -NULL= - -IPATH= -I ::libtiff - -CFLAGS= -w -m {IPATH} {CONF_LIBRARY} - -LIBPORT= ::port:libport.o - -LOptions= -model far -w -srt -d -c 'MPS ' -t MPST - -LIBTIFF= ::libtiff:libtiff.o - -LIBS= {LIBTIFF} %b6 - {LIBPORT} %b6 - "{CLibraries}"CSANELib.o %b6 - "{CLibraries}"Math.o %b6 - "{CLibraries}"StdClib.o %b6 - "{Libraries}"Stubs.o %b6 - "{Libraries}"Runtime.o %b6 - "{Libraries}"Interface.o %b6 - "{Libraries}"ToolLibs.o %b6 - {NULL} - -SRCS= %b6 - pal2rgb.c %b6 - ras2tiff.c %b6 - thumbnail.c %b6 - tiff2bw.c %b6 - tiff2ps.c %b6 - tiffcmp.c %b6 - tiffcp.c %b6 - tiffdither.c %b6 - tiffdump.c %b6 - tiffinfo.c %b6 - tiffmedian.c %b6 - {NULL} - -MACHALL=ras2tiff - -ALL= %b6 - tiffinfo %b6 - tiffcmp %b6 - tiffcp %b6 - tiffdump %b6 - tiffmedian %b6 - tiff2bw %b6 - tiffdither %b6 - tiff2ps %b6 - pal2rgb %b6 - gif2tiff %b6 - {MACHALL} - -all %c4 {ALL} - -tiffinfo %c4 tiffinfo.c.o {LIBTIFF} - Link {LOptions} tiffinfo.c.o {LIBS} -o tiffinfo - -tiffcmp %c4 tiffcmp.c.o {LIBTIFF} - Link {LOptions} tiffcmp.c.o {LIBS} -o tiffcmp - -tiffcp %c4 tiffcp.c.o {LIBTIFF} - Link {LOptions} tiffcp.c.o {LIBS} -o tiffcp - -tiffdump %c4 tiffdump.c.o {LIBTIFF} - Link {LOptions} tiffdump.c.o {LIBS} -o tiffdump - -tiffmedian %c4 tiffmedian.c.o {LIBTIFF} - Link {LOptions} tiffmedian.c.o {LIBS} -o tiffmedian - -tiff2ps %c4 tiff2ps.c.o {LIBTIFF} - Link {LOptions} tiff2ps.c.o {LIBS} -o tiff2ps - -# junky stuff... -# convert RGB image to B&W -tiff2bw %c4 tiff2bw.c.o {LIBTIFF} - Link {LOptions} tiff2bw.c.o {LIBS} -o tiff2bw - -# convert B&W image to bilevel w/ FS dithering -tiffdither %c4 tiffdither.c.o {LIBTIFF} - Link {LOptions} tiffdither.c.o {LIBS} -o tiffdither - -# GIF converter -gif2tiff %c4 gif2tiff.c.o {LIBTIFF} - Link {LOptions} gif2tiff.c.o {LIBS} -o gif2tiff - -# convert Palette image to RGB -pal2rgb %c4 pal2rgb.c.o {LIBTIFF} - Link {LOptions} pal2rgb.c.o {LIBS} -o pal2rgb - -# Sun rasterfile converter -ras2tiff %c4 ras2tiff.c.o {LIBTIFF} - Link {LOptions} ras2tiff.c.o {LIBS} -o ras2tiff - -# generate thumbnail images from fax -thumbnail %c4 thumbnail.c.o {LIBTIFF} - Link {LOptions} thumbnail.c.o {LIBS} -o thumbnail - -clean %c4 - {RM} {ALL} %c5.c.o ycbcr diff --git a/libs/tiff-3.8.2/contrib/mac-mpw/top.make b/libs/tiff-3.8.2/contrib/mac-mpw/top.make deleted file mode 100644 index 5a6a29b45c..0000000000 --- a/libs/tiff-3.8.2/contrib/mac-mpw/top.make +++ /dev/null @@ -1,133 +0,0 @@ -# -# Tag Image File Format Library -# -# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler -# Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Stanford and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# - -# -# Makefile for Mac using MPW 3.2.3 and MPW C 3.2.4 -# -# -# Written by: Niles D. Ritter -# - -RM= delete -y -i -PORT=:port: -LIBTIFF=:libtiff: -TOOLS=:tools: -CONTRIB=:contrib:mac-mpw: - -MACTRANS="{CONTRIB}mactrans" - -NULL= - -MAKEFILES = %b6 - {PORT}Makefile %b6 - {LIBTIFF}Makefile %b6 - {TOOLS}Makefile %b6 - {NULL} - -all %c4 PORT LIBTIFF TOOLS - -MAKEFILES %c4 {MAKEFILES} -TOOLS %c4 LIBTIFF - -LIBTIFF %c4 PORT - -# Create the port routines -PORT %c4 {PORT}Makefile - directory {PORT} - (make || set status 0) > build.mpw - set echo 1 - execute build.mpw - set echo 0 - {RM} build.mpw || set status 0 - directory :: - -# Create the port routines -LIBTIFF %c4 {LIBTIFF}Makefile - directory {LIBTIFF} - (make || set status 0) > build.mpw - set echo 1 - execute build.mpw - set echo 0 - {RM} build.mpw || set status 0 - directory :: - -# Create the tools -TOOLS %c4 {TOOLS}Makefile - directory {TOOLS} - (make || set status 0) > build.mpw - set echo 1 - execute build.mpw - set echo 0 - {RM} build.mpw || set status 0 - directory :: - -# Makefile dependencies -{PORT}Makefile %c4 {CONTRIB}port.make - catenate {CONTRIB}port.make | {MACTRANS} > {PORT}Makefile - -{LIBTIFF}Makefile %c4 {CONTRIB}libtiff.make - catenate {CONTRIB}libtiff.make | {MACTRANS} > {LIBTIFF}Makefile - -{TOOLS}Makefile %c4 {CONTRIB}tools.make - catenate {CONTRIB}tools.make | {MACTRANS} > {TOOLS}Makefile - - -clean %c4 clean.port clean.contrib clean.libtiff clean.tools clean.make - -clean.port %c4 - directory {PORT} - (make clean || set status 0) > purge - purge - {RM} purge || set status 0 - {RM} Makefile || set status 0 - {RM} build.mpw || set status 0 - cd :: - -clean.contrib %c4 - {RM} {MACTRANS} || set status 0 - -clean.libtiff %c4 - directory {LIBTIFF} - (make clean || set status 0) > purge - purge - {RM} purge || set status 0 - {RM} Makefile || set status 0 - {RM} build.mpw || set status 0 - cd :: - -clean.tools %c4 - directory {TOOLS} - (make clean || set status 0) > purge - purge - {RM} purge || set status 0 - {RM} Makefile || set status 0 - {RM} build.mpw || set status 0 - cd :: - -clean.make %c4 - {RM} {MAKEFILES} || set status 0 - {RM} build.mpw || set status 0 - diff --git a/libs/tiff-3.8.2/contrib/ojpeg/README b/libs/tiff-3.8.2/contrib/ojpeg/README deleted file mode 100644 index 548902dc06..0000000000 --- a/libs/tiff-3.8.2/contrib/ojpeg/README +++ /dev/null @@ -1,24 +0,0 @@ - -For the broadest possible support for OJPEG files the following steps are -necessary: - - o Ensure you are able to build with JPEG support (see config.site). - - o Uncomment OJPEG="yes" statement in config.site file or - #define OJPEG_SUPPORT somewhere. This can be put in tiffconf.h for - instance. - - o Append the jdhuff_add.c code to the end of jdhuff.c within the IJG JPEG - libraries jdhuff.c file and recompile libjpeg (jpeg-6b tested). - - o Rebuild cleanly. - - -OJPEG support implemented by Scott Marovich at HP (marovich@hpl.hp.com). - ---- - -For notes on further improved JPEG-in-TIFF support also see the following -bug in bugzilla: - - http://bugzilla.remotesensing.org/show_bug.cgi?id=156 diff --git a/libs/tiff-3.8.2/contrib/ojpeg/jdhuff_add.c b/libs/tiff-3.8.2/contrib/ojpeg/jdhuff_add.c deleted file mode 100644 index 8d4221b8e4..0000000000 --- a/libs/tiff-3.8.2/contrib/ojpeg/jdhuff_add.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * BEWARE OF KLUDGE: This subroutine is a hack for decoding illegal JPEG-in- - * TIFF encapsulations produced by Microsoft's Wang Imaging - * for Windows application with the public-domain TIFF Library. Based upon an - * examination of selected output files, this program apparently divides a JPEG - * bit-stream into consecutive horizontal TIFF "strips", such that the JPEG - * encoder's/decoder's DC coefficients for each image component are reset before - * each "strip". Moreover, a "strip" is not necessarily encoded in a multiple - * of 8 bits, so one must sometimes discard 1-7 bits at the end of each "strip" - * for alignment to the next input-Byte storage boundary. IJG JPEG Library - * decoder state is not normally exposed to client applications, so this sub- - * routine provides the TIFF Library with a "hook" to make these corrections. - * It should be called after "jpeg_start_decompress()" and before - * "jpeg_finish_decompress()", just before decoding each "strip" using - * "jpeg_read_raw_data()" or "jpeg_read_scanlines()". - * - * This kludge is not sanctioned or supported by the Independent JPEG Group, and - * future changes to the IJG JPEG Library might invalidate it. Do not send bug - * reports about this code to IJG developers. Instead, contact the author for - * advice: Scott B. Marovich , Hewlett-Packard Labs, 6/01. - */ -GLOBAL(void) -jpeg_reset_huff_decode (register j_decompress_ptr cinfo,register float *refbw) -{ register huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy; - register int ci = 0; - - /* Re-initialize DC predictions */ - do entropy->saved.last_dc_val[ci] = -refbw[ci << 1]; - while (++ci < cinfo->comps_in_scan); - /* Discard encoded input bits, up to the next Byte boundary */ - entropy->bitstate.bits_left &= ~7; -} diff --git a/libs/tiff-3.8.2/html/build.html b/libs/tiff-3.8.2/html/build.html deleted file mode 100644 index e0b21575c0..0000000000 --- a/libs/tiff-3.8.2/html/build.html +++ /dev/null @@ -1,880 +0,0 @@ - - - - -Building the TIFF Software Distribution - - -

Building the Software Distribution

- -
-This chapter contains step-by-step instructions on how to configure -and build the TIFF software distribution. The software is most -easily built on a UNIX system, but with a little bit of work it can -easily be built and used on other non-UNIX platforms. -
-

Building on a UNIX System

-To build the software on a UNIX system you need to first run the -configure shell script that is located in the top level of the -source directory. This script probes the target system for -necessary tools and functions and constructs a build environment in -which the software may be compiled. Once configuration is done, you -simply run make (or gmake) to build the software -and then make install to do the installation; for example: -
-
-hyla% cd tiff-v3.4beta099
-hyla% ./configure
-    ...lots of messages...
-hyla% make
-    ...lots of messages...
-hyla# make install
-
-Supplied makefiles are depend on GNU make utility, so you -will need the one. Depending on your installation make -command may invoke standard system make and gmake -invoke GNU make. In this case you should use former. If you don't -have make at all, but only gmake, you should -export environment variable MAKE=gmake before -./configure. -

In general, the software is designed such that the following -should be ``make-able'' in each directory:

-
-
-make [all]      build stuff
-make install    build&install stuff
-make clean      remove .o files, executables and cruft
-make distclean  remove everything, that can be recreated
-
-Note that after running "make distclean" the -configure script must be run again to create the Makefiles -and other make-related files. -
-

Build Trees

-There are two schemes for configuring and building the software. If -you intend to build the software for only one target system, you -can configure the software so that it is built in the same -directories as the source code. -
-
-hyla% cd tiff-v3.4beta099
-hyla% ls
-COPYRIGHT       VERSION         config.sub      dist            man
-Makefile.in     config.guess    configure       html            port
-README          config.site     contrib         libtiff         tools
-hyla% ./configure
-
-

Otherwise, you can configure a build tree that is parallel to -the source tree hierarchy but which contains only configured files -and files created during the build procedure.

-
-
-hyla% cd tiff-v3.4beta099
-hyla% mkdir obj obj/mycpu
-hyla% cd obj/mycpu
-hyla% ../../configure
-
-This second scheme is useful for: -
    -
  • building multiple targets from a single source tree
  • -
  • building from a read-only source tree (e.g. if you receive the -distribution on CD-ROM)
  • -
- -
-

Configuration Options

-The configuration process is critical to the proper compilation, -installation, and operation of the software. The configure script -runs a series of tests to decide whether or not the target system -supports required functionality and, if it does not, whether it can -emulate or workaround the missing functions. This procedure is -fairly complicated and, due to the nonstandard nature of most UNIX -systems, prone to error. The first time that you configure the -software for use you should check the output from the configure -script and look for anything that does not make sense for your -system. -

A second function of the configure script is to set the default -configuration parameters for the software. Of particular note are -the directories where the software is to be installed. By default -the software is installed in the /usr/local hierarchy. To -change this behaviour the appropriate parameters can be specified -on the command line to configure. Run ./configure --help to -get a list of possible options. Installation related options are -shown below.

-
-
-Installation directories:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [/usr/local]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [PREFIX]
-
-By default, `make install' will install all the files in
-`/usr/local/bin', `/usr/local/lib' etc.  You can specify
-an installation prefix other than `/usr/local' using `--prefix',
-for instance `--prefix=$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
-  --bindir=DIR           user executables [EPREFIX/bin]
-  --sbindir=DIR          system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR       program executables [EPREFIX/libexec]
-  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
-  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
-  --libdir=DIR           object code libraries [EPREFIX/lib]
-  --includedir=DIR       C header files [PREFIX/include]
-  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
-  --infodir=DIR          info documentation [PREFIX/info]
-  --mandir=DIR           man documentation [PREFIX/man]
-
-Program names:
-  --program-prefix=PREFIX            prepend PREFIX to installed program names
-  --program-suffix=SUFFIX            append SUFFIX to installed program names
-  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
-
-
- -
-

Configuring Optional Packages/Support

-The TIFF software comes with several packages that are installed -only as needed, or only if specifically configured at the time the -configure script is run. Packages can be configured via the -configure script commandline parameters. -
-
Static/Shared Objects Support
-
--enable-shared[=PKGS]    build shared -libraries [default=yes]
---enable-static[=PKGS]    build static -libraries [default=yes]
-

These options control whether or not to configure the software -to build a shared and static binaries for the TIFF library. Use of -shared libraries can significantly reduce the disk space needed for -users of the TIFF software. If shared libarries are not used then -the code is statically linked into each application that uses it. -By default both types of binaries is configured.

-

--enable-rpath    Enable runtime linker -paths (-R libtool option)

-

Add library directories (see other options below) to the TIFF -library run-time linker path.

-
-
JPEG Support
-
--disable-jpeg    disable IJG JPEG -library usage (required for JPEG compression, enabled by default) ---with-jpeg-include-dir=DIR    location of IJG -JPEG library headers ---with-jpeg-lib-dir=DIR    location of IJG JPEG -library binary)
-
The JPEG package enables support for the handling of -TIFF images with JPEG-encoded data. Support for JPEG-encoded data -requires the Independent JPEG Group (IJG) libjpeg -distribution; this software is available at ftp.uu.net:/graphics/jpeg/. -configure script automatically tries to search the working -IJG JPEG installation. If it fails to find library, JPEG support -will be automatically disabled.If you want specify the exact paths -to library binary and headers, use above switches for that.
-
ZIP Support
-
The ZIP support enables support for the handling of -TIFF images with deflate-encoded data. Support for deflate-encoded -data requires the freely available zlib distribution -written by Jean-loup Gailly and Mark Adler; this software is -available at ftp.uu.net:/pub/archiving/zip/zlib/ -(or try quest.jpl.nasa.gov:/beta/zlib/). -If ZIP support is enabled the DIRS_LIBINC and -DIR_GZLIB parameters should also be set (see below). By -default this package is not configured.
-
- -
-

A Sample Configuration Session

-This section shows a sample configuration session and describes the -work done. The session is shown indented in a fixed width -font with user-supplied input in a bold font. -Comments are shown in a normal or italic font. This session -was collected on a 486 machine running BSDI 1.1. -
-
-
-wullbrandt% mkdir tiff
-wullbrandt% cd tiff
-wullbrandt% ln -s /hosts/oxford/usr/people/sam/tiff src
-
-
-A build tree separate from the source tree is used here. In fact, -in this case the distribution is accessed from a read-only -NFS-mounted filesystem. -
-
-
-wullbrandt% src/configure
-Configuring TIFF Software v3.4beta015.
-
-Reading site-wide parameters from ../tiff-v3.4beta015/config.site.
-Reading local parameters from config.local.
-Gosh, aren't you lucky to have a i386-unknown-bsdi1.1 system!
-
-
-Note that configure announces the distribution version and the -deduced target configuration (i386-unknown-bsdi1.1 here). -
-
-
-Using /usr/local/bin/gcc for a C compiler (set CC to override).
-Looks like /usr/local/bin/gcc supports the -g option.
-Using " -g" for C compiler options.
-
-
-configure checked the normal shell search path for potential ANSI C -compilers. The compiler is selected according to it properly -compiling a small ANSI C test program. A specific compiler may be -requested by setting the CC environment variable to the -appropriate pathname, by supplying the parameter on the command -line, e.g. -with-CC=gcc, or by setting CC in a -configuration file. -

Note -that an ANSI C compiler is required to build the software. If a C -compiler requires options to enable ANSI C compilation, they can be -specified with the ENVOPTS parameter.

-

Once a compiler is selected configure checks to see if the -compiler accepts a -g option to enable the generation of debugging -symbols, and if the compiler includes an ANSI C preprocessor.

-
-
-
-Using /usr/ucb/make to configure the software.
-
-
-Next various system-specific libraries that may or may not be -needed are checked for (none are needed in this case). If your -system requires a library that is not automatically included it can -be specified by setting the MACHDEPLIBS parameter. -

Creating port.h. The port.h file is included by -all the C code in the library (but not the tools). It includes -definitions for functions and type definitions that are missing -from system include files, #defines to enable or disable -system-specific functionality, and other odds and ends.

-
-
-
-Creating libtiff/port.h with necessary definitions.
-... using LSB2MSB bit order for your i386 cpu
-... using big-endian byte order for your i386 cpu
-... configure use of mmap for memory-mapped files
-... O_RDONLY is in <fcntl.h>
-... using double for promoted floating point parameters
-... enabling use of inline functions
-Done creating libtiff/port.h.
-
-
-This file can take a long time to create so configure generates the -file only when it is needed, either because the file does not exist -or because a different target or compiler is to be used. Note that -running "make distclean" in the top-level directory of the -build tree will remove the port.h file (along with all the -other files generated by configure). -

Selecting emulated library functions. Certain library -functions used by the tools are not present on all systems and can -be emulated using other system functionality. configure checks for -the presence of such functions and if they are missing, will -configure emulation code from the port directory to use -instead. Building the TIFF software on unsupported systems may -require adding to the code to the port directory.

-
-
-
-Checking system libraries for functionality to emulate.
-Done checking system libraries.
-
-
-If a routine must be emulated and configure does not automatically -check for it, the routine name can be specified using the -PORTFUNCS parameter. To add emulation support for a new -function foo, create a file port/foo.c that -contains the emulation code and then set PORTFUNCS=foo in -a configuration file or modify the configure script to -automatically check for the missing function. -
-
-
-Checking for Dynamic Shared Object (DSO) support.
-Done checking for DSO support.
-
-
-If the DSO package is enabled (DSO=auto or -DSO=yes), then configure will verify the system and -compiler are capable of constructing SVR4-style DSO's in the -expected way. Note that while a system may support DSO's the -compiler may not be capable of generating the required -position-independent code and/or the compiler may not pass the -needed options through to the loader. -

Selecting utility programs. configure locates various -system utility programs that are used during installation of the -software.

-
-
-
-Selecting programs used during installation.
-Looks like mv supports the -f option to force a move.
-Looks like /bin/ln supports the -s option to create a symbolic link.
-Done selecting programs.
-
-
-

Selecting default configuration parameters. The remainder -of the work done by configure involves setting up configuration -parameters that control the placement and setup of files during the -installation procedure.

-
-
-
-Selecting default TIFF configuration parameters.
-
-Looks like manual pages go in /usr/contrib/man.
-Looks like manual pages should be installed with bsd-nroff-gzip-0.gz.
-
-TIFF configuration parameters are:
-
-[ 1] Directory for tools:               /usr/contrib/bin
-[ 2] Directory for libraries:           /usr/contrib/lib
-[ 3] Directory for include files:       /usr/contrib/include
-[ 4] Directory for manual pages:        /usr/contrib/man
-[ 5] Manual page installation scheme:   bsd-nroff-gzip-0.gz
-
-Are these ok [yes]? 
-
-
-At this point you can interactively modify any of the displayed -parameters. Hitting a carriage return or typing yes will -accept the current parameters. Typing one of the number displayed -along the left hand side causes configure to prompt for a new value -of the specified parameter. Typing anything else causes configure -to prompt for a new value for each parameter. In general -hitting carriage return will accept the current value and typing -anything that is unacceptable will cause a help message to be -displayed. A description of each of the configuration parameters is -given below. -

Once acceptable parameters are setup configure will generate all -the files that depend on these parameters. Note that certain files -may or may not be created based on the configuration of optional -packages and/or the functions supported by target system.

-
-
-
-Creating Makefile from ../tiff-v3.4beta015/Makefile.in
-Creating libtiff/Makefile from ../tiff-v3.4beta015/libtiff/Makefile.in
-Creating man/Makefile from ../tiff-v3.4beta015/man/Makefile.in
-Creating tools/Makefile from ../tiff-v3.4beta015/tools/Makefile.in
-Creating port/install.sh from ../tiff-v3.4beta015/port/install.sh.in
-Done.
-
-
- -
-

Shared Library Support

-It is desirable to make the TIFF library be a shared object on -systems that have support for shared libraries. Unfortunately the -rules to use to build a shared library vary between operating -systems and even compilers. The distributed software includes -support for building a shared version of the library on a number of -different systems. This support is split between rules in the file -libtiff/Makefile.in that construct the shared library and -checks done by the configure script to verify that the -expected rules are supported by compilation tools for the target -system. -

To add new support for building a shared library both these -files must be updated. In the configure script search for the -section where the autoconfiguration setting of the DSO -parameter is handled and add a new case for the target system that -sets the DSOSUF, DSOLD, DSOOPTS, and -LIBCOPTS options as appropriate for the system. -DSOSUF specifies the filename suffix used for the shared -library (e.g. ``.so'' for Dynamic Shared Objects on most SVR4-based -systems). DSOLD specifies the program to use to build the -shared library from a compiled object file; typically ``${LD}'' -though on some systems it is better to use the C compiler directly -so system-dependent options and libraries are automatically -supplied. DSOOPTS are options that must be specified to -DSOLD when building the shared library. LIBCOPTS -are options to pass to the C compiler when constructing a -relocatable object file to include in a shared library; e.g. ``-K -PIC'' on a Sun system. The DSO parameter must also be set -to a unique label that identifies the target system and compilation -tools. This label is used to select a target in -libtiff/Makefile.in to do the actual work in building the -shared library. Finally, to complete support for the shared library -added the appropriate rules to libtiff/Makefile.in under the -target specified in the configure script.

-
-

Building the Software under Windows 95/98/NT/2000 with MS -VC++

-With Microsoft Visual C++ installed, and properly configured for -commandline use (you will likely need to source VCVARS32.BAT in -AUTOEXEC.bAT or somewhere similar) you should be able to use the -provided makefile.vc. -

The source package is delivered using Unix line termination -conventions, which work with MSVC but do not work with Windows -'notepad'. If you use unzip from the Info-Zip package, you -can extract the files using Windows normal line termination -conventions with a command similar to:

-
-  unzip -aa -a tiff-3.7.4.zip
-
-

By default libtiff expects that a pre-built zlib and jpeg -library are provided by the user. If this is not the case, then you -may edit libtiff\tiffconf.h using a text editor (e.g. notepad) and -comment out the entries for JPEG_SUPPORT, PIXARLOG_SUPPORT, and -ZIP_SUPPORT. Ignore the comment at the top of the file which says -that it has no influence on the build, because the statement is not -true for Windows. However, by taking this approach, libtiff will -not be able to open some TIFF files.

-

To build using the provided makefile.vc you may use:

-
-  C:\tiff-3.7.4> nmake /f makefile.vc clean
-  C:\tiff-3.7.4> nmake /f makefile.vc
-
-    or (the hard way)
-
-  C:\tiff-3.7.4> cd port
-  C:\tiff-3.7.4\port> nmake /f makefile.vc clean
-  C:\tiff-3.7.4\port> nmake /f makefile.vc
-  C:\tiff-3.7.4> cd ../libtiff
-  C:\tiff-3.7.4\libtiff> nmake /f makefile.vc clean
-  C:\tiff-3.7.4\libtiff> nmake /f makefile.vc
-  C:\tiff-3.7.4\libtiff> cd ..\tools
-  C:\tiff-3.7.4\tools> nmake /f makefile.vc clean
-  C:\tiff-3.7.4\tools> nmake /f makefile.vc
-
-

This will build the library file -libtiff\libtiff\libtiff.lib. This can be used in Win32 -programs. You may want to adjust the build options before start -compiling. All parameters contained in the nmake.opt -file.This is a plain text file you can open with your favorite text -editor.

-

The makefile also builds a DLL (libtiff.dll) with an associated -import library (libtiff_i.lib). Any builds using libtiff will need -to include the LIBTIFF\LIBTIFF directory in the include path.

-

The libtiff\tools\makefile.vc should build .exe's for -all the standard TIFF tool programs.

-

-
-

Building the Software under MS/DOS with the DJGPP v2 -compiler

-[From the file contrib/dosdjgpp/README.] -

The directory contrib/dosdjgpp contains the files -necessary to build the library and tools with the DJGPP v2 compiler -under MSDOS.

-

All you have to do is copy the files in the directory into the -respective directories and run make. If you want, you can use the -conf.bat script to do that for you, make sure that the file -is stored with MSDOS text EOL-convention (CR/LF), otherwise the -command.com will not do anything.

-

Note that you probably will not be able to build the library -with the v1.x versions of djgpp, due to two problems. First, the -top makefile calls a sub-make for each directory and you are likely -to run out of memory, since each recursive invocation of a djgpp -v1.x program requires about 130k, to avoid that, you can enter the -directories manually and call make (well, there are only two dirs). -The 2nd problem is that djgpp 1.x doesn't call the coff2exe -(stubify) program when creating an executable. This means that all -programs compiled are not converted to exe and consequently are not -available for calling directly. For the tools directory, you can -just call coff2exe for each program after make finishes, but in the -libtiff directory, a few programs are created during the make -process that have to be called for make to continue (e.g. -mkg3states). Make will probably report an error at each such stage. -To fix that, either add a coff2exe call before each program is -called or call coff2exe manually and rerun make (there 2-3 such -programs).

-
-

Building the Software on a Macintosh with MPW

-The directory contrib/mac-mpw contains support for compiling -the library and tools under the MPW Shell on a Macintosh system. -This support was contributed by Niles Ritter (ndr@tazboy.jpl.nasa.gov). -

[From the file contrib/mac-mpw/README.]

-

This directory contains all of the utilities and makefile source -to build the LIBTIFF library and tools from the MPW Shell. The file -BUILD.mpw in this directory is an executable script which uses all -of these files to create the MPW makefiles and run them.

-

The <file>.make files are not MPW makefiles as such, but -are when run through the "mactrans" program, which turns the ascii -"%nn" metacharacters into the standard weird MPW make -characters.

-

This translation trick is necessary to protect the files when -they are put into unix tarfiles, which tend to mangle the special -characters.

-
-

Building the Software on a Macintosh with CodeWarrior

-The directory contrib/mac-cw contains support for compiling -the library and tools with MetroWerks CodeWarrior 6.1 on a -Macintosh system. This support was contributed by Niles Ritter -(ndr@tazboy.jpl.nasa.gov). -

[From the file contrib/mac-cw/README.] In this -directory you will find a Makefile.script Applescript file, which -should be run in order to build the libtiff code using MetroWerks -CodeWarrior. Refer to the "metrowerks.note" instructions on -building the library for 68k and PowerPC native code, as well as -building some of the libtiff tools, which are rather unix-like, but -at least give an example of how to link everything together. -

-
-

Building the Software on a VMS System

-The VMS port was done by Karsten Spang (krs@kampsax.dk), who also "sort of" -maintains it. The VMS specific files are not in the main -directories. Instead they are placed under -[.CONTRIB.VMS...] in the distribution tree. Installation: -It is assumed that you have unpacked the tar file into a VMS -directory tree, in this text called DISK:[TIFF]. -
    -
  1. Move the VMS specific files to their proper directories. -
    -$ SET DEFAULT DISK:[TIFF.CONTRIB.VMS]
    -$ RENAME [.LIBTIFF]*.* [-.-.LIBTIFF]
    -$ RENAME [.TOOLS]*.* [-.-.TOOLS]
    -
  2. -
  3. Compile the library. -
    -$ SET DEFAULT DISK:[TIFF.LIBTIFF]
    -$ @MAKEVMS
    -
  4. -
  5. Compile the tools. -
    -$ SET DEFAULT DISK:[TIFF.TOOLS]
    -$ @MAKEVMS
    -
  6. -
  7. Define the programs. -
    -$ DEFINE TIFFSHR DISK:[TIFF.LIBTIFF]TIFFSHR
    -$ FAX2PS    :==$DISK:[TIFF.TOOLS]FAX2PS
    -$ FAX2TIFF  :==$DISK:[TIFF.TOOLS]FAX2TIFF
    -$ GIF2TIFF  :==$DISK:[TIFF.TOOLS]GIF2TIFF
    -$ PAL2RGB   :==$DISK:[TIFF.TOOLS]PAL2RGB
    -$ PPM2TIFF  :==$DISK:[TIFF.TOOLS]PPM2TIFF
    -$ RAS2TIFF  :==$DISK:[TIFF.TOOLS]RAS2TIFF
    -$ RGB2YCBCR :==$DISK:[TIFF.TOOLS]RGB2YCBCR
    -$ THUMBNAIL :==$DISK:[TIFF.TOOLS]THUMBNAIL
    -$ TIFF2BW   :==$DISK:[TIFF.TOOLS]TIFF2BW
    -$ TIFF2PS   :==$DISK:[TIFF.TOOLS]TIFF2PS
    -$ TIFFCMP   :==$DISK:[TIFF.TOOLS]TIFFCMP
    -$ TIFFCP    :==$DISK:[TIFF.TOOLS]TIFFCP
    -$ TIFFDITHER:==$DISK:[TIFF.TOOLS]TIFFDITHER
    -$ TIFFDUMP  :==$DISK:[TIFF.TOOLS]TIFFDUMP
    -$ TIFFINFO  :==$DISK:[TIFF.TOOLS]TIFFINFO
    -$ TIFFMEDIAN:==$DISK:[TIFF.TOOLS]TIFFMEDIAN
    -$ TIFFSPLIT :==$DISK:[TIFF.TOOLS]TIFFSPLIT
    -$ YCBCR     :==$DISK:[TIFF.TOOLS]YCBCR
    -
  8. -
-You will want to add these lines to your LOGIN.COM file, -after changing the name of the directory that you have used on your -machine. -

This release has been tested on OpenVMS/VAX 5.5-2, using VAX C -3.2. A previous release was tested under OpenVMS/AXP ?.? using DEC -C ?.?, it is believed that this release as well works on AXP. The -code contains some GNU C specific things. This does *not* imply, -however, that the VAX/GCC configuration has been tested, *it has -not*.

-

The command procedures (MAKEVMS.COM) for building the -library and tools, is believed to choose the correct options for -the VAX and AXP cases automatically.

-

On the AXP, IEEE floating point is used by default. If you want -VAX floating point, remove the /FLOAT=IEEE_FLOAT -qualifier, and change HAVE_IEEEFP=1 to -HAVE_IEEEFP=0 in the MAKEVMS.COM files in both -the libtiff and tools directories.

-

Compiling your own program on a VMS system:

-When compiling a source file in which you "#include -<tiffio.h>", use the following command -
-    $ CC/INCLUDE=DISK:[TIFF.LIBTIFF]
-
-This ensures that the header file is found. On the AXP, also add -/FLOAT=IEEE_FLOAT (if used when building the library). -

Linking your own program to the TIFF library on a VMS -system:

-You can link to the library in two ways: Either using the shareable -library, or using the object library. On the VAX these -possibilities are: -
    -
  1. Using the shareable TIFF library. -
    -$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS,SYS$INPUT:/OPTIONS
    -    SYS$SHARE:VAXCRTL/SHAREABLE
    -
  2. -
  3. Using the TIFF object library. -
    -$ LINK MY_PROGRAM, -
    -    DISK:[TIFF.LIBTIFF]TIFF/LIBRARY/INCLUDE=(TIF_FAX3SM,TIF_CODEC), -
    -    SYS$INPUT:/OPTIONS
    -    SYS$SHARE:VAXCRTL/SHAREABLE
    -
  4. -
-On AXP (and possibly also using DEC C on VAX) the corresponding -commands are -
    -
  1. Using the shareable TIFF library. -
    -$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS
    -
  2. -
  3. Using the TIFF object library. -
    -$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/LIBRARY
    -
  4. -
-Method 1 uses the shortest link time and smallest .EXE -files, but it requires that TIFFSHR is defined as above at -link time and at run time. Using the compilation -procedure above, the tools are linked in this way. -

Method 2 gives somewhat longer link time and larger -.EXE files, but does not require TIFFSHR to be -defined. This method is recommended if you want to run your program -on another machine, and for some reason don't want to have the -library on that machine. If you plan to have more than one program -(including the tools) on the machine, it is recommended that you -copy the library to the other machine and use method 1.

-
-

Building the Software on an Acorn RISC OS system

-The directory contrib/acorn contains support for compiling -the library under Acorn C/C++ under Acorn's RISC OS 3.10 or above. -Subsequent pathnames will use the Acorn format: The full-stop or -period character is a pathname delimeter, and the slash character -is not interpreted; the reverse position from Unix. Thus -"libtiff/tif_acorn.c" becomes "libtiff.tif_acorn/c". -

This support was contributed by Peter Greenham. (peter@enlarion.demon.co.uk).

-

Installing LibTIFF:

-

LIBTIFF uses several files which have names longer than the -normal RISC OS maximum of ten characters. This complicates matters. -Maybe one day Acorn will address the problem and implement long -filenames properly. Until then this gets messy, especially as I'm -trying to do this with obeyfiles and not have to include binaries -in this distribution.

-

First of all, ensure you have Truncate configured on (type -*Configure Truncate On)

-

Although it is, of course, preferable to have long filenames, -LIBTIFF can be installed with short filenames, and it will compile -and link without problems. However, getting it there is more -problematic. contrib.acorn.install is an installation -obeyfile which will create a normal Acorn-style library from the -source (ie: with c, h and o folders etc.), but needs the -distribution library to have been unpacked into a location which is -capable of supporting long filenames, even if only temporarily.

-

My recommendation, until Acorn address this problem properly, is -to use Jason Tribbeck's -LongFilenames, or any other working system that gives you long -filenames, like a nearby NFS server for instance.

-

If you are using Longfilenames, even if only temporarily to -install LIBTIFF, unpack the TAR into a RAMDisc which has been -longfilenamed (ie: *addlongfs ram) and then install from -there to the hard disk. Unfortunately Longfilenames seems a bit -unhappy about copying a bunch of long-named files across the same -filing system, but is happy going between systems. You'll need to -create a ramdisk of about 2Mb.

-

Now you can run the installation script I've supplied (in -contrib.acorn), which will automate the process of installing -LIBTIFF as an Acorn-style library. The syntax is as follows:

-

install <source_dir> <dest_dir>

-

Install will then create <dest_dir> and put the library in -there. For example, having used LongFilenames on the RAMDisk and -unpacked the library into there, you can then type:

-

Obey RAM::RamDisc0.$.contrib.acorn.install RAM::RamDisc0.$ -ADFS::4.$.LIBTIFF

-

It doesn't matter if the destination location can cope with long -filenames or not. The filenames will be truncated if necessary -(*Configure Truncate On if you get errors) and all will be -well.

-

Compiling LibTIFF:

-

Once the LibTIFF folder has been created and the files put -inside, making the library should be just a matter of running -'SetVars' to set the appropriate system variables, then -running 'Makefile'.

-

OSLib

-

OSLib -is a comprehensive API for RISC OS machines, written by Jonathan -Coxhead of Acorn Computers (although OSLib is not an official Acorn -product). Using the OSLib SWI veneers produces code which is more -compact and more efficient than code written using _kernel_swi or -_swi. The Acorn port of LibTIFF can take advantage of this if -present. Edit the Makefile and go to the Static dependencies -section. The first entry is:

-
-# Static dependencies:
-@.o.tif_acorn:   @.c.tif_acorn
-        cc $(ccflags) -o @.o.tif_acorn @.c.tif_acorn 
-
-

Change the cc line to:

-
-        cc $(ccflags) -DINCLUDE_OSLIB -o @.o.tif_acorn @.c.tif_acorn 
-
-

Remember, however, that OSLib is only recommended for -efficiency's sake. It is not required.

-
-

Building the Software on Other Systems

-This section contains information that might be useful if you are -working on a non-UNIX system that is not directly supported. All -library-related files described below are located in the -libtiff directory. -

The library requires two files that are generated -on-the-fly. The file tif_fax3sm.c has the state -tables for the Group 3 and Group 4 decoders. This file is generated -by the mkg3states program on a UNIX system; for -example,

-
-
-
-cd libtiff
-cc -o mkg3states mkg3states.c
-rm -f tif_fax3sm.c
-./mkg3states -c const tif_fax3sm.c
-
-
-The -c option can be used to control whether or not the -resutling tables are generated with a const declaration. -The -s option can be used to specify a C storage class for -the table declarations. The -b option can be used to force -data values to be explicitly bracketed with ``{}'' (apparently -needed for some MS-Windows compilers); otherwise the structures are -emitted in as compact a format as possible. Consult the source code -for this program if you have questions. -

The second file required to build the library, version.h, -contains the version information returned by the -TIFFGetVersion routine. This file is built on most systems -using the mkversion program and the contents of the -VERSION and tiff.alpha files; for example,

-
-
-cd libtiff
-cc -o mkversion mkversion.c
-rm -f version.h
-./mkversion -v ../VERSION -a ../dist/tiff.alpha version.h
-
-

Otherwise, when building the library on a non-UNIX system be -sure to consult the files tiffcomp.h and tiffconf.h. -The former contains system compatibility definitions while the -latter is provided so that the software configuration can be -controlled on systems that do not support the make facility for -building the software.

-

Systems without a 32-bit compiler may not be able to handle some -of the codecs in the library; especially the Group 3 and 4 decoder. -If you encounter problems try disabling support for a particular -codec; consult the documentation.

-

Programs in the tools directory are written to assume an ANSI C -compilation environment. There may be a few POSIX'isms as well. The -code in the port directory is provided to emulate routines -that may be missing on some systems. On UNIX systems the -configure script automatically figures out which routines -are not present on a system and enables the use of the equivalent -emulation routines from the port directory. It may be -necessary to manually do this work on a non-UNIX system.

-
-

Checking out the Software

-

Assuming you have working versions of tiffgt and -tiffsv, you can just use them to view any of the sample -images available for testing (see the section -on obtaining the test images). Otherwise, you can do a cursory -check of the library with the tiffcp and tiffcmp -programs. For example,

-
-
-tiffcp -lzw cramps.tif x.tif
-tiffcmp cramps.tif x.tif
-
-

(tiffcmp should be silent if the files compare -correctly).

-
-

Table of Contents

-The following files makup the core library: -
-libtiff/tiff.h                  TIFF spec definitions
-libtiff/tiffcomp.h              non-UNIX OS-compatibility definitions
-libtiff/tiffconf.h              non-UNIX configuration definitions
-libtiff/tiffio.h                public TIFF library definitions
-libtiff/tiffiop.h               private TIFF library definitions
-libtiff/t4.h                    CCITT Group 3/4 code tables+definitions
-libtiff/tif_dir.h               private defs for TIFF directory handling
-libtiff/tif_fax3.h              CCITT Group 3/4-related definitions
-libtiff/tif_predict.h           private defs for Predictor tag support
-libtiff/uvcode.h                LogL/LogLuv codec-specific definitions
-libtiff/version.h               version string (generated by Makefile)
-
-libtiff/tif_acorn.c             Acorn-related OS support
-libtiff/tif_apple.c             Apple-related OS support
-libtiff/tif_atari.c             Atari-related OS support
-libtiff/tif_aux.c               auxilary directory-related functions
-libtiff/tif_close.c             close an open TIFF file
-libtiff/tif_codec.c             configuration table of builtin codecs
-libtiff/tif_compress.c          compression scheme support
-libtiff/tif_dir.c               directory tag interface code
-libtiff/tif_dirinfo.c           directory known tag support code
-libtiff/tif_dirread.c           directory reading code
-libtiff/tif_dirwrite.c          directory writing code
-libtiff/tif_dumpmode.c          "no" compression codec
-libtiff/tif_error.c             library error handler
-libtiff/tif_fax3.c              CCITT Group 3 and 4 codec
-libtiff/tif_fax3sm.c            G3/G4 state tables (generated by mkg3states)
-libtiff/tif_flush.c             i/o and directory state flushing
-libtiff/tif_getimage.c          TIFFRGBAImage support
-libtiff/tif_jpeg.c              JPEG codec (interface to the IJG distribution)
-libtiff/tif_luv.c               SGI LogL/LogLuv codec
-libtiff/tif_lzw.c               LZW codec
-libtiff/tif_msdos.c             MSDOS-related OS support
-libtiff/tif_next.c              NeXT 2-bit scheme codec (decoding only)
-libtiff/tif_open.c              open and simply query code
-libtiff/tif_packbits.c          Packbits codec
-libtiff/tif_pixarlog.c          Pixar codec
-libtiff/tif_predict.c           Predictor tag support
-libtiff/tif_print.c             directory printing support
-libtiff/tif_read.c              image data reading support
-libtiff/tif_strip.c             some strip-related code
-libtiff/tif_swab.c              byte and bit swapping support
-libtiff/tif_thunder.c           Thunderscan codec (decoding only)
-libtiff/tif_tile.c              some tile-related code
-libtiff/tif_unix.c              UNIX-related OS support
-libtiff/tif_version.c           library version support
-libtiff/tif_vms.c               VMS-related OS support
-libtiff/tif_warning.c           library warning handler
-libtiff/tif_win3.c              Windows-3.1-related OS support
-libtiff/tif_win32.c             Win32 (95/98/NT) related OS support
-libtiff/tif_write.c             image data writing support
-libtiff/tif_zip.c               Deflate codec
-
-libtiff/mkg3states.c            program to generate G3/G4 decoder state tables
-libtiff/mkspans.c               program to generate black-white span tables
-libtiff/mkversion.c             program to generate libtiff/version.h.
-
-
-Last updated: $Date: 2005/12/24 22:25:05 $ - - diff --git a/libs/tiff-3.8.2/html/man/TIFFGetField.3tiff.html b/libs/tiff-3.8.2/html/man/TIFFGetField.3tiff.html deleted file mode 100644 index ca114a354b..0000000000 --- a/libs/tiff-3.8.2/html/man/TIFFGetField.3tiff.html +++ /dev/null @@ -1,1446 +0,0 @@ - - - - - - -TIFFGetField - - - -

TIFFGetField

-NAME
-SYNOPSIS
-DESCRIPTION
-AUTOREGISTERED TAGS
-RETURN VALUES
-DIAGNOSTICS
-SEE ALSO
- -
- -

NAME

- - - - - -
-

TIFFGetField, TIFFVGetField − get the value(s) of a -tag in an open TIFF file

-
- -

SYNOPSIS

- - - - - -
-

#include <tiffio.h>

- -

int TIFFGetField(TIFF *tif, ttag_t -tag, ...)

- -

#include <stdarg.h>

- -

int TIFFVGetField(TIFF *tif, ttag_t -tag, va_list ap)
-int TIFFGetFieldDefaulted(TIFF *
tif, -ttag_t tag, ...)
-int TIFFVGetFieldDefaulted(TIFF *
tif, -ttag_t tag, va_list ap)

-
- -

DESCRIPTION

- - - - - -
-

TIFFGetField returns the value of a tag or -pseudo-tag associated with the the current directory of the -opened TIFF file tif. (A -pseudo-tag is a parameter that is used to control the -operation of the TIFF library but whose value -is not read or written to the underlying file.) The file -must have been previously opened with -TIFFOpen(3TIFF). The tag is identified by tag, -one of the values defined in the include file tiff.h -(see also the table below). The type and number of values -returned is dependent on the tag being requested. The -programming interface uses a variable argument list as -prescribed by the stdarg(3) interface. The returned -values should only be interpreted if TIFFGetField -returns 1.

- -

TIFFVGetField is functionally equivalent to -TIFFGetField except that it takes a pointer to a -variable argument list. TIFFVGetField is useful for -layering interfaces on top of the functionality provided by -TIFFGetField.

- -

TIFFGetFieldDefaulted and -TIFFVGetFieldDefaulted are identical to -TIFFGetField and TIFFVGetField, except that if -a tag is not defined in the current directory and it has a -default value, then the default value is returned.

- -

The tags understood by libtiff(3TIFF), the number -of parameter values, and the types for the returned values -are shown below. The data types are specified as in C and -correspond to the types used to specify tag values to -TIFFSetField(3TIFF). Remember that -TIFFGetField returns parameter values, so all the -listed data types are pointers to storage where values -should be returned. Consult the TIFF -specification (or relevant industry specification) for -information on the meaning of each tag and their possible -values.

- - -

Tag Name Count Types Notes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

TIFFTAG_ARTIST

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_BADFAXLINES

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_BITSPERSAMPLE

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_CLEANFAXDATA

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_COLORMAP

-
- -

3

-
- -

uint16**

-
- -

1<<BitsPerSample arrays

-
- -

TIFFTAG_COMPRESSION

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_CONSECUTIVEBADFAXLINES

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_COPYRIGHT

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_DATATYPE

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_DATETIME

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_DOCUMENTNAME

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_DOTRANGE

-
- -

2

-
- -

uint16*

-
-
- -

TIFFTAG_EXTRASAMPLES

-
- -

2

-
- -

uint16*,uint16**

-
- -

count & types array

-
- -

TIFFTAG_FAXFILLFUNC

-
- -

1

-
- -

TIFFFaxFillFunc*

-
- -

G3/G4 compression pseudo-tag

-
- -

TIFFTAG_FAXMODE

-
- -

1

-
- -

int*

-
- -

G3/G4 compression pseudo-tag

-
- -

TIFFTAG_FILLORDER

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_GROUP3OPTIONS

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_GROUP4OPTIONS

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_HALFTONEHINTS

-
- -

2

-
- -

uint16*

-
-
- -

TIFFTAG_HOSTCOMPUTER

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_ICCPROFILE

-
- -

2

-
- -

uint32*,void**

-
- -

count, profile data

-
- -

TIFFTAG_IMAGEDEPTH

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_IMAGEDESCRIPTION

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_IMAGELENGTH

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_IMAGEWIDTH

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_INKNAMES

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_INKSET

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_JPEGCOLORMODE

-
- -

1

-
- -

int*

-
- -

JPEG pseudo-tag

-
- -

TIFFTAG_JPEGQUALITY

-
- -

1

-
- -

int*

-
- -

JPEG pseudo-tag

-
- -

TIFFTAG_JPEGTABLES

-
- -

2

-
- -

uint32*,void**

-
- -

count & tables

-
- -

TIFFTAG_JPEGTABLESMODE

-
- -

1

-
- -

int*

-
- -

JPEG pseudo-tag

-
- -

TIFFTAG_MAKE

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_MATTEING

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_MAXSAMPLEVALUE

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_MINSAMPLEVALUE

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_MODEL

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_ORIENTATION

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_PAGENAME

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_PAGENUMBER

-
- -

2

-
- -

uint16*

-
-
- -

TIFFTAG_PHOTOMETRIC

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_PHOTOSHOP

-
- -

2

-
- -

uint32*,void**

-
- -

count, data

-
- -

TIFFTAG_PLANARCONFIG

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_PREDICTOR

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_PRIMARYCHROMATICITIES

-
- -

1

-
- -

float**

-
- -

6-entry array

-
- -

TIFFTAG_REFERENCEBLACKWHITE

-
- -

1

-
- -

float**

-
- -

2*SamplesPerPixel array

-
- -

TIFFTAG_RESOLUTIONUNIT

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_RICHTIFFIPTC

-
- -

2

-
- -

uint32*,void**

-
- -

count, data

-
- -

TIFFTAG_ROWSPERSTRIP

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_SAMPLEFORMAT

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_SAMPLESPERPIXEL

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_SMAXSAMPLEVALUE

-
- -

1

-
- -

double*

-
-
- -

TIFFTAG_SMINSAMPLEVALUE

-
- -

1

-
- -

double*

-
-
- -

TIFFTAG_SOFTWARE

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_STONITS

-
- -

1

-
- -

double**

-
-
- -

TIFFTAG_STRIPBYTECOUNTS

-
- -

1

-
- -

uint32**

-
-
- -

TIFFTAG_STRIPOFFSETS

-
- -

1

-
- -

uint32**

-
-
- -

TIFFTAG_SUBFILETYPE

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_SUBIFD

-
- -

2

-
- -

uint16*,uint32**

-
- -

count & offsets array

-
- -

TIFFTAG_TARGETPRINTER

-
- -

1

-
- -

char**

-
-
- -

TIFFTAG_THRESHHOLDING

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_TILEBYTECOUNTS

-
- -

1

-
- -

uint32**

-
-
- -

TIFFTAG_TILEDEPTH

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_TILELENGTH

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_TILEOFFSETS

-
- -

1

-
- -

uint32**

-
-
- -

TIFFTAG_TILEWIDTH

-
- -

1

-
- -

uint32*

-
-
- -

TIFFTAG_TRANSFERFUNCTION

-
- -

1 or 3†

-
- -

uint16**1<<BitsPerSample entry arrays

-
- -

TIFFTAG_WHITEPOINT

-
- -

1

-
- -

float**

-
- -

2-entry array

-
- -

TIFFTAG_XMLPACKET

-
- -

2

-
- -

uint32*,void**

-
- -

count, data

-
- -

TIFFTAG_XPOSITION

-
- -

1

-
- -

float*

-
-
- -

TIFFTAG_XRESOLUTION

-
- -

1

-
- -

float*

-
-
- -

TIFFTAG_YCBCRCOEFFICIENTS

-
- -

1

-
- -

float**

-
- -

3-entry array

-
- -

TIFFTAG_YCBCRPOSITIONING

-
- -

1

-
- -

uint16*

-
-
- -

TIFFTAG_YCBCRSUBSAMPLING

-
- -

2

-
- -

uint16*

-
-
- -

TIFFTAG_YPOSITION

-
- -

1

-
- -

float*

-
-
- -

TIFFTAG_YRESOLUTION

-
- -

1

-
- -

float*‡

-
-
- - - - - -
-

† If SamplesPerPixel is one, then a single -array is returned; otherwise three arrays are returned.
-‡ The contents of this field are quite complex. See -The ICC Profile Format Specification, Annex B.3 -"Embedding ICC Profiles in TIFF Files" (available -at http://www.color.org) for an explanation.

-
- -

AUTOREGISTERED TAGS

- - - - - -
-

If you can’t find the tag in the table above that -means this is unsupported tag. But you still be able to read -it’s value if you know the data type of that tag. For -example, if you want to read the LONG value from the tag -33424 and ASCII string from the tag 36867 you can use the -following code:

-
- - - - - -
-
uint16  count;
-void    *data;
-
-TIFFGetField(tiff, 33424, &count, &data);
-printf("Tag %d: %d, count %d0, 33424, *(uint32 *)data, count);
-TIFFGetField(tiff, 36867, &count, &data);
-printf("Tag %d: %s, count %d0, 36867, (char *)data, count);
-
-
- - - - - - -
-

is not supported by libtiff(3TIFF), library

-
- -

RETURN VALUES

- - - - - -
-

1 is returned if the tag is defined in the current -directory; otherwise a 0 is returned.

-
- -

DIAGNOSTICS

- - - - - -
-

All error messages are directed to the -TIFFError(3TIFF) routine.

- -

Unknown field, tag 0x%x. An unknown tag was -supplied.

-
- -

SEE ALSO

- - - - - -
-

TIFFOpen(3TIFF), TIFFSetField(3TIFF), -TIFFSetDirectory(3TIFF), -TIFFReadDirectory(3TIFF), -TIFFWriteDirectory(3TIFF) libtiff(3TIFF),

- -

Libtiff library home page: -http://www.remotesensing.org/libtiff/

-
-
- - diff --git a/libs/tiff-3.8.2/html/man/TIFFSetField.3tiff.html b/libs/tiff-3.8.2/html/man/TIFFSetField.3tiff.html deleted file mode 100644 index ad938cda19..0000000000 --- a/libs/tiff-3.8.2/html/man/TIFFSetField.3tiff.html +++ /dev/null @@ -1,1362 +0,0 @@ - - - - - - -TIFFSetField - - - -

TIFFSetField

-NAME
-SYNOPSIS
-DESCRIPTION
-RETURN VALUES
-DIAGNOSTICS
-SEE ALSO
- -
- -

NAME

- - - - - -
-

TIFFSetField, TIFFVSetField − set the value(s) of a -tag in a TIFF file open for writing

-
- -

SYNOPSIS

- - - - - -
-

#include <tiffio.h>

- -

int TIFFSetField(TIFF *tif, ttag_t -tag, ...)

- -

#include <stdarg.h>

- -

int TIFFVSetField(TIFF *tif, ttag_t -tag, va_list ap)

-
- -

DESCRIPTION

- - - - - -
-

TIFFSetField sets the value of a field or -pseudo-tag in the current directory associated with the open -TIFF file tif. (A pseudo-tag is -a parameter that is used to control the operation of the -TIFF library but whose value is not read or -written to the underlying file.) To set the value of a field -the file must have been previously opened for writing with -TIFFOpen(3TIFF); pseudo-tags can be set whether the -file was opened for reading or writing. The field is -identified by tag, one of the values defined in the -include file tiff.h (see also the table below). The -actual value is specified using a variable argument list, as -prescribed by the stdarg(3) interface (or, on some -machines, the varargs(3) interface.)

- -

TIFFVSetField is functionally equivalent to -TIFFSetField except that it takes a pointer to a -variable argument list. TIFFVSetField is useful for -writing routines that are layered on top of the -functionality provided by TIFFSetField.

- -

The tags understood by libtiff, the number of -parameter values, and the expected types for the parameter -values are shown below. The data types are: char* is -null-terminated string and corresponds to the -ASCII data type; uint16 is an unsigned -16-bit value; uint32 is an unsigned 32-bit value; -uint16* is an array of unsigned 16-bit values. -void* is an array of data values of unspecified -type.

- -

Consult the TIFF specification for -information on the meaning of each tag.

- - -

Tag Name Count Types Notes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

TIFFTAG_ARTIST

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_BADFAXLINES

-
- -

1

-
- -

uint32

-
-
- -

TIFFTAG_BITSPERSAMPLE

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_CLEANFAXDATA

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_COLORMAP

-
- -

3

-
- -

uint16*

-
- -

1<<BitsPerSample arrays

-
- -

TIFFTAG_COMPRESSION

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_CONSECUTIVEBADFAXLINES

-
- -

1

-
- -

uint32

-
-
- -

TIFFTAG_COPYRIGHT

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_DATETIME

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_DOCUMENTNAME

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_DOTRANGE

-
- -

2

-
- -

uint16

-
-
- -

TIFFTAG_EXTRASAMPLES

-
- -

2

-
- -

uint16,uint16*

-
- -

† count & types array

-
- -

TIFFTAG_FAXFILLFUNC

-
- -

1

-
- -

TIFFFaxFillFunc

-
- -

G3/G4 compression pseudo-tag

-
- -

TIFFTAG_FAXMODE

-
- -

1

-
- -

int

-
- -

† G3/G4 compression pseudo-tag

-
- -

TIFFTAG_FILLORDER

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_GROUP3OPTIONS

-
- -

1

-
- -

uint32

-
- -

-
- -

TIFFTAG_GROUP4OPTIONS

-
- -

1

-
- -

uint32

-
- -

-
- -

TIFFTAG_HALFTONEHINTS

-
- -

2

-
- -

uint16

-
-
- -

TIFFTAG_HOSTCOMPUTER

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_ICCPROFILE

-
- -

2

-
- -

uint32,void*

-
- -

count, profile data

-
- -

TIFFTAG_IMAGEDEPTH

-
- -

1

-
- -

uint32

-
- -

-
- -

TIFFTAG_IMAGEDESCRIPTION

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_IMAGELENGTH

-
- -

1

-
- -

uint32

-
-
- -

TIFFTAG_IMAGEWIDTH

-
- -

1

-
- -

uint32

-
- -

-
- -

TIFFTAG_INKNAMES

-
- -

2

-
- -

uint16, char*

-
-
- -

TIFFTAG_INKSET

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_JPEGCOLORMODE

-
- -

1

-
- -

int

-
- -

† JPEG pseudo-tag

-
- -

TIFFTAG_JPEGQUALITY

-
- -

1

-
- -

int

-
- -

JPEG pseudo-tag

-
- -

TIFFTAG_JPEGTABLES

-
- -

2

-
- -

uint32*,void*

-
- -

† count & tables

-
- -

TIFFTAG_JPEGTABLESMODE

-
- -

1

-
- -

int

-
- -

† JPEG pseudo-tag

-
- -

TIFFTAG_MAKE

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_MATTEING

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_MAXSAMPLEVALUE

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_MINSAMPLEVALUE

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_MODEL

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_ORIENTATION

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_PAGENAME

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_PAGENUMBER

-
- -

2

-
- -

uint16

-
-
- -

TIFFTAG_PHOTOMETRIC

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_PHOTOSHOP

-
- -

?

-
- -

uint32,void*

-
- -

count, data

-
- -

TIFFTAG_PLANARCONFIG

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_PREDICTOR

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_PRIMARYCHROMATICITIES

-
- -

1

-
- -

float*

-
- -

6-entry array

-
- -

TIFFTAG_REFERENCEBLACKWHITE

-
- -

1

-
- -

float*

-
- -

† 2*SamplesPerPixel array

-
- -

TIFFTAG_RESOLUTIONUNIT

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_RICHTIFFIPTC

-
- -

2

-
- -

uint32,void*

-
- -

count, data

-
- -

TIFFTAG_ROWSPERSTRIP

-
- -

1

-
- -

uint32

-
- -

† must be > 0

-
- -

TIFFTAG_SAMPLEFORMAT

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_SAMPLESPERPIXEL

-
- -

1

-
- -

uint16

-
- -

† value must be <= 4

-
- -

TIFFTAG_SMAXSAMPLEVALUE

-
- -

1

-
- -

double

-
-
- -

TIFFTAG_SMINSAMPLEVALUE

-
- -

1

-
- -

double

-
-
- -

TIFFTAG_SOFTWARE

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_STONITS

-
- -

1

-
- -

double

-
- -

-
- -

TIFFTAG_SUBFILETYPE

-
- -

1

-
- -

uint32

-
-
- -

TIFFTAG_SUBIFD

-
- -

2

-
- -

uint16,uint32*

-
- -

count & offsets array

-
- -

TIFFTAG_TARGETPRINTER

-
- -

1

-
- -

char*

-
-
- -

TIFFTAG_THRESHHOLDING

-
- -

1

-
- -

uint16

-
-
- -

TIFFTAG_TILEDEPTH

-
- -

1

-
- -

uint32

-
- -

-
- -

TIFFTAG_TILELENGTH

-
- -

1

-
- -

uint32

-
- -

† must be a multiple of 8

-
- -

TIFFTAG_TILEWIDTH

-
- -

1

-
- -

uint32

-
- -

† must be a multiple of 8

-
- -

TIFFTAG_TRANSFERFUNCTION

-
- -

1 or 3‡ uint16*

-
- -

1<<BitsPerSample entry arrays

-
- -

TIFFTAG_WHITEPOINT

-
- -

1

-
- -

float*

-
- -

2-entry array

-
- -

TIFFTAG_XMLPACKET

-
- -

2

-
- -

uint32,void*

-
- -

count, data

-
- -

TIFFTAG_XPOSITION

-
- -

1

-
- -

float

-
-
- -

TIFFTAG_XRESOLUTION

-
- -

1

-
- -

float

-
-
- -

TIFFTAG_YCBCRCOEFFICIENTS

-
- -

1

-
- -

float*

-
- -

† 3-entry array

-
- -

TIFFTAG_YCBCRPOSITIONING

-
- -

1

-
- -

uint16

-
- -

-
- -

TIFFTAG_YCBCRSAMPLING

-
- -

2

-
- -

uint16

-
- -

-
- -

TIFFTAG_YPOSITION

-
- -

1

-
- -

float

-
-
- -

TIFFTAG_YRESOLUTION

-
- -

1

-
- -

float

-
-
- - - - - -
-

† Tag may not have its values changed once data is -written.
-‡ If SamplesPerPixel is one, then a single -array is passed; otherwise three arrays should be -passed.
-* The contents of this field are quite complex. See The -ICC Profile Format Specification, Annex B.3 -"Embedding ICC Profiles in TIFF Files" (available -at http://www.color.org) for an explanation.

-
- -

RETURN VALUES

- - - - - -
-

1 is returned if the operation was successful. Otherwise, -0 is returned if an error was detected.

-
- -

DIAGNOSTICS

- - - - - -
-

All error messages are directed to the -TIFFError(3TIFF) routine.

- -

%s: Cannot modify tag "%s" while -writing. Data has already been written to the file, so -the specified tag’s value can not be changed. This -restriction is applied to all tags that affect the format of -written data.

- -

%d: Bad value for "%s". An invalid value -was supplied for the named tag.

-
- -

SEE ALSO

- - - - - -
-

TIFFOpen(3TIFF), TIFFGetField(3TIFF), -TIFFSetDirectory(3TIFF), -TIFFWriteDirectory(3TIFF), -TIFFReadDirectory(3TIFF), libtiff(3TIFF)

- -

Libtiff library home page: -http://www.remotesensing.org/libtiff/

-
-
- - diff --git a/libs/tiff-3.8.2/html/man/libtiff.3tiff.html b/libs/tiff-3.8.2/html/man/libtiff.3tiff.html deleted file mode 100644 index 8a4f5075e1..0000000000 --- a/libs/tiff-3.8.2/html/man/libtiff.3tiff.html +++ /dev/null @@ -1,3137 +0,0 @@ - - - - - - -INTRO - - - -

INTRO

-NAME
-SYNOPSIS
-DESCRIPTION
-DATA TYPES
-LIST OF ROUTINES
-TAG USAGE
-PSEUDO TAGS
-DIAGNOSTICS
-SEE ALSO
-BUGS
- -
- -

NAME

- - - - - -
-

libtiff − introduction to libtiff, a -library for reading and writing TIFF -files

-
- -

SYNOPSIS

- - - - - -
-

#include <tiffio.h>

- -

cc file.c -ltiff

-
- -

DESCRIPTION

- - - - - -
-

libtiff is a library for reading and writing -data files encoded with the Tag Image File format, -Revision 6.0 (or revision 5.0 or revision 4.0). This file -format is suitable for archiving multi-color and -monochromatic image data.

- -

The library supports several compression algorithms, -as indicated by the Compression field, including: no -compression (1), CCITT 1D Huffman compression -(2), CCITT Group 3 Facsimile compression -(3), CCITT Group 4 Facsimile compression (4), -Lempel-Ziv & Welch compression (5), baseline JPEG -compression (7), word-aligned 1D Huffman compression -(32771), and PackBits compression (32773). In addition, -several nonstandard compression algorithms are supported: -the 4-bit compression algorithm used by the -ThunderScan program (32809) (decompression only), -NeXT’s 2-bit compression algorithm (32766) -(decompression only), an experimental LZ-style algorithm -known as Deflate (32946), and an experimental CIE LogLuv -compression scheme designed for images with high dynamic -range (32845 for LogL and 32845 for LogLuv). Directory -information may be in either little- or big-endian byte -order−byte swapping is automatically done by the -library. Data bit ordering may be either Most Significant -Bit ( MSB ) to Least Significant Bit ( LSB -) or LSB to MSB. Finally, the -library does not support files in which the -BitsPerSample, Compression, -MinSampleValue, or MaxSampleValue fields are -defined differently on a per-sample basis (in Rev. 6.0 the -Compression tag is not defined on a per-sample basis, -so this is immaterial).

-
- -

DATA TYPES

- - - - - -
-

The library makes extensive use of C typedefs to -promote portability. Two sets of typedefs are used, one for -communication with clients of the library and one for -internal data structures and parsing of the TIFF -format. The following typedefs are exposed to users -either through function definitions or through parameters -passed through the varargs interfaces.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

typedef unsigned short uint16;

-
- -

16-bit unsigned integer

-
- -

typedef unsigned <thing> -uint32;

-
- -

32-bit unsigned integer

-
- -

typedef unsigned int ttag_t;

-
- -

directory tag

-
- -

typedef uint16 tdir_t;

-
- -

directory index

-
- -

typedef uint16 tsample_t;

-
- -

sample number

-
- -

typedef uint32 tstrip_t;

-
- -

strip number

-
- -

typedef uint32 ttile_t;

-
- -

tile number

-
- -

typedef int32 tsize_t;

-
- -

i/o size in bytes

-
- -

typedef void* tdata_t;

-
- -

image data ref

-
- -

typedef void* thandle_t;

-
- -

client data handle

-
- -

typedef int32 toff_t;

-
- -

file offset

-
- - - - - -
-

Note that tstrip_t, ttile_t, and -tsize_t are constrained to be no more than 32-bit -quantities by 32-bit fields they are stored in in the -TIFF image. Likewise tsample_t is limited by the -16-bit field used to store the SamplesPerPixel tag. -tdir_t constrains the maximum number of IFDs -that may appear in an image and may be an arbitrary -size (w/o penalty). ttag_t must be either int, -unsigned int, pointer, or double because the library uses a -varargs interface and ANSI C restricts the type -of the parameter before an ellipsis to be a promoted type. -toff_t is defined as int32 because TIFF file offsets -are (unsigned) 32-bit quantities. A signed value is used -because some interfaces return −1 on error. Finally, -note that user-specified data references are passed as -opaque handles and only cast at the lowest layers where -their type is presumed.

-
- -

LIST OF ROUTINES

- - - - - -
-

The following routines are part of the library. -Consult specific manual pages for details on their -operation; on most systems doing ‘‘man -function-name’’ will work.

- - -

Name Description

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

TIFFCheckpointDirectory

-
- -

writes the current state of the directory

-
- -

TIFFCheckTile

-
- -

very x,y,z,sample is within image

-
- -

TIFFCIELabToRGBInit

-
- -

initialize CIE L*a*b* 1976 to RGB conversion -state

-
- -

TIFFCIELabToXYZ

-
- -

perform CIE L*a*b* 1976 to CIE XYZ -conversion

-
- -

TIFFClientOpen

-
- -

open a file for reading or writing

-
- -

TIFFClose

-
- -

close an open file

-
- -

TIFFComputeStrip

-
- -

return strip containing y,sample

-
- -

TIFFComputeTile

-
- -

return tile containing x,y,z,sample

-
- -

TIFFCurrentDirectory

-
- -

return index of current directory

-
- -

TIFFCurrentRow

-
- -

return index of current scanline

-
- -

TIFFCurrentStrip

-
- -

return index of current strip

-
- -

TIFFCurrentTile

-
- -

return index of current tile

-
- -

TIFFDataWidth

-
- -

return the size of TIFF data types

-
- -

TIFFError

-
- -

library error handler

-
- -

TIFFFdOpen

-
- -

open a file for reading or writing

-
- -

TIFFFileName

-
- -

return name of open file

-
- -

TIFFFileno

-
- -

return open file descriptor

-
- -

TIFFFindCODEC

-
- -

find standard codec for the specific -scheme

-
- -

TIFFFlush

-
- -

flush all pending writes

-
- -

TIFFFlushData

-
- -

flush pending data writes

-
- -

TIFFGetBitRevTable

-
- -

return bit reversal table

-
- -

TIFFGetField

-
- -

return tag value in current directory

-
- -

TIFFGetFieldDefaulted

-
- -

return tag value in current directory

-
- -

TIFFGetMode

-
- -

return open file mode

-
- -

TIFFGetVersion

-
- -

return library version string

-
- -

TIFFIsCODECConfigured

-
- -

check, whether we have working codec

-
- -

TIFFIsMSB2LSB

-
- -

return true if image data is being -returned

-
- -

with bit 0 as the most significant bit

-
- -

TIFFIsTiled

-
- -

return true if image data is tiled

-
- -

TIFFIsByteSwapped

-
- -

return true if image data is byte-swapped

-
- -

TIFFNumberOfStrips

-
- -

return number of strips in an image

-
- -

TIFFNumberOfTiles

-
- -

return number of tiles in an image

-
- -

TIFFOpen

-
- -

open a file for reading or writing

-
- -

TIFFPrintDirectory

-
- -

print description of the current -directory

-
- -

TIFFReadBufferSetup

-
- -

specify i/o buffer for reading

-
- -

TIFFReadDirectory

-
- -

read the next directory

-
- -

TIFFReadEncodedStrip

-
- -

read and decode a strip of data

-
- -

TIFFReadEncodedTile

-
- -

read and decode a tile of data

-
- -

TIFFReadRawStrip

-
- -

read a raw strip of data

-
- -

TIFFReadRawTile

-
- -

read a raw tile of data

-
- -

TIFFReadRGBAImage

-
- -

read an image into a fixed format raster

-
- -

TIFFReadScanline

-
- -

read and decode a row of data

-
- -

TIFFReadTile

-
- -

read and decode a tile of data

-
- -

TIFFRegisterCODEC

-
- -

override standard codec for the specific -scheme

-
- -

TIFFReverseBits

-
- -

reverse bits in an array of bytes

-
- -

TIFFRGBAImageBegin

-
- -

setup decoder state for TIFFRGBAImageGet

-
- -

TIFFRGBAImageEnd

-
- -

release TIFFRGBAImage decoder state

-
- -

TIFFRGBAImageGet

-
- -

read and decode an image

-
- -

TIFFRGBAImageOK

-
- -

is image readable by TIFFRGBAImageGet

-
- -

TIFFScanlineSize

-
- -

return size of a scanline

-
- -

TIFFSetDirectory

-
- -

set the current directory

-
- -

TIFFSetSubDirectory

-
- -

set the current directory

-
- -

TIFFSetErrorHandler

-
- -

set error handler function

-
- -

TIFFSetField

-
- -

set a tag’s value in the current -directory

-
- -

TIFFSetWarningHandler

-
- -

set warning handler function

-
- -

TIFFStripSize

-
- -

returns size of a strip

-
- -

TIFFRawStripSize

-
- -

returns the number of bytes in a raw -strip

-
- -

TIFFSwabShort

-
- -

swap bytes of short

-
- -

TIFFSwabLong

-
- -

swap bytes of long

-
- -

TIFFSwabArrayOfShort

-
- -

swap bytes of an array of shorts

-
- -

TIFFSwabArrayOfLong

-
- -

swap bytes of an array of longs

-
- -

TIFFTileRowSize

-
- -

return size of a row in a tile

-
- -

TIFFTileSize

-
- -

return size of a tile

-
- -

TIFFUnRegisterCODEC

-
- -

unregisters the codec

-
- -

TIFFVGetField

-
- -

return tag value in current directory

-
- -

TIFFVGetFieldDefaulted

-
- -

return tag value in current directory

-
- -

TIFFVSetField

-
- -

set a tag’s value in the current -directory

-
- -

TIFFVStripSize

-
- -

returns the number of bytes in a strip

-
- -

TIFFWarning

-
- -

library warning handler

-
- -

TIFFWriteDirectory

-
- -

write the current directory

-
- -

TIFFWriteEncodedStrip

-
- -

compress and write a strip of data

-
- -

TIFFWriteEncodedTile

-
- -

compress and write a tile of data

-
- -

TIFFWriteRawStrip

-
- -

write a raw strip of data

-
- -

TIFFWriteRawTile

-
- -

write a raw tile of data

-
- -

TIFFWriteScanline

-
- -

write a scanline of data

-
- -

TIFFWriteTile

-
- -

compress and write a tile of data

-
- -

TIFFXYZToRGB

-
- -

perform CIE XYZ to RGB conversion

-
- -

TIFFYCbCrToRGBInit

-
- -

initialize YCbCr to RGB conversion state

-
- -

TIFFYCbCrtoRGB

-
- -

perform YCbCr to RGB conversion

-
- - - - - -
-

Auxiliary functions:

- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

_TIFFfree

-
- -

free memory buffer

-
- -

_TIFFmalloc

-
- -

dynamically allocate memory buffer

-
- -

_TIFFmemcmp

-
- -

compare contents of the memory buffers

-
- -

_TIFFmemcpy

-
- -

copy contents of the one buffer to -another

-
- -

_TIFFmemset

-
- -

fill memory buffer with a constant byte

-
- -

_TIFFrealloc

-
- -

dynamically reallocate memory buffer

-
- -

TAG USAGE

- - - - - -
-

The table below lists the TIFF tags that -are recognized and handled by the library. If no use is -indicated in the table, then the library reads and writes -the tag, but does not use it internally. Note that some tags -are meaningful only when a particular compression scheme is -being used; e.g. Group3Options is only useful if -Compression is set to CCITT Group 3 -encoding. Tags of this sort are considered -codec-specific tags and the library does not -recognize them except when the Compression tag has -been previously set to the relevant compression -scheme.

- -
Tag Name                Value  R/W  Library Use/Notes
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Artist

-
- -

315

-
- -

R/W

-
- -

BadFaxLines

-
- -

326

-
- -

R/W

-
- -

BitsPerSample

-
- -

258

-
- -

R/W

-
- -

lots

-
- -

CellLength

-
- -

265

-
-
- -

parsed but ignored

-
- -

CellWidth

-
- -

264

-
-
- -

parsed but ignored

-
- -

CleanFaxData

-
- -

327

-
- -

R/W

-
- -

ColorMap

-
- -

320

-
- -

R/W

-
- -

ColorResponseUnit

-
- -

300

-
-
- -

parsed but ignored

-
- -

Compression

-
- -

259

-
- -

R/W

-
- -

choosing codec

-
- -

ConsecutiveBadFaxLines

-
- -

328

-
- -

R/W

-
- - - - - -
-

Copyright 33432 R/W

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

DataType

-
- -

32996

-
- -

R

-
- -

obsoleted by SampleFormat tag

-
- -

DateTime

-
- -

306

-
- -

R/W

-
- -

DocumentName

-
- -

269

-
- -

R/W

-
- -

DotRange

-
- -

336

-
- -

R/W

-
- -

ExtraSamples

-
- -

338

-
- -

R/W

-
- -

lots

-
- -

FaxRecvParams

-
- -

34908

-
- -

R/W

-
- -

FaxSubAddress

-
- -

34909

-
- -

R/W

-
- -

FaxRecvTime

-
- -

34910

-
- -

R/W

-
- -

FillOrder

-
- -

266

-
- -

R/W

-
- -

control bit order

-
- -

FreeByteCounts

-
- -

289

-
-
- -

parsed but ignored

-
- -

FreeOffsets

-
- -

288

-
-
- -

parsed but ignored

-
- -

GrayResponseCurve

-
- -

291

-
-
- -

parsed but ignored

-
- -

GrayResponseUnit

-
- -

290

-
-
- -

parsed but ignored

-
- -

Group3Options

-
- -

292

-
- -

R/W

-
- -

used by Group 3 codec

-
- -

Group4Options

-
- -

293

-
- -

R/W

-
- -

HostComputer

-
- -

316

-
- -

R/W

-
- -

ImageDepth

-
- -

32997

-
- -

R/W

-
- -

tile/strip calculations

-
- -

ImageDescription

-
- -

270

-
- -

R/W

-
- -

ImageLength

-
- -

257

-
- -

R/W

-
- -

lots

-
- -

ImageWidth

-
- -

256

-
- -

R/W

-
- -

lots

-
- -

InkNames

-
- -

333

-
- -

R/W

-
- -

InkSet

-
- -

332

-
- -

R/W

-
- -

JPEGTables

-
- -

347

-
- -

R/W

-
- -

used by JPEG codec

-
- -

Make

-
- -

271

-
- -

R/W

-
- -

Matteing

-
- -

32995

-
- -

R

-
- -

obsoleted by ExtraSamples tag

-
- -

MaxSampleValue

-
- -

281

-
- -

R/W

-
- -

MinSampleValue

-
- -

280

-
- -

R/W

-
- -

Model

-
- -

272

-
- -

R/W

-
- -

NewSubFileType

-
- -

254

-
- -

R/W

-
- -

called SubFileType in spec

-
- -

NumberOfInks

-
- -

334

-
- -

R/W

-
- -

Orientation

-
- -

274

-
- -

R/W

-
- -

PageName

-
- -

285

-
- -

R/W

-
- -

PageNumber

-
- -

297

-
- -

R/W

-
- -

PhotometricInterpretation

-
- -

262

-
- -

R/Wused by Group 3 and JPEG codecs

-
- -

PlanarConfiguration

-
- -

284

-
- -

R/W

-
- -

data i/o

-
- -

Predictor

-
- -

317

-
- -

R/W

-
- -

used by LZW and Deflate codecs

-
- -

PrimaryChromacities

-
- -

319

-
- -

R/W

-
- -

ReferenceBlackWhite

-
- -

532

-
- -

R/W

-
- -

ResolutionUnit

-
- -

296

-
- -

R/W

-
- -

used by Group 3 codec

-
- -

RowsPerStrip

-
- -

278

-
- -

R/W

-
- -

data i/o

-
- -

SampleFormat

-
- -

339

-
- -

R/W

-
- -

SamplesPerPixel

-
- -

277

-
- -

R/W

-
- -

lots

-
- -

SMinSampleValue

-
- -

340

-
- -

R/W

-
- -

SMaxSampleValue

-
- -

341

-
- -

R/W

-
- -

Software

-
- -

305

-
- -

R/W

-
- -

StoNits

-
- -

37439

-
- -

R/W

-
- -

StripByteCounts

-
- -

279

-
- -

R/W

-
- -

data i/o

-
- -

StripOffsets

-
- -

273

-
- -

R/W

-
- -

data i/o

-
- -

SubFileType

-
- -

255

-
- -

R/W

-
- -

called OSubFileType in spec

-
- -

TargetPrinter

-
- -

337

-
- -

R/W

-
- -

Thresholding

-
- -

263

-
- -

R/W

-
-
- -

TileByteCounts

-
- -

324

-
- -

R/W

-
- -

data i/o

-
- -

TileDepth

-
- -

32998

-
- -

R/W

-
- -

tile/strip calculations

-
- -

TileLength

-
- -

323

-
- -

R/W

-
- -

data i/o

-
- -

TileOffsets

-
- -

324

-
- -

R/W

-
- -

data i/o

-
- -

TileWidth

-
- -

322

-
- -

R/W

-
- -

data i/o

-
- -

TransferFunction

-
- -

301

-
- -

R/W

-
- -

WhitePoint

-
- -

318

-
- -

R/W

-
- -

XPosition

-
- -

286

-
- -

R/W

-
- -

XResolution

-
- -

282

-
- -

R/W

-
- -

YCbCrCoefficients

-
- -

529

-
- -

R/W

-
- -

used by TIFFRGBAImage support

-
- -

YCbCrPositioning

-
- -

531

-
- -

R/W

-
- -

tile/strip size calulcations

-
- -

YCbCrSubsampling

-
- -

530

-
- -

R/W

-
- -

YPosition

-
- -

286

-
- -

R/W

-
- -

YResolution

-
- -

283

-
- -

R/W

-
- -

used by Group 3 codec

-
- -

PSEUDO TAGS

- - - - - -
-

In addition to the normal TIFF tags the -library supports a collection of tags whose values lie in a -range outside the valid range of TIFF tags. These -tags are termed pseud-tags and are used to control -various codec-specific functions within the library. The -table below summarizes the defined pseudo-tags.

- -
Tag Name                Codec  R/W  Library Use/Notes
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

TIFFTAG_FAXMODE

-
- -

G3

-
- -

R/W

-
- -

general codec operation

-
- -

TIFFTAG_FAXFILLFUNC

-
- -

G3/G4

-
- -

R/W

-
- -

bitmap fill function

-
- -

TIFFTAG_JPEGQUALITY

-
- -

JPEG

-
- -

R/W

-
- -

compression quality control

-
- -

TIFFTAG_JPEGCOLORMODE

-
- -

JPEG

-
- -

R/W

-
- -

control colorspace conversions

-
- -

TIFFTAG_JPEGTABLESMODE

-
- -

JPEG

-
- -

R/W

-
- -

control contents of JPEGTables tag

-
- -

TIFFTAG_ZIPQUALITY

-
- -

Deflate

-
- -

R/Wcompression quality level

-
- -

TIFFTAG_PIXARLOGDATAFMT

-
- -

PixarLog

-
- -

R/Wuser data format

-
- -

TIFFTAG_PIXARLOGQUALITY

-
- -

PixarLog

-
- -

R/Wcompression quality level

-
- -

TIFFTAG_SGILOGDATAFMT

-
- -

SGILog

-
- -

R/W

-
- -

user data format

-
- - - - - -
-

TIFFTAG_FAXMODE

- - - - - -
-

Control the operation of the Group 3 codec. Possible -values (independent bits that can be combined by -or’ing them together) are: FAXMODE_CLASSIC (enable -old-style format in which the RTC is written at -the end of the last strip), FAXMODE_NORTC (opposite of -FAXMODE_CLASSIC; also called FAXMODE_CLASSF), FAXMODE_NOEOL -(do not write EOL codes at the start of each row -of data), FAXMODE_BYTEALIGN (align each encoded row to an -8-bit boundary), FAXMODE_WORDALIGN (align each encoded row -to an 16-bit boundary), The default value is dependent on -the compression scheme; this pseudo-tag is used by the -various G3 and G4 codecs to share code.

-
- - - - - -
-

TIFFTAG_FAXFILLFUNC

- - - - - -
-

Control the function used to convert arrays of black -and white runs to packed bit arrays. This hook can be used -to image decoded scanlines in multi-bit depth rasters (e.g. -for display in colormap mode) or for other purposes. The -default value is a pointer to a builtin function that images -packed bilevel data.

-
- - - - - -
-

TIFFTAG_IPTCNEWSPHOTO

- - - - - -
-

Tag contaings image metadata per the IPTC newsphoto -spec: Headline, captioning, credit, etc... Used by most wire -services.

-
- - - - - -
-

TIFFTAG_PHOTOSHOP

- - - - - -
-

Tag contains Photoshop captioning information and -metadata. Photoshop uses in parallel and redundantly -alongside IPTCNEWSPHOTO information.

-
- - - - - -
-

TIFFTAG_JPEGQUALITY

- - - - - -
-

Control the compression quality level used in the -baseline algorithm. Note that quality levels are in the -range 0-100 with a default value of 75.

-
- - - - - -
-

TIFFTAG_JPEGCOLORMODE

- - - - - -
-

Control whether or not conversion is done between -RGB and YCbCr colorspaces. Possible values are: -JPEGCOLORMODE_RAW (do not convert), and JPEGCOLORMODE_RGB -(convert to/from RGB) The default value is -JPEGCOLORMODE_RAW.

-
- - - - - -
-

TIFFTAG_JPEGTABLESMODE

- - - - - -
-

Control the information written in the -JPEGTables tag. Possible values (independent bits -that can be combined by or’ing them together) are: -JPEGTABLESMODE_QUANT (include quantization tables), and -JPEGTABLESMODE_HUFF (include Huffman encoding tables). The -default value is -JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF.

-
- - - - - -
-

TIFFTAG_ZIPQUALITY

- - - - - -
-

Control the compression technique used by the -Deflate codec. Quality levels are in the range 1-9 with -larger numbers yielding better compression at the cost of -more computation. The default quality level is 6 which -yields a good time-space tradeoff.

-
- - - - - -
-

TIFFTAG_PIXARLOGDATAFMT

- - - - - -
-

Control the format of user data passed in to -the PixarLog codec when encoding and passed out from -when decoding. Possible values are: PIXARLOGDATAFMT_8BIT for -8-bit unsigned pixels, PIXARLOGDATAFMT_8BITABGR for 8-bit -unsigned ABGR-ordered pixels, PIXARLOGDATAFMT_11BITLOG for -11-bit log-encoded raw data, PIXARLOGDATAFMT_12BITPICIO for -12-bit PICIO-compatible data, PIXARLOGDATAFMT_16BIT for -16-bit signed samples, and PIXARLOGDATAFMT_FLOAT for 32-bit -IEEE floating point samples.

-
- - - - - -
-

TIFFTAG_PIXARLOGQUALITY

- - - - - -
-

Control the compression technique used by the -PixarLog codec. This value is treated identically to -TIFFTAG_ZIPQUALITY; see the above description.

-
- - - - - -
-

TIFFTAG_SGILOGDATAFMT

- - - - - -
-

Control the format of client data passed in -to the SGILog codec when encoding and passed out from -when decoding. Possible values are: SGILOGDATAFMT_FLTXYZ for -converting between LogLuv and 32-bit IEEE floating valued -XYZ pixels, SGILOGDATAFMT_16BITLUV for 16-bit encoded Luv -pixels, SGILOGDATAFMT_32BITRAW and SGILOGDATAFMT_24BITRAW -for no conversion of data, SGILOGDATAFMT_8BITRGB for -returning 8-bit RGB data (valid only when decoding -LogLuv-encoded data), SGILOGDATAFMT_FLTY for converting -between LogL and 32-bit IEEE floating valued Y pixels, -SGILOGDATAFMT_16BITL for 16-bit encoded L pixels, and -SGILOGDATAFMT_8BITGRY for returning 8-bit greyscale data -(valid only when decoding LogL-encoded data).

-
- -

DIAGNOSTICS

- - - - - -
-

All error messages are directed through the -TIFFError routine. By default messages are directed -to stderr in the form: module: message\n. -Warning messages are likewise directed through the -TIFFWarning routine.

-
- -

SEE ALSO

- - - - - -
-

fax2tiff(1), gif2tiff(1), -pal2rgb(1), ppm2tiff(1), rgb2ycbcr(1), -ras2tiff(1), raw2tiff(1), sgi2tiff(1), -tiff2bw(1), tiffdither(1), tiffdump(1), -tiffcp(1), tiffcmp(1), tiffgt(1), -tiffinfo(1), tiffmedian(1), -tiffsplit(1), tiffsv(1).

- -

Tag Image File Format Specification — -Revision 6.0, an Aldus Technical Memorandum.

- -

The Spirit of TIFF Class F, an appendix to -the TIFF 5.0 specification prepared by Cygnet -Technologies.

- -

Libtiff library home page: -http://www.remotesensing.org/libtiff/

-
- -

BUGS

- - - - - -
-

The library does not support multi-sample images -where some samples have different bits/sample.

- -

The library does not support random access to -compressed data that is organized with more than one row per -tile or strip.

-
-
- - diff --git a/libs/tiff-3.8.2/libtiff/tif_acorn.c b/libs/tiff-3.8.2/libtiff/tif_acorn.c deleted file mode 100644 index 478390fc59..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_acorn.c +++ /dev/null @@ -1,519 +0,0 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_acorn.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library RISC OS specific Routines. - * Developed out of the Unix version. - * Peter Greenham, May 1995 - */ -#include "tiffiop.h" -#include -#include - -/* -Low-level file handling -~~~~~~~~~~~~~~~~~~~~~~~ -The functions in osfcn.h are unavailable when compiling under C, as it's a -C++ header. Therefore they have been implemented here. - -Now, why have I done it this way? - -The definitive API library for RISC OS is Jonathan Coxhead's OSLib, which -uses heavily optimised ARM assembler or even plain inline SWI calls for -maximum performance and minimum runtime size. However, I don't want to make -LIBTIFF need that to survive. Therefore I have also emulated the functions -using macros to _swi() and _swix() defined in the swis.h header, and -borrowing types from kernel.h, which is less efficient but doesn't need any -third-party libraries. - */ - -#ifdef INCLUDE_OSLIB - -#include "osfile.h" -#include "osgbpb.h" -#include "osargs.h" -#include "osfind.h" - -#else - -/* OSLIB EMULATION STARTS */ - -#include "kernel.h" -#include "swis.h" - -/* From oslib:types.h */ -typedef unsigned int bits; -typedef unsigned char byte; -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif -#ifndef SKIP -#define SKIP 0 -#endif - -/* From oslib:os.h */ -typedef _kernel_oserror os_error; -typedef byte os_f; - -/* From oslib:osfile.h */ -#undef OS_File -#define OS_File 0x8 - -/* From oslib:osgbpb.h */ -#undef OS_GBPB -#define OS_GBPB 0xC -#undef OSGBPB_Write -#define OSGBPB_Write 0x2 -#undef OSGBPB_Read -#define OSGBPB_Read 0x4 - -extern os_error *xosgbpb_write (os_f file, - byte *data, - int size, - int *unwritten); -extern int osgbpb_write (os_f file, - byte *data, - int size); - -#define xosgbpb_write(file, data, size, unwritten) \ - (os_error*) _swix(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4)|_OUT(3), \ - OSGBPB_WriteAt, \ - file, \ - data, \ - size, \ - unwritten) - -#define osgbpb_write(file, data, size) \ - _swi(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(3), \ - OSGBPB_Write, \ - file, \ - data, \ - size) - -extern os_error *xosgbpb_read (os_f file, - byte *buffer, - int size, - int *unread); -extern int osgbpb_read (os_f file, - byte *buffer, - int size); - -#define xosgbpb_read(file, buffer, size, unread) \ - (os_error*) _swix(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(3), \ - OSGBPB_Read, \ - file, \ - buffer, \ - size, \ - unread) - -#define osgbpb_read(file, buffer, size) \ - _swi(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(3), \ - OSGBPB_Read, \ - file, \ - buffer, \ - size) - -/* From oslib:osfind.h */ -#undef OS_Find -#define OS_Find 0xD -#undef OSFind_Openin -#define OSFind_Openin 0x40 -#undef OSFind_Openout -#define OSFind_Openout 0x80 -#undef OSFind_Openup -#define OSFind_Openup 0xC0 -#undef OSFind_Close -#define OSFind_Close 0x0 - -#define xosfind_open(reason, file_name, path, file) \ - (os_error*) _swix(OS_Find, _IN(0)|_IN(1)|_IN(2)|_OUT(0), \ - reason, file_name, path, file) - -#define osfind_open(reason, file_name, path) \ - (os_f) _swi(OS_Find, _IN(0)|_IN(1)|_IN(2)|_RETURN(0), \ - reason, file_name, path) - -extern os_error *xosfind_openin (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openin (bits flags, - char *file_name, - char *path); - -#define xosfind_openin(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openin, file_name, path, file) - -#define osfind_openin(flags, file_name, path) \ - osfind_open(flags | OSFind_Openin, file_name, path) - -extern os_error *xosfind_openout (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openout (bits flags, - char *file_name, - char *path); - -#define xosfind_openout(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openout, file_name, path, file) - -#define osfind_openout(flags, file_name, path) \ - osfind_open(flags | OSFind_Openout, file_name, path) - -extern os_error *xosfind_openup (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openup (bits flags, - char *file_name, - char *path); - -#define xosfind_openup(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openup, file_name, path, file) - -#define osfind_openup(flags, file_name, path) \ - osfind_open(flags | OSFind_Openup, file_name, path) - -extern os_error *xosfind_close (os_f file); -extern void osfind_close (os_f file); - -#define xosfind_close(file) \ - (os_error*) _swix(OS_Find, _IN(0)|_IN(1), \ - OSFind_Close, \ - file) - -#define osfind_close(file) \ - (void) _swi(OS_Find, _IN(0)|_IN(1), \ - OSFind_Close, \ - file) - -/* From oslib:osargs.h */ -#undef OS_Args -#define OS_Args 0x9 -#undef OSArgs_ReadPtr -#define OSArgs_ReadPtr 0x0 -#undef OSArgs_SetPtr -#define OSArgs_SetPtr 0x1 -#undef OSArgs_ReadExt -#define OSArgs_ReadExt 0x2 - -extern os_error *xosargs_read_ptr (os_f file, - int *ptr); -extern int osargs_read_ptr (os_f file); - -#define xosargs_read_ptr(file, ptr) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_OUT(2), \ - OSArgs_ReadPtr, \ - file, \ - ptr) - -#define osargs_read_ptr(file) \ - _swi(OS_Args, _IN(0)|_IN(1)|_RETURN(2), \ - OSArgs_ReadPtr, \ - file) - -extern os_error *xosargs_set_ptr (os_f file, - int ptr); -extern void osargs_set_ptr (os_f file, - int ptr); - -#define xosargs_set_ptr(file, ptr) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_IN(2), \ - OSArgs_SetPtr, \ - file, \ - ptr) - -#define osargs_set_ptr(file, ptr) \ - (void) _swi(OS_Args, _IN(0)|_IN(1)|_IN(2), \ - OSArgs_SetPtr, \ - file, \ - ptr) - -extern os_error *xosargs_read_ext (os_f file, - int *ext); -extern int osargs_read_ext (os_f file); - -#define xosargs_read_ext(file, ext) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_OUT(2), \ - OSArgs_ReadExt, \ - file, \ - ext) - -#define osargs_read_ext(file) \ - _swi(OS_Args, _IN(0)|_IN(1)|_RETURN(2), \ - OSArgs_ReadExt, \ - file) - -/* OSLIB EMULATION ENDS */ - -#endif - -#ifndef __osfcn_h -/* Will be set or not during tiffcomp.h */ -/* You get this to compile under C++? Please say how! */ - -extern int open(const char* name, int flags, int mode) -{ - /* From what I can tell, should return <0 for failure */ - os_error* e = (os_error*) 1; /* Cheeky way to use a pointer eh? :-) */ - os_f file = (os_f) -1; - - flags = flags; - - switch(mode) - { - case O_RDONLY: - { - e = xosfind_openin(SKIP, name, SKIP, &file); - break; - } - case O_WRONLY: - case O_RDWR|O_CREAT: - case O_RDWR|O_CREAT|O_TRUNC: - { - e = xosfind_openout(SKIP, name, SKIP, &file); - break; - } - case O_RDWR: - { - e = xosfind_openup(SKIP, name, SKIP, &file); - break; - } - } - if (e) - { - file = (os_f) -1; - } - return (file); -} - -extern int close(int fd) -{ - return ((int) xosfind_close((os_f) fd)); -} - -extern int write(int fd, const char *buf, int nbytes) -{ - /* Returns number of bytes written */ - return (nbytes - osgbpb_write((os_f) fd, (const byte*) buf, nbytes)); -} - -extern int read(int fd, char *buf, int nbytes) -{ - /* Returns number of bytes read */ - return (nbytes - osgbpb_read((os_f) fd, (byte*) buf, nbytes)); -} - -extern off_t lseek(int fd, off_t offset, int whence) -{ - int absolute = 0; - - switch (whence) - { - case SEEK_SET: - { - absolute = (int) offset; - break; - } - case SEEK_CUR: - { - absolute = osargs_read_ptr((os_f) fd) + (int) offset; - break; - } - case SEEK_END: - { - absolute = osargs_read_ext((os_f) fd) + (int) offset; - break; - } - } - - osargs_set_ptr((os_f) fd, absolute); - - return ((off_t) osargs_read_ptr((os_f) fd)); -} -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) read((int) fd, buf, (size_t) size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) write((int) fd, buf, (size_t) size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - return (lseek((int) fd, SEEK_END, SEEK_SET)); -} - -#ifdef HAVE_MMAP -#error "I didn't know Acorn had that!" -#endif - -/* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; (void) pbase; (void) psize; - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; (void) base; (void) size; -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - _tiffMapProc, _tiffUnmapProc); - if (tif) - { - tif->tif_fd = fd; - } - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - - if (m == -1) - { - return ((TIFF*) 0); - } - - fd = open(name, 0, m); - - if (fd < 0) - { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF *)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -void* -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -void* -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -acornWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - { - fprintf(stderr, "%s: ", module); - } - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = acornWarningHandler; - -static void -acornErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - { - fprintf(stderr, "%s: ", module); - } - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = acornErrorHandler; diff --git a/libs/tiff-3.8.2/libtiff/tif_apple.c b/libs/tiff-3.8.2/libtiff/tif_apple.c deleted file mode 100644 index 47e0e0767f..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_apple.c +++ /dev/null @@ -1,274 +0,0 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_apple.c,v 1.3 2005/12/21 12:23:13 joris Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Macintosh-specific routines. - * - * These routines use only Toolbox and high-level File Manager traps. - * They make no calls to the THINK C "unix" compatibility library. Also, - * malloc is not used directly but it is still referenced internally by - * the ANSI library in rare cases. Heap fragmentation by the malloc ring - * buffer is therefore minimized. - * - * O_RDONLY and O_RDWR are treated identically here. The tif_mode flag is - * checked in TIFFWriteCheck(). - * - * Create below fills in a blank creator signature and sets the file type - * to 'TIFF'. It is much better for the application to do this by Create'ing - * the file first and TIFFOpen'ing it later. - * --------- - * This code has been "Carbonized", and may not work with older MacOS versions. - * If so, grab the tif_apple.c out of an older libtiff distribution, like - * 3.5.5 from www.libtiff.org. - */ - -#include "tiffiop.h" -#include -#include -#include -#include - -#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec) -#define CtoPstr c2pstr -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (FSRead((short) fd, (long*) &size, (char*) buf) == noErr ? - size : (tsize_t) -1); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ? - size : (tsize_t) -1); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - long fpos, size; - - if (GetEOF((short) fd, &size) != noErr) - return EOF; - (void) GetFPos((short) fd, &fpos); - - switch (whence) { - case SEEK_CUR: - if (off + fpos > size) - SetEOF((short) fd, off + fpos); - if (SetFPos((short) fd, fsFromMark, off) != noErr) - return EOF; - break; - case SEEK_END: - if (off > 0) - SetEOF((short) fd, off + size); - if (SetFPos((short) fd, fsFromStart, off + size) != noErr) - return EOF; - break; - case SEEK_SET: - if (off > size) - SetEOF((short) fd, off); - if (SetFPos((short) fd, fsFromStart, off) != noErr) - return EOF; - break; - } - - return (toff_t)(GetFPos((short) fd, &fpos) == noErr ? fpos : EOF); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (FSClose((short) fd)); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - long size; - - if (GetEOF((short) fd, &size) != noErr) { - TIFFErrorExt(fd, "_tiffSizeProc", "%s: Cannot get file size"); - return (-1L); - } - return ((toff_t) size); -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -static void ourc2pstr( char* inString ) -{ - int sLen = strlen( inString ); - BlockMoveData( inString, &inString[1], sLen ); - inString[0] = sLen; -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - Str255 pname; - FInfo finfo; - short fref; - OSErr err; - FSSpec fSpec; - - strcpy((char*) pname, name); - ourc2pstr((char*) pname); - - err = FSMakeFSSpec( 0, 0, pname, &fSpec ); - - switch (_TIFFgetMode(mode, module)) { - default: - return ((TIFF*) 0); - case O_RDWR | O_CREAT | O_TRUNC: - if (FSpGetFInfo(&fSpec, &finfo) == noErr) - FSpDelete(&fSpec); - /* fall through */ - case O_RDWR | O_CREAT: - if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) { - if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr) - goto badCreate; - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - } else if (err == noErr) { - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - } else - goto badOpen; - break; - case O_RDONLY: - if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr) - goto badOpen; - break; - case O_RDWR: - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - break; - } - return (TIFFFdOpen((int) fref, name, mode)); -badCreate: - TIFFErrorExt(0, module, "%s: Cannot create", name); - return ((TIFF*) 0); -badOpen: - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*) 0); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (NewPtr((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - DisposePtr(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - Ptr n = p; - - SetPtrSize(p, (size_t) s); - if (MemError() && (n = NewPtr((size_t) s)) != NULL) { - BlockMove(p, n, GetPtrSize(p)); - DisposePtr(p); - } - return ((tdata_t) n); -} - -static void -appleWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler; - -static void -appleErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler; diff --git a/libs/tiff-3.8.2/libtiff/tif_atari.c b/libs/tiff-3.8.2/libtiff/tif_atari.c deleted file mode 100644 index a519fa4426..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_atari.c +++ /dev/null @@ -1,243 +0,0 @@ -/* "$Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_atari.c,v 1.2 2005/12/21 12:23:13 joris Exp $" */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library ATARI-specific Routines. - */ -#include "tiffiop.h" -#if defined(__TURBOC__) -#include -#include -#else -#include -#include -#endif - -#ifndef O_ACCMODE -#define O_ACCMODE 3 -#endif - -#include - -#define AEFILNF -33 - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - long r; - - r = Fread((int) fd, size, buf); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return r; -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - long r; - - r = Fwrite((int) fd, size, buf); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return r; -} - -static toff_t -_tiffSeekProc(thandle_t fd, off_t off, int whence) -{ - char buf[256]; - long current_off, expected_off, new_off; - - if (whence == SEEK_END || off <= 0) - return Fseek(off, (int) fd, whence); - current_off = Fseek(0, (int) fd, SEEK_CUR); /* find out where we are */ - if (whence == SEEK_SET) - expected_off = off; - else - expected_off = off + current_off; - new_off = Fseek(off, (int) fd, whence); - if (new_off == expected_off) - return new_off; - /* otherwise extend file -- zero filling the hole */ - if (new_off < 0) /* error? */ - new_off = Fseek(0, (int) fd, SEEK_END); /* go to eof */ - _TIFFmemset(buf, 0, sizeof(buf)); - while (expected_off > new_off) { - off = expected_off - new_off; - if (off > sizeof(buf)) - off = sizeof(buf); - if ((current_off = Fwrite((int) fd, off, buf)) != off) - return (current_off > 0) ? - new_off + current_off : new_off; - new_off += off; - } - return new_off; -} - -static int -_tiffCloseProc(thandle_t fd) -{ - long r; - - r = Fclose((int) fd); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return (int)r; -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - long pos, eof; - - pos = Fseek(0, (int) fd, SEEK_CUR); - eof = Fseek(0, (int) fd, SEEK_END); - Fseek(pos, (int) fd, SEEK_SET); - return eof; -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* -* Open a TIFF file descriptor for read/writing. -*/ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* -* Open a TIFF file for read/writing. -*/ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m; - long fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m & O_TRUNC) { - fd = Fcreate(name, 0); - } else { - fd = Fopen(name, m & O_ACCMODE); - if (fd == AEFILNF && m & O_CREAT) - fd = Fcreate(name, 0); - } - if (fd < 0) - errno = (int)fd; - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -#include - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, size_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, size_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -atariWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = atariWarningHandler; - -static void -atariErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = atariErrorHandler; diff --git a/libs/tiff-3.8.2/libtiff/tif_dir.c b/libs/tiff-3.8.2/libtiff/tif_dir.c deleted file mode 100644 index 160256753e..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_dir.c +++ /dev/null @@ -1,1350 +0,0 @@ -/* $Id: tif_dir.c,v 1.72 2006/03/15 12:49:35 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Tag Get & Set Routines. - * (and also some miscellaneous stuff) - */ -#include "tiffiop.h" - -/* - * These are used in the backwards compatibility code... - */ -#define DATATYPE_VOID 0 /* !untyped data */ -#define DATATYPE_INT 1 /* !signed integer data */ -#define DATATYPE_UINT 2 /* !unsigned integer data */ -#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ - -static void -setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size) -{ - if (*vpp) - _TIFFfree(*vpp), *vpp = 0; - if (vp) { - tsize_t bytes = nmemb * elem_size; - if (elem_size && bytes / elem_size == nmemb) - *vpp = (void*) _TIFFmalloc(bytes); - if (*vpp) - _TIFFmemcpy(*vpp, vp, bytes); - } -} -void _TIFFsetByteArray(void** vpp, void* vp, uint32 n) - { setByteArray(vpp, vp, n, 1); } -void _TIFFsetString(char** cpp, char* cp) - { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); } -void _TIFFsetNString(char** cpp, char* cp, uint32 n) - { setByteArray((void**) cpp, (void*) cp, n, 1); } -void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n) - { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); } -void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n) - { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); } -void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n) - { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); } -void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n) - { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); } - -/* - * Install extra samples information. - */ -static int -setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v) -{ - uint16* va; - uint32 i; - - *v = va_arg(ap, uint32); - if ((uint16) *v > td->td_samplesperpixel) - return (0); - va = va_arg(ap, uint16*); - if (*v > 0 && va == NULL) /* typically missing param */ - return (0); - for (i = 0; i < *v; i++) - if (va[i] > EXTRASAMPLE_UNASSALPHA) - return (0); - td->td_extrasamples = (uint16) *v; - _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); - return (1); -} - -static uint32 -checkInkNamesString(TIFF* tif, uint32 slen, const char* s) -{ - TIFFDirectory* td = &tif->tif_dir; - uint16 i = td->td_samplesperpixel; - - if (slen > 0) { - const char* ep = s+slen; - const char* cp = s; - for (; i > 0; i--) { - for (; *cp != '\0'; cp++) - if (cp >= ep) - goto bad; - cp++; /* skip \0 */ - } - return (cp-s); - } -bad: - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Invalid InkNames value; expecting %d names, found %d", - tif->tif_name, - td->td_samplesperpixel, - td->td_samplesperpixel-i); - return (0); -} - -static int -_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - static const char module[] = "_TIFFVSetField"; - - TIFFDirectory* td = &tif->tif_dir; - int status = 1; - uint32 v32, i, v; - char* s; - - switch (tag) { - case TIFFTAG_SUBFILETYPE: - td->td_subfiletype = va_arg(ap, uint32); - break; - case TIFFTAG_IMAGEWIDTH: - td->td_imagewidth = va_arg(ap, uint32); - break; - case TIFFTAG_IMAGELENGTH: - td->td_imagelength = va_arg(ap, uint32); - break; - case TIFFTAG_BITSPERSAMPLE: - td->td_bitspersample = (uint16) va_arg(ap, int); - /* - * If the data require post-decoding processing to byte-swap - * samples, set it up here. Note that since tags are required - * to be ordered, compression code can override this behaviour - * in the setup method if it wants to roll the post decoding - * work in with its normal work. - */ - if (tif->tif_flags & TIFF_SWAB) { - if (td->td_bitspersample == 16) - tif->tif_postdecode = _TIFFSwab16BitData; - else if (td->td_bitspersample == 24) - tif->tif_postdecode = _TIFFSwab24BitData; - else if (td->td_bitspersample == 32) - tif->tif_postdecode = _TIFFSwab32BitData; - else if (td->td_bitspersample == 64) - tif->tif_postdecode = _TIFFSwab64BitData; - else if (td->td_bitspersample == 128) /* two 64's */ - tif->tif_postdecode = _TIFFSwab64BitData; - } - break; - case TIFFTAG_COMPRESSION: - v = va_arg(ap, uint32) & 0xffff; - /* - * If we're changing the compression scheme, the notify the - * previous module so that it can cleanup any state it's - * setup. - */ - if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { - if (td->td_compression == v) - break; - (*tif->tif_cleanup)(tif); - tif->tif_flags &= ~TIFF_CODERSETUP; - } - /* - * Setup new compression routine state. - */ - if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) - td->td_compression = (uint16) v; - else - status = 0; - break; - case TIFFTAG_PHOTOMETRIC: - td->td_photometric = (uint16) va_arg(ap, int); - break; - case TIFFTAG_THRESHHOLDING: - td->td_threshholding = (uint16) va_arg(ap, int); - break; - case TIFFTAG_FILLORDER: - v = va_arg(ap, uint32); - if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) - goto badvalue; - td->td_fillorder = (uint16) v; - break; - break; - case TIFFTAG_ORIENTATION: - v = va_arg(ap, uint32); - if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Bad value %lu for \"%s\" tag ignored", - v, _TIFFFieldWithTag(tif, tag)->field_name); - } else - td->td_orientation = (uint16) v; - break; - case TIFFTAG_SAMPLESPERPIXEL: - /* XXX should cross check -- e.g. if pallette, then 1 */ - v = va_arg(ap, uint32); - if (v == 0) - goto badvalue; - td->td_samplesperpixel = (uint16) v; - break; - case TIFFTAG_ROWSPERSTRIP: - v32 = va_arg(ap, uint32); - if (v32 == 0) - goto badvalue32; - td->td_rowsperstrip = v32; - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - td->td_tilelength = v32; - td->td_tilewidth = td->td_imagewidth; - } - break; - case TIFFTAG_MINSAMPLEVALUE: - td->td_minsamplevalue = (uint16) va_arg(ap, int); - break; - case TIFFTAG_MAXSAMPLEVALUE: - td->td_maxsamplevalue = (uint16) va_arg(ap, int); - break; - case TIFFTAG_SMINSAMPLEVALUE: - td->td_sminsamplevalue = va_arg(ap, double); - break; - case TIFFTAG_SMAXSAMPLEVALUE: - td->td_smaxsamplevalue = va_arg(ap, double); - break; - case TIFFTAG_XRESOLUTION: - td->td_xresolution = (float) va_arg(ap, double); - break; - case TIFFTAG_YRESOLUTION: - td->td_yresolution = (float) va_arg(ap, double); - break; - case TIFFTAG_PLANARCONFIG: - v = va_arg(ap, uint32); - if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) - goto badvalue; - td->td_planarconfig = (uint16) v; - break; - case TIFFTAG_XPOSITION: - td->td_xposition = (float) va_arg(ap, double); - break; - case TIFFTAG_YPOSITION: - td->td_yposition = (float) va_arg(ap, double); - break; - case TIFFTAG_RESOLUTIONUNIT: - v = va_arg(ap, uint32); - if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) - goto badvalue; - td->td_resolutionunit = (uint16) v; - break; - case TIFFTAG_PAGENUMBER: - td->td_pagenumber[0] = (uint16) va_arg(ap, int); - td->td_pagenumber[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_HALFTONEHINTS: - td->td_halftonehints[0] = (uint16) va_arg(ap, int); - td->td_halftonehints[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_COLORMAP: - v32 = (uint32)(1L<td_bitspersample); - _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); - break; - case TIFFTAG_EXTRASAMPLES: - if (!setExtraSamples(td, ap, &v)) - goto badvalue; - break; - case TIFFTAG_MATTEING: - td->td_extrasamples = (uint16) (va_arg(ap, int) != 0); - if (td->td_extrasamples) { - uint16 sv = EXTRASAMPLE_ASSOCALPHA; - _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); - } - break; - case TIFFTAG_TILEWIDTH: - v32 = va_arg(ap, uint32); - if (v32 % 16) { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile width %d, convert file", v32); - } - td->td_tilewidth = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILELENGTH: - v32 = va_arg(ap, uint32); - if (v32 % 16) { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile length %d, convert file", v32); - } - td->td_tilelength = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILEDEPTH: - v32 = va_arg(ap, uint32); - if (v32 == 0) - goto badvalue32; - td->td_tiledepth = v32; - break; - case TIFFTAG_DATATYPE: - v = va_arg(ap, uint32); - switch (v) { - case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; - case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; - case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; - case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; - default: goto badvalue; - } - td->td_sampleformat = (uint16) v; - break; - case TIFFTAG_SAMPLEFORMAT: - v = va_arg(ap, uint32); - if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) - goto badvalue; - td->td_sampleformat = (uint16) v; - - /* Try to fix up the SWAB function for complex data. */ - if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT - && td->td_bitspersample == 32 - && tif->tif_postdecode == _TIFFSwab32BitData ) - tif->tif_postdecode = _TIFFSwab16BitData; - else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT - || td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) - && td->td_bitspersample == 64 - && tif->tif_postdecode == _TIFFSwab64BitData ) - tif->tif_postdecode = _TIFFSwab32BitData; - break; - case TIFFTAG_IMAGEDEPTH: - td->td_imagedepth = va_arg(ap, uint32); - break; - case TIFFTAG_SUBIFD: - if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { - td->td_nsubifd = (uint16) va_arg(ap, int); - _TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*), - (long) td->td_nsubifd); - } else { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Sorry, cannot nest SubIFDs", - tif->tif_name); - status = 0; - } - break; - case TIFFTAG_YCBCRPOSITIONING: - td->td_ycbcrpositioning = (uint16) va_arg(ap, int); - break; - case TIFFTAG_YCBCRSUBSAMPLING: - td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int); - td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_TRANSFERFUNCTION: - v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; - for (i = 0; i < v; i++) - _TIFFsetShortArray(&td->td_transferfunction[i], - va_arg(ap, uint16*), 1L<td_bitspersample); - break; - case TIFFTAG_INKNAMES: - v = va_arg(ap, uint32); - s = va_arg(ap, char*); - v = checkInkNamesString(tif, v, s); - status = v > 0; - if( v > 0 ) { - _TIFFsetNString(&td->td_inknames, s, v); - td->td_inknameslen = v; - } - break; - default: { - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - TIFFTagValue *tv; - int tv_size, iCustom; - - /* - * This can happen if multiple images are open with different - * codecs which have private tags. The global tag information - * table may then have tags that are valid for one file but not - * the other. If the client tries to set a tag that is not valid - * for the image's codec then we'll arrive here. This - * happens, for example, when tiffcp is used to convert between - * compression schemes and codec-specific tags are blindly copied. - */ - if(fip == NULL || fip->field_bit != FIELD_CUSTOM) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Invalid %stag \"%s\" (not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - _TIFFFieldWithTag(tif, tag)->field_name); - status = 0; - break; - } - - /* - * Find the existing entry for this custom value. - */ - tv = NULL; - for(iCustom = 0; iCustom < td->td_customValueCount; iCustom++) { - if(td->td_customValues[iCustom].info == fip) { - tv = td->td_customValues + iCustom; - if(tv->value != NULL) - { - _TIFFfree(tv->value); - tv->value = NULL; - } - break; - } - } - - /* - * Grow the custom list if the entry was not found. - */ - if(tv == NULL) { - TIFFTagValue *new_customValues; - - td->td_customValueCount++; - new_customValues = (TIFFTagValue *) - _TIFFrealloc(td->td_customValues, - sizeof(TIFFTagValue) * td->td_customValueCount); - if (!new_customValues) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Failed to allocate space for list of custom values", - tif->tif_name); - status = 0; - goto end; - } - - td->td_customValues = new_customValues; - - tv = td->td_customValues + (td->td_customValueCount-1); - tv->info = fip; - tv->value = NULL; - tv->count = 0; - } - - /* - * Set custom value ... save a copy of the custom tag value. - */ - tv_size = _TIFFDataSize(fip->field_type); - if (tv_size == 0) { - status = 0; - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad field type %d for \"%s\"", - tif->tif_name, fip->field_type, - fip->field_name); - goto end; - } - - if(fip->field_passcount) { - if (fip->field_writecount == TIFF_VARIABLE2) - tv->count = (uint32) va_arg(ap, uint32); - else - tv->count = (int) va_arg(ap, int); - } else if (fip->field_writecount == TIFF_VARIABLE - || fip->field_writecount == TIFF_VARIABLE2) - tv->count = 1; - else if (fip->field_writecount == TIFF_SPP) - tv->count = td->td_samplesperpixel; - else - tv->count = fip->field_writecount; - - - if (fip->field_type == TIFF_ASCII) - _TIFFsetString((char **)&tv->value, va_arg(ap, char *)); - else { - tv->value = _TIFFmalloc(tv_size * tv->count); - if (!tv->value) { - status = 0; - goto end; - } - - if ((fip->field_passcount - || fip->field_writecount == TIFF_VARIABLE - || fip->field_writecount == TIFF_VARIABLE2 - || fip->field_writecount == TIFF_SPP - || tv->count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - _TIFFmemcpy(tv->value, va_arg(ap, void *), - tv->count * tv_size); - } else { - /* - * XXX: The following loop required to handle - * TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS, - * TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags. - * These tags are actually arrays and should be passed as - * array pointers to TIFFSetField() function, but actually - * passed as a list of separate values. This behaviour - * must be changed in the future! - */ - int i; - char *val = (char *)tv->value; - - for (i = 0; i < tv->count; i++, val += tv_size) { - switch (fip->field_type) { - case TIFF_BYTE: - case TIFF_UNDEFINED: - { - uint8 v = (uint8)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SBYTE: - { - int8 v = (int8)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SHORT: - { - uint16 v = (uint16)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SSHORT: - { - int16 v = (int16)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_LONG: - case TIFF_IFD: - { - uint32 v = va_arg(ap, uint32); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SLONG: - { - int32 v = va_arg(ap, int32); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { - float v = (float)va_arg(ap, double); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_DOUBLE: - { - double v = va_arg(ap, double); - _TIFFmemcpy(val, &v, tv_size); - } - break; - default: - _TIFFmemset(val, 0, tv_size); - status = 0; - break; - } - } - } - } - } - } - if (status) { - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } - -end: - va_end(ap); - return (status); -badvalue: - TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %d for \"%s\"", - tif->tif_name, v, _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -badvalue32: - TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %ld for \"%s\"", - tif->tif_name, v32, _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -} - -/* - * Return 1/0 according to whether or not - * it is permissible to set the tag's value. - * Note that we allow ImageLength to be changed - * so that we can append and extend to images. - * Any other tag may not be altered once writing - * has commenced, unless its value has no effect - * on the format of the data that is written. - */ -static int -OkToChangeTag(TIFF* tif, ttag_t tag) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - if (!fip) { /* unknown tag */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); - return (0); - } - if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && - !fip->field_oktochange) { - /* - * Consult info table to see if tag can be changed - * after we've started writing. We only allow changes - * to those tags that don't/shouldn't affect the - * compression and/or format of the data. - */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Cannot modify tag \"%s\" while writing", - tif->tif_name, fip->field_name); - return (0); - } - return (1); -} - -/* - * Record the value of a field in the - * internal directory structure. The - * field will be written to the file - * when/if the directory structure is - * updated. - */ -int -TIFFSetField(TIFF* tif, ttag_t tag, ...) -{ - va_list ap; - int status; - - va_start(ap, tag); - status = TIFFVSetField(tif, tag, ap); - va_end(ap); - return (status); -} - -/* - * Like TIFFSetField, but taking a varargs - * parameter list. This routine is useful - * for building higher-level interfaces on - * top of the library. - */ -int -TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - return OkToChangeTag(tif, tag) ? - (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0; -} - -static int -_TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFDirectory* td = &tif->tif_dir; - int ret_val = 1; - - switch (tag) { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32*) = td->td_subfiletype; - break; - case TIFFTAG_IMAGEWIDTH: - *va_arg(ap, uint32*) = td->td_imagewidth; - break; - case TIFFTAG_IMAGELENGTH: - *va_arg(ap, uint32*) = td->td_imagelength; - break; - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16*) = td->td_bitspersample; - break; - case TIFFTAG_COMPRESSION: - *va_arg(ap, uint16*) = td->td_compression; - break; - case TIFFTAG_PHOTOMETRIC: - *va_arg(ap, uint16*) = td->td_photometric; - break; - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16*) = td->td_threshholding; - break; - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16*) = td->td_fillorder; - break; - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16*) = td->td_orientation; - break; - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16*) = td->td_samplesperpixel; - break; - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32*) = td->td_rowsperstrip; - break; - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_minsamplevalue; - break; - case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_maxsamplevalue; - break; - case TIFFTAG_SMINSAMPLEVALUE: - *va_arg(ap, double*) = td->td_sminsamplevalue; - break; - case TIFFTAG_SMAXSAMPLEVALUE: - *va_arg(ap, double*) = td->td_smaxsamplevalue; - break; - case TIFFTAG_XRESOLUTION: - *va_arg(ap, float*) = td->td_xresolution; - break; - case TIFFTAG_YRESOLUTION: - *va_arg(ap, float*) = td->td_yresolution; - break; - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16*) = td->td_planarconfig; - break; - case TIFFTAG_XPOSITION: - *va_arg(ap, float*) = td->td_xposition; - break; - case TIFFTAG_YPOSITION: - *va_arg(ap, float*) = td->td_yposition; - break; - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16*) = td->td_resolutionunit; - break; - case TIFFTAG_PAGENUMBER: - *va_arg(ap, uint16*) = td->td_pagenumber[0]; - *va_arg(ap, uint16*) = td->td_pagenumber[1]; - break; - case TIFFTAG_HALFTONEHINTS: - *va_arg(ap, uint16*) = td->td_halftonehints[0]; - *va_arg(ap, uint16*) = td->td_halftonehints[1]; - break; - case TIFFTAG_COLORMAP: - *va_arg(ap, uint16**) = td->td_colormap[0]; - *va_arg(ap, uint16**) = td->td_colormap[1]; - *va_arg(ap, uint16**) = td->td_colormap[2]; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - *va_arg(ap, uint32**) = td->td_stripoffset; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - *va_arg(ap, uint32**) = td->td_stripbytecount; - break; - case TIFFTAG_MATTEING: - *va_arg(ap, uint16*) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - break; - case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16*) = td->td_extrasamples; - *va_arg(ap, uint16**) = td->td_sampleinfo; - break; - case TIFFTAG_TILEWIDTH: - *va_arg(ap, uint32*) = td->td_tilewidth; - break; - case TIFFTAG_TILELENGTH: - *va_arg(ap, uint32*) = td->td_tilelength; - break; - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32*) = td->td_tiledepth; - break; - case TIFFTAG_DATATYPE: - switch (td->td_sampleformat) { - case SAMPLEFORMAT_UINT: - *va_arg(ap, uint16*) = DATATYPE_UINT; - break; - case SAMPLEFORMAT_INT: - *va_arg(ap, uint16*) = DATATYPE_INT; - break; - case SAMPLEFORMAT_IEEEFP: - *va_arg(ap, uint16*) = DATATYPE_IEEEFP; - break; - case SAMPLEFORMAT_VOID: - *va_arg(ap, uint16*) = DATATYPE_VOID; - break; - } - break; - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16*) = td->td_sampleformat; - break; - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32*) = td->td_imagedepth; - break; - case TIFFTAG_SUBIFD: - *va_arg(ap, uint16*) = td->td_nsubifd; - *va_arg(ap, uint32**) = td->td_subifd; - break; - case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16*) = td->td_ycbcrpositioning; - break; - case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; - break; - case TIFFTAG_TRANSFERFUNCTION: - *va_arg(ap, uint16**) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, uint16**) = td->td_transferfunction[1]; - *va_arg(ap, uint16**) = td->td_transferfunction[2]; - } - break; - case TIFFTAG_INKNAMES: - *va_arg(ap, char**) = td->td_inknames; - break; - default: - { - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - int i; - - /* - * This can happen if multiple images are open with - * different codecs which have private tags. The - * global tag information table may then have tags - * that are valid for one file but not the other. - * If the client tries to get a tag that is not valid - * for the image's codec then we'll arrive here. - */ - if( fip == NULL || fip->field_bit != FIELD_CUSTOM ) - { - TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField", - "%s: Invalid %stag \"%s\" (not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - _TIFFFieldWithTag(tif, tag)->field_name); - ret_val = 0; - break; - } - - /* - * Do we have a custom value? - */ - ret_val = 0; - for (i = 0; i < td->td_customValueCount; i++) { - TIFFTagValue *tv = td->td_customValues + i; - - if (tv->info->field_tag != tag) - continue; - - if (fip->field_passcount) { - if (fip->field_readcount == TIFF_VARIABLE2) - *va_arg(ap, uint32*) = (uint32)tv->count; - else /* Assume TIFF_VARIABLE */ - *va_arg(ap, uint16*) = (uint16)tv->count; - *va_arg(ap, void **) = tv->value; - ret_val = 1; - } else { - if ((fip->field_type == TIFF_ASCII - || fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2 - || fip->field_readcount == TIFF_SPP - || tv->count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - *va_arg(ap, void **) = tv->value; - ret_val = 1; - } else { - int j; - char *val = (char *)tv->value; - - for (j = 0; j < tv->count; - j++, val += _TIFFDataSize(tv->info->field_type)) { - switch (fip->field_type) { - case TIFF_BYTE: - case TIFF_UNDEFINED: - *va_arg(ap, uint8*) = - *(uint8 *)val; - ret_val = 1; - break; - case TIFF_SBYTE: - *va_arg(ap, int8*) = - *(int8 *)val; - ret_val = 1; - break; - case TIFF_SHORT: - *va_arg(ap, uint16*) = - *(uint16 *)val; - ret_val = 1; - break; - case TIFF_SSHORT: - *va_arg(ap, int16*) = - *(int16 *)val; - ret_val = 1; - break; - case TIFF_LONG: - case TIFF_IFD: - *va_arg(ap, uint32*) = - *(uint32 *)val; - ret_val = 1; - break; - case TIFF_SLONG: - *va_arg(ap, int32*) = - *(int32 *)val; - ret_val = 1; - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - *va_arg(ap, float*) = - *(float *)val; - ret_val = 1; - break; - case TIFF_DOUBLE: - *va_arg(ap, double*) = - *(double *)val; - ret_val = 1; - break; - default: - ret_val = 0; - break; - } - } - } - } - break; - } - } - } - return(ret_val); -} - -/* - * Return the value of a field in the - * internal directory structure. - */ -int -TIFFGetField(TIFF* tif, ttag_t tag, ...) -{ - int status; - va_list ap; - - va_start(ap, tag); - status = TIFFVGetField(tif, tag, ap); - va_end(ap); - return (status); -} - -/* - * Like TIFFGetField, but taking a varargs - * parameter list. This routine is useful - * for building higher-level interfaces on - * top of the library. - */ -int -TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? - (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0); -} - -#define CleanupField(member) { \ - if (td->member) { \ - _TIFFfree(td->member); \ - td->member = 0; \ - } \ -} - -/* - * Release storage associated with a directory. - */ -void -TIFFFreeDirectory(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - int i; - - _TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS); - CleanupField(td_colormap[0]); - CleanupField(td_colormap[1]); - CleanupField(td_colormap[2]); - CleanupField(td_sampleinfo); - CleanupField(td_subifd); - CleanupField(td_inknames); - CleanupField(td_transferfunction[0]); - CleanupField(td_transferfunction[1]); - CleanupField(td_transferfunction[2]); - CleanupField(td_stripoffset); - CleanupField(td_stripbytecount); - TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING); - TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING); - - /* Cleanup custom tag values */ - for( i = 0; i < td->td_customValueCount; i++ ) { - if (td->td_customValues[i].value) - _TIFFfree(td->td_customValues[i].value); - } - - td->td_customValueCount = 0; - CleanupField(td_customValues); -} -#undef CleanupField - -/* - * Client Tag extension support (from Niles Ritter). - */ -static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; - -TIFFExtendProc -TIFFSetTagExtender(TIFFExtendProc extender) -{ - TIFFExtendProc prev = _TIFFextender; - _TIFFextender = extender; - return (prev); -} - -/* - * Setup for a new directory. Should we automatically call - * TIFFWriteDirectory() if the current one is dirty? - * - * The newly created directory will not exist on the file till - * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called. - */ -int -TIFFCreateDirectory(TIFF* tif) -{ - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; - tif->tif_nextdiroff = 0; - tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - - return 0; -} - -/* - * Setup a default directory structure. - */ -int -TIFFDefaultDirectory(TIFF* tif) -{ - register TIFFDirectory* td = &tif->tif_dir; - - size_t tiffFieldInfoCount; - const TIFFFieldInfo *tiffFieldInfo = - _TIFFGetFieldInfo(&tiffFieldInfoCount); - _TIFFSetupFieldInfo(tif, tiffFieldInfo, tiffFieldInfoCount); - - _TIFFmemset(td, 0, sizeof (*td)); - td->td_fillorder = FILLORDER_MSB2LSB; - td->td_bitspersample = 1; - td->td_threshholding = THRESHHOLD_BILEVEL; - td->td_orientation = ORIENTATION_TOPLEFT; - td->td_samplesperpixel = 1; - td->td_rowsperstrip = (uint32) -1; - td->td_tilewidth = 0; - td->td_tilelength = 0; - td->td_tiledepth = 1; - td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ - td->td_resolutionunit = RESUNIT_INCH; - td->td_sampleformat = SAMPLEFORMAT_UINT; - td->td_imagedepth = 1; - td->td_ycbcrsubsampling[0] = 2; - td->td_ycbcrsubsampling[1] = 2; - td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; - tif->tif_postdecode = _TIFFNoPostDecode; - tif->tif_foundfield = NULL; - tif->tif_tagmethods.vsetfield = _TIFFVSetField; - tif->tif_tagmethods.vgetfield = _TIFFVGetField; - tif->tif_tagmethods.printdir = NULL; - /* - * Give client code a chance to install their own - * tag extensions & methods, prior to compression overloads. - */ - if (_TIFFextender) - (*_TIFFextender)(tif); - (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * NB: The directory is marked dirty as a result of setting - * up the default compression scheme. However, this really - * isn't correct -- we want TIFF_DIRTYDIRECT to be set only - * if the user does something. We could just do the setup - * by hand, but it seems better to use the normal mechanism - * (i.e. TIFFSetField). - */ - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - - /* - * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 - * we clear the ISTILED flag when setting up a new directory. - * Should we also be clearing stuff like INSUBIFD? - */ - tif->tif_flags &= ~TIFF_ISTILED; - - return (1); -} - -static int -TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off) -{ - static const char module[] = "TIFFAdvanceDirectory"; - uint16 dircount; - if (isMapped(tif)) - { - toff_t poff=*nextdir; - if (poff+sizeof(uint16) > tif->tif_size) - { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - _TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry); - if (off != NULL) - *off = poff; - if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size) - { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - _TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdir); - return (1); - } - else - { - if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - if (off != NULL) - *off = TIFFSeekFile(tif, - dircount*sizeof (TIFFDirEntry), SEEK_CUR); - else - (void) TIFFSeekFile(tif, - dircount*sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, nextdir, sizeof (uint32))) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdir); - return (1); - } -} - -/* - * Count the number of directories in a file. - */ -tdir_t -TIFFNumberOfDirectories(TIFF* tif) -{ - toff_t nextdir = tif->tif_header.tiff_diroff; - tdir_t n = 0; - - while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL)) - n++; - return (n); -} - -/* - * Set the n-th directory as the current directory. - * NB: Directories are numbered starting at 0. - */ -int -TIFFSetDirectory(TIFF* tif, tdir_t dirn) -{ - toff_t nextdir; - tdir_t n; - - nextdir = tif->tif_header.tiff_diroff; - for (n = dirn; n > 0 && nextdir != 0; n--) - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) - return (0); - tif->tif_nextdiroff = nextdir; - /* - * Set curdir to the actual directory index. The - * -1 is because TIFFReadDirectory will increment - * tif_curdir after successfully reading the directory. - */ - tif->tif_curdir = (dirn - n) - 1; - /* - * Reset tif_dirnumber counter and start new list of seen directories. - * We need this to prevent IFD loops. - */ - tif->tif_dirnumber = 0; - return (TIFFReadDirectory(tif)); -} - -/* - * Set the current directory to be the directory - * located at the specified file offset. This interface - * is used mainly to access directories linked with - * the SubIFD tag (e.g. thumbnail images). - */ -int -TIFFSetSubDirectory(TIFF* tif, uint32 diroff) -{ - tif->tif_nextdiroff = diroff; - /* - * Reset tif_dirnumber counter and start new list of seen directories. - * We need this to prevent IFD loops. - */ - tif->tif_dirnumber = 0; - return (TIFFReadDirectory(tif)); -} - -/* - * Return file offset of the current directory. - */ -uint32 -TIFFCurrentDirOffset(TIFF* tif) -{ - return (tif->tif_diroff); -} - -/* - * Return an indication of whether or not we are - * at the last directory in the file. - */ -int -TIFFLastDirectory(TIFF* tif) -{ - return (tif->tif_nextdiroff == 0); -} - -/* - * Unlink the specified directory from the directory chain. - */ -int -TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) -{ - static const char module[] = "TIFFUnlinkDirectory"; - toff_t nextdir; - toff_t off; - tdir_t n; - - if (tif->tif_mode == O_RDONLY) { - TIFFErrorExt(tif->tif_clientdata, module, - "Can not unlink directory in read-only file"); - return (0); - } - /* - * Go to the directory before the one we want - * to unlink and nab the offset of the link - * field we'll need to patch. - */ - nextdir = tif->tif_header.tiff_diroff; - off = sizeof (uint16) + sizeof (uint16); - for (n = dirn-1; n > 0; n--) { - if (nextdir == 0) { - TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); - return (0); - } - if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) - return (0); - } - /* - * Advance to the directory to be unlinked and fetch - * the offset of the directory that follows. - */ - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) - return (0); - /* - * Go back and patch the link field of the preceding - * directory to point to the offset of the directory - * that follows. - */ - (void) TIFFSeekFile(tif, off, SEEK_SET); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - if (!WriteOK(tif, &nextdir, sizeof (uint32))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); - return (0); - } - /* - * Leave directory state setup safely. We don't have - * facilities for doing inserting and removing directories, - * so it's safest to just invalidate everything. This - * means that the caller can only append to the directory - * chain. - */ - (*tif->tif_cleanup)(tif); - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE); - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; /* force link on next write */ - tif->tif_nextdiroff = 0; /* next write must be at end */ - tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - return (1); -} - -/* [BFC] - * - * Author: Bruce Cameron - * - * Set a table of tags that are to be replaced during directory process by the - * 'IGNORE' state - or return TRUE/FALSE for the requested tag such that - * 'ReadDirectory' can use the stored information. - * - * FIXME: this is never used properly. Should be removed in the future. - */ -int -TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID) -{ - static int TIFFignoretags [FIELD_LAST]; - static int tagcount = 0 ; - int i; /* Loop index */ - int j; /* Loop index */ - - switch (task) - { - case TIS_STORE: - if ( tagcount < (FIELD_LAST - 1) ) - { - for ( j = 0 ; j < tagcount ; ++j ) - { /* Do not add duplicate tag */ - if ( TIFFignoretags [j] == TIFFtagID ) - return (TRUE) ; - } - TIFFignoretags [tagcount++] = TIFFtagID ; - return (TRUE) ; - } - break ; - - case TIS_EXTRACT: - for ( i = 0 ; i < tagcount ; ++i ) - { - if ( TIFFignoretags [i] == TIFFtagID ) - return (TRUE) ; - } - break; - - case TIS_EMPTY: - tagcount = 0 ; /* Clear the list */ - return (TRUE) ; - - default: - break; - } - - return (FALSE); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_dir.h b/libs/tiff-3.8.2/libtiff/tif_dir.h deleted file mode 100644 index 13048c296d..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_dir.h +++ /dev/null @@ -1,199 +0,0 @@ -/* $Id: tif_dir.h,v 1.28 2005/12/26 14:31:25 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFDIR_ -#define _TIFFDIR_ -/* - * ``Library-private'' Directory-related Definitions. - */ - -/* - * Internal format of a TIFF directory entry. - */ -typedef struct { -#define FIELD_SETLONGS 4 - /* bit vector of fields that are set */ - unsigned long td_fieldsset[FIELD_SETLONGS]; - - uint32 td_imagewidth, td_imagelength, td_imagedepth; - uint32 td_tilewidth, td_tilelength, td_tiledepth; - uint32 td_subfiletype; - uint16 td_bitspersample; - uint16 td_sampleformat; - uint16 td_compression; - uint16 td_photometric; - uint16 td_threshholding; - uint16 td_fillorder; - uint16 td_orientation; - uint16 td_samplesperpixel; - uint32 td_rowsperstrip; - uint16 td_minsamplevalue, td_maxsamplevalue; - double td_sminsamplevalue, td_smaxsamplevalue; - float td_xresolution, td_yresolution; - uint16 td_resolutionunit; - uint16 td_planarconfig; - float td_xposition, td_yposition; - uint16 td_pagenumber[2]; - uint16* td_colormap[3]; - uint16 td_halftonehints[2]; - uint16 td_extrasamples; - uint16* td_sampleinfo; - tstrip_t td_stripsperimage; - tstrip_t td_nstrips; /* size of offset & bytecount arrays */ - uint32* td_stripoffset; - uint32* td_stripbytecount; - int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ - uint16 td_nsubifd; - uint32* td_subifd; - /* YCbCr parameters */ - uint16 td_ycbcrsubsampling[2]; - uint16 td_ycbcrpositioning; - /* Colorimetry parameters */ - uint16* td_transferfunction[3]; - /* CMYK parameters */ - int td_inknameslen; - char* td_inknames; - - int td_customValueCount; - TIFFTagValue *td_customValues; -} TIFFDirectory; - -/* - * Field flags used to indicate fields that have - * been set in a directory, and to reference fields - * when manipulating a directory. - */ - -/* - * FIELD_IGNORE is used to signify tags that are to - * be processed but otherwise ignored. This permits - * antiquated tags to be quietly read and discarded. - * Note that a bit *is* allocated for ignored tags; - * this is understood by the directory reading logic - * which uses this fact to avoid special-case handling - */ -#define FIELD_IGNORE 0 - -/* multi-item fields */ -#define FIELD_IMAGEDIMENSIONS 1 -#define FIELD_TILEDIMENSIONS 2 -#define FIELD_RESOLUTION 3 -#define FIELD_POSITION 4 - -/* single-item fields */ -#define FIELD_SUBFILETYPE 5 -#define FIELD_BITSPERSAMPLE 6 -#define FIELD_COMPRESSION 7 -#define FIELD_PHOTOMETRIC 8 -#define FIELD_THRESHHOLDING 9 -#define FIELD_FILLORDER 10 -#define FIELD_ORIENTATION 15 -#define FIELD_SAMPLESPERPIXEL 16 -#define FIELD_ROWSPERSTRIP 17 -#define FIELD_MINSAMPLEVALUE 18 -#define FIELD_MAXSAMPLEVALUE 19 -#define FIELD_PLANARCONFIG 20 -#define FIELD_RESOLUTIONUNIT 22 -#define FIELD_PAGENUMBER 23 -#define FIELD_STRIPBYTECOUNTS 24 -#define FIELD_STRIPOFFSETS 25 -#define FIELD_COLORMAP 26 -#define FIELD_EXTRASAMPLES 31 -#define FIELD_SAMPLEFORMAT 32 -#define FIELD_SMINSAMPLEVALUE 33 -#define FIELD_SMAXSAMPLEVALUE 34 -#define FIELD_IMAGEDEPTH 35 -#define FIELD_TILEDEPTH 36 -#define FIELD_HALFTONEHINTS 37 -#define FIELD_YCBCRSUBSAMPLING 39 -#define FIELD_YCBCRPOSITIONING 40 -#define FIELD_TRANSFERFUNCTION 44 -#define FIELD_INKNAMES 46 -#define FIELD_SUBIFD 49 -/* FIELD_CUSTOM (see tiffio.h) 65 */ -/* end of support for well-known tags; codec-private tags follow */ -#define FIELD_CODEC 66 /* base of codec-private tags */ - - -/* - * Pseudo-tags don't normally need field bits since they - * are not written to an output file (by definition). - * The library also has express logic to always query a - * codec for a pseudo-tag so allocating a field bit for - * one is a waste. If codec wants to promote the notion - * of a pseudo-tag being ``set'' or ``unset'' then it can - * do using internal state flags without polluting the - * field bit space defined for real tags. - */ -#define FIELD_PSEUDO 0 - -#define FIELD_LAST (32*FIELD_SETLONGS-1) - -#define TIFFExtractData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ - (v) & (tif)->tif_typemask[type])) -#define TIFFInsertData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ - (v) & (tif)->tif_typemask[type])) - - -#define BITn(n) (((unsigned long)1L)<<((n)&0x1f)) -#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) -#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) -#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) -#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) - -#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) -#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) - -#if defined(__cplusplus) -extern "C" { -#endif -extern const TIFFFieldInfo *_TIFFGetFieldInfo(size_t *); -extern const TIFFFieldInfo *_TIFFGetExifFieldInfo(size_t *); -extern void _TIFFSetupFieldInfo(TIFF*, const TIFFFieldInfo[], size_t); -extern void _TIFFPrintFieldInfo(TIFF*, FILE*); -extern TIFFDataType _TIFFSampleToTagType(TIFF*); -extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif, - ttag_t tag, - TIFFDataType dt ); -extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag, - TIFFDataType dt ); - -#define _TIFFMergeFieldInfo TIFFMergeFieldInfo -#define _TIFFFindFieldInfo TIFFFindFieldInfo -#define _TIFFFindFieldInfoByName TIFFFindFieldInfoByName -#define _TIFFFieldWithTag TIFFFieldWithTag -#define _TIFFFieldWithName TIFFFieldWithName - -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFDIR_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_dirinfo.c b/libs/tiff-3.8.2/libtiff/tif_dirinfo.c deleted file mode 100644 index c22178f78d..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_dirinfo.c +++ /dev/null @@ -1,846 +0,0 @@ -/* $Id: tif_dirinfo.c,v 1.62 2006/02/07 10:45:38 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Core Directory Tag Support. - */ -#include "tiffiop.h" -#include - -/* - * NB: NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. - * If a tag can have both LONG and SHORT types then the LONG must be - * placed before the SHORT for writing to work properly. - * - * NOTE: The second field (field_readcount) and third field (field_writecount) - * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3) - * and TIFFTAG_SPP (-2). The macros should be used but would throw off - * the formatting of the code, so please interprete the -1, -2 and -3 - * values accordingly. - */ -static const TIFFFieldInfo -tiffFieldInfo[] = { - { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, FIELD_SUBFILETYPE, - 1, 0, "SubfileType" }, -/* XXX SHORT for compatibility w/ old versions of the library */ - { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, - 1, 0, "SubfileType" }, - { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, - 1, 0, "OldSubfileType" }, - { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, - 0, 0, "ImageWidth" }, - { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, - 0, 0, "ImageWidth" }, - { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, - 1, 0, "ImageLength" }, - { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, - 1, 0, "ImageLength" }, - { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_SHORT, FIELD_BITSPERSAMPLE, - 0, 0, "BitsPerSample" }, -/* XXX LONG for compatibility with some broken TIFF writers */ - { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_LONG, FIELD_BITSPERSAMPLE, - 0, 0, "BitsPerSample" }, - { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, FIELD_COMPRESSION, - 0, 0, "Compression" }, -/* XXX LONG for compatibility with some broken TIFF writers */ - { TIFFTAG_COMPRESSION, -1, 1, TIFF_LONG, FIELD_COMPRESSION, - 0, 0, "Compression" }, - { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, FIELD_PHOTOMETRIC, - 0, 0, "PhotometricInterpretation" }, -/* XXX LONG for compatibility with some broken TIFF writers */ - { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_LONG, FIELD_PHOTOMETRIC, - 0, 0, "PhotometricInterpretation" }, - { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, FIELD_THRESHHOLDING, - 1, 0, "Threshholding" }, - { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "CellWidth" }, - { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "CellLength" }, - { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, FIELD_FILLORDER, - 0, 0, "FillOrder" }, - { TIFFTAG_DOCUMENTNAME, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DocumentName" }, - { TIFFTAG_IMAGEDESCRIPTION, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "ImageDescription" }, - { TIFFTAG_MAKE, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Make" }, - { TIFFTAG_MODEL, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Model" }, - { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_LONG, FIELD_STRIPOFFSETS, - 0, 0, "StripOffsets" }, - { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_SHORT, FIELD_STRIPOFFSETS, - 0, 0, "StripOffsets" }, - { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, FIELD_ORIENTATION, - 0, 0, "Orientation" }, - { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, FIELD_SAMPLESPERPIXEL, - 0, 0, "SamplesPerPixel" }, - { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, FIELD_ROWSPERSTRIP, - 0, 0, "RowsPerStrip" }, - { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_SHORT, FIELD_ROWSPERSTRIP, - 0, 0, "RowsPerStrip" }, - { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, - 0, 0, "StripByteCounts" }, - { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, - 0, 0, "StripByteCounts" }, - { TIFFTAG_MINSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MINSAMPLEVALUE, - 1, 0, "MinSampleValue" }, - { TIFFTAG_MAXSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MAXSAMPLEVALUE, - 1, 0, "MaxSampleValue" }, - { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, - 1, 0, "XResolution" }, - { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, - 1, 0, "YResolution" }, - { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, FIELD_PLANARCONFIG, - 0, 0, "PlanarConfiguration" }, - { TIFFTAG_PAGENAME, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "PageName" }, - { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, - 1, 0, "XPosition" }, - { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, - 1, 0, "YPosition" }, - { TIFFTAG_FREEOFFSETS, -1,-1, TIFF_LONG, FIELD_IGNORE, - 0, 0, "FreeOffsets" }, - { TIFFTAG_FREEBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_IGNORE, - 0, 0, "FreeByteCounts" }, - { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "GrayResponseUnit" }, - { TIFFTAG_GRAYRESPONSECURVE,-1,-1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "GrayResponseCurve" }, - { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_RESOLUTIONUNIT, - 1, 0, "ResolutionUnit" }, - { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, FIELD_PAGENUMBER, - 1, 0, "PageNumber" }, - { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, - 1, 0, "ColorResponseUnit" }, - { TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION, - 1, 0, "TransferFunction" }, - { TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Software" }, - { TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DateTime" }, - { TIFFTAG_ARTIST, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Artist" }, - { TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "HostComputer" }, - { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "WhitePoint" }, - { TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "PrimaryChromaticities" }, - { TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP, - 1, 0, "ColorMap" }, - { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS, - 1, 0, "HalftoneHints" }, - { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, - 0, 0, "TileWidth" }, - { TIFFTAG_TILEWIDTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, - 0, 0, "TileWidth" }, - { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, - 0, 0, "TileLength" }, - { TIFFTAG_TILELENGTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, - 0, 0, "TileLength" }, - { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG, FIELD_STRIPOFFSETS, - 0, 0, "TileOffsets" }, - { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, - 0, 0, "TileByteCounts" }, - { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, - 0, 0, "TileByteCounts" }, - { TIFFTAG_SUBIFD, -1,-1, TIFF_IFD, FIELD_SUBIFD, - 1, 1, "SubIFD" }, - { TIFFTAG_SUBIFD, -1,-1, TIFF_LONG, FIELD_SUBIFD, - 1, 1, "SubIFD" }, - { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "InkSet" }, - { TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES, - 1, 1, "InkNames" }, - { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "NumberOfInks" }, - { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "DotRange" }, - { TIFFTAG_DOTRANGE, 2, 2, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "DotRange" }, - { TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "TargetPrinter" }, - { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_EXTRASAMPLES, - 0, 1, "ExtraSamples" }, -/* XXX for bogus Adobe Photoshop v2.5 files */ - { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_BYTE, FIELD_EXTRASAMPLES, - 0, 1, "ExtraSamples" }, - { TIFFTAG_SAMPLEFORMAT, -1,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, - 0, 0, "SampleFormat" }, - { TIFFTAG_SMINSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMINSAMPLEVALUE, - 1, 0, "SMinSampleValue" }, - { TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE, - 1, 0, "SMaxSampleValue" }, - { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "ClipPath" }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, FIELD_CUSTOM, - 0, 0, "XClipPathUnits" }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SSHORT, FIELD_CUSTOM, - 0, 0, "XClipPathUnits" }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, FIELD_CUSTOM, - 0, 0, "XClipPathUnits" }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, FIELD_CUSTOM, - 0, 0, "YClipPathUnits" }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SSHORT, FIELD_CUSTOM, - 0, 0, "YClipPathUnits" }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SBYTE, FIELD_CUSTOM, - 0, 0, "YClipPathUnits" }, - { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "YCbCrCoefficients" }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING, - 0, 0, "YCbCrSubsampling" }, - { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, - 0, 0, "YCbCrPositioning" }, - { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ReferenceBlackWhite" }, -/* XXX temporarily accept LONG for backwards compatibility */ - { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "ReferenceBlackWhite" }, - { TIFFTAG_XMLPACKET, -3,-3, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "XMLPacket" }, -/* begin SGI tags */ - { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_EXTRASAMPLES, - 0, 0, "Matteing" }, - { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, - 0, 0, "DataType" }, - { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, - 0, 0, "ImageDepth" }, - { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, - 0, 0, "ImageDepth" }, - { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, - 0, 0, "TileDepth" }, - { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, - 0, 0, "TileDepth" }, -/* end SGI tags */ -/* begin Pixar tags */ - { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "ImageFullWidth" }, - { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "ImageFullLength" }, - { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "TextureFormat" }, - { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "TextureWrapModes" }, - { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, FIELD_CUSTOM, - 1, 0, "FieldOfViewCotangent" }, - { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16,16, TIFF_FLOAT, - FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen" }, - { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16,16, TIFF_FLOAT, - FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera" }, - { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "Copyright" }, -/* end Pixar tags */ - { TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, FIELD_CUSTOM, - 0, 1, "RichTIFFIPTC" }, - { TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "Photoshop" }, - { TIFFTAG_EXIFIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "EXIFIFDOffset" }, - { TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "ICC Profile" }, - { TIFFTAG_GPSIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "GPSIFDOffset" }, - { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_CUSTOM, - 0, 0, "StoNits" }, - { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "InteroperabilityIFDOffset" }, -/* begin DNG tags */ - { TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "DNGVersion" }, - { TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "DNGBackwardVersion" }, - { TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "UniqueCameraModel" }, - { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "LocalizedCameraModel" }, - { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 1, 1, "LocalizedCameraModel" }, - { TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "CFAPlaneColor" }, - { TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "CFALayout" }, - { TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 0, 1, "LinearizationTable" }, - { TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "BlackLevelRepeatDim" }, - { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_LONG, FIELD_CUSTOM, - 0, 1, "BlackLevel" }, - { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 0, 1, "BlackLevel" }, - { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 1, "BlackLevel" }, - { TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "BlackLevelDeltaH" }, - { TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "BlackLevelDeltaV" }, - { TIFFTAG_WHITELEVEL, -2, -2, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "WhiteLevel" }, - { TIFFTAG_WHITELEVEL, -2, -2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "WhiteLevel" }, - { TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "DefaultScale" }, - { TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "BestQualityScale" }, - { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "DefaultCropOrigin" }, - { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "DefaultCropOrigin" }, - { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "DefaultCropOrigin" }, - { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "DefaultCropSize" }, - { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "DefaultCropSize" }, - { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "DefaultCropSize" }, - { TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ColorMatrix1" }, - { TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ColorMatrix2" }, - { TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "CameraCalibration1" }, - { TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "CameraCalibration2" }, - { TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ReductionMatrix1" }, - { TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "ReductionMatrix2" }, - { TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 1, "AnalogBalance" }, - { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 0, 1, "AsShotNeutral" }, - { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 1, "AsShotNeutral" }, - { TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "AsShotWhiteXY" }, - { TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 0, "BaselineExposure" }, - { TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "BaselineNoise" }, - { TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "BaselineSharpness" }, - { TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "BayerGreenSplit" }, - { TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "LinearResponseLimit" }, - { TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "CameraSerialNumber" }, - { TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "LensInfo" }, - { TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "ChromaBlurRadius" }, - { TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "AntiAliasStrength" }, - { TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 0, 0, "ShadowScale" }, - { TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 0, 1, "DNGPrivateData" }, - { TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "MakerNoteSafety" }, - { TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "CalibrationIlluminant1" }, - { TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "CalibrationIlluminant2" }, - { TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, FIELD_CUSTOM, - 0, 0, "RawDataUniqueID" }, - { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "OriginalRawFileName" }, - { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, FIELD_CUSTOM, - 1, 1, "OriginalRawFileName" }, - { TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "OriginalRawFileData" }, - { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, FIELD_CUSTOM, - 0, 0, "ActiveArea" }, - { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_SHORT, FIELD_CUSTOM, - 0, 0, "ActiveArea" }, - { TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, FIELD_CUSTOM, - 0, 1, "MaskedAreas" }, - { TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "AsShotICCProfile" }, - { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "AsShotPreProfileMatrix" }, - { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 0, 1, "CurrentICCProfile" }, - { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, - 0, 1, "CurrentPreProfileMatrix" }, -/* end DNG tags */ -}; - -static const TIFFFieldInfo -exifFieldInfo[] = { - { EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ExposureTime" }, - { EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FNumber" }, - { EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "ExposureProgram" }, - { EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SpectralSensitivity" }, - { EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 1, 1, "ISOSpeedRatings" }, - { EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "OptoelectricConversionFactor" }, - { EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "ExifVersion" }, - { EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DateTimeOriginal" }, - { EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "DateTimeDigitized" }, - { EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "ComponentsConfiguration" }, - { EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "CompressedBitsPerPixel" }, - { EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 1, 0, "ShutterSpeedValue" }, - { EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ApertureValue" }, - { EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 1, 0, "BrightnessValue" }, - { EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, FIELD_CUSTOM, - 1, 0, "ExposureBiasValue" }, - { EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "MaxApertureValue" }, - { EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "SubjectDistance" }, - { EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "MeteringMode" }, - { EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "LightSource" }, - { EXIFTAG_FLASH, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Flash" }, - { EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FocalLength" }, - { EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, FIELD_CUSTOM, - 1, 1, "SubjectArea" }, - { EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "MakerNote" }, - { EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "UserComment" }, - { EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SubSecTime" }, - { EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SubSecTimeOriginal" }, - { EXIFTAG_SUBSECTIMEDIGITIZED,-1, -1, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "SubSecTimeDigitized" }, - { EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "FlashpixVersion" }, - { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "PixelXDimension" }, - { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "PixelXDimension" }, - { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, FIELD_CUSTOM, - 1, 0, "PixelYDimension" }, - { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "PixelYDimension" }, - { EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "RelatedSoundFile" }, - { EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FlashEnergy" }, - { EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "SpatialFrequencyResponse" }, - { EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FocalPlaneXResolution" }, - { EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "FocalPlaneYResolution" }, - { EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "FocalPlaneResolutionUnit" }, - { EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SubjectLocation" }, - { EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "ExposureIndex" }, - { EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SensingMethod" }, - { EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "FileSource" }, - { EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 0, "SceneType" }, - { EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "CFAPattern" }, - { EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "CustomRendered" }, - { EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "ExposureMode" }, - { EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "WhiteBalance" }, - { EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "DigitalZoomRatio" }, - { EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "FocalLengthIn35mmFilm" }, - { EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SceneCaptureType" }, - { EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, FIELD_CUSTOM, - 1, 0, "GainControl" }, - { EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Contrast" }, - { EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Saturation" }, - { EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "Sharpness" }, - { EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, FIELD_CUSTOM, - 1, 1, "DeviceSettingDescription" }, - { EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, - 1, 0, "SubjectDistanceRange" }, - { EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, FIELD_CUSTOM, - 1, 0, "ImageUniqueID" } -}; - -const TIFFFieldInfo * -_TIFFGetFieldInfo(size_t *size) -{ - *size = TIFFArrayCount(tiffFieldInfo); - return tiffFieldInfo; -} - -const TIFFFieldInfo * -_TIFFGetExifFieldInfo(size_t *size) -{ - *size = TIFFArrayCount(exifFieldInfo); - return exifFieldInfo; -} - -void -_TIFFSetupFieldInfo(TIFF* tif, const TIFFFieldInfo info[], size_t n) -{ - if (tif->tif_fieldinfo) { - size_t i; - - for (i = 0; i < tif->tif_nfields; i++) - { - TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; - if (fld->field_bit == FIELD_CUSTOM && - strncmp("Tag ", fld->field_name, 4) == 0) { - _TIFFfree(fld->field_name); - _TIFFfree(fld); - } - } - - _TIFFfree(tif->tif_fieldinfo); - tif->tif_nfields = 0; - } - _TIFFMergeFieldInfo(tif, info, n); -} - -static int -tagCompare(const void* a, const void* b) -{ - const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; - const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; - /* NB: be careful of return values for 16-bit platforms */ - if (ta->field_tag != tb->field_tag) - return (ta->field_tag < tb->field_tag ? -1 : 1); - else - return ((int)tb->field_type - (int)ta->field_type); -} - -static int -tagNameCompare(const void* a, const void* b) -{ - const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; - const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; - - return strcmp(ta->field_name, tb->field_name); -} - -void -_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) -{ - TIFFFieldInfo** tp; - int i; - - tif->tif_foundfield = NULL; - - if (tif->tif_nfields > 0) { - tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFrealloc(tif->tif_fieldinfo, - (tif->tif_nfields+n) * sizeof (TIFFFieldInfo*)); - } else { - tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFmalloc(n * sizeof (TIFFFieldInfo*)); - } - assert(tif->tif_fieldinfo != NULL); - tp = tif->tif_fieldinfo + tif->tif_nfields; - for (i = 0; i < n; i++) - *tp++ = (TIFFFieldInfo*) (info + i); /* XXX */ - - /* Sort the field info by tag number */ - qsort(tif->tif_fieldinfo, tif->tif_nfields += n, - sizeof (TIFFFieldInfo*), tagCompare); -} - -void -_TIFFPrintFieldInfo(TIFF* tif, FILE* fd) -{ - size_t i; - - fprintf(fd, "%s: \n", tif->tif_name); - for (i = 0; i < tif->tif_nfields; i++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; - fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" - , (int)i - , (unsigned long) fip->field_tag - , fip->field_readcount, fip->field_writecount - , fip->field_type - , fip->field_bit - , fip->field_oktochange ? "TRUE" : "FALSE" - , fip->field_passcount ? "TRUE" : "FALSE" - , fip->field_name - ); - } -} - -/* - * Return size of TIFFDataType in bytes - */ -int -TIFFDataWidth(TIFFDataType type) -{ - switch(type) - { - case 0: /* nothing */ - case 1: /* TIFF_BYTE */ - case 2: /* TIFF_ASCII */ - case 6: /* TIFF_SBYTE */ - case 7: /* TIFF_UNDEFINED */ - return 1; - case 3: /* TIFF_SHORT */ - case 8: /* TIFF_SSHORT */ - return 2; - case 4: /* TIFF_LONG */ - case 9: /* TIFF_SLONG */ - case 11: /* TIFF_FLOAT */ - case 13: /* TIFF_IFD */ - return 4; - case 5: /* TIFF_RATIONAL */ - case 10: /* TIFF_SRATIONAL */ - case 12: /* TIFF_DOUBLE */ - return 8; - default: - return 0; /* will return 0 for unknown types */ - } -} - -/* - * Return size of TIFFDataType in bytes. - * - * XXX: We need a separate function to determine the space needed - * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8, - * but we use 4-byte float to represent rationals. - */ -int -_TIFFDataSize(TIFFDataType type) -{ - switch (type) { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_ASCII: - case TIFF_UNDEFINED: - return 1; - case TIFF_SHORT: - case TIFF_SSHORT: - return 2; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - case TIFF_IFD: - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - return 4; - case TIFF_DOUBLE: - return 8; - default: - return 0; - } -} - -/* - * Return nearest TIFFDataType to the sample type of an image. - */ -TIFFDataType -_TIFFSampleToTagType(TIFF* tif) -{ - uint32 bps = TIFFhowmany8(tif->tif_dir.td_bitspersample); - - switch (tif->tif_dir.td_sampleformat) { - case SAMPLEFORMAT_IEEEFP: - return (bps == 4 ? TIFF_FLOAT : TIFF_DOUBLE); - case SAMPLEFORMAT_INT: - return (bps <= 1 ? TIFF_SBYTE : - bps <= 2 ? TIFF_SSHORT : TIFF_SLONG); - case SAMPLEFORMAT_UINT: - return (bps <= 1 ? TIFF_BYTE : - bps <= 2 ? TIFF_SHORT : TIFF_LONG); - case SAMPLEFORMAT_VOID: - return (TIFF_UNDEFINED); - } - /*NOTREACHED*/ - return (TIFF_UNDEFINED); -} - -const TIFFFieldInfo* -_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt) -{ - int i, n; - - if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag && - (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return (tif->tif_foundfield); - /* NB: use sorted search (e.g. binary search) */ - if(dt != TIFF_ANY) { - TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0}; - TIFFFieldInfo* pkey = &key; - const TIFFFieldInfo **ret; - - key.field_tag = tag; - key.field_type = dt; - - ret = (const TIFFFieldInfo **) bsearch(&pkey, - tif->tif_fieldinfo, - tif->tif_nfields, - sizeof(TIFFFieldInfo *), - tagCompare); - return (ret) ? (*ret) : NULL; - } else for (i = 0, n = tif->tif_nfields; i < n; i++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; - if (fip->field_tag == tag && - (dt == TIFF_ANY || fip->field_type == dt)) - return (tif->tif_foundfield = fip); - } - return ((const TIFFFieldInfo *)0); -} - -const TIFFFieldInfo* -_TIFFFindFieldInfoByName(TIFF* tif, const char *field_name, TIFFDataType dt) -{ - int i, n; - - if (tif->tif_foundfield - && streq(tif->tif_foundfield->field_name, field_name) - && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return (tif->tif_foundfield); - /* NB: use sorted search (e.g. binary search) */ - if(dt != TIFF_ANY) { - TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0}; - TIFFFieldInfo* pkey = &key; - const TIFFFieldInfo **ret; - - key.field_name = (char *)field_name; - key.field_type = dt; - - ret = (const TIFFFieldInfo **) lfind(&pkey, - tif->tif_fieldinfo, - &tif->tif_nfields, - sizeof(TIFFFieldInfo *), - tagNameCompare); - return (ret) ? (*ret) : NULL; - } else - for (i = 0, n = tif->tif_nfields; i < n; i++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; - if (streq(fip->field_name, field_name) && - (dt == TIFF_ANY || fip->field_type == dt)) - return (tif->tif_foundfield = fip); - } - return ((const TIFFFieldInfo *)0); -} - -const TIFFFieldInfo* -_TIFFFieldWithTag(TIFF* tif, ttag_t tag) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - if (!fip) { - TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag", - "Internal error, unknown tag 0x%x", - (unsigned int) tag); - assert(fip != NULL); - /*NOTREACHED*/ - } - return (fip); -} - -const TIFFFieldInfo* -_TIFFFieldWithName(TIFF* tif, const char *field_name) -{ - const TIFFFieldInfo* fip = - _TIFFFindFieldInfoByName(tif, field_name, TIFF_ANY); - if (!fip) { - TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName", - "Internal error, unknown tag %s", field_name); - assert(fip != NULL); - /*NOTREACHED*/ - } - return (fip); -} - -const TIFFFieldInfo* -_TIFFFindOrRegisterFieldInfo( TIFF *tif, ttag_t tag, TIFFDataType dt ) - -{ - const TIFFFieldInfo *fld; - - fld = _TIFFFindFieldInfo( tif, tag, dt ); - if( fld == NULL ) - { - fld = _TIFFCreateAnonFieldInfo( tif, tag, dt ); - _TIFFMergeFieldInfo( tif, fld, 1 ); - } - - return fld; -} - -TIFFFieldInfo* -_TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type) -{ - TIFFFieldInfo *fld; - (void) tif; - - fld = (TIFFFieldInfo *) _TIFFmalloc(sizeof (TIFFFieldInfo)); - if (fld == NULL) - return NULL; - _TIFFmemset( fld, 0, sizeof(TIFFFieldInfo) ); - - fld->field_tag = tag; - fld->field_readcount = TIFF_VARIABLE; - fld->field_writecount = TIFF_VARIABLE; - fld->field_type = field_type; - fld->field_bit = FIELD_CUSTOM; - fld->field_oktochange = TRUE; - fld->field_passcount = TRUE; - fld->field_name = (char *) _TIFFmalloc(32); - if (fld->field_name == NULL) { - _TIFFfree(fld); - return NULL; - } - - /* note that this name is a special sign to TIFFClose() and - * _TIFFSetupFieldInfo() to free the field - */ - sprintf(fld->field_name, "Tag %d", (int) tag); - - return fld; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_dirread.c b/libs/tiff-3.8.2/libtiff/tif_dirread.c deleted file mode 100644 index 2147e335f7..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_dirread.c +++ /dev/null @@ -1,1789 +0,0 @@ -/* $Id: tif_dirread.c,v 1.82 2006/03/16 12:24:53 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Read Support Routines. - */ -#include "tiffiop.h" - -#define IGNORE 0 /* tag placeholder used below */ - -#ifdef HAVE_IEEEFP -# define TIFFCvtIEEEFloatToNative(tif, n, fp) -# define TIFFCvtIEEEDoubleToNative(tif, n, dp) -#else -extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); -extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); -#endif - -static int EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16); -static void MissingRequired(TIFF*, const char*); -static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); -static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*); -static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*); -static float TIFFFetchRational(TIFF*, TIFFDirEntry*); -static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*); -static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchPerSampleLongs(TIFF*, TIFFDirEntry*, uint32*); -static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); -static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); -static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); -static int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*); -static int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchShortPair(TIFF*, TIFFDirEntry*); -static void ChopUpSingleUncompressedStrip(TIFF*); - -/* - * Read the next TIFF directory from a file - * and convert it to the internal format. - * We read directories sequentially. - */ -int -TIFFReadDirectory(TIFF* tif) -{ - static const char module[] = "TIFFReadDirectory"; - - int n; - TIFFDirectory* td; - TIFFDirEntry *dp, *dir = NULL; - uint16 iv; - uint32 v; - const TIFFFieldInfo* fip; - size_t fix; - uint16 dircount; - toff_t nextdiroff; - int diroutoforderwarning = 0; - toff_t* new_dirlist; - - tif->tif_diroff = tif->tif_nextdiroff; - if (tif->tif_diroff == 0) /* no more directories */ - return (0); - - /* - * XXX: Trick to prevent IFD looping. The one can create TIFF file - * with looped directory pointers. We will maintain a list of already - * seen directories and check every IFD offset against this list. - */ - for (n = 0; n < tif->tif_dirnumber; n++) { - if (tif->tif_dirlist[n] == tif->tif_diroff) - return (0); - } - tif->tif_dirnumber++; - new_dirlist = (toff_t *)_TIFFrealloc(tif->tif_dirlist, - tif->tif_dirnumber * sizeof(toff_t)); - if (!new_dirlist) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Failed to allocate space for IFD list", - tif->tif_name); - return (0); - } - tif->tif_dirlist = new_dirlist; - tif->tif_dirlist[tif->tif_dirnumber - 1] = tif->tif_diroff; - - /* - * Cleanup any previous compression state. - */ - (*tif->tif_cleanup)(tif); - tif->tif_curdir++; - nextdiroff = 0; - if (!isMapped(tif)) { - if (!SeekOK(tif, tif->tif_diroff)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error accessing TIFF directory", - tif->tif_name); - return (0); - } - if (!ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFCheckMalloc(tif, dircount, - sizeof (TIFFDirEntry), - "to read TIFF directory"); - if (dir == NULL) - return (0); - if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%.100s: Can not read TIFF directory", - tif->tif_name); - goto bad; - } - /* - * Read offset to next directory for sequential scans. - */ - (void) ReadOK(tif, &nextdiroff, sizeof (uint32)); - } else { - toff_t off = tif->tif_diroff; - - if (off + sizeof (uint16) > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return (0); - } else - _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16)); - off += sizeof (uint16); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFCheckMalloc(tif, dircount, - sizeof (TIFFDirEntry), - "to read TIFF directory"); - if (dir == NULL) - return (0); - if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory", - tif->tif_name); - goto bad; - } else { - _TIFFmemcpy(dir, tif->tif_base + off, - dircount*sizeof (TIFFDirEntry)); - } - off += dircount* sizeof (TIFFDirEntry); - if (off + sizeof (uint32) <= tif->tif_size) - _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32)); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdiroff); - tif->tif_nextdiroff = nextdiroff; - - tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ - /* - * Setup default value and then make a pass over - * the fields to check type and tag information, - * and to extract info required to size data - * structures. A second pass is made afterwards - * to read in everthing not taken in the first pass. - */ - td = &tif->tif_dir; - /* free any old stuff and reinit */ - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - /* - * Electronic Arts writes gray-scale TIFF files - * without a PlanarConfiguration directory entry. - * Thus we setup a default value here, even though - * the TIFF spec says there is no default value. - */ - TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - - /* - * Sigh, we must make a separate pass through the - * directory for the following reason: - * - * We must process the Compression tag in the first pass - * in order to merge in codec-private tag definitions (otherwise - * we may get complaints about unknown tags). However, the - * Compression tag may be dependent on the SamplesPerPixel - * tag value because older TIFF specs permited Compression - * to be written as a SamplesPerPixel-count tag entry. - * Thus if we don't first figure out the correct SamplesPerPixel - * tag value then we may end up ignoring the Compression tag - * value because it has an incorrect count value (if the - * true value of SamplesPerPixel is not 1). - * - * It sure would have been nice if Aldus had really thought - * this stuff through carefully. - */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) { - if (!TIFFFetchNormalTag(tif, dp)) - goto bad; - dp->tdir_tag = IGNORE; - } - } - /* - * First real pass over the directory. - */ - fix = 0; - for (dp = dir, n = dircount; n > 0; n--, dp++) { - - if (fix >= tif->tif_nfields || dp->tdir_tag == IGNORE) - continue; - - /* - * Silicon Beach (at least) writes unordered - * directory tags (violating the spec). Handle - * it here, but be obnoxious (maybe they'll fix it?). - */ - if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) { - if (!diroutoforderwarning) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: invalid TIFF directory; tags are not sorted in ascending order", - tif->tif_name); - diroutoforderwarning = 1; - } - fix = 0; /* O(n^2) */ - } - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - if (fix >= tif->tif_nfields || - tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - - TIFFWarningExt(tif->tif_clientdata, - module, - "%s: unknown field with tag %d (0x%x) encountered", - tif->tif_name, - dp->tdir_tag, - dp->tdir_tag, - dp->tdir_type); - - TIFFMergeFieldInfo(tif, - _TIFFCreateAnonFieldInfo(tif, - dp->tdir_tag, - (TIFFDataType) dp->tdir_type), - 1 ); - fix = 0; - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - } - /* - * Null out old tags that we ignore. - */ - if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { - ignore: - dp->tdir_tag = IGNORE; - continue; - } - /* - * Check data type. - */ - fip = tif->tif_fieldinfo[fix]; - while (dp->tdir_type != (unsigned short) fip->field_type - && fix < tif->tif_nfields) { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip = tif->tif_fieldinfo[++fix]; - if (fix >= tif->tif_nfields || - fip->field_tag != dp->tdir_tag) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: wrong data type %d for \"%s\"; tag ignored", - tif->tif_name, dp->tdir_type, - tif->tif_fieldinfo[fix-1]->field_name); - goto ignore; - } - } - /* - * Check count if known in advance. - */ - if (fip->field_readcount != TIFF_VARIABLE - && fip->field_readcount != TIFF_VARIABLE2) { - uint32 expected = (fip->field_readcount == TIFF_SPP) ? - (uint32) td->td_samplesperpixel : - (uint32) fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - goto ignore; - } - - switch (dp->tdir_tag) { - case TIFFTAG_COMPRESSION: - /* - * The 5.0 spec says the Compression tag has - * one value, while earlier specs say it has - * one value per sample. Because of this, we - * accept the tag if one value is supplied. - */ - if (dp->tdir_count == 1) { - v = TIFFExtractData(tif, - dp->tdir_type, dp->tdir_offset); - if (!TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - break; - /* XXX: workaround for broken TIFFs */ - } else if (dp->tdir_type == TIFF_LONG) { - if (!TIFFFetchPerSampleLongs(tif, dp, &v) || - !TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - } else { - if (!TIFFFetchPerSampleShorts(tif, dp, &iv) - || !TIFFSetField(tif, dp->tdir_tag, iv)) - goto bad; - } - dp->tdir_tag = IGNORE; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEOFFSETS: - case TIFFTAG_TILEBYTECOUNTS: - TIFFSetFieldBit(tif, fip->field_bit); - break; - case TIFFTAG_IMAGEWIDTH: - case TIFFTAG_IMAGELENGTH: - case TIFFTAG_IMAGEDEPTH: - case TIFFTAG_TILELENGTH: - case TIFFTAG_TILEWIDTH: - case TIFFTAG_TILEDEPTH: - case TIFFTAG_PLANARCONFIG: - case TIFFTAG_ROWSPERSTRIP: - case TIFFTAG_EXTRASAMPLES: - if (!TIFFFetchNormalTag(tif, dp)) - goto bad; - dp->tdir_tag = IGNORE; - break; - } - } - - /* - * Allocate directory structure and setup defaults. - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { - MissingRequired(tif, "ImageLength"); - goto bad; - } - /* - * Setup appropriate structures (by strip or by tile) - */ - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - td->td_nstrips = TIFFNumberOfStrips(tif); - td->td_tilewidth = td->td_imagewidth; - td->td_tilelength = td->td_rowsperstrip; - td->td_tiledepth = td->td_imagedepth; - tif->tif_flags &= ~TIFF_ISTILED; - } else { - td->td_nstrips = TIFFNumberOfTiles(tif); - tif->tif_flags |= TIFF_ISTILED; - } - if (!td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: cannot handle zero number of %s", - tif->tif_name, isTiled(tif) ? "tiles" : "strips"); - goto bad; - } - td->td_stripsperimage = td->td_nstrips; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { - MissingRequired(tif, - isTiled(tif) ? "TileOffsets" : "StripOffsets"); - goto bad; - } - - /* - * Second pass: extract other information. - */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (dp->tdir_tag == IGNORE) - continue; - switch (dp->tdir_tag) { - case TIFFTAG_MINSAMPLEVALUE: - case TIFFTAG_MAXSAMPLEVALUE: - case TIFFTAG_BITSPERSAMPLE: - case TIFFTAG_DATATYPE: - case TIFFTAG_SAMPLEFORMAT: - /* - * The 5.0 spec says the Compression tag has - * one value, while earlier specs say it has - * one value per sample. Because of this, we - * accept the tag if one value is supplied. - * - * The MinSampleValue, MaxSampleValue, BitsPerSample - * DataType and SampleFormat tags are supposed to be - * written as one value/sample, but some vendors - * incorrectly write one value only -- so we accept - * that as well (yech). Other vendors write correct - * value for NumberOfSamples, but incorrect one for - * BitsPerSample and friends, and we will read this - * too. - */ - if (dp->tdir_count == 1) { - v = TIFFExtractData(tif, - dp->tdir_type, dp->tdir_offset); - if (!TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - /* XXX: workaround for broken TIFFs */ - } else if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE - && dp->tdir_type == TIFF_LONG) { - if (!TIFFFetchPerSampleLongs(tif, dp, &v) || - !TIFFSetField(tif, dp->tdir_tag, (uint16)v)) - goto bad; - } else { - if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || - !TIFFSetField(tif, dp->tdir_tag, iv)) - goto bad; - } - break; - case TIFFTAG_SMINSAMPLEVALUE: - case TIFFTAG_SMAXSAMPLEVALUE: - { - double dv = 0.0; - if (!TIFFFetchPerSampleAnys(tif, dp, &dv) || - !TIFFSetField(tif, dp->tdir_tag, dv)) - goto bad; - } - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - if (!TIFFFetchStripThing(tif, dp, - td->td_nstrips, &td->td_stripoffset)) - goto bad; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - if (!TIFFFetchStripThing(tif, dp, - td->td_nstrips, &td->td_stripbytecount)) - goto bad; - break; - case TIFFTAG_COLORMAP: - case TIFFTAG_TRANSFERFUNCTION: - { - char* cp; - /* - * TransferFunction can have either 1x or 3x - * data values; Colormap can have only 3x - * items. - */ - v = 1L<td_bitspersample; - if (dp->tdir_tag == TIFFTAG_COLORMAP || - dp->tdir_count != v) { - if (!CheckDirCount(tif, dp, 3 * v)) - break; - } - v *= sizeof(uint16); - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, - sizeof (uint16), - "to read \"TransferFunction\" tag"); - if (cp != NULL) { - if (TIFFFetchData(tif, dp, cp)) { - /* - * This deals with there being - * only one array to apply to - * all samples. - */ - uint32 c = 1L << td->td_bitspersample; - if (dp->tdir_count == c) - v = 0L; - TIFFSetField(tif, dp->tdir_tag, - cp, cp+v, cp+2*v); - } - _TIFFfree(cp); - } - break; - } - case TIFFTAG_PAGENUMBER: - case TIFFTAG_HALFTONEHINTS: - case TIFFTAG_YCBCRSUBSAMPLING: - case TIFFTAG_DOTRANGE: - (void) TIFFFetchShortPair(tif, dp); - break; - case TIFFTAG_REFERENCEBLACKWHITE: - (void) TIFFFetchRefBlackWhite(tif, dp); - break; -/* BEGIN REV 4.0 COMPATIBILITY */ - case TIFFTAG_OSUBFILETYPE: - v = 0L; - switch (TIFFExtractData(tif, dp->tdir_type, - dp->tdir_offset)) { - case OFILETYPE_REDUCEDIMAGE: - v = FILETYPE_REDUCEDIMAGE; - break; - case OFILETYPE_PAGE: - v = FILETYPE_PAGE; - break; - } - if (v) - TIFFSetField(tif, TIFFTAG_SUBFILETYPE, v); - break; -/* END REV 4.0 COMPATIBILITY */ - default: - (void) TIFFFetchNormalTag(tif, dp); - break; - } - } - /* - * Verify Palette image has a Colormap. - */ - if (td->td_photometric == PHOTOMETRIC_PALETTE && - !TIFFFieldSet(tif, FIELD_COLORMAP)) { - MissingRequired(tif, "Colormap"); - goto bad; - } - /* - * Attempt to deal with a missing StripByteCounts tag. - */ - if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { - /* - * Some manufacturers violate the spec by not giving - * the size of the strips. In this case, assume there - * is one uncompressed strip of data. - */ - if ((td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_nstrips > 1) || - (td->td_planarconfig == PLANARCONFIG_SEPARATE && - td->td_nstrips != td->td_samplesperpixel)) { - MissingRequired(tif, "StripByteCounts"); - goto bad; - } - TIFFWarningExt(tif->tif_clientdata, module, - "%s: TIFF directory is missing required " - "\"%s\" field, calculating from imagelength", - tif->tif_name, - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; -/* - * Assume we have wrong StripByteCount value (in case of single strip) in - * following cases: - * - it is equal to zero along with StripOffset; - * - it is larger than file itself (in case of uncompressed image); - * - it is smaller than the size of the bytes per row multiplied on the - * number of rows. The last case should not be checked in the case of - * writing new image, because we may do not know the exact strip size - * until the whole image will be written and directory dumped out. - */ -#define BYTECOUNTLOOKSBAD \ - ( (td->td_stripbytecount[0] == 0 && td->td_stripoffset[0] != 0) || \ - (td->td_compression == COMPRESSION_NONE && \ - td->td_stripbytecount[0] > TIFFGetFileSize(tif) - td->td_stripoffset[0]) || \ - (tif->tif_mode == O_RDONLY && \ - td->td_compression == COMPRESSION_NONE && \ - td->td_stripbytecount[0] < TIFFScanlineSize(tif) * td->td_imagelength) ) - - } else if (td->td_nstrips == 1 - && td->td_stripoffset[0] != 0 - && BYTECOUNTLOOKSBAD) { - /* - * XXX: Plexus (and others) sometimes give a value of zero for - * a tag when they don't know what the correct value is! Try - * and handle the simple case of estimating the size of a one - * strip image. - */ - TIFFWarningExt(tif->tif_clientdata, module, - "%s: Bogus \"%s\" field, ignoring and calculating from imagelength", - tif->tif_name, - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - if(EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } else if (td->td_planarconfig == PLANARCONFIG_CONTIG - && td->td_nstrips > 2 - && td->td_compression == COMPRESSION_NONE - && td->td_stripbytecount[0] != td->td_stripbytecount[1]) { - /* - * XXX: Some vendors fill StripByteCount array with absolutely - * wrong values (it can be equal to StripOffset array, for - * example). Catch this case here. - */ - TIFFWarningExt(tif->tif_clientdata, module, - "%s: Wrong \"%s\" field, ignoring and calculating from imagelength", - tif->tif_name, - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } - if (dir) { - _TIFFfree((char *)dir); - dir = NULL; - } - if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) - td->td_maxsamplevalue = (uint16)((1L<td_bitspersample)-1); - /* - * Setup default compression scheme. - */ - - /* - * XXX: We can optimize checking for the strip bounds using the sorted - * bytecounts array. See also comments for TIFFAppendToStrip() - * function in tif_write.c. - */ - if (td->td_nstrips > 1) { - tstrip_t strip; - - td->td_stripbytecountsorted = 1; - for (strip = 1; strip < td->td_nstrips; strip++) { - if (td->td_stripoffset[strip - 1] > - td->td_stripoffset[strip]) { - td->td_stripbytecountsorted = 0; - break; - } - } - } - - if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) - TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * Some manufacturers make life difficult by writing - * large amounts of uncompressed data as a single strip. - * This is contrary to the recommendations of the spec. - * The following makes an attempt at breaking such images - * into strips closer to the recommended 8k bytes. A - * side effect, however, is that the RowsPerStrip tag - * value may be changed. - */ - if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE && - (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP) - ChopUpSingleUncompressedStrip(tif); - - /* - * Reinitialize i/o since we are starting on a new directory. - */ - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - tif->tif_col = (uint32) -1; - tif->tif_curtile = (ttile_t) -1; - tif->tif_tilesize = (tsize_t) -1; - - tif->tif_scanlinesize = TIFFScanlineSize(tif); - if (!tif->tif_scanlinesize) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: cannot handle zero scanline size", - tif->tif_name); - return (0); - } - - if (isTiled(tif)) { - tif->tif_tilesize = TIFFTileSize(tif); - if (!tif->tif_tilesize) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: cannot handle zero tile size", - tif->tif_name); - return (0); - } - } else { - if (!TIFFStripSize(tif)) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: cannot handle zero strip size", - tif->tif_name); - return (0); - } - } - return (1); -bad: - if (dir) - _TIFFfree(dir); - return (0); -} - -/* - * Read custom directory from the arbitarry offset. - * The code is very similar to TIFFReadDirectory(). - */ -int -TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, - const TIFFFieldInfo info[], size_t n) -{ - static const char module[] = "TIFFReadCustomDirectory"; - - TIFFDirectory* td = &tif->tif_dir; - TIFFDirEntry *dp, *dir = NULL; - const TIFFFieldInfo* fip; - size_t fix; - uint16 i, dircount; - - _TIFFSetupFieldInfo(tif, info, n); - - tif->tif_diroff = diroff; - - if (!isMapped(tif)) { - if (!SeekOK(tif, diroff)) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error accessing TIFF directory", - tif->tif_name); - return (0); - } - if (!ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFCheckMalloc(tif, dircount, - sizeof (TIFFDirEntry), - "to read TIFF custom directory"); - if (dir == NULL) - return (0); - if (!ReadOK(tif, dir, dircount * sizeof (TIFFDirEntry))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%.100s: Can not read TIFF directory", - tif->tif_name); - goto bad; - } - } else { - toff_t off = diroff; - - if (off + sizeof (uint16) > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return (0); - } else - _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16)); - off += sizeof (uint16); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFCheckMalloc(tif, dircount, - sizeof (TIFFDirEntry), - "to read TIFF custom directory"); - if (dir == NULL) - return (0); - if (off + dircount * sizeof (TIFFDirEntry) > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Can not read TIFF directory", - tif->tif_name); - goto bad; - } else { - _TIFFmemcpy(dir, tif->tif_base + off, - dircount * sizeof (TIFFDirEntry)); - } - } - - TIFFFreeDirectory(tif); - - fix = 0; - for (dp = dir, i = dircount; i > 0; i--, dp++) { - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - - if (fix >= tif->tif_nfields || dp->tdir_tag == IGNORE) - continue; - - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - - if (fix >= tif->tif_nfields || - tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - - TIFFWarningExt(tif->tif_clientdata, module, - "%s: unknown field with tag %d (0x%x) encountered", - tif->tif_name, dp->tdir_tag, dp->tdir_tag, - dp->tdir_type); - - TIFFMergeFieldInfo(tif, - _TIFFCreateAnonFieldInfo(tif, - dp->tdir_tag, - (TIFFDataType)dp->tdir_type), - 1); - - fix = 0; - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - } - /* - * Null out old tags that we ignore. - */ - if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { - ignore: - dp->tdir_tag = IGNORE; - continue; - } - /* - * Check data type. - */ - fip = tif->tif_fieldinfo[fix]; - while (dp->tdir_type != (unsigned short) fip->field_type - && fix < tif->tif_nfields) { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip = tif->tif_fieldinfo[++fix]; - if (fix >= tif->tif_nfields || - fip->field_tag != dp->tdir_tag) { - TIFFWarningExt(tif->tif_clientdata, module, - "%s: wrong data type %d for \"%s\"; tag ignored", - tif->tif_name, dp->tdir_type, - tif->tif_fieldinfo[fix-1]->field_name); - goto ignore; - } - } - /* - * Check count if known in advance. - */ - if (fip->field_readcount != TIFF_VARIABLE - && fip->field_readcount != TIFF_VARIABLE2) { - uint32 expected = (fip->field_readcount == TIFF_SPP) ? - (uint32) td->td_samplesperpixel : - (uint32) fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - goto ignore; - } - - (void) TIFFFetchNormalTag(tif, dp); - } - - if (dir) - _TIFFfree(dir); - return 1; - -bad: - if (dir) - _TIFFfree(dir); - return 0; -} - -/* - * EXIF is important special case of custom IFD, so we have a special - * function to read it. - */ -int -TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff) -{ - size_t exifFieldInfoCount; - const TIFFFieldInfo *exifFieldInfo = - _TIFFGetExifFieldInfo(&exifFieldInfoCount); - return TIFFReadCustomDirectory(tif, diroff, exifFieldInfo, - exifFieldInfoCount); -} - -static int -EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) -{ - static const char module[] = "EstimateStripByteCounts"; - - register TIFFDirEntry *dp; - register TIFFDirectory *td = &tif->tif_dir; - uint16 i; - - if (td->td_stripbytecount) - _TIFFfree(td->td_stripbytecount); - td->td_stripbytecount = (uint32*) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint32), - "for \"StripByteCounts\" array"); - if (td->td_compression != COMPRESSION_NONE) { - uint32 space = (uint32)(sizeof (TIFFHeader) - + sizeof (uint16) - + (dircount * sizeof (TIFFDirEntry)) - + sizeof (uint32)); - toff_t filesize = TIFFGetFileSize(tif); - uint16 n; - - /* calculate amount of space used by indirect values */ - for (dp = dir, n = dircount; n > 0; n--, dp++) - { - uint32 cc = TIFFDataWidth((TIFFDataType) dp->tdir_type); - if (cc == 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Cannot determine size of unknown tag type %d", - tif->tif_name, dp->tdir_type); - return -1; - } - cc = cc * dp->tdir_count; - if (cc > sizeof (uint32)) - space += cc; - } - space = filesize - space; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - space /= td->td_samplesperpixel; - for (i = 0; i < td->td_nstrips; i++) - td->td_stripbytecount[i] = space; - /* - * This gross hack handles the case were the offset to - * the last strip is past the place where we think the strip - * should begin. Since a strip of data must be contiguous, - * it's safe to assume that we've overestimated the amount - * of data in the strip and trim this number back accordingly. - */ - i--; - if (((toff_t)(td->td_stripoffset[i]+td->td_stripbytecount[i])) - > filesize) - td->td_stripbytecount[i] = - filesize - td->td_stripoffset[i]; - } else { - uint32 rowbytes = TIFFScanlineSize(tif); - uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; - for (i = 0; i < td->td_nstrips; i++) - td->td_stripbytecount[i] = rowbytes*rowsperstrip; - } - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - td->td_rowsperstrip = td->td_imagelength; - return 1; -} - -static void -MissingRequired(TIFF* tif, const char* tagname) -{ - static const char module[] = "MissingRequired"; - - TIFFErrorExt(tif->tif_clientdata, module, - "%s: TIFF directory is missing required \"%s\" field", - tif->tif_name, tagname); -} - -/* - * Check the count field of a directory - * entry against a known value. The caller - * is expected to skip/ignore the tag if - * there is a mismatch. - */ -static int -CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) -{ - if (count > dir->tdir_count) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count, count); - return (0); - } else if (count < dir->tdir_count) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (%lu, expecting %lu); tag trimmed", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count, count); - return (1); - } - return (1); -} - -/* - * Fetch a contiguous directory item. - */ -static tsize_t -TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - int w = TIFFDataWidth((TIFFDataType) dir->tdir_type); - tsize_t cc = dir->tdir_count * w; - - /* Check for overflow. */ - if (!dir->tdir_count || !w || cc / w != (tsize_t)dir->tdir_count) - goto bad; - - if (!isMapped(tif)) { - if (!SeekOK(tif, dir->tdir_offset)) - goto bad; - if (!ReadOK(tif, cp, cc)) - goto bad; - } else { - /* Check for overflow. */ - if ((tsize_t)dir->tdir_offset + cc < (tsize_t)dir->tdir_offset - || (tsize_t)dir->tdir_offset + cc < cc - || (tsize_t)dir->tdir_offset + cc > (tsize_t)tif->tif_size) - goto bad; - _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc); - } - if (tif->tif_flags & TIFF_SWAB) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); - break; - } - } - return (cc); -bad: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error fetching data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (tsize_t) 0; -} - -/* - * Fetch an ASCII item from the file. - */ -static tsize_t -TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - if (dir->tdir_count <= 4) { - uint32 l = dir->tdir_offset; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&l); - _TIFFmemcpy(cp, &l, dir->tdir_count); - return (1); - } - return (TIFFFetchData(tif, dir, cp)); -} - -/* - * Convert numerator+denominator to float. - */ -static int -cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) -{ - if (denom == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%s: Rational with zero denominator (num = %lu)", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num); - return (0); - } else { - if (dir->tdir_type == TIFF_RATIONAL) - *rv = ((float)num / (float)denom); - else - *rv = ((float)(int32)num / (float)(int32)denom); - return (1); - } -} - -/* - * Fetch a rational item from the file - * at offset off and return the value - * as a floating point number. - */ -static float -TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir) -{ - uint32 l[2]; - float v; - - return (!TIFFFetchData(tif, dir, (char *)l) || - !cvtRational(tif, dir, l[0], l[1], &v) ? 1.0f : v); -} - -/* - * Fetch a single floating point value - * from the offset field and return it - * as a native float. - */ -static float -TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) -{ - float v; - int32 l = TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); - _TIFFmemcpy(&v, &l, sizeof(float)); - TIFFCvtIEEEFloatToNative(tif, 1, &v); - return (v); -} - -/* - * Fetch an array of BYTE or SBYTE values. - */ -static int -TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint8* v) -{ - if (dir->tdir_count <= 4) { - /* - * Extract data from offset field. - */ - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - if (dir->tdir_type == TIFF_SBYTE) - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset & 0xff; - case 3: v[2] = (dir->tdir_offset >> 8) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 16) & 0xff; - case 1: v[0] = dir->tdir_offset >> 24; - } - else - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset & 0xff; - case 3: v[2] = (dir->tdir_offset >> 8) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 16) & 0xff; - case 1: v[0] = dir->tdir_offset >> 24; - } - } else { - if (dir->tdir_type == TIFF_SBYTE) - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset >> 24; - case 3: v[2] = (dir->tdir_offset >> 16) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 8) & 0xff; - case 1: v[0] = dir->tdir_offset & 0xff; - } - else - switch (dir->tdir_count) { - case 4: v[3] = dir->tdir_offset >> 24; - case 3: v[2] = (dir->tdir_offset >> 16) & 0xff; - case 2: v[1] = (dir->tdir_offset >> 8) & 0xff; - case 1: v[0] = dir->tdir_offset & 0xff; - } - } - return (1); - } else - return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */ -} - -/* - * Fetch an array of SHORT or SSHORT values. - */ -static int -TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) -{ - if (dir->tdir_count <= 2) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - switch (dir->tdir_count) { - case 2: v[1] = (uint16) (dir->tdir_offset & 0xffff); - case 1: v[0] = (uint16) (dir->tdir_offset >> 16); - } - } else { - switch (dir->tdir_count) { - case 2: v[1] = (uint16) (dir->tdir_offset >> 16); - case 1: v[0] = (uint16) (dir->tdir_offset & 0xffff); - } - } - return (1); - } else - return (TIFFFetchData(tif, dir, (char *)v) != 0); -} - -/* - * Fetch a pair of SHORT or BYTE values. Some tags may have either BYTE - * or SHORT type and this function works with both ones. - */ -static int -TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) -{ - switch (dir->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - { - uint8 v[4]; - return TIFFFetchByteArray(tif, dir, v) - && TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); - } - case TIFF_SHORT: - case TIFF_SSHORT: - { - uint16 v[2]; - return TIFFFetchShortArray(tif, dir, v) - && TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); - } - default: - return 0; - } -} - -/* - * Fetch an array of LONG or SLONG values. - */ -static int -TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) -{ - if (dir->tdir_count == 1) { - v[0] = dir->tdir_offset; - return (1); - } else - return (TIFFFetchData(tif, dir, (char*) v) != 0); -} - -/* - * Fetch an array of RATIONAL or SRATIONAL values. - */ -static int -TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - int ok = 0; - uint32* l; - - l = (uint32*)_TIFFCheckMalloc(tif, - dir->tdir_count, TIFFDataWidth((TIFFDataType) dir->tdir_type), - "to fetch array of rationals"); - if (l) { - if (TIFFFetchData(tif, dir, (char *)l)) { - uint32 i; - for (i = 0; i < dir->tdir_count; i++) { - ok = cvtRational(tif, dir, - l[2*i+0], l[2*i+1], &v[i]); - if (!ok) - break; - } - } - _TIFFfree((char *)l); - } - return (ok); -} - -/* - * Fetch an array of FLOAT values. - */ -static int -TIFFFetchFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - - if (dir->tdir_count == 1) { - v[0] = *(float*) &dir->tdir_offset; - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } else if (TIFFFetchData(tif, dir, (char*) v)) { - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } else - return (0); -} - -/* - * Fetch an array of DOUBLE values. - */ -static int -TIFFFetchDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - if (TIFFFetchData(tif, dir, (char*) v)) { - TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v); - return (1); - } else - return (0); -} - -/* - * Fetch an array of ANY values. The actual values are - * returned as doubles which should be able hold all the - * types. Yes, there really should be an tany_t to avoid - * this potential non-portability ... Note in particular - * that we assume that the double return value vector is - * large enough to read in any fundamental type. We use - * that vector as a buffer to read in the base type vector - * and then convert it in place to double (from end - * to front of course). - */ -static int -TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - int i; - - switch (dir->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - if (!TIFFFetchByteArray(tif, dir, (uint8*) v)) - return (0); - if (dir->tdir_type == TIFF_BYTE) { - uint8* vp = (uint8*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int8* vp = (int8*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_SHORT: - case TIFF_SSHORT: - if (!TIFFFetchShortArray(tif, dir, (uint16*) v)) - return (0); - if (dir->tdir_type == TIFF_SHORT) { - uint16* vp = (uint16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int16* vp = (int16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_LONG: - case TIFF_SLONG: - if (!TIFFFetchLongArray(tif, dir, (uint32*) v)) - return (0); - if (dir->tdir_type == TIFF_LONG) { - uint32* vp = (uint32*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int32* vp = (int32*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (!TIFFFetchRationalArray(tif, dir, (float*) v)) - return (0); - { float* vp = (float*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_FLOAT: - if (!TIFFFetchFloatArray(tif, dir, (float*) v)) - return (0); - { float* vp = (float*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_DOUBLE: - return (TIFFFetchDoubleArray(tif, dir, (double*) v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "cannot read TIFF_ANY type %d for field \"%s\"", - dir->tdir_type, - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); - } - return (1); -} - -/* - * Fetch a tag that is not handled by special case code. - */ -static int -TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp) -{ - static const char mesg[] = "to fetch tag value"; - int ok = 0; - const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag); - - if (dp->tdir_count > 1) { /* array of values */ - char* cp = NULL; - - switch (dp->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (uint8), mesg); - ok = cp && TIFFFetchByteArray(tif, dp, (uint8*) cp); - break; - case TIFF_SHORT: - case TIFF_SSHORT: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (uint16), mesg); - ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); - break; - case TIFF_LONG: - case TIFF_SLONG: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (uint32), mesg); - ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (float), mesg); - ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp); - break; - case TIFF_FLOAT: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (float), mesg); - ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp); - break; - case TIFF_DOUBLE: - cp = (char *)_TIFFCheckMalloc(tif, - dp->tdir_count, sizeof (double), mesg); - ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp); - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - /* - * Some vendors write strings w/o the trailing - * NULL byte, so always append one just in case. - */ - cp = (char *)_TIFFCheckMalloc(tif, dp->tdir_count + 1, - 1, mesg); - if( (ok = (cp && TIFFFetchString(tif, dp, cp))) != 0 ) - cp[dp->tdir_count] = '\0'; /* XXX */ - break; - } - if (ok) { - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, dp->tdir_count, cp) - : TIFFSetField(tif, dp->tdir_tag, cp)); - } - if (cp != NULL) - _TIFFfree(cp); - } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */ - switch (dp->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - /* - * If the tag is also acceptable as a LONG or SLONG - * then TIFFSetField will expect an uint32 parameter - * passed to it (through varargs). Thus, for machines - * where sizeof (int) != sizeof (uint32) we must do - * a careful check here. It's hard to say if this - * is worth optimizing. - * - * NB: We use TIFFFieldWithTag here knowing that - * it returns us the first entry in the table - * for the tag and that that entry is for the - * widest potential data type the tag may have. - */ - { TIFFDataType type = fip->field_type; - if (type != TIFF_LONG && type != TIFF_SLONG) { - uint16 v = (uint16) - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)); - break; - } - } - /* fall thru... */ - case TIFF_LONG: - case TIFF_SLONG: - { uint32 v32 = - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v32) - : TIFFSetField(tif, dp->tdir_tag, v32)); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { float v = (dp->tdir_type == TIFF_FLOAT ? - TIFFFetchFloat(tif, dp) - : TIFFFetchRational(tif, dp)); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)); - } - break; - case TIFF_DOUBLE: - { double v; - ok = (TIFFFetchDoubleArray(tif, dp, &v) && - (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)) - ); - } - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - { char c[2]; - if( (ok = (TIFFFetchString(tif, dp, c) != 0)) != 0 ) { - c[1] = '\0'; /* XXX paranoid */ - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, c) - : TIFFSetField(tif, dp->tdir_tag, c)); - } - } - break; - } - } - return (ok); -} - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Fetch samples/pixel short values for - * the specified tag and verify that - * all values are the same. - */ -static int -TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, uint16* pl) -{ - uint16 samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - uint16 buf[10]; - uint16* v = buf; - - if (dir->tdir_count > NITEMS(buf)) - v = (uint16*) _TIFFCheckMalloc(tif, dir->tdir_count, sizeof(uint16), - "to fetch per-sample values"); - if (v && TIFFFetchShortArray(tif, dir, v)) { - uint16 i; - int check_count = dir->tdir_count; - if( samples < check_count ) - check_count = samples; - - for (i = 1; i < check_count; i++) - if (v[i] != v[0]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v && v != buf) - _TIFFfree(v); - } - return (status); -} - -/* - * Fetch samples/pixel long values for - * the specified tag and verify that - * all values are the same. - */ -static int -TIFFFetchPerSampleLongs(TIFF* tif, TIFFDirEntry* dir, uint32* pl) -{ - uint16 samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - uint32 buf[10]; - uint32* v = buf; - - if (dir->tdir_count > NITEMS(buf)) - v = (uint32*) _TIFFCheckMalloc(tif, dir->tdir_count, sizeof(uint32), - "to fetch per-sample values"); - if (v && TIFFFetchLongArray(tif, dir, v)) { - uint16 i; - int check_count = dir->tdir_count; - - if( samples < check_count ) - check_count = samples; - for (i = 1; i < check_count; i++) - if (v[i] != v[0]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v && v != buf) - _TIFFfree(v); - } - return (status); -} - -/* - * Fetch samples/pixel ANY values for the specified tag and verify that all - * values are the same. - */ -static int -TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) -{ - uint16 samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - double buf[10]; - double* v = buf; - - if (dir->tdir_count > NITEMS(buf)) - v = (double*) _TIFFCheckMalloc(tif, dir->tdir_count, sizeof (double), - "to fetch per-sample values"); - if (v && TIFFFetchAnyArray(tif, dir, v)) { - uint16 i; - int check_count = dir->tdir_count; - if( samples < check_count ) - check_count = samples; - - for (i = 1; i < check_count; i++) - if (v[i] != v[0]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v && v != buf) - _TIFFfree(v); - } - return (status); -} -#undef NITEMS - -/* - * Fetch a set of offsets or lengths. - * While this routine says "strips", in fact it's also used for tiles. - */ -static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) -{ - register uint32* lp; - int status; - - CheckDirCount(tif, dir, (uint32) nstrips); - - /* - * Allocate space for strip information. - */ - if (*lpp == NULL && - (*lpp = (uint32 *)_TIFFCheckMalloc(tif, - nstrips, sizeof (uint32), "for strip array")) == NULL) - return (0); - lp = *lpp; - _TIFFmemset( lp, 0, sizeof(uint32) * nstrips ); - - if (dir->tdir_type == (int)TIFF_SHORT) { - /* - * Handle uint16->uint32 expansion. - */ - uint16* dp = (uint16*) _TIFFCheckMalloc(tif, - dir->tdir_count, sizeof (uint16), "to fetch strip tag"); - if (dp == NULL) - return (0); - if( (status = TIFFFetchShortArray(tif, dir, dp)) != 0 ) { - int i; - - for( i = 0; i < nstrips && i < (int) dir->tdir_count; i++ ) - { - lp[i] = dp[i]; - } - } - _TIFFfree((char*) dp); - - } else if( nstrips != (int) dir->tdir_count ) { - /* Special case to correct length */ - - uint32* dp = (uint32*) _TIFFCheckMalloc(tif, - dir->tdir_count, sizeof (uint32), "to fetch strip tag"); - if (dp == NULL) - return (0); - - status = TIFFFetchLongArray(tif, dir, dp); - if( status != 0 ) { - int i; - - for( i = 0; i < nstrips && i < (int) dir->tdir_count; i++ ) - { - lp[i] = dp[i]; - } - } - - _TIFFfree( (char *) dp ); - } else - status = TIFFFetchLongArray(tif, dir, lp); - - return (status); -} - -/* - * Fetch and set the RefBlackWhite tag. - */ -static int -TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir) -{ - static const char mesg[] = "for \"ReferenceBlackWhite\" array"; - char* cp; - int ok; - - if (dir->tdir_type == TIFF_RATIONAL) - return (TIFFFetchNormalTag(tif, dir)); - /* - * Handle LONG's for backward compatibility. - */ - cp = (char *)_TIFFCheckMalloc(tif, dir->tdir_count, - sizeof (uint32), mesg); - if( (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) != 0) { - float* fp = (float*) - _TIFFCheckMalloc(tif, dir->tdir_count, sizeof (float), mesg); - if( (ok = (fp != NULL)) != 0 ) { - uint32 i; - for (i = 0; i < dir->tdir_count; i++) - fp[i] = (float)((uint32*) cp)[i]; - ok = TIFFSetField(tif, dir->tdir_tag, fp); - _TIFFfree((char*) fp); - } - } - if (cp) - _TIFFfree(cp); - return (ok); -} - -/* - * Replace a single strip (tile) of uncompressed data by - * multiple strips (tiles), each approximately 8Kbytes. - * This is useful for dealing with large images or - * for dealing with machines with a limited amount - * memory. - */ -static void -ChopUpSingleUncompressedStrip(TIFF* tif) -{ - register TIFFDirectory *td = &tif->tif_dir; - uint32 bytecount = td->td_stripbytecount[0]; - uint32 offset = td->td_stripoffset[0]; - tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; - tstrip_t strip, nstrips, rowsperstrip; - uint32* newcounts; - uint32* newoffsets; - - /* - * Make the rows hold at least one scanline, but fill specified amount - * of data if possible. - */ - if (rowbytes > STRIP_SIZE_DEFAULT) { - stripbytes = rowbytes; - rowsperstrip = 1; - } else if (rowbytes > 0 ) { - rowsperstrip = STRIP_SIZE_DEFAULT / rowbytes; - stripbytes = rowbytes * rowsperstrip; - } - else - return; - - /* - * never increase the number of strips in an image - */ - if (rowsperstrip >= td->td_rowsperstrip) - return; - nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); - if( nstrips == 0 ) /* something is wonky, do nothing. */ - return; - - newcounts = (uint32*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint32), - "for chopped \"StripByteCounts\" array"); - newoffsets = (uint32*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint32), - "for chopped \"StripOffsets\" array"); - if (newcounts == NULL || newoffsets == NULL) { - /* - * Unable to allocate new strip information, give - * up and use the original one strip information. - */ - if (newcounts != NULL) - _TIFFfree(newcounts); - if (newoffsets != NULL) - _TIFFfree(newoffsets); - return; - } - /* - * Fill the strip information arrays with new bytecounts and offsets - * that reflect the broken-up format. - */ - for (strip = 0; strip < nstrips; strip++) { - if (stripbytes > (tsize_t) bytecount) - stripbytes = bytecount; - newcounts[strip] = stripbytes; - newoffsets[strip] = offset; - offset += stripbytes; - bytecount -= stripbytes; - } - /* - * Replace old single strip info with multi-strip info. - */ - td->td_stripsperimage = td->td_nstrips = nstrips; - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - - _TIFFfree(td->td_stripbytecount); - _TIFFfree(td->td_stripoffset); - td->td_stripbytecount = newcounts; - td->td_stripoffset = newoffsets; - td->td_stripbytecountsorted = 1; -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_dirwrite.c b/libs/tiff-3.8.2/libtiff/tif_dirwrite.c deleted file mode 100644 index 71681221f8..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_dirwrite.c +++ /dev/null @@ -1,1243 +0,0 @@ -/* $Id: tif_dirwrite.c,v 1.34 2006/02/23 16:07:45 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Write Support Routines. - */ -#include "tiffiop.h" - -#ifdef HAVE_IEEEFP -# define TIFFCvtNativeToIEEEFloat(tif, n, fp) -# define TIFFCvtNativeToIEEEDouble(tif, n, dp) -#else -extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*); -extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*); -#endif - -static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*); -static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32); -static void TIFFSetupShort(TIFF*, ttag_t, TIFFDirEntry*, uint16); -static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*); -static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**); -static int TIFFWriteShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFWriteLongArray(TIFF *, TIFFDirEntry*, uint32*); -static int TIFFWriteRationalArray(TIFF *, TIFFDirEntry*, float*); -static int TIFFWriteFloatArray(TIFF *, TIFFDirEntry*, float*); -static int TIFFWriteDoubleArray(TIFF *, TIFFDirEntry*, double*); -static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*); -static int TIFFWriteAnyArray(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); -static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*); -static int TIFFWriteInkNames(TIFF*, TIFFDirEntry*); -static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*); -static int TIFFLinkDirectory(TIFF*); - -#define WriteRationalPair(type, tag1, v1, tag2, v2) { \ - TIFFWriteRational((tif), (type), (tag1), (dir), (v1)) \ - TIFFWriteRational((tif), (type), (tag2), (dir)+1, (v2)) \ - (dir)++; \ -} -#define TIFFWriteRational(tif, type, tag, dir, v) \ - (dir)->tdir_tag = (tag); \ - (dir)->tdir_type = (type); \ - (dir)->tdir_count = 1; \ - if (!TIFFWriteRationalArray((tif), (dir), &(v))) \ - goto bad; - -/* - * Write the contents of the current directory - * to the specified file. This routine doesn't - * handle overwriting a directory with auxiliary - * storage that's been changed. - */ -static int -_TIFFWriteDirectory(TIFF* tif, int done) -{ - uint16 dircount; - toff_t diroff; - ttag_t tag; - uint32 nfields; - tsize_t dirsize; - char* data; - TIFFDirEntry* dir; - TIFFDirectory* td; - unsigned long b, fields[FIELD_SETLONGS]; - int fi, nfi; - - if (tif->tif_mode == O_RDONLY) - return (1); - /* - * Clear write state so that subsequent images with - * different characteristics get the right buffers - * setup for them. - */ - if (done) - { - if (tif->tif_flags & TIFF_POSTENCODE) { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error post-encoding before directory write"); - return (0); - } - } - (*tif->tif_close)(tif); /* shutdown encoder */ - /* - * Flush any data that might have been written - * by the compression close+cleanup routines. - */ - if (tif->tif_rawcc > 0 && !TIFFFlushData1(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Error flushing data before directory write"); - return (0); - } - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - tif->tif_rawdatasize = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); - } - - td = &tif->tif_dir; - /* - * Size the directory so that we can calculate - * offsets for the data items that aren't kept - * in-place in each field. - */ - nfields = 0; - for (b = 0; b <= FIELD_LAST; b++) - if (TIFFFieldSet(tif, b) && b != FIELD_CUSTOM) - nfields += (b < FIELD_SUBFILETYPE ? 2 : 1); - nfields += td->td_customValueCount; - dirsize = nfields * sizeof (TIFFDirEntry); - data = (char*) _TIFFmalloc(dirsize); - if (data == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Cannot write directory, out of space"); - return (0); - } - /* - * Directory hasn't been placed yet, put - * it at the end of the file and link it - * into the existing directory structure. - */ - if (tif->tif_diroff == 0 && !TIFFLinkDirectory(tif)) - goto bad; - tif->tif_dataoff = (toff_t)( - tif->tif_diroff + sizeof (uint16) + dirsize + sizeof (toff_t)); - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); - tif->tif_curdir++; - dir = (TIFFDirEntry*) data; - /* - * Setup external form of directory - * entries and write data items. - */ - _TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields)); - /* - * Write out ExtraSamples tag only if - * extra samples are present in the data. - */ - if (FieldSet(fields, FIELD_EXTRASAMPLES) && !td->td_extrasamples) { - ResetFieldBit(fields, FIELD_EXTRASAMPLES); - nfields--; - dirsize -= sizeof (TIFFDirEntry); - } /*XXX*/ - for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi]; - - /* - ** For custom fields, we test to see if the custom field - ** is set or not. For normal fields, we just use the - ** FieldSet test. - */ - if( fip->field_bit == FIELD_CUSTOM ) - { - int ci, is_set = FALSE; - - for( ci = 0; ci < td->td_customValueCount; ci++ ) - is_set |= (td->td_customValues[ci].info == fip); - - if( !is_set ) - continue; - } - else if (!FieldSet(fields, fip->field_bit)) - continue; - - - /* - ** Handle other fields. - */ - switch (fip->field_bit) - { - case FIELD_STRIPOFFSETS: - /* - * We use one field bit for both strip and tile - - * offsets, and so must be careful in selecting - * the appropriate field descriptor (so that tags - * are written in sorted order). - */ - tag = isTiled(tif) ? - TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS; - if (tag != fip->field_tag) - continue; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nstrips; - if (!TIFFWriteLongArray(tif, dir, td->td_stripoffset)) - goto bad; - break; - case FIELD_STRIPBYTECOUNTS: - /* - * We use one field bit for both strip and tile - * byte counts, and so must be careful in selecting - * the appropriate field descriptor (so that tags - * are written in sorted order). - */ - tag = isTiled(tif) ? - TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS; - if (tag != fip->field_tag) - continue; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nstrips; - if (!TIFFWriteLongArray(tif, dir, - td->td_stripbytecount)) - goto bad; - break; - case FIELD_ROWSPERSTRIP: - TIFFSetupShortLong(tif, TIFFTAG_ROWSPERSTRIP, - dir, td->td_rowsperstrip); - break; - case FIELD_COLORMAP: - if (!TIFFWriteShortTable(tif, TIFFTAG_COLORMAP, dir, - 3, td->td_colormap)) - goto bad; - break; - case FIELD_IMAGEDIMENSIONS: - TIFFSetupShortLong(tif, TIFFTAG_IMAGEWIDTH, - dir++, td->td_imagewidth); - TIFFSetupShortLong(tif, TIFFTAG_IMAGELENGTH, - dir, td->td_imagelength); - break; - case FIELD_TILEDIMENSIONS: - TIFFSetupShortLong(tif, TIFFTAG_TILEWIDTH, - dir++, td->td_tilewidth); - TIFFSetupShortLong(tif, TIFFTAG_TILELENGTH, - dir, td->td_tilelength); - break; - case FIELD_COMPRESSION: - TIFFSetupShort(tif, TIFFTAG_COMPRESSION, - dir, td->td_compression); - break; - case FIELD_PHOTOMETRIC: - TIFFSetupShort(tif, TIFFTAG_PHOTOMETRIC, - dir, td->td_photometric); - break; - case FIELD_POSITION: - WriteRationalPair(TIFF_RATIONAL, - TIFFTAG_XPOSITION, td->td_xposition, - TIFFTAG_YPOSITION, td->td_yposition); - break; - case FIELD_RESOLUTION: - WriteRationalPair(TIFF_RATIONAL, - TIFFTAG_XRESOLUTION, td->td_xresolution, - TIFFTAG_YRESOLUTION, td->td_yresolution); - break; - case FIELD_BITSPERSAMPLE: - case FIELD_MINSAMPLEVALUE: - case FIELD_MAXSAMPLEVALUE: - case FIELD_SAMPLEFORMAT: - if (!TIFFWritePerSampleShorts(tif, fip->field_tag, dir)) - goto bad; - break; - case FIELD_SMINSAMPLEVALUE: - case FIELD_SMAXSAMPLEVALUE: - if (!TIFFWritePerSampleAnys(tif, - _TIFFSampleToTagType(tif), fip->field_tag, dir)) - goto bad; - break; - case FIELD_PAGENUMBER: - case FIELD_HALFTONEHINTS: - case FIELD_YCBCRSUBSAMPLING: - if (!TIFFSetupShortPair(tif, fip->field_tag, dir)) - goto bad; - break; - case FIELD_INKNAMES: - if (!TIFFWriteInkNames(tif, dir)) - goto bad; - break; - case FIELD_TRANSFERFUNCTION: - if (!TIFFWriteTransferFunction(tif, dir)) - goto bad; - break; - case FIELD_SUBIFD: - /* - * XXX: Always write this field using LONG type - * for backward compatibility. - */ - dir->tdir_tag = (uint16) fip->field_tag; - dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nsubifd; - if (!TIFFWriteLongArray(tif, dir, td->td_subifd)) - goto bad; - /* - * Total hack: if this directory includes a SubIFD - * tag then force the next directories to be - * written as ``sub directories'' of this one. This - * is used to write things like thumbnails and - * image masks that one wants to keep out of the - * normal directory linkage access mechanism. - */ - if (dir->tdir_count > 0) { - tif->tif_flags |= TIFF_INSUBIFD; - tif->tif_nsubifd = (uint16) dir->tdir_count; - if (dir->tdir_count > 1) - tif->tif_subifdoff = dir->tdir_offset; - else - tif->tif_subifdoff = (uint32)( - tif->tif_diroff - + sizeof (uint16) - + ((char*)&dir->tdir_offset-data)); - } - break; - default: - /* XXX: Should be fixed and removed. */ - if (fip->field_tag == TIFFTAG_DOTRANGE) { - if (!TIFFSetupShortPair(tif, fip->field_tag, dir)) - goto bad; - } - else if (!TIFFWriteNormalTag(tif, dir, fip)) - goto bad; - break; - } - dir++; - - if( fip->field_bit != FIELD_CUSTOM ) - ResetFieldBit(fields, fip->field_bit); - } - - /* - * Write directory. - */ - dircount = (uint16) nfields; - diroff = (uint32) tif->tif_nextdiroff; - if (tif->tif_flags & TIFF_SWAB) { - /* - * The file's byte order is opposite to the - * native machine architecture. We overwrite - * the directory information with impunity - * because it'll be released below after we - * write it to the file. Note that all the - * other tag construction routines assume that - * we do this byte-swapping; i.e. they only - * byte-swap indirect data. - */ - for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { - TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); - } - dircount = (uint16) nfields; - TIFFSwabShort(&dircount); - TIFFSwabLong(&diroff); - } - (void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET); - if (!WriteOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing directory count"); - goto bad; - } - if (!WriteOK(tif, data, dirsize)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing directory contents"); - goto bad; - } - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing directory link"); - goto bad; - } - if (done) { - TIFFFreeDirectory(tif); - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - (*tif->tif_cleanup)(tif); - - /* - * Reset directory-related state for subsequent - * directories. - */ - TIFFCreateDirectory(tif); - } - _TIFFfree(data); - return (1); -bad: - _TIFFfree(data); - return (0); -} -#undef WriteRationalPair - -int -TIFFWriteDirectory(TIFF* tif) -{ - return _TIFFWriteDirectory(tif, TRUE); -} - -/* - * Similar to TIFFWriteDirectory(), writes the directory out - * but leaves all data structures in memory so that it can be - * written again. This will make a partially written TIFF file - * readable before it is successfully completed/closed. - */ -int -TIFFCheckpointDirectory(TIFF* tif) -{ - int rc; - /* Setup the strips arrays, if they haven't already been. */ - if (tif->tif_dir.td_stripoffset == NULL) - (void) TIFFSetupStrips(tif); - rc = _TIFFWriteDirectory(tif, FALSE); - (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END)); - return rc; -} - -/* - * Process tags that are not special cased. - */ -static int -TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip) -{ - uint16 wc = (uint16) fip->field_writecount; - uint32 wc2; - - dir->tdir_tag = (uint16) fip->field_tag; - dir->tdir_type = (uint16) fip->field_type; - dir->tdir_count = wc; - - switch (fip->field_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - if (fip->field_passcount) { - uint16* wp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &wp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &wp); - dir->tdir_count = wc; - } - if (!TIFFWriteShortArray(tif, dir, wp)) - return 0; - } else { - if (wc == 1) { - uint16 sv; - TIFFGetField(tif, fip->field_tag, &sv); - dir->tdir_offset = - TIFFInsertData(tif, dir->tdir_type, sv); - } else { - uint16* wp; - TIFFGetField(tif, fip->field_tag, &wp); - if (!TIFFWriteShortArray(tif, dir, wp)) - return 0; - } - } - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_IFD: - if (fip->field_passcount) { - uint32* lp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &lp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &lp); - dir->tdir_count = wc; - } - if (!TIFFWriteLongArray(tif, dir, lp)) - return 0; - } else { - if (wc == 1) { - /* XXX handle LONG->SHORT conversion */ - TIFFGetField(tif, fip->field_tag, - &dir->tdir_offset); - } else { - uint32* lp; - TIFFGetField(tif, fip->field_tag, &lp); - if (!TIFFWriteLongArray(tif, dir, lp)) - return 0; - } - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (fip->field_passcount) { - float* fp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &fp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &fp); - dir->tdir_count = wc; - } - if (!TIFFWriteRationalArray(tif, dir, fp)) - return 0; - } else { - if (wc == 1) { - float fv; - TIFFGetField(tif, fip->field_tag, &fv); - if (!TIFFWriteRationalArray(tif, dir, &fv)) - return 0; - } else { - float* fp; - TIFFGetField(tif, fip->field_tag, &fp); - if (!TIFFWriteRationalArray(tif, dir, fp)) - return 0; - } - } - break; - case TIFF_FLOAT: - if (fip->field_passcount) { - float* fp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &fp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &fp); - dir->tdir_count = wc; - } - if (!TIFFWriteFloatArray(tif, dir, fp)) - return 0; - } else { - if (wc == 1) { - float fv; - TIFFGetField(tif, fip->field_tag, &fv); - if (!TIFFWriteFloatArray(tif, dir, &fv)) - return 0; - } else { - float* fp; - TIFFGetField(tif, fip->field_tag, &fp); - if (!TIFFWriteFloatArray(tif, dir, fp)) - return 0; - } - } - break; - case TIFF_DOUBLE: - if (fip->field_passcount) { - double* dp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &dp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &dp); - dir->tdir_count = wc; - } - if (!TIFFWriteDoubleArray(tif, dir, dp)) - return 0; - } else { - if (wc == 1) { - double dv; - TIFFGetField(tif, fip->field_tag, &dv); - if (!TIFFWriteDoubleArray(tif, dir, &dv)) - return 0; - } else { - double* dp; - TIFFGetField(tif, fip->field_tag, &dp); - if (!TIFFWriteDoubleArray(tif, dir, dp)) - return 0; - } - } - break; - case TIFF_ASCII: - { - char* cp; - if (fip->field_passcount) - TIFFGetField(tif, fip->field_tag, &wc, &cp); - else - TIFFGetField(tif, fip->field_tag, &cp); - - dir->tdir_count = (uint32) (strlen(cp) + 1); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - - case TIFF_BYTE: - case TIFF_SBYTE: - if (fip->field_passcount) { - char* cp; - if (wc == (uint16) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &cp); - dir->tdir_count = wc2; - } else { /* Assume TIFF_VARIABLE */ - TIFFGetField(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } - if (!TIFFWriteByteArray(tif, dir, cp)) - return 0; - } else { - if (wc == 1) { - char cv; - TIFFGetField(tif, fip->field_tag, &cv); - if (!TIFFWriteByteArray(tif, dir, &cv)) - return 0; - } else { - char* cp; - TIFFGetField(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return 0; - } - } - break; - - case TIFF_UNDEFINED: - { char* cp; - if (wc == (unsigned short) TIFF_VARIABLE) { - TIFFGetField(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } else if (wc == (unsigned short) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &cp); - dir->tdir_count = wc2; - } else - TIFFGetField(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - - case TIFF_NOTYPE: - break; - } - return (1); -} - -/* - * Setup a directory entry with either a SHORT - * or LONG type according to the value. - */ -static void -TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_count = 1; - if (v > 0xffffL) { - dir->tdir_type = (short) TIFF_LONG; - dir->tdir_offset = v; - } else { - dir->tdir_type = (short) TIFF_SHORT; - dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v); - } -} - -/* - * Setup a SHORT directory entry - */ -static void -TIFFSetupShort(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint16 v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_count = 1; - dir->tdir_type = (short) TIFF_SHORT; - dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v); -} -#undef MakeShortDirent - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Setup a directory entry that references a - * samples/pixel array of SHORT values and - * (potentially) write the associated indirect - * values. - */ -static int -TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - uint16 buf[10], v; - uint16* w = buf; - uint16 i, samples = tif->tif_dir.td_samplesperpixel; - int status; - - if (samples > NITEMS(buf)) { - w = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); - if (w == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write per-sample shorts"); - return (0); - } - } - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_SHORT; - dir->tdir_count = samples; - status = TIFFWriteShortArray(tif, dir, w); - if (w != buf) - _TIFFfree((char*) w); - return (status); -} - -/* - * Setup a directory entry that references a samples/pixel array of ``type'' - * values and (potentially) write the associated indirect values. The source - * data from TIFFGetField() for the specified tag must be returned as double. - */ -static int -TIFFWritePerSampleAnys(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir) -{ - double buf[10], v; - double* w = buf; - uint16 i, samples = tif->tif_dir.td_samplesperpixel; - int status; - - if (samples > NITEMS(buf)) { - w = (double*) _TIFFmalloc(samples * sizeof (double)); - if (w == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write per-sample values"); - return (0); - } - } - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w); - if (w != buf) - _TIFFfree(w); - return (status); -} -#undef NITEMS - -/* - * Setup a pair of shorts that are returned by - * value, rather than as a reference to an array. - */ -static int -TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - uint16 v[2]; - - TIFFGetField(tif, tag, &v[0], &v[1]); - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) TIFF_SHORT; - dir->tdir_count = 2; - return (TIFFWriteShortArray(tif, dir, v)); -} - -/* - * Setup a directory entry for an NxM table of shorts, - * where M is known to be 2**bitspersample, and write - * the associated indirect data. - */ -static int -TIFFWriteShortTable(TIFF* tif, - ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table) -{ - uint32 i, off; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) TIFF_SHORT; - /* XXX -- yech, fool TIFFWriteData */ - dir->tdir_count = (uint32) (1L<tif_dir.td_bitspersample); - off = tif->tif_dataoff; - for (i = 0; i < n; i++) - if (!TIFFWriteData(tif, dir, (char *)table[i])) - return (0); - dir->tdir_count *= n; - dir->tdir_offset = off; - return (1); -} - -/* - * Write/copy data associated with an ASCII or opaque tag value. - */ -static int -TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - if (dir->tdir_count > 4) { - if (!TIFFWriteData(tif, dir, cp)) - return (0); - } else - _TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count); - return (1); -} - -/* - * Setup a directory entry of an array of SHORT - * or SSHORT and write the associated indirect values. - */ -static int -TIFFWriteShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) -{ - if (dir->tdir_count <= 2) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - dir->tdir_offset = (uint32) ((long) v[0] << 16); - if (dir->tdir_count == 2) - dir->tdir_offset |= v[1] & 0xffff; - } else { - dir->tdir_offset = v[0] & 0xffff; - if (dir->tdir_count == 2) - dir->tdir_offset |= (long) v[1] << 16; - } - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Setup a directory entry of an array of LONG - * or SLONG and write the associated indirect values. - */ -static int -TIFFWriteLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) -{ - if (dir->tdir_count == 1) { - dir->tdir_offset = v[0]; - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Setup a directory entry of an array of RATIONAL - * or SRATIONAL and write the associated indirect values. - */ -static int -TIFFWriteRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - uint32 i; - uint32* t; - int status; - - t = (uint32*) _TIFFmalloc(2 * dir->tdir_count * sizeof (uint32)); - if (t == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write RATIONAL array"); - return (0); - } - for (i = 0; i < dir->tdir_count; i++) { - float fv = v[i]; - int sign = 1; - uint32 den; - - if (fv < 0) { - if (dir->tdir_type == TIFF_RATIONAL) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL", - _TIFFFieldWithTag(tif,dir->tdir_tag)->field_name, - fv); - fv = 0; - } else - fv = -fv, sign = -1; - } - den = 1L; - if (fv > 0) { - while (fv < 1L<<(31-3) && den < 1L<<(31-3)) - fv *= 1<<3, den *= 1L<<3; - } - t[2*i+0] = (uint32) (sign * (fv + 0.5)); - t[2*i+1] = den; - } - status = TIFFWriteData(tif, dir, (char *)t); - _TIFFfree((char*) t); - return (status); -} - -static int -TIFFWriteFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - TIFFCvtNativeToIEEEFloat(tif, dir->tdir_count, v); - if (dir->tdir_count == 1) { - dir->tdir_offset = *(uint32*) &v[0]; - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -static int -TIFFWriteDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - TIFFCvtNativeToIEEEDouble(tif, dir->tdir_count, v); - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Write an array of ``type'' values for a specified tag (i.e. this is a tag - * which is allowed to have different types, e.g. SMaxSampleType). - * Internally the data values are represented as double since a double can - * hold any of the TIFF tag types (yes, this should really be an abstract - * type tany_t for portability). The data is converted into the specified - * type in a temporary buffer and then handed off to the appropriate array - * writer. - */ -static int -TIFFWriteAnyArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) -{ - char buf[10 * sizeof(double)]; - char* w = buf; - int i, status = 0; - - if (n * TIFFDataWidth(type) > sizeof buf) { - w = (char*) _TIFFmalloc(n * TIFFDataWidth(type)); - if (w == NULL) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space to write array"); - return (0); - } - } - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (uint16) type; - dir->tdir_count = n; - - switch (type) { - case TIFF_BYTE: - { - uint8* bp = (uint8*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint8) v[i]; - if (!TIFFWriteByteArray(tif, dir, (char*) bp)) - goto out; - } - break; - case TIFF_SBYTE: - { - int8* bp = (int8*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int8) v[i]; - if (!TIFFWriteByteArray(tif, dir, (char*) bp)) - goto out; - } - break; - case TIFF_SHORT: - { - uint16* bp = (uint16*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint16) v[i]; - if (!TIFFWriteShortArray(tif, dir, (uint16*)bp)) - goto out; - } - break; - case TIFF_SSHORT: - { - int16* bp = (int16*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int16) v[i]; - if (!TIFFWriteShortArray(tif, dir, (uint16*)bp)) - goto out; - } - break; - case TIFF_LONG: - { - uint32* bp = (uint32*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint32) v[i]; - if (!TIFFWriteLongArray(tif, dir, bp)) - goto out; - } - break; - case TIFF_SLONG: - { - int32* bp = (int32*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int32) v[i]; - if (!TIFFWriteLongArray(tif, dir, (uint32*) bp)) - goto out; - } - break; - case TIFF_FLOAT: - { - float* bp = (float*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (float) v[i]; - if (!TIFFWriteFloatArray(tif, dir, bp)) - goto out; - } - break; - case TIFF_DOUBLE: - return (TIFFWriteDoubleArray(tif, dir, v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - /* TIFF_RATIONAL */ - /* TIFF_SRATIONAL */ - goto out; - } - status = 1; - out: - if (w != buf) - _TIFFfree(w); - return (status); -} - -static int -TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir) -{ - TIFFDirectory* td = &tif->tif_dir; - tsize_t n = (1L<td_bitspersample) * sizeof (uint16); - uint16** tf = td->td_transferfunction; - int ncols; - - /* - * Check if the table can be written as a single column, - * or if it must be written as 3 columns. Note that we - * write a 3-column tag if there are 2 samples/pixel and - * a single column of data won't suffice--hmm. - */ - switch (td->td_samplesperpixel - td->td_extrasamples) { - default: if (_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3; break; } - case 2: if (_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3; break; } - case 1: case 0: ncols = 1; - } - return (TIFFWriteShortTable(tif, - TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf)); -} - -static int -TIFFWriteInkNames(TIFF* tif, TIFFDirEntry* dir) -{ - TIFFDirectory* td = &tif->tif_dir; - - dir->tdir_tag = TIFFTAG_INKNAMES; - dir->tdir_type = (short) TIFF_ASCII; - dir->tdir_count = td->td_inknameslen; - return (TIFFWriteByteArray(tif, dir, td->td_inknames)); -} - -/* - * Write a contiguous directory item. - */ -static int -TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - tsize_t cc; - - if (tif->tif_flags & TIFF_SWAB) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); - break; - } - } - dir->tdir_offset = tif->tif_dataoff; - cc = dir->tdir_count * TIFFDataWidth((TIFFDataType) dir->tdir_type); - if (SeekOK(tif, dir->tdir_offset) && - WriteOK(tif, cp, cc)) { - tif->tif_dataoff += (cc + 1) & ~1; - return (1); - } - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); -} - -/* - * Similar to TIFFWriteDirectory(), but if the directory has already - * been written once, it is relocated to the end of the file, in case it - * has changed in size. Note that this will result in the loss of the - * previously used directory space. - */ - -int -TIFFRewriteDirectory( TIFF *tif ) -{ - static const char module[] = "TIFFRewriteDirectory"; - - /* We don't need to do anything special if it hasn't been written. */ - if( tif->tif_diroff == 0 ) - return TIFFWriteDirectory( tif ); - - /* - ** Find and zero the pointer to this directory, so that TIFFLinkDirectory - ** will cause it to be added after this directories current pre-link. - */ - - /* Is it the first directory in the file? */ - if (tif->tif_header.tiff_diroff == tif->tif_diroff) - { - tif->tif_header.tiff_diroff = 0; - tif->tif_diroff = 0; - - TIFFSeekFile(tif, (toff_t)(TIFF_MAGIC_SIZE+TIFF_VERSION_SIZE), - SEEK_SET); - if (!WriteOK(tif, &(tif->tif_header.tiff_diroff), - sizeof (tif->tif_diroff))) - { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error updating TIFF header"); - return (0); - } - } - else - { - toff_t nextdir, off; - - nextdir = tif->tif_header.tiff_diroff; - do { - uint16 dircount; - - if (!SeekOK(tif, nextdir) || - !ReadOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void) TIFFSeekFile(tif, - dircount * sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, &nextdir, sizeof (nextdir))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - } while (nextdir != tif->tif_diroff && nextdir != 0); - off = TIFFSeekFile(tif, 0, SEEK_CUR); /* get current offset */ - (void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET); - tif->tif_diroff = 0; - if (!WriteOK(tif, &(tif->tif_diroff), sizeof (nextdir))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); - return (0); - } - } - - /* - ** Now use TIFFWriteDirectory() normally. - */ - - return TIFFWriteDirectory( tif ); -} - - -/* - * Link the current directory into the - * directory chain for the file. - */ -static int -TIFFLinkDirectory(TIFF* tif) -{ - static const char module[] = "TIFFLinkDirectory"; - toff_t nextdir; - toff_t diroff, off; - - tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; - diroff = tif->tif_diroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&diroff); - - /* - * Handle SubIFDs - */ - if (tif->tif_flags & TIFF_INSUBIFD) { - (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Error writing SubIFD directory link", - tif->tif_name); - return (0); - } - /* - * Advance to the next SubIFD or, if this is - * the last one configured, revert back to the - * normal directory linkage. - */ - if (--tif->tif_nsubifd) - tif->tif_subifdoff += sizeof (diroff); - else - tif->tif_flags &= ~TIFF_INSUBIFD; - return (1); - } - - if (tif->tif_header.tiff_diroff == 0) { - /* - * First directory, overwrite offset in header. - */ - tif->tif_header.tiff_diroff = tif->tif_diroff; - (void) TIFFSeekFile(tif, - (toff_t)(TIFF_MAGIC_SIZE+TIFF_VERSION_SIZE), - SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing TIFF header"); - return (0); - } - return (1); - } - /* - * Not the first directory, search to the last and append. - */ - nextdir = tif->tif_header.tiff_diroff; - do { - uint16 dircount; - - if (!SeekOK(tif, nextdir) || - !ReadOK(tif, &dircount, sizeof (dircount))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void) TIFFSeekFile(tif, - dircount * sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, &nextdir, sizeof (nextdir))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - } while (nextdir != 0); - off = TIFFSeekFile(tif, 0, SEEK_CUR); /* get current offset */ - (void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); - return (0); - } - return (1); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_msdos.c b/libs/tiff-3.8.2/libtiff/tif_msdos.c deleted file mode 100644 index de1c4bb9d6..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_msdos.c +++ /dev/null @@ -1,179 +0,0 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_msdos.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library MSDOS-specific Routines. - */ -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#include /* for open, close, etc. function prototypes */ -#include -#endif -#include "tiffiop.h" - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (read((int) fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (write((int) fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return (lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (void*) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - fd = open(name, m|O_BINARY, 0666); - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -#ifdef __GNUC__ -extern char* malloc(); -extern char* realloc(); -#else -#include -#endif - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -msdosWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; - -static void -msdosErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; diff --git a/libs/tiff-3.8.2/libtiff/tif_ojpeg.c b/libs/tiff-3.8.2/libtiff/tif_ojpeg.c deleted file mode 100644 index 40bc5735c6..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_ojpeg.c +++ /dev/null @@ -1,2629 +0,0 @@ -/* $Id: tif_ojpeg.c,v 1.16 2006/03/01 11:09:13 dron Exp $ */ - -#include "tiffiop.h" -#ifdef OJPEG_SUPPORT - -/* JPEG Compression support, as per the original TIFF 6.0 specification. - - WARNING: KLUDGE ALERT! The type of JPEG encapsulation defined by the TIFF - Version 6.0 specification is now totally obsolete and - deprecated for new applications and images. This file is an unsupported hack - that was created solely in order to read (but NOT write!) a few old, - unconverted images still present on some users' computer systems. The code - isn't pretty or robust, and it won't read every "old format" JPEG-in-TIFF - file (see Samuel Leffler's draft "TIFF Technical Note No. 2" for a long and - incomplete list of known problems), but it seems to work well enough in the - few cases of practical interest to the author; so, "caveat emptor"! This - file should NEVER be enhanced to write new images using anything other than - the latest approved JPEG-in-TIFF encapsulation method, implemented by the - "tif_jpeg.c" file elsewhere in this library. - - This file interfaces with Release 6B of the JPEG Library written by theu - Independent JPEG Group, which you can find on the Internet at: - ftp://ftp.uu.net:/graphics/jpeg/. - - The "C" Preprocessor macros, "[CD]_LOSSLESS_SUPPORTED", are defined by your - JPEG Library Version 6B only if you have applied a (massive!) patch by Ken - Murchison of Oceana Matrix Ltd. to support lossless Huffman - encoding (TIFF "JPEGProc" tag value = 14). This patch can be found on the - Internet at: ftp://ftp.oceana.com/pub/ljpeg-6b.tar.gz. - - Some old files produced by the Wang Imaging application for Microsoft Windows - apparently can be decoded only with a special patch to the JPEG Library, - which defines a subroutine named "jpeg_reset_huff_decode()" in its "jdhuff.c" - module (the "jdshuff.c" module, if Ken Murchison's patch has been applied). - Unfortunately the patch differs slightly in each case, and some TIFF Library - have reported problems finding the code, so both versions appear below; you - should carefully extract and apply only the version that applies to your JPEG - Library! - - Contributed by Scott Marovich with considerable help - from Charles Auer to unravel the mysteries of image files - created by the Wang Imaging application for Microsoft Windows. -*/ -#if 0 /* Patch for JPEG Library WITHOUT lossless Huffman coding */ -*** jdhuff.c.orig Mon Oct 20 17:51:10 1997 ---- jdhuff.c Sun Nov 11 17:33:58 2001 -*************** -*** 648,651 **** ---- 648,683 ---- - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } - } -+ -+ /* -+ * BEWARE OF KLUDGE: This subroutine is a hack for decoding illegal JPEG-in- -+ * TIFF encapsulations produced by Microsoft's Wang Imaging -+ * for Windows application with the public-domain TIFF Library. Based upon an -+ * examination of selected output files, this program apparently divides a JPEG -+ * bit-stream into consecutive horizontal TIFF "strips", such that the JPEG -+ * encoder's/decoder's DC coefficients for each image component are reset before -+ * each "strip". Moreover, a "strip" is not necessarily encoded in a multiple -+ * of 8 bits, so one must sometimes discard 1-7 bits at the end of each "strip" -+ * for alignment to the next input-Byte storage boundary. IJG JPEG Library -+ * decoder state is not normally exposed to client applications, so this sub- -+ * routine provides the TIFF Library with a "hook" to make these corrections. -+ * It should be called after "jpeg_start_decompress()" and before -+ * "jpeg_finish_decompress()", just before decoding each "strip" using -+ * "jpeg_read_raw_data()" or "jpeg_read_scanlines()". -+ * -+ * This kludge is not sanctioned or supported by the Independent JPEG Group, and -+ * future changes to the IJG JPEG Library might invalidate it. Do not send bug -+ * reports about this code to IJG developers. Instead, contact the author for -+ * advice: Scott B. Marovich , Hewlett-Packard Labs, 6/01. -+ */ -+ GLOBAL(void) -+ jpeg_reset_huff_decode (register j_decompress_ptr cinfo) -+ { register huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy; -+ register int ci = 0; -+ -+ /* Discard encoded input bits, up to the next Byte boundary */ -+ entropy->bitstate.bits_left &= ~7; -+ /* Re-initialize DC predictions to 0 */ -+ do entropy->saved.last_dc_val[ci] = 0; while (++ci < cinfo->comps_in_scan); -+ } -#endif /* Patch for JPEG Library WITHOUT lossless Huffman coding */ -#if 0 /* Patch for JPEG Library WITH lossless Huffman coding */ -*** jdshuff.c.orig Mon Mar 11 16:44:54 2002 ---- jdshuff.c Mon Mar 11 16:44:54 2002 -*************** -*** 357,360 **** ---- 357,393 ---- - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } - } -+ -+ /* -+ * BEWARE OF KLUDGE: This subroutine is a hack for decoding illegal JPEG-in- -+ * TIFF encapsulations produced by Microsoft's Wang Imaging -+ * for Windows application with the public-domain TIFF Library. Based upon an -+ * examination of selected output files, this program apparently divides a JPEG -+ * bit-stream into consecutive horizontal TIFF "strips", such that the JPEG -+ * encoder's/decoder's DC coefficients for each image component are reset before -+ * each "strip". Moreover, a "strip" is not necessarily encoded in a multiple -+ * of 8 bits, so one must sometimes discard 1-7 bits at the end of each "strip" -+ * for alignment to the next input-Byte storage boundary. IJG JPEG Library -+ * decoder state is not normally exposed to client applications, so this sub- -+ * routine provides the TIFF Library with a "hook" to make these corrections. -+ * It should be called after "jpeg_start_decompress()" and before -+ * "jpeg_finish_decompress()", just before decoding each "strip" using -+ * "jpeg_read_raw_data()" or "jpeg_read_scanlines()". -+ * -+ * This kludge is not sanctioned or supported by the Independent JPEG Group, and -+ * future changes to the IJG JPEG Library might invalidate it. Do not send bug -+ * reports about this code to IJG developers. Instead, contact the author for -+ * advice: Scott B. Marovich , Hewlett-Packard Labs, 6/01. -+ */ -+ GLOBAL(void) -+ jpeg_reset_huff_decode (register j_decompress_ptr cinfo) -+ { register shuff_entropy_ptr entropy = (shuff_entropy_ptr) -+ ((j_lossy_d_ptr)cinfo->codec)->entropy_private; -+ register int ci = 0; -+ -+ /* Discard encoded input bits, up to the next Byte boundary */ -+ entropy->bitstate.bits_left &= ~7; -+ /* Re-initialize DC predictions to 0 */ -+ do entropy->saved.last_dc_val[ci] = 0; while (++ci < cinfo->comps_in_scan); -+ } -#endif /* Patch for JPEG Library WITH lossless Huffman coding */ -#include -#include -#ifdef FAR -#undef FAR /* Undefine FAR to avoid conflict with JPEG definition */ -#endif -#define JPEG_INTERNALS /* Include "jpegint.h" for "DSTATE_*" symbols */ -#define JPEG_CJPEG_DJPEG /* Include all Version 6B+ "jconfig.h" options */ -#undef INLINE -#include "jpeglib.h" -#undef JPEG_CJPEG_DJPEG -#undef JPEG_INTERNALS - -/* Hack for files produced by Wang Imaging application on Microsoft Windows */ -extern void jpeg_reset_huff_decode(j_decompress_ptr); - -/* On some machines, it may be worthwhile to use "_setjmp()" or "sigsetjmp()" - instead of "setjmp()". These macros make it easier: -*/ -#define SETJMP(jbuf)setjmp(jbuf) -#define LONGJMP(jbuf,code)longjmp(jbuf,code) -#define JMP_BUF jmp_buf - -#define TIFFTAG_WANG_PAGECONTROL 32934 - -/* Bit-vector offsets for keeping track of TIFF records that we've parsed. */ - -#define FIELD_JPEGPROC FIELD_CODEC -#define FIELD_JPEGIFOFFSET (FIELD_CODEC+1) -#define FIELD_JPEGIFBYTECOUNT (FIELD_CODEC+2) -#define FIELD_JPEGRESTARTINTERVAL (FIELD_CODEC+3) -#define FIELD_JPEGTABLES (FIELD_CODEC+4) /* New, post-6.0 JPEG-in-TIFF tag! */ -#define FIELD_JPEGLOSSLESSPREDICTORS (FIELD_CODEC+5) -#define FIELD_JPEGPOINTTRANSFORM (FIELD_CODEC+6) -#define FIELD_JPEGQTABLES (FIELD_CODEC+7) -#define FIELD_JPEGDCTABLES (FIELD_CODEC+8) -#define FIELD_JPEGACTABLES (FIELD_CODEC+9) -#define FIELD_WANG_PAGECONTROL (FIELD_CODEC+10) -#define FIELD_JPEGCOLORMODE (FIELD_CODEC+11) - -typedef struct jpeg_destination_mgr jpeg_destination_mgr; -typedef struct jpeg_source_mgr jpeg_source_mgr; -typedef struct jpeg_error_mgr jpeg_error_mgr; - -/* State variable for each open TIFF file that uses "libjpeg" for JPEG - decompression. (Note: This file should NEVER perform JPEG compression - except in the manner implemented by the "tif_jpeg.c" file, elsewhere in this - library; see comments above.) JPEG Library internal state is recorded in a - "jpeg_{de}compress_struct", while a "jpeg_common_struct" records a few items - common to both compression and expansion. The "cinfo" field containing JPEG - Library state MUST be the 1st member of our own state variable, so that we - can safely "cast" pointers back and forth. -*/ -typedef struct /* This module's private, per-image state variable */ - { - union /* JPEG Library state variable; this MUST be our 1st field! */ - { - struct jpeg_compress_struct c; - struct jpeg_decompress_struct d; - struct jpeg_common_struct comm; - } cinfo; - jpeg_error_mgr err; /* JPEG Library error manager */ - JMP_BUF exit_jmpbuf; /* ...for catching JPEG Library failures */ -# ifdef never - - /* (The following two fields could be a "union", but they're small enough that - it's not worth the effort.) - */ - jpeg_destination_mgr dest; /* Destination for compressed data */ -# endif - jpeg_source_mgr src; /* Source of expanded data */ - JSAMPARRAY ds_buffer[MAX_COMPONENTS]; /* ->Temporary downsampling buffers */ - TIFF *tif; /* Reverse pointer, needed by some code */ - TIFFVGetMethod vgetparent; /* "Super class" methods... */ - TIFFVSetMethod vsetparent; - TIFFStripMethod defsparent; - TIFFTileMethod deftparent; - void *jpegtables; /* ->"New" JPEG tables, if we synthesized any */ - uint32 is_WANG, /* <=> Wang Imaging for Microsoft Windows output file? */ - jpegtables_length; /* Length of "new" JPEG tables, if they exist */ - tsize_t bytesperline; /* No. of decompressed Bytes per scan line */ - int jpegquality, /* Compression quality level */ - jpegtablesmode, /* What to put in JPEGTables */ - samplesperclump, - scancount; /* No. of scan lines accumulated */ - J_COLOR_SPACE photometric; /* IJG JPEG Library's photometry code */ - unsigned char h_sampling, /* Luminance sampling factors */ - v_sampling, - jpegcolormode; /* Who performs RGB <-> YCbCr conversion? */ - /* JPEGCOLORMODE_RAW <=> TIFF Library or its client */ - /* JPEGCOLORMODE_RGB <=> JPEG Library */ - /* These fields are added to support TIFFGetField */ - uint16 jpegproc; - uint32 jpegifoffset; - uint32 jpegifbytecount; - uint32 jpegrestartinterval; - void* jpeglosslesspredictors; - uint16 jpeglosslesspredictors_length; - void* jpegpointtransform; - uint32 jpegpointtransform_length; - void* jpegqtables; - uint32 jpegqtables_length; - void* jpegdctables; - uint32 jpegdctables_length; - void* jpegactables; - uint32 jpegactables_length; - - } OJPEGState; -#define OJState(tif)((OJPEGState*)(tif)->tif_data) - -static const TIFFFieldInfo ojpegFieldInfo[]=/* JPEG-specific TIFF-record tags */ - { - - /* This is the current JPEG-in-TIFF metadata-encapsulation tag, and its - treatment in this file is idiosyncratic. It should never appear in a - "source" image conforming to the TIFF Version 6.0 specification, so we - arrange to report an error if it appears. But in order to support possible - future conversion of "old" JPEG-in-TIFF encapsulations to "new" ones, we - might wish to synthesize an equivalent value to be returned by the TIFF - Library's "getfield" method. So, this table tells the TIFF Library to pass - these records to us in order to filter them below. - */ - { - TIFFTAG_JPEGTABLES ,TIFF_VARIABLE2,TIFF_VARIABLE2, - TIFF_UNDEFINED,FIELD_JPEGTABLES ,FALSE,TRUE ,"JPEGTables" - }, - - /* These tags are defined by the TIFF Version 6.0 specification and are now - obsolete. This module reads them from an old "source" image, but it never - writes them to a new "destination" image. - */ - { - TIFFTAG_JPEGPROC ,1 ,1 , - TIFF_SHORT ,FIELD_JPEGPROC ,FALSE,FALSE,"JPEGProc" - }, - { - TIFFTAG_JPEGIFOFFSET ,1 ,1 , - TIFF_LONG ,FIELD_JPEGIFOFFSET ,FALSE,FALSE,"JPEGInterchangeFormat" - }, - { - TIFFTAG_JPEGIFBYTECOUNT ,1 ,1 , - TIFF_LONG ,FIELD_JPEGIFBYTECOUNT ,FALSE,FALSE,"JPEGInterchangeFormatLength" - }, - { - TIFFTAG_JPEGRESTARTINTERVAL ,1 ,1 , - TIFF_SHORT ,FIELD_JPEGRESTARTINTERVAL ,FALSE,FALSE,"JPEGRestartInterval" - }, - { - TIFFTAG_JPEGLOSSLESSPREDICTORS,TIFF_VARIABLE,TIFF_VARIABLE, - TIFF_SHORT ,FIELD_JPEGLOSSLESSPREDICTORS,FALSE,TRUE ,"JPEGLosslessPredictors" - }, - { - TIFFTAG_JPEGPOINTTRANSFORM ,TIFF_VARIABLE,TIFF_VARIABLE, - TIFF_SHORT ,FIELD_JPEGPOINTTRANSFORM ,FALSE,TRUE ,"JPEGPointTransforms" - }, - { - TIFFTAG_JPEGQTABLES ,TIFF_VARIABLE,TIFF_VARIABLE, - TIFF_LONG ,FIELD_JPEGQTABLES ,FALSE,TRUE ,"JPEGQTables" - }, - { - TIFFTAG_JPEGDCTABLES ,TIFF_VARIABLE,TIFF_VARIABLE, - TIFF_LONG ,FIELD_JPEGDCTABLES ,FALSE,TRUE ,"JPEGDCTables" - }, - { - TIFFTAG_JPEGACTABLES ,TIFF_VARIABLE,TIFF_VARIABLE, - TIFF_LONG ,FIELD_JPEGACTABLES ,FALSE,TRUE ,"JPEGACTables" - }, - { - TIFFTAG_WANG_PAGECONTROL ,TIFF_VARIABLE,1 , - TIFF_LONG ,FIELD_WANG_PAGECONTROL ,FALSE,FALSE,"WANG PageControl" - }, - - /* This is a pseudo tag intended for internal use only by the TIFF Library and - its clients, which should never appear in an input/output image file. It - specifies whether the TIFF Library (or its client) should do YCbCr <-> RGB - color-space conversion (JPEGCOLORMODE_RAW <=> 0) or whether we should ask - the JPEG Library to do it (JPEGCOLORMODE_RGB <=> 1). - */ - { - TIFFTAG_JPEGCOLORMODE ,0 ,0 , - TIFF_ANY ,FIELD_PSEUDO ,FALSE,FALSE,"JPEGColorMode" - } - }; -static const char JPEGLib_name[]={"JPEG Library"}, - bad_bps[]={"%u BitsPerSample not allowed for JPEG"}, - bad_photometry[]={"PhotometricInterpretation %u not allowed for JPEG"}, - bad_subsampling[]={"invalid YCbCr subsampling factor(s)"}, -# ifdef never - no_write_frac[]={"fractional scan line discarded"}, -# endif - no_read_frac[]={"fractional scan line not read"}, - no_jtable_space[]={"No space for JPEGTables"}; - -/* The following diagnostic subroutines interface with and replace default - subroutines in the JPEG Library. Our basic strategy is to use "setjmp()"/ - "longjmp()" in order to return control to the TIFF Library when the JPEG - library detects an error, and to use TIFF Library subroutines for displaying - diagnostic messages to a client application. -*/ -static void -TIFFojpeg_error_exit(register j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - int code = cinfo->err->msg_code; - - if (((OJPEGState *)cinfo)->is_WANG) { - if (code == JERR_SOF_DUPLICATE || code == JERR_SOI_DUPLICATE) - return; /* ignore it */ - } - - (*cinfo->err->format_message)(cinfo,buffer); - TIFFError(JPEGLib_name,buffer); /* Display error message */ - jpeg_abort(cinfo); /* Clean up JPEG Library state */ - LONGJMP(((OJPEGState *)cinfo)->exit_jmpbuf,1); /* Return to TIFF client */ -} - -static void -TIFFojpeg_output_message(register j_common_ptr cinfo) - { char buffer[JMSG_LENGTH_MAX]; - - /* This subroutine is invoked only for warning messages, since the JPEG - Library's "error_exit" method does its own thing and "trace_level" is never - set > 0. - */ - (*cinfo->err->format_message)(cinfo,buffer); - TIFFWarning(JPEGLib_name,buffer); - } - -/* The following subroutines, which also interface with the JPEG Library, exist - mainly in limit the side effects of "setjmp()" and convert JPEG normal/error - conditions into TIFF Library return codes. -*/ -#define CALLJPEG(sp,fail,op)(SETJMP((sp)->exit_jmpbuf)?(fail):(op)) -#define CALLVJPEG(sp,op)CALLJPEG(sp,0,((op),1)) -#ifdef never - -static int -TIFFojpeg_create_compress(register OJPEGState *sp) - { - sp->cinfo.c.err = jpeg_std_error(&sp->err); /* Initialize error handling */ - sp->err.error_exit = TIFFojpeg_error_exit; - sp->err.output_message = TIFFojpeg_output_message; - return CALLVJPEG(sp,jpeg_create_compress(&sp->cinfo.c)); - } - -/* The following subroutines comprise a JPEG Library "destination" data manager - by directing compressed data from the JPEG Library to a TIFF Library output - buffer. -*/ -static void -std_init_destination(register j_compress_ptr cinfo){} /* "Dummy" stub */ - -static boolean -std_empty_output_buffer(register j_compress_ptr cinfo) - { -# define sp ((OJPEGState *)cinfo) - register TIFF *tif = sp->tif; - - tif->tif_rawcc = tif->tif_rawdatasize; /* Entire buffer has been filled */ - TIFFFlushData1(tif); - sp->dest.next_output_byte = (JOCTET *)tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t)tif->tif_rawdatasize; - return TRUE; -# undef sp - } - -static void -std_term_destination(register j_compress_ptr cinfo) - { -# define sp ((OJPEGState *)cinfo) - register TIFF *tif = sp->tif; - - /* NB: The TIFF Library does the final buffer flush. */ - tif->tif_rawcp = (tidata_t)sp->dest.next_output_byte; - tif->tif_rawcc = tif->tif_rawdatasize - (tsize_t)sp->dest.free_in_buffer; -# undef sp - } - -/* Alternate destination manager to output JPEGTables field: */ - -static void -tables_init_destination(register j_compress_ptr cinfo) - { -# define sp ((OJPEGState *)cinfo) - /* The "jpegtables_length" field is the allocated buffer size while building */ - sp->dest.next_output_byte = (JOCTET *)sp->jpegtables; - sp->dest.free_in_buffer = (size_t)sp->jpegtables_length; -# undef sp - } - -static boolean -tables_empty_output_buffer(register j_compress_ptr cinfo) - { void *newbuf; -# define sp ((OJPEGState *)cinfo) - - /* The entire buffer has been filled, so enlarge it by 1000 bytes. */ - if (!( newbuf = _TIFFrealloc( (tdata_t)sp->jpegtables - , (tsize_t)(sp->jpegtables_length + 1000) - ) - ) - ) ERREXIT1(cinfo,JERR_OUT_OF_MEMORY,100); - sp->dest.next_output_byte = (JOCTET *)newbuf + sp->jpegtables_length; - sp->dest.free_in_buffer = (size_t)1000; - sp->jpegtables = newbuf; - sp->jpegtables_length += 1000; - return TRUE; -# undef sp - } - -static void -tables_term_destination(register j_compress_ptr cinfo) - { -# define sp ((OJPEGState *)cinfo) - /* Set tables length to no. of Bytes actually emitted. */ - sp->jpegtables_length -= sp->dest.free_in_buffer; -# undef sp - } - -/*ARGSUSED*/ static int -TIFFojpeg_tables_dest(register OJPEGState *sp, TIFF *tif) - { - - /* Allocate a working buffer for building tables. The initial size is 1000 - Bytes, which is usually adequate. - */ - if (sp->jpegtables) _TIFFfree(sp->jpegtables); - if (!(sp->jpegtables = (void*) - _TIFFmalloc((tsize_t)(sp->jpegtables_length = 1000)) - ) - ) - { - sp->jpegtables_length = 0; - TIFFError("TIFFojpeg_tables_dest",no_jtable_space); - return 0; - }; - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = tables_init_destination; - sp->dest.empty_output_buffer = tables_empty_output_buffer; - sp->dest.term_destination = tables_term_destination; - return 1; - } -#else /* well, hardly ever */ - -static int -_notSupported(register TIFF *tif) - { const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression); - - TIFFError(tif->tif_name,"%s compression not supported",c->name); - return 0; - } -#endif /* never */ - -/* The following subroutines comprise a JPEG Library "source" data manager by - by directing compressed data to the JPEG Library from a TIFF Library input - buffer. -*/ -static void -std_init_source(register j_decompress_ptr cinfo) - { -# define sp ((OJPEGState *)cinfo) - register TIFF *tif = sp->tif; - - if (sp->src.bytes_in_buffer == 0) - { - sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata; - sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc; - }; -# undef sp - } - -static boolean -std_fill_input_buffer(register j_decompress_ptr cinfo) - { static const JOCTET dummy_EOI[2]={0xFF,JPEG_EOI}; -# define sp ((OJPEGState *)cinfo) - - /* Control should never get here, since an entire strip/tile is read into - memory before the decompressor is called; thus, data should have been - supplied by the "init_source" method. ...But, sometimes things fail. - */ - WARNMS(cinfo,JWRN_JPEG_EOF); - sp->src.next_input_byte = dummy_EOI; /* Insert a fake EOI marker */ - sp->src.bytes_in_buffer = sizeof dummy_EOI; - return TRUE; -# undef sp - } - -static void -std_skip_input_data(register j_decompress_ptr cinfo, long num_bytes) - { -# define sp ((OJPEGState *)cinfo) - - if (num_bytes > 0) - { - if (num_bytes > (long)sp->src.bytes_in_buffer) /* oops: buffer overrun */ - (void)std_fill_input_buffer(cinfo); - else - { - sp->src.next_input_byte += (size_t)num_bytes; - sp->src.bytes_in_buffer -= (size_t)num_bytes; - } - } -# undef sp - } - -/*ARGSUSED*/ static void -std_term_source(register j_decompress_ptr cinfo){} /* "Dummy" stub */ - -/* Allocate temporary I/O buffers for downsampled data, using values computed in - "jpeg_start_{de}compress()". We use the JPEG Library's allocator so that - buffers will be released automatically when done with a strip/tile. This is - also a handy place to compute samplesperclump, bytesperline, etc. -*/ -static int -alloc_downsampled_buffers(TIFF *tif,jpeg_component_info *comp_info, - int num_components) - { register OJPEGState *sp = OJState(tif); - - sp->samplesperclump = 0; - if (num_components > 0) - { tsize_t size = sp->cinfo.comm.is_decompressor -# ifdef D_LOSSLESS_SUPPORTED - ? sp->cinfo.d.min_codec_data_unit -# else - ? DCTSIZE -# endif -# ifdef C_LOSSLESS_SUPPORTED - : sp->cinfo.c.data_unit; -# else - : DCTSIZE; -# endif - int ci = 0; - register jpeg_component_info *compptr = comp_info; - - do - { JSAMPARRAY buf; - - sp->samplesperclump += - compptr->h_samp_factor * compptr->v_samp_factor; -# if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED) - if (!(buf = CALLJPEG(sp,0,(*sp->cinfo.comm.mem->alloc_sarray)(&sp->cinfo.comm,JPOOL_IMAGE,compptr->width_in_data_units*size,compptr->v_samp_factor*size)))) -# else - if (!(buf = CALLJPEG(sp,0,(*sp->cinfo.comm.mem->alloc_sarray)(&sp->cinfo.comm,JPOOL_IMAGE,compptr->width_in_blocks*size,compptr->v_samp_factor*size)))) -# endif - return 0; - sp->ds_buffer[ci] = buf; - } - while (++compptr,++ci < num_components); - }; - return 1; - } -#ifdef never - -/* JPEG Encoding begins here. */ - -/*ARGSUSED*/ static int -OJPEGEncode(register TIFF *tif,tidata_t buf,tsize_t cc,tsample_t s) - { tsize_t rows; /* No. of unprocessed rows in file */ - register OJPEGState *sp = OJState(tif); - - /* Encode a chunk of pixels, where returned data is NOT down-sampled (the - standard case). The data is expected to be written in scan-line multiples. - */ - if (cc % sp->bytesperline) TIFFWarning(tif->tif_name,no_write_frac); - if ( (cc /= bytesperline) /* No. of complete rows in caller's buffer */ - > (rows = sp->cinfo.c.image_height - sp->cinfo.c.next_scanline) - ) cc = rows; - while (--cc >= 0) - { - if ( CALLJPEG(sp,-1,jpeg_write_scanlines(&sp->cinfo.c,(JSAMPARRAY)&buf,1)) - != 1 - ) return 0; - ++tif->tif_row; - buf += sp->bytesperline; - }; - return 1; - } - -/*ARGSUSED*/ static int -OJPEGEncodeRaw(register TIFF *tif,tidata_t buf,tsize_t cc,tsample_t s) - { tsize_t rows; /* No. of unprocessed rows in file */ - JDIMENSION lines_per_MCU, size; - register OJPEGState *sp = OJState(tif); - - /* Encode a chunk of pixels, where returned data is down-sampled as per the - sampling factors. The data is expected to be written in scan-line - multiples. - */ - cc /= sp->bytesperline; - if (cc % sp->bytesperline) TIFFWarning(tif->tif_name,no_write_frac); - if ( (cc /= bytesperline) /* No. of complete rows in caller's buffer */ - > (rows = sp->cinfo.c.image_height - sp->cinfo.c.next_scanline) - ) cc = rows; -# ifdef C_LOSSLESS_SUPPORTED - lines_per_MCU = sp->cinfo.c.max_samp_factor*(size = sp->cinfo.d.data_unit); -# else - lines_per_MCU = sp->cinfo.c.max_samp_factor*(size = DCTSIZE); -# endif - while (--cc >= 0) - { int ci = 0, clumpoffset = 0; - register jpeg_component_info *compptr = sp->cinfo.c.comp_info; - - /* The fastest way to separate the data is to make 1 pass over the scan - line for each row of each component. - */ - do - { int ypos = 0; - - do - { int padding; - register JSAMPLE *inptr = (JSAMPLE*)buf + clumpoffset, - *outptr = - sp->ds_buffer[ci][sp->scancount*compptr->v_samp_factor+ypos]; - /* Cb,Cr both have sampling factors 1, so this is correct */ - register int clumps_per_line = - sp->cinfo.c.comp_info[1].downsampled_width, - xpos; - - padding = (int) -# ifdef C_LOSSLESS_SUPPORTED - ( compptr->width_in_data_units * size -# else - ( compptr->width_in_blocks * size -# endif - - clumps_per_line * compptr->h_samp_factor - ); - if (compptr->h_samp_factor == 1) /* Cb & Cr fast path */ - do *outptr++ = *inptr; - while ((inptr += sp->samplesperclump),--clumps_per_line > 0); - else /* general case */ - do - { - xpos = 0; - do *outptr++ = inptr[xpos]; - while (++xpos < compptr->h_samp_factor); - } - while ((inptr += sp->samplesperclump),--clumps_per_line > 0); - xpos = 0; /* Pad each scan line as needed */ - do outptr[0] = outptr[-1]; while (++outptr,++xpos < padding); - clumpoffset += compptr->h_samp_factor; - } - while (++ypos < compptr->v_samp_factor); - } - while (++compptr,++ci < sp->cinfo.c.num_components); - if (++sp->scancount >= size) - { - if ( CALLJPEG(sp,-1,jpeg_write_raw_data(&sp->cinfo.c,sp->ds_buffer,lines_per_MCU)) - != lines_per_MCU - ) return 0; - sp->scancount = 0; - }; - ++tif->tif_row++ - buf += sp->bytesperline; - }; - return 1; - } - -static int -OJPEGSetupEncode(register TIFF *tif) - { static const char module[]={"OJPEGSetupEncode"}; - uint32 segment_height, segment_width; - int status = 1; /* Assume success by default */ - register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - - /* Verify miscellaneous parameters. This will need work if the TIFF Library - ever supports different depths for different components, or if the JPEG - Library ever supports run-time depth selection. Neither seems imminent. - */ - if (td->td_bitspersample != 8) - { - TIFFError(module,bad_bps,td->td_bitspersample); - status = 0; - }; - - /* The TIFF Version 6.0 specification and IJG JPEG Library accept different - sets of color spaces, so verify that our image belongs to the common subset - and map its photometry code, then initialize to handle subsampling and - optional JPEG Library YCbCr <-> RGB color-space conversion. - */ - switch (td->td_photometric) - { - case PHOTOMETRIC_YCBCR : - - /* ISO IS 10918-1 requires that JPEG subsampling factors be 1-4, but - TIFF Version 6.0 is more restrictive: only 1, 2, and 4 are allowed. - */ - if ( ( td->td_ycbcrsubsampling[0] == 1 - || td->td_ycbcrsubsampling[0] == 2 - || td->td_ycbcrsubsampling[0] == 4 - ) - && ( td->td_ycbcrsubsampling[1] == 1 - || td->td_ycbcrsubsampling[1] == 2 - || td->td_ycbcrsubsampling[1] == 4 - ) - ) - sp->cinfo.c.raw_data_in = - ( (sp->h_sampling = td->td_ycbcrsubsampling[0]) << 3 - | (sp->v_sampling = td->td_ycbcrsubsampling[1]) - ) != 011; - else - { - TIFFError(module,bad_subsampling); - status = 0; - }; - - /* A ReferenceBlackWhite field MUST be present, since the default value - is inapproriate for YCbCr. Fill in the proper value if the - application didn't set it. - */ - if (!TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) - { float refbw[6]; - long top = 1L << td->td_bitspersample; - - refbw[0] = 0; - refbw[1] = (float)(top-1L); - refbw[2] = (float)(top>>1); - refbw[3] = refbw[1]; - refbw[4] = refbw[2]; - refbw[5] = refbw[1]; - TIFFSetField(tif,TIFFTAG_REFERENCEBLACKWHITE,refbw); - }; - sp->cinfo.c.jpeg_color_space = JCS_YCbCr; - if (sp->jpegcolormode == JPEGCOLORMODE_RGB) - { - sp->cinfo.c.raw_data_in = FALSE; - sp->in_color_space = JCS_RGB; - break; - }; - goto L2; - case PHOTOMETRIC_MINISBLACK: - sp->cinfo.c.jpeg_color_space = JCS_GRAYSCALE; - goto L1; - case PHOTOMETRIC_RGB : - sp->cinfo.c.jpeg_color_space = JCS_RGB; - goto L1; - case PHOTOMETRIC_SEPARATED : - sp->cinfo.c.jpeg_color_space = JCS_CMYK; - L1: sp->jpegcolormode = JPEGCOLORMODE_RAW; /* No JPEG Lib. conversion */ - L2: sp->cinfo.d.in_color_space = sp->cinfo.d.jpeg_color-space; - break; - default : - TIFFError(module,bad_photometry,td->td_photometric); - status = 0; - }; - tif->tif_encoderow = tif->tif_encodestrip = tif->tif_encodetile = - sp->cinfo.c.raw_data_in ? OJPEGEncodeRaw : OJPEGEncode; - if (isTiled(tif)) - { tsize_t size; - -# ifdef C_LOSSLESS_SUPPORTED - if ((size = sp->v_sampling*sp->cinfo.c.data_unit) < 16) size = 16; -# else - if ((size = sp->v_sampling*DCTSIZE) < 16) size = 16; -# endif - if ((segment_height = td->td_tilelength) % size) - { - TIFFError(module,"JPEG tile height must be multiple of %d",size); - status = 0; - }; -# ifdef C_LOSSLESS_SUPPORTED - if ((size = sp->h_sampling*sp->cinfo.c.data_unit) < 16) size = 16; -# else - if ((size = sp->h_sampling*DCTSIZE) < 16) size = 16; -# endif - if ((segment_width = td->td_tilewidth) % size) - { - TIFFError(module,"JPEG tile width must be multiple of %d",size); - status = 0; - }; - sp->bytesperline = TIFFTileRowSize(tif); - } - else - { tsize_t size; - -# ifdef C_LOSSLESS_SUPPORTED - if ((size = sp->v_sampling*sp->cinfo.c.data_unit) < 16) size = 16; -# else - if ((size = sp->v_sampling*DCTSIZE) < 16) size = 16; -# endif - if (td->td_rowsperstrip < (segment_height = td->td_imagelength)) - { - if (td->td_rowsperstrip % size) - { - TIFFError(module,"JPEG RowsPerStrip must be multiple of %d",size); - status = 0; - }; - segment_height = td->td_rowsperstrip; - }; - segment_width = td->td_imagewidth; - sp->bytesperline = tif->tif_scanlinesize; - }; - if (segment_width > 65535 || segment_height > 65535) - { - TIFFError(module,"Strip/tile too large for JPEG"); - status = 0; - }; - - /* Initialize all JPEG parameters to default values. Note that the JPEG - Library's "jpeg_set_defaults()" method needs legal values for the - "in_color_space" and "input_components" fields. - */ - sp->cinfo.c.input_components = 1; /* Default for JCS_UNKNOWN */ - if (!CALLVJPEG(sp,jpeg_set_defaults(&sp->cinfo.c))) status = 0; - switch (sp->jpegtablesmode & (JPEGTABLESMODE_HUFF|JPEGTABLESMODE_QUANT)) - { register JHUFF_TBL *htbl; - register JQUANT_TBL *qtbl; - - case 0 : - sp->cinfo.c.optimize_coding = TRUE; - case JPEGTABLESMODE_HUFF : - if (!CALLVJPEG(sp,jpeg_set_quality(&sp->cinfo.c,sp->jpegquality,FALSE))) - return 0; - if (qtbl = sp->cinfo.c.quant_tbl_ptrs[0]) qtbl->sent_table = FALSE; - if (qtbl = sp->cinfo.c.quant_tbl_ptrs[1]) qtbl->sent_table = FALSE; - goto L3; - case JPEGTABLESMODE_QUANT : - sp->cinfo.c.optimize_coding = TRUE; - - /* We do not support application-supplied JPEG tables, so mark the field - "not present". - */ - L3: TIFFClrFieldBit(tif,FIELD_JPEGTABLES); - break; - case JPEGTABLESMODE_HUFF|JPEGTABLESMODE_QUANT: - if ( !CALLVJPEG(sp,jpeg_set_quality(&sp->cinfo.c,sp->jpegquality,FALSE)) - || !CALLVJPEG(sp,jpeg_suppress_tables(&sp->cinfo.c,TRUE)) - ) - { - status = 0; - break; - }; - if (qtbl = sp->cinfo.c.quant_tbl_ptrs[0]) qtbl->sent_table = FALSE; - if (htbl = sp->cinfo.c.dc_huff_tbl_ptrs[0]) htbl->sent_table = FALSE; - if (htbl = sp->cinfo.c.ac_huff_tbl_ptrs[0]) htbl->sent_table = FALSE; - if (sp->cinfo.c.jpeg_color_space == JCS_YCbCr) - { - if (qtbl = sp->cinfo.c.quant_tbl_ptrs[1]) - qtbl->sent_table = FALSE; - if (htbl = sp->cinfo.c.dc_huff_tbl_ptrs[1]) - htbl->sent_table = FALSE; - if (htbl = sp->cinfo.c.ac_huff_tbl_ptrs[1]) - htbl->sent_table = FALSE; - }; - if ( TIFFojpeg_tables_dest(sp,tif) - && CALLVJPEG(sp,jpeg_write_tables(&sp->cinfo.c)) - ) - { - - /* Mark the field "present". We can't use "TIFFSetField()" because - "BEENWRITING" is already set! - */ - TIFFSetFieldBit(tif,FIELD_JPEGTABLES); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } - else status = 0; - }; - if ( sp->cinfo.c.raw_data_in - && !alloc_downsampled_buffers(tif,sp->cinfo.c.comp_info, - sp->cinfo.c.num_components) - ) status = 0; - if (status == 0) return 0; /* If TIFF errors, don't bother to continue */ - /* Grab parameters that are same for all strips/tiles. */ - - sp->dest.init_destination = std_init_destination; - sp->dest.empty_output_buffer = std_empty_output_buffer; - sp->dest.term_destination = std_term_destination; - sp->cinfo.c.dest = &sp->dest; - sp->cinfo.c.data_precision = td->td_bitspersample; - sp->cinfo.c.write_JFIF_header = /* Don't write extraneous markers */ - sp->cinfo.c.write_Adobe_marker = FALSE; - sp->cinfo.c.image_width = segment_width; - sp->cinfo.c.image_height = segment_height; - sp->cinfo.c.comp_info[0].h_samp_factor = - sp->cinfo.c.comp_info[0].v_samp_factor = 1; - return CALLVJPEG(sp,jpeg_start_compress(&sp->cinfo.c,FALSE)); -# undef td - } - -static int -OJPEGPreEncode(register TIFF *tif,tsample_t s) - { register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - - /* If we are about to write the first row of an image plane, which should - coincide with a JPEG "scan", reset the JPEG Library's compressor. Otherwise - let the compressor run "as is" and return a "success" status without further - ado. - */ - if ( (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip) - % td->td_stripsperimage - == 0 - ) - { - if ( (sp->cinfo.c.comp_info[0].component_id = s) == 1) - && sp->cinfo.c.jpeg_color_space == JCS_YCbCr - ) - { - sp->cinfo.c.comp_info[0].quant_tbl_no = - sp->cinfo.c.comp_info[0].dc_tbl_no = - sp->cinfo.c.comp_info[0].ac_tbl_no = 1; - sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; - sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; - - /* Scale expected strip/tile size to match a downsampled component. */ - - sp->cinfo.c.image_width = TIFFhowmany(segment_width,sp->h_sampling); - sp->cinfo.c.image_height=TIFFhowmany(segment_height,sp->v_sampling); - }; - sp->scancount = 0; /* Mark subsampling buffer(s) empty */ - }; - return 1; -# undef td - } - -static int -OJPEGPostEncode(register TIFF *tif) - { register OJPEGState *sp = OJState(tif); - - /* Finish up at the end of a strip or tile. */ - - if (sp->scancount > 0) /* emit partial buffer of down-sampled data */ - { JDIMENSION n; - -# ifdef C_LOSSLESS_SUPPORTED - if ( sp->scancount < sp->cinfo.c.data_unit - && sp->cinfo.c.num_components > 0 - ) -# else - if (sp->scancount < DCTSIZE && sp->cinfo.c.num_components > 0) -# endif - { int ci = 0, /* Pad the data vertically */ -# ifdef C_LOSSLESS_SUPPORTED - size = sp->cinfo.c.data_unit; -# else - size = DCTSIZE; -# endif - register jpeg_component_info *compptr = sp->cinfo.c.comp_info; - - do -# ifdef C_LOSSLESS_SUPPORTED - { tsize_t row_width = compptr->width_in_data_units -# else - tsize_t row_width = compptr->width_in_blocks -# endif - *size*sizeof(JSAMPLE); - int ypos = sp->scancount*compptr->v_samp_factor; - - do _TIFFmemcpy( (tdata_t)sp->ds_buffer[ci][ypos] - , (tdata_t)sp->ds_buffer[ci][ypos-1] - , row_width - ); - while (++ypos < compptr->v_samp_factor*size); - } - while (++compptr,++ci < sp->cinfo.c.num_components); - }; - n = sp->cinfo.c.max_v_samp_factor*size; - if (CALLJPEG(sp,-1,jpeg_write_raw_data(&sp->cinfo.c,sp->ds_buffer,n)) != n) - return 0; - }; - return CALLVJPEG(sp,jpeg_finish_compress(&sp->cinfo.c)); - } -#endif /* never */ - -/* JPEG Decoding begins here. */ - -/*ARGSUSED*/ static int -OJPEGDecode(register TIFF *tif,tidata_t buf,tsize_t cc,tsample_t s) - { tsize_t bytesperline = isTiled(tif) - ? TIFFTileRowSize(tif) - : tif->tif_scanlinesize, - rows; /* No. of unprocessed rows in file */ - register OJPEGState *sp = OJState(tif); - - /* Decode a chunk of pixels, where the input data has not NOT been down- - sampled, or else the TIFF Library's client has used the "JPEGColorMode" TIFF - pseudo-tag to request that the JPEG Library do color-space conversion; this - is the normal case. The data is expected to be read in scan-line multiples, - and this subroutine is called for both pixel-interleaved and separate color - planes. - - WARNING: Unlike "OJPEGDecodeRawContig()", below, the no. of Bytes in each - decoded row is calculated here as "bytesperline" instead of - using "sp->bytesperline", which might be a little smaller. This can - occur for an old tiled image whose width isn't a multiple of 8 pixels. - That's illegal according to the TIFF Version 6 specification, but some - test files, like "zackthecat.tif", were built that way. In those cases, - we want to embed the image's true width in our caller's buffer (which is - presumably allocated according to the expected tile width) by - effectively "padding" it with unused Bytes at the end of each row. - */ - if ( (cc /= bytesperline) /* No. of complete rows in caller's buffer */ - > (rows = sp->cinfo.d.output_height - sp->cinfo.d.output_scanline) - ) cc = rows; - while (--cc >= 0) - { - if ( CALLJPEG(sp,-1,jpeg_read_scanlines(&sp->cinfo.d,(JSAMPARRAY)&buf,1)) - != 1 - ) return 0; - buf += bytesperline; - ++tif->tif_row; - }; - - /* BEWARE OF KLUDGE: If our input file was produced by Microsoft's Wang - Imaging for Windows application, the DC coefficients of - each JPEG image component (Y,Cb,Cr) must be reset at the end of each TIFF - "strip", and any JPEG data bits remaining in the current Byte of the - decoder's input buffer must be discarded. To do so, we create an "ad hoc" - interface in the "jdhuff.c" module of IJG JPEG Library Version 6 (module - "jdshuff.c", if Ken Murchison's lossless-Huffman patch is applied), and we - invoke that interface here after decoding each "strip". - */ - if (sp->is_WANG) jpeg_reset_huff_decode(&sp->cinfo.d); - return 1; - } - -/*ARGSUSED*/ static int -OJPEGDecodeRawContig(register TIFF *tif,tidata_t buf,tsize_t cc,tsample_t s) - { tsize_t rows; /* No. of unprocessed rows in file */ - JDIMENSION lines_per_MCU, size; - register OJPEGState *sp = OJState(tif); - - /* Decode a chunk of pixels, where the input data has pixel-interleaved color - planes, some of which have been down-sampled, but the TIFF Library's client - has NOT used the "JPEGColorMode" TIFF pseudo-tag to request that the JPEG - Library do color-space conversion. In other words, we must up-sample/ - expand/duplicate image components according to the image's sampling factors, - without changing its color space. The data is expected to be read in scan- - line multiples. - */ - if ( (cc /= sp->bytesperline) /* No. of complete rows in caller's buffer */ - > (rows = sp->cinfo.d.output_height - sp->cinfo.d.output_scanline) - ) cc = rows; - lines_per_MCU = sp->cinfo.d.max_v_samp_factor -# ifdef D_LOSSLESS_SUPPORTED - * (size = sp->cinfo.d.min_codec_data_unit); -# else - * (size = DCTSIZE); -# endif - while (--cc >= 0) - { int clumpoffset, ci; - register jpeg_component_info *compptr; - - if (sp->scancount >= size) /* reload downsampled-data buffers */ - { - if ( CALLJPEG(sp,-1,jpeg_read_raw_data(&sp->cinfo.d,sp->ds_buffer,lines_per_MCU)) - != lines_per_MCU - ) return 0; - sp->scancount = 0; - }; - - /* The fastest way to separate the data is: make 1 pass over the scan - line for each row of each component. - */ - clumpoffset = ci = 0; - compptr = sp->cinfo.d.comp_info; - do - { int ypos = 0; - - if (compptr->h_samp_factor == 1) /* fast path */ - do - { register JSAMPLE *inptr = - sp->ds_buffer[ci][sp->scancount*compptr->v_samp_factor+ypos], - *outptr = (JSAMPLE *)buf + clumpoffset; - register int clumps_per_line = compptr->downsampled_width; - - do *outptr = *inptr++; - while ((outptr += sp->samplesperclump),--clumps_per_line > 0); - } - while ( (clumpoffset += compptr->h_samp_factor) - , ++ypos < compptr->v_samp_factor - ); - else /* general case */ - do - { register JSAMPLE *inptr = - sp->ds_buffer[ci][sp->scancount*compptr->v_samp_factor+ypos], - *outptr = (JSAMPLE *)buf + clumpoffset; - register int clumps_per_line = compptr->downsampled_width; - - do - { register int xpos = 0; - - do outptr[xpos] = *inptr++; - while (++xpos < compptr->h_samp_factor); - } - while ((outptr += sp->samplesperclump),--clumps_per_line > 0); - } - while ( (clumpoffset += compptr->h_samp_factor) - , ++ypos < compptr->v_samp_factor - ); - } - while (++compptr,++ci < sp->cinfo.d.num_components); - ++sp->scancount; - buf += sp->bytesperline; - ++tif->tif_row; - }; - - /* BEWARE OF KLUDGE: If our input file was produced by Microsoft's Wang - Imaging for Windows application, the DC coefficients of - each JPEG image component (Y,Cb,Cr) must be reset at the end of each TIFF - "strip", and any JPEG data bits remaining in the current Byte of the - decoder's input buffer must be discarded. To do so, we create an "ad hoc" - interface in the "jdhuff.c" module of IJG JPEG Library Version 6 (module - "jdshuff.c", if Ken Murchison's lossless-Huffman patch is applied), and we - invoke that interface here after decoding each "strip". - */ - if (sp->is_WANG) jpeg_reset_huff_decode(&sp->cinfo.d); - return 1; - } - -/*ARGSUSED*/ static int -OJPEGDecodeRawSeparate(TIFF *tif,register tidata_t buf,tsize_t cc,tsample_t s) - { tsize_t rows; /* No. of unprocessed rows in file */ - JDIMENSION lines_per_MCU, - size, /* ...of MCU */ - v; /* Component's vertical up-sampling ratio */ - register OJPEGState *sp = OJState(tif); - register jpeg_component_info *compptr = sp->cinfo.d.comp_info + s; - - /* Decode a chunk of pixels, where the input data has separate color planes, - some of which have been down-sampled, but the TIFF Library's client has NOT - used the "JPEGColorMode" TIFF pseudo-tag to request that the JPEG Library - do color-space conversion. The data is expected to be read in scan-line - multiples. - */ - v = sp->cinfo.d.max_v_samp_factor/compptr->v_samp_factor; - if ( (cc /= compptr->downsampled_width) /* No. of rows in caller's buffer */ - > (rows = (sp->cinfo.d.output_height-sp->cinfo.d.output_scanline+v-1)/v) - ) cc = rows; /* No. of rows of "clumps" to read */ - lines_per_MCU = sp->cinfo.d.max_v_samp_factor -# ifdef D_LOSSLESS_SUPPORTED - * (size = sp->cinfo.d.min_codec_data_unit); -# else - * (size = DCTSIZE); -# endif - L: if (sp->scancount >= size) /* reload downsampled-data buffers */ - { - if ( CALLJPEG(sp,-1,jpeg_read_raw_data(&sp->cinfo.d,sp->ds_buffer,lines_per_MCU)) - != lines_per_MCU - ) return 0; - sp->scancount = 0; - }; - rows = 0; - do - { register JSAMPLE *inptr = - sp->ds_buffer[s][sp->scancount*compptr->v_samp_factor + rows]; - register int clumps_per_line = compptr->downsampled_width; - - do *buf++ = *inptr++; while (--clumps_per_line > 0); /* Copy scanline */ - tif->tif_row += v; - if (--cc <= 0) return 1; /* End of caller's buffer? */ - } - while (++rows < compptr->v_samp_factor); - ++sp->scancount; - goto L; - } - -/* "OJPEGSetupDecode()" temporarily forces the JPEG Library to use the following - subroutine as a "dummy" input reader in order to fool the library into - thinking that it has read the image's first "Start of Scan" (SOS) marker, so - that it initializes accordingly. -*/ -/*ARGSUSED*/ METHODDEF(int) -fake_SOS_marker(j_decompress_ptr cinfo){return JPEG_REACHED_SOS;} - -/*ARGSUSED*/ METHODDEF(int) -suspend(j_decompress_ptr cinfo){return JPEG_SUSPENDED;} - -/* The JPEG Library's "null" color-space converter actually re-packs separate - color planes (it's native image representation) into a pixel-interleaved, - contiguous plane. But if our TIFF Library client is tryng to process a - PLANARCONFIG_SEPARATE image, we don't want that; so here are modifications of - code in the JPEG Library's "jdcolor.c" file, which simply copy Bytes to a - color plane specified by the current JPEG "scan". -*/ -METHODDEF(void) -ycc_rgb_convert(register j_decompress_ptr cinfo,JSAMPIMAGE in,JDIMENSION row, - register JSAMPARRAY out,register int nrows) - { typedef struct /* "jdcolor.c" color-space conversion state */ - { - - /* WARNING: This declaration is ugly and dangerous! It's supposed to be - private to the JPEG Library's "jdcolor.c" module, but we also - need it here. Since the library's copy might change without notice, be - sure to keep this one synchronized or the following code will break! - */ - struct jpeg_color_deconverter pub; /* Public fields */ - /* Private state for YCC->RGB conversion */ - int *Cr_r_tab, /* ->Cr to R conversion table */ - *Cb_b_tab; /* ->Cb to B conversion table */ - INT32 *Cr_g_tab, /* ->Cr to G conversion table */ - *Cb_g_tab; /* ->Cb to G conversion table */ - } *my_cconvert_ptr; - my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; - JSAMPARRAY irow0p = in[0] + row; - register JSAMPLE *range_limit = cinfo->sample_range_limit; - register JSAMPROW outp, Y; - - switch (cinfo->output_scan_number - 1) - { JSAMPARRAY irow1p, irow2p; - register INT32 *table0, *table1; - SHIFT_TEMPS - - case RGB_RED : irow2p = in[2] + row; - table0 = (INT32 *)cconvert->Cr_r_tab; - while (--nrows >= 0) - { register JSAMPROW Cr = *irow2p++; - register int i = cinfo->output_width; - - Y = *irow0p++; - outp = *out++; - while (--i >= 0) - *outp++ = range_limit[*Y++ + table0[*Cr++]]; - }; - return; - case RGB_GREEN: irow1p = in[1] + row; - irow2p = in[2] + row; - table0 = cconvert->Cb_g_tab; - table1 = cconvert->Cr_g_tab; - while (--nrows >= 0) - { register JSAMPROW Cb = *irow1p++, - Cr = *irow2p++; - register int i = cinfo->output_width; - - Y = *irow0p++; - outp = *out++; - while (--i >= 0) - *outp++ = - range_limit[ *Y++ - + RIGHT_SHIFT(table0[*Cb++]+table1[*Cr++],16) - ]; - }; - return; - case RGB_BLUE : irow1p = in[1] + row; - table0 = (INT32 *)cconvert->Cb_b_tab; - while (--nrows >= 0) - { register JSAMPROW Cb = *irow1p++; - register int i = cinfo->output_width; - - Y = *irow0p++; - outp = *out++; - while (--i >= 0) - *outp++ = range_limit[*Y++ + table0[*Cb++]]; - } - } - } - -METHODDEF(void) -null_convert(register j_decompress_ptr cinfo,JSAMPIMAGE in,JDIMENSION row, - register JSAMPARRAY out,register int nrows) - { register JSAMPARRAY irowp = in[cinfo->output_scan_number - 1] + row; - - while (--nrows >= 0) _TIFFmemcpy(*out++,*irowp++,cinfo->output_width); - } - -static int -OJPEGSetupDecode(register TIFF *tif) - { static char module[]={"OJPEGSetupDecode"}; - J_COLOR_SPACE jpeg_color_space, /* Color space of JPEG-compressed image */ - out_color_space; /* Color space of decompressed image */ - uint32 segment_width; - int status = 1; /* Assume success by default */ - boolean downsampled_output=FALSE, /* <=> Want JPEG Library's "raw" image? */ - is_JFIF; /* <=> JFIF image? */ - register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - - /* Verify miscellaneous parameters. This will need work if the TIFF Library - ever supports different depths for different components, or if the JPEG - Library ever supports run-time depth selection. Neither seems imminent. - */ - if (td->td_bitspersample != sp->cinfo.d.data_precision) - { - TIFFError(module,bad_bps,td->td_bitspersample); - status = 0; - }; - - /* The TIFF Version 6.0 specification and IJG JPEG Library accept different - sets of color spaces, so verify that our image belongs to the common subset - and map its photometry code, then initialize to handle subsampling and - optional JPEG Library YCbCr <-> RGB color-space conversion. - */ - switch (td->td_photometric) - { - case PHOTOMETRIC_YCBCR : - - /* ISO IS 10918-1 requires that JPEG subsampling factors be 1-4, but - TIFF Version 6.0 is more restrictive: only 1, 2, and 4 are allowed. - */ - if ( ( td->td_ycbcrsubsampling[0] == 1 - || td->td_ycbcrsubsampling[0] == 2 - || td->td_ycbcrsubsampling[0] == 4 - ) - && ( td->td_ycbcrsubsampling[1] == 1 - || td->td_ycbcrsubsampling[1] == 2 - || td->td_ycbcrsubsampling[1] == 4 - ) - ) - downsampled_output = - ( - (sp->h_sampling = td->td_ycbcrsubsampling[0]) << 3 - | (sp->v_sampling = td->td_ycbcrsubsampling[1]) - ) != 011; - else - { - TIFFError(module,bad_subsampling); - status = 0; - }; - jpeg_color_space = JCS_YCbCr; - if (sp->jpegcolormode == JPEGCOLORMODE_RGB) - { - downsampled_output = FALSE; - out_color_space = JCS_RGB; - break; - }; - goto L2; - case PHOTOMETRIC_MINISBLACK: - jpeg_color_space = JCS_GRAYSCALE; - goto L1; - case PHOTOMETRIC_RGB : - jpeg_color_space = JCS_RGB; - goto L1; - case PHOTOMETRIC_SEPARATED : - jpeg_color_space = JCS_CMYK; - L1: sp->jpegcolormode = JPEGCOLORMODE_RAW; /* No JPEG Lib. conversion */ - L2: out_color_space = jpeg_color_space; - break; - default : - TIFFError(module,bad_photometry,td->td_photometric); - status = 0; - }; - if (status == 0) return 0; /* If TIFF errors, don't bother to continue */ - - /* Set parameters that are same for all strips/tiles. */ - - sp->cinfo.d.src = &sp->src; - sp->src.init_source = std_init_source; - sp->src.fill_input_buffer = std_fill_input_buffer; - sp->src.skip_input_data = std_skip_input_data; - sp->src.resync_to_restart = jpeg_resync_to_restart; - sp->src.term_source = std_term_source; - - /* BOGOSITY ALERT! The Wang Imaging application for Microsoft Windows produces - images containing "JPEGInterchangeFormat[Length]" TIFF - records that resemble JFIF-in-TIFF encapsulations but, in fact, violate the - TIFF Version 6 specification in several ways; nevertheless, we try to handle - them gracefully because there are apparently a lot of them around. The - purported "JFIF" data stream in one of these files vaguely resembles a JPEG - "tables only" data stream, except that there's no trailing EOI marker. The - rest of the JPEG data stream lies in a discontiguous file region, identified - by the 0th Strip offset (which is *also* illegal!), where it begins with an - SOS marker and apparently continues to the end of the file. There is no - trailing EOI marker here, either. - */ - is_JFIF = !sp->is_WANG && TIFFFieldSet(tif,FIELD_JPEGIFOFFSET); - - /* Initialize decompression parameters that won't be overridden by JPEG Library - defaults set during the "jpeg_read_header()" call, below. - */ - segment_width = td->td_imagewidth; - if (isTiled(tif)) - { - if (sp->is_WANG) /* we don't know how to handle it */ - { - TIFFError(module,"Tiled Wang image not supported"); - return 0; - }; - - /* BOGOSITY ALERT! "TIFFTileRowSize()" seems to work fine for modern JPEG- - in-TIFF encapsulations where the image width--like the - tile width--is a multiple of 8 or 16 pixels. But image widths and - heights are aren't restricted to 8- or 16-bit multiples, and we need - the exact Byte count of decompressed scan lines when we call the JPEG - Library. At least one old file ("zackthecat.tif") in the TIFF Library - test suite has widths and heights slightly less than the tile sizes, and - it apparently used the bogus computation below to determine the number - of Bytes per scan line (was this due to an old, broken version of - "TIFFhowmany()"?). Before we get here, "OJPEGSetupDecode()" verified - that our image uses 8-bit samples, so the following check appears to - return the correct answer in all known cases tested to date. - */ - if (is_JFIF || (segment_width & 7) == 0) - sp->bytesperline = TIFFTileRowSize(tif); /* Normal case */ - else - { - /* Was the file-encoder's segment-width calculation bogus? */ - segment_width = (segment_width/sp->h_sampling + 1) * sp->h_sampling; - sp->bytesperline = segment_width * td->td_samplesperpixel; - } - } - else sp->bytesperline = TIFFVStripSize(tif,1); - - /* BEWARE OF KLUDGE: If we have JPEG Interchange File Format (JFIF) image, - then we want to read "metadata" in the bit-stream's - header and validate it against corresponding information in TIFF records. - But if we have a *really old* JPEG file that's not JFIF, then we simply - assign TIFF-record values to JPEG Library variables without checking. - */ - if (is_JFIF) /* JFIF image */ - { unsigned char *end_of_data; - int subsampling_factors; - register unsigned char *p; - register int i; - - /* WARNING: Although the image file contains a JFIF bit stream, it might - also contain some old TIFF records causing "OJPEGVSetField()" - to have allocated quantization or Huffman decoding tables. But when the - JPEG Library reads and parses the JFIF header below, it reallocate these - tables anew without checking for "dangling" pointers, thereby causing a - memory "leak". We have enough information to potentially deallocate the - old tables here, but unfortunately JPEG Library Version 6B uses a "pool" - allocator for small objects, with no deallocation procedure; instead, it - reclaims a whole pool when an image is closed/destroyed, so well-behaved - TIFF client applications (i.e., those which close their JPEG images as - soon as they're no longer needed) will waste memory for a short time but - recover it eventually. But ill-behaved TIFF clients (i.e., those which - keep many JPEG images open gratuitously) can exhaust memory prematurely. - If the JPEG Library ever implements a deallocation procedure, insert - this clean-up code: - */ -# ifdef someday - if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) /* free quant. tables */ - { register int i = 0; - - do - { register JQUANT_TBL *q; - - if (q = sp->cinfo.d.quant_tbl_ptrs[i]) - { - jpeg_free_small(&sp->cinfo.comm,q,sizeof *q); - sp->cinfo.d.quant_tbl_ptrs[i] = 0; - } - } - while (++i < NUM_QUANT_TBLS); - }; - if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) /* free Huffman tables */ - { register int i = 0; - - do - { register JHUFF_TBL *h; - - if (h = sp->cinfo.d.dc_huff_tbl_ptrs[i]) - { - jpeg_free_small(&sp->cinfo.comm,h,sizeof *h); - sp->cinfo.d.dc_huff_tbl_ptrs[i] = 0; - }; - if (h = sp->cinfo.d.ac_huff_tbl_ptrs[i]) - { - jpeg_free_small(&sp->cinfo.comm,h,sizeof *h); - sp->cinfo.d.ac_huff_tbl_ptrs[i] = 0; - } - } - while (++i < NUM_HUFF_TBLS); - }; -# endif /* someday */ - - /* Since we might someday wish to try rewriting "old format" JPEG-in-TIFF - encapsulations in "new format" files, try to synthesize the value of a - modern "JPEGTables" TIFF record by scanning the JPEG data from just past - the "Start of Information" (SOI) marker until something other than a - legitimate "table" marker is found, as defined in ISO IS 10918-1 - Appending B.2.4; namely: - - -- Define Quantization Table (DQT) - -- Define Huffman Table (DHT) - -- Define Arithmetic Coding table (DAC) - -- Define Restart Interval (DRI) - -- Comment (COM) - -- Application data (APPn) - - For convenience, we also accept "Expansion" (EXP) markers, although they - are apparently not a part of normal "table" data. - */ - sp->jpegtables = p = (unsigned char *)sp->src.next_input_byte; - end_of_data = p + sp->src.bytes_in_buffer; - p += 2; - while (p < end_of_data && p[0] == 0xFF) - switch (p[1]) - { - default : goto L; - case 0xC0: /* SOF0 */ - case 0xC1: /* SOF1 */ - case 0xC2: /* SOF2 */ - case 0xC3: /* SOF3 */ - case 0xC4: /* DHT */ - case 0xC5: /* SOF5 */ - case 0xC6: /* SOF6 */ - case 0xC7: /* SOF7 */ - case 0xC9: /* SOF9 */ - case 0xCA: /* SOF10 */ - case 0xCB: /* SOF11 */ - case 0xCC: /* DAC */ - case 0xCD: /* SOF13 */ - case 0xCE: /* SOF14 */ - case 0xCF: /* SOF15 */ - case 0xDB: /* DQT */ - case 0xDD: /* DRI */ - case 0xDF: /* EXP */ - case 0xE0: /* APP0 */ - case 0xE1: /* APP1 */ - case 0xE2: /* APP2 */ - case 0xE3: /* APP3 */ - case 0xE4: /* APP4 */ - case 0xE5: /* APP5 */ - case 0xE6: /* APP6 */ - case 0xE7: /* APP7 */ - case 0xE8: /* APP8 */ - case 0xE9: /* APP9 */ - case 0xEA: /* APP10 */ - case 0xEB: /* APP11 */ - case 0xEC: /* APP12 */ - case 0xED: /* APP13 */ - case 0xEE: /* APP14 */ - case 0xEF: /* APP15 */ - case 0xFE: /* COM */ - p += (p[2] << 8 | p[3]) + 2; - }; - L: if (p - (unsigned char *)sp->jpegtables > 2) /* fake "JPEGTables" */ - { - - /* In case our client application asks, pretend that this image file - contains a modern "JPEGTables" TIFF record by copying to a buffer - the initial part of the JFIF bit-stream that we just scanned, from - the SOI marker through the "metadata" tables, then append an EOI - marker and flag the "JPEGTables" TIFF record as "present". - */ - sp->jpegtables_length = p - (unsigned char*)sp->jpegtables + 2; - p = sp->jpegtables; - if (!(sp->jpegtables = _TIFFmalloc(sp->jpegtables_length))) - { - TIFFError(module,no_jtable_space); - return 0; - }; - _TIFFmemcpy(sp->jpegtables,p,sp->jpegtables_length-2); - p = (unsigned char *)sp->jpegtables + sp->jpegtables_length; - p[-2] = 0xFF; p[-1] = JPEG_EOI; /* Append EOI marker */ - TIFFSetFieldBit(tif,FIELD_JPEGTABLES); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } - else sp->jpegtables = 0; /* Don't simulate "JPEGTables" */ - if ( CALLJPEG(sp,-1,jpeg_read_header(&sp->cinfo.d,TRUE)) - != JPEG_HEADER_OK - ) return 0; - if ( sp->cinfo.d.image_width != segment_width - || sp->cinfo.d.image_height != td->td_imagelength - ) - { - TIFFError(module,"Improper JPEG strip/tile size"); - return 0; - }; - if (sp->cinfo.d.num_components != td->td_samplesperpixel) - { - TIFFError(module,"Improper JPEG component count"); - return 0; - }; - if (sp->cinfo.d.data_precision != td->td_bitspersample) - { - TIFFError(module,"Improper JPEG data precision"); - return 0; - }; - - /* Check that JPEG image components all have the same subsampling factors - declared (or defaulted) in the TIFF file, since TIFF Version 6.0 is more - restrictive than JPEG: Only the 0th component may have horizontal and - vertical subsampling factors other than <1,1>. - */ - subsampling_factors = sp->h_sampling << 3 | sp->v_sampling; - i = 0; - do - { - if ( ( sp->cinfo.d.comp_info[i].h_samp_factor << 3 - | sp->cinfo.d.comp_info[i].v_samp_factor - ) - != subsampling_factors - ) - { - TIFFError(module,"Improper JPEG subsampling factors"); - return 0; - }; - subsampling_factors = 011; /* Required for image components > 0 */ - } - while (++i < sp->cinfo.d.num_components); - } - else /* not JFIF image */ - { int (*save)(j_decompress_ptr cinfo) = sp->cinfo.d.marker->read_markers; - register int i; - - /* We're not assuming that this file's JPEG bit stream has any header - "metadata", so fool the JPEG Library into thinking that we read a - "Start of Input" (SOI) marker and a "Start of Frame" (SOFx) marker, then - force it to read a simulated "Start of Scan" (SOS) marker when we call - "jpeg_read_header()" below. This should cause the JPEG Library to - establish reasonable defaults. - */ - sp->cinfo.d.marker->saw_SOI = /* Pretend we saw SOI marker */ - sp->cinfo.d.marker->saw_SOF = TRUE; /* Pretend we saw SOF marker */ - sp->cinfo.d.marker->read_markers = - sp->is_WANG ? suspend : fake_SOS_marker; - sp->cinfo.d.global_state = DSTATE_INHEADER; - sp->cinfo.d.Se = DCTSIZE2-1; /* Suppress JPEG Library warning */ - sp->cinfo.d.image_width = segment_width; - sp->cinfo.d.image_height = td->td_imagelength; - - /* The following color-space initialization, including the complicated - "switch"-statement below, essentially duplicates the logic used by the - JPEG Library's "jpeg_init_colorspace()" subroutine during compression. - */ - sp->cinfo.d.num_components = td->td_samplesperpixel; - sp->cinfo.d.comp_info = (jpeg_component_info *) - (*sp->cinfo.d.mem->alloc_small) - ( &sp->cinfo.comm - , JPOOL_IMAGE - , sp->cinfo.d.num_components * sizeof *sp->cinfo.d.comp_info - ); - i = 0; - do - { - sp->cinfo.d.comp_info[i].component_index = i; - sp->cinfo.d.comp_info[i].component_needed = TRUE; - sp->cinfo.d.cur_comp_info[i] = &sp->cinfo.d.comp_info[i]; - } - while (++i < sp->cinfo.d.num_components); - switch (jpeg_color_space) - { - case JCS_UNKNOWN : - i = 0; - do - { - sp->cinfo.d.comp_info[i].component_id = i; - sp->cinfo.d.comp_info[i].h_samp_factor = - sp->cinfo.d.comp_info[i].v_samp_factor = 1; - } - while (++i < sp->cinfo.d.num_components); - break; - case JCS_GRAYSCALE: - sp->cinfo.d.comp_info[0].component_id = - sp->cinfo.d.comp_info[0].h_samp_factor = - sp->cinfo.d.comp_info[0].v_samp_factor = 1; - break; - case JCS_RGB : - sp->cinfo.d.comp_info[0].component_id = 'R'; - sp->cinfo.d.comp_info[1].component_id = 'G'; - sp->cinfo.d.comp_info[2].component_id = 'B'; - i = 0; - do sp->cinfo.d.comp_info[i].h_samp_factor = - sp->cinfo.d.comp_info[i].v_samp_factor = 1; - while (++i < sp->cinfo.d.num_components); - break; - case JCS_CMYK : - sp->cinfo.d.comp_info[0].component_id = 'C'; - sp->cinfo.d.comp_info[1].component_id = 'M'; - sp->cinfo.d.comp_info[2].component_id = 'Y'; - sp->cinfo.d.comp_info[3].component_id = 'K'; - i = 0; - do sp->cinfo.d.comp_info[i].h_samp_factor = - sp->cinfo.d.comp_info[i].v_samp_factor = 1; - while (++i < sp->cinfo.d.num_components); - break; - case JCS_YCbCr : - i = 0; - do - { - sp->cinfo.d.comp_info[i].component_id = i+1; - sp->cinfo.d.comp_info[i].h_samp_factor = - sp->cinfo.d.comp_info[i].v_samp_factor = 1; - sp->cinfo.d.comp_info[i].quant_tbl_no = - sp->cinfo.d.comp_info[i].dc_tbl_no = - sp->cinfo.d.comp_info[i].ac_tbl_no = i > 0; - } - while (++i < sp->cinfo.d.num_components); - sp->cinfo.d.comp_info[0].h_samp_factor = sp->h_sampling; - sp->cinfo.d.comp_info[0].v_samp_factor = sp->v_sampling; - }; - sp->cinfo.d.comps_in_scan = td->td_planarconfig == PLANARCONFIG_CONTIG - ? sp->cinfo.d.num_components - : 1; - i = CALLJPEG(sp,-1,jpeg_read_header(&sp->cinfo.d,!sp->is_WANG)); - sp->cinfo.d.marker->read_markers = save; /* Restore input method */ - if (sp->is_WANG) /* produced by Wang Imaging on Microsoft Windows */ - { - if (i != JPEG_SUSPENDED) return 0; - - /* BOGOSITY ALERT! Files prooduced by the Wang Imaging application for - Microsoft Windows are a special--and, technically - illegal--case. A JPEG SOS marker and rest of the data stream should - be located at the end of the file, in a position identified by the - 0th Strip offset. - */ - i = td->td_nstrips - 1; - sp->src.next_input_byte = tif->tif_base + td->td_stripoffset[0]; - sp->src.bytes_in_buffer = td->td_stripoffset[i] - - td->td_stripoffset[0] + td->td_stripbytecount[i]; - i = CALLJPEG(sp,-1,jpeg_read_header(&sp->cinfo.d,TRUE)); - }; - if (i != JPEG_HEADER_OK) return 0; - }; - - /* Some of our initialization must wait until the JPEG Library is initialized - above, in order to override its defaults. - */ - if ( (sp->cinfo.d.raw_data_out = downsampled_output) - && !alloc_downsampled_buffers(tif,sp->cinfo.d.comp_info, - sp->cinfo.d.num_components) - ) return 0; - sp->cinfo.d.jpeg_color_space = jpeg_color_space; - sp->cinfo.d.out_color_space = out_color_space; - sp->cinfo.d.dither_mode = JDITHER_NONE; /* Reduce image "noise" */ - sp->cinfo.d.two_pass_quantize = FALSE; - - /* If the image consists of separate, discontiguous TIFF "samples" (= color - planes, hopefully = JPEG "scans"), then we must use the JPEG Library's - "buffered image" mode to decompress the entire image into temporary buffers, - because the JPEG Library must parse the entire JPEG bit-stream in order to - be satsified that it has a complete set of color components for each pixel, - but the TIFF Library must allow our client to extract 1 component at a time. - Initializing the JPEG Library's "buffered image" mode is tricky: First, we - start its decompressor, then we tell the decompressor to "consume" (i.e., - buffer) the entire bit-stream. - - WARNING: Disabling "fancy" up-sampling seems to slightly reduce "noise" for - certain old Wang Imaging files, but it absolutely *must* be - enabled if the image has separate color planes, since in that case, the JPEG - Library doesn't use an "sp->cinfo.d.cconvert" structure (so de-referencing - this pointer below will cause a fatal crash) but writing our own code to up- - sample separate color planes is too much work for right now. Maybe someday? - */ - sp->cinfo.d.do_fancy_upsampling = /* Always let this default (to TRUE)? */ - sp->cinfo.d.buffered_image = td->td_planarconfig == PLANARCONFIG_SEPARATE; - if (!CALLJPEG(sp,0,jpeg_start_decompress(&sp->cinfo.d))) return 0; - if (sp->cinfo.d.buffered_image) /* separate color planes */ - { - if (sp->cinfo.d.raw_data_out) - tif->tif_decoderow = tif->tif_decodestrip = tif->tif_decodetile = - OJPEGDecodeRawSeparate; - else - { - tif->tif_decoderow = tif->tif_decodestrip = tif->tif_decodetile = - OJPEGDecode; - - /* In JPEG Library Version 6B, color-space conversion isn't implemented - for separate color planes, so we must do it ourself if our TIFF - client doesn't want to: - */ - sp->cinfo.d.cconvert->color_convert = - sp->cinfo.d.jpeg_color_space == sp->cinfo.d.out_color_space - ? null_convert : ycc_rgb_convert; - }; - L3: switch (CALLJPEG(sp,0,jpeg_consume_input(&sp->cinfo.d))) - { - default : goto L3; - - /* If no JPEG "End of Information" (EOI) marker is found when bit- - stream parsing ends, check whether we have enough data to proceed - before reporting an error. - */ - case JPEG_SUSPENDED : if ( sp->cinfo.d.input_scan_number - *sp->cinfo.d.image_height - + sp->cinfo.d.input_iMCU_row - *sp->cinfo.d.max_v_samp_factor -# ifdef D_LOSSLESS_SUPPORTED - *sp->cinfo.d.data_units_in_MCU - *sp->cinfo.d.min_codec_data_unit -# else - *sp->cinfo.d.blocks_in_MCU - *DCTSIZE -# endif - < td->td_samplesperpixel - *sp->cinfo.d.image_height - ) - { - TIFFError(tif->tif_name, - "Premature end of JPEG bit-stream"); - return 0; - } - case JPEG_REACHED_EOI: ; - } - } - else /* pixel-interleaved color planes */ - tif->tif_decoderow = tif->tif_decodestrip = tif->tif_decodetile = - downsampled_output ? OJPEGDecodeRawContig : OJPEGDecode; - return 1; -# undef td - } - -static int -OJPEGPreDecode(register TIFF *tif,tsample_t s) - { register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - - /* If we are about to read the first row of an image plane (hopefully, these - are coincident with JPEG "scans"!), reset the JPEG Library's decompressor - appropriately. Otherwise, let the decompressor run "as is" and return a - "success" status without further ado. - */ - if ( (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip) - % td->td_stripsperimage - == 0 - ) - { - if ( sp->cinfo.d.buffered_image - && !CALLJPEG(sp,0,jpeg_start_output(&sp->cinfo.d,s+1)) - ) return 0; - sp->cinfo.d.output_scanline = 0; - - /* Mark subsampling buffers "empty". */ - -# ifdef D_LOSSLESS_SUPPORTED - sp->scancount = sp->cinfo.d.min_codec_data_unit; -# else - sp->scancount = DCTSIZE; -# endif - }; - return 1; -# undef td - } - -/*ARGSUSED*/ static void -OJPEGPostDecode(register TIFF *tif,tidata_t buf,tsize_t cc) - { register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - - /* The JPEG Library decompressor has reached the end of a strip/tile. If this - is the end of a TIFF image "sample" (= JPEG "scan") in a file with separate - components (color planes), then end the "scan". If it ends the image's last - sample/scan, then also stop the JPEG Library's decompressor. - */ - if (sp->cinfo.d.output_scanline >= sp->cinfo.d.output_height) - { - if (sp->cinfo.d.buffered_image) - CALLJPEG(sp,-1,jpeg_finish_output(&sp->cinfo.d)); /* End JPEG scan */ - if ( (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip) - >= td->td_nstrips-1 - ) CALLJPEG(sp,0,jpeg_finish_decompress(&sp->cinfo.d)); - } -# undef td - } - -static int -OJPEGVSetField(register TIFF *tif,ttag_t tag,va_list ap) -{ - uint32 v32; - register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - toff_t tiffoff=0; - uint32 bufoff=0; - uint32 code_count=0; - int i2=0; - int k2=0; - - switch (tag) - { - default : return - (*sp->vsetparent)(tif,tag,ap); - - /* BEWARE OF KLUDGE: Some old-format JPEG-in-TIFF files, including those - produced by the Wang Imaging application for Micro- - soft Windows, illegally omit a "ReferenceBlackWhite" TIFF tag, even - though the TIFF specification's default is intended for the RGB color - space and is inappropriate for the YCbCr color space ordinarily used for - JPEG images. Since many TIFF client applications request the value of - this tag immediately after a TIFF image directory is parsed, and before - any other code in this module receives control, we are forced to fix - this problem very early in image-file processing. Fortunately, legal - TIFF files are supposed to store their tags in numeric order, so a - mandatory "PhotometricInterpretation" tag should always appear before - an optional "ReferenceBlackWhite" tag. Hence, we slyly peek ahead when - we discover the desired photometry, by installing modified black and - white reference levels. - */ - case TIFFTAG_PHOTOMETRIC : - if ( (v32 = (*sp->vsetparent)(tif,tag,ap)) - && td->td_photometric == PHOTOMETRIC_YCBCR - ) - { - float *ref; - if (!TIFFGetField(tif, TIFFTAG_REFERENCEBLACKWHITE, &ref)) { - float refbw[6]; - long top = 1L << td->td_bitspersample; - refbw[0] = 0; - refbw[1] = (float)(top-1L); - refbw[2] = (float)(top>>1); - refbw[3] = refbw[1]; - refbw[4] = refbw[2]; - refbw[5] = refbw[1]; - TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw); - } - } - return v32; - - /* BEWARE OF KLUDGE: According to Charles Auer , if our - input is a multi-image (multi-directory) JPEG-in-TIFF - file is produced by the Wang Imaging application on Microsoft Windows, - for some reason the first directory excludes the vendor-specific "WANG - PageControl" tag (32934) that we check below, so the only other way to - identify these directories is apparently to look for a software- - identification tag with the substring, "Wang Labs". Single-image files - can apparently pass both tests, which causes no harm here, but what a - mess this is! - */ - case TIFFTAG_SOFTWARE : - { - char *software; - - v32 = (*sp->vsetparent)(tif,tag,ap); - if( TIFFGetField( tif, TIFFTAG_SOFTWARE, &software ) - && strstr( software, "Wang Labs" ) ) - sp->is_WANG = 1; - return v32; - } - - case TIFFTAG_JPEGPROC : - case TIFFTAG_JPEGIFOFFSET : - case TIFFTAG_JPEGIFBYTECOUNT : - case TIFFTAG_JPEGRESTARTINTERVAL : - case TIFFTAG_JPEGLOSSLESSPREDICTORS: - case TIFFTAG_JPEGPOINTTRANSFORM : - case TIFFTAG_JPEGQTABLES : - case TIFFTAG_JPEGDCTABLES : - case TIFFTAG_JPEGACTABLES : - case TIFFTAG_WANG_PAGECONTROL : - case TIFFTAG_JPEGCOLORMODE : ; - }; - v32 = va_arg(ap,uint32); /* No. of values in this TIFF record */ - - /* This switch statement is added for OJPEGVSetField */ - if(v32 !=0){ - switch(tag){ - case TIFFTAG_JPEGPROC: - sp->jpegproc=v32; - break; - case TIFFTAG_JPEGIFOFFSET: - sp->jpegifoffset=v32; - break; - case TIFFTAG_JPEGIFBYTECOUNT: - sp->jpegifbytecount=v32; - break; - case TIFFTAG_JPEGRESTARTINTERVAL: - sp->jpegrestartinterval=v32; - break; - case TIFFTAG_JPEGLOSSLESSPREDICTORS: - sp->jpeglosslesspredictors_length=v32; - break; - case TIFFTAG_JPEGPOINTTRANSFORM: - sp->jpegpointtransform_length=v32; - break; - case TIFFTAG_JPEGQTABLES: - sp->jpegqtables_length=v32; - break; - case TIFFTAG_JPEGACTABLES: - sp->jpegactables_length=v32; - break; - case TIFFTAG_JPEGDCTABLES: - sp->jpegdctables_length=v32; - break; - default: - break; - } - } - - /* BEWARE: The following actions apply only if we are reading a "source" TIFF - image to be decompressed for a client application program. If we - ever enhance this file's CODEC to write "destination" JPEG-in-TIFF images, - we'll need an "if"- and another "switch"-statement below, because we'll - probably want to store these records' values in some different places. Most - of these need not be parsed here in order to decode JPEG bit stream, so we - set boolean flags to note that they have been seen, but we otherwise ignore - them. - */ - switch (tag) - { JHUFF_TBL **h; - - /* Validate the JPEG-process code. */ - - case TIFFTAG_JPEGPROC : - switch (v32) - { - default : TIFFError(tif->tif_name, - "Unknown JPEG process"); - return 0; -# ifdef C_LOSSLESS_SUPPORTED - - /* Image uses (lossy) baseline sequential coding. */ - - case JPEGPROC_BASELINE: sp->cinfo.d.process = JPROC_SEQUENTIAL; - sp->cinfo.d.data_unit = DCTSIZE; - break; - - /* Image uses (lossless) Huffman coding. */ - - case JPEGPROC_LOSSLESS: sp->cinfo.d.process = JPROC_LOSSLESS; - sp->cinfo.d.data_unit = 1; -# else /* not C_LOSSLESS_SUPPORTED */ - case JPEGPROC_LOSSLESS: TIFFError(JPEGLib_name, - "Does not support lossless Huffman coding"); - return 0; - case JPEGPROC_BASELINE: ; -# endif /* C_LOSSLESS_SUPPORTED */ - }; - break; - - /* The TIFF Version 6.0 specification says that if the value of a TIFF - "JPEGInterchangeFormat" record is 0, then we are to behave as if this - record were absent; i.e., the data does *not* represent a JPEG Inter- - change Format File (JFIF), so don't even set the boolean "I've been - here" flag below. Otherwise, the field's value represents the file - offset of the JPEG SOI marker. - */ - case TIFFTAG_JPEGIFOFFSET : - if (v32) - { - sp->src.next_input_byte = tif->tif_base + v32; - break; - }; - return 1; - case TIFFTAG_JPEGIFBYTECOUNT : - sp->src.bytes_in_buffer = v32; - break; - - /* The TIFF Version 6.0 specification says that if the JPEG "Restart" - marker interval is 0, then the data has no "Restart" markers; i.e., we - must behave as if this TIFF record were absent. So, don't even set the - boolean "I've been here" flag below. - */ - /* - * Instead, set the field bit so TIFFGetField can get whether or not - * it was set. - */ - case TIFFTAG_JPEGRESTARTINTERVAL : - if (v32) - sp->cinfo.d.restart_interval = v32; - break; - /* The TIFF Version 6.0 specification says that this tag is supposed to be - a vector containing a value for each image component, but for lossless - Huffman coding (the only JPEG process defined by the specification for - which this tag should be needed), ISO IS 10918-1 uses only a single - value, equivalent to the "Ss" field in a JPEG bit-stream's "Start of - Scan" (SOS) marker. So, we extract the first vector element and ignore - the rest. (I hope this is correct!) - */ - case TIFFTAG_JPEGLOSSLESSPREDICTORS: - if (v32) - { - sp->cinfo.d.Ss = *va_arg(ap,uint16 *); - sp->jpeglosslesspredictors = - _TIFFmalloc(sp->jpeglosslesspredictors_length - * sizeof(uint16)); - if(sp->jpeglosslesspredictors==NULL){return(0);} - for(i2=0;i2jpeglosslesspredictors_length;i2++){ - ((uint16*)sp->jpeglosslesspredictors)[i2] = - ((uint16*)sp->cinfo.d.Ss)[i2]; - } - sp->jpeglosslesspredictors_length*=sizeof(uint16); - break; - }; - return v32; - - /* The TIFF Version 6.0 specification says that this tag is supposed to be - a vector containing a value for each image component, but for lossless - Huffman coding (the only JPEG process defined by the specification for - which this tag should be needed), ISO IS 10918-1 uses only a single - value, equivalent to the "Al" field in a JPEG bit-stream's "Start of - Scan" (SOS) marker. So, we extract the first vector element and ignore - the rest. (I hope this is correct!) - */ - case TIFFTAG_JPEGPOINTTRANSFORM : - if (v32) - { - sp->cinfo.d.Al = *va_arg(ap,uint16 *); - sp->jpegpointtransform = - _TIFFmalloc(sp->jpegpointtransform_length*sizeof(uint16)); - if(sp->jpegpointtransform==NULL){return(0);} - for(i2=0;i2jpegpointtransform_length;i2++) { - ((uint16*)sp->jpegpointtransform)[i2] = - ((uint16*)sp->cinfo.d.Al)[i2]; - } - sp->jpegpointtransform_length*=sizeof(uint16); - break; - } - return v32; - - /* We have a vector of offsets to quantization tables, so load 'em! */ - - case TIFFTAG_JPEGQTABLES : - if (v32) - { uint32 *v; - int i; - if (v32 > NUM_QUANT_TBLS) - { - TIFFError(tif->tif_name,"Too many quantization tables"); - return 0; - }; - i = 0; - v = va_arg(ap,uint32 *); - sp->jpegqtables=_TIFFmalloc(64*sp->jpegqtables_length); - if(sp->jpegqtables==NULL){return(0);} - tiffoff = TIFFSeekFile(tif, 0, SEEK_CUR); - bufoff=0; - for(i2=0;i2jpegqtables_length;i2++){ - TIFFSeekFile(tif, v[i2], SEEK_SET); - TIFFReadFile(tif, &(((unsigned char*)(sp->jpegqtables))[bufoff]), - 64); - bufoff+=64; - } - sp->jpegqtables_length=bufoff; - TIFFSeekFile(tif, tiffoff, SEEK_SET); - - do /* read quantization table */ - { register UINT8 *from = tif->tif_base + *v++; - register UINT16 *to; - register int j = DCTSIZE2; - - if (!( sp->cinfo.d.quant_tbl_ptrs[i] - = CALLJPEG(sp,0,jpeg_alloc_quant_table(&sp->cinfo.comm)) - ) - ) - { - TIFFError(JPEGLib_name,"No space for quantization table"); - return 0; - }; - to = sp->cinfo.d.quant_tbl_ptrs[i]->quantval; - do *to++ = *from++; while (--j > 0); - } - while (++i < v32); - sp->jpegtablesmode |= JPEGTABLESMODE_QUANT; - }; - break; - - /* We have a vector of offsets to DC Huffman tables, so load 'em! */ - - case TIFFTAG_JPEGDCTABLES : - h = sp->cinfo.d.dc_huff_tbl_ptrs; - goto L; - - /* We have a vector of offsets to AC Huffman tables, so load 'em! */ - - case TIFFTAG_JPEGACTABLES : - h = sp->cinfo.d.ac_huff_tbl_ptrs; - L: if (v32) - { uint32 *v; - int i; - if (v32 > NUM_HUFF_TBLS) - { - TIFFError(tif->tif_name,"Too many Huffman tables"); - return 0; - }; - v = va_arg(ap,uint32 *); - if(tag == TIFFTAG_JPEGDCTABLES) { - sp->jpegdctables=_TIFFmalloc(272*sp->jpegdctables_length); - if(sp->jpegdctables==NULL){return(0);} - tiffoff = TIFFSeekFile(tif, 0, SEEK_CUR); - bufoff=0; - code_count=0; - for(i2=0;i2jpegdctables_length;i2++){ - TIFFSeekFile(tif, v[i2], SEEK_SET); - TIFFReadFile(tif, - &(((unsigned char*)(sp->jpegdctables))[bufoff]), - 16); - code_count=0; - for(k2=0;k2<16;k2++){ - code_count+=((unsigned char*)(sp->jpegdctables))[k2+bufoff]; - } - TIFFReadFile(tif, - &(((unsigned char*)(sp->jpegdctables))[bufoff+16]), - code_count); - bufoff+=16; - bufoff+=code_count; - } - sp->jpegdctables_length=bufoff; - TIFFSeekFile(tif, tiffoff, SEEK_SET); - } - if(tag==TIFFTAG_JPEGACTABLES){ - sp->jpegactables=_TIFFmalloc(272*sp->jpegactables_length); - if(sp->jpegactables==NULL){return(0);} - tiffoff = TIFFSeekFile(tif, 0, SEEK_CUR); - bufoff=0; - code_count=0; - for(i2=0;i2jpegactables_length;i2++){ - TIFFSeekFile(tif, v[i2], SEEK_SET); - TIFFReadFile(tif, &(((unsigned char*)(sp->jpegactables))[bufoff]), 16); - code_count=0; - for(k2=0;k2<16;k2++){ - code_count+=((unsigned char*)(sp->jpegactables))[k2+bufoff]; - } - TIFFReadFile(tif, &(((unsigned char*)(sp->jpegactables))[bufoff+16]), code_count); - bufoff+=16; - bufoff+=code_count; - } - sp->jpegactables_length=bufoff; - TIFFSeekFile(tif, tiffoff, SEEK_SET); - } - i = 0; - do /* copy each Huffman table */ - { int size = 0; - register UINT8 *from = tif->tif_base + *v++, *to; - register int j = sizeof (*h)->bits; - - /* WARNING: This code relies on the fact that an image file not - "memory mapped" was read entirely into a single - buffer by "TIFFInitOJPEG()", so we can do a fast memory-to- - memory copy here. Each table consists of 16 Bytes, which are - suffixed to a 0 Byte when copied, followed by a variable - number of Bytes whose length is the sum of the first 16. - */ - if (!( *h - = CALLJPEG(sp,0,jpeg_alloc_huff_table(&sp->cinfo.comm)) - ) - ) - { - TIFFError(JPEGLib_name,"No space for Huffman table"); - return 0; - }; - to = (*h++)->bits; - *to++ = 0; - while (--j > 0) size += *to++ = *from++; /* Copy 16 Bytes */ - if (size > sizeof (*h)->huffval/sizeof *(*h)->huffval) - { - TIFFError(tif->tif_name,"Huffman table too big"); - return 0; - }; - if ((j = size) > 0) do *to++ = *from++; while (--j > 0); - while (++size <= sizeof (*h)->huffval/sizeof *(*h)->huffval) - *to++ = 0; /* Zero the rest of the table for cleanliness */ - } - while (++i < v32); - sp->jpegtablesmode |= JPEGTABLESMODE_HUFF; - }; - break; - - /* The following vendor-specific TIFF tag occurs in (highly illegal) files - produced by the Wang Imaging application for Microsoft Windows. These - can apparently have several "pages", in which case this tag specifies - the offset of a "page control" structure, which we don't currently know - how to handle. 0 indicates a 1-page image with no "page control", which - we make a feeble effort to handle. - */ - case TIFFTAG_WANG_PAGECONTROL : - if (v32 == 0) v32 = -1; - sp->is_WANG = v32; - tag = TIFFTAG_JPEGPROC+FIELD_WANG_PAGECONTROL-FIELD_JPEGPROC; - break; - - /* This pseudo tag indicates whether our caller is expected to do YCbCr <-> - RGB color-space conversion (JPEGCOLORMODE_RAW <=> 0) or whether we must - ask the JPEG Library to do it (JPEGCOLORMODE_RGB <=> 1). - */ - case TIFFTAG_JPEGCOLORMODE : - sp->jpegcolormode = v32; - - /* Mark the image to indicate whether returned data is up-sampled, so - that "TIFF{Strip,Tile}Size()" reflect the true amount of data present. - */ - v32 = tif->tif_flags; /* Save flags temporarily */ - tif->tif_flags &= ~TIFF_UPSAMPLED; - if ( td->td_photometric == PHOTOMETRIC_YCBCR - && (td->td_ycbcrsubsampling[0]<<3 | td->td_ycbcrsubsampling[1]) - != 011 - && sp->jpegcolormode == JPEGCOLORMODE_RGB - ) tif->tif_flags |= TIFF_UPSAMPLED; - - /* If the up-sampling state changed, re-calculate tile size. */ - - if ((tif->tif_flags ^ v32) & TIFF_UPSAMPLED) - { - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; - tif->tif_flags |= TIFF_DIRTYDIRECT; - }; - return 1; - }; - TIFFSetFieldBit(tif,tag-TIFFTAG_JPEGPROC+FIELD_JPEGPROC); - return 1; -# undef td - } - -static int -OJPEGVGetField(register TIFF *tif,ttag_t tag,va_list ap) - { register OJPEGState *sp = OJState(tif); - - switch (tag) - { - - /* If this file has managed to synthesize a set of consolidated "metadata" - tables for the current (post-TIFF Version 6.0 specification) JPEG-in- - TIFF encapsulation strategy, then tell our caller about them; otherwise, - keep mum. - */ - case TIFFTAG_JPEGTABLES : - if (sp->jpegtables_length) /* we have "new"-style JPEG tables */ - { - *va_arg(ap,uint32 *) = sp->jpegtables_length; - *va_arg(ap,char **) = sp->jpegtables; - return 1; - }; - - /* This pseudo tag indicates whether our caller is expected to do YCbCr <-> - RGB color-space conversion (JPEGCOLORMODE_RAW <=> 0) or whether we must - ask the JPEG Library to do it (JPEGCOLORMODE_RGB <=> 1). - */ - case TIFFTAG_JPEGCOLORMODE : - *va_arg(ap,uint32 *) = sp->jpegcolormode; - return 1; - - /* The following tags are defined by the TIFF Version 6.0 specification - and are obsolete. If our caller asks for information about them, do not - return anything, even if we parsed them in an old-format "source" image. - */ - case TIFFTAG_JPEGPROC : - *va_arg(ap, uint16*)=sp->jpegproc; - return(1); - break; - case TIFFTAG_JPEGIFOFFSET : - *va_arg(ap, uint32*)=sp->jpegifoffset; - return(1); - break; - case TIFFTAG_JPEGIFBYTECOUNT : - *va_arg(ap, uint32*)=sp->jpegifbytecount; - return(1); - break; - case TIFFTAG_JPEGRESTARTINTERVAL : - *va_arg(ap, uint32*)=sp->jpegrestartinterval; - return(1); - break; - case TIFFTAG_JPEGLOSSLESSPREDICTORS: - *va_arg(ap, uint32*)=sp->jpeglosslesspredictors_length; - *va_arg(ap, void**)=sp->jpeglosslesspredictors; - return(1); - break; - case TIFFTAG_JPEGPOINTTRANSFORM : - *va_arg(ap, uint32*)=sp->jpegpointtransform_length; - *va_arg(ap, void**)=sp->jpegpointtransform; - return(1); - break; - case TIFFTAG_JPEGQTABLES : - *va_arg(ap, uint32*)=sp->jpegqtables_length; - *va_arg(ap, void**)=sp->jpegqtables; - return(1); - break; - case TIFFTAG_JPEGDCTABLES : - *va_arg(ap, uint32*)=sp->jpegdctables_length; - *va_arg(ap, void**)=sp->jpegdctables; - return(1); - break; - case TIFFTAG_JPEGACTABLES : - *va_arg(ap, uint32*)=sp->jpegactables_length; - *va_arg(ap, void**)=sp->jpegactables; - return(1); - break; - }; - return (*sp->vgetparent)(tif,tag,ap); - } - -static void -OJPEGPrintDir(register TIFF *tif,FILE *fd,long flags) - { register OJPEGState *sp = OJState(tif); - - if ( ( flags - & (TIFFPRINT_JPEGQTABLES|TIFFPRINT_JPEGDCTABLES|TIFFPRINT_JPEGACTABLES) - ) - && sp->jpegtables_length - ) - fprintf(fd," JPEG Table Data: , %lu bytes\n", - sp->jpegtables_length); - } - -static uint32 -OJPEGDefaultStripSize(register TIFF *tif,register uint32 s) - { register OJPEGState *sp = OJState(tif); -# define td (&tif->tif_dir) - - if ((s = (*sp->defsparent)(tif,s)) < td->td_imagelength) - { register tsize_t size = sp->cinfo.comm.is_decompressor -# ifdef D_LOSSLESS_SUPPORTED - ? sp->cinfo.d.min_codec_data_unit -# else - ? DCTSIZE -# endif -# ifdef C_LOSSLESS_SUPPORTED - : sp->cinfo.c.data_unit; -# else - : DCTSIZE; -# endif - - size = TIFFroundup(size,16); - s = TIFFroundup(s,td->td_ycbcrsubsampling[1]*size); - }; - return s; -# undef td - } - -static void -OJPEGDefaultTileSize(register TIFF *tif,register uint32 *tw,register uint32 *th) - { register OJPEGState *sp = OJState(tif); - register tsize_t size; -# define td (&tif->tif_dir) - - size = sp->cinfo.comm.is_decompressor -# ifdef D_LOSSLESS_SUPPORTED - ? sp->cinfo.d.min_codec_data_unit -# else - ? DCTSIZE -# endif -# ifdef C_LOSSLESS_SUPPORTED - : sp->cinfo.c.data_unit; -# else - : DCTSIZE; -# endif - size = TIFFroundup(size,16); - (*sp->deftparent)(tif,tw,th); - *tw = TIFFroundup(*tw,td->td_ycbcrsubsampling[0]*size); - *th = TIFFroundup(*th,td->td_ycbcrsubsampling[1]*size); -# undef td - } - -static void -OJPEGCleanUp(register TIFF *tif) - { register OJPEGState *sp; - - if ( (sp = OJState(tif)) ) - { - CALLVJPEG(sp,jpeg_destroy(&sp->cinfo.comm)); /* Free JPEG Lib. vars. */ - if (sp->jpegtables) {_TIFFfree(sp->jpegtables);sp->jpegtables=0;} - if (sp->jpeglosslesspredictors) { - _TIFFfree(sp->jpeglosslesspredictors); - sp->jpeglosslesspredictors = 0; - } - if (sp->jpegpointtransform) { - _TIFFfree(sp->jpegpointtransform); - sp->jpegpointtransform=0; - } - if (sp->jpegqtables) {_TIFFfree(sp->jpegqtables);sp->jpegqtables=0;} - if (sp->jpegactables) {_TIFFfree(sp->jpegactables);sp->jpegactables=0;} - if (sp->jpegdctables) {_TIFFfree(sp->jpegdctables);sp->jpegdctables=0;} - /* If the image file isn't "memory mapped" and we read it all into a - single, large memory buffer, free the buffer now. - */ - if (!isMapped(tif) && tif->tif_base) /* free whole-file buffer */ - { - _TIFFfree(tif->tif_base); - tif->tif_base = 0; - tif->tif_size = 0; - }; - _TIFFfree(sp); /* Release local variables */ - tif->tif_data = 0; - } - } - -int -TIFFInitOJPEG(register TIFF *tif,int scheme) - { register OJPEGState *sp; -# define td (&tif->tif_dir) -# ifndef never - - /* This module supports a decompression-only CODEC, which is intended strictly - for viewing old image files using the obsolete JPEG-in-TIFF encapsulation - specified by the TIFF Version 6.0 specification. It does not, and never - should, support compression for new images. If a client application asks us - to, refuse and complain loudly! - */ - if (tif->tif_mode != O_RDONLY) return _notSupported(tif); -# endif /* never */ - if (!isMapped(tif)) - { - - /* BEWARE OF KLUDGE: If our host operating-system doesn't let an image - file be "memory mapped", then we want to read the - entire file into a single (possibly large) memory buffer as if it had - been "memory mapped". Although this is likely to waste space, because - analysis of the file's content might cause parts of it to be read into - smaller buffers duplicatively, it appears to be the lesser of several - evils. Very old JPEG-in-TIFF encapsulations aren't guaranteed to be - JFIF bit streams, or to have a TIFF "JPEGTables" record or much other - "metadata" to help us locate the decoding tables and entropy-coded data, - so we're likely do a lot of random-access grokking around, and we must - ultimately tell the JPEG Library to sequentially scan much of the file - anyway. This is all likely to be easier if we use "brute force" to - read the entire file, once, and don't use incremental disc I/O. If our - client application tries to process a file so big that we can't buffer - it entirely, then tough shit: we'll give up and exit! - */ - if (!(tif->tif_base = _TIFFmalloc(tif->tif_size=TIFFGetFileSize(tif)))) - { - TIFFError(tif->tif_name,"Cannot allocate file buffer"); - return 0; - }; - if (!SeekOK(tif,0) || !ReadOK(tif,tif->tif_base,tif->tif_size)) - { - TIFFError(tif->tif_name,"Cannot read file"); - return 0; - } - }; - - /* Allocate storage for this module's per-file variables. */ - - if (!(tif->tif_data = (tidata_t)_TIFFmalloc(sizeof *sp))) - { - TIFFError("TIFFInitOJPEG","No space for JPEG state block"); - return 0; - }; - (sp = OJState(tif))->tif = tif; /* Initialize reverse pointer */ - sp->cinfo.d.err = jpeg_std_error(&sp->err); /* Initialize error handling */ - sp->err.error_exit = TIFFojpeg_error_exit; - sp->err.output_message = TIFFojpeg_output_message; - if (!CALLVJPEG(sp,jpeg_create_decompress(&sp->cinfo.d))) return 0; - - /* Install CODEC-specific tag information and override default TIFF Library - "method" subroutines with our own, CODEC-specific methods. Like all good - members of an object-class, we save some of these subroutine pointers for - "fall back" in case our own methods fail. - */ - _TIFFMergeFieldInfo(tif,ojpegFieldInfo, - sizeof ojpegFieldInfo/sizeof *ojpegFieldInfo); - sp->defsparent = tif->tif_defstripsize; - sp->deftparent = tif->tif_deftilesize; - sp->vgetparent = tif->tif_tagmethods.vgetfield; - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_defstripsize = OJPEGDefaultStripSize; - tif->tif_deftilesize = OJPEGDefaultTileSize; - tif->tif_tagmethods.vgetfield = OJPEGVGetField; - tif->tif_tagmethods.vsetfield = OJPEGVSetField; - tif->tif_tagmethods.printdir = OJPEGPrintDir; -# ifdef never - tif->tif_setupencode = OJPEGSetupEncode; - tif->tif_preencode = OJPEGPreEncode; - tif->tif_postencode = OJPEGPostEncode; -# else /* well, hardly ever */ - tif->tif_setupencode = tif->tif_postencode = _notSupported; - tif->tif_preencode = (TIFFPreMethod)_notSupported; -# endif /* never */ - tif->tif_setupdecode = OJPEGSetupDecode; - tif->tif_predecode = OJPEGPreDecode; - tif->tif_postdecode = OJPEGPostDecode; - tif->tif_cleanup = OJPEGCleanUp; - - /* If the image file doesn't have "JPEGInterchangeFormat[Length]" TIFF records - to guide us, we have few clues about where its encapsulated JPEG bit stream - is located, so establish intelligent defaults: If the Image File Directory - doesn't immediately follow the TIFF header, assume that the JPEG data lies - in between; otherwise, assume that it follows the Image File Directory. - */ - if (tif->tif_header.tiff_diroff > sizeof tif->tif_header) - { - sp->src.next_input_byte = tif->tif_base + sizeof tif->tif_header; - sp->src.bytes_in_buffer = tif->tif_header.tiff_diroff - - sizeof tif->tif_header; - } - else /* this case is ugly! */ - { uint32 maxoffset = tif->tif_size; - uint16 dircount; - - /* Calculate the offset to the next Image File Directory, if there is one, - or to the end of the file, if not. Then arrange to read the file from - the end of the Image File Directory to that offset. - */ - if (tif->tif_nextdiroff) maxoffset = tif->tif_nextdiroff; /* Not EOF */ - _TIFFmemcpy(&dircount,(const tdata_t) - (sp->src.next_input_byte = tif->tif_base+tif->tif_header.tiff_diroff), - sizeof dircount); - if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); - sp->src.next_input_byte += dircount*sizeof(TIFFDirEntry) - + sizeof maxoffset + sizeof dircount; - sp->src.bytes_in_buffer = tif->tif_base - sp->src.next_input_byte - + maxoffset; - }; - - /* IJG JPEG Library Version 6B can be configured for either 8- or 12-bit sample - precision, but we assume that "old JPEG" TIFF clients only need 8 bits. - */ - sp->cinfo.d.data_precision = 8; -# ifdef C_LOSSLESS_SUPPORTED - - /* If the "JPEGProc" TIFF tag is missing from the Image File Dictionary, the - JPEG Library will use its (lossy) baseline sequential process by default. - */ - sp->cinfo.d.data_unit = DCTSIZE; -# endif /* C_LOSSLESS_SUPPORTED */ - - /* Initialize other CODEC-specific variables requiring default values. */ - - tif->tif_flags |= TIFF_NOBITREV; /* No bit-reversal within data bytes */ - sp->h_sampling = sp->v_sampling = 1; /* No subsampling by default */ - sp->is_WANG = 0; /* Assume not a MS Windows Wang Imaging file by default */ - sp->jpegtables = 0; /* No "new"-style JPEG tables synthesized yet */ - sp->jpegtables_length = 0; - sp->jpegquality = 75; /* Default IJG quality */ - sp->jpegcolormode = JPEGCOLORMODE_RAW; - sp->jpegtablesmode = 0; /* No tables found yet */ - sp->jpeglosslesspredictors=0; - sp->jpeglosslesspredictors_length=0; - sp->jpegpointtransform=0; - sp->jpegpointtransform_length=0; - sp->jpegqtables=0; - sp->jpegqtables_length=0; - sp->jpegdctables=0; - sp->jpegdctables_length=0; - sp->jpegactables=0; - sp->jpegactables_length=0; - return 1; -# undef td - } -#endif /* OJPEG_SUPPORT */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_read.c b/libs/tiff-3.8.2/libtiff/tif_read.c deleted file mode 100644 index c7d1fba7d9..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_read.c +++ /dev/null @@ -1,650 +0,0 @@ -/* $Id: tif_read.c,v 1.13 2005/12/21 12:23:13 joris Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * Scanline-oriented Read Support - */ -#include "tiffiop.h" -#include - - int TIFFFillStrip(TIFF*, tstrip_t); - int TIFFFillTile(TIFF*, ttile_t); -static int TIFFStartStrip(TIFF*, tstrip_t); -static int TIFFStartTile(TIFF*, ttile_t); -static int TIFFCheckRead(TIFF*, int); - -#define NOSTRIP ((tstrip_t) -1) /* undefined state */ -#define NOTILE ((ttile_t) -1) /* undefined state */ - -/* - * Seek to a random row+sample in a file. - */ -static int -TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) -{ - register TIFFDirectory *td = &tif->tif_dir; - tstrip_t strip; - - if (row >= td->td_imagelength) { /* out of range */ - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%lu: Row out of range, max %lu", - (unsigned long) row, (unsigned long) td->td_imagelength); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); - return (0); - } - strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; - } else - strip = row / td->td_rowsperstrip; - if (strip != tif->tif_curstrip) { /* different strip, refill */ - if (!TIFFFillStrip(tif, strip)) - return (0); - } else if (row < tif->tif_row) { - /* - * Moving backwards within the same strip: backup - * to the start and then decode forward (below). - * - * NB: If you're planning on lots of random access within a - * strip, it's better to just read and decode the entire - * strip, and then access the decoded data in a random fashion. - */ - if (!TIFFStartStrip(tif, strip)) - return (0); - } - if (row != tif->tif_row) { - /* - * Seek forward to the desired row. - */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (0); - tif->tif_row = row; - } - return (1); -} - -int -TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) -{ - int e; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if( (e = TIFFSeek(tif, row, sample)) != 0) { - /* - * Decompress desired row into user buffer. - */ - e = (*tif->tif_decoderow) - (tif, (tidata_t) buf, tif->tif_scanlinesize, sample); - - /* we are now poised at the beginning of the next row */ - tif->tif_row = row + 1; - - if (e) - (*tif->tif_postdecode)(tif, (tidata_t) buf, - tif->tif_scanlinesize); - } - return (e > 0 ? 1 : -1); -} - -/* - * Read a strip of data and decompress the specified - * amount into the user-supplied buffer. - */ -tsize_t -TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 nrows; - tsize_t stripsize; - tstrip_t sep_strip, strips_per_sep; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if (strip >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%ld: Strip out of range, max %ld", - (long) strip, (long) td->td_nstrips); - return (-1); - } - /* - * Calculate the strip size according to the number of - * rows in the strip (check for truncated last strip on any - * of the separations). - */ - if( td->td_rowsperstrip >= td->td_imagelength ) - strips_per_sep = 1; - else - strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1) - / td->td_rowsperstrip; - - sep_strip = strip % strips_per_sep; - - if (sep_strip != strips_per_sep-1 || - (nrows = td->td_imagelength % td->td_rowsperstrip) == 0) - nrows = td->td_rowsperstrip; - - stripsize = TIFFVStripSize(tif, nrows); - if (size == (tsize_t) -1) - size = stripsize; - else if (size > stripsize) - size = stripsize; - if (TIFFFillStrip(tif, strip) - && (*tif->tif_decodestrip)(tif, (tidata_t) buf, size, - (tsample_t)(strip / td->td_stripsperimage)) > 0 ) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return ((tsize_t) -1); -} - -static tsize_t -TIFFReadRawStrip1(TIFF* tif, - tstrip_t strip, tdata_t buf, tsize_t size, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (!isMapped(tif)) { - tsize_t cc; - - if (!SeekOK(tif, td->td_stripoffset[strip])) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at scanline %lu, strip %lu", - tif->tif_name, - (unsigned long) tif->tif_row, (unsigned long) strip); - return (-1); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at scanline %lu; got %lu bytes, expected %lu", - tif->tif_name, - (unsigned long) tif->tif_row, - (unsigned long) cc, - (unsigned long) size); - return (-1); - } - } else { - if (td->td_stripoffset[strip] + size > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at scanline %lu, strip %lu; got %lu bytes, expected %lu", - tif->tif_name, - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned long) tif->tif_size - td->td_stripoffset[strip], - (unsigned long) size); - return (-1); - } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[strip], - size); - } - return (size); -} - -/* - * Read a strip of data from the file. - */ -tsize_t -TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) -{ - static const char module[] = "TIFFReadRawStrip"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - if (!TIFFCheckRead(tif, 0)) - return ((tsize_t) -1); - if (strip >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%lu: Strip out of range, max %lu", - (unsigned long) strip, (unsigned long) td->td_nstrips); - return ((tsize_t) -1); - } - bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - return ((tsize_t) -1); - } - if (size != (tsize_t)-1 && size < bytecount) - bytecount = size; - return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); -} - -/* - * Read the specified strip and setup for decoding. - * The data buffer is expanded, as necessary, to - * hold the strip's data. - */ -int -TIFFFillStrip(TIFF* tif, tstrip_t strip) -{ - static const char module[] = "TIFFFillStrip"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - return (0); - } - if (isMapped(tif) && - (isFillOrder(tif, td->td_fillorder) - || (tif->tif_flags & TIFF_NOBITREV))) { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is going - * to handle this operation itself. In this case, avoid - * copying the raw data and instead just reference the - * data from the memory mapped file image. This assumes - * that the decompression routines do not modify the - * contents of the raw data buffer (if they try to, - * the application will get a fault since the file is - * mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - if ( td->td_stripoffset[strip] + bytecount > tif->tif_size) { - /* - * This error message might seem strange, but it's - * what would happen if a read were done instead. - */ - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error on strip %lu; got %lu bytes, expected %lu", - tif->tif_name, - (unsigned long) strip, - (unsigned long) tif->tif_size - td->td_stripoffset[strip], - (unsigned long) bytecount); - tif->tif_curstrip = NOSTRIP; - return (0); - } - tif->tif_rawdatasize = bytecount; - tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip]; - } else { - /* - * Expand raw data buffer, if needed, to - * hold data strip coming from file - * (perhaps should set upper bound on - * the size of a buffer we'll use?). - */ - if (bytecount > tif->tif_rawdatasize) { - tif->tif_curstrip = NOSTRIP; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Data buffer too small to hold strip %lu", - tif->tif_name, (unsigned long) strip); - return (0); - } - if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) - return (0); - } - if (TIFFReadRawStrip1(tif, strip, (unsigned char *)tif->tif_rawdata, - bytecount, module) != bytecount) - return (0); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecount); - } - return (TIFFStartStrip(tif, strip)); -} - -/* - * Tile-oriented Read Support - * Contributed by Nancy Cam (Silicon Graphics). - */ - -/* - * Read and decompress a tile of data. The - * tile is selected by the (x,y,z,s) coordinates. - */ -tsize_t -TIFFReadTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) - return (-1); - return (TIFFReadEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); -} - -/* - * Read a tile of data and decompress the specified - * amount into the user-supplied buffer. - */ -tsize_t -TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize = tif->tif_tilesize; - - if (!TIFFCheckRead(tif, 1)) - return (-1); - if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%ld: Tile out of range, max %ld", - (long) tile, (unsigned long) td->td_nstrips); - return (-1); - } - if (size == (tsize_t) -1) - size = tilesize; - else if (size > tilesize) - size = tilesize; - if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, - (tidata_t) buf, size, (tsample_t)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return (-1); -} - -static tsize_t -TIFFReadRawTile1(TIFF* tif, - ttile_t tile, tdata_t buf, tsize_t size, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (!isMapped(tif)) { - tsize_t cc; - - if (!SeekOK(tif, td->td_stripoffset[tile])) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at row %ld, col %ld, tile %ld", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile); - return ((tsize_t) -1); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at row %ld, col %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (unsigned long) cc, - (unsigned long) size); - return ((tsize_t) -1); - } - } else { - if (td->td_stripoffset[tile] + size > tif->tif_size) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at row %ld, col %ld, tile %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile, - (unsigned long) tif->tif_size - td->td_stripoffset[tile], - (unsigned long) size); - return ((tsize_t) -1); - } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[tile], size); - } - return (size); -} - -/* - * Read a tile of data from the file. - */ -tsize_t -TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) -{ - static const char module[] = "TIFFReadRawTile"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - if (!TIFFCheckRead(tif, 1)) - return ((tsize_t) -1); - if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); - return ((tsize_t) -1); - } - bytecount = td->td_stripbytecount[tile]; - if (size != (tsize_t) -1 && size < bytecount) - bytecount = size; - return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); -} - -/* - * Read the specified tile and setup for decoding. - * The data buffer is expanded, as necessary, to - * hold the tile's data. - */ -int -TIFFFillTile(TIFF* tif, ttile_t tile) -{ - static const char module[] = "TIFFFillTile"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - bytecount = td->td_stripbytecount[tile]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid tile byte count, tile %lu", - (unsigned long) bytecount, (unsigned long) tile); - return (0); - } - if (isMapped(tif) && - (isFillOrder(tif, td->td_fillorder) - || (tif->tif_flags & TIFF_NOBITREV))) { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is going - * to handle this operation itself. In this case, avoid - * copying the raw data and instead just reference the - * data from the memory mapped file image. This assumes - * that the decompression routines do not modify the - * contents of the raw data buffer (if they try to, - * the application will get a fault since the file is - * mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - if ( td->td_stripoffset[tile] + bytecount > tif->tif_size) { - tif->tif_curtile = NOTILE; - return (0); - } - tif->tif_rawdatasize = bytecount; - tif->tif_rawdata = tif->tif_base + td->td_stripoffset[tile]; - } else { - /* - * Expand raw data buffer, if needed, to - * hold data tile coming from file - * (perhaps should set upper bound on - * the size of a buffer we'll use?). - */ - if (bytecount > tif->tif_rawdatasize) { - tif->tif_curtile = NOTILE; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Data buffer too small to hold tile %ld", - tif->tif_name, (long) tile); - return (0); - } - if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) - return (0); - } - if (TIFFReadRawTile1(tif, tile, - (unsigned char *)tif->tif_rawdata, - bytecount, module) != bytecount) - return (0); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecount); - } - return (TIFFStartTile(tif, tile)); -} - -/* - * Setup the raw data buffer in preparation for - * reading a strip of raw data. If the buffer - * is specified as zero, then a buffer of appropriate - * size is allocated by the library. Otherwise, - * the client must guarantee that the buffer is - * large enough to hold any individual strip of - * raw data. - */ -int -TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) -{ - static const char module[] = "TIFFReadBufferSetup"; - - if (tif->tif_rawdata) { - if (tif->tif_flags & TIFF_MYBUFFER) - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - } - if (bp) { - tif->tif_rawdatasize = size; - tif->tif_rawdata = (tidata_t) bp; - tif->tif_flags &= ~TIFF_MYBUFFER; - } else { - tif->tif_rawdatasize = TIFFroundup(size, 1024); - tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); - tif->tif_flags |= TIFF_MYBUFFER; - } - if (tif->tif_rawdata == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: No space for data buffer at scanline %ld", - tif->tif_name, (long) tif->tif_row); - tif->tif_rawdatasize = 0; - return (0); - } - return (1); -} - -/* - * Set state to appear as if a - * strip has just been read in. - */ -static int -TIFFStartStrip(TIFF* tif, tstrip_t strip) -{ - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[strip]; - return ((*tif->tif_predecode)(tif, - (tsample_t)(strip / td->td_stripsperimage))); -} - -/* - * Set state to appear as if a - * tile has just been read in. - */ -static int -TIFFStartTile(TIFF* tif, ttile_t tile) -{ - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curtile = tile; - tif->tif_row = - (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * - td->td_tilelength; - tif->tif_col = - (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * - td->td_tilewidth; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[tile]; - return ((*tif->tif_predecode)(tif, - (tsample_t)(tile/td->td_stripsperimage))); -} - -static int -TIFFCheckRead(TIFF* tif, int tiles) -{ - if (tif->tif_mode == O_WRONLY) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading"); - return (0); - } - if (tiles ^ isTiled(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ? - "Can not read tiles from a stripped image" : - "Can not read scanlines from a tiled image"); - return (0); - } - return (1); -} - -void -_TIFFNoPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; (void) buf; (void) cc; -} - -void -_TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 1) == 0); - TIFFSwabArrayOfShort((uint16*) buf, cc/2); -} - -void -_TIFFSwab24BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc % 3) == 0); - TIFFSwabArrayOfTriples((uint8*) buf, cc/3); -} - -void -_TIFFSwab32BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32*) buf, cc/4); -} - -void -_TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 7) == 0); - TIFFSwabArrayOfDouble((double*) buf, cc/8); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_stream.cxx b/libs/tiff-3.8.2/libtiff/tif_stream.cxx deleted file mode 100644 index a356d8ece7..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_stream.cxx +++ /dev/null @@ -1,289 +0,0 @@ -/* $Id: tif_stream.cxx,v 1.5 2005/07/26 08:11:13 dron Exp $ */ - -/* - * Copyright (c) 1988-1996 Sam Leffler - * Copyright (c) 1991-1996 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library UNIX-specific Routines. - */ -#include "tiffiop.h" -#include - -using namespace std; - -class tiffis_data -{ - public: - - istream *myIS; - long myStreamStartPos; -}; - -class tiffos_data -{ - public: - - ostream *myOS; - long myStreamStartPos; -}; - -static tsize_t -_tiffosReadProc(thandle_t, tdata_t, tsize_t) -{ - return 0; -} - -static tsize_t -_tiffisReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - tiffis_data *data = (tiffis_data *)fd; - - data->myIS->read((char *)buf, (int)size); - - return data->myIS->gcount(); -} - -static tsize_t -_tiffosWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - tiffos_data *data = (tiffos_data *)fd; - ostream *os = data->myOS; - int pos = os->tellp(); - - os->write((const char *)buf, size); - - return ((int)os->tellp()) - pos; -} - -static tsize_t -_tiffisWriteProc(thandle_t, tdata_t, tsize_t) -{ - return 0; -} - -static toff_t -_tiffosSeekProc(thandle_t fd, toff_t off, int whence) -{ - tiffos_data *data = (tiffos_data *)fd; - ostream *os = data->myOS; - - // if the stream has already failed, don't do anything - if( os->fail() ) - return os->tellp(); - - switch(whence) { - case SEEK_SET: - os->seekp(data->myStreamStartPos + off, ios::beg); - break; - case SEEK_CUR: - os->seekp(off, ios::cur); - break; - case SEEK_END: - os->seekp(off, ios::end); - break; - } - - // Attempt to workaround problems with seeking past the end of the - // stream. ofstream doesn't have a problem with this but - // ostrstream/ostringstream does. In that situation, add intermediate - // '\0' characters. - if( os->fail() ) { - ios::iostate old_state; - toff_t origin; - - old_state = os->rdstate(); - // reset the fail bit or else tellp() won't work below - os->clear(os->rdstate() & ~ios::failbit); - switch( whence ) { - case SEEK_SET: - origin = data->myStreamStartPos; - break; - case SEEK_CUR: - origin = os->tellp(); - break; - case SEEK_END: - os->seekp(0, ios::end); - origin = os->tellp(); - break; - } - // restore original stream state - os->clear(old_state); - - // only do something if desired seek position is valid - if( origin + off > data->myStreamStartPos ) { - toff_t num_fill; - - // clear the fail bit - os->clear(os->rdstate() & ~ios::failbit); - - // extend the stream to the expected size - os->seekp(0, ios::end); - num_fill = origin + off - (toff_t)os->tellp(); - for( toff_t i = 0; i < num_fill; i++ ) - os->put('\0'); - - // retry the seek - os->seekp(origin + off, ios::beg); - } - } - - return os->tellp(); -} - -static toff_t -_tiffisSeekProc(thandle_t fd, toff_t off, int whence) -{ - tiffis_data *data = (tiffis_data *)fd; - - switch(whence) { - case SEEK_SET: - data->myIS->seekg(data->myStreamStartPos + off, ios::beg); - break; - case SEEK_CUR: - data->myIS->seekg(off, ios::cur); - break; - case SEEK_END: - data->myIS->seekg(off, ios::end); - break; - } - - return ((long)data->myIS->tellg()) - data->myStreamStartPos; -} - -static toff_t -_tiffosSizeProc(thandle_t fd) -{ - tiffos_data *data = (tiffos_data *)fd; - ostream *os = data->myOS; - toff_t pos = os->tellp(); - toff_t len; - - os->seekp(0, ios::end); - len = os->tellp(); - os->seekp(pos); - - return len; -} - -static toff_t -_tiffisSizeProc(thandle_t fd) -{ - tiffis_data *data = (tiffis_data *)fd; - int pos = data->myIS->tellg(); - int len; - - data->myIS->seekg(0, ios::end); - len = data->myIS->tellg(); - data->myIS->seekg(pos); - - return len; -} - -static int -_tiffosCloseProc(thandle_t fd) -{ - // Our stream was not allocated by us, so it shouldn't be closed by us. - delete (tiffos_data *)fd; - return 0; -} - -static int -_tiffisCloseProc(thandle_t fd) -{ - // Our stream was not allocated by us, so it shouldn't be closed by us. - delete (tiffis_data *)fd; - return 0; -} - -static int -_tiffDummyMapProc(thandle_t , tdata_t* , toff_t* ) -{ - return (0); -} - -static void -_tiffDummyUnmapProc(thandle_t , tdata_t , toff_t ) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -static TIFF* -_tiffStreamOpen(const char* name, const char* mode, void *fd) -{ - TIFF* tif; - - if( strchr(mode, 'w') ) { - tiffos_data *data = new tiffos_data; - data->myOS = (ostream *)fd; - data->myStreamStartPos = data->myOS->tellp(); - - // Open for writing. - tif = TIFFClientOpen(name, mode, - (thandle_t) data, - _tiffosReadProc, _tiffosWriteProc, - _tiffosSeekProc, _tiffosCloseProc, - _tiffosSizeProc, - _tiffDummyMapProc, _tiffDummyUnmapProc); - } else { - tiffis_data *data = new tiffis_data; - data->myIS = (istream *)fd; - data->myStreamStartPos = data->myIS->tellg(); - // Open for reading. - tif = TIFFClientOpen(name, mode, - (thandle_t) data, - _tiffisReadProc, _tiffisWriteProc, - _tiffisSeekProc, _tiffisCloseProc, - _tiffisSizeProc, - _tiffDummyMapProc, _tiffDummyUnmapProc); - } - - return (tif); -} - -TIFF* -TIFFStreamOpen(const char* name, ostream *os) -{ - // If os is either a ostrstream or ostringstream, and has no data - // written to it yet, then tellp() will return -1 which will break us. - // We workaround this by writing out a dummy character and - // then seek back to the beginning. - if( !os->fail() && (int)os->tellp() < 0 ) { - *os << '\0'; - os->seekp(0); - } - - // NB: We don't support mapped files with streams so add 'm' - return _tiffStreamOpen(name, "wm", os); -} - -TIFF* -TIFFStreamOpen(const char* name, istream *is) -{ - // NB: We don't support mapped files with streams so add 'm' - return _tiffStreamOpen(name, "rm", is); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_strip.c b/libs/tiff-3.8.2/libtiff/tif_strip.c deleted file mode 100644 index 78854d1046..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_strip.c +++ /dev/null @@ -1,294 +0,0 @@ -/* $Id: tif_strip.c,v 1.17 2006/03/21 16:29:33 dron Exp $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Strip-organized Image Support Routines. - */ -#include "tiffiop.h" - -static uint32 -summarize(TIFF* tif, size_t summand1, size_t summand2, const char* where) -{ - /* - * XXX: We are using casting to uint32 here, bacause sizeof(size_t) - * may be larger than sizeof(uint32) on 64-bit architectures. - */ - uint32 bytes = summand1 + summand2; - - if (bytes - summand1 != summand2) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -static uint32 -multiply(TIFF* tif, size_t nmemb, size_t elem_size, const char* where) -{ - uint32 bytes = nmemb * elem_size; - - if (elem_size && bytes / elem_size != nmemb) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -/* - * Compute which strip a (row,sample) value is in. - */ -tstrip_t -TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample) -{ - TIFFDirectory *td = &tif->tif_dir; - tstrip_t strip; - - strip = row / td->td_rowsperstrip; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); - return ((tstrip_t) 0); - } - strip += sample*td->td_stripsperimage; - } - return (strip); -} - -/* - * Compute how many strips are in an image. - */ -tstrip_t -TIFFNumberOfStrips(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tstrip_t nstrips; - - nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip)); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - nstrips = multiply(tif, nstrips, td->td_samplesperpixel, - "TIFFNumberOfStrips"); - return (nstrips); -} - -/* - * Compute the # bytes in a variable height, row-aligned strip. - */ -tsize_t -TIFFVStripSize(TIFF* tif, uint32 nrows) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (nrows == (uint32) -1) - nrows = td->td_imagelength; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - uint16 ycbcrsubsampling[2]; - tsize_t w, scanline, samplingarea; - - TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, - ycbcrsubsampling + 1 ); - - samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1]; - if (samplingarea == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Invalid YCbCr subsampling"); - return 0; - } - - w = TIFFroundup(td->td_imagewidth, ycbcrsubsampling[0]); - scanline = TIFFhowmany8(multiply(tif, w, td->td_bitspersample, - "TIFFVStripSize")); - nrows = TIFFroundup(nrows, ycbcrsubsampling[1]); - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - scanline = multiply(tif, nrows, scanline, "TIFFVStripSize"); - return ((tsize_t) - summarize(tif, scanline, - multiply(tif, 2, scanline / samplingarea, - "TIFFVStripSize"), "TIFFVStripSize")); - } else - return ((tsize_t) multiply(tif, nrows, TIFFScanlineSize(tif), - "TIFFVStripSize")); -} - - -/* - * Compute the # bytes in a raw strip. - */ -tsize_t -TIFFRawStripSize(TIFF* tif, tstrip_t strip) -{ - TIFFDirectory* td = &tif->tif_dir; - tsize_t bytecount = td->td_stripbytecount[strip]; - - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - bytecount = (tsize_t) -1; - } - - return bytecount; -} - -/* - * Compute the # bytes in a (row-aligned) strip. - * - * Note that if RowsPerStrip is larger than the - * recorded ImageLength, then the strip size is - * truncated to reflect the actual space required - * to hold the strip. - */ -tsize_t -TIFFStripSize(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - uint32 rps = td->td_rowsperstrip; - if (rps > td->td_imagelength) - rps = td->td_imagelength; - return (TIFFVStripSize(tif, rps)); -} - -/* - * Compute a default strip size based on the image - * characteristics and a requested value. If the - * request is <1 then we choose a strip size according - * to certain heuristics. - */ -uint32 -TIFFDefaultStripSize(TIFF* tif, uint32 request) -{ - return (*tif->tif_defstripsize)(tif, request); -} - -uint32 -_TIFFDefaultStripSize(TIFF* tif, uint32 s) -{ - if ((int32) s < 1) { - /* - * If RowsPerStrip is unspecified, try to break the - * image up into strips that are approximately - * STRIP_SIZE_DEFAULT bytes long. - */ - tsize_t scanline = TIFFScanlineSize(tif); - s = (uint32)STRIP_SIZE_DEFAULT / (scanline == 0 ? 1 : scanline); - if (s == 0) /* very wide images */ - s = 1; - } - return (s); -} - -/* - * Return the number of bytes to read/write in a call to - * one of the scanline-oriented i/o routines. Note that - * this number may be 1/samples-per-pixel if data is - * stored as separate planes. - */ -tsize_t -TIFFScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - if (td->td_photometric == PHOTOMETRIC_YCBCR - && !isUpSampled(tif)) { - uint16 ycbcrsubsampling[2]; - - TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, - ycbcrsubsampling + 1); - - if (ycbcrsubsampling[0] == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Invalid YCbCr subsampling"); - return 0; - } - - scanline = TIFFroundup(td->td_imagewidth, - ycbcrsubsampling[0]); - scanline = TIFFhowmany8(multiply(tif, scanline, - td->td_bitspersample, - "TIFFScanlineSize")); - return ((tsize_t) - summarize(tif, scanline, - multiply(tif, 2, - scanline / ycbcrsubsampling[0], - "TIFFVStripSize"), - "TIFFVStripSize")); - } else { - scanline = multiply(tif, td->td_imagewidth, - td->td_samplesperpixel, - "TIFFScanlineSize"); - } - } else - scanline = td->td_imagewidth; - return ((tsize_t) TIFFhowmany8(multiply(tif, scanline, - td->td_bitspersample, - "TIFFScanlineSize"))); -} - -/* - * Return the number of bytes required to store a complete - * decoded and packed raster scanline (as opposed to the - * I/O size returned by TIFFScanlineSize which may be less - * if data is store as separate planes). - */ -tsize_t -TIFFRasterScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - scanline = multiply (tif, td->td_bitspersample, td->td_imagewidth, - "TIFFRasterScanlineSize"); - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - scanline = multiply (tif, scanline, td->td_samplesperpixel, - "TIFFRasterScanlineSize"); - return ((tsize_t) TIFFhowmany8(scanline)); - } else - return ((tsize_t) multiply (tif, TIFFhowmany8(scanline), - td->td_samplesperpixel, - "TIFFRasterScanlineSize")); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_win3.c b/libs/tiff-3.8.2/libtiff/tif_win3.c deleted file mode 100644 index b16b214da3..0000000000 --- a/libs/tiff-3.8.2/libtiff/tif_win3.c +++ /dev/null @@ -1,225 +0,0 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win3.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Windows 3.x-specific Routines. - */ -#include "tiffiop.h" -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#include /* for open, close, etc. function prototypes */ -#endif - -#include -#include -#include - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (_hread(fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (_hwrite(fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return (_llseek(fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (_lclose(fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - OFSTRUCT of; - int mm = 0; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m & O_CREAT) { - if ((m & O_TRUNC) || OpenFile(name, &of, OF_EXIST) != HFILE_ERROR) - mm |= OF_CREATE; - } - if (m & O_WRONLY) - mm |= OF_WRITE; - if (m & O_RDWR) - mm |= OF_READWRITE; - fd = OpenFile(name, &of, mm); - if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (tdata_t) GlobalAllocPtr(GHND, (DWORD) s); -} - -void -_TIFFfree(tdata_t p) -{ - GlobalFreePtr(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (tdata_t) GlobalReAllocPtr(p, (DWORD) s, GHND); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - char* pp = (char*) p; - - while (c > 0) { - tsize_t chunk = 0x10000 - ((uint32) pp & 0xffff);/* What's left in segment */ - if (chunk > 0xff00) /* No more than 0xff00 */ - chunk = 0xff00; - if (chunk > c) /* No more than needed */ - chunk = c; - memset(pp, v, chunk); - pp = (char*) (chunk + (char huge*) pp); - c -= chunk; - } -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - if (c > 0xFFFF) - hmemcpy((void _huge*) d, (void _huge*) s, c); - else - (void) memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t d, const tdata_t s, tsize_t c) -{ - char* dd = (char*) d; - char* ss = (char*) s; - tsize_t chunks, chunkd, chunk; - int result; - - while (c > 0) { - chunks = 0x10000 - ((uint32) ss & 0xffff); /* What's left in segment */ - chunkd = 0x10000 - ((uint32) dd & 0xffff); /* What's left in segment */ - chunk = c; /* Get the largest of */ - if (chunk > chunks) /* c, chunks, chunkd, */ - chunk = chunks; /* 0xff00 */ - if (chunk > chunkd) - chunk = chunkd; - if (chunk > 0xff00) - chunk = 0xff00; - result = memcmp(dd, ss, chunk); - if (result != 0) - return (result); - dd = (char*) (chunk + (char huge*) dd); - ss = (char*) (chunk + (char huge*) ss); - c -= chunk; - } - return (0); -} - -static void -win3WarningHandler(const char* module, const char* fmt, va_list ap) -{ - char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ":"); - vsprintf(e+strlen(e), fmt, ap); - strcat(e, "."); - MessageBox(GetActiveWindow(), e, "LibTIFF Warning", - MB_OK|MB_ICONEXCLAMATION); -} -TIFFErrorHandler _TIFFwarningHandler = win3WarningHandler; - -static void -win3ErrorHandler(const char* module, const char* fmt, va_list ap) -{ - char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ":"); - vsprintf(e+strlen(e), fmt, ap); - strcat(e, "."); - MessageBox(GetActiveWindow(), e, "LibTIFF Error", MB_OK|MB_ICONSTOP); -} -TIFFErrorHandler _TIFFerrorHandler = win3ErrorHandler; diff --git a/libs/tiff-3.8.2/libtiff/tiffio.h b/libs/tiff-3.8.2/libtiff/tiffio.h deleted file mode 100644 index 7aaf561386..0000000000 --- a/libs/tiff-3.8.2/libtiff/tiffio.h +++ /dev/null @@ -1,515 +0,0 @@ -/* $Id: tiffio.h,v 1.50 2006/03/21 16:37:51 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" -#include "tiffvers.h" - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets being the most important, and to ensure - * that it is unsigned, rather than signed. - */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrip_t; /* strip number */ -typedef uint32 ttile_t; /* tile number */ -typedef int32 tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ -typedef uint32 toff_t; /* file offset */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* - * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c - * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). - * - * By default tif_unix.c is assumed. - */ - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) -# define AVOID_WIN32_FILEIO -# endif -#endif - -#if defined(USE_WIN32_FILEIO) -# define VC_EXTRALEAN -# include -# ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -# else -typedef HFILE thandle_t; /* client data handle */ -# endif /* __WIN32__ */ -#else -typedef void* thandle_t; /* client data handle */ -#endif /* USE_WIN32_FILEIO */ - -#ifndef NULL -# define NULL (void *)0 -#endif - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * Colour conversion stuff - */ - -/* reference white */ -#define D65_X0 (95.0470F) -#define D65_Y0 (100.0F) -#define D65_Z0 (108.8827F) - -#define D50_X0 (96.4250F) -#define D50_Y0 (100.0F) -#define D50_Z0 (82.4680F) - -/* Structure for holding information about a display device. */ - -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ - -typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ - float d_Y0G; - float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; -} TIFFDisplay; - -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; -} TIFFYCbCrToRGB; - -typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ -#define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ -} TIFFCIELabToRGB; - -/* - * RGBA-style image support. - */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap pallete */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; /* put decoded strip/tile */ - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include -#include - -/* share internal LogLuv conversion routines? */ -#ifndef LOGLUV_PUBLIC -#define LOGLUV_PUBLIC 1 -#endif - -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); -typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); -typedef void (*TIFFExtendProc)(TIFF*); - -extern const char* TIFFGetVersion(void); - -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); -extern TIFFCodec* TIFFGetConfiguredCODECs(void); - -/* - * Auxiliary functions. - */ - -extern tdata_t _TIFFmalloc(tsize_t); -extern tdata_t _TIFFrealloc(tdata_t, tsize_t); -extern void _TIFFmemset(tdata_t, int, tsize_t); -extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); -extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); -extern void _TIFFfree(tdata_t); - -/* -** Stuff, related to tag handling and creating custom tags. -*/ -extern int TIFFGetTagListCount( TIFF * ); -extern ttag_t TIFFGetTagListEntry( TIFF *, int tag_index ); - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -#define FIELD_CUSTOM 65 - -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -typedef struct _TIFFTagValue { - const TIFFFieldInfo *info; - int count; - void *value; -} TIFFTagValue; - -extern void TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); -extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); -extern const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *, - TIFFDataType); -extern const TIFFFieldInfo* TIFFFieldWithTag(TIFF*, ttag_t); -extern const TIFFFieldInfo* TIFFFieldWithName(TIFF*, const char *); - -typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - -typedef struct { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ -} TIFFTagMethods; - -extern TIFFTagMethods *TIFFAccessTagMethods( TIFF * ); -extern void *TIFFGetClientInfo( TIFF *, const char * ); -extern void TIFFSetClientInfo( TIFF *, void *, const char * ); - -extern void TIFFCleanup(TIFF*); -extern void TIFFClose(TIFF*); -extern int TIFFFlush(TIFF*); -extern int TIFFFlushData(TIFF*); -extern int TIFFGetField(TIFF*, ttag_t, ...); -extern int TIFFVGetField(TIFF*, ttag_t, va_list); -extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); -extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); -extern int TIFFReadDirectory(TIFF*); -extern int TIFFReadCustomDirectory(TIFF*, toff_t, const TIFFFieldInfo[], - size_t); -extern int TIFFReadEXIFDirectory(TIFF*, toff_t); -extern tsize_t TIFFScanlineSize(TIFF*); -extern tsize_t TIFFRasterScanlineSize(TIFF*); -extern tsize_t TIFFStripSize(TIFF*); -extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t); -extern tsize_t TIFFVStripSize(TIFF*, uint32); -extern tsize_t TIFFTileRowSize(TIFF*); -extern tsize_t TIFFTileSize(TIFF*); -extern tsize_t TIFFVTileSize(TIFF*, uint32); -extern uint32 TIFFDefaultStripSize(TIFF*, uint32); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int TIFFFileno(TIFF*); -extern int TIFFSetFileno(TIFF*, int); -extern thandle_t TIFFClientdata(TIFF*); -extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); -extern int TIFFGetMode(TIFF*); -extern int TIFFSetMode(TIFF*, int); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern int TIFFIsBigEndian(TIFF*); -extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); -extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); -extern TIFFSeekProc TIFFGetSeekProc(TIFF*); -extern TIFFCloseProc TIFFGetCloseProc(TIFF*); -extern TIFFSizeProc TIFFGetSizeProc(TIFF*); -extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); -extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern tdir_t TIFFCurrentDirectory(TIFF*); -extern tdir_t TIFFNumberOfDirectories(TIFF*); -extern uint32 TIFFCurrentDirOffset(TIFF*); -extern tstrip_t TIFFCurrentStrip(TIFF*); -extern ttile_t TIFFCurrentTile(TIFF*); -extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFSetupStrips(TIFF *); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, tdir_t); -extern int TIFFSetSubDirectory(TIFF*, uint32); -extern int TIFFUnlinkDirectory(TIFF*, tdir_t); -extern int TIFFSetField(TIFF*, ttag_t, ...); -extern int TIFFVSetField(TIFF*, ttag_t, va_list); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFCheckpointDirectory(TIFF *); -extern int TIFFRewriteDirectory(TIFF *); -extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -# ifdef __WIN32__ -extern TIFF* TIFFOpenW(const wchar_t*, const char*); -# endif /* __WIN32__ */ -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...); -extern void TIFFWarning(const char*, const char*, ...); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern ttile_t TIFFNumberOfTiles(TIFF*); -extern tsize_t TIFFReadTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tsize_t TIFFWriteTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); -extern tstrip_t TIFFNumberOfStrips(TIFF*); -extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ -extern void TIFFSetWriteOffset(TIFF*, toff_t); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16*, unsigned long); -extern void TIFFSwabArrayOfTriples(uint8*, unsigned long); -extern void TIFFSwabArrayOfLong(uint32*, unsigned long); -extern void TIFFSwabArrayOfDouble(double*, unsigned long); -extern void TIFFReverseBits(unsigned char *, unsigned long); -extern const unsigned char* TIFFGetBitRevTable(int); - -#ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -extern double LogL16toY(int); -extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); -extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); -#if defined(c_plusplus) || defined(__cplusplus) -extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); -extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); -extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); -#else -extern int LogL16fromY(double, int); -extern int LogL10fromY(double, int); -extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); -#endif -#endif /* LOGLUV_PUBLIC */ - -extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); -extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); - -extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); - -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - -#endif /* _TIFFIO_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tiffiop.h b/libs/tiff-3.8.2/libtiff/tiffiop.h deleted file mode 100644 index e32cb1c701..0000000000 --- a/libs/tiff-3.8.2/libtiff/tiffiop.h +++ /dev/null @@ -1,323 +0,0 @@ -/* $Id: tiffiop.h,v 1.46 2006/03/16 12:22:27 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIOP_ -#define _TIFFIOP_ -/* - * ``Library-private'' definitions. - */ - -#include "tif_config.h" - -#ifdef HAVE_FCNTL_H -# include -#endif - -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#ifdef HAVE_STRING_H -# include -#endif - -#ifdef HAVE_ASSERT_H -# include -#else -# define assert(x) -#endif - -#ifdef HAVE_SEARCH_H -# include -#else -extern void *lfind(const void *, const void *, size_t *, size_t, - int (*)(const void *, const void *)); -#endif - -#include "tiffio.h" -#include "tif_dir.h" - -#ifndef STRIP_SIZE_DEFAULT -# define STRIP_SIZE_DEFAULT 8192 -#endif - -#define streq(a,b) (strcmp(a,b) == 0) - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -typedef struct client_info { - struct client_info *next; - void *data; - char *name; -} TIFFClientInfoLink; - -/* - * Typedefs for ``method pointers'' used internally. - */ -typedef unsigned char tidataval_t; /* internal image data value type */ -typedef tidataval_t* tidata_t; /* reference to internal image data */ - -typedef void (*TIFFVoidMethod)(TIFF*); -typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, tsample_t); -typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); - -struct tiff { - char* tif_name; /* name of open file */ - int tif_fd; /* open file descriptor */ - int tif_mode; /* open mode (O_*) */ - uint32 tif_flags; -#define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */ -#define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */ -#define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */ -#define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */ -#define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */ -#define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */ -#define TIFF_SWAB 0x0080 /* byte swap file information */ -#define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */ -#define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */ -#define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */ -#define TIFF_MAPPED 0x0800 /* file is mapped into memory */ -#define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */ -#define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */ -#define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */ -#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */ -#define TIFF_HEADERONLY 0x10000 /* read header only, do not process */ - /* the first directory */ - toff_t tif_diroff; /* file offset of current directory */ - toff_t tif_nextdiroff; /* file offset of following directory */ - toff_t* tif_dirlist; /* list of offsets to already seen */ - /* directories to prevent IFD looping */ - uint16 tif_dirnumber; /* number of already seen directories */ - TIFFDirectory tif_dir; /* internal rep of current directory */ - TIFFHeader tif_header; /* file's header block */ - const int* tif_typeshift; /* data type shift counts */ - const long* tif_typemask; /* data type masks */ - uint32 tif_row; /* current scanline */ - tdir_t tif_curdir; /* current directory (index) */ - tstrip_t tif_curstrip; /* current strip for read/write */ - toff_t tif_curoff; /* current offset for read/write */ - toff_t tif_dataoff; /* current offset for writing dir */ -/* SubIFD support */ - uint16 tif_nsubifd; /* remaining subifds to write */ - toff_t tif_subifdoff; /* offset for patching SubIFD link */ -/* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - ttile_t tif_curtile; /* current tile for read/write */ - tsize_t tif_tilesize; /* # of bytes in a tile */ -/* compression scheme hooks */ - int tif_decodestatus; - TIFFBoolMethod tif_setupdecode;/* called once before predecode */ - TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ - TIFFBoolMethod tif_setupencode;/* called once before preencode */ - int tif_encodestatus; - TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ - TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ - TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ - TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ - TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ - TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ - TIFFCodeMethod tif_decodetile; /* tile decoding routine */ - TIFFCodeMethod tif_encodetile; /* tile encoding routine */ - TIFFVoidMethod tif_close; /* cleanup-on-close routine */ - TIFFSeekMethod tif_seek; /* position within a strip routine */ - TIFFVoidMethod tif_cleanup; /* cleanup state routine */ - TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ - TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ - tidata_t tif_data; /* compression scheme private data */ -/* input/output buffering */ - tsize_t tif_scanlinesize;/* # of bytes in a scanline */ - tsize_t tif_scanlineskew;/* scanline skew for reading strips */ - tidata_t tif_rawdata; /* raw data buffer */ - tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ - tidata_t tif_rawcp; /* current spot in raw buffer */ - tsize_t tif_rawcc; /* bytes unread from raw buffer */ -/* memory-mapped file support */ - tidata_t tif_base; /* base of mapped file */ - toff_t tif_size; /* size of mapped file region (bytes) */ - TIFFMapFileProc tif_mapproc; /* map file method */ - TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ -/* input/output callback methods */ - thandle_t tif_clientdata; /* callback parameter */ - TIFFReadWriteProc tif_readproc; /* read method */ - TIFFReadWriteProc tif_writeproc;/* write method */ - TIFFSeekProc tif_seekproc; /* lseek method */ - TIFFCloseProc tif_closeproc; /* close method */ - TIFFSizeProc tif_sizeproc; /* filesize method */ -/* post-decoding support */ - TIFFPostMethod tif_postdecode; /* post decoding routine */ -/* tag support */ - TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ - size_t tif_nfields; /* # entries in registered tag table */ - const TIFFFieldInfo *tif_foundfield;/* cached pointer to already found tag */ - TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */ - TIFFClientInfoLink *tif_clientinfo; /* extra client information. */ -}; - -#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ - -#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) -#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) -#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) -#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) -#define TIFFReadFile(tif, buf, size) \ - ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) -#define TIFFWriteFile(tif, buf, size) \ - ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) -#define TIFFSeekFile(tif, off, whence) \ - ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) -#define TIFFCloseFile(tif) \ - ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) -#define TIFFGetFileSize(tif) \ - ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) -#define TIFFMapFileContents(tif, paddr, psize) \ - ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) -#define TIFFUnmapFileContents(tif, addr, size) \ - ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) - -/* - * Default Read/Seek/Write definitions. - */ -#ifndef ReadOK -#define ReadOK(tif, buf, size) \ - (TIFFReadFile(tif, (tdata_t) buf, (tsize_t)(size)) == (tsize_t)(size)) -#endif -#ifndef SeekOK -#define SeekOK(tif, off) \ - (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) -#endif -#ifndef WriteOK -#define WriteOK(tif, buf, size) \ - (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) -#endif - -/* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) -#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) -#define TIFFroundup(x, y) (TIFFhowmany(x,y)*(y)) - -#define TIFFmax(A,B) ((A)>(B)?(A):(B)) -#define TIFFmin(A,B) ((A)<(B)?(A):(B)) - -#define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0])) - -#if defined(__cplusplus) -extern "C" { -#endif -extern int _TIFFgetMode(const char*, const char*); -extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); -extern int _TIFFNoPreCode (TIFF*, tsample_t); -extern int _TIFFNoSeek(TIFF*, uint32); -extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab24BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); -extern int TIFFFlushData1(TIFF*); -extern int TIFFDefaultDirectory(TIFF*); -extern void _TIFFSetDefaultCompressionState(TIFF*); -extern int TIFFSetCompressionScheme(TIFF*, int); -extern int TIFFSetDefaultCompressionState(TIFF*); -extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); -extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int _TIFFDataSize(TIFFDataType); - -extern void _TIFFsetByteArray(void**, void*, uint32); -extern void _TIFFsetString(char**, char*); -extern void _TIFFsetShortArray(uint16**, uint16*, uint32); -extern void _TIFFsetLongArray(uint32**, uint32*, uint32); -extern void _TIFFsetFloatArray(float**, float*, uint32); -extern void _TIFFsetDoubleArray(double**, double*, uint32); - -extern void _TIFFprintAscii(FILE*, const char*); -extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); - -extern TIFFErrorHandler _TIFFwarningHandler; -extern TIFFErrorHandler _TIFFerrorHandler; -extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; -extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; - -extern tdata_t _TIFFCheckMalloc(TIFF*, size_t, size_t, const char*); - -extern int TIFFInitDumpMode(TIFF*, int); -#ifdef PACKBITS_SUPPORT -extern int TIFFInitPackBits(TIFF*, int); -#endif -#ifdef CCITT_SUPPORT -extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); -extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); -#endif -#ifdef THUNDER_SUPPORT -extern int TIFFInitThunderScan(TIFF*, int); -#endif -#ifdef NEXT_SUPPORT -extern int TIFFInitNeXT(TIFF*, int); -#endif -#ifdef LZW_SUPPORT -extern int TIFFInitLZW(TIFF*, int); -#endif -#ifdef OJPEG_SUPPORT -extern int TIFFInitOJPEG(TIFF*, int); -#endif -#ifdef JPEG_SUPPORT -extern int TIFFInitJPEG(TIFF*, int); -#endif -#ifdef JBIG_SUPPORT -extern int TIFFInitJBIG(TIFF*, int); -#endif -#ifdef ZIP_SUPPORT -extern int TIFFInitZIP(TIFF*, int); -#endif -#ifdef PIXARLOG_SUPPORT -extern int TIFFInitPixarLog(TIFF*, int); -#endif -#ifdef LOGLUV_SUPPORT -extern int TIFFInitSGILog(TIFF*, int); -#endif -#ifdef VMS -extern const TIFFCodec _TIFFBuiltinCODECS[]; -#else -extern TIFFCodec _TIFFBuiltinCODECS[]; -#endif - -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFIOP_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/test/Makefile.am b/libs/tiff-3.8.2/test/Makefile.am deleted file mode 100644 index 0658e53fe9..0000000000 --- a/libs/tiff-3.8.2/test/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2004, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Process this file with automake to produce Makefile.in. - -LIBTIFF = $(top_builddir)/libtiff/libtiff.la - -#EXTRA_DIST = Makefile.vc - -TESTS = $(check_PROGRAMS) - -check_PROGRAMS = ascii_tag long_tag short_tag strip_rw - -ascii_tag_SOURCES = ascii_tag.c -ascii_tag_LDADD = $(LIBTIFF) -long_tag_SOURCES = long_tag.c check_tag.c -long_tag_LDADD = $(LIBTIFF) -short_tag_SOURCES = short_tag.c check_tag.c -short_tag_LDADD = $(LIBTIFF) -strip_rw_SOURCES = strip_rw.c strip.c test_arrays.c test_arrays.h -strip_rw_LDADD = $(LIBTIFF) - -INCLUDES = -I$(top_srcdir)/libtiff - diff --git a/libs/tiff-3.8.2/tools/tiff2ps.c b/libs/tiff-3.8.2/tools/tiff2ps.c deleted file mode 100644 index a3d2a44bba..0000000000 --- a/libs/tiff-3.8.2/tools/tiff2ps.c +++ /dev/null @@ -1,2100 +0,0 @@ -/* $Id: tiff2ps.c,v 1.35 2006/02/23 14:50:32 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tif_config.h" - -#include -#include /* for atof */ -#include -#include -#include - -#ifdef HAVE_UNISTD_H -# include -#endif - -#include "tiffio.h" - -/* - * Revision history - * - * 2001-Mar-21 - * I (Bruce A. Mallett) added this revision history comment ;) - * - * Fixed PS_Lvl2page() code which outputs non-ASCII85 raw - * data. Moved test for when to output a line break to - * *after* the output of a character. This just serves - * to fix an eye-nuisance where the first line of raw - * data was one character shorter than subsequent lines. - * - * Added an experimental ASCII85 encoder which can be used - * only when there is a single buffer of bytes to be encoded. - * This version is much faster at encoding a straight-line - * buffer of data because it can avoid alot of the loop - * overhead of the byte-by-bye version. To use this version - * you need to define EXP_ASCII85ENCODER (experimental ...). - * - * Added bug fix given by Michael Schmidt to PS_Lvl2page() - * in which an end-of-data marker ('>') was not being output - * when producing non-ASCII85 encoded PostScript Level 2 - * data. - * - * Fixed PS_Lvl2colorspace() so that it no longer assumes that - * a TIFF having more than 2 planes is a CMYK. This routine - * no longer looks at the samples per pixel but instead looks - * at the "photometric" value. This change allows support of - * CMYK TIFFs. - * - * Modified the PostScript L2 imaging loop so as to test if - * the input stream is still open before attempting to do a - * flushfile on it. This was done because some RIPs close - * the stream after doing the image operation. - * - * Got rid of the realloc() being done inside a loop in the - * PSRawDataBW() routine. The code now walks through the - * byte-size array outside the loop to determine the largest - * size memory block that will be needed. - * - * Added "-m" switch to ask tiff2ps to, where possible, use the - * "imagemask" operator instead of the "image" operator. - * - * Added the "-i #" switch to allow interpolation to be disabled. - * - * Unrolled a loop or two to improve performance. - */ - -/* - * Define EXP_ASCII85ENCODER if you want to use an experimental - * version of the ASCII85 encoding routine. The advantage of - * using this routine is that tiff2ps will convert to ASCII85 - * encoding at between 3 and 4 times the speed as compared to - * using the old (non-experimental) encoder. The disadvantage - * is that you will be using a new (and unproven) encoding - * routine. So user beware, you have been warned! - */ - -#define EXP_ASCII85ENCODER - -/* - * NB: this code assumes uint32 works with printf's %l[ud]. - */ -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -int ascii85 = FALSE; /* use ASCII85 encoding */ -int interpolate = TRUE; /* interpolate level2 image */ -int level2 = FALSE; /* generate PostScript level 2 */ -int level3 = FALSE; /* generate PostScript level 3 */ -int printAll = FALSE; /* print all images in file */ -int generateEPSF = TRUE; /* generate Encapsulated PostScript */ -int PSduplex = FALSE; /* enable duplex printing */ -int PStumble = FALSE; /* enable top edge binding */ -int PSavoiddeadzone = TRUE; /* enable avoiding printer deadzone */ -double maxPageHeight = 0; /* maximum size to fit on page */ -double splitOverlap = 0; /* amount for split pages to overlag */ -int rotate = FALSE; /* rotate image by 180 degrees */ -char *filename; /* input filename */ -int useImagemask = FALSE; /* Use imagemask instead of image operator */ -uint16 res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */ - -/* - * ASCII85 Encoding Support. - */ -unsigned char ascii85buf[10]; -int ascii85count; -int ascii85breaklen; - -int TIFF2PS(FILE*, TIFF*, double, double, double, double, int); -void PSpage(FILE*, TIFF*, uint32, uint32); -void PSColorContigPreamble(FILE*, uint32, uint32, int); -void PSColorSeparatePreamble(FILE*, uint32, uint32, int); -void PSDataColorContig(FILE*, TIFF*, uint32, uint32, int); -void PSDataColorSeparate(FILE*, TIFF*, uint32, uint32, int); -void PSDataPalette(FILE*, TIFF*, uint32, uint32); -void PSDataBW(FILE*, TIFF*, uint32, uint32); -void PSRawDataBW(FILE*, TIFF*, uint32, uint32); -void Ascii85Init(void); -void Ascii85Put(unsigned char code, FILE* fd); -void Ascii85Flush(FILE* fd); -void PSHead(FILE*, TIFF*, uint32, uint32, double, double, double, double); -void PSTail(FILE*, int); - -#if defined( EXP_ASCII85ENCODER) -int Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, int raw_l ); -#endif - -static void usage(int); - -int -main(int argc, char* argv[]) -{ - int dirnum = -1, c, np = 0; - int centered = 0; - double bottommargin = 0; - double leftmargin = 0; - double pageWidth = 0; - double pageHeight = 0; - uint32 diroff = 0; - extern char *optarg; - extern int optind; - FILE* output = stdout; - - while ((c = getopt(argc, argv, "b:d:h:H:L:i:w:l:o:O:acelmrxyzps1238DT")) != -1) - switch (c) { - case 'b': - bottommargin = atof(optarg); - break; - case 'c': - centered = 1; - break; - case 'd': - dirnum = atoi(optarg); - break; - case 'D': - PSduplex = TRUE; - break; - case 'i': - interpolate = atoi(optarg) ? TRUE:FALSE; - break; - case 'T': - PStumble = TRUE; - break; - case 'e': - PSavoiddeadzone = FALSE; - generateEPSF = TRUE; - break; - case 'h': - pageHeight = atof(optarg); - break; - case 'H': - maxPageHeight = atof(optarg); - if (pageHeight==0) pageHeight = maxPageHeight; - break; - case 'L': - splitOverlap = atof(optarg); - break; - case 'm': - useImagemask = TRUE; - break; - case 'o': - diroff = (uint32) strtoul(optarg, NULL, 0); - break; - case 'O': /* XXX too bad -o is already taken */ - output = fopen(optarg, "w"); - if (output == NULL) { - fprintf(stderr, - "%s: %s: Cannot open output file.\n", - argv[0], optarg); - exit(-2); - } - break; - case 'l': - leftmargin = atof(optarg); - break; - case 'a': - printAll = TRUE; - /* fall thru... */ - case 'p': - generateEPSF = FALSE; - break; - case 'r': - rotate = TRUE; - break; - case 's': - printAll = FALSE; - break; - case 'w': - pageWidth = atof(optarg); - break; - case 'z': - PSavoiddeadzone = FALSE; - break; - case '1': - level2 = FALSE; - level3 = FALSE; - ascii85 = FALSE; - break; - case '2': - level2 = TRUE; - ascii85 = TRUE; /* default to yes */ - break; - case '3': - level3 = TRUE; - ascii85 = TRUE; /* default to yes */ - break; - case '8': - ascii85 = FALSE; - break; - case 'x': - res_unit = RESUNIT_CENTIMETER; - break; - case 'y': - res_unit = RESUNIT_INCH; - break; - case '?': - usage(-1); - } - for (; argc - optind > 0; optind++) { - TIFF* tif = TIFFOpen(filename = argv[optind], "r"); - if (tif != NULL) { - if (dirnum != -1 - && !TIFFSetDirectory(tif, (tdir_t)dirnum)) - return (-1); - else if (diroff != 0 && - !TIFFSetSubDirectory(tif, diroff)) - return (-1); - np = TIFF2PS(output, tif, pageWidth, pageHeight, - leftmargin, bottommargin, centered); - TIFFClose(tif); - } - } - if (np) - PSTail(output, np); - else - usage(-1); - if (output != stdout) - fclose(output); - return (0); -} - -static uint16 samplesperpixel; -static uint16 bitspersample; -static uint16 planarconfiguration; -static uint16 photometric; -static uint16 compression; -static uint16 extrasamples; -static int alpha; - -static int -checkImage(TIFF* tif) -{ - switch (photometric) { - case PHOTOMETRIC_YCBCR: - if ((compression == COMPRESSION_JPEG || compression == COMPRESSION_OJPEG) - && planarconfiguration == PLANARCONFIG_CONTIG) { - /* can rely on libjpeg to convert to RGB */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, - JPEGCOLORMODE_RGB); - photometric = PHOTOMETRIC_RGB; - } else { - if (level2 || level3) - break; - TIFFError(filename, "Can not handle image with %s", - "PhotometricInterpretation=YCbCr"); - return (0); - } - /* fall thru... */ - case PHOTOMETRIC_RGB: - if (alpha && bitspersample != 8) { - TIFFError(filename, - "Can not handle %d-bit/sample RGB image with alpha", - bitspersample); - return (0); - } - /* fall thru... */ - case PHOTOMETRIC_SEPARATED: - case PHOTOMETRIC_PALETTE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - break; - case PHOTOMETRIC_LOGL: - case PHOTOMETRIC_LOGLUV: - if (compression != COMPRESSION_SGILOG && - compression != COMPRESSION_SGILOG24) { - TIFFError(filename, - "Can not handle %s data with compression other than SGILog", - (photometric == PHOTOMETRIC_LOGL) ? - "LogL" : "LogLuv" - ); - return (0); - } - /* rely on library to convert to RGB/greyscale */ - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - photometric = (photometric == PHOTOMETRIC_LOGL) ? - PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB; - bitspersample = 8; - break; - case PHOTOMETRIC_CIELAB: - /* fall thru... */ - default: - TIFFError(filename, - "Can not handle image with PhotometricInterpretation=%d", - photometric); - return (0); - } - switch (bitspersample) { - case 1: case 2: - case 4: case 8: - break; - default: - TIFFError(filename, "Can not handle %d-bit/sample image", - bitspersample); - return (0); - } - if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0) - TIFFWarning(filename, "Ignoring extra samples"); - return (1); -} - -#define PS_UNIT_SIZE 72.0F -#define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res))) - -static char RGBcolorimage[] = "\ -/bwproc {\n\ - rgbproc\n\ - dup length 3 idiv string 0 3 0\n\ - 5 -1 roll {\n\ - add 2 1 roll 1 sub dup 0 eq {\n\ - pop 3 idiv\n\ - 3 -1 roll\n\ - dup 4 -1 roll\n\ - dup 3 1 roll\n\ - 5 -1 roll put\n\ - 1 add 3 0\n\ - } { 2 1 roll } ifelse\n\ - } forall\n\ - pop pop pop\n\ -} def\n\ -/colorimage where {pop} {\n\ - /colorimage {pop pop /rgbproc exch def {bwproc} image} bind def\n\ -} ifelse\n\ -"; - -/* - * Adobe Photoshop requires a comment line of the form: - * - * %ImageData:
- * <1 for binary|2 for hex> "data start" - * - * It is claimed to be part of some future revision of the EPS spec. - */ -static void -PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline) -{ - fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"", - (long) w, (long) h, bitspersample, nc, bs); - fprintf(fd, startline, nc); - fprintf(fd, "\"\n"); -} - -/* - * pw : image width in pixels - * ph : image height in pixels - * pprw : image width in PS units (72 dpi) - * pprh : image height in PS units (72 dpi) - */ -static void -setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh) -{ - float xres = 0.0F, yres = 0.0F; - - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, pw); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, ph); - if (res_unit == 0) - TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &res_unit); - /* - * Calculate printable area. - */ - if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) - || fabs(xres) < 0.0000001) - xres = PS_UNIT_SIZE; - if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) - || fabs(yres) < 0.0000001) - yres = PS_UNIT_SIZE; - switch (res_unit) { - case RESUNIT_CENTIMETER: - xres *= 2.54F, yres *= 2.54F; - break; - case RESUNIT_INCH: - break; - case RESUNIT_NONE: - default: - xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE; - break; - } - *pprh = PSUNITS(*ph, yres); - *pprw = PSUNITS(*pw, xres); -} - -static int -isCCITTCompression(TIFF* tif) -{ - uint16 compress; - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); - return (compress == COMPRESSION_CCITTFAX3 || - compress == COMPRESSION_CCITTFAX4 || - compress == COMPRESSION_CCITTRLE || - compress == COMPRESSION_CCITTRLEW); -} - -static tsize_t tf_bytesperrow; -static tsize_t ps_bytesperrow; -static tsize_t tf_rowsperstrip; -static tsize_t tf_numberstrips; -static char *hex = "0123456789abcdef"; - -/* - * imagewidth & imageheight are 1/72 inches - * pagewidth & pageheight are inches - */ -int -PlaceImage(FILE *fp, double pagewidth, double pageheight, - double imagewidth, double imageheight, int splitpage, - double lm, double bm, int cnt) -{ - double xtran = 0; - double ytran = 0; - double xscale = 1; - double yscale = 1; - double left_offset = lm * PS_UNIT_SIZE; - double bottom_offset = bm * PS_UNIT_SIZE; - double subimageheight; - double splitheight; - double overlap; - - pagewidth *= PS_UNIT_SIZE; - pageheight *= PS_UNIT_SIZE; - - if (maxPageHeight==0) - splitheight = 0; - else - splitheight = maxPageHeight * PS_UNIT_SIZE; - overlap = splitOverlap * PS_UNIT_SIZE; - - /* - * WIDTH: - * if too wide, scrunch to fit - * else leave it alone - */ - if (imagewidth <= pagewidth) { - xscale = imagewidth; - } else { - xscale = pagewidth; - } - - /* HEIGHT: - * if too long, scrunch to fit - * if too short, move to top of page - */ - if (imageheight <= pageheight) { - yscale = imageheight; - ytran = pageheight - imageheight; - } else if (imageheight > pageheight && - (splitheight == 0 || imageheight <= splitheight)) { - yscale = pageheight; - } else /* imageheight > splitheight */ { - subimageheight = imageheight - (pageheight-overlap)*splitpage; - if (subimageheight <= pageheight) { - yscale = imageheight; - ytran = pageheight - subimageheight; - splitpage = 0; - } else if ( subimageheight > pageheight && subimageheight <= splitheight) { - yscale = imageheight * pageheight / subimageheight; - ytran = 0; - splitpage = 0; - } else /* sumimageheight > splitheight */ { - yscale = imageheight; - ytran = pageheight - subimageheight; - splitpage++; - } - } - - bottom_offset += ytran / (cnt?2:1); - if (cnt) - left_offset += xtran / 2; - fprintf(fp, "%f %f translate\n", left_offset, bottom_offset); - fprintf(fp, "%f %f scale\n", xscale, yscale); - if (rotate) - fputs ("1 1 translate 180 rotate\n", fp); - - return splitpage; -} - - -/* returns the sequence number of the page processed */ -int -TIFF2PS(FILE* fd, TIFF* tif, - double pw, double ph, double lm, double bm, int cnt) -{ - uint32 w, h; - float ox, oy; - double prw, prh; - double scale = 1.0; - uint32 subfiletype; - uint16* sampleinfo; - static int npages = 0; - int split; - - if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox)) - ox = 0; - if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy)) - oy = 0; - setupPageState(tif, &w, &h, &prw, &prh); - - do { - tf_numberstrips = TIFFNumberOfStrips(tif); - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, - &tf_rowsperstrip); - setupPageState(tif, &w, &h, &prw, &prh); - if (!npages) - PSHead(fd, tif, w, h, prw, prh, ox, oy); - TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, - &bitspersample); - TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, - &samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, - &planarconfiguration); - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, - &extrasamples, &sampleinfo); - alpha = (extrasamples == 1 && - sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { - switch (samplesperpixel - extrasamples) { - case 1: - if (isCCITTCompression(tif)) - photometric = PHOTOMETRIC_MINISWHITE; - else - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - photometric = PHOTOMETRIC_RGB; - break; - case 4: - photometric = PHOTOMETRIC_SEPARATED; - break; - } - } - if (checkImage(tif)) { - tf_bytesperrow = TIFFScanlineSize(tif); - npages++; - fprintf(fd, "%%%%Page: %d %d\n", npages, npages); - if (!generateEPSF && ( level2 || level3 )) { - double psw, psh; - if (pw != 0.0) { - psw = pw * PS_UNIT_SIZE; - if (res_unit == RESUNIT_CENTIMETER) - psw *= 2.54F; - } else - psw=rotate ? prh:prw; - if (ph != 0.0) { - psh = ph * PS_UNIT_SIZE; - if (res_unit == RESUNIT_CENTIMETER) - psh *= 2.54F; - } else - psh=rotate ? prw:prh; - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", - psw, psh); - fputs( - "<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n", - fd); - } - fprintf(fd, "gsave\n"); - fprintf(fd, "100 dict begin\n"); - if (pw != 0 || ph != 0) { - double psw = pw, psh = ph; - if (!psw) - psw = prw; - if (!psh) - psh = prh; - if (maxPageHeight) { /* used -H option */ - split = PlaceImage(fd,psw,psh,prw,prh, - 0,lm,bm,cnt); - while( split ) { - PSpage(fd, tif, w, h); - fprintf(fd, "end\n"); - fprintf(fd, "grestore\n"); - fprintf(fd, "showpage\n"); - npages++; - fprintf(fd, "%%%%Page: %d %d\n", - npages, npages); - fprintf(fd, "gsave\n"); - fprintf(fd, "100 dict begin\n"); - split = PlaceImage(fd,psw,psh,prw,prh, - split,lm,bm,cnt); - } - } else { - double left_offset = lm * PS_UNIT_SIZE; - double bottom_offset = bm * PS_UNIT_SIZE; - psw *= PS_UNIT_SIZE; - psh *= PS_UNIT_SIZE; - - /* NB: maintain image aspect ratio */ - scale = psw/prw < psh/prh ? - psw/prw : psh/prh; - if (scale > 1.0) - scale = 1.0; - if (cnt) { - bottom_offset += - (psh - prh * scale) / 2; - left_offset += - (psw - prw * scale) / 2; - } - fprintf(fd, "%f %f translate\n", - left_offset, bottom_offset); - fprintf(fd, "%f %f scale\n", - prw * scale, prh * scale); - if (rotate) - fputs ("1 1 translate 180 rotate\n", fd); - } - } else { - fprintf(fd, "%f %f scale\n", prw, prh); - if (rotate) - fputs ("1 1 translate 180 rotate\n", fd); - } - PSpage(fd, tif, w, h); - fprintf(fd, "end\n"); - fprintf(fd, "grestore\n"); - fprintf(fd, "showpage\n"); - } - if (generateEPSF) - break; - TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype); - } while (((subfiletype & FILETYPE_PAGE) || printAll) && - TIFFReadDirectory(tif)); - - return(npages); -} - - -static char DuplexPreamble[] = "\ -%%BeginFeature: *Duplex True\n\ -systemdict begin\n\ - /languagelevel where { pop languagelevel } { 1 } ifelse\n\ - 2 ge { 1 dict dup /Duplex true put setpagedevice }\n\ - { statusdict /setduplex known { statusdict begin setduplex true end } if\n\ - } ifelse\n\ -end\n\ -%%EndFeature\n\ -"; - -static char TumblePreamble[] = "\ -%%BeginFeature: *Tumble True\n\ -systemdict begin\n\ - /languagelevel where { pop languagelevel } { 1 } ifelse\n\ - 2 ge { 1 dict dup /Tumble true put setpagedevice }\n\ - { statusdict /settumble known { statusdict begin true settumble end } if\n\ - } ifelse\n\ -end\n\ -%%EndFeature\n\ -"; - -static char AvoidDeadZonePreamble[] = "\ -gsave newpath clippath pathbbox grestore\n\ - 4 2 roll 2 copy translate\n\ - exch 3 1 roll sub 3 1 roll sub exch\n\ - currentpagedevice /PageSize get aload pop\n\ - exch 3 1 roll div 3 1 roll div abs exch abs\n\ - 2 copy gt { exch } if pop\n\ - dup 1 lt { dup scale } { pop } ifelse\n\ -"; - -void -PSHead(FILE *fd, TIFF *tif, uint32 w, uint32 h, - double pw, double ph, double ox, double oy) -{ - time_t t; - - (void) tif; (void) w; (void) h; - t = time(0); - fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : ""); - fprintf(fd, "%%%%Creator: tiff2ps\n"); - fprintf(fd, "%%%%Title: %s\n", filename); - fprintf(fd, "%%%%CreationDate: %s", ctime(&t)); - fprintf(fd, "%%%%DocumentData: Clean7Bit\n"); - fprintf(fd, "%%%%Origin: %ld %ld\n", (long) ox, (long) oy); - /* NB: should use PageBoundingBox */ - fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n", - (long) ceil(pw), (long) ceil(ph)); - fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1))); - fprintf(fd, "%%%%Pages: (atend)\n"); - fprintf(fd, "%%%%EndComments\n"); - fprintf(fd, "%%%%BeginSetup\n"); - if (PSduplex) - fprintf(fd, "%s", DuplexPreamble); - if (PStumble) - fprintf(fd, "%s", TumblePreamble); - if (PSavoiddeadzone && (level2 || level3)) - fprintf(fd, "%s", AvoidDeadZonePreamble); - fprintf(fd, "%%%%EndSetup\n"); -} - -void -PSTail(FILE *fd, int npages) -{ - fprintf(fd, "%%%%Trailer\n"); - fprintf(fd, "%%%%Pages: %d\n", npages); - fprintf(fd, "%%%%EOF\n"); -} - -static int -checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) -{ - (void) tif; - while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - TIFFWarning(filename, "Assuming 8-bit colormap"); - return (8); -} - -static void -PS_Lvl2colorspace(FILE* fd, TIFF* tif) -{ - uint16 *rmap, *gmap, *bmap; - int i, num_colors; - const char * colorspace_p; - - switch ( photometric ) - { - case PHOTOMETRIC_SEPARATED: - colorspace_p = "CMYK"; - break; - - case PHOTOMETRIC_RGB: - colorspace_p = "RGB"; - break; - - default: - colorspace_p = "Gray"; - } - - /* - * Set up PostScript Level 2 colorspace according to - * section 4.8 in the PostScript refenence manual. - */ - fputs("% PostScript Level 2 only.\n", fd); - if (photometric != PHOTOMETRIC_PALETTE) { - if (photometric == PHOTOMETRIC_YCBCR) { - /* MORE CODE HERE */ - } - fprintf(fd, "/Device%s setcolorspace\n", colorspace_p ); - return; - } - - /* - * Set up an indexed/palette colorspace - */ - num_colors = (1 << bitspersample); - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { - TIFFError(filename, - "Palette image w/o \"Colormap\" tag"); - return; - } - if (checkcmap(tif, num_colors, rmap, gmap, bmap) == 16) { - /* - * Convert colormap to 8-bits values. - */ -#define CVT(x) (((x) * 255) / ((1L<<16)-1)) - for (i = 0; i < num_colors; i++) { - rmap[i] = CVT(rmap[i]); - gmap[i] = CVT(gmap[i]); - bmap[i] = CVT(bmap[i]); - } -#undef CVT - } - fprintf(fd, "[ /Indexed /DeviceRGB %d", num_colors - 1); - if (ascii85) { - Ascii85Init(); - fputs("\n<~", fd); - ascii85breaklen -= 2; - } else - fputs(" <", fd); - for (i = 0; i < num_colors; i++) { - if (ascii85) { - Ascii85Put((unsigned char)rmap[i], fd); - Ascii85Put((unsigned char)gmap[i], fd); - Ascii85Put((unsigned char)bmap[i], fd); - } else { - fputs((i % 8) ? " " : "\n ", fd); - fprintf(fd, "%02x%02x%02x", - rmap[i], gmap[i], bmap[i]); - } - } - if (ascii85) - Ascii85Flush(fd); - else - fputs(">\n", fd); - fputs("] setcolorspace\n", fd); -} - -static int -PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) -{ - int use_rawdata; - uint32 tile_width, tile_height; - uint16 predictor, minsamplevalue, maxsamplevalue; - int repeat_count; - char im_h[64], im_x[64], im_y[64]; - char * imageOp = "image"; - - if ( useImagemask && (bitspersample == 1) ) - imageOp = "imagemask"; - - (void)strcpy(im_x, "0"); - (void)sprintf(im_y, "%lu", (long) h); - (void)sprintf(im_h, "%lu", (long) h); - tile_width = w; - tile_height = h; - if (TIFFIsTiled(tif)) { - repeat_count = TIFFNumberOfTiles(tif); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tile_width); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &tile_height); - if (tile_width > w || tile_height > h || - (w % tile_width) != 0 || (h % tile_height != 0)) { - /* - * The tiles does not fit image width and height. - * Set up a clip rectangle for the image unit square. - */ - fputs("0 0 1 1 rectclip\n", fd); - } - if (tile_width < w) { - fputs("/im_x 0 def\n", fd); - (void)strcpy(im_x, "im_x neg"); - } - if (tile_height < h) { - fputs("/im_y 0 def\n", fd); - (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h); - } - } else { - repeat_count = tf_numberstrips; - tile_height = tf_rowsperstrip; - if (tile_height > h) - tile_height = h; - if (repeat_count > 1) { - fputs("/im_y 0 def\n", fd); - fprintf(fd, "/im_h %lu def\n", - (unsigned long) tile_height); - (void)strcpy(im_h, "im_h"); - (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h); - } - } - - /* - * Output start of exec block - */ - fputs("{ % exec\n", fd); - - if (repeat_count > 1) - fprintf(fd, "%d { %% repeat\n", repeat_count); - - /* - * Output filter options and image dictionary. - */ - if (ascii85) - fputs(" /im_stream currentfile /ASCII85Decode filter def\n", - fd); - fputs(" <<\n", fd); - fputs(" /ImageType 1\n", fd); - fprintf(fd, " /Width %lu\n", (unsigned long) tile_width); - /* - * Workaround for some software that may crash when last strip - * of image contains fewer number of scanlines than specified - * by the `/Height' variable. So for stripped images with multiple - * strips we will set `/Height' as `im_h', because one is - * recalculated for each strip - including the (smaller) final strip. - * For tiled images and images with only one strip `/Height' will - * contain number of scanlines in tile (or image height in case of - * one-stripped image). - */ - if (TIFFIsTiled(tif) || tf_numberstrips == 1) - fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); - else - fprintf(fd, " /Height im_h\n"); - - if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) - fputs(" /MultipleDataSources true\n", fd); - fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n", - (unsigned long) w, - (long)h, im_x, im_y); - fprintf(fd, " /BitsPerComponent %d\n", bitspersample); - fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false"); - - switch (samplesperpixel - extrasamples) { - case 1: - switch (photometric) { - case PHOTOMETRIC_MINISBLACK: - fputs(" /Decode [0 1]\n", fd); - break; - case PHOTOMETRIC_MINISWHITE: - switch (compression) { - case COMPRESSION_CCITTRLE: - case COMPRESSION_CCITTRLEW: - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - /* - * Manage inverting with /Blackis1 flag - * since there migth be uncompressed parts - */ - fputs(" /Decode [0 1]\n", fd); - break; - default: - /* - * ERROR... - */ - fputs(" /Decode [1 0]\n", fd); - break; - } - break; - case PHOTOMETRIC_PALETTE: - TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE, - &minsamplevalue); - TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, - &maxsamplevalue); - fprintf(fd, " /Decode [%u %u]\n", - minsamplevalue, maxsamplevalue); - break; - default: - /* - * ERROR ? - */ - fputs(" /Decode [0 1]\n", fd); - break; - } - break; - case 3: - switch (photometric) { - case PHOTOMETRIC_RGB: - fputs(" /Decode [0 1 0 1 0 1]\n", fd); - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - default: - /* - * ERROR?? - */ - fputs(" /Decode [0 1 0 1 0 1]\n", fd); - break; - } - break; - case 4: - /* - * ERROR?? - */ - fputs(" /Decode [0 1 0 1 0 1 0 1]\n", fd); - break; - } - fputs(" /DataSource", fd); - if (planarconfiguration == PLANARCONFIG_SEPARATE && - samplesperpixel > 1) - fputs(" [", fd); - if (ascii85) - fputs(" im_stream", fd); - else - fputs(" currentfile /ASCIIHexDecode filter", fd); - - use_rawdata = TRUE; - switch (compression) { - case COMPRESSION_NONE: /* 1: uncompressed */ - break; - case COMPRESSION_CCITTRLE: /* 2: CCITT modified Huffman RLE */ - case COMPRESSION_CCITTRLEW: /* 32771: #1 w/ word alignment */ - case COMPRESSION_CCITTFAX3: /* 3: CCITT Group 3 fax encoding */ - case COMPRESSION_CCITTFAX4: /* 4: CCITT Group 4 fax encoding */ - fputs("\n\t<<\n", fd); - if (compression == COMPRESSION_CCITTFAX3) { - uint32 g3_options; - - fputs("\t /EndOfLine true\n", fd); - fputs("\t /EndOfBlock false\n", fd); - if (!TIFFGetField(tif, TIFFTAG_GROUP3OPTIONS, - &g3_options)) - g3_options = 0; - if (g3_options & GROUP3OPT_2DENCODING) - fprintf(fd, "\t /K %s\n", im_h); - if (g3_options & GROUP3OPT_UNCOMPRESSED) - fputs("\t /Uncompressed true\n", fd); - if (g3_options & GROUP3OPT_FILLBITS) - fputs("\t /EncodedByteAlign true\n", fd); - } - if (compression == COMPRESSION_CCITTFAX4) { - uint32 g4_options; - - fputs("\t /K -1\n", fd); - TIFFGetFieldDefaulted(tif, TIFFTAG_GROUP4OPTIONS, - &g4_options); - if (g4_options & GROUP4OPT_UNCOMPRESSED) - fputs("\t /Uncompressed true\n", fd); - } - if (!(tile_width == w && w == 1728U)) - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Rows %s\n", im_h); - if (compression == COMPRESSION_CCITTRLE || - compression == COMPRESSION_CCITTRLEW) { - fputs("\t /EncodedByteAlign true\n", fd); - fputs("\t /EndOfBlock false\n", fd); - } - if (photometric == PHOTOMETRIC_MINISBLACK) - fputs("\t /BlackIs1 true\n", fd); - fprintf(fd, "\t>> /CCITTFaxDecode filter"); - break; - case COMPRESSION_LZW: /* 5: Lempel-Ziv & Welch */ - TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); - if (predictor == 2) { - fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %u\n", predictor); - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Colors %u\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %u\n", - bitspersample); - fputs("\t>>", fd); - } - fputs(" /LZWDecode filter", fd); - break; - case COMPRESSION_DEFLATE: /* 5: ZIP */ - case COMPRESSION_ADOBE_DEFLATE: - if ( level3 ) { - TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); - if (predictor > 1) { - fprintf(fd, "\t %% PostScript Level 3 only."); - fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %u\n", predictor); - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Colors %u\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %u\n", - bitspersample); - fputs("\t>>", fd); - } - fputs(" /FlateDecode filter", fd); - } else { - use_rawdata = FALSE ; - } - break; - case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */ - fputs(" /RunLengthDecode filter", fd); - use_rawdata = TRUE; - break; - case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */ - case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */ -#ifdef notdef - /* - * Code not tested yet - */ - fputs(" /DCTDecode filter", fd); - use_rawdata = TRUE; -#else - use_rawdata = FALSE; -#endif - break; - case COMPRESSION_NEXT: /* 32766: NeXT 2-bit RLE */ - case COMPRESSION_THUNDERSCAN: /* 32809: ThunderScan RLE */ - case COMPRESSION_PIXARFILM: /* 32908: Pixar companded 10bit LZW */ - case COMPRESSION_JBIG: /* 34661: ISO JBIG */ - use_rawdata = FALSE; - break; - case COMPRESSION_SGILOG: /* 34676: SGI LogL or LogLuv */ - case COMPRESSION_SGILOG24: /* 34677: SGI 24-bit LogLuv */ - use_rawdata = FALSE; - break; - default: - /* - * ERROR... - */ - use_rawdata = FALSE; - break; - } - if (planarconfiguration == PLANARCONFIG_SEPARATE && - samplesperpixel > 1) { - uint16 i; - - /* - * NOTE: This code does not work yet... - */ - for (i = 1; i < samplesperpixel; i++) - fputs(" dup", fd); - fputs(" ]", fd); - } - - fprintf( fd, "\n >> %s\n", imageOp ); - if (ascii85) - fputs(" im_stream status { im_stream flushfile } if\n", fd); - if (repeat_count > 1) { - if (tile_width < w) { - fprintf(fd, " /im_x im_x %lu add def\n", - (unsigned long) tile_width); - if (tile_height < h) { - fprintf(fd, " im_x %lu ge {\n", - (unsigned long) w); - fputs(" /im_x 0 def\n", fd); - fprintf(fd, " /im_y im_y %lu add def\n", - (unsigned long) tile_height); - fputs(" } if\n", fd); - } - } - if (tile_height < h) { - if (tile_width >= w) { - fprintf(fd, " /im_y im_y %lu add def\n", - (unsigned long) tile_height); - if (!TIFFIsTiled(tif)) { - fprintf(fd, " /im_h %lu im_y sub", - (unsigned long) h); - fprintf(fd, " dup %lu gt { pop", - (unsigned long) tile_height); - fprintf(fd, " %lu } if def\n", - (unsigned long) tile_height); - } - } - } - fputs("} repeat\n", fd); - } - /* - * End of exec function - */ - fputs("}\n", fd); - - return(use_rawdata); -} - -#define MAXLINE 36 - -int -PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) -{ - uint16 fillorder; - int use_rawdata, tiled_image, breaklen = MAXLINE; - uint32 chunk_no, num_chunks, *bc; - unsigned char *buf_data, *cp; - tsize_t chunk_size, byte_count; - -#if defined( EXP_ASCII85ENCODER ) - int ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ -#endif - - PS_Lvl2colorspace(fd, tif); - use_rawdata = PS_Lvl2ImageDict(fd, tif, w, h); - -/* See http://bugzilla.remotesensing.org/show_bug.cgi?id=80 */ -#ifdef ENABLE_BROKEN_BEGINENDDATA - fputs("%%BeginData:\n", fd); -#endif - fputs("exec\n", fd); - - tiled_image = TIFFIsTiled(tif); - if (tiled_image) { - num_chunks = TIFFNumberOfTiles(tif); - TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc); - } else { - num_chunks = TIFFNumberOfStrips(tif); - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); - } - - if (use_rawdata) { - chunk_size = (tsize_t) bc[0]; - for (chunk_no = 1; chunk_no < num_chunks; chunk_no++) - if ((tsize_t) bc[chunk_no] > chunk_size) - chunk_size = (tsize_t) bc[chunk_no]; - } else { - if (tiled_image) - chunk_size = TIFFTileSize(tif); - else - chunk_size = TIFFStripSize(tif); - } - buf_data = (unsigned char *)_TIFFmalloc(chunk_size); - if (!buf_data) { - TIFFError(filename, "Can't alloc %u bytes for %s.", - chunk_size, tiled_image ? "tiles" : "strips"); - return(FALSE); - } - -#if defined( EXP_ASCII85ENCODER ) - if ( ascii85 ) { - /* - * Allocate a buffer to hold the ASCII85 encoded data. Note - * that it is allocated with sufficient room to hold the - * encoded data (5*chunk_size/4) plus the EOD marker (+8) - * and formatting line breaks. The line breaks are more - * than taken care of by using 6*chunk_size/4 rather than - * 5*chunk_size/4. - */ - - ascii85_p = _TIFFmalloc( (chunk_size+(chunk_size/2)) + 8 ); - - if ( !ascii85_p ) { - _TIFFfree( buf_data ); - - TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); - return ( FALSE ); - } - } -#endif - - TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); - for (chunk_no = 0; chunk_no < num_chunks; chunk_no++) { - if (ascii85) - Ascii85Init(); - else - breaklen = MAXLINE; - if (use_rawdata) { - if (tiled_image) - byte_count = TIFFReadRawTile(tif, chunk_no, - buf_data, chunk_size); - else - byte_count = TIFFReadRawStrip(tif, chunk_no, - buf_data, chunk_size); - if (fillorder == FILLORDER_LSB2MSB) - TIFFReverseBits(buf_data, byte_count); - } else { - if (tiled_image) - byte_count = TIFFReadEncodedTile(tif, - chunk_no, buf_data, - chunk_size); - else - byte_count = TIFFReadEncodedStrip(tif, - chunk_no, buf_data, - chunk_size); - } - if (byte_count < 0) { - TIFFError(filename, "Can't read %s %d.", - tiled_image ? "tile" : "strip", chunk_no); - if (ascii85) - Ascii85Put('\0', fd); - } - /* - * For images with alpha, matte against a white background; - * i.e. Cback * (1 - Aimage) where Cback = 1. We will fill the - * lower part of the buffer with the modified values. - * - * XXX: needs better solution - */ - if (alpha) { - int adjust, i, j = 0; - int ncomps = samplesperpixel - extrasamples; - for (i = 0; i < byte_count; i+=samplesperpixel) { - adjust = 255 - buf_data[i + ncomps]; - switch (ncomps) { - case 1: - buf_data[j++] = buf_data[i] + adjust; - break; - case 2: - buf_data[j++] = buf_data[i] + adjust; - buf_data[j++] = buf_data[i+1] + adjust; - break; - case 3: - buf_data[j++] = buf_data[i] + adjust; - buf_data[j++] = buf_data[i+1] + adjust; - buf_data[j++] = buf_data[i+2] + adjust; - break; - } - } - byte_count -= j; - } - - if (ascii85) { -#if defined( EXP_ASCII85ENCODER ) - ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, buf_data, byte_count ); - - if ( ascii85_l > 0 ) - fwrite( ascii85_p, ascii85_l, 1, fd ); -#else - for (cp = buf_data; byte_count > 0; byte_count--) - Ascii85Put(*cp++, fd); -#endif - } - else - { - for (cp = buf_data; byte_count > 0; byte_count--) { - putc(hex[((*cp)>>4)&0xf], fd); - putc(hex[(*cp)&0xf], fd); - cp++; - - if (--breaklen <= 0) { - putc('\n', fd); - breaklen = MAXLINE; - } - } - } - - if ( !ascii85 ) { - if ( level2 || level3 ) - putc( '>', fd ); - putc('\n', fd); - } -#if !defined( EXP_ASCII85ENCODER ) - else - Ascii85Flush(fd); -#endif - } - -#if defined( EXP_ASCII85ENCODER ) - if ( ascii85_p ) - _TIFFfree( ascii85_p ); -#endif - - _TIFFfree(buf_data); -#ifdef ENABLE_BROKEN_BEGINENDDATA - fputs("%%EndData\n", fd); -#endif - return(TRUE); -} - -void -PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) -{ - char * imageOp = "image"; - - if ( useImagemask && (bitspersample == 1) ) - imageOp = "imagemask"; - - if ((level2 || level3) && PS_Lvl2page(fd, tif, w, h)) - return; - ps_bytesperrow = tf_bytesperrow - (extrasamples * bitspersample / 8)*w; - switch (photometric) { - case PHOTOMETRIC_RGB: - if (planarconfiguration == PLANARCONFIG_CONTIG) { - fprintf(fd, "%s", RGBcolorimage); - PSColorContigPreamble(fd, w, h, 3); - PSDataColorContig(fd, tif, w, h, 3); - } else { - PSColorSeparatePreamble(fd, w, h, 3); - PSDataColorSeparate(fd, tif, w, h, 3); - } - break; - case PHOTOMETRIC_SEPARATED: - /* XXX should emit CMYKcolorimage */ - if (planarconfiguration == PLANARCONFIG_CONTIG) { - PSColorContigPreamble(fd, w, h, 4); - PSDataColorContig(fd, tif, w, h, 4); - } else { - PSColorSeparatePreamble(fd, w, h, 4); - PSDataColorSeparate(fd, tif, w, h, 4); - } - break; - case PHOTOMETRIC_PALETTE: - fprintf(fd, "%s", RGBcolorimage); - PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); - fprintf(fd, "/scanLine %ld string def\n", - (long) ps_bytesperrow * 3L); - fprintf(fd, "%lu %lu 8\n", - (unsigned long) w, (unsigned long) h); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); - fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); - fprintf(fd, "false 3 colorimage\n"); - PSDataPalette(fd, tif, w, h); - break; - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - PhotoshopBanner(fd, w, h, 1, 1, imageOp); - fprintf(fd, "/scanLine %ld string def\n", - (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); - fprintf(fd, - "{currentfile scanLine readhexstring pop} bind\n"); - fprintf(fd, "%s\n", imageOp); - PSDataBW(fd, tif, w, h); - break; - } - putc('\n', fd); -} - -void -PSColorContigPreamble(FILE* fd, uint32 w, uint32 h, int nc) -{ - ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); - PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); - fprintf(fd, "/line %ld string def\n", (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); - fprintf(fd, "{currentfile line readhexstring pop} bind\n"); - fprintf(fd, "false %d colorimage\n", nc); -} - -void -PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc) -{ - int i; - - PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); - for (i = 0; i < nc; i++) - fprintf(fd, "/line%d %ld string def\n", - i, (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); - for (i = 0; i < nc; i++) - fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); - fprintf(fd, "true %d colorimage\n", nc); -} - -#define DOBREAK(len, howmany, fd) \ - if (((len) -= (howmany)) <= 0) { \ - putc('\n', fd); \ - (len) = MAXLINE-(howmany); \ - } -#define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd) - -void -PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) -{ - uint32 row; - int breaklen = MAXLINE, cc, es = samplesperpixel - nc; - unsigned char *tf_buf; - unsigned char *cp, c; - - (void) w; - tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); - if (tf_buf == NULL) { - TIFFError(filename, "No space for scanline buffer"); - return; - } - for (row = 0; row < h; row++) { - if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) - break; - cp = tf_buf; - if (alpha) { - int adjust; - cc = 0; - for (; cc < tf_bytesperrow; cc += samplesperpixel) { - DOBREAK(breaklen, nc, fd); - /* - * For images with alpha, matte against - * a white background; i.e. - * Cback * (1 - Aimage) - * where Cback = 1. - */ - adjust = 255 - cp[nc]; - switch (nc) { - case 4: c = *cp++ + adjust; PUTHEX(c,fd); - case 3: c = *cp++ + adjust; PUTHEX(c,fd); - case 2: c = *cp++ + adjust; PUTHEX(c,fd); - case 1: c = *cp++ + adjust; PUTHEX(c,fd); - } - cp += es; - } - } else { - cc = 0; - for (; cc < tf_bytesperrow; cc += samplesperpixel) { - DOBREAK(breaklen, nc, fd); - switch (nc) { - case 4: c = *cp++; PUTHEX(c,fd); - case 3: c = *cp++; PUTHEX(c,fd); - case 2: c = *cp++; PUTHEX(c,fd); - case 1: c = *cp++; PUTHEX(c,fd); - } - cp += es; - } - } - } - _TIFFfree((char *) tf_buf); -} - -void -PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) -{ - uint32 row; - int breaklen = MAXLINE, cc; - tsample_t s, maxs; - unsigned char *tf_buf; - unsigned char *cp, c; - - (void) w; - tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); - if (tf_buf == NULL) { - TIFFError(filename, "No space for scanline buffer"); - return; - } - maxs = (samplesperpixel > nc ? nc : samplesperpixel); - for (row = 0; row < h; row++) { - for (s = 0; s < maxs; s++) { - if (TIFFReadScanline(tif, tf_buf, row, s) < 0) - break; - for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { - DOBREAK(breaklen, 1, fd); - c = *cp++; - PUTHEX(c,fd); - } - } - } - _TIFFfree((char *) tf_buf); -} - -#define PUTRGBHEX(c,fd) \ - PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd) - -void -PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) -{ - uint16 *rmap, *gmap, *bmap; - uint32 row; - int breaklen = MAXLINE, cc, nc; - unsigned char *tf_buf; - unsigned char *cp, c; - - (void) w; - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { - TIFFError(filename, "Palette image w/o \"Colormap\" tag"); - return; - } - switch (bitspersample) { - case 8: case 4: case 2: case 1: - break; - default: - TIFFError(filename, "Depth %d not supported", bitspersample); - return; - } - nc = 3 * (8 / bitspersample); - tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); - if (tf_buf == NULL) { - TIFFError(filename, "No space for scanline buffer"); - return; - } - if (checkcmap(tif, 1<= 0; i--) { - rmap[i] = CVT(rmap[i]); - gmap[i] = CVT(gmap[i]); - bmap[i] = CVT(bmap[i]); - } -#undef CVT - } - for (row = 0; row < h; row++) { - if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) - break; - for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { - DOBREAK(breaklen, nc, fd); - switch (bitspersample) { - case 8: - c = *cp++; PUTRGBHEX(c, fd); - break; - case 4: - c = *cp++; PUTRGBHEX(c&0xf, fd); - c >>= 4; PUTRGBHEX(c, fd); - break; - case 2: - c = *cp++; PUTRGBHEX(c&0x3, fd); - c >>= 2; PUTRGBHEX(c&0x3, fd); - c >>= 2; PUTRGBHEX(c&0x3, fd); - c >>= 2; PUTRGBHEX(c, fd); - break; - case 1: - c = *cp++; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c&0x1, fd); - c >>= 1; PUTRGBHEX(c, fd); - break; - } - } - } - _TIFFfree((char *) tf_buf); -} - -void -PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) -{ - int breaklen = MAXLINE; - unsigned char* tf_buf; - unsigned char* cp; - tsize_t stripsize = TIFFStripSize(tif); - tstrip_t s; - -#if defined( EXP_ASCII85ENCODER ) - int ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8 *ascii85_p = 0; /* Holds ASCII85 encoded data */ -#endif - - (void) w; (void) h; - tf_buf = (unsigned char *) _TIFFmalloc(stripsize); - memset(tf_buf, 0, stripsize); - if (tf_buf == NULL) { - TIFFError(filename, "No space for scanline buffer"); - return; - } - -#if defined( EXP_ASCII85ENCODER ) - if ( ascii85 ) { - /* - * Allocate a buffer to hold the ASCII85 encoded data. Note - * that it is allocated with sufficient room to hold the - * encoded data (5*stripsize/4) plus the EOD marker (+8) - * and formatting line breaks. The line breaks are more - * than taken care of by using 6*stripsize/4 rather than - * 5*stripsize/4. - */ - - ascii85_p = _TIFFmalloc( (stripsize+(stripsize/2)) + 8 ); - - if ( !ascii85_p ) { - _TIFFfree( tf_buf ); - - TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); - return; - } - } -#endif - - if (ascii85) - Ascii85Init(); - - for (s = 0; s < TIFFNumberOfStrips(tif); s++) { - int cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize); - if (cc < 0) { - TIFFError(filename, "Can't read strip"); - break; - } - cp = tf_buf; - if (photometric == PHOTOMETRIC_MINISWHITE) { - for (cp += cc; --cp >= tf_buf;) - *cp = ~*cp; - cp++; - } - if (ascii85) { -#if defined( EXP_ASCII85ENCODER ) - if (alpha) { - int adjust, i; - for (i = 0; i < cc; i+=2) { - adjust = 255 - cp[i + 1]; - cp[i / 2] = cp[i] + adjust; - } - cc /= 2; - } - - ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, cp, cc ); - - if ( ascii85_l > 0 ) - fwrite( ascii85_p, ascii85_l, 1, fd ); -#else - while (cc-- > 0) - Ascii85Put(*cp++, fd); -#endif /* EXP_ASCII85_ENCODER */ - } else { - unsigned char c; - - if (alpha) { - int adjust; - while (cc-- > 0) { - DOBREAK(breaklen, 1, fd); - /* - * For images with alpha, matte against - * a white background; i.e. - * Cback * (1 - Aimage) - * where Cback = 1. - */ - adjust = 255 - cp[1]; - c = *cp++ + adjust; PUTHEX(c,fd); - cp++, cc--; - } - } else { - while (cc-- > 0) { - c = *cp++; - DOBREAK(breaklen, 1, fd); - PUTHEX(c, fd); - } - } - } - } - - if ( !ascii85 ) - { - if ( level2 || level3) - fputs(">\n", fd); - } -#if !defined( EXP_ASCII85ENCODER ) - else - Ascii85Flush(fd); -#else - if ( ascii85_p ) - _TIFFfree( ascii85_p ); -#endif - - _TIFFfree(tf_buf); -} - -void -PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) -{ - uint32 *bc; - uint32 bufsize; - int breaklen = MAXLINE, cc; - uint16 fillorder; - unsigned char *tf_buf; - unsigned char *cp, c; - tstrip_t s; - -#if defined( EXP_ASCII85ENCODER ) - int ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ -#endif - - (void) w; (void) h; - TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); - - /* - * Find largest strip: - */ - - bufsize = bc[0]; - - for ( s = 0; ++s < (tstrip_t)tf_numberstrips; ) { - if ( bc[s] > bufsize ) - bufsize = bc[s]; - } - - tf_buf = (unsigned char*) _TIFFmalloc(bufsize); - if (tf_buf == NULL) { - TIFFError(filename, "No space for strip buffer"); - return; - } - -#if defined( EXP_ASCII85ENCODER ) - if ( ascii85 ) { - /* - * Allocate a buffer to hold the ASCII85 encoded data. Note - * that it is allocated with sufficient room to hold the - * encoded data (5*bufsize/4) plus the EOD marker (+8) - * and formatting line breaks. The line breaks are more - * than taken care of by using 6*bufsize/4 rather than - * 5*bufsize/4. - */ - - ascii85_p = _TIFFmalloc( (bufsize+(bufsize/2)) + 8 ); - - if ( !ascii85_p ) { - _TIFFfree( tf_buf ); - - TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); - return; - } - } -#endif - - for (s = 0; s < (tstrip_t) tf_numberstrips; s++) { - cc = TIFFReadRawStrip(tif, s, tf_buf, bc[s]); - if (cc < 0) { - TIFFError(filename, "Can't read strip"); - break; - } - if (fillorder == FILLORDER_LSB2MSB) - TIFFReverseBits(tf_buf, cc); - if (!ascii85) { - for (cp = tf_buf; cc > 0; cc--) { - DOBREAK(breaklen, 1, fd); - c = *cp++; - PUTHEX(c, fd); - } - fputs(">\n", fd); - breaklen = MAXLINE; - } else { - Ascii85Init(); -#if defined( EXP_ASCII85ENCODER ) - ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, tf_buf, cc ); - - if ( ascii85_l > 0 ) - fwrite( ascii85_p, ascii85_l, 1, fd ); -#else - for (cp = tf_buf; cc > 0; cc--) - Ascii85Put(*cp++, fd); - Ascii85Flush(fd); -#endif /* EXP_ASCII85ENCODER */ - } - } - _TIFFfree((char *) tf_buf); - -#if defined( EXP_ASCII85ENCODER ) - if ( ascii85_p ) - _TIFFfree( ascii85_p ); -#endif -} - -void -Ascii85Init(void) -{ - ascii85breaklen = 2*MAXLINE; - ascii85count = 0; -} - -static char* -Ascii85Encode(unsigned char* raw) -{ - static char encoded[6]; - uint32 word; - - word = (((raw[0]<<8)+raw[1])<<16) + (raw[2]<<8) + raw[3]; - if (word != 0L) { - uint32 q; - uint16 w1; - - q = word / (85L*85*85*85); /* actually only a byte */ - encoded[0] = (char) (q + '!'); - - word -= q * (85L*85*85*85); q = word / (85L*85*85); - encoded[1] = (char) (q + '!'); - - word -= q * (85L*85*85); q = word / (85*85); - encoded[2] = (char) (q + '!'); - - w1 = (uint16) (word - q*(85L*85)); - encoded[3] = (char) ((w1 / 85) + '!'); - encoded[4] = (char) ((w1 % 85) + '!'); - encoded[5] = '\0'; - } else - encoded[0] = 'z', encoded[1] = '\0'; - return (encoded); -} - -void -Ascii85Put(unsigned char code, FILE* fd) -{ - ascii85buf[ascii85count++] = code; - if (ascii85count >= 4) { - unsigned char* p; - int n; - - for (n = ascii85count, p = ascii85buf; n >= 4; n -= 4, p += 4) { - char* cp; - for (cp = Ascii85Encode(p); *cp; cp++) { - putc(*cp, fd); - if (--ascii85breaklen == 0) { - putc('\n', fd); - ascii85breaklen = 2*MAXLINE; - } - } - } - _TIFFmemcpy(ascii85buf, p, n); - ascii85count = n; - } -} - -void -Ascii85Flush(FILE* fd) -{ - if (ascii85count > 0) { - char* res; - _TIFFmemset(&ascii85buf[ascii85count], 0, 3); - res = Ascii85Encode(ascii85buf); - fwrite(res[0] == 'z' ? "!!!!" : res, ascii85count + 1, 1, fd); - } - fputs("~>\n", fd); -} -#if defined( EXP_ASCII85ENCODER) - -#define A85BREAKCNTR ascii85breaklen -#define A85BREAKLEN (2*MAXLINE) - -/***************************************************************************** -* -* Name: Ascii85EncodeBlock( ascii85_p, f_eod, raw_p, raw_l ) -* -* Description: This routine will encode the raw data in the buffer described -* by raw_p and raw_l into ASCII85 format and store the encoding -* in the buffer given by ascii85_p. -* -* Parameters: ascii85_p - A buffer supplied by the caller which will -* contain the encoded ASCII85 data. -* f_eod - Flag: Nz means to end the encoded buffer with -* an End-Of-Data marker. -* raw_p - Pointer to the buffer of data to be encoded -* raw_l - Number of bytes in raw_p[] to be encoded -* -* Returns: (int) < 0 Error, see errno -* >= 0 Number of bytes written to ascii85_p[]. -* -* Notes: An external variable given by A85BREAKCNTR is used to -* determine when to insert newline characters into the -* encoded data. As each byte is placed into ascii85_p this -* external is decremented. If the variable is decrement to -* or past zero then a newline is inserted into ascii85_p -* and the A85BREAKCNTR is then reset to A85BREAKLEN. -* Note: for efficiency reasons the A85BREAKCNTR variable -* is not actually checked on *every* character -* placed into ascii85_p but often only for every -* 5 characters. -* -* THE CALLER IS RESPONSIBLE FOR ENSURING THAT ASCII85_P[] IS -* SUFFICIENTLY LARGE TO THE ENCODED DATA! -* You will need at least 5 * (raw_l/4) bytes plus space for -* newline characters and space for an EOD marker (if -* requested). A safe calculation is to use 6*(raw_l/4) + 8 -* to size ascii85_p. -* -*****************************************************************************/ - -int Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, int raw_l ) - -{ - char ascii85[5]; /* Encoded 5 tuple */ - int ascii85_l; /* Number of bytes written to ascii85_p[] */ - int rc; /* Return code */ - uint32 val32; /* Unencoded 4 tuple */ - - ascii85_l = 0; /* Nothing written yet */ - - if ( raw_p ) - { - --raw_p; /* Prepare for pre-increment fetches */ - - for ( ; raw_l > 3; raw_l -= 4 ) - { - val32 = *(++raw_p) << 24; - val32 += *(++raw_p) << 16; - val32 += *(++raw_p) << 8; - val32 += *(++raw_p); - - if ( val32 == 0 ) /* Special case */ - { - ascii85_p[ascii85_l] = 'z'; - rc = 1; - } - - else - { - ascii85[4] = (char) ((val32 % 85) + 33); - val32 /= 85; - - ascii85[3] = (char) ((val32 % 85) + 33); - val32 /= 85; - - ascii85[2] = (char) ((val32 % 85) + 33); - val32 /= 85; - - ascii85[1] = (char) ((val32 % 85) + 33); - ascii85[0] = (char) ((val32 / 85) + 33); - - _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, sizeof(ascii85) ); - rc = sizeof(ascii85); - } - - ascii85_l += rc; - - if ( (A85BREAKCNTR -= rc) <= 0 ) - { - ascii85_p[ascii85_l] = '\n'; - ++ascii85_l; - A85BREAKCNTR = A85BREAKLEN; - } - } - - /* - * Output any straggler bytes: - */ - - if ( raw_l > 0 ) - { - int len; /* Output this many bytes */ - - len = raw_l + 1; - val32 = *++raw_p << 24; /* Prime the pump */ - - if ( --raw_l > 0 ) val32 += *(++raw_p) << 16; - if ( --raw_l > 0 ) val32 += *(++raw_p) << 8; - - val32 /= 85; - - ascii85[3] = (char) ((val32 % 85) + 33); - val32 /= 85; - - ascii85[2] = (char) ((val32 % 85) + 33); - val32 /= 85; - - ascii85[1] = (char) ((val32 % 85) + 33); - ascii85[0] = (char) ((val32 / 85) + 33); - - _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, len ); - ascii85_l += len; - } - } - - /* - * If requested add an ASCII85 End Of Data marker: - */ - - if ( f_eod ) - { - ascii85_p[ascii85_l++] = '~'; - ascii85_p[ascii85_l++] = '>'; - ascii85_p[ascii85_l++] = '\n'; - } - - return ( ascii85_l ); - -} /* Ascii85EncodeBlock() */ - -#endif /* EXP_ASCII85ENCODER */ - - -char* stuff[] = { -"usage: tiff2ps [options] input.tif ...", -"where options are:", -" -1 generate PostScript Level 1 (default)", -" -2 generate PostScript Level 2", -" -3 generate PostScript Level 3", -" -8 disable use of ASCII85 encoding with PostScript Level 2/3", -" -a convert all directories in file (default is first)", -" -b # set the bottom margin to # inches", -" -c center image (-b and -l still add to this)", -" -d # convert directory number #", -" -D enable duplex printing (two pages per sheet of paper)", -" -e generate Encapsulated PostScript (EPS) (implies -z)", -" -h # assume printed page height is # inches (default 11)", -" -w # assume printed page width is # inches (default 8.5)", -" -H # split image if height is more than # inches", -" -L # overLap split images by # inches", -" -i # enable/disable (Nz/0) pixel interpolation (default: enable)", -" -l # set the left margin to # inches", -" -m use \"imagemask\" operator instead of \"image\"", -" -o # convert directory at file offset #", -" -O file write PostScript to file instead of standard output", -" -p generate regular PostScript", -" -r rotate by 180 degrees", -" -s generate PostScript for a single image", -" -T print pages for top edge binding", -" -x override resolution units as centimeters", -" -y override resolution units as inches", -" -z enable printing in the deadzone (only for PostScript Level 2/3)", -NULL -}; - -static void -usage(int code) -{ - char buf[BUFSIZ]; - int i; - - setbuf(stderr, buf); - fprintf(stderr, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(stderr, "%s\n", stuff[i]); - exit(code); -} - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-4.0.2/.update b/libs/tiff-4.0.2/.update new file mode 100644 index 0000000000..8822907a94 --- /dev/null +++ b/libs/tiff-4.0.2/.update @@ -0,0 +1 @@ +Tue Dec 6 17:55:59 CST 2011 diff --git a/libs/tiff-3.8.2/COPYRIGHT b/libs/tiff-4.0.2/COPYRIGHT similarity index 100% rename from libs/tiff-3.8.2/COPYRIGHT rename to libs/tiff-4.0.2/COPYRIGHT diff --git a/libs/tiff-3.8.2/ChangeLog b/libs/tiff-4.0.2/ChangeLog similarity index 61% rename from libs/tiff-3.8.2/ChangeLog rename to libs/tiff-4.0.2/ChangeLog index 7d09b1b180..4eab3bba5b 100644 --- a/libs/tiff-3.8.2/ChangeLog +++ b/libs/tiff-4.0.2/ChangeLog @@ -1,3 +1,2058 @@ +2012-06-15 Frank Warmerdam + + * libtiff 4.0.2 released. + + * tools/tif2pdf.c, tools/tifdump.c: avoid unitialized variable + warnings with clang. + +2012-06-15 Tom Lane + + * tools/tiff2pdf.c: Defend against integer overflows while + calculating required buffer sizes (CVE-2012-2113). + +2012-06-12 Frank Warmerdam + + * libtiff/tif_print.c: Be careful about printing corrupt inknames. + + * libtiff/tif_fax3.c: Ensure runs array is initialized to zeros. + +2012-06-07 Frank Warmerdam + + * libtiff/tif_print.c: avoid pretty printing other fields when + we don't have the proper amount and type of data or if the field + is actually autodefined. + +2012-06-05 Frank Warmerdam + + * libtiff/tif_tile.c, libtiff/tif_strip.c: Ensure that illegal + ycbcrsubsampling values result in a runtime error, not just an + assertion. + + * tests/custom_dir.c: Add testing of EXIF and custom directory + reading and writing. + + * libtiff/tif_dir.c, libtiff/tiffio.h: Add TIFFCreateCustomDirectory() + and TIFFCreateEXIFDirectory() functions. + + * libtiff/tif_dir.c, tif_print.c : Remove FIELD_CUSTOM handling for + PAGENUMBER, HALFTONEHINTS, and YCBCRSUBSAMPLING. Implement DOTRANGE + differently. This is to avoid using special TIFFGetField/TIFFSetField + rules for these fields in non-image directories (like EXIF). + +2012-06-04 Frank Warmerdam + + * libtiff/tif_jpeg.c: Remove code for fixing up h_sampling and v_sampling + in JPEGPreDecode(). If a fixup will be done it needs to be done sooner + in JPEGFixupTagsSubsampling() or else buffer sized may be wrong. + +2012-06-01 Frank Warmerdam + + * tools/tiffinfo.c: Do not try to read image data in EXIF directories. + + * libtiff/tif_getimage.c: added support for _SEPARATED CMYK images. + http://bugzilla.maptools.org/show_bug.cgi?id=2379 + + * libtiff/tif_unix.c: use strerror() to return a more specific error message + on failed open. + http://bugzilla.maptools.org/show_bug.cgi?id=2341 + + * libtiff/tif_jpeg.c: Fix JPEGDecodeRaw() bugs. + http://bugzilla.maptools.org/show_bug.cgi?id=2386 + + * tests/decode_raw.c, tests/images/quad-tile.jpg.tiff: add limited support + for testing jpeg in tiff image decoding including the "raw" decode interface. + +2012-05-31 Frank Warmerdam + + * libtiff/tif_jpeg.c: avoid overrunning the end of the output buffer in + JPEGDecodeRaw() - mostly likely to occur when there is confusion about + sampling values. + + * libtiff/tif_read.c: Make sure tif_rawdatasize is cleared when tif_rawdata is freed. + + * libtiff/tif_getimage.c: Add support for greyscale+alpha c/o Jérémie Laval. + http://bugzilla.maptools.org/show_bug.cgi?id=2398 + +2012-05-29 Frank Warmerdam + + * libtiff/tif_dir.c: avoid using specific set/get logic to process fields in custom directories, + like EXIF directories. This fixes problems like a tag "320" existing in a custom directory getting + processed as if it were a colormap when it isn't really. Damn the wide variety of argument formulations + to get/set functions for different tags! + + * libtiff/tif_dir.c: Ensure that we keep track of when tif_rawdata + is a pointer into an mmap()ed file via TIFF_BUFFERMMAP flag. + +2012-05-24 Frank Warmerdam + + * libtiff/tif_pixarlog.c: Allocate working buffer one word larger since we "forward + accumulate" and overwrite the end by one word in at least some cases. + +2012-05-23 Frank Warmerdam + + * libtiff/tif_pixarlog.c: avoid accessing out of the lookup arrays for out of range inputs. + + * tools/tiffinfo.c: initialize h=0 to avoid undefined variable for degenerate files. + + * libtiff/tif_ojpeg.c: if OJPEGWriteHeader() fails once do not bother trying again on + the same image. + + * libtiff/tif_ojpeg.c: make things more resilient in the face of files without + stripbytecounts or stripoffsets or where loading these fails. + + * libtiff/tif_print.c: be careful about whether min/max values are singular + or one per sample. + + * libtiff/tif_print.c: Avoid confusion about count size when printing custom fields. + May affect things like ISOSpeedRatings. + + * libtiff/tif_dir.c: avoid one byte past end of ink names reading + in some cases. + +2012-05-19 Bob Friesenhahn + + * man/TIFFGetField.3tiff: Correct the 'count' field type in the + example for how to retreive the value of unsupported tags. + +2012-03-30 Frank Warmerdam + + * tif_getimage.c: Fix size overflow (zdi-can-1221,CVE-2012-1173) + care of Tom Lane @ Red Hat. + +2012-02-18 Bob Friesenhahn + + * libtiff 4.0.1 released. + + * Update automake used to 1.11.3. + + * libtiff/tiffio.h: Use double-underbar syntax in GCC printf + attribute specification to lessen the risk of accidental macro + substitution. Patch from Vincent Torri. + +2012-01-31 Frank Warmerdam + + * libtiff/tif_dir.c, libtiff/tif_dirread.c: Extra caution around + assumption tag fetching is always successful. + + * libtiff/tif_jpeg.c: Extra caution for case where sp is NULL. + +2012-01-22 Bob Friesenhahn + + * configure.ac: Add support for using library symbol versioning on + ELF systems with the GNU linker. Support is enabled via + --enable-ld-version-script. Disabled by default for now until + there is a decision for how to deploy a libtiff with versioned + symbols after libtiff 4.0.0 was already released. + +2011-12-22 Bob Friesenhahn + + * libtiff/tif_win32.c: Eliminate some minor 64-bit warnings in + + tif_win32.c. Patch by Edward Lam. + + * configure.ac: Add libtiff private dependency on -llzma for + pkg-config. Patch by Mark Brand. + Updated Automake to 1.11.2. + +2011-12-21 Bob Friesenhahn + + * libtiff 4.0.0 released. + +2011-12-08 Frank Warmerdam + + * libtiff/tif_dirread.c, libtiff/tif_read.c: more cautious checking + of _TIFFFillStriles() results (#gdal 4372) + +2011-12-07 Frank Warmerdam + + * libtiff/tif_dirread.c: fixes to deal with invalid files where + _TIFFFillStriles() fails, and we try to chop up strips (gdal #4372) + + * libtiff/tif_dirread.c: fix error reporting when there is no + tag information struct and name (gdal #4373) + +2011-10-22 Bob Friesenhahn + + * Update GNU libtool to 2.4.2. + + * tools/tiffsplit.c (tiffcp): TIFFGetField count field should be + uint32 type for TIFFTAG_JPEGTABLES. Patch by Christophe + Deroulers. + +2011-06-21 Frank Warmerdam + + * libtiff/libtiff.def: Restore TIFFMergeFieldInfo. + +2011-05-31 Jim Meyering + + * libtiff/tif_dirread.c (TIFFFetchStripThing): Free "data" also + upon failure to allocate "resizeddata". + * tools/tiff2ps.c (PSDataBW): Zero buffer *after* checking for + allocation failure, not before. + * libtiff/tif_ojpeg.c: plug leaks on OJPEG read failure path + * tools/rgb2ycbcr.c (cvtRaster): unchecked malloc + * libtiff/tif_jpeg.c, tools/tiff2pdf.c, tools/tiff2ps.c: mark + NULL-deref and possible overflow + * tools/tiff2pdf.c: remove decl+set of set-but-not-used local, "written" + * libtiff/tif_jpeg.c (JPEGInitializeLibJPEG): Remove declaration + and set of otherwise unused local, data_is_empty. + * libtiff/tif_jpeg.c (JPEGDecodeRaw) [JPEG_LIB_MK1_OR_12BIT]: + Diagnose out-of-memory failure and return 0 rather than + dereferencing NULL. + +2011-05-24 Frank Warmerdam + + * libtiff/tif_dirread.c: produce special error message for zero tag + directories instead of error out on the malloc(0) failure. + +2011-05-16 Frank Warmerdam + + * libtiff/tif_dirinfo.c: Restore TIFFMergeFieldInfo() and + related declarations as they are in active use by libraries + such as libgeotiff, and work just fine. (#2315) + +2011-04-20 Frank Warmerdam + + * libtiff/tif_dirinfo.c,tiffio.h: Remove the obsolete + TIFFMergeFieldInfo/TIFFFindFieldInfo/TIFFFindFieldInfoByName API. + http://bugzilla.maptools.org/show_bug.cgi?id=2315 + + * libtiff/libtiff.def: add some missing (64bit) APIs. + http://bugzilla.maptools.org/show_bug.cgi?id=2316 + +2011-04-09 Bob Friesenhahn + + * libtiff 4.0.0beta7 released. + +2011-04-09 Bob Friesenhahn + + * configure.ac: Should use AC_CANONICAL_HOST since host specifies + the run-time target whereas target is used to specify the final + output target if the package is a build tool (like a compiler), + which libtiff is not. Resolves libtiff bug 2307 "Use + AC_CANONICAL_HOST macro". + +2011-04-02 Bob Friesenhahn + + * configure.ac: Support configuring TIFF_INT64_FORMAT and + TIFF_UINT64_FORMAT appropriately for MinGW32. + + * tools/tiffdump.c (ReadDirectory): MinGW32 needs to use WIN32 + printf conventions for 64-bit types because it uses the WIN32 CRT. + + * libtiff/{tif_dumpmode.c,tif_luv.c,tif_lzw.c,tif_print.c, + tif_read.c,tif_strip.c,tif_thunder.c}: MinGW32 needs to use WIN32 + printf conventions for 64-bit types because it uses the WIN32 CRT. + + * tools/tiff2pdf.c (t2p_write_pdf_string): Fix printf syntax not + understood by WIN32 CRT. + + * libtiff/tif_ojpeg.c: Fixes to compile with MinGW32 GCC. + + * tools/fax2ps.c (main): Use tmpfile() rather than mkstemp() since + it is much more portable. Tmpfile is included in ISO/IEC + 9899:1990 and the WIN32 CRT. + +2011-03-26 Frank Warmerdam + + * tools/tiffset.c: add -d and -sd switches to allow operation on + a particular directory, not just the first (jef). + +2011-03-21 Frank Warmerdam + + * libtiff/tif_thunder.c: Correct potential buffer overflow with + thunder encoded files with wrong bitspersample set. The libtiff + development team would like to thank Marin Barbella and TippingPoint's + Zero Day Initiative for reporting this vulnerability (ZDI-CAN-1004, + CVE-2011-1167). + http://bugzilla.maptools.org/show_bug.cgi?id=2300 + +2011-03-10 Frank Warmerdam + + * libtiff/tif_fax3.h: Fix to last change allowing zero length + runs at the start of a scanline - needed for legal cases. + +2011-03-02 Frank Warmerdam + + * libtiff/tif_fax3.h: Protect against a fax VL(n) codeword commanding + a move left. Without this, a malicious input file can generate an + indefinitely large series of runs without a0 ever reaching the right + margin, thus overrunning our buffer of run lengths. Per CVE-2011-0192. + This is a modified version of a patch proposed by Drew Yao of Apple + Product Security. It adds an unexpected() report, and disallows the + equality case, since emitting a run without increasing a0 still allows + buffer overrun. + +2011-02-23 Frank Warmerdam + + * libtiff/tif_jpeg.c: avoid divide by zero in degenerate case (#2296) + + * tools/tiff2rgba.c: close source file on error to make leak + detection easier. + + * libtiff/tif_getimage.c: avoid leaks if TIFFRGBAImageBegin() fails. + + http://bugzilla.maptools.org/show_bug.cgi?id=2295 + +2011-02-22 Frank Warmerdam + + * libtiff/tif_lzma.c: Maintain tif_rawcc/tif_rawcp (CHUNKY_STRING_READ + _SUPPORT) + +2011-02-18 Frank Warmerdam + + * configure.ac, configure: Added support for --enable-chunky-strip-read + configure option to enable the experimental feature from a couple + months ago for reading big strips in chunks. + + * configure.ac, tif_read.c, tif_readdir.c, tif_dir.h, tiffiop.h, + tif_write.c, tif_print.c, tif_jpeg.c, tif_dirwrite.c, tif_write.c: + Implement optional support for deferring the load of strip/tile + offset and size tags for optimized scanning of directories. Enabled + with the --enable-defer-strile-load configure option (DEFER_STRILE_LOAD + #define in tif_config.h). + +2011-02-11 Frank Warmerdam + + * libtiff/tif_print.c: remove unused variable. + +2011-02-09 Frank Warmerdam + + * libtiff/tif_win32.c: avoid error/warning buffer overrun problem + with non-console (popup message) builds on win32. + + http://bugzilla.maptools.org/show_bug.cgi?id=2293 + +2011-01-24 Olivier Paquet + + * libtiff/{tif_dir.{h,c}, tif_dirinfo.c, tif_dirread.c, tif_dirwrite.c, + tif_print.c, tiff.h, tiffiop.h} : Added support for + TIFFTAG_SMINSAMPLEVALUE and TIFFTAG_SMAXSAMPLEVALUE to have different + values for each sample. Presents the min/max of all samples by default for + compatibility. TIFFSetField/TIFFGetField can be made to handle those tags + as arrays by changing the new TIFFTAG_PERSAMPLE pseudo tag. + http://www.asmail.be/msg0055458208.html + +2011-01-06 Frank Warmerdam + + * libtiff/tif_pixarlog.c: Note that tif_rawcc/tif_rawcp are not + maintained. + + * libtiff/tif_zip.c: Maintain tif_rawcc/tif_rawcp when decoding + for CHUNKY_STRIP_READ_SUPPORT. + + * libtiff/tif_jpeg.c: ensure that rawcc and rawcp are maintained + during JPEGPreDecode and JPEGDecode calls. + * libtiff/tif_read.c: larger read ahead for CHUNKY_STRIP_READ_SUPPORT, + as compression formats like JPEG keep 16 lines interleaved in a sense + and might need to touch quite a bit of data. + + http://trac.osgeo.org/gdal/ticket/3894 + +2011-01-03 Lee Howard + + * libtiff/tif_jpeg.c: Fix regressions with 2 and 3 band images + caused by commit on 2010-12-14. Submitted by e-mail from + Even Rouault + +2010-12-31 Olivier Paquet + + * libtiff/tif_dirwrite.c: Fixed writing of TIFFTAG_REFERENCEBLACKWHITE. + http://bugzilla.maptools.org/show_bug.cgi?id=2266 + +2010-12-23 Andrey Kiselev + + * tools/tiffcp.c, man/tiffcp.1: Added support for specifying the + compression level parameter (preset) for Deflate and LZMA encoders, + e.g "-c lzma:p1" or "-c zip:p9". + + * libtiff/tif_lzma.c: Properly set the LZMA2 compression level + (preset) in LZMAVSetField(). + +2010-12-18 Bob Friesenhahn + + * libtiff/Makefile.am (libtiff_la_SOURCES): Added tif_lzma.c to + Makefile. + +2010-12-14 Andrey Kiselev + + * configure.ac, libtiff/{tif_codec.c, tif_config.h.in, tiff.h, + tiffiop.h, tif_lzma.c}, tools/tiffcp.c, man/tiffcp.1: Implement a new + TIFF compression scheme LZMA reserving a new value 34925 for + Compression tag. As per + bug http://bugzilla.maptools.org/show_bug.cgi?id=2221 + +2010-12-14 Lee Howard + + * libtiff/tif_dirread.c: tolerate some cases where + FIELD_COLORMAP is missing + http://bugzilla.maptools.org/show_bug.cgi?id=2189 + +2010-12-14 Lee Howard + + * libtiff/tif_read.c: change read_ahead to tmsize_t + http://bugzilla.maptools.org/show_bug.cgi?id=2222 + +2010-12-14 Lee Howard + + * configure.ac, libtiff/Makefile.am: Build tif_win32.c on + Windows except on Cygwin + http://bugzilla.maptools.org/show_bug.cgi?id=2224 + +2010-12-14 Lee Howard + + * tools/gif2tiff.c: fix buffer overrun + http://bugzilla.maptools.org/show_bug.cgi?id=2270 + +2010-12-14 Lee Howard + + * libtiff/tif_jpeg.c: reduce usage of JCS_UNKNOWN in order + to improve compatibility with various viewers + submitted by e-mail from Dwight Kelly + +2010-12-13 Lee Howard + + * tools/fax2ps.c: be consistent with page-numbering + http://bugzilla.maptools.org/show_bug.cgi?id=2225 + +2010-12-13 Lee Howard + + * libtiff/tif_color.c: prevent crash in handling bad TIFFs + resolves CVE-2010-2595 + http://bugzilla.maptools.org/show_bug.cgi?id=2208 + +2010-12-13 Lee Howard + + * tools/tiffcrop.c: new release by Richard Nolde + http://bugzilla.maptools.org/show_bug.cgi?id=2004 + +2010-12-12 Lee Howard + + * tools/tiff2pdf.c: fix colors for images with RGBA + interleaved data + http://bugzilla.maptools.org/show_bug.cgi?id=2250 + +2010-12-12 Lee Howard + + * libtiff/tif_dirread.c: fix for Zeiss LSM and Canon CR2 files + http://bugzilla.maptools.org/show_bug.cgi?id=2164 + +2010-12-11 Lee Howard + + * tools/tiff2pdf.c: remove invalid duplication for Lab + http://bugzilla.maptools.org/show_bug.cgi?id=2162 + +2010-12-11 Lee Howard + + * libtiff/tif_jpeg.c: fix use of clumplines calculation + http://bugzilla.maptools.org/show_bug.cgi?id=2149 + +2010-12-11 Lee Howard + + * tools/fax2ps.c: replace unsafe tmpfile() with mkstemp() + http://bugzilla.maptools.org/show_bug.cgi?id=2118 + +2010-12-11 Lee Howard + + * libtiff/tif_ojpeg.c, libtiff/tif_pixarlog.c, + libtiff/tif_zip.c: fix build errors for VC6 + http://bugzilla.maptools.org/show_bug.cgi?id=2105 + +2010-12-11 Lee Howard + + * libtiff/tif_stream.cxx: warnings cleanup + http://bugzilla.maptools.org/show_bug.cgi?id=2091 + * libtiff/tif_dirread.c: warnings cleanup + http://bugzilla.maptools.org/show_bug.cgi?id=2092 + +2010-12-11 Lee Howard + + * tools/tiff2pdf.c: add fill-page option + http://bugzilla.maptools.org/show_bug.cgi?id=2051 + +2010-12-11 Lee Howard + + * libtiff/tif_dirread.c: modify warnings + http://bugzilla.maptools.org/show_bug.cgi?id=2016 + +2010-12-11 Lee Howard + + * libtiff/tif_ojpeg.c: fix buffer overflow on problem data + http://bugzilla.maptools.org/show_bug.cgi?id=1999 + +2010-12-11 Lee Howard + + * tools/tiffinfoce.c: strip byte counts are uint64* now + +2010-12-11 Lee Howard + + * libtiff/tif_ojpeg.c: fix crash when reading a TIFF with a zero + or missing byte-count tag + * tools/tiffsplit.c: abort when reading a TIFF without a byte-count + per http://bugzilla.maptools.org/show_bug.cgi?id=1996 + +2010-12-08 Lee Howard + + * libtiff/tif_dirread.c: fix crash when reading a badly-constructed + TIFF per http://bugzilla.maptools.org/show_bug.cgi?id=1994 + +2010-12-06 Lee Howard + + * libtiff/tif_open.c: Fix mode check before opening a file. + http://bugzilla.maptools.org/show_bug.cgi?id=1906 + +2010-11-27 Bob Friesenhahn + + * libtiff-4.pc.in: Added libtiff pkg-config .pc file support. + Patch by Vincent Torri. + +2010-10-21 Frank Warmerdam + + * tools/tiffinfo.c: avoid direct reference to _TIFFerrorHandler. + + * libtiff/tif_config.vc.h: define snprintf to _snprintf for tiff2pdf. + + * libtiff/libtiff.def: export _TIFFCheckMalloc for tools. + +2010-09-25 Lee Howard + + * tools/tiff2ps.c: improvements and enhancements from Richard Nolde + with additional command line options for Document Title, + Document Creator, and Page Orientation + +2010-07-13 Bob Friesenhahn + + * tools/tiffcrop.c: Patch from Richard Nolde to avoid a + potentially unterminated buffer due to using an exceptionally long + file name. + +2010-07-08 Andrey Kiselev + + * tools/tiff2pdf.c: Fixed ID buffer filling in + t2p_write_pdf_trailer(), thanks to Dmitry V. Levin. + +2010-07-07 Andrey Kiselev + + * libtiff/tif_dirread.c: Really reset the tag count in CheckDirCount() + to expected value as the warning message suggests. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=1963 + +2010-07-06 Andrey Kiselev + + * tools/tiffset.c: Properly handle TIFFTAG_PAGENUMBER, + TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_DOTRANGE + which should be set by value. + + * libtiff/tif_dirinfo.c: Don't use assertions in _TIFFFieldWithTag() + and _TIFFFieldWithName() if the tag is not found in the tag table. + This should be normal situation and returned NULL value should be + properly handled by the caller. + +2010-07-02 Andrey Kiselev + + * libtiff/tif_getimage.c: Avoid wrong math du to the signed/unsigned + integer type conversions. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2207 + + * tools/{tiff2bw.c, thumbnail.c, pal2rgb.c}: Fix the count for + WhitePoint tag as per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2042 + + * libtiff/tif_getimage.c: Check the number of samples per pixel when + working with YCbCr image in PickContigCase(). As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2216 + + * libtiff/tif_dir.c: Set the bogus post-decoding hook when processing + TIFFTAG_BITSPERSAMPLE in _TIFFVSetField() for the case of 8 bit when + we don't need any post-processing. That helps to reset the hook if we + previously set this field to some other value and the hook was + initialized accordingly. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2035 + +2010-07-01 Andrey Kiselev + + * tools/tiffgt.c: Properly check the raster buffer allocations for + integer overflows. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2108 + + * m4/acinclude.m4: Update GL/GLU/GLUt/Pthread macros from the + upstream. + + * libtiff/{tif_aux.c, tif_strip.c, tif_tile.c, tiffiop.h}: Move + multiply_32() and multiply_64() functions into tif_aux.c file and + rename them into _TIFFMultiply32() and _TIFFMultiply64() respectively. + +2010-06-30 Andrey Kiselev + + * tools/tiff2pdf.c: Better generation of ID field in + t2p_write_pdf_trailer(). Get rid of GCC aliasing warnings. + + * tools/tiff2pdf.c: Fixed computation of the tile buffer size when + converting JPEG encoded tiles. + + * tools/tiff2pdf.c: Better handling of string fields, use static + string buffers instead of dynamically allocated, use strncpy() instead + of strcpy(), control the string lengths. + +2010-06-25 Andrey Kiselev + + * tools/tiffcp.c: Initialize buffer arrays with zero to avoid + referencing to uninitialized memory in some cases (e.g. when tile size + set bigger than the image size). + +2010-06-15 Bob Friesenhahn + + * tools/tiffcrop.c: Patch from Richard Nolde. Reject YCbCr + subsampled data since tiffcrop currently doesn't support it. Fix + JPEG support. + +2010-06-13 Frank Warmerdam + + * libtiff/tif_dirinfo.c: Fix invocation of tag compare function (#2201) + + * tools/tiff2pdf.c: Fix assorted bugs in tiff2pdf: missing "return" + in t2p_read_tiff_size() causes t2p->tiff_datasize to be set entirely + wrong for COMPRESSION_JPEG case, resulting in memory stomp if actual + size is larger. Also, there are a bunch of places that try to + memset() a malloc'd buffer before checking for malloc failure, which + would result in core dump if there actually were a failure. (#2211) + +2010-06-11 Bob Friesenhahn + + * libtiff/tiffiop.h (TIFFSafeMultiply): Need more castings to + avoid compiler warnings if parameter types are not sign + consistent. + + * libtiff 4.0.0alpha6 released. + + * tools/tiffcrop.c: Applied patch from Richard Nolde: Corrected + European page size dimensions. Added an option to allow the user + to specify a custom page size on the command line. Fix the case + where a page size specified with a fractional part was being + coerced to an integer by retyping the variables that define the + paper size. + + * html/index.html: Update for the 3.9.3 release. + + * tools/tiffcp.c (tiffcp): Applied Tom Lane's patch to reject + YCbCr subsampled data since tiffcp currently doesn't support it. + http://bugzilla.maptools.org/show_bug.cgi?id=2097 + + * Update libtool to version 2.2.10. + +2010-06-10 Bob Friesenhahn + + * libtiff/tiffiop.h (TIFFSafeMultiply): Work properly if + multiplier is zero. + +2010-06-09 Bob Friesenhahn + + * libtiff/tif_fax3.c (Fax3SetupState): Yesterday's fix for + CVE-2010-1411 was not complete. + + * libtiff/tiffiop.h (TIFFSafeMultiply): New macro to safely + multiply two integers. Returns zero if there is an integer + overflow. + + * tools/tiffcp.c (main): tiffcp should not leak memory if an error + is reported when reading the input file. + +2010-06-08 Bob Friesenhahn + + * Update libtool to version 2.2.8. + + * libtiff/tif_fax3.c (Fax3SetupState): Avoid under-allocation of + buffer due to integer overflow in TIFFroundup() and several other + potential overflows. In conjunction with the fix to TIFFhowmany(), + fixes CVE-2010-1411. + + * libtiff/tiffiop.h (TIFFhowmany): Return zero if parameters would + result in an integer overflow. This causes TIFFroundup() to also + return zero if there would be an integer overflow. + + * contrib: Add an emacs formatting mode footer to all source files + so that emacs can be effectively used. + +2010-06-03 Oliver Chen Feng + + * libtiff/tools/tiffcp.c: add a new option -x to force merged tiff + file PAGENUMBER value in sequence for users who care the page + sequence, this will also prevent tiff2pdf from creating pdf file from + the merged tiff file with wrong page sequence. + +2010-05-08 Olivier Paquet + + * libtiff/tif_dirread.c: Restored TIFFReadDirEntryFloat function in order + to add missing TIFF_SETGET_FLOAT case to TIFFFetchNormalTag. + * libtiff/tif_dirinfo.c: Use correct set_field_type for + TIFFTAG_PIXAR_FOVCOT so it is readable again (regression from 3.9.2). + http://bugzilla.maptools.org/show_bug.cgi?id=2192 + +2010-05-07 Frank Warmerdam + + * libtiff/tif_jpeg.c: Ensure that quality is always set in + JPEGPreEncode(), not just when we want to output local tables. + Otherwise the quality used during compression may not be right and + might not match the tables in the tables tag. This bug only occurs + when seeking between directories in the midst of writing blocks. + http://trac.osgeo.org/gdal/ticket/3539 + +2010-05-06 Andrey Kiselev + + * html/man/TIFFGetField.3tiff.html, html/man/TIFFSetField.3tiff.html: + Regenerated from the source. + +2010-05-05 Olivier Paquet + + * libtiff/tif_print.c: Fixed printing of TIFFTAG_REFERENCEBLACKWHITE which + had stopped working. Also made it always print 6 floats instead of + 2*SamplesPerPixel. + http://bugzilla.maptools.org/show_bug.cgi?id=2191 + http://bugzilla.maptools.org/show_bug.cgi?id=2186 + * man/TIFFGetField.3tiff, man/TIFFSetField.3tiff: Fixed doc to reflect the + fact that libtiff considers TIFFTAG_REFERENCEBLACKWHITE to be 6 floats. + +2010-05-05 Frank Warmerdam + + * libtiff/tif_jpeg.c: Fix to use memcmp(), not memcpy() when checking + if the jpeg table was written. This is a fix for the last fix on 04-21. + +2010-04-21 Frank Warmerdam + + * libtiff/tif_jpeg.c: avoid preparing jpeg tables everytime + JPEGSetupEncode() is called if the tables already seem to be + established. This prevents spurious updates and rewriting of + directories with jpegtables when doing updates to existing images. + http://trac.osgeo.org/gdal/ticket/3539 + +2010-04-20 Olivier Paquet + + * libtiff/tif_dirinfo.c: Use correct set_field_type for + TIFFTAG_PIXAR_IMAGEFULLWIDTH, TIFFTAG_PIXAR_IMAGEFULLLENGTH, + TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN and TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA. + They were unreadable with TIFF_SETGET_UNDEFINED, a regression from 3.9.2. + http://bugzilla.maptools.org/show_bug.cgi?id=2139 + +2010-04-10 Bob Friesenhahn + + * libtiff/tif_dir.c (_TIFFVSetField): Add a special error case for + when the tag count value is zero. Error handling is still a + regression since in 3.9.2, empty tags are skipped (with a warning) + rather than returning a hard error and refusing to read the file. + + * tools/ppm2tiff.c (main): While case for parsing comment line + requires extra parenthesis to work as expected. Reported by + Thomas Sinclair. + +2010-04-02 Frank Warmerdam + + * libtiff/tif_read.c (primarily): Add support for + CHUNKY_STRIP_READ_SUPPORT where large strips are + read in chunks for applications using TIFFReadScanline(). + This is intended to make it more practical work with very + large compressed one-strip files. Feature is off by default. + Enable by defining CHUNK_STRIP_READ_SUPPORT as a macro. + http://trac.osgeo.org/gdal/ticket/3514 + +2010-03-31 Frank Warmerdam + + * libtiff/tif_flush.c: Use TIFFRewriteDirectory() when flushing + directories so previously placed directories will be migrated to + the end of file if needed. + +2010-03-30 Frank Warmerdam + + * libtiff/tif_lzw.c: change type of dec_bitsleft field to uint64 + to support operating on strips/tiles of more than 256MB. + http://trac.osgeo.org/gdal/ticket/3512 + +2010-03-10 Bob Friesenhahn + + * libtiff/tif_aux.c (_TIFFCheckRealloc): Improve error message so + that it is clearly a memory allocation error message, and also + includes the size of the allocation request. + +2010-02-22 Lee Howard + + * libtiff/tif_jpeg.c: Do not generate a JPEGTables tag when creating + the JPEG TIFF as is is not required in order to prevent it from + being unused and filled with invalid data. (Leave it to be + generated by later activity.) + http://bugzilla.maptools.org/show_bug.cgi?id=2135 + * tools/tiff2pdf.c: Write the JPEG SOI headers into the TIFF strip + data rather than skipping them. This fixes the ability to view in + Acrobat Reader, Evince, and Ghostscript. + http://bugzilla.maptools.org/show_bug.cgi?id=2135 + * libtiff/tif_fax3.c: Don't return error on badly-terminated MMR + strips. + http://bugzilla.maptools.org/show_bug.cgi?id=2029 + +2009-12-03 Frank Warmerdam + + * libtiff/tif_jpeg.c: Made JPEGDecodeRaw() check for buffer overruns. + Made so that when working with downsampled images a stub function + reporting an error is used for tif_decoderow. We cannot meaningfully + support reading scanlines in this situation. (#1936) + + * libtiff/tif_jpeg.c: Ensure that tif_scanlinesize is computed after + resetting of the upsampling values (gdal:#3259). + http://bugzilla.maptools.org/show_bug.cgi?id=1936 + +2009-11-30 Frank Warmerdam + + * contrib/dbs/tiff-grayscale.c, contrib/tif-palette.c, + tools/ras2tiff.c: Fix resource leaks on error. + http://bugzilla.maptools.org/show_bug.cgi?id=2121 + + * libtiff/tif_{aux.c,dir.c,dir.h,dirinfo.c}: Return to handling + TIFFTAG_REFERENCEBLACKWHITE as a field in the TIFF directory instead + of as a custom(generic) field to avoid a potential reentrancy problem. + http://bugzilla.maptools.org/show_bug.cgi?id=2125 + + * libtiff/tif_color.c, libtiff/tif_getimage.c, libtiff/tiffio.h, + man/TIFFcolor.3tiff: Make TIFFDisplay argument in TIFFCIELabToRGBInit + const, and display_sRGB static and const. + http://bugzilla.maptools.org/show_bug.cgi?id=2124 + +2009-11-04 Bob Friesenhahn + + * libtiff 4.0.0alpha5 released. + +2009-11-03 Bob Friesenhahn + + * tools/tiffcrop.c: Updated tiffcrop from Richard Nolde. This + version has undergone substantial testing with arbitrary sample + bit depths. Also eliminates GCC compilation warnings. + +2009-11-02 Bob Friesenhahn + + * port/libport.h: Add extern declarations for getopt standard + globals. + +2009-10-31 Bob Friesenhahn + + * libtiff/tif_lzw.c (LZWDecode, LZWDecodeCompat): Fix warnings + noticed in 64-bit build of libtiff with Visual Studio 2005. + Resolves "Bug 2067 - Visual Studio 2005 64-bit warnings in + tif_lzw.c", http://bugzilla.maptools.org/show_bug.cgi?id=2067 + + * libtiff/tif_pixarlog.c (PixarLogEncode): Fix non-important + warning noticed in Visual Studio 2005 build. Resolves "Bug 2068 - + Visual Studio 2005 64-bit warning in tif_pixarlog.c", + http://bugzilla.maptools.org/show_bug.cgi?id=2068 + +2009-10-29 Bob Friesenhahn + + * libtiff/tif_dirread.c: Eliminate GCC "dereferencing type-punned + pointer" warnings. + +2009-10-28 Bob Friesenhahn + + * html/tools.html: Add manual page links, and a summary + description of tiffcrop. + +2009-10-07 Bob Friesenhahn + + * configure.ac: x86_64 should use the same fill order as i386. + +2009-09-24 Bob Friesenhahn + + * tools/tiffcrop.c, man/tiffcrop.1: New tiffcrop from Richard + Nolde. Major updates to add significant functionality for reading + and writing tile based images with bit depths not a multiple of 8 + which cannot be handled by tiffcp. + +2009-09-03 Bob Friesenhahn + + * libtiff/tif_ojpeg.c (OJPEGWriteHeaderInfo): IJG JPEG 7 needs + do_fancy_upsampling=FALSE in order to read raw data. Resolves + "Bug 2090 - OJPEG crash with libjpeg v7". + http://bugzilla.maptools.org/show_bug.cgi?id=2090 + +2009-09-03 Frank Warmerdam + + * libtiff/tif_getimage.c: Fixed error recognition handling in RGBA + interface when stoponerror is set. + http://bugzilla.maptools.org/show_bug.cgi?id=2071 + +2009-08-30 Bob Friesenhahn + + * tools/{tiffcrop.c,tiffgt.c}: Applied patch from Oden Eriksson to + fix build with gcc when using the "-Wformat + -Werror=format-security" flags. + +2009-08-29 Bob Friesenhahn + + * test/{bmp2tiff_palette.sh, bmp2tiff_rgb.sh, gif2tiff.sh, + ppm2tiff_pbm.sh, ppm2tiff_pgm.sh, ppm2tiff_ppm.sh}: Additional + utilities tests. + +2009-08-28 Bob Friesenhahn + + * tools/tiffinfo.c: tiffinfo should return error status to the + caller. Register a private error callback to accomplish that. + + * test/Makefile.am (TIFFIMAGES): Add test images in BMP, GIF, and + PNM formats so that we will be able to test more of the tools. + While adding these test images I notice that bmp2tiff and gif2tiff + only support ancient versions of their respective formats. + +2009-08-27 Bob Friesenhahn + + * libtiff 4.0.0alpha4 released. + + * HOWTO-RELEASE: Improved release instructions. + +2009-08-24 Bob Friesenhahn + + * man/{TIFFClose.3tiff,raw2tiff.1,tiffcmp.1,tiffsplit.1}: Applied + fixes for "Bug 2023 - nroff errors in manual pages". + http://bugzilla.maptools.org/show_bug.cgi?id=2023 + + * tools/{rgb2ycbcr.c, tiff2rgba.c}: Applied fixes for "Bug 2079 - + CVE-2009-2347 libtiff: integer overflows in various inter-color + space conversion tools". + http://bugzilla.maptools.org/show_bug.cgi?id=2079 + + * libtiff/tif_print.c (TIFFPrintDirectory): Apply fix from Jay + Berkenbilt for "Bug 2024 - possible null pointer dereference with + one-line fix". + http://bugzilla.maptools.org/show_bug.cgi?id=2024 + + * libtiff/tif_dirread.c (TIFFReadCustomDirectory): Apply patch + from Jay Berkenbilt for "Bug 1895 - logic error in tif_dirread.c: + segfault after setting tdir_tag = IGNORE". + http://bugzilla.maptools.org/show_bug.cgi?id=1895 + +2009-08-23 Bob Friesenhahn + + * test/Makefile.am, test/tiffcrop*.sh: Split previously existing + tiffcrop.sh into a collection of many specific tests. Re-wrote + all of the existing tests to be based on some simple shell + functions. Make distcheck works again. + + Export certain variables (MAKE, MAKEFLAGS, MEMCHECK) to tests and + added 'memcheck' and 'ptrcheck' targets to make it easy to run the + tests under valgrind. + +2009-08-21 Bob Friesenhahn + + * test/tiffcp-logluv.sh: Fix test so that it works with a VPATH + build. + + * test/Makefile.am (AUTOMAKE_OPTIONS): Colorized tests was not + actually activated since it needed to be enabled in this + Makefile.am. Also activated parallel-tests mode since it offers + useful features such as per-test .log files and a summary test + report .log file. + +2009-08-20 Bob Friesenhahn + + * configure.ac: Updated autotools. Autoconf 2.64, Automake 1.11, + libtool 2.2.6. Enabled support for silent build rules + (--enable-silent-rules or 'make V=0') and colorized tests. + + * html/{index.html, v3.9.0.html}: Update for 3.9.0 release. + +2009-06-30 Frank Warmerdam + + * tests/tiffcp-logluv.sh: minimal testing of sgilog compression. + + * tools/tiffcp.c: add -c sgilog support. + + * libtiff/tif_luv.c: correct return codes from encoderow to be + 1 on success instead of zero. + http://bugzilla.maptools.org/show_bug.cgi?id=2069 + + * libtiff/tif_lzw.c: back out patch from #2065 and apply patch from + #1085 for a better underflow fix that errors properly. + http://bugzilla.maptools.org/show_bug.cgi?id=2065 + http://bugzilla.maptools.org/show_bug.cgi?id=1985 + +2009-06-26 Frank Warmerdam + + * libtiff/tif_strip.c: Remove an inappropriate assertion that often + fails on oddly sized 12bit jpeg compressed ycbcr images. + +2009-06-22 Frank Warmerdam + + * libtiff/tif_lzw.c: Fix buffer underflow bug. + http://bugzilla.maptools.org/show_bug.cgi?id=2065 + +2009-06-21 Frank Warmerdam + + * configure.ac, libtiff/tif_jpeg.c, libtiff/tif_jpeg_12.c: add support + for dual mode 8/12 bit jpeg support. + +2009-06-03 Frank Warmerdam + + * libtiff/tif_write.c: do not override the planar configuration to be + contig for one sample files if planar configuration is already set. + http://bugzilla.maptools.org/show_bug.cgi?id=2057 + +2009-06-02 Frank Warmerdam + + * libtiff/libtiff.def: Add TIFFUnsetField. + +2009-05-03 Frank Warmerdam + + * libtiff/{tif_jpeg.c,tif_ojpeg.c,tif_getimage.c}: Fixed various + error reports to use "%s" as format string. + http://trac.osgeo.org/gdal/ticket/2976 + +2009-03-12 Frank Warmerdam + + * libtiff/{tif_fax3.c,tif_jpeg.c,tif_ojpeg.c}: Fix printdir chaining + for some codecs (#2020). + +2009-02-12 Frank Warmerdam + + * libtiff/tif_luv.c: Fix handling of tiled logluv images. + http://bugzilla.maptools.org/show_bug.cgi?id=2005 + +2009-02-09 Frank Warmerdam + + * libtiff/tif_dirread.c: Improve allocation safety when allocated + buffer for large tags. (#1998) Related to (#1993) + +2009-02-06 Frank Warmerdam + + * tools/tiffcrop.c: Don't default image->res_unit to INCH. Now the + test suite should pass. + +2009-02-05 Frank Warmerdam + + * libtiff/tif_dirread.c: Re-incorporated a sanity check on tag size, + but at the 2GB boundary to avoid overflow on 32bit systems. + http://bugzilla.maptools.org/show_bug.cgi?id=1993 + + * libtiff/tif_dirread.c: Remove some assertions that blow due to + corrupt files rather than in response to library internal + inconsistencies. + http://bugzilla.maptools.org/show_bug.cgi?id=1995 + http://bugzilla.maptools.org/show_bug.cgi?id=1991 + + * libtiff/tif_dirread.c: Fixed testing for failed result from + TIFFReadDirectoryFindFieldInfo(). + http://bugzilla.maptools.org/show_bug.cgi?id=1992 + +2009-01-23 Frank Warmerdam + + * libtiff/tif_predict.c: Add support for 32bit integer horz. predictors. + http://bugzilla.maptools.org/show_bug.cgi?id=1911 + + * libtiff/tif_dirwrite.c: Fix byte swapping of next directory offset. + + http://bugzilla.maptools.org/show_bug.cgi?id=1924 + + * tools/tiffcrop.c: initialize xres/yres values. + + * test/*.sh - default ${srcdir} to local directory. + + * test/common.sh - start verbose mode after common settings. + + * libtiff/tif_dirinfo.c: Replace lfind() with local equivelent to + avoid type mismatches on different platforms. + http://bugzilla.maptools.org/show_bug.cgi?id=1889 + +2009-01-22 Frank Warmerdam + + * tools/{fax2tiff.c,thumbnail.c,tiff2pdf.c,tiff2ps.c,tiffdump.c, + tiffsplit.c}: avoid warnings, mostly 32bit/64bit casting issues. + + * port,tools: Introduce libport.h, and include in tools if NEED_LIBPORT + defined, primarily to reduce prototype warnings on windows. + + * libtiff/tif_dirinfo.c,tif_dirread.c: Avoid warnings + about unused parameters, and uninitialized variables. + +2009-01-21 Bob Friesenhahn + + * test/common.sh: Execute tests like 'make VERBOSE=TRUE check' in + order to trace full execution detail while executing the test suite. + +2009-01-20 Frank Warmerdam + + * tools/tiffsplit.c: fix sampleformat to be shortv instead of longv. + +2009-01-20 Bob Friesenhahn + + * test/Makefile.am (CLEANFILES): Make sure that test output files + are removed by 'make clean' + + * Update autotools for 4.0.0 beta3 + + * 4.0.0 beta3 produced. + +2009-01-12 Bob Friesenhahn + + * test/tiffcrop.sh: New test script for tiffcrop from Richard + Nolde. + + * tools/tiff2ps.c: Remove spurious message to stderr. + +2009-01-11 Bob Friesenhahn + + * tools/tiff2ps.c: Incorporated significant functionality update + from Richard Nolde. In particular, support for rotating the image + by 90, 180, 270, and 'auto' has been added. + + * man/tiffcrop.1: Incorporated documentation updates from Richard + Nolde. + + * tools/tiffcrop.c: Incorporated significant functionality update + from Richard Nolde. + +2008-12-31 Bob Friesenhahn + + * libtiff/tiffio.h: GCC will now validate format specifications + for TIFFError(), TIFFErrorExt(), TIFFWarning(), and + TIFFWarningExt() in order to reveal bugs. + + * Many fixes throughout to work better as a 64-bit build. + +2008-12-30 Bob Friesenhahn + + * tools/{tiff2pdf.c, tiff2ps.c, tiffinfo.c}: Offset and length + tags now require 64-bit parameter rather than 32-bit. + + * libtiff/tif_dirread.c: Fixed issues with unaligned access to + 64-bit values. + + * tools/thumbnail.c: Eliminate crash noticed while running test + suite. + +2008-12-29 Bob Friesenhahn + + * libtiff/tif_ojpeg.c (OJPEGLibjpegJpegSourceMgrFillInputBuffer): + Initialize stack variables to avoid compiler warning. + + * tools/tiffinfoce.c (main): Use toff_t for offset type when + retrieving offset of EXIF IFD. + + * libtiff/tiffio.h: Undeprecate toff_t and restore its use in the + TIFFClientOpen() callback and other external function definitions. + + * tools/tiffinfo.c (main): Offset to EXIF IFD requires a 64-bit + type now. Fixes crash when dumping files containing an EXIF IFD. + + * m4/libtool.m4: Update to libtool 2.2.6. + +2008-12-21 Frank Warmerdam + + * libtiff/tif_dir.c, tiffio.h: Introduce TIFFUnsetField() function. + + * libtiff/tif_jpeg.c: Avoid errors if the application writes a full + strip for the last partial strip in a jpeg compressed file. + http://bugzilla.maptools.org/show_bug.cgi?id=1981 + +2008-10-29 Frank Warmerdam + + * libtiff/tif_flush.c: Make sure that BEENWRITING is cleared when + we take the shortcut to only update the strip/tile offsets in place. + http://trac.osgeo.org/gdal/ticket/2621 + +2008-10-21 Andrey Kiselev + + * libtiff/tif_jbig.c: Support the JBIG-KIT 2.0 (compatibility with + the older versions retained). + +2008-10-09 Frank Warmerdam + + * libtiff/tif_jpeg.c: Add #ifdefs for changes needed if using + IPP enabled version of libjpeg from Intel. + http://bugzilla.maptools.org/show_bug.cgi?id=1951 + +2008-09-05 Andrey Kiselev + + * tools/tiffsplit.c: Use byte counts of proper size (uint64). + Required for libtiff 4.0. + + * tools/tiffsplit.c: Use dynamically allocated array instead of static + when constructing output file names. + +2008-09-03 Andrey Kiselev + + * tools/tiffsplit.c: Get rid of unsafe strcpy()/strcat() calls when + doing the filename/path construction. + + * tools/tiff2pdf.c: More appropriate format string in + t2p_write_pdf_string(); avoid signed/unsigned mismatch. + + * libtiff/tif_lzw.c: Properly zero out the codetable. As per bug + + http://bugzilla.maptools.org/show_bug.cgi?id=1929 + + * libtiff/tif_lzw.c: Properly zero out the string table. Fixes + CVE-2008-2327 security issue. + +2008-09-01 Frank Warmerdam + + * libtiff/tif_dirread.c: Avoid unused TIFFReadDirEntryFloat() function. + + * libtiff/tif_dirwrite.c: modified to write IFDs as either IFD8 or IFD + depending on whether the file is bigtiff or classic tiff. + http://bugzilla.maptools.org/show_bug.cgi?id=1917 + +2008-08-12 Edward Lam + + * tools/tiffdump.c: When compiling for Microsoft Windows, apply + consistent (__int64) casting when testing if _lseeki64 has + successfully seeked as requested. This is necessary for large + file support to work since off_t is only 32-bit. + +2008-07-29 Frank Warmerdam + + * tif_strip.c: Replace assertions related to samplesperpixel != 3 or + the subsampling values not being 1, 2 or 4 (for jpeg compressed images) + with control logic to return runtime errors (c/o Even Rouault) (#1927). + +2008-06-17 Frank Warmerdam + + * tools/tiffcrop.c: Fix some portability problems. + + * libtiff/tif_ojpeg.c: Use same jpeg/win32 boolean/FAR hacks as are + used in tif_jpeg.c. + + * libtiff/tif_win32.c: Ensure TIFFOpenW() uses same FILE_SHARE flags + as TIFFOpen(). + +2008-06-01 Frank Warmerdam + + * libtiff/tif_dirwrite.c: Fix alignment problems affecting architectures + like Sparc/Solaris. + http://bugzilla.maptools.org/show_bug.cgi?id=1892 + +2008-05-27 Frank Warmerdam + + * libtiff.def: Add TIFFFindField + http://bugzilla.maptools.org/show_bug.cgi?id=1891 + +2008-05-26 Frank Warmerdam + + * tif_config.*.h, tiffconf.*.h: Remove SIZEOF_LONG definition, unused. + + * li2008-04-15 Andrey Kiselev + +btiff/tif_win32.c: Replace custom Win32 memory api with generic + POSIX one. No apparent value to use of GlobalAlloc() in the modern + age. http://bugzilla.maptools.org/show_bug.cgi?id=1885 + + * libtiff/tiffconf.vc.h: Added JBIG_SUPPORT and MDI_SUPPORT items + in windows version (care of Edward Lam). + +2008-05-24 Frank Warmerdam + + * tif_codec.c: Avoid NULL pointer dereferencing for exotic + compression codec codes. + + * tif_dirwrite.c: fix potential memory leak. + + * tif_dirread.c: Fix unchecked malloc result. + +2008-05-24 Bob Friesenhahn + + * test {tiff2pdf.sh tiff2ps-EPS1.sh tiff2ps-PS1.sh tiff2ps-PS2.sh + tiff2ps-PS3.sh tiffcp-g3-1d-fill.sh tiffcp-g3-1d.sh + tiffcp-g3-2d-fill.sh tiffcp-g3-2d.sh tiffcp-g3.sh tiffcp-g4.sh + tiffcp-split-join.sh tiffcp-split.sh tiffcp-thumbnail.sh + tiffdump.sh tiffinfo.sh}: Added more test scripts based on + suggestions from Lee Howard posted to the tiff list on 13 Sep + 2007. + +2008-05-23 Frank Warmerdam + + * libtiff/tif_fax3.c: Add an assert in an effort to detect a + possible runtime problem reported by coverity. + + * contrib/iptcutil/iptcutil.c: Fixed memory leak of str. + + * tools/tiffcrop.c, man/tiffcrop.1: Major update from Richard Nolde. + http://bugzilla.maptools.org/show_bug.cgi?id=1888 + + * tools/tiffdither.c: remove dead onestrip code. avoid memory leak. + + * tools/rgb2ycbcr.c: fix memory leak of raster buffer. + + * tools/tiffcp.c: Simplify inknames code to avoid pointless test. + Cleanup scanline allocation to avoid coverity warning. + + * tools/thumbnail.c: Check for TIFFOpen() failure. + +2008-05-18 Frank Warmerdam + + * libtiff/tif_dirinfo.c: Use TIFF_SETGET_ASCII for PIXAR_TEXTUREFORMAT + and PIXAR_WRAPMODES instead of TIFF_SETGET_UNDEFINED. Not exactly clear + why this is needed. + +2008-05-09 Bob Friesenhahn + + * Makefile.am (ACLOCAL_AMFLAGS): Libtool 2.2.4 does not like + "ACLOCAL_AMFLAGS=-I ./m4". It wants "ACLOCAL_AMFLAGS=-I m4". + +2008-04-15 Andrey Kiselev + + * test/: Test suite updated. Everything is passed now. + + * libtiff/tif_dirinfo.c: Fixed description of the + TIFFTAG_NUMBEROFINKS tag. + +2008-04-14 Andrey Kiselev + + * libtiff/{tif_dirread.c, tif_dirwrite.c, tiffiop.h}: + Get rid of some of "dereferencing type-punned" warnings by converting + tdir_offset field of TIFFDirEntry structure into union. + +2008-04-10 Andrey Kiselev + + * libtiff/{tif_flush.c, tif_dirwrite.c, tiffio.h, tiffiop.h}: + TIFFRewriteField() renamed into _TIFFRewriteField() and moved out + from the public interface. Type of its 'count' parameter changed + from uint32 to tmsize_t. + + * /libtiff/tiffiop.h: Make tif_nfields and tif_nfieldscompat fields + of the tiff structure have the size_t type instead of uint32. + +2008-04-09 Andrey Kiselev + + * tools/tiffdump.c: Added support for MSVS 6.0. + + * libtiff/tif_dirread.c: Use custom functions _TIFFUInt64ToFloat() + and _TIFFUInt64ToDouble() to convert 64-bit integers into floating + point values on MSVS 6.0 platform. + +2008-03-14 Frank Warmerdam + + * tif_dirread.c: Removed sanity checks on tags larger than 4MB in + TIFFReadDirEntryArray() since they are interfering with seemingly + legitimate files. http://trac.osgeo.org/gdal/ticket/2005 + +2008-02-09 Joris Van Damme + + * tif_dirread.c: Added handling for the case of number of values for + PageNumber tag different from 2 (previously resulted in an assert + indicating lack of handling and was forgotten about) + +2008-02-01 Frank Warmerdam + + * libtiff/tif_jpeg.c: Do not try to fixup subsampling tags based on + the actual jpeg data stream if the first strip/tile has zero size. + This is the case when GDAL creates a new file with zero sizes, closes + and reopens it. + +2008-01-07 Frank Warmerdam + + * tools/tiff2ps.c: fix up 64bit issues (from Edward Lam). + +2008-01-01 Frank Warmerdam + + * libtiff/tif_dirwrite.c: #ifdef out lots of unused functions. + + * Makefile.vc, libtiff/Makefile.vc, tools/Makefile.vc: Improve clean + targets. + + * tools/tiffinfo.c, tools/tiffcmp.c, tools/gif2tiff.c, tools/bmp2tiff.c + tools/tiff2pdf.c: Fix 64-bit warnings when compiling under MSVC 2005 + (x64). + + * tools/tiffset.c: Changes to reflect the fact that TIFFFieldWithTag() + and TIFFFieldWithName() now return TIFFField pointers instead of + TIFFFieldInfo pointers. + + * tools/tiffdump.c: Added ssize_t typedef on Windows since it doesn't + exist. This makes it compile again on Windows + + * tif_aux.c, tif_getimage.c, tif_next.c, tif_predict.c, tif_win32.c, + tiffconf.vc.h: Various 64bit fixes from Edward Lam identified on win64. + + * test/rewrite_tag.c: New test for TIFFRewriteField(). + +2007-12-31 Frank Warmerdam + + * tif_dirwrite.c: Added TIFFRewriteField(). This new function + rewrites one field "on disk" updating an existing directory + entry. Lots of limitations still... + + * tiffiop.h, tif_write.c, tif_dirread.c, tif_flush.c: Keep track of + TIFF_DIRTYSTRIP separately from TIFF_DIRTYDIRECT to indicate that + the strip offset/size values are dirty but nothing else about the + directory is dirty. In flush handle "just stripmaps dirty" as a + special case that just rewrites these values without otherwise + modifying the directory on disk using TIFFRewriteField(). + + We also modify logic so that in update mode the directory is not + marked dirty on read, but only when something is changed. This + means we need to keep track of updates to the stripmap stuff in + TIFFAppendToStrip(). + +2007-12-10 Frank Warmerdam + + * tif_jpeg.c: Improve ability to switch between encoding and decoding + in the jpeg code (gdal bug #2033). + +2007-11-23 Frank Warmerdam + + * tif_dir.c, tif_dirread.c, tif_dirwrite.c, tif_read.c, tif_write.c, + tiffiop.h: Added TIFF_BUF4WRITE flag to indicate if contents of the + rawcp/rawcc buffer are for writing and thus may require flushing. + Necessary to distinguish whether they need to be written to disk when + in mixed read/write mode and doing a mixture of writing followed by + reading. http://trac.osgeo.org/gdal/ticket/1758 + +2007-11-23 Andrey Kiselev + + * configure.com, libtiff/tif_vms.c: Better OpenVMS support. Patches + from Alexey Chupahin. + +2007-11-02 Frank Warmerdam + + * tif_write.c: Rip out the fancy logic in TIFFAppendToStrip() for + establishing if an existing tile can be rewritten to the same location + by comparing the current size to all the other blocks in the same + directory. This is dangerous in many situations and can easily + corrupt a file. (observed in esoteric GDAL situation that's hard to + document). This change involves leaving the stripbytecount[] values + unaltered till TIFFAppendToStrip(). Now we only write a block back + to the same location it used to be at if the new data is the same + size or smaller - otherwise we move it to the end of file. + + * tif_dirwrite.c: Try to avoid writing out a full readbuffer of tile + data when writing the directory just because we have BEENWRITING at + some point in the past. This was causing odd junk to be written out + in a tile of data when a single tile had an interleaving of reading + and writing with reading last. (highlighted by gdal + autotest/gcore/tif_write.py test 7. + + * tif_predict.c: use working buffer in PredictorEncodeTile to avoid + modifying callers buffer. + http://trac.osgeo.org/gdal/ticket/1965 + + * tif_predict.c/h: more fixes related to last item, keeping a + distinct pfunc for encode and decode cases as these were getting + mixed up sometimes. + http://trac.osgeo.org/gdal/ticket/1948 + +2007-11-01 Frank Warmerdam + + * tif_predict.c/h, tif_lzw.c, tif_zip.c: Improvements so that + predictor based encoding and decoding works in read-write update + mode properly. + http://trac.osgeo.org/gdal/ticket/1948 + +2007-10-24 Joris Van Damme + + * tif_dirread.c: Fixed problem with bogus file triggering + assert(td->td_planarconfig == PLANARCONFIG_CONTIG) in + ChopUpSingleUncompressedStrip + +2007-10-22 Joris Van Damme + + * tif_jpeg.c: Resolved buffer incrementation bug that lead to faulty images + at best, access violation at worst, when subsampled JPEG compressed imagery + is decoded without the JPEG_COLORMODE feature + +2007-10-11 Frank Warmerdam + + * html/index.html: Update "people responsible" section. + +2007-10-05 Frank Warmerdam + + * tools/tiff2pdf.c: Fix problem with alpha setting in some cases + as reported on the mailing list. + +2007-10-01 Joris Van Damme + + * changed some more incorrect %lud printf flags to %lu + +2007-09-29 Joris Van Damme + + * tif_dirread.c: Strip chopping interfered badly with uncompressed + subsampled images because it tried to divide subsampled rowblocks, + leading to all sorts of errors throughout the library for these + images. Fixed by making strip chopping divide in row counts that + are a multiple of vertical subsampling value. + +2007-09-28 Joris Van Damme + + * tif_dirread.c: Logical cast working around compiler warning + + * tif_read.c: Correction of some error flags and parameter lists + +2007-09-27 Joris Van Damme + + * tif_dirread.c: Made calculation of td_maxsamplevalue more robust + when dealing with large bitspersample values, shutting up purification + tools that warn about truncation, though it remains incorrect and + indicates a conceptual problem there. + + * tif_open.c: Moved early exit in case of 'h' flag (to disable reading + of first IFD) to proper place because it badly interfered with memory + mapping, resulting in mapping flag even with dummy mapping functions + that returned 0 whilst at the same time the mapping tif_size wasn't + set, thus resulting in continuous incorrect beyond-eof errors. + +2007-09-24 Joris Van Damme + + * tif_dirinfo.c: Fixed (MSVC) compiler reports about + inconsistent use of const in tiffFields and exifFields definition + +2007-09-20 Frank Warmerdam + + * tif_dirwrite.c: Always write tile/strip offsets and sizes + using LONG8 type when output format is BigTIFF. The + TIFFWriteDirectoryTagLongLong8Array() function was restructured + accordingly. + + * tif_dirread.c: Improvements to error reporting text in + TIFFFetchDirectory(). + +2007-09-19 Bob Friesenhahn + + * test/images: Added a small collection of test images for use by + test programs and scripts. + * test/tiffinfo.sh: A trivial example test script. + * test/common.sh: Added small script for setting the environment + used by script-based tests. + +2007-08-24 Frank Warmerdam + + * tif_dirwrite.c: Write the tif_nextdiroff value instead of a fixed + zero when writing directory contents to preserve the ability to + rewrite directories in place, even in the middle of a directory + chain. + + * tif_dirinfo.c: _TIFFMergeFields() now only merges in field + definitions that are missing. Existing definitions are silently + ignored. + + * tif_dirread.c: Add runtime error for fields for which no definition + is found (in addition to an assert for developers) in + TIFFFetchNormalTag(). Not sure if this is needed, but it seems + prudent. + +2007-08-10 Joris Van Damme + + * libtiff/tif_getimage.c: removed SubsamplingHor and SubsamplingVer + from _TIFFRGBAImage structure to revert unwanted ABI change. + +2007-08-10 Joris Van Damme + + * libtiff/tif_win32.c: use SetFilePointer instead of + SetFilePointerEx, as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1580 + +2007-07-19 Andrey Kiselev + + * libtiff/tif_stream.cxx: Put all callback functions declarations + inside extern "C" block. + + * libtiff/{tif_lzw.c, tif_luv.c, tif_dumpmode.c, tif_print.c, + tif_read.c, tif_strip.c, tif_thunder.c}: Use "%I64d" printf() + formatter instead of "%lld" with MSVC compiler. + + * libtiff/{tiffiop.h, tif_aux.c}: Added _TIFFUInt64ToFloat() and + _TIFFUInt64ToDouble() functions. + +2007-07-18 Andrey Kiselev + + * libtiff/tif_dirread.c: Handle the case of MSVC 6 when using 64-bit + integer constants. + + * libtiff/{Makefile.am, Makefile.v}: Do not distribute tiffconf.h, + remove tif_config.h/tiffconf.h during cleaning. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1573 + + * libtiff/tif_unix.c: Do not use O_LARGEFILE. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1577 + +2007-07-13 Andrey Kiselev + + * libtiff 4.0.0alpha released. + +2007-07-12 Andrey Kiselev + + * tools/tiff2pdf.c: Added missed extern optind as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1567 + + * libtiff/{tif_close.c, tif_dirinfo.c, tiffiop.c, tif_dirread.c, + tif_dir.h, tif_dir.c, tiffio.h}: Transition to the new-style tag + extending scheme completed. + +2007-07-11 Bob Friesenhahn + + * libtiff/tif_stream.cxx: Adapt to use toff_t again. Update to + use standard C++ library size types and attempt to detect overflow + cases. + +2007-07-08 Andrey Kiselev + + * libtiff/{tif_jpeg.c, tif_dir.h, tif_dir.c, tif_dirinfo.c, tiffio.h, + tif_ojpeg.c, tif_print.c, tif_fax3.c, tif_dirread.c}: More work on new + tag extending scheme. Use the new scheme everywhere. + + * libtiff/{tif_zip.c, tif_predict.c, tif_pixarlog.c, tif_luv.c, + tif_fax3.c, tif_dirread.c, tif_dirwrite.c, tif_close.c, tif_ojpeg.c, + tif_jpeg.c, tif_dirinfo.c, tif_dir.h, tiffio.h, tiffiop.h}: + TIFFFIeldInfo structure replaced with TIFFField structure. + TIFFFieldInfo retained for the backward compatibility. + +2007-07-05 Bob Friesenhahn + + * tools/tiff2pdf.c: Fix a compile problem when JPEG_SUPPORT is not + defined. + +2007-07-04 Andrey Kiselev + + * libtiff/{tif_dir.c, tiff.h, tiffio.h, libtiff.def}: Unused + TIFFReassignTagToIgnore() function and TIFFIgnoreSense enumeration + removed. + + * libtiff/{tif_dirinfo.c, tif_fax3.c, tif_jbig.c, tif_jpeg.c}: Move + tags TIFFTAG_FAXRECVPARAMS, TIFFTAG_FAXSUBADDRESS, + TIFFTAG_FAXRECVTIME and TIFFTAG_FAXDCS to the common tag directory. + These tags are not codec-specific and relate to image content, so + process them as other normal tags. + + * libtiff/{tiffio.h, tif_dir.h}: TIFFTagValue structure moved from the + public tiffio.h to private tif_dir.h. + + * contrib/{acorn, mac-cw, mac-mpw}: Removed as unmaintained and + outdated. + +2007-07-03 Andrey Kiselev + + * libtiff{tif_acorn.c, tif_apple.c, tif_atari.c, tif_msdos.c, + tif_win3.c}: Obsoleted portability stuff removed. + + * tools/tiff2ps.c: Added support 16-bit images as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1566 + + Patch from William Bader. + + * tools/tiff2pdf.c: Fix for TIFFTAG_JPEGTABLES tag fetching and + significant upgrade of the whole utility as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1560 + + Now we don't need tiffiop.h in tiff2pdf anymore and will open output + PDF file using TIFFClientOpen() machinery as it is implemented + by Leon Bottou. + +2007-06-26 Bob Friesenhahn + + * configure.ac: Fix typo when substituting value for unsigned 8 bit type. + Added support for a TIFF_PTRDIFF_T type to use when doing pointer arithmetic. + Added support for a TIFF_SSIZE_T in order to return memory sizes but still + allow returning -1 for errors. + * libtiff/tiffconf.vc.h: Add porting type defintions for WIN32. + +2007-06-25 Bob Friesenhahn + + * port/strtoull.c: New porting function in case strtoull() is not + available on the target system. + * configure.ac: Add configure support for determining sized types + in a portable way and performing necessary substitutions in + tif_config.h and tiffconf.h. Updated tiff.h to use the new + definitions. + +2007-04-27 Andrey Kiselev + + * tools/tiff2pdf.c: Check the tmpfile() return status as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=154 + +2007-04-07 Andrey Kiselev + + * libtiff/{tif_dir.h, tif_dirread.c, tif_dirinfo.c, tif_jpeg.c, + tif_fax3.c, tif_jbig.c, tif_luv.c, tif_ojpeg.c, tif_pixarlog.c, + tif_predict.c, tif_zip.c}: Finally fix bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1274 + + by introducing _TIFFMergeFieldInfo() returning integer error status + instead of void in case of problems with field merging (e.g., if the + field with such a tag already registered). TIFFMergeFieldInfo() in + public API remains void. Use _TIFFMergeFieldInfo() everywhere and + check returned value. + +2007-04-07 Frank Warmerdam + + * contrib/addtiffo/tif_overview.c: Fix problems with odd sized output + blocks in TIFF_DownSample_Subsampled() (bug 1542). + +2007-04-06 Frank Warmerdam + + * libtiff/tif_jpeg.c: Changed JPEGInitializeLibJPEG() so that it + will convert from decompressor to compressor or compress to decompress + if required by the force arguments. This works around a problem in + where the JPEGFixupTestSubsampling() may cause a decompressor to + be setup on a directory when later a compressor is required with the + force flag set. Occurs with the addtiffo program for instance. + +2007-04-06 Andrey Kiselev + + * tools/tiffcrop.c, man/tiffcrop.1: Significant update in + functionality from Richard Nolde. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1525 + +2007-03-28 Frank Warmerdam + + * libtiff/tif_fax3.c: "inline static" -> "static inline" for IRIC CC. + +2007-03-17 Joris Van Damme + + * start of BigTIFF upgrade - CVS HEAD unstable until further notice + +2007-03-07 Joris Van Damme + + * libtiff/tif_getimage.c: workaround for 'Fractional scanline' error reading + OJPEG images with rowsperstrip that is not a multiple of vertical subsampling + factor. This bug is mentioned in: + http://bugzilla.remotesensing.org/show_bug.cgi?id=1390 + http://www.asmail.be/msg0054766825.html + +2007-03-07 Joris Van Damme + + * libtiff/tif_win32.c: made inclusion of windows.h unconditional + + * libtiff/tif_win32.c: replaced preprocessor indication for consiously + unused arguments by standard C indication for the same + +2007-02-27 Andrey Kiselev + + * libtiff/tif_dirread.c: Use uint32 type instead of tsize_t in byte + counters in TIFFFetchData(). Should finally fix the issue + + http://bugzilla.remotesensing.org/show_bug.cgi?id=890 + +2007-02-24 Andrey Kiselev + + * tools/tiffset.c: Properly handle tags with TIFF_VARIABLE writecount. + As per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1350 + + * libtiff/tif_dirread.c: Added special function to handle + SubjectDistance EXIF tag as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1362 + + * tools/tiff2pdf.c: Do not assume inches when the resolution units + do not specified. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1366 + + * tools/{tiffcp.c, tiffcrop.c}: Do not change RowsPerStrip value if + it was set as infinite. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1368 + + * tools/tiffcrop.c, man/tiffcrop.1: New tiffcrop utility contributed + by Richard Nolde. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1383 + +2007-02-22 Andrey Kiselev + + * libtiff/tif_dir.c: Workaround for incorrect TIFFs with + ExtraSamples == 999 produced by Corel Draw. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1490 + + * libtiff/{tif_dirread.c, tif_read.c}: Type of the byte counters + changed from tsize_t to uint32 to be able to work with data arrays + larger than 2GB. Fixes bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=890 + + Idea submitted by Matt Hancher. + +2007-01-31 Andrey Kiselev + + * tools/tif2rgba.c: This utility does not work properly on big-endian + architectures. It was fixed including the bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1149 + +2007-01-15 Mateusz Loskot + + * Submitted libtiff port for Windows CE platform + * libtiff/tif_config.wince.h: Added configuration header for WinCE. + * libtiff/tiffconf.wince.h: Ported old configuration header for WinCE. + * libtiff/tif_wince.c: Added WinCE-specific implementation of some + functons from tif_win32.c. + * libtiff/tif_win32.c: Disabled some functions already reimplemented in tif_wince.c. + * libtiff/tiffiop.h, port/lfind.c: Added conditional include of some + standard header files for Windows CE build. + * tools/tiffinfoce.c: Ported tiffinfo utility for Windows CE. + +2006-11-19 Frank Warmerdam + + * libtiff/tif_write.c: TIFFAppendToStrip() - clear sorted flag if + we move a strip. + http://bugzilla.remotesensing.org/show_bug.cgi?id=1359 + +2006-10-13 Andrey Kiselev + + * libtiff/tif_dir.c: More fixes for vulnerabilities, reported + in Gentoo bug (): + + http://bugs.gentoo.org/show_bug.cgi?id=142383 + + * libtiff/contrib/dbs/xtiff/xtiff.c: Make xtiff utility compilable. + Though it is still far from the state of being working and useful. + +2006-10-12 Andrey Kiselev + + * libtiff/tif_fax3.c: Save the state of printdir codec dependent + method. + + * libtiff/tif_jpeg.c: Save the state of printdir codec dependent method + as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1273 + + * libtiff/tif_win32.c: Fixed problem with offset value manipulation + as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1322 + + * libtiff/{tif_read.c, tif_jpeg.c, tif_dir.c}: More fixes for + vulnerabilities, reported in Gentoo bug (): + + http://bugs.gentoo.org/show_bug.cgi?id=142383 + +2006-09-28 Andrey Kiselev + + * libtiff/{tif_fax3.c, tif_next.c, tif_pixarlog.c}: Fixed multiple + vulnerabilities, as per Gentoo bug (): + + http://bugs.gentoo.org/show_bug.cgi?id=142383 + +2006-09-27 Frank Warmerdam + + * libtiff/tif_lzw.c, libtiff/tif_zip.c: Fixed problems with mixing + encoding and decoding on the same read-write TIFF handle. The LZW + code can now maintain encode and decode state at the same time. The + ZIP code will switch back and forth as needed. + http://bugzilla.remotesensing.org/show_bug.cgi?id=757 + +2006-09-20 Frank Warmerdam + + * libtiff: Rename config.h.vc and tif_config.h.vc to config.vc.h and + tif_config.vc.h for easier identification by folks using an IDE. + +2006-07-25 Frank Warmerdam + + * tif_msdos.c: Avoid handle leak for failed opens. c/o Thierry Pierron + +2006-07-19 Frank Warmerdam + + * tif_dirwrite.c: take care not to flush out buffer of strip/tile + data in _TIFFWriteDirectory if TIFF_BEENWRITING not set. Relates + to bug report by Peng Gao with black strip at bottom of images. + +2006-07-12 Frank Warmerdam + + * tif_dirwrite.c: make sure to use uint32 for wordcount in + TIFFWriteNormanTag if writecount is VARIABLE2 for ASCII fields. + It already seems to have been done for other field types. Needed + for "tiffset" on files with geotiff ascii text. + +2006-07-04 Bob Friesenhahn + + * {configure.ac, libtiff/tif_config.h.vc, libtiff/tif_jbig.c} + (JBIGDecode): jbg_newlen is not available in older JBIG-KIT and + its use does not appear to be required, so use it only when it is + available. + +2006-06-24 Andrey Kiselev + + * libtiff/tif_dirinfo.c: Added missed EXIF tag ColorSpace (40961). + + * libtiff/tif_dirread.c: Move IFD fetching code in the separate + function TIFFFetchDirectory() avoiding code duplication in + TIFFReadDirectory() and TIFFReadCustomDirectory(). + +2006-06-19 Frank Warmerdam + + * tools/tiff2pdf.c: Fix handling of -q values. + http://bugzilla.remotesensing.org/show_bug.cgi?id=587 + +2006-06-17 Frank Warmerdam + + * tif_readdir.c: Added case in EstimateStripByteCounts() for tiled + files. Modified TIFFReadDirectory() to not invoke + EstimateStripByteCounts() for case where entry 0 and 1 are unequal + but one of them is zero. + http://bugzilla.remotesensing.org/show_bug.cgi?id=1204 + +2006-06-08 Andrey Kiselev + + * libtiff/{tif_open.c, tif_dirread.c, tiffiop.h}: Move IFD looping + checking code in the separate function TIFFCheckDirOffset(). + + * libtiff/tif_aux.c: Added _TIFFCheckRealloc() function. + + * tools/tiffcmp.c: Fixed floating point comparison logic as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1191 + + * libtiff/tif_fax3.c: Fixed problems in fax decoder as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1194 + + * tools/tiff2pdf.c: Fixed buffer overflow condition in + t2p_write_pdf_string() as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1196 + +2006-06-07 Andrey Kiselev + + * {configure, configure.ac, libtiff/tif_jbig.c, tools/tiffcp.c}: Added + support for JBIG compression scheme (34661 code) contributed by Lee + Howard. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=896 + + * configure, configure.ac: OJPEG support enabled by default. + + * contrib/ojpeg/: Removed. New OJPEG support does not need this patch. + +2006-06-03 Bob Friesenhahn + + * libtiff/{tif_dirinfo.c, tif_print.c} : Fix crash in + TIFFPrintDirectory(). Joris Van Damme authored the fix. + +2006-04-21 Andrey Kiselev + + * tools/tiff2pdf.c: Unified line ending characters (always use '\n') + as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1163 + + * README.vms, Makefile.am, configure.com, libtiff/{Makefile.am, + tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}: + Added support for OpenVMS by Alexey Chupahin, elvis_75@mail.ru. + +2006-04-20 Andrey Kiselev + + * tools/{fax2ps.c, fax2tiff.c, ppm2tiff.c, ras2tiff.c, tiff2pdf.c}: + Properly set the binary mode for stdin stream as per bug + http://bugzilla.remotesensing.org/show_bug.cgi?id=1141 + + * man/{bmp2tiff.1, fax2ps.1, fax2tiff.1, gif2tiff.1, ras2tiff.1, + raw2tiff.1, rgb2ycbcr.1, sgi2tiff.1, tiff2bw.1, tiff2pdf.1, tiff2ps.1, + tiff2rgba.1, tiffcmp.1, tiffcp.1, tiffdither.1, tiffdump.1, tiffgt.1, + tiffset.1}: Improvements in page formatting as per bug + http://bugzilla.remotesensing.org/show_bug.cgi?id=1140 + + * html/tools.html, html/man/Makefile.am, tools/tiff2pdf.c: Fixed + typos as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1139 + +2006-04-18 Frank Warmerdam + + * nmake.opt: use /EHsc for VS2005 compatibility. Also define + _CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005. + +2006-04-12 Joris Van Damme + + * libtiff/tif_getimage.c: Added support for planarconfig separate + non-subsampled YCbCr (i.e. separate YCbCr with subsampling [1,1]) + +2006-04-11 Joris Van Damme + + * libtiff/tif_getimage.c: Revision of all RGB(A) put routines + - Conversion of unassociated alpha to associated alpha now done with + more performant LUT, and calculation more correct + - Conversion of 16bit data to 8bit data now done with + more performant LUT, and calculation more correct + - Bugfix of handling of 16bit RGB with unassociated alpha + +2006-04-11 Joris Van Damme + + * libtiff/tif_getimage.c: + - When there is no alpha, gtTileSeparate and gtStripSeparate allocated + buffer for alpha strile and filled it, only to never read it back. + Removed allocation and fill. + - Minor rename of vars in gtTileSeparate and gtStripSeparate + anticipating planned functionality extension + +2006-04-08 Joris Van Damme + + * libtiff/tif_getimage.c: renamed pickTileContigCase to PickContigCase + and pickTileSeparateCase to PickSeparateCase as both work on strips as + well + + * libtiff/tif_getimage.c: moved img->get selection from + TIFFRGBAImageBegin into PickContigCase and PickSeparateCase to create + logical hook for planned functionality extension + +2006-04-08 Joris Van Damme + + * libtiff/tif_ojpeg.c: resolved memory leak that was a consequence + of inappropriate use of jpeg_abort instead of jpeg_destroy + +2006-04-07 Joris Van Damme + + * libtiff/tif_getimage.c: replaced usage of TIFFScanlineSize in + gtStripContig with TIFFNewScanlineSize so as to fix buggy behaviour + on subsampled images - this ought to get sorted when we feel brave + enough to replace TIFFScanlineSize alltogether + + * libtiff/tif_ojpeg.c: fixed bug in OJPEGReadSkip + +2006-04-04 Joris Van Damme + + * libtiff/tiffio.h: added new type tstrile_t + + * libtiff/tif_dir.h: changed types of td_stripsperimage and td_nstrips + to new tstrile_t, types of td_stripoffset and td_stripbytecount to + toff_t* + + * libtiff/tif_ojpeg.c: totally new implementation + + * libtiff/tif_dirread.c: added several hacks to suit new support of + OJPEG + + * libtiff/tif_getimage.c: removed TIFFTAG_JPEGCOLORMODE handling + of OJPEG images in favor of tif_getimage.c native handling of + YCbCr and desubsampling + +2006-03-29 Frank Warmerdam + + * libtiff/tif_jpeg.c: JPEGVSetField() so that altering the photometric + interpretation causes the "upsampled" flag to be recomputed. Fixes + peculiar bug where photometric flag had to be set before jpegcolormode + flag. + +2006-03-25 Joris Van Damme + + * libtiff/tif_jpeg.c: strip size related bugfix in encode raw + + * libtiff/tif_strip.c: temporarilly added two new versions of + TIFFScanlineSize + - TIFFNewScanlineSize: proposed new version, after all related + issues and side-effects are sorted out + - TIFFOldScanlineSize: old version, from prior to 2006-03-21 change + This needs further sorting out. + +2006-03-25 Joris Van Damme + + * contrib/addtiffo/tif_ovrcache.c: bugfix to correctly pass size + of last truncated strip data to TIFFWriteEncodedStrip + +2006-03-25 Joris Van Damme + + * libtiff/{tif_jpeg.c, tif_strip.c}: bugfix of tif_jpeg decode raw + +2006-03-25 Joris Van Damme + + * libtiff/tif_getimage.c: bugfix/rewrite of putcontig8bitYCbCr22tile + + * libtiff/tif_getimage.c: added putcontig8bitYCbCr12tile + + * libtiff/tif_read.c: added support for new TIFF_NOREADRAW flag to + prepare the path for new tif_ojpeg.c + 2006-03-23 Andrey Kiselev * libtiff 3.8.2 released. diff --git a/libs/tiff-4.0.2/HOWTO-RELEASE b/libs/tiff-4.0.2/HOWTO-RELEASE new file mode 100644 index 0000000000..418fce2324 --- /dev/null +++ b/libs/tiff-4.0.2/HOWTO-RELEASE @@ -0,0 +1,116 @@ +HOWTO-RELEASE: + +Notes on releasing. + +0. Make sure that you have current FSF releases of autoconf, automake, + and libtool packages installed under a common installation prefix + and that these tools are in your executable search path prior to + any other installed versions. Versions delivered with Linux may be + altered so it is best to install official FSF releases. GNU 'm4' + 1.4.6 or later is needed in order to avoid bugs in m4. These + packages may be downloaded from the following ftp locations: + + autoconf - ftp://ftp.gnu.org/pub/gnu/autoconf + automake - ftp://ftp.gnu.org/pub/gnu/automake + libtool - ftp://ftp.gnu.org/pub/gnu/libtool + + Release builds should only be done on a system with a functioning + and correctly set system clock and on a filesystem which accurately + records file update times. Use of GNU make is recommended. + +1. Commit any unsaved changes. + +2. Create html/vX.X.html. Take ChangeLog entries and html-ify in there. + Easist thing to do is take html/vX.(X-1).html and use it as a template. + Add that file to the list of EXTRA_DIST files in the html/Makefile.am. + +3. Update html/index.html to refer to this new page as the current release. + +4. Increment the release version in configure.ac. Put 'alpha' or + 'beta' after the version, if applicable. For example: + + 4.0.0 + or + 4.0.0beta7 + + Version should be updated in two places: in the second argument of the + AC_INIT macro and in LIBTIFF_xxx_VERSION variables. + +5. Update library ELF versioning in configure.ac (LIBTIFF_CURRENT, + LIBTIFF_REVISION, and LIBTIFF_AGE). These numbers have nothing to + do with the libtiff release version numbers. + + Note that as of libtiff 4.X, proper ELF versioning is used so + please follow the rules listed in configure.ac. At a bare minimum, + you should increment LIBTIFF_REVISION for each release so that + installed library files don't overwrite existing files. If APIs + have been added, removed, or interface structures have changed, + then more care is required. + +6. Add an entry to Changelog similar to: + + * libtiff 4.0.0 released. + +7. In the source tree do + + ./autogen.sh + + This step may be skipped if you have already been using a + maintainer build with current autoconf, automake, and libtool + packages. It is only needed when updating tool versions. + +8. It is recommended (but not required) to build outside of the source + tree so that the source tree is kept in a pristine state. This + also allows sharing the source directory on several networked + systems. For example: + + mkdir libtiff-build + cd libtiff-build + /path/to/libtiff/configure --enable-maintainer-mode + + otherwise do + + ./configure --enable-maintainer-mode + +9. In the build tree do + + make release + + This will update "RELEASE-DATE", "VERSION", and libtiff/tiffvers.h + in the source tree. + +10. In the source tree, verify that the version info in RELEASE-DATE, + VERSION and libtiff/tiffvers.h is right. + +11. In the build tree do + + make + make distcheck + + If 'make distcheck' fails, then correct any issues until it + succeeds. + + Two files with names tiff-version.tar.gz and tiff-version.zip will + be created in the top level build directory. + +12. In the source tree do + + 'cvs commit'. + +13. In the source tree do + + cvs tag Release-v4-0-0 + + (or the appropriate name for the release) + +14. Copy release packages from the build tree to the + ftp.remotesensing.org ftp site. + + scp tiff-*.tar.gz tiff-*.zip \ + warmerdam@upload.osgeo.org:/osgeo/download/libtiff + +15. Announce to list, tiff@lists.maptools.org + +16. Update libtiff page on freshmeat with new version announcement. + + diff --git a/libs/tiff-3.8.2/Makefile.am b/libs/tiff-4.0.2/Makefile.am similarity index 71% rename from libs/tiff-3.8.2/Makefile.am rename to libs/tiff-4.0.2/Makefile.am index 9ddf5210bd..8e93e3c3da 100644 --- a/libs/tiff-3.8.2/Makefile.am +++ b/libs/tiff-4.0.2/Makefile.am @@ -25,13 +25,14 @@ docdir = $(LIBTIFF_DOCDIR) -AUTOMAKE_OPTIONS = dist-zip foreign +AUTOMAKE_OPTIONS = 1.11 dist-zip foreign ACLOCAL_AMFLAGS = -I m4 docfiles = \ COPYRIGHT \ ChangeLog \ README \ + README.vms \ RELEASE-DATE \ TODO \ VERSION @@ -41,14 +42,18 @@ EXTRA_DIST = \ Makefile.vc \ SConstruct \ autogen.sh \ - nmake.opt + configure.com \ + nmake.opt \ + libtiff-4.pc.in dist_doc_DATA = $(docfiles) -SUBDIRS = port libtiff tools contrib test man html +SUBDIRS = port libtiff tools build contrib test man html release: - (rm -f RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > RELEASE-DATE) - (rm -f VERSION && echo $(LIBTIFF_VERSION) > VERSION) - (rm -f ./libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),' ./libtiff/tiffvers.h.in > ./libtiff/tiffvers.h) + (rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE) + (rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION) + (rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h) +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libtiff-4.pc diff --git a/libs/tiff-3.8.2/Makefile.vc b/libs/tiff-4.0.2/Makefile.vc similarity index 96% rename from libs/tiff-3.8.2/Makefile.vc rename to libs/tiff-4.0.2/Makefile.vc index 7ffefc2c32..0a5fcaa18d 100644 --- a/libs/tiff-3.8.2/Makefile.vc +++ b/libs/tiff-4.0.2/Makefile.vc @@ -1,4 +1,4 @@ -# $Id: Makefile.vc,v 1.5 2006/03/23 14:54:00 dron Exp $ +# $Id: Makefile.vc,v 1.7 2008-01-01 15:53:10 fwarmerdam Exp $ # # Copyright (C) 2004, Andrey Kiselev # @@ -56,4 +56,3 @@ clean: cd tools $(MAKE) /f Makefile.vc clean cd .. - diff --git a/libs/tiff-3.8.2/README b/libs/tiff-4.0.2/README similarity index 93% rename from libs/tiff-3.8.2/README rename to libs/tiff-4.0.2/README index c0e5521d8a..5f30f4ee50 100644 --- a/libs/tiff-3.8.2/README +++ b/libs/tiff-4.0.2/README @@ -1,13 +1,15 @@ -$Header: /cvs/maptools/cvsroot/libtiff/README,v 1.5 2004/10/30 13:44:45 dron Exp $ +$Header: /cvs/maptools/cvsroot/libtiff/README,v 1.7 2012-02-18 21:53:27 bfriesen Exp $ TIFF Software Distribution -------------------------- This file is just a placeholder; all the documentation is now in HTML in the html directory. To view the documentation point your -favorite WWW viewer at html/index.html; e.g. +favorite WWW viewer at html/index.html; - netscape html/index.html +e.g. + + firefox html/index.html If you don't have an HTML viewer then you can read the HTML source or fetch a PostScript version of this documentation from the directory diff --git a/libs/tiff-4.0.2/README.vms b/libs/tiff-4.0.2/README.vms new file mode 100644 index 0000000000..44d9663927 --- /dev/null +++ b/libs/tiff-4.0.2/README.vms @@ -0,0 +1,12 @@ +Dear OpenVMS user +to make this library, execute +$@CONFIGURE +$@BUILD + +Build process should be error and warning free. When process will be finished, +LIBTIFF$STRATUP.COM file containing all required definitions, will be created. +Please call it from system startup procedure or individual user procedure LOGIN.COM +To link software with libtiff, use TIFF:LIBTIFF.OPT + +best regards, +Alexey Chupahin, elvis_75@mail.ru diff --git a/libs/tiff-4.0.2/RELEASE-DATE b/libs/tiff-4.0.2/RELEASE-DATE new file mode 100644 index 0000000000..d32f7156c7 --- /dev/null +++ b/libs/tiff-4.0.2/RELEASE-DATE @@ -0,0 +1 @@ +20120615 diff --git a/libs/tiff-3.8.2/SConstruct b/libs/tiff-4.0.2/SConstruct similarity index 97% rename from libs/tiff-3.8.2/SConstruct rename to libs/tiff-4.0.2/SConstruct index 3285157bf4..984b09d5c5 100644 --- a/libs/tiff-3.8.2/SConstruct +++ b/libs/tiff-4.0.2/SConstruct @@ -1,4 +1,4 @@ -# $Id: SConstruct,v 1.2 2006/03/23 14:54:00 dron Exp $ +# $Id: SConstruct,v 1.4 2007-02-24 15:03:47 dron Exp $ # Tag Image File Format (TIFF) Software # @@ -76,7 +76,7 @@ Export([ 'env', 'idir_prefix', 'idir_lib', 'idir_bin', 'idir_inc', 'idir_doc' ]) # Now proceed to system feature checks target_cpu, target_vendor, target_kernel, target_os = \ - os.popen("./config.guess").readlines()[0].split("-") + os.popen("./config/config.guess").readlines()[0].split("-") def Define(context, key, have): import SCons.Conftest @@ -132,6 +132,7 @@ if target_os != 'cygwin' \ # Check for system headers conf.CheckCHeader('assert.h') conf.CheckCHeader('fcntl.h') +conf.CheckCHeader('io.h') conf.CheckCHeader('limits.h') conf.CheckCHeader('malloc.h') conf.CheckCHeader('search.h') @@ -145,6 +146,7 @@ conf.CheckFunc('memmove') conf.CheckFunc('memset') conf.CheckFunc('mmap') conf.CheckFunc('pow') +conf.CheckFunc('setmode') conf.CheckFunc('sqrt') conf.CheckFunc('strchr') conf.CheckFunc('strrchr') diff --git a/libs/tiff-3.8.2/TODO b/libs/tiff-4.0.2/TODO similarity index 85% rename from libs/tiff-3.8.2/TODO rename to libs/tiff-4.0.2/TODO index 6c58eb045d..121d93d563 100644 --- a/libs/tiff-3.8.2/TODO +++ b/libs/tiff-4.0.2/TODO @@ -1,4 +1,4 @@ -# $Header: /cvs/maptools/cvsroot/libtiff/TODO,v 1.6 2002/10/10 05:28:43 warmerda Exp $ +# $Header: /cvs/maptools/cvsroot/libtiff/TODO,v 1.6 2002-10-10 05:28:43 warmerda Exp $ o gif2tiff segaulting on selected images o tiffcmp read data by strip/tile instead of scanline diff --git a/libs/tiff-4.0.2/VERSION b/libs/tiff-4.0.2/VERSION new file mode 100644 index 0000000000..4d54daddb6 --- /dev/null +++ b/libs/tiff-4.0.2/VERSION @@ -0,0 +1 @@ +4.0.2 diff --git a/libs/tiff-3.8.2/autogen.sh b/libs/tiff-4.0.2/autogen.sh similarity index 77% rename from libs/tiff-3.8.2/autogen.sh rename to libs/tiff-4.0.2/autogen.sh index 1849c4a4d7..5633885062 100755 --- a/libs/tiff-3.8.2/autogen.sh +++ b/libs/tiff-4.0.2/autogen.sh @@ -1,6 +1,6 @@ #!/bin/sh set -x -#libtoolize --force --copy +libtoolize --force --copy aclocal -I ./m4 autoheader automake --foreign --add-missing --copy diff --git a/libs/tiff-3.8.2/contrib/acorn/Makefile.am b/libs/tiff-4.0.2/build/Makefile.am similarity index 90% rename from libs/tiff-3.8.2/contrib/acorn/Makefile.am rename to libs/tiff-4.0.2/build/Makefile.am index 3b5be71f88..48fe8b4e9a 100644 --- a/libs/tiff-3.8.2/contrib/acorn/Makefile.am +++ b/libs/tiff-4.0.2/build/Makefile.am @@ -1,6 +1,7 @@ +# # Tag Image File Format (TIFF) Software # -# Copyright (C) 2004, Andrey Kiselev +# Copyright (C) 2007, Andrey Kiselev # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided @@ -23,5 +24,7 @@ # Process this file with automake to produce Makefile.in. -EXTRA_DIST = Makefile.acorn ReadMe SetVars cleanlib convert install +EXTRA_DIST = README + +SUBDIRS = diff --git a/libs/tiff-4.0.2/build/README b/libs/tiff-4.0.2/build/README new file mode 100644 index 0000000000..f765efc85f --- /dev/null +++ b/libs/tiff-4.0.2/build/README @@ -0,0 +1,3 @@ +This directory contains scripts and tools needed to build libtiff library +and its utilities in various environments. + diff --git a/libs/tiff-3.8.2/config/compile b/libs/tiff-4.0.2/config/compile similarity index 100% rename from libs/tiff-3.8.2/config/compile rename to libs/tiff-4.0.2/config/compile diff --git a/libs/tiff-3.8.2/config/depcomp b/libs/tiff-4.0.2/config/depcomp similarity index 89% rename from libs/tiff-3.8.2/config/depcomp rename to libs/tiff-4.0.2/config/depcomp index 04701da536..ca5ea4e1ef 100755 --- a/libs/tiff-3.8.2/config/depcomp +++ b/libs/tiff-4.0.2/config/depcomp @@ -1,9 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2005-07-09.11 +scriptversion=2006-10-15.18 -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 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 @@ -91,7 +92,20 @@ 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" +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" stat=$? if test $stat -eq 0; then : else @@ -276,6 +290,46 @@ icc) rm -f "$tmpdepfile" ;; +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + 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 + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + 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'. @@ -288,13 +342,13 @@ tru64) 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 + # static library. This mechanism 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 + # compilations output dependencies 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 diff --git a/libs/tiff-3.8.2/config/missing b/libs/tiff-4.0.2/config/missing similarity index 90% rename from libs/tiff-3.8.2/config/missing rename to libs/tiff-4.0.2/config/missing index 894e786e16..1c8ff7049d 100755 --- a/libs/tiff-3.8.2/config/missing +++ b/libs/tiff-4.0.2/config/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2005-06-08.21 +scriptversion=2006-05-10.23 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. @@ -33,6 +33,8 @@ if test $# -eq 0; then fi run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. @@ -44,7 +46,7 @@ fi msg="missing on your system" -case "$1" in +case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= @@ -77,6 +79,7 @@ Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one 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 @@ -106,7 +109,7 @@ 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 +case $1 in lex|yacc) # Not GNU programs, they don't have --version. ;; @@ -135,7 +138,7 @@ esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. -case "$1" in +case $1 in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if @@ -164,7 +167,7 @@ WARNING: \`$1' is $msg. You should only need it if test -z "$files" && files="config.h" touch_files= for f in $files; do - case "$f" in + case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; @@ -192,8 +195,8 @@ WARNING: \`$1' is needed, but is $msg. 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'` + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else @@ -214,25 +217,25 @@ WARNING: \`$1' $msg. You should only need it if 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 + if test $# -ne 1; then eval LASTARG="\${$#}" - case "$LASTARG" in + case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi - if [ ! -f y.tab.h ]; then + if test ! -f y.tab.h; then echo >y.tab.h fi - if [ ! -f y.tab.c ]; then + if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; @@ -244,18 +247,18 @@ WARNING: \`$1' is $msg. You should only need it if 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 + if test $# -ne 1; then eval LASTARG="\${$#}" - case "$LASTARG" in + case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi - if [ ! -f lex.yy.c ]; then + if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; @@ -267,11 +270,9 @@ WARNING: \`$1' is $msg. You should only need it if \`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 + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then touch $file else test -z "$file" || exec >$file @@ -289,11 +290,17 @@ WARNING: \`$1' is $msg. You should only need it if 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'` + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 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` + 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 @@ -317,13 +324,13 @@ WARNING: \`$1' is $msg. You should only need it if fi firstarg="$1" if shift; then - case "$firstarg" in + case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac - case "$firstarg" in + case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 diff --git a/libs/tiff-3.8.2/config/mkinstalldirs b/libs/tiff-4.0.2/config/mkinstalldirs similarity index 98% rename from libs/tiff-3.8.2/config/mkinstalldirs rename to libs/tiff-4.0.2/config/mkinstalldirs index 259dbfcd35..ef7e16fdaf 100755 --- a/libs/tiff-3.8.2/config/mkinstalldirs +++ b/libs/tiff-4.0.2/config/mkinstalldirs @@ -1,7 +1,7 @@ #! /bin/sh # mkinstalldirs --- make directory hierarchy -scriptversion=2005-06-29.22 +scriptversion=2006-05-11.19 # Original author: Noah Friedman # Created: 1993-05-16 @@ -11,6 +11,9 @@ scriptversion=2005-06-29.22 # bugs to or send patches to # . +nl=' +' +IFS=" "" $nl" errstatus=0 dirmode= diff --git a/libs/tiff-3.8.2/configure.ac b/libs/tiff-4.0.2/configure.ac similarity index 53% rename from libs/tiff-3.8.2/configure.ac rename to libs/tiff-4.0.2/configure.ac index dc4676f4e6..5d13f32e05 100644 --- a/libs/tiff-3.8.2/configure.ac +++ b/libs/tiff-4.0.2/configure.ac @@ -24,17 +24,16 @@ dnl OF THIS SOFTWARE. dnl Process this file with autoconf to produce a configure script. -AC_PREREQ(2.59) -AC_INIT([LibTIFF Software], 3.8.2, [tiff@lists.maptools.org], tiff) +AC_PREREQ(2.63) +AC_INIT([LibTIFF Software],[4.0.2],[tiff@lists.maptools.org],[tiff]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(m4) AC_LANG(C) -CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" -CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" -LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" +AC_PROG_LIBTOOL +m4_include(m4/acinclude.m4) -dnl Compute the canonical target-system type variable -AC_CANONICAL_TARGET +dnl Compute the canonical host (run-time) system type variable +AC_CANONICAL_HOST AM_INIT_AUTOMAKE dnl Do not rebuild generated files every time @@ -42,26 +41,60 @@ AM_MAINTAINER_MODE dnl Versioning. dnl Don't fill the ALPHA_VERSION field, if not applicable. -LIBTIFF_MAJOR_VERSION=3 -LIBTIFF_MINOR_VERSION=8 +LIBTIFF_MAJOR_VERSION=4 +LIBTIFF_MINOR_VERSION=0 LIBTIFF_MICRO_VERSION=2 LIBTIFF_ALPHA_VERSION= LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION dnl This will be used with the 'make release' target LIBTIFF_RELEASE_DATE=`date +"%Y%m%d"` +dnl Libtool library revision control info +dnl See the libtool documentation under the heading "Libtool's versioning +dnl system" in order to understand the meaning of these fields +dnl +dnl current +dnl The most recent interface number that this library implements. +dnl revision +dnl The implementation number of the current interface. +dnl age +dnl The difference between the newest and oldest interfaces that +dnl this library implements. In other words, the library implements +dnl all the interface numbers in the range from number current - +dnl age to current. +dnl +dnl Here are a set of rules to help you update your library version +dnl information: +dnl +dnl 1. Start with version information of `0:0:0' for each libtool library. +dnl 2. Update the version information only immediately before a public +dnl release of your software. More frequent updates are unnecessary, and +dnl only guarantee that the current interface number gets larger faster. +dnl 3. If the library source code has changed at all since the last update, +dnl then increment revision (`c:r:a' becomes `c:r+1:a'). +dnl 4. If any interfaces have been added, removed, or changed since the last +dnl update, increment current, and set revision to 0. +dnl 5. If any interfaces have been added since the last public release, then +dnl increment age. +dnl 6. If any interfaces have been removed since the last public release, +dnl then set age to 0. +LIBTIFF_CURRENT=6 +LIBTIFF_REVISION=0 +LIBTIFF_AGE=1 +LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE + # This is a special hack for OpenBSD and MirOS systems. The dynamic linker # in OpenBSD uses some special semantics for shared libraries. Their soname # contains only two numbers, major and minor. # See http://bugzilla.remotesensing.org/show_bug.cgi?id=838 for details. -case "$target_os" in - openbsd* | mirbsd*) - LIBTIFF_VERSION_INFO=$LIBTIFF_MAJOR_VERSION$LIBTIFF_MINOR_VERSION:$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION:0 - ;; - *) - LIBTIFF_VERSION_INFO=$LIBTIFF_MAJOR_VERSION:$LIBTIFF_MINOR_VERSION:$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION - ;; -esac +#case "$host_os" in +# openbsd* | mirbsd*) +# LIBTIFF_VERSION_INFO=$LIBTIFF_MAJOR_VERSION$LIBTIFF_MINOR_VERSION:$LIBTIFF_MICRO_VERSION:0 +# ;; +# *) +# LIBTIFF_VERSION_INFO=$LIBTIFF_MAJOR_VERSION:$LIBTIFF_MINOR_VERSION:$LIBTIFF_MICRO_VERSION +# ;; +#esac AC_SUBST(LIBTIFF_MAJOR_VERSION) AC_SUBST(LIBTIFF_MINOR_VERSION) @@ -80,23 +113,66 @@ VL_PROG_CC_WARNINGS() AC_PROG_INSTALL AC_PROG_LN_S -AC_PROG_LIBTOOL -AC_LIBTOOL_WIN32_DLL + + +# Check if LD supports linker scripts, and define automake conditional +# HAVE_LD_VERSION_SCRIPT if so. This functionality is currently +# constrained to compilers using GNU ld on ELF systems or systems +# which provide an adequate emulation thereof. +AC_ARG_ENABLE([ld-version-script], + AS_HELP_STRING([--enable-ld-version-script], + [enable linker version script (default is disabled)]), + [have_ld_version_script=$enableval], [have_ld_version_script=no]) +if test "$have_ld_version_script" != no; then + AC_MSG_CHECKING([if LD -Wl,--version-script works]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" + cat > conftest.map < + #include + + int main() + { + if (strcasecmp("bla", "Bla")==0) exit(0); + else exit(2); + } +$! +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$IF (TMP .NE. %X10B90001) +$ THEN +$ HAVE_STRCASECMP=0 +$ GOTO NEXT1 +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_STRCASECMP=0 +$ GOTO NEXT1 +$ENDIF +$! +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$RUN TEST +$IF ($STATUS .NE. %X00000001) +$ THEN +$ HAVE_STRCASECMP=0 +$ ELSE +$ HAVE_STRCASECMP=1 +$ENDIF +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$NEXT1: +$IF (HAVE_STRCASECMP.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for strcasecmp ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for strcasecmp ... No" +$ENDIF +$! +$! + +$!"Checking for lfind " +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT + #include + + int main() + { + lfind((const void *)key, (const void *)NULL, (size_t *)NULL, + (size_t) 0, NULL); + } +$! +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$IF (TMP .NE. %X10B90001) +$ THEN +$ HAVE_LFIND=0 +$ GOTO NEXT2 +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_LFIND=0 +$ GOTO NEXT2 +$ ELSE +$ HAVE_LFIND=1 +$ENDIF +$! +$NEXT2: +$IF (HAVE_LFIND.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for lfind ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for lfind ... No" +$ENDIF +$! +$! +$!"Checking for correct zlib library " +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT + #include + #include + #include + int main() + { + printf("checking version zlib: %s\n",zlibVersion()); + } +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10B90001) +$ THEN +$ HAVE_ZLIB=0 +$ GOTO EXIT +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST,ZLIB:LIBZ/LIB +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_ZLIB=0 +$ GOTO EXIT +$ ELSE +$ HAVE_ZLIB=1 +$ENDIF +$IF (HAVE_ZLIB.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for correct zlib library ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for correct zlib library ... No" +$ WRITE SYS$OUTPUT "This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html" +$ENDIF +$RUN TEST +$! + +$DEL TEST.OBJ;* +$! Checking for JPEG ... +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(JPEG) SYS$INPUT + #include + #include + #include + #include + int main() + { + printf("checking version jpeg: %s\n",JVERSION); + jpeg_quality_scaling(0); + return 0; + } +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10B90001) +$ THEN +$ WRITE SYS$OUTPUT "Checking for static jpeg library ... No" +$ HAVE_JPEG=0 +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST,JPEG:LIBJPEG/LIB +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_JPEG=0 +$ ELSE +$ HAVE_JPEG=1 +$ENDIF +$IF (HAVE_JPEG.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for static jpeg library ... Yes" +$ JPEG_LIBRARY_PATH="JPEG:LIBJPEG/LIB" +$ RUN TEST +$ ELSE +$ WRITE SYS$OUTPUT "Checking for static jpeg library ... No" +$ENDIF +$! +$!"Checking for SHARED JPEG library " +$OPEN/WRITE OUT TEST.OPT +$WRITE OUT "SYS$SHARE:LIBJPEG$SHR/SHARE" +$WRITE OUT "ZLIB:LIBZ/LIB" +$CLOSE OUT +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST,TEST/OPT +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_JPEG_SHARED=0 +$ ELSE +$ HAVE_JPEG_SHARED=1 +$ENDIF +$IF (HAVE_JPEG_SHARED.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for shared jpeg library ... Yes" +$ JPEG_LIBRARY_PATH="SYS$SHARE:LIBJPEG$SHR/SHARE" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for shared jpeg library ... No" +$ENDIF +$! +$ IF ( (HAVE_JPEG_SHARED.EQ.0).AND.(HAVE_JPEG.EQ.0) ) +$ THEN +$ WRITE SYS$OUTPUT "No JPEG library installed. This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html" +$ GOTO EXIT +$ ENDIF +$! +$! +$! +$! Checking for X11 ... +$IF F$TRNLNM("DECW$INCLUDE") .NES. "" +$ THEN +$ WRITE SYS$OUTPUT "Checking for X11 ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for X11 ... No" +$ WRITE SYS$OUTPUT "This is fatal. Please install X11 software" +$ GOTO EXIT +$ENDIF +$! +$!WRITING BUILD FILES +$OPEN/WRITE OUT BUILD.COM +$ WRITE OUT "$set def [.port]" +$ WRITE OUT "$",MAKE +$ WRITE OUT "$set def [-.libtiff]" +$ WRITE OUT "$",MAKE +$ WRITE OUT "$set def [-.tools]" +$ WRITE OUT "$",MAKE +$ WRITE OUT "$set def [-]" +$ WRITE OUT "$cop [.PORT]LIBPORT.OLB [.LIBTIFF]LIBPORT.OLB" +$ WRITE OUT "$ CURRENT = F$ENVIRONMENT (""DEFAULT"") " +$ WRITE OUT "$TIFF=CURRENT" +$ WRITE OUT "$OPEN/WRITE OUTT LIBTIFF$STARTUP.COM" +$ WRITE OUT "$TIFF[F$LOCATE(""]"",TIFF),9]:="".LIBTIFF]""" +$ WRITE OUT "$WRITE OUTT ""DEFINE TIFF ","'","'","TIFF'"" " +$ WRITE OUT "$TIFF=CURRENT" +$ WRITE OUT "$TIFF[F$LOCATE(""]"",TIFF),7]:="".TOOLS]""" +$ WRITE OUT "$WRITE OUTT ""BMP2TIFF:==$", "'","'","TIFF'BMP2TIFF""" +$ WRITE OUT "$WRITE OUTT ""FAX2PS:==$", "'","'","TIFF'FAX2PS""" +$ WRITE OUT "$WRITE OUTT ""FAX2TIFF:==$", "'","'","TIFF'FAX2TIFF""" +$ WRITE OUT "$WRITE OUTT ""GIF2TIFF:==$", "'","'","TIFF'GIF2TIFF""" +$ WRITE OUT "$WRITE OUTT ""PAL2RGB:==$", "'","'","TIFF'PAL2RGB""" +$ WRITE OUT "$WRITE OUTT ""PPM2TIFF:==$", "'","'","TIFF'PPM2TIFF""" +$ WRITE OUT "$WRITE OUTT ""RAS2TIFF:==$", "'","'","TIFF'RAS2TIFF""" +$ WRITE OUT "$WRITE OUTT ""RAW2TIFF:==$", "'","'","TIFF'RAW2TIFF""" +$ WRITE OUT "$WRITE OUTT ""RGB2YCBCR:==$", "'","'","TIFF'RGB2YCBCR""" +$ WRITE OUT "$WRITE OUTT ""THUMBNAIL:==$", "'","'","TIFF'THUMBNAIL""" +$ WRITE OUT "$WRITE OUTT ""TIFF2BW:==$", "'","'","TIFF'TIFF2BW""" +$ WRITE OUT "$WRITE OUTT ""TIFF2PDF:==$", "'","'","TIFF'TIFF2PDF""" +$ WRITE OUT "$WRITE OUTT ""TIFF2PS:==$", "'","'","TIFF'TIFF2PS""" +$ WRITE OUT "$WRITE OUTT ""TIFF2RGBA:==$", "'","'","TIFF'TIFF2RGBA""" +$ WRITE OUT "$WRITE OUTT ""TIFFCMP:==$", "'","'","TIFF'TIFFCMP""" +$ WRITE OUT "$WRITE OUTT ""TIFFCP:==$", "'","'","TIFF'TIFFCP""" +$ WRITE OUT "$WRITE OUTT ""TIFFDITHER:==$", "'","'","TIFF'TIFFDITHER""" +$ WRITE OUT "$WRITE OUTT ""TIFFDUMP:==$", "'","'","TIFF'TIFFDUMP""" +$ WRITE OUT "$WRITE OUTT ""TIFFINFO:==$", "'","'","TIFF'TIFFINFO""" +$ WRITE OUT "$WRITE OUTT ""TIFFMEDIAN:==$", "'","'","TIFF'TIFFMEDIAN""" +$ WRITE OUT "$WRITE OUTT ""TIFFCROP:==$", "'","'","TIFF'TIFFCROP""" +$ WRITE OUT "$WRITE OUTT ""TIFFSET:==$", "'","'","TIFF'TIFFSET""" +$ WRITE OUT "$CLOSE OUTT" +$ WRITE OUT "$OPEN/WRITE OUTT [.LIBTIFF]LIBTIFF.OPT" +$ WRITE OUT "$WRITE OUTT ""TIFF:TIFF/LIB"" +$ WRITE OUT "$WRITE OUTT ""TIFF:LIBPORT/LIB"" +$ WRITE OUT "$WRITE OUTT ""JPEG:LIBJPEG/LIB"" +$ WRITE OUT "$WRITE OUTT ""ZLIB:LIBZ/LIB"" +$ WRITE OUT "$CLOSE OUTT" +$! +$ WRITE OUT "$WRITE SYS$OUTPUT "" "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""LIBTIFF$STARTUP.COM has been created. "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""This file setups all logicals needed. It should be execute before using LibTIFF "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""Nice place to call it - LOGIN.COM "" " +$ WRITE OUT "$WRITE SYS$OUTPUT """" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""Using the library:"" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""CC/INC=TIFF ASCII_TAG.C"" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""LINK ASCII_TAG,TIFF:LIBTIFF/OPT"" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" " +$CLOSE OUT +$! +$! DESCRIP.MMS in [.PORT] +$OBJ="dummy.obj" +$IF HAVE_STRCASECMP.NE.1 +$ THEN +$ OBJ=OBJ+",strcasecmp.obj" +$ENDIF +$IF HAVE_LFIND.NE.1 +$ THEN +$ OBJ=OBJ+",lfind.obj" +$ENDIF +$OPEN/WRITE OUT [.PORT]DESCRIP.MMS +$WRITE OUT "OBJ=",OBJ +$WRITE OUT "" +$WRITE OUT "LIBPORT.OLB : $(OBJ)" +$WRITE OUT " LIB/CREA LIBPORT $(OBJ)" +$WRITE OUT "" +$WRITE OUT "" +$WRITE OUT "dummy.obj : dummy.c" +$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" +$WRITE OUT "" +$WRITE OUT "" +$WRITE OUT "strcasecmp.obj : strcasecmp.c" +$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" +$WRITE OUT "" +$WRITE OUT "" +$WRITE OUT "lfind.obj : lfind.c" +$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" +$WRITE OUT "" +$WRITE OUT "" +$CLOSE OUT +$! +$! +$WRITE SYS$OUTPUT "Creating LIBTIFF$DEF.OPT" +$IF (SHARED.EQ.64) +$ THEN +$ COPY SYS$INPUT TIFF$DEF.OPT +SYMBOL_VECTOR= (- +TIFFOpen=PROCEDURE,- +TIFFGetVersion=PROCEDURE,- +TIFFCleanup=PROCEDURE,- +TIFFClose=PROCEDURE,- +TIFFFlush=PROCEDURE,- +TIFFFlushData=PROCEDURE,- +TIFFGetField=PROCEDURE,- +TIFFVGetField=PROCEDURE,- +TIFFGetFieldDefaulted=PROCEDURE,- +TIFFVGetFieldDefaulted=PROCEDURE,- +TIFFGetTagListEntry=PROCEDURE,- +TIFFGetTagListCount=PROCEDURE,- +TIFFReadDirectory=PROCEDURE,- +TIFFScanlineSize=PROCEDURE,- +TIFFStripSize=PROCEDURE,- +TIFFVStripSize=PROCEDURE,- +TIFFRawStripSize=PROCEDURE,- +TIFFTileRowSize=PROCEDURE,- +TIFFTileSize=PROCEDURE,- +TIFFVTileSize=PROCEDURE,- +TIFFFileno=PROCEDURE,- +TIFFSetFileno=PROCEDURE,- +TIFFGetMode=PROCEDURE,- +TIFFIsTiled=PROCEDURE,- +TIFFIsByteSwapped=PROCEDURE,- +TIFFIsBigEndian=PROCEDURE,- +TIFFIsMSB2LSB=PROCEDURE,- +TIFFIsUpSampled=PROCEDURE,- +TIFFCIELabToRGBInit=PROCEDURE,- +TIFFCIELabToXYZ=PROCEDURE,- +TIFFXYZToRGB=PROCEDURE,- +TIFFYCbCrToRGBInit=PROCEDURE,- +TIFFYCbCrtoRGB=PROCEDURE,- +TIFFCurrentRow=PROCEDURE,- +TIFFCurrentDirectory=PROCEDURE,- +TIFFCurrentStrip=PROCEDURE,- +TIFFCurrentTile=PROCEDURE,- +TIFFDataWidth=PROCEDURE,- +TIFFReadBufferSetup=PROCEDURE,- +TIFFWriteBufferSetup=PROCEDURE,- +TIFFSetupStrips=PROCEDURE,- +TIFFLastDirectory=PROCEDURE,- +TIFFSetDirectory=PROCEDURE,- +TIFFSetSubDirectory=PROCEDURE,- +TIFFUnlinkDirectory=PROCEDURE,- +TIFFSetField=PROCEDURE,- +TIFFVSetField=PROCEDURE,- +TIFFCheckpointDirectory=PROCEDURE,- +TIFFWriteDirectory=PROCEDURE,- +TIFFRewriteDirectory=PROCEDURE,- +TIFFPrintDirectory=PROCEDURE,- +TIFFReadScanline=PROCEDURE,- +TIFFWriteScanline=PROCEDURE,- +TIFFReadRGBAImage=PROCEDURE,- +TIFFReadRGBAImageOriented=PROCEDURE,- +TIFFFdOpen=PROCEDURE,- +TIFFClientOpen=PROCEDURE,- +TIFFFileName=PROCEDURE,- +TIFFError=PROCEDURE,- +TIFFErrorExt=PROCEDURE,- +TIFFWarning=PROCEDURE,- +TIFFWarningExt=PROCEDURE,- +TIFFSetErrorHandler=PROCEDURE,- +TIFFSetErrorHandlerExt=PROCEDURE,- +TIFFSetWarningHandler=PROCEDURE,- +TIFFSetWarningHandlerExt=PROCEDURE,- +TIFFComputeTile=PROCEDURE,- +TIFFCheckTile=PROCEDURE,- +TIFFNumberOfTiles=PROCEDURE,- +TIFFReadTile=PROCEDURE,- +TIFFWriteTile=PROCEDURE,- +TIFFComputeStrip=PROCEDURE,- +TIFFNumberOfStrips=PROCEDURE,- +TIFFRGBAImageBegin=PROCEDURE,- +TIFFRGBAImageGet=PROCEDURE,- +TIFFRGBAImageEnd=PROCEDURE,- +TIFFReadEncodedStrip=PROCEDURE,- +TIFFReadRawStrip=PROCEDURE,- +TIFFReadEncodedTile=PROCEDURE,- +TIFFReadRawTile=PROCEDURE,- +TIFFReadRGBATile=PROCEDURE,- +TIFFReadRGBAStrip=PROCEDURE,- +TIFFWriteEncodedStrip=PROCEDURE,- +TIFFWriteRawStrip=PROCEDURE,- +TIFFWriteEncodedTile=PROCEDURE,- +TIFFWriteRawTile=PROCEDURE,- +TIFFSetWriteOffset=PROCEDURE,- +TIFFSwabDouble=PROCEDURE,- +TIFFSwabShort=PROCEDURE,- +TIFFSwabLong=PROCEDURE,- +TIFFSwabArrayOfShort=PROCEDURE,- +TIFFSwabArrayOfLong=PROCEDURE,- +TIFFSwabArrayOfDouble=PROCEDURE,- +TIFFSwabArrayOfTriples=PROCEDURE,- +TIFFReverseBits=PROCEDURE,- +TIFFGetBitRevTable=PROCEDURE,- +TIFFDefaultStripSize=PROCEDURE,- +TIFFDefaultTileSize=PROCEDURE,- +TIFFRasterScanlineSize=PROCEDURE,- +_TIFFmalloc=PROCEDURE,- +_TIFFrealloc=PROCEDURE,- +_TIFFfree=PROCEDURE,- +_TIFFmemset=PROCEDURE,- +_TIFFmemcpy=PROCEDURE,- +_TIFFmemcmp=PROCEDURE,- +TIFFCreateDirectory=PROCEDURE,- +TIFFSetTagExtender=PROCEDURE,- +TIFFMergeFieldInfo=PROCEDURE,- +TIFFFindFieldInfo=PROCEDURE,- +TIFFFindFieldInfoByName=PROCEDURE,- +TIFFFieldWithName=PROCEDURE,- +TIFFFieldWithTag=PROCEDURE,- +TIFFCurrentDirOffset=PROCEDURE,- +TIFFWriteCheck=PROCEDURE,- +TIFFRGBAImageOK=PROCEDURE,- +TIFFNumberOfDirectories=PROCEDURE,- +TIFFSetFileName=PROCEDURE,- +TIFFSetClientdata=PROCEDURE,- +TIFFSetMode=PROCEDURE,- +TIFFClientdata=PROCEDURE,- +TIFFGetReadProc=PROCEDURE,- +TIFFGetWriteProc=PROCEDURE,- +TIFFGetSeekProc=PROCEDURE,- +TIFFGetCloseProc=PROCEDURE,- +TIFFGetSizeProc=PROCEDURE,- +TIFFGetMapFileProc=PROCEDURE,- +TIFFGetUnmapFileProc=PROCEDURE,- +TIFFIsCODECConfigured=PROCEDURE,- +TIFFGetConfiguredCODECs=PROCEDURE,- +TIFFFindCODEC=PROCEDURE,- +TIFFRegisterCODEC=PROCEDURE,- +TIFFUnRegisterCODEC=PROCEDURE,- +TIFFFreeDirectory=PROCEDURE,- +TIFFReadCustomDirectory=PROCEDURE,- +TIFFReadEXIFDirectory=PROCEDURE,- +TIFFAccessTagMethods=PROCEDURE,- +TIFFGetClientInfo=PROCEDURE,- +TIFFSetClientInfo=PROCEDURE,- +TIFFReassignTagToIgnore=PROCEDURE- +) + +$ENDIF +$IF (SHARED.EQ.32) +$ THEN +$ COPY SYS$INPUT TIFF$DEF.OPT +UNIVERSAL=TIFFOpen +UNIVERSAL=TIFFGetVersion +UNIVERSAL=TIFFCleanup +UNIVERSAL=TIFFClose +UNIVERSAL=TIFFFlush +UNIVERSAL=TIFFFlushData +UNIVERSAL=TIFFGetField +UNIVERSAL=TIFFVGetField +UNIVERSAL=TIFFGetFieldDefaulted +UNIVERSAL=TIFFVGetFieldDefaulted +UNIVERSAL=TIFFGetTagListEntry +UNIVERSAL=TIFFGetTagListCount +UNIVERSAL=TIFFReadDirectory +UNIVERSAL=TIFFScanlineSize +UNIVERSAL=TIFFStripSize +UNIVERSAL=TIFFVStripSize +UNIVERSAL=TIFFRawStripSize +UNIVERSAL=TIFFTileRowSize +UNIVERSAL=TIFFTileSize +UNIVERSAL=TIFFVTileSize +UNIVERSAL=TIFFFileno +UNIVERSAL=TIFFSetFileno +UNIVERSAL=TIFFGetMode +UNIVERSAL=TIFFIsTiled +UNIVERSAL=TIFFIsByteSwapped +UNIVERSAL=TIFFIsBigEndian +UNIVERSAL=TIFFIsMSB2LSB +UNIVERSAL=TIFFIsUpSampled +UNIVERSAL=TIFFCIELabToRGBInit +UNIVERSAL=TIFFCIELabToXYZ +UNIVERSAL=TIFFXYZToRGB +UNIVERSAL=TIFFYCbCrToRGBInit +UNIVERSAL=TIFFYCbCrtoRGB +UNIVERSAL=TIFFCurrentRow +UNIVERSAL=TIFFCurrentDirectory +UNIVERSAL=TIFFCurrentStrip +UNIVERSAL=TIFFCurrentTile +UNIVERSAL=TIFFDataWidth +UNIVERSAL=TIFFReadBufferSetup +UNIVERSAL=TIFFWriteBufferSetup +UNIVERSAL=TIFFSetupStrips +UNIVERSAL=TIFFLastDirectory +UNIVERSAL=TIFFSetDirectory +UNIVERSAL=TIFFSetSubDirectory +UNIVERSAL=TIFFUnlinkDirectory +UNIVERSAL=TIFFSetField +UNIVERSAL=TIFFVSetField +UNIVERSAL=TIFFCheckpointDirectory +UNIVERSAL=TIFFWriteDirectory +UNIVERSAL=TIFFRewriteDirectory +UNIVERSAL=TIFFPrintDirectory +UNIVERSAL=TIFFReadScanline +UNIVERSAL=TIFFWriteScanline +UNIVERSAL=TIFFReadRGBAImage +UNIVERSAL=TIFFReadRGBAImageOriented +UNIVERSAL=TIFFFdOpen +UNIVERSAL=TIFFClientOpen +UNIVERSAL=TIFFFileName +UNIVERSAL=TIFFError +UNIVERSAL=TIFFErrorExt +UNIVERSAL=TIFFWarning +UNIVERSAL=TIFFWarningExt +UNIVERSAL=TIFFSetErrorHandler +UNIVERSAL=TIFFSetErrorHandlerExt +UNIVERSAL=TIFFSetWarningHandler +UNIVERSAL=TIFFSetWarningHandlerExt +UNIVERSAL=TIFFComputeTile +UNIVERSAL=TIFFCheckTile +UNIVERSAL=TIFFNumberOfTiles +UNIVERSAL=TIFFReadTile +UNIVERSAL=TIFFWriteTile +UNIVERSAL=TIFFComputeStrip +UNIVERSAL=TIFFNumberOfStrips +UNIVERSAL=TIFFRGBAImageBegin +UNIVERSAL=TIFFRGBAImageGet +UNIVERSAL=TIFFRGBAImageEnd +UNIVERSAL=TIFFReadEncodedStrip +UNIVERSAL=TIFFReadRawStrip +UNIVERSAL=TIFFReadEncodedTile +UNIVERSAL=TIFFReadRawTile +UNIVERSAL=TIFFReadRGBATile +UNIVERSAL=TIFFReadRGBAStrip +UNIVERSAL=TIFFWriteEncodedStrip +UNIVERSAL=TIFFWriteRawStrip +UNIVERSAL=TIFFWriteEncodedTile +UNIVERSAL=TIFFWriteRawTile +UNIVERSAL=TIFFSetWriteOffset +UNIVERSAL=TIFFSwabDouble +UNIVERSAL=TIFFSwabShort +UNIVERSAL=TIFFSwabLong +UNIVERSAL=TIFFSwabArrayOfShort +UNIVERSAL=TIFFSwabArrayOfLong +UNIVERSAL=TIFFSwabArrayOfDouble +UNIVERSAL=TIFFSwabArrayOfTriples +UNIVERSAL=TIFFReverseBits +UNIVERSAL=TIFFGetBitRevTable +UNIVERSAL=TIFFDefaultStripSize +UNIVERSAL=TIFFDefaultTileSize +UNIVERSAL=TIFFRasterScanlineSize +UNIVERSAL=_TIFFmalloc +UNIVERSAL=_TIFFrealloc +UNIVERSAL=_TIFFfree +UNIVERSAL=_TIFFmemset +UNIVERSAL=_TIFFmemcpy +UNIVERSAL=_TIFFmemcmp +UNIVERSAL=TIFFCreateDirectory +UNIVERSAL=TIFFSetTagExtender +UNIVERSAL=TIFFMergeFieldInfo +UNIVERSAL=TIFFFindFieldInfo +UNIVERSAL=TIFFFindFieldInfoByName +UNIVERSAL=TIFFFieldWithName +UNIVERSAL=TIFFFieldWithTag +UNIVERSAL=TIFFCurrentDirOffset +UNIVERSAL=TIFFWriteCheck +UNIVERSAL=TIFFRGBAImageOK +UNIVERSAL=TIFFNumberOfDirectories +UNIVERSAL=TIFFSetFileName +UNIVERSAL=TIFFSetClientdata +UNIVERSAL=TIFFSetMode +UNIVERSAL=TIFFClientdata +UNIVERSAL=TIFFGetReadProc +UNIVERSAL=TIFFGetWriteProc +UNIVERSAL=TIFFGetSeekProc +UNIVERSAL=TIFFGetCloseProc +UNIVERSAL=TIFFGetSizeProc +UNIVERSAL=TIFFGetMapFileProc +UNIVERSAL=TIFFGetUnmapFileProc +UNIVERSAL=TIFFIsCODECConfigured +UNIVERSAL=TIFFGetConfiguredCODECs +UNIVERSAL=TIFFFindCODEC +UNIVERSAL=TIFFRegisterCODEC +UNIVERSAL=TIFFUnRegisterCODEC +UNIVERSAL=TIFFFreeDirectory +UNIVERSAL=TIFFReadCustomDirectory +UNIVERSAL=TIFFReadEXIFDirectory +UNIVERSAL=TIFFAccessTagMethods +UNIVERSAL=TIFFGetClientInfo +UNIVERSAL=TIFFSetClientInfo +UNIVERSAL=TIFFReassignTagToIgnore + +$ENDIF +$! +$! +$! Writing TIFF$SHR.OPT file to build TOOLS +$ IF (SHARED.GT.0) +$ THEN +$ OPEN/WRITE OUT TIFF$SHR.OPT +$ WRITE OUT "[]TIFF/LIB" +$ WRITE OUT "[-.PORT]LIBPORT/LIB" +$ WRITE OUT JPEG_LIBRARY_PATH +$ WRITE OUT "ZLIB:LIBZ/LIB" +$ CLOSE OUT +$ ENDIF +$! +$! +$! Writing OPT.OPT file to build TOOLS +$OPEN/WRITE OUT OPT.OPT +$ IF (SHARED.GT.0) +$ THEN +$ WRITE OUT "[-.LIBTIFF]TIFF$SHR/SHARE" +$ WRITE OUT JPEG_LIBRARY_PATH +$ ELSE +$ WRITE OUT "[-.LIBTIFF]TIFF/LIB" +$ WRITE OUT "[-.PORT]LIBPORT/LIB" +$ WRITE OUT JPEG_LIBRARY_PATH +$ ENDIF +$ WRITE OUT "ZLIB:LIBZ/LIB" +$CLOSE OUT +$! +$! +$COPY SYS$INPUT [.LIBTIFF]DESCRIP.MMS +# (c) Alexey Chupahin 22-NOV-2007 +# OpenVMS 7.3-1, DEC 2000 mod.300 +# OpenVMS 8.3, HP rx1620 +# Makefile for DEC C compilers. +# + +INCL = /INCLUDE=(JPEG,ZLIB,[]) + +CFLAGS = $(INCL) + +OBJ_SYSDEP_MODULE = tif_vms.obj + +OBJ = \ +tif_aux.obj,\ +tif_close.obj,\ +tif_codec.obj,\ +tif_color.obj,\ +tif_compress.obj,\ +tif_dir.obj,\ +tif_dirinfo.obj,\ +tif_dirread.obj,\ +tif_dirwrite.obj,\ +tif_dumpmode.obj,\ +tif_error.obj,\ +tif_extension.obj,\ +tif_fax3.obj,\ +tif_fax3sm.obj,\ +tif_flush.obj,\ +tif_getimage.obj,\ +tif_jbig.obj,\ +tif_jpeg.obj,\ +tif_luv.obj,\ +tif_lzw.obj,\ +tif_next.obj,\ +tif_ojpeg.obj,\ +tif_open.obj,\ +tif_packbits.obj,\ +tif_pixarlog.obj,\ +tif_predict.obj,\ +tif_print.obj,\ +tif_read.obj,\ +tif_strip.obj,\ +tif_swab.obj,\ +tif_thunder.obj,\ +tif_tile.obj,\ +tif_version.obj,\ +tif_warning.obj,\ +tif_write.obj,\ +tif_zip.obj, $(OBJ_SYSDEP_MODULE) + +$IF (SHARED.GT.0) +$ THEN +$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS +ALL : tiff.olb, tiff$shr.exe + $WRITE SYS$OUTPUT "Done" + +tiff$shr.exe : tiff.olb + LINK/SHARE=TIFF$SHR.EXE TIF_AUX,[-]TIFF$DEF/OPT, [-]TIFF$SHR/OPT + COPY TIFF$SHR.EXE SYS$SHARE + PURGE SYS$SHARE:TIFF$SHR.EXE + +$ ELSE +$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS +ALL : tiff.olb + $WRITE SYS$OUTPUT "Done" + +$ENDIF +$! +$! +$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS + +tiff.olb : $(OBJ) + lib/crea tiff.olb $(OBJ) + +#tif_config.h : tif_config.h-vms +# copy tif_config.h-vms tif_config.h +# +#tiffconf.h : tiffconf.h-vms +# copy tiffconf.h-vms tiffconf.h + +tif_aux.obj : tif_aux.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_close.obj : tif_close.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_codec.obj : tif_codec.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_color.obj : tif_color.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_compress.obj : tif_compress.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dir.obj : tif_dir.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dirinfo.obj : tif_dirinfo.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dirread.obj : tif_dirread.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dirwrite.obj : tif_dirwrite.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dumpmode.obj : tif_dumpmode.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_error.obj : tif_error.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_extension.obj : tif_extension.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_fax3.obj : tif_fax3.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_fax3sm.obj : tif_fax3sm.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_flush.obj : tif_flush.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_getimage.obj : tif_getimage.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_jbig.obj : tif_jbig.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_jpeg.obj : tif_jpeg.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_luv.obj : tif_luv.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_lzw.obj : tif_lzw.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_next.obj : tif_next.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_ojpeg.obj : tif_ojpeg.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_open.obj : tif_open.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_packbits.obj : tif_packbits.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_pixarlog.obj : tif_pixarlog.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_predict.obj : tif_predict.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_print.obj : tif_print.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_read.obj : tif_read.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_strip.obj : tif_strip.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_swab.obj : tif_swab.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_thunder.obj : tif_thunder.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_tile.obj : tif_tile.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_unix.obj : tif_unix.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_version.obj : tif_version.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_warning.obj : tif_warning.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_write.obj : tif_write.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_zip.obj : tif_zip.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + + +clean : + del *.obj;* + del *.olb;* +$! +$! +$! +$COPY SYS$INPUT [.TOOLS]DESCRIP.MMS +# (c) Alexey Chupahin 22-NOV-2007 +# OpenVMS 7.3-1, DEC 2000 mod.300 +# OpenVMS 8.3, HP rx1620 + +INCL = /INCL=([],[-.LIBTIFF]) +CFLAGS = $(INCL) +LIBS = [-]OPT/OPT + +OBJ=\ +bmp2tiff.exe,\ +fax2ps.exe,\ +fax2tiff.exe,\ +gif2tiff.exe,\ +pal2rgb.exe,\ +ppm2tiff.exe,\ +ras2tiff.exe,\ +raw2tiff.exe,\ +rgb2ycbcr.exe,\ +thumbnail.exe,\ +tiff2bw.exe,\ +tiff2pdf.exe,\ +tiff2ps.exe,\ +tiff2rgba.exe,\ +tiffcmp.exe,\ +tiffcp.exe,\ +tiffcrop.exe,\ +tiffdither.exe,\ +tiffdump.exe,\ +tiffinfo.exe,\ +tiffmedian.exe,\ +tiffset.exe,\ +tiffsplit.exe,\ +ycbcr.exe + + +all : $(OBJ) + $! + +bmp2tiff.obj : bmp2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +bmp2tiff.exe : bmp2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +fax2ps.obj : fax2ps.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +fax2ps.exe : fax2ps.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +fax2tiff.obj : fax2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +fax2tiff.exe : fax2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +gif2tiff.obj : gif2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +gif2tiff.exe : gif2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +pal2rgb.obj : pal2rgb.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +pal2rgb.exe : pal2rgb.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +ppm2tiff.obj : ppm2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +ppm2tiff.exe : ppm2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +ras2tiff.obj : ras2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +ras2tiff.exe : ras2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +raw2tiff.obj : raw2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +raw2tiff.exe : raw2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +rgb2ycbcr.obj : rgb2ycbcr.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +rgb2ycbcr.exe : rgb2ycbcr.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +sgi2tiff.obj : sgi2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +sgi2tiff.exe : sgi2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +sgisv.obj : sgisv.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +sgisv.exe : sgisv.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +thumbnail.obj : thumbnail.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +thumbnail.exe : thumbnail.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2bw.obj : tiff2bw.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2bw.exe : tiff2bw.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2pdf.obj : tiff2pdf.c + $(CC) $(CFLAGS) /NOWARN $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2pdf.exe : tiff2pdf.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2ps.obj : tiff2ps.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2ps.exe : tiff2ps.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2rgba.obj : tiff2rgba.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2rgba.exe : tiff2rgba.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffcmp.obj : tiffcmp.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffcmp.exe : tiffcmp.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffcp.obj : tiffcp.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffcp.exe : tiffcp.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffcrop.obj : tiffcrop.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffcrop.exe : tiffcrop.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffdither.obj : tiffdither.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffdither.exe : tiffdither.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffdump.obj : tiffdump.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffdump.exe : tiffdump.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffgt.obj : tiffgt.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffgt.exe : tiffgt.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffinfo.obj : tiffinfo.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffinfo.exe : tiffinfo.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffmedian.obj : tiffmedian.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffmedian.exe : tiffmedian.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffset.obj : tiffset.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffset.exe : tiffset.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffsplit.obj : tiffsplit.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffsplit.exe : tiffsplit.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +ycbcr.obj : ycbcr.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +ycbcr.exe : ycbcr.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + + +CLEAN : + DEL ALL.;* + DEL *.OBJ;* + DEL *.EXE;* + +$! +$! +$! +$!copiing and patching TIFF_CONF.H, TIF_CONFIG.H +$! +$CURRENT = F$ENVIRONMENT (""DEFAULT"") +$CURRENT[F$LOCATE("]",CURRENT),9]:=".LIBTIFF]" +$WRITE SYS$OUTPUT "Creating TIFFCONF.H and TIF_CONFIG.H" +$COPY SYS$INPUT 'CURRENT'TIFFCONF.H +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +/* Define to 1 if the system has the type `int16'. */ +//#define HAVE_INT16 + +/* Define to 1 if the system has the type `int32'. */ +//#define HAVE_INT32 + +/* Define to 1 if the system has the type `int8'. */ +//#define HAVE_INT8 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* Compatibility stuff. */ + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ + +#ifdef __IEEE_FLOAT +#define HAVE_IEEEFP 1 +#endif + +#define HAVE_GETOPT 1 + +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian + (Intel) */ +#define HOST_BIGENDIAN 0 + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Support LogLuv high dynamic range encoding */ +#define LOGLUV_SUPPORT 1 + +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 + +/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation + fails with unpatched IJG JPEG library) */ + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 + +/* Support Pixar log-format algorithm (requires Zlib) */ +#define PIXARLOG_SUPPORT 1 + +/* Support ThunderScan 4-bit RLE algorithm */ +#define THUNDER_SUPPORT 1 + +/* Support Deflate compression */ +/* #undef ZIP_SUPPORT */ + +/* Support strip chopping (whether or not to convert single-strip uncompressed + images to mutiple strips of ~8Kb to reduce memory usage) */ +#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP + +/* Enable SubIFD tag (330) support */ +#define SUBIFD_SUPPORT 1 + +/* Treat extra sample as alpha (default enabled). The RGBA interface will + treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many + packages produce RGBA files but don't mark the alpha properly. */ +#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 + +/* + * Feature support definitions. + * XXX: These macros are obsoleted. Don't use them in your apps! + * Macros stays here for backward compatibility and should be always defined. + */ +#define COLORIMETRY_SUPPORT +#define YCBCR_SUPPORT +#define CMYK_SUPPORT +#define ICC_SUPPORT +#define PHOTOSHOP_SUPPORT +#define IPTC_SUPPORT + +#endif /* _TIFFCONF_ */ + + +$COPY SYS$INPUT 'CURRENT'TIF_CONFIG.H +/* Define to 1 if you have the header file. */ + +#ifndef HAVE_GETOPT +# define HAVE_GETOPT 1 +#endif + +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ + +#ifdef __IEEE_FLOAT +#define HAVE_IEEEFP 1 +#endif + +#define HAVE_UNISTD_H 1 + +#define HAVE_STRING_H 1 +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_IO_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_SEARCH_H 1 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* Set the native cpu bit order */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +/* +#ifndef __cplusplus +# ifndef inline +# define inline __inline +# endif +#endif +*/ + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 +/* Support C++ stream API (requires C++ compiler) */ +#define CXX_SUPPORT 1 + +/* Treat extra sample as alpha (default enabled). The RGBA interface will + treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many + packages produce RGBA files but don't mark the alpha properly. */ +#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 + +/* little Endian */ +#define HOST_BIGENDIAN 0 +#define JPEG_SUPPORT 1 +#define LOGLUV_SUPPORT 1 +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support Microsoft Document Imaging format */ +#define MDI_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 +#define OJPEG_SUPPORT 1 + +/* Name of package */ +#define PACKAGE "tiff" + + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "tiff@lists.maptools.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "LibTIFF Software" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "LibTIFF Software 3.9.0beta for VMS" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "tiff" + +$PURGE 'CURRENT'TIFFCONF.H +$PURGE 'CURRENT'TIF_CONFIG.H +$OPEN/APPEND OUT 'CURRENT'TIF_CONFIG.H +$IF HAVE_LFIND.EQ.1 +$ THEN +$ WRITE OUT "#define HAVE_SEARCH_H 1" +$ ELSE +$ WRITE OUT "#undef HAVE_SEARCH_H" +$ENDIF +$CLOSE OUT +$! +$! +$WRITE SYS$OUTPUT " " +$WRITE SYS$OUTPUT " " +$WRITE SYS$OUTPUT "Now you can type @BUILD " +$! +$EXIT: +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$DEL TEST.OBJ;* +$DEL TEST.C;* +$DEL TEST.EXE;* +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT diff --git a/libs/tiff-3.8.2/contrib/ojpeg/Makefile.am b/libs/tiff-4.0.2/contrib/Makefile.am similarity index 93% rename from libs/tiff-3.8.2/contrib/ojpeg/Makefile.am rename to libs/tiff-4.0.2/contrib/Makefile.am index b33e05e5d3..b231ef91e3 100644 --- a/libs/tiff-3.8.2/contrib/ojpeg/Makefile.am +++ b/libs/tiff-4.0.2/contrib/Makefile.am @@ -23,5 +23,7 @@ # Process this file with automake to produce Makefile.in. -EXTRA_DIST = README jdhuff_add.c +EXTRA_DIST = README + +SUBDIRS = addtiffo dbs iptcutil mfs pds ras stream tags win_dib diff --git a/libs/tiff-3.8.2/contrib/README b/libs/tiff-4.0.2/contrib/README similarity index 100% rename from libs/tiff-3.8.2/contrib/README rename to libs/tiff-4.0.2/contrib/README diff --git a/libs/tiff-3.8.2/contrib/addtiffo/Makefile.am b/libs/tiff-4.0.2/contrib/addtiffo/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/addtiffo/Makefile.am rename to libs/tiff-4.0.2/contrib/addtiffo/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/addtiffo/Makefile.vc b/libs/tiff-4.0.2/contrib/addtiffo/Makefile.vc similarity index 100% rename from libs/tiff-3.8.2/contrib/addtiffo/Makefile.vc rename to libs/tiff-4.0.2/contrib/addtiffo/Makefile.vc diff --git a/libs/tiff-3.8.2/contrib/addtiffo/README b/libs/tiff-4.0.2/contrib/addtiffo/README similarity index 100% rename from libs/tiff-3.8.2/contrib/addtiffo/README rename to libs/tiff-4.0.2/contrib/addtiffo/README diff --git a/libs/tiff-3.8.2/contrib/addtiffo/addtiffo.c b/libs/tiff-4.0.2/contrib/addtiffo/addtiffo.c similarity index 94% rename from libs/tiff-3.8.2/contrib/addtiffo/addtiffo.c rename to libs/tiff-4.0.2/contrib/addtiffo/addtiffo.c index 9dc04e6a2c..d3920e26cf 100644 --- a/libs/tiff-3.8.2/contrib/addtiffo/addtiffo.c +++ b/libs/tiff-4.0.2/contrib/addtiffo/addtiffo.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: addtiffo.c,v 1.6 2005/12/16 05:59:55 fwarmerdam Exp $ + * $Id: addtiffo.c,v 1.7 2010-06-08 18:55:15 bfriesen Exp $ * * Project: GeoTIFF Overview Builder * Purpose: Mainline for building overviews in a TIFF file. @@ -28,6 +28,10 @@ ****************************************************************************** * * $Log: addtiffo.c,v $ + * Revision 1.7 2010-06-08 18:55:15 bfriesen + * * contrib: Add an emacs formatting mode footer to all source files + * so that emacs can be effectively used. + * * Revision 1.6 2005/12/16 05:59:55 fwarmerdam * Major upgrade to support YCbCr subsampled jpeg images * @@ -163,3 +167,10 @@ int main( int argc, char ** argv ) return( 0 ); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/addtiffo/tif_overview.c b/libs/tiff-4.0.2/contrib/addtiffo/tif_overview.c similarity index 82% rename from libs/tiff-3.8.2/contrib/addtiffo/tif_overview.c rename to libs/tiff-4.0.2/contrib/addtiffo/tif_overview.c index 317eceaf43..156c081252 100644 --- a/libs/tiff-3.8.2/contrib/addtiffo/tif_overview.c +++ b/libs/tiff-4.0.2/contrib/addtiffo/tif_overview.c @@ -77,7 +77,7 @@ void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, /* function is called. */ /************************************************************************/ -uint32 TIFF_WriteOverview( TIFF *hTIFF, int nXSize, int nYSize, +uint32 TIFF_WriteOverview( TIFF *hTIFF, uint32 nXSize, uint32 nYSize, int nBitsPerPixel, int nPlanarConfig, int nSamples, int nBlockXSize, int nBlockYSize, int bTiled, int nCompressFlag, int nPhotometric, @@ -89,8 +89,10 @@ uint32 TIFF_WriteOverview( TIFF *hTIFF, int nXSize, int nYSize, int nHorSubsampling, int nVerSubsampling ) { - uint32 nBaseDirOffset; - uint32 nOffset; + toff_t nBaseDirOffset; + toff_t nOffset; + + (void) bUseSubIFDs; nBaseDirOffset = TIFFCurrentDirOffset( hTIFF ); @@ -161,10 +163,11 @@ uint32 TIFF_WriteOverview( TIFF *hTIFF, int nXSize, int nYSize, static void TIFF_GetSourceSamples( double * padfSamples, unsigned char *pabySrc, int nPixelBytes, int nSampleFormat, - int nXSize, int nYSize, + uint32 nXSize, uint32 nYSize, int nPixelOffset, int nLineOffset ) { - int iXOff, iYOff, iSample; + uint32 iXOff, iYOff; + int iSample; iSample = 0; @@ -256,15 +259,16 @@ TIFF_SetSample( unsigned char * pabyData, int nPixelBytes, int nSampleFormat, static void TIFF_DownSample( unsigned char *pabySrcTile, - int nBlockXSize, int nBlockYSize, + uint32 nBlockXSize, uint32 nBlockYSize, int nPixelSkewBits, int nBitsPerPixel, unsigned char * pabyOTile, - int nOBlockXSize, int nOBlockYSize, - int nTXOff, int nTYOff, int nOMult, + uint32 nOBlockXSize, uint32 nOBlockYSize, + uint32 nTXOff, uint32 nTYOff, int nOMult, int nSampleFormat, const char * pszResampling ) { - int i, j, k, nPixelBytes = (nBitsPerPixel) / 8; + uint32 i, j; + int k, nPixelBytes = (nBitsPerPixel) / 8; int nPixelGroupBytes = (nBitsPerPixel+nPixelSkewBits)/8; unsigned char *pabySrc, *pabyDst; double *padfSamples; @@ -324,14 +328,13 @@ void TIFF_DownSample( unsigned char *pabySrcTile, for( i = 0; i*nOMult < nBlockXSize; i++ ) { double dfTotal; - int iSample; - int nXSize, nYSize; + uint32 nXSize, nYSize, iSample; if( i + nTXOff >= nOBlockXSize ) break; - nXSize = MIN(nOMult,nBlockXSize-i); - nYSize = MIN(nOMult,nBlockYSize-j); + nXSize = MIN((uint32)nOMult,nBlockXSize-i); + nYSize = MIN((uint32)nOMult,nBlockYSize-j); TIFF_GetSourceSamples( padfSamples, pabySrc, nPixelBytes, nSampleFormat, @@ -357,125 +360,108 @@ void TIFF_DownSample( unsigned char *pabySrcTile, free( padfSamples ); } +/************************************************************************/ +/* TIFF_DownSample_Subsampled() */ +/************************************************************************/ static void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, - int nBlockXSize, int nBlockYSize, + uint32 nBlockXSize, uint32 nBlockYSize, unsigned char * pabyOTile, - int nOBlockXSize, int nOBlockYSize, - int nTXOff, int nTYOff, int nOMult, - const char * pszResampling, + uint32 nOBlockXSize, uint32 nOBlockYSize, + uint32 nTXOff, uint32 nTYOff, int nOMult, + const char *pszResampling, int nHorSubsampling, int nVerSubsampling ) { /* TODO: test with variety of subsampling values, and incovinient tile/strip sizes */ - int nSampleBlockSize; + int nSampleBlockSize; int nSourceSampleRowSize; int nDestSampleRowSize; - int nSourceX, nSourceY; - int nSourceXSec, nSourceYSec; - int nSourceXSecEnd, nSourceYSecEnd; - int nDestX, nDestY; + uint32 nSourceX, nSourceY; + uint32 nSourceXSec, nSourceYSec; + uint32 nSourceXSecEnd, nSourceYSecEnd; + uint32 nDestX, nDestY; int nSampleOffsetInSampleBlock; - unsigned char * pSourceBase; - unsigned char * pDestBase; - int nSourceBaseInc; - unsigned char * pSourceBaseEnd; unsigned int nCummulator; unsigned int nCummulatorCount; nSampleBlockSize = nHorSubsampling * nVerSubsampling + 2; - nSourceSampleRowSize = ( ( nBlockXSize + nHorSubsampling - 1 ) / nHorSubsampling ) * nSampleBlockSize; - nDestSampleRowSize = ( ( nOBlockXSize + nHorSubsampling - 1 ) / nHorSubsampling ) * nSampleBlockSize; + nSourceSampleRowSize = + ( ( nBlockXSize + nHorSubsampling - 1 ) / nHorSubsampling ) * nSampleBlockSize; + nDestSampleRowSize = + ( ( nOBlockXSize + nHorSubsampling - 1 ) / nHorSubsampling ) * nSampleBlockSize; if( strncmp(pszResampling,"nearest",4) == 0 - || strncmp(pszResampling,"NEAR",4) == 0 ) - { + || strncmp(pszResampling,"NEAR",4) == 0 ) + { if( nSample == 0 ) { -#ifdef NOOPTIMIZATION - /* - * This version is not optimized, and should not be used except as documentation and as more clear - * starting point for bug fixes (hope not) and extension - */ - for( nSourceY = 0, nDestY = nTYOff; nSourceY < nBlockYSize; nSourceY += nOMult, nDestY ++) - { - for( nSourceX = 0, nDestX = nTXOff; nSourceX < nBlockXSize; nSourceX += nOMult, nDestX ++) - { - * ( pabyOTile + ( nDestY / nVerSubsampling ) * nDestSampleRowSize - + ( nDestY % nVerSubsampling ) * nHorSubsampling - + ( nDestX / nHorSubsampling ) * nSampleBlockSize - + ( nDestX % nHorSubsampling ) ) = - * ( pabySrcTile + ( nSourceY / nVerSubsampling ) * nSourceSampleRowSize - + ( nSourceY % nVerSubsampling ) * nHorSubsampling - + ( nSourceX / nHorSubsampling ) * nSampleBlockSize - + ( nSourceX % nHorSubsampling ) ); - } - } -#else - for( nSourceY = 0, nDestY = nTYOff; nSourceY < nBlockYSize; nSourceY += nOMult, nDestY ++) + for( nSourceY = 0, nDestY = nTYOff; + nSourceY < nBlockYSize; + nSourceY += nOMult, nDestY ++) { - pSourceBase = pabySrcTile + ( nSourceY / nVerSubsampling ) * nSourceSampleRowSize - + ( nSourceY % nVerSubsampling ) * nHorSubsampling; - pDestBase = pabyOTile + ( nDestY / nVerSubsampling ) * nDestSampleRowSize - + ( nDestY % nVerSubsampling ) * nHorSubsampling; - for( nSourceX = 0, nDestX = nTXOff; nSourceX < nBlockXSize; nSourceX += nOMult, nDestX ++) + if( nDestY >= nOBlockYSize ) + break; + + for( nSourceX = 0, nDestX = nTXOff; + nSourceX < nBlockXSize; + nSourceX += nOMult, nDestX ++) { - * ( pDestBase + ( nDestX / nHorSubsampling ) * nSampleBlockSize - + ( nDestX % nHorSubsampling ) ) = - * ( pSourceBase + ( nSourceX / nHorSubsampling ) * nSampleBlockSize - + ( nSourceX % nHorSubsampling ) ); + if( nDestX >= nOBlockXSize ) + break; + + * ( pabyOTile + ( nDestY / nVerSubsampling ) * nDestSampleRowSize + + ( nDestY % nVerSubsampling ) * nHorSubsampling + + ( nDestX / nHorSubsampling ) * nSampleBlockSize + + ( nDestX % nHorSubsampling ) ) = + * ( pabySrcTile + ( nSourceY / nVerSubsampling ) * nSourceSampleRowSize + + ( nSourceY % nVerSubsampling ) * nHorSubsampling + + ( nSourceX / nHorSubsampling ) * nSampleBlockSize + + ( nSourceX % nHorSubsampling ) ); } } -#endif } else { -#ifdef NOOPTIMIZATION - /* - * This version is not optimized, and should not be used except as documentation and as more clear - * starting point for bug fixes (hope not) and extension - */ nSampleOffsetInSampleBlock = nHorSubsampling * nVerSubsampling + nSample - 1; - for( nSourceY = 0, nDestY = ( nTYOff / nVerSubsampling ); nSourceY < ( nBlockYSize / nVerSubsampling ); - nSourceY += nOMult, nDestY ++) + for( nSourceY = 0, nDestY = ( nTYOff / nVerSubsampling ); + nSourceY < ( nBlockYSize / nVerSubsampling ); + nSourceY += nOMult, nDestY ++) { - for( nSourceX = 0, nDestX = ( nTXOff / nHorSubsampling ); nSourceX < ( nBlockXSize / nHorSubsampling ); - nSourceX += nOMult, nDestX ++) + if( nDestY*nVerSubsampling >= nOBlockYSize ) + break; + + for( nSourceX = 0, nDestX = ( nTXOff / nHorSubsampling ); + nSourceX < ( nBlockXSize / nHorSubsampling ); + nSourceX += nOMult, nDestX ++) { + if( nDestX*nHorSubsampling >= nOBlockXSize ) + break; + * ( pabyOTile + nDestY * nDestSampleRowSize - + nDestX * nSampleBlockSize - + nSampleOffsetInSampleBlock ) = + + nDestX * nSampleBlockSize + + nSampleOffsetInSampleBlock ) = * ( pabySrcTile + nSourceY * nSourceSampleRowSize - + nSourceX * nSampleBlockSize - + nSampleOffsetInSampleBlock ); + + nSourceX * nSampleBlockSize + + nSampleOffsetInSampleBlock ); } } -#else - nSampleOffsetInSampleBlock = nHorSubsampling * nVerSubsampling + nSample - 1; - nSourceBaseInc = nOMult * nSampleBlockSize; - for( nSourceY = 0, nDestY = ( nTYOff / nVerSubsampling ); nSourceY < ( nBlockYSize / nVerSubsampling); - nSourceY += nOMult, nDestY ++) - { - pSourceBase = pabySrcTile + nSourceY * nSourceSampleRowSize - + nSampleOffsetInSampleBlock; - pSourceBaseEnd = pSourceBase + ( ( ( nBlockXSize / nHorSubsampling ) + nOMult - 1 ) / nOMult ) * nSourceBaseInc; - pDestBase = pabyOTile + nDestY * nDestSampleRowSize - + ( nTXOff / nHorSubsampling ) * nSampleBlockSize - + nSampleOffsetInSampleBlock; - for( ; pSourceBase < pSourceBaseEnd; pSourceBase += nSourceBaseInc, pDestBase += nSampleBlockSize) - * pDestBase = * pSourceBase; - } -#endif } } else if( strncmp(pszResampling,"averag",6) == 0 - || strncmp(pszResampling,"AVERAG",6) == 0 ) + || strncmp(pszResampling,"AVERAG",6) == 0 ) { if( nSample == 0 ) { for( nSourceY = 0, nDestY = nTYOff; nSourceY < nBlockYSize; nSourceY += nOMult, nDestY ++) { + if( nDestY >= nOBlockYSize ) + break; + for( nSourceX = 0, nDestX = nTXOff; nSourceX < nBlockXSize; nSourceX += nOMult, nDestX ++) { + if( nDestX >= nOBlockXSize ) + break; + nSourceXSecEnd = nSourceX + nOMult; if( nSourceXSecEnd > nBlockXSize ) nSourceXSecEnd = nBlockXSize; @@ -488,16 +474,16 @@ void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, for( nSourceXSec = nSourceX; nSourceXSec < nSourceXSecEnd; nSourceXSec ++) { nCummulator += * ( pabySrcTile + ( nSourceYSec / nVerSubsampling ) * nSourceSampleRowSize - + ( nSourceYSec % nVerSubsampling ) * nHorSubsampling - + ( nSourceXSec / nHorSubsampling ) * nSampleBlockSize - + ( nSourceXSec % nHorSubsampling ) ); + + ( nSourceYSec % nVerSubsampling ) * nHorSubsampling + + ( nSourceXSec / nHorSubsampling ) * nSampleBlockSize + + ( nSourceXSec % nHorSubsampling ) ); } } nCummulatorCount = ( nSourceXSecEnd - nSourceX ) * ( nSourceYSecEnd - nSourceY ); * ( pabyOTile + ( nDestY / nVerSubsampling ) * nDestSampleRowSize - + ( nDestY % nVerSubsampling ) * nHorSubsampling - + ( nDestX / nHorSubsampling ) * nSampleBlockSize - + ( nDestX % nHorSubsampling ) ) = + + ( nDestY % nVerSubsampling ) * nHorSubsampling + + ( nDestX / nHorSubsampling ) * nSampleBlockSize + + ( nDestX % nHorSubsampling ) ) = ( ( nCummulator + ( nCummulatorCount >> 1 ) ) / nCummulatorCount ); } } @@ -506,11 +492,17 @@ void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, { nSampleOffsetInSampleBlock = nHorSubsampling * nVerSubsampling + nSample - 1; for( nSourceY = 0, nDestY = ( nTYOff / nVerSubsampling ); nSourceY < ( nBlockYSize / nVerSubsampling ); - nSourceY += nOMult, nDestY ++) + nSourceY += nOMult, nDestY ++) { + if( nDestY*nVerSubsampling >= nOBlockYSize ) + break; + for( nSourceX = 0, nDestX = ( nTXOff / nHorSubsampling ); nSourceX < ( nBlockXSize / nHorSubsampling ); - nSourceX += nOMult, nDestX ++) + nSourceX += nOMult, nDestX ++) { + if( nDestX*nHorSubsampling >= nOBlockXSize ) + break; + nSourceXSecEnd = nSourceX + nOMult; if( nSourceXSecEnd > ( nBlockXSize / nHorSubsampling ) ) nSourceXSecEnd = ( nBlockXSize / nHorSubsampling ); @@ -523,14 +515,14 @@ void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, for( nSourceXSec = nSourceX; nSourceXSec < nSourceXSecEnd; nSourceXSec ++) { nCummulator += * ( pabySrcTile + nSourceYSec * nSourceSampleRowSize - + nSourceXSec * nSampleBlockSize - + nSampleOffsetInSampleBlock ); + + nSourceXSec * nSampleBlockSize + + nSampleOffsetInSampleBlock ); } } nCummulatorCount = ( nSourceXSecEnd - nSourceX ) * ( nSourceYSecEnd - nSourceY ); * ( pabyOTile + nDestY * nDestSampleRowSize - + nDestX * nSampleBlockSize - + nSampleOffsetInSampleBlock ) = + + nDestX * nSampleBlockSize + + nSampleOffsetInSampleBlock ) = ( ( nCummulator + ( nCummulatorCount >> 1 ) ) / nCummulatorCount ); } } @@ -546,13 +538,14 @@ void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, /************************************************************************/ void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, - int bSubsampled, int nHorSubsampling, int nVerSubsampling, + int bSubsampled, + int nHorSubsampling, int nVerSubsampling, int nOverviews, int * panOvList, int nBitsPerPixel, int nSamples, TIFFOvrCache ** papoRawBIs, - int nSXOff, int nSYOff, + uint32 nSXOff, uint32 nSYOff, unsigned char *pabySrcTile, - int nBlockXSize, int nBlockYSize, + uint32 nBlockXSize, uint32 nBlockYSize, int nSampleFormat, const char * pszResampling ) { @@ -592,10 +585,10 @@ void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, { TIFFOvrCache *poRBI = papoRawBIs[iOverview]; unsigned char *pabyOTile; - int nTXOff, nTYOff, nOXOff, nOYOff, nOMult; - int nOBlockXSize = poRBI->nBlockXSize; - int nOBlockYSize = poRBI->nBlockYSize; - int nSkewBits, nSampleByteOffset; + uint32 nTXOff, nTYOff, nOXOff, nOYOff, nOMult; + uint32 nOBlockXSize = poRBI->nBlockXSize; + uint32 nOBlockYSize = poRBI->nBlockYSize; + int nSkewBits, nSampleByteOffset; /* * Fetch the destination overview tile @@ -706,6 +699,9 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, uint16 *panRedMap, *panGreenMap, *panBlueMap; TIFFErrorHandler pfnWarning; + (void) pfnProgress; + (void) pProgressData; + /* -------------------------------------------------------------------- */ /* Get the base raster size. */ /* -------------------------------------------------------------------- */ @@ -810,14 +806,14 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, for( i = 0; i < nOverviews; i++ ) { - int nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; - uint32 nDirOffset; + uint32 nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; + toff_t nDirOffset; nOXSize = (nXSize + panOvList[i] - 1) / panOvList[i]; nOYSize = (nYSize + panOvList[i] - 1) / panOvList[i]; - nOBlockXSize = MIN((int)nBlockXSize,nOXSize); - nOBlockYSize = MIN((int)nBlockYSize,nOYSize); + nOBlockXSize = MIN(nBlockXSize,nOXSize); + nOBlockYSize = MIN(nBlockYSize,nOYSize); if( bTiled ) { @@ -894,3 +890,10 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/addtiffo/tif_ovrcache.c b/libs/tiff-4.0.2/contrib/addtiffo/tif_ovrcache.c similarity index 80% rename from libs/tiff-3.8.2/contrib/addtiffo/tif_ovrcache.c rename to libs/tiff-4.0.2/contrib/addtiffo/tif_ovrcache.c index 67cc74d2d1..e19483bc4d 100644 --- a/libs/tiff-3.8.2/contrib/addtiffo/tif_ovrcache.c +++ b/libs/tiff-4.0.2/contrib/addtiffo/tif_ovrcache.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: tif_ovrcache.c,v 1.6 2005/12/21 12:23:13 joris Exp $ + * $Id: tif_ovrcache.c,v 1.9 2010-06-08 18:55:15 bfriesen Exp $ * * Project: TIFF Overview Builder * Purpose: Library functions to maintain two rows of tiles or two strips @@ -40,11 +40,11 @@ /* existing TIFF directory. */ /************************************************************************/ -TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, int nDirOffset ) +TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset ) { TIFFOvrCache *psCache; - uint32 nBaseDirOffset; + toff_t nBaseDirOffset; psCache = (TIFFOvrCache *) _TIFFmalloc(sizeof(TIFFOvrCache)); psCache->nDirOffset = nDirOffset; @@ -136,8 +136,9 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) { int nRet, iTileX, iTileY = psCache->nBlockOffset; unsigned char *pabyData; - uint32 nBaseDirOffset; - + toff_t nBaseDirOffset; + uint32 RowsInStrip; + /* -------------------------------------------------------------------- */ /* If the output cache is multi-byte per sample, and the file */ /* being written to is of a different byte order than the current */ @@ -169,72 +170,72 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) /* -------------------------------------------------------------------- */ /* Write blocks to TIFF file. */ /* -------------------------------------------------------------------- */ - for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ ) - { - int nTileID; + for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ ) + { + int nTileID; - if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) - { - int iSample; + if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) + { + int iSample; - for( iSample = 0; iSample < psCache->nSamples; iSample++ ) - { - pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, iSample ); + for( iSample = 0; iSample < psCache->nSamples; iSample++ ) + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, iSample ); - if( psCache->bTiled ) - { - nTileID = - TIFFComputeTile( psCache->hTIFF, - iTileX * psCache->nBlockXSize, - iTileY * psCache->nBlockYSize, - 0, (tsample_t) iSample ); - TIFFWriteEncodedTile( psCache->hTIFF, nTileID, - pabyData, - TIFFTileSize(psCache->hTIFF) ); - } - else - { - nTileID = - TIFFComputeStrip( psCache->hTIFF, - iTileY * psCache->nBlockYSize, - (tsample_t) iSample ); + if( psCache->bTiled ) + { + nTileID = TIFFComputeTile( psCache->hTIFF, + iTileX * psCache->nBlockXSize, + iTileY * psCache->nBlockYSize, + 0, (tsample_t) iSample ); + TIFFWriteEncodedTile( psCache->hTIFF, nTileID, + pabyData, + TIFFTileSize(psCache->hTIFF) ); + } + else + { + nTileID = TIFFComputeStrip( psCache->hTIFF, + iTileY * psCache->nBlockYSize, + (tsample_t) iSample ); + RowsInStrip=psCache->nBlockYSize; + if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize) + RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize; + TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, + pabyData, + TIFFVStripSize(psCache->hTIFF,RowsInStrip) ); + } + } - TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, - pabyData, - TIFFStripSize(psCache->hTIFF) ); - } - } + } + else + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 ); - } - else - { - pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 ); - - if( psCache->bTiled ) - { - nTileID = - TIFFComputeTile( psCache->hTIFF, - iTileX * psCache->nBlockXSize, - iTileY * psCache->nBlockYSize, - 0, 0 ); - TIFFWriteEncodedTile( psCache->hTIFF, nTileID, - pabyData, - TIFFTileSize(psCache->hTIFF) ); - } - else - { - nTileID = - TIFFComputeStrip( psCache->hTIFF, - iTileY * psCache->nBlockYSize, - 0 ); - - TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, - pabyData, - TIFFStripSize(psCache->hTIFF) ); - } - } - } - /* TODO: add checks on error status return of TIFFWriteEncodedTile and TIFFWriteEncodedStrip */ + if( psCache->bTiled ) + { + nTileID = TIFFComputeTile( psCache->hTIFF, + iTileX * psCache->nBlockXSize, + iTileY * psCache->nBlockYSize, + 0, 0 ); + TIFFWriteEncodedTile( psCache->hTIFF, nTileID, + pabyData, + TIFFTileSize(psCache->hTIFF) ); + } + else + { + nTileID = TIFFComputeStrip( psCache->hTIFF, + iTileY * psCache->nBlockYSize, + 0 ); + RowsInStrip=psCache->nBlockYSize; + if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize) + RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize; + TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, + pabyData, + TIFFVStripSize(psCache->hTIFF,RowsInStrip) ); + } + } + } + /* TODO: add checks on error status return of TIFFWriteEncodedTile and TIFFWriteEncodedStrip */ /* -------------------------------------------------------------------- */ /* Rotate buffers. */ @@ -331,3 +332,10 @@ void TIFFDestroyOvrCache( TIFFOvrCache * psCache ) _TIFFfree( psCache->pabyRow2Blocks ); _TIFFfree( psCache ); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/addtiffo/tif_ovrcache.h b/libs/tiff-4.0.2/contrib/addtiffo/tif_ovrcache.h similarity index 78% rename from libs/tiff-3.8.2/contrib/addtiffo/tif_ovrcache.h rename to libs/tiff-4.0.2/contrib/addtiffo/tif_ovrcache.h index 3298c87275..0ad10829dd 100644 --- a/libs/tiff-3.8.2/contrib/addtiffo/tif_ovrcache.h +++ b/libs/tiff-4.0.2/contrib/addtiffo/tif_ovrcache.h @@ -51,8 +51,8 @@ typedef struct uint16 nPlanarConfig; uint32 nBlockXSize; uint32 nBlockYSize; - uint32 nBytesPerBlock; - uint32 nBytesPerRow; + toff_t nBytesPerBlock; + toff_t nBytesPerRow; int nBlocksPerRow; int nBlocksPerColumn; @@ -61,13 +61,13 @@ typedef struct unsigned char *pabyRow1Blocks; unsigned char *pabyRow2Blocks; - int nDirOffset; + toff_t nDirOffset; TIFF *hTIFF; int bTiled; } TIFFOvrCache; -TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, int nDirOffset ); +TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset ); unsigned char *TIFFGetOvrBlock( TIFFOvrCache *psCache, int iTileX, int iTileY, int iSample ); unsigned char *TIFFGetOvrBlock_Subsampled( TIFFOvrCache *psCache, int iTileX, int iTileY ); @@ -76,17 +76,12 @@ void TIFFDestroyOvrCache( TIFFOvrCache * ); void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, int (*)(double,void*), void * ); -void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, - int bSubsampled, int nHorSamples, int nVerSamples, - int nOverviews, int * panOvList, - int nBitsPerPixel, - int nSamples, TIFFOvrCache ** papoRawBIs, - int nSXOff, int nSYOff, - unsigned char *pabySrcTile, - int nBlockXSize, int nBlockYSize, - int nSampleFormat, const char * pszResampling ); +void TIFF_ProcessFullResBlock( TIFF *, int, int, int, int, int, int *, int, + int, TIFFOvrCache **, uint32, uint32, + unsigned char *, uint32, uint32, + int, const char * ); -uint32 TIFF_WriteOverview( TIFF *, int, int, int, int, int, int, int, +uint32 TIFF_WriteOverview( TIFF *, uint32, uint32, int, int, int, int, int, int, int, int, int, unsigned short *, unsigned short *, unsigned short *, int, int, int); @@ -99,3 +94,10 @@ uint32 TIFF_WriteOverview( TIFF *, int, int, int, int, int, int, int, #endif /* ndef TIF_OVRCACHE_H_INCLUDED */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/Makefile.am b/libs/tiff-4.0.2/contrib/dbs/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/dbs/Makefile.am rename to libs/tiff-4.0.2/contrib/dbs/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/dbs/README b/libs/tiff-4.0.2/contrib/dbs/README similarity index 100% rename from libs/tiff-3.8.2/contrib/dbs/README rename to libs/tiff-4.0.2/contrib/dbs/README diff --git a/libs/tiff-3.8.2/contrib/dbs/tiff-bi.c b/libs/tiff-4.0.2/contrib/dbs/tiff-bi.c similarity index 94% rename from libs/tiff-3.8.2/contrib/dbs/tiff-bi.c rename to libs/tiff-4.0.2/contrib/dbs/tiff-bi.c index ca43393a14..33f05c7d0a 100644 --- a/libs/tiff-3.8.2/contrib/dbs/tiff-bi.c +++ b/libs/tiff-4.0.2/contrib/dbs/tiff-bi.c @@ -1,4 +1,4 @@ -/* $Id: tiff-bi.c,v 1.2 2004/05/03 16:46:36 dron Exp $ */ +/* $Id: tiff-bi.c,v 1.3 2010-06-08 18:55:15 bfriesen Exp $ */ /* * tiff-bi.c -- create a Class B (bilevel) TIFF file @@ -82,3 +82,10 @@ int main(int argc, char **argv) TIFFClose(tif); return 0; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/tiff-grayscale.c b/libs/tiff-4.0.2/contrib/dbs/tiff-grayscale.c similarity index 96% rename from libs/tiff-3.8.2/contrib/dbs/tiff-grayscale.c rename to libs/tiff-4.0.2/contrib/dbs/tiff-grayscale.c index 51f7c11b1b..00b229f346 100644 --- a/libs/tiff-3.8.2/contrib/dbs/tiff-grayscale.c +++ b/libs/tiff-4.0.2/contrib/dbs/tiff-grayscale.c @@ -1,4 +1,4 @@ -/* $Id: tiff-grayscale.c,v 1.4 2004/09/03 08:26:08 dron Exp $ */ +/* $Id: tiff-grayscale.c,v 1.6 2010-06-08 18:55:15 bfriesen Exp $ */ /* * tiff-grayscale.c -- create a Class G (grayscale) TIFF file @@ -86,6 +86,7 @@ int main(int argc, char **argv) if ((tif = TIFFOpen(argv[3], "w")) == NULL) { fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]); + free(gray); return 0; } @@ -137,3 +138,10 @@ Usage() fprintf(stderr, "Usage: %s -depth (8 | 4 | 2) tiff-image\n", programName); exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/tiff-palette.c b/libs/tiff-4.0.2/contrib/dbs/tiff-palette.c similarity index 97% rename from libs/tiff-3.8.2/contrib/dbs/tiff-palette.c rename to libs/tiff-4.0.2/contrib/dbs/tiff-palette.c index 1501e8e3dc..3d9e862ba0 100644 --- a/libs/tiff-3.8.2/contrib/dbs/tiff-palette.c +++ b/libs/tiff-4.0.2/contrib/dbs/tiff-palette.c @@ -1,4 +1,4 @@ -/* $Id: tiff-palette.c,v 1.3 2004/09/03 08:27:20 dron Exp $ */ +/* $Id: tiff-palette.c,v 1.5 2010-06-08 18:55:15 bfriesen Exp $ */ /* * tiff-palette.c -- create a Class P (palette) TIFF file @@ -219,6 +219,7 @@ int main(int argc, char **argv) if ((tif = TIFFOpen(argv[3], "w")) == NULL) { fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]); + free(red);free(green);free(blue); return 0; } @@ -274,3 +275,10 @@ Usage() fprintf(stderr, "Usage: %s -depth (8 | 4 | 2 | 1) tiff-image\n", programName); exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/tiff-rgb.c b/libs/tiff-4.0.2/contrib/dbs/tiff-rgb.c similarity index 97% rename from libs/tiff-3.8.2/contrib/dbs/tiff-rgb.c rename to libs/tiff-4.0.2/contrib/dbs/tiff-rgb.c index 7c8fe02f7a..bf90499023 100644 --- a/libs/tiff-3.8.2/contrib/dbs/tiff-rgb.c +++ b/libs/tiff-4.0.2/contrib/dbs/tiff-rgb.c @@ -1,4 +1,4 @@ -/* $Id: tiff-rgb.c,v 1.3 2004/09/03 08:29:16 dron Exp $ */ +/* $Id: tiff-rgb.c,v 1.4 2010-06-08 18:55:15 bfriesen Exp $ */ /* * tiff-rgb.c -- create a 24-bit Class R (rgb) TIFF file @@ -192,3 +192,10 @@ Usage() fprintf(stderr, "Usage: %s -gamma gamma tiff-image\n", programName); exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/xtiff/Makefile.am b/libs/tiff-4.0.2/contrib/dbs/xtiff/Makefile.am similarity index 78% rename from libs/tiff-3.8.2/contrib/dbs/xtiff/Makefile.am rename to libs/tiff-4.0.2/contrib/dbs/xtiff/Makefile.am index f709860928..749f5ceb68 100644 --- a/libs/tiff-3.8.2/contrib/dbs/xtiff/Makefile.am +++ b/libs/tiff-4.0.2/contrib/dbs/xtiff/Makefile.am @@ -1,4 +1,3 @@ -# $Id: Makefile.am,v 1.2 2006/03/23 14:54:01 dron Exp $ # # Tag Image File Format (TIFF) Software # @@ -25,5 +24,19 @@ # Process this file with automake to produce Makefile.in. -EXTRA_DIST = Imakefile README patchlevel.h xtiff.c xtifficon.h +#LIBTIFF = $(top_builddir)/libtiff/libtiff.la + +EXTRA_DIST = README patchlevel.h xtiff.c xtifficon.h + +#noinst_PROGRAMS = + +#if HAVE_XAW +#noinst_PROGRAMS += xtiff +#endif + +#xtiff_SOURCES = patchlevel.h xtiff.c xtifficon.h +#xtiff_CFLAGS = $(CFLAGS) $(XAW_CFLAGS) $(AM_CFLAGS) +#xtiff_LDADD = $(LIBTIFF) $(X_LIBS) $(XAW_LIBS) + +#INCLUDES = -I$(top_srcdir)/libtiff diff --git a/libs/tiff-3.8.2/contrib/dbs/xtiff/README b/libs/tiff-4.0.2/contrib/dbs/xtiff/README similarity index 100% rename from libs/tiff-3.8.2/contrib/dbs/xtiff/README rename to libs/tiff-4.0.2/contrib/dbs/xtiff/README diff --git a/libs/tiff-4.0.2/contrib/dbs/xtiff/patchlevel.h b/libs/tiff-4.0.2/contrib/dbs/xtiff/patchlevel.h new file mode 100644 index 0000000000..538b6d9756 --- /dev/null +++ b/libs/tiff-4.0.2/contrib/dbs/xtiff/patchlevel.h @@ -0,0 +1,8 @@ +#define PATCHLEVEL 0 +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/xtiff/xtiff.c b/libs/tiff-4.0.2/contrib/dbs/xtiff/xtiff.c similarity index 94% rename from libs/tiff-3.8.2/contrib/dbs/xtiff/xtiff.c rename to libs/tiff-4.0.2/contrib/dbs/xtiff/xtiff.c index 918265ec23..263403002f 100644 --- a/libs/tiff-3.8.2/contrib/dbs/xtiff/xtiff.c +++ b/libs/tiff-4.0.2/contrib/dbs/xtiff/xtiff.c @@ -1,4 +1,6 @@ /* + * $Id: xtiff.c,v 1.3 2010-06-08 18:55:15 bfriesen Exp $ + * * xtiff - view a TIFF file in an X window * * Dan Sears @@ -54,6 +56,7 @@ */ #include #include +#include #include #include #include @@ -69,7 +72,7 @@ #include "xtifficon.h" #define TIFF_GAMMA "2.2" /* default gamma from the TIFF 5.0 spec */ -#define ROUND(x) (u_short) ((x) + 0.5) +#define ROUND(x) (uint16) ((x) + 0.5) #define SCALE(x, s) (((x) * 65535L) / (s)) #define MCHECK(m) if (!m) { fprintf(stderr, "malloc failed\n"); exit(0); } #define MIN(a, b) (((a) < (b)) ? (a) : (b)) @@ -84,7 +87,7 @@ #define PP(args) () #endif -void main PP((int argc, char **argv)); +int main PP((int argc, char **argv)); void OpenTIFFFile PP((void)); void GetTIFFHeader PP((void)); void SetNameLabel PP((void)); @@ -130,8 +133,8 @@ typedef struct { Boolean help; float gamma; Boolean usePixmap; - int viewportWidth; - int viewportHeight; + uint32 viewportWidth; + uint32 viewportHeight; int translate; Boolean verbose; } AppData, *AppDataPtr; @@ -229,14 +232,14 @@ XImage * xImage; GC xWinGc; int xImageDepth, xScreen, xRedMask, xGreenMask, xBlueMask, xOffset = 0, yOffset = 0, grabX = -1, grabY = -1; -u_char basePixel = 0; +unsigned char basePixel = 0; /* * TIFF data structures */ TIFF * tfFile = NULL; -u_long tfImageWidth, tfImageHeight; -u_short tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, +uint32 tfImageWidth, tfImageHeight; +uint16 tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, tfPhotometricInterpretation, tfGrayResponseUnit, tfImageDepth, tfBytesPerRow; int tfDirectory = 0, tfMultiPage = False; @@ -252,15 +255,13 @@ double *dRed, *dGreen, *dBlue; /* * shared data structures */ -u_short * redMap = NULL, *greenMap = NULL, *blueMap = NULL, +uint16 * redMap = NULL, *greenMap = NULL, *blueMap = NULL, *grayMap = NULL, colormapSize; -u_char * imageMemory; +char * imageMemory; char * fileName; -void -main(argc, argv) - int argc; - char ** argv; +int +main(int argc, char **argv) { XSetWindowAttributes window_attributes; Widget widget_list[3]; @@ -379,6 +380,8 @@ main(argc, argv) CreateXImage(); XtMainLoop(); + + return 0; } void @@ -450,9 +453,9 @@ GetTIFFHeader() */ switch (tfPhotometricInterpretation) { case PHOTOMETRIC_RGB: - redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] @@ -461,9 +464,9 @@ GetTIFFHeader() case PHOTOMETRIC_PALETTE: if (!TIFFGetField(tfFile, TIFFTAG_COLORMAP, &redMap, &greenMap, &blueMap)) { - redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] @@ -478,18 +481,18 @@ GetTIFFHeader() } break; case PHOTOMETRIC_MINISWHITE: - redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(colormapSize-1-i, colormapSize-1); break; case PHOTOMETRIC_MINISBLACK: - redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); - blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize-1); @@ -575,9 +578,9 @@ static char* classNames[] = { void GetVisual() { - register XColor *colors = NULL; - register u_long *pixels = NULL; - register int i; + XColor *colors = NULL; + unsigned long *pixels = NULL; + unsigned long i; switch (tfImageDepth) { /* @@ -595,7 +598,7 @@ GetVisual() MCHECK(colors); for (i = 0; i < colormapSize; i++) { - colors[i].pixel = (u_long) (i << 16) + (i << 8) + i; + colors[i].pixel = (i << 16) + (i << 8) + i; colors[i].red = redMap[i]; colors[i].green = greenMap[i]; colors[i].blue = blueMap[i]; @@ -630,7 +633,7 @@ GetVisual() MCHECK(colors); for (i = 0; i < colormapSize; i++) { - colors[i].pixel = (u_long) i; + colors[i].pixel = i; colors[i].red = redMap[i]; colors[i].green = greenMap[i]; colors[i].blue = blueMap[i]; @@ -652,11 +655,12 @@ GetVisual() else { xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), xVisual, AllocNone); - pixels = (u_long *) malloc(colormapSize * sizeof(u_long)); + pixels = (unsigned long *) + malloc(colormapSize * sizeof(unsigned long)); MCHECK(pixels); (void) XAllocColorCells(xDisplay, xColormap, True, NULL, 0, pixels, colormapSize); - basePixel = (u_char) pixels[0]; + basePixel = (unsigned char) pixels[0]; free(pixels); } XStoreColors(xDisplay, xColormap, colors, colormapSize); @@ -733,14 +737,15 @@ void GetTIFFImage() { int pixel_map[3], red_shift, green_shift, blue_shift; - register u_char *scan_line, *output_p, *input_p; - register int i, j, s; + char *scan_line, *output_p, *input_p; + uint32 i, j; + uint16 s; - scan_line = (u_char *) malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); + scan_line = (char *) malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); MCHECK(scan_line); if ((tfImageDepth == 32) || (tfImageDepth == 24)) { - output_p = imageMemory = (u_char *) + output_p = imageMemory = (char *) malloc(tfImageWidth * tfImageHeight * 4); MCHECK(imageMemory); @@ -792,7 +797,7 @@ GetTIFFImage() } } else { if (xImageDepth == tfImageDepth) { - output_p = imageMemory = (u_char *) + output_p = imageMemory = (char *) malloc(tfBytesPerRow * tfImageHeight); MCHECK(imageMemory); @@ -800,7 +805,7 @@ GetTIFFImage() if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) break; } else if ((xImageDepth == 8) && (tfImageDepth == 4)) { - output_p = imageMemory = (u_char *) + output_p = imageMemory = (char *) malloc(tfBytesPerRow * 2 * tfImageHeight + 2); MCHECK(imageMemory); @@ -820,7 +825,7 @@ GetTIFFImage() } } } else if ((xImageDepth == 8) && (tfImageDepth == 2)) { - output_p = imageMemory = (u_char *) + output_p = imageMemory = (char *) malloc(tfBytesPerRow * 4 * tfImageHeight + 4); MCHECK(imageMemory); @@ -837,7 +842,7 @@ GetTIFFImage() } } } else if ((xImageDepth == 4) && (tfImageDepth == 2)) { - output_p = imageMemory = (u_char *) + output_p = imageMemory = (char *) malloc(tfBytesPerRow * 2 * tfImageHeight + 2); MCHECK(imageMemory); @@ -1273,3 +1278,13 @@ Usage() fprintf(stderr, "\t[-verbose (True | False)]\n"); exit(0); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/dbs/xtiff/xtifficon.h b/libs/tiff-4.0.2/contrib/dbs/xtiff/xtifficon.h similarity index 91% rename from libs/tiff-3.8.2/contrib/dbs/xtiff/xtifficon.h rename to libs/tiff-4.0.2/contrib/dbs/xtiff/xtifficon.h index 8ee16674c6..3eac48efc5 100644 --- a/libs/tiff-3.8.2/contrib/dbs/xtiff/xtifficon.h +++ b/libs/tiff-4.0.2/contrib/dbs/xtiff/xtifficon.h @@ -12,3 +12,10 @@ static char xtifficon_bits[] = { 0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f, 0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f, 0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff}; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/iptcutil/Makefile.am b/libs/tiff-4.0.2/contrib/iptcutil/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/iptcutil/Makefile.am rename to libs/tiff-4.0.2/contrib/iptcutil/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/iptcutil/README b/libs/tiff-4.0.2/contrib/iptcutil/README similarity index 100% rename from libs/tiff-3.8.2/contrib/iptcutil/README rename to libs/tiff-4.0.2/contrib/iptcutil/README diff --git a/libs/tiff-3.8.2/contrib/iptcutil/iptcutil.c b/libs/tiff-4.0.2/contrib/iptcutil/iptcutil.c similarity index 98% rename from libs/tiff-3.8.2/contrib/iptcutil/iptcutil.c rename to libs/tiff-4.0.2/contrib/iptcutil/iptcutil.c index b6333cb4d2..eaee188f2d 100644 --- a/libs/tiff-3.8.2/contrib/iptcutil/iptcutil.c +++ b/libs/tiff-4.0.2/contrib/iptcutil/iptcutil.c @@ -1,11 +1,10 @@ -/* $Id: iptcutil.c,v 1.4 2004/09/21 13:34:39 dron Exp $ */ +/* $Id: iptcutil.c,v 1.8 2011-05-08 00:44:18 fwarmerdam Exp $ */ #include "tif_config.h" #include #include #include -#include #include #ifdef HAVE_STRINGS_H @@ -294,7 +293,10 @@ int formatIPTC(FILE *ifile, FILE *ofile) { c = str[tagindx] = getc(ifile); if (c == EOF) - return -1; + { + free(str); + return -1; + } } str[ taglen ] = 0; @@ -332,12 +334,12 @@ char *super_fgets(char *b, int *blen, FILE *file) c=fgetc(file); if (c == EOF || c == '\n') break; - if (((int)q - (int)b + 1 ) >= (int) len) + if (((long)q - (long)b + 1 ) >= (long) len) { - int + long tlen; - tlen=(int)q-(int)b; + tlen=(long)q-(long)b; len<<=1; b=(char *) realloc((char *) b,(len+2)); if ((char *) b == (char *) NULL) @@ -352,7 +354,7 @@ char *super_fgets(char *b, int *blen, FILE *file) int tlen; - tlen=(int)q - (int)b; + tlen=(long)q - (long)b; if (tlen == 0) return (char *) NULL; b[tlen] = '\0'; @@ -385,7 +387,7 @@ int main(int argc, char *argv[]) if( argc < 2 ) { - printf(usage); + puts(usage); return 1; } @@ -444,7 +446,7 @@ int main(int argc, char *argv[]) } else { - printf(usage); + puts(usage); return 1; } } @@ -932,3 +934,10 @@ byebye: return 0; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/iptcutil/test.iptc b/libs/tiff-4.0.2/contrib/iptcutil/test.iptc similarity index 100% rename from libs/tiff-3.8.2/contrib/iptcutil/test.iptc rename to libs/tiff-4.0.2/contrib/iptcutil/test.iptc diff --git a/libs/tiff-3.8.2/contrib/iptcutil/test.txt b/libs/tiff-4.0.2/contrib/iptcutil/test.txt similarity index 100% rename from libs/tiff-3.8.2/contrib/iptcutil/test.txt rename to libs/tiff-4.0.2/contrib/iptcutil/test.txt diff --git a/libs/tiff-3.8.2/contrib/mfs/Makefile.am b/libs/tiff-4.0.2/contrib/mfs/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/mfs/Makefile.am rename to libs/tiff-4.0.2/contrib/mfs/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/mfs/README b/libs/tiff-4.0.2/contrib/mfs/README similarity index 100% rename from libs/tiff-3.8.2/contrib/mfs/README rename to libs/tiff-4.0.2/contrib/mfs/README diff --git a/libs/tiff-3.8.2/contrib/mfs/mfs_file.c b/libs/tiff-4.0.2/contrib/mfs/mfs_file.c similarity index 99% rename from libs/tiff-3.8.2/contrib/mfs/mfs_file.c rename to libs/tiff-4.0.2/contrib/mfs/mfs_file.c index 53a7c4c205..6675e2a38a 100644 --- a/libs/tiff-3.8.2/contrib/mfs/mfs_file.c +++ b/libs/tiff-4.0.2/contrib/mfs/mfs_file.c @@ -577,3 +577,10 @@ static void mem_init () } } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/pds/Makefile.am b/libs/tiff-4.0.2/contrib/pds/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/pds/Makefile.am rename to libs/tiff-4.0.2/contrib/pds/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/pds/README b/libs/tiff-4.0.2/contrib/pds/README similarity index 100% rename from libs/tiff-3.8.2/contrib/pds/README rename to libs/tiff-4.0.2/contrib/pds/README diff --git a/libs/tiff-3.8.2/contrib/pds/tif_imageiter.c b/libs/tiff-4.0.2/contrib/pds/tif_imageiter.c similarity index 99% rename from libs/tiff-3.8.2/contrib/pds/tif_imageiter.c rename to libs/tiff-4.0.2/contrib/pds/tif_imageiter.c index c2c67ac087..e025dc5234 100644 --- a/libs/tiff-3.8.2/contrib/pds/tif_imageiter.c +++ b/libs/tiff-4.0.2/contrib/pds/tif_imageiter.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/contrib/pds/tif_imageiter.c,v 1.3 2005/12/21 12:23:13 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/contrib/pds/tif_imageiter.c,v 1.4 2010-06-08 18:55:15 bfriesen Exp $ */ /* * Copyright (c) 1991-1996 Sam Leffler @@ -516,3 +516,10 @@ main(int argc, char **argv) } #endif +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/pds/tif_imageiter.h b/libs/tiff-4.0.2/contrib/pds/tif_imageiter.h similarity index 96% rename from libs/tiff-3.8.2/contrib/pds/tif_imageiter.h rename to libs/tiff-4.0.2/contrib/pds/tif_imageiter.h index 5b7ea40ac5..e7dbe46cc4 100644 --- a/libs/tiff-3.8.2/contrib/pds/tif_imageiter.h +++ b/libs/tiff-4.0.2/contrib/pds/tif_imageiter.h @@ -55,3 +55,10 @@ struct _TIFFImageIter { ImageIterTileSeparateRoutine separate; } callback; /* fn to exec for each block */ }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/pds/tif_pdsdirread.c b/libs/tiff-4.0.2/contrib/pds/tif_pdsdirread.c similarity index 99% rename from libs/tiff-3.8.2/contrib/pds/tif_pdsdirread.c rename to libs/tiff-4.0.2/contrib/pds/tif_pdsdirread.c index ce197d5eec..37e513ae33 100644 --- a/libs/tiff-3.8.2/contrib/pds/tif_pdsdirread.c +++ b/libs/tiff-4.0.2/contrib/pds/tif_pdsdirread.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/contrib/pds/tif_pdsdirread.c,v 1.3 2005/12/21 12:23:13 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/contrib/pds/tif_pdsdirread.c,v 1.4 2010-06-08 18:55:15 bfriesen Exp $ */ /* * Copyright (c) 1988-1996 Sam Leffler @@ -1122,3 +1122,10 @@ ChopUpSingleUncompressedStrip(TIFF* tif) td->td_stripoffset = newoffsets; } #endif /* STRIPCHOP_SUPPORT */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/pds/tif_pdsdirwrite.c b/libs/tiff-4.0.2/contrib/pds/tif_pdsdirwrite.c similarity index 99% rename from libs/tiff-3.8.2/contrib/pds/tif_pdsdirwrite.c rename to libs/tiff-4.0.2/contrib/pds/tif_pdsdirwrite.c index 9a80c04c32..3c632da695 100644 --- a/libs/tiff-3.8.2/contrib/pds/tif_pdsdirwrite.c +++ b/libs/tiff-4.0.2/contrib/pds/tif_pdsdirwrite.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.3 2005/12/21 12:23:13 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.4 2010-06-08 18:55:15 bfriesen Exp $ */ /* When writing data to TIFF files, it is often useful to store application- specific data in a private TIFF directory so that the tags don't need to @@ -962,3 +962,10 @@ TIFFLinkDirectory(TIFF* tif) } return (1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/ras/Makefile.am b/libs/tiff-4.0.2/contrib/ras/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/ras/Makefile.am rename to libs/tiff-4.0.2/contrib/ras/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/ras/README b/libs/tiff-4.0.2/contrib/ras/README similarity index 100% rename from libs/tiff-3.8.2/contrib/ras/README rename to libs/tiff-4.0.2/contrib/ras/README diff --git a/libs/tiff-3.8.2/contrib/ras/ras2tif.c b/libs/tiff-4.0.2/contrib/ras/ras2tif.c similarity index 98% rename from libs/tiff-3.8.2/contrib/ras/ras2tif.c rename to libs/tiff-4.0.2/contrib/ras/ras2tif.c index b11b879982..c44b313e34 100644 --- a/libs/tiff-3.8.2/contrib/ras/ras2tif.c +++ b/libs/tiff-4.0.2/contrib/ras/ras2tif.c @@ -245,3 +245,10 @@ main(argc, argv) exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/ras/tif2ras.c b/libs/tiff-4.0.2/contrib/ras/tif2ras.c similarity index 98% rename from libs/tiff-3.8.2/contrib/ras/tif2ras.c rename to libs/tiff-4.0.2/contrib/ras/tif2ras.c index 6c7aae91f5..e1c321df14 100644 --- a/libs/tiff-3.8.2/contrib/ras/tif2ras.c +++ b/libs/tiff-4.0.2/contrib/ras/tif2ras.c @@ -1,5 +1,5 @@ #ifndef lint -static char id[] = "$Id: tif2ras.c,v 1.2 1999/11/28 20:15:36 mwelles Exp $"; +static char id[] = "$Id: tif2ras.c,v 1.3 2010-06-08 18:55:15 bfriesen Exp $"; #endif /*- * tif2ras.c - Converts from a Tagged Image File Format image to a Sun Raster. @@ -335,3 +335,10 @@ main(argc, argv) exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/stream/Makefile.am b/libs/tiff-4.0.2/contrib/stream/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/stream/Makefile.am rename to libs/tiff-4.0.2/contrib/stream/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/stream/README b/libs/tiff-4.0.2/contrib/stream/README similarity index 100% rename from libs/tiff-3.8.2/contrib/stream/README rename to libs/tiff-4.0.2/contrib/stream/README diff --git a/libs/tiff-3.8.2/contrib/stream/tiffstream.cpp b/libs/tiff-4.0.2/contrib/stream/tiffstream.cpp similarity index 98% rename from libs/tiff-3.8.2/contrib/stream/tiffstream.cpp rename to libs/tiff-4.0.2/contrib/stream/tiffstream.cpp index 98eb229981..ffff687581 100644 --- a/libs/tiff-3.8.2/contrib/stream/tiffstream.cpp +++ b/libs/tiff-4.0.2/contrib/stream/tiffstream.cpp @@ -229,4 +229,10 @@ TiffStream::isOpen(thandle_t fd) return (ts->m_inStream != NULL || ts->m_outStream != NULL || ts->m_ioStream != NULL); -} \ No newline at end of file +}/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/stream/tiffstream.h b/libs/tiff-4.0.2/contrib/stream/tiffstream.h similarity index 92% rename from libs/tiff-3.8.2/contrib/stream/tiffstream.h rename to libs/tiff-4.0.2/contrib/stream/tiffstream.h index 58f9e035ea..a583ae24b2 100644 --- a/libs/tiff-3.8.2/contrib/stream/tiffstream.h +++ b/libs/tiff-4.0.2/contrib/stream/tiffstream.h @@ -60,4 +60,11 @@ private: }; -#endif // _TIFF_STREAM_H_ \ No newline at end of file +#endif // _TIFF_STREAM_H_ +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/tags/Makefile.am b/libs/tiff-4.0.2/contrib/tags/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/tags/Makefile.am rename to libs/tiff-4.0.2/contrib/tags/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/tags/README b/libs/tiff-4.0.2/contrib/tags/README similarity index 100% rename from libs/tiff-3.8.2/contrib/tags/README rename to libs/tiff-4.0.2/contrib/tags/README diff --git a/libs/tiff-3.8.2/contrib/tags/listtif.c b/libs/tiff-4.0.2/contrib/tags/listtif.c similarity index 85% rename from libs/tiff-3.8.2/contrib/tags/listtif.c rename to libs/tiff-4.0.2/contrib/tags/listtif.c index 2ea12cea71..605de84377 100644 --- a/libs/tiff-3.8.2/contrib/tags/listtif.c +++ b/libs/tiff-4.0.2/contrib/tags/listtif.c @@ -30,3 +30,10 @@ failure: exit (-1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/tags/maketif.c b/libs/tiff-4.0.2/contrib/tags/maketif.c similarity index 94% rename from libs/tiff-3.8.2/contrib/tags/maketif.c rename to libs/tiff-4.0.2/contrib/tags/maketif.c index 99a9ef037a..e965201a60 100644 --- a/libs/tiff-3.8.2/contrib/tags/maketif.c +++ b/libs/tiff-4.0.2/contrib/tags/maketif.c @@ -68,3 +68,10 @@ void WriteImage(TIFF *tif) +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/tags/xtif_dir.c b/libs/tiff-4.0.2/contrib/tags/xtif_dir.c similarity index 98% rename from libs/tiff-3.8.2/contrib/tags/xtif_dir.c rename to libs/tiff-4.0.2/contrib/tags/xtif_dir.c index 7b9ef91588..e67a6abf78 100644 --- a/libs/tiff-3.8.2/contrib/tags/xtif_dir.c +++ b/libs/tiff-4.0.2/contrib/tags/xtif_dir.c @@ -341,3 +341,10 @@ XTIFFClose(TIFF *tif) _XTIFFFreeDirectory(xt); _TIFFfree(xt); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/tags/xtiffio.h b/libs/tiff-4.0.2/contrib/tags/xtiffio.h similarity index 94% rename from libs/tiff-3.8.2/contrib/tags/xtiffio.h rename to libs/tiff-4.0.2/contrib/tags/xtiffio.h index 2aea724d62..e8600df070 100644 --- a/libs/tiff-3.8.2/contrib/tags/xtiffio.h +++ b/libs/tiff-4.0.2/contrib/tags/xtiffio.h @@ -50,3 +50,10 @@ extern void XTIFFClose(TIFF *tif); #endif /* __xtiffio_h */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/tags/xtiffiop.h b/libs/tiff-4.0.2/contrib/tags/xtiffiop.h similarity index 95% rename from libs/tiff-3.8.2/contrib/tags/xtiffiop.h rename to libs/tiff-4.0.2/contrib/tags/xtiffiop.h index 0d3f1f2cc9..9d534a8343 100644 --- a/libs/tiff-3.8.2/contrib/tags/xtiffiop.h +++ b/libs/tiff-4.0.2/contrib/tags/xtiffiop.h @@ -63,3 +63,10 @@ typedef struct xtiff xtiff; #define XTIFF_INITIALIZED 0x80000000 #endif /* __xtiffiop_h */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/win_dib/Makefile.am b/libs/tiff-4.0.2/contrib/win_dib/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/contrib/win_dib/Makefile.am rename to libs/tiff-4.0.2/contrib/win_dib/Makefile.am diff --git a/libs/tiff-3.8.2/contrib/win_dib/Makefile.w95 b/libs/tiff-4.0.2/contrib/win_dib/Makefile.w95 similarity index 100% rename from libs/tiff-3.8.2/contrib/win_dib/Makefile.w95 rename to libs/tiff-4.0.2/contrib/win_dib/Makefile.w95 diff --git a/libs/tiff-3.8.2/contrib/win_dib/README.Tiffile b/libs/tiff-4.0.2/contrib/win_dib/README.Tiffile similarity index 100% rename from libs/tiff-3.8.2/contrib/win_dib/README.Tiffile rename to libs/tiff-4.0.2/contrib/win_dib/README.Tiffile diff --git a/libs/tiff-3.8.2/contrib/win_dib/README.tiff2dib b/libs/tiff-4.0.2/contrib/win_dib/README.tiff2dib similarity index 100% rename from libs/tiff-3.8.2/contrib/win_dib/README.tiff2dib rename to libs/tiff-4.0.2/contrib/win_dib/README.tiff2dib diff --git a/libs/tiff-3.8.2/contrib/win_dib/Tiffile.cpp b/libs/tiff-4.0.2/contrib/win_dib/Tiffile.cpp similarity index 99% rename from libs/tiff-3.8.2/contrib/win_dib/Tiffile.cpp rename to libs/tiff-4.0.2/contrib/win_dib/Tiffile.cpp index 6e371d3dd0..9d958b1c8e 100644 --- a/libs/tiff-3.8.2/contrib/win_dib/Tiffile.cpp +++ b/libs/tiff-4.0.2/contrib/win_dib/Tiffile.cpp @@ -440,3 +440,10 @@ getStripContig1Bit(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (ret); } +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/contrib/win_dib/tiff2dib.c b/libs/tiff-4.0.2/contrib/win_dib/tiff2dib.c similarity index 99% rename from libs/tiff-3.8.2/contrib/win_dib/tiff2dib.c rename to libs/tiff-4.0.2/contrib/win_dib/tiff2dib.c index f5d4040f87..475ef304a1 100644 --- a/libs/tiff-3.8.2/contrib/win_dib/tiff2dib.c +++ b/libs/tiff-4.0.2/contrib/win_dib/tiff2dib.c @@ -370,3 +370,10 @@ WORD DIBNumColors(LPSTR lpDIB) return 0; } } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/html/Makefile.am b/libs/tiff-4.0.2/html/Makefile.am similarity index 95% rename from libs/tiff-3.8.2/html/Makefile.am rename to libs/tiff-4.0.2/html/Makefile.am index 6941dfb0ee..8cb6706cb5 100644 --- a/libs/tiff-3.8.2/html/Makefile.am +++ b/libs/tiff-4.0.2/html/Makefile.am @@ -1,4 +1,3 @@ -# $Id: Makefile.am,v 1.16 2006/03/23 14:54:01 dron Exp $ # # Tag Image File Format (TIFF) Software # @@ -73,7 +72,13 @@ docfiles = \ v3.7.4.html \ v3.8.0.html \ v3.8.1.html \ - v3.8.2.html + v3.8.2.html \ + v3.9.0beta.html \ + v3.9.1.html \ + v3.9.2.html \ + v4.0.0.html \ + v4.0.1.html \ + v4.0.2.html dist_doc_DATA = $(docfiles) diff --git a/libs/tiff-3.8.2/html/TIFFTechNote2.html b/libs/tiff-4.0.2/html/TIFFTechNote2.html similarity index 100% rename from libs/tiff-3.8.2/html/TIFFTechNote2.html rename to libs/tiff-4.0.2/html/TIFFTechNote2.html diff --git a/libs/tiff-3.8.2/html/addingtags.html b/libs/tiff-4.0.2/html/addingtags.html similarity index 99% rename from libs/tiff-3.8.2/html/addingtags.html rename to libs/tiff-4.0.2/html/addingtags.html index 452821c2d0..1eab96339f 100644 --- a/libs/tiff-3.8.2/html/addingtags.html +++ b/libs/tiff-4.0.2/html/addingtags.html @@ -285,7 +285,7 @@ is room for, just increase FIELD_SETLONGS at the top of
-Last updated: $Date: 2004/09/10 14:43:18 $ +Last updated: $Date: 2004-09-10 14:43:18 $ diff --git a/libs/tiff-3.8.2/html/bugs.html b/libs/tiff-4.0.2/html/bugs.html similarity index 63% rename from libs/tiff-3.8.2/html/bugs.html rename to libs/tiff-4.0.2/html/bugs.html index 9eeb8a55dc..345fca0017 100644 --- a/libs/tiff-3.8.2/html/bugs.html +++ b/libs/tiff-4.0.2/html/bugs.html @@ -14,16 +14,26 @@ This software is free. Please let us know when you find a problem or fix a bug.

-Thanks to remotesensing.org, libtiff now uses bugzilla to track bugs. +Thanks to MapTools.org, libtiff now uses +bugzilla to track bugs. All bugs filed in the older bugzilla at +bugzilla.remotesensing.org (pre April 2008) have unfortunately been lost.

If you think you've discovered a bug, please first check to see if it is already known by looking at the list of already reported bugs. You can do so by visiting the buglist at -http://bugzilla.remotesensing.org/buglist.cgi?product=libtiff. Also verify that +http://bugzilla.maptools.org/buglist.cgi?product=libtiff. Also verify that the problem is still reproducable with the current development software from CVS. -

-If you'd like to enter a new bug, you can do so at http://bugzilla.remotesensing.org/enter_bug.cgi?product=libtiff. +

+If you'd like to enter a new bug, you can do so at +http://bugzilla.maptools.org/enter_bug.cgi?product=libtiff. +

+If you'd like to inform us about some kind of security issue that should not +be disclosed for a period of time, then you can contact maintainers directly. +Send a copies of your report to the following people: Frank Warmerdam +<warmerdam@pobox.com>, +Andrey Kiselev +<dron@ak4719.spb.edu>.

Of course, reporting bugs is no substitute for discussion. The @@ -48,6 +58,6 @@ Systems.


-Last updated: $Date: 2005/07/26 14:43:24 $ +Last updated: $Date: 2008-09-03 08:05:04 $ diff --git a/libs/tiff-4.0.2/html/build.html b/libs/tiff-4.0.2/html/build.html new file mode 100644 index 0000000000..ad8e1893de --- /dev/null +++ b/libs/tiff-4.0.2/html/build.html @@ -0,0 +1,524 @@ + + + + +Building the TIFF Software Distribution + + +

Building the Software Distribution

+ +
+This chapter contains step-by-step instructions on how to configure +and build the TIFF software distribution. The software is most +easily built on a UNIX system, but with a little bit of work it can +easily be built and used on other non-UNIX platforms. +
+ +

Building on a UNIX System

+To build the software on a UNIX system you need to first run the +configure shell script that is located in the top level of the +source directory. This script probes the target system for +necessary tools and functions and constructs a build environment in +which the software may be compiled. Once configuration is done, you +simply run make (or gmake) to build the software +and then make install to do the installation; for example: +
+
+hyla% cd ./tiff-4.0.0
+hyla% ./configure
+    ...lots of messages...
+hyla% make
+    ...lots of messages...
+hyla% make check
+    ...lots of messages...
+hyla# make install
+
+Supplied makefiles are dependent on a make utility and a C +(and optionally a C++ compiler), so you will need these tools. +

In general, the software is designed such that the following +should be ``make-able'' in each directory:

+
+
+make [all]      build stuff
+make check      run the test suite
+make install    build&install stuff
+make clean      remove .o files, executables and cruft
+make distclean  remove everything, that can be recreated
+
+Note that after running "make distclean" the +configure script must be run again to create the Makefiles +and other make-related files. +
+

Build Trees

+There are two schemes for configuring and building the software. If +you intend to build the software for only one target system, you +can configure the software so that it is built in the same +directories as the source code. +
+
+hyla% gzip -dc tiff-4.0.0.tar.gz | tar -xf -
+hyla% cd ./tiff-4.0.0
+hyla% ./configure
+hyla% make
+hyla% make check
+hyla% make install
+
+

Otherwise, you can configure a build tree that is parallel to +the source tree hierarchy (or in some completely different place) +but which contains only configured files and files created during +the build procedure.

+
+
+hyla% gzip -dc tiff-4.0.0.tar.gz | tar -xf -
+hyla% mkdir tiff-4.0.0-build
+hyla% cd ./tiff-4.0.0-build
+hyla% ../tiff-4.0.0/configure
+hyla% make
+hyla% make check
+hyla% make install
+
+This second scheme is useful for: +
    +
  • building multiple targets from a single source tree
  • +
  • building from a read-only source tree (e.g. if you receive the +distribution on CD-ROM)
  • +
  • sharing the source files via a network, but building on +multiple systems
  • +
+ +
+

Configuration Options

+The configuration process is critical to the proper compilation, +installation, and operation of the software. The configure script +runs a series of tests to decide whether or not the target system +supports required functionality and, if it does not, whether it can +emulate or workaround the missing functions. This procedure is +fairly complicated and, due to the nonstandard nature of most UNIX +systems, prone to error. The first time that you configure the +software for use you should check the output from the configure +script and look for anything that does not make sense for your +system. +

A second function of the configure script is to set the default +configuration parameters for the software. Of particular note are +the directories where the software is to be installed. By default +the software is installed in the /usr/local hierarchy. To +change this behaviour the appropriate parameters can be specified +on the command line to configure. Run ./configure --help to +get a full list of possible options. Standard installation related +options are shown below.

+
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [/usr/local]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, `make install' will install all the files in
+`/usr/local/bin', `/usr/local/lib' etc.  You can specify
+an installation prefix other than `/usr/local' using `--prefix',
+for instance `--prefix=$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/tiff]
+  --htmldir=DIR           html documentation [DOCDIR]
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+
+ +
+

Configuring Optional Packages/Support

+The TIFF software comes with several packages that are installed +only as needed, or only if specifically configured at the time the +configure script is run. Packages can be configured via the +configure script commandline parameters. +
+
Static/Shared Objects Support
+
--enable-shared[=PKGS]    build shared +libraries [default=yes]
+--enable-static[=PKGS]    build static +libraries [default=yes]
+

These options control whether or not to configure the software +to build a shared and static binaries for the TIFF library. Use of +shared libraries can significantly reduce the disk space needed for +users of the TIFF software. If shared libarries are not used then +the code is statically linked into each application that uses it. +By default both types of binaries is configured.

+

+--enable-rpath             Enable +runtime linker paths (-R libtool option)

+

Add library directories (see other options below) to the TIFF +library run-time linker path.

+

--enable-ld-version-script  Enable linker version +script (default is disabled)

+

Add shared library symbol versioning on ELF-based systems (e.g. +Linux and FreeBSD) which use the GNU linker. This is needed if +several major versions of libtiff might be loaded at once into the +same program.

+
+
JPEG Support
+
--disable-jpeg    disable IJG JPEG +library usage (required for JPEG compression, enabled by default) +--with-jpeg-include-dir=DIR    location of IJG +JPEG library headers +--with-jpeg-lib-dir=DIR    location of IJG JPEG +library binary)
+
The JPEG package enables support for the handling of +TIFF images with JPEG-encoded data. Support for JPEG-encoded data +requires the Independent JPEG Group (IJG) libjpeg +distribution; this software is available at http://www.ijg.org/. configure +script automatically tries to search for a working IJG JPEG +installation. If it fails to find library, JPEG support will be +automatically disabled.If you want specify the exact paths to +library binary and headers, use above switches for that.
+
ZIP Support
+
The ZIP support enables support for the handling of +TIFF images with deflate-encoded data. Support for deflate-encoded +data requires the freely available zlib distribution +written by Jean-loup Gailly and Mark Adler; this software is +available at http://www.zlib.org/. If ZIP support is +enabled the DIRS_LIBINC and DIR_GZLIB parameters +should also be set (see below). By default this package is not +configured.
+
+ +
+ +

Building the Software under Windows 95/98/NT/2000 with MS +VC++

+With Microsoft Visual C++ installed, and properly configured for +commandline use (you will likely need to source VCVARS32.BAT in +AUTOEXEC.bAT or somewhere similar) you should be able to use the +provided makefile.vc. +

The source package is delivered using Unix line termination +conventions, which work with MSVC but do not work with Windows +'notepad'. If you use unzip from the Info-Zip package, you +can extract the files using Windows normal line termination +conventions with a command similar to:

+
+  unzip -aa -a tiff-4.0.0.zip
+
+

By default libtiff expects that a pre-built zlib and jpeg +library are provided by the user. If this is not the case, then you +may edit libtiff\tiffconf.h using a text editor (e.g. notepad) and +comment out the entries for JPEG_SUPPORT, PIXARLOG_SUPPORT, and +ZIP_SUPPORT. Ignore the comment at the top of the file which says +that it has no influence on the build, because the statement is not +true for Windows. However, by taking this approach, libtiff will +not be able to open some TIFF files.

+

To build using the provided makefile.vc you may use:

+
+  C:\tiff-4.0.0> nmake /f makefile.vc clean
+  C:\tiff-4.0.0> nmake /f makefile.vc
+
+    or (the hard way)
+
+  C:\tiff-4.0.0> cd port
+  C:\tiff-4.0.0\port> nmake /f makefile.vc clean
+  C:\tiff-4.0.0\port> nmake /f makefile.vc
+  C:\tiff-4.0.0> cd ../libtiff
+  C:\tiff-4.0.0\libtiff> nmake /f makefile.vc clean
+  C:\tiff-4.0.0\libtiff> nmake /f makefile.vc
+  C:\tiff-4.0.0\libtiff> cd ..\tools
+  C:\tiff-4.0.0\tools> nmake /f makefile.vc clean
+  C:\tiff-4.0.0\tools> nmake /f makefile.vc
+
+

This will build the library file +libtiff\libtiff\libtiff.lib. This can be used in Win32 +programs. You may want to adjust the build options before start +compiling. All parameters contained in the nmake.opt +file.This is a plain text file you can open with your favorite text +editor.

+

The makefile also builds a DLL (libtiff.dll) with an associated +import library (libtiff_i.lib). Any builds using libtiff will need +to include the LIBTIFF\LIBTIFF directory in the include path.

+

The libtiff\tools\makefile.vc should build .exe's for +all the standard TIFF tool programs.

+
+ +

Building the Software on a VMS System

+The VMS port was done by Karsten Spang (krs@kampsax.dk), who also "sort of" +maintains it. The VMS specific files are not in the main +directories. Instead they are placed under +[.CONTRIB.VMS...] in the distribution tree. Installation: +It is assumed that you have unpacked the tar file into a VMS +directory tree, in this text called DISK:[TIFF]. +
    +
  1. Move the VMS specific files to their proper directories. +
    +$ SET DEFAULT DISK:[TIFF.CONTRIB.VMS]
    +$ RENAME [.LIBTIFF]*.* [-.-.LIBTIFF]
    +$ RENAME [.TOOLS]*.* [-.-.TOOLS]
    +
  2. +
  3. Compile the library. +
    +$ SET DEFAULT DISK:[TIFF.LIBTIFF]
    +$ @MAKEVMS
    +
  4. +
  5. Compile the tools. +
    +$ SET DEFAULT DISK:[TIFF.TOOLS]
    +$ @MAKEVMS
    +
  6. +
  7. Define the programs. +
    +$ DEFINE TIFFSHR DISK:[TIFF.LIBTIFF]TIFFSHR
    +$ FAX2PS    :==$DISK:[TIFF.TOOLS]FAX2PS
    +$ FAX2TIFF  :==$DISK:[TIFF.TOOLS]FAX2TIFF
    +$ GIF2TIFF  :==$DISK:[TIFF.TOOLS]GIF2TIFF
    +$ PAL2RGB   :==$DISK:[TIFF.TOOLS]PAL2RGB
    +$ PPM2TIFF  :==$DISK:[TIFF.TOOLS]PPM2TIFF
    +$ RAS2TIFF  :==$DISK:[TIFF.TOOLS]RAS2TIFF
    +$ RGB2YCBCR :==$DISK:[TIFF.TOOLS]RGB2YCBCR
    +$ THUMBNAIL :==$DISK:[TIFF.TOOLS]THUMBNAIL
    +$ TIFF2BW   :==$DISK:[TIFF.TOOLS]TIFF2BW
    +$ TIFF2PS   :==$DISK:[TIFF.TOOLS]TIFF2PS
    +$ TIFFCMP   :==$DISK:[TIFF.TOOLS]TIFFCMP
    +$ TIFFCP    :==$DISK:[TIFF.TOOLS]TIFFCP
    +$ TIFFDITHER:==$DISK:[TIFF.TOOLS]TIFFDITHER
    +$ TIFFDUMP  :==$DISK:[TIFF.TOOLS]TIFFDUMP
    +$ TIFFINFO  :==$DISK:[TIFF.TOOLS]TIFFINFO
    +$ TIFFMEDIAN:==$DISK:[TIFF.TOOLS]TIFFMEDIAN
    +$ TIFFSPLIT :==$DISK:[TIFF.TOOLS]TIFFSPLIT
    +$ YCBCR     :==$DISK:[TIFF.TOOLS]YCBCR
    +
  8. +
+You will want to add these lines to your LOGIN.COM file, +after changing the name of the directory that you have used on your +machine. +

This release has been tested on OpenVMS/VAX 5.5-2, using VAX C +3.2. A previous release was tested under OpenVMS/AXP ?.? using DEC +C ?.?, it is believed that this release as well works on AXP. The +code contains some GNU C specific things. This does *not* imply, +however, that the VAX/GCC configuration has been tested, *it has +not*.

+

The command procedures (MAKEVMS.COM) for building the +library and tools, is believed to choose the correct options for +the VAX and AXP cases automatically.

+

On the AXP, IEEE floating point is used by default. If you want +VAX floating point, remove the /FLOAT=IEEE_FLOAT +qualifier, and change HAVE_IEEEFP=1 to +HAVE_IEEEFP=0 in the MAKEVMS.COM files in both +the libtiff and tools directories.

+

Compiling your own program on a VMS system:

+When compiling a source file in which you "#include +<tiffio.h>", use the following command +
+    $ CC/INCLUDE=DISK:[TIFF.LIBTIFF]
+
+This ensures that the header file is found. On the AXP, also add +/FLOAT=IEEE_FLOAT (if used when building the library). +

Linking your own program to the TIFF library on a VMS +system:

+You can link to the library in two ways: Either using the shareable +library, or using the object library. On the VAX these +possibilities are: +
    +
  1. Using the shareable TIFF library. +
    +$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS,SYS$INPUT:/OPTIONS
    +    SYS$SHARE:VAXCRTL/SHAREABLE
    +
  2. +
  3. Using the TIFF object library. +
    +$ LINK MY_PROGRAM, -
    +    DISK:[TIFF.LIBTIFF]TIFF/LIBRARY/INCLUDE=(TIF_FAX3SM,TIF_CODEC), -
    +    SYS$INPUT:/OPTIONS
    +    SYS$SHARE:VAXCRTL/SHAREABLE
    +
  4. +
+On AXP (and possibly also using DEC C on VAX) the corresponding +commands are +
    +
  1. Using the shareable TIFF library. +
    +$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS
    +
  2. +
  3. Using the TIFF object library. +
    +$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/LIBRARY
    +
  4. +
+Method 1 uses the shortest link time and smallest .EXE +files, but it requires that TIFFSHR is defined as above at +link time and at run time. Using the compilation +procedure above, the tools are linked in this way. +

Method 2 gives somewhat longer link time and larger +.EXE files, but does not require TIFFSHR to be +defined. This method is recommended if you want to run your program +on another machine, and for some reason don't want to have the +library on that machine. If you plan to have more than one program +(including the tools) on the machine, it is recommended that you +copy the library to the other machine and use method 1.

+
+ +

Building the Software on Other Systems

+This section contains information that might be useful if you are +working on a non-UNIX system that is not directly supported. All +library-related files described below are located in the +libtiff directory. +

The library requires two files that are generated +on-the-fly. The file tif_fax3sm.c has the state +tables for the Group 3 and Group 4 decoders. This file is generated +by the mkg3states program on a UNIX system; for +example,

+
+
+
+cd libtiff
+cc -o mkg3states mkg3states.c
+rm -f tif_fax3sm.c
+./mkg3states -c const tif_fax3sm.c
+
+
+The -c option can be used to control whether or not the +resutling tables are generated with a const declaration. +The -s option can be used to specify a C storage class for +the table declarations. The -b option can be used to force +data values to be explicitly bracketed with ``{}'' (apparently +needed for some MS-Windows compilers); otherwise the structures are +emitted in as compact a format as possible. Consult the source code +for this program if you have questions. +

The second file required to build the library, version.h, +contains the version information returned by the +TIFFGetVersion routine. This file is built on most systems +using the mkversion program and the contents of the +VERSION and tiff.alpha files; for example,

+
+
+cd libtiff
+cc -o mkversion mkversion.c
+rm -f version.h
+./mkversion -v ../VERSION -a ../dist/tiff.alpha version.h
+
+

Otherwise, when building the library on a non-UNIX system be +sure to consult the files tiffcomp.h and tiffconf.h. +The former contains system compatibility definitions while the +latter is provided so that the software configuration can be +controlled on systems that do not support the make facility for +building the software.

+

Systems without a 32-bit compiler may not be able to handle some +of the codecs in the library; especially the Group 3 and 4 decoder. +If you encounter problems try disabling support for a particular +codec; consult the documentation.

+

Programs in the tools directory are written to assume an ANSI C +compilation environment. There may be a few POSIX'isms as well. The +code in the port directory is provided to emulate routines +that may be missing on some systems. On UNIX systems the +configure script automatically figures out which routines +are not present on a system and enables the use of the equivalent +emulation routines from the port directory. It may be +necessary to manually do this work on a non-UNIX system.

+
+

Checking out the Software

+

Assuming you have working versions of tiffgt and +tiffsv, you can just use them to view any of the sample +images available for testing (see the section +on obtaining the test images). Otherwise, you can do a cursory +check of the library with the tiffcp and tiffcmp +programs. For example,

+
+
+tiffcp -lzw cramps.tif x.tif
+tiffcmp cramps.tif x.tif
+
+

(tiffcmp should be silent if the files compare +correctly).

+
+

Table of Contents

+The following files makup the core library: +
+libtiff/tiff.h                  TIFF spec definitions
+libtiff/tiffcomp.h              non-UNIX OS-compatibility definitions
+libtiff/tiffconf.h              non-UNIX configuration definitions
+libtiff/tiffio.h                public TIFF library definitions
+libtiff/tiffiop.h               private TIFF library definitions
+libtiff/t4.h                    CCITT Group 3/4 code tables+definitions
+libtiff/tif_dir.h               private defs for TIFF directory handling
+libtiff/tif_fax3.h              CCITT Group 3/4-related definitions
+libtiff/tif_predict.h           private defs for Predictor tag support
+libtiff/uvcode.h                LogL/LogLuv codec-specific definitions
+libtiff/version.h               version string (generated by Makefile)
+libtiff/tif_apple.c             Apple-related OS support
+libtiff/tif_atari.c             Atari-related OS support
+libtiff/tif_aux.c               auxilary directory-related functions
+libtiff/tif_close.c             close an open TIFF file
+libtiff/tif_codec.c             configuration table of builtin codecs
+libtiff/tif_compress.c          compression scheme support
+libtiff/tif_dir.c               directory tag interface code
+libtiff/tif_dirinfo.c           directory known tag support code
+libtiff/tif_dirread.c           directory reading code
+libtiff/tif_dirwrite.c          directory writing code
+libtiff/tif_dumpmode.c          "no" compression codec
+libtiff/tif_error.c             library error handler
+libtiff/tif_fax3.c              CCITT Group 3 and 4 codec
+libtiff/tif_fax3sm.c            G3/G4 state tables (generated by mkg3states)
+libtiff/tif_flush.c             i/o and directory state flushing
+libtiff/tif_getimage.c          TIFFRGBAImage support
+libtiff/tif_jpeg.c              JPEG codec (interface to the IJG distribution)
+libtiff/tif_luv.c               SGI LogL/LogLuv codec
+libtiff/tif_lzw.c               LZW codec
+libtiff/tif_msdos.c             MSDOS-related OS support
+libtiff/tif_next.c              NeXT 2-bit scheme codec (decoding only)
+libtiff/tif_open.c              open and simply query code
+libtiff/tif_packbits.c          Packbits codec
+libtiff/tif_pixarlog.c          Pixar codec
+libtiff/tif_predict.c           Predictor tag support
+libtiff/tif_print.c             directory printing support
+libtiff/tif_read.c              image data reading support
+libtiff/tif_strip.c             some strip-related code
+libtiff/tif_swab.c              byte and bit swapping support
+libtiff/tif_thunder.c           Thunderscan codec (decoding only)
+libtiff/tif_tile.c              some tile-related code
+libtiff/tif_unix.c              UNIX-related OS support
+libtiff/tif_version.c           library version support
+libtiff/tif_vms.c               VMS-related OS support
+libtiff/tif_warning.c           library warning handler
+libtiff/tif_win3.c              Windows-3.1-related OS support
+libtiff/tif_win32.c             Win32 (95/98/NT) related OS support
+libtiff/tif_write.c             image data writing support
+libtiff/tif_zip.c               Deflate codec
+
+libtiff/mkg3states.c            program to generate G3/G4 decoder state tables
+libtiff/mkspans.c               program to generate black-white span tables
+libtiff/mkversion.c             program to generate libtiff/version.h.
+
+
+Last updated: $Date: 2012-02-18 21:36:31 $ + + diff --git a/libs/tiff-3.8.2/html/contrib.html b/libs/tiff-4.0.2/html/contrib.html similarity index 98% rename from libs/tiff-3.8.2/html/contrib.html rename to libs/tiff-4.0.2/html/contrib.html index d138900a8b..e864e73d9e 100644 --- a/libs/tiff-3.8.2/html/contrib.html +++ b/libs/tiff-4.0.2/html/contrib.html @@ -203,7 +203,7 @@ their authors.


-Last updated: $Date: 2006/01/03 01:42:30 $ +Last updated: $Date: 2006-01-03 01:42:30 $ diff --git a/libs/tiff-3.8.2/html/document.html b/libs/tiff-4.0.2/html/document.html similarity index 88% rename from libs/tiff-3.8.2/html/document.html rename to libs/tiff-4.0.2/html/document.html index e3e754fb62..fc7ee55b08 100644 --- a/libs/tiff-3.8.2/html/document.html +++ b/libs/tiff-4.0.2/html/document.html @@ -14,8 +14,8 @@ TIFF Documentation

A copy of the 6.0 specification is available from Adobe at http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf, or from the libtiff -ftp site at -ftp://ftp.remotesensing.org/pub/libtiff/TIFF6.pdf.

+ftp site at +ftp://ftp.remotesensing.org/pub/libtiff/doc/TIFF6.pdf.

Draft TIFF Technical Note #2 covers problems @@ -45,7 +45,7 @@ a TIFF variation supporting files larger than 4GB.


- Last updated: $Date: 2004/12/02 14:51:19 $ + Last updated: $Date: 2006-07-10 18:13:52 $
diff --git a/libs/tiff-3.8.2/html/images.html b/libs/tiff-4.0.2/html/images.html similarity index 96% rename from libs/tiff-3.8.2/html/images.html rename to libs/tiff-4.0.2/html/images.html index 150ed0c42a..24acf25c76 100644 --- a/libs/tiff-3.8.2/html/images.html +++ b/libs/tiff-4.0.2/html/images.html @@ -35,7 +35,7 @@ of images with different storage characteristics.


-Last updated: $Date: 2006/01/02 23:50:44 $ +Last updated: $Date: 2006-01-02 23:50:44 $ diff --git a/libs/tiff-3.8.2/html/images/Makefile.am b/libs/tiff-4.0.2/html/images/Makefile.am similarity index 100% rename from libs/tiff-3.8.2/html/images/Makefile.am rename to libs/tiff-4.0.2/html/images/Makefile.am diff --git a/libs/tiff-3.8.2/html/images/back.gif b/libs/tiff-4.0.2/html/images/back.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/back.gif rename to libs/tiff-4.0.2/html/images/back.gif diff --git a/libs/tiff-3.8.2/html/images/bali.jpg b/libs/tiff-4.0.2/html/images/bali.jpg similarity index 100% rename from libs/tiff-3.8.2/html/images/bali.jpg rename to libs/tiff-4.0.2/html/images/bali.jpg diff --git a/libs/tiff-3.8.2/html/images/cat.gif b/libs/tiff-4.0.2/html/images/cat.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/cat.gif rename to libs/tiff-4.0.2/html/images/cat.gif diff --git a/libs/tiff-3.8.2/html/images/cover.jpg b/libs/tiff-4.0.2/html/images/cover.jpg similarity index 100% rename from libs/tiff-3.8.2/html/images/cover.jpg rename to libs/tiff-4.0.2/html/images/cover.jpg diff --git a/libs/tiff-3.8.2/html/images/cramps.gif b/libs/tiff-4.0.2/html/images/cramps.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/cramps.gif rename to libs/tiff-4.0.2/html/images/cramps.gif diff --git a/libs/tiff-3.8.2/html/images/dave.gif b/libs/tiff-4.0.2/html/images/dave.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/dave.gif rename to libs/tiff-4.0.2/html/images/dave.gif diff --git a/libs/tiff-3.8.2/html/images/info.gif b/libs/tiff-4.0.2/html/images/info.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/info.gif rename to libs/tiff-4.0.2/html/images/info.gif diff --git a/libs/tiff-3.8.2/html/images/jello.jpg b/libs/tiff-4.0.2/html/images/jello.jpg similarity index 100% rename from libs/tiff-3.8.2/html/images/jello.jpg rename to libs/tiff-4.0.2/html/images/jello.jpg diff --git a/libs/tiff-3.8.2/html/images/jim.gif b/libs/tiff-4.0.2/html/images/jim.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/jim.gif rename to libs/tiff-4.0.2/html/images/jim.gif diff --git a/libs/tiff-3.8.2/html/images/note.gif b/libs/tiff-4.0.2/html/images/note.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/note.gif rename to libs/tiff-4.0.2/html/images/note.gif diff --git a/libs/tiff-3.8.2/html/images/oxford.gif b/libs/tiff-4.0.2/html/images/oxford.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/oxford.gif rename to libs/tiff-4.0.2/html/images/oxford.gif diff --git a/libs/tiff-3.8.2/html/images/quad.jpg b/libs/tiff-4.0.2/html/images/quad.jpg similarity index 100% rename from libs/tiff-3.8.2/html/images/quad.jpg rename to libs/tiff-4.0.2/html/images/quad.jpg diff --git a/libs/tiff-3.8.2/html/images/ring.gif b/libs/tiff-4.0.2/html/images/ring.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/ring.gif rename to libs/tiff-4.0.2/html/images/ring.gif diff --git a/libs/tiff-3.8.2/html/images/smallliz.jpg b/libs/tiff-4.0.2/html/images/smallliz.jpg similarity index 100% rename from libs/tiff-3.8.2/html/images/smallliz.jpg rename to libs/tiff-4.0.2/html/images/smallliz.jpg diff --git a/libs/tiff-3.8.2/html/images/strike.gif b/libs/tiff-4.0.2/html/images/strike.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/strike.gif rename to libs/tiff-4.0.2/html/images/strike.gif diff --git a/libs/tiff-3.8.2/html/images/warning.gif b/libs/tiff-4.0.2/html/images/warning.gif similarity index 100% rename from libs/tiff-3.8.2/html/images/warning.gif rename to libs/tiff-4.0.2/html/images/warning.gif diff --git a/libs/tiff-3.8.2/html/index.html b/libs/tiff-4.0.2/html/index.html similarity index 74% rename from libs/tiff-3.8.2/html/index.html rename to libs/tiff-4.0.2/html/index.html index e48544ee35..aa38485e48 100644 --- a/libs/tiff-3.8.2/html/index.html +++ b/libs/tiff-4.0.2/html/index.html @@ -24,19 +24,11 @@ Latest Stable Release - v3.8.2 - - - Latest Development Release - v3.8.2 + v4.0.2 Master Download Site - ftp.remotesensing.org, directory pub/libtiff - - - Mirror Download Site - http://libtiff.maptools.org/dl/ + download.osgeo.org, directory libtiff Windows Binaries @@ -53,8 +45,12 @@ Anonymous CVS export CVSROOT=:pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot
- cvs login # use empty password"
- cvs checkout libtiff
+ cvs login
+ (use empty password)
+ cvs checkout libtiff
+ to get the stable libtiff code or
+ cvs checkout -r branch-3-9 libtiff
+ to get the previous stable branch supporting the 3.9.X release series.
@@ -66,23 +62,20 @@

Included in this software distribution is a library, libtiff, for - reading and writing TIFF, a small collection of tools for doing simple - manipulations of TIFF images on UNIX systems, - and documentation on the library and - tools. A small assortment of TIFF-related software for UNIX - that has been contributed by others is also included. + reading and writing TIFF, a small collection of tools for doing + simple manipulations of TIFF images, and documentation on the + library and tools. Libtiff is a portable software, it was built + and tested on various systems: UNIX flavors (Linux, BSD, Solaris, + MacOS X), Windows, and OpenVMS. It should be possible to port + libtiff and additional tools on other OSes.

The library, along with associated tool programs, should handle most of your needs for reading and writing TIFF images on 32- and 64-bit - machines. This software can also be used on older 16-bit systems - though it may require some effort and you may need to leave out some of - the compression support. + machines.

- The software was orginally authored and maintained by Sam Leffler. - While he keeps a fatherly eye on the mailing list, he is no longer - responsible for day to day maintenance. + The software was originally authored and maintained by Sam Leffler.

Questions should be sent to the TIFF mailing list: @@ -94,7 +87,9 @@ The persons responsible for putting up this site and putting together versions >= 3.5.1 are Frank Warmerdam, - Andrey Kiselev and Mike Welles. + Andrey Kiselev, + Bob Friesenhahn, + Joris Van Damme and Lee Howard.

The following sections are included in this documentation: @@ -113,9 +108,16 @@

  • Acknowledgements and copyright issues
  • Man Pages
  • +

    + BigTIFF News +

    +

    - Last updated $Date: 2006/03/23 14:54:01 $. + Last updated $Date: 2012-06-16 00:19:37 $.

    diff --git a/libs/tiff-3.8.2/html/internals.html b/libs/tiff-4.0.2/html/internals.html similarity index 99% rename from libs/tiff-3.8.2/html/internals.html rename to libs/tiff-4.0.2/html/internals.html index 3cc9673125..83d53b089c 100644 --- a/libs/tiff-3.8.2/html/internals.html +++ b/libs/tiff-4.0.2/html/internals.html @@ -565,7 +565,7 @@ the portability of your TIFF files.


    -Last updated: $Date: 2004/09/10 14:47:31 $ +Last updated: $Date: 2004-09-10 14:47:31 $ diff --git a/libs/tiff-3.8.2/html/intro.html b/libs/tiff-4.0.2/html/intro.html similarity index 98% rename from libs/tiff-3.8.2/html/intro.html rename to libs/tiff-4.0.2/html/intro.html index 61c01d4a2d..7b7bb82bf1 100644 --- a/libs/tiff-3.8.2/html/intro.html +++ b/libs/tiff-4.0.2/html/intro.html @@ -62,7 +62,7 @@ application.


    -Last updated: $Date: 1999/08/09 20:21:21 $ +Last updated: $Date: 1999-08-09 20:21:21 $ diff --git a/libs/tiff-3.8.2/html/libtiff.html b/libs/tiff-4.0.2/html/libtiff.html similarity index 99% rename from libs/tiff-3.8.2/html/libtiff.html rename to libs/tiff-4.0.2/html/libtiff.html index 6a2c42e607..16355ad91e 100644 --- a/libs/tiff-3.8.2/html/libtiff.html +++ b/libs/tiff-4.0.2/html/libtiff.html @@ -741,7 +741,7 @@


    - Last updated: $Date: 2005/12/28 06:53:18 $ + Last updated: $Date: 2005-12-28 06:53:18 $

    diff --git a/libs/tiff-3.8.2/html/man/Makefile.am b/libs/tiff-4.0.2/html/man/Makefile.am similarity index 98% rename from libs/tiff-3.8.2/html/man/Makefile.am rename to libs/tiff-4.0.2/html/man/Makefile.am index 885f9567e4..c14c4dbc5a 100644 --- a/libs/tiff-3.8.2/html/man/Makefile.am +++ b/libs/tiff-4.0.2/html/man/Makefile.am @@ -86,6 +86,7 @@ docfiles = \ tiff2rgba.1.html \ tiffcmp.1.html \ tiffcp.1.html \ + tiffcrop.1.html \ tiffdither.1.html \ tiffdump.1.html \ tiffgt.1.html \ @@ -101,9 +102,9 @@ INDEXSTART = 'Libtiff HTML manpage index $(indexfile) - for i in $^; do \ + for i in $(docfiles); do \ ${ECHO} '
  • '$$i'' >> $(indexfile); \ done ${ECHO} ${INDEXEND} >> $(indexfile) @@ -111,7 +112,7 @@ index: $(docfiles) manpages = $(docfiles:.html=) .PHONY: htmldoc -htmldoc: index +htmldoc: for i in $(manpages); do \ ${GROFF} $(MANSRCDIR)/$$i > $(HTMLMANDIR)/$$i.html; \ done diff --git a/libs/tiff-3.8.2/html/man/TIFFClose.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFClose.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFClose.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFClose.3tiff.html index 0a92e318af..720ca327f7 100644 --- a/libs/tiff-3.8.2/html/man/TIFFClose.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFClose.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFDataWidth.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFDataWidth.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFDataWidth.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFDataWidth.3tiff.html index 5d82ef4965..575e3cb8ca 100644 --- a/libs/tiff-3.8.2/html/man/TIFFDataWidth.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFDataWidth.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFError.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFError.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFError.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFError.3tiff.html index c7453c3eca..721cec7ecd 100644 --- a/libs/tiff-3.8.2/html/man/TIFFError.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFError.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFFlush.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFFlush.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFFlush.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFFlush.3tiff.html index 5e5a510347..742f3aeedc 100644 --- a/libs/tiff-3.8.2/html/man/TIFFFlush.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFFlush.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-4.0.2/html/man/TIFFGetField.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFGetField.3tiff.html new file mode 100644 index 0000000000..bd2f78bb22 --- /dev/null +++ b/libs/tiff-4.0.2/html/man/TIFFGetField.3tiff.html @@ -0,0 +1,1969 @@ + + + + + + + + + +TIFFGetField + + + + +

    TIFFGetField

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +AUTOREGISTERED TAGS
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + +

    TIFFGetField, +TIFFVGetField − get the value(s) of a tag in an open +TIFF file

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFGetField(TIFF *tif, ttag_t +tag, ...)

    + +

    #include +<stdarg.h>

    + +

    int +TIFFVGetField(TIFF *tif, ttag_t +tag, va_list ap)
    +int TIFFGetFieldDefaulted(TIFF *
    tif, +ttag_t tag, ...)
    +int TIFFVGetFieldDefaulted(TIFF *
    tif, +ttag_t tag, va_list ap)

    + +

    DESCRIPTION + +

    + + + +

    TIFFGetField +returns the value of a tag or pseudo-tag associated with the +the current directory of the opened TIFF file +tif. (A pseudo-tag is a parameter that is used +to control the operation of the TIFF library +but whose value is not read or written to the underlying +file.) The file must have been previously opened with +TIFFOpen(3TIFF). The tag is identified by tag, +one of the values defined in the include file tiff.h +(see also the table below). The type and number of values +returned is dependent on the tag being requested. The +programming interface uses a variable argument list as +prescribed by the stdarg(3) interface. The returned +values should only be interpreted if TIFFGetField +returns 1.

    + + +

    TIFFVGetField +is functionally equivalent to TIFFGetField except +that it takes a pointer to a variable argument list. +TIFFVGetField is useful for layering interfaces on +top of the functionality provided by +TIFFGetField.

    + + +

    TIFFGetFieldDefaulted +and TIFFVGetFieldDefaulted are identical to +TIFFGetField and TIFFVGetField, except that if +a tag is not defined in the current directory and it has a +default value, then the default value is returned.

    + +

    The tags +understood by libtiff(3TIFF), the number of parameter +values, and the types for the returned values are shown +below. The data types are specified as in C and correspond +to the types used to specify tag values to +TIFFSetField(3TIFF). Remember that +TIFFGetField returns parameter values, so all the +listed data types are pointers to storage where values +should be returned. Consult the TIFF +specification (or relevant industry specification) for +information on the meaning of each tag and their possible +values.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +

    Tag Name

    + + +

    Count

    +
    + + +

    Types

    + + +

    Notes

    + + +

    TIFFTAG_ARTIST

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_BADFAXLINES

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_BITSPERSAMPLE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_CLEANFAXDATA

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_COLORMAP

    + + +

    3

    +
    + + +

    uint16**

    + + +

    1<<BitsPerSample arrays

    + + +

    TIFFTAG_COMPRESSION

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_CONSECUTIVEBADFAXLINES

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_COPYRIGHT

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_DATATYPE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_DATETIME

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_DOCUMENTNAME

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_DOTRANGE

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_EXTRASAMPLES

    + + +

    2

    +
    + + +

    uint16*,uint16**

    + + +

    count & types array

    + + +

    TIFFTAG_FAXFILLFUNC

    + + +

    1

    +
    + + +

    TIFFFaxFillFunc*

    + + +

    G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FAXMODE

    + + +

    1

    +
    + + +

    int*

    + + +

    G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FILLORDER

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_GROUP3OPTIONS

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_GROUP4OPTIONS

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_HALFTONEHINTS

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_HOSTCOMPUTER

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_ICCPROFILE

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, profile data

    + + +

    TIFFTAG_IMAGEDEPTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_IMAGEDESCRIPTION

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_IMAGELENGTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_IMAGEWIDTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_INKNAMES

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_INKSET

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_JPEGCOLORMODE

    + + +

    1

    +
    + + +

    int*

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGQUALITY

    + + +

    1

    +
    + + +

    int*

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGTABLES

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count & tables

    + + +

    TIFFTAG_JPEGTABLESMODE

    + + +

    1

    +
    + + +

    int*

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_MAKE

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_MATTEING

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_MAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_MINSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_MODEL

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_ORIENTATION

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PAGENAME

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_PAGENUMBER

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PHOTOMETRIC

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PHOTOSHOP

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, data

    + + +

    TIFFTAG_PLANARCONFIG

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PREDICTOR

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PRIMARYCHROMATICITIES

    + + +

    1

    +
    + + +

    float**

    + + +

    6-entry array

    + + +

    TIFFTAG_REFERENCEBLACKWHITE

    + + +

    1

    +
    + + +

    float**

    + + +

    6-entry array

    + + +

    TIFFTAG_RESOLUTIONUNIT

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_RICHTIFFIPTC

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, data

    + + +

    TIFFTAG_ROWSPERSTRIP

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_SAMPLEFORMAT

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_SAMPLESPERPIXEL

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_SMAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    double*

    +
    + + +

    TIFFTAG_SMINSAMPLEVALUE

    + + +

    1

    +
    + + +

    double*

    +
    + + +

    TIFFTAG_SOFTWARE

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_STONITS

    + + +

    1

    +
    + + +

    double**

    +
    + + +

    TIFFTAG_STRIPBYTECOUNTS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_STRIPOFFSETS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_SUBFILETYPE

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_SUBIFD

    + + +

    2

    +
    + + +

    uint16*,uint32**

    + + +

    count & offsets array

    + + +

    TIFFTAG_TARGETPRINTER

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_THRESHHOLDING

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_TILEBYTECOUNTS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_TILEDEPTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_TILELENGTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_TILEOFFSETS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_TILEWIDTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_TRANSFERFUNCTION

    + + +

    1 or 3†

    + + +

    uint16**1<<BitsPerSample entry arrays

    + + +

    TIFFTAG_WHITEPOINT

    + + +

    1

    +
    + + +

    float**

    + + +

    2-entry array

    + + +

    TIFFTAG_XMLPACKET

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, data

    + + +

    TIFFTAG_XPOSITION

    + + +

    1

    +
    + + +

    float*

    +
    + + +

    TIFFTAG_XRESOLUTION

    + + +

    1

    +
    + + +

    float*

    +
    + + +

    TIFFTAG_YCBCRCOEFFICIENTS

    + + +

    1

    +
    + + +

    float**

    + + +

    3-entry array

    + + +

    TIFFTAG_YCBCRPOSITIONING

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_YCBCRSUBSAMPLING

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_YPOSITION

    + + +

    1

    +
    + + +

    float*

    +
    + + +

    TIFFTAG_YRESOLUTION

    + + +

    1

    +
    + + +

    float*‡

    +
    + +

    † If +SamplesPerPixel is one, then a single array is +returned; otherwise three arrays are returned.
    +‡ The contents of this field are quite complex. See +The ICC Profile Format Specification, Annex B.3 +"Embedding ICC Profiles in TIFF Files" (available +at http://www.color.org) for an explanation.

    + +

    AUTOREGISTERED TAGS + +

    + + +

    If you +can’t find the tag in the table above that means this +is unsupported tag. But you still be able to read it’s +value if you know the data type of that tag. For example, if +you want to read the LONG value from the tag 33424 and ASCII +string from the tag 36867 you can use the following +code:

    + +

    uint16 count; +
    +void *data;

    + + +

    TIFFGetField(tiff, +33424, &count, &data);
    +printf("Tag %d: %d, count %d0, 33424, *(uint32 *)data, +count);
    +TIFFGetField(tiff, 36867, &count, &data);
    +printf("Tag %d: %s, count %d0, 36867, (char *)data, +count);

    + +

    is not +supported by libtiff(3TIFF), library

    + +

    RETURN VALUES + +

    + + +

    1 is returned +if the tag is defined in the current directory; otherwise a +0 is returned.

    + +

    DIAGNOSTICS + +

    + + +

    All error +messages are directed to the TIFFError(3TIFF) +routine.

    + +

    Unknown +field, tag 0x%x. An unknown tag was supplied.

    + +

    SEE ALSO + +

    + + + +

    TIFFOpen(3TIFF), +TIFFSetField(3TIFF), TIFFSetDirectory(3TIFF), +TIFFReadDirectory(3TIFF), +TIFFWriteDirectory(3TIFF) libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.remotesensing.org/libtiff/

    +
    + + diff --git a/libs/tiff-3.8.2/html/man/TIFFOpen.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFOpen.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFOpen.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFOpen.3tiff.html index 3d3ca66003..2379121f12 100644 --- a/libs/tiff-3.8.2/html/man/TIFFOpen.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFOpen.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFPrintDirectory.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFPrintDirectory.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFPrintDirectory.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFPrintDirectory.3tiff.html index d40011dc66..f4dca6e448 100644 --- a/libs/tiff-3.8.2/html/man/TIFFPrintDirectory.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFPrintDirectory.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFRGBAImage.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFRGBAImage.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFRGBAImage.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFRGBAImage.3tiff.html index 71b7ec8b92..08a9924027 100644 --- a/libs/tiff-3.8.2/html/man/TIFFRGBAImage.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFRGBAImage.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadDirectory.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadDirectory.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFReadDirectory.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadDirectory.3tiff.html index d8663527da..82350ad3ad 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadDirectory.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadDirectory.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadEncodedStrip.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadEncodedStrip.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFReadEncodedStrip.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadEncodedStrip.3tiff.html index 20798dbf60..d5c4c15e65 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadEncodedStrip.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadEncodedStrip.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadEncodedTile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadEncodedTile.3tiff.html similarity index 96% rename from libs/tiff-3.8.2/html/man/TIFFReadEncodedTile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadEncodedTile.3tiff.html index 378bea8904..b42dc0908c 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadEncodedTile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadEncodedTile.3tiff.html @@ -1,5 +1,5 @@ - + @@ -41,8 +41,8 @@ data from an open TIFF file

    #include <tiffio.h>

    int TIFFReadEncodedTile(TIFF *tif, -u_long tile, u_char *buf, -u_long size)

    +ttile_t tile, tdata_t buf, +tsize_t size)

    diff --git a/libs/tiff-3.8.2/html/man/TIFFReadRGBAImage.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadRGBAImage.3tiff.html similarity index 97% rename from libs/tiff-3.8.2/html/man/TIFFReadRGBAImage.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadRGBAImage.3tiff.html index a9a907a076..1ebb09b8b3 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadRGBAImage.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadRGBAImage.3tiff.html @@ -1,5 +1,5 @@ - + @@ -47,12 +47,12 @@ and decode an image into a fixed-format raster

    0xff)

    int TIFFReadRGBAImage(TIFF *tif, -u_long width, u_long height, -u_long *raster, int +uint32 width, uint32 height, +uint32 *raster, int stopOnError)
    int TIFFReadRGBAImageOriented(TIFF *
    tif, -u_long width, u_long height, -u_long *raster, int orientation, +uint32 width, uint32 height, +uint32 *raster, int orientation, int stopOnError)

    diff --git a/libs/tiff-3.8.2/html/man/TIFFReadRGBAStrip.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadRGBAStrip.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFReadRGBAStrip.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadRGBAStrip.3tiff.html index 3ec0776db8..37d36d3c33 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadRGBAStrip.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadRGBAStrip.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadRGBATile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadRGBATile.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFReadRGBATile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadRGBATile.3tiff.html index cff9142106..6bd298a2d3 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadRGBATile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadRGBATile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadRawStrip.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadRawStrip.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFReadRawStrip.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadRawStrip.3tiff.html index 4d9433d4b8..4dd1fbccdb 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadRawStrip.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadRawStrip.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadRawTile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadRawTile.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFReadRawTile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadRawTile.3tiff.html index 916dc2e4a7..e74295bed3 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadRawTile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadRawTile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadScanline.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadScanline.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFReadScanline.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadScanline.3tiff.html index 3ecf88c8d7..e825e4cbf5 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadScanline.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadScanline.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFReadTile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFReadTile.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFReadTile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFReadTile.3tiff.html index f278d8d2ed..be245f88da 100644 --- a/libs/tiff-3.8.2/html/man/TIFFReadTile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFReadTile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFSetDirectory.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFSetDirectory.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFSetDirectory.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFSetDirectory.3tiff.html index 17968534a5..9047b0bcd9 100644 --- a/libs/tiff-3.8.2/html/man/TIFFSetDirectory.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFSetDirectory.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-4.0.2/html/man/TIFFSetField.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFSetField.3tiff.html new file mode 100644 index 0000000000..f160fedd15 --- /dev/null +++ b/libs/tiff-4.0.2/html/man/TIFFSetField.3tiff.html @@ -0,0 +1,1865 @@ + + + + + + + + + +TIFFSetField + + + + +

    TIFFSetField

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + +

    TIFFSetField, +TIFFVSetField − set the value(s) of a tag in a +TIFF file open for writing

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFSetField(TIFF *tif, ttag_t +tag, ...)

    + +

    #include +<stdarg.h>

    + +

    int +TIFFVSetField(TIFF *tif, ttag_t +tag, va_list ap)

    + +

    DESCRIPTION + +

    + + + +

    TIFFSetField +sets the value of a field or pseudo-tag in the current +directory associated with the open TIFF file +tif. (A pseudo-tag is a parameter that is used +to control the operation of the TIFF library +but whose value is not read or written to the underlying +file.) To set the value of a field the file must have been +previously opened for writing with TIFFOpen(3TIFF); +pseudo-tags can be set whether the file was opened for +reading or writing. The field is identified by tag, +one of the values defined in the include file tiff.h +(see also the table below). The actual value is specified +using a variable argument list, as prescribed by the +stdarg(3) interface (or, on some machines, the +varargs(3) interface.)

    + + +

    TIFFVSetField +is functionally equivalent to TIFFSetField except +that it takes a pointer to a variable argument list. +TIFFVSetField is useful for writing routines that are +layered on top of the functionality provided by +TIFFSetField.

    + +

    The tags +understood by libtiff, the number of parameter +values, and the expected types for the parameter values are +shown below. The data types are: char* is +null-terminated string and corresponds to the +ASCII data type; uint16 is an unsigned +16-bit value; uint32 is an unsigned 32-bit value; +uint16* is an array of unsigned 16-bit values. +void* is an array of data values of unspecified +type.

    + +

    Consult the +TIFF specification for information on the +meaning of each tag.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +

    Tag Name

    + + +

    Count

    +
    + + +

    Types

    + + +

    Notes

    + + +

    TIFFTAG_ARTIST

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_BADFAXLINES

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_BITSPERSAMPLE

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_CLEANFAXDATA

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_COLORMAP

    + + +

    3

    +
    + + +

    uint16*

    + + +

    1<<BitsPerSample arrays

    + + +

    TIFFTAG_COMPRESSION

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_CONSECUTIVEBADFAXLINES

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_COPYRIGHT

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_DATETIME

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_DOCUMENTNAME

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_DOTRANGE

    + + +

    2

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_EXTRASAMPLES

    + + +

    2

    +
    + + +

    uint16,uint16*

    + + +

    † count & types array

    + + +

    TIFFTAG_FAXFILLFUNC

    + + +

    1

    +
    + + +

    TIFFFaxFillFunc

    + + +

    G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FAXMODE

    + + +

    1

    +
    + + +

    int

    + + +

    † G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FILLORDER

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_GROUP3OPTIONS

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_GROUP4OPTIONS

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_HALFTONEHINTS

    + + +

    2

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_HOSTCOMPUTER

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_ICCPROFILE

    + + +

    2

    +
    + + +

    uint32,void*

    + + +

    count, profile data

    + + +

    TIFFTAG_IMAGEDEPTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_IMAGEDESCRIPTION

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_IMAGELENGTH

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_IMAGEWIDTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_INKNAMES

    + + +

    2

    +
    + + +

    uint16, char*

    +
    + + +

    TIFFTAG_INKSET

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_JPEGCOLORMODE

    + + +

    1

    +
    + + +

    int

    + + +

    † JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGQUALITY

    + + +

    1

    +
    + + +

    int

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGTABLES

    + + +

    2

    +
    + + +

    uint32*,void*

    + + +

    † count & tables

    + + +

    TIFFTAG_JPEGTABLESMODE

    + + +

    1

    +
    + + +

    int

    + + +

    † JPEG pseudo-tag

    + + +

    TIFFTAG_MAKE

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_MATTEING

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_MAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_MINSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_MODEL

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_ORIENTATION

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_PAGENAME

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_PAGENUMBER

    + + +

    2

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_PHOTOMETRIC

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_PHOTOSHOP

    + + +

    ?

    +
    + + +

    uint32,void*

    + + +

    count, data

    + + +

    TIFFTAG_PLANARCONFIG

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_PREDICTOR

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_PRIMARYCHROMATICITIES

    + + +

    1

    +
    + + +

    float*

    + + +

    6-entry array

    + + +

    TIFFTAG_REFERENCEBLACKWHITE

    + + +

    1

    +
    + + +

    float*

    + + +

    † 6-entry array

    + + +

    TIFFTAG_RESOLUTIONUNIT

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_RICHTIFFIPTC

    + + +

    2

    +
    + + +

    uint32,void*

    + + +

    count, data

    + + +

    TIFFTAG_ROWSPERSTRIP

    + + +

    1

    +
    + + +

    uint32

    + + +

    † must be > 0

    + + +

    TIFFTAG_SAMPLEFORMAT

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_SAMPLESPERPIXEL

    + + +

    1

    +
    + + +

    uint16

    + + +

    † value must be <= 4

    + + +

    TIFFTAG_SMAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    double

    +
    + + +

    TIFFTAG_SMINSAMPLEVALUE

    + + +

    1

    +
    + + +

    double

    +
    + + +

    TIFFTAG_SOFTWARE

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_STONITS

    + + +

    1

    +
    + + +

    double

    + + +

    + + +

    TIFFTAG_SUBFILETYPE

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_SUBIFD

    + + +

    2

    +
    + + +

    uint16,uint32*

    + + +

    count & offsets array

    + + +

    TIFFTAG_TARGETPRINTER

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_THRESHHOLDING

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_TILEDEPTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_TILELENGTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    † must be a multiple of 8

    + + +

    TIFFTAG_TILEWIDTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    † must be a multiple of 8

    + + +

    TIFFTAG_TRANSFERFUNCTION

    + + +

    1 or 3‡ uint16*

    + + +

    1<<BitsPerSample entry arrays

    + + +

    TIFFTAG_WHITEPOINT

    + + +

    1

    +
    + + +

    float*

    + + +

    2-entry array

    + + +

    TIFFTAG_XMLPACKET

    + + +

    2

    +
    + + +

    uint32,void*

    + + +

    count, data

    + + +

    TIFFTAG_XPOSITION

    + + +

    1

    +
    + + +

    float

    +
    + + +

    TIFFTAG_XRESOLUTION

    + + +

    1

    +
    + + +

    float

    +
    + + +

    TIFFTAG_YCBCRCOEFFICIENTS

    + + +

    1

    +
    + + +

    float*

    + + +

    † 3-entry array

    + + +

    TIFFTAG_YCBCRPOSITIONING

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_YCBCRSAMPLING

    + + +

    2

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_YPOSITION

    + + +

    1

    +
    + + +

    float

    +
    + + +

    TIFFTAG_YRESOLUTION

    + + +

    1

    +
    + + +

    float

    +
    + +

    † Tag may not have its +values changed once data is written.
    +‡ If SamplesPerPixel is one, then a single +array is passed; otherwise three arrays should be passed. +
    +* The contents of this field are quite complex. See The +ICC Profile Format Specification, Annex B.3 +"Embedding ICC Profiles in TIFF Files" (available +at http://www.color.org) for an explanation.

    + +

    RETURN VALUES + +

    + + +

    1 is returned +if the operation was successful. Otherwise, 0 is returned if +an error was detected.

    + +

    DIAGNOSTICS + +

    + + +

    All error +messages are directed to the TIFFError(3TIFF) +routine.

    + +

    %s: Cannot +modify tag "%s" while writing. Data has +already been written to the file, so the specified +tag’s value can not be changed. This restriction is +applied to all tags that affect the format of written +data.

    + +

    %d: Bad +value for "%s". An invalid value was supplied +for the named tag.

    + +

    SEE ALSO + +

    + + + +

    TIFFOpen(3TIFF), +TIFFGetField(3TIFF), TIFFSetDirectory(3TIFF), +TIFFWriteDirectory(3TIFF), +TIFFReadDirectory(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library +home page: http://www.remotesensing.org/libtiff/

    +
    + + diff --git a/libs/tiff-3.8.2/html/man/TIFFWarning.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWarning.3tiff.html similarity index 97% rename from libs/tiff-3.8.2/html/man/TIFFWarning.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWarning.3tiff.html index d030df40ac..18f2e8b43c 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWarning.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWarning.3tiff.html @@ -1,5 +1,5 @@ - + @@ -41,7 +41,7 @@ warning interface

    void TIFFWarning(const char *module, const char *fmt, ...)

    -

    #include <stdargh.h>

    +

    #include <stdarg.h>

    typedef void (*TIFFWarningHandler)(const char *module, const char *fmt, diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteDirectory.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteDirectory.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFWriteDirectory.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteDirectory.3tiff.html index ba22c0e5a3..1e72a5bec3 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteDirectory.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteDirectory.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteEncodedStrip.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteEncodedStrip.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFWriteEncodedStrip.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteEncodedStrip.3tiff.html index 78c4e76948..3b90199a08 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteEncodedStrip.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteEncodedStrip.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteEncodedTile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteEncodedTile.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFWriteEncodedTile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteEncodedTile.3tiff.html index dcbf479aa2..5e85f6ddbe 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteEncodedTile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteEncodedTile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteRawStrip.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteRawStrip.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFWriteRawStrip.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteRawStrip.3tiff.html index eaceba6bd5..9a3ef0c199 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteRawStrip.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteRawStrip.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteRawTile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteRawTile.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFWriteRawTile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteRawTile.3tiff.html index 543b0788c2..639af6c717 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteRawTile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteRawTile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteScanline.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteScanline.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFWriteScanline.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteScanline.3tiff.html index da929e7295..4c68f9d4b9 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteScanline.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteScanline.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFWriteTile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFWriteTile.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFWriteTile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFWriteTile.3tiff.html index fa9ddc3a65..6f6ffd23bd 100644 --- a/libs/tiff-3.8.2/html/man/TIFFWriteTile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFWriteTile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFbuffer.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFbuffer.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFbuffer.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFbuffer.3tiff.html index ac667bebdb..09009b5fab 100644 --- a/libs/tiff-3.8.2/html/man/TIFFbuffer.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFbuffer.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFcodec.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFcodec.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFcodec.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFcodec.3tiff.html index 08c6643618..d2007542f8 100644 --- a/libs/tiff-3.8.2/html/man/TIFFcodec.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFcodec.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFcolor.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFcolor.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFcolor.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFcolor.3tiff.html index 38fb745745..edf423b6c3 100644 --- a/libs/tiff-3.8.2/html/man/TIFFcolor.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFcolor.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFmemory.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFmemory.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFmemory.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFmemory.3tiff.html index 296f4fa1b5..c3f38e0b7e 100644 --- a/libs/tiff-3.8.2/html/man/TIFFmemory.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFmemory.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFquery.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFquery.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFquery.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFquery.3tiff.html index f896d262b5..2b47fc3de7 100644 --- a/libs/tiff-3.8.2/html/man/TIFFquery.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFquery.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFsize.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFsize.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFsize.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFsize.3tiff.html index 1c81247872..5a14254ed4 100644 --- a/libs/tiff-3.8.2/html/man/TIFFsize.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFsize.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFstrip.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFstrip.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFstrip.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFstrip.3tiff.html index 1b7ac9c027..b8bc7c62de 100644 --- a/libs/tiff-3.8.2/html/man/TIFFstrip.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFstrip.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFswab.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFswab.3tiff.html similarity index 98% rename from libs/tiff-3.8.2/html/man/TIFFswab.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFswab.3tiff.html index 0663168b62..80d1db4587 100644 --- a/libs/tiff-3.8.2/html/man/TIFFswab.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFswab.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/TIFFtile.3tiff.html b/libs/tiff-4.0.2/html/man/TIFFtile.3tiff.html similarity index 99% rename from libs/tiff-3.8.2/html/man/TIFFtile.3tiff.html rename to libs/tiff-4.0.2/html/man/TIFFtile.3tiff.html index a37009d2b9..addeb51590 100644 --- a/libs/tiff-3.8.2/html/man/TIFFtile.3tiff.html +++ b/libs/tiff-4.0.2/html/man/TIFFtile.3tiff.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/fax2ps.1.html b/libs/tiff-4.0.2/html/man/fax2ps.1.html similarity index 77% rename from libs/tiff-3.8.2/html/man/fax2ps.1.html rename to libs/tiff-4.0.2/html/man/fax2ps.1.html index 3e8c0d78c0..aba6fc3075 100644 --- a/libs/tiff-3.8.2/html/man/fax2ps.1.html +++ b/libs/tiff-4.0.2/html/man/fax2ps.1.html @@ -1,5 +1,5 @@ - + @@ -28,7 +28,7 @@

    fax2ps − convert a TIFF facsimile to -compressed ™

    +compressed PostScript™

    @@ -39,7 +39,7 @@ compressed ™

    -

    fax2ps [ options ] [ file... ]

    +

    fax2ps [ options ] [ file ... ]

    @@ -51,8 +51,9 @@ compressed ™

    fax2ps reads one or more TIFF -facsimile image files and prints a compressed form of on the -standard output that is suitable for printing.

    +facsimile image files and prints a compressed form of +PostScript on the standard output that is suitable for +printing.

    By default, each page is scaled to reflect the image dimensions and resolutions stored in the file. The @@ -64,38 +65,38 @@ default output page is 8.5 by 11 inches. Alternate page dimensions can be specified in inches with the −W and −H options.

    -

    By default fax2ps generates for all pages in the -file. The −p option can be used to select one -or more pages from a multi-page document.

    +

    By default fax2ps generates PostScript for all +pages in the file. The −p option can be used to +select one or more pages from a multi-page document.

    -

    fax2ps generates a compressed form of that is -optimized for sending pages of text to a printer attached to -a host through a low-speed link (such as a serial line). -Each output page is filled with white and then only the -black areas are drawn. The specification of the black -drawing operations is optimized by using a special font that -encodes the move-draw operations required to fill the black -regions on the page. This compression scheme typically -results in a substantially reduced description, relative to -the straightforward imaging of the page with a image -operator. This algorithm can, however, be ineffective for -continuous-tone and white-on-black images. For these images, -it sometimes is more efficient to send the raster bitmap -image directly; see tiff2ps(1).

    +

    fax2ps generates a compressed form of PostScript +that is optimized for sending pages of text to a PostScript +printer attached to a host through a low-speed link (such as +a serial line). Each output page is filled with white and +then only the black areas are drawn. The PostScript +specification of the black drawing operations is optimized +by using a special font that encodes the move-draw +operations required to fill the black regions on the page. +This compression scheme typically results in a substantially +reduced PostScript description, relative to the +straightforward imaging of the page with a PostScript +image operator. This algorithm can, however, be +ineffective for continuous-tone and white-on-black images. +For these images, it sometimes is more efficient to send the +raster bitmap image directly; see tiff2ps(1).

    OPTIONS

    + cols="4" cellspacing="0" cellpadding="0"> - + -

    −p number

    Print only the indicated page. Multiple pages may be @@ -144,14 +145,13 @@ taken from the file.

    + cols="4" cellspacing="0" cellpadding="0"> - - - - - -
    +

    −S

    Scale each page of image data to fill the output page @@ -163,11 +163,10 @@ file.

    +

    −W width

    Use width as the width, in inches, of the output @@ -177,11 +176,10 @@ page.

    +

    −H height

    Use height as the height, in inches, of the @@ -206,7 +204,7 @@ may be generated due to transmission errors in received facsimile. fax2ps attempts to recover from such data errors by resynchronizing decoding at the end of the current scanline. This can result in long horizontal black lines in -the resultant image.

    +the resultant PostScript image.

    @@ -217,9 +215,9 @@ the resultant image.

    -

    If the destination printer supports Level II then it is -always faster to just send the encoded bitmap generated by -the tiff2ps(1) program.

    +

    If the destination printer supports PostScript Level II +then it is always faster to just send the encoded bitmap +generated by the tiff2ps(1) program.

    @@ -231,8 +229,8 @@ the tiff2ps(1) program.

    fax2ps should probably figure out when it is doing -a poor job of compressing the output and just generate to -image the bitmap raster instead.

    +a poor job of compressing the output and just generate +PostScript to image the bitmap raster instead.

    diff --git a/libs/tiff-3.8.2/html/man/fax2tiff.1.html b/libs/tiff-4.0.2/html/man/fax2tiff.1.html similarity index 98% rename from libs/tiff-3.8.2/html/man/fax2tiff.1.html rename to libs/tiff-4.0.2/html/man/fax2tiff.1.html index dca50e1902..3aac8c7939 100644 --- a/libs/tiff-3.8.2/html/man/fax2tiff.1.html +++ b/libs/tiff-4.0.2/html/man/fax2tiff.1.html @@ -1,5 +1,5 @@ - + @@ -485,10 +485,10 @@ data written to the output file. By default (or when value 0 is specified), tiffcp attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip (with except of G3/G4 compression schemes). If you -specify special value -1 it will results in infinite -number of the rows per strip. The entire image will be the -one strip in that case. This is default in case of G3/G4 -output compression schemes.

    +specify special value −1 it will results in +infinite number of the rows per strip. The entire image will +be the one strip in that case. This is default in case of +G3/G4 output compression schemes.

    diff --git a/libs/tiff-3.8.2/html/man/gif2tiff.1.html b/libs/tiff-4.0.2/html/man/gif2tiff.1.html similarity index 92% rename from libs/tiff-3.8.2/html/man/gif2tiff.1.html rename to libs/tiff-4.0.2/html/man/gif2tiff.1.html index ffd3cac763..c50735377f 100644 --- a/libs/tiff-3.8.2/html/man/gif2tiff.1.html +++ b/libs/tiff-4.0.2/html/man/gif2tiff.1.html @@ -1,5 +1,5 @@ - + @@ -73,10 +73,10 @@ specified with the options described below.

    Specify a compression scheme to use when writing image -data: −c none for no compression, -c -packbits for the PackBits compression algorithm, -c -zip for the Deflate compression algorithm, and -−c lzw for Lempel-Ziv & Welch (the +data: −c none for no compression, −c +packbits for the PackBits compression algorithm, +−c zip for the Deflate compression algorithm, +and −c lzw for Lempel-Ziv & Welch (the default).

    diff --git a/libs/tiff-3.8.2/html/man/index.html b/libs/tiff-4.0.2/html/man/index.html similarity index 98% rename from libs/tiff-3.8.2/html/man/index.html rename to libs/tiff-4.0.2/html/man/index.html index 9fdba2e199..7e9e8d2c7f 100644 --- a/libs/tiff-3.8.2/html/man/index.html +++ b/libs/tiff-4.0.2/html/man/index.html @@ -1,5 +1,4 @@ Libtiff HTML manpage index

      Man Pages

      -

    • libtiff.3tiff.html
    • TIFFbuffer.3tiff.html
    • TIFFClose.3tiff.html
    • TIFFcodec.3tiff.html @@ -53,6 +52,7 @@
    • tiff2rgba.1.html
    • tiffcmp.1.html
    • tiffcp.1.html +
    • tiffcrop.1.html
    • tiffdither.1.html
    • tiffdump.1.html
    • tiffgt.1.html diff --git a/libs/tiff-4.0.2/html/man/libtiff.3tiff.html b/libs/tiff-4.0.2/html/man/libtiff.3tiff.html new file mode 100644 index 0000000000..931ae94b4c --- /dev/null +++ b/libs/tiff-4.0.2/html/man/libtiff.3tiff.html @@ -0,0 +1,1150 @@ + + + + + + +INTRO + + + +

      INTRO

      +NAME
      +SYNOPSIS
      +DESCRIPTION
      +DATA TYPES
      +LIST OF ROUTINES
      +TAG USAGE
      +PSEUDO TAGS
      +DIAGNOSTICS
      +SEE ALSO
      +BUGS
      + +
      + +

      NAME

      + + + + + +
      +

      libtiff − introduction to libtiff, a +library for reading and writing TIFF +files

      +
      + +

      SYNOPSIS

      + + + + + +
      +

      #include <tiffio.h>

      + +

      cc file.c -ltiff

      +
      + +

      DESCRIPTION

      + + + + + +
      +

      libtiff is a library for reading and writing +data files encoded with the Tag Image File format, +Revision 6.0 (or revision 5.0 or revision 4.0). This file +format is suitable for archiving multi-color and +monochromatic image data.

      + +

      The library supports several compression algorithms, +as indicated by the Compression field, including: no +compression (1), CCITT 1D Huffman compression +(2), CCITT Group 3 Facsimile compression +(3), CCITT Group 4 Facsimile compression (4), +Lempel-Ziv & Welch compression (5), baseline JPEG +compression (7), word-aligned 1D Huffman compression +(32771), and PackBits compression (32773). In addition, +several nonstandard compression algorithms are supported: +the 4-bit compression algorithm used by the +ThunderScan program (32809) (decompression only), +NeXT’s 2-bit compression algorithm (32766) +(decompression only), an experimental LZ-style algorithm +known as Deflate (32946), and an experimental CIE LogLuv +compression scheme designed for images with high dynamic +range (32845 for LogL and 32845 for LogLuv). Directory +information may be in either little- or big-endian byte +order−byte swapping is automatically done by the +library. Data bit ordering may be either Most Significant +Bit ( MSB ) to Least Significant Bit ( LSB +) or LSB to MSB. Finally, the +library does not support files in which the +BitsPerSample, Compression, +MinSampleValue, or MaxSampleValue fields are +defined differently on a per-sample basis (in Rev. 6.0 the +Compression tag is not defined on a per-sample basis, +so this is immaterial).

      +
      + +

      DATA TYPES

      + + + + + +
      +

      The library makes extensive use of C typedefs to +promote portability. Two sets of typedefs are used, one for +communication with clients of the library and one for +internal data structures and parsing of the TIFF +format. The following typedefs are exposed to users +either through function definitions or through parameters +passed through the varargs interfaces.

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +

      typedef unsigned short uint16;

      +
      + +

      16-bit unsigned integer

      +
      + +

      typedef unsigned <thing> +uint32;

      +
      + +

      32-bit unsigned integer

      +
      + +

      typedef unsigned int ttag_t;

      +
      + +

      directory tag

      +
      + +

      typedef uint16 tdir_t;

      +
      + +

      directory index

      +
      + +

      typedef uint16 tsample_t;

      +
      + +

      sample number

      +
      + +

      typedef uint32 tstrip_t;

      +
      + +

      strip number

      +
      + +

      typedef uint32 ttile_t;

      +
      + +

      tile number

      +
      + +

      typedef int32 tsize_t;

      +
      + +

      i/o size in bytes

      +
      + +

      typedef void* tdata_t;

      +
      + +

      image data ref

      +
      + +

      typedef void* thandle_t;

      +
      + +

      client data handle

      +
      + +

      typedef int32 toff_t;

      +
      + +

      file offset

      +
      + + + + + +
      +

      Note that tstrip_t, ttile_t, and +tsize_t are constrained to be no more than 32-bit +quantities by 32-bit fields they are stored in in the +TIFF image. Likewise tsample_t is limited by the +16-bit field used to store the SamplesPerPixel tag. +tdir_t constrains the maximum number of IFDs +that may appear in an image and may be an arbitrary +size (w/o penalty). ttag_t must be either int, +unsigned int, pointer, or double because the library uses a +varargs interface and ANSI C restricts the type +of the parameter before an ellipsis to be a promoted type. +toff_t is defined as int32 because TIFF file offsets +are (unsigned) 32-bit quantities. A signed value is used +because some interfaces return −1 on error. Finally, +note that user-specified data references are passed as +opaque handles and only cast at the lowest layers where +their type is presumed.

      +
      + +

      LIST OF ROUTINES

      + + + + + +
      +

      The following routines are part of the library. +Consult specific manual pages for details on their +operation; on most systems doing ‘‘man +function-name’’ will work.

      + + +

      Name Description

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +

      TIFFCheckpointDirectory

      +
      + +

      writes the current state of the directory

      +
      + +

      TIFFCheckTile

      +
      + +

      very x,y,z,sample is within image

      +
      + +

      TIFFCIELabToRGBInit

      +
      + +

      initialize CIE L*a*b* 1976 to RGB conversion +state

      +
      + +

      TIFFCIELabToXYZ

      +
      + +

      perform CIE L*a*b* 1976 to CIE XYZ +conversion

      +
      + +

      TIFFClientOpen

      +
      + +

      open a file for reading or writing

      +
      + +

      TIFFClose

      +
      + +

      close an open file

      +
      + +

      TIFFComputeStrip

      +
      + +

      return strip containing y,sample

      +
      + +

      TIFFComputeTile

      +
      + +

      return tile containing x,y,z,sample

      +
      + +

      TIFFCurrentDirectory

      +
      + +

      return index of current directory

      +
      + +

      TIFFCurrentRow

      +
      + +

      return index of current scanline

      +
      + +

      TIFFCurrentStrip

      +
      + +

      return index of current strip

      +
      + +

      TIFFCurrentTile

      +
      + +

      return index of current tile

      +
      + +

      TIFFDataWidth

      +
      + +

      return the size of TIFF data types

      +
      + +

      TIFFError

      +
      + +

      library error handler

      +
      + +

      TIFFFdOpen

      +
      + +

      open a file for reading or writing

      +
      + +

      TIFFFileName

      +
      + +

      return name of open file

      +
      + +

      TIFFFileno

      +
      + +

      return open file descriptor

      +
      + +

      TIFFFindCODEC

      +
      + +

      find standard codec for the specific +scheme

      +
      + +

      TIFFFlush

      +
      + +

      flush all pending writes

      +
      + +

      TIFFFlushData

      +
      + +

      flush pending data writes

      +
      + +

      TIFFGetBitRevTable

      +
      + +

      return bit reversal table

      +
      + +

      TIFFGetField

      +
      + +

      return tag value in current directory

      +
      + +

      TIFFGetFieldDefaulted

      +
      + +

      return tag value in current directory

      +
      + +

      TIFFGetMode

      +
      + +

      return open file mode

      +
      + +

      TIFFGetVersion

      +
      + +

      return library version string

      +
      + +

      TIFFIsCODECConfigured

      +
      + +

      check, whether we have working codec

      +
      + +

      TIFFIsMSB2LSB

      +
      + +

      return true if image data is being +returned

      +
      + +

      with bit 0 as the most significant bit

      +
      + +

      TIFFIsTiled

      +
      + +

      return true if image data is tiled

      +
      + +

      TIFFIsByteSwapped

      +
      + +

      return true if image data is byte-swapped

      +
      + +

      TIFFNumberOfStrips

      +
      + +

      return number of strips in an image

      +
      + +

      TIFFNumberOfTiles

      +
      + +

      return number of tiles in an image

      +
      + +

      TIFFOpen

      +
      + +

      open a file for reading or writing

      +
      + +

      TIFFPrintDirectory

      +
      + +

      print description of the current +directory

      +
      + +

      TIFFReadBufferSetup

      +
      + +

      specify i/o buffer for reading

      +
      + +

      TIFFReadDirectory

      +
      + +

      read the next directory

      +
      + +

      TIFFReadEncodedStrip

      +
      + +

      read and decode a strip of data

      +
      + +

      TIFFReadEncodedTile

      +
      + +

      read and decode a tile of data

      +
      + +

      TIFFReadRawStrip

      +
      + +

      read a raw strip of data

      +
      + +

      TIFFReadRawTile

      +
      + +

      read a raw tile of data

      +
      + +

      TIFFReadRGBAImage

      +
      + +

      read an image into a fixed format raster

      +
      + +

      TIFFReadScanline

      +
      + +

      read and decode a row of data

      +
      + +

      TIFFReadTile

      +
      + +

      read and decode a tile of data

      +
      + +

      TIFFRegisterCODEC

      +
      + +

      override standard codec for the specific +scheme

      +
      + +

      TIFFReverseBits

      +
      + +

      reverse bits in an array of bytes

      +
      + +

      TIFFRGBAImageBegin

      +
      + +

      setup decoder state for TIFFRGBAImageGet

      +
      + +

      TIFFRGBAImageEnd

      +
      + +

      release TIFFRGBAImage decoder state

      +
      + +

      TIFFRGBAImageGet

      +
      + +

      read and decode an image

      +
      + +

      TIFFRGBAImageOK

      +
      + +

      is image readable by TIFFRGBAImageGet

      +
      + +

      TIFFScanlineSize

      +
      + +

      return size of a scanline

      +
      + +

      TIFFSetDirectory

      +
      + +

      set the current directory

      +
      + +

      TIFFSetSubDirectory

      +
      + +

      set the current directory

      +
      + +

      TIFFSetErrorHandler

      +
      + +

      set error handler function

      +
      + +

      TIFFSetField

      +
      + +

      set a tag’s value in the current +directory

      +
      + +

      TIFFSetWarningHandler

      +
      + +

      set warning handler function

      +
      + +

      TIFFStripSize

      +
      + +

      returns size of a strip

      +
      + +

      TIFFRawStripSize

      +
      + +

      returns the number of bytes in a raw +strip

      +
      + +

      TIFFSwabShort

      +
      + +

      swap bytes of short

      +
      + +

      TIFFSwabLong

      +
      + +

      swap bytes of long

      +
      + +

      TIFFSwabArrayOfShort

      +
      + +

      swap bytes of an array of shorts

      +
      + +

      TIFFSwabArrayOfLong

      +
      + +

      swap bytes of an array of longs

      +
      + +

      TIFFTileRowSize

      +
      + +

      return size of a row in a tile

      +
      + +

      TIFFTileSize

      +
      + +

      return size of a tile

      +
      + +

      TIFFUnRegisterCODEC

      +
      + +

      unregisters the codec

      +
      + +

      TIFFVGetField

      +
      + +

      return tag value in current directory

      +
      + +

      TIFFVGetFieldDefaulted

      +
      + +

      return tag value in current directory

      +
      + +

      TIFFVSetField

      +
      + +

      set a tag’s value in the current +directory

      +
      + +

      TIFFVStripSize

      +
      + +

      returns the number of bytes in a strip

      +
      + +

      TIFFWarning

      +
      + +

      library warning handler

      +
      + +

      TIFFWriteDirectory

      +
      + +

      write the current directory

      +
      + +

      TIFFWriteEncodedStrip

      +
      + +

      compress and write a strip of data

      +
      + +

      TIFFWriteEncodedTile

      +
      + +

      compress and write a tile of data

      +
      + +

      TIFFWriteRawStrip

      +
      + +

      write a raw strip of data

      +
      + +

      TIFFWriteRawTile

      +
      + +

      write a raw tile of data

      +
      + +

      TIFFWriteScanline

      +
      + +

      write a scanline of data

      +
      + +

      TIFFWriteTile

      +
      + +

      compress and write a tile of data

      +
      + +

      TIFFXYZToRGB

      +
      + +

      perform CIE XYZ to RGB conversion

      +
      + +

      TIFFYCbCrToRGBInit

      +
      + +

      initialize YCbCr to RGB conversion state

      +
      + +

      TIFFYCbCrtoRGB

      +
      + +

      perform YCbCr to RGB conversion

      +
      + + + + + +
      +

      Auxiliary functions:

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +

      _TIFFfree

      +
      + +

      free memory buffer

      +
      + +

      _TIFFmalloc

      +
      + +

      dynamically allocate memory buffer

      +
      + +

      _TIFFmemcmp

      +
      + +

      compare contents of the memory buffers

      +
      + +

      _TIFFmemcpy

      +
      + +

      copy contents of the one buffer to +another

      +
      + +

      _TIFFmemset

      +
      + +

      fill memory buffer with a constant byte

      +
      + +

      _TIFFrealloc

      +
      + +

      dynamically reallocate memory buffer

      +
      + +

      TAG USAGE

      + + + + + diff --git a/libs/tiff-3.8.2/html/man/raw2tiff.1.html b/libs/tiff-4.0.2/html/man/raw2tiff.1.html similarity index 77% rename from libs/tiff-3.8.2/html/man/raw2tiff.1.html rename to libs/tiff-4.0.2/html/man/raw2tiff.1.html index 21e4f4f11e..ce47e9f801 100644 --- a/libs/tiff-3.8.2/html/man/raw2tiff.1.html +++ b/libs/tiff-4.0.2/html/man/raw2tiff.1.html @@ -1,5 +1,5 @@ - + @@ -53,10 +53,10 @@ output.tif

      TIFF. By default, the TIFF image is created with data samples packed (PlanarConfiguration=1), compressed with the PackBits -algorithm (Compression=32773), and with each -strip no more than 8 kilobytes. These characteristics can -overridden, or explicitly specified with the options -described below.

      +algorithm (Compression=32773), and with each strip no +more than 8 kilobytes. These characteristics can overridden, +or explicitly specified with the options described +below.

      +

      The table below lists the TIFF tags that +are recognized and handled by the library. If no use is +indicated in the table, then the library reads and writes +the tag, but does not use it internally. Note that some tags +are meaningful only when a particul \ No newline at end of file diff --git a/libs/tiff-3.8.2/html/man/pal2rgb.1.html b/libs/tiff-4.0.2/html/man/pal2rgb.1.html similarity index 99% rename from libs/tiff-3.8.2/html/man/pal2rgb.1.html rename to libs/tiff-4.0.2/html/man/pal2rgb.1.html index 57081611a9..d06ddb6da0 100644 --- a/libs/tiff-3.8.2/html/man/pal2rgb.1.html +++ b/libs/tiff-4.0.2/html/man/pal2rgb.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/ppm2tiff.1.html b/libs/tiff-4.0.2/html/man/ppm2tiff.1.html similarity index 98% rename from libs/tiff-3.8.2/html/man/ppm2tiff.1.html rename to libs/tiff-4.0.2/html/man/ppm2tiff.1.html index b2e1bcce93..e3c664e264 100644 --- a/libs/tiff-3.8.2/html/man/ppm2tiff.1.html +++ b/libs/tiff-4.0.2/html/man/ppm2tiff.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/ras2tiff.1.html b/libs/tiff-4.0.2/html/man/ras2tiff.1.html similarity index 91% rename from libs/tiff-3.8.2/html/man/ras2tiff.1.html rename to libs/tiff-4.0.2/html/man/ras2tiff.1.html index f36a472274..2c652aba6d 100644 --- a/libs/tiff-3.8.2/html/man/ras2tiff.1.html +++ b/libs/tiff-4.0.2/html/man/ras2tiff.1.html @@ -1,5 +1,5 @@ - + @@ -81,12 +81,12 @@ depth is 24 or 1 (min-is-black) if the depth is not 24.

      Specify a compression scheme to use when writing image -data: −c none for no compression, -c -packbits for the PackBits compression algorithm, -c -jpeg for the baseline JPEG compression algorithm, -c -zip for the Deflate compression algorithm, and -−c lzw for Lempel-Ziv & Welch (the -default).

      +data: −c none for no compression, −c +packbits for the PackBits compression algorithm, +−c jpeg for the baseline JPEG compression +algorithm, −c zip for the Deflate compression +algorithm, and −c lzw for Lempel-Ziv & +Welch (the default).

      @@ -67,7 +67,7 @@ described below.

      -

      −H <number>

      +

      −H number

      +

      −w number

      -

      −w <number>

      +

      −l number

      -

      −l <number>

      @@ -124,7 +124,7 @@ below).

      +

      −b number

      -

      length of input image in lines(can be guessed, see +

      length of input image in lines (can be guessed, see GUESSING THE IMAGE GEOMETRY below).

      -

      −b <number>

      +

      −d data_type

      -

      −d data_type

      -

      type of samples in input image, where data_type +

      type of samples in input image, where data_type may be:

      + cols="3" cellspacing="0" cellpadding="0"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      + -

      byte

      +

      byte

      - +

      8-bit unsigned integer (default),

      -
      + -

      short

      +

      short

      +

      16-bit unsigned integer,

      -
      + -

      long

      +

      long

      - +

      32-bit unsigned integer,

      -
      + -

      sbyte

      +

      sbyte

      +

      8-bit signed integer,

      -
      + -

      sshort

      +

      sshort

      +

      16-bit signed integer,

      -
      + -

      slong

      +

      slong

      +

      32-bit signed integer,

      -
      + -

      float

      +

      float

      +

      32-bit IEEE floating point,

      -
      + -

      double

      +

      double

      + -

      64-bit IEEE floating point,

      -
      +

      64-bit IEEE floating point.

      @@ -268,7 +242,7 @@ may be:

      -

      −i config

      +

      −i config

      +config may be:

      type of samples interleaving in input image, where -config may be:

      + cols="3" cellspacing="0" cellpadding="0"> - - - - - - - -
      + -

      pixel

      +

      pixel

      +

      pixel interleaved data (default),

      -
      + -

      band

      +

      band

      - +

      band interleaved data.

      -
      +

      −p photo

      -

      −p photo

      +image, where photo may be:

      photometric interpretation (color space) of the input -image, where photo may be:
      -miniswhite
      white color represented with 0 value,
      -minisblack
      black color represented with 0 value -(default),

      + cols="3" cellspacing="0" cellpadding="0"> - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - -
      + -

      rgb

      +

      miniswhite

      + + +

      white color represented with 0 value,

      +
      + +

      minisblack

      +
      + +

      black color represented with 0 value (default),

      +
      + +

      rgb

      +

      image has RGB color model,

      -
      + -

      cmyk

      +

      cmyk

      - +

      image has CMYK (separated) color model,

      -
      + -

      ycbcr

      +

      ycbcr

      - +

      image has YCbCr color model,

      -
      + -

      cielab

      +

      cielab

      +

      image has CIE L*a*b color model,

      -
      + -

      icclab

      +

      icclab

      +

      image has ICC L*a*b color model,

      -
      + -

      itulab

      +

      itulab

      + -

      image has ITU L*a*b color model,

      -
      +

      image has ITU L*a*b color model.

      @@ -473,12 +430,12 @@ minisblack black color represented with 0 value

      Specify a compression scheme to use when writing image -data: −c none for no compression, -c +data: −c none for no compression, −c packbits for the PackBits compression algorithm (the -default), -c jpeg for the baseline JPEG compression -algorithm, -c zip for the Deflate compression -algorithm, and −c lzw for Lempel-Ziv & -Welch.

      +default), −c jpeg for the baseline JPEG +compression algorithm, −c zip for the Deflate +compression algorithm, and −c lzw for +Lempel-Ziv & Welch.

      @@ -489,7 +446,7 @@ Welch.

      -

      −r <number>

      +

      −r number

      - + @@ -82,11 +82,12 @@ explicitly set the number of rows per strip.

      diff --git a/libs/tiff-3.8.2/html/man/sgi2tiff.1.html b/libs/tiff-4.0.2/html/man/sgi2tiff.1.html similarity index 91% rename from libs/tiff-3.8.2/html/man/sgi2tiff.1.html rename to libs/tiff-4.0.2/html/man/sgi2tiff.1.html index 0a5c3b7aa0..7665a6e42c 100644 --- a/libs/tiff-3.8.2/html/man/sgi2tiff.1.html +++ b/libs/tiff-4.0.2/html/man/sgi2tiff.1.html @@ -1,5 +1,5 @@ - + @@ -74,12 +74,12 @@ the options described below.

      diff --git a/libs/tiff-3.8.2/html/man/thumbnail.1.html b/libs/tiff-4.0.2/html/man/thumbnail.1.html similarity index 98% rename from libs/tiff-3.8.2/html/man/thumbnail.1.html rename to libs/tiff-4.0.2/html/man/thumbnail.1.html index b78b461e6b..2d1f3c9afe 100644 --- a/libs/tiff-3.8.2/html/man/thumbnail.1.html +++ b/libs/tiff-4.0.2/html/man/thumbnail.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/tiff2bw.1.html b/libs/tiff-4.0.2/html/man/tiff2bw.1.html similarity index 88% rename from libs/tiff-3.8.2/html/man/tiff2bw.1.html rename to libs/tiff-4.0.2/html/man/tiff2bw.1.html index 3acd5fe079..1ebb4d392e 100644 --- a/libs/tiff-3.8.2/html/man/tiff2bw.1.html +++ b/libs/tiff-4.0.2/html/man/tiff2bw.1.html @@ -1,5 +1,5 @@ - + @@ -36,7 +36,7 @@ to greyscale

      Specify a compression scheme to use when writing image -data: −c none for no compression, -c +data: −c none for no compression, −c packbits for the PackBits compression algorithm (the -default), -c jpeg for the JPEG compression algorithm, --c zip for the deflate compression algorithm, and -−c lzw for Lempel-Ziv & Welch.

      +default), −c jpeg for the JPEG compression +algorithm, −c zip for the deflate compression +algorithm, and −c lzw for Lempel-Ziv & +Welch.

      Specify a compression scheme to use when writing image -data: −c none for no compression, -c -packbits for the PackBits compression algorithm), -c -jpeg for the baseline JPEG compression algorithm, -c -zip for the Deflate compression algorithm, and -−c lzw for Lempel-Ziv & Welch (the -default).

      +data: −c none for no compression, −c +packbits for the PackBits compression algorithm), +−c jpeg for the baseline JPEG compression +algorithm, −c zip for the Deflate compression +algorithm, and −c lzw for Lempel-Ziv & +Welch (the default).

      -

      tiff2bw [ options ] input.tif +

      tiff2bw [ options ] input.tif output.tif

      @@ -73,12 +73,13 @@ used.

      Specify a compression scheme to use when writing image -data: −c none for no compression, -c -packbits for the PackBits compression algorithm, -c -zip for the Deflate compression algorithm, -c g3 -for the CCITT Group 3 compression algorithm, -c g4 -for the CCITT Group 4 compression algorithm, and −c -lzw for Lempel-Ziv & Welch (the default).

      +data: −c none for no compression, −c +packbits for the PackBits compression algorithm, +−c zip for the Deflate compression algorithm, +−c g3 for the CCITT Group 3 compression +algorithm, −c g4 for the CCITT Group 4 +compression algorithm, and −c lzw for +Lempel-Ziv & Welch (the default).

      diff --git a/libs/tiff-3.8.2/html/man/tiff2pdf.1.html b/libs/tiff-4.0.2/html/man/tiff2pdf.1.html similarity index 82% rename from libs/tiff-3.8.2/html/man/tiff2pdf.1.html rename to libs/tiff-4.0.2/html/man/tiff2pdf.1.html index 0efb26322b..3b6dd4b1da 100644 --- a/libs/tiff-3.8.2/html/man/tiff2pdf.1.html +++ b/libs/tiff-4.0.2/html/man/tiff2pdf.1.html @@ -1,5 +1,5 @@ - + @@ -26,7 +26,8 @@ -

      tiff2pdf - convert a TIFF image to a PDF document

      +

      tiff2pdf − convert a TIFF image to a PDF +document

      @@ -37,8 +38,7 @@ -

      tiff2pdf [ options ] -input.tiff

      +

      tiff2pdf [ options ] input.tiff

      @@ -49,7 +49,7 @@ -

      tiff2pdf opens a TIFF image and writes a PDF +

      tiff2pdf opens a TIFF image and writes a PDF document to standard output.

      The program converts one TIFF file to one PDF file, @@ -67,7 +67,8 @@ or width) convert the input image to a tiled TIFF if it is not already.

      The standard output is standard output. Set the output -file name with the -ooutput.pdf option.

      +file name with the −o output.pdf +option.

      All black and white files are compressed into a single strip CCITT G4 Fax compressed PDF, unless tiled, where tiled @@ -109,13 +110,14 @@ resolution and page width and length can be set by the −u option, the default unit is inch.

      Various items of the output document information can be -set with the −e, −c, −a, −t, -−s, and −k options. Setting the -argument of the option to "" for these tags causes -the relevant document information field to be not written. -Some of the document information values otherwise get their -information from the input TIFF image, the software, author, -document name, and image description.

      +set with the −e, −c, +−a, −t, −s, and +−k options. Setting the argument of the option +to "" for these tags causes the relevant document +information field to be not written. Some of the document +information values otherwise get their information from the +input TIFF image, the software, author, document name, and +image description.

      The Portable Document Format (PDF) specification is copyrighted by Adobe Systems, Incorporated.

      @@ -129,7 +131,7 @@ copyrighted by Adobe Systems, Incorporated.

      -

      −ooutput-file

      +

      −o output-file

      -

      Set the output to go to file output-file

      +

      Set the output to go to file. output-file

      @@ -152,8 +154,8 @@ copyrighted by Adobe Systems, Incorporated.

      -

      Compress with JPEG (requires libjpeg configured with -libtiff).

      +

      Compress with JPEG (requires libjpeg configured +with libtiff).

      @@ -164,8 +166,8 @@ libtiff).

      -

      Compress with Zip/Deflate (requires zlib configured with -libtiff).

      +

      Compress with Zip/Deflate (requires zlib +configured with libtiff).

      @@ -174,7 +176,7 @@ libtiff).

      -

      −qquality

      +

      −q quality

      @@ -240,7 +243,7 @@ no compressed data passthrough.

      +

      −p paper-size

      -

      Set PDF "Interpolate" user preference.

      +

      Set PDF ‘‘Interpolate’’ user +preference.

      -

      −ppaper-size

      -

      Set paper size, eg "letter", "legal", -"A4".

      +

      Set paper size, e.g., letter, legal, +A4.

      @@ -258,7 +261,7 @@ no compressed data passthrough.

      -

      −u[i|m]

      +

      −u [i|m]

      -

      Set distance unit, i for inch, m for +

      Set distance unit, i for inch, m for centimeter.

      @@ -276,7 +279,7 @@ centimeter.

      -

      −wwidth

      +

      −w width

      +

      −l length

      -

      −llength

      Set length in units.

      - + + cols="2" cellspacing="0" cellpadding="0"> - - - - + +
      - -

      −xxres

      -
      - + +

      −x xres

      + + + + + - - - - - - -

      Set x/width resolution default.

      -
      - -

      −yyres

      -
      - -

      Set y/length resolution default.

      -
      -
      +

      −y yres

      -

      −r[d|o]

      +
      -

      Set d for resolution default for images without -resolution, o for resolution override for all -images.

      +

      Set y/length resolution default.

      +
      + + + + + +
      +

      −r [d|o]

      + + + + +
      +

      Set d for resolution default for images without +resolution, o for resolution override for all +images.

      @@ -363,11 +370,12 @@ images.

      −f

      - + -

      Set PDF "Fit Window" user preference.

      +

      Set PDF ‘‘Fit Window’’ user +preference.

      - + @@ -376,7 +384,7 @@ images.

      -

      −eYYYYMMDDHHMMSS

      +

      −e YYYYMMDDHHMMSS

      YYYYMMDDHHMMSS.

      +

      −c creator

      -

      −ccreator

      +

      −a author

      -

      −aauthor

      Set document information author, overrides image artist -default

      +default.

      @@ -430,7 +438,7 @@ default

      -

      −ttitle

      +

      −t title

      Set document information title, overrides image document -name default

      +name default.

      @@ -448,7 +456,7 @@ name default

      -

      −ssubject

      +

      −s subject

      Set document information subject, overrides image image -description default

      +description default.

      @@ -466,7 +474,7 @@ description default

      -

      −kkeywords

      +

      −k keywords

      - - - - -
      - +

      EXAMPLES

      @@ -516,17 +519,19 @@ from input.tiff.

      -

      tiff2pdf -o output.pdf input.tiff

      +
      tiff2pdf −o output.pdf input.tiff
      +
      + + +input.tiff and write it to standard output.

      The following example would generate PDF output from -input.tiff and write it to standard output.

      -
      +
      tiff2pdf input.tiff
      +
      +
      -

      tiff2pdf input.tiff

      + @@ -545,9 +553,9 @@ input.tiff and write it to standard output.

      The following example would generate the file output.pdf from input.tiff, putting the image pages on a letter sized page, compressing the output with JPEG, with JPEG quality -75, setting the title to "Document", and setting -the "Fit Window" option.

      - +75, setting the title to +‘‘Document’’, and setting the +‘‘Fit Window’’ option.

      +
      tiff2pdf −p letter −j −q 75 −t "Document" −f −o output.pdf input.tiff
      +
      +
      -

      tiff2pdf -p letter -j -q 75 -t "Document" -f -o -output.pdf input.tiff

      BUGS

      + @@ -587,8 +597,8 @@ output.pdf input.tiff

      -

      libtiff(3), tiffcp(1), -tiff2ps(1)

      +

      libtiff(3), tiffcp(1), +tiff2ps(1)

      Libtiff library home page: http://www.remotesensing.org/libtiff/

      diff --git a/libs/tiff-3.8.2/html/man/tiff2ps.1.html b/libs/tiff-4.0.2/html/man/tiff2ps.1.html similarity index 78% rename from libs/tiff-3.8.2/html/man/tiff2ps.1.html rename to libs/tiff-4.0.2/html/man/tiff2ps.1.html index e58887d30d..ef2cd7f9e9 100644 --- a/libs/tiff-3.8.2/html/man/tiff2ps.1.html +++ b/libs/tiff-4.0.2/html/man/tiff2ps.1.html @@ -1,5 +1,5 @@ - + @@ -15,7 +15,6 @@ OPTIONS
      EXAMPLES
      BUGS
      -BUGS
      SEE ALSO

      @@ -28,7 +27,7 @@

      tiff2ps − convert a TIFF image to -™

      +PostScript™

      @@ -52,26 +51,28 @@

      tiff2ps reads TIFF images and -writes or Encapsulated (EPS) on the standard output. By -default, tiff2ps writes Encapsulated for the first -image in the specified TIFF image file.

      +writes PostScript or Encapsulated PostScript (EPS) on the +standard output. By default, tiff2ps writes +Encapsulated PostScript for the first image in the specified +TIFF image file.

      -

      By default, tiff2ps will generate that fills a -printed area specified by the TIFF tags in -the input file. If the file does not contain +

      By default, tiff2ps will generate PostScript that +fills a printed area specified by the TIFF +tags in the input file. If the file does not contain XResolution or YResolution tags, then the printed area is set according to the image dimensions. The −w and −h options (see below) can be used to set the dimensions of the printed area in inches; overriding any relevant TIFF tags.

      -

      The generated for RGB, palette, and -CMYK images uses the colorimage -operator. The generated for greyscale and bilevel images -uses the image operator. When the colorimage -operator is used, code to emulate this operator on older -printers is also generated. Note that this emulation code -can be very slow.

      +

      The PostScript generated for RGB, palette, +and CMYK images uses the colorimage +operator. The PostScript generated for greyscale and bilevel +images uses the image operator. When the +colorimage operator is used, PostScript code to +emulate this operator on older PostScript printers is also +generated. Note that this emulation code can be very +slow.

      Color images with associated alpha data are composited over a white background.

      @@ -91,7 +92,7 @@ over a white background.

      -

      Generate Level 1 (the default).

      +

      Generate PostScript Level 1 (the default).

      @@ -104,7 +105,7 @@ over a white background.

      -

      Generate Level 2.

      +

      Generate PostScript Level 2.

      @@ -117,8 +118,9 @@ over a white background.

      -

      Generate Level 3. It basically allows one to use the -/flateDecode filter for ZIP compressed TIFF images.

      +

      Generate PostScript Level 3. It basically allows one to +use the /flateDecode filter for ZIP compressed TIFF +images.

      @@ -160,7 +162,8 @@ This does not affect the height of the printed image.

      Center the image in the output. This option only shows -an effect if both the -w and the -h option are given.

      +an effect if both the −w and the +−h option are given.

      @@ -174,7 +177,7 @@ an effect if both the -w and the -h option are given.

      Set the initial TIFF directory to the -specified directory number. (NB: directories are numbered +specified directory number. (NB: Directories are numbered starting at zero.) This option is useful for selecting individual pages in a multi-page (e.g. facsimile) file.

      @@ -189,7 +192,8 @@ individual pages in a multi-page (e.g. facsimile) file.

      -

      Force the generation of Encapsulated (implies -z).

      +

      Force the generation of Encapsulated PostScript (implies +−z).

      @@ -276,12 +280,12 @@ does not affect the width of the printed image.

      -

      Where possible render using the imagemask -operator instead of the image operator. When this option is -specified tiff2ps will use imagemask for -rendering 1 bit deep images. If this option is not specified -or if the image depth is greater than 1 then the image -operator is used.

      +

      Where possible render using the imagemask +PostScript operator instead of the image operator. +When this option is specified tiff2ps will use +imagemask for rendering 1 bit deep images. If this +option is not specified or if the image depth is greater +than 1 then the image operator is used.

      @@ -297,7 +301,7 @@ operator is used.

      Set the initial TIFF directory to the IFD at the specified file offset. This option is useful for selecting thumbnail images and the like which -are hidden using the SubIFD tag.

      +are hidden using the SubIFD tag.

      @@ -310,7 +314,8 @@ are hidden using the SubIFD tag.

      -

      Force the generation of (non-Encapsulated) .

      +

      Force the generation of (non-Encapsulated) +PostScript.

      @@ -392,12 +397,12 @@ inches.

      -

      When generating Level 2, data is scaled so that it does -not image into the deadzone on a page (the outer -margin that the printing device is unable to mark). This -option suppresses this behavior. When Level 1 is generated, -data is imaged to the entire printed page and this option -has no affect.

      +

      When generating PostScript Level 2, data is scaled so +that it does not image into the deadzone on a page +(the outer margin that the printing device is unable to +mark). This option suppresses this behavior. When PostScript +Level 1 is generated, data is imaged to the entire printed +page and this option has no affect.

      @@ -410,8 +415,8 @@ has no affect.

      -

      The following generates Level 2 for all pages of a -facsimile:

      +

      The following generates PostScript Level 2 for all pages +of a facsimile:

      -
      tiff2ps -a2 fax.tif | lpr
      +
      tiff2ps −a2 fax.tif | lpr
       
      @@ -434,8 +439,8 @@ facsimile:

      Ghostscript then you can efficiently preview facsimile generated with the above command.

      -

      To generate Encapsulated for a the image at directory 2 -of an image use:

      +

      To generate Encapsulated PostScript for a the image at +directory 2 of an image use:

      -
      tiff2ps -d 1 foo.tif
      +
      tiff2ps −d 1 foo.tif
       
      @@ -454,7 +459,7 @@ of an image use:

      -

      (notice that directories are numbered starting at +

      (Notice that directories are numbered starting at zero.)

      If you have a long image, it may be split in several @@ -466,7 +471,7 @@ pages:

      -
      tiff2ps -h11 -w8.5 -H14 -L.5 foo.tif > foo.ps
      +
      tiff2ps −h11 −w8.5 −H14 −L.5 foo.tif > foo.ps
       
      @@ -495,24 +500,15 @@ readability).

      -

      Because does not support the notion of a colormap, 8-bit -palette images produce 24-bit images. This conversion -results in output that is six times bigger than the original -image and which takes a long time to send to a printer over -a serial line. Matters are even worse for 4-, 2-, and 1-bit -palette images.

      - - - -

      BUGS

      +

      Because PostScript does not support the notion of a +colormap, 8-bit palette images produce 24-bit PostScript +images. This conversion results in output that is six times +bigger than the original image and which takes a long time +to send to a printer over a serial line. Matters are even +worse for 4-, 2-, and 1-bit palette images.

      - - - -
      -

      Does not handle tiled images when generating PS Level I -output.

      +

      Does not handle tiled images when generating PostScript +Level I output.

      diff --git a/libs/tiff-3.8.2/html/man/tiff2rgba.1.html b/libs/tiff-4.0.2/html/man/tiff2rgba.1.html similarity index 84% rename from libs/tiff-3.8.2/html/man/tiff2rgba.1.html rename to libs/tiff-4.0.2/html/man/tiff2rgba.1.html index b39a27962d..35e06a54e2 100644 --- a/libs/tiff-3.8.2/html/man/tiff2rgba.1.html +++ b/libs/tiff-4.0.2/html/man/tiff2rgba.1.html @@ -1,5 +1,5 @@ - + @@ -36,7 +36,7 @@ RGBA color space

      -

      tiff2rgba [ options ] input.tif +

      tiff2rgba [ options ] input.tif output.tif

      @@ -63,11 +63,11 @@ combinations of BitsPerSample, photometric interpretation, block organization and planar configuration.

      The generated images are stripped images with four -samples per pixel (red, green, blue and alpha) or if the -n -flag is used, three samples per pixel (red, green, and -blue). The resulting images are always planar configuration -contiguous. For this reason, this program is a useful -utility for transform exotic TIFF files into a form +samples per pixel (red, green, blue and alpha) or if the +−n flag is used, three samples per pixel (red, +green, and blue). The resulting images are always planar +configuration contiguous. For this reason, this program is a +useful utility for transform exotic TIFF files into a form ingestible by almost any TIFF supporting software.

      @@ -87,10 +87,11 @@ ingestible by almost any TIFF supporting software.

      Specify a compression scheme to use when writing image data: −c none for no compression (the default), --c packbits for the PackBits compression algorithm, --c zip for the Deflate compression algorithm, -c -jpeg for the JPEG compression algorithm, and −c -lzw for Lempel-Ziv & Welch.

      +−c packbits for the PackBits compression +algorithm, −c zip for the Deflate compression +algorithm, −c jpeg for the JPEG compression +algorithm, and −c lzw for Lempel-Ziv & +Welch.

      @@ -135,8 +136,8 @@ limited RAM.

      Drop the alpha component from the output file, producing -a pure RGB file. Currently this does not work if the -b flag -is also in effect.

      +a pure RGB file. Currently this does not work if the +−b flag is also in effect.

      diff --git a/libs/tiff-3.8.2/html/man/tiffcmp.1.html b/libs/tiff-4.0.2/html/man/tiffcmp.1.html similarity index 96% rename from libs/tiff-3.8.2/html/man/tiffcmp.1.html rename to libs/tiff-4.0.2/html/man/tiffcmp.1.html index 339bce91a9..acd2e90f0b 100644 --- a/libs/tiff-3.8.2/html/man/tiffcmp.1.html +++ b/libs/tiff-4.0.2/html/man/tiffcmp.1.html @@ -1,5 +1,5 @@ - + @@ -88,7 +88,7 @@ files.

      -

      −z number

      +

      −z number

      compared; they may also generate spurious diagnostics.

      The image data of tiled files is not compared, since the -TIFFReadScanline() function is used. A error will be +TIFFReadScanline() function is used. An error will be reported for tiled files.

      The pixel and/or sample number reported in differences diff --git a/libs/tiff-3.8.2/html/man/tiffcp.1.html b/libs/tiff-4.0.2/html/man/tiffcp.1.html similarity index 84% rename from libs/tiff-3.8.2/html/man/tiffcp.1.html rename to libs/tiff-4.0.2/html/man/tiffcp.1.html index 310783a98f..4c7fcb62f7 100644 --- a/libs/tiff-3.8.2/html/man/tiffcp.1.html +++ b/libs/tiff-4.0.2/html/man/tiffcp.1.html @@ -1,5 +1,5 @@ - + @@ -74,7 +74,7 @@ any way.

      +

      −b image

      -

      −b image

      MSB2LSB.

      + + + + + + @@ -274,7 +288,7 @@ force samples to be written in separate planes.

      data written to the output file. By default (or when value 0 is specified), tiffcp attempts to set the rows/strip that no more than 8 kilobytes of data appear in a -strip. If you specify special value -1 it will +strip. If you specify special value −1 it will results in infinite number of the rows per strip. The entire image will be the one strip in that case.

      @@ -327,6 +341,20 @@ of data appear in a tile.

      + + + + + +
      +

      −i

      +
      + +

      Ignore non-fatal read errors and continue processing of +the input file.

      +
      +
      +

      −l

      + +

      −x

      +
      + +

      Force the output file to be written with PAGENUMBER value +in sequence.

      +
      +
      +

      −,=character

      -

      −,={character}

      -

      substitute {character} for ’,’ in parsing -image directory indices in files. This is necessary if -filenames contain commas. Note that ’,=’ with +

      substitute character for ‘,’ in +parsing image directory indices in files. This is necessary +if filenames contain commas. Note that −,= with whitespace immediately following will disable the special -meaning of the ’,’ entirely. See examples.

      +meaning of the ‘,’ entirely. See examples.

      @@ -366,7 +394,7 @@ result using LZW encoding:

      -
      tiffcp -c lzw a.tif b.tif result.tif
      +
      tiffcp −c lzw a.tif b.tif result.tif
       
      @@ -387,7 +415,7 @@ used:

      -
      tiffcp -c g4 -r 10000 g3.tif g4.tif
      +
      tiffcp −c g4 −r 10000 g3.tif g4.tif
       
      @@ -403,10 +431,11 @@ rows in the source file.)

      To extract a selected set of images from a multi-image TIFF file, the file name may be immediately followed by a -’,’ separated list of image directory indices. +‘,’ separated list of image directory indices. The first image is always in directory 0. Thus, to copy the -1st and 3rd images of image file "album.tif" to -"result.tif":

      +1st and 3rd images of image file +‘‘album.tif’’ to +‘‘result.tif’’:

      +

      A trailing comma denotes remaining images in sequence. +The following command will copy all image with except the +first one:

      -

      Given file "CCD.tif" whose first image is a -noise bias followed by images which include that bias, -subtract the noise from all those images following it (while -decompressing) with the command:

      -
      tiffcp -c none -b CCD.tif CCD.tif,1, result.tif
      +
      tiffcp album.tif,1, result.tif
       
      @@ -447,9 +475,11 @@ decompressing) with the command:

      -

      If the file above were named "CCD,X.tif", the -"-,=" option would be required to correctly parse -this filename with image numbers, as follows:

      +

      Given file ‘‘CCD.tif’’ whose +first image is a noise bias followed by images which include +that bias, subtract the noise from all those images +following it (while decompressing) with the +command:

      +
      -
      tiffcp -c none -,=% -b CCD,X.tif CCD,X%1%.tif result.tif
      +
      tiffcp −c none −b CCD.tif CCD.tif,1, result.tif
      +
      +
      + + + + + + +
      +

      If the file above were named +‘‘CCD,X.tif’’, the −,= +option would be required to correctly parse this filename +with image numbers, as follows:

      + + + + + diff --git a/libs/tiff-4.0.2/html/man/tiffcrop.1.html b/libs/tiff-4.0.2/html/man/tiffcrop.1.html new file mode 100644 index 0000000000..9c1edbbcf5 --- /dev/null +++ b/libs/tiff-4.0.2/html/man/tiffcrop.1.html @@ -0,0 +1,684 @@ + + + + + + +TIFFCROP + + + +

      TIFFCROP

      +NAME
      +SYNOPSIS
      +DESCRIPTION
      +OPTIONS
      +EXAMPLES
      +SEE ALSO
      + +
      + +

      NAME

      + +
      +
      tiffcp −c none −,=% −b CCD,X.tif CCD,X%1%.tif result.tif
       
       
      + + + +
      +

      tiffcrop − copy (and possibly convert and crop or +process) a TIFF file

      +
      + +

      SYNOPSIS

      + + + + + +
      +

      tiffcrop [ options ] src1.tif ... +srcN.tif dst.tif

      +
      + +

      DESCRIPTION

      + + + + + +
      +

      tiffcrop combines one or more files created +according to the Tag Image File Format, Revision 6.0 into a +single TIFF file. The output file may be +compressed using a different algorithm than the input files. +tiffcrop is most often used to extract portions of an +image for processing with bar code recognizer or OCR +software when that software cannot restrict the region of +interest to a specific portion of the image or to improve +efficiency when the regions of interest must be rotated.

      + +

      By default, tiffcrop will copy all the understood +tags in a TIFF directory of an input file to +the associated directory in the output file.

      + +

      tiffcrop can be used to reorganize the storage +characteristics of data in a file, and it will alter or +convert the image data content as specified at the same +time, unlike tiffcp.

      + +

      tiffcrop will behave exactly like tiffcp if none +of the new options are specified.

      +
      + +

      OPTIONS

      + + + + + +
      +

      −N odd|even|#,#-#,#|last

      + + + + + +
      +

      sequences and ranges of images within file to process. +The words odd or even may be used to specify +all odd or even numbered images. The word last may be +used in place of a number in the sequence to indicate the +final image in the file without knowing how many images +there are. Ranges of images may be specified with a dash and +multiple sets can be indicated by joining them in a +comma-separated list. e.g.. use −N 1,5-7,last +to process the 1st, 5th through 7th, and final image in the +file.

      +
      + + + + + +
      +

      −E top|bottom|left|right

      + + + + + +
      +

      use the top, bottom, left, or right edge as origin +reference for width and length of crop regions. May be +abbreviated to first letter.

      +
      + + + + + +
      +

      −U in|cm|px

      + + + + + +
      +

      units to apply to dimensions for margins and crop +regions. Inches or centimeters are converted to pixels using +the resolution unit specified in the TIFF file (which +defaults to inches if not specified in the IFD).

      +
      + + + + + +
      +

      −m #,#,#,#

      + + + + + +
      +

      margins to be removed from the image. The order must be +top, left, bottom, right with only commas separating the +elements of the list. Margins are scaled according to the +current units and removed before any other extractions are +computed. Capital M was in use.

      +
      + + + + + + + + + + + + + + +
      + +

      −X #

      +
      + +

      horizontal (X-axis) dimension of a region to extract +relative to the specified origin reference. If the origin is +the top or bottom edge, the X axis value will be assumed to +start at the left edge.

      +
      +
      + +

      −Y #

      +
      + +

      vertical (Y-axis) dimension of a region to extract +relative to the specified origin reference. If the origin is +the left or right edge, the Y axis value will be assumed to +start at the top.

      +
      +
      + + + + + +
      +

      −Z #:#,#:#

      + + + + + +
      +

      zones of the image designated as position X of Y equal +sized portions measured from the reference edge, e.g. 1:3 +would be first third of the image starting from the +reference edge minus any margins specified for the confining +edges. Multiple zones can be specified as a comma separated +list but they must reference the same edge. To extract the +top quarter and the bottom third of an image you would use +−Z 1:4,3:3.

      +
      + + + + + +
      +

      −F horiz|vert

      + + + + + +
      +

      flip, i.e. mirror, the image or extracted region +horizontally or vertically.

      +
      + + + + + +
      +

      −R 90|180|270

      + + + + + +
      +

      rotate the image or extracted region 90, 180, or 270 +degrees clockwise.

      +
      + + + + + + + + +
      + +

      −I

      +
      + +

      invert the colorspace values for grayscale and bi-level +images. This would be used to correct negative images that +have incorrect PHOTOMETRIC INTERPRETATION tags. No support +for color images.

      +
      +
      + + + + + +
      +

      −b image

      + + + + + +
      +

      subtract the following monochrome image from all others +processed. This can be used to remove a noise bias from a +set of images. This bias image is typically an image of +noise the camera saw with its shutter closed. Bias image +support is not available with options for cropping, +rotating, or inverting the image.

      +
      + + + + + + + + + + + + + + + + + + + + +
      + +

      −B

      +
      + +

      Force output to be written with Big-Endian byte order. +This option only has an effect when the output file is +created or overwritten and not when it is appended to.

      +
      +
      + +

      −C

      +
      + +

      Suppress the use of ‘‘strip +chopping’’ when reading images that have a +single strip/tile of uncompressed data.

      +
      +
      + +

      −c

      +
      + +

      Specify the compression to use for data written to the +output file: none for no compression, packbits +for PackBits compression, lzw for Lempel-Ziv & +Welch compression, jpeg for baseline JPEG +compression, zip for Deflate compression, g3 +for CCITT Group 3 (T.4) compression, and g4 for CCITT +Group 4 (T.6) compression. By default tiffcrop will +compress data according to the value of the +Compression tag found in the source file.

      +
      +
      + + + + + +
      +

      The CCITT Group 3 and Group 4 compression +algorithms can only be used with bi-level data.

      + +

      Group 3 compression can be specified together with +several T.4-specific options: 1d for 1-dimensional +encoding, 2d for 2-dimensional encoding, and +fill to force each encoded scanline to be zero-filled +so that the terminating EOL code lies on a byte boundary. +Group 3-specific options are specified by appending a +‘‘:’’-separated list to the +‘‘g3’’ option; e.g. −c +g3:2d:fill to get 2D-encoded data with byte-aligned EOL +codes.

      + +

      LZW compression can be specified together +with a predictor value. A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. LZW-specific +options are specified by appending a +‘‘:’’-separated list to the +‘‘lzw’’ option; e.g. −c +lzw:2 for LZW compression with horizontal +differencing.

      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +

      −f

      +
      + +

      Specify the bit fill order to use in writing output +data. By default, tiffcrop will create a new file +with the same fill order as the original. Specifying +−f lsb2msb will force data to be written with +the FillOrder tag set to LSB2MSB, while +−f msb2lsb will force data to be written with +the FillOrder tag set to MSB2LSB.

      +
      +
      + +

      −i

      +
      + +

      Ignore non-fatal read errors and continue processing of +the input file.

      +
      +
      + +

      −l

      +
      + +

      Specify the length of a tile (in pixels). +tiffcrop attempts to set the tile dimensions so that +no more than 8 kilobytes of data appear in a tile.

      +
      +
      + +

      −L

      +
      + +

      Force output to be written with Little-Endian byte +order. This option only has an effect when the output file +is created or overwritten and not when it is appended +to.

      +
      +
      + +

      −M

      +
      + +

      Suppress the use of memory-mapped files when reading +images.

      +
      +
      + +

      −p

      +
      + +

      Specify the planar configuration to use in writing image +data that has one 8-bit sample per pixel. By default, +tiffcrop will create a new file with the same planar +configuration as the original. Specifying −p +contig will force data to be written with multi-sample +data packed together, while −p separate will +force samples to be written in separate planes.

      +
      +
      + +

      −r

      +
      + +

      Specify the number of rows (scanlines) in each strip of +data written to the output file. By default (or when value +0 is specified), tiffcrop attempts to set the +rows/strip that no more than 8 kilobytes of data appear in a +strip. If you specify special value -1 it will +results in infinite number of the rows per strip. The entire +image will be the one strip in that case.

      +
      +
      + +

      −s

      +
      + +

      Force the output file to be written with data organized +in strips (rather than tiles).

      +
      +
      + +

      −t

      +
      + +

      Force the output file to be written with data organized +in tiles (rather than strips). options can be used to force +the resultant image to be written as strips or tiles of +data, respectively.

      +
      +
      + +

      −w

      +
      + +

      Specify the width of a tile (in pixels). tiffcrop +attempts to set the tile dimensions so that no more than 8 +kilobytes of data appear in a tile. tiffcrop attempts +to set the tile dimensions so that no more than 8 kilobytes +of data appear in a tile.

      +
      +
      + + + + + +
      +

      −,={character}

      + + + + + +
      +

      substitute {character} for ’,’ in parsing +image directory indices in files. This is necessary if +filenames contain commas. Note that ’,=’ with +whitespace immediately following will disable the special +meaning of the ’,’ entirely. See examples.

      +
      + +

      EXAMPLES

      + + + + + +
      +

      The following concatenates two files and writes the +result using LZW encoding:

      + + + + + +
      +
      tiffcrop -c lzw a.tif b.tif result.tif
      +
      +
      + + + + + + +
      +

      To convert a G3 1d-encoded TIFF to a +single strip of G4-encoded data the following might be +used:

      + + + + + +
      +
      tiffcrop -c g4 -r 10000 g3.tif g4.tif
      +
      +
      + + + + + + +
      +

      (1000 is just a number that is larger than the number of +rows in the source file.)

      + +

      To extract a selected set of images from a multi-image +TIFF file use the -N option described above. Thus, to copy +the 1st and 3rd images of image file "album.tif" +to "result.tif":

      + + + + + +
      +
      tiffcrop -N 1,3 album.tif result.tif
      +
      +
      + + + + + + +
      +

      Given file "CCD.tif" whose first image is a +noise bias followed by images which include that bias, +subtract the noise from all those images following it (while +decompressing) with the command:

      + + + + + +
      +
      tiffcrop -c none -b CCD.tif CCD.tif -d 2 result.tif
      +
      +
      + +

      SEE ALSO

      + + + + + + +
      +

      pal2rgb(1), tiffinfo(1), tiffcmp(1), +tiffcp(1), tiffmedian(1), tiffsplit(1), +libtiff(3TIFF)

      + +

      Libtiff library home page: +http://www.remotesensing.org/libtiff/

      +
      +
      + + diff --git a/libs/tiff-3.8.2/html/man/tiffdither.1.html b/libs/tiff-4.0.2/html/man/tiffdither.1.html similarity index 95% rename from libs/tiff-3.8.2/html/man/tiffdither.1.html rename to libs/tiff-4.0.2/html/man/tiffdither.1.html index 162c0e67a5..5e3cb7c5d2 100644 --- a/libs/tiff-3.8.2/html/man/tiffdither.1.html +++ b/libs/tiff-4.0.2/html/man/tiffdither.1.html @@ -1,5 +1,5 @@ - + @@ -128,9 +128,10 @@ differencing.

      data. By default, tiffdither will create a new file with the same fill order as the original. Specifying −f lsb2msb will force data to be written with -the FillOrder tag set to LSB2MSB , while -−f msb2lsb will force data to be written with -the FillOrder tag set to MSB2LSB .

      +the FillOrder tag set to LSB2MSB , +while −f msb2lsb will force data to be written +with the Fill- Order tag set to MSB2LSB +.

      diff --git a/libs/tiff-3.8.2/html/man/tiffdump.1.html b/libs/tiff-4.0.2/html/man/tiffdump.1.html similarity index 97% rename from libs/tiff-3.8.2/html/man/tiffdump.1.html rename to libs/tiff-4.0.2/html/man/tiffdump.1.html index da04dcb59f..c37d2eebcd 100644 --- a/libs/tiff-3.8.2/html/man/tiffdump.1.html +++ b/libs/tiff-4.0.2/html/man/tiffdump.1.html @@ -1,5 +1,5 @@ - + @@ -93,7 +93,7 @@ than the default decimal.

      -

      −m items

      +

      −m items

      +

      −o offset

      -

      −o offset

      - + @@ -69,7 +69,7 @@ following characteristics:

      diff --git a/libs/tiff-3.8.2/html/man/tiffinfo.1.html b/libs/tiff-4.0.2/html/man/tiffinfo.1.html similarity index 98% rename from libs/tiff-3.8.2/html/man/tiffinfo.1.html rename to libs/tiff-4.0.2/html/man/tiffinfo.1.html index 59bdd38310..d3a013ce77 100644 --- a/libs/tiff-3.8.2/html/man/tiffinfo.1.html +++ b/libs/tiff-4.0.2/html/man/tiffinfo.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/tiffmedian.1.html b/libs/tiff-4.0.2/html/man/tiffmedian.1.html similarity index 99% rename from libs/tiff-3.8.2/html/man/tiffmedian.1.html rename to libs/tiff-4.0.2/html/man/tiffmedian.1.html index afe3aa99df..78310511c6 100644 --- a/libs/tiff-3.8.2/html/man/tiffmedian.1.html +++ b/libs/tiff-4.0.2/html/man/tiffmedian.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/tiffset.1.html b/libs/tiff-4.0.2/html/man/tiffset.1.html similarity index 90% rename from libs/tiff-3.8.2/html/man/tiffset.1.html rename to libs/tiff-4.0.2/html/man/tiffset.1.html index 0069cb6627..7192d6e96e 100644 --- a/libs/tiff-3.8.2/html/man/tiffset.1.html +++ b/libs/tiff-4.0.2/html/man/tiffset.1.html @@ -1,5 +1,5 @@ - + @@ -37,7 +37,7 @@ header

      -

      BitsPerSample

      +

      BitsPerSample

      @@ -79,7 +79,7 @@ following characteristics:

      -

      SamplesPerPixel

      +

      SamplesPerPixel

      @@ -89,7 +89,7 @@ following characteristics:

      -

      PhotometricInterpretation

      +

      PhotometricInterpretation

      @@ -100,7 +100,7 @@ following characteristics:

      -

      PlanarConfiguration

      +

      PlanarConfiguration

      @@ -110,7 +110,7 @@ following characteristics:

      -

      Orientation

      +

      Orientation

      @@ -450,9 +450,9 @@ octal.

      Override the value of the PhotometricInterpretation tag; the parameter may be -one of: miniswhite, minisblack, rgb, -palette, mask, separated, ycbcr, -and cielab.

      +one of: miniswhite, minisblack, rgb, +palette, mask, separated, ycbcr, +and cielab.

      -

      tiffset [ options ] filename.tif

      +

      tiffset [ options ] filename.tif

      @@ -60,7 +60,8 @@ header to a specified value.

      -

      −s tagnumber [count] value ...

      +

      −s tagnumber [ count ] +value ...

      +

      −sf tagnumber filename

      -

      −sf tagnumber filename

      -
      tiffset -sf 270 descrip a.tif
      +
      tiffset −sf 270 descrip a.tif
       
      @@ -119,7 +120,8 @@ This option is supported for ASCII tags only.

      The following example sets the artist tag (315) of a.tif -to the string "Anonymous":

      +to the string +‘‘Anonymous’’:

      -
      tiffset -s 305 Anonymous a.tif
      +
      tiffset −s 305 Anonymous a.tif
       
      @@ -147,9 +149,9 @@ dpi:

      -
      tiffset -s 296 2 a.tif
      -tiffset -s 282 300.0 a.tif
      -tiffset -s 283 300.0 a.tif
      +
      tiffset −s 296 2 a.tif
      +tiffset −s 282 300.0 a.tif
      +tiffset −s 283 300.0 a.tif
       
      diff --git a/libs/tiff-3.8.2/html/man/tiffsplit.1.html b/libs/tiff-4.0.2/html/man/tiffsplit.1.html similarity index 98% rename from libs/tiff-3.8.2/html/man/tiffsplit.1.html rename to libs/tiff-4.0.2/html/man/tiffsplit.1.html index 6f5ada64bb..4de5c812eb 100644 --- a/libs/tiff-3.8.2/html/man/tiffsplit.1.html +++ b/libs/tiff-4.0.2/html/man/tiffsplit.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/man/tiffsv.1.html b/libs/tiff-4.0.2/html/man/tiffsv.1.html similarity index 99% rename from libs/tiff-3.8.2/html/man/tiffsv.1.html rename to libs/tiff-4.0.2/html/man/tiffsv.1.html index 823709696e..f9921a4841 100644 --- a/libs/tiff-3.8.2/html/man/tiffsv.1.html +++ b/libs/tiff-4.0.2/html/man/tiffsv.1.html @@ -1,5 +1,5 @@ - + diff --git a/libs/tiff-3.8.2/html/misc.html b/libs/tiff-4.0.2/html/misc.html similarity index 73% rename from libs/tiff-3.8.2/html/misc.html rename to libs/tiff-4.0.2/html/misc.html index 2ea9ad4e49..4f8b829b55 100644 --- a/libs/tiff-3.8.2/html/misc.html +++ b/libs/tiff-4.0.2/html/misc.html @@ -25,18 +25,20 @@ also be nice to be acknowledged.

      The libtiff software was written by Sam Leffler while working for Silicon Graphics.

      -The LZW algorithm is derived from the compress program (the proper -attribution is included in the source code). The Group 3 fax stuff -originated as code from Jef Poskanzer, but has since been rewritten -several times. The latest version uses an algorithm from Frank -Cringle -- consult libtiff/mkg3states.c and -libtiff/tif_fax3.h for further information. -The JPEG support was written by Tom Lane and is dependent on the -excellent work of Tom Lane and the Independent JPEG Group (IJG) -who distribute their work under friendly licensing similar to this -software. -Many other people have by now helped with bug fixes and code; a -few of the more persistent contributors have been: +The LZW algorithm is derived from the compress program (the proper attribution +is included in the source code). The Group 3 fax stuff originated as code +from Jef Poskanzer, but has since been rewritten several times. The latest +version uses an algorithm from Frank Cringle -- consult +libtiff/mkg3states.c and libtiff/tif_fax3.h for further +information. The JPEG support was written by Tom Lane and is dependent on the +excellent work of Tom Lane and the Independent JPEG Group (IJG) who distribute +their work under friendly licensing similar to this software. Joris Van Damme +implemented the robust Old JPEG decoder (as included in libtiff since version +3.9.0, there was another Old JPEG module in older releases, which was +incomplete and unsuitable for many existing images of that format). JBIG +module was written by Lee Howard and depends on JBIG library from the Markus +Kuhn. Many other people have by now helped with bug fixes and code; a few of +the more persistent contributors have been:

           Bjorn P. Brox
      @@ -73,6 +75,8 @@ few of the more persistent contributors have been:
           Bob Friesenhahn
           Lee Howard
           Joris Van Damme
      +    Tavis Ormandy
      +    Richard Nolde
       
      (my apology to anyone that was inadvertently not listed.) @@ -107,6 +111,6 @@ OF THIS SOFTWARE.
      -Last updated: $Date: 2005/10/23 19:43:29 $ +Last updated: $Date: 2007-02-24 15:47:04 $ diff --git a/libs/tiff-3.8.2/html/support.html b/libs/tiff-4.0.2/html/support.html similarity index 99% rename from libs/tiff-3.8.2/html/support.html rename to libs/tiff-4.0.2/html/support.html index f6f5d60877..a1255b9ba3 100644 --- a/libs/tiff-3.8.2/html/support.html +++ b/libs/tiff-4.0.2/html/support.html @@ -648,7 +648,7 @@


      - Last updated: $Date: 2005/12/28 06:53:18 $ + Last updated: $Date: 2005-12-28 06:53:18 $

      diff --git a/libs/tiff-3.8.2/html/tools.html b/libs/tiff-4.0.2/html/tools.html similarity index 54% rename from libs/tiff-3.8.2/html/tools.html rename to libs/tiff-4.0.2/html/tools.html index d085dbc274..65e9c0dd8d 100644 --- a/libs/tiff-3.8.2/html/tools.html +++ b/libs/tiff-4.0.2/html/tools.html @@ -11,7 +11,7 @@ width="144" height="108" align="left" border="1" hspace="6"> TIFF Tools Overview

      This software distribution comes with a small collection of programs for converting non-TIFF format images to TIFF and for -manipulating and interogating the contents of TIFF images. Several +manipulating and interrogating the contents of TIFF images. Several of these tools are useful in their own right. Many of them however are more intended to serve as programming examples for using the TIFF library.

      @@ -21,13 +21,13 @@ examples for writing programs to display and save TIFF images. +tiffgt     - + @@ -37,112 +37,121 @@ use the IRIS GL, can be easily tailored to other devices. The remaining programs should be device-independent:
      -tiffgt     Display the contents of one or more TIFF images using OpenGL. The software makes extensive use of the TIFFRGBAImage facilities described elsewhere.
      tiffsvtiffsv A program to save all or part of a screen dump on a Silicon Graphics system. As for tiffgt this code, while written to use the IRIS GL, can be easily tailored to other devices.
      - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + + + + + - + - + - + +RGB TIFF image, and creates a TIFF palette file as a result - + - + @@ -150,6 +159,6 @@ multi-image file

      Check out the manual pages for details about the above programs.


      -Last updated: $Date: 2006/01/03 02:16:07 $ +Last updated: $Date: 2009-10-28 22:13:37 $ diff --git a/libs/tiff-3.8.2/html/v3.4beta007.html b/libs/tiff-4.0.2/html/v3.4beta007.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta007.html rename to libs/tiff-4.0.2/html/v3.4beta007.html index c535d2708d..e8b697ea92 100644 --- a/libs/tiff-3.8.2/html/v3.4beta007.html +++ b/libs/tiff-4.0.2/html/v3.4beta007.html @@ -105,7 +105,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta016.html b/libs/tiff-4.0.2/html/v3.4beta016.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta016.html rename to libs/tiff-4.0.2/html/v3.4beta016.html index 22f185f54b..f9b0078c20 100644 --- a/libs/tiff-3.8.2/html/v3.4beta016.html +++ b/libs/tiff-4.0.2/html/v3.4beta016.html @@ -115,7 +115,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta018.html b/libs/tiff-4.0.2/html/v3.4beta018.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta018.html rename to libs/tiff-4.0.2/html/v3.4beta018.html index ac1877fae4..17bf989243 100644 --- a/libs/tiff-3.8.2/html/v3.4beta018.html +++ b/libs/tiff-4.0.2/html/v3.4beta018.html @@ -77,7 +77,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta024.html b/libs/tiff-4.0.2/html/v3.4beta024.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.4beta024.html rename to libs/tiff-4.0.2/html/v3.4beta024.html index 25a33478fa..74cd6e84cb 100644 --- a/libs/tiff-3.8.2/html/v3.4beta024.html +++ b/libs/tiff-4.0.2/html/v3.4beta024.html @@ -132,7 +132,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta028.html b/libs/tiff-4.0.2/html/v3.4beta028.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.4beta028.html rename to libs/tiff-4.0.2/html/v3.4beta028.html index ff7ef69a23..2b73c3dbfd 100644 --- a/libs/tiff-3.8.2/html/v3.4beta028.html +++ b/libs/tiff-4.0.2/html/v3.4beta028.html @@ -139,7 +139,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta029.html b/libs/tiff-4.0.2/html/v3.4beta029.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta029.html rename to libs/tiff-4.0.2/html/v3.4beta029.html index f2a3d3f6aa..bb06fa119c 100644 --- a/libs/tiff-3.8.2/html/v3.4beta029.html +++ b/libs/tiff-4.0.2/html/v3.4beta029.html @@ -79,7 +79,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta031.html b/libs/tiff-4.0.2/html/v3.4beta031.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta031.html rename to libs/tiff-4.0.2/html/v3.4beta031.html index d5b7eac4f4..9b645fa31a 100644 --- a/libs/tiff-3.8.2/html/v3.4beta031.html +++ b/libs/tiff-4.0.2/html/v3.4beta031.html @@ -87,7 +87,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta032.html b/libs/tiff-4.0.2/html/v3.4beta032.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta032.html rename to libs/tiff-4.0.2/html/v3.4beta032.html index bc14ef3368..61c3f4b711 100644 --- a/libs/tiff-3.8.2/html/v3.4beta032.html +++ b/libs/tiff-4.0.2/html/v3.4beta032.html @@ -83,7 +83,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta033.html b/libs/tiff-4.0.2/html/v3.4beta033.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta033.html rename to libs/tiff-4.0.2/html/v3.4beta033.html index 8d8345a871..78c22f39e0 100644 --- a/libs/tiff-3.8.2/html/v3.4beta033.html +++ b/libs/tiff-4.0.2/html/v3.4beta033.html @@ -75,7 +75,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta034.html b/libs/tiff-4.0.2/html/v3.4beta034.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.4beta034.html rename to libs/tiff-4.0.2/html/v3.4beta034.html index 77d9863b4b..d928b1a56e 100644 --- a/libs/tiff-3.8.2/html/v3.4beta034.html +++ b/libs/tiff-4.0.2/html/v3.4beta034.html @@ -61,7 +61,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta035.html b/libs/tiff-4.0.2/html/v3.4beta035.html similarity index 97% rename from libs/tiff-3.8.2/html/v3.4beta035.html rename to libs/tiff-4.0.2/html/v3.4beta035.html index 22fb2b8d0e..ac5f4933ef 100644 --- a/libs/tiff-3.8.2/html/v3.4beta035.html +++ b/libs/tiff-4.0.2/html/v3.4beta035.html @@ -56,7 +56,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.4beta036.html b/libs/tiff-4.0.2/html/v3.4beta036.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.4beta036.html rename to libs/tiff-4.0.2/html/v3.4beta036.html index e36754d364..aa7a876842 100644 --- a/libs/tiff-3.8.2/html/v3.4beta036.html +++ b/libs/tiff-4.0.2/html/v3.4beta036.html @@ -110,7 +110,7 @@ The following information is located here:
      Sam Leffler / sam@engr.sgi.com -Last updated $Date: 1999/08/09 20:21:21 $. +Last updated $Date: 1999-08-09 20:21:21 $.
      diff --git a/libs/tiff-3.8.2/html/v3.5.1.html b/libs/tiff-4.0.2/html/v3.5.1.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.5.1.html rename to libs/tiff-4.0.2/html/v3.5.1.html index 0c88de9547..9302cbbb1f 100644 --- a/libs/tiff-3.8.2/html/v3.5.1.html +++ b/libs/tiff-4.0.2/html/v3.5.1.html @@ -69,7 +69,7 @@ utility.
      -Last updated $Date: 2006/01/03 01:42:30 $. +Last updated $Date: 2006-01-03 01:42:30 $. diff --git a/libs/tiff-3.8.2/html/v3.5.2.html b/libs/tiff-4.0.2/html/v3.5.2.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.5.2.html rename to libs/tiff-4.0.2/html/v3.5.2.html index 71b486a6f4..ad70db838f 100644 --- a/libs/tiff-3.8.2/html/v3.5.2.html +++ b/libs/tiff-4.0.2/html/v3.5.2.html @@ -102,7 +102,7 @@ The following information is located here:
      -Last updated $Date: 2004/11/26 14:37:20 $. +Last updated $Date: 2004-11-26 14:37:20 $. diff --git a/libs/tiff-3.8.2/html/v3.5.3.html b/libs/tiff-4.0.2/html/v3.5.3.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.5.3.html rename to libs/tiff-4.0.2/html/v3.5.3.html index e7910d9b7a..3103a6b483 100644 --- a/libs/tiff-3.8.2/html/v3.5.3.html +++ b/libs/tiff-4.0.2/html/v3.5.3.html @@ -126,7 +126,7 @@ LZW decompression is unchanged.
      -Last updated $Date: 2004/11/26 14:37:20 $. +Last updated $Date: 2004-11-26 14:37:20 $. diff --git a/libs/tiff-3.8.2/html/v3.5.4.html b/libs/tiff-4.0.2/html/v3.5.4.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.5.4.html rename to libs/tiff-4.0.2/html/v3.5.4.html index 714621e0c8..7b06dafce0 100644 --- a/libs/tiff-3.8.2/html/v3.5.4.html +++ b/libs/tiff-4.0.2/html/v3.5.4.html @@ -82,7 +82,7 @@ The following information is located here:
      -Last updated $Date: 2006/01/03 01:45:41 $. +Last updated $Date: 2006-01-03 01:45:41 $. diff --git a/libs/tiff-3.8.2/html/v3.5.5.html b/libs/tiff-4.0.2/html/v3.5.5.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.5.5.html rename to libs/tiff-4.0.2/html/v3.5.5.html index 20be92f8ec..38b1f6dc7c 100644 --- a/libs/tiff-3.8.2/html/v3.5.5.html +++ b/libs/tiff-4.0.2/html/v3.5.5.html @@ -149,7 +149,7 @@ The following information is located here:
      -Last updated $Date: 2004/11/26 14:37:20 $. +Last updated $Date: 2004-11-26 14:37:20 $. diff --git a/libs/tiff-3.8.2/html/v3.5.6-beta.html b/libs/tiff-4.0.2/html/v3.5.6-beta.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.5.6-beta.html rename to libs/tiff-4.0.2/html/v3.5.6-beta.html index 682f845baa..d4933a8e15 100644 --- a/libs/tiff-3.8.2/html/v3.5.6-beta.html +++ b/libs/tiff-4.0.2/html/v3.5.6-beta.html @@ -179,7 +179,7 @@ The following information is located here:
      -Last updated $Date: 2006/03/18 17:12:47 $. +Last updated $Date: 2006-03-18 17:12:47 $. diff --git a/libs/tiff-3.8.2/html/v3.5.7.html b/libs/tiff-4.0.2/html/v3.5.7.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.5.7.html rename to libs/tiff-4.0.2/html/v3.5.7.html index 528df74e6e..84dff1abb6 100644 --- a/libs/tiff-3.8.2/html/v3.5.7.html +++ b/libs/tiff-4.0.2/html/v3.5.7.html @@ -253,7 +253,7 @@ Updated bug section of tiffcmp.1 to note tiled file issues.
      -Last updated $Date: 2004/11/26 14:37:20 $. +Last updated $Date: 2004-11-26 14:37:20 $. diff --git a/libs/tiff-3.8.2/html/v3.6.0.html b/libs/tiff-4.0.2/html/v3.6.0.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.6.0.html rename to libs/tiff-4.0.2/html/v3.6.0.html index 888e5472e7..4d65197e37 100644 --- a/libs/tiff-3.8.2/html/v3.6.0.html +++ b/libs/tiff-4.0.2/html/v3.6.0.html @@ -428,7 +428,7 @@ KIT:
      -Last updated $Date: 2003/10/04 11:38:17 $. +Last updated $Date: 2003-10-04 11:38:17 $. diff --git a/libs/tiff-3.8.2/html/v3.6.1.html b/libs/tiff-4.0.2/html/v3.6.1.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.6.1.html rename to libs/tiff-4.0.2/html/v3.6.1.html index d10606225b..58e5605569 100644 --- a/libs/tiff-3.8.2/html/v3.6.1.html +++ b/libs/tiff-4.0.2/html/v3.6.1.html @@ -193,7 +193,7 @@ KIT:
      -Last updated $Date: 2003/12/24 22:14:15 $. +Last updated $Date: 2003-12-24 22:14:15 $. diff --git a/libs/tiff-3.8.2/html/v3.7.0.html b/libs/tiff-4.0.2/html/v3.7.0.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.7.0.html rename to libs/tiff-4.0.2/html/v3.7.0.html index 413f2c6053..739775696a 100644 --- a/libs/tiff-3.8.2/html/v3.7.0.html +++ b/libs/tiff-4.0.2/html/v3.7.0.html @@ -138,7 +138,7 @@ KIT:
      -Last updated $Date: 2004/12/20 19:31:44 $. +Last updated $Date: 2004-12-20 19:31:44 $. diff --git a/libs/tiff-3.8.2/html/v3.7.0alpha.html b/libs/tiff-4.0.2/html/v3.7.0alpha.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.7.0alpha.html rename to libs/tiff-4.0.2/html/v3.7.0alpha.html index 95c633ca5d..d18de35b14 100644 --- a/libs/tiff-3.8.2/html/v3.7.0alpha.html +++ b/libs/tiff-4.0.2/html/v3.7.0alpha.html @@ -243,7 +243,7 @@ KIT:
      -Last updated $Date: 2006/03/18 17:12:47 $. +Last updated $Date: 2006-03-18 17:12:47 $. diff --git a/libs/tiff-3.8.2/html/v3.7.0beta.html b/libs/tiff-4.0.2/html/v3.7.0beta.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.7.0beta.html rename to libs/tiff-4.0.2/html/v3.7.0beta.html index 7d7c868b08..81701f0003 100644 --- a/libs/tiff-3.8.2/html/v3.7.0beta.html +++ b/libs/tiff-4.0.2/html/v3.7.0beta.html @@ -156,7 +156,7 @@ KIT:
      -Last updated $Date: 2006/03/18 17:12:47 $. +Last updated $Date: 2006-03-18 17:12:47 $. diff --git a/libs/tiff-3.8.2/html/v3.7.0beta2.html b/libs/tiff-4.0.2/html/v3.7.0beta2.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.7.0beta2.html rename to libs/tiff-4.0.2/html/v3.7.0beta2.html index 67dd8dad3f..151524a0b9 100644 --- a/libs/tiff-3.8.2/html/v3.7.0beta2.html +++ b/libs/tiff-4.0.2/html/v3.7.0beta2.html @@ -125,7 +125,7 @@ KIT:
      -Last updated $Date: 2006/03/18 17:12:47 $. +Last updated $Date: 2006-03-18 17:12:47 $. diff --git a/libs/tiff-3.8.2/html/v3.7.1.html b/libs/tiff-4.0.2/html/v3.7.1.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.7.1.html rename to libs/tiff-4.0.2/html/v3.7.1.html index b888792f21..d3ffb7a336 100644 --- a/libs/tiff-3.8.2/html/v3.7.1.html +++ b/libs/tiff-4.0.2/html/v3.7.1.html @@ -227,7 +227,7 @@ The following information is located here: -Last updated $Date: 2004/12/20 19:31:44 $. +Last updated $Date: 2004-12-20 19:31:44 $. diff --git a/libs/tiff-3.8.2/html/v3.7.2.html b/libs/tiff-4.0.2/html/v3.7.2.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.7.2.html rename to libs/tiff-4.0.2/html/v3.7.2.html index 6cb6f7cd3a..415ee6fb20 100644 --- a/libs/tiff-3.8.2/html/v3.7.2.html +++ b/libs/tiff-4.0.2/html/v3.7.2.html @@ -216,7 +216,7 @@ The following information is located here: -Last updated $Date: 2005/03/15 15:17:44 $. +Last updated $Date: 2005-03-15 15:17:44 $. diff --git a/libs/tiff-3.8.2/html/v3.7.3.html b/libs/tiff-4.0.2/html/v3.7.3.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.7.3.html rename to libs/tiff-4.0.2/html/v3.7.3.html index d69845176c..0eee449d05 100644 --- a/libs/tiff-3.8.2/html/v3.7.3.html +++ b/libs/tiff-4.0.2/html/v3.7.3.html @@ -224,7 +224,7 @@ The following information is located here: -Last updated $Date: 2006/01/04 22:04:46 $. +Last updated $Date: 2006-01-04 22:04:46 $. diff --git a/libs/tiff-3.8.2/html/v3.7.4.html b/libs/tiff-4.0.2/html/v3.7.4.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.7.4.html rename to libs/tiff-4.0.2/html/v3.7.4.html index 943732019e..3ef394b607 100644 --- a/libs/tiff-3.8.2/html/v3.7.4.html +++ b/libs/tiff-4.0.2/html/v3.7.4.html @@ -127,7 +127,7 @@ The following information is located here: -Last updated $Date: 2005/11/03 14:18:43 $. +Last updated $Date: 2005-11-03 14:18:43 $. diff --git a/libs/tiff-3.8.2/html/v3.8.0.html b/libs/tiff-4.0.2/html/v3.8.0.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.8.0.html rename to libs/tiff-4.0.2/html/v3.8.0.html index 914dcb0c55..ecd5b74ecd 100644 --- a/libs/tiff-3.8.2/html/v3.8.0.html +++ b/libs/tiff-4.0.2/html/v3.8.0.html @@ -193,7 +193,7 @@ The following information is located here: -Last updated $Date: 2006/01/04 23:38:38 $. +Last updated $Date: 2006-01-04 23:38:38 $. diff --git a/libs/tiff-3.8.2/html/v3.8.1.html b/libs/tiff-4.0.2/html/v3.8.1.html similarity index 99% rename from libs/tiff-3.8.2/html/v3.8.1.html rename to libs/tiff-4.0.2/html/v3.8.1.html index 9fea1407e6..975309335f 100644 --- a/libs/tiff-3.8.2/html/v3.8.1.html +++ b/libs/tiff-4.0.2/html/v3.8.1.html @@ -211,7 +211,7 @@ The following information is located here:
      -Last updated $Date: 2006/03/13 14:52:12 $. +Last updated $Date: 2006-03-13 14:52:12 $. diff --git a/libs/tiff-3.8.2/html/v3.8.2.html b/libs/tiff-4.0.2/html/v3.8.2.html similarity index 98% rename from libs/tiff-3.8.2/html/v3.8.2.html rename to libs/tiff-4.0.2/html/v3.8.2.html index e648127586..0422975c00 100644 --- a/libs/tiff-3.8.2/html/v3.8.2.html +++ b/libs/tiff-4.0.2/html/v3.8.2.html @@ -131,7 +131,7 @@ The following information is located here:
      -Last updated $Date: 2006/03/23 14:54:01 $. +Last updated $Date: 2006-03-23 14:54:01 $. diff --git a/libs/tiff-4.0.2/html/v3.9.0beta.html b/libs/tiff-4.0.2/html/v3.9.0beta.html new file mode 100644 index 0000000000..d7d8821a5a --- /dev/null +++ b/libs/tiff-4.0.2/html/v3.9.0beta.html @@ -0,0 +1,304 @@ + + + + Changes in TIFF v3.9.0beta + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

      +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

      +

      +


      + + + +MAJOR CHANGES: + +
        +
      • New tiffcrop utility contributed by Richard Nolde. + tiffcrop does the same as tiffcp, but also can crop, + extract, rotate and mirror images. + +
      • tif_jbig.c: Added support for JBIG compression scheme + (34661 code), contributed by Lee Howard. + +
      • Totally new implementation of OJPEG module from + Joris Van Damme. No need to patch libjpeg anymore. Many OJPEG files + should be supported now that was not supported previously. + +
      + + +


      + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
        + +
      • tif_config.wince.h, tiffconf.wince.h, tif_wince.c: WinCE-specific + compatibility stuff from Mateusz Loskot. + +
      • Rename config.h.vc and tif_config.h.vc to config.vc.h and + tif_config.vc.h for easier identification by folks using an IDE. + +
      • configure, configure.ac: OJPEG support enabled by default (i.e., + whe the conformant JPEG support enabled). + +
      • README.vms, Makefile.am, configure.com, libtiff/{Makefile.am, + tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}: + Added support for OpenVMS by Alexey Chupahin. + +
      • nmake.opt: use /EHsc for VS2005 compatibility. Also define + _CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005. + +
      + +


      + + + +CHANGES IN LIBTIFF: + +
        +
      • tif_dirinfo.c (_TIFFFindFieldInfo): Don't attempt to + bsearch() on a NULL fieldinfo list. + (_TIFFFindFieldInfoByName): Don't attempt to lfind() on a NULL + fieldinfo list. + +
      • tif_jpeg.c: Changed JPEGInitializeLibJPEG() so that it + will convert from decompressor to compressor or compress to decompress + if required by the force arguments. This works around a problem in + where the JPEGFixupTestSubsampling() may cause a decompressor to + be setup on a directory when later a compressor is required with the + force flag set. Occurs with the addtiffo program for instance. + +
      • tif_dirwrite.c: Fixed swapping of byte arrays stored + in-place in tag offsets as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1363 + +
      • tif_getimage.c: workaround for 'Fractional scanline' error + reading OJPEG images with rowsperstrip that is not a multiple of + vertical subsampling factor. This bug is mentioned in + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1390 and + + http://www.asmail.be/msg0054766825.html + +
      • tif_dirread.c: Added special function to handle + SubjectDistance EXIF tag as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1362 + +
      • tif_dirread.c, tif_read.c: Type of the byte counters + changed from tsize_t to uint32 to be able to work with data arrays + larger than 2GB. Fixes bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=89 + Idea submitted by Matt Hancher. + +
      • tif_dir.c: Workaround for incorrect TIFFs with + ExtraSamples == 999 produced by Corel Draw. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1490 + +
      • tif_write.c: TIFFAppendToStrip() - clear sorted flag if + we move a strip. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1359 + +
      • tif_fax3.c: Save the state of printdir codec dependent method. + +
      • tif_jpeg.c: Save the state of printdir codec dependent method + as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1273 + +
      • tif_win32.c: Fixed problem with offset value manipulation + as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1322 + +
      • tif_fax3.c, tif_next.c, tif_pixarlog.c: Fixed multiple + vulnerabilities, as per Gentoo bug (): + + http://bugs.gentoo.org/show_bug.cgi?id=142383 + +
      • tif_lzw.c, tif_zip.c: Fixed problems with mixing + encoding and decoding on the same read-write TIFF handle. The LZW + code can now maintain encode and decode state at the same time. The + ZIP code will switch back and forth as needed. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=757 + +
      • tif_msdos.c: Avoid handle leak for failed opens. + c/o Thierry Pierron + +
      • tif_dirwrite.c: take care not to flush out buffer of strip/tile + data in _TIFFWriteDirectory if TIFF_BEENWRITING not set. Relates + to bug report by Peng Gao with black strip at bottom of images. + +
      • tif_dirwrite.c: make sure to use uint32 for wordcount in + TIFFWriteNormanTag if writecount is VARIABLE2 for ASCII fields. + It already seems to have been done for other field types. Needed + for "tiffset" on files with geotiff ascii text. + +
      • tif_dirinfo.c: Added missed EXIF tag ColorSpace (40961). + +
      • tif_dirread.c: Move IFD fetching code in the separate + function TIFFFetchDirectory() avoiding code duplication in + TIFFReadDirectory() and TIFFReadCustomDirectory(). + +
      • tif_readdir.c: Added case in EstimateStripByteCounts() for tiled + files. Modified TIFFReadDirectory() to not invoke + EstimateStripByteCounts() for case where entry 0 and 1 are unequal but + one of them is zero. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1204 + +
      • tif_open.c, tif_dirread.c, tiffiop.h: Move IFD looping + checking code in the separate function TIFFCheckDirOffset(). + +
      • tif_aux.c: Added _TIFFCheckRealloc() function. + +
      • tif_fax3.c: Fixed problems in fax decoder as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1194 + +
      • tif_jbig.c: Added support for JBIG compression scheme + (34661 code) contributed by Lee Howard. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=896 + +
      • tif_getimage.c: Added support for planarconfig separate + non-subsampled YCbCr (i.e. separate YCbCr with subsampling [1,1]). + +
      • tif_getimage.c: Revision of all RGB(A) put routines: +
          +
        • Conversion of unassociated alpha to associated alpha + now done with more performant LUT, and calculation more + correct. +
        • Conversion of 16bit data to 8bit data now done with + more performant LUT, and calculation more correct +
        • Bugfix of handling of 16bit RGB with unassociated alpha +
        + +
      • tif_ojpeg.c: totally new implementation + +
      • tif_getimage.c: removed TIFFTAG_JPEGCOLORMODE handling + of OJPEG images in favor of tif_getimage.c native handling of + YCbCr and desubsampling. + +
      • tif_jpeg.c: JPEGVSetField() so that altering the photometric + interpretation causes the "upsampled" flag to be recomputed. Fixes + peculiar bug where photometric flag had to be set before jpegcolormode + flag. + +
      + +


      + + + +CHANGES IN THE TOOLS: + + + +


      + + + +CHANGES IN THE CONTRIB AREA: + +
        + +
      • contrib/addtiffo/tif_overview.c: Fix problems with odd sized + output blocks in TIFF_DownSample_Subsampled() (bug 1542). + +
      • contrib/dbs/xtiff/xtiff.c: Make xtiff utility compilable. + Though it is still far from the state of being working and useful. + +
      + +Last updated $Date: 2009-08-20 22:57:39 $. + + + diff --git a/libs/tiff-4.0.2/html/v3.9.1.html b/libs/tiff-4.0.2/html/v3.9.1.html new file mode 100644 index 0000000000..c97d94f8c5 --- /dev/null +++ b/libs/tiff-4.0.2/html/v3.9.1.html @@ -0,0 +1,115 @@ + + + + Changes in TIFF v3.9.1 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

      +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

      +

      +


      + + + +MAJOR CHANGES: + +
        +
      • This is a bug-fix release for several bugs (two of which + are dire) which were discovered in the 3.9.0 release. + +
      + + +


      + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
        + +
      • Several defines were missing from tif_config.vc.h which + are necessary to compile the library using MSVC. + +
      • Colorized tests were actually not enabled as expected. + Parallel tests mode is now also enabled so that tests can be + run in parallel, and test output is sent to .log files. + +
      + +


      + + + +CHANGES IN LIBTIFF: + +
        +
      • libtiff/tif_write.c (TIFFAppendToStrip): Remove cast + which caused libtiff to output a wrong last strip with + byte-count and strip-offset of zero. This cast was added on + the day of the 3.9.0 release. + +
      • libtiff/tif_dirwrite.c: Back out changes from 2007-11-22 + that resulted in the final strip not being written in some + circumstances. + http://bugzilla.maptools.org/show_bug.cgi?id=2088 + +
      + +


      + + + +CHANGES IN THE TOOLS: + +
        +
      • None + +
      + +


      + + + +CHANGES IN THE CONTRIB AREA: + +
        + +
      • None + +
      + +Last updated $Date: 2009-08-28 18:54:11 $. + + + diff --git a/libs/tiff-4.0.2/html/v3.9.2.html b/libs/tiff-4.0.2/html/v3.9.2.html new file mode 100644 index 0000000000..bb76794c97 --- /dev/null +++ b/libs/tiff-4.0.2/html/v3.9.2.html @@ -0,0 +1,122 @@ + + + + Changes in TIFF v3.9.2 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

      +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

      +

      +


      + + + +MAJOR CHANGES: + +
        + +
      • Fixes a number of bugs present in the 3.9.1 release. + +
      • OJPEG support updated to work with IJG JPEG 7 release. + +
      • Tiffcrop validated for most TIFF storage subformats and sample depths. + +
      + + +


      + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
        + +
      • x86_64 now uses the same default fill order as i386. + +
      + +


      + + + +CHANGES IN LIBTIFF: + +
        +
      • Writing tags with an array value of type TIFF_DOUBLE now + returns correct error status. The TIFFTAG_SMINSAMPLEVALUE and + TIFFTAG_SMAXSAMPLEVALUE tags failed to write without this fix. + +
      • OJPEG decoder now works with IJG JPEG 7. Resolves "Bug + 2090 - OJPEG crash with libjpeg v7". + http://bugzilla.maptools.org/show_bug.cgi?id=2090 + +
      • Eliminate most GCC "dereferencing type-punned pointer" + warnings. + +
      + +


      + + + +CHANGES IN THE TOOLS: + +
        + +
      • New tiffcrop from Richard Nolde. Major updates to add + significant functionality for reading and writing tile based + images with bit depths not a multiple of 8 which cannot be + handled by tiffcp. + +
      • Allow building tools with GCC using the "-Wformat + -Werror=format-security" flags. + +
      + +


      + + + +CHANGES IN THE CONTRIB AREA: + +
        + +
      • None + +
      + +Last updated $Date: 2009-11-04 17:38:13 $. + + + diff --git a/libs/tiff-4.0.2/html/v4.0.0.html b/libs/tiff-4.0.2/html/v4.0.0.html new file mode 100644 index 0000000000..9694a1e048 --- /dev/null +++ b/libs/tiff-4.0.2/html/v4.0.0.html @@ -0,0 +1,269 @@ + + + + Changes in TIFF v4.0.0 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

      +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. Please consult +the ChangeLog file in the source package for full change details. The +following information is located here: +

      +

      +


      + + + +

      MAJOR CHANGES:

      + +BigTIFF support changes: + +
        + +
      • The options parameter in the TIFFOpen and TIFFClientOpen funcs has + been extended. When creating new files, you can add option '4' to + specify you want to create a ClassicTIFF file, though that is the + default and the option is not strictly necessary. (As such, old + calling code will continue to function and create ClassicTIFF files.) + Or you can add option '8' to specify you want to create a BigTIFF file + instead. This new option is also reflected in some of the tools we + already upgraded. For instance, you can use the -8 option on tiffcp to + have tiffcp produce BigTIFF files instead of the default ClassicTIFF. + (Whilst on additional option is provided for version selection when + creating new files, no such option is necessary when reading TIFF + files. LibTiff reads ClassicTIFF and BigTIFF both, and the application + does not need to be aware which TIFF version an opened file is.) + +
      • Although the tag count in BigTIFF is 64bit, we restricted the + count in the implementation to a much more reasonable size. This is + necessary in current implementation, because all tag data gets read + automatically in the IFD reading stage, so if there's half a dozen + private tags with multiple gigabytes of data that causes considerable + overhead even if the application level is never interested in these + tags. Our choice to ignore tags with data longer then a certain sanity + value is much needed as things stand. We also recommend to step away + from writing tiles that are 8 kilobyte in their uncompressed form, or + writing single-line strips, in really big files, resulting in mega's + of tiles or strips. It's much more efficient to choose bigger tile or + strip sizes, up to several megabyte if needed, and have a few kilo of + tiles or strips instead. + +
      • Although it's rare, some application code does directly access + file offsets. Some of these are automatically upgraded because they + used the toff_t type, others need to be aware that the datatype + changed and need to start using toff_t or uint64. This impacts access + to tags like the EXIF IFD tag, for example, or the SubIfds tag, or to + StripOffsets or TileOffsets, the return type of functions like + TIFFCurrentDirOffset, and a parameter type to functions like + TIFFSetSubDirectory. + +
      • Although it's rare, some application code does use structures + like TIFFHeader or TIFFDirEntry that used to be an exact binary + representation of TIFF structures. These need to change. The old + TIFFHeader structure is replaced by the new TIFFHeaderClassic, + TIFFHeaderBig, and TIFFHeaderCommon structures that are an exact + binary representation of the ClassicTIFF and BigTIFF header, and of + the part that is common to both. There is no new equivalent for the + old TIFFDirEntry structure (or more precisely, there is still a + TIFFDirEntry structure, but it is changed, moved to library-private + definition, and no longer an exact binary representation of the tag + structure of either TIFF version). + +
      • Sizer functions, like TIFFTileSize or TIFFScanlineSize and the + like, return a tmsize_t value (tmsize_t is defined as int32 on 32bit + machines, and int64 on 64bit machines, and as such it is meant to + represent signed memory sizes). This is because we figure 98% of the + calling code uses the return value as sizes in allocations and the + like. So, any overflow that is theoretically possible with BigTIFF + when LibTiff is running on a 32bit system, is best detected inside the + sizer functions and it is best to return a type that makes sense as a + memory size. If your calling code is the exception and is interested + in actual file size, you best use the newer TIFFTileSize64 or + TIFFScanlineSize64 function that returns an uint64 type. + +
      • These TIFF tags require a 64-bit type as an argument in + libtiff 4.0.0: +
          +
        • TIFFTAG_FREEBYTECOUNTS +
        • TIFFTAG_FREEOFFSETS +
        • TIFFTAG_STRIPBYTECOUNTS +
        • TIFFTAG_STRIPOFFSETS +
        • TIFFTAG_TILEBYTECOUNTS +
        • TIFFTAG_TILEOFFSETS +
        + +
      + +Other important backward incompatible changes in the public API: + +
        +
      • TIFFRewriteField() renamed into _TIFFRewriteField() and moved out + from the public interface (from tiffio.h to tiffiop.h). Type of its + 'count' parameter changed from uint32 to tmsize_t. + +
      • TIFFMergeFieldInfo() returns non-void result now. It returns 0 + if successful and -1 if failed. Though this is now obsoleted function + and should not be used in new programs. Use the new tag extension + scheme instead. + +
      • TIFFFieldWithTag() and TIFFFieldWithName() functions now return + pointer to TIFFField constant object instead of TIFFFieldInfo. + +
      • TIFFReassignTagToIgnore() function and TIFFIgnoreSense enumeration + have been removed. They was unused and never been used properly. + Should be unneeded for high-level applications. + +
      • TIFFTagValue structure removed from the public tiffio.h + to private tif_dir.h and not accessible anymore. It should be unneeded + for high-level applications. + +
      + +


      + + +

      CHANGES IN THE SOFTWARE CONFIGURATION:

      + +
        + +
      • Updated autotools: Autoconf 2.68, Automake 1.11.1, libtool + 2.4. + +
      • Enabled support for Automake silent build rules + (--enable-silent-rules or 'make V=0') + +
      • Enabled support for Automake colorized and parallel tests. + +
      • Added detection of 64-bit integer types since libtiff 4.0 + requires use of 64-bit signed and unsigned integer types. + +
      • Libtiff now provides a more comprehensive test suite with + over 72 tests, which may be executed on Unix-like systems, or + under Microsoft Windows using MinGW/MSYS or Cygwin. + +
      • --disable-lzma configure option to disable use of liblzma. + +
      • --enable-defer-strile-load configure option to enable + experimental deferred strip/tile offset/size loading. May + cause some extremely sophisticated uses of libtiff to fail. + +
      • --enable-chunky-strip-read configure option to enable + experimental enable reading large strips in chunks in + TIFFReadScanline(). + +
      • Now always uses WIN32 native I/O functions for Microsoft + Windows except for under Cygwin. + +
      • Now provides a pkg-config support file (libtiff-4.pc). + +
      + +


      + + + +

      CHANGES IN LIBTIFF:

      + +
        + +
      • Patches/fixes made to stable libtiff (v3.9.X) are also + applied to 4.0.0. There are too many to list here. See the + distribution ChangeLog for a detailed change list. + +
      • There is considerable change in some files like + tif_dirread and tif_dirwrite. These changes don't impact + backwards compatibility, they are mostly a clean rewrite that + does allow BigTIFF support as well as somewhat more robust + reading of the unexpected already and will also serve future + API extension but does not impact current API or functionality + in a negative way that you need to know about. + +
      • Although there is still a functional definition for types + like toff_t (file offset), tstrip_t (strip index number), etc, + we recommend against using these in newer code. We have + learned that it is next to impossible to use these + consistently and make real abstraction of the binary format of + these types. Instead, at a certain level we always end up + doing casts anyway, and taking the exact binary format into + account, so these types are nothing but dangerously misleading + and obfuscating. You do not need to update calling code that + uses them, as 99.9% of such code will continue to work. But we + recommend against using them in newer calling code, and we + started replacing them with binary clear types like uint16, + uint32 and such in the library. + +
      • We do use and will continue to use one functional type + that is an exception to the above rule, being tmsize_t. This + is a signed memory size type, i.e. it is int32 on 32bit + machines, or int64 on 64bit machines. + +
      • Optionally support LZMA compression via TIFF tag 34925. + Tiffcp supports compression levels similar to "-c lzma:p1" or + "-c zip:p9 for setting the LZMA compression parameters. + +
      • Optionally defer the load of strip/tile offset and size + tags for optimized scanning of directories. Enabled with the + --enable-defer-strile-load configure option (DEFER_STRILE_LOAD + #define in tif_config.h). + +
      • Optionally enable experimental support for reading big + strips in chunks. Enabled with the --enable-chunky-strip-read + configure option. + +
      + +


      + + + +

      CHANGES IN THE TOOLS:

      + +
        + +
      • tiffset: add -d and -sd switches to allow operation on + a particular directory, not just the first. + +
      + +


      + + + +

      CHANGES IN THE CONTRIB AREA:

      + +
        +
      + +Last updated $Date: 2011-04-09 21:01:00 $. + + + diff --git a/libs/tiff-4.0.2/html/v4.0.1.html b/libs/tiff-4.0.2/html/v4.0.1.html new file mode 100644 index 0000000000..1f113c1956 --- /dev/null +++ b/libs/tiff-4.0.2/html/v4.0.1.html @@ -0,0 +1,113 @@ + + + + Changes in TIFF v4.0.1 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

      +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

      +

      +


      + + + +MAJOR CHANGES: + +
        + +
      • None + +
      + + +


      + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
        + +
      • --enable-ld-version-script: New configure option to + enable shared library symbol versioning on ELF-based systems + (e.g. Linux and FreeBSD) which use the GNU linker. This + allows multiple major versions of libtiff to be loaded + simultaneously into the same application or library without + conflict, as long as all libtiffs involved are built with + versioned symbols. This option is not enabled by default. + +
      • Added libtiff private dependency on -llzma for pkg-config. + +
      + +


      + + + +CHANGES IN LIBTIFF: + +
        +
      • libtiff/tif_dir.c, libtiff/tif_dirread.c: Extra caution around + assumption tag fetching is always successful. + +
      • libtiff/tif_jpeg.c: Extra caution for case where sp is NULL. + +
      + +


      + + + +CHANGES IN THE TOOLS: + +
        + +
      • None + +
      + +


      + + + +CHANGES IN THE CONTRIB AREA: + +
        + +
      • None + +
      + +Last updated $Date: 2012-02-18 21:53:27 $. + + + diff --git a/libs/tiff-4.0.2/html/v4.0.2.html b/libs/tiff-4.0.2/html/v4.0.2.html new file mode 100644 index 0000000000..78d2008731 --- /dev/null +++ b/libs/tiff-4.0.2/html/v4.0.2.html @@ -0,0 +1,118 @@ + + + + Changes in TIFF v4.0.2 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

      +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

      +

      +


      + + + +MAJOR CHANGES: + +
        + +
      • None + +
      + + +


      + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
        + +
      • None + +
      + +


      + + + +CHANGES IN LIBTIFF: + +
        + +
      • tif_getimage.c: added support for _SEPARATED CMYK images. + +
      • tif_getimage.c: Added support for greyscale + alpha. + +
      • Added TIFFCreateCustomDirectory() and TIFFCreateEXIFDirectory() functions. +
      • tif_print.c: Lots of fixes around printing corrupt or + hostile input. + +
      • Improve handling of corrupt ycbcrsubsampling values. + +
      • tif_unix.c: use strerror to get meaningful error messages. + +
      • tif_jpeg.c: fix serious bugs in JPEGDecodeRaw(). + +
      • tif_jpeg.c: Fix size overflow (zdi-can-1221,CVE-2012-1173). + +
      + +


      + + + +CHANGES IN THE TOOLS: + +
        + +
      • tiff2pdf: Defend against integer overflows while + calculating required buffer sizes (CVE-2012-2113). + +
      + +


      + + + +CHANGES IN THE CONTRIB AREA: + +
        + +
      • None + +
      + +Last updated $Date: 2012-06-16 00:19:37 $. + + + diff --git a/libs/tiff-4.0.2/libtiff-4.pc.in b/libs/tiff-4.0.2/libtiff-4.pc.in new file mode 100644 index 0000000000..abe75a62e2 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff-4.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libtiff +Description: Tag Image File Format (TIFF) library. +Version: @VERSION@ +Libs: -L${libdir} -ltiff +Libs.private: @tiff_libs_private@ +Cflags: -I${includedir} diff --git a/libs/tiff-3.8.2/libtiff/Makefile.am b/libs/tiff-4.0.2/libtiff/Makefile.am similarity index 76% rename from libs/tiff-3.8.2/libtiff/Makefile.am rename to libs/tiff-4.0.2/libtiff/Makefile.am index a8780c7cf6..82fa31dc8f 100644 --- a/libs/tiff-3.8.2/libtiff/Makefile.am +++ b/libs/tiff-4.0.2/libtiff/Makefile.am @@ -25,28 +25,39 @@ LIBPORT = $(top_builddir)/port/libport.la LIBTIFF = $(top_builddir)/libtiff/libtiff.la +libtiffincludedir = $(includedir) -EXTRA_DIST = Makefile.vc SConstruct tif_config.h.vc tiffconf.h.vc libtiff.def \ - $(EXTRA_SRCS) +EXTRA_DIST = Makefile.vc \ + SConstruct \ + tif_config.h-vms \ + tif_config.vc.h \ + tif_config.wince.h \ + tiffconf.vc.h \ + tiffconf.wince.h \ + libtiff.def \ + libtiff.map \ + libtiffxx.map -HDRS = \ +libtiffinclude_HEADERS = \ tiff.h \ - tiffconf.h \ tiffio.h \ tiffvers.h if HAVE_CXX -HDRS += tiffio.hxx +libtiffinclude_HEADERS += tiffio.hxx endif -EXTRA_HDRS = \ +noinst_HEADERS = \ t4.h \ tif_dir.h \ tif_predict.h \ tiffiop.h \ uvcode.h -SRCS = \ +nodist_libtiffinclude_HEADERS = \ + tiffconf.h + +libtiff_la_SOURCES = \ tif_aux.c \ tif_close.c \ tif_codec.c \ @@ -63,8 +74,11 @@ SRCS = \ tif_fax3sm.c \ tif_flush.c \ tif_getimage.c \ + tif_jbig.c \ tif_jpeg.c \ + tif_jpeg_12.c \ tif_luv.c \ + tif_lzma.c \ tif_lzw.c \ tif_next.c \ tif_ojpeg.c \ @@ -78,49 +92,47 @@ SRCS = \ tif_swab.c \ tif_thunder.c \ tif_tile.c \ - tif_unix.c \ tif_version.c \ tif_warning.c \ tif_write.c \ tif_zip.c -SRCSXX = \ +libtiffxx_la_SOURCES = \ tif_stream.cxx -EXTRA_SRCS = \ - tif_acorn.c \ - tif_apple.c \ - tif_atari.c \ - tif_msdos.c \ - tif_next.c \ - tif_win3.c \ - tif_win32.c - -libtiffincludedir = $(includedir) -libtiffinclude_HEADERS = $(HDRS) -noinst_HEADERS = $(EXTRA_HDRS) +if WIN32_IO +EXTRA_DIST += tif_unix.c +libtiff_la_SOURCES += tif_win32.c +else +EXTRA_DIST += tif_win32.c +libtiff_la_SOURCES += tif_unix.c +endif lib_LTLIBRARIES = libtiff.la if HAVE_CXX lib_LTLIBRARIES += libtiffxx.la endif -libtiff_la_SOURCES = $(SRCS) libtiff_la_LDFLAGS = \ -no-undefined \ - -version-number $(LIBTIFF_VERSION_INFO) + -version-info $(LIBTIFF_VERSION_INFO) if HAVE_RPATH libtiff_la_LDFLAGS += $(LIBDIR) endif +if HAVE_LD_VERSION_SCRIPT +libtiff_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiff.map +endif libtiff_la_LIBADD = $(LIBPORT) -libtiffxx_la_SOURCES = $(SRCSXX) libtiffxx_la_LDFLAGS = \ -no-undefined \ - -version-number $(LIBTIFF_VERSION_INFO) + -version-info $(LIBTIFF_VERSION_INFO) if HAVE_RPATH libtiffxx_la_LDFLAGS += $(LIBDIR) endif +if HAVE_LD_VERSION_SCRIPT +libtiffxx_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiffxx.map +endif libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) libtiffxx_la_DEPENDENCIES = libtiff.la diff --git a/libs/tiff-3.8.2/libtiff/Makefile.vc b/libs/tiff-4.0.2/libtiff/Makefile.vc similarity index 87% rename from libs/tiff-3.8.2/libtiff/Makefile.vc rename to libs/tiff-4.0.2/libtiff/Makefile.vc index e0b61f5309..42792ba130 100644 --- a/libs/tiff-3.8.2/libtiff/Makefile.vc +++ b/libs/tiff-4.0.2/libtiff/Makefile.vc @@ -1,4 +1,4 @@ -# $Id: Makefile.vc,v 1.15 2006/03/23 14:54:02 dron Exp $ +# $Id: Makefile.vc,v 1.22 2009-06-23 18:25:43 fwarmerdam Exp $ # # Copyright (C) 2004, Andrey Kiselev # @@ -29,7 +29,7 @@ !INCLUDE ..\nmake.opt -INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE) +INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE) $(JBIG_INCLUDE) !IFDEF USE_WIN_CRT_LIB OBJ_SYSDEP_MODULE = tif_unix.obj @@ -53,7 +53,9 @@ OBJ = \ tif_fax3.obj \ tif_fax3sm.obj \ tif_getimage.obj \ + tif_jbig.obj \ tif_jpeg.obj \ + tif_jpeg_12.obj \ tif_ojpeg.obj \ tif_flush.obj \ tif_luv.obj \ @@ -78,11 +80,11 @@ OBJ = \ all: libtiff.lib $(DLLNAME) -tif_config.h: tif_config.h.vc - copy tif_config.h.vc tif_config.h +tif_config.h: tif_config.vc.h + copy tif_config.vc.h tif_config.h -tiffconf.h: tiffconf.h.vc - copy tiffconf.h.vc tiffconf.h +tiffconf.h: tiffconf.vc.h + copy tiffconf.vc.h tiffconf.h libtiff.lib: tif_config.h tiffconf.h $(OBJ) $(AR) /out:libtiff.lib $(OBJ) $(LIBS) @@ -92,7 +94,9 @@ $(DLLNAME): tif_config.h tiffconf.h libtiff.def $(OBJ) /implib:libtiff_i.lib $(OBJ) $(LIBS) clean: + -del tif_config.h tiffconf.h -del *.obj -del *.lib -del *.dll - -del *.exe + -del *.dll.manifest + -del *.pdb diff --git a/libs/tiff-3.8.2/libtiff/SConstruct b/libs/tiff-4.0.2/libtiff/SConstruct similarity index 96% rename from libs/tiff-3.8.2/libtiff/SConstruct rename to libs/tiff-4.0.2/libtiff/SConstruct index 421ab24670..dc00c8cbc5 100644 --- a/libs/tiff-3.8.2/libtiff/SConstruct +++ b/libs/tiff-4.0.2/libtiff/SConstruct @@ -1,4 +1,4 @@ -# $Id: SConstruct,v 1.2 2006/03/23 14:54:02 dron Exp $ +# $Id: SConstruct,v 1.4 2007-02-24 15:03:50 dron Exp $ # Tag Image File Format (TIFF) Software # @@ -46,6 +46,7 @@ SRCS = [ \ 'tif_fax3sm.c', \ 'tif_flush.c', \ 'tif_getimage.c', \ + 'tif_jbig.c', \ 'tif_jpeg.c', \ 'tif_luv.c', \ 'tif_lzw.c', \ @@ -69,3 +70,4 @@ SRCS = [ \ StaticLibrary('tiff', SRCS) SharedLibrary('tiff', SRCS) + diff --git a/libs/tiff-3.8.2/libtiff/libtiff.def b/libs/tiff-4.0.2/libtiff/libtiff.def similarity index 90% rename from libs/tiff-3.8.2/libtiff/libtiff.def rename to libs/tiff-4.0.2/libtiff/libtiff.def index 3caefd8365..ce36cfdeba 100644 --- a/libs/tiff-3.8.2/libtiff/libtiff.def +++ b/libs/tiff-4.0.2/libtiff/libtiff.def @@ -12,12 +12,19 @@ EXPORTS TIFFOpen TIFFGetTagListEntry TIFFGetTagListCount TIFFReadDirectory + TIFFScanlineSize64 TIFFScanlineSize + TIFFStripSize64 TIFFStripSize + TIFFVStripSize64 TIFFVStripSize + TIFFRawStripSize64 TIFFRawStripSize + TIFFTileRowSize64 TIFFTileRowSize + TIFFTileSize64 TIFFTileSize + TIFFVTileSize64 TIFFVTileSize TIFFFileno TIFFSetFileno @@ -86,17 +93,20 @@ EXPORTS TIFFOpen TIFFWriteEncodedTile TIFFWriteRawTile TIFFSetWriteOffset + TIFFSwabFloat TIFFSwabDouble TIFFSwabShort TIFFSwabLong TIFFSwabArrayOfShort TIFFSwabArrayOfLong + TIFFSwabArrayOfFloat TIFFSwabArrayOfDouble TIFFSwabArrayOfTriples TIFFReverseBits TIFFGetBitRevTable TIFFDefaultStripSize TIFFDefaultTileSize + TIFFRasterScanlineSize64 TIFFRasterScanlineSize _TIFFmalloc _TIFFrealloc @@ -106,9 +116,6 @@ EXPORTS TIFFOpen _TIFFmemcmp TIFFCreateDirectory TIFFSetTagExtender - TIFFMergeFieldInfo - TIFFFindFieldInfo - TIFFFindFieldInfoByName TIFFFieldWithName TIFFFieldWithTag TIFFCurrentDirOffset @@ -137,4 +144,8 @@ EXPORTS TIFFOpen TIFFAccessTagMethods TIFFGetClientInfo TIFFSetClientInfo - TIFFReassignTagToIgnore + TIFFSwabLong8 + TIFFSwabArrayOfLong8 + TIFFFindField + TIFFUnsetField + TIFFMergeFieldInfo diff --git a/libs/tiff-3.8.2/libtiff/mkg3states.c b/libs/tiff-4.0.2/libtiff/mkg3states.c similarity index 97% rename from libs/tiff-3.8.2/libtiff/mkg3states.c rename to libs/tiff-4.0.2/libtiff/mkg3states.c index cb28720465..1df9ccc5f6 100644 --- a/libs/tiff-3.8.2/libtiff/mkg3states.c +++ b/libs/tiff-4.0.2/libtiff/mkg3states.c @@ -1,4 +1,4 @@ -/* "$Id: mkg3states.c,v 1.9 2004/10/10 11:46:16 dron Exp $ */ +/* "$Id: mkg3states.c,v 1.11 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -41,6 +41,10 @@ #include "tif_fax3.h" +#ifndef HAVE_GETOPT +extern int getopt(int, char**, char*); +#endif + #define streq(a,b) (strcmp(a,b) == 0) /* NB: can't use names in tif_fax3.h 'cuz they are declared const */ @@ -438,3 +442,10 @@ main(int argc, char* argv[]) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/t4.h b/libs/tiff-4.0.2/libtiff/t4.h similarity index 93% rename from libs/tiff-3.8.2/libtiff/t4.h rename to libs/tiff-4.0.2/libtiff/t4.h index 10bb17a5cb..b908f54f09 100644 --- a/libs/tiff-3.8.2/libtiff/t4.h +++ b/libs/tiff-4.0.2/libtiff/t4.h @@ -1,26 +1,26 @@ -/* $Id: t4.h,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */ +/* $Id: t4.h,v 1.3 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -33,18 +33,18 @@ * worthwhile to make code & length 8 bits. */ typedef struct tableentry { - unsigned short length; /* bit length of g3 code */ - unsigned short code; /* g3 code */ - short runlen; /* run length in bits */ + unsigned short length; /* bit length of g3 code */ + unsigned short code; /* g3 code */ + short runlen; /* run length in bits */ } tableentry; -#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ +#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ /* status values returned instead of a run length */ -#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ -#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ -#define G3CODE_EOF -3 /* end of input data */ -#define G3CODE_INCOMP -4 /* incomplete run code */ +#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ +#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ +#define G3CODE_EOF -3 /* end of input data */ +#define G3CODE_INCOMP -4 /* incomplete run code */ /* * Note that these tables are ordered such that the @@ -279,7 +279,14 @@ const tableentry TIFFFaxBlackCodes[] = { { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; #else -extern const tableentry TIFFFaxWhiteCodes[]; -extern const tableentry TIFFFaxBlackCodes[]; +extern const tableentry TIFFFaxWhiteCodes[]; +extern const tableentry TIFFFaxBlackCodes[]; #endif #endif /* _T4_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_aux.c b/libs/tiff-4.0.2/libtiff/tif_aux.c similarity index 67% rename from libs/tiff-3.8.2/libtiff/tif_aux.c rename to libs/tiff-4.0.2/libtiff/tif_aux.c index 9b0c5c2239..927150a493 100644 --- a/libs/tiff-3.8.2/libtiff/tif_aux.c +++ b/libs/tiff-4.0.2/libtiff/tif_aux.c @@ -1,4 +1,4 @@ -/* $Id: tif_aux.c,v 1.19 2006/02/07 10:41:30 dron Exp $ */ +/* $Id: tif_aux.c,v 1.26 2010-07-01 15:33:28 dron Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -33,35 +33,72 @@ #include "tif_predict.h" #include -tdata_t -_TIFFCheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what) +uint32 +_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) { - tdata_t cp = NULL; - tsize_t bytes = nmemb * elem_size; + uint32 bytes = first * second; + + if (second && bytes / second != first) { + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); + bytes = 0; + } + + return bytes; +} + +uint64 +_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where) +{ + uint64 bytes = first * second; + + if (second && bytes / second != first) { + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); + bytes = 0; + } + + return bytes; +} + +void* +_TIFFCheckRealloc(TIFF* tif, void* buffer, + tmsize_t nmemb, tmsize_t elem_size, const char* what) +{ + void* cp = NULL; + tmsize_t bytes = nmemb * elem_size; /* * XXX: Check for integer overflow. */ if (nmemb && elem_size && bytes / elem_size == nmemb) - cp = _TIFFmalloc(bytes); + cp = _TIFFrealloc(buffer, bytes); - if (cp == NULL) - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space %s", what); + if (cp == NULL) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Failed to allocate memory for %s " + "(%ld elements of %ld bytes each)", + what,(long) nmemb, (long) elem_size); + } - return (cp); + return cp; +} + +void* +_TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what) +{ + return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what); } static int TIFFDefaultTransferFunction(TIFFDirectory* td) { uint16 **tf = td->td_transferfunction; - tsize_t i, n, nbytes; + tmsize_t i, n, nbytes; tf[0] = tf[1] = tf[2] = 0; - if (td->td_bitspersample >= sizeof(tsize_t) * 8 - 2) + if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2) return 0; - n = 1<td_bitspersample; + n = ((tmsize_t)1)<td_bitspersample; nbytes = n * sizeof (uint16); if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes))) return 0; @@ -92,6 +129,35 @@ bad: return 0; } +static int +TIFFDefaultRefBlackWhite(TIFFDirectory* td) +{ + int i; + + if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float)))) + return 0; + if (td->td_photometric == PHOTOMETRIC_YCBCR) { + /* + * YCbCr (Class Y) images must have the ReferenceBlackWhite + * tag set. Fix the broken images, which lacks that tag. + */ + td->td_refblackwhite[0] = 0.0F; + td->td_refblackwhite[1] = td->td_refblackwhite[3] = + td->td_refblackwhite[5] = 255.0F; + td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F; + } else { + /* + * Assume RGB (Class R) + */ + for (i = 0; i < 3; i++) { + td->td_refblackwhite[2*i+0] = 0; + td->td_refblackwhite[2*i+1] = + (float)((1L<td_bitspersample)-1L); + } + } + return 1; +} + /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. @@ -101,7 +167,7 @@ bad: * place in the library -- in TIFFDefaultDirectory. */ int -TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) +TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) { TIFFDirectory *td = &tif->tif_dir; @@ -217,33 +283,10 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) } return (1); case TIFFTAG_REFERENCEBLACKWHITE: - { - int i; - static float ycbcr_refblackwhite[] = - { 0.0F, 255.0F, 128.0F, 255.0F, 128.0F, 255.0F }; - static float rgb_refblackwhite[6]; - - for (i = 0; i < 3; i++) { - rgb_refblackwhite[2 * i + 0] = 0.0F; - rgb_refblackwhite[2 * i + 1] = - (float)((1L<td_bitspersample)-1L); - } - - if (td->td_photometric == PHOTOMETRIC_YCBCR) { - /* - * YCbCr (Class Y) images must have the - * ReferenceBlackWhite tag set. Fix the - * broken images, which lacks that tag. - */ - *va_arg(ap, float **) = ycbcr_refblackwhite; - } else { - /* - * Assume RGB (Class R) - */ - *va_arg(ap, float **) = rgb_refblackwhite; - } - return 1; - } + if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td)) + return (0); + *va_arg(ap, float **) = td->td_refblackwhite; + return (1); } return 0; } @@ -253,7 +296,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) * value if the tag is not present in the directory. */ int -TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) +TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) { int ok; va_list ap; @@ -264,4 +307,52 @@ TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) return (ok); } +struct _Int64Parts { + int32 low, high; +}; + +typedef union { + struct _Int64Parts part; + int64 value; +} _Int64; + +float +_TIFFUInt64ToFloat(uint64 ui64) +{ + _Int64 i; + + i.value = ui64; + if (i.part.high >= 0) { + return (float)i.value; + } else { + long double df; + df = (long double)i.value; + df += 18446744073709551616.0; /* adding 2**64 */ + return (float)df; + } +} + +double +_TIFFUInt64ToDouble(uint64 ui64) +{ + _Int64 i; + + i.value = ui64; + if (i.part.high >= 0) { + return (double)i.value; + } else { + long double df; + df = (long double)i.value; + df += 18446744073709551616.0; /* adding 2**64 */ + return (double)df; + } +} + /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_close.c b/libs/tiff-4.0.2/libtiff/tif_close.c similarity index 67% rename from libs/tiff-3.8.2/libtiff/tif_close.c rename to libs/tiff-4.0.2/libtiff/tif_close.c index 52f53c0eb2..13d2bab5ce 100644 --- a/libs/tiff-3.8.2/libtiff/tif_close.c +++ b/libs/tiff-4.0.2/libtiff/tif_close.c @@ -1,4 +1,4 @@ -/* $Id: tif_close.c,v 1.9 2005/11/23 22:20:56 dron Exp $ */ +/* $Id: tif_close.c,v 1.19 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -28,6 +28,7 @@ * TIFF Library. */ #include "tiffiop.h" +#include /************************************************************************/ /* TIFFCleanup() */ @@ -45,51 +46,62 @@ void TIFFCleanup(TIFF* tif) { + /* + * Flush buffered data and directory (if dirty). + */ if (tif->tif_mode != O_RDONLY) - /* - * Flush buffered data and directory (if dirty). - */ - TIFFFlush(tif); + TIFFFlush(tif); (*tif->tif_cleanup)(tif); TIFFFreeDirectory(tif); if (tif->tif_dirlist) - _TIFFfree(tif->tif_dirlist); - - /* Clean up client info links */ + _TIFFfree(tif->tif_dirlist); + + /* + * Clean up client info links. + */ while( tif->tif_clientinfo ) { - TIFFClientInfoLink *link = tif->tif_clientinfo; + TIFFClientInfoLink *link = tif->tif_clientinfo; - tif->tif_clientinfo = link->next; - _TIFFfree( link->name ); - _TIFFfree( link ); + tif->tif_clientinfo = link->next; + _TIFFfree( link->name ); + _TIFFfree( link ); } if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) - _TIFFfree(tif->tif_rawdata); + _TIFFfree(tif->tif_rawdata); if (isMapped(tif)) - TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); + TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size); - /* Clean up custom fields */ - if (tif->tif_nfields > 0) - { - size_t i; + /* + * Clean up custom fields. + */ + if (tif->tif_fields && tif->tif_nfields > 0) { + uint32 i; - for (i = 0; i < tif->tif_nfields; i++) - { - TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; - if (fld->field_bit == FIELD_CUSTOM && - strncmp("Tag ", fld->field_name, 4) == 0) - { - _TIFFfree(fld->field_name); - _TIFFfree(fld); + for (i = 0; i < tif->tif_nfields; i++) { + TIFFField *fld = tif->tif_fields[i]; + if (fld->field_bit == FIELD_CUSTOM && + strncmp("Tag ", fld->field_name, 4) == 0) { + _TIFFfree(fld->field_name); + _TIFFfree(fld); + } } - } - - _TIFFfree(tif->tif_fieldinfo); + + _TIFFfree(tif->tif_fields); } + if (tif->tif_nfieldscompat > 0) { + uint32 i; + + for (i = 0; i < tif->tif_nfieldscompat; i++) { + if (tif->tif_fieldscompat[i].allocated_size) + _TIFFfree(tif->tif_fieldscompat[i].fields); + } + _TIFFfree(tif->tif_fieldscompat); + } + _TIFFfree(tif); } @@ -117,3 +129,12 @@ TIFFClose(TIFF* tif) (void) (*closeproc)(fd); } +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_codec.c b/libs/tiff-4.0.2/libtiff/tif_codec.c similarity index 69% rename from libs/tiff-3.8.2/libtiff/tif_codec.c rename to libs/tiff-4.0.2/libtiff/tif_codec.c index c31d10c732..e20166737a 100644 --- a/libs/tiff-3.8.2/libtiff/tif_codec.c +++ b/libs/tiff-4.0.2/libtiff/tif_codec.c @@ -1,4 +1,4 @@ -/* $Id: tif_codec.c,v 1.10 2005/12/21 12:23:13 joris Exp $ */ +/* $Id: tif_codec.c,v 1.15 2010-12-14 12:53:00 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -31,43 +31,46 @@ */ #include "tiffiop.h" -static int NotConfigured(TIFF*, int); +static int NotConfigured(TIFF*, int); -#ifndef LZW_SUPPORT -#define TIFFInitLZW NotConfigured +#ifndef LZW_SUPPORT +#define TIFFInitLZW NotConfigured #endif -#ifndef PACKBITS_SUPPORT -#define TIFFInitPackBits NotConfigured +#ifndef PACKBITS_SUPPORT +#define TIFFInitPackBits NotConfigured #endif -#ifndef THUNDER_SUPPORT -#define TIFFInitThunderScan NotConfigured +#ifndef THUNDER_SUPPORT +#define TIFFInitThunderScan NotConfigured #endif -#ifndef NEXT_SUPPORT -#define TIFFInitNeXT NotConfigured +#ifndef NEXT_SUPPORT +#define TIFFInitNeXT NotConfigured #endif -#ifndef JPEG_SUPPORT -#define TIFFInitJPEG NotConfigured +#ifndef JPEG_SUPPORT +#define TIFFInitJPEG NotConfigured #endif -#ifndef OJPEG_SUPPORT -#define TIFFInitOJPEG NotConfigured +#ifndef OJPEG_SUPPORT +#define TIFFInitOJPEG NotConfigured #endif -#ifndef CCITT_SUPPORT -#define TIFFInitCCITTRLE NotConfigured -#define TIFFInitCCITTRLEW NotConfigured -#define TIFFInitCCITTFax3 NotConfigured -#define TIFFInitCCITTFax4 NotConfigured +#ifndef CCITT_SUPPORT +#define TIFFInitCCITTRLE NotConfigured +#define TIFFInitCCITTRLEW NotConfigured +#define TIFFInitCCITTFax3 NotConfigured +#define TIFFInitCCITTFax4 NotConfigured #endif #ifndef JBIG_SUPPORT -#define TIFFInitJBIG NotConfigured +#define TIFFInitJBIG NotConfigured #endif -#ifndef ZIP_SUPPORT -#define TIFFInitZIP NotConfigured +#ifndef ZIP_SUPPORT +#define TIFFInitZIP NotConfigured #endif -#ifndef PIXARLOG_SUPPORT -#define TIFFInitPixarLog NotConfigured +#ifndef PIXARLOG_SUPPORT +#define TIFFInitPixarLog NotConfigured #endif #ifndef LOGLUV_SUPPORT -#define TIFFInitSGILog NotConfigured +#define TIFFInitSGILog NotConfigured +#endif +#ifndef LZMA_SUPPORT +#define TIFFInitLZMA NotConfigured #endif /* @@ -95,6 +98,7 @@ TIFFCodec _TIFFBuiltinCODECS[] = { { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, + { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, { NULL, 0, NULL } }; @@ -102,22 +106,26 @@ static int _notConfigured(TIFF* tif) { const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - + char compression_code[20]; + + sprintf( compression_code, "%d", tif->tif_dir.td_compression ); TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%s compression support is not configured", c->name); + "%s compression support is not configured", + c ? c->name : compression_code ); return (0); } static int NotConfigured(TIFF* tif, int scheme) { - (void) scheme; - - tif->tif_decodestatus = FALSE; - tif->tif_setupdecode = _notConfigured; - tif->tif_encodestatus = FALSE; - tif->tif_setupencode = _notConfigured; - return (1); + (void) scheme; + + tif->tif_fixuptags = _notConfigured; + tif->tif_decodestatus = FALSE; + tif->tif_setupdecode = _notConfigured; + tif->tif_encodestatus = FALSE; + tif->tif_setupencode = _notConfigured; + return (1); } /************************************************************************/ @@ -126,7 +134,7 @@ NotConfigured(TIFF* tif, int scheme) /** * Check whether we have working codec for the specific coding scheme. - * + * * @return returns 1 if the codec is configured and working. Otherwise * 0 will be returned. */ @@ -137,14 +145,21 @@ TIFFIsCODECConfigured(uint16 scheme) const TIFFCodec* codec = TIFFFindCODEC(scheme); if(codec == NULL) { - return 0; - } - if(codec->init == NULL) { - return 0; - } + return 0; + } + if(codec->init == NULL) { + return 0; + } if(codec->init != NotConfigured){ - return 1; - } + return 1; + } return 0; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_color.c b/libs/tiff-4.0.2/libtiff/tif_color.c similarity index 94% rename from libs/tiff-3.8.2/libtiff/tif_color.c rename to libs/tiff-4.0.2/libtiff/tif_color.c index 0f484aa7cc..be4850ce6b 100644 --- a/libs/tiff-3.8.2/libtiff/tif_color.c +++ b/libs/tiff-4.0.2/libtiff/tif_color.c @@ -1,4 +1,4 @@ -/* $Id: tif_color.c,v 1.12 2006/02/09 15:42:20 dron Exp $ */ +/* $Id: tif_color.c,v 1.19 2010-12-14 02:22:42 faxguy Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -123,7 +123,7 @@ TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, */ int TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, - TIFFDisplay *display, float *refWhite) + const TIFFDisplay *display, float *refWhite) { int i; double gamma; @@ -183,13 +183,18 @@ void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, uint32 *r, uint32 *g, uint32 *b) { + int32 i; + /* XXX: Only 8-bit YCbCr input supported for now */ Y = HICLAMP(Y, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255); - *r = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]]; - *g = ycbcr->clamptab[ycbcr->Y_tab[Y] - + (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT)]; - *b = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]]; + i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]; + *r = CLAMP(i, 0, 255); + i = ycbcr->Y_tab[Y] + + (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT); + *g = CLAMP(i, 0, 255); + i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]; + *b = CLAMP(i, 0, 255); } /* @@ -219,7 +224,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) #define LumaBlue luma[2] clamptab = (TIFFRGBValue*)( - (tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); + (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) @@ -273,3 +278,10 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) #undef FIX /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_compress.c b/libs/tiff-4.0.2/libtiff/tif_compress.c similarity index 73% rename from libs/tiff-3.8.2/libtiff/tif_compress.c rename to libs/tiff-4.0.2/libtiff/tif_compress.c index f7bb2a5aed..20e72fd073 100644 --- a/libs/tiff-3.8.2/libtiff/tif_compress.c +++ b/libs/tiff-4.0.2/libtiff/tif_compress.c @@ -1,4 +1,4 @@ -/* $Id: tif_compress.c,v 1.11 2005/12/21 12:23:13 joris Exp $ */ +/* $Id: tif_compress.c,v 1.22 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -36,33 +36,34 @@ TIFFNoEncode(TIFF* tif, const char* method) { const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - if (c) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%s %s encoding is not implemented", - c->name, method); - } else { + if (c) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s encoding is not implemented", - tif->tif_dir.td_compression, method); + "%s %s encoding is not implemented", + c->name, method); + } else { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Compression scheme %u %s encoding is not implemented", + tif->tif_dir.td_compression, method); } return (-1); } int -_TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "scanline")); } int -_TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "strip")); } int -_TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoTileEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "tile")); @@ -74,31 +75,39 @@ TIFFNoDecode(TIFF* tif, const char* method) const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); if (c) - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%s %s decoding is not implemented", - c->name, method); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%s %s decoding is not implemented", + c->name, method); else TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s decoding is not implemented", - tif->tif_dir.td_compression, method); + "Compression scheme %u %s decoding is not implemented", + tif->tif_dir.td_compression, method); return (-1); } int -_TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoFixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} + +int +_TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "scanline")); } int -_TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "strip")); } int -_TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoTileDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "tile")); @@ -109,12 +118,12 @@ _TIFFNoSeek(TIFF* tif, uint32 off) { (void) off; TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression algorithm does not support random access"); + "Compression algorithm does not support random access"); return (0); } int -_TIFFNoPreCode(TIFF* tif, tsample_t s) +_TIFFNoPreCode(TIFF* tif, uint16 s) { (void) tif; (void) s; return (1); @@ -126,25 +135,26 @@ static void _TIFFvoid(TIFF* tif) { (void) tif; } void _TIFFSetDefaultCompressionState(TIFF* tif) { + tif->tif_fixuptags = _TIFFNoFixupTags; tif->tif_decodestatus = TRUE; tif->tif_setupdecode = _TIFFtrue; tif->tif_predecode = _TIFFNoPreCode; - tif->tif_decoderow = _TIFFNoRowDecode; + tif->tif_decoderow = _TIFFNoRowDecode; tif->tif_decodestrip = _TIFFNoStripDecode; - tif->tif_decodetile = _TIFFNoTileDecode; + tif->tif_decodetile = _TIFFNoTileDecode; tif->tif_encodestatus = TRUE; tif->tif_setupencode = _TIFFtrue; tif->tif_preencode = _TIFFNoPreCode; tif->tif_postencode = _TIFFtrue; tif->tif_encoderow = _TIFFNoRowEncode; - tif->tif_encodestrip = _TIFFNoStripEncode; - tif->tif_encodetile = _TIFFNoTileEncode; + tif->tif_encodestrip = _TIFFNoStripEncode; + tif->tif_encodetile = _TIFFNoTileEncode; tif->tif_close = _TIFFvoid; tif->tif_seek = _TIFFNoSeek; tif->tif_cleanup = _TIFFvoid; tif->tif_defstripsize = _TIFFDefaultStripSize; tif->tif_deftilesize = _TIFFDefaultTileSize; - tif->tif_flags &= ~TIFF_NOBITREV; + tif->tif_flags &= ~(TIFF_NOBITREV|TIFF_NOREADRAW); } int @@ -168,10 +178,10 @@ TIFFSetCompressionScheme(TIFF* tif, int scheme) * by this library. */ typedef struct _codec { - struct _codec* next; - TIFFCodec* info; + struct _codec* next; + TIFFCodec* info; } codec_t; -static codec_t* registeredCODECS = NULL; +static codec_t* registeredCODECS = NULL; const TIFFCodec* TIFFFindCODEC(uint16 scheme) @@ -192,12 +202,12 @@ TIFFCodec* TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) { codec_t* cd = (codec_t*) - _TIFFmalloc(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1); + _TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1)); if (cd != NULL) { - cd->info = (TIFFCodec*) ((tidata_t) cd + sizeof (codec_t)); + cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t)); cd->info->name = (char*) - ((tidata_t) cd->info + sizeof (TIFFCodec)); + ((uint8*) cd->info + sizeof (TIFFCodec)); strcpy(cd->info->name, name); cd->info->scheme = scheme; cd->info->init = init; @@ -242,13 +252,14 @@ TIFFUnRegisterCODEC(TIFFCodec* c) TIFFCodec* TIFFGetConfiguredCODECs() { - int i = 1; - codec_t *cd; - const TIFFCodec *c; - TIFFCodec *codecs = NULL, *new_codecs; + int i = 1; + codec_t *cd; + const TIFFCodec* c; + TIFFCodec* codecs = NULL; + TIFFCodec* new_codecs; - for (cd = registeredCODECS; cd; cd = cd->next) { - new_codecs = (TIFFCodec *) + for (cd = registeredCODECS; cd; cd = cd->next) { + new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); if (!new_codecs) { _TIFFfree (codecs); @@ -258,16 +269,16 @@ TIFFGetConfiguredCODECs() _TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec)); i++; } - for (c = _TIFFBuiltinCODECS; c->name; c++) { - if (TIFFIsCODECConfigured(c->scheme)) { - new_codecs = (TIFFCodec *) + for (c = _TIFFBuiltinCODECS; c->name; c++) { + if (TIFFIsCODECConfigured(c->scheme)) { + new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); if (!new_codecs) { _TIFFfree (codecs); return NULL; } codecs = new_codecs; - _TIFFmemcpy(codecs + i - 1, (const tdata_t)c, sizeof(TIFFCodec)); + _TIFFmemcpy(codecs + i - 1, (const void*)c, sizeof(TIFFCodec)); i++; } } @@ -280,7 +291,14 @@ TIFFGetConfiguredCODECs() codecs = new_codecs; _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec)); - return codecs; + return codecs; } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_config.h.vc b/libs/tiff-4.0.2/libtiff/tif_config.h-vms similarity index 90% rename from libs/tiff-3.8.2/libtiff/tif_config.h.vc rename to libs/tiff-4.0.2/libtiff/tif_config.h-vms index 98e40fae8e..d653bd8270 100644 --- a/libs/tiff-3.8.2/libtiff/tif_config.h.vc +++ b/libs/tiff-4.0.2/libtiff/tif_config.h-vms @@ -8,17 +8,17 @@ machine */ #define HAVE_IEEEFP 1 -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_IO_H 1 +//#define HAVE_IO_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_SEARCH_H 1 +//#define HAVE_SEARCH_H 1 /* The size of a `int', as computed by sizeof. */ #define SIZEOF_INT 4 @@ -35,10 +35,12 @@ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ +/* #ifndef __cplusplus # ifndef inline # define inline __inline # endif #endif +*/ -#define lfind _lfind +// #define lfind _lfind diff --git a/libs/tiff-4.0.2/libtiff/tif_config.vc.h b/libs/tiff-4.0.2/libtiff/tif_config.vc.h new file mode 100644 index 0000000000..c297cf3c49 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_config.vc.h @@ -0,0 +1,71 @@ +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Define to 1 if you have the `jbg_newlen' function. */ +#define HAVE_JBG_NEWLEN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_IO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SEARCH_H 1 + +/* Define to 1 if you have the `setmode' function. */ +#define HAVE_SETMODE 1 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%I64d" + +/* Signed 64-bit type */ +#define TIFF_INT64_T signed __int64 + +/* Unsigned 64-bit type formatter */ +#define TIFF_UINT64_FORMAT "%I64u" + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned __int64 + +/* Set the native cpu bit order */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +#define snprintf _snprintf + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +# ifndef inline +# define inline __inline +# endif +#endif + +#define lfind _lfind +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_config.wince.h b/libs/tiff-4.0.2/libtiff/tif_config.wince.h new file mode 100644 index 0000000000..94e92bbf94 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_config.wince.h @@ -0,0 +1,71 @@ +/* $Id: tif_config.wince.h,v 1.3 2010-03-10 18:56:48 bfriesen Exp $ */ + +/* + * TIFF library configuration header for Windows CE platform. + */ +#ifndef _WIN32_WCE +# error This version of tif_config.h header is dedicated for Windows CE platform! +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Define to 1 if you have the `jbg_newlen' function. */ +#define HAVE_JBG_NEWLEN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#define HAVE_IO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SEARCH_H 1 + +/* Define to 1 if you have the `setmode' function. */ +#define HAVE_SETMODE 1 + +/* Define to 1 if you have the `bsearch' function. */ +#define HAVE_BSEARCH 1 +#define bsearch wceex_bsearch + +/* Define to 1 if you have the `lfind' function. */ +#define HAVE_LFIND 1 +#define lfind wceex_lfind + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* Set the native cpu bit order */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +# ifndef inline +# define inline __inline +# endif +#endif + + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_dir.c b/libs/tiff-4.0.2/libtiff/tif_dir.c new file mode 100644 index 0000000000..8bf3ea719f --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_dir.c @@ -0,0 +1,1659 @@ +/* $Id: tif_dir.c,v 1.113 2012-06-14 20:32:53 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Directory Tag Get & Set Routines. + * (and also some miscellaneous stuff) + */ +#include "tiffiop.h" + +/* + * These are used in the backwards compatibility code... + */ +#define DATATYPE_VOID 0 /* !untyped data */ +#define DATATYPE_INT 1 /* !signed integer data */ +#define DATATYPE_UINT 2 /* !unsigned integer data */ +#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ + +static void +setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size) +{ + if (*vpp) + _TIFFfree(*vpp), *vpp = 0; + if (vp) { + tmsize_t bytes = (tmsize_t)(nmemb * elem_size); + if (elem_size && bytes / elem_size == nmemb) + *vpp = (void*) _TIFFmalloc(bytes); + if (*vpp) + _TIFFmemcpy(*vpp, vp, bytes); + } +} +void _TIFFsetByteArray(void** vpp, void* vp, uint32 n) + { setByteArray(vpp, vp, n, 1); } +void _TIFFsetString(char** cpp, char* cp) + { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); } +void _TIFFsetNString(char** cpp, char* cp, uint32 n) + { setByteArray((void**) cpp, (void*) cp, n, 1); } +void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n) + { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); } +void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n) + { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); } +void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n) + { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); } +void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n) + { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); } +void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n) + { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); } + +static void +setDoubleArrayOneValue(double** vpp, double value, size_t nmemb) +{ + if (*vpp) + _TIFFfree(*vpp); + *vpp = _TIFFmalloc(nmemb*sizeof(double)); + if (*vpp) + { + while (nmemb--) + ((double*)*vpp)[nmemb] = value; + } +} + +/* + * Install extra samples information. + */ +static int +setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v) +{ +/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */ +#define EXTRASAMPLE_COREL_UNASSALPHA 999 + + uint16* va; + uint32 i; + + *v = (uint16) va_arg(ap, uint16_vap); + if ((uint16) *v > td->td_samplesperpixel) + return 0; + va = va_arg(ap, uint16*); + if (*v > 0 && va == NULL) /* typically missing param */ + return 0; + for (i = 0; i < *v; i++) { + if (va[i] > EXTRASAMPLE_UNASSALPHA) { + /* + * XXX: Corel Draw is known to produce incorrect + * ExtraSamples tags which must be patched here if we + * want to be able to open some of the damaged TIFF + * files: + */ + if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA) + va[i] = EXTRASAMPLE_UNASSALPHA; + else + return 0; + } + } + td->td_extrasamples = (uint16) *v; + _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); + return 1; + +#undef EXTRASAMPLE_COREL_UNASSALPHA +} + +/* + * Confirm we have "samplesperpixel" ink names separated by \0. Returns + * zero if the ink names are not as expected. + */ +static uint32 +checkInkNamesString(TIFF* tif, uint32 slen, const char* s) +{ + TIFFDirectory* td = &tif->tif_dir; + uint16 i = td->td_samplesperpixel; + + if (slen > 0) { + const char* ep = s+slen; + const char* cp = s; + for (; i > 0; i--) { + for (; cp < ep && *cp != '\0'; cp++) {} + if (cp >= ep) + goto bad; + cp++; /* skip \0 */ + } + return ((uint32)(cp-s)); + } +bad: + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", + "%s: Invalid InkNames value; expecting %d names, found %d", + tif->tif_name, + td->td_samplesperpixel, + td->td_samplesperpixel-i); + return (0); +} + +static int +_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + static const char module[] = "_TIFFVSetField"; + + TIFFDirectory* td = &tif->tif_dir; + int status = 1; + uint32 v32, i, v; + char* s; + const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); + uint32 standard_tag = tag; + + /* + * We want to force the custom code to be used for custom + * fields even if the tag happens to match a well known + * one - important for reinterpreted handling of standard + * tag values in custom directories (ie. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } + + switch (standard_tag) { + case TIFFTAG_SUBFILETYPE: + td->td_subfiletype = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_IMAGEWIDTH: + td->td_imagewidth = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_IMAGELENGTH: + td->td_imagelength = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_BITSPERSAMPLE: + td->td_bitspersample = (uint16) va_arg(ap, uint16_vap); + /* + * If the data require post-decoding processing to byte-swap + * samples, set it up here. Note that since tags are required + * to be ordered, compression code can override this behaviour + * in the setup method if it wants to roll the post decoding + * work in with its normal work. + */ + if (tif->tif_flags & TIFF_SWAB) { + if (td->td_bitspersample == 8) + tif->tif_postdecode = _TIFFNoPostDecode; + else if (td->td_bitspersample == 16) + tif->tif_postdecode = _TIFFSwab16BitData; + else if (td->td_bitspersample == 24) + tif->tif_postdecode = _TIFFSwab24BitData; + else if (td->td_bitspersample == 32) + tif->tif_postdecode = _TIFFSwab32BitData; + else if (td->td_bitspersample == 64) + tif->tif_postdecode = _TIFFSwab64BitData; + else if (td->td_bitspersample == 128) /* two 64's */ + tif->tif_postdecode = _TIFFSwab64BitData; + } + break; + case TIFFTAG_COMPRESSION: + v = (uint16) va_arg(ap, uint16_vap); + /* + * If we're changing the compression scheme, the notify the + * previous module so that it can cleanup any state it's + * setup. + */ + if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { + if ((uint32)td->td_compression == v) + break; + (*tif->tif_cleanup)(tif); + tif->tif_flags &= ~TIFF_CODERSETUP; + } + /* + * Setup new compression routine state. + */ + if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) + td->td_compression = (uint16) v; + else + status = 0; + break; + case TIFFTAG_PHOTOMETRIC: + td->td_photometric = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_THRESHHOLDING: + td->td_threshholding = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_FILLORDER: + v = (uint16) va_arg(ap, uint16_vap); + if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) + goto badvalue; + td->td_fillorder = (uint16) v; + break; + case TIFFTAG_ORIENTATION: + v = (uint16) va_arg(ap, uint16_vap); + if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) + goto badvalue; + else + td->td_orientation = (uint16) v; + break; + case TIFFTAG_SAMPLESPERPIXEL: + v = (uint16) va_arg(ap, uint16_vap); + if (v == 0) + goto badvalue; + td->td_samplesperpixel = (uint16) v; + break; + case TIFFTAG_ROWSPERSTRIP: + v32 = (uint32) va_arg(ap, uint32); + if (v32 == 0) + goto badvalue32; + td->td_rowsperstrip = v32; + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + td->td_tilelength = v32; + td->td_tilewidth = td->td_imagewidth; + } + break; + case TIFFTAG_MINSAMPLEVALUE: + td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_MAXSAMPLEVALUE: + td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_SMINSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + _TIFFsetDoubleArray(&td->td_sminsamplevalue, va_arg(ap, double*), td->td_samplesperpixel); + else + setDoubleArrayOneValue(&td->td_sminsamplevalue, va_arg(ap, double), td->td_samplesperpixel); + break; + case TIFFTAG_SMAXSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + _TIFFsetDoubleArray(&td->td_smaxsamplevalue, va_arg(ap, double*), td->td_samplesperpixel); + else + setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel); + break; + case TIFFTAG_XRESOLUTION: + td->td_xresolution = (float) va_arg(ap, double); + break; + case TIFFTAG_YRESOLUTION: + td->td_yresolution = (float) va_arg(ap, double); + break; + case TIFFTAG_PLANARCONFIG: + v = (uint16) va_arg(ap, uint16_vap); + if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) + goto badvalue; + td->td_planarconfig = (uint16) v; + break; + case TIFFTAG_XPOSITION: + td->td_xposition = (float) va_arg(ap, double); + break; + case TIFFTAG_YPOSITION: + td->td_yposition = (float) va_arg(ap, double); + break; + case TIFFTAG_RESOLUTIONUNIT: + v = (uint16) va_arg(ap, uint16_vap); + if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) + goto badvalue; + td->td_resolutionunit = (uint16) v; + break; + case TIFFTAG_PAGENUMBER: + td->td_pagenumber[0] = (uint16) va_arg(ap, uint16_vap); + td->td_pagenumber[1] = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_HALFTONEHINTS: + td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap); + td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_COLORMAP: + v32 = (uint32)(1L<td_bitspersample); + _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); + _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); + _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); + break; + case TIFFTAG_EXTRASAMPLES: + if (!setExtraSamples(td, ap, &v)) + goto badvalue; + break; + case TIFFTAG_MATTEING: + td->td_extrasamples = (((uint16) va_arg(ap, uint16_vap)) != 0); + if (td->td_extrasamples) { + uint16 sv = EXTRASAMPLE_ASSOCALPHA; + _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); + } + break; + case TIFFTAG_TILEWIDTH: + v32 = (uint32) va_arg(ap, uint32); + if (v32 % 16) { + if (tif->tif_mode != O_RDONLY) + goto badvalue32; + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "Nonstandard tile width %d, convert file", v32); + } + td->td_tilewidth = v32; + tif->tif_flags |= TIFF_ISTILED; + break; + case TIFFTAG_TILELENGTH: + v32 = (uint32) va_arg(ap, uint32); + if (v32 % 16) { + if (tif->tif_mode != O_RDONLY) + goto badvalue32; + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "Nonstandard tile length %d, convert file", v32); + } + td->td_tilelength = v32; + tif->tif_flags |= TIFF_ISTILED; + break; + case TIFFTAG_TILEDEPTH: + v32 = (uint32) va_arg(ap, uint32); + if (v32 == 0) + goto badvalue32; + td->td_tiledepth = v32; + break; + case TIFFTAG_DATATYPE: + v = (uint16) va_arg(ap, uint16_vap); + switch (v) { + case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; + case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; + case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; + case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; + default: goto badvalue; + } + td->td_sampleformat = (uint16) v; + break; + case TIFFTAG_SAMPLEFORMAT: + v = (uint16) va_arg(ap, uint16_vap); + if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) + goto badvalue; + td->td_sampleformat = (uint16) v; + + /* Try to fix up the SWAB function for complex data. */ + if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT + && td->td_bitspersample == 32 + && tif->tif_postdecode == _TIFFSwab32BitData ) + tif->tif_postdecode = _TIFFSwab16BitData; + else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT + || td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) + && td->td_bitspersample == 64 + && tif->tif_postdecode == _TIFFSwab64BitData ) + tif->tif_postdecode = _TIFFSwab32BitData; + break; + case TIFFTAG_IMAGEDEPTH: + td->td_imagedepth = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_SUBIFD: + if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { + td->td_nsubifd = (uint16) va_arg(ap, uint16_vap); + _TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*), + (long) td->td_nsubifd); + } else { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Sorry, cannot nest SubIFDs", + tif->tif_name); + status = 0; + } + break; + case TIFFTAG_YCBCRPOSITIONING: + td->td_ycbcrpositioning = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_YCBCRSUBSAMPLING: + td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, uint16_vap); + td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_TRANSFERFUNCTION: + v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; + for (i = 0; i < v; i++) + _TIFFsetShortArray(&td->td_transferfunction[i], + va_arg(ap, uint16*), 1L<td_bitspersample); + break; + case TIFFTAG_REFERENCEBLACKWHITE: + /* XXX should check for null range */ + _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); + break; + case TIFFTAG_INKNAMES: + v = (uint16) va_arg(ap, uint16_vap); + s = va_arg(ap, char*); + v = checkInkNamesString(tif, v, s); + status = v > 0; + if( v > 0 ) { + _TIFFsetNString(&td->td_inknames, s, v); + td->td_inknameslen = v; + } + break; + case TIFFTAG_PERSAMPLE: + v = (uint16) va_arg(ap, uint16_vap); + if( v == PERSAMPLE_MULTI ) + tif->tif_flags |= TIFF_PERSAMPLE; + else + tif->tif_flags &= ~TIFF_PERSAMPLE; + break; + default: { + TIFFTagValue *tv; + int tv_size, iCustom; + + /* + * This can happen if multiple images are open with different + * codecs which have private tags. The global tag information + * table may then have tags that are valid for one file but not + * the other. If the client tries to set a tag that is not valid + * for the image's codec then we'll arrive here. This + * happens, for example, when tiffcp is used to convert between + * compression schemes and codec-specific tags are blindly copied. + */ + if(fip == NULL || fip->field_bit != FIELD_CUSTOM) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Invalid %stag \"%s\" (not supported by codec)", + tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", + fip ? fip->field_name : "Unknown"); + status = 0; + break; + } + + /* + * Find the existing entry for this custom value. + */ + tv = NULL; + for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) { + if (td->td_customValues[iCustom].info->field_tag == tag) { + tv = td->td_customValues + iCustom; + if (tv->value != NULL) { + _TIFFfree(tv->value); + tv->value = NULL; + } + break; + } + } + + /* + * Grow the custom list if the entry was not found. + */ + if(tv == NULL) { + TIFFTagValue *new_customValues; + + td->td_customValueCount++; + new_customValues = (TIFFTagValue *) + _TIFFrealloc(td->td_customValues, + sizeof(TIFFTagValue) * td->td_customValueCount); + if (!new_customValues) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Failed to allocate space for list of custom values", + tif->tif_name); + status = 0; + goto end; + } + + td->td_customValues = new_customValues; + + tv = td->td_customValues + (td->td_customValueCount - 1); + tv->info = fip; + tv->value = NULL; + tv->count = 0; + } + + /* + * Set custom value ... save a copy of the custom tag value. + */ + tv_size = _TIFFDataSize(fip->field_type); + if (tv_size == 0) { + status = 0; + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad field type %d for \"%s\"", + tif->tif_name, fip->field_type, + fip->field_name); + goto end; + } + + if (fip->field_type == TIFF_ASCII) + { + uint32 ma; + char* mb; + if (fip->field_passcount) + { + assert(fip->field_writecount==TIFF_VARIABLE2); + ma=(uint32)va_arg(ap,uint32); + mb=(char*)va_arg(ap,char*); + } + else + { + mb=(char*)va_arg(ap,char*); + ma=(uint32)(strlen(mb)+1); + } + tv->count=ma; + setByteArray(&tv->value,mb,ma,1); + } + else + { + if (fip->field_passcount) { + if (fip->field_writecount == TIFF_VARIABLE2) + tv->count = (uint32) va_arg(ap, uint32); + else + tv->count = (int) va_arg(ap, int); + } else if (fip->field_writecount == TIFF_VARIABLE + || fip->field_writecount == TIFF_VARIABLE2) + tv->count = 1; + else if (fip->field_writecount == TIFF_SPP) + tv->count = td->td_samplesperpixel; + else + tv->count = fip->field_writecount; + + if (tv->count == 0) { + status = 0; + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Null count for \"%s\" (type " + "%d, writecount %d, passcount %d)", + tif->tif_name, + fip->field_name, + fip->field_type, + fip->field_writecount, + fip->field_passcount); + goto end; + } + + tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size, + "custom tag binary object"); + if (!tv->value) { + status = 0; + goto end; + } + + if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + handled this way ... likely best if we move it into + the directory structure with an explicit field in + libtiff 4.1 and assign it a FIELD_ value */ + uint16 v[2]; + v[0] = (uint16)va_arg(ap, int); + v[1] = (uint16)va_arg(ap, int); + _TIFFmemcpy(tv->value, &v, 4); + } + + else if (fip->field_passcount + || fip->field_writecount == TIFF_VARIABLE + || fip->field_writecount == TIFF_VARIABLE2 + || fip->field_writecount == TIFF_SPP + || tv->count > 1) { + _TIFFmemcpy(tv->value, va_arg(ap, void *), + tv->count * tv_size); + } else { + char *val = (char *)tv->value; + assert( tv->count == 1 ); + + switch (fip->field_type) { + case TIFF_BYTE: + case TIFF_UNDEFINED: + { + uint8 v = (uint8)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SBYTE: + { + int8 v = (int8)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SHORT: + { + uint16 v = (uint16)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SSHORT: + { + int16 v = (int16)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_LONG: + case TIFF_IFD: + { + uint32 v = va_arg(ap, uint32); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SLONG: + { + int32 v = va_arg(ap, int32); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_LONG8: + case TIFF_IFD8: + { + uint64 v = va_arg(ap, uint64); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SLONG8: + { + int64 v = va_arg(ap, int64); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + { + float v = (float)va_arg(ap, double); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_DOUBLE: + { + double v = va_arg(ap, double); + _TIFFmemcpy(val, &v, tv_size); + } + break; + default: + _TIFFmemset(val, 0, tv_size); + status = 0; + break; + } + } + } + } + } + if (status) { + const TIFFField* fip=TIFFFieldWithTag(tif,tag); + if (fip) + TIFFSetFieldBit(tif, fip->field_bit); + tif->tif_flags |= TIFF_DIRTYDIRECT; + } + +end: + va_end(ap); + return (status); +badvalue: + { + const TIFFField* fip=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad value %u for \"%s\" tag", + tif->tif_name, v, + fip ? fip->field_name : "Unknown"); + va_end(ap); + } + return (0); +badvalue32: + { + const TIFFField* fip=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad value %u for \"%s\" tag", + tif->tif_name, v32, + fip ? fip->field_name : "Unknown"); + va_end(ap); + } + return (0); +} + +/* + * Return 1/0 according to whether or not + * it is permissible to set the tag's value. + * Note that we allow ImageLength to be changed + * so that we can append and extend to images. + * Any other tag may not be altered once writing + * has commenced, unless its value has no effect + * on the format of the data that is written. + */ +static int +OkToChangeTag(TIFF* tif, uint32 tag) +{ + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + if (!fip) { /* unknown tag */ + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", + tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); + return (0); + } + if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && + !fip->field_oktochange) { + /* + * Consult info table to see if tag can be changed + * after we've started writing. We only allow changes + * to those tags that don't/shouldn't affect the + * compression and/or format of the data. + */ + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", + "%s: Cannot modify tag \"%s\" while writing", + tif->tif_name, fip->field_name); + return (0); + } + return (1); +} + +/* + * Record the value of a field in the + * internal directory structure. The + * field will be written to the file + * when/if the directory structure is + * updated. + */ +int +TIFFSetField(TIFF* tif, uint32 tag, ...) +{ + va_list ap; + int status; + + va_start(ap, tag); + status = TIFFVSetField(tif, tag, ap); + va_end(ap); + return (status); +} + +/* + * Clear the contents of the field in the internal structure. + */ +int +TIFFUnsetField(TIFF* tif, uint32 tag) +{ + const TIFFField *fip = TIFFFieldWithTag(tif, tag); + TIFFDirectory* td = &tif->tif_dir; + + if( !fip ) + return 0; + + if( fip->field_bit != FIELD_CUSTOM ) + TIFFClrFieldBit(tif, fip->field_bit); + else + { + TIFFTagValue *tv = NULL; + int i; + + for (i = 0; i < td->td_customValueCount; i++) { + + tv = td->td_customValues + i; + if( tv->info->field_tag == tag ) + break; + } + + if( i < td->td_customValueCount ) + { + _TIFFfree(tv->value); + for( ; i < td->td_customValueCount-1; i++) { + td->td_customValues[i] = td->td_customValues[i+1]; + } + td->td_customValueCount--; + } + } + + tif->tif_flags |= TIFF_DIRTYDIRECT; + + return (1); +} + +/* + * Like TIFFSetField, but taking a varargs + * parameter list. This routine is useful + * for building higher-level interfaces on + * top of the library. + */ +int +TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + return OkToChangeTag(tif, tag) ? + (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0; +} + +static int +_TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + TIFFDirectory* td = &tif->tif_dir; + int ret_val = 1; + uint32 standard_tag = tag; + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + + /* + * We want to force the custom code to be used for custom + * fields even if the tag happens to match a well known + * one - important for reinterpreted handling of standard + * tag values in custom directories (ie. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } + + switch (standard_tag) { + case TIFFTAG_SUBFILETYPE: + *va_arg(ap, uint32*) = td->td_subfiletype; + break; + case TIFFTAG_IMAGEWIDTH: + *va_arg(ap, uint32*) = td->td_imagewidth; + break; + case TIFFTAG_IMAGELENGTH: + *va_arg(ap, uint32*) = td->td_imagelength; + break; + case TIFFTAG_BITSPERSAMPLE: + *va_arg(ap, uint16*) = td->td_bitspersample; + break; + case TIFFTAG_COMPRESSION: + *va_arg(ap, uint16*) = td->td_compression; + break; + case TIFFTAG_PHOTOMETRIC: + *va_arg(ap, uint16*) = td->td_photometric; + break; + case TIFFTAG_THRESHHOLDING: + *va_arg(ap, uint16*) = td->td_threshholding; + break; + case TIFFTAG_FILLORDER: + *va_arg(ap, uint16*) = td->td_fillorder; + break; + case TIFFTAG_ORIENTATION: + *va_arg(ap, uint16*) = td->td_orientation; + break; + case TIFFTAG_SAMPLESPERPIXEL: + *va_arg(ap, uint16*) = td->td_samplesperpixel; + break; + case TIFFTAG_ROWSPERSTRIP: + *va_arg(ap, uint32*) = td->td_rowsperstrip; + break; + case TIFFTAG_MINSAMPLEVALUE: + *va_arg(ap, uint16*) = td->td_minsamplevalue; + break; + case TIFFTAG_MAXSAMPLEVALUE: + *va_arg(ap, uint16*) = td->td_maxsamplevalue; + break; + case TIFFTAG_SMINSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + *va_arg(ap, double**) = td->td_sminsamplevalue; + else + { + /* libtiff historially treats this as a single value. */ + uint16 i; + double v = td->td_sminsamplevalue[0]; + for (i=1; i < td->td_samplesperpixel; ++i) + if( td->td_sminsamplevalue[i] < v ) + v = td->td_sminsamplevalue[i]; + *va_arg(ap, double*) = v; + } + break; + case TIFFTAG_SMAXSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + *va_arg(ap, double**) = td->td_smaxsamplevalue; + else + { + /* libtiff historially treats this as a single value. */ + uint16 i; + double v = td->td_smaxsamplevalue[0]; + for (i=1; i < td->td_samplesperpixel; ++i) + if( td->td_smaxsamplevalue[i] > v ) + v = td->td_smaxsamplevalue[i]; + *va_arg(ap, double*) = v; + } + break; + case TIFFTAG_XRESOLUTION: + *va_arg(ap, float*) = td->td_xresolution; + break; + case TIFFTAG_YRESOLUTION: + *va_arg(ap, float*) = td->td_yresolution; + break; + case TIFFTAG_PLANARCONFIG: + *va_arg(ap, uint16*) = td->td_planarconfig; + break; + case TIFFTAG_XPOSITION: + *va_arg(ap, float*) = td->td_xposition; + break; + case TIFFTAG_YPOSITION: + *va_arg(ap, float*) = td->td_yposition; + break; + case TIFFTAG_RESOLUTIONUNIT: + *va_arg(ap, uint16*) = td->td_resolutionunit; + break; + case TIFFTAG_PAGENUMBER: + *va_arg(ap, uint16*) = td->td_pagenumber[0]; + *va_arg(ap, uint16*) = td->td_pagenumber[1]; + break; + case TIFFTAG_HALFTONEHINTS: + *va_arg(ap, uint16*) = td->td_halftonehints[0]; + *va_arg(ap, uint16*) = td->td_halftonehints[1]; + break; + case TIFFTAG_COLORMAP: + *va_arg(ap, uint16**) = td->td_colormap[0]; + *va_arg(ap, uint16**) = td->td_colormap[1]; + *va_arg(ap, uint16**) = td->td_colormap[2]; + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: + _TIFFFillStriles( tif ); + *va_arg(ap, uint64**) = td->td_stripoffset; + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: + _TIFFFillStriles( tif ); + *va_arg(ap, uint64**) = td->td_stripbytecount; + break; + case TIFFTAG_MATTEING: + *va_arg(ap, uint16*) = + (td->td_extrasamples == 1 && + td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); + break; + case TIFFTAG_EXTRASAMPLES: + *va_arg(ap, uint16*) = td->td_extrasamples; + *va_arg(ap, uint16**) = td->td_sampleinfo; + break; + case TIFFTAG_TILEWIDTH: + *va_arg(ap, uint32*) = td->td_tilewidth; + break; + case TIFFTAG_TILELENGTH: + *va_arg(ap, uint32*) = td->td_tilelength; + break; + case TIFFTAG_TILEDEPTH: + *va_arg(ap, uint32*) = td->td_tiledepth; + break; + case TIFFTAG_DATATYPE: + switch (td->td_sampleformat) { + case SAMPLEFORMAT_UINT: + *va_arg(ap, uint16*) = DATATYPE_UINT; + break; + case SAMPLEFORMAT_INT: + *va_arg(ap, uint16*) = DATATYPE_INT; + break; + case SAMPLEFORMAT_IEEEFP: + *va_arg(ap, uint16*) = DATATYPE_IEEEFP; + break; + case SAMPLEFORMAT_VOID: + *va_arg(ap, uint16*) = DATATYPE_VOID; + break; + } + break; + case TIFFTAG_SAMPLEFORMAT: + *va_arg(ap, uint16*) = td->td_sampleformat; + break; + case TIFFTAG_IMAGEDEPTH: + *va_arg(ap, uint32*) = td->td_imagedepth; + break; + case TIFFTAG_SUBIFD: + *va_arg(ap, uint16*) = td->td_nsubifd; + *va_arg(ap, uint64**) = td->td_subifd; + break; + case TIFFTAG_YCBCRPOSITIONING: + *va_arg(ap, uint16*) = td->td_ycbcrpositioning; + break; + case TIFFTAG_YCBCRSUBSAMPLING: + *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; + break; + case TIFFTAG_TRANSFERFUNCTION: + *va_arg(ap, uint16**) = td->td_transferfunction[0]; + if (td->td_samplesperpixel - td->td_extrasamples > 1) { + *va_arg(ap, uint16**) = td->td_transferfunction[1]; + *va_arg(ap, uint16**) = td->td_transferfunction[2]; + } + break; + case TIFFTAG_REFERENCEBLACKWHITE: + *va_arg(ap, float**) = td->td_refblackwhite; + break; + case TIFFTAG_INKNAMES: + *va_arg(ap, char**) = td->td_inknames; + break; + default: + { + int i; + + /* + * This can happen if multiple images are open + * with different codecs which have private + * tags. The global tag information table may + * then have tags that are valid for one file + * but not the other. If the client tries to + * get a tag that is not valid for the image's + * codec then we'll arrive here. + */ + if( fip == NULL || fip->field_bit != FIELD_CUSTOM ) + { + TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField", + "%s: Invalid %stag \"%s\" " + "(not supported by codec)", + tif->tif_name, + isPseudoTag(tag) ? "pseudo-" : "", + fip ? fip->field_name : "Unknown"); + ret_val = 0; + break; + } + + /* + * Do we have a custom value? + */ + ret_val = 0; + for (i = 0; i < td->td_customValueCount; i++) { + TIFFTagValue *tv = td->td_customValues + i; + + if (tv->info->field_tag != tag) + continue; + + if (fip->field_passcount) { + if (fip->field_readcount == TIFF_VARIABLE2) + *va_arg(ap, uint32*) = (uint32)tv->count; + else /* Assume TIFF_VARIABLE */ + *va_arg(ap, uint16*) = (uint16)tv->count; + *va_arg(ap, void **) = tv->value; + ret_val = 1; + } else if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + handled this way ... likely best if we move it into + the directory structure with an explicit field in + libtiff 4.1 and assign it a FIELD_ value */ + *va_arg(ap, uint16*) = ((uint16 *)tv->value)[0]; + *va_arg(ap, uint16*) = ((uint16 *)tv->value)[1]; + ret_val = 1; + } else { + if (fip->field_type == TIFF_ASCII + || fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2 + || fip->field_readcount == TIFF_SPP + || tv->count > 1) { + *va_arg(ap, void **) = tv->value; + ret_val = 1; + } else { + char *val = (char *)tv->value; + assert( tv->count == 1 ); + switch (fip->field_type) { + case TIFF_BYTE: + case TIFF_UNDEFINED: + *va_arg(ap, uint8*) = + *(uint8 *)val; + ret_val = 1; + break; + case TIFF_SBYTE: + *va_arg(ap, int8*) = + *(int8 *)val; + ret_val = 1; + break; + case TIFF_SHORT: + *va_arg(ap, uint16*) = + *(uint16 *)val; + ret_val = 1; + break; + case TIFF_SSHORT: + *va_arg(ap, int16*) = + *(int16 *)val; + ret_val = 1; + break; + case TIFF_LONG: + case TIFF_IFD: + *va_arg(ap, uint32*) = + *(uint32 *)val; + ret_val = 1; + break; + case TIFF_SLONG: + *va_arg(ap, int32*) = + *(int32 *)val; + ret_val = 1; + break; + case TIFF_LONG8: + case TIFF_IFD8: + *va_arg(ap, uint64*) = + *(uint64 *)val; + ret_val = 1; + break; + case TIFF_SLONG8: + *va_arg(ap, int64*) = + *(int64 *)val; + ret_val = 1; + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + *va_arg(ap, float*) = + *(float *)val; + ret_val = 1; + break; + case TIFF_DOUBLE: + *va_arg(ap, double*) = + *(double *)val; + ret_val = 1; + break; + default: + ret_val = 0; + break; + } + } + } + break; + } + } + } + return(ret_val); +} + +/* + * Return the value of a field in the + * internal directory structure. + */ +int +TIFFGetField(TIFF* tif, uint32 tag, ...) +{ + int status; + va_list ap; + + va_start(ap, tag); + status = TIFFVGetField(tif, tag, ap); + va_end(ap); + return (status); +} + +/* + * Like TIFFGetField, but taking a varargs + * parameter list. This routine is useful + * for building higher-level interfaces on + * top of the library. + */ +int +TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? + (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0); +} + +#define CleanupField(member) { \ + if (td->member) { \ + _TIFFfree(td->member); \ + td->member = 0; \ + } \ +} + +/* + * Release storage associated with a directory. + */ +void +TIFFFreeDirectory(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + int i; + + _TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS); + CleanupField(td_sminsamplevalue); + CleanupField(td_smaxsamplevalue); + CleanupField(td_colormap[0]); + CleanupField(td_colormap[1]); + CleanupField(td_colormap[2]); + CleanupField(td_sampleinfo); + CleanupField(td_subifd); + CleanupField(td_inknames); + CleanupField(td_refblackwhite); + CleanupField(td_transferfunction[0]); + CleanupField(td_transferfunction[1]); + CleanupField(td_transferfunction[2]); + CleanupField(td_stripoffset); + CleanupField(td_stripbytecount); + TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING); + TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING); + + /* Cleanup custom tag values */ + for( i = 0; i < td->td_customValueCount; i++ ) { + if (td->td_customValues[i].value) + _TIFFfree(td->td_customValues[i].value); + } + + td->td_customValueCount = 0; + CleanupField(td_customValues); + +#if defined(DEFER_STRILE_LOAD) + _TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry)); + _TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry)); +#endif +} +#undef CleanupField + +/* + * Client Tag extension support (from Niles Ritter). + */ +static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; + +TIFFExtendProc +TIFFSetTagExtender(TIFFExtendProc extender) +{ + TIFFExtendProc prev = _TIFFextender; + _TIFFextender = extender; + return (prev); +} + +/* + * Setup for a new directory. Should we automatically call + * TIFFWriteDirectory() if the current one is dirty? + * + * The newly created directory will not exist on the file till + * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called. + */ +int +TIFFCreateDirectory(TIFF* tif) +{ + TIFFDefaultDirectory(tif); + tif->tif_diroff = 0; + tif->tif_nextdiroff = 0; + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + + return 0; +} + +int +TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) +{ + TIFFDefaultDirectory(tif); + + /* + * Reset the field definitions to match the application provided list. + * Hopefully TIFFDefaultDirectory() won't have done anything irreversable + * based on it's assumption this is an image directory. + */ + _TIFFSetupFields(tif, infoarray); + + tif->tif_diroff = 0; + tif->tif_nextdiroff = 0; + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + + return 0; +} + +int +TIFFCreateEXIFDirectory(TIFF* tif) +{ + const TIFFFieldArray* exifFieldArray; + exifFieldArray = _TIFFGetExifFields(); + return TIFFCreateCustomDirectory(tif, exifFieldArray); +} + +/* + * Setup a default directory structure. + */ +int +TIFFDefaultDirectory(TIFF* tif) +{ + register TIFFDirectory* td = &tif->tif_dir; + const TIFFFieldArray* tiffFieldArray; + + tiffFieldArray = _TIFFGetFields(); + _TIFFSetupFields(tif, tiffFieldArray); + + _TIFFmemset(td, 0, sizeof (*td)); + td->td_fillorder = FILLORDER_MSB2LSB; + td->td_bitspersample = 1; + td->td_threshholding = THRESHHOLD_BILEVEL; + td->td_orientation = ORIENTATION_TOPLEFT; + td->td_samplesperpixel = 1; + td->td_rowsperstrip = (uint32) -1; + td->td_tilewidth = 0; + td->td_tilelength = 0; + td->td_tiledepth = 1; + td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ + td->td_resolutionunit = RESUNIT_INCH; + td->td_sampleformat = SAMPLEFORMAT_UINT; + td->td_imagedepth = 1; + td->td_ycbcrsubsampling[0] = 2; + td->td_ycbcrsubsampling[1] = 2; + td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; + tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_foundfield = NULL; + tif->tif_tagmethods.vsetfield = _TIFFVSetField; + tif->tif_tagmethods.vgetfield = _TIFFVGetField; + tif->tif_tagmethods.printdir = NULL; + /* + * Give client code a chance to install their own + * tag extensions & methods, prior to compression overloads. + */ + if (_TIFFextender) + (*_TIFFextender)(tif); + (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + /* + * NB: The directory is marked dirty as a result of setting + * up the default compression scheme. However, this really + * isn't correct -- we want TIFF_DIRTYDIRECT to be set only + * if the user does something. We could just do the setup + * by hand, but it seems better to use the normal mechanism + * (i.e. TIFFSetField). + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + + /* + * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 + * we clear the ISTILED flag when setting up a new directory. + * Should we also be clearing stuff like INSUBIFD? + */ + tif->tif_flags &= ~TIFF_ISTILED; + + return (1); +} + +static int +TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) +{ + static const char module[] = "TIFFAdvanceDirectory"; + if (isMapped(tif)) + { + uint64 poff=*nextdir; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + tmsize_t poffa,poffb,poffc,poffd; + uint16 dircount; + uint32 nextdir32; + poffa=(tmsize_t)poff; + poffb=poffa+sizeof(uint16); + if (((uint64)poffa!=poff)||(poffbtif->tif_size)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); + return(0); + } + _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort(&dircount); + poffc=poffb+dircount*12; + poffd=poffc+sizeof(uint32); + if ((poffctif->tif_size)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link"); + return(0); + } + if (off!=NULL) + *off=(uint64)poffc; + _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nextdir32); + *nextdir=nextdir32; + } + else + { + tmsize_t poffa,poffb,poffc,poffd; + uint64 dircount64; + uint16 dircount16; + poffa=(tmsize_t)poff; + poffb=poffa+sizeof(uint64); + if (((uint64)poffa!=poff)||(poffbtif->tif_size)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); + return(0); + } + _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed"); + return(0); + } + dircount16=(uint16)dircount64; + poffc=poffb+dircount16*20; + poffd=poffc+sizeof(uint64); + if ((poffctif->tif_size)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link"); + return(0); + } + if (off!=NULL) + *off=(uint64)poffc; + _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(nextdir); + } + return(1); + } + else + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint16 dircount; + uint32 nextdir32; + if (!SeekOK(tif, *nextdir) || + !ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + if (off != NULL) + *off = TIFFSeekFile(tif, + dircount*12, SEEK_CUR); + else + (void) TIFFSeekFile(tif, + dircount*12, SEEK_CUR); + if (!ReadOK(tif, &nextdir32, sizeof (uint32))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdir32); + *nextdir=nextdir32; + } + else + { + uint64 dircount64; + uint16 dircount16; + if (!SeekOK(tif, *nextdir) || + !ReadOK(tif, &dircount64, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); + return(0); + } + dircount16 = (uint16)dircount64; + if (off != NULL) + *off = TIFFSeekFile(tif, + dircount16*20, SEEK_CUR); + else + (void) TIFFSeekFile(tif, + dircount16*20, SEEK_CUR); + if (!ReadOK(tif, nextdir, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(nextdir); + } + return (1); + } +} + +/* + * Count the number of directories in a file. + */ +uint16 +TIFFNumberOfDirectories(TIFF* tif) +{ + uint64 nextdir; + uint16 n; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + nextdir = tif->tif_header.classic.tiff_diroff; + else + nextdir = tif->tif_header.big.tiff_diroff; + n = 0; + while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL)) + n++; + return (n); +} + +/* + * Set the n-th directory as the current directory. + * NB: Directories are numbered starting at 0. + */ +int +TIFFSetDirectory(TIFF* tif, uint16 dirn) +{ + uint64 nextdir; + uint16 n; + + if (!(tif->tif_flags&TIFF_BIGTIFF)) + nextdir = tif->tif_header.classic.tiff_diroff; + else + nextdir = tif->tif_header.big.tiff_diroff; + for (n = dirn; n > 0 && nextdir != 0; n--) + if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) + return (0); + tif->tif_nextdiroff = nextdir; + /* + * Set curdir to the actual directory index. The + * -1 is because TIFFReadDirectory will increment + * tif_curdir after successfully reading the directory. + */ + tif->tif_curdir = (dirn - n) - 1; + /* + * Reset tif_dirnumber counter and start new list of seen directories. + * We need this to prevent IFD loops. + */ + tif->tif_dirnumber = 0; + return (TIFFReadDirectory(tif)); +} + +/* + * Set the current directory to be the directory + * located at the specified file offset. This interface + * is used mainly to access directories linked with + * the SubIFD tag (e.g. thumbnail images). + */ +int +TIFFSetSubDirectory(TIFF* tif, uint64 diroff) +{ + tif->tif_nextdiroff = diroff; + /* + * Reset tif_dirnumber counter and start new list of seen directories. + * We need this to prevent IFD loops. + */ + tif->tif_dirnumber = 0; + return (TIFFReadDirectory(tif)); +} + +/* + * Return file offset of the current directory. + */ +uint64 +TIFFCurrentDirOffset(TIFF* tif) +{ + return (tif->tif_diroff); +} + +/* + * Return an indication of whether or not we are + * at the last directory in the file. + */ +int +TIFFLastDirectory(TIFF* tif) +{ + return (tif->tif_nextdiroff == 0); +} + +/* + * Unlink the specified directory from the directory chain. + */ +int +TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) +{ + static const char module[] = "TIFFUnlinkDirectory"; + uint64 nextdir; + uint64 off; + uint16 n; + + if (tif->tif_mode == O_RDONLY) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not unlink directory in read-only file"); + return (0); + } + /* + * Go to the directory before the one we want + * to unlink and nab the offset of the link + * field we'll need to patch. + */ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + nextdir = tif->tif_header.classic.tiff_diroff; + off = 4; + } + else + { + nextdir = tif->tif_header.big.tiff_diroff; + off = 8; + } + for (n = dirn-1; n > 0; n--) { + if (nextdir == 0) { + TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); + return (0); + } + if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) + return (0); + } + /* + * Advance to the directory to be unlinked and fetch + * the offset of the directory that follows. + */ + if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) + return (0); + /* + * Go back and patch the link field of the preceding + * directory to point to the offset of the directory + * that follows. + */ + (void) TIFFSeekFile(tif, off, SEEK_SET); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 nextdir32; + nextdir32=(uint32)nextdir; + assert((uint64)nextdir32==nextdir); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdir32); + if (!WriteOK(tif, &nextdir32, sizeof (uint32))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); + return (0); + } + } + else + { + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&nextdir); + if (!WriteOK(tif, &nextdir, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); + return (0); + } + } + /* + * Leave directory state setup safely. We don't have + * facilities for doing inserting and removing directories, + * so it's safest to just invalidate everything. This + * means that the caller can only append to the directory + * chain. + */ + (*tif->tif_cleanup)(tif); + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawcc = 0; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = 0; + } + tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE|TIFF_BUF4WRITE); + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + tif->tif_diroff = 0; /* force link on next write */ + tif->tif_nextdiroff = 0; /* next write must be at end */ + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + return (1); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_dir.h b/libs/tiff-4.0.2/libtiff/tif_dir.h new file mode 100644 index 0000000000..6af5f3dc37 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_dir.h @@ -0,0 +1,308 @@ +/* $Id: tif_dir.h,v 1.54 2011-02-18 20:53:05 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFDIR_ +#define _TIFFDIR_ +/* + * ``Library-private'' Directory-related Definitions. + */ + +typedef struct { + const TIFFField *info; + int count; + void *value; +} TIFFTagValue; + +/* + * TIFF Image File Directories are comprised of a table of field + * descriptors of the form shown below. The table is sorted in + * ascending order by tag. The values associated with each entry are + * disjoint and may appear anywhere in the file (so long as they are + * placed on a word boundary). + * + * If the value is 4 bytes or less, in ClassicTIFF, or 8 bytes or less in + * BigTIFF, then it is placed in the offset field to save space. If so, + * it is left-justified in the offset field. + */ +typedef struct { + uint16 tdir_tag; /* see below */ + uint16 tdir_type; /* data type; see below */ + uint64 tdir_count; /* number of items; length in spec */ + union { + uint16 toff_short; + uint32 toff_long; + uint64 toff_long8; + } tdir_offset; /* either offset or the data itself if fits */ +} TIFFDirEntry; + +/* + * Internal format of a TIFF directory entry. + */ +typedef struct { +#define FIELD_SETLONGS 4 + /* bit vector of fields that are set */ + unsigned long td_fieldsset[FIELD_SETLONGS]; + + uint32 td_imagewidth, td_imagelength, td_imagedepth; + uint32 td_tilewidth, td_tilelength, td_tiledepth; + uint32 td_subfiletype; + uint16 td_bitspersample; + uint16 td_sampleformat; + uint16 td_compression; + uint16 td_photometric; + uint16 td_threshholding; + uint16 td_fillorder; + uint16 td_orientation; + uint16 td_samplesperpixel; + uint32 td_rowsperstrip; + uint16 td_minsamplevalue, td_maxsamplevalue; + double* td_sminsamplevalue; + double* td_smaxsamplevalue; + float td_xresolution, td_yresolution; + uint16 td_resolutionunit; + uint16 td_planarconfig; + float td_xposition, td_yposition; + uint16 td_pagenumber[2]; + uint16* td_colormap[3]; + uint16 td_halftonehints[2]; + uint16 td_extrasamples; + uint16* td_sampleinfo; + /* even though the name is misleading, td_stripsperimage is the number + * of striles (=strips or tiles) per plane, and td_nstrips the total + * number of striles */ + uint32 td_stripsperimage; + uint32 td_nstrips; /* size of offset & bytecount arrays */ + uint64* td_stripoffset; + uint64* td_stripbytecount; + int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ +#if defined(DEFER_STRILE_LOAD) + TIFFDirEntry td_stripoffset_entry; /* for deferred loading */ + TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */ +#endif + uint16 td_nsubifd; + uint64* td_subifd; + /* YCbCr parameters */ + uint16 td_ycbcrsubsampling[2]; + uint16 td_ycbcrpositioning; + /* Colorimetry parameters */ + uint16* td_transferfunction[3]; + float* td_refblackwhite; + /* CMYK parameters */ + int td_inknameslen; + char* td_inknames; + + int td_customValueCount; + TIFFTagValue *td_customValues; +} TIFFDirectory; + +/* + * Field flags used to indicate fields that have been set in a directory, and + * to reference fields when manipulating a directory. + */ + +/* + * FIELD_IGNORE is used to signify tags that are to be processed but otherwise + * ignored. This permits antiquated tags to be quietly read and discarded. + * Note that a bit *is* allocated for ignored tags; this is understood by the + * directory reading logic which uses this fact to avoid special-case handling + */ +#define FIELD_IGNORE 0 + +/* multi-item fields */ +#define FIELD_IMAGEDIMENSIONS 1 +#define FIELD_TILEDIMENSIONS 2 +#define FIELD_RESOLUTION 3 +#define FIELD_POSITION 4 + +/* single-item fields */ +#define FIELD_SUBFILETYPE 5 +#define FIELD_BITSPERSAMPLE 6 +#define FIELD_COMPRESSION 7 +#define FIELD_PHOTOMETRIC 8 +#define FIELD_THRESHHOLDING 9 +#define FIELD_FILLORDER 10 +#define FIELD_ORIENTATION 15 +#define FIELD_SAMPLESPERPIXEL 16 +#define FIELD_ROWSPERSTRIP 17 +#define FIELD_MINSAMPLEVALUE 18 +#define FIELD_MAXSAMPLEVALUE 19 +#define FIELD_PLANARCONFIG 20 +#define FIELD_RESOLUTIONUNIT 22 +#define FIELD_PAGENUMBER 23 +#define FIELD_STRIPBYTECOUNTS 24 +#define FIELD_STRIPOFFSETS 25 +#define FIELD_COLORMAP 26 +#define FIELD_EXTRASAMPLES 31 +#define FIELD_SAMPLEFORMAT 32 +#define FIELD_SMINSAMPLEVALUE 33 +#define FIELD_SMAXSAMPLEVALUE 34 +#define FIELD_IMAGEDEPTH 35 +#define FIELD_TILEDEPTH 36 +#define FIELD_HALFTONEHINTS 37 +#define FIELD_YCBCRSUBSAMPLING 39 +#define FIELD_YCBCRPOSITIONING 40 +#define FIELD_REFBLACKWHITE 41 +#define FIELD_TRANSFERFUNCTION 44 +#define FIELD_INKNAMES 46 +#define FIELD_SUBIFD 49 +/* FIELD_CUSTOM (see tiffio.h) 65 */ +/* end of support for well-known tags; codec-private tags follow */ +#define FIELD_CODEC 66 /* base of codec-private tags */ + + +/* + * Pseudo-tags don't normally need field bits since they are not written to an + * output file (by definition). The library also has express logic to always + * query a codec for a pseudo-tag so allocating a field bit for one is a + * waste. If codec wants to promote the notion of a pseudo-tag being ``set'' + * or ``unset'' then it can do using internal state flags without polluting + * the field bit space defined for real tags. + */ +#define FIELD_PSEUDO 0 + +#define FIELD_LAST (32*FIELD_SETLONGS-1) + +#define BITn(n) (((unsigned long)1L)<<((n)&0x1f)) +#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) +#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) +#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) +#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) + +#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) +#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) + +typedef enum { + TIFF_SETGET_UNDEFINED = 0, + TIFF_SETGET_ASCII = 1, + TIFF_SETGET_UINT8 = 2, + TIFF_SETGET_SINT8 = 3, + TIFF_SETGET_UINT16 = 4, + TIFF_SETGET_SINT16 = 5, + TIFF_SETGET_UINT32 = 6, + TIFF_SETGET_SINT32 = 7, + TIFF_SETGET_UINT64 = 8, + TIFF_SETGET_SINT64 = 9, + TIFF_SETGET_FLOAT = 10, + TIFF_SETGET_DOUBLE = 11, + TIFF_SETGET_IFD8 = 12, + TIFF_SETGET_INT = 13, + TIFF_SETGET_UINT16_PAIR = 14, + TIFF_SETGET_C0_ASCII = 15, + TIFF_SETGET_C0_UINT8 = 16, + TIFF_SETGET_C0_SINT8 = 17, + TIFF_SETGET_C0_UINT16 = 18, + TIFF_SETGET_C0_SINT16 = 19, + TIFF_SETGET_C0_UINT32 = 20, + TIFF_SETGET_C0_SINT32 = 21, + TIFF_SETGET_C0_UINT64 = 22, + TIFF_SETGET_C0_SINT64 = 23, + TIFF_SETGET_C0_FLOAT = 24, + TIFF_SETGET_C0_DOUBLE = 25, + TIFF_SETGET_C0_IFD8 = 26, + TIFF_SETGET_C16_ASCII = 27, + TIFF_SETGET_C16_UINT8 = 28, + TIFF_SETGET_C16_SINT8 = 29, + TIFF_SETGET_C16_UINT16 = 30, + TIFF_SETGET_C16_SINT16 = 31, + TIFF_SETGET_C16_UINT32 = 32, + TIFF_SETGET_C16_SINT32 = 33, + TIFF_SETGET_C16_UINT64 = 34, + TIFF_SETGET_C16_SINT64 = 35, + TIFF_SETGET_C16_FLOAT = 36, + TIFF_SETGET_C16_DOUBLE = 37, + TIFF_SETGET_C16_IFD8 = 38, + TIFF_SETGET_C32_ASCII = 39, + TIFF_SETGET_C32_UINT8 = 40, + TIFF_SETGET_C32_SINT8 = 41, + TIFF_SETGET_C32_UINT16 = 42, + TIFF_SETGET_C32_SINT16 = 43, + TIFF_SETGET_C32_UINT32 = 44, + TIFF_SETGET_C32_SINT32 = 45, + TIFF_SETGET_C32_UINT64 = 46, + TIFF_SETGET_C32_SINT64 = 47, + TIFF_SETGET_C32_FLOAT = 48, + TIFF_SETGET_C32_DOUBLE = 49, + TIFF_SETGET_C32_IFD8 = 50, + TIFF_SETGET_OTHER = 51 +} TIFFSetGetFieldType; + +#if defined(__cplusplus) +extern "C" { +#endif + +extern const TIFFFieldArray* _TIFFGetFields(void); +extern const TIFFFieldArray* _TIFFGetExifFields(void); +extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray); +extern void _TIFFPrintFieldInfo(TIFF*, FILE*); + +extern int _TIFFFillStriles(TIFF*); + +typedef enum { + tfiatImage, + tfiatExif, + tfiatOther +} TIFFFieldArrayType; + +struct _TIFFFieldArray { + TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */ + uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */ + uint32 count; /* number of elements in fields array */ + TIFFField* fields; /* actual field info */ +}; + +struct _TIFFField { + uint32 field_tag; /* field's tag */ + short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ + short field_writecount; /* write count/TIFF_VARIABLE */ + TIFFDataType field_type; /* type of associated data */ + uint32 reserved; /* reserved for future extension */ + TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */ + TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */ + unsigned short field_bit; /* bit in fieldsset bit vector */ + unsigned char field_oktochange; /* if true, can change while writing */ + unsigned char field_passcount; /* if true, pass dir count on set */ + char* field_name; /* ASCII name */ + TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */ +}; + +extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32); +extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType); +extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType); + +#if defined(__cplusplus) +} +#endif +#endif /* _TIFFDIR_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_dirinfo.c b/libs/tiff-4.0.2/libtiff/tif_dirinfo.c new file mode 100644 index 0000000000..d4c441c8fa --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_dirinfo.c @@ -0,0 +1,921 @@ +/* $Id: tif_dirinfo.c,v 1.114 2011-05-17 00:21:17 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Core Directory Tag Support. + */ +#include "tiffiop.h" +#include + +/* + * NOTE: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. + * + * NOTE: The second field (field_readcount) and third field (field_writecount) + * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3) + * and TIFF_SPP (-2). The macros should be used but would throw off + * the formatting of the code, so please interprete the -1, -2 and -3 + * values accordingly. + */ + +static TIFFFieldArray tiffFieldArray; +static TIFFFieldArray exifFieldArray; + +static TIFFField +tiffFields[] = { + { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL }, + { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "OldSubfileType", NULL }, + { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL }, + { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL }, + { TIFFTAG_BITSPERSAMPLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL }, + { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL }, + { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL }, + { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL }, + { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellWidth", NULL }, + { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellLength", NULL }, + { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL }, + { TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL }, + { TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL }, + { TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL }, + { TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL }, + { TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL }, + { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL }, + { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL }, + { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL }, + { TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL }, + { TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL }, + { TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL }, + { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL }, + { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL }, + { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL }, + { TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL }, + { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL }, + { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL }, + { TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL }, + { TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL }, + { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL }, + { TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL }, + { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL }, + { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL }, + { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL }, + { TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL }, + { TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL }, + { TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL }, + { TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL }, + { TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL }, + { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL }, + { TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL }, + { TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL }, + { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL }, + { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL }, + { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL }, + { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL }, + { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL }, + { TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", &tiffFieldArray }, + { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL }, + { TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL }, + { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NumberOfInks", NULL }, + { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL }, + { TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL }, + { TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL }, + { TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL }, + { TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL }, + { TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL }, + { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL }, + { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, + { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, + { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL }, + { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL }, + { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL }, + { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL }, + { TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "XMLPacket", NULL }, + /* begin SGI tags */ + { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL }, + { TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL }, + { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL }, + { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL }, + /* end SGI tags */ + /* begin Pixar tags */ + { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL }, + { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL }, + { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL }, + { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL }, + { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL }, + { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL }, + { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL }, + { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL }, + /* end Pixar tags */ + { TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL }, + { TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Photoshop", NULL }, + { TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset", &exifFieldArray }, + { TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile", NULL }, + { TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GPSIFDOffset", NULL }, + { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL }, + { TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL }, + { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL }, + { TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL }, + { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL }, + { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL }, + /* begin DNG tags */ + { TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGVersion", NULL }, + { TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGBackwardVersion", NULL }, + { TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL }, + { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL }, + { TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CFAPlaneColor", NULL }, + { TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFALayout", NULL }, + { TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "LinearizationTable", NULL }, + { TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BlackLevelRepeatDim", NULL }, + { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevel", NULL }, + { TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaH", NULL }, + { TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaV", NULL }, + { TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "WhiteLevel", NULL }, + { TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultScale", NULL }, + { TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BestQualityScale", NULL }, + { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropOrigin", NULL }, + { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropSize", NULL }, + { TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix1", NULL }, + { TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix2", NULL }, + { TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration1", NULL }, + { TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration2", NULL }, + { TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix1", NULL }, + { TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix2", NULL }, + { TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AnalogBalance", NULL }, + { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotNeutral", NULL }, + { TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AsShotWhiteXY", NULL }, + { TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineExposure", NULL }, + { TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineNoise", NULL }, + { TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineSharpness", NULL }, + { TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BayerGreenSplit", NULL }, + { TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LinearResponseLimit", NULL }, + { TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL }, + { TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LensInfo", NULL }, + { TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ChromaBlurRadius", NULL }, + { TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AntiAliasStrength", NULL }, + { TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ShadowScale", NULL }, + { TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "DNGPrivateData", NULL }, + { TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "MakerNoteSafety", NULL }, + { TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant1", NULL }, + { TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant2", NULL }, + { TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "RawDataUniqueID", NULL }, + { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL }, + { TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "OriginalRawFileData", NULL }, + { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ActiveArea", NULL }, + { TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "MaskedAreas", NULL }, + { TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotICCProfile", NULL }, + { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL }, + { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL }, + { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix", NULL }, + /* end DNG tags */ + /* begin TIFF/FX tags */ + { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed" }, + { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL }, + { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL }, + { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL }, + { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL }, + { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL }, + { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL }, + { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL }, + { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL }, + { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL }, + { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL }, + { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL }, + /* end TIFF/FX tags */ + /* begin pseudo tags */ + { TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL}, +}; + +static TIFFField +exifFields[] = { + { EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL }, + { EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL }, + { EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL }, + { EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL }, + { EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL }, + { EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL }, + { EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL }, + { EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL }, + { EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL }, + { EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL }, + { EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL }, + { EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL }, + { EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL }, + { EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL }, + { EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL }, + { EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL }, + { EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL }, + { EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL }, + { EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL }, + { EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL }, + { EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL }, + { EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL }, + { EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL }, + { EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL }, + { EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL }, + { EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL }, + { EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL }, + { EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL }, + { EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL }, + { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL }, + { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL }, + { EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL }, + { EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL }, + { EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL }, + { EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL }, + { EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL }, + { EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL }, + { EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL }, + { EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL }, + { EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL }, + { EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL }, + { EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL }, + { EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL }, + { EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL }, + { EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL }, + { EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL }, + { EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL }, + { EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL }, + { EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL }, + { EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL }, + { EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL }, + { EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL }, + { EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL }, + { EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL }, + { EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL }, + { EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL } +}; + +static TIFFFieldArray +tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), tiffFields }; +static TIFFFieldArray +exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), exifFields }; + +/* + * We have our own local lfind() equivelent to avoid subtle differences + * in types passed to lfind() on different systems. + */ + +static void * +td_lfind(const void *key, const void *base, size_t *nmemb, size_t size, + int(*compar)(const void *, const void *)) +{ + char *element, *end; + + end = (char *)base + *nmemb * size; + for (element = (char *)base; element < end; element += size) + if (!compar(key, element)) /* key found */ + return element; + + return NULL; +} + +const TIFFFieldArray* +_TIFFGetFields(void) +{ + return(&tiffFieldArray); +} + +const TIFFFieldArray* +_TIFFGetExifFields(void) +{ + return(&exifFieldArray); +} + +void +_TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray) +{ + if (tif->tif_fields && tif->tif_nfields > 0) { + uint32 i; + + for (i = 0; i < tif->tif_nfields; i++) { + TIFFField *fld = tif->tif_fields[i]; + if (fld->field_bit == FIELD_CUSTOM && + strncmp("Tag ", fld->field_name, 4) == 0) { + _TIFFfree(fld->field_name); + _TIFFfree(fld); + } + } + + _TIFFfree(tif->tif_fields); + tif->tif_fields = NULL; + tif->tif_nfields = 0; + } + if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count)) { + TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFields", + "Setting up field info failed"); + } +} + +static int +tagCompare(const void* a, const void* b) +{ + const TIFFField* ta = *(const TIFFField**) a; + const TIFFField* tb = *(const TIFFField**) b; + /* NB: be careful of return values for 16-bit platforms */ + if (ta->field_tag != tb->field_tag) + return (int)ta->field_tag - (int)tb->field_tag; + else + return (ta->field_type == TIFF_ANY) ? + 0 : ((int)tb->field_type - (int)ta->field_type); +} + +static int +tagNameCompare(const void* a, const void* b) +{ + const TIFFField* ta = *(const TIFFField**) a; + const TIFFField* tb = *(const TIFFField**) b; + int ret = strcmp(ta->field_name, tb->field_name); + + if (ret) + return ret; + else + return (ta->field_type == TIFF_ANY) ? + 0 : ((int)tb->field_type - (int)ta->field_type); +} + +int +_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) +{ + static const char module[] = "_TIFFMergeFields"; + static const char reason[] = "for fields array"; + TIFFField** tp; + uint32 i; + + tif->tif_foundfield = NULL; + + if (tif->tif_fields && tif->tif_nfields > 0) { + tif->tif_fields = (TIFFField**) + _TIFFCheckRealloc(tif, tif->tif_fields, + (tif->tif_nfields + n), + sizeof(TIFFField *), reason); + } else { + tif->tif_fields = (TIFFField **) + _TIFFCheckMalloc(tif, n, sizeof(TIFFField *), + reason); + } + if (!tif->tif_fields) { + TIFFErrorExt(tif->tif_clientdata, module, + "Failed to allocate fields array"); + return 0; + } + + tp = tif->tif_fields + tif->tif_nfields; + for (i = 0; i < n; i++) { + const TIFFField *fip = + TIFFFindField(tif, info[i].field_tag, TIFF_ANY); + + /* only add definitions that aren't already present */ + if (!fip) { + tif->tif_fields[tif->tif_nfields] = (TIFFField *) (info+i); + tif->tif_nfields++; + } + } + + /* Sort the field info by tag number */ + qsort(tif->tif_fields, tif->tif_nfields, + sizeof(TIFFField *), tagCompare); + + return n; +} + +void +_TIFFPrintFieldInfo(TIFF* tif, FILE* fd) +{ + uint32 i; + + fprintf(fd, "%s: \n", tif->tif_name); + for (i = 0; i < tif->tif_nfields; i++) { + const TIFFField* fip = tif->tif_fields[i]; + fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" + , (int)i + , (unsigned long) fip->field_tag + , fip->field_readcount, fip->field_writecount + , fip->field_type + , fip->field_bit + , fip->field_oktochange ? "TRUE" : "FALSE" + , fip->field_passcount ? "TRUE" : "FALSE" + , fip->field_name + ); + } +} + +/* + * Return size of TIFFDataType in bytes + */ +int +TIFFDataWidth(TIFFDataType type) +{ + switch(type) + { + case 0: /* nothing */ + case TIFF_BYTE: + case TIFF_ASCII: + case TIFF_SBYTE: + case TIFF_UNDEFINED: + return 1; + case TIFF_SHORT: + case TIFF_SSHORT: + return 2; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + return 4; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_DOUBLE: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + return 8; + default: + return 0; /* will return 0 for unknown types */ + } +} + +/* + * Return size of TIFFDataType in bytes. + * + * XXX: We need a separate function to determine the space needed + * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8, + * but we use 4-byte float to represent rationals. + */ +int +_TIFFDataSize(TIFFDataType type) +{ + switch (type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_ASCII: + case TIFF_UNDEFINED: + return 1; + case TIFF_SHORT: + case TIFF_SSHORT: + return 2; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + return 4; + case TIFF_DOUBLE: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + return 8; + default: + return 0; + } +} + +const TIFFField* +TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt) +{ + TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; + TIFFField* pkey = &key; + const TIFFField **ret; + if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag && + (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) + return tif->tif_foundfield; + + /* If we are invoked with no field information, then just return. */ + if (!tif->tif_fields) + return NULL; + + /* NB: use sorted search (e.g. binary search) */ + + key.field_tag = tag; + key.field_type = dt; + + ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields, + tif->tif_nfields, + sizeof(TIFFField *), tagCompare); + return tif->tif_foundfield = (ret ? *ret : NULL); +} + +const TIFFField* +_TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt) +{ + TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; + TIFFField* pkey = &key; + const TIFFField **ret; + if (tif->tif_foundfield + && streq(tif->tif_foundfield->field_name, field_name) + && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) + return (tif->tif_foundfield); + + /* If we are invoked with no field information, then just return. */ + if (!tif->tif_fields) + return NULL; + + /* NB: use linear search since list is sorted by key#, not name */ + + key.field_name = (char *)field_name; + key.field_type = dt; + + ret = (const TIFFField **) + td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields, + sizeof(TIFFField *), tagNameCompare); + + return tif->tif_foundfield = (ret ? *ret : NULL); +} + +const TIFFField* +TIFFFieldWithTag(TIFF* tif, uint32 tag) +{ + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + if (!fip) { + TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag", + "Internal error, unknown tag 0x%x", + (unsigned int) tag); + } + return (fip); +} + +const TIFFField* +TIFFFieldWithName(TIFF* tif, const char *field_name) +{ + const TIFFField* fip = + _TIFFFindFieldByName(tif, field_name, TIFF_ANY); + if (!fip) { + TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName", + "Internal error, unknown tag %s", field_name); + } + return (fip); +} + +const TIFFField* +_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) + +{ + const TIFFField *fld; + + fld = TIFFFindField(tif, tag, dt); + if (fld == NULL) { + fld = _TIFFCreateAnonField(tif, tag, dt); + if (!_TIFFMergeFields(tif, fld, 1)) + return NULL; + } + + return fld; +} + +TIFFField* +_TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type) +{ + TIFFField *fld; + (void) tif; + + fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField)); + if (fld == NULL) + return NULL; + _TIFFmemset(fld, 0, sizeof(TIFFField)); + + fld->field_tag = tag; + fld->field_readcount = TIFF_VARIABLE2; + fld->field_writecount = TIFF_VARIABLE2; + fld->field_type = field_type; + fld->reserved = 0; + switch (field_type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + fld->set_field_type = TIFF_SETGET_C32_UINT8; + fld->get_field_type = TIFF_SETGET_C32_UINT8; + break; + case TIFF_ASCII: + fld->set_field_type = TIFF_SETGET_C32_ASCII; + fld->get_field_type = TIFF_SETGET_C32_ASCII; + break; + case TIFF_SHORT: + fld->set_field_type = TIFF_SETGET_C32_UINT16; + fld->get_field_type = TIFF_SETGET_C32_UINT16; + break; + case TIFF_LONG: + fld->set_field_type = TIFF_SETGET_C32_UINT32; + fld->get_field_type = TIFF_SETGET_C32_UINT32; + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + fld->set_field_type = TIFF_SETGET_C32_FLOAT; + fld->get_field_type = TIFF_SETGET_C32_FLOAT; + break; + case TIFF_SBYTE: + fld->set_field_type = TIFF_SETGET_C32_SINT8; + fld->get_field_type = TIFF_SETGET_C32_SINT8; + break; + case TIFF_SSHORT: + fld->set_field_type = TIFF_SETGET_C32_SINT16; + fld->get_field_type = TIFF_SETGET_C32_SINT16; + break; + case TIFF_SLONG: + fld->set_field_type = TIFF_SETGET_C32_SINT32; + fld->get_field_type = TIFF_SETGET_C32_SINT32; + break; + case TIFF_DOUBLE: + fld->set_field_type = TIFF_SETGET_C32_DOUBLE; + fld->get_field_type = TIFF_SETGET_C32_DOUBLE; + break; + case TIFF_IFD: + case TIFF_IFD8: + fld->set_field_type = TIFF_SETGET_C32_IFD8; + fld->get_field_type = TIFF_SETGET_C32_IFD8; + break; + case TIFF_LONG8: + fld->set_field_type = TIFF_SETGET_C32_UINT64; + fld->get_field_type = TIFF_SETGET_C32_UINT64; + break; + case TIFF_SLONG8: + fld->set_field_type = TIFF_SETGET_C32_SINT64; + fld->get_field_type = TIFF_SETGET_C32_SINT64; + break; + default: + fld->set_field_type = TIFF_SETGET_UNDEFINED; + fld->get_field_type = TIFF_SETGET_UNDEFINED; + break; + } + fld->field_bit = FIELD_CUSTOM; + fld->field_oktochange = TRUE; + fld->field_passcount = TRUE; + fld->field_name = (char *) _TIFFmalloc(32); + if (fld->field_name == NULL) { + _TIFFfree(fld); + return NULL; + } + fld->field_subfields = NULL; + + /* + * note that this name is a special sign to TIFFClose() and + * _TIFFSetupFields() to free the field + */ + sprintf(fld->field_name, "Tag %d", (int) tag); + + return fld; +} + +/**************************************************************************** + * O B S O L E T E D I N T E R F A C E S + * + * Don't use this stuff in your applications, it may be removed in the future + * libtiff versions. + ****************************************************************************/ + +static TIFFSetGetFieldType +_TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount) +{ + if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0) + return TIFF_SETGET_ASCII; + + else if (count == 1 && passcount == 0) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_UINT16; + case TIFF_LONG: + return TIFF_SETGET_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } + + else if (count >= 1 && passcount == 0) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_C0_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_C0_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_C0_UINT16; + case TIFF_LONG: + return TIFF_SETGET_C0_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_C0_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_C0_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_C0_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_C0_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_C0_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_C0_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_C0_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_C0_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } + + else if (count == TIFF_VARIABLE && passcount == 1) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_C16_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_C16_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_C16_UINT16; + case TIFF_LONG: + return TIFF_SETGET_C16_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_C16_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_C16_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_C16_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_C16_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_C16_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_C16_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_C16_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_C16_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } + + else if (count == TIFF_VARIABLE2 && passcount == 1) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_C32_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_C32_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_C32_UINT16; + case TIFF_LONG: + return TIFF_SETGET_C32_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_C32_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_C32_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_C32_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_C32_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_C32_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_C32_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_C32_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_C32_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } + + return TIFF_SETGET_UNDEFINED; +} + +int +TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) +{ + static const char module[] = "TIFFMergeFieldInfo"; + static const char reason[] = "for fields array"; + TIFFField *tp; + size_t nfields; + uint32 i; + + if (tif->tif_nfieldscompat > 0) { + tif->tif_fieldscompat = (TIFFFieldArray *) + _TIFFCheckRealloc(tif, tif->tif_fieldscompat, + tif->tif_nfieldscompat + 1, + sizeof(TIFFFieldArray), reason); + } else { + tif->tif_fieldscompat = (TIFFFieldArray *) + _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray), + reason); + } + if (!tif->tif_fieldscompat) { + TIFFErrorExt(tif->tif_clientdata, module, + "Failed to allocate fields array"); + return -1; + } + nfields = tif->tif_nfieldscompat++; + + tif->tif_fieldscompat[nfields].type = tfiatOther; + tif->tif_fieldscompat[nfields].allocated_size = n; + tif->tif_fieldscompat[nfields].count = n; + tif->tif_fieldscompat[nfields].fields = + (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), + reason); + if (!tif->tif_fieldscompat[nfields].fields) { + TIFFErrorExt(tif->tif_clientdata, module, + "Failed to allocate fields array"); + return -1; + } + + tp = tif->tif_fieldscompat[nfields].fields; + for (i = 0; i < n; i++) { + tp->field_tag = info[i].field_tag; + tp->field_readcount = info[i].field_readcount; + tp->field_writecount = info[i].field_writecount; + tp->field_type = info[i].field_type; + tp->reserved = 0; + tp->set_field_type = + _TIFFSetGetType(info[i].field_type, + info[i].field_readcount, + info[i].field_passcount); + tp->get_field_type = + _TIFFSetGetType(info[i].field_type, + info[i].field_readcount, + info[i].field_passcount); + tp->field_bit = info[i].field_bit; + tp->field_oktochange = info[i].field_oktochange; + tp->field_passcount = info[i].field_passcount; + tp->field_name = info[i].field_name; + tp->field_subfields = NULL; + tp++; + } + + if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Setting up field info failed"); + return -1; + } + + return 0; +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_dirread.c b/libs/tiff-4.0.2/libtiff/tif_dirread.c new file mode 100644 index 0000000000..c242d8fa54 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_dirread.c @@ -0,0 +1,5600 @@ +/* $Id: tif_dirread.c,v 1.174 2012-02-01 02:24:47 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Directory Read Support Routines. + */ + +/* Suggested pending improvements: + * - add a field 'ignore' to the TIFFDirEntry structure, to flag status, + * eliminating current use of the IGNORE value, and therefore eliminating + * current irrational behaviour on tags with tag id code 0 + * - add a field 'field_info' to the TIFFDirEntry structure, and set that with + * the pointer to the appropriate TIFFField structure early on in + * TIFFReadDirectory, so as to eliminate current possibly repetitive lookup. + */ + +#include "tiffiop.h" + +#define IGNORE 0 /* tag placeholder used below */ +#define FAILED_FII ((uint32) -1) + +#ifdef HAVE_IEEEFP +# define TIFFCvtIEEEFloatToNative(tif, n, fp) +# define TIFFCvtIEEEDoubleToNative(tif, n, dp) +#else +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); +#endif + +enum TIFFReadDirEntryErr { + TIFFReadDirEntryErrOk = 0, + TIFFReadDirEntryErrCount = 1, + TIFFReadDirEntryErrType = 2, + TIFFReadDirEntryErrIo = 3, + TIFFReadDirEntryErrRange = 4, + TIFFReadDirEntryErrPsdif = 5, + TIFFReadDirEntryErrSizesan = 6, + TIFFReadDirEntryErrAlloc = 7, +}; + +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* direntry, float* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); +#if 0 +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); +#endif + +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value); +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value); +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value); +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value); +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFDirEntry* direntry, double* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFFDirEntry* direntry, double* value); +static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, float* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest); +static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, const char* module, const char* tagname, int recover); + +static void TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount); +static TIFFDirEntry* TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid); +static void TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii); + +static int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount); +static void MissingRequired(TIFF*, const char*); +static int TIFFCheckDirOffset(TIFF* tif, uint64 diroff); +static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); +static uint16 TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, uint64* nextdiroff); +static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*, int recover); +static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp); +static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*); +static void ChopUpSingleUncompressedStrip(TIFF*); +static uint64 TIFFReadUInt64(const uint8 *value); + +typedef union _UInt64Aligned_t +{ + double d; + uint64 l; + uint32 i[2]; + uint16 s[4]; + uint8 c[8]; +} UInt64Aligned_t; + +/* + Unaligned safe copy of a uint64 value from an octet array. +*/ +static uint64 TIFFReadUInt64(const uint8 *value) +{ + UInt64Aligned_t result; + + result.c[0]=value[0]; + result.c[1]=value[1]; + result.c[2]=value[2]; + result.c[3]=value[3]; + result.c[4]=value[4]; + result.c[5]=value[5]; + result.c[6]=value[6]; + result.c[7]=value[7]; + + return result.l; +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + TIFFReadDirEntryCheckedByte(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteSbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteShort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteSshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteLong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteSlong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeByteLong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeByteSlong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortSbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + TIFFReadDirEntryCheckedShort(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortSshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortLong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortSlong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeShortLong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeShortSlong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLongSbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLongSshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + TIFFReadDirEntryCheckedLong(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLongSlong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeLongLong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeLongSlong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLong8Sbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLong8Sshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLong8Slong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + err=TIFFReadDirEntryCheckedLong8(tif,direntry,value); + return(err); + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeLong8Slong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* direntry, float* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); +#if defined(__WIN32__) && (_MSC_VER < 1500) + /* + * XXX: MSVC 6.0 does not support conversion + * of 64-bit integers into floating point + * values. + */ + *value = _TIFFUInt64ToFloat(m); +#else + *value=(float)m; +#endif + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_RATIONAL: + { + double m; + err=TIFFReadDirEntryCheckedRational(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SRATIONAL: + { + double m; + err=TIFFReadDirEntryCheckedSrational(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_FLOAT: + TIFFReadDirEntryCheckedFloat(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_DOUBLE: + { + double m; + err=TIFFReadDirEntryCheckedDouble(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); +#if defined(__WIN32__) && (_MSC_VER < 1500) + /* + * XXX: MSVC 6.0 does not support conversion + * of 64-bit integers into floating point + * values. + */ + *value = _TIFFUInt64ToDouble(m); +#else + *value = (double)m; +#endif + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_RATIONAL: + err=TIFFReadDirEntryCheckedRational(tif,direntry,value); + return(err); + case TIFF_SRATIONAL: + err=TIFFReadDirEntryCheckedSrational(tif,direntry,value); + return(err); + case TIFF_FLOAT: + { + float m; + TIFFReadDirEntryCheckedFloat(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_DOUBLE: + err=TIFFReadDirEntryCheckedDouble(tif,direntry,value); + return(err); + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +{ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_LONG: + case TIFF_IFD: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + case TIFF_IFD8: + err=TIFFReadDirEntryCheckedLong8(tif,direntry,value); + return(err); + default: + return(TIFFReadDirEntryErrType); + } +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value) +{ + int typesize; + uint32 datasize; + void* data; + typesize=TIFFDataWidth(direntry->tdir_type); + if ((direntry->tdir_count==0)||(typesize==0)) + { + *value=0; + return(TIFFReadDirEntryErrOk); + } + (void) desttypesize; + + /* + * As a sanity check, make sure we have no more than a 2GB tag array + * in either the current data type or the dest data type. This also + * avoids problems with overflow of tmsize_t on 32bit systems. + */ + if ((uint64)(2147483647/typesize)tdir_count) + return(TIFFReadDirEntryErrSizesan); + if ((uint64)(2147483647/desttypesize)tdir_count) + return(TIFFReadDirEntryErrSizesan); + + *count=(uint32)direntry->tdir_count; + datasize=(*count)*typesize; + assert((tmsize_t)datasize>0); + data=_TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray"); + if (data==0) + return(TIFFReadDirEntryErrAlloc); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (datasize<=4) + _TIFFmemcpy(data,&direntry->tdir_offset,datasize); + else + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + } + } + else + { + if (datasize<=8) + _TIFFmemcpy(data,&direntry->tdir_offset,datasize); + else + { + enum TIFFReadDirEntryErr err; + uint64 offset = direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&offset); + err=TIFFReadDirEntryData(tif,offset,(tmsize_t)datasize,data); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + } + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint8* data; + switch (direntry->tdir_type) + { + case TIFF_ASCII: + case TIFF_UNDEFINED: + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,1,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_ASCII: + case TIFF_UNDEFINED: + case TIFF_BYTE: + *value=(uint8*)origdata; + return(TIFFReadDirEntryErrOk); + case TIFF_SBYTE: + { + int8* m; + uint32 n; + m=(int8*)origdata; + for (n=0; ntdir_type) + { + case TIFF_SHORT: + { + uint16* ma; + uint8* mb; + uint32 n; + ma=(uint16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + err=TIFFReadDirEntryCheckRangeByteShort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + uint8* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeByteSshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + uint8* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeByteLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + uint8* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeByteSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + uint8* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeByteLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + uint8* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeByteSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int8* data; + switch (direntry->tdir_type) + { + case TIFF_UNDEFINED: + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,1,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_UNDEFINED: + case TIFF_BYTE: + { + uint8* m; + uint32 n; + m=(uint8*)origdata; + for (n=0; ntdir_type) + { + case TIFF_SHORT: + { + uint16* ma; + int8* mb; + uint32 n; + ma=(uint16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + err=TIFFReadDirEntryCheckRangeSbyteShort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + int8* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeSbyteSshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + int8* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeSbyteLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + int8* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeSbyteSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + int8* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeSbyteLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + int8* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeSbyteSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint16* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,2,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_SHORT: + *value=(uint16*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort(*value,count); + return(TIFFReadDirEntryErrOk); + case TIFF_SSHORT: + { + int16* m; + uint32 n; + m=(int16*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)m); + err=TIFFReadDirEntryCheckRangeShortSshort(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(uint16*)origdata; + return(TIFFReadDirEntryErrOk); + } + } + data=(uint16*)_TIFFmalloc(count*2); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + uint16* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeShortLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + uint16* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeShortSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + uint16* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeShortLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + uint16* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeShortSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int16* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,2,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_SHORT: + { + uint16* m; + uint32 n; + m=(uint16*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(m); + err=TIFFReadDirEntryCheckRangeSshortShort(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(int16*)origdata; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + *value=(int16*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort((uint16*)(*value),count); + return(TIFFReadDirEntryErrOk); + } + data=(int16*)_TIFFmalloc(count*2); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + int16* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeSshortLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + int16* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeSshortSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + int16* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeSshortLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + int16* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeSshortSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint32* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG: + *value=(uint32*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(*value,count); + return(TIFFReadDirEntryErrOk); + case TIFF_SLONG: + { + int32* m; + uint32 n; + m=(int32*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)m); + err=TIFFReadDirEntryCheckRangeLongSlong(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(uint32*)origdata; + return(TIFFReadDirEntryErrOk); + } + } + data=(uint32*)_TIFFmalloc(count*4); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + uint32* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(uint32)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + uint32* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeLongSshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint32)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + uint32* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeLongLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint32)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + uint32* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeLongSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint32)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int32* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG: + { + uint32* m; + uint32 n; + m=(uint32*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)m); + err=TIFFReadDirEntryCheckRangeSlongLong(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(int32*)origdata; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + *value=(int32*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)(*value),count); + return(TIFFReadDirEntryErrOk); + } + data=(int32*)_TIFFmalloc(count*4); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + int32* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(int32)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + int32* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(int32)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + int32* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeSlongLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int32)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + int32* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeSlongSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int32)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint64* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG8: + *value=(uint64*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(*value,count); + return(TIFFReadDirEntryErrOk); + case TIFF_SLONG8: + { + int64* m; + uint32 n; + m=(int64*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)m); + err=TIFFReadDirEntryCheckRangeLong8Slong8(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(uint64*)origdata; + return(TIFFReadDirEntryErrOk); + } + } + data=(uint64*)_TIFFmalloc(count*8); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + uint64* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(uint64)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + uint64* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeLong8Sshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint64)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + uint64* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(uint64)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + uint64* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeLong8Slong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint64)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int64* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG8: + { + uint64* m; + uint32 n; + m=(uint64*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(m); + err=TIFFReadDirEntryCheckRangeSlong8Long8(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(int64*)origdata; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + *value=(int64*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)(*value),count); + return(TIFFReadDirEntryErrOk); + } + data=(int64*)_TIFFmalloc(count*8); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + int64* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(int64)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + int64* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(int64)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + int64* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(int64)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + int64* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + *mb++=(int64)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value) +{ + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + float* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + case TIFF_DOUBLE: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_FLOAT: + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFCvtIEEEDoubleToNative(tif,count,(float*)origdata); + *value=(float*)origdata; + return(TIFFReadDirEntryErrOk); + } + data=(float*)_TIFFmalloc(count*sizeof(float)); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + float* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + float* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + float* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + float* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + float* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); +#if defined(__WIN32__) && (_MSC_VER < 1500) + /* + * XXX: MSVC 6.0 does not support + * conversion of 64-bit integers into + * floating point values. + */ + *mb++ = _TIFFUInt64ToFloat(*ma++); +#else + *mb++ = (float)(*ma++); +#endif + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + float* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_RATIONAL: + { + uint32* ma; + uint32 maa; + uint32 mab; + float* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(float)maa/(float)mab; + } + } + break; + case TIFF_SRATIONAL: + { + uint32* ma; + int32 maa; + uint32 mab; + float* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*(int32*)ma; + ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(float)maa/(float)mab; + } + } + break; + case TIFF_DOUBLE: + { + double* ma; + float* mb; + uint32 n; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); + ma=(double*)origdata; + mb=data; + for (n=0; ntdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + case TIFF_DOUBLE: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_DOUBLE: + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); + *value=(double*)origdata; + return(TIFFReadDirEntryErrOk); + } + data=(double*)_TIFFmalloc(count*sizeof(double)); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + double* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + double* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + double* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + double* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + double* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); +#if defined(__WIN32__) && (_MSC_VER < 1500) + /* + * XXX: MSVC 6.0 does not support + * conversion of 64-bit integers into + * floating point values. + */ + *mb++ = _TIFFUInt64ToDouble(*ma++); +#else + *mb++ = (double)(*ma++); +#endif + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + double* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_RATIONAL: + { + uint32* ma; + uint32 maa; + uint32 mab; + double* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(double)maa/(double)mab; + } + } + break; + case TIFF_SRATIONAL: + { + uint32* ma; + int32 maa; + uint32 mab; + double* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*(int32*)ma; + ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(double)maa/(double)mab; + } + } + break; + case TIFF_FLOAT: + { + float* ma; + double* mb; + uint32 n; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFCvtIEEEFloatToNative(tif,count,(float*)origdata); + ma=(float*)origdata; + mb=data; + for (n=0; ntdir_type) + { + case TIFF_LONG: + case TIFF_LONG8: + case TIFF_IFD: + case TIFF_IFD8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG8: + case TIFF_IFD8: + *value=(uint64*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(*value,count); + return(TIFFReadDirEntryErrOk); + } + data=(uint64*)_TIFFmalloc(count*8); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_LONG: + case TIFF_IFD: + { + uint32* ma; + uint64* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(uint64)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +{ + enum TIFFReadDirEntryErr err; + uint16* m; + uint16* na; + uint16 nb; + if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + return(TIFFReadDirEntryErrCount); + err=TIFFReadDirEntryShortArray(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + na=m; + nb=tif->tif_dir.td_samplesperpixel; + *value=*na++; + nb--; + while (nb>0) + { + if (*na++!=*value) + { + err=TIFFReadDirEntryErrPsdif; + break; + } + nb--; + } + _TIFFfree(m); + return(err); +} + +#if 0 +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + enum TIFFReadDirEntryErr err; + double* m; + double* na; + uint16 nb; + if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + return(TIFFReadDirEntryErrCount); + err=TIFFReadDirEntryDoubleArray(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + na=m; + nb=tif->tif_dir.td_samplesperpixel; + *value=*na++; + nb--; + while (nb>0) + { + if (*na++!=*value) + { + err=TIFFReadDirEntryErrPsdif; + break; + } + nb--; + } + _TIFFfree(m); + return(err); +} +#endif + +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) +{ + (void) tif; + *value=*(uint8*)(&direntry->tdir_offset); +} + +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value) +{ + (void) tif; + *value=*(int8*)(&direntry->tdir_offset); +} + +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +{ + *value = direntry->tdir_offset.toff_short; + /* *value=*(uint16*)(&direntry->tdir_offset); */ + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort(value); +} + +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value) +{ + *value=*(int16*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)value); +} + +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +{ + *value=*(uint32*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(value); +} + +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value) +{ + *value=*(int32*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)value); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +{ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,value); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + *value = direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(value); + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value) +{ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,value); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + *value=*(int64*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)value); + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + UInt64Aligned_t m; + + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(uint32)==4); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,m.i); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + m.l = direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m.i,2); + if (m.i[0]==0) + *value=0.0; + else + *value=(double)m.i[0]/(double)m.i[1]; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + UInt64Aligned_t m; + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(int32)==4); + assert(sizeof(uint32)==4); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,m.i); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + m.l=direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m.i,2); + if ((int32)m.i[0]==0) + *value=0.0; + else + *value=(double)((int32)m.i[0])/(double)m.i[1]; + return(TIFFReadDirEntryErrOk); +} + +static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, float* value) +{ + union + { + float f; + uint32 i; + } float_union; + assert(sizeof(float)==4); + assert(sizeof(uint32)==4); + assert(sizeof(float_union)==4); + float_union.i=*(uint32*)(&direntry->tdir_offset); + *value=float_union.f; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)value); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(UInt64Aligned_t)==8); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,value); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + { + UInt64Aligned_t uint64_union; + uint64_union.l=direntry->tdir_offset.toff_long8; + *value=uint64_union.d; + } + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)value); + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value) +{ + if (value>0xFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value) +{ + if ((value<0)||(value>0xFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value) +{ + if (value>0xFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value) +{ + if ((value<0)||(value>0xFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value) +{ + if (value>0xFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value) +{ + if ((value<0)||(value>0xFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value) +{ + if ((value<-0x80)||(value>0x7F)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value) +{ + if ((value<-0x80)||(value>0x7F)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value) +{ + if ((value<-0x80)||(value>0x7F)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value) +{ + if (value>0xFFFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value) +{ + if ((value<0)||(value>0xFFFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value) +{ + if (value>0xFFFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value) +{ + if ((value<0)||(value>0xFFFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value) +{ + if (value>0x7FFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value) +{ + if (value>0x7FFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value) +{ + if ((value<-0x8000)||(value>0x7FFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value) +{ + if (value>0x7FFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value) +{ + if ((value<-0x8000)||(value>0x7FFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +/* + * Largest 32-bit unsigned integer value. + */ +#if defined(__WIN32__) && defined(_MSC_VER) +# define TIFF_UINT32_MAX 0xFFFFFFFFI64 +#else +# define TIFF_UINT32_MAX 0xFFFFFFFFLL +#endif + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeLongLong8(uint64 value) +{ + if (value > TIFF_UINT32_MAX) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeLongSlong8(int64 value) +{ + if ((value<0) || (value > TIFF_UINT32_MAX)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +#undef TIFF_UINT32_MAX + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeSlongLong(uint32 value) +{ + if (value > 0x7FFFFFFFUL) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeSlongLong8(uint64 value) +{ + if (value > 0x7FFFFFFFUL) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeSlongSlong8(int64 value) +{ + if ((value < 0L-0x80000000L) || (value > 0x7FFFFFFFL)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value) +{ + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeLong8Sshort(int16 value) +{ + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeLong8Slong(int32 value) +{ + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeLong8Slong8(int64 value) +{ + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +/* + * Largest 64-bit signed integer value. + */ +#if defined(__WIN32__) && defined(_MSC_VER) +# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFI64 +#else +# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFLL +#endif + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value) +{ + if (value > TIFF_INT64_MAX) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +#undef TIFF_INT64_MAX + +static enum TIFFReadDirEntryErr +TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) +{ + assert(size>0); + if (!isMapped(tif)) { + if (!SeekOK(tif,offset)) + return(TIFFReadDirEntryErrIo); + if (!ReadOK(tif,dest,size)) + return(TIFFReadDirEntryErrIo); + } else { + tmsize_t ma,mb; + ma=(tmsize_t)offset; + mb=ma+size; + if (((uint64)ma!=offset)||(mbtif->tif_size)) + return(TIFFReadDirEntryErrIo); + _TIFFmemcpy(dest,tif->tif_base+ma,size); + } + return(TIFFReadDirEntryErrOk); +} + +static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, const char* module, const char* tagname, int recover) +{ + if (!recover) { + switch (err) { + case TIFFReadDirEntryErrCount: + TIFFErrorExt(tif->tif_clientdata, module, + "Incorrect count for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrType: + TIFFErrorExt(tif->tif_clientdata, module, + "Incompatible type for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrIo: + TIFFErrorExt(tif->tif_clientdata, module, + "IO error during reading of \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrRange: + TIFFErrorExt(tif->tif_clientdata, module, + "Incorrect value for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrPsdif: + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle different values per sample for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrSizesan: + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on size of \"%s\" value failed", + tagname); + break; + case TIFFReadDirEntryErrAlloc: + TIFFErrorExt(tif->tif_clientdata, module, + "Out of memory reading of \"%s\"", + tagname); + break; + default: + assert(0); /* we should never get here */ + break; + } + } else { + switch (err) { + case TIFFReadDirEntryErrCount: + TIFFErrorExt(tif->tif_clientdata, module, + "Incorrect count for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrType: + TIFFWarningExt(tif->tif_clientdata, module, + "Incompatible type for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrIo: + TIFFWarningExt(tif->tif_clientdata, module, + "IO error during reading of \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrRange: + TIFFWarningExt(tif->tif_clientdata, module, + "Incorrect value for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrPsdif: + TIFFWarningExt(tif->tif_clientdata, module, + "Cannot handle different values per sample for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrSizesan: + TIFFWarningExt(tif->tif_clientdata, module, + "Sanity check on size of \"%s\" value failed; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrAlloc: + TIFFWarningExt(tif->tif_clientdata, module, + "Out of memory reading of \"%s\"; tag ignored", + tagname); + break; + default: + assert(0); /* we should never get here */ + break; + } + } +} + +/* + * Read the next TIFF directory from a file and convert it to the internal + * format. We read directories sequentially. + */ +int +TIFFReadDirectory(TIFF* tif) +{ + static const char module[] = "TIFFReadDirectory"; + TIFFDirEntry* dir; + uint16 dircount; + TIFFDirEntry* dp; + uint16 di; + const TIFFField* fip; + uint32 fii=FAILED_FII; + toff_t nextdiroff; + tif->tif_diroff=tif->tif_nextdiroff; + if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff)) + return 0; /* last offset or bad offset (IFD looping) */ + (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ + tif->tif_curdir++; + nextdiroff = tif->tif_nextdiroff; + dircount=TIFFFetchDirectory(tif,nextdiroff,&dir,&tif->tif_nextdiroff); + if (!dircount) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Failed to read directory at offset " TIFF_UINT64_FORMAT,nextdiroff); + return 0; + } + TIFFReadDirectoryCheckOrder(tif,dir,dircount); + + /* + * Mark duplicates of any tag to be ignored (bugzilla 1994) + * to avoid certain pathological problems. + */ + { + TIFFDirEntry* ma; + uint16 mb; + for (ma=dir, mb=0; mbtdir_tag==na->tdir_tag) + na->tdir_tag=IGNORE; + } + } + } + + tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ + tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */ + /* free any old stuff and reinit */ + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + /* + * Electronic Arts writes gray-scale TIFF files + * without a PlanarConfiguration directory entry. + * Thus we setup a default value here, even though + * the TIFF spec says there is no default value. + */ + TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); + /* + * Setup default value and then make a pass over + * the fields to check type and tag information, + * and to extract info required to size data + * structures. A second pass is made afterwards + * to read in everthing not taken in the first pass. + * But we must process the Compression tag first + * in order to merge in codec-private tag definitions (otherwise + * we may get complaints about unknown tags). However, the + * Compression tag may be dependent on the SamplesPerPixel + * tag value because older TIFF specs permited Compression + * to be written as a SamplesPerPixel-count tag entry. + * Thus if we don't first figure out the correct SamplesPerPixel + * tag value then we may end up ignoring the Compression tag + * value because it has an incorrect count value (if the + * true value of SamplesPerPixel is not 1). + */ + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_SAMPLESPERPIXEL); + if (dp) + { + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_tag=IGNORE; + } + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_COMPRESSION); + if (dp) + { + /* + * The 5.0 spec says the Compression tag has one value, while + * earlier specs say it has one value per sample. Because of + * this, we accept the tag if one value is supplied with either + * count. + */ + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + TIFFReadDirEntryOutputErr(tif,err,module,"Compression",0); + goto bad; + } + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,value)) + goto bad; + dp->tdir_tag=IGNORE; + } + else + { + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE)) + goto bad; + } + /* + * First real pass over the directory. + */ + for (di=0, dp=dir; ditdir_tag!=IGNORE) + { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + if (fii == FAILED_FII) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Unknown field with tag %d (0x%x) encountered", + dp->tdir_tag,dp->tdir_tag); + /* the following knowingly leaks the + anonymous field structure */ + if (!_TIFFMergeFields(tif, + _TIFFCreateAnonField(tif, + dp->tdir_tag, + (TIFFDataType) dp->tdir_type), + 1)) { + TIFFWarningExt(tif->tif_clientdata, + module, + "Registering anonymous field with tag %d (0x%x) failed", + dp->tdir_tag, + dp->tdir_tag); + dp->tdir_tag=IGNORE; + } else { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + assert(fii != FAILED_FII); + } + } + } + if (dp->tdir_tag!=IGNORE) + { + fip=tif->tif_fields[fii]; + if (fip->field_bit==FIELD_IGNORE) + dp->tdir_tag=IGNORE; + else + { + switch (dp->tdir_tag) + { + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEOFFSETS: + case TIFFTAG_TILEBYTECOUNTS: + TIFFSetFieldBit(tif,fip->field_bit); + break; + case TIFFTAG_IMAGEWIDTH: + case TIFFTAG_IMAGELENGTH: + case TIFFTAG_IMAGEDEPTH: + case TIFFTAG_TILELENGTH: + case TIFFTAG_TILEWIDTH: + case TIFFTAG_TILEDEPTH: + case TIFFTAG_PLANARCONFIG: + case TIFFTAG_ROWSPERSTRIP: + case TIFFTAG_EXTRASAMPLES: + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_tag=IGNORE; + break; + } + } + } + } + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) planarconfig tag says it's separate, + * c) strip offsets/bytecounts tag are both present and + * d) both contain exactly one value, then we consistently find + * that the buggy implementation of the buggy compression scheme + * matches contig planarconfig best. So we 'fix-up' the tag here + */ + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG)&& + (tif->tif_dir.td_planarconfig==PLANARCONFIG_SEPARATE)) + { + if (!_TIFFFillStriles(tif)) + goto bad; + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_STRIPOFFSETS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount, + TIFFTAG_STRIPBYTECOUNTS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + tif->tif_dir.td_planarconfig=PLANARCONFIG_CONTIG; + TIFFWarningExt(tif->tif_clientdata,module, + "Planarconfig tag value assumed incorrect, " + "assuming data is contig instead of chunky"); + } + } + } + /* + * Allocate directory structure and setup defaults. + */ + if (!TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) + { + MissingRequired(tif,"ImageLength"); + goto bad; + } + /* + * Setup appropriate structures (by strip or by tile) + */ + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); + tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth; + tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip; + tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth; + tif->tif_flags &= ~TIFF_ISTILED; + } else { + tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); + tif->tif_flags |= TIFF_ISTILED; + } + if (!tif->tif_dir.td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero number of %s", + isTiled(tif) ? "tiles" : "strips"); + goto bad; + } + tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips; + if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE) + tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel; + if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG) && + (isTiled(tif)==0) && + (tif->tif_dir.td_nstrips==1)) { + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) it's not a tiled TIFF, + * and c) the number of strips is 1, + * then we tolerate the absence of stripoffsets tag, + * because, presumably, all required data is in the + * JpegInterchangeFormat stream. + */ + TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); + } else { + MissingRequired(tif, + isTiled(tif) ? "TileOffsets" : "StripOffsets"); + goto bad; + } + } + /* + * Second pass: extract other information. + */ + for (di=0, dp=dir; ditdir_tag) + { + case IGNORE: + break; + case TIFFTAG_MINSAMPLEVALUE: + case TIFFTAG_MAXSAMPLEVALUE: + case TIFFTAG_BITSPERSAMPLE: + case TIFFTAG_DATATYPE: + case TIFFTAG_SAMPLEFORMAT: + /* + * The MinSampleValue, MaxSampleValue, BitsPerSample + * DataType and SampleFormat tags are supposed to be + * written as one value/sample, but some vendors + * incorrectly write one value only -- so we accept + * that as well (yech). Other vendors write correct + * value for NumberOfSamples, but incorrect one for + * BitsPerSample and friends, and we will read this + * too. + */ + { + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); + goto bad; + } + if (!TIFFSetField(tif,dp->tdir_tag,value)) + goto bad; + } + break; + case TIFFTAG_SMINSAMPLEVALUE: + case TIFFTAG_SMAXSAMPLEVALUE: + { + + double *data; + enum TIFFReadDirEntryErr err; + uint32 saved_flags; + int m; + if (dp->tdir_count != (uint64)tif->tif_dir.td_samplesperpixel) + err = TIFFReadDirEntryErrCount; + else + err = TIFFReadDirEntryDoubleArray(tif, dp, &data); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); + goto bad; + } + saved_flags = tif->tif_flags; + tif->tif_flags |= TIFF_PERSAMPLE; + m = TIFFSetField(tif,dp->tdir_tag,data); + tif->tif_flags = saved_flags; + _TIFFfree(data); + if (!m) + goto bad; + } + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: +#if defined(DEFER_STRILE_LOAD) + _TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry), + dp, sizeof(TIFFDirEntry) ); +#else + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset)) + goto bad; +#endif + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: +#if defined(DEFER_STRILE_LOAD) + _TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry), + dp, sizeof(TIFFDirEntry) ); +#else + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount)) + goto bad; +#endif + break; + case TIFFTAG_COLORMAP: + case TIFFTAG_TRANSFERFUNCTION: + { + enum TIFFReadDirEntryErr err; + uint32 countpersample; + uint32 countrequired; + uint32 incrementpersample; + uint16* value=NULL; + countpersample=(1L<tif_dir.td_bitspersample); + if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample)) + { + countrequired=countpersample; + incrementpersample=0; + } + else + { + countrequired=3*countpersample; + incrementpersample=countpersample; + } + if (dp->tdir_count!=(uint64)countrequired) + err=TIFFReadDirEntryErrCount; + else + err=TIFFReadDirEntryShortArray(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",1); + } + else + { + TIFFSetField(tif,dp->tdir_tag,value,value+incrementpersample,value+2*incrementpersample); + _TIFFfree(value); + } + } + break; +/* BEGIN REV 4.0 COMPATIBILITY */ + case TIFFTAG_OSUBFILETYPE: + { + uint16 valueo; + uint32 value; + if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk) + { + switch (valueo) + { + case OFILETYPE_REDUCEDIMAGE: value=FILETYPE_REDUCEDIMAGE; break; + case OFILETYPE_PAGE: value=FILETYPE_PAGE; break; + default: value=0; break; + } + if (value!=0) + TIFFSetField(tif,TIFFTAG_SUBFILETYPE,value); + } + } + break; +/* END REV 4.0 COMPATIBILITY */ + default: + (void) TIFFFetchNormalTag(tif, dp, TRUE); + break; + } + } + /* + * OJPEG hack: + * - If a) compression is OJPEG, and b) photometric tag is missing, + * then we consistently find that photometric should be YCbCr + * - If a) compression is OJPEG, and b) photometric tag says it's RGB, + * then we consistently find that the buggy implementation of the + * buggy compression scheme matches photometric YCbCr instead. + * - If a) compression is OJPEG, and b) bitspersample tag is missing, + * then we consistently find bitspersample should be 8. + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is RGB or YCbCr, then we consistently find + * samplesperpixel should be 3 + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is MINISWHITE or MINISBLACK, then we consistently + * find samplesperpixel should be 3 + */ + if (tif->tif_dir.td_compression==COMPRESSION_OJPEG) + { + if (!TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Photometric tag is missing, assuming data is YCbCr"); + if (!TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_YCBCR)) + goto bad; + } + else if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + tif->tif_dir.td_photometric=PHOTOMETRIC_YCBCR; + TIFFWarningExt(tif->tif_clientdata, module, + "Photometric tag value assumed incorrect, " + "assuming data is YCbCr instead of RGB"); + } + if (!TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) + { + TIFFWarningExt(tif->tif_clientdata,module, + "BitsPerSample tag is missing, assuming 8 bits per sample"); + if (!TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8)) + goto bad; + } + if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + { + if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag is missing, " + "assuming correct SamplesPerPixel value is 3"); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + if (tif->tif_dir.td_photometric==PHOTOMETRIC_YCBCR) + { + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag is missing, " + "applying correct SamplesPerPixel value of 3"); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + else if ((tif->tif_dir.td_photometric==PHOTOMETRIC_MINISWHITE) + || (tif->tif_dir.td_photometric==PHOTOMETRIC_MINISBLACK)) + { + /* + * SamplesPerPixel tag is missing, but is not required + * by spec. Assume correct SamplesPerPixel value of 1. + */ + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1)) + goto bad; + } + } + } + /* + * Verify Palette image has a Colormap. + */ + if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE && + !TIFFFieldSet(tif, FIELD_COLORMAP)) { + if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3) + tif->tif_dir.td_photometric = PHOTOMETRIC_RGB; + else if (tif->tif_dir.td_bitspersample>=8) + tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK; + else { + MissingRequired(tif, "Colormap"); + goto bad; + } + } + /* + * OJPEG hack: + * We do no further messing with strip/tile offsets/bytecounts in OJPEG + * TIFFs + */ + if (tif->tif_dir.td_compression!=COMPRESSION_OJPEG) + { + /* + * Attempt to deal with a missing StripByteCounts tag. + */ + if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { + /* + * Some manufacturers violate the spec by not giving + * the size of the strips. In this case, assume there + * is one uncompressed strip of data. + */ + if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && + tif->tif_dir.td_nstrips > 1) || + (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE && + tif->tif_dir.td_nstrips != (uint32)tif->tif_dir.td_samplesperpixel)) { + MissingRequired(tif, "StripByteCounts"); + goto bad; + } + TIFFWarningExt(tif->tif_clientdata, module, + "TIFF directory is missing required " + "\"StripByteCounts\" field, calculating from imagelength"); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + /* + * Assume we have wrong StripByteCount value (in case + * of single strip) in following cases: + * - it is equal to zero along with StripOffset; + * - it is larger than file itself (in case of uncompressed + * image); + * - it is smaller than the size of the bytes per row + * multiplied on the number of rows. The last case should + * not be checked in the case of writing new image, + * because we may do not know the exact strip size + * until the whole image will be written and directory + * dumped out. + */ + #define BYTECOUNTLOOKSBAD \ + ( (tif->tif_dir.td_stripbytecount[0] == 0 && tif->tif_dir.td_stripoffset[0] != 0) || \ + (tif->tif_dir.td_compression == COMPRESSION_NONE && \ + tif->tif_dir.td_stripbytecount[0] > TIFFGetFileSize(tif) - tif->tif_dir.td_stripoffset[0]) || \ + (tif->tif_mode == O_RDONLY && \ + tif->tif_dir.td_compression == COMPRESSION_NONE && \ + tif->tif_dir.td_stripbytecount[0] < TIFFScanlineSize64(tif) * tif->tif_dir.td_imagelength) ) + + } else if (tif->tif_dir.td_nstrips == 1 + && _TIFFFillStriles(tif) + && tif->tif_dir.td_stripoffset[0] != 0 + && BYTECOUNTLOOKSBAD) { + /* + * XXX: Plexus (and others) sometimes give a value of + * zero for a tag when they don't know what the + * correct value is! Try and handle the simple case + * of estimating the size of a one strip image. + */ + TIFFWarningExt(tif->tif_clientdata, module, + "Bogus \"StripByteCounts\" field, ignoring and calculating from imagelength"); + if(EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + +#if !defined(DEFER_STRILE_LOAD) + } else if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG + && tif->tif_dir.td_nstrips > 2 + && tif->tif_dir.td_compression == COMPRESSION_NONE + && tif->tif_dir.td_stripbytecount[0] != tif->tif_dir.td_stripbytecount[1] + && tif->tif_dir.td_stripbytecount[0] != 0 + && tif->tif_dir.td_stripbytecount[1] != 0 ) { + /* + * XXX: Some vendors fill StripByteCount array with + * absolutely wrong values (it can be equal to + * StripOffset array, for example). Catch this case + * here. + * + * We avoid this check if deferring strile loading + * as it would always force us to load the strip/tile + * information. + */ + TIFFWarningExt(tif->tif_clientdata, module, + "Wrong \"StripByteCounts\" field, ignoring and calculating from imagelength"); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; +#endif /* !defined(DEFER_STRILE_LOAD) */ + } + } + if (dir) + { + _TIFFfree(dir); + dir=NULL; + } + if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) + { + if (tif->tif_dir.td_bitspersample>=16) + tif->tif_dir.td_maxsamplevalue=0xFFFF; + else + tif->tif_dir.td_maxsamplevalue = (uint16)((1L<tif_dir.td_bitspersample)-1); + } + /* + * XXX: We can optimize checking for the strip bounds using the sorted + * bytecounts array. See also comments for TIFFAppendToStrip() + * function in tif_write.c. + */ +#if !defined(DEFER_STRILE_LOAD) + if (tif->tif_dir.td_nstrips > 1) { + uint32 strip; + + tif->tif_dir.td_stripbytecountsorted = 1; + for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { + if (tif->tif_dir.td_stripoffset[strip - 1] > + tif->tif_dir.td_stripoffset[strip]) { + tif->tif_dir.td_stripbytecountsorted = 0; + break; + } + } + } +#endif /* !defined(DEFER_STRILE_LOAD) */ + + /* + * An opportunity for compression mode dependent tag fixup + */ + (*tif->tif_fixuptags)(tif); + + /* + * Some manufacturers make life difficult by writing + * large amounts of uncompressed data as a single strip. + * This is contrary to the recommendations of the spec. + * The following makes an attempt at breaking such images + * into strips closer to the recommended 8k bytes. A + * side effect, however, is that the RowsPerStrip tag + * value may be changed. + */ + if ((tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)&& + (tif->tif_dir.td_nstrips==1)&& + (tif->tif_dir.td_compression==COMPRESSION_NONE)&& + ((tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED))==TIFF_STRIPCHOP)) + { + if ( !_TIFFFillStriles(tif) || !tif->tif_dir.td_stripbytecount ) + return 0; + ChopUpSingleUncompressedStrip(tif); + } + + /* + * Clear the dirty directory flag. + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + + /* + * Reinitialize i/o since we are starting on a new directory. + */ + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + tif->tif_col = (uint32) -1; + tif->tif_curtile = (uint32) -1; + tif->tif_tilesize = (tmsize_t) -1; + + tif->tif_scanlinesize = TIFFScanlineSize(tif); + if (!tif->tif_scanlinesize) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero scanline size"); + return (0); + } + + if (isTiled(tif)) { + tif->tif_tilesize = TIFFTileSize(tif); + if (!tif->tif_tilesize) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero tile size"); + return (0); + } + } else { + if (!TIFFStripSize(tif)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero strip size"); + return (0); + } + } + return (1); +bad: + if (dir) + _TIFFfree(dir); + return (0); +} + +static void +TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +{ + static const char module[] = "TIFFReadDirectoryCheckOrder"; + uint16 m; + uint16 n; + TIFFDirEntry* o; + m=0; + for (n=0, o=dir; ntdir_tagtif_clientdata,module, + "Invalid TIFF directory; tags are not sorted in ascending order"); + break; + } + m=o->tdir_tag+1; + } +} + +static TIFFDirEntry* +TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid) +{ + TIFFDirEntry* m; + uint16 n; + (void) tif; + for (m=dir, n=0; ntdir_tag==tagid) + return(m); + } + return(0); +} + +static void +TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) +{ + int32 ma,mb,mc; + ma=-1; + mc=(int32)tif->tif_nfields; + while (1) + { + if (ma+1==mc) + { + *fii = FAILED_FII; + return; + } + mb=(ma+mc)/2; + if (tif->tif_fields[mb]->field_tag==(uint32)tagid) + break; + if (tif->tif_fields[mb]->field_tag<(uint32)tagid) + ma=mb; + else + mc=mb; + } + while (1) + { + if (mb==0) + break; + if (tif->tif_fields[mb-1]->field_tag!=(uint32)tagid) + break; + mb--; + } + *fii=mb; +} + +/* + * Read custom directory from the arbitarry offset. + * The code is very similar to TIFFReadDirectory(). + */ +int +TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, + const TIFFFieldArray* infoarray) +{ + static const char module[] = "TIFFReadCustomDirectory"; + TIFFDirEntry* dir; + uint16 dircount; + TIFFDirEntry* dp; + uint16 di; + const TIFFField* fip; + uint32 fii; + _TIFFSetupFields(tif, infoarray); + dircount=TIFFFetchDirectory(tif,diroff,&dir,NULL); + if (!dircount) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Failed to read custom directory at offset " TIFF_UINT64_FORMAT,diroff); + return 0; + } + TIFFFreeDirectory(tif); + _TIFFmemset(&tif->tif_dir, 0, sizeof(TIFFDirectory)); + TIFFReadDirectoryCheckOrder(tif,dir,dircount); + for (di=0, dp=dir; ditdir_tag,&fii); + if (fii == FAILED_FII) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Unknown field with tag %d (0x%x) encountered", + dp->tdir_tag, dp->tdir_tag); + if (!_TIFFMergeFields(tif, _TIFFCreateAnonField(tif, + dp->tdir_tag, + (TIFFDataType) dp->tdir_type), + 1)) { + TIFFWarningExt(tif->tif_clientdata, module, + "Registering anonymous field with tag %d (0x%x) failed", + dp->tdir_tag, dp->tdir_tag); + dp->tdir_tag=IGNORE; + } else { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + assert( fii != FAILED_FII ); + } + } + if (dp->tdir_tag!=IGNORE) + { + fip=tif->tif_fields[fii]; + if (fip->field_bit==FIELD_IGNORE) + dp->tdir_tag=IGNORE; + else + { + /* check data type */ + while ((fip->field_type!=TIFF_ANY)&&(fip->field_type!=dp->tdir_type)) + { + fii++; + if ((fii==tif->tif_nfields)|| + (tif->tif_fields[fii]->field_tag!=(uint32)dp->tdir_tag)) + { + fii=0xFFFF; + break; + } + fip=tif->tif_fields[fii]; + } + if (fii==0xFFFF) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Wrong data type %d for \"%s\"; tag ignored", + dp->tdir_type,fip->field_name); + dp->tdir_tag=IGNORE; + } + else + { + /* check count if known in advance */ + if ((fip->field_readcount!=TIFF_VARIABLE)&& + (fip->field_readcount!=TIFF_VARIABLE2)) + { + uint32 expected; + if (fip->field_readcount==TIFF_SPP) + expected=(uint32)tif->tif_dir.td_samplesperpixel; + else + expected=(uint32)fip->field_readcount; + if (!CheckDirCount(tif,dp,expected)) + dp->tdir_tag=IGNORE; + } + } + } + switch (dp->tdir_tag) + { + case IGNORE: + break; + case EXIFTAG_SUBJECTDISTANCE: + (void) TIFFFetchSubjectDistance(tif,dp); + break; + default: + (void) TIFFFetchNormalTag(tif, dp, TRUE); + break; + } + } + } + if (dir) + _TIFFfree(dir); + return 1; +} + +/* + * EXIF is important special case of custom IFD, so we have a special + * function to read it. + */ +int +TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff) +{ + const TIFFFieldArray* exifFieldArray; + exifFieldArray = _TIFFGetExifFields(); + return TIFFReadCustomDirectory(tif, diroff, exifFieldArray); +} + +static int +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +{ + static const char module[] = "EstimateStripByteCounts"; + + TIFFDirEntry *dp; + TIFFDirectory *td = &tif->tif_dir; + uint32 strip; + + _TIFFFillStriles( tif ); + + if (td->td_stripbytecount) + _TIFFfree(td->td_stripbytecount); + td->td_stripbytecount = (uint64*) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + "for \"StripByteCounts\" array"); + if( td->td_stripbytecount == NULL ) + return -1; + + if (td->td_compression != COMPRESSION_NONE) { + uint64 space; + uint64 filesize; + uint16 n; + filesize = TIFFGetFileSize(tif); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + space=sizeof(TIFFHeaderClassic)+2+dircount*12+4; + else + space=sizeof(TIFFHeaderBig)+8+dircount*20+8; + /* calculate amount of space used by indirect values */ + for (dp = dir, n = dircount; n > 0; n--, dp++) + { + uint32 typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type); + uint64 datasize; + typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type); + if (typewidth == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot determine size of unknown tag type %d", + dp->tdir_type); + return -1; + } + datasize=(uint64)typewidth*dp->tdir_count; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (datasize<=4) + datasize=0; + } + else + { + if (datasize<=8) + datasize=0; + } + space+=datasize; + } + space = filesize - space; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + space /= td->td_samplesperpixel; + for (strip = 0; strip < td->td_nstrips; strip++) + td->td_stripbytecount[strip] = space; + /* + * This gross hack handles the case were the offset to + * the last strip is past the place where we think the strip + * should begin. Since a strip of data must be contiguous, + * it's safe to assume that we've overestimated the amount + * of data in the strip and trim this number back accordingly. + */ + strip--; + if (td->td_stripoffset[strip]+td->td_stripbytecount[strip] > filesize) + td->td_stripbytecount[strip] = filesize - td->td_stripoffset[strip]; + } else if (isTiled(tif)) { + uint64 bytespertile = TIFFTileSize64(tif); + + for (strip = 0; strip < td->td_nstrips; strip++) + td->td_stripbytecount[strip] = bytespertile; + } else { + uint64 rowbytes = TIFFScanlineSize64(tif); + uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; + for (strip = 0; strip < td->td_nstrips; strip++) + td->td_stripbytecount[strip] = rowbytes * rowsperstrip; + } + TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); + if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) + td->td_rowsperstrip = td->td_imagelength; + return 1; +} + +static void +MissingRequired(TIFF* tif, const char* tagname) +{ + static const char module[] = "MissingRequired"; + + TIFFErrorExt(tif->tif_clientdata, module, + "TIFF directory is missing required \"%s\" field", + tagname); +} + +/* + * Check the directory offset against the list of already seen directory + * offsets. This is a trick to prevent IFD looping. The one can create TIFF + * file with looped directory pointers. We will maintain a list of already + * seen directories and check every IFD offset against that list. + */ +static int +TIFFCheckDirOffset(TIFF* tif, uint64 diroff) +{ + uint16 n; + + if (diroff == 0) /* no more directories */ + return 0; + + for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) { + if (tif->tif_dirlist[n] == diroff) + return 0; + } + + tif->tif_dirnumber++; + + if (tif->tif_dirnumber > tif->tif_dirlistsize) { + uint64* new_dirlist; + + /* + * XXX: Reduce memory allocation granularity of the dirlist + * array. + */ + new_dirlist = (uint64*)_TIFFCheckRealloc(tif, tif->tif_dirlist, + tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list"); + if (!new_dirlist) + return 0; + tif->tif_dirlistsize = 2 * tif->tif_dirnumber; + tif->tif_dirlist = new_dirlist; + } + + tif->tif_dirlist[tif->tif_dirnumber - 1] = diroff; + + return 1; +} + +/* + * Check the count field of a directory entry against a known value. The + * caller is expected to skip/ignore the tag if there is a mismatch. + */ +static int +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) +{ + if ((uint64)count > dir->tdir_count) { + const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag ignored", + fip ? fip->field_name : "unknown tagname", + dir->tdir_count, count); + return (0); + } else if ((uint64)count < dir->tdir_count) { + const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag trimmed", + fip ? fip->field_name : "unknown tagname", + dir->tdir_count, count); + dir->tdir_count = count; + return (1); + } + return (1); +} + +/* + * Read IFD structure from the specified offset. If the pointer to + * nextdiroff variable has been specified, read it too. Function returns a + * number of fields in the directory or 0 if failed. + */ +static uint16 +TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, + uint64 *nextdiroff) +{ + static const char module[] = "TIFFFetchDirectory"; + + void* origdir; + uint16 dircount16; + uint32 dirsize; + TIFFDirEntry* dir; + uint8* ma; + TIFFDirEntry* mb; + uint16 n; + + assert(pdir); + + tif->tif_diroff = diroff; + if (nextdiroff) + *nextdiroff = 0; + if (!isMapped(tif)) { + if (!SeekOK(tif, tif->tif_diroff)) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); + return 0; + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (!ReadOK(tif, &dircount16, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); + return 0; + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount16); + if (dircount16>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dirsize = 12; + } else { + uint64 dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); + return 0; + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dircount16 = (uint16)dircount64; + dirsize = 20; + } + origdir = _TIFFCheckMalloc(tif, dircount16, + dirsize, "to read TIFF directory"); + if (origdir == NULL) + return 0; + if (!ReadOK(tif, origdir, (tmsize_t)(dircount16*dirsize))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%.100s: Can not read TIFF directory", + tif->tif_name); + _TIFFfree(origdir); + return 0; + } + /* + * Read offset to next directory for sequential scans if + * needed. + */ + if (nextdiroff) + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 nextdiroff32; + if (!ReadOK(tif, &nextdiroff32, sizeof(uint32))) + nextdiroff32 = 0; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nextdiroff32); + *nextdiroff=nextdiroff32; + } else { + if (!ReadOK(tif, nextdiroff, sizeof(uint64))) + *nextdiroff = 0; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(nextdiroff); + } + } + } else { + tmsize_t m; + tmsize_t off = (tmsize_t) tif->tif_diroff; + if ((uint64)off!=tif->tif_diroff) + { + TIFFErrorExt(tif->tif_clientdata,module,"Can not read TIFF directory count"); + return(0); + } + + /* + * Check for integer overflow when validating the dir_off, + * otherwise a very high offset may cause an OOB read and + * crash the client. Make two comparisons instead of + * + * off + sizeof(uint16) > tif->tif_size + * + * to avoid overflow. + */ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + m=off+sizeof(uint16); + if ((mtif->tif_size)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not read TIFF directory count"); + return 0; + } else { + _TIFFmemcpy(&dircount16, tif->tif_base + off, + sizeof(uint16)); + } + off += sizeof (uint16); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount16); + if (dircount16>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dirsize = 12; + } + else + { + tmsize_t m; + uint64 dircount64; + m=off+sizeof(uint64); + if ((mtif->tif_size)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not read TIFF directory count"); + return 0; + } else { + _TIFFmemcpy(&dircount64, tif->tif_base + off, + sizeof(uint64)); + } + off += sizeof (uint64); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dircount16 = (uint16)dircount64; + dirsize = 20; + } + if (dircount16 == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, zero tag directories not supported"); + return 0; + } + origdir = _TIFFCheckMalloc(tif, dircount16, + dirsize, + "to read TIFF directory"); + if (origdir == NULL) + return 0; + m=off+dircount16*dirsize; + if ((mtif->tif_size)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not read TIFF directory"); + _TIFFfree(origdir); + return 0; + } else { + _TIFFmemcpy(origdir, tif->tif_base + off, + dircount16 * dirsize); + } + if (nextdiroff) { + off += dircount16 * dirsize; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 nextdiroff32; + m=off+sizeof(uint32); + if ((mtif->tif_size)) + nextdiroff32 = 0; + else + _TIFFmemcpy(&nextdiroff32, tif->tif_base + off, + sizeof (uint32)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nextdiroff32); + *nextdiroff = nextdiroff32; + } + else + { + m=off+sizeof(uint64); + if ((mtif->tif_size)) + *nextdiroff = 0; + else + _TIFFmemcpy(nextdiroff, tif->tif_base + off, + sizeof (uint64)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(nextdiroff); + } + } + } + dir = (TIFFDirEntry*)_TIFFCheckMalloc(tif, dircount16, + sizeof(TIFFDirEntry), + "to read TIFF directory"); + if (dir==0) + { + _TIFFfree(origdir); + return 0; + } + ma=(uint8*)origdir; + mb=dir; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + mb->tdir_tag=*(uint16*)ma; + ma+=sizeof(uint16); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + mb->tdir_type=*(uint16*)ma; + ma+=sizeof(uint16); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + mb->tdir_count=(uint64)(*(uint32*)ma); + ma+=sizeof(uint32); + *(uint32*)(&mb->tdir_offset)=*(uint32*)ma; + ma+=sizeof(uint32); + } + else + { + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + mb->tdir_count=TIFFReadUInt64(ma); + ma+=sizeof(uint64); + mb->tdir_offset.toff_long8=TIFFReadUInt64(ma); + ma+=sizeof(uint64); + } + mb++; + } + _TIFFfree(origdir); + *pdir = dir; + return dircount16; +} + +/* + * Fetch a tag that is not handled by special case code. + */ +static int +TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) +{ + static const char module[] = "TIFFFetchNormalTag"; + enum TIFFReadDirEntryErr err; + uint32 fii; + const TIFFField* fip = NULL; + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + if( fii == FAILED_FII ) + { + TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag", + "No definition found for tag %d", + dp->tdir_tag); + return 0; + } + fip=tif->tif_fields[fii]; + assert(fip->set_field_type!=TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with this in specialized code */ + assert(fip->set_field_type!=TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only the case for pseudo-tags */ + err=TIFFReadDirEntryErrOk; + switch (fip->set_field_type) + { + case TIFF_SETGET_UNDEFINED: + break; + case TIFF_SETGET_ASCII: + { + uint8* data; + assert(fip->field_passcount==0); + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + uint8* ma; + uint32 mb; + int n; + ma=data; + mb=0; + while (mb<(uint32)dp->tdir_count) + { + if (*ma==0) + break; + ma++; + mb++; + } + if (mb+1<(uint32)dp->tdir_count) + TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" contains null byte in value; value incorrectly truncated during reading due to implementation limitations",fip->field_name); + else if (mb+1>(uint32)dp->tdir_count) + { + uint8* o; + TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte",fip->field_name); + if ((uint32)dp->tdir_count+1!=dp->tdir_count+1) + o=NULL; + else + o=_TIFFmalloc((uint32)dp->tdir_count+1); + if (o==NULL) + { + if (data!=NULL) + _TIFFfree(data); + return(0); + } + _TIFFmemcpy(o,data,(uint32)dp->tdir_count); + o[(uint32)dp->tdir_count]=0; + if (data!=0) + _TIFFfree(data); + data=o; + } + n=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!n) + return(0); + } + } + break; + case TIFF_SETGET_UINT8: + { + uint8 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryByte(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT16: + { + uint16 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryShort(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT32: + { + uint32 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryLong(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT64: + { + uint64 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryLong8(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_FLOAT: + { + float data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryFloat(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_DOUBLE: + { + double data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryDouble(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_IFD8: + { + uint64 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryIfd8(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT16_PAIR: + { + uint16* data; + assert(fip->field_readcount==2); + assert(fip->field_passcount==0); + if (dp->tdir_count!=2) + return(0); + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data[0],data[1]); + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C0_UINT8: + { + uint8* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C0_UINT16: + { + uint16* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C0_UINT32: + { + uint32* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryLongArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C0_FLOAT: + { + float* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryFloatArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_ASCII: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT8: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT16: + { + uint16* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT32: + { + uint32* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryLongArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT64: + { + uint64* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryLong8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_FLOAT: + { + float* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryFloatArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_DOUBLE: + { + double* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryDoubleArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_IFD8: + { + uint64* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryIfd8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C32_ASCII: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT8: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT8: + { + int8* data = NULL; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntrySbyteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT16: + { + uint16* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT16: + { + int16* data = NULL; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntrySshortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT32: + { + uint32* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryLongArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT32: + { + int32* data = NULL; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntrySlongArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT64: + { + uint64* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryLong8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT64: + { + int64* data = NULL; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntrySlong8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_FLOAT: + { + float* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryFloatArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_DOUBLE: + { + double* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryDoubleArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_IFD8: + { + uint64* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryIfd8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + default: + assert(0); /* we should never get here */ + break; + } + if (err!=TIFFReadDirEntryErrOk) + { + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",recover); + return(0); + } + return(1); +} + +/* + * Fetch a set of offsets or lengths. + * While this routine says "strips", in fact it's also used for tiles. + */ +static int +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) +{ + static const char module[] = "TIFFFetchStripThing"; + enum TIFFReadDirEntryErr err; + uint64* data; + err=TIFFReadDirEntryLong8Array(tif,dir,&data); + if (err!=TIFFReadDirEntryErrOk) + { + const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); + return(0); + } + if (dir->tdir_count!=(uint64)nstrips) + { + uint64* resizeddata; + resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array"); + if (resizeddata==0) { + _TIFFfree(data); + return(0); + } + if (dir->tdir_count<(uint64)nstrips) + { + _TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64)); + _TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64)); + } + else + _TIFFmemcpy(resizeddata,data,nstrips*sizeof(uint64)); + _TIFFfree(data); + data=resizeddata; + } + *lpp=data; + return(1); +} + +/* + * Fetch and set the SubjectDistance EXIF tag. + */ +static int +TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) +{ + static const char module[] = "TIFFFetchSubjectDistance"; + enum TIFFReadDirEntryErr err; + UInt64Aligned_t m; + m.l=0; + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(uint32)==4); + if (dir->tdir_count!=1) + err=TIFFReadDirEntryErrCount; + else if (dir->tdir_type!=TIFF_RATIONAL) + err=TIFFReadDirEntryErrType; + else + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 offset; + offset=*(uint32*)(&dir->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,m.i); + } + else + { + m.l=dir->tdir_offset.toff_long8; + err=TIFFReadDirEntryErrOk; + } + } + if (err==TIFFReadDirEntryErrOk) + { + double n; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m.i,2); + if (m.i[0]==0) + n=0.0; + else if (m.i[0]==0xFFFFFFFF) + /* + * XXX: Numerator 0xFFFFFFFF means that we have infinite + * distance. Indicate that with a negative floating point + * SubjectDistance value. + */ + n=-1.0; + else + n=(double)m.i[0]/(double)m.i[1]; + return(TIFFSetField(tif,dir->tdir_tag,n)); + } + else + { + TIFFReadDirEntryOutputErr(tif,err,module,"SubjectDistance",TRUE); + return(0); + } +} + +/* + * Replace a single strip (tile) of uncompressed data by multiple strips + * (tiles), each approximately STRIP_SIZE_DEFAULT bytes. This is useful for + * dealing with large images or for dealing with machines with a limited + * amount memory. + */ +static void +ChopUpSingleUncompressedStrip(TIFF* tif) +{ + register TIFFDirectory *td = &tif->tif_dir; + uint64 bytecount; + uint64 offset; + uint32 rowblock; + uint64 rowblockbytes; + uint64 stripbytes; + uint32 strip; + uint64 nstrips64; + uint32 nstrips32; + uint32 rowsperstrip; + uint64* newcounts; + uint64* newoffsets; + + bytecount = td->td_stripbytecount[0]; + offset = td->td_stripoffset[0]; + assert(td->td_planarconfig == PLANARCONFIG_CONTIG); + if ((td->td_photometric == PHOTOMETRIC_YCBCR)&& + (!isUpSampled(tif))) + rowblock = td->td_ycbcrsubsampling[1]; + else + rowblock = 1; + rowblockbytes = TIFFVTileSize64(tif, rowblock); + /* + * Make the rows hold at least one scanline, but fill specified amount + * of data if possible. + */ + if (rowblockbytes > STRIP_SIZE_DEFAULT) { + stripbytes = rowblockbytes; + rowsperstrip = rowblock; + } else if (rowblockbytes > 0 ) { + uint32 rowblocksperstrip; + rowblocksperstrip = (uint32) (STRIP_SIZE_DEFAULT / rowblockbytes); + rowsperstrip = rowblocksperstrip * rowblock; + stripbytes = rowblocksperstrip * rowblockbytes; + } + else + return; + + /* + * never increase the number of strips in an image + */ + if (rowsperstrip >= td->td_rowsperstrip) + return; + nstrips64 = TIFFhowmany_64(bytecount, stripbytes); + if ((nstrips64==0)||(nstrips64>0xFFFFFFFF)) /* something is wonky, do nothing. */ + return; + nstrips32 = (uint32)nstrips64; + + newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64), + "for chopped \"StripByteCounts\" array"); + newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64), + "for chopped \"StripOffsets\" array"); + if (newcounts == NULL || newoffsets == NULL) { + /* + * Unable to allocate new strip information, give up and use + * the original one strip information. + */ + if (newcounts != NULL) + _TIFFfree(newcounts); + if (newoffsets != NULL) + _TIFFfree(newoffsets); + return; + } + /* + * Fill the strip information arrays with new bytecounts and offsets + * that reflect the broken-up format. + */ + for (strip = 0; strip < nstrips32; strip++) { + if (stripbytes > bytecount) + stripbytes = bytecount; + newcounts[strip] = stripbytes; + newoffsets[strip] = offset; + offset += stripbytes; + bytecount -= stripbytes; + } + /* + * Replace old single strip info with multi-strip info. + */ + td->td_stripsperimage = td->td_nstrips = nstrips32; + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + + _TIFFfree(td->td_stripbytecount); + _TIFFfree(td->td_stripoffset); + td->td_stripbytecount = newcounts; + td->td_stripoffset = newoffsets; + td->td_stripbytecountsorted = 1; +} + +int _TIFFFillStriles( TIFF *tif ) +{ +#if defined(DEFER_STRILE_LOAD) + register TIFFDirectory *td = &tif->tif_dir; + int return_value = 1; + + if( td->td_stripoffset != NULL ) + return 1; + + if( td->td_stripoffset_entry.tdir_count == 0 ) + return 0; + + if (!TIFFFetchStripThing(tif,&(td->td_stripoffset_entry), + td->td_nstrips,&td->td_stripoffset)) + { + return_value = 0; + } + + if (!TIFFFetchStripThing(tif,&(td->td_stripbytecount_entry), + td->td_nstrips,&td->td_stripbytecount)) + { + return_value = 0; + } + + _TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry)); + _TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry)); + + if (tif->tif_dir.td_nstrips > 1 && return_value == 1 ) { + uint32 strip; + + tif->tif_dir.td_stripbytecountsorted = 1; + for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { + if (tif->tif_dir.td_stripoffset[strip - 1] > + tif->tif_dir.td_stripoffset[strip]) { + tif->tif_dir.td_stripbytecountsorted = 0; + break; + } + } + } + + return return_value; +#else /* !defined(DEFER_STRILE_LOAD) */ + (void) tif; + return 1; +#endif +} + + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_dirwrite.c b/libs/tiff-4.0.2/libtiff/tif_dirwrite.c new file mode 100644 index 0000000000..11738cfe75 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_dirwrite.c @@ -0,0 +1,2910 @@ +/* $Id: tif_dirwrite.c,v 1.76 2011-02-18 20:53:04 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Directory Write Support Routines. + */ +#include "tiffiop.h" + +#ifdef HAVE_IEEEFP +#define TIFFCvtNativeToIEEEFloat(tif, n, fp) +#define TIFFCvtNativeToIEEEDouble(tif, n, dp) +#else +extern void TIFFCvtNativeToIEEEFloat(TIFF* tif, uint32 n, float* fp); +extern void TIFFCvtNativeToIEEEDouble(TIFF* tif, uint32 n, double* dp); +#endif + +static int TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff); + +static int TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +#if 0 +static int TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif + +static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); +static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +#ifdef notdef +static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +#endif +static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +#if 0 +static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +#endif +static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); +#if 0 +static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +#endif +static int TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); +static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); +static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); +#ifdef notdef +static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +#endif +static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); +#if 0 +static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +#endif +static int TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +#if 0 +static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +#endif +static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +#if 0 +static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +#endif +static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#ifdef notdef +static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); +#endif +static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); +static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +#ifdef notdef +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +#endif +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +#if 0 +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +#if 0 +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif +static int TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +#ifdef notdef +static int TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#endif +static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#ifdef notdef +static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#endif +static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); + +static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); +static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +#endif +static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +#endif +static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); +static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); +static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +#endif +static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); +static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +#endif +static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +#endif +static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); +#endif +static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); +static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +#endif +static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif +static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); + +static int TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data); + +static int TIFFLinkDirectory(TIFF*); + +/* + * Write the contents of the current directory + * to the specified file. This routine doesn't + * handle overwriting a directory with auxiliary + * storage that's been changed. + */ +int +TIFFWriteDirectory(TIFF* tif) +{ + return TIFFWriteDirectorySec(tif,TRUE,TRUE,NULL); +} + +/* + * Similar to TIFFWriteDirectory(), writes the directory out + * but leaves all data structures in memory so that it can be + * written again. This will make a partially written TIFF file + * readable before it is successfully completed/closed. + */ +int +TIFFCheckpointDirectory(TIFF* tif) +{ + int rc; + /* Setup the strips arrays, if they haven't already been. */ + if (tif->tif_dir.td_stripoffset == NULL) + (void) TIFFSetupStrips(tif); + rc = TIFFWriteDirectorySec(tif,TRUE,FALSE,NULL); + (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END)); + return rc; +} + +int +TIFFWriteCustomDirectory(TIFF* tif, uint64* pdiroff) +{ + return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff); +} + +/* + * Similar to TIFFWriteDirectory(), but if the directory has already + * been written once, it is relocated to the end of the file, in case it + * has changed in size. Note that this will result in the loss of the + * previously used directory space. + */ +int +TIFFRewriteDirectory( TIFF *tif ) +{ + static const char module[] = "TIFFRewriteDirectory"; + + /* We don't need to do anything special if it hasn't been written. */ + if( tif->tif_diroff == 0 ) + return TIFFWriteDirectory( tif ); + + /* + * Find and zero the pointer to this directory, so that TIFFLinkDirectory + * will cause it to be added after this directories current pre-link. + */ + + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff) + { + tif->tif_header.classic.tiff_diroff = 0; + tif->tif_diroff = 0; + + TIFFSeekFile(tif,4,SEEK_SET); + if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff),4)) + { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error updating TIFF header"); + return (0); + } + } + else + { + uint32 nextdir; + nextdir = tif->tif_header.classic.tiff_diroff; + while(1) { + uint16 dircount; + uint32 nextnextdir; + + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount, 2)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextnextdir); + if (nextnextdir==tif->tif_diroff) + { + uint32 m; + m=0; + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + tif->tif_diroff=0; + break; + } + nextdir=nextnextdir; + } + } + } + else + { + if (tif->tif_header.big.tiff_diroff == tif->tif_diroff) + { + tif->tif_header.big.tiff_diroff = 0; + tif->tif_diroff = 0; + + TIFFSeekFile(tif,8,SEEK_SET); + if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff),8)) + { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error updating TIFF header"); + return (0); + } + } + else + { + uint64 nextdir; + nextdir = tif->tif_header.big.tiff_diroff; + while(1) { + uint64 dircount64; + uint16 dircount; + uint64 nextnextdir; + + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount64, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on tag count failed, likely corrupt TIFF"); + return (0); + } + dircount=(uint16)dircount64; + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&nextnextdir); + if (nextnextdir==tif->tif_diroff) + { + uint64 m; + m=0; + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + tif->tif_diroff=0; + break; + } + nextdir=nextnextdir; + } + } + } + + /* + * Now use TIFFWriteDirectory() normally. + */ + + return TIFFWriteDirectory( tif ); +} + +static int +TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) +{ + static const char module[] = "TIFFWriteDirectorySec"; + uint32 ndir; + TIFFDirEntry* dir; + uint32 dirsize; + void* dirmem; + uint32 m; + if (tif->tif_mode == O_RDONLY) + return (1); + + _TIFFFillStriles( tif ); + + /* + * Clear write state so that subsequent images with + * different characteristics get the right buffers + * setup for them. + */ + if (imagedone) + { + if (tif->tif_flags & TIFF_POSTENCODE) + { + tif->tif_flags &= ~TIFF_POSTENCODE; + if (!(*tif->tif_postencode)(tif)) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Error post-encoding before directory write"); + return (0); + } + } + (*tif->tif_close)(tif); /* shutdown encoder */ + /* + * Flush any data that might have been written + * by the compression close+cleanup routines. But + * be careful not to write stuff if we didn't add data + * in the previous steps as the "rawcc" data may well be + * a previously read tile/strip in mixed read/write mode. + */ + if (tif->tif_rawcc > 0 + && (tif->tif_flags & TIFF_BEENWRITING) != 0 ) + { + if( !TIFFFlushData1(tif) ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Error flushing data before directory write"); + return (0); + } + } + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) + { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawcc = 0; + tif->tif_rawdatasize = 0; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = 0; + } + tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); + } + dir=NULL; + dirmem=NULL; + dirsize=0; + while (1) + { + ndir=0; + if (isimage) + { + if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) + { + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_IMAGEWIDTH,tif->tif_dir.td_imagewidth)) + goto bad; + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_IMAGELENGTH,tif->tif_dir.td_imagelength)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) + { + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_TILEWIDTH,tif->tif_dir.td_tilewidth)) + goto bad; + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_TILELENGTH,tif->tif_dir.td_tilelength)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_RESOLUTION)) + { + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_XRESOLUTION,tif->tif_dir.td_xresolution)) + goto bad; + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_YRESOLUTION,tif->tif_dir.td_yresolution)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_POSITION)) + { + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_XPOSITION,tif->tif_dir.td_xposition)) + goto bad; + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_YPOSITION,tif->tif_dir.td_yposition)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) + { + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,TIFFTAG_SUBFILETYPE,tif->tif_dir.td_subfiletype)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_BITSPERSAMPLE,tif->tif_dir.td_bitspersample)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_COMPRESSION)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_COMPRESSION,tif->tif_dir.td_compression)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_PHOTOMETRIC,tif->tif_dir.td_photometric)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_THRESHHOLDING,tif->tif_dir.td_threshholding)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_FILLORDER)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_FILLORDER,tif->tif_dir.td_fillorder)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_ORIENTATION)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_ORIENTATION,tif->tif_dir.td_orientation)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_SAMPLESPERPIXEL,tif->tif_dir.td_samplesperpixel)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) + { + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_ROWSPERSTRIP,tif->tif_dir.td_rowsperstrip)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_MINSAMPLEVALUE,tif->tif_dir.td_minsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_MAXSAMPLEVALUE,tif->tif_dir.td_maxsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_PLANARCONFIG,tif->tif_dir.td_planarconfig)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_RESOLUTIONUNIT,tif->tif_dir.td_resolutionunit)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) + { + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_PAGENUMBER,2,&tif->tif_dir.td_pagenumber[0])) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_STRIPBYTECOUNTS)) + { + if (!isTiled(tif)) + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_STRIPBYTECOUNTS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripbytecount)) + goto bad; + } + else + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_TILEBYTECOUNTS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripbytecount)) + goto bad; + } + } + if (TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) + { + if (!isTiled(tif)) + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_STRIPOFFSETS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripoffset)) + goto bad; + } + else + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_TILEOFFSETS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripoffset)) + goto bad; + } + } + if (TIFFFieldSet(tif,FIELD_COLORMAP)) + { + if (!TIFFWriteDirectoryTagColormap(tif,&ndir,dir)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES)) + { + if (tif->tif_dir.td_extrasamples) + { + uint16 na; + uint16* nb; + TIFFGetFieldDefaulted(tif,TIFFTAG_EXTRASAMPLES,&na,&nb); + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_EXTRASAMPLES,na,nb)) + goto bad; + } + } + if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_SAMPLEFORMAT,tif->tif_dir.td_sampleformat)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagSampleformatArray(tif,&ndir,dir,TIFFTAG_SMINSAMPLEVALUE,tif->tif_dir.td_samplesperpixel,tif->tif_dir.td_sminsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagSampleformatArray(tif,&ndir,dir,TIFFTAG_SMAXSAMPLEVALUE,tif->tif_dir.td_samplesperpixel,tif->tif_dir.td_smaxsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) + { + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,TIFFTAG_IMAGEDEPTH,tif->tif_dir.td_imagedepth)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) + { + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,TIFFTAG_TILEDEPTH,tif->tif_dir.td_tiledepth)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) + { + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_HALFTONEHINTS,2,&tif->tif_dir.td_halftonehints[0])) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) + { + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_YCBCRSUBSAMPLING,2,&tif->tif_dir.td_ycbcrsubsampling[0])) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_YCBCRPOSITIONING,tif->tif_dir.td_ycbcrpositioning)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) + { + if (!TIFFWriteDirectoryTagRationalArray(tif,&ndir,dir,TIFFTAG_REFERENCEBLACKWHITE,6,tif->tif_dir.td_refblackwhite)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) + { + if (!TIFFWriteDirectoryTagTransferfunction(tif,&ndir,dir)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_INKNAMES)) + { + if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,TIFFTAG_INKNAMES,tif->tif_dir.td_inknameslen,tif->tif_dir.td_inknames)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SUBIFD)) + { + if (!TIFFWriteDirectoryTagSubifd(tif,&ndir,dir)) + goto bad; + } + { + uint32 n; + for (n=0; ntif_nfields; n++) { + const TIFFField* o; + o = tif->tif_fields[n]; + if ((o->field_bit>=FIELD_CODEC)&&(TIFFFieldSet(tif,o->field_bit))) + { + switch (o->get_field_type) + { + case TIFF_SETGET_ASCII: + { + uint32 pa; + char* pb; + assert(o->field_type==TIFF_ASCII); + assert(o->field_readcount==TIFF_VARIABLE); + assert(o->field_passcount==0); + TIFFGetField(tif,o->field_tag,&pb); + pa=(uint32)(strlen(pb)); + if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,o->field_tag,pa,pb)) + goto bad; + } + break; + case TIFF_SETGET_UINT16: + { + uint16 p; + assert(o->field_type==TIFF_SHORT); + assert(o->field_readcount==1); + assert(o->field_passcount==0); + TIFFGetField(tif,o->field_tag,&p); + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,o->field_tag,p)) + goto bad; + } + break; + case TIFF_SETGET_UINT32: + { + uint32 p; + assert(o->field_type==TIFF_LONG); + assert(o->field_readcount==1); + assert(o->field_passcount==0); + TIFFGetField(tif,o->field_tag,&p); + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,o->field_tag,p)) + goto bad; + } + break; + case TIFF_SETGET_C32_UINT8: + { + uint32 pa; + void* pb; + assert(o->field_type==TIFF_UNDEFINED); + assert(o->field_readcount==TIFF_VARIABLE2); + assert(o->field_passcount==1); + TIFFGetField(tif,o->field_tag,&pa,&pb); + if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,o->field_tag,pa,pb)) + goto bad; + } + break; + default: + assert(0); /* we should never get here */ + break; + } + } + } + } + } + for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++) + { + switch (tif->tif_dir.td_customValues[m].info->field_type) + { + case TIFF_ASCII: + if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_UNDEFINED: + if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_BYTE: + if (!TIFFWriteDirectoryTagByteArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SBYTE: + if (!TIFFWriteDirectoryTagSbyteArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SHORT: + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SSHORT: + if (!TIFFWriteDirectoryTagSshortArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_LONG: + if (!TIFFWriteDirectoryTagLongArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SLONG: + if (!TIFFWriteDirectoryTagSlongArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_LONG8: + if (!TIFFWriteDirectoryTagLong8Array(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SLONG8: + if (!TIFFWriteDirectoryTagSlong8Array(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_RATIONAL: + if (!TIFFWriteDirectoryTagRationalArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SRATIONAL: + if (!TIFFWriteDirectoryTagSrationalArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_FLOAT: + if (!TIFFWriteDirectoryTagFloatArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_DOUBLE: + if (!TIFFWriteDirectoryTagDoubleArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_IFD: + if (!TIFFWriteDirectoryTagIfdArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_IFD8: + if (!TIFFWriteDirectoryTagIfdIfd8Array(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + default: + assert(0); /* we should never get here */ + break; + } + } + if (dir!=NULL) + break; + dir=_TIFFmalloc(ndir*sizeof(TIFFDirEntry)); + if (dir==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + goto bad; + } + if (isimage) + { + if ((tif->tif_diroff==0)&&(!TIFFLinkDirectory(tif))) + goto bad; + } + else + tif->tif_diroff=(TIFFSeekFile(tif,0,SEEK_END)+1)&(~1); + if (pdiroff!=NULL) + *pdiroff=tif->tif_diroff; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + dirsize=2+ndir*12+4; + else + dirsize=8+ndir*20+8; + tif->tif_dataoff=tif->tif_diroff+dirsize; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + tif->tif_dataoff=(uint32)tif->tif_dataoff; + if ((tif->tif_dataofftif_diroff)||(tif->tif_dataoff<(uint64)dirsize)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded"); + goto bad; + } + if (tif->tif_dataoff&1) + tif->tif_dataoff++; + if (isimage) + tif->tif_curdir++; + } + if (isimage) + { + if (TIFFFieldSet(tif,FIELD_SUBIFD)&&(tif->tif_subifdoff==0)) + { + uint32 na; + TIFFDirEntry* nb; + for (na=0, nb=dir; ; na++, nb++) + { + assert(natdir_tag==TIFFTAG_SUBIFD) + break; + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + tif->tif_subifdoff=tif->tif_diroff+2+na*12+8; + else + tif->tif_subifdoff=tif->tif_diroff+8+na*20+12; + } + } + dirmem=_TIFFmalloc(dirsize); + if (dirmem==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + goto bad; + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint8* n; + uint32 nTmp; + TIFFDirEntry* o; + n=dirmem; + *(uint16*)n=ndir; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + o=dir; + for (m=0; mtdir_tag; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + *(uint16*)n=o->tdir_type; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + nTmp = (uint32)o->tdir_count; + _TIFFmemcpy(n,&nTmp,4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)n); + n+=4; + /* This is correct. The data has been */ + /* swabbed previously in TIFFWriteDirectoryTagData */ + _TIFFmemcpy(n,&o->tdir_offset,4); + n+=4; + o++; + } + nTmp = (uint32)tif->tif_nextdiroff; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nTmp); + _TIFFmemcpy(n,&nTmp,4); + } + else + { + uint8* n; + TIFFDirEntry* o; + n=dirmem; + *(uint64*)n=ndir; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)n); + n+=8; + o=dir; + for (m=0; mtdir_tag; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + *(uint16*)n=o->tdir_type; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + _TIFFmemcpy(n,&o->tdir_count,8); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)n); + n+=8; + _TIFFmemcpy(n,&o->tdir_offset,8); + n+=8; + o++; + } + _TIFFmemcpy(n,&tif->tif_nextdiroff,8); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)n); + } + _TIFFfree(dir); + dir=NULL; + if (!SeekOK(tif,tif->tif_diroff)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory"); + goto bad; + } + if (!WriteOK(tif,dirmem,(tmsize_t)dirsize)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory"); + goto bad; + } + _TIFFfree(dirmem); + if (imagedone) + { + TIFFFreeDirectory(tif); + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + (*tif->tif_cleanup)(tif); + /* + * Reset directory-related state for subsequent + * directories. + */ + TIFFCreateDirectory(tif); + } + return(1); +bad: + if (dir!=NULL) + _TIFFfree(dir); + if (dirmem!=NULL) + _TIFFfree(dirmem); + return(0); +} + +static int +TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +{ + static const char module[] = "TIFFWriteDirectoryTagSampleformatArray"; + void* conv; + uint32 i; + int ok; + conv = _TIFFmalloc(count*sizeof(double)); + if (conv == NULL) + { + TIFFErrorExt(tif->tif_clientdata, module, "Out of memory"); + return (0); + } + + switch (tif->tif_dir.td_sampleformat) + { + case SAMPLEFORMAT_IEEEFP: + if (tif->tif_dir.td_bitspersample<=32) + { + for (i = 0; i < count; ++i) + ((float*)conv)[i] = (float)value[i]; + ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv); + } + else + { + ok = TIFFWriteDirectoryTagDoubleArray(tif,ndir,dir,tag,count,value); + } + break; + case SAMPLEFORMAT_INT: + if (tif->tif_dir.td_bitspersample<=8) + { + for (i = 0; i < count; ++i) + ((int8*)conv)[i] = (int8)value[i]; + ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv); + } + else if (tif->tif_dir.td_bitspersample<=16) + { + for (i = 0; i < count; ++i) + ((int16*)conv)[i] = (int16)value[i]; + ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16*)conv); + } + else + { + for (i = 0; i < count; ++i) + ((int32*)conv)[i] = (int32)value[i]; + ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv); + } + break; + case SAMPLEFORMAT_UINT: + if (tif->tif_dir.td_bitspersample<=8) + { + for (i = 0; i < count; ++i) + ((uint8*)conv)[i] = (uint8)value[i]; + ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv); + } + else if (tif->tif_dir.td_bitspersample<=16) + { + for (i = 0; i < count; ++i) + ((uint16*)conv)[i] = (uint16)value[i]; + ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16*)conv); + } + else + { + for (i = 0; i < count; ++i) + ((uint32*)conv)[i] = (uint32)value[i]; + ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv); + } + break; + default: + ok = 0; + } + + _TIFFfree(conv); + return (ok); +} + +#if 0 +static int +TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + switch (tif->tif_dir.td_sampleformat) + { + case SAMPLEFORMAT_IEEEFP: + if (tif->tif_dir.td_bitspersample<=32) + return(TIFFWriteDirectoryTagFloatPerSample(tif,ndir,dir,tag,(float)value)); + else + return(TIFFWriteDirectoryTagDoublePerSample(tif,ndir,dir,tag,value)); + case SAMPLEFORMAT_INT: + if (tif->tif_dir.td_bitspersample<=8) + return(TIFFWriteDirectoryTagSbytePerSample(tif,ndir,dir,tag,(int8)value)); + else if (tif->tif_dir.td_bitspersample<=16) + return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16)value)); + else + return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32)value)); + case SAMPLEFORMAT_UINT: + if (tif->tif_dir.td_bitspersample<=8) + return(TIFFWriteDirectoryTagBytePerSample(tif,ndir,dir,tag,(uint8)value)); + else if (tif->tif_dir.td_bitspersample<=16) + return(TIFFWriteDirectoryTagShortPerSample(tif,ndir,dir,tag,(uint16)value)); + else + return(TIFFWriteDirectoryTagLongPerSample(tif,ndir,dir,tag,(uint32)value)); + default: + return(1); + } +} +#endif + +static int +TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedAscii(tif,ndir,dir,tag,count,value)); +} + +static int +TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedUndefinedArray(tif,ndir,dir,tag,count,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedByte(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedByteArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int +TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +{ + static const char module[] = "TIFFWriteDirectoryTagBytePerSample"; + uint8* m; + uint8* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint8)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedByteArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int +TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSbyte(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSbyteArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int +TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +{ + static const char module[] = "TIFFWriteDirectoryTagSbytePerSample"; + int8* m; + int8* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int8)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedSbyteArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +static int +TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,value)); +} + +static int +TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,value)); +} + +static int +TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +{ + static const char module[] = "TIFFWriteDirectoryTagShortPerSample"; + uint16* m; + uint16* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint16)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSshort(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSshortArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int +TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +{ + static const char module[] = "TIFFWriteDirectoryTagSshortPerSample"; + int16* m; + int16* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int16)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedSshortArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +static int +TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value)); +} + +static int +TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int +TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +{ + static const char module[] = "TIFFWriteDirectoryTagLongPerSample"; + uint32* m; + uint32* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int +TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlong(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlongArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int +TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +{ + static const char module[] = "TIFFWriteDirectoryTagSlongPerSample"; + int32* m; + int32* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedSlongArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int +TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLong8(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLong8Array(tif,ndir,dir,tag,count,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlong8(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlong8Array(tif,ndir,dir,tag,count,value)); +} + +static int +TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedRational(tif,ndir,dir,tag,value)); +} + +static int +TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedRationalArray(tif,ndir,dir,tag,count,value)); +} + +static int +TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSrationalArray(tif,ndir,dir,tag,count,value)); +} + +#ifdef notdef +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedFloat(tif,ndir,dir,tag,value)); +} +#endif + +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedFloatArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +{ + static const char module[] = "TIFFWriteDirectoryTagFloatPerSample"; + float* m; + float* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(float)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedFloatArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedDouble(tif,ndir,dir,tag,value)); +} +#endif + +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedDoubleArray(tif,ndir,dir,tag,count,value)); +} + +#if 0 +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + static const char module[] = "TIFFWriteDirectoryTagDoublePerSample"; + double* m; + double* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(double)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedDoubleArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +static int +TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,tag,count,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedIfd8Array(tif,ndir,dir,tag,count,value)); +} +#endif + +static int +TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + if (value<=0xFFFF) + return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,(uint16)value)); + else + return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value)); +} + +/************************************************************************/ +/* TIFFWriteDirectoryTagLongLong8Array() */ +/* */ +/* Write out LONG8 array as LONG8 for BigTIFF or LONG for */ +/* Classic TIFF with some checking. */ +/************************************************************************/ + +static int +TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + static const char module[] = "TIFFWriteDirectoryTagLongLong8Array"; + uint64* ma; + uint32 mb; + uint32* p; + uint32* q; + int o; + + /* is this just a counting pass? */ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + + /* We always write LONG8 for BigTIFF, no checking needed. */ + if( tif->tif_flags&TIFF_BIGTIFF ) + return TIFFWriteDirectoryTagCheckedLong8Array(tif,ndir,dir, + tag,count,value); + + /* + ** For classic tiff we want to verify everything is in range for LONG + ** and convert to long format. + */ + + p = _TIFFmalloc(count*sizeof(uint32)); + if (p==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + + for (q=p, ma=value, mb=0; mb0xFFFFFFFF) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file."); + _TIFFfree(p); + return(0); + } + *q= (uint32)(*ma); + } + + o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,p); + _TIFFfree(p); + + return(o); +} + +/************************************************************************/ +/* TIFFWriteDirectoryTagIfdIfd8Array() */ +/* */ +/* Write either IFD8 or IFD array depending on file type. */ +/************************************************************************/ + +static int +TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array"; + uint64* ma; + uint32 mb; + uint32* p; + uint32* q; + int o; + + /* is this just a counting pass? */ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + + /* We always write IFD8 for BigTIFF, no checking needed. */ + if( tif->tif_flags&TIFF_BIGTIFF ) + return TIFFWriteDirectoryTagCheckedIfd8Array(tif,ndir,dir, + tag,count,value); + + /* + ** For classic tiff we want to verify everything is in range for IFD + ** and convert to long format. + */ + + p = _TIFFmalloc(count*sizeof(uint32)); + if (p==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + + for (q=p, ma=value, mb=0; mb0xFFFFFFFF) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file."); + _TIFFfree(p); + return(0); + } + *q= (uint32)(*ma); + } + + o=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,tag,count,p); + _TIFFfree(p); + + return(o); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + static const char module[] = "TIFFWriteDirectoryTagShortLongLong8Array"; + uint64* ma; + uint32 mb; + uint8 n; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + n=0; + for (ma=value, mb=0; mb0xFFFF)) + n=1; + if ((n==1)&&(*ma>0xFFFFFFFF)) + { + n=2; + break; + } + } + if (n==0) + { + uint16* p; + uint16* q; + p=_TIFFmalloc(count*sizeof(uint16)); + if (p==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (ma=value, mb=0, q=p; mbtif_clientdata,module,"Out of memory"); + return(0); + } + for (ma=value, mb=0, q=p; mbtif_dir.td_bitspersample); + n=_TIFFmalloc(3*m*sizeof(uint16)); + if (n==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16)); + _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16)); + _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16)); + o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_COLORMAP,3*m,n); + _TIFFfree(n); + return(o); +} + +static int +TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +{ + static const char module[] = "TIFFWriteDirectoryTagTransferfunction"; + uint32 m; + uint16 n; + uint16* o; + int p; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=(1<tif_dir.td_bitspersample); + n=tif->tif_dir.td_samplesperpixel-tif->tif_dir.td_extrasamples; + /* + * Check if the table can be written as a single column, + * or if it must be written as 3 columns. Note that we + * write a 3-column tag if there are 2 samples/pixel and + * a single column of data won't suffice--hmm. + */ + if (n>3) + n=3; + if (n==3) + { + if (!_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16))) + n=2; + } + if (n==2) + { + if (!_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16))) + n=1; + } + if (n==0) + n=1; + o=_TIFFmalloc(n*m*sizeof(uint16)); + if (o==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + _TIFFmemcpy(&o[0],tif->tif_dir.td_transferfunction[0],m*sizeof(uint16)); + if (n>1) + _TIFFmemcpy(&o[m],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16)); + if (n>2) + _TIFFmemcpy(&o[2*m],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16)); + p=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_TRANSFERFUNCTION,n*m,o); + _TIFFfree(o); + return(p); +} + +static int +TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +{ + static const char module[] = "TIFFWriteDirectoryTagSubifd"; + uint64 m; + int n; + if (tif->tif_dir.td_nsubifd==0) + return(1); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=tif->tif_dataoff; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32* o; + uint64* pa; + uint32* pb; + uint16 p; + o=_TIFFmalloc(tif->tif_dir.td_nsubifd*sizeof(uint32)); + if (o==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + pa=tif->tif_dir.td_subifd; + pb=o; + for (p=0; p < tif->tif_dir.td_nsubifd; p++) + { + assert(pa != 0); + assert(*pa <= 0xFFFFFFFFUL); + *pb++=(uint32)(*pa++); + } + n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o); + _TIFFfree(o); + } + else + n=TIFFWriteDirectoryTagCheckedIfd8Array(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,tif->tif_dir.td_subifd); + if (!n) + return(0); + /* + * Total hack: if this directory includes a SubIFD + * tag then force the next directories to be + * written as ``sub directories'' of this one. This + * is used to write things like thumbnails and + * image masks that one wants to keep out of the + * normal directory linkage access mechanism. + */ + tif->tif_flags|=TIFF_INSUBIFD; + tif->tif_nsubifd=tif->tif_dir.td_nsubifd; + if (tif->tif_dir.td_nsubifd==1) + tif->tif_subifdoff=0; + else + tif->tif_subifdoff=m; + return(1); +} + +static int +TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +{ + assert(sizeof(char)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_ASCII,count,count,value)); +} + +static int +TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +{ + assert(sizeof(uint8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_UNDEFINED,count,count,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +{ + assert(sizeof(uint8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,1,1,&value)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +{ + assert(sizeof(uint8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,count,count,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +{ + assert(sizeof(int8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,1,1,&value)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +{ + assert(sizeof(int8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,count,count,value)); +} + +static int +TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +{ + uint16 m; + assert(sizeof(uint16)==2); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,1,2,&m)); +} + +static int +TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) +{ + assert(count<0x80000000); + assert(sizeof(uint16)==2); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,count,count*2,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +{ + int16 m; + assert(sizeof(int16)==2); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)(&m)); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,1,2,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +{ + assert(count<0x80000000); + assert(sizeof(int16)==2); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort((uint16*)value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,count,count*2,value)); +} + +static int +TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +{ + uint32 m; + assert(sizeof(uint32)==4); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,1,4,&m)); +} + +static int +TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +{ + assert(count<0x40000000); + assert(sizeof(uint32)==4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,count,count*4,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +{ + int32 m; + assert(sizeof(int32)==4); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)(&m)); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,1,4,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +{ + assert(count<0x40000000); + assert(sizeof(int32)==4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,count,count*4,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +{ + uint64 m; + assert(sizeof(uint64)==8); + assert(tif->tif_flags&TIFF_BIGTIFF); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,1,8,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + assert(count<0x20000000); + assert(sizeof(uint64)==8); + assert(tif->tif_flags&TIFF_BIGTIFF); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) +{ + int64 m; + assert(sizeof(int64)==8); + assert(tif->tif_flags&TIFF_BIGTIFF); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)(&m)); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,1,8,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +{ + assert(count<0x20000000); + assert(sizeof(int64)==8); + assert(tif->tif_flags&TIFF_BIGTIFF); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value)); +} + +static int +TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + uint32 m[2]; + assert(value>=0.0); + assert(sizeof(uint32)==4); + if (value<=0.0) + { + m[0]=0; + m[1]=1; + } + else if (value==(double)(uint32)value) + { + m[0]=(uint32)value; + m[1]=1; + } + else if (value<1.0) + { + m[0]=(uint32)(value*0xFFFFFFFF); + m[1]=0xFFFFFFFF; + } + else + { + m[0]=0xFFFFFFFF; + m[1]=(uint32)(0xFFFFFFFF/value); + } + if (tif->tif_flags&TIFF_SWAB) + { + TIFFSwabLong(&m[0]); + TIFFSwabLong(&m[1]); + } + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,1,8,&m[0])); +} + +static int +TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray"; + uint32* m; + float* na; + uint32* nb; + uint32 nc; + int o; + assert(sizeof(uint32)==4); + m=_TIFFmalloc(count*2*sizeof(uint32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=value, nb=m, nc=0; nctif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m,count*2); + o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,count,count*8,&m[0]); + _TIFFfree(m); + return(o); +} + +static int +TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray"; + int32* m; + float* na; + int32* nb; + uint32 nc; + int o; + assert(sizeof(int32)==4); + m=_TIFFmalloc(count*2*sizeof(int32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=value, nb=m, nc=0; nc-1.0) + { + nb[0]=-(int32)((-*na)*0x7FFFFFFF); + nb[1]=0x7FFFFFFF; + } + else + { + nb[0]=-0x7FFFFFFF; + nb[1]=(int32)(0x7FFFFFFF/(-*na)); + } + } + else + { + if (*na==(int32)(*na)) + { + nb[0]=(int32)(*na); + nb[1]=1; + } + else if (*na<1.0) + { + nb[0]=(int32)((*na)*0x7FFFFFFF); + nb[1]=0x7FFFFFFF; + } + else + { + nb[0]=0x7FFFFFFF; + nb[1]=(int32)(0x7FFFFFFF/(*na)); + } + } + } + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)m,count*2); + o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); + _TIFFfree(m); + return(o); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +{ + float m; + assert(sizeof(float)==4); + m=value; + TIFFCvtNativeToIEEEFloat(tif,1,&m); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabFloat(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_FLOAT,1,4,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + assert(count<0x40000000); + assert(sizeof(float)==4); + TIFFCvtNativeToIEEEFloat(tif,count,&value); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfFloat(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_FLOAT,count,count*4,value)); +} + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + double m; + assert(sizeof(double)==8); + m=value; + TIFFCvtNativeToIEEEDouble(tif,1,&m); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabDouble(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_DOUBLE,1,8,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +{ + assert(count<0x20000000); + assert(sizeof(double)==8); + TIFFCvtNativeToIEEEDouble(tif,count,&value); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfDouble(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_DOUBLE,count,count*8,value)); +} + +static int +TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +{ + assert(count<0x40000000); + assert(sizeof(uint32)==4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_IFD,count,count*4,value)); +} + +static int +TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + assert(count<0x20000000); + assert(sizeof(uint64)==8); + assert(tif->tif_flags&TIFF_BIGTIFF); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_IFD8,count,count*8,value)); +} + +static int +TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data) +{ + static const char module[] = "TIFFWriteDirectoryTagData"; + uint32 m; + m=0; + while (m<(*ndir)) + { + assert(dir[m].tdir_tag!=tag); + if (dir[m].tdir_tag>tag) + break; + m++; + } + if (m<(*ndir)) + { + uint32 n; + for (n=*ndir; n>m; n--) + dir[n]=dir[n-1]; + } + dir[m].tdir_tag=tag; + dir[m].tdir_type=datatype; + dir[m].tdir_count=count; + dir[m].tdir_offset.toff_long8 = 0; + if (datalength<=((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U)) + _TIFFmemcpy(&dir[m].tdir_offset,data,datalength); + else + { + uint64 na,nb; + na=tif->tif_dataoff; + nb=na+datalength; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + nb=(uint32)nb; + if ((nbtif_clientdata,module,"Maximum TIFF file size exceeded"); + return(0); + } + if (!SeekOK(tif,na)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data"); + return(0); + } + assert(datalength<0x80000000UL); + if (!WriteOK(tif,data,(tmsize_t)datalength)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data"); + return(0); + } + tif->tif_dataoff=nb; + if (tif->tif_dataoff&1) + tif->tif_dataoff++; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 o; + o=(uint32)na; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&o); + _TIFFmemcpy(&dir[m].tdir_offset,&o,4); + } + else + { + dir[m].tdir_offset.toff_long8 = na; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&dir[m].tdir_offset.toff_long8); + } + } + (*ndir)++; + return(1); +} + +/* + * Link the current directory into the directory chain for the file. + */ +static int +TIFFLinkDirectory(TIFF* tif) +{ + static const char module[] = "TIFFLinkDirectory"; + + tif->tif_diroff = (TIFFSeekFile(tif,0,SEEK_END)+1) &~ 1; + + /* + * Handle SubIFDs + */ + if (tif->tif_flags & TIFF_INSUBIFD) + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 m; + m = (uint32)tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&m); + (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing SubIFD directory link"); + return (0); + } + /* + * Advance to the next SubIFD or, if this is + * the last one configured, revert back to the + * normal directory linkage. + */ + if (--tif->tif_nsubifd) + tif->tif_subifdoff += 4; + else + tif->tif_flags &= ~TIFF_INSUBIFD; + return (1); + } + else + { + uint64 m; + m = tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&m); + (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing SubIFD directory link"); + return (0); + } + /* + * Advance to the next SubIFD or, if this is + * the last one configured, revert back to the + * normal directory linkage. + */ + if (--tif->tif_nsubifd) + tif->tif_subifdoff += 8; + else + tif->tif_flags &= ~TIFF_INSUBIFD; + return (1); + } + } + + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 m; + uint32 nextdir; + m = (uint32)(tif->tif_diroff); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&m); + if (tif->tif_header.classic.tiff_diroff == 0) { + /* + * First directory, overwrite offset in header. + */ + tif->tif_header.classic.tiff_diroff = (uint32) tif->tif_diroff; + (void) TIFFSeekFile(tif,4, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error writing TIFF header"); + return (0); + } + return (1); + } + /* + * Not the first directory, search to the last and append. + */ + nextdir = tif->tif_header.classic.tiff_diroff; + while(1) { + uint16 dircount; + uint32 nextnextdir; + + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount, 2)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextnextdir); + if (nextnextdir==0) + { + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + break; + } + nextdir=nextnextdir; + } + } + else + { + uint64 m; + uint64 nextdir; + m = tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&m); + if (tif->tif_header.big.tiff_diroff == 0) { + /* + * First directory, overwrite offset in header. + */ + tif->tif_header.big.tiff_diroff = tif->tif_diroff; + (void) TIFFSeekFile(tif,8, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error writing TIFF header"); + return (0); + } + return (1); + } + /* + * Not the first directory, search to the last and append. + */ + nextdir = tif->tif_header.big.tiff_diroff; + while(1) { + uint64 dircount64; + uint16 dircount; + uint64 nextnextdir; + + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount64, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on tag count failed, likely corrupt TIFF"); + return (0); + } + dircount=(uint16)dircount64; + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&nextnextdir); + if (nextnextdir==0) + { + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + break; + } + nextdir=nextnextdir; + } + } + return (1); +} + +/************************************************************************/ +/* TIFFRewriteField() */ +/* */ +/* Rewrite a field in the directory on disk without regard to */ +/* updating the TIFF directory structure in memory. Currently */ +/* only supported for field that already exist in the on-disk */ +/* directory. Mainly used for updating stripoffset / */ +/* stripbytecount values after the directory is already on */ +/* disk. */ +/* */ +/* Returns zero on failure, and one on success. */ +/************************************************************************/ + +int +_TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, + tmsize_t count, void* data) +{ + static const char module[] = "TIFFResetField"; + const TIFFField* fip = NULL; + uint16 dircount; + tmsize_t dirsize; + uint8 direntry_raw[20]; + uint16 entry_tag = 0; + uint16 entry_type = 0; + uint64 entry_count = 0; + uint64 entry_offset = 0; + int value_in_entry = 0; + uint64 read_offset; + uint8 *buf_to_write = NULL; + TIFFDataType datatype; + +/* -------------------------------------------------------------------- */ +/* Find field definition. */ +/* -------------------------------------------------------------------- */ + fip = TIFFFindField(tif, tag, TIFF_ANY); + +/* -------------------------------------------------------------------- */ +/* Do some checking this is a straight forward case. */ +/* -------------------------------------------------------------------- */ + if( isMapped(tif) ) + { + TIFFErrorExt( tif->tif_clientdata, module, + "Memory mapped files not currently supported for this operation." ); + return 0; + } + + if( tif->tif_diroff == 0 ) + { + TIFFErrorExt( tif->tif_clientdata, module, + "Attempt to reset field on directory not already on disk." ); + return 0; + } + +/* -------------------------------------------------------------------- */ +/* Read the directory entry count. */ +/* -------------------------------------------------------------------- */ + if (!SeekOK(tif, tif->tif_diroff)) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); + return 0; + } + + read_offset = tif->tif_diroff; + + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (!ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); + return 0; + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + dirsize = 12; + read_offset += 2; + } else { + uint64 dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); + return 0; + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + dircount = (uint16)dircount64; + dirsize = 20; + read_offset += 8; + } + +/* -------------------------------------------------------------------- */ +/* Read through directory to find target tag. */ +/* -------------------------------------------------------------------- */ + while( dircount > 0 ) + { + if (!ReadOK(tif, direntry_raw, dirsize)) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory entry.", + tif->tif_name); + return 0; + } + + memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort( &entry_tag ); + + if( entry_tag == tag ) + break; + + read_offset += dirsize; + } + + if( entry_tag != tag ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Could not find tag %d.", + tif->tif_name, tag ); + return 0; + } + +/* -------------------------------------------------------------------- */ +/* Extract the type, count and offset for this entry. */ +/* -------------------------------------------------------------------- */ + memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort( &entry_type ); + + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 value; + + memcpy( &value, direntry_raw + 4, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( &value ); + entry_count = value; + + memcpy( &value, direntry_raw + 8, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( &value ); + entry_offset = value; + } + else + { + memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( &entry_count ); + + memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( &entry_offset ); + } + +/* -------------------------------------------------------------------- */ +/* What data type do we want to write this as? */ +/* -------------------------------------------------------------------- */ + if( TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags&TIFF_BIGTIFF) ) + { + if( in_datatype == TIFF_LONG8 ) + datatype = TIFF_LONG; + else if( in_datatype == TIFF_SLONG8 ) + datatype = TIFF_SLONG; + else if( in_datatype == TIFF_IFD8 ) + datatype = TIFF_IFD; + else + datatype = in_datatype; + } + else + datatype = in_datatype; + +/* -------------------------------------------------------------------- */ +/* Prepare buffer of actual data to write. This includes */ +/* swabbing as needed. */ +/* -------------------------------------------------------------------- */ + buf_to_write = + (uint8 *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype), + "for field buffer."); + if (!buf_to_write) + return 0; + + if( datatype == in_datatype ) + memcpy( buf_to_write, data, count * TIFFDataWidth(datatype) ); + else if( datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8 ) + { + tmsize_t i; + + for( i = 0; i < count; i++ ) + { + ((int32 *) buf_to_write)[i] = + (int32) ((int64 *) data)[i]; + if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] ) + { + _TIFFfree( buf_to_write ); + TIFFErrorExt( tif->tif_clientdata, module, + "Value exceeds 32bit range of output type." ); + return 0; + } + } + } + else if( (datatype == TIFF_LONG && in_datatype == TIFF_LONG8) + || (datatype == TIFF_IFD && in_datatype == TIFF_IFD8) ) + { + tmsize_t i; + + for( i = 0; i < count; i++ ) + { + ((uint32 *) buf_to_write)[i] = + (uint32) ((uint64 *) data)[i]; + if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] ) + { + _TIFFfree( buf_to_write ); + TIFFErrorExt( tif->tif_clientdata, module, + "Value exceeds 32bit range of output type." ); + return 0; + } + } + } + + if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) ) + { + if( TIFFDataWidth(datatype) == 2 ) + TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count ); + else if( TIFFDataWidth(datatype) == 4 ) + TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count ); + else if( TIFFDataWidth(datatype) == 8 ) + TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count ); + } + +/* -------------------------------------------------------------------- */ +/* Is this a value that fits into the directory entry? */ +/* -------------------------------------------------------------------- */ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if( TIFFDataWidth(datatype) * count <= 4 ) + { + entry_offset = read_offset + 8; + value_in_entry = 1; + } + } + else + { + if( TIFFDataWidth(datatype) * count <= 8 ) + { + entry_offset = read_offset + 12; + value_in_entry = 1; + } + } + +/* -------------------------------------------------------------------- */ +/* If the tag type, and count match, then we just write it out */ +/* over the old values without altering the directory entry at */ +/* all. */ +/* -------------------------------------------------------------------- */ + if( entry_count == (uint64)count && entry_type == (uint16) datatype ) + { + if (!SeekOK(tif, entry_offset)) { + _TIFFfree( buf_to_write ); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); + return 0; + } + if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { + _TIFFfree( buf_to_write ); + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + + _TIFFfree( buf_to_write ); + return 1; + } + +/* -------------------------------------------------------------------- */ +/* Otherwise, we write the new tag data at the end of the file. */ +/* -------------------------------------------------------------------- */ + if( !value_in_entry ) + { + entry_offset = TIFFSeekFile(tif,0,SEEK_END); + + if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { + _TIFFfree( buf_to_write ); + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + + _TIFFfree( buf_to_write ); + } + else + { + memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype)); + } + +/* -------------------------------------------------------------------- */ +/* Adjust the directory entry. */ +/* -------------------------------------------------------------------- */ + entry_type = datatype; + memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); + + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 value; + + value = (uint32) entry_count; + memcpy( direntry_raw + 4, &value, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( (uint32 *) (direntry_raw + 4) ); + + value = (uint32) entry_offset; + memcpy( direntry_raw + 8, &value, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( (uint32 *) (direntry_raw + 8) ); + } + else + { + memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( (uint64 *) (direntry_raw + 4) ); + + memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( (uint64 *) (direntry_raw + 12) ); + } + +/* -------------------------------------------------------------------- */ +/* Write the directory entry out to disk. */ +/* -------------------------------------------------------------------- */ + if (!SeekOK(tif, read_offset )) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); + return 0; + } + + if (!WriteOK(tif, direntry_raw,dirsize)) + { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not write TIFF directory entry.", + tif->tif_name); + return 0; + } + + return 1; +} +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_dumpmode.c b/libs/tiff-4.0.2/libtiff/tif_dumpmode.c similarity index 70% rename from libs/tiff-3.8.2/libtiff/tif_dumpmode.c rename to libs/tiff-4.0.2/libtiff/tif_dumpmode.c index fb21ffe2fd..a94cf0b34a 100644 --- a/libs/tiff-3.8.2/libtiff/tif_dumpmode.c +++ b/libs/tiff-4.0.2/libtiff/tif_dumpmode.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.4 2005/12/21 12:23:13 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.14 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -31,22 +31,29 @@ */ #include "tiffiop.h" +static int +DumpFixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} + /* * Encode a hunk of pixels. */ static int -DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { (void) s; while (cc > 0) { - tsize_t n; + tmsize_t n; n = cc; if (tif->tif_rawcc + n > tif->tif_rawdatasize) n = tif->tif_rawdatasize - tif->tif_rawcc; - assert( n > 0 ); - + assert( n > 0 ); + /* * Avoid copy if client has setup raw * data buffer to avoid extra copy. @@ -68,13 +75,24 @@ DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) * Decode a hunk of pixels. */ static int -DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { + static const char module[] = "DumpModeDecode"; (void) s; if (tif->tif_rawcc < cc) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "DumpModeDecode: Not enough data for scanline %d", - tif->tif_row); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, +"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes", + (unsigned long) tif->tif_row, + (signed __int64) tif->tif_rawcc, + (signed __int64) cc); +#else + TIFFErrorExt(tif->tif_clientdata, module, +"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes", + (unsigned long) tif->tif_row, + (signed long long) tif->tif_rawcc, + (signed long long) cc); +#endif return (0); } /* @@ -84,7 +102,7 @@ DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) if (tif->tif_rawcp != buf) _TIFFmemcpy(buf, tif->tif_rawcp, cc); tif->tif_rawcp += cc; - tif->tif_rawcc -= cc; + tif->tif_rawcc -= cc; return (1); } @@ -106,12 +124,20 @@ int TIFFInitDumpMode(TIFF* tif, int scheme) { (void) scheme; + tif->tif_fixuptags = DumpFixupTags; tif->tif_decoderow = DumpModeDecode; tif->tif_decodestrip = DumpModeDecode; tif->tif_decodetile = DumpModeDecode; tif->tif_encoderow = DumpModeEncode; tif->tif_encodestrip = DumpModeEncode; - tif->tif_encodetile = DumpModeEncode; + tif->tif_encodetile = DumpModeEncode; tif->tif_seek = DumpModeSeek; return (1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_error.c b/libs/tiff-4.0.2/libtiff/tif_error.c similarity index 94% rename from libs/tiff-3.8.2/libtiff/tif_error.c rename to libs/tiff-4.0.2/libtiff/tif_error.c index 7025080ed3..0bc8b878bd 100644 --- a/libs/tiff-3.8.2/libtiff/tif_error.c +++ b/libs/tiff-4.0.2/libtiff/tif_error.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.4 2005/12/23 01:18:59 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.5 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -71,3 +71,10 @@ TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...) va_end(ap); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_extension.c b/libs/tiff-4.0.2/libtiff/tif_extension.c similarity index 91% rename from libs/tiff-3.8.2/libtiff/tif_extension.c rename to libs/tiff-4.0.2/libtiff/tif_extension.c index 6861522285..10afd4162c 100644 --- a/libs/tiff-3.8.2/libtiff/tif_extension.c +++ b/libs/tiff-4.0.2/libtiff/tif_extension.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.4 2004/10/02 13:29:41 dron Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.7 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -41,13 +41,13 @@ int TIFFGetTagListCount( TIFF *tif ) return td->td_customValueCount; } -ttag_t TIFFGetTagListEntry( TIFF *tif, int tag_index ) +uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index ) { TIFFDirectory* td = &tif->tif_dir; if( tag_index < 0 || tag_index >= td->td_customValueCount ) - return (ttag_t) -1; + return (uint32)(-1); else return td->td_customValues[tag_index].info->field_tag; } @@ -102,10 +102,17 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name ) link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink)); assert (link != NULL); link->next = tif->tif_clientinfo; - link->name = (char *) _TIFFmalloc(strlen(name)+1); + link->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1)); assert (link->name != NULL); strcpy(link->name, name); link->data = data; tif->tif_clientinfo = link; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_fax3.c b/libs/tiff-4.0.2/libtiff/tif_fax3.c similarity index 82% rename from libs/tiff-3.8.2/libtiff/tif_fax3.c rename to libs/tiff-4.0.2/libtiff/tif_fax3.c index 679a7281f8..15b1710858 100644 --- a/libs/tiff-3.8.2/libtiff/tif_fax3.c +++ b/libs/tiff-4.0.2/libtiff/tif_fax3.c @@ -1,4 +1,4 @@ -/* $Id: tif_fax3.c,v 1.40 2006/03/16 12:38:24 dron Exp $ */ +/* $Id: tif_fax3.c,v 1.73 2012-06-13 00:27:20 fwarmerdam Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -48,21 +48,19 @@ * derived from this ``base state'' block. */ typedef struct { - int rw_mode; /* O_RDONLY for decode, else encode */ - int mode; /* operating mode */ - uint32 rowbytes; /* bytes in a decoded scanline */ - uint32 rowpixels; /* pixels in a scanline */ + int rw_mode; /* O_RDONLY for decode, else encode */ + int mode; /* operating mode */ + tmsize_t rowbytes; /* bytes in a decoded scanline */ + uint32 rowpixels; /* pixels in a scanline */ - uint16 cleanfaxdata; /* CleanFaxData tag */ - uint32 badfaxrun; /* BadFaxRun tag */ - uint32 badfaxlines; /* BadFaxLines tag */ - uint32 groupoptions; /* Group 3/4 options tag */ - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spent receiving (secs) */ - char* faxdcs; /* Table 2/T.30 encoded session params */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + uint16 cleanfaxdata; /* CleanFaxData tag */ + uint32 badfaxrun; /* BadFaxRun tag */ + uint32 badfaxlines; /* BadFaxLines tag */ + uint32 groupoptions; /* Group 3/4 options tag */ + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ } Fax3BaseState; #define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data) @@ -88,12 +86,11 @@ typedef struct { int line; } Fax3CodecState; -#define DecoderState(tif) ((Fax3CodecState*) Fax3State(tif)) -#define EncoderState(tif) ((Fax3CodecState*) Fax3State(tif)) +#define DecoderState(tif) ((Fax3CodecState*) Fax3State(tif)) +#define EncoderState(tif) ((Fax3CodecState*) Fax3State(tif)) -#define is2DEncoding(sp) \ - (sp->b.groupoptions & GROUP3OPT_2DENCODING) -#define isAligned(p,t) ((((unsigned long)(p)) & (sizeof (t)-1)) == 0) +#define is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING) +#define isAligned(p,t) ((((size_t)(p)) & (sizeof (t)-1)) == 0) /* * Group 3 and Group 4 Decoding. @@ -139,15 +136,15 @@ typedef struct { sp->bit = BitsAvail; \ sp->data = BitAcc; \ sp->EOLcnt = EOLcnt; \ - tif->tif_rawcc -= (tidata_t) cp - tif->tif_rawcp; \ - tif->tif_rawcp = (tidata_t) cp; \ + tif->tif_rawcc -= (tmsize_t)((uint8*) cp - tif->tif_rawcp); \ + tif->tif_rawcp = (uint8*) cp; \ } while (0) /* * Setup state for decoding a strip. */ static int -Fax3PreDecode(TIFF* tif, tsample_t s) +Fax3PreDecode(TIFF* tif, uint16 s) { Fax3CodecState* sp = DecoderState(tif); @@ -182,10 +179,10 @@ Fax3PreDecode(TIFF* tif, tsample_t s) static void Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad code word at line %lu of %s %lu (x %lu)", - tif->tif_name, (unsigned long) line, isTiled(tif) ? "tile" : "strip", - (unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - (unsigned long) a0); + TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %u of %s %u (x %u)", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0); } #define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0) @@ -193,33 +190,31 @@ static void Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Uncompressed data (not supported) at line %lu of %s %lu (x %lu)", - tif->tif_name, (unsigned long) line, isTiled(tif) ? "tile" : "strip", - (unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - (unsigned long) a0); + "Uncompressed data (not supported) at line %u of %s %u (x %u)", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0); } #define extension(a0) Fax3Extension(module, tif, sp->line, a0) static void Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 lastx) { - TIFFWarningExt(tif->tif_clientdata, module, "%s: %s at line %lu of %s %lu (got %lu, expected %lu)", - tif->tif_name, + TIFFWarningExt(tif->tif_clientdata, module, "%s at line %u of %s %u (got %u, expected %u)", a0 < lastx ? "Premature EOL" : "Line length mismatch", - (unsigned long) line, isTiled(tif) ? "tile" : "strip", - (unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - (unsigned long) a0, lastx); + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0, lastx); } #define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx) static void Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) { - TIFFWarningExt(tif->tif_clientdata, module, "%s: Premature EOF at line %lu of %s %lu (x %lu)", - tif->tif_name, - (unsigned long) line, isTiled(tif) ? "tile" : "strip", - (unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), - (unsigned long) a0); + TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %u of %s %u (x %u)", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0); } #define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0) @@ -229,14 +224,18 @@ Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) * Decode the requested amount of G3 1D-encoded data. */ static int -Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { DECLARE_STATE(tif, sp, "Fax3Decode1D"); - (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } CACHE_STATE(tif, sp); thisrun = sp->curruns; - while ((long)occ > 0) { + while (occ > 0) { a0 = 0; RunLength = 0; pa = thisrun; @@ -268,14 +267,18 @@ Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) * Decode the requested amount of G3 2D-encoded data. */ static int -Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); int is1D; /* current line is 1d/2d-encoded */ - (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } CACHE_STATE(tif, sp); - while ((long)occ > 0) { + while (occ > 0) { a0 = 0; RunLength = 0; pa = thisrun = sp->curruns; @@ -323,7 +326,7 @@ Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) * this is <8 bytes. We optimize the code here to reflect the * machine characteristics. */ -#if SIZEOF_LONG == 8 +#if SIZEOF_UNSIGNED_LONG == 8 # define FILL(n, cp) \ switch (n) { \ case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\ @@ -451,6 +454,13 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) #undef ZERO #undef FILL +static int +Fax3FixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} + /* * Setup G3/G4-related compression/decompression state * before data is processed. This routine is called once @@ -461,14 +471,16 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) static int Fax3SetupState(TIFF* tif) { + static const char module[] = "Fax3SetupState"; TIFFDirectory* td = &tif->tif_dir; Fax3BaseState* sp = Fax3State(tif); int needsRefLine; Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif); - uint32 rowbytes, rowpixels, nruns; + tmsize_t rowbytes; + uint32 rowpixels, nruns; if (td->td_bitspersample != 1) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "Bits/sample must be 1 for Group 3/4 encoding/decoding"); return (0); } @@ -482,8 +494,8 @@ Fax3SetupState(TIFF* tif) rowbytes = TIFFScanlineSize(tif); rowpixels = td->td_imagewidth; } - sp->rowbytes = (uint32) rowbytes; - sp->rowpixels = (uint32) rowpixels; + sp->rowbytes = rowbytes; + sp->rowpixels = rowpixels; /* * Allocate any additional space required for decoding/encoding. */ @@ -492,12 +504,29 @@ Fax3SetupState(TIFF* tif) td->td_compression == COMPRESSION_CCITTFAX4 ); - nruns = needsRefLine ? 2*TIFFroundup(rowpixels,32) : rowpixels; - nruns += 3; - dsp->runs = (uint32*) _TIFFCheckMalloc(tif, 2*nruns, sizeof (uint32), - "for Group 3/4 run arrays"); + /* + Assure that allocation computations do not overflow. + + TIFFroundup and TIFFSafeMultiply return zero on integer overflow + */ + dsp->runs=(uint32*) NULL; + nruns = TIFFroundup_32(rowpixels,32); + if (needsRefLine) { + nruns = TIFFSafeMultiply(uint32,nruns,2); + } + if ((nruns == 0) || (TIFFSafeMultiply(uint32,nruns,2) == 0)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Row pixels integer overflow (rowpixels %u)", + rowpixels); + return (0); + } + dsp->runs = (uint32*) _TIFFCheckMalloc(tif, + TIFFSafeMultiply(uint32,nruns,2), + sizeof (uint32), + "for Group 3/4 run arrays"); if (dsp->runs == NULL) return (0); + memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2)); dsp->curruns = dsp->runs; if (needsRefLine) dsp->refruns = dsp->runs + nruns; @@ -521,9 +550,8 @@ Fax3SetupState(TIFF* tif) */ esp->refline = (unsigned char*) _TIFFmalloc(rowbytes); if (esp->refline == NULL) { - TIFFErrorExt(tif->tif_clientdata, "Fax3SetupState", - "%s: No space for Group 3/4 reference line", - tif->tif_name); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for Group 3/4 reference line"); return (0); } } else /* 1d encoding */ @@ -539,14 +567,14 @@ Fax3SetupState(TIFF* tif) #define Fax3FlushBits(tif, sp) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ - *(tif)->tif_rawcp++ = (tidataval_t) (sp)->data; \ + *(tif)->tif_rawcp++ = (uint8) (sp)->data; \ (tif)->tif_rawcc++; \ (sp)->data = 0, (sp)->bit = 8; \ } #define _FlushBits(tif) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ - *(tif)->tif_rawcp++ = (tidataval_t) data; \ + *(tif)->tif_rawcp++ = (uint8) data; \ (tif)->tif_rawcc++; \ data = 0, bit = 8; \ } @@ -558,6 +586,7 @@ static const int _msbmask[9] = length -= bit; \ _FlushBits(tif); \ } \ + assert( length < 9 ); \ data |= (bits & _msbmask[length]) << (bit - length); \ bit -= length; \ if (bit == 0) \ @@ -685,7 +714,7 @@ Fax3PutEOL(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -Fax3PreEncode(TIFF* tif, tsample_t s) +Fax3PreEncode(TIFF* tif, uint16 s) { Fax3CodecState* sp = EncoderState(tif); @@ -1006,12 +1035,17 @@ Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) * Encode a buffer of pixels. */ static int -Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +Fax3Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { + static const char module[] = "Fax3Encode"; Fax3CodecState* sp = EncoderState(tif); - (void) s; - while ((long)cc > 0) { + if (cc % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be written"); + return (0); + } + while (cc > 0) { if ((sp->b.mode & FAXMODE_NOEOL) == 0) Fax3PutEOL(tif); if (is2DEncoding(sp)) { @@ -1021,7 +1055,7 @@ Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) sp->tag = G3_2D; } else { if (!Fax3Encode2DRow(tif, bp, sp->refline, - sp->b.rowpixels)) + sp->b.rowpixels)) return (0); sp->k--; } @@ -1076,14 +1110,13 @@ Fax3Cleanup(TIFF* tif) tif->tif_tagmethods.vgetfield = sp->b.vgetparent; tif->tif_tagmethods.vsetfield = sp->b.vsetparent; + tif->tif_tagmethods.printdir = sp->b.printdir; if (sp->runs) _TIFFfree(sp->runs); if (sp->refline) _TIFFfree(sp->refline); - if (Fax3State(tif)->subaddress) - _TIFFfree(Fax3State(tif)->subaddress); _TIFFfree(tif->tif_data); tif->tif_data = NULL; @@ -1093,106 +1126,77 @@ Fax3Cleanup(TIFF* tif) #define FIELD_BADFAXLINES (FIELD_CODEC+0) #define FIELD_CLEANFAXDATA (FIELD_CODEC+1) #define FIELD_BADFAXRUN (FIELD_CODEC+2) -#define FIELD_RECVPARAMS (FIELD_CODEC+3) -#define FIELD_SUBADDRESS (FIELD_CODEC+4) -#define FIELD_RECVTIME (FIELD_CODEC+5) -#define FIELD_FAXDCS (FIELD_CODEC+6) #define FIELD_OPTIONS (FIELD_CODEC+7) -static const TIFFFieldInfo faxFieldInfo[] = { - { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxMode" }, - { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxFillFunc" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, - TRUE, FALSE, "CleanFaxData" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, - TRUE, FALSE, "FaxRecvParams" }, - { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, - TRUE, FALSE, "FaxSubAddress" }, - { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, - TRUE, FALSE, "FaxRecvTime" }, - { TIFFTAG_FAXDCS, -1,-1, TIFF_ASCII, FIELD_FAXDCS, - TRUE, FALSE, "FaxDcs" }, +static const TIFFField faxFields[] = { + { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "FaxMode", NULL }, + { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "FaxFillFunc", NULL }, + { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines", NULL }, + { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UINT16, FIELD_CLEANFAXDATA, TRUE, FALSE, "CleanFaxData", NULL }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_BADFAXRUN, TRUE, FALSE, "ConsecutiveBadFaxLines", NULL }}; +static const TIFFField fax3Fields[] = { + { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group3Options", NULL }, }; -static const TIFFFieldInfo fax3FieldInfo[] = { - { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group3Options" }, +static const TIFFField fax4Fields[] = { + { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group4Options", NULL }, }; -static const TIFFFieldInfo fax4FieldInfo[] = { - { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group4Options" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) static int -Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap) +Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); + const TIFFField* fip; assert(sp != 0); assert(sp->vsetparent != 0); switch (tag) { case TIFFTAG_FAXMODE: - sp->mode = va_arg(ap, int); - return (1); /* NB: pseudo tag */ + sp->mode = (int) va_arg(ap, int); + return 1; /* NB: pseudo tag */ case TIFFTAG_FAXFILLFUNC: DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); - return (1); /* NB: pseudo tag */ + return 1; /* NB: pseudo tag */ case TIFFTAG_GROUP3OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) - sp->groupoptions = va_arg(ap, uint32); + sp->groupoptions = (uint32) va_arg(ap, uint32); break; case TIFFTAG_GROUP4OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) - sp->groupoptions = va_arg(ap, uint32); + sp->groupoptions = (uint32) va_arg(ap, uint32); break; case TIFFTAG_BADFAXLINES: - sp->badfaxlines = va_arg(ap, uint32); + sp->badfaxlines = (uint32) va_arg(ap, uint32); break; case TIFFTAG_CLEANFAXDATA: - sp->cleanfaxdata = (uint16) va_arg(ap, int); + sp->cleanfaxdata = (uint16) va_arg(ap, uint16_vap); break; case TIFFTAG_CONSECUTIVEBADFAXLINES: - sp->badfaxrun = va_arg(ap, uint32); - break; - case TIFFTAG_FAXRECVPARAMS: - sp->recvparams = va_arg(ap, uint32); - break; - case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&sp->subaddress, va_arg(ap, char*)); - break; - case TIFFTAG_FAXRECVTIME: - sp->recvtime = va_arg(ap, uint32); - break; - case TIFFTAG_FAXDCS: - _TIFFsetString(&sp->faxdcs, va_arg(ap, char*)); + sp->badfaxrun = (uint32) va_arg(ap, uint32); break; default: return (*sp->vsetparent)(tif, tag, ap); } - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); + + if ((fip = TIFFFieldWithTag(tif, tag))) + TIFFSetFieldBit(tif, fip->field_bit); + else + return 0; + tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); + return 1; } static int -Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap) +Fax3VGetField(TIFF* tif, uint32 tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); + assert(sp != 0); + switch (tag) { case TIFFTAG_FAXMODE: *va_arg(ap, int*) = sp->mode; @@ -1213,18 +1217,6 @@ Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap) case TIFFTAG_CONSECUTIVEBADFAXLINES: *va_arg(ap, uint32*) = sp->badfaxrun; break; - case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = sp->recvparams; - break; - case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = sp->subaddress; - break; - case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = sp->recvtime; - break; - case TIFFTAG_FAXDCS: - *va_arg(ap, char**) = sp->faxdcs; - break; default: return (*sp->vgetparent)(tif, tag, ap); } @@ -1236,6 +1228,8 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) { Fax3BaseState* sp = Fax3State(tif); + assert(sp != 0); + (void) flags; if (TIFFFieldSet(tif,FIELD_OPTIONS)) { const char* sep = " "; @@ -1279,32 +1273,34 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", (unsigned long) sp->badfaxrun); - if (TIFFFieldSet(tif,FIELD_RECVPARAMS)) - fprintf(fd, " Fax Receive Parameters: %08lx\n", - (unsigned long) sp->recvparams); - if (TIFFFieldSet(tif,FIELD_SUBADDRESS)) - fprintf(fd, " Fax SubAddress: %s\n", sp->subaddress); - if (TIFFFieldSet(tif,FIELD_RECVTIME)) - fprintf(fd, " Fax Receive Time: %lu secs\n", - (unsigned long) sp->recvtime); - if (TIFFFieldSet(tif,FIELD_FAXDCS)) - fprintf(fd, " Fax DCS: %s\n", sp->faxdcs); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); } static int InitCCITTFax3(TIFF* tif) { + static const char module[] = "InitCCITTFax3"; Fax3BaseState* sp; + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, faxFields, TIFFArrayCount(faxFields))) { + TIFFErrorExt(tif->tif_clientdata, "InitCCITTFax3", + "Merging common CCITT Fax codec-specific tags failed"); + return 0; + } + /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (tidata_t) + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (Fax3CodecState)); if (tif->tif_data == NULL) { - TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax3", - "%s: No space for state block", tif->tif_name); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for state block"); return (0); } @@ -1312,19 +1308,15 @@ InitCCITTFax3(TIFF* tif) sp->rw_mode = tif->tif_mode; /* - * Merge codec-specific tag information and - * override parent get/set field methods. + * Override parent get/set field methods. */ - _TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo)); sp->vgetparent = tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_tagmethods.vsetfield; tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */ + sp->printdir = tif->tif_tagmethods.printdir; tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */ sp->groupoptions = 0; - sp->recvparams = 0; - sp->subaddress = NULL; - sp->faxdcs = NULL; if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */ tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */ @@ -1335,6 +1327,7 @@ InitCCITTFax3(TIFF* tif) /* * Install codec methods. */ + tif->tif_fixuptags = Fax3FixupTags; tif->tif_setupdecode = Fax3SetupState; tif->tif_predecode = Fax3PreDecode; tif->tif_decoderow = Fax3Decode1D; @@ -1357,14 +1350,22 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) { (void) scheme; if (InitCCITTFax3(tif)) { - _TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo)); + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, fax3Fields, + TIFFArrayCount(fax3Fields))) { + TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax3", + "Merging CCITT Fax 3 codec-specific tags failed"); + return 0; + } /* * The default format is Class/F-style w/o RTC. */ return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); } else - return (0); + return 01; } /* @@ -1372,18 +1373,22 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) * Compression Scheme Support. */ -#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } +#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } /* * Decode the requested amount of G4-encoded data. */ static int -Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { DECLARE_STATE_2D(tif, sp, "Fax4Decode"); - (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } CACHE_STATE(tif, sp); - while ((long)occ > 0) { + while (occ > 0) { a0 = 0; RunLength = 0; pa = thisrun = sp->curruns; @@ -1409,12 +1414,12 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) BADG4: #ifdef FAX3_DEBUG if( GetBits(13) != 0x1001 ) - fputs( "Bad RTC\n", stderr ); + fputs( "Bad EOFB\n", stderr ); #endif ClrBits( 13 ); (*sp->fill)(buf, thisrun, pa, lastx); UNCACHE_STATE(tif, sp); - return (-1); + return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */ } UNCACHE_STATE(tif, sp); return (1); @@ -1425,12 +1430,17 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) * Encode the requested amount of data. */ static int -Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +Fax4Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { + static const char module[] = "Fax4Encode"; Fax3CodecState *sp = EncoderState(tif); - (void) s; - while ((long)cc > 0) { + if (cc % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be written"); + return (0); + } + while (cc > 0) { if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) return (0); _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); @@ -1458,7 +1468,15 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme) { (void) scheme; if (InitCCITTFax3(tif)) { /* reuse G3 support */ - _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, fax4Fields, + TIFFArrayCount(fax4Fields))) { + TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax4", + "Merging CCITT Fax 4 codec-specific tags failed"); + return 0; + } tif->tif_decoderow = Fax4Decode; tif->tif_decodestrip = Fax4Decode; @@ -1484,15 +1502,19 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme) * Decode the requested amount of RLE-encoded data. */ static int -Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); int mode = sp->b.mode; - (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } CACHE_STATE(tif, sp); thisrun = sp->curruns; - while ((long)occ > 0) { + while (occ > 0) { a0 = 0; RunLength = 0; pa = thisrun; @@ -1552,7 +1574,7 @@ TIFFInitCCITTRLEW(TIFF* tif, int scheme) if (InitCCITTFax3(tif)) { /* reuse G3 support */ tif->tif_decoderow = Fax3DecodeRLE; tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; + tif->tif_decodetile = Fax3DecodeRLE; /* * Suppress RTC+EOLs when encoding and word-align data. */ @@ -1564,3 +1586,10 @@ TIFFInitCCITTRLEW(TIFF* tif, int scheme) #endif /* CCITT_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_fax3.h b/libs/tiff-4.0.2/libtiff/tif_fax3.h similarity index 93% rename from libs/tiff-3.8.2/libtiff/tif_fax3.h rename to libs/tiff-4.0.2/libtiff/tif_fax3.h index 030632f80a..b0f46c9a43 100644 --- a/libs/tiff-3.8.2/libtiff/tif_fax3.h +++ b/libs/tiff-4.0.2/libtiff/tif_fax3.h @@ -1,4 +1,4 @@ -/* $Id: tif_fax3.h,v 1.5 2005/12/12 09:23:11 dron Exp $ */ +/* $Id: tif_fax3.h,v 1.9 2011-03-10 20:23:07 fwarmerdam Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -52,7 +52,7 @@ * data in the run array as needed (e.g. to append zero runs to bring * the count up to a nice multiple). */ -typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); +typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); /* * The default run filler; made external for other decoders. @@ -60,36 +60,36 @@ typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); #if defined(__cplusplus) extern "C" { #endif -extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); +extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); #if defined(__cplusplus) } #endif /* finite state machine codes */ -#define S_Null 0 -#define S_Pass 1 -#define S_Horiz 2 -#define S_V0 3 -#define S_VR 4 -#define S_VL 5 -#define S_Ext 6 -#define S_TermW 7 -#define S_TermB 8 -#define S_MakeUpW 9 -#define S_MakeUpB 10 -#define S_MakeUp 11 -#define S_EOL 12 +#define S_Null 0 +#define S_Pass 1 +#define S_Horiz 2 +#define S_V0 3 +#define S_VR 4 +#define S_VL 5 +#define S_Ext 6 +#define S_TermW 7 +#define S_TermB 8 +#define S_MakeUpW 9 +#define S_MakeUpB 10 +#define S_MakeUp 11 +#define S_EOL 12 -typedef struct { /* state table entry */ - unsigned char State; /* see above */ - unsigned char Width; /* width of code in bits */ - uint32 Param; /* unsigned 32-bit run length in bits */ +typedef struct { /* state table entry */ + unsigned char State; /* see above */ + unsigned char Width; /* width of code in bits */ + uint32 Param; /* unsigned 32-bit run length in bits */ } TIFFFaxTabEnt; -extern const TIFFFaxTabEnt TIFFFaxMainTable[]; -extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; -extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; +extern const TIFFFaxTabEnt TIFFFaxMainTable[]; +extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; +extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; /* * The following macros define the majority of the G3/G4 decoder @@ -478,6 +478,12 @@ done1d: \ break; \ case S_VL: \ CHECK_b1; \ + if (b1 <= (int) (a0 + TabEnt->Param)) { \ + if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) { \ + unexpected("VL", a0); \ + goto eol2d; \ + } \ + } \ SETVALUE(b1 - a0 - TabEnt->Param); \ b1 -= *--pb; \ break; \ @@ -523,3 +529,10 @@ eol2d: \ CLEANUP_RUNS(); \ } while (0) #endif /* _FAX3_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_fax3sm.c b/libs/tiff-4.0.2/libtiff/tif_fax3sm.c similarity index 99% rename from libs/tiff-3.8.2/libtiff/tif_fax3sm.c rename to libs/tiff-4.0.2/libtiff/tif_fax3sm.c index 08ce1ad608..822191ecf4 100644 --- a/libs/tiff-3.8.2/libtiff/tif_fax3sm.c +++ b/libs/tiff-4.0.2/libtiff/tif_fax3sm.c @@ -1251,3 +1251,10 @@ {8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, {8,3,4},{8,2,2} }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_flush.c b/libs/tiff-4.0.2/libtiff/tif_flush.c new file mode 100644 index 0000000000..fd14e4cdae --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_flush.c @@ -0,0 +1,118 @@ +/* $Id: tif_flush.c,v 1.9 2010-03-31 06:40:10 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + */ +#include "tiffiop.h" + +int +TIFFFlush(TIFF* tif) +{ + if( tif->tif_mode == O_RDONLY ) + return 1; + + if (!TIFFFlushData(tif)) + return (0); + + /* In update (r+) mode we try to detect the case where + only the strip/tile map has been altered, and we try to + rewrite only that portion of the directory without + making any other changes */ + + if( (tif->tif_flags & TIFF_DIRTYSTRIP) + && !(tif->tif_flags & TIFF_DIRTYDIRECT) + && tif->tif_mode == O_RDWR ) + { + uint64 *offsets=NULL, *sizes=NULL; + + if( TIFFIsTiled(tif) ) + { + if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets ) + && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes ) + && _TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8, + tif->tif_dir.td_nstrips, offsets ) + && _TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8, + tif->tif_dir.td_nstrips, sizes ) ) + { + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + tif->tif_flags &= ~TIFF_BEENWRITING; + return 1; + } + } + else + { + if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets ) + && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes ) + && _TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8, + tif->tif_dir.td_nstrips, offsets ) + && _TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8, + tif->tif_dir.td_nstrips, sizes ) ) + { + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + tif->tif_flags &= ~TIFF_BEENWRITING; + return 1; + } + } + } + + if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP)) + && !TIFFRewriteDirectory(tif)) + return (0); + + return (1); +} + +/* + * Flush buffered data to the file. + * + * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING + * is not set, so that TIFFFlush() will proceed to write out the directory. + * The documentation says returning 1 is an error indicator, but not having + * been writing isn't exactly a an error. Hopefully this doesn't cause + * problems for other people. + */ +int +TIFFFlushData(TIFF* tif) +{ + if ((tif->tif_flags & TIFF_BEENWRITING) == 0) + return (1); + if (tif->tif_flags & TIFF_POSTENCODE) { + tif->tif_flags &= ~TIFF_POSTENCODE; + if (!(*tif->tif_postencode)(tif)) + return (0); + } + return (TIFFFlushData1(tif)); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_getimage.c b/libs/tiff-4.0.2/libtiff/tif_getimage.c similarity index 54% rename from libs/tiff-3.8.2/libtiff/tif_getimage.c rename to libs/tiff-4.0.2/libtiff/tif_getimage.c index d71c85f4e4..a85273cc3a 100644 --- a/libs/tiff-3.8.2/libtiff/tif_getimage.c +++ b/libs/tiff-4.0.2/libtiff/tif_getimage.c @@ -1,4 +1,4 @@ -/* $Id: tif_getimage.c,v 1.49 2005/12/24 15:36:16 dron Exp $ */ +/* $Id: tif_getimage.c,v 1.82 2012-06-06 00:17:49 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -32,14 +32,17 @@ #include "tiffiop.h" #include -static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int pickTileContigCase(TIFFRGBAImage*); -static int pickTileSeparateCase(TIFFRGBAImage*); +static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); +static int PickContigCase(TIFFRGBAImage*); +static int PickSeparateCase(TIFFRGBAImage*); -static const char photoTag[] = "PhotometricInterpretation"; +static int BuildMapUaToAa(TIFFRGBAImage* img); +static int BuildMapBitdepth16To8(TIFFRGBAImage* img); + +static const char photoTag[] = "PhotometricInterpretation"; /* * Helper constants used in Orientation tag handling @@ -51,7 +54,7 @@ static const char photoTag[] = "PhotometricInterpretation"; * Color conversion constants. We will define display types here. */ -TIFFDisplay display_sRGB = { +static const TIFFDisplay display_sRGB = { { /* XYZ -> luminance matrix */ { 3.2410F, -1.5374F, -0.4986F }, { -0.9692F, 1.8760F, 0.0416F }, @@ -72,118 +75,122 @@ TIFFDisplay display_sRGB = { int TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) { - TIFFDirectory* td = &tif->tif_dir; - uint16 photometric; - int colorchannels; + TIFFDirectory* td = &tif->tif_dir; + uint16 photometric; + int colorchannels; - if (!tif->tif_decodestatus) { - sprintf(emsg, "Sorry, requested compression method is not configured"); - return (0); - } - switch (td->td_bitspersample) { - case 1: case 2: case 4: - case 8: case 16: - break; - default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", - td->td_bitspersample); - return (0); - } - colorchannels = td->td_samplesperpixel - td->td_extrasamples; - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { - switch (colorchannels) { - case 1: - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); + if (!tif->tif_decodestatus) { + sprintf(emsg, "Sorry, requested compression method is not configured"); + return (0); } - } - switch (photometric) { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_PALETTE: - if (td->td_planarconfig == PLANARCONFIG_CONTIG - && td->td_samplesperpixel != 1 - && td->td_bitspersample < 8 ) { - sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", - photoTag, photometric, - "Samples/pixel", td->td_samplesperpixel, - td->td_bitspersample); - return (0); + switch (td->td_bitspersample) { + case 1: + case 2: + case 4: + case 8: + case 16: + break; + default: + sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + td->td_bitspersample); + return (0); } - /* - ** We should likely validate that any extra samples are either - ** to be ignored, or are alpha, and if alpha we should try to use - ** them. But for now we won't bother with this. - */ - break; - case PHOTOMETRIC_YCBCR: - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", - "Planarconfiguration", td->td_planarconfig); - return (0); - } - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; - case PHOTOMETRIC_SEPARATED: - { - uint16 inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) { - sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return 0; + colorchannels = td->td_samplesperpixel - td->td_extrasamples; + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { + switch (colorchannels) { + case 1: + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + return (0); } - if (td->td_samplesperpixel < 4) { - sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", td->td_samplesperpixel); - return 0; - } - break; } - case PHOTOMETRIC_LOGL: - if (td->td_compression != COMPRESSION_SGILOG) { - sprintf(emsg, "Sorry, LogL data must have %s=%d", - "Compression", COMPRESSION_SGILOG); - return (0); + switch (photometric) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: + if (td->td_planarconfig == PLANARCONFIG_CONTIG + && td->td_samplesperpixel != 1 + && td->td_bitspersample < 8 ) { + sprintf(emsg, + "Sorry, can not handle contiguous data with %s=%d, " + "and %s=%d and Bits/Sample=%d", + photoTag, photometric, + "Samples/pixel", td->td_samplesperpixel, + td->td_bitspersample); + return (0); + } + /* + * We should likely validate that any extra samples are either + * to be ignored, or are alpha, and if alpha we should try to use + * them. But for now we won't bother with this. + */ + break; + case PHOTOMETRIC_YCBCR: + /* + * TODO: if at all meaningful and useful, make more complete + * support check here, or better still, refactor to let supporting + * code decide whether there is support and what meaningfull + * error to return + */ + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + return (0); + } + break; + case PHOTOMETRIC_SEPARATED: + { + uint16 inkset; + TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); + if (inkset != INKSET_CMYK) { + sprintf(emsg, + "Sorry, can not handle separated image with %s=%d", + "InkSet", inkset); + return 0; + } + if (td->td_samplesperpixel < 4) { + sprintf(emsg, + "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", td->td_samplesperpixel); + return 0; + } + break; + } + case PHOTOMETRIC_LOGL: + if (td->td_compression != COMPRESSION_SGILOG) { + sprintf(emsg, "Sorry, LogL data must have %s=%d", + "Compression", COMPRESSION_SGILOG); + return (0); + } + break; + case PHOTOMETRIC_LOGLUV: + if (td->td_compression != COMPRESSION_SGILOG && + td->td_compression != COMPRESSION_SGILOG24) { + sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", + "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); + return (0); + } + if (td->td_planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + "Planarconfiguration", td->td_planarconfig); + return (0); + } + break; + case PHOTOMETRIC_CIELAB: + break; + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, photometric); + return (0); } - break; - case PHOTOMETRIC_LOGLUV: - if (td->td_compression != COMPRESSION_SGILOG && - td->td_compression != COMPRESSION_SGILOG24) { - sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); - return (0); - } - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", - "Planarconfiguration", td->td_planarconfig); - return (0); - } - break; - case PHOTOMETRIC_CIELAB: - break; - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", - photoTag, photometric); - return (0); - } - return (1); + return (1); } void @@ -199,11 +206,16 @@ TIFFRGBAImageEnd(TIFFRGBAImage* img) _TIFFfree(img->ycbcr), img->ycbcr = NULL; if (img->cielab) _TIFFfree(img->cielab), img->cielab = NULL; + if (img->UaToAa) + _TIFFfree(img->UaToAa), img->UaToAa = NULL; + if (img->Bitdepth16To8) + _TIFFfree(img->Bitdepth16To8), img->Bitdepth16To8 = NULL; if( img->redcmap ) { _TIFFfree( img->redcmap ); _TIFFfree( img->greencmap ); _TIFFfree( img->bluecmap ); + img->redcmap = img->greencmap = img->bluecmap = NULL; } } @@ -221,221 +233,236 @@ isCCITTCompression(TIFF* tif) int TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) { - uint16* sampleinfo; - uint16 extrasamples; - uint16 planarconfig; - uint16 compress; - int colorchannels; - uint16 *red_orig, *green_orig, *blue_orig; - int n_color; + uint16* sampleinfo; + uint16 extrasamples; + uint16 planarconfig; + uint16 compress; + int colorchannels; + uint16 *red_orig, *green_orig, *blue_orig; + int n_color; - /* Initialize to normal values */ - img->row_offset = 0; - img->col_offset = 0; - img->redcmap = NULL; - img->greencmap = NULL; - img->bluecmap = NULL; - img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */ - - img->tif = tif; - img->stoponerr = stop; - TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); - switch (img->bitspersample) { - case 1: case 2: case 4: - case 8: case 16: - break; - default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", - img->bitspersample); - return (0); - } - img->alpha = 0; - TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, - &extrasamples, &sampleinfo); - if (extrasamples >= 1) - { - switch (sampleinfo[0]) { - case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without */ - if (img->samplesperpixel > 3) /* correct info about alpha channel */ - img->alpha = EXTRASAMPLE_ASSOCALPHA; - break; - case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ - case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ - img->alpha = sampleinfo[0]; - break; + /* Initialize to normal values */ + img->row_offset = 0; + img->col_offset = 0; + img->redcmap = NULL; + img->greencmap = NULL; + img->bluecmap = NULL; + img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */ + + img->tif = tif; + img->stoponerr = stop; + TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); + switch (img->bitspersample) { + case 1: + case 2: + case 4: + case 8: + case 16: + break; + default: + sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + img->bitspersample); + goto fail_return; + } + img->alpha = 0; + TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); + TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, + &extrasamples, &sampleinfo); + if (extrasamples >= 1) + { + switch (sampleinfo[0]) { + case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without */ + if (img->samplesperpixel > 3) /* correct info about alpha channel */ + img->alpha = EXTRASAMPLE_ASSOCALPHA; + break; + case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ + case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ + img->alpha = sampleinfo[0]; + break; + } } - } #ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA - if( !TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) - img->photometric = PHOTOMETRIC_MINISWHITE; + if( !TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) + img->photometric = PHOTOMETRIC_MINISWHITE; - if( extrasamples == 0 - && img->samplesperpixel == 4 - && img->photometric == PHOTOMETRIC_RGB ) - { - img->alpha = EXTRASAMPLE_ASSOCALPHA; - extrasamples = 1; - } + if( extrasamples == 0 + && img->samplesperpixel == 4 + && img->photometric == PHOTOMETRIC_RGB ) + { + img->alpha = EXTRASAMPLE_ASSOCALPHA; + extrasamples = 1; + } #endif - colorchannels = img->samplesperpixel - extrasamples; - TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); - TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { - switch (colorchannels) { - case 1: - if (isCCITTCompression(tif)) - img->photometric = PHOTOMETRIC_MINISWHITE; - else - img->photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - img->photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); - } - } - switch (img->photometric) { - case PHOTOMETRIC_PALETTE: - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, - &red_orig, &green_orig, &blue_orig)) { - sprintf(emsg, "Missing required \"Colormap\" tag"); - return (0); + colorchannels = img->samplesperpixel - extrasamples; + TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); + TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { + switch (colorchannels) { + case 1: + if (isCCITTCompression(tif)) + img->photometric = PHOTOMETRIC_MINISWHITE; + else + img->photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + img->photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + goto fail_return; + } } + switch (img->photometric) { + case PHOTOMETRIC_PALETTE: + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, + &red_orig, &green_orig, &blue_orig)) { + sprintf(emsg, "Missing required \"Colormap\" tag"); + goto fail_return; + } - /* copy the colormaps so we can modify them */ - n_color = (1L << img->bitspersample); - img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - if( !img->redcmap || !img->greencmap || !img->bluecmap ) { - sprintf(emsg, "Out of memory for colormap copy"); - return (0); - } + /* copy the colormaps so we can modify them */ + n_color = (1L << img->bitspersample); + img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); + img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); + img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); + if( !img->redcmap || !img->greencmap || !img->bluecmap ) { + sprintf(emsg, "Out of memory for colormap copy"); + goto fail_return; + } - _TIFFmemcpy( img->redcmap, red_orig, n_color * 2 ); - _TIFFmemcpy( img->greencmap, green_orig, n_color * 2 ); - _TIFFmemcpy( img->bluecmap, blue_orig, n_color * 2 ); - - /* fall thru... */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (planarconfig == PLANARCONFIG_CONTIG - && img->samplesperpixel != 1 - && img->bitspersample < 8 ) { - sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", - photoTag, img->photometric, - "Samples/pixel", img->samplesperpixel, - img->bitspersample); - return (0); - } - break; - case PHOTOMETRIC_YCBCR: - if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", - "Planarconfiguration", planarconfig); - return (0); - } - /* It would probably be nice to have a reality check here. */ - if (planarconfig == PLANARCONFIG_CONTIG) - /* can rely on libjpeg to convert to RGB */ - /* XXX should restore current state on exit */ - switch (compress) { - case COMPRESSION_OJPEG: - case COMPRESSION_JPEG: - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - img->photometric = PHOTOMETRIC_RGB; - break; + _TIFFmemcpy( img->redcmap, red_orig, n_color * 2 ); + _TIFFmemcpy( img->greencmap, green_orig, n_color * 2 ); + _TIFFmemcpy( img->bluecmap, blue_orig, n_color * 2 ); - default: - /* do nothing */; - break; - } - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); + /* fall thru... */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (planarconfig == PLANARCONFIG_CONTIG + && img->samplesperpixel != 1 + && img->bitspersample < 8 ) { + sprintf(emsg, + "Sorry, can not handle contiguous data with %s=%d, " + "and %s=%d and Bits/Sample=%d", + photoTag, img->photometric, + "Samples/pixel", img->samplesperpixel, + img->bitspersample); + goto fail_return; + } + break; + case PHOTOMETRIC_YCBCR: + /* It would probably be nice to have a reality check here. */ + if (planarconfig == PLANARCONFIG_CONTIG) + /* can rely on libjpeg to convert to RGB */ + /* XXX should restore current state on exit */ + switch (compress) { + case COMPRESSION_JPEG: + /* + * TODO: when complete tests verify complete desubsampling + * and YCbCr handling, remove use of TIFFTAG_JPEGCOLORMODE in + * favor of tif_getimage.c native handling + */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + img->photometric = PHOTOMETRIC_RGB; + break; + default: + /* do nothing */; + break; + } + /* + * TODO: if at all meaningful and useful, make more complete + * support check here, or better still, refactor to let supporting + * code decide whether there is support and what meaningfull + * error to return + */ + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + goto fail_return; + } + break; + case PHOTOMETRIC_SEPARATED: + { + uint16 inkset; + TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); + if (inkset != INKSET_CMYK) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "InkSet", inkset); + goto fail_return; + } + if (img->samplesperpixel < 4) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", img->samplesperpixel); + goto fail_return; + } + } + break; + case PHOTOMETRIC_LOGL: + if (compress != COMPRESSION_SGILOG) { + sprintf(emsg, "Sorry, LogL data must have %s=%d", + "Compression", COMPRESSION_SGILOG); + goto fail_return; + } + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ + img->bitspersample = 8; + break; + case PHOTOMETRIC_LOGLUV: + if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24) { + sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", + "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); + goto fail_return; + } + if (planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + "Planarconfiguration", planarconfig); + return (0); + } + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + img->photometric = PHOTOMETRIC_RGB; /* little white lie */ + img->bitspersample = 8; + break; + case PHOTOMETRIC_CIELAB: + break; + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, img->photometric); + goto fail_return; } - break; - case PHOTOMETRIC_SEPARATED: { - uint16 inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return (0); + img->Map = NULL; + img->BWmap = NULL; + img->PALmap = NULL; + img->ycbcr = NULL; + img->cielab = NULL; + img->UaToAa = NULL; + img->Bitdepth16To8 = NULL; + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); + TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); + img->isContig = + !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1); + if (img->isContig) { + if (!PickContigCase(img)) { + sprintf(emsg, "Sorry, can not handle image"); + goto fail_return; + } + } else { + if (!PickSeparateCase(img)) { + sprintf(emsg, "Sorry, can not handle image"); + goto fail_return; + } } - if (img->samplesperpixel < 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", img->samplesperpixel); - return (0); - } - break; - } - case PHOTOMETRIC_LOGL: - if (compress != COMPRESSION_SGILOG) { - sprintf(emsg, "Sorry, LogL data must have %s=%d", - "Compression", COMPRESSION_SGILOG); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_LOGLUV: - if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24) { - sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); - return (0); - } - if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", - "Planarconfiguration", planarconfig); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_RGB; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_CIELAB: - break; - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", - photoTag, img->photometric); - return (0); - } - img->Map = NULL; - img->BWmap = NULL; - img->PALmap = NULL; - img->ycbcr = NULL; - img->cielab = NULL; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); - TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); - img->isContig = - !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); - if (img->isContig) { - img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig; - if (!pickTileContigCase(img)) { - sprintf(emsg, "Sorry, can not handle image"); - return 0; - } - } else { - img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate; - if (!pickTileSeparateCase(img)) { - sprintf(emsg, "Sorry, can not handle image"); - return 0; - } - } - return 1; + return 1; + + fail_return: + _TIFFfree( img->redcmap ); + _TIFFfree( img->greencmap ); + _TIFFfree( img->bluecmap ); + img->redcmap = img->greencmap = img->bluecmap = NULL; + return 0; } int @@ -473,7 +500,7 @@ TIFFReadRGBAImageOriented(TIFF* tif, rwidth, img.height); TIFFRGBAImageEnd(&img); } else { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); ok = 0; } return (ok); @@ -564,7 +591,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; uint32 col, row, y, rowstoread; - uint32 pos; + tmsize_t pos; uint32 tw, th; unsigned char* buf; int32 fromskew, toskew; @@ -573,7 +600,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) buf = (unsigned char*) _TIFFmalloc(TIFFTileSize(tif)); if (buf == 0) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "No space for tile buffer"); return (0); } _TIFFmemset(buf, 0, TIFFTileSize(tif)); @@ -596,14 +623,14 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) nrow = (row + rowstoread > h ? h - row : rowstoread); for (col = 0; col < w; col += tw) { - if (TIFFReadTile(tif, buf, col+img->col_offset, - row+img->row_offset, 0, 0) < 0 && img->stoponerr) + if (TIFFReadTile(tif, buf, col+img->col_offset, + row+img->row_offset, 0, 0)==(tmsize_t)(-1) && img->stoponerr) { ret = 0; break; } - pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); if (col + tw > w) { @@ -654,119 +681,144 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) static int gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF* tif = img->tif; - tileSeparateRoutine put = img->put.separate; - uint32 col, row, y, rowstoread; - uint32 pos; - uint32 tw, th; - unsigned char* buf; - unsigned char* r; - unsigned char* g; - unsigned char* b; - unsigned char* a; - tsize_t tilesize; - int32 fromskew, toskew; - int alpha = img->alpha; - uint32 nrow; - int ret = 1, flip; + TIFF* tif = img->tif; + tileSeparateRoutine put = img->put.separate; + uint32 col, row, y, rowstoread; + tmsize_t pos; + uint32 tw, th; + unsigned char* buf; + unsigned char* p0; + unsigned char* p1; + unsigned char* p2; + unsigned char* pa; + tmsize_t tilesize; + tmsize_t bufsize; + int32 fromskew, toskew; + int alpha = img->alpha; + uint32 nrow; + int ret = 1, flip; + int colorchannels; - tilesize = TIFFTileSize(tif); - buf = (unsigned char*) _TIFFmalloc(4*tilesize); - if (buf == 0) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); + tilesize = TIFFTileSize(tif); + bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize); + if (bufsize == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate"); return (0); - } - _TIFFmemset(buf, 0, 4*tilesize); - r = buf; - g = r + tilesize; - b = g + tilesize; - a = b + tilesize; - if (!alpha) - _TIFFmemset(a, 0xff, tilesize); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + } + buf = (unsigned char*) _TIFFmalloc(bufsize); + if (buf == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "No space for tile buffer"); + return (0); + } + _TIFFmemset(buf, 0, bufsize); + p0 = buf; + p1 = p0 + tilesize; + p2 = p1 + tilesize; + pa = (alpha?(p2+tilesize):NULL); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(tw + w); - } - else { - y = 0; - toskew = -(int32)(tw - w); - } + flip = setorientation(img); + if (flip & FLIP_VERTICALLY) { + y = h - 1; + toskew = -(int32)(tw + w); + } + else { + y = 0; + toskew = -(int32)(tw - w); + } - for (row = 0; row < h; row += nrow) - { - rowstoread = th - (row + img->row_offset) % th; - nrow = (row + rowstoread > h ? h - row : rowstoread); - for (col = 0; col < w; col += tw) + switch( img->photometric ) { - if (TIFFReadTile(tif, r, col+img->col_offset, - row+img->row_offset,0,0) < 0 && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadTile(tif, g, col+img->col_offset, - row+img->row_offset,0,1) < 0 && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadTile(tif, b, col+img->col_offset, - row+img->row_offset,0,2) < 0 && img->stoponerr) - { - ret = 0; - break; - } - if (alpha && TIFFReadTile(tif,a,col+img->col_offset, - row+img->row_offset,0,3) < 0 && img->stoponerr) - { - ret = 0; - break; - } + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: + colorchannels = 1; + p2 = p1 = p0; + break; - pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); - - if (col + tw > w) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32 npix = w - col; - fromskew = tw - npix; - (*put)(img, raster+y*w+col, col, y, - npix, nrow, fromskew, toskew + fromskew, - r + pos, g + pos, b + pos, a + pos); - } else { - (*put)(img, raster+y*w+col, col, y, - tw, nrow, 0, toskew, r + pos, g + pos, b + pos, a + pos); - } + default: + colorchannels = 3; + break; } - y += (flip & FLIP_VERTICALLY ?-(int32) nrow : (int32) nrow); - } + for (row = 0; row < h; row += nrow) + { + rowstoread = th - (row + img->row_offset) % th; + nrow = (row + rowstoread > h ? h - row : rowstoread); + for (col = 0; col < w; col += tw) + { + if (TIFFReadTile(tif, p0, col+img->col_offset, + row+img->row_offset,0,0)==(tmsize_t)(-1) && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadTile(tif, p1, col+img->col_offset, + row+img->row_offset,0,1) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadTile(tif, p2, col+img->col_offset, + row+img->row_offset,0,2) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (alpha + && TIFFReadTile(tif,pa,col+img->col_offset, + row+img->row_offset,0,colorchannels) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } - if (flip & FLIP_HORIZONTALLY) { - uint32 line; + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } + if (col + tw > w) + { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + uint32 npix = w - col; + fromskew = tw - npix; + (*put)(img, raster+y*w+col, col, y, + npix, nrow, fromskew, toskew + fromskew, + p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); + } else { + (*put)(img, raster+y*w+col, col, y, + tw, nrow, 0, toskew, p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); + } + } - _TIFFfree(buf); - return (ret); + y += (flip & FLIP_VERTICALLY ?-(int32) nrow : (int32) nrow); + } + + if (flip & FLIP_HORIZONTALLY) { + uint32 line; + + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; + + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++, right--; + } + } + } + + _TIFFfree(buf); + return (ret); } /* @@ -778,73 +830,78 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) static int gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF* tif = img->tif; - tileContigRoutine put = img->put.contig; - uint32 row, y, nrow, rowstoread; - uint32 pos; - unsigned char* buf; - uint32 rowsperstrip; - uint32 imagewidth = img->width; - tsize_t scanline; - int32 fromskew, toskew; - int ret = 1, flip; + TIFF* tif = img->tif; + tileContigRoutine put = img->put.contig; + uint32 row, y, nrow, nrowsub, rowstoread; + tmsize_t pos; + unsigned char* buf; + uint32 rowsperstrip; + uint16 subsamplinghor,subsamplingver; + uint32 imagewidth = img->width; + tmsize_t scanline; + int32 fromskew, toskew; + int ret = 1, flip; - buf = (unsigned char*) _TIFFmalloc(TIFFStripSize(tif)); - if (buf == 0) { + buf = (unsigned char*) _TIFFmalloc(TIFFStripSize(tif)); + if (buf == 0) { TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer"); return (0); - } - _TIFFmemset(buf, 0, TIFFStripSize(tif)); + } + _TIFFmemset(buf, 0, TIFFStripSize(tif)); - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(w + w); - } else { - y = 0; - toskew = -(int32)(w - w); - } + flip = setorientation(img); + if (flip & FLIP_VERTICALLY) { + y = h - 1; + toskew = -(int32)(w + w); + } else { + y = 0; + toskew = -(int32)(w - w); + } - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += nrow) - { - rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; - nrow = (row + rowstoread > h ? h - row : rowstoread); - if (TIFFReadEncodedStrip(tif, - TIFFComputeStrip(tif,row+img->row_offset, 0), - buf, - ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver); + scanline = TIFFScanlineSize(tif); + fromskew = (w < imagewidth ? imagewidth - w : 0); + for (row = 0; row < h; row += nrow) + { + rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; + nrow = (row + rowstoread > h ? h - row : rowstoread); + nrowsub = nrow; + if ((nrowsub%subsamplingver)!=0) + nrowsub+=subsamplingver-nrowsub%subsamplingver; + if (TIFFReadEncodedStrip(tif, + TIFFComputeStrip(tif,row+img->row_offset, 0), + buf, + ((row + img->row_offset)%rowsperstrip + nrowsub) * scanline)==(tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } - pos = ((row + img->row_offset) % rowsperstrip) * scanline; - (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos); - y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); - } + pos = ((row + img->row_offset) % rowsperstrip) * scanline; + (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos); + y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); + } - if (flip & FLIP_HORIZONTALLY) { - uint32 line; + if (flip & FLIP_HORIZONTALLY) { + uint32 line; - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; - _TIFFfree(buf); - return (ret); + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++, right--; + } + } + } + + _TIFFfree(buf); + return (ret); } /* @@ -856,105 +913,127 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) static int gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF* tif = img->tif; - tileSeparateRoutine put = img->put.separate; - unsigned char *buf; - unsigned char *r, *g, *b, *a; - uint32 row, y, nrow, rowstoread; - uint32 pos; - tsize_t scanline; - uint32 rowsperstrip, offset_row; - uint32 imagewidth = img->width; - tsize_t stripsize; - int32 fromskew, toskew; - int alpha = img->alpha; - int ret = 1, flip; + TIFF* tif = img->tif; + tileSeparateRoutine put = img->put.separate; + unsigned char *buf; + unsigned char *p0, *p1, *p2, *pa; + uint32 row, y, nrow, rowstoread; + tmsize_t pos; + tmsize_t scanline; + uint32 rowsperstrip, offset_row; + uint32 imagewidth = img->width; + tmsize_t stripsize; + tmsize_t bufsize; + int32 fromskew, toskew; + int alpha = img->alpha; + int ret = 1, flip, colorchannels; - stripsize = TIFFStripSize(tif); - r = buf = (unsigned char *)_TIFFmalloc(4*stripsize); - if (buf == 0) { + stripsize = TIFFStripSize(tif); + bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize); + if (bufsize == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate"); + return (0); + } + p0 = buf = (unsigned char *)_TIFFmalloc(bufsize); + if (buf == 0) { TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); return (0); - } - _TIFFmemset(buf, 0, 4*stripsize); - g = r + stripsize; - b = g + stripsize; - a = b + stripsize; - if (!alpha) - _TIFFmemset(a, 0xff, stripsize); + } + _TIFFmemset(buf, 0, bufsize); + p1 = p0 + stripsize; + p2 = p1 + stripsize; + pa = (alpha?(p2+stripsize):NULL); - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(w + w); - } - else { - y = 0; - toskew = -(int32)(w - w); - } + flip = setorientation(img); + if (flip & FLIP_VERTICALLY) { + y = h - 1; + toskew = -(int32)(w + w); + } + else { + y = 0; + toskew = -(int32)(w - w); + } - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += nrow) - { - rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; - nrow = (row + rowstoread > h ? h - row : rowstoread); - offset_row = row + img->row_offset; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), - r, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) + switch( img->photometric ) { - ret = 0; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: + colorchannels = 1; + p2 = p1 = p0; break; - } - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), - g, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), - b, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr) - { - ret = 0; - break; - } - if (alpha && - (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 3), - a, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 - && img->stoponerr)) - { - ret = 0; + + default: + colorchannels = 3; break; } - pos = ((row + img->row_offset) % rowsperstrip) * scanline; - (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r + pos, g + pos, - b + pos, a + pos); - y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); - } + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + scanline = TIFFScanlineSize(tif); + fromskew = (w < imagewidth ? imagewidth - w : 0); + for (row = 0; row < h; row += nrow) + { + rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; + nrow = (row + rowstoread > h ? h - row : rowstoread); + offset_row = row + img->row_offset; + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), + p0, ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), + p1, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), + p2, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (alpha) + { + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, colorchannels), + pa, ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + } - if (flip & FLIP_HORIZONTALLY) { - uint32 line; + pos = ((row + img->row_offset) % rowsperstrip) * scanline; + (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos, + p2 + pos, (alpha?(pa+pos):NULL)); + y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow); + } - for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; - - while ( left < right ) { - uint32 temp = *left; - *left = *right; - *right = temp; - left++, right--; - } - } - } + if (flip & FLIP_HORIZONTALLY) { + uint32 line; - _TIFFfree(buf); - return (ret); + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; + + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++, right--; + } + } + } + + _TIFFfree(buf); + return (ret); } /* @@ -963,9 +1042,9 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * ABGR pixels (i.e. suitable for passing to lrecwrite.) * * The routines have been created according to the most - * important cases and optimized. pickTileContigCase and - * pickTileSeparateCase analyze the parameters and select - * the appropriate "put" routine to use. + * important cases and optimized. PickContigCase and + * PickSeparateCase analyze the parameters and select + * the appropriate "get" and "put" routine to use. */ #define REPEAT8(op) REPEAT4(op); REPEAT4(op) #define REPEAT4(op) REPEAT2(op); REPEAT2(op) @@ -1022,6 +1101,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) #define PACK4(r,g,b,a) \ ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) #define W2B(v) (((v)>>8)&0xff) +/* TODO: PACKW should have be made redundant in favor of Bitdepth16To8 LUT */ #define PACKW(r,g,b) \ ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) #define PACKW4(r,g,b,a) \ @@ -1128,6 +1208,26 @@ DECLAREContigPutFunc(putgreytile) } } +/* + * 8-bit greyscale with associated alpha => colormap/RGBA + */ +DECLAREContigPutFunc(putagreytile) +{ + int samplesperpixel = img->samplesperpixel; + uint32** BWmap = img->BWmap; + + (void) y; + while (h-- > 0) { + for (x = w; x-- > 0;) + { + *cp++ = BWmap[*pp][0] & (*(pp+1) << 24 | ~A1); + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + /* * 16-bit greyscale => colormap/RGB */ @@ -1222,26 +1322,6 @@ DECLAREContigPutFunc(putRGBcontig8bittile) } } -/* - * 8-bit packed samples, w/ Map => RGB - */ -DECLAREContigPutFunc(putRGBcontig8bitMaptile) -{ - TIFFRGBValue* Map = img->Map; - int samplesperpixel = img->samplesperpixel; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACK(Map[pp[0]], Map[pp[1]], Map[pp[2]]); - pp += samplesperpixel; - } - pp += fromskew; - cp += toskew; - } -} - /* * 8-bit packed samples => RGBA w/ associated alpha * (known to have Map == NULL) @@ -1267,23 +1347,24 @@ DECLAREContigPutFunc(putRGBAAcontig8bittile) */ DECLAREContigPutFunc(putRGBUAcontig8bittile) { - int samplesperpixel = img->samplesperpixel; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - uint32 r, g, b, a; - for (x = w; x-- > 0;) { - a = pp[3]; - r = (pp[0] * a) / 255; - g = (pp[1] * a) / 255; - b = (pp[2] * a) / 255; - *cp++ = PACK4(r,g,b,a); - pp += samplesperpixel; + int samplesperpixel = img->samplesperpixel; + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + uint32 r, g, b, a; + uint8* m; + for (x = w; x-- > 0;) { + a = pp[3]; + m = img->UaToAa+(a<<8); + r = m[pp[0]]; + g = m[pp[1]]; + b = m[pp[2]]; + *cp++ = PACK4(r,g,b,a); + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; } - cp += toskew; - pp += fromskew; - } } /* @@ -1291,19 +1372,20 @@ DECLAREContigPutFunc(putRGBUAcontig8bittile) */ DECLAREContigPutFunc(putRGBcontig16bittile) { - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACKW(wp[0], wp[1], wp[2]); - wp += samplesperpixel; + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + for (x = w; x-- > 0;) { + *cp++ = PACK(img->Bitdepth16To8[wp[0]], + img->Bitdepth16To8[wp[1]], + img->Bitdepth16To8[wp[2]]); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; } - cp += toskew; - wp += fromskew; - } } /* @@ -1312,19 +1394,21 @@ DECLAREContigPutFunc(putRGBcontig16bittile) */ DECLAREContigPutFunc(putRGBAAcontig16bittile) { - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACKW4(wp[0], wp[1], wp[2], wp[3]); - wp += samplesperpixel; + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + for (x = w; x-- > 0;) { + *cp++ = PACK4(img->Bitdepth16To8[wp[0]], + img->Bitdepth16To8[wp[1]], + img->Bitdepth16To8[wp[2]], + img->Bitdepth16To8[wp[3]]); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; } - cp += toskew; - wp += fromskew; - } } /* @@ -1333,32 +1417,25 @@ DECLAREContigPutFunc(putRGBAAcontig16bittile) */ DECLAREContigPutFunc(putRGBUAcontig16bittile) { - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - uint32 r,g,b,a; - /* - * We shift alpha down four bits just in case unsigned - * arithmetic doesn't handle the full range. - * We still have plenty of accuracy, since the output is 8 bits. - * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) - * Since we want r*a * 0xff for eight bit output, - * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. - */ - for (x = w; x-- > 0;) { - a = wp[3] >> 4; - r = (wp[0] * a) / 0x10eff; - g = (wp[1] * a) / 0x10eff; - b = (wp[2] * a) / 0x10eff; - *cp++ = PACK4(r,g,b,a); - wp += samplesperpixel; + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + uint32 r,g,b,a; + uint8* m; + for (x = w; x-- > 0;) { + a = img->Bitdepth16To8[wp[3]]; + m = img->UaToAa+(a<<8); + r = m[img->Bitdepth16To8[wp[0]]]; + g = m[img->Bitdepth16To8[wp[1]]]; + b = m[img->Bitdepth16To8[wp[2]]]; + *cp++ = PACK4(r,g,b,a); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; } - cp += toskew; - wp += fromskew; - } } /* @@ -1436,33 +1513,37 @@ DECLARESepPutFunc(putRGBseparate8bittile) } } -/* - * 8-bit unpacked samples => RGB - */ -DECLARESepPutFunc(putRGBseparate8bitMaptile) -{ - TIFFRGBValue* Map = img->Map; - - (void) y; (void) a; - while (h-- > 0) { - for (x = w; x > 0; x--) - *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]); - SKEW(r, g, b, fromskew); - cp += toskew; - } -} - /* * 8-bit unpacked samples => RGBA w/ associated alpha */ DECLARESepPutFunc(putRGBAAseparate8bittile) { - (void) img; (void) x; (void) y; - while (h-- > 0) { - UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } + (void) img; (void) x; (void) y; + while (h-- > 0) { + UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } +} + +/* + * 8-bit unpacked CMYK samples => RGBA + */ +DECLARESepPutFunc(putCMYKseparate8bittile) +{ + (void) img; (void) y; + while (h-- > 0) { + uint32 rv, gv, bv, kv; + for (x = w; x-- > 0;) { + kv = 255 - *a++; + rv = (kv*(255-*r++))/255; + gv = (kv*(255-*g++))/255; + bv = (kv*(255-*b++))/255; + *cp++ = PACK4(rv,gv,bv,255); + } + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } } /* @@ -1470,19 +1551,21 @@ DECLARESepPutFunc(putRGBAAseparate8bittile) */ DECLARESepPutFunc(putRGBUAseparate8bittile) { - (void) img; (void) y; - while (h-- > 0) { - uint32 rv, gv, bv, av; - for (x = w; x-- > 0;) { - av = *a++; - rv = (*r++ * av) / 255; - gv = (*g++ * av) / 255; - bv = (*b++ * av) / 255; - *cp++ = PACK4(rv,gv,bv,av); + (void) img; (void) y; + while (h-- > 0) { + uint32 rv, gv, bv, av; + uint8* m; + for (x = w; x-- > 0;) { + av = *a++; + m = img->UaToAa+(av<<8); + rv = m[*r++]; + gv = m[*g++]; + bv = m[*b++]; + *cp++ = PACK4(rv,gv,bv,av); + } + SKEW4(r, g, b, a, fromskew); + cp += toskew; } - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } } /* @@ -1490,17 +1573,18 @@ DECLARESepPutFunc(putRGBUAseparate8bittile) */ DECLARESepPutFunc(putRGBseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - - (void) img; (void) y; (void) a; - while (h-- > 0) { - for (x = 0; x < w; x++) - *cp++ = PACKW(*wr++, *wg++, *wb++); - SKEW(wr, wg, wb, fromskew); - cp += toskew; - } + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + (void) img; (void) y; (void) a; + while (h-- > 0) { + for (x = 0; x < w; x++) + *cp++ = PACK(img->Bitdepth16To8[*wr++], + img->Bitdepth16To8[*wg++], + img->Bitdepth16To8[*wb++]); + SKEW(wr, wg, wb, fromskew); + cp += toskew; + } } /* @@ -1508,18 +1592,20 @@ DECLARESepPutFunc(putRGBseparate16bittile) */ DECLARESepPutFunc(putRGBAAseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; - - (void) img; (void) y; - while (h-- > 0) { - for (x = 0; x < w; x++) - *cp++ = PACKW4(*wr++, *wg++, *wb++, *wa++); - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + uint16 *wa = (uint16*) a; + (void) img; (void) y; + while (h-- > 0) { + for (x = 0; x < w; x++) + *cp++ = PACK4(img->Bitdepth16To8[*wr++], + img->Bitdepth16To8[*wg++], + img->Bitdepth16To8[*wb++], + img->Bitdepth16To8[*wa++]); + SKEW4(wr, wg, wb, wa, fromskew); + cp += toskew; + } } /* @@ -1527,32 +1613,25 @@ DECLARESepPutFunc(putRGBAAseparate16bittile) */ DECLARESepPutFunc(putRGBUAseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; - - (void) img; (void) y; - while (h-- > 0) { - uint32 r,g,b,a; - /* - * We shift alpha down four bits just in case unsigned - * arithmetic doesn't handle the full range. - * We still have plenty of accuracy, since the output is 8 bits. - * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) - * Since we want r*a * 0xff for eight bit output, - * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. - */ - for (x = w; x-- > 0;) { - a = *wa++ >> 4; - r = (*wr++ * a) / 0x10eff; - g = (*wg++ * a) / 0x10eff; - b = (*wb++ * a) / 0x10eff; - *cp++ = PACK4(r,g,b,a); + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + uint16 *wa = (uint16*) a; + (void) img; (void) y; + while (h-- > 0) { + uint32 r,g,b,a; + uint8* m; + for (x = w; x-- > 0;) { + a = img->Bitdepth16To8[*wa++]; + m = img->UaToAa+(a<<8); + r = m[img->Bitdepth16To8[*wr++]]; + g = m[img->Bitdepth16To8[*wg++]]; + b = m[img->Bitdepth16To8[*wb++]]; + *cp++ = PACK4(r,g,b,a); + } + SKEW4(wr, wg, wb, wa, fromskew); + cp += toskew; } - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } } /* @@ -1890,63 +1969,57 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) { - uint32* cp1 = cp+w+toskew; - int32 incr = 2*toskew+w; - - (void) y; - fromskew = (fromskew * 6) / 2; - if ((h & 1) == 0 && (w & 1) == 0) { - for (; h >= 2; h -= 2) { - x = w>>1; - do { - int32 Cb = pp[4]; - int32 Cr = pp[5]; - - YCbCrtoRGB(cp [0], pp[0]); - YCbCrtoRGB(cp [1], pp[1]); - YCbCrtoRGB(cp1[0], pp[2]); - YCbCrtoRGB(cp1[1], pp[3]); - - cp += 2, cp1 += 2; - pp += 6; - } while (--x); - cp += incr, cp1 += incr; - pp += fromskew; - } - } else { - while (h > 0) { - for (x = w; x > 0;) { - int32 Cb = pp[4]; - int32 Cr = pp[5]; - switch (x) { - default: - switch (h) { - default: YCbCrtoRGB(cp1[1], pp[ 3]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) { - default: YCbCrtoRGB(cp1[0], pp[ 2]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - } - if (x < 2) { - cp += x; cp1 += x; - x = 0; - } - else { - cp += 2; cp1 += 2; - x -= 2; - } - pp += 6; - } - if (h <= 2) - break; - h -= 2; - cp += incr, cp1 += incr; - pp += fromskew; - } - } + uint32* cp2; + int32 incr = 2*toskew+w; + (void) y; + fromskew = (fromskew / 2) * 6; + cp2 = cp+w+toskew; + while (h>=2) { + x = w; + while (x>=2) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); + YCbCrtoRGB(cp2[0], pp[2]); + YCbCrtoRGB(cp2[1], pp[3]); + cp += 2; + cp2 += 2; + pp += 6; + x -= 2; + } + if (x==1) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp2[0], pp[2]); + cp ++ ; + cp2 ++ ; + pp += 6; + } + cp += incr; + cp2 += incr; + pp += fromskew; + h-=2; + } + if (h==1) { + x = w; + while (x>=2) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); + cp += 2; + cp2 += 2; + pp += 6; + x -= 2; + } + if (x==1) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + } + } } /* @@ -1954,35 +2027,73 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) { - (void) y; - fromskew = (fromskew * 4) / 2; - do { - x = w>>1; + (void) y; + fromskew = (fromskew * 4) / 2; do { - int32 Cb = pp[2]; - int32 Cr = pp[3]; + x = w>>1; + do { + int32 Cb = pp[2]; + int32 Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); - cp += 2; - pp += 4; - } while (--x); + cp += 2; + pp += 4; + } while (--x); - if( (w&1) != 0 ) - { - int32 Cb = pp[2]; - int32 Cr = pp[3]; - - YCbCrtoRGB(cp [0], pp[0]); + if( (w&1) != 0 ) + { + int32 Cb = pp[2]; + int32 Cr = pp[3]; - cp += 1; - pp += 4; - } + YCbCrtoRGB(cp[0], pp[0]); - cp += toskew; - pp += fromskew; - } while (--h); + cp += 1; + pp += 4; + } + + cp += toskew; + pp += fromskew; + } while (--h); +} + +/* + * 8-bit packed YCbCr samples w/ 1,2 subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr12tile) +{ + uint32* cp2; + int32 incr = 2*toskew+w; + (void) y; + fromskew = (fromskew / 2) * 4; + cp2 = cp+w+toskew; + while (h>=2) { + x = w; + do { + uint32 Cb = pp[2]; + uint32 Cr = pp[3]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp2[0], pp[1]); + cp ++; + cp2 ++; + pp += 4; + } while (--x); + cp += incr; + cp2 += incr; + pp += fromskew; + h-=2; + } + if (h==1) { + x = w; + do { + uint32 Cb = pp[2]; + uint32 Cr = pp[3]; + YCbCrtoRGB(cp[0], pp[0]); + cp ++; + pp += 4; + } while (--x); + } } /* @@ -1990,76 +2101,77 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr11tile) { - (void) y; - fromskew *= 3; - do { - x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ + (void) y; + fromskew *= 3; do { - int32 Cb = pp[1]; - int32 Cr = pp[2]; + x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ + do { + int32 Cb = pp[1]; + int32 Cr = pp[2]; - YCbCrtoRGB(*cp++, pp[0]); + YCbCrtoRGB(*cp++, pp[0]); - pp += 3; - } while (--x); - cp += toskew; - pp += fromskew; - } while (--h); + pp += 3; + } while (--x); + cp += toskew; + pp += fromskew; + } while (--h); } -#undef YCbCrtoRGB -static tileContigRoutine +/* + * 8-bit packed YCbCr samples w/ no subsampling => RGB + */ +DECLARESepPutFunc(putseparate8bitYCbCr11tile) +{ + (void) y; + (void) a; + /* TODO: naming of input vars is still off, change obfuscating declaration inside define, or resolve obfuscation */ + while (h-- > 0) { + x = w; + do { + uint32 dr, dg, db; + TIFFYCbCrtoRGB(img->ycbcr,*r++,*g++,*b++,&dr,&dg,&db); + *cp++ = PACK(dr,dg,db); + } while (--x); + SKEW(r, g, b, fromskew); + cp += toskew; + } +} +#undef YCbCrtoRGB + +static int initYCbCrConversion(TIFFRGBAImage* img) { - static char module[] = "initCIELabConversion"; + static const char module[] = "initYCbCrConversion"; float *luma, *refBlackWhite; - uint16 hs, vs; if (img->ycbcr == NULL) { - img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc( - TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)) + img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc( + TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)) + 4*256*sizeof (TIFFRGBValue) + 2*256*sizeof (int) + 3*256*sizeof (int32) - ); - if (img->ycbcr == NULL) { + ); + if (img->ycbcr == NULL) { TIFFErrorExt(img->tif->tif_clientdata, module, - "No space for YCbCr->RGB conversion state"); - return (NULL); - } + "No space for YCbCr->RGB conversion state"); + return (0); + } } TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE, - &refBlackWhite); + &refBlackWhite); if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0) - return NULL; - - /* - * The 6.0 spec says that subsampling must be - * one of 1, 2, or 4, and that vertical subsampling - * must always be <= horizontal subsampling; so - * there are only a few possibilities and we just - * enumerate the cases. - */ - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); - switch ((hs<<4)|vs) { - case 0x44: return (putcontig8bitYCbCr44tile); - case 0x42: return (putcontig8bitYCbCr42tile); - case 0x41: return (putcontig8bitYCbCr41tile); - case 0x22: return (putcontig8bitYCbCr22tile); - case 0x21: return (putcontig8bitYCbCr21tile); - case 0x11: return (putcontig8bitYCbCr11tile); - } - - return (NULL); + return(0); + return (1); } static tileContigRoutine initCIELabConversion(TIFFRGBAImage* img) { - static char module[] = "initCIELabConversion"; + static const char module[] = "initCIELabConversion"; float *whitePoint; float refWhite[3]; @@ -2327,73 +2439,148 @@ buildMap(TIFFRGBAImage* img) * Select the appropriate conversion routine for packed data. */ static int -pickTileContigCase(TIFFRGBAImage* img) +PickContigCase(TIFFRGBAImage* img) { - tileContigRoutine put = 0; - - if (buildMap(img)) { + img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig; + img->put.contig = NULL; switch (img->photometric) { - case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAcontig8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAcontig8bittile; - else - put = putRGBcontig8bittile; - } else - put = putRGBcontig8bitMaptile; - break; - case 16: - put = putRGBcontig16bittile; - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAcontig16bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAcontig16bittile; - } - break; - } - break; - case PHOTOMETRIC_SEPARATED: - if (img->bitspersample == 8) { - if (!img->Map) - put = putRGBcontig8bitCMYKtile; - else - put = putRGBcontig8bitCMYKMaptile; - } - break; - case PHOTOMETRIC_PALETTE: - switch (img->bitspersample) { - case 8: put = put8bitcmaptile; break; - case 4: put = put4bitcmaptile; break; - case 2: put = put2bitcmaptile; break; - case 1: put = put1bitcmaptile; break; - } - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - switch (img->bitspersample) { - case 16: put = put16bitbwtile; break; - case 8: put = putgreytile; break; - case 4: put = put4bitbwtile; break; - case 2: put = put2bitbwtile; break; - case 1: put = put1bitbwtile; break; - } - break; - case PHOTOMETRIC_YCBCR: - if (img->bitspersample == 8) - put = initYCbCrConversion(img); - break; - case PHOTOMETRIC_CIELAB: - if (img->bitspersample == 8) - put = initCIELabConversion(img); - break; + case PHOTOMETRIC_RGB: + switch (img->bitspersample) { + case 8: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + img->put.contig = putRGBAAcontig8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapUaToAa(img)) + img->put.contig = putRGBUAcontig8bittile; + } + else + img->put.contig = putRGBcontig8bittile; + break; + case 16: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + { + if (BuildMapBitdepth16To8(img)) + img->put.contig = putRGBAAcontig16bittile; + } + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapBitdepth16To8(img) && + BuildMapUaToAa(img)) + img->put.contig = putRGBUAcontig16bittile; + } + else + { + if (BuildMapBitdepth16To8(img)) + img->put.contig = putRGBcontig16bittile; + } + break; + } + break; + case PHOTOMETRIC_SEPARATED: + if (buildMap(img)) { + if (img->bitspersample == 8) { + if (!img->Map) + img->put.contig = putRGBcontig8bitCMYKtile; + else + img->put.contig = putRGBcontig8bitCMYKMaptile; + } + } + break; + case PHOTOMETRIC_PALETTE: + if (buildMap(img)) { + switch (img->bitspersample) { + case 8: + img->put.contig = put8bitcmaptile; + break; + case 4: + img->put.contig = put4bitcmaptile; + break; + case 2: + img->put.contig = put2bitcmaptile; + break; + case 1: + img->put.contig = put1bitcmaptile; + break; + } + } + break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (buildMap(img)) { + switch (img->bitspersample) { + case 16: + img->put.contig = put16bitbwtile; + break; + case 8: + if (img->alpha && img->samplesperpixel == 2) + img->put.contig = putagreytile; + else + img->put.contig = putgreytile; + break; + case 4: + img->put.contig = put4bitbwtile; + break; + case 2: + img->put.contig = put2bitbwtile; + break; + case 1: + img->put.contig = put1bitbwtile; + break; + } + } + break; + case PHOTOMETRIC_YCBCR: + if ((img->bitspersample==8) && (img->samplesperpixel==3)) + { + if (initYCbCrConversion(img)!=0) + { + /* + * The 6.0 spec says that subsampling must be + * one of 1, 2, or 4, and that vertical subsampling + * must always be <= horizontal subsampling; so + * there are only a few possibilities and we just + * enumerate the cases. + * Joris: added support for the [1,2] case, nonetheless, to accomodate + * some OJPEG files + */ + uint16 SubsamplingHor; + uint16 SubsamplingVer; + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &SubsamplingHor, &SubsamplingVer); + switch ((SubsamplingHor<<4)|SubsamplingVer) { + case 0x44: + img->put.contig = putcontig8bitYCbCr44tile; + break; + case 0x42: + img->put.contig = putcontig8bitYCbCr42tile; + break; + case 0x41: + img->put.contig = putcontig8bitYCbCr41tile; + break; + case 0x22: + img->put.contig = putcontig8bitYCbCr22tile; + break; + case 0x21: + img->put.contig = putcontig8bitYCbCr21tile; + break; + case 0x12: + img->put.contig = putcontig8bitYCbCr12tile; + break; + case 0x11: + img->put.contig = putcontig8bitYCbCr11tile; + break; + } + } + } + break; + case PHOTOMETRIC_CIELAB: + if (buildMap(img)) { + if (img->bitspersample == 8) + img->put.contig = initCIELabConversion(img); + break; + } } - } - return ((img->put.contig = put) != 0); + return ((img->get!=NULL) && (img->put.contig!=NULL)); } /* @@ -2403,41 +2590,116 @@ pickTileContigCase(TIFFRGBAImage* img) * to the "packed routines. */ static int -pickTileSeparateCase(TIFFRGBAImage* img) +PickSeparateCase(TIFFRGBAImage* img) { - tileSeparateRoutine put = 0; - - if (buildMap(img)) { + img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate; + img->put.separate = NULL; switch (img->photometric) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + /* greyscale images processed pretty much as RGB by gtTileSeparate */ case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAseparate8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAseparate8bittile; - else - put = putRGBseparate8bittile; - } else - put = putRGBseparate8bitMaptile; - break; - case 16: - put = putRGBseparate16bittile; - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAseparate16bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAseparate16bittile; + switch (img->bitspersample) { + case 8: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + img->put.separate = putRGBAAseparate8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapUaToAa(img)) + img->put.separate = putRGBUAseparate8bittile; + } + else + img->put.separate = putRGBseparate8bittile; + break; + case 16: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + { + if (BuildMapBitdepth16To8(img)) + img->put.separate = putRGBAAseparate16bittile; + } + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapBitdepth16To8(img) && + BuildMapUaToAa(img)) + img->put.separate = putRGBUAseparate16bittile; + } + else + { + if (BuildMapBitdepth16To8(img)) + img->put.separate = putRGBseparate16bittile; + } + break; + } + break; + case PHOTOMETRIC_SEPARATED: + if (img->bitspersample == 8 && img->samplesperpixel == 4) + { + img->alpha = 1; // Not alpha, but seems like the only way to get 4th band + img->put.separate = putCMYKseparate8bittile; + } + break; + case PHOTOMETRIC_YCBCR: + if ((img->bitspersample==8) && (img->samplesperpixel==3)) + { + if (initYCbCrConversion(img)!=0) + { + uint16 hs, vs; + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); + switch ((hs<<4)|vs) { + case 0x11: + img->put.separate = putseparate8bitYCbCr11tile; + break; + /* TODO: add other cases here */ + } + } } break; - } - break; } - } - return ((img->put.separate = put) != 0); + return ((img->get!=NULL) && (img->put.separate!=NULL)); } +static int +BuildMapUaToAa(TIFFRGBAImage* img) +{ + static const char module[]="BuildMapUaToAa"; + uint8* m; + uint16 na,nv; + assert(img->UaToAa==NULL); + img->UaToAa=_TIFFmalloc(65536); + if (img->UaToAa==NULL) + { + TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); + return(0); + } + m=img->UaToAa; + for (na=0; na<256; na++) + { + for (nv=0; nv<256; nv++) + *m++=(nv*na+127)/255; + } + return(1); +} + +static int +BuildMapBitdepth16To8(TIFFRGBAImage* img) +{ + static const char module[]="BuildMapBitdepth16To8"; + uint8* m; + uint32 n; + assert(img->Bitdepth16To8==NULL); + img->Bitdepth16To8=_TIFFmalloc(65536); + if (img->Bitdepth16To8==NULL) + { + TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); + return(0); + } + m=img->Bitdepth16To8; + for (n=0; n<65536; n++) + *m++=(n+128)/257; + return(1); +} + + /* * Read a whole strip off data from the file, and convert to RGBA form. * If this is the last strip, then it will only contain the portion of @@ -2484,7 +2746,7 @@ TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) TIFFRGBAImageEnd(&img); } else { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); ok = 0; } @@ -2536,7 +2798,7 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) if (!TIFFRGBAImageOK(tif, emsg) || !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { - TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); return( 0 ); } @@ -2596,3 +2858,10 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_jbig.c b/libs/tiff-4.0.2/libtiff/tif_jbig.c new file mode 100644 index 0000000000..37878f6e70 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_jbig.c @@ -0,0 +1,213 @@ +/* $Id: tif_jbig.c,v 1.15 2010-03-10 18:56:48 bfriesen Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * JBIG Compression Algorithm Support. + * Contributed by Lee Howard + * + */ + +#include "tiffiop.h" + +#ifdef JBIG_SUPPORT +#include "jbig.h" + +static int JBIGSetupDecode(TIFF* tif) +{ + if (TIFFNumberOfStrips(tif) != 1) + { + TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in decoder"); + return 0; + } + + return 1; +} + +static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) +{ + struct jbg_dec_state decoder; + int decodeStatus = 0; + unsigned char* pImage = NULL; + (void) size, (void) s; + + if (isFillOrder(tif, tif->tif_dir.td_fillorder)) + { + TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize); + } + + jbg_dec_init(&decoder); + +#if defined(HAVE_JBG_NEWLEN) + jbg_newlen(tif->tif_rawdata, (size_t)tif->tif_rawdatasize); + /* + * I do not check the return status of jbg_newlen because even if this + * function fails it does not necessarily mean that decoding the image + * will fail. It is generally only needed for received fax images + * that do not contain the actual length of the image in the BIE + * header. I do not log when an error occurs because that will cause + * problems when converting JBIG encoded TIFF's to + * PostScript. As long as the actual image length is contained in the + * BIE header jbg_dec_in should succeed. + */ +#endif /* HAVE_JBG_NEWLEN */ + + decodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawdata, + (size_t)tif->tif_rawdatasize, NULL); + if (JBG_EOK != decodeStatus) + { + /* + * XXX: JBG_EN constant was defined in pre-2.0 releases of the + * JBIG-KIT. Since the 2.0 the error reporting functions were + * changed. We will handle both cases here. + */ + TIFFErrorExt(tif->tif_clientdata, + "JBIG", "Error (%d) decoding: %s", + decodeStatus, +#if defined(JBG_EN) + jbg_strerror(decodeStatus, JBG_EN) +#else + jbg_strerror(decodeStatus) +#endif + ); + return 0; + } + + pImage = jbg_dec_getimage(&decoder, 0); + _TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder)); + jbg_dec_free(&decoder); + return 1; +} + +static int JBIGSetupEncode(TIFF* tif) +{ + if (TIFFNumberOfStrips(tif) != 1) + { + TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in encoder"); + return 0; + } + + return 1; +} + +static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16 s) +{ + (void) s; + while (cc > 0) + { + tmsize_t n = (tmsize_t)cc; + + if (tif->tif_rawcc + n > tif->tif_rawdatasize) + { + n = tif->tif_rawdatasize - tif->tif_rawcc; + } + + assert(n > 0); + _TIFFmemcpy(tif->tif_rawcp, pp, n); + tif->tif_rawcp += n; + tif->tif_rawcc += n; + pp += n; + cc -= (size_t)n; + if (tif->tif_rawcc >= tif->tif_rawdatasize && + !TIFFFlushData1(tif)) + { + return (-1); + } + } + + return (1); +} + +static void JBIGOutputBie(unsigned char* buffer, size_t len, void* userData) +{ + TIFF* tif = (TIFF*)userData; + + if (isFillOrder(tif, tif->tif_dir.td_fillorder)) + { + TIFFReverseBits(buffer, (tmsize_t)len); + } + + JBIGCopyEncodedData(tif, buffer, len, 0); +} + +static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) +{ + TIFFDirectory* dir = &tif->tif_dir; + struct jbg_enc_state encoder; + + (void) size, (void) s; + + jbg_enc_init(&encoder, + dir->td_imagewidth, + dir->td_imagelength, + 1, + &buffer, + JBIGOutputBie, + tif); + /* + * jbg_enc_out does the "real" encoding. As data is encoded, + * JBIGOutputBie is called, which writes the data to the directory. + */ + jbg_enc_out(&encoder); + jbg_enc_free(&encoder); + + return 1; +} + +int TIFFInitJBIG(TIFF* tif, int scheme) +{ + assert(scheme == COMPRESSION_JBIG); + + /* + * These flags are set so the JBIG Codec can control when to reverse + * bits and when not to and to allow the jbig decoder and bit reverser + * to write to memory when necessary. + */ + tif->tif_flags |= TIFF_NOBITREV; + tif->tif_flags &= ~TIFF_MAPPED; + + /* Setup the function pointers for encode, decode, and cleanup. */ + tif->tif_setupdecode = JBIGSetupDecode; + tif->tif_decodestrip = JBIGDecode; + + tif->tif_setupencode = JBIGSetupEncode; + tif->tif_encodestrip = JBIGEncode; + + return 1; +} + +#endif /* JBIG_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_jpeg.c b/libs/tiff-4.0.2/libtiff/tif_jpeg.c similarity index 58% rename from libs/tiff-3.8.2/libtiff/tif_jpeg.c rename to libs/tiff-4.0.2/libtiff/tif_jpeg.c index 9a63b35ba0..3c8d3bf765 100644 --- a/libs/tiff-3.8.2/libtiff/tif_jpeg.c +++ b/libs/tiff-4.0.2/libtiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.45 2006/03/16 12:38:24 dron Exp $ */ +/* $Id: tif_jpeg.c,v 1.108 2012-06-05 03:24:30 fwarmerdam Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -44,8 +44,9 @@ */ #include -int TIFFFillStrip(TIFF*, tstrip_t); -int TIFFFillTile(TIFF*, ttile_t); +int TIFFFillStrip(TIFF* tif, uint32 strip); +int TIFFFillTile(TIFF* tif, uint32 tile); +int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ); /* We undefine FAR to avoid conflict with JPEG definition */ @@ -77,7 +78,7 @@ int TIFFFillTile(TIFF*, ttile_t); */ /* Define "boolean" as unsigned char, not int, per Windows custom. */ -#if defined(WIN32) && !defined(__MINGW32__) +#if defined(__WIN32__) && !defined(__MINGW32__) # ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ typedef unsigned char boolean; # endif @@ -87,6 +88,17 @@ int TIFFFillTile(TIFF*, ttile_t); #include "jpeglib.h" #include "jerror.h" +/* + * Do we want to do special processing suitable for when JSAMPLE is a + * 16bit value? + */ + +#if defined(JPEG_LIB_MK1) +# define JPEG_LIB_MK1_OR_12BIT 1 +#elif BITS_IN_JSAMPLE == 12 +# define JPEG_LIB_MK1_OR_12BIT 1 +#endif + /* * We are using width_in_blocks which is supposed to be private to * libjpeg. Unfortunately, the libjpeg delivered with Cygwin has @@ -108,7 +120,7 @@ int TIFFFillTile(TIFF*, ttile_t); typedef struct jpeg_destination_mgr jpeg_destination_mgr; typedef struct jpeg_source_mgr jpeg_source_mgr; -typedef struct jpeg_error_mgr jpeg_error_mgr; +typedef struct jpeg_error_mgr jpeg_error_mgr; /* * State block for each open TIFF file using @@ -123,13 +135,13 @@ typedef struct jpeg_error_mgr jpeg_error_mgr; * so we can safely cast JPEGState* -> jpeg_xxx_struct* * and vice versa! */ -typedef struct { +typedef struct { union { struct jpeg_compress_struct c; struct jpeg_decompress_struct d; struct jpeg_common_struct comm; } cinfo; /* NB: must be first */ - int cinfo_initialized; + int cinfo_initialized; jpeg_error_mgr err; /* libjpeg error manager */ JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */ @@ -144,7 +156,7 @@ typedef struct { uint16 photometric; /* copy of PhotometricInterpretation */ uint16 h_sampling; /* luminance sampling factors */ uint16 v_sampling; - tsize_t bytesperline; /* decompressed bytes per scanline */ + tmsize_t bytesperline; /* decompressed bytes per scanline */ /* pointers to intermediate buffers when processing downsampled data */ JSAMPARRAY ds_buffer[MAX_COMPONENTS]; int scancount; /* number of "scanlines" accumulated */ @@ -152,6 +164,7 @@ typedef struct { TIFFVGetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ TIFFStripMethod defsparent; /* super-class method */ TIFFTileMethod deftparent; /* super-class method */ /* pseudo-tag fields */ @@ -162,47 +175,25 @@ typedef struct { int jpegtablesmode; /* What to put in JPEGTables */ int ycbcrsampling_fetched; - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spent receiving (secs) */ - char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */ } JPEGState; #define JState(tif) ((JPEGState*)(tif)->tif_data) -static int JPEGDecode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGDecodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGInitializeLibJPEG( TIFF * tif, - int force_encode, int force_decode ); +static int JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int JPEGInitializeLibJPEG(TIFF * tif, int decode ); +static int DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); #define FIELD_JPEGTABLES (FIELD_CODEC+0) -#define FIELD_RECVPARAMS (FIELD_CODEC+1) -#define FIELD_SUBADDRESS (FIELD_CODEC+2) -#define FIELD_RECVTIME (FIELD_CODEC+3) -#define FIELD_FAXDCS (FIELD_CODEC+4) -static const TIFFFieldInfo jpegFieldInfo[] = { - { TIFFTAG_JPEGTABLES, -3,-3, TIFF_UNDEFINED, FIELD_JPEGTABLES, - FALSE, TRUE, "JPEGTables" }, - { TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, - TRUE, FALSE, "" }, - { TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "" }, - { TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "" }, - /* Specific for JPEG in faxes */ - { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, - TRUE, FALSE, "FaxRecvParams" }, - { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, - TRUE, FALSE, "FaxSubAddress" }, - { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, - TRUE, FALSE, "FaxRecvTime" }, - { TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, FIELD_FAXDCS, - TRUE, FALSE, "FaxDcs" }, +static const TIFFField jpegFields[] = { + { TIFFTAG_JPEGTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_C32_UINT8, FIELD_JPEGTABLES, FALSE, TRUE, "JPEGTables", NULL }, + { TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, + { TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL }, + { TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL } }; -#define N(a) (sizeof (a) / sizeof (a[0])) /* * libjpeg interface layer. @@ -225,7 +216,7 @@ TIFFjpeg_error_exit(j_common_ptr cinfo) char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) (cinfo, buffer); - TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", buffer); /* display the error message */ + TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", "%s", buffer); /* display the error message */ jpeg_abort(cinfo); /* clean up libjpeg state */ LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ } @@ -241,7 +232,7 @@ TIFFjpeg_output_message(j_common_ptr cinfo) char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) (cinfo, buffer); - TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", buffer); + TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", "%s", buffer); } /* @@ -410,6 +401,19 @@ std_empty_output_buffer(j_compress_ptr cinfo) /* the entire buffer has been filled */ tif->tif_rawcc = tif->tif_rawdatasize; + +#ifdef IPPJ_HUFF + /* + * The Intel IPP performance library does not necessarily fill up + * the whole output buffer on each pass, so only dump out the parts + * that have been filled. + * http://trac.osgeo.org/gdal/wiki/JpegIPP + */ + if ( sp->dest.free_in_buffer >= 0 ) { + tif->tif_rawcc = tif->tif_rawdatasize - sp->dest.free_in_buffer; + } +#endif + TIFFFlushData1(tif); sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; @@ -423,9 +427,9 @@ std_term_destination(j_compress_ptr cinfo) JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; - tif->tif_rawcp = (tidata_t) sp->dest.next_output_byte; + tif->tif_rawcp = (uint8*) sp->dest.next_output_byte; tif->tif_rawcc = - tif->tif_rawdatasize - (tsize_t) sp->dest.free_in_buffer; + tif->tif_rawdatasize - (tmsize_t) sp->dest.free_in_buffer; /* NB: libtiff does the final buffer flush */ } @@ -460,8 +464,8 @@ tables_empty_output_buffer(j_compress_ptr cinfo) void* newbuf; /* the entire buffer has been filled; enlarge it by 1000 bytes */ - newbuf = _TIFFrealloc((tdata_t) sp->jpegtables, - (tsize_t) (sp->jpegtables_length + 1000)); + newbuf = _TIFFrealloc((void*) sp->jpegtables, + (tmsize_t) (sp->jpegtables_length + 1000)); if (newbuf == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100); sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length; @@ -477,7 +481,7 @@ tables_term_destination(j_compress_ptr cinfo) JPEGState* sp = (JPEGState*) cinfo; /* set tables length to number of bytes actually emitted */ - sp->jpegtables_length -= sp->dest.free_in_buffer; + sp->jpegtables_length -= (uint32) sp->dest.free_in_buffer; } static int @@ -491,7 +495,7 @@ TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif) if (sp->jpegtables) _TIFFfree(sp->jpegtables); sp->jpegtables_length = 1000; - sp->jpegtables = (void*) _TIFFmalloc((tsize_t) sp->jpegtables_length); + sp->jpegtables = (void*) _TIFFmalloc((tmsize_t) sp->jpegtables_length); if (sp->jpegtables == NULL) { sp->jpegtables_length = 0; TIFFErrorExt(sp->tif->tif_clientdata, "TIFFjpeg_tables_dest", "No space for JPEGTables"); @@ -525,11 +529,29 @@ std_fill_input_buffer(j_decompress_ptr cinfo) JPEGState* sp = (JPEGState* ) cinfo; static const JOCTET dummy_EOI[2] = { 0xFF, JPEG_EOI }; +#ifdef IPPJ_HUFF + /* + * The Intel IPP performance library does not necessarily read the whole + * input buffer in one pass, so it is possible to get here with data + * yet to read. + * + * We just return without doing anything, until the entire buffer has + * been read. + * http://trac.osgeo.org/gdal/wiki/JpegIPP + */ + if( sp->src.bytes_in_buffer > 0 ) { + return (TRUE); + } +#endif + /* - * Should never get here since entire strip/tile is - * read into memory before the decompressor is called, - * and thus was supplied by init_source. + * Normally the whole strip/tile is read and so we don't need to do + * a fill. In the case of CHUNKY_STRIP_READ_SUPPORT we might not have + * all the data, but the rawdata is refreshed between scanlines and + * we push this into the io machinery in JPEGDecode(). + * http://trac.osgeo.org/gdal/ticket/3894 */ + WARNMS(cinfo, JWRN_JPEG_EOF); /* insert a fake EOI marker */ sp->src.next_input_byte = dummy_EOI; @@ -543,7 +565,7 @@ std_skip_input_data(j_decompress_ptr cinfo, long num_bytes) JPEGState* sp = (JPEGState*) cinfo; if (num_bytes > 0) { - if (num_bytes > (long) sp->src.bytes_in_buffer) { + if ((size_t)num_bytes > sp->src.bytes_in_buffer) { /* oops, buffer overrun */ (void) std_fill_input_buffer(cinfo); } else { @@ -557,8 +579,6 @@ static void std_term_source(j_decompress_ptr cinfo) { /* No work necessary here */ - /* Or must we update tif->tif_rawcp, tif->tif_rawcc ??? */ - /* (if so, need empty tables_term_source!) */ (void) cinfo; } @@ -634,13 +654,308 @@ alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info, * JPEG Decoding. */ +#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING + +#define JPEG_MARKER_SOF0 0xC0 +#define JPEG_MARKER_SOF1 0xC1 +#define JPEG_MARKER_SOF3 0xC3 +#define JPEG_MARKER_DHT 0xC4 +#define JPEG_MARKER_SOI 0xD8 +#define JPEG_MARKER_SOS 0xDA +#define JPEG_MARKER_DQT 0xDB +#define JPEG_MARKER_DRI 0xDD +#define JPEG_MARKER_APP0 0xE0 +#define JPEG_MARKER_COM 0xFE +struct JPEGFixupTagsSubsamplingData +{ + TIFF* tif; + void* buffer; + uint32 buffersize; + uint8* buffercurrentbyte; + uint32 bufferbytesleft; + uint64 fileoffset; + uint64 filebytesleft; + uint8 filepositioned; +}; +static void JPEGFixupTagsSubsampling(TIFF* tif); +static int JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data); +static int JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result); +static int JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result); +static void JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength); + +#endif + +static int +JPEGFixupTags(TIFF* tif) +{ +#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING + if ((tif->tif_dir.td_photometric==PHOTOMETRIC_YCBCR)&& + (tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)&& + (tif->tif_dir.td_samplesperpixel==3)) + JPEGFixupTagsSubsampling(tif); +#endif + + return(1); +} + +#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING + +static void +JPEGFixupTagsSubsampling(TIFF* tif) +{ + /* + * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in + * the TIFF tags, but still use non-default (2,2) values within the jpeg + * data stream itself. In order for TIFF applications to work properly + * - for instance to get the strip buffer size right - it is imperative + * that the subsampling be available before we start reading the image + * data normally. This function will attempt to analyze the first strip in + * order to get the sampling values from the jpeg data stream. + * + * Note that JPEGPreDeocode() will produce a fairly loud warning when the + * discovered sampling does not match the default sampling (2,2) or whatever + * was actually in the tiff tags. + * + * See the bug in bugzilla for details: + * + * http://bugzilla.remotesensing.org/show_bug.cgi?id=168 + * + * Frank Warmerdam, July 2002 + * Joris Van Damme, May 2007 + */ + static const char module[] = "JPEGFixupTagsSubsampling"; + struct JPEGFixupTagsSubsamplingData m; + + _TIFFFillStriles( tif ); + + if( tif->tif_dir.td_stripbytecount == NULL + || tif->tif_dir.td_stripbytecount[0] == 0 ) + { + /* Do not even try to check if the first strip/tile does not + yet exist, as occurs when GDAL has created a new NULL file + for instance. */ + return; + } + + m.tif=tif; + m.buffersize=2048; + m.buffer=_TIFFmalloc(m.buffersize); + if (m.buffer==NULL) + { + TIFFWarningExt(tif->tif_clientdata,module, + "Unable to allocate memory for auto-correcting of subsampling values; auto-correcting skipped"); + return; + } + m.buffercurrentbyte=NULL; + m.bufferbytesleft=0; + m.fileoffset=tif->tif_dir.td_stripoffset[0]; + m.filepositioned=0; + m.filebytesleft=tif->tif_dir.td_stripbytecount[0]; + if (!JPEGFixupTagsSubsamplingSec(&m)) + TIFFWarningExt(tif->tif_clientdata,module, + "Unable to auto-correct subsampling values, likely corrupt JPEG compressed data in first strip/tile; auto-correcting skipped"); + _TIFFfree(m.buffer); +} + +static int +JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) +{ + static const char module[] = "JPEGFixupTagsSubsamplingSec"; + uint8 m; + while (1) + { + while (1) + { + if (!JPEGFixupTagsSubsamplingReadByte(data,&m)) + return(0); + if (m==255) + break; + } + while (1) + { + if (!JPEGFixupTagsSubsamplingReadByte(data,&m)) + return(0); + if (m!=255) + break; + } + switch (m) + { + case JPEG_MARKER_SOI: + /* this type of marker has no data and should be skipped */ + break; + case JPEG_MARKER_COM: + case JPEG_MARKER_APP0: + case JPEG_MARKER_APP0+1: + case JPEG_MARKER_APP0+2: + case JPEG_MARKER_APP0+3: + case JPEG_MARKER_APP0+4: + case JPEG_MARKER_APP0+5: + case JPEG_MARKER_APP0+6: + case JPEG_MARKER_APP0+7: + case JPEG_MARKER_APP0+8: + case JPEG_MARKER_APP0+9: + case JPEG_MARKER_APP0+10: + case JPEG_MARKER_APP0+11: + case JPEG_MARKER_APP0+12: + case JPEG_MARKER_APP0+13: + case JPEG_MARKER_APP0+14: + case JPEG_MARKER_APP0+15: + case JPEG_MARKER_DQT: + case JPEG_MARKER_SOS: + case JPEG_MARKER_DHT: + case JPEG_MARKER_DRI: + /* this type of marker has data, but it has no use to us and should be skipped */ + { + uint16 n; + if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) + return(0); + if (n<2) + return(0); + n-=2; + if (n>0) + JPEGFixupTagsSubsamplingSkip(data,n); + } + break; + case JPEG_MARKER_SOF0: + case JPEG_MARKER_SOF1: + /* this marker contains the subsampling factors we're scanning for */ + { + uint16 n; + uint16 o; + uint8 p; + uint8 ph,pv; + if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) + return(0); + if (n!=8+data->tif->tif_dir.td_samplesperpixel*3) + return(0); + JPEGFixupTagsSubsamplingSkip(data,7); + if (!JPEGFixupTagsSubsamplingReadByte(data,&p)) + return(0); + ph=(p>>4); + pv=(p&15); + JPEGFixupTagsSubsamplingSkip(data,1); + for (o=1; otif->tif_dir.td_samplesperpixel; o++) + { + JPEGFixupTagsSubsamplingSkip(data,1); + if (!JPEGFixupTagsSubsamplingReadByte(data,&p)) + return(0); + if (p!=0x11) + { + TIFFWarningExt(data->tif->tif_clientdata,module, + "Subsampling values inside JPEG compressed data have no TIFF equivalent, auto-correction of TIFF subsampling values failed"); + return(1); + } + JPEGFixupTagsSubsamplingSkip(data,1); + } + if (((ph!=1)&&(ph!=2)&&(ph!=4))||((pv!=1)&&(pv!=2)&&(pv!=4))) + { + TIFFWarningExt(data->tif->tif_clientdata,module, + "Subsampling values inside JPEG compressed data have no TIFF equivalent, auto-correction of TIFF subsampling values failed"); + return(1); + } + if ((ph!=data->tif->tif_dir.td_ycbcrsubsampling[0])||(pv!=data->tif->tif_dir.td_ycbcrsubsampling[1])) + { + TIFFWarningExt(data->tif->tif_clientdata,module, + "Auto-corrected former TIFF subsampling values [%d,%d] to match subsampling values inside JPEG compressed data [%d,%d]", + (int)data->tif->tif_dir.td_ycbcrsubsampling[0], + (int)data->tif->tif_dir.td_ycbcrsubsampling[1], + (int)ph,(int)pv); + data->tif->tif_dir.td_ycbcrsubsampling[0]=ph; + data->tif->tif_dir.td_ycbcrsubsampling[1]=pv; + } + } + return(1); + default: + return(0); + } + } +} + +static int +JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result) +{ + if (data->bufferbytesleft==0) + { + uint32 m; + if (data->filebytesleft==0) + return(0); + if (!data->filepositioned) + { + TIFFSeekFile(data->tif,data->fileoffset,SEEK_SET); + data->filepositioned=1; + } + m=data->buffersize; + if ((uint64)m>data->filebytesleft) + m=(uint32)data->filebytesleft; + assert(m<0x80000000UL); + if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m) + return(0); + data->buffercurrentbyte=data->buffer; + data->bufferbytesleft=m; + data->fileoffset+=m; + data->filebytesleft-=m; + } + *result=*data->buffercurrentbyte; + data->buffercurrentbyte++; + data->bufferbytesleft--; + return(1); +} + +static int +JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result) +{ + uint8 ma; + uint8 mb; + if (!JPEGFixupTagsSubsamplingReadByte(data,&ma)) + return(0); + if (!JPEGFixupTagsSubsamplingReadByte(data,&mb)) + return(0); + *result=(ma<<8)|mb; + return(1); +} + +static void +JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength) +{ + if ((uint32)skiplength<=data->bufferbytesleft) + { + data->buffercurrentbyte+=skiplength; + data->bufferbytesleft-=skiplength; + } + else + { + uint16 m; + m=skiplength-data->bufferbytesleft; + if (m<=data->filebytesleft) + { + data->bufferbytesleft=0; + data->fileoffset+=m; + data->filebytesleft-=m; + data->filepositioned=0; + } + else + { + data->bufferbytesleft=0; + data->filebytesleft=0; + } + } +} + +#endif + + static int JPEGSetupDecode(TIFF* tif) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; - JPEGInitializeLibJPEG( tif, 0, 1 ); +#if defined(JPEG_DUAL_MODE_8_12) && !defined(TIFFInitJPEG) + if( tif->tif_dir.td_bitspersample == 12 ) + return TIFFReInitJPEG_12( tif, COMPRESSION_JPEG, 0 ); +#endif + + JPEGInitializeLibJPEG( tif, TRUE ); assert(sp != NULL); assert(sp->cinfo.comm.is_decompressor); @@ -678,7 +993,7 @@ JPEGSetupDecode(TIFF* tif) * Set up for decoding a strip or tile. */ static int -JPEGPreDecode(TIFF* tif, tsample_t s) +JPEGPreDecode(TIFF* tif, uint16 s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -688,6 +1003,12 @@ JPEGPreDecode(TIFF* tif, tsample_t s) int ci; assert(sp != NULL); + + if (sp->cinfo.comm.is_decompressor == 0) + { + tif->tif_setupdecode( tif ); + } + assert(sp->cinfo.comm.is_decompressor); /* * Reset decoder state from any previous strip/tile, @@ -698,8 +1019,13 @@ JPEGPreDecode(TIFF* tif, tsample_t s) /* * Read the header for this strip/tile. */ + if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) return (0); + + tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcc = sp->src.bytes_in_buffer; + /* * Check image parameters and set decompression parameters. */ @@ -719,17 +1045,32 @@ JPEGPreDecode(TIFF* tif, tsample_t s) * For PC 2, scale down the expected strip/tile size * to match a downsampled component */ - segment_width = TIFFhowmany(segment_width, sp->h_sampling); - segment_height = TIFFhowmany(segment_height, sp->v_sampling); + segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); + segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); } - if (sp->cinfo.d.image_width != segment_width || - sp->cinfo.d.image_height != segment_height) { + if (sp->cinfo.d.image_width < segment_width || + sp->cinfo.d.image_height < segment_height) { TIFFWarningExt(tif->tif_clientdata, module, - "Improper JPEG strip/tile size, expected %dx%d, got %dx%d", - segment_width, - segment_height, - sp->cinfo.d.image_width, - sp->cinfo.d.image_height); + "Improper JPEG strip/tile size, " + "expected %dx%d, got %dx%d", + segment_width, segment_height, + sp->cinfo.d.image_width, + sp->cinfo.d.image_height); + } + if (sp->cinfo.d.image_width > segment_width || + sp->cinfo.d.image_height > segment_height) { + /* + * This case could be dangerous, if the strip or tile size has + * been reported as less than the amount of data jpeg will + * return, some potential security issues arise. Catch this + * case and error out. + */ + TIFFErrorExt(tif->tif_clientdata, module, + "JPEG strip/tile size exceeds expected dimensions," + " expected %dx%d, got %dx%d", + segment_width, segment_height, + sp->cinfo.d.image_width, sp->cinfo.d.image_height); + return (0); } if (sp->cinfo.d.num_components != (td->td_planarconfig == PLANARCONFIG_CONTIG ? @@ -739,47 +1080,28 @@ JPEGPreDecode(TIFF* tif, tsample_t s) } #ifdef JPEG_LIB_MK1 if (12 != td->td_bitspersample && 8 != td->td_bitspersample) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); + return (0); } - sp->cinfo.d.data_precision = td->td_bitspersample; - sp->cinfo.d.bits_in_jsample = td->td_bitspersample; + sp->cinfo.d.data_precision = td->td_bitspersample; + sp->cinfo.d.bits_in_jsample = td->td_bitspersample; #else if (sp->cinfo.d.data_precision != td->td_bitspersample) { - TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); + return (0); } #endif if (td->td_planarconfig == PLANARCONFIG_CONTIG) { /* Component 0 should have expected sampling factors */ if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { - TIFFWarningExt(tif->tif_clientdata, module, - "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor, - sp->h_sampling, sp->v_sampling); - - /* - * XXX: Files written by the Intergraph software - * has different sampling factors stored in the - * TIFF tags and in the JPEG structures. We will - * try to deduce Intergraph files by the presense - * of the tag 33918. - */ - if (!_TIFFFindFieldInfo(tif, 33918, TIFF_ANY)) { - TIFFWarningExt(tif->tif_clientdata, module, - "Decompressor will try reading with " - "sampling %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor); - - sp->h_sampling = (uint16) - sp->cinfo.d.comp_info[0].h_samp_factor; - sp->v_sampling = (uint16) - sp->cinfo.d.comp_info[0].v_samp_factor; - } + TIFFErrorExt(tif->tif_clientdata, module, + "Improper JPEG sampling factors %d,%d\n" + "Apparently should be %d,%d.", + sp->cinfo.d.comp_info[0].h_samp_factor, + sp->cinfo.d.comp_info[0].v_samp_factor, + sp->h_sampling, sp->v_sampling); + return (0); } /* Rest should have sampling factors 1,1 */ for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { @@ -801,11 +1123,11 @@ JPEGPreDecode(TIFF* tif, tsample_t s) if (td->td_planarconfig == PLANARCONFIG_CONTIG && sp->photometric == PHOTOMETRIC_YCBCR && sp->jpegcolormode == JPEGCOLORMODE_RGB) { - /* Convert YCbCr to RGB */ + /* Convert YCbCr to RGB */ sp->cinfo.d.jpeg_color_space = JCS_YCbCr; sp->cinfo.d.out_color_space = JCS_RGB; } else { - /* Suppress colorspace handling */ + /* Suppress colorspace handling */ sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; sp->cinfo.d.out_color_space = JCS_UNKNOWN; if (td->td_planarconfig == PLANARCONFIG_CONTIG && @@ -816,7 +1138,7 @@ JPEGPreDecode(TIFF* tif, tsample_t s) if (downsampled_output) { /* Need to use raw-data interface to libjpeg */ sp->cinfo.d.raw_data_out = TRUE; - tif->tif_decoderow = JPEGDecodeRaw; + tif->tif_decoderow = DecodeRowError; tif->tif_decodestrip = JPEGDecodeRaw; tif->tif_decodetile = JPEGDecodeRaw; } else { @@ -824,7 +1146,7 @@ JPEGPreDecode(TIFF* tif, tsample_t s) sp->cinfo.d.raw_data_out = FALSE; tif->tif_decoderow = JPEGDecode; tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; + tif->tif_decodetile = JPEGDecode; } /* Start JPEG decompressor */ if (!TIFFjpeg_start_decompress(sp)) @@ -844,103 +1166,130 @@ JPEGPreDecode(TIFF* tif, tsample_t s) * "Standard" case: returned data is not downsampled. */ /*ARGSUSED*/ static int -JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - tsize_t nrows; - (void) s; - - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read"); - - if( nrows > (int) sp->cinfo.d.image_height ) - nrows = sp->cinfo.d.image_height; - - /* data is expected to be read in multiples of a scanline */ - if (nrows) - { - JSAMPROW line_work_buf = NULL; + JPEGState *sp = JState(tif); + tmsize_t nrows; + (void) s; /* - ** For 6B, only use temporary buffer for 12 bit imagery. - ** For Mk1 always use it. + ** Update available information, buffer may have been refilled + ** between decode requests */ -#if !defined(JPEG_LIB_MK1) - if( sp->cinfo.d.data_precision == 12 ) + sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; + sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; + + if( sp->bytesperline == 0 ) + return 0; + + nrows = cc / sp->bytesperline; + if (cc % sp->bytesperline) + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read"); + + if( nrows > (tmsize_t) sp->cinfo.d.image_height ) + nrows = sp->cinfo.d.image_height; + + /* data is expected to be read in multiples of a scanline */ + if (nrows) + { + JSAMPROW line_work_buf = NULL; + + /* + * For 6B, only use temporary buffer for 12 bit imagery. + * For Mk1 always use it. + */ +#if !defined(JPEG_LIB_MK1) + if( sp->cinfo.d.data_precision == 12 ) #endif - { - line_work_buf = (JSAMPROW) - _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width - * sp->cinfo.d.num_components ); - } + { + line_work_buf = (JSAMPROW) + _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width + * sp->cinfo.d.num_components ); + } - do { - if( line_work_buf != NULL ) - { - /* - ** In the MK1 case, we aways read into a 16bit buffer, and then - ** pack down to 12bit or 8bit. In 6B case we only read into 16 - ** bit buffer for 12bit data, which we need to repack. - */ - if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) - return (0); + do { + if( line_work_buf != NULL ) + { + /* + * In the MK1 case, we aways read into a 16bit buffer, and then + * pack down to 12bit or 8bit. In 6B case we only read into 16 + * bit buffer for 12bit data, which we need to repack. + */ + if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) + return (0); - if( sp->cinfo.d.data_precision == 12 ) - { - int value_pairs = (sp->cinfo.d.output_width - * sp->cinfo.d.num_components) / 2; - int iPair; + if( sp->cinfo.d.data_precision == 12 ) + { + int value_pairs = (sp->cinfo.d.output_width + * sp->cinfo.d.num_components) / 2; + int iPair; - for( iPair = 0; iPair < value_pairs; iPair++ ) - { - unsigned char *out_ptr = - ((unsigned char *) buf) + iPair * 3; - JSAMPLE *in_ptr = line_work_buf + iPair * 2; + for( iPair = 0; iPair < value_pairs; iPair++ ) + { + unsigned char *out_ptr = + ((unsigned char *) buf) + iPair * 3; + JSAMPLE *in_ptr = line_work_buf + iPair * 2; - out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; - out_ptr[1] = ((in_ptr[0] & 0xf) << 4) - | ((in_ptr[1] & 0xf00) >> 8); - out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); - } - } - else if( sp->cinfo.d.data_precision == 8 ) - { - int value_count = (sp->cinfo.d.output_width - * sp->cinfo.d.num_components); - int iValue; + out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; + out_ptr[1] = ((in_ptr[0] & 0xf) << 4) + | ((in_ptr[1] & 0xf00) >> 8); + out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); + } + } + else if( sp->cinfo.d.data_precision == 8 ) + { + int value_count = (sp->cinfo.d.output_width + * sp->cinfo.d.num_components); + int iValue; - for( iValue = 0; iValue < value_count; iValue++ ) - { - ((unsigned char *) buf)[iValue] = - line_work_buf[iValue] & 0xff; - } - } - } - else - { - /* - ** In the libjpeg6b 8bit case. We read directly into the - ** TIFF buffer. - */ - JSAMPROW bufptr = (JSAMPROW)buf; - - if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) - return (0); - } + for( iValue = 0; iValue < value_count; iValue++ ) + { + ((unsigned char *) buf)[iValue] = + line_work_buf[iValue] & 0xff; + } + } + } + else + { + /* + * In the libjpeg6b 8bit case. We read directly into the + * TIFF buffer. + */ + JSAMPROW bufptr = (JSAMPROW)buf; - ++tif->tif_row; - buf += sp->bytesperline; - cc -= sp->bytesperline; - } while (--nrows > 0); + if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) + return (0); + } - if( line_work_buf != NULL ) - _TIFFfree( line_work_buf ); - } + ++tif->tif_row; + buf += sp->bytesperline; + cc -= sp->bytesperline; + } while (--nrows > 0); - /* Close down the decompressor if we've finished the strip or tile. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height - || TIFFjpeg_finish_decompress(sp); + if( line_work_buf != NULL ) + _TIFFfree( line_work_buf ); + } + + /* Update information on consumed data */ + tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcc = sp->src.bytes_in_buffer; + + /* Close down the decompressor if we've finished the strip or tile. */ + return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height + || TIFFjpeg_finish_decompress(sp); +} + +/*ARGSUSED*/ static int +DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) + +{ + (void) buf; + (void) cc; + (void) s; + + TIFFErrorExt(tif->tif_clientdata, "TIFFReadScanline", + "scanline oriented access is not supported for downsampled JPEG compressed images, consider enabling TIFF_JPEGCOLORMODE as JPEGCOLORMODE_RGB." ); + return 0; } /* @@ -948,121 +1297,140 @@ JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * Returned data is downsampled per sampling factors. */ /*ARGSUSED*/ static int -JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - tsize_t nrows; - (void) s; + JPEGState *sp = JState(tif); + tmsize_t nrows; + (void) s; - /* data is expected to be read in multiples of a scanline */ - if ( (nrows = sp->cinfo.d.image_height) ) { - /* Cb,Cr both have sampling factors 1, so this is correct */ - JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; - int samples_per_clump = sp->samplesperclump; - -#ifdef JPEG_LIB_MK1 - unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) * - sp->cinfo.d.output_width * - sp->cinfo.d.num_components); + /* data is expected to be read in multiples of a scanline */ + if ( (nrows = sp->cinfo.d.image_height) ) { + + /* Cb,Cr both have sampling factors 1, so this is correct */ + JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; + int samples_per_clump = sp->samplesperclump; + +#if defined(JPEG_LIB_MK1_OR_12BIT) + unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) * + sp->cinfo.d.output_width * + sp->cinfo.d.num_components); + if(tmpbuf==NULL) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "Out of memory"); + return 0; + } #endif - - do { - jpeg_component_info *compptr; - int ci, clumpoffset; - /* Reload downsampled-data buffer if needed */ - if (sp->scancount >= DCTSIZE) { - int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) - != n) - return (0); - sp->scancount = 0; - } - /* - * Fastest way to unseparate data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.d.comp_info; - ci < sp->cinfo.d.num_components; - ci++, compptr++) { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - int ypos; + do { + jpeg_component_info *compptr; + int ci, clumpoffset; - for (ypos = 0; ypos < vsamp; ypos++) { - JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; -#ifdef JPEG_LIB_MK1 - JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset; + if( cc < sp->bytesperline ) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "application buffer not large enough for all data."); + return 0; + } + + /* Reload downsampled-data buffer if needed */ + if (sp->scancount >= DCTSIZE) { + int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; + if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) + return (0); + sp->scancount = 0; + } + /* + * Fastest way to unseparate data is to make one pass + * over the scanline for each row of each component. + */ + clumpoffset = 0; /* first sample in clump */ + for (ci = 0, compptr = sp->cinfo.d.comp_info; + ci < sp->cinfo.d.num_components; + ci++, compptr++) { + int hsamp = compptr->h_samp_factor; + int vsamp = compptr->v_samp_factor; + int ypos; + + for (ypos = 0; ypos < vsamp; ypos++) { + JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; + JDIMENSION nclump; +#if defined(JPEG_LIB_MK1_OR_12BIT) + JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset; #else - JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset; -#endif - JDIMENSION nclump; - - if (hsamp == 1) { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - outptr[0] = *inptr++; - outptr += samples_per_clump; - } - } else { - int xpos; - - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - for (xpos = 0; xpos < hsamp; xpos++) - outptr[xpos] = *inptr++; - outptr += samples_per_clump; - } - } - clumpoffset += hsamp; - } - } - -#ifdef JPEG_LIB_MK1 - { - if (sp->cinfo.d.data_precision == 8) - { - int i=0; - int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components; - for (i=0; icinfo.d.output_width - * sp->cinfo.d.num_components) / 2; - int iPair; - for( iPair = 0; iPair < value_pairs; iPair++ ) - { - unsigned char *out_ptr = ((unsigned char *) buf) + iPair * 3; - JSAMPLE *in_ptr = tmpbuf + iPair * 2; - out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; - out_ptr[1] = ((in_ptr[0] & 0xf) << 4) - | ((in_ptr[1] & 0xf00) >> 8); - out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); - } - } - } + JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset; + if (cc < clumpoffset + samples_per_clump*(clumps_per_line-1) + hsamp) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "application buffer not large enough for all data, possible subsampling issue"); + return 0; + } #endif - ++sp->scancount; - ++tif->tif_row; - buf += sp->bytesperline; - cc -= sp->bytesperline; - } while (--nrows > 0); - -#ifdef JPEG_LIB_MK1 - _TIFFfree(tmpbuf); + if (hsamp == 1) { + /* fast path for at least Cb and Cr */ + for (nclump = clumps_per_line; nclump-- > 0; ) { + outptr[0] = *inptr++; + outptr += samples_per_clump; + } + } else { + int xpos; + + /* general case */ + for (nclump = clumps_per_line; nclump-- > 0; ) { + for (xpos = 0; xpos < hsamp; xpos++) + outptr[xpos] = *inptr++; + outptr += samples_per_clump; + } + } + clumpoffset += hsamp; + } + } + +#if defined(JPEG_LIB_MK1_OR_12BIT) + { + if (sp->cinfo.d.data_precision == 8) + { + int i=0; + int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components; + for (i=0; icinfo.d.output_width + * sp->cinfo.d.num_components) / 2; + int iPair; + for( iPair = 0; iPair < value_pairs; iPair++ ) + { + unsigned char *out_ptr = ((unsigned char *) buf) + iPair * 3; + JSAMPLE *in_ptr = (JSAMPLE *) (tmpbuf + iPair * 2); + out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; + out_ptr[1] = ((in_ptr[0] & 0xf) << 4) + | ((in_ptr[1] & 0xf00) >> 8); + out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); + } + } + } #endif - } + sp->scancount ++; + tif->tif_row += sp->v_sampling; - /* Close down the decompressor if done. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height - || TIFFjpeg_finish_decompress(sp); + buf += sp->bytesperline; + cc -= sp->bytesperline; + + nrows -= sp->v_sampling; + } while (nrows > 0); + +#if defined(JPEG_LIB_MK1_OR_12BIT) + _TIFFfree(tmpbuf); +#endif + + } + + /* Close down the decompressor if done. */ + return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height + || TIFFjpeg_finish_decompress(sp); } @@ -1095,8 +1463,6 @@ prepare_JPEGTables(TIFF* tif) { JPEGState* sp = JState(tif); - JPEGInitializeLibJPEG( tif, 0, 0 ); - /* Initialize quant tables for current quality setting */ if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) return (0); @@ -1131,7 +1497,12 @@ JPEGSetupEncode(TIFF* tif) TIFFDirectory *td = &tif->tif_dir; static const char module[] = "JPEGSetupEncode"; - JPEGInitializeLibJPEG( tif, 1, 0 ); +#if defined(JPEG_DUAL_MODE_8_12) && !defined(TIFFInitJPEG) + if( tif->tif_dir.td_bitspersample == 12 ) + return TIFFReInitJPEG_12( tif, COMPRESSION_JPEG, 1 ); +#endif + + JPEGInitializeLibJPEG( tif, FALSE ); assert(sp != NULL); assert(!sp->cinfo.comm.is_decompressor); @@ -1197,9 +1568,9 @@ JPEGSetupEncode(TIFF* tif) /* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */ if (td->td_bitspersample != 8 && td->td_bitspersample != 12) #else - if (td->td_bitspersample != BITS_IN_JSAMPLE ) + if (td->td_bitspersample != BITS_IN_JSAMPLE ) #endif - { + { TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", (int) td->td_bitspersample); return (0); @@ -1233,12 +1604,16 @@ JPEGSetupEncode(TIFF* tif) /* Create a JPEGTables field if appropriate */ if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { - if (!prepare_JPEGTables(tif)) - return (0); - /* Mark the field present */ - /* Can't use TIFFSetField since BEENWRITING is already set! */ - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - tif->tif_flags |= TIFF_DIRTYDIRECT; + if( sp->jpegtables == NULL + || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) + { + if (!prepare_JPEGTables(tif)) + return (0); + /* Mark the field present */ + /* Can't use TIFFSetField since BEENWRITING is already set! */ + tif->tif_flags |= TIFF_DIRTYDIRECT; + TIFFSetFieldBit(tif, FIELD_JPEGTABLES); + } } else { /* We do not support application-supplied JPEGTables, */ /* so mark the field not present */ @@ -1255,7 +1630,7 @@ JPEGSetupEncode(TIFF* tif) * Set encoding state at the start of a strip or tile. */ static int -JPEGPreEncode(TIFF* tif, tsample_t s) +JPEGPreEncode(TIFF* tif, uint16 s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -1264,6 +1639,12 @@ JPEGPreEncode(TIFF* tif, tsample_t s) int downsampled_input; assert(sp != NULL); + + if (sp->cinfo.comm.is_decompressor == 1) + { + tif->tif_setupencode( tif ); + } + assert(!sp->cinfo.comm.is_decompressor); /* * Set encoding parameters for this strip/tile. @@ -1283,8 +1664,8 @@ JPEGPreEncode(TIFF* tif, tsample_t s) /* for PC 2, scale down the strip/tile size * to match a downsampled component */ - segment_width = TIFFhowmany(segment_width, sp->h_sampling); - segment_height = TIFFhowmany(segment_height, sp->v_sampling); + segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); + segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); } if (segment_width > 65535 || segment_height > 65535) { TIFFErrorExt(tif->tif_clientdata, module, "Strip/tile too large for JPEG"); @@ -1312,8 +1693,15 @@ JPEGPreEncode(TIFF* tif, tsample_t s) sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; } else { - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) + if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1) + sp->cinfo.c.in_color_space = JCS_GRAYSCALE; + else if (td->td_photometric == PHOTOMETRIC_RGB) + sp->cinfo.c.in_color_space = JCS_RGB; + else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4) + sp->cinfo.c.in_color_space = JCS_CMYK; + else + sp->cinfo.c.in_color_space = JCS_UNKNOWN; + if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space)) return (0); /* jpeg_set_colorspace set all sampling factors to 1 */ } @@ -1334,9 +1722,9 @@ JPEGPreEncode(TIFF* tif, tsample_t s) sp->cinfo.c.write_JFIF_header = FALSE; sp->cinfo.c.write_Adobe_marker = FALSE; /* set up table handling correctly */ + if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) + return (0); if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) { - if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) - return (0); unsuppress_quant_table(sp, 0); unsuppress_quant_table(sp, 1); } @@ -1376,27 +1764,69 @@ JPEGPreEncode(TIFF* tif, tsample_t s) * "Standard" case: incoming data is not downsampled. */ static int -JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { JPEGState *sp = JState(tif); - tsize_t nrows; + tmsize_t nrows; JSAMPROW bufptr[1]; + short *line16 = NULL; + int line16_count = 0; (void) s; assert(sp != NULL); /* data is expected to be supplied in multiples of a scanline */ nrows = cc / sp->bytesperline; if (cc % sp->bytesperline) - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded"); + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "fractional scanline discarded"); + /* The last strip will be limited to image size */ + if( !isTiled(tif) && tif->tif_row+nrows > tif->tif_dir.td_imagelength ) + nrows = tif->tif_dir.td_imagelength - tif->tif_row; + + if( sp->cinfo.c.data_precision == 12 ) + { + line16_count = (sp->bytesperline * 2) / 3; + line16 = (short *) _TIFFmalloc(sizeof(short) * line16_count); + // FIXME: undiagnosed malloc failure + } + while (nrows-- > 0) { + + if( sp->cinfo.c.data_precision == 12 ) + { + + int value_pairs = line16_count / 2; + int iPair; + + bufptr[0] = (JSAMPROW) line16; + + for( iPair = 0; iPair < value_pairs; iPair++ ) + { + unsigned char *in_ptr = + ((unsigned char *) buf) + iPair * 3; + JSAMPLE *out_ptr = (JSAMPLE *) (line16 + iPair * 2); + + out_ptr[0] = (in_ptr[0] << 4) | ((in_ptr[1] & 0xf0) >> 4); + out_ptr[1] = ((in_ptr[1] & 0x0f) << 8) | in_ptr[2]; + } + } + else + { bufptr[0] = (JSAMPROW) buf; - if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) - return (0); - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; + } + if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) + return (0); + if (nrows > 0) + tif->tif_row++; + buf += sp->bytesperline; } + + if( sp->cinfo.c.data_precision == 12 ) + { + _TIFFfree( line16 ); + } + return (1); } @@ -1405,28 +1835,35 @@ JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * Incoming data is expected to be downsampled per sampling factors. */ static int -JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { JPEGState *sp = JState(tif); JSAMPLE* inptr; JSAMPLE* outptr; - tsize_t nrows; + tmsize_t nrows; JDIMENSION clumps_per_line, nclump; int clumpoffset, ci, xpos, ypos; jpeg_component_info* compptr; int samples_per_clump = sp->samplesperclump; + tmsize_t bytesperclumpline; (void) s; assert(sp != NULL); - /* data is expected to be supplied in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) + /* data is expected to be supplied in multiples of a clumpline */ + /* a clumpline is equivalent to v_sampling desubsampled scanlines */ + /* TODO: the following calculation of bytesperclumpline, should substitute calculation of sp->bytesperline, except that it is per v_sampling lines */ + bytesperclumpline = (((sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling) + *(sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7) + /8; + + nrows = ( cc / bytesperclumpline ) * sp->v_sampling; + if (cc % bytesperclumpline) TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded"); /* Cb,Cr both have sampling factors 1, so this is correct */ clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; - while (nrows-- > 0) { + while (nrows > 0) { /* * Fastest way to separate the data is to make one pass * over the scanline for each row of each component. @@ -1471,9 +1908,9 @@ JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) return (0); sp->scancount = 0; } - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; + tif->tif_row += sp->v_sampling; + buf += bytesperclumpline; + nrows -= sp->v_sampling; } return (1); } @@ -1498,12 +1935,12 @@ JPEGPostEncode(TIFF* tif) ci < sp->cinfo.c.num_components; ci++, compptr++) { int vsamp = compptr->v_samp_factor; - tsize_t row_width = compptr->width_in_blocks * DCTSIZE + tmsize_t row_width = compptr->width_in_blocks * DCTSIZE * sizeof(JSAMPLE); for (ypos = sp->scancount * vsamp; ypos < DCTSIZE * vsamp; ypos++) { - _TIFFmemcpy((tdata_t)sp->ds_buffer[ci][ypos], - (tdata_t)sp->ds_buffer[ci][ypos-1], + _TIFFmemcpy((void*)sp->ds_buffer[ci][ypos], + (void*)sp->ds_buffer[ci][ypos-1], row_width); } @@ -1525,29 +1962,67 @@ JPEGCleanup(TIFF* tif) tif->tif_tagmethods.vgetfield = sp->vgetparent; tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.printdir = sp->printdir; - if( sp->cinfo_initialized ) - TIFFjpeg_destroy(sp); /* release libjpeg resources */ - if (sp->jpegtables) /* tag value */ - _TIFFfree(sp->jpegtables); + if( sp != NULL ) { + if( sp->cinfo_initialized ) + TIFFjpeg_destroy(sp); /* release libjpeg resources */ + if (sp->jpegtables) /* tag value */ + _TIFFfree(sp->jpegtables); + } _TIFFfree(tif->tif_data); /* release local state */ tif->tif_data = NULL; _TIFFSetDefaultCompressionState(tif); } -static int -JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap) +static void +JPEGResetUpsampled( TIFF* tif ) { JPEGState* sp = JState(tif); TIFFDirectory* td = &tif->tif_dir; + + /* + * Mark whether returned data is up-sampled or not so TIFFStripSize + * and TIFFTileSize return values that reflect the true amount of + * data. + */ + tif->tif_flags &= ~TIFF_UPSAMPLED; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + if (td->td_photometric == PHOTOMETRIC_YCBCR && + sp->jpegcolormode == JPEGCOLORMODE_RGB) { + tif->tif_flags |= TIFF_UPSAMPLED; + } else { +#ifdef notdef + if (td->td_ycbcrsubsampling[0] != 1 || + td->td_ycbcrsubsampling[1] != 1) + ; /* XXX what about up-sampling? */ +#endif + } + } + + /* + * Must recalculate cached tile size in case sampling state changed. + * Should we really be doing this now if image size isn't set? + */ + if( tif->tif_tilesize > 0 ) + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1); + if( tif->tif_scanlinesize > 0 ) + tif->tif_scanlinesize = TIFFScanlineSize(tif); +} + +static int +JPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + JPEGState* sp = JState(tif); + const TIFFField* fip; uint32 v32; assert(sp != NULL); switch (tag) { case TIFFTAG_JPEGTABLES: - v32 = va_arg(ap, uint32); + v32 = (uint32) va_arg(ap, uint32); if (v32 == 0) { /* XXX */ return (0); @@ -1558,128 +2033,42 @@ JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap) TIFFSetFieldBit(tif, FIELD_JPEGTABLES); break; case TIFFTAG_JPEGQUALITY: - sp->jpegquality = va_arg(ap, int); + sp->jpegquality = (int) va_arg(ap, int); return (1); /* pseudo tag */ case TIFFTAG_JPEGCOLORMODE: - sp->jpegcolormode = va_arg(ap, int); - /* - * Mark whether returned data is up-sampled or not - * so TIFFStripSize and TIFFTileSize return values - * that reflect the true amount of data. - */ - tif->tif_flags &= ~TIFF_UPSAMPLED; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - if (td->td_photometric == PHOTOMETRIC_YCBCR && - sp->jpegcolormode == JPEGCOLORMODE_RGB) { - tif->tif_flags |= TIFF_UPSAMPLED; - } else { - if (td->td_ycbcrsubsampling[0] != 1 || - td->td_ycbcrsubsampling[1] != 1) - ; /* XXX what about up-sampling? */ - } - } - /* - * Must recalculate cached tile size - * in case sampling state changed. - */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; + sp->jpegcolormode = (int) va_arg(ap, int); + JPEGResetUpsampled( tif ); return (1); /* pseudo tag */ + case TIFFTAG_PHOTOMETRIC: + { + int ret_value = (*sp->vsetparent)(tif, tag, ap); + JPEGResetUpsampled( tif ); + return ret_value; + } case TIFFTAG_JPEGTABLESMODE: - sp->jpegtablesmode = va_arg(ap, int); + sp->jpegtablesmode = (int) va_arg(ap, int); return (1); /* pseudo tag */ case TIFFTAG_YCBCRSUBSAMPLING: - /* mark the fact that we have a real ycbcrsubsampling! */ + /* mark the fact that we have a real ycbcrsubsampling! */ sp->ycbcrsampling_fetched = 1; + /* should we be recomputing upsampling info here? */ return (*sp->vsetparent)(tif, tag, ap); - case TIFFTAG_FAXRECVPARAMS: - sp->recvparams = va_arg(ap, uint32); - break; - case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&sp->subaddress, va_arg(ap, char*)); - break; - case TIFFTAG_FAXRECVTIME: - sp->recvtime = va_arg(ap, uint32); - break; - case TIFFTAG_FAXDCS: - _TIFFsetString(&sp->faxdcs, va_arg(ap, char*)); - break; default: return (*sp->vsetparent)(tif, tag, ap); } - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); + + if ((fip = TIFFFieldWithTag(tif, tag))) { + TIFFSetFieldBit(tif, fip->field_bit); + } else { + return (0); + } + tif->tif_flags |= TIFF_DIRTYDIRECT; return (1); } -/* - * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in - * the TIFF tags, but still use non-default (2,2) values within the jpeg - * data stream itself. In order for TIFF applications to work properly - * - for instance to get the strip buffer size right - it is imperative - * that the subsampling be available before we start reading the image - * data normally. This function will attempt to load the first strip in - * order to get the sampling values from the jpeg data stream. Various - * hacks are various places are done to ensure this function gets called - * before the td_ycbcrsubsampling values are used from the directory structure, - * including calling TIFFGetField() for the YCBCRSUBSAMPLING field from - * TIFFStripSize(), and the printing code in tif_print.c. - * - * Note that JPEGPreDeocode() will produce a fairly loud warning when the - * discovered sampling does not match the default sampling (2,2) or whatever - * was actually in the tiff tags. - * - * Problems: - * o This code will cause one whole strip/tile of compressed data to be - * loaded just to get the tags right, even if the imagery is never read. - * It would be more efficient to just load a bit of the header, and - * initialize things from that. - * - * See the bug in bugzilla for details: - * - * http://bugzilla.remotesensing.org/show_bug.cgi?id=168 - * - * Frank Warmerdam, July 2002 - */ - -static void -JPEGFixupTestSubsampling( TIFF * tif ) -{ -#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - JPEGInitializeLibJPEG( tif, 0, 0 ); - - /* - * Some JPEG-in-TIFF files don't provide the ycbcrsampling tags, - * and use a sampling schema other than the default 2,2. To handle - * this we actually have to scan the header of a strip or tile of - * jpeg data to get the sampling. - */ - if( !sp->cinfo.comm.is_decompressor - || sp->ycbcrsampling_fetched - || td->td_photometric != PHOTOMETRIC_YCBCR ) - return; - - sp->ycbcrsampling_fetched = 1; - if( TIFFIsTiled( tif ) ) - { - if( !TIFFFillTile( tif, 0 ) ) - return; - } - else - { - if( !TIFFFillStrip( tif, 0 ) ) - return; - } - - TIFFSetField( tif, TIFFTAG_YCBCRSUBSAMPLING, - (uint16) sp->h_sampling, (uint16) sp->v_sampling ); -#endif /* CHECK_JPEG_YCBCR_SUBSAMPLING */ -} - static int -JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap) +JPEGVGetField(TIFF* tif, uint32 tag, va_list ap) { JPEGState* sp = JState(tif); @@ -1699,22 +2088,6 @@ JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap) case TIFFTAG_JPEGTABLESMODE: *va_arg(ap, int*) = sp->jpegtablesmode; break; - case TIFFTAG_YCBCRSUBSAMPLING: - JPEGFixupTestSubsampling( tif ); - return (*sp->vgetparent)(tif, tag, ap); - break; - case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = sp->recvparams; - break; - case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = sp->subaddress; - break; - case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = sp->recvtime; - break; - case TIFFTAG_FAXDCS: - *va_arg(ap, char**) = sp->faxdcs; - break; default: return (*sp->vgetparent)(tif, tag, ap); } @@ -1727,21 +2100,15 @@ JPEGPrintDir(TIFF* tif, FILE* fd, long flags) JPEGState* sp = JState(tif); assert(sp != NULL); - (void) flags; - if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (unsigned long) sp->jpegtables_length); - if (TIFFFieldSet(tif,FIELD_RECVPARAMS)) - fprintf(fd, " Fax Receive Parameters: %08lx\n", - (unsigned long) sp->recvparams); - if (TIFFFieldSet(tif,FIELD_SUBADDRESS)) - fprintf(fd, " Fax SubAddress: %s\n", sp->subaddress); - if (TIFFFieldSet(tif,FIELD_RECVTIME)) - fprintf(fd, " Fax Receive Time: %lu secs\n", - (unsigned long) sp->recvtime); - if (TIFFFieldSet(tif,FIELD_FAXDCS)) - fprintf(fd, " Fax DCS: %s\n", sp->faxdcs); + + if( sp != NULL ) { + if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) + fprintf(fd, " JPEG Tables: (%lu bytes)\n", + (unsigned long) sp->jpegtables_length); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); + } } static uint32 @@ -1752,7 +2119,7 @@ JPEGDefaultStripSize(TIFF* tif, uint32 s) s = (*sp->defsparent)(tif, s); if (s < td->td_imagelength) - s = TIFFroundup(s, td->td_ycbcrsubsampling[1] * DCTSIZE); + s = TIFFroundup_32(s, td->td_ycbcrsubsampling[1] * DCTSIZE); return (s); } @@ -1763,8 +2130,8 @@ JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) TIFFDirectory *td = &tif->tif_dir; (*sp->deftparent)(tif, tw, th); - *tw = TIFFroundup(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); - *th = TIFFroundup(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); + *tw = TIFFroundup_32(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); + *th = TIFFroundup_32(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); } /* @@ -1789,44 +2156,21 @@ JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) * NFW, Feb 3rd, 2003. */ -static int JPEGInitializeLibJPEG( TIFF * tif, int force_encode, int force_decode ) +static int JPEGInitializeLibJPEG( TIFF * tif, int decompress ) { JPEGState* sp = JState(tif); - uint32 *byte_counts = NULL; - int data_is_empty = TRUE; - int decompress; - if( sp->cinfo_initialized ) - return 1; - - /* - * Do we have tile data already? Make sure we initialize the - * the state in decompressor mode if we have tile data, even if we - * are not in read-only file access mode. - */ - if( TIFFIsTiled( tif ) - && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &byte_counts ) - && byte_counts != NULL ) + if(sp->cinfo_initialized) { - data_is_empty = byte_counts[0] == 0; - } - if( !TIFFIsTiled( tif ) - && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &byte_counts) - && byte_counts != NULL ) - { - data_is_empty = byte_counts[0] == 0; - } + if( !decompress && sp->cinfo.comm.is_decompressor ) + TIFFjpeg_destroy( sp ); + else if( decompress && !sp->cinfo.comm.is_decompressor ) + TIFFjpeg_destroy( sp ); + else + return 1; - if( force_decode ) - decompress = 1; - else if( force_encode ) - decompress = 0; - else if( tif->tif_mode == O_RDONLY ) - decompress = 1; - else if( data_is_empty ) - decompress = 0; - else - decompress = 1; + sp->cinfo_initialized = 0; + } /* * Initialize libjpeg. @@ -1834,7 +2178,6 @@ static int JPEGInitializeLibJPEG( TIFF * tif, int force_encode, int force_decode if ( decompress ) { if (!TIFFjpeg_create_decompress(sp)) return (0); - } else { if (!TIFFjpeg_create_compress(sp)) return (0); @@ -1852,29 +2195,39 @@ TIFFInitJPEG(TIFF* tif, int scheme) assert(scheme == COMPRESSION_JPEG); + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, jpegFields, TIFFArrayCount(jpegFields))) { + TIFFErrorExt(tif->tif_clientdata, + "TIFFInitJPEG", + "Merging JPEG codec-specific tags failed"); + return 0; + } + /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (JPEGState)); + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (JPEGState)); if (tif->tif_data == NULL) { - TIFFErrorExt(tif->tif_clientdata, "TIFFInitJPEG", "No space for JPEG state block"); - return (0); + TIFFErrorExt(tif->tif_clientdata, + "TIFFInitJPEG", "No space for JPEG state block"); + return 0; } - _TIFFmemset( tif->tif_data, 0, sizeof(JPEGState)); + _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState)); sp = JState(tif); sp->tif = tif; /* back link */ /* - * Merge codec-specific tag information and override parent get/set - * field methods. + * Override parent get/set field methods. */ - _TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo)); sp->vgetparent = tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_tagmethods.vsetfield; tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */ + sp->printdir = tif->tif_tagmethods.printdir; tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */ /* Default values for codec-specific fields */ @@ -1883,16 +2236,12 @@ TIFFInitJPEG(TIFF* tif, int scheme) sp->jpegquality = 75; /* Default IJG quality */ sp->jpegcolormode = JPEGCOLORMODE_RAW; sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; - - sp->recvparams = 0; - sp->subaddress = NULL; - sp->faxdcs = NULL; - sp->ycbcrsampling_fetched = 0; /* * Install codec methods. */ + tif->tif_fixuptags = JPEGFixupTags; tif->tif_setupdecode = JPEGSetupDecode; tif->tif_predecode = JPEGPreDecode; tif->tif_decoderow = JPEGDecode; @@ -1903,7 +2252,7 @@ TIFFInitJPEG(TIFF* tif, int scheme) tif->tif_postencode = JPEGPostEncode; tif->tif_encoderow = JPEGEncode; tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; + tif->tif_encodetile = JPEGEncode; tif->tif_cleanup = JPEGCleanup; sp->defsparent = tif->tif_defstripsize; tif->tif_defstripsize = JPEGDefaultStripSize; @@ -1922,21 +2271,31 @@ TIFFInitJPEG(TIFF* tif, int scheme) if( tif->tif_diroff == 0 ) { #define SIZE_OF_JPEGTABLES 2000 +/* +The following line assumes incorrectly that all JPEG-in-TIFF files will have +a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags to be written +when the JPEG data is placed with TIFFWriteRawStrip. The field bit should be +set, anyway, later when actual JPEGTABLES header is generated, so removing it +here hopefully is harmless. TIFFSetFieldBit(tif, FIELD_JPEGTABLES); +*/ sp->jpegtables_length = SIZE_OF_JPEGTABLES; sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); + // FIXME: NULL-deref after malloc failure _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); #undef SIZE_OF_JPEGTABLES } - /* - * Mark the TIFFTAG_YCBCRSAMPLES as present even if it is not - * see: JPEGFixupTestSubsampling(). - */ - TIFFSetFieldBit( tif, FIELD_YCBCRSUBSAMPLING ); - return 1; } #endif /* JPEG_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_jpeg_12.c b/libs/tiff-4.0.2/libtiff/tif_jpeg_12.c new file mode 100644 index 0000000000..87aaa19e0b --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_jpeg_12.c @@ -0,0 +1,65 @@ + +#include "tiffiop.h" + +#if defined(JPEG_DUAL_MODE_8_12) + +# define TIFFInitJPEG TIFFInitJPEG_12 + +# include LIBJPEG_12_PATH + +# include "tif_jpeg.c" + +int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ) + +{ + JPEGState* sp; + + assert(scheme == COMPRESSION_JPEG); + + sp = JState(tif); + sp->tif = tif; /* back link */ + + /* + * Override parent get/set field methods. + */ + tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */ + tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */ + tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */ + + /* + * Install codec methods. + */ + tif->tif_fixuptags = JPEGFixupTags; + tif->tif_setupdecode = JPEGSetupDecode; + tif->tif_predecode = JPEGPreDecode; + tif->tif_decoderow = JPEGDecode; + tif->tif_decodestrip = JPEGDecode; + tif->tif_decodetile = JPEGDecode; + tif->tif_setupencode = JPEGSetupEncode; + tif->tif_preencode = JPEGPreEncode; + tif->tif_postencode = JPEGPostEncode; + tif->tif_encoderow = JPEGEncode; + tif->tif_encodestrip = JPEGEncode; + tif->tif_encodetile = JPEGEncode; + tif->tif_cleanup = JPEGCleanup; + tif->tif_defstripsize = JPEGDefaultStripSize; + tif->tif_deftilesize = JPEGDefaultTileSize; + tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ + + sp->cinfo_initialized = FALSE; + + if( is_encode ) + return JPEGSetupEncode(tif); + else + return JPEGSetupDecode(tif); +} + +#endif /* defined(JPEG_DUAL_MODE_8_12) */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_luv.c b/libs/tiff-4.0.2/libtiff/tif_luv.c similarity index 77% rename from libs/tiff-3.8.2/libtiff/tif_luv.c rename to libs/tiff-4.0.2/libtiff/tif_luv.c index eea2d7ea01..eba6c08ebd 100644 --- a/libs/tiff-3.8.2/libtiff/tif_luv.c +++ b/libs/tiff-4.0.2/libtiff/tif_luv.c @@ -1,4 +1,4 @@ -/* $Id: tif_luv.c,v 1.17 2006/03/16 12:38:24 dron Exp $ */ +/* $Id: tif_luv.c,v 1.35 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1997 Greg Ward Larson @@ -155,40 +155,44 @@ * State block for each open TIFF * file using LogLuv compression/decompression. */ -typedef struct logLuvState LogLuvState; +typedef struct logLuvState LogLuvState; struct logLuvState { - int user_datafmt; /* user data format */ - int encode_meth; /* encoding method */ - int pixel_size; /* bytes per pixel */ + int user_datafmt; /* user data format */ + int encode_meth; /* encoding method */ + int pixel_size; /* bytes per pixel */ - tidata_t* tbuf; /* translation buffer */ - int tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState*, tidata_t, int); + uint8* tbuf; /* translation buffer */ + tmsize_t tbuflen; /* buffer length */ + void (*tfunc)(LogLuvState*, uint8*, tmsize_t); - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + TIFFVSetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ }; -#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data) -#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data) +#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data) +#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data) -#define SGILOGDATAFMT_UNKNOWN -1 +#define SGILOGDATAFMT_UNKNOWN -1 -#define MINRUN 4 /* minimum run length */ +#define MINRUN 4 /* minimum run length */ /* * Decode a string of 16-bit gray pixels. */ static int -LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { + static const char module[] = "LogL16Decode"; LogLuvState* sp = DecoderState(tif); - int shft, i, npixels; + int shft; + tmsize_t i; + tmsize_t npixels; unsigned char* bp; int16* tp; int16 b; - int cc, rc; + tmsize_t cc; + int rc; assert(s == 0); assert(sp != NULL); @@ -201,15 +205,15 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) assert(sp->tbuflen >= npixels); tp = (int16*) sp->tbuf; } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); + _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); bp = (unsigned char*) tif->tif_rawcp; cc = tif->tif_rawcc; - /* get each byte string */ + /* get each byte string */ for (shft = 2*8; (shft -= 8) >= 0; ) { for (i = 0; i < npixels && cc > 0; ) if (*bp >= 128) { /* run */ - rc = *bp++ + (2-128); + rc = *bp++ + (2-128); /* TODO: potential input buffer overrun when decoding corrupt or truncated data */ b = (int16)(*bp++ << shft); cc -= 2; while (rc-- && i < npixels) @@ -220,16 +224,24 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) tp[i++] |= (int16)*bp++ << shft; } if (i != npixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LogL16Decode: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - tif->tif_rawcp = (tidata_t) bp; +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at row %lu (short %I64d pixels)", + (unsigned long) tif->tif_row, + (unsigned __int64) (npixels - i)); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at row %lu (short %llu pixels)", + (unsigned long) tif->tif_row, + (unsigned long long) (npixels - i)); +#endif + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; return (1); } @@ -238,10 +250,13 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) * Decode a string of 24-bit pixels. */ static int -LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { + static const char module[] = "LogLuvDecode24"; LogLuvState* sp = DecoderState(tif); - int cc, i, npixels; + tmsize_t cc; + tmsize_t i; + tmsize_t npixels; unsigned char* bp; uint32* tp; @@ -256,7 +271,7 @@ LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) assert(sp->tbuflen >= npixels); tp = (uint32 *) sp->tbuf; } - /* copy to array of uint32 */ + /* copy to array of uint32 */ bp = (unsigned char*) tif->tif_rawcp; cc = tif->tif_rawcc; for (i = 0; i < npixels && cc > 0; i++) { @@ -264,12 +279,20 @@ LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) bp += 3; cc -= 3; } - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; if (i != npixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LogLuvDecode24: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at row %lu (short %I64d pixels)", + (unsigned long) tif->tif_row, + (unsigned __int64) (npixels - i)); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at row %lu (short %llu pixels)", + (unsigned long) tif->tif_row, + (unsigned long long) (npixels - i)); +#endif return (0); } (*sp->tfunc)(sp, op, npixels); @@ -280,14 +303,18 @@ LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) * Decode a string of 32-bit pixels. */ static int -LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { + static const char module[] = "LogLuvDecode32"; LogLuvState* sp; - int shft, i, npixels; + int shft; + tmsize_t i; + tmsize_t npixels; unsigned char* bp; uint32* tp; uint32 b; - int cc, rc; + tmsize_t cc; + int rc; assert(s == 0); sp = DecoderState(tif); @@ -301,17 +328,17 @@ LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) assert(sp->tbuflen >= npixels); tp = (uint32*) sp->tbuf; } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); + _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); bp = (unsigned char*) tif->tif_rawcp; cc = tif->tif_rawcc; - /* get each byte string */ + /* get each byte string */ for (shft = 4*8; (shft -= 8) >= 0; ) { for (i = 0; i < npixels && cc > 0; ) if (*bp >= 128) { /* run */ rc = *bp++ + (2-128); b = (uint32)*bp++ << shft; - cc -= 2; + cc -= 2; /* TODO: potential input buffer overrun when decoding corrupt or truncated data */ while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ @@ -320,16 +347,24 @@ LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) tp[i++] |= (uint32)*bp++ << shft; } if (i != npixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LogLuvDecode32: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - tif->tif_rawcp = (tidata_t) bp; +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at row %lu (short %I64d pixels)", + (unsigned long) tif->tif_row, + (unsigned __int64) (npixels - i)); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at row %lu (short %llu pixels)", + (unsigned long) tif->tif_row, + (unsigned long long) (npixels - i)); +#endif + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; return (1); } @@ -340,9 +375,9 @@ LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) * is row by row. */ static int -LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tsize_t rowlen = TIFFScanlineSize(tif); + tmsize_t rowlen = TIFFScanlineSize(tif); assert(cc%rowlen == 0); while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) @@ -356,9 +391,9 @@ LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * is row by row. */ static int -LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tsize_t rowlen = TIFFTileRowSize(tif); + tmsize_t rowlen = TIFFTileRowSize(tif); assert(cc%rowlen == 0); while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) @@ -370,14 +405,19 @@ LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * Encode a row of 16-bit pixels. */ static int -LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { LogLuvState* sp = EncoderState(tif); - int shft, i, j, npixels; - tidata_t op; + int shft; + tmsize_t i; + tmsize_t j; + tmsize_t npixels; + uint8* op; int16* tp; int16 b; - int occ, rc=0, mask, beg; + tmsize_t occ; + int rc=0, mask; + tmsize_t beg; assert(s == 0); assert(sp != NULL); @@ -390,7 +430,7 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) assert(sp->tbuflen >= npixels); (*sp->tfunc)(sp, bp, npixels); } - /* compress each byte string */ + /* compress each byte string */ op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; for (shft = 2*8; (shft -= 8) >= 0; ) @@ -408,7 +448,7 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) b = (int16) (tp[beg] & mask); rc = 1; while (rc < 127+2 && beg+rc < npixels && - (tp[beg+rc] & mask) == b) + (tp[beg+rc] & mask) == b) rc++; if (rc >= MINRUN) break; /* long enough */ @@ -417,33 +457,33 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) b = (int16) (tp[i] & mask);/*check short run */ j = i+1; while ((tp[j++] & mask) == b) - if (j == beg) { - *op++ = (tidataval_t)(128-2+j-i); - *op++ = (tidataval_t) (b >> shft); - occ -= 2; - i = beg; - break; - } + if (j == beg) { + *op++ = (uint8)(128-2+j-i); + *op++ = (uint8)(b >> shft); + occ -= 2; + i = beg; + break; + } } while (i < beg) { /* write out non-run */ if ((j = beg-i) > 127) j = 127; if (occ < j+3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (tidataval_t) j; occ--; + *op++ = (uint8) j; occ--; while (j--) { - *op++ = (tidataval_t) (tp[i++] >> shft & 0xff); + *op++ = (uint8) (tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (tidataval_t) (128-2+rc); - *op++ = (tidataval_t) (tp[beg] >> shft & 0xff); + *op++ = (uint8) (128-2+rc); + *op++ = (uint8) (tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -451,18 +491,20 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) tif->tif_rawcp = op; tif->tif_rawcc = tif->tif_rawdatasize - occ; - return (0); + return (1); } /* * Encode a row of 24-bit pixels. */ static int -LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { LogLuvState* sp = EncoderState(tif); - int i, npixels, occ; - tidata_t op; + tmsize_t i; + tmsize_t npixels; + tmsize_t occ; + uint8* op; uint32* tp; assert(s == 0); @@ -476,7 +518,7 @@ LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) assert(sp->tbuflen >= npixels); (*sp->tfunc)(sp, bp, npixels); } - /* write out encoded pixels */ + /* write out encoded pixels */ op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; for (i = npixels; i--; ) { @@ -488,29 +530,34 @@ LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (tidataval_t)(*tp >> 16); - *op++ = (tidataval_t)(*tp >> 8 & 0xff); - *op++ = (tidataval_t)(*tp++ & 0xff); + *op++ = (uint8)(*tp >> 16); + *op++ = (uint8)(*tp >> 8 & 0xff); + *op++ = (uint8)(*tp++ & 0xff); occ -= 3; } tif->tif_rawcp = op; tif->tif_rawcc = tif->tif_rawdatasize - occ; - return (0); + return (1); } /* * Encode a row of 32-bit pixels. */ static int -LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { LogLuvState* sp = EncoderState(tif); - int shft, i, j, npixels; - tidata_t op; + int shft; + tmsize_t i; + tmsize_t j; + tmsize_t npixels; + uint8* op; uint32* tp; uint32 b; - int occ, rc=0, mask, beg; + tmsize_t occ; + int rc=0, mask; + tmsize_t beg; assert(s == 0); assert(sp != NULL); @@ -524,7 +571,7 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) assert(sp->tbuflen >= npixels); (*sp->tfunc)(sp, bp, npixels); } - /* compress each byte string */ + /* compress each byte string */ op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; for (shft = 4*8; (shft -= 8) >= 0; ) @@ -552,8 +599,8 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (tidataval_t)(128-2+j-i); - *op++ = (tidataval_t)(b >> shft); + *op++ = (uint8)(128-2+j-i); + *op++ = (uint8)(b >> shft); occ -= 2; i = beg; break; @@ -569,15 +616,15 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (tidataval_t) j; occ--; + *op++ = (uint8) j; occ--; while (j--) { - *op++ = (tidataval_t)(tp[i++] >> shft & 0xff); + *op++ = (uint8)(tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (tidataval_t) (128-2+rc); - *op++ = (tidataval_t)(tp[beg] >> shft & 0xff); + *op++ = (uint8) (128-2+rc); + *op++ = (uint8)(tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -585,7 +632,7 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) tif->tif_rawcp = op; tif->tif_rawcc = tif->tif_rawdatasize - occ; - return (0); + return (1); } /* @@ -593,12 +640,12 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tsize_t rowlen = TIFFScanlineSize(tif); + tmsize_t rowlen = TIFFScanlineSize(tif); assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) bp += rowlen, cc -= rowlen; return (cc == 0); } @@ -608,12 +655,12 @@ LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tsize_t rowlen = TIFFTileRowSize(tif); + tmsize_t rowlen = TIFFTileRowSize(tif); assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) bp += rowlen, cc -= rowlen; return (cc == 0); } @@ -676,7 +723,7 @@ LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ } static void -L16toY(LogLuvState* sp, tidata_t op, int n) +L16toY(LogLuvState* sp, uint8* op, tmsize_t n) { int16* l16 = (int16*) sp->tbuf; float* yp = (float*) op; @@ -686,7 +733,7 @@ L16toY(LogLuvState* sp, tidata_t op, int n) } static void -L16toGry(LogLuvState* sp, tidata_t op, int n) +L16toGry(LogLuvState* sp, uint8* op, tmsize_t n) { int16* l16 = (int16*) sp->tbuf; uint8* gp = (uint8*) op; @@ -698,7 +745,7 @@ L16toGry(LogLuvState* sp, tidata_t op, int n) } static void -L16fromY(LogLuvState* sp, tidata_t op, int n) +L16fromY(LogLuvState* sp, uint8* op, tmsize_t n) { int16* l16 = (int16*) sp->tbuf; float* yp = (float*) op; @@ -760,7 +807,7 @@ oog_encode(double u, double v) /* encode out-of-gamut chroma */ static int oog_table[NANGLES]; static int initialized = 0; register int i; - + if (!initialized) { /* set up perimeter table */ double eps[NANGLES], ua, va, ang, epsa; int ui, vi, ustep; @@ -774,7 +821,7 @@ oog_encode(double u, double v) /* encode out-of-gamut chroma */ for (ui = uv_row[vi].nus-1; ui >= 0; ui -= ustep) { ua = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; ang = uv2ang(ua, va); - i = (int) ang; + i = (int) ang; epsa = fabs(ang - (i+.5)); if (epsa < eps[i]) { oog_table[i] = uv_row[vi].ncum + ui; @@ -916,9 +963,9 @@ LogLuv24fromXYZ(float XYZ[3], int em) } static void -Luv24toXYZ(LogLuvState* sp, tidata_t op, int n) +Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -929,9 +976,9 @@ Luv24toXYZ(LogLuvState* sp, tidata_t op, int n) } static void -Luv24toLuv48(LogLuvState* sp, tidata_t op, int n) +Luv24toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; int16* luv3 = (int16*) op; while (n-- > 0) { @@ -949,9 +996,9 @@ Luv24toLuv48(LogLuvState* sp, tidata_t op, int n) } static void -Luv24toRGB(LogLuvState* sp, tidata_t op, int n) +Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; uint8* rgb = (uint8*) op; while (n-- > 0) { @@ -964,9 +1011,9 @@ Luv24toRGB(LogLuvState* sp, tidata_t op, int n) } static void -Luv24fromXYZ(LogLuvState* sp, tidata_t op, int n) +Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -976,9 +1023,9 @@ Luv24fromXYZ(LogLuvState* sp, tidata_t op, int n) } static void -Luv24fromLuv48(LogLuvState* sp, tidata_t op, int n) +Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; int16* luv3 = (int16*) op; while (n-- > 0) { @@ -1057,9 +1104,9 @@ LogLuv32fromXYZ(float XYZ[3], int em) } static void -Luv32toXYZ(LogLuvState* sp, tidata_t op, int n) +Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1069,9 +1116,9 @@ Luv32toXYZ(LogLuvState* sp, tidata_t op, int n) } static void -Luv32toLuv48(LogLuvState* sp, tidata_t op, int n) +Luv32toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; int16* luv3 = (int16*) op; while (n-- > 0) { @@ -1087,9 +1134,9 @@ Luv32toLuv48(LogLuvState* sp, tidata_t op, int n) } static void -Luv32toRGB(LogLuvState* sp, tidata_t op, int n) +Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; uint8* rgb = (uint8*) op; while (n-- > 0) { @@ -1102,9 +1149,9 @@ Luv32toRGB(LogLuvState* sp, tidata_t op, int n) } static void -Luv32fromXYZ(LogLuvState* sp, tidata_t op, int n) +Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32* luv = (uint32*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1114,7 +1161,7 @@ Luv32fromXYZ(LogLuvState* sp, tidata_t op, int n) } static void -Luv32fromLuv48(LogLuvState* sp, tidata_t op, int n) +Luv32fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { uint32* luv = (uint32*) sp->tbuf; int16* luv3 = (int16*) op; @@ -1137,7 +1184,7 @@ Luv32fromLuv48(LogLuvState* sp, tidata_t op, int n) } static void -_logLuvNop(LogLuvState* sp, tidata_t op, int n) +_logLuvNop(LogLuvState* sp, uint8* op, tmsize_t n) { (void) sp; (void) op; (void) n; } @@ -1161,10 +1208,10 @@ LogL16GuessDataFmt(TIFFDirectory *td) return (SGILOGDATAFMT_UNKNOWN); } -static uint32 -multiply(size_t m1, size_t m2) +static tmsize_t +multiply_ms(tmsize_t m1, tmsize_t m2) { - uint32 bytes = m1 * m2; + tmsize_t bytes = m1 * m2; if (m1 && bytes / m1 != m2) bytes = 0; @@ -1175,9 +1222,9 @@ multiply(size_t m1, size_t m2) static int LogL16InitState(TIFF* tif) { + static const char module[] = "LogL16InitState"; TIFFDirectory *td = &tif->tif_dir; LogLuvState* sp = DecoderState(tif); - static const char module[] = "LogL16InitState"; assert(sp != NULL); assert(td->td_photometric == PHOTOMETRIC_LOGL); @@ -1196,15 +1243,17 @@ LogL16InitState(TIFF* tif) sp->pixel_size = sizeof (uint8); break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "No support for converting user data format to LogL"); return (0); } - sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip); - if (multiply(sp->tbuflen, sizeof (int16)) == 0 || - (sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer", - tif->tif_name); + if( isTiled(tif) ) + sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength); + else + sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); + if (multiply_ms(sp->tbuflen, sizeof (int16)) == 0 || + (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } return (1); @@ -1265,9 +1314,9 @@ LogLuvGuessDataFmt(TIFFDirectory *td) static int LogLuvInitState(TIFF* tif) { + static const char module[] = "LogLuvInitState"; TIFFDirectory* td = &tif->tif_dir; LogLuvState* sp = DecoderState(tif); - static const char module[] = "LogLuvInitState"; assert(sp != NULL); assert(td->td_photometric == PHOTOMETRIC_LOGLUV); @@ -1294,23 +1343,33 @@ LogLuvInitState(TIFF* tif) sp->pixel_size = 3*sizeof (uint8); break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "No support for converting user data format to LogLuv"); return (0); } - sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip); - if (multiply(sp->tbuflen, sizeof (uint32)) == 0 || - (sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer", - tif->tif_name); + if( isTiled(tif) ) + sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength); + else + sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); + if (multiply_ms(sp->tbuflen, sizeof (uint32)) == 0 || + (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } return (1); } +static int +LogLuvFixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} + static int LogLuvSetupDecode(TIFF* tif) { + static const char module[] = "LogLuvSetupDecode"; LogLuvState* sp = DecoderState(tif); TIFFDirectory* td = &tif->tif_dir; @@ -1323,10 +1382,10 @@ LogLuvSetupDecode(TIFF* tif) tif->tif_decoderow = LogLuvDecode24; switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24toXYZ; + sp->tfunc = Luv24toXYZ; break; case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24toLuv48; + sp->tfunc = Luv24toLuv48; break; case SGILOGDATAFMT_8BIT: sp->tfunc = Luv24toRGB; @@ -1361,8 +1420,8 @@ LogLuvSetupDecode(TIFF* tif) } return (1); default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + TIFFErrorExt(tif->tif_clientdata, module, + "Inappropriate photometric interpretation %d for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); break; } @@ -1372,6 +1431,7 @@ LogLuvSetupDecode(TIFF* tif) static int LogLuvSetupEncode(TIFF* tif) { + static const char module[] = "LogLuvSetupEncode"; LogLuvState* sp = EncoderState(tif); TIFFDirectory* td = &tif->tif_dir; @@ -1386,7 +1446,7 @@ LogLuvSetupEncode(TIFF* tif) sp->tfunc = Luv24fromXYZ; break; case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24fromLuv48; + sp->tfunc = Luv24fromLuv48; break; case SGILOGDATAFMT_RAW: break; @@ -1394,13 +1454,13 @@ LogLuvSetupEncode(TIFF* tif) goto notsupported; } } else { - tif->tif_encoderow = LogLuvEncode32; + tif->tif_encoderow = LogLuvEncode32; switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32fromXYZ; + sp->tfunc = Luv32fromXYZ; break; case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32fromLuv48; + sp->tfunc = Luv32fromLuv48; break; case SGILOGDATAFMT_RAW: break; @@ -1412,7 +1472,7 @@ LogLuvSetupEncode(TIFF* tif) case PHOTOMETRIC_LOGL: if (!LogL16InitState(tif)) break; - tif->tif_encoderow = LogL16Encode; + tif->tif_encoderow = LogL16Encode; switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = L16fromY; @@ -1424,14 +1484,14 @@ LogLuvSetupEncode(TIFF* tif) } break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Inappropriate photometric interpretation %d for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); + TIFFErrorExt(tif->tif_clientdata, module, + "Inappropriate photometric interpretation %d for SGILog compression; %s", + td->td_photometric, "must be either LogLUV or LogL"); break; } return (1); notsupported: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "SGILog compression supported only for %s, or raw data", td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv"); return (0); @@ -1474,14 +1534,15 @@ LogLuvCleanup(TIFF* tif) } static int -LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap) +LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) { + static const char module[] = "LogLuvVSetField"; LogLuvState* sp = DecoderState(tif); int bps, fmt; switch (tag) { case TIFFTAG_SGILOGDATAFMT: - sp->user_datafmt = va_arg(ap, int); + sp->user_datafmt = (int) va_arg(ap, int); /* * Tweak the TIFF header so that the rest of libtiff knows what * size of data will be passed between app and library, and @@ -1513,16 +1574,16 @@ LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap) /* * Must recalculate sizes should bits/sample change. */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t) -1; tif->tif_scanlinesize = TIFFScanlineSize(tif); return (1); case TIFFTAG_SGILOGENCODE: - sp->encode_meth = va_arg(ap, int); + sp->encode_meth = (int) va_arg(ap, int); if (sp->encode_meth != SGILOGENCODE_NODITHER && - sp->encode_meth != SGILOGENCODE_RANDITHER) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Unknown encoding %d for LogLuv compression", - sp->encode_meth); + sp->encode_meth != SGILOGENCODE_RANDITHER) { + TIFFErrorExt(tif->tif_clientdata, module, + "Unknown encoding %d for LogLuv compression", + sp->encode_meth); return (0); } return (1); @@ -1532,7 +1593,7 @@ LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap) } static int -LogLuvVGetField(TIFF* tif, ttag_t tag, va_list ap) +LogLuvVGetField(TIFF* tif, uint32 tag, va_list ap) { LogLuvState *sp = (LogLuvState *)tif->tif_data; @@ -1545,11 +1606,9 @@ LogLuvVGetField(TIFF* tif, ttag_t tag, va_list ap) } } -static const TIFFFieldInfo LogLuvFieldInfo[] = { - { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, FIELD_PSEUDO, - TRUE, FALSE, "SGILogDataFmt"}, - { TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, FIELD_PSEUDO, - TRUE, FALSE, "SGILogEncode"} +static const TIFFField LogLuvFields[] = { + { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogDataFmt", NULL}, + { TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogEncode", NULL} }; int @@ -1560,17 +1619,27 @@ TIFFInitSGILog(TIFF* tif, int scheme) assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG); + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, LogLuvFields, + TIFFArrayCount(LogLuvFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging SGILog codec-specific tags failed"); + return 0; + } + /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LogLuvState)); + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LogLuvState)); if (tif->tif_data == NULL) goto bad; sp = (LogLuvState*) tif->tif_data; - _TIFFmemset((tdata_t)sp, 0, sizeof (*sp)); + _TIFFmemset((void*)sp, 0, sizeof (*sp)); sp->user_datafmt = SGILOGDATAFMT_UNKNOWN; sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? - SGILOGENCODE_RANDITHER : SGILOGENCODE_NODITHER; + SGILOGENCODE_RANDITHER : SGILOGENCODE_NODITHER; sp->tfunc = _logLuvNop; /* @@ -1578,18 +1647,19 @@ TIFFInitSGILog(TIFF* tif, int scheme) * NB: tif_decoderow & tif_encoderow are filled * in at setup time. */ + tif->tif_fixuptags = LogLuvFixupTags; tif->tif_setupdecode = LogLuvSetupDecode; tif->tif_decodestrip = LogLuvDecodeStrip; tif->tif_decodetile = LogLuvDecodeTile; tif->tif_setupencode = LogLuvSetupEncode; - tif->tif_encodestrip = LogLuvEncodeStrip; + tif->tif_encodestrip = LogLuvEncodeStrip; tif->tif_encodetile = LogLuvEncodeTile; tif->tif_close = LogLuvClose; tif->tif_cleanup = LogLuvCleanup; - /* override SetField so we can handle our private pseudo-tag */ - _TIFFMergeFieldInfo(tif, LogLuvFieldInfo, - TIFFArrayCount(LogLuvFieldInfo)); + /* + * Override parent get/set field methods. + */ sp->vgetparent = tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_tagmethods.vsetfield; @@ -1604,3 +1674,10 @@ bad: #endif /* LOGLUV_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_lzma.c b/libs/tiff-4.0.2/libtiff/tif_lzma.c new file mode 100644 index 0000000000..dedf1d948b --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_lzma.c @@ -0,0 +1,495 @@ +/* $Id: tif_lzma.c,v 1.4 2011-12-22 00:29:29 bfriesen Exp $ */ + +/* + * Copyright (c) 2010, Andrey Kiselev + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef LZMA_SUPPORT +/* + * TIFF Library. + * + * LZMA2 Compression Support + * + * You need an LZMA2 SDK to link with. See http://tukaani.org/xz/ for details. + * + * The codec is derived from ZLIB codec (tif_zip.c). + */ + +#include "tif_predict.h" +#include "lzma.h" + +#include + +/* + * State block for each open TIFF file using LZMA2 compression/decompression. + */ +typedef struct { + TIFFPredictorState predict; + lzma_stream stream; + lzma_filter filters[LZMA_FILTERS_MAX + 1]; + lzma_options_delta opt_delta; /* delta filter options */ + lzma_options_lzma opt_lzma; /* LZMA2 filter options */ + int preset; /* compression level */ + lzma_check check; /* type of the integrity check */ + int state; /* state flags */ +#define LSTATE_INIT_DECODE 0x01 +#define LSTATE_INIT_ENCODE 0x02 + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ +} LZMAState; + +#define LState(tif) ((LZMAState*) (tif)->tif_data) +#define DecoderState(tif) LState(tif) +#define EncoderState(tif) LState(tif) + +static int LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); + +static const char * +LZMAStrerror(lzma_ret ret) +{ + switch (ret) { + case LZMA_OK: + return "operation completed successfully"; + case LZMA_STREAM_END: + return "end of stream was reached"; + case LZMA_NO_CHECK: + return "input stream has no integrity check"; + case LZMA_UNSUPPORTED_CHECK: + return "cannot calculate the integrity check"; + case LZMA_GET_CHECK: + return "integrity check type is now available"; + case LZMA_MEM_ERROR: + return "cannot allocate memory"; + case LZMA_MEMLIMIT_ERROR: + return "memory usage limit was reached"; + case LZMA_FORMAT_ERROR: + return "file format not recognized"; + case LZMA_OPTIONS_ERROR: + return "invalid or unsupported options"; + case LZMA_DATA_ERROR: + return "data is corrupt"; + case LZMA_BUF_ERROR: + return "no progress is possible (stream is truncated or corrupt)"; + case LZMA_PROG_ERROR: + return "programming error"; + default: + return "unindentified liblzma error"; + } +} + +static int +LZMAFixupTags(TIFF* tif) +{ + (void) tif; + return 1; +} + +static int +LZMASetupDecode(TIFF* tif) +{ + LZMAState* sp = DecoderState(tif); + + assert(sp != NULL); + + /* if we were last encoding, terminate this mode */ + if (sp->state & LSTATE_INIT_ENCODE) { + lzma_end(&sp->stream); + sp->state = 0; + } + + sp->state |= LSTATE_INIT_DECODE; + return 1; +} + +/* + * Setup state for decoding a strip. + */ +static int +LZMAPreDecode(TIFF* tif, uint16 s) +{ + static const char module[] = "LZMAPreDecode"; + LZMAState* sp = DecoderState(tif); + lzma_ret ret; + + (void) s; + assert(sp != NULL); + + if( (sp->state & LSTATE_INIT_DECODE) == 0 ) + tif->tif_setupdecode(tif); + + sp->stream.next_in = tif->tif_rawdata; + sp->stream.avail_in = (size_t) tif->tif_rawcc; + if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } + + /* + * Disable memory limit when decoding. UINT64_MAX is a flag to disable + * the limit, we are passing (uint64_t)-1 which should be the same. + */ + ret = lzma_stream_decoder(&sp->stream, (uint64_t)-1, 0); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing the stream decoder, %s", + LZMAStrerror(ret)); + return 0; + } + return 1; +} + +static int +LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +{ + static const char module[] = "LZMADecode"; + LZMAState* sp = DecoderState(tif); + + (void) s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_DECODE); + + sp->stream.next_in = tif->tif_rawcp; + sp->stream.avail_in = (size_t) tif->tif_rawcc; + + sp->stream.next_out = op; + sp->stream.avail_out = (size_t) occ; + if ((tmsize_t)sp->stream.avail_out != occ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } + + do { + /* + * Save the current stream state to properly recover from the + * decoding errors later. + */ + const uint8_t *next_in = sp->stream.next_in; + size_t avail_in = sp->stream.avail_in; + + lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); + if (ret == LZMA_STREAM_END) + break; + if (ret == LZMA_MEMLIMIT_ERROR) { + lzma_ret r = lzma_stream_decoder(&sp->stream, + lzma_memusage(&sp->stream), 0); + if (r != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing the stream decoder, %s", + LZMAStrerror(r)); + break; + } + sp->stream.next_in = next_in; + sp->stream.avail_in = avail_in; + continue; + } + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Decoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, LZMAStrerror(ret)); + break; + } + } while (sp->stream.avail_out > 0); + if (sp->stream.avail_out != 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %lu (short %lu bytes)", + (unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out); + return 0; + } + + tif->tif_rawcp = (uint8 *)sp->stream.next_in; /* cast away const */ + tif->tif_rawcc = sp->stream.avail_in; + + return 1; +} + +static int +LZMASetupEncode(TIFF* tif) +{ + LZMAState* sp = EncoderState(tif); + + assert(sp != NULL); + if (sp->state & LSTATE_INIT_DECODE) { + lzma_end(&sp->stream); + sp->state = 0; + } + + sp->state |= LSTATE_INIT_ENCODE; + return 1; +} + +/* + * Reset encoding state at the start of a strip. + */ +static int +LZMAPreEncode(TIFF* tif, uint16 s) +{ + static const char module[] = "LZMAPreEncode"; + LZMAState *sp = EncoderState(tif); + + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_ENCODE ) + tif->tif_setupencode(tif); + + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (size_t)tif->tif_rawdatasize; + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } + return (lzma_stream_encoder(&sp->stream, sp->filters, sp->check) == LZMA_OK); +} + +/* + * Encode a chunk of pixels. + */ +static int +LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +{ + static const char module[] = "LZMAEncode"; + LZMAState *sp = EncoderState(tif); + + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_ENCODE); + + (void) s; + sp->stream.next_in = bp; + sp->stream.avail_in = (size_t) cc; + if ((tmsize_t)sp->stream.avail_in != cc) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } + do { + lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Encoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, LZMAStrerror(ret)); + return 0; + } + if (sp->stream.avail_out == 0) { + tif->tif_rawcc = tif->tif_rawdatasize; + TIFFFlushData1(tif); + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in LZMAPreEncode */ + } + } while (sp->stream.avail_in > 0); + return 1; +} + +/* + * Finish off an encoded strip by flushing the last + * string and tacking on an End Of Information code. + */ +static int +LZMAPostEncode(TIFF* tif) +{ + static const char module[] = "LZMAPostEncode"; + LZMAState *sp = EncoderState(tif); + lzma_ret ret; + + sp->stream.avail_in = 0; + do { + ret = lzma_code(&sp->stream, LZMA_FINISH); + switch (ret) { + case LZMA_STREAM_END: + case LZMA_OK: + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) { + tif->tif_rawcc = + tif->tif_rawdatasize - sp->stream.avail_out; + TIFFFlushData1(tif); + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */ + } + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, "Liblzma error: %s", + LZMAStrerror(ret)); + return 0; + } + } while (ret != LZMA_STREAM_END); + return 1; +} + +static void +LZMACleanup(TIFF* tif) +{ + LZMAState* sp = LState(tif); + + assert(sp != 0); + + (void)TIFFPredictorCleanup(tif); + + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + + if (sp->state) { + lzma_end(&sp->stream); + sp->state = 0; + } + _TIFFfree(sp); + tif->tif_data = NULL; + + _TIFFSetDefaultCompressionState(tif); +} + +static int +LZMAVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + static const char module[] = "LZMAVSetField"; + LZMAState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_LZMAPRESET: + sp->preset = (int) va_arg(ap, int); + lzma_lzma_preset(&sp->opt_lzma, sp->preset); + if (sp->state & LSTATE_INIT_ENCODE) { + lzma_ret ret = lzma_stream_encoder(&sp->stream, + sp->filters, + sp->check); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma error: %s", + LZMAStrerror(ret)); + } + } + return 1; + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ +} + +static int +LZMAVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + LZMAState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_LZMAPRESET: + *va_arg(ap, int*) = sp->preset; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; +} + +static const TIFFField lzmaFields[] = { + { TIFFTAG_LZMAPRESET, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "LZMA2 Compression Preset", NULL }, +}; + +int +TIFFInitLZMA(TIFF* tif, int scheme) +{ + static const char module[] = "TIFFInitLZMA"; + LZMAState* sp; + lzma_stream tmp_stream = LZMA_STREAM_INIT; + + assert( scheme == COMPRESSION_LZMA ); + + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, lzmaFields, TIFFArrayCount(lzmaFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging LZMA2 codec-specific tags failed"); + return 0; + } + + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZMAState)); + if (tif->tif_data == NULL) + goto bad; + sp = LState(tif); + memcpy(&sp->stream, &tmp_stream, sizeof(lzma_stream)); + + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = LZMAVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = LZMAVSetField; /* hook for codec tags */ + + /* Default values for codec-specific fields */ + sp->preset = LZMA_PRESET_DEFAULT; /* default comp. level */ + sp->check = LZMA_CHECK_NONE; + sp->state = 0; + + /* Data filters. So far we are using delta and LZMA2 filters only. */ + sp->opt_delta.type = LZMA_DELTA_TYPE_BYTE; + /* + * The sample size in bytes seems to be reasonable distance for delta + * filter. + */ + sp->opt_delta.dist = (tif->tif_dir.td_bitspersample % 8) ? + 1 : tif->tif_dir.td_bitspersample / 8; + sp->filters[0].id = LZMA_FILTER_DELTA; + sp->filters[0].options = &sp->opt_delta; + + lzma_lzma_preset(&sp->opt_lzma, sp->preset); + sp->filters[1].id = LZMA_FILTER_LZMA2; + sp->filters[1].options = &sp->opt_lzma; + + sp->filters[2].id = LZMA_VLI_UNKNOWN; + sp->filters[2].options = NULL; + + /* + * Install codec methods. + */ + tif->tif_fixuptags = LZMAFixupTags; + tif->tif_setupdecode = LZMASetupDecode; + tif->tif_predecode = LZMAPreDecode; + tif->tif_decoderow = LZMADecode; + tif->tif_decodestrip = LZMADecode; + tif->tif_decodetile = LZMADecode; + tif->tif_setupencode = LZMASetupEncode; + tif->tif_preencode = LZMAPreEncode; + tif->tif_postencode = LZMAPostEncode; + tif->tif_encoderow = LZMAEncode; + tif->tif_encodestrip = LZMAEncode; + tif->tif_encodetile = LZMAEncode; + tif->tif_cleanup = LZMACleanup; + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + return 1; +bad: + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZMA2 state block"); + return 0; +} +#endif /* LZMA_SUPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/libtiff/tif_lzw.c b/libs/tiff-4.0.2/libtiff/tif_lzw.c similarity index 73% rename from libs/tiff-3.8.2/libtiff/tif_lzw.c rename to libs/tiff-4.0.2/libtiff/tif_lzw.c index 1c7b796df0..fd9c7a0a74 100644 --- a/libs/tiff-3.8.2/libtiff/tif_lzw.c +++ b/libs/tiff-4.0.2/libtiff/tif_lzw.c @@ -1,4 +1,4 @@ -/* $Id: tif_lzw.c,v 1.28 2006/03/16 12:38:24 dron Exp $ */ +/* $Id: tif_lzw.c,v 1.45 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -27,7 +27,7 @@ #include "tiffiop.h" #ifdef LZW_SUPPORT /* - * TIFF Library. + * TIFF Library. * Rev 5.0 Lempel-Ziv & Welch Compression Support * * This code is derived from the compress program whose code is @@ -53,34 +53,34 @@ * * Future revisions to the TIFF spec are expected to "clarify this issue". */ -#define LZW_COMPAT /* include backwards compatibility code */ +#define LZW_COMPAT /* include backwards compatibility code */ /* * Each strip of data is supposed to be terminated by a CODE_EOI. * If the following #define is included, the decoder will also * check for end-of-strip w/o seeing this code. This makes the * library more robust, but also slower. */ -#define LZW_CHECKEOS /* include checks for strips w/o EOI code */ +#define LZW_CHECKEOS /* include checks for strips w/o EOI code */ #define MAXCODE(n) ((1L<<(n))-1) /* * The TIFF spec specifies that encoded bit * strings range from 9 to 12 bits. */ -#define BITS_MIN 9 /* start with 9 bits */ -#define BITS_MAX 12 /* max of 12 bit strings */ +#define BITS_MIN 9 /* start with 9 bits */ +#define BITS_MAX 12 /* max of 12 bit strings */ /* predefined codes */ -#define CODE_CLEAR 256 /* code to clear string table */ -#define CODE_EOI 257 /* end-of-information code */ -#define CODE_FIRST 258 /* first free code entry */ -#define CODE_MAX MAXCODE(BITS_MAX) -#define HSIZE 9001L /* 91% occupancy */ -#define HSHIFT (13-8) +#define CODE_CLEAR 256 /* code to clear string table */ +#define CODE_EOI 257 /* end-of-information code */ +#define CODE_FIRST 258 /* first free code entry */ +#define CODE_MAX MAXCODE(BITS_MAX) +#define HSIZE 9001L /* 91% occupancy */ +#define HSHIFT (13-8) #ifdef LZW_COMPAT /* NB: +1024 is for compatibility with old files */ -#define CSIZE (MAXCODE(BITS_MAX)+1024L) +#define CSIZE (MAXCODE(BITS_MAX)+1024L) #else -#define CSIZE (MAXCODE(BITS_MAX)+1L) +#define CSIZE (MAXCODE(BITS_MAX)+1L) #endif /* @@ -88,23 +88,23 @@ * compression/decompression. Note that the predictor * state block must be first in this data structure. */ -typedef struct { - TIFFPredictorState predict; /* predictor super class */ +typedef struct { + TIFFPredictorState predict; /* predictor super class */ - unsigned short nbits; /* # of bits/code */ - unsigned short maxcode; /* maximum code for lzw_nbits */ - unsigned short free_ent; /* next free entry in hash table */ - long nextdata; /* next bits of i/o */ - long nextbits; /* # of valid bits in lzw_nextdata */ + unsigned short nbits; /* # of bits/code */ + unsigned short maxcode; /* maximum code for lzw_nbits */ + unsigned short free_ent; /* next free entry in hash table */ + long nextdata; /* next bits of i/o */ + long nextbits; /* # of valid bits in lzw_nextdata */ - int rw_mode; /* preserve rw_mode from init */ + int rw_mode; /* preserve rw_mode from init */ } LZWBaseState; -#define lzw_nbits base.nbits -#define lzw_maxcode base.maxcode -#define lzw_free_ent base.free_ent -#define lzw_nextdata base.nextdata -#define lzw_nextbits base.nextbits +#define lzw_nbits base.nbits +#define lzw_maxcode base.maxcode +#define lzw_free_ent base.free_ent +#define lzw_nextdata base.nextdata +#define lzw_nextbits base.nextbits /* * Encoding-specific state. @@ -125,44 +125,44 @@ typedef struct code_ent { unsigned char firstchar; /* first token of string */ } code_t; -typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t); +typedef int (*decodeFunc)(TIFF*, uint8*, tmsize_t, uint16); typedef struct { LZWBaseState base; /* Decoding specific data */ - long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ - long dec_restart; /* restart count */ + long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ + long dec_restart; /* restart count */ #ifdef LZW_CHECKEOS - long dec_bitsleft; /* available bits in raw data */ + uint64 dec_bitsleft; /* available bits in raw data */ #endif decodeFunc dec_decode; /* regular or backwards compatible */ - code_t* dec_codep; /* current recognized code */ - code_t* dec_oldcodep; /* previously recognized code */ - code_t* dec_free_entp; /* next free entry */ - code_t* dec_maxcodep; /* max available entry */ - code_t* dec_codetab; /* kept separate for small machines */ + code_t* dec_codep; /* current recognized code */ + code_t* dec_oldcodep; /* previously recognized code */ + code_t* dec_free_entp; /* next free entry */ + code_t* dec_maxcodep; /* max available entry */ + code_t* dec_codetab; /* kept separate for small machines */ /* Encoding specific data */ - int enc_oldcode; /* last code encountered */ - long enc_checkpoint; /* point at which to clear table */ + int enc_oldcode; /* last code encountered */ + long enc_checkpoint; /* point at which to clear table */ #define CHECK_GAP 10000 /* enc_ratio check interval */ - long enc_ratio; /* current compression ratio */ - long enc_incount; /* (input) data bytes encoded */ - long enc_outcount; /* encoded (output) bytes */ - tidata_t enc_rawlimit; /* bound on tif_rawdata buffer */ - hash_t* enc_hashtab; /* kept separate for small machines */ + long enc_ratio; /* current compression ratio */ + long enc_incount; /* (input) data bytes encoded */ + long enc_outcount; /* encoded (output) bytes */ + uint8* enc_rawlimit; /* bound on tif_rawdata buffer */ + hash_t* enc_hashtab; /* kept separate for small machines */ } LZWCodecState; -#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) -#define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) -#define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) +#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) +#define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) +#define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) -static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t); +static int LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); #ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t); +static int LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); #endif -static void cl_hash(LZWCodecState*); +static void cl_hash(LZWCodecState*); /* * LZW Decoder. @@ -174,8 +174,8 @@ static void cl_hash(LZWCodecState*); * strip is suppose to be terminated with CODE_EOI. */ #define NextCode(_tif, _sp, _bp, _code, _get) { \ - if ((_sp)->dec_bitsleft < nbits) { \ - TIFFWarningExt(_tif->tif_clientdata, _tif->tif_name, \ + if ((_sp)->dec_bitsleft < (uint64)nbits) { \ + TIFFWarningExt(_tif->tif_clientdata, module, \ "LZWDecode: Strip %d not terminated with EOI code", \ _tif->tif_curstrip); \ _code = CODE_EOI; \ @@ -188,55 +188,68 @@ static void cl_hash(LZWCodecState*); #define NextCode(tif, sp, bp, code, get) get(sp, bp, code) #endif +static int +LZWFixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} + static int LZWSetupDecode(TIFF* tif) { + static const char module[] = "LZWSetupDecode"; LZWCodecState* sp = DecoderState(tif); - static const char module[] = " LZWSetupDecode"; int code; - if( sp == NULL ) - { - /* - * Allocate state block so tag methods have storage to record - * values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof(LZWCodecState)); - if (tif->tif_data == NULL) - { - TIFFErrorExt(tif->tif_clientdata, "LZWPreDecode", "No space for LZW state block"); - return (0); - } + if( sp == NULL ) + { + /* + * Allocate state block so tag methods have storage to record + * values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState)); + if (tif->tif_data == NULL) + { + TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block"); + return (0); + } - DecoderState(tif)->dec_codetab = NULL; - DecoderState(tif)->dec_decode = NULL; - - /* - * Setup predictor setup. - */ - (void) TIFFPredictorInit(tif); + DecoderState(tif)->dec_codetab = NULL; + DecoderState(tif)->dec_decode = NULL; + + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + + sp = DecoderState(tif); + } - sp = DecoderState(tif); - } - assert(sp != NULL); if (sp->dec_codetab == NULL) { sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t)); if (sp->dec_codetab == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW code table"); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZW code table"); return (0); } /* * Pre-load the table. */ - code = 255; - do { - sp->dec_codetab[code].value = code; - sp->dec_codetab[code].firstchar = code; - sp->dec_codetab[code].length = 1; - sp->dec_codetab[code].next = NULL; - } while (code--); + code = 255; + do { + sp->dec_codetab[code].value = code; + sp->dec_codetab[code].firstchar = code; + sp->dec_codetab[code].length = 1; + sp->dec_codetab[code].next = NULL; + } while (code--); + /* + * Zero-out the unused entries + */ + _TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0, + (CODE_FIRST - CODE_CLEAR) * sizeof (code_t)); } return (1); } @@ -245,19 +258,25 @@ LZWSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -LZWPreDecode(TIFF* tif, tsample_t s) +LZWPreDecode(TIFF* tif, uint16 s) { + static const char module[] = "LZWPreDecode"; LZWCodecState *sp = DecoderState(tif); (void) s; assert(sp != NULL); + if( sp->dec_codetab == NULL ) + { + tif->tif_setupdecode( tif ); + } + /* * Check for old bit-reversed codes. */ if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { #ifdef LZW_COMPAT if (!sp->dec_decode) { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + TIFFWarningExt(tif->tif_clientdata, module, "Old-style LZW codes, convert file"); /* * Override default decoding methods with @@ -280,7 +299,7 @@ LZWPreDecode(TIFF* tif, tsample_t s) sp->lzw_maxcode = MAXCODE(BITS_MIN); #else /* !LZW_COMPAT */ if (!sp->dec_decode) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "Old-style LZW codes not supported"); sp->dec_decode = LZWDecode; } @@ -297,7 +316,7 @@ LZWPreDecode(TIFF* tif, tsample_t s) sp->dec_restart = 0; sp->dec_nbitsmask = MAXCODE(BITS_MIN); #ifdef LZW_CHECKEOS - sp->dec_bitsleft = tif->tif_rawcc << 3; + sp->dec_bitsleft = ((uint64)tif->tif_rawcc) << 3; #endif sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; /* @@ -328,16 +347,17 @@ LZWPreDecode(TIFF* tif, tsample_t s) } static void -codeLoop(TIFF* tif) +codeLoop(TIFF* tif, const char* module) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Bogus encoding, loop in the code table; scanline %d", + TIFFErrorExt(tif->tif_clientdata, module, + "Bogus encoding, loop in the code table; scanline %d", tif->tif_row); } static int -LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { + static const char module[] = "LZWDecode"; LZWCodecState *sp = DecoderState(tif); char *op = (char*) op0; long occ = (long) occ0; @@ -350,6 +370,13 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) (void) s; assert(sp != NULL); + assert(sp->dec_codetab != NULL); + + /* + Fail if value does not fit in long. + */ + if ((tmsize_t) occ != occ0) + return (0); /* * Restart interrupted output operation. */ @@ -408,12 +435,20 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) break; if (code == CODE_CLEAR) { free_entp = sp->dec_codetab + CODE_FIRST; + _TIFFmemset(free_entp, 0, + (CSIZE - CODE_FIRST) * sizeof (code_t)); nbits = BITS_MIN; nbitsmask = MAXCODE(BITS_MIN); maxcodep = sp->dec_codetab + nbitsmask-1; NextCode(tif, sp, bp, code, GetNextCode); if (code == CODE_EOI) break; + if (code >= CODE_CLEAR) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "LZWDecode: Corrupted LZW table at scanline %d", + tif->tif_row); + return (0); + } *op++ = (char)code, occ--; oldcodep = sp->dec_codetab + code; continue; @@ -421,22 +456,22 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) codep = sp->dec_codetab + code; /* - * Add the new entry to the code table. - */ + * Add the new entry to the code table. + */ if (free_entp < &sp->dec_codetab[0] || - free_entp >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", - tif->tif_row); + free_entp >= &sp->dec_codetab[CSIZE]) { + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", + tif->tif_row); return (0); } free_entp->next = oldcodep; if (free_entp->next < &sp->dec_codetab[0] || - free_entp->next >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", - tif->tif_row); + free_entp->next >= &sp->dec_codetab[CSIZE]) { + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", + tif->tif_row); return (0); } free_entp->firstchar = free_entp->next->firstchar; @@ -452,15 +487,15 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) oldcodep = codep; if (code >= 256) { /* - * Code maps to a string, copy string + * Code maps to a string, copy string * value to output (written in reverse). - */ + */ if(codep->length == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Wrong length of decoded string: " - "data probably corrupted at scanline %d", - tif->tif_row); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "Wrong length of decoded string: " + "data probably corrupted at scanline %d", + tif->tif_row); + return (0); } if (codep->length > occ) { /* @@ -474,14 +509,14 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) codep = codep->next; } while (codep && codep->length > occ); if (codep) { - sp->dec_restart = occ; + sp->dec_restart = (long)occ; tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ && codep); if (codep) - codeLoop(tif); + codeLoop(tif, module); } break; } @@ -495,15 +530,16 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) *tp = t; } while (codep && tp > op); if (codep) { - codeLoop(tif); + codeLoop(tif, module); break; } + assert(occ >= len); op += len, occ -= len; } else *op++ = (char)code, occ--; } - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; sp->lzw_nbits = (unsigned short) nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; @@ -513,9 +549,15 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) sp->dec_maxcodep = maxcodep; if (occ > 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Not enough data at scanline %d (short %d bytes)", - tif->tif_row, occ); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %d (short %I64d bytes)", + tif->tif_row, (unsigned __int64) occ); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %d (short %llu bytes)", + tif->tif_row, (unsigned long long) occ); +#endif return (0); } return (1); @@ -538,8 +580,9 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) } static int -LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { + static const char module[] = "LZWDecodeCompat"; LZWCodecState *sp = DecoderState(tif); char *op = (char*) op0; long occ = (long) occ0; @@ -551,6 +594,13 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) (void) s; assert(sp != NULL); + + /* + Fail if value does not fit in long. + */ + if ((tmsize_t) occ != occ0) + return (0); + /* * Restart interrupted output operation. */ @@ -604,12 +654,20 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) break; if (code == CODE_CLEAR) { free_entp = sp->dec_codetab + CODE_FIRST; + _TIFFmemset(free_entp, 0, + (CSIZE - CODE_FIRST) * sizeof (code_t)); nbits = BITS_MIN; nbitsmask = MAXCODE(BITS_MIN); maxcodep = sp->dec_codetab + nbitsmask; NextCode(tif, sp, bp, code, GetNextCodeCompat); if (code == CODE_EOI) break; + if (code >= CODE_CLEAR) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "LZWDecode: Corrupted LZW table at scanline %d", + tif->tif_row); + return (0); + } *op++ = code, occ--; oldcodep = sp->dec_codetab + code; continue; @@ -617,22 +675,20 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) codep = sp->dec_codetab + code; /* - * Add the new entry to the code table. - */ + * Add the new entry to the code table. + */ if (free_entp < &sp->dec_codetab[0] || - free_entp >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Corrupted LZW table at scanline %d", - tif->tif_row); + free_entp >= &sp->dec_codetab[CSIZE]) { + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", tif->tif_row); return (0); } free_entp->next = oldcodep; if (free_entp->next < &sp->dec_codetab[0] || - free_entp->next >= &sp->dec_codetab[CSIZE]) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Corrupted LZW table at scanline %d", - tif->tif_row); + free_entp->next >= &sp->dec_codetab[CSIZE]) { + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", tif->tif_row); return (0); } free_entp->firstchar = free_entp->next->firstchar; @@ -648,15 +704,15 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) oldcodep = codep; if (code >= 256) { /* - * Code maps to a string, copy string + * Code maps to a string, copy string * value to output (written in reverse). - */ + */ if(codep->length == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Wrong length of decoded " - "string: data probably corrupted at scanline %d", - tif->tif_row); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "Wrong length of decoded " + "string: data probably corrupted at scanline %d", + tif->tif_row); + return (0); } if (codep->length > occ) { /* @@ -677,16 +733,17 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) } while (--occ); break; } + assert(occ >= codep->length); op += codep->length, occ -= codep->length; tp = op; do { *--tp = codep->value; - } while( (codep = codep->next) != NULL); + } while( (codep = codep->next) != NULL ); } else *op++ = code, occ--; } - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; sp->lzw_nbits = nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; @@ -696,9 +753,15 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) sp->dec_maxcodep = maxcodep; if (occ > 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecodeCompat: Not enough data at scanline %d (short %d bytes)", - tif->tif_row, occ); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %d (short %I64d bytes)", + tif->tif_row, (unsigned __int64) occ); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %d (short %llu bytes)", + tif->tif_row, (unsigned long long) occ); +#endif return (0); } return (1); @@ -712,13 +775,14 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) static int LZWSetupEncode(TIFF* tif) { - LZWCodecState* sp = EncoderState(tif); static const char module[] = "LZWSetupEncode"; + LZWCodecState* sp = EncoderState(tif); assert(sp != NULL); sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t)); if (sp->enc_hashtab == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW hash table"); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZW hash table"); return (0); } return (1); @@ -728,12 +792,18 @@ LZWSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -LZWPreEncode(TIFF* tif, tsample_t s) +LZWPreEncode(TIFF* tif, uint16 s) { LZWCodecState *sp = EncoderState(tif); (void) s; assert(sp != NULL); + + if( sp->enc_hashtab == NULL ) + { + tif->tif_setupencode( tif ); + } + sp->lzw_nbits = BITS_MIN; sp->lzw_maxcode = MAXCODE(BITS_MIN); sp->lzw_free_ent = CODE_FIRST; @@ -787,7 +857,7 @@ LZWPreEncode(TIFF* tif, tsample_t s) * for the decoder. */ static int -LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { register LZWCodecState *sp = EncoderState(tif); register long fcode; @@ -798,11 +868,15 @@ LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) long incount, outcount, checkpoint; long nextdata, nextbits; int free_ent, maxcode, nbits; - tidata_t op, limit; + uint8* op; + uint8* limit; (void) s; if (sp == NULL) return (0); + + assert(sp->enc_hashtab != NULL); + /* * Load local state. */ @@ -874,7 +948,7 @@ LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * are at least 4 bytes free--room for 2 codes. */ if (op > limit) { - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); + tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); TIFFFlushData1(tif); op = tif->tif_rawdata; } @@ -952,14 +1026,14 @@ static int LZWPostEncode(TIFF* tif) { register LZWCodecState *sp = EncoderState(tif); - tidata_t op = tif->tif_rawcp; + uint8* op = tif->tif_rawcp; long nextbits = sp->lzw_nextbits; long nextdata = sp->lzw_nextdata; long outcount = sp->enc_outcount; int nbits = sp->lzw_nbits; if (op > sp->enc_rawlimit) { - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); + tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); TIFFFlushData1(tif); op = tif->tif_rawdata; } @@ -970,7 +1044,7 @@ LZWPostEncode(TIFF* tif) PutNextCode(op, CODE_EOI); if (nextbits > 0) *op++ = (unsigned char)(nextdata << (8-nextbits)); - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); + tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); return (1); } @@ -983,7 +1057,7 @@ cl_hash(LZWCodecState* sp) register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; register long i = HSIZE-8; - do { + do { i -= 8; hp[-7].hash = -1; hp[-6].hash = -1; @@ -995,7 +1069,7 @@ cl_hash(LZWCodecState* sp) hp[ 0].hash = -1; hp -= 8; } while (i >= 0); - for (i += 8; i > 0; i--, hp--) + for (i += 8; i > 0; i--, hp--) hp->hash = -1; } @@ -1021,11 +1095,12 @@ LZWCleanup(TIFF* tif) int TIFFInitLZW(TIFF* tif, int scheme) { + static const char module[] = "TIFFInitLZW"; assert(scheme == COMPRESSION_LZW); /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWCodecState)); + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LZWCodecState)); if (tif->tif_data == NULL) goto bad; DecoderState(tif)->dec_codetab = NULL; @@ -1036,6 +1111,7 @@ TIFFInitLZW(TIFF* tif, int scheme) /* * Install codec methods. */ + tif->tif_fixuptags = LZWFixupTags; tif->tif_setupdecode = LZWSetupDecode; tif->tif_predecode = LZWPreDecode; tif->tif_decoderow = LZWDecode; @@ -1054,7 +1130,7 @@ TIFFInitLZW(TIFF* tif, int scheme) (void) TIFFPredictorInit(tif); return (1); bad: - TIFFErrorExt(tif->tif_clientdata, "TIFFInitLZW", + TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block"); return (0); } @@ -1082,3 +1158,10 @@ bad: #endif /* LZW_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_next.c b/libs/tiff-4.0.2/libtiff/tif_next.c similarity index 67% rename from libs/tiff-3.8.2/libtiff/tif_next.c rename to libs/tiff-4.0.2/libtiff/tif_next.c index 81528cb9d8..524e127c13 100644 --- a/libs/tiff-3.8.2/libtiff/tif_next.c +++ b/libs/tiff-4.0.2/libtiff/tif_next.c @@ -1,4 +1,4 @@ -/* $Id: tif_next.c,v 1.6 2005/12/21 12:23:13 joris Exp $ */ +/* $Id: tif_next.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -46,13 +46,13 @@ #define WHITE ((1<<2)-1) static int -NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - register unsigned char *bp, *op; - register tsize_t cc; - register int n; - tidata_t row; - tsize_t scanline; + static const char module[] = "NeXTDecode"; + unsigned char *bp, *op; + tmsize_t cc; + uint8* row; + tmsize_t scanline, n; (void) s; /* @@ -60,13 +60,18 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) * white (we assume a PhotometricInterpretation * of ``min-is-black''). */ - for (op = buf, cc = occ; cc-- > 0;) + for (op = (unsigned char*) buf, cc = occ; cc-- > 0;) *op++ = 0xff; bp = (unsigned char *)tif->tif_rawcp; cc = tif->tif_rawcc; scanline = tif->tif_scanlinesize; - for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) { + if (occ % scanline) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (0); + } + for (row = buf; occ > 0; occ -= scanline, row += scanline) { n = *bp++, cc--; switch (n) { case LITERALROW: @@ -80,10 +85,10 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) cc -= scanline; break; case LITERALSPAN: { - int off; + tmsize_t off; /* - * The scanline has a literal span - * that begins at some offset. + * The scanline has a literal span that begins at some + * offset. */ off = (bp[0] * 256) + bp[1]; n = (bp[2] * 256) + bp[3]; @@ -95,23 +100,27 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) break; } default: { - register int npixels = 0, grey; - unsigned long imagewidth = tif->tif_dir.td_imagewidth; + uint32 npixels = 0, grey; + uint32 imagewidth = tif->tif_dir.td_imagewidth; /* - * The scanline is composed of a sequence - * of constant color ``runs''. We shift - * into ``run mode'' and interpret bytes - * as codes of the form - * until we've filled the scanline. + * The scanline is composed of a sequence of constant + * color ``runs''. We shift into ``run mode'' and + * interpret bytes as codes of the form + * until we've filled the scanline. */ op = row; for (;;) { - grey = (n>>6) & 0x3; + grey = (uint32)((n>>6) & 0x3); n &= 0x3f; - while (n-- > 0) + /* + * Ensure the run does not exceed the scanline + * bounds, potentially resulting in a security + * issue. + */ + while (n-- > 0 && npixels < imagewidth) SETPIXEL(op, grey); - if (npixels >= (int) imagewidth) + if (npixels >= imagewidth) break; if (cc == 0) goto bad; @@ -121,11 +130,11 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) } } } - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; return (1); bad: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", + TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", (long) tif->tif_row); return (0); } @@ -134,11 +143,18 @@ int TIFFInitNeXT(TIFF* tif, int scheme) { (void) scheme; - tif->tif_decoderow = NeXTDecode; - tif->tif_decodestrip = NeXTDecode; + tif->tif_decoderow = NeXTDecode; + tif->tif_decodestrip = NeXTDecode; tif->tif_decodetile = NeXTDecode; return (1); } #endif /* NEXT_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_ojpeg.c b/libs/tiff-4.0.2/libtiff/tif_ojpeg.c new file mode 100644 index 0000000000..6ea3c38ba7 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_ojpeg.c @@ -0,0 +1,2496 @@ +/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam Exp $ */ + +/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0 + specification is now totally obsolete and deprecated for new applications and + images. This file was was created solely in order to read unconverted images + still present on some users' computer systems. It will never be extended + to write such files. Writing new-style JPEG compressed TIFFs is implemented + in tif_jpeg.c. + + The code is carefully crafted to robustly read all gathered JPEG-in-TIFF + testfiles, and anticipate as much as possible all other... But still, it may + fail on some. If you encounter problems, please report them on the TIFF + mailing list and/or to Joris Van Damme . + + Please read the file called "TIFF Technical Note #2" if you need to be + convinced this compression scheme is bad and breaks TIFF. That document + is linked to from the LibTiff site + and from AWare Systems' TIFF section + . It is also absorbed + in Adobe's specification supplements, marked "draft" up to this day, but + supported by the TIFF community. + + This file interfaces with Release 6B of the JPEG Library written by the + Independent JPEG Group. Previous versions of this file required a hack inside + the LibJpeg library. This version no longer requires that. Remember to + remove the hack if you update from the old version. + + Copyright (c) Joris Van Damme + Copyright (c) AWare Systems + + The licence agreement for this file is the same as the rest of the LibTiff + library. + + IN NO EVENT SHALL JORIS VAN DAMME OR AWARE SYSTEMS BE LIABLE FOR + ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + OF THIS SOFTWARE. + + Joris Van Damme and/or AWare Systems may be available for custom + developement. If you like what you see, and need anything similar or related, + contact . +*/ + +/* What is what, and what is not? + + This decoder starts with an input stream, that is essentially the JpegInterchangeFormat + stream, if any, followed by the strile data, if any. This stream is read in + OJPEGReadByte and related functions. + + It analyzes the start of this stream, until it encounters non-marker data, i.e. + compressed image data. Some of the header markers it sees have no actual content, + like the SOI marker, and APP/COM markers that really shouldn't even be there. Some + other markers do have content, and the valuable bits and pieces of information + in these markers are saved, checking all to verify that the stream is more or + less within expected bounds. This happens inside the OJPEGReadHeaderInfoSecStreamXxx + functions. + + Some OJPEG imagery contains no valid JPEG header markers. This situation is picked + up on if we've seen no SOF marker when we're at the start of the compressed image + data. In this case, the tables are read from JpegXxxTables tags, and the other + bits and pieces of information is initialized to its most basic value. This is + implemented in the OJPEGReadHeaderInfoSecTablesXxx functions. + + When this is complete, a good and valid JPEG header can be assembled, and this is + passed through to LibJpeg. When that's done, the remainder of the input stream, i.e. + the compressed image data, can be passed through unchanged. This is done in + OJPEGWriteStream functions. + + LibTiff rightly expects to know the subsampling values before decompression. Just like + in new-style JPEG-in-TIFF, though, or even more so, actually, the YCbCrsubsampling + tag is notoriously unreliable. To correct these tag values with the ones inside + the JPEG stream, the first part of the input stream is pre-scanned in + OJPEGSubsamplingCorrect, making no note of any other data, reporting no warnings + or errors, up to the point where either these values are read, or it's clear they + aren't there. This means that some of the data is read twice, but we feel speed + in correcting these values is important enough to warrant this sacrifice. Allthough + there is currently no define or other configuration mechanism to disable this behaviour, + the actual header scanning is build to robustly respond with error report if it + should encounter an uncorrected mismatch of subsampling values. See + OJPEGReadHeaderInfoSecStreamSof. + + The restart interval and restart markers are the most tricky part... The restart + interval can be specified in a tag. It can also be set inside the input JPEG stream. + It can be used inside the input JPEG stream. If reading from strile data, we've + consistenly discovered the need to insert restart markers in between the different + striles, as is also probably the most likely interpretation of the original TIFF 6.0 + specification. With all this setting of interval, and actual use of markers that is not + predictable at the time of valid JPEG header assembly, the restart thing may turn + out the Achilles heel of this implementation. Fortunately, most OJPEG writer vendors + succeed in reading back what they write, which may be the reason why we've been able + to discover ways that seem to work. + + Some special provision is made for planarconfig separate OJPEG files. These seem + to consistently contain header info, a SOS marker, a plane, SOS marker, plane, SOS, + and plane. This may or may not be a valid JPEG configuration, we don't know and don't + care. We want LibTiff to be able to access the planes individually, without huge + buffering inside LibJpeg, anyway. So we compose headers to feed to LibJpeg, in this + case, that allow us to pass a single plane such that LibJpeg sees a valid + single-channel JPEG stream. Locating subsequent SOS markers, and thus subsequent + planes, is done inside OJPEGReadSecondarySos. + + The benefit of the scheme is... that it works, basically. We know of no other that + does. It works without checking software tag, or otherwise going about things in an + OJPEG flavor specific manner. Instead, it is a single scheme, that covers the cases + with and without JpegInterchangeFormat, with and without striles, with part of + the header in JpegInterchangeFormat and remainder in first strile, etc. It is forgiving + and robust, may likely work with OJPEG flavors we've not seen yet, and makes most out + of the data. + + Another nice side-effect is that a complete JPEG single valid stream is build if + planarconfig is not separate (vast majority). We may one day use that to build + converters to JPEG, and/or to new-style JPEG compression inside TIFF. + + A dissadvantage is the lack of random access to the individual striles. This is the + reason for much of the complicated restart-and-position stuff inside OJPEGPreDecode. + Applications would do well accessing all striles in order, as this will result in + a single sequential scan of the input stream, and no restarting of LibJpeg decoding + session. +*/ + +#define WIN32_LEAN_AND_MEAN +#define VC_EXTRALEAN + +#include "tiffiop.h" +#ifdef OJPEG_SUPPORT + +/* Configuration defines here are: + * JPEG_ENCAP_EXTERNAL: The normal way to call libjpeg, uses longjump. In some environments, + * like eg LibTiffDelphi, this is not possible. For this reason, the actual calls to + * libjpeg, with longjump stuff, are encapsulated in dedicated functions. When + * JPEG_ENCAP_EXTERNAL is defined, these encapsulating functions are declared external + * to this unit, and can be defined elsewhere to use stuff other then longjump. + * The default mode, without JPEG_ENCAP_EXTERNAL, implements the call encapsulators + * here, internally, with normal longjump. + * SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent is + * conviniently available, but still it may be worthwhile to use _setjmp or sigsetjmp + * in place of plain setjmp. These macros will make it easier. It is useless + * to fiddle with these if you define JPEG_ENCAP_EXTERNAL. + * OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee + * instant processing, optimal streaming and optimal use of processor cache, but also big + * enough so as to not result in significant call overhead. It should be at least a few + * bytes to accomodate some structures (this is verified in asserts), but it would not be + * sensible to make it this small anyway, and it should be at most 64K since it is indexed + * with uint16. We recommend 2K. + * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has + * absolutely no effect. That is why most people insist the EGYPTIANWALK is a bit silly. + */ + +/* define LIBJPEG_ENCAP_EXTERNAL */ +#define SETJMP(jbuf) setjmp(jbuf) +#define LONGJMP(jbuf,code) longjmp(jbuf,code) +#define JMP_BUF jmp_buf +#define OJPEG_BUFFER 2048 +/* define EGYPTIANWALK */ + +#define JPEG_MARKER_SOF0 0xC0 +#define JPEG_MARKER_SOF1 0xC1 +#define JPEG_MARKER_SOF3 0xC3 +#define JPEG_MARKER_DHT 0xC4 +#define JPEG_MARKER_RST0 0XD0 +#define JPEG_MARKER_SOI 0xD8 +#define JPEG_MARKER_EOI 0xD9 +#define JPEG_MARKER_SOS 0xDA +#define JPEG_MARKER_DQT 0xDB +#define JPEG_MARKER_DRI 0xDD +#define JPEG_MARKER_APP0 0xE0 +#define JPEG_MARKER_COM 0xFE + +#define FIELD_OJPEG_JPEGINTERCHANGEFORMAT (FIELD_CODEC+0) +#define FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH (FIELD_CODEC+1) +#define FIELD_OJPEG_JPEGQTABLES (FIELD_CODEC+2) +#define FIELD_OJPEG_JPEGDCTABLES (FIELD_CODEC+3) +#define FIELD_OJPEG_JPEGACTABLES (FIELD_CODEC+4) +#define FIELD_OJPEG_JPEGPROC (FIELD_CODEC+5) +#define FIELD_OJPEG_JPEGRESTARTINTERVAL (FIELD_CODEC+6) + +static const TIFFField ojpegFields[] = { + {TIFFTAG_JPEGIFOFFSET,1,1,TIFF_LONG8,0,TIFF_SETGET_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGINTERCHANGEFORMAT,TRUE,FALSE,"JpegInterchangeFormat",NULL}, + {TIFFTAG_JPEGIFBYTECOUNT,1,1,TIFF_LONG8,0,TIFF_SETGET_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH,TRUE,FALSE,"JpegInterchangeFormatLength",NULL}, + {TIFFTAG_JPEGQTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGQTABLES,FALSE,TRUE,"JpegQTables",NULL}, + {TIFFTAG_JPEGDCTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGDCTABLES,FALSE,TRUE,"JpegDcTables",NULL}, + {TIFFTAG_JPEGACTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGACTABLES,FALSE,TRUE,"JpegAcTables",NULL}, + {TIFFTAG_JPEGPROC,1,1,TIFF_SHORT,0,TIFF_SETGET_UINT16,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGPROC,FALSE,FALSE,"JpegProc",NULL}, + {TIFFTAG_JPEGRESTARTINTERVAL,1,1,TIFF_SHORT,0,TIFF_SETGET_UINT16,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGRESTARTINTERVAL,FALSE,FALSE,"JpegRestartInterval",NULL}, +}; + +#ifndef LIBJPEG_ENCAP_EXTERNAL +#include +#endif + +/* We undefine FAR to avoid conflict with JPEG definition */ + +#ifdef FAR +#undef FAR +#endif + +/* + Libjpeg's jmorecfg.h defines INT16 and INT32, but only if XMD_H is + not defined. Unfortunately, the MinGW and Borland compilers include + a typedef for INT32, which causes a conflict. MSVC does not include + a conficting typedef given the headers which are included. +*/ +#if defined(__BORLANDC__) || defined(__MINGW32__) +# define XMD_H 1 +#endif + +/* Define "boolean" as unsigned char, not int, per Windows custom. */ +#if defined(__WIN32__) && !defined(__MINGW32__) +# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; +# endif +# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +#endif + +#include "jpeglib.h" +#include "jerror.h" + +typedef struct jpeg_error_mgr jpeg_error_mgr; +typedef struct jpeg_common_struct jpeg_common_struct; +typedef struct jpeg_decompress_struct jpeg_decompress_struct; +typedef struct jpeg_source_mgr jpeg_source_mgr; + +typedef enum { + osibsNotSetYet, + osibsJpegInterchangeFormat, + osibsStrile, + osibsEof +} OJPEGStateInBufferSource; + +typedef enum { + ososSoi, + ososQTable0,ososQTable1,ososQTable2,ososQTable3, + ososDcTable0,ososDcTable1,ososDcTable2,ososDcTable3, + ososAcTable0,ososAcTable1,ososAcTable2,ososAcTable3, + ososDri, + ososSof, + ososSos, + ososCompressed, + ososRst, + ososEoi +} OJPEGStateOutState; + +typedef struct { + TIFF* tif; + #ifndef LIBJPEG_ENCAP_EXTERNAL + JMP_BUF exit_jmpbuf; + #endif + TIFFVGetMethod vgetparent; + TIFFVSetMethod vsetparent; + TIFFPrintMethod printdir; + uint64 file_size; + uint32 image_width; + uint32 image_length; + uint32 strile_width; + uint32 strile_length; + uint32 strile_length_total; + uint8 samples_per_pixel; + uint8 plane_sample_offset; + uint8 samples_per_pixel_per_plane; + uint64 jpeg_interchange_format; + uint64 jpeg_interchange_format_length; + uint8 jpeg_proc; + uint8 subsamplingcorrect; + uint8 subsamplingcorrect_done; + uint8 subsampling_tag; + uint8 subsampling_hor; + uint8 subsampling_ver; + uint8 subsampling_force_desubsampling_inside_decompression; + uint8 qtable_offset_count; + uint8 dctable_offset_count; + uint8 actable_offset_count; + uint64 qtable_offset[3]; + uint64 dctable_offset[3]; + uint64 actable_offset[3]; + uint8* qtable[4]; + uint8* dctable[4]; + uint8* actable[4]; + uint16 restart_interval; + uint8 restart_index; + uint8 sof_log; + uint8 sof_marker_id; + uint32 sof_x; + uint32 sof_y; + uint8 sof_c[3]; + uint8 sof_hv[3]; + uint8 sof_tq[3]; + uint8 sos_cs[3]; + uint8 sos_tda[3]; + struct { + uint8 log; + OJPEGStateInBufferSource in_buffer_source; + uint32 in_buffer_next_strile; + uint64 in_buffer_file_pos; + uint64 in_buffer_file_togo; + } sos_end[3]; + uint8 readheader_done; + uint8 writeheader_done; + uint16 write_cursample; + uint32 write_curstrile; + uint8 libjpeg_session_active; + uint8 libjpeg_jpeg_query_style; + jpeg_error_mgr libjpeg_jpeg_error_mgr; + jpeg_decompress_struct libjpeg_jpeg_decompress_struct; + jpeg_source_mgr libjpeg_jpeg_source_mgr; + uint8 subsampling_convert_log; + uint32 subsampling_convert_ylinelen; + uint32 subsampling_convert_ylines; + uint32 subsampling_convert_clinelen; + uint32 subsampling_convert_clines; + uint32 subsampling_convert_ybuflen; + uint32 subsampling_convert_cbuflen; + uint32 subsampling_convert_ycbcrbuflen; + uint8* subsampling_convert_ycbcrbuf; + uint8* subsampling_convert_ybuf; + uint8* subsampling_convert_cbbuf; + uint8* subsampling_convert_crbuf; + uint32 subsampling_convert_ycbcrimagelen; + uint8** subsampling_convert_ycbcrimage; + uint32 subsampling_convert_clinelenout; + uint32 subsampling_convert_state; + uint32 bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */ + uint32 lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */ + OJPEGStateInBufferSource in_buffer_source; + uint32 in_buffer_next_strile; + uint32 in_buffer_strile_count; + uint64 in_buffer_file_pos; + uint8 in_buffer_file_pos_log; + uint64 in_buffer_file_togo; + uint16 in_buffer_togo; + uint8* in_buffer_cur; + uint8 in_buffer[OJPEG_BUFFER]; + OJPEGStateOutState out_state; + uint8 out_buffer[OJPEG_BUFFER]; + uint8* skip_buffer; +} OJPEGState; + +static int OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap); +static int OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap); +static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags); + +static int OJPEGFixupTags(TIFF* tif); +static int OJPEGSetupDecode(TIFF* tif); +static int OJPEGPreDecode(TIFF* tif, uint16 s); +static int OJPEGPreDecodeSkipRaw(TIFF* tif); +static int OJPEGPreDecodeSkipScanlines(TIFF* tif); +static int OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc); +static int OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc); +static void OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc); +static int OJPEGSetupEncode(TIFF* tif); +static int OJPEGPreEncode(TIFF* tif, uint16 s); +static int OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int OJPEGPostEncode(TIFF* tif); +static void OJPEGCleanup(TIFF* tif); + +static void OJPEGSubsamplingCorrect(TIFF* tif); +static int OJPEGReadHeaderInfo(TIFF* tif); +static int OJPEGReadSecondarySos(TIFF* tif, uint16 s); +static int OJPEGWriteHeaderInfo(TIFF* tif); +static void OJPEGLibjpegSessionAbort(TIFF* tif); + +static int OJPEGReadHeaderInfoSec(TIFF* tif); +static int OJPEGReadHeaderInfoSecStreamDri(TIFF* tif); +static int OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif); +static int OJPEGReadHeaderInfoSecStreamDht(TIFF* tif); +static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id); +static int OJPEGReadHeaderInfoSecStreamSos(TIFF* tif); +static int OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif); +static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif); +static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif); + +static int OJPEGReadBufferFill(OJPEGState* sp); +static int OJPEGReadByte(OJPEGState* sp, uint8* byte); +static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte); +static void OJPEGReadByteAdvance(OJPEGState* sp); +static int OJPEGReadWord(OJPEGState* sp, uint16* word); +static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem); +static void OJPEGReadSkip(OJPEGState* sp, uint16 len); + +static int OJPEGWriteStream(TIFF* tif, void** mem, uint32* len); +static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len); +static void OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); +static void OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); +static void OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); +static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len); +static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len); +static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len); +static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len); +static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len); +static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len); + +#ifdef LIBJPEG_ENCAP_EXTERNAL +extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); +extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); +extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); +extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); +extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); +extern void jpeg_encap_unwind(TIFF* tif); +#else +static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j); +static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); +static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); +static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); +static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); +static void jpeg_encap_unwind(TIFF* tif); +#endif + +static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo); +static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo); +static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo); +static boolean OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo); +static void OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes); +static boolean OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired); +static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo); + +int +TIFFInitOJPEG(TIFF* tif, int scheme) +{ + static const char module[]="TIFFInitOJPEG"; + OJPEGState* sp; + + assert(scheme==COMPRESSION_OJPEG); + + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging Old JPEG codec-specific tags failed"); + return 0; + } + + /* state block */ + sp=_TIFFmalloc(sizeof(OJPEGState)); + if (sp==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"No space for OJPEG state block"); + return(0); + } + _TIFFmemset(sp,0,sizeof(OJPEGState)); + sp->tif=tif; + sp->jpeg_proc=1; + sp->subsampling_hor=2; + sp->subsampling_ver=2; + TIFFSetField(tif,TIFFTAG_YCBCRSUBSAMPLING,2,2); + /* tif codec methods */ + tif->tif_fixuptags=OJPEGFixupTags; + tif->tif_setupdecode=OJPEGSetupDecode; + tif->tif_predecode=OJPEGPreDecode; + tif->tif_postdecode=OJPEGPostDecode; + tif->tif_decoderow=OJPEGDecode; + tif->tif_decodestrip=OJPEGDecode; + tif->tif_decodetile=OJPEGDecode; + tif->tif_setupencode=OJPEGSetupEncode; + tif->tif_preencode=OJPEGPreEncode; + tif->tif_postencode=OJPEGPostEncode; + tif->tif_encoderow=OJPEGEncode; + tif->tif_encodestrip=OJPEGEncode; + tif->tif_encodetile=OJPEGEncode; + tif->tif_cleanup=OJPEGCleanup; + tif->tif_data=(uint8*)sp; + /* tif tag methods */ + sp->vgetparent=tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield=OJPEGVGetField; + sp->vsetparent=tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield=OJPEGVSetField; + sp->printdir=tif->tif_tagmethods.printdir; + tif->tif_tagmethods.printdir=OJPEGPrintDir; + /* Some OJPEG files don't have strip or tile offsets or bytecounts tags. + Some others do, but have totally meaningless or corrupt values + in these tags. In these cases, the JpegInterchangeFormat stream is + reliable. In any case, this decoder reads the compressed data itself, + from the most reliable locations, and we need to notify encapsulating + LibTiff not to read raw strips or tiles for us. */ + tif->tif_flags|=TIFF_NOREADRAW; + return(1); +} + +static int +OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + switch(tag) + { + case TIFFTAG_JPEGIFOFFSET: + *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format; + break; + case TIFFTAG_JPEGIFBYTECOUNT: + *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format_length; + break; + case TIFFTAG_YCBCRSUBSAMPLING: + if (sp->subsamplingcorrect_done==0) + OJPEGSubsamplingCorrect(tif); + *va_arg(ap,uint16*)=(uint16)sp->subsampling_hor; + *va_arg(ap,uint16*)=(uint16)sp->subsampling_ver; + break; + case TIFFTAG_JPEGQTABLES: + *va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count; + *va_arg(ap,void**)=(void*)sp->qtable_offset; + break; + case TIFFTAG_JPEGDCTABLES: + *va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count; + *va_arg(ap,void**)=(void*)sp->dctable_offset; + break; + case TIFFTAG_JPEGACTABLES: + *va_arg(ap,uint32*)=(uint32)sp->actable_offset_count; + *va_arg(ap,void**)=(void*)sp->actable_offset; + break; + case TIFFTAG_JPEGPROC: + *va_arg(ap,uint16*)=(uint16)sp->jpeg_proc; + break; + case TIFFTAG_JPEGRESTARTINTERVAL: + *va_arg(ap,uint16*)=sp->restart_interval; + break; + default: + return (*sp->vgetparent)(tif,tag,ap); + } + return (1); +} + +static int +OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + static const char module[]="OJPEGVSetField"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 ma; + uint64* mb; + uint32 n; + switch(tag) + { + case TIFFTAG_JPEGIFOFFSET: + sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64); + break; + case TIFFTAG_JPEGIFBYTECOUNT: + sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64); + break; + case TIFFTAG_YCBCRSUBSAMPLING: + sp->subsampling_tag=1; + sp->subsampling_hor=(uint8)va_arg(ap,uint16_vap); + sp->subsampling_ver=(uint8)va_arg(ap,uint16_vap); + tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor; + tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver; + break; + case TIFFTAG_JPEGQTABLES: + ma=(uint32)va_arg(ap,uint32); + if (ma!=0) + { + if (ma>3) + { + TIFFErrorExt(tif->tif_clientdata,module,"JpegQTables tag has incorrect count"); + return(0); + } + sp->qtable_offset_count=(uint8)ma; + mb=(uint64*)va_arg(ap,uint64*); + for (n=0; nqtable_offset[n]=mb[n]; + } + break; + case TIFFTAG_JPEGDCTABLES: + ma=(uint32)va_arg(ap,uint32); + if (ma!=0) + { + if (ma>3) + { + TIFFErrorExt(tif->tif_clientdata,module,"JpegDcTables tag has incorrect count"); + return(0); + } + sp->dctable_offset_count=(uint8)ma; + mb=(uint64*)va_arg(ap,uint64*); + for (n=0; ndctable_offset[n]=mb[n]; + } + break; + case TIFFTAG_JPEGACTABLES: + ma=(uint32)va_arg(ap,uint32); + if (ma!=0) + { + if (ma>3) + { + TIFFErrorExt(tif->tif_clientdata,module,"JpegAcTables tag has incorrect count"); + return(0); + } + sp->actable_offset_count=(uint8)ma; + mb=(uint64*)va_arg(ap,uint64*); + for (n=0; nactable_offset[n]=mb[n]; + } + break; + case TIFFTAG_JPEGPROC: + sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap); + break; + case TIFFTAG_JPEGRESTARTINTERVAL: + sp->restart_interval=(uint16)va_arg(ap,uint16_vap); + break; + default: + return (*sp->vsetparent)(tif,tag,ap); + } + TIFFSetFieldBit(tif,TIFFFieldWithTag(tif,tag)->field_bit); + tif->tif_flags|=TIFF_DIRTYDIRECT; + return(1); +} + +static void +OJPEGPrintDir(TIFF* tif, FILE* fd, long flags) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + (void)flags; + assert(sp!=NULL); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMAT)) + fprintf(fd," JpegInterchangeFormat: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) + fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format_length); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) + { + fprintf(fd," JpegQTables:"); + for (m=0; mqtable_offset_count; m++) + fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]); + fprintf(fd,"\n"); + } + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGDCTABLES)) + { + fprintf(fd," JpegDcTables:"); + for (m=0; mdctable_offset_count; m++) + fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]); + fprintf(fd,"\n"); + } + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGACTABLES)) + { + fprintf(fd," JpegAcTables:"); + for (m=0; mactable_offset_count; m++) + fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->actable_offset[m]); + fprintf(fd,"\n"); + } + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC)) + fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL)) + fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); +} + +static int +OJPEGFixupTags(TIFF* tif) +{ + (void) tif; + return(1); +} + +static int +OJPEGSetupDecode(TIFF* tif) +{ + static const char module[]="OJPEGSetupDecode"; + TIFFWarningExt(tif->tif_clientdata,module,"Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software"); + return(1); +} + +static int +OJPEGPreDecode(TIFF* tif, uint16 s) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 m; + if (sp->subsamplingcorrect_done==0) + OJPEGSubsamplingCorrect(tif); + if (sp->readheader_done==0) + { + if (OJPEGReadHeaderInfo(tif)==0) + return(0); + } + if (sp->sos_end[s].log==0) + { + if (OJPEGReadSecondarySos(tif,s)==0) + return(0); + } + if isTiled(tif) + m=tif->tif_curtile; + else + m=tif->tif_curstrip; + if ((sp->writeheader_done!=0) && ((sp->write_cursample!=s) || (sp->write_curstrile>m))) + { + if (sp->libjpeg_session_active!=0) + OJPEGLibjpegSessionAbort(tif); + sp->writeheader_done=0; + } + if (sp->writeheader_done==0) + { + sp->plane_sample_offset=(uint8)s; + sp->write_cursample=s; + sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; + if ((sp->in_buffer_file_pos_log==0) || + (sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos)) + { + sp->in_buffer_source=sp->sos_end[s].in_buffer_source; + sp->in_buffer_next_strile=sp->sos_end[s].in_buffer_next_strile; + sp->in_buffer_file_pos=sp->sos_end[s].in_buffer_file_pos; + sp->in_buffer_file_pos_log=0; + sp->in_buffer_file_togo=sp->sos_end[s].in_buffer_file_togo; + sp->in_buffer_togo=0; + sp->in_buffer_cur=0; + } + if (OJPEGWriteHeaderInfo(tif)==0) + return(0); + } + while (sp->write_curstrilelibjpeg_jpeg_query_style==0) + { + if (OJPEGPreDecodeSkipRaw(tif)==0) + return(0); + } + else + { + if (OJPEGPreDecodeSkipScanlines(tif)==0) + return(0); + } + sp->write_curstrile++; + } + return(1); +} + +static int +OJPEGPreDecodeSkipRaw(TIFF* tif) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 m; + m=sp->lines_per_strile; + if (sp->subsampling_convert_state!=0) + { + if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m) + { + sp->subsampling_convert_state+=m; + if (sp->subsampling_convert_state==sp->subsampling_convert_clines) + sp->subsampling_convert_state=0; + return(1); + } + m-=sp->subsampling_convert_clines-sp->subsampling_convert_state; + sp->subsampling_convert_state=0; + } + while (m>=sp->subsampling_convert_clines) + { + if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) + return(0); + m-=sp->subsampling_convert_clines; + } + if (m>0) + { + if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) + return(0); + sp->subsampling_convert_state=m; + } + return(1); +} + +static int +OJPEGPreDecodeSkipScanlines(TIFF* tif) +{ + static const char module[]="OJPEGPreDecodeSkipScanlines"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 m; + if (sp->skip_buffer==NULL) + { + sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); + if (sp->skip_buffer==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + } + for (m=0; mlines_per_strile; m++) + { + if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&sp->skip_buffer,1)==0) + return(0); + } + return(1); +} + +static int +OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + (void)s; + if (sp->libjpeg_jpeg_query_style==0) + { + if (OJPEGDecodeRaw(tif,buf,cc)==0) + return(0); + } + else + { + if (OJPEGDecodeScanlines(tif,buf,cc)==0) + return(0); + } + return(1); +} + +static int +OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc) +{ + static const char module[]="OJPEGDecodeRaw"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8* m; + tmsize_t n; + uint8* oy; + uint8* ocb; + uint8* ocr; + uint8* p; + uint32 q; + uint8* r; + uint8 sx,sy; + if (cc%sp->bytes_per_line!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); + return(0); + } + assert(cc>0); + m=buf; + n=cc; + do + { + if (sp->subsampling_convert_state==0) + { + if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) + return(0); + } + oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_convert_ylinelen; + ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; + ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; + p=m; + for (q=0; qsubsampling_convert_clinelenout; q++) + { + r=oy; + for (sy=0; sysubsampling_ver; sy++) + { + for (sx=0; sxsubsampling_hor; sx++) + *p++=*r++; + r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor; + } + oy+=sp->subsampling_hor; + *p++=*ocb++; + *p++=*ocr++; + } + sp->subsampling_convert_state++; + if (sp->subsampling_convert_state==sp->subsampling_convert_clines) + sp->subsampling_convert_state=0; + m+=sp->bytes_per_line; + n-=sp->bytes_per_line; + } while(n>0); + return(1); +} + +static int +OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc) +{ + static const char module[]="OJPEGDecodeScanlines"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8* m; + tmsize_t n; + if (cc%sp->bytes_per_line!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); + return(0); + } + assert(cc>0); + m=buf; + n=cc; + do + { + if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0) + return(0); + m+=sp->bytes_per_line; + n-=sp->bytes_per_line; + } while(n>0); + return(1); +} + +static void +OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + (void)buf; + (void)cc; + sp->write_curstrile++; + if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) + { + assert(sp->libjpeg_session_active!=0); + OJPEGLibjpegSessionAbort(tif); + sp->writeheader_done=0; + } +} + +static int +OJPEGSetupEncode(TIFF* tif) +{ + static const char module[]="OJPEGSetupEncode"; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); +} + +static int +OJPEGPreEncode(TIFF* tif, uint16 s) +{ + static const char module[]="OJPEGPreEncode"; + (void)s; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); +} + +static int +OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +{ + static const char module[]="OJPEGEncode"; + (void)buf; + (void)cc; + (void)s; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); +} + +static int +OJPEGPostEncode(TIFF* tif) +{ + static const char module[]="OJPEGPostEncode"; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); +} + +static void +OJPEGCleanup(TIFF* tif) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp!=0) + { + tif->tif_tagmethods.vgetfield=sp->vgetparent; + tif->tif_tagmethods.vsetfield=sp->vsetparent; + tif->tif_tagmethods.printdir=sp->printdir; + if (sp->qtable[0]!=0) + _TIFFfree(sp->qtable[0]); + if (sp->qtable[1]!=0) + _TIFFfree(sp->qtable[1]); + if (sp->qtable[2]!=0) + _TIFFfree(sp->qtable[2]); + if (sp->qtable[3]!=0) + _TIFFfree(sp->qtable[3]); + if (sp->dctable[0]!=0) + _TIFFfree(sp->dctable[0]); + if (sp->dctable[1]!=0) + _TIFFfree(sp->dctable[1]); + if (sp->dctable[2]!=0) + _TIFFfree(sp->dctable[2]); + if (sp->dctable[3]!=0) + _TIFFfree(sp->dctable[3]); + if (sp->actable[0]!=0) + _TIFFfree(sp->actable[0]); + if (sp->actable[1]!=0) + _TIFFfree(sp->actable[1]); + if (sp->actable[2]!=0) + _TIFFfree(sp->actable[2]); + if (sp->actable[3]!=0) + _TIFFfree(sp->actable[3]); + if (sp->libjpeg_session_active!=0) + OJPEGLibjpegSessionAbort(tif); + if (sp->subsampling_convert_ycbcrbuf!=0) + _TIFFfree(sp->subsampling_convert_ycbcrbuf); + if (sp->subsampling_convert_ycbcrimage!=0) + _TIFFfree(sp->subsampling_convert_ycbcrimage); + if (sp->skip_buffer!=0) + _TIFFfree(sp->skip_buffer); + _TIFFfree(sp); + tif->tif_data=NULL; + _TIFFSetDefaultCompressionState(tif); + } +} + +static void +OJPEGSubsamplingCorrect(TIFF* tif) +{ + static const char module[]="OJPEGSubsamplingCorrect"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 mh; + uint8 mv; + _TIFFFillStriles( tif ); + + assert(sp->subsamplingcorrect_done==0); + if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) && + (tif->tif_dir.td_photometric!=PHOTOMETRIC_ITULAB))) + { + if (sp->subsampling_tag!=0) + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag not appropriate for this Photometric and/or SamplesPerPixel"); + sp->subsampling_hor=1; + sp->subsampling_ver=1; + sp->subsampling_force_desubsampling_inside_decompression=0; + } + else + { + sp->subsamplingcorrect_done=1; + mh=sp->subsampling_hor; + mv=sp->subsampling_ver; + sp->subsamplingcorrect=1; + OJPEGReadHeaderInfoSec(tif); + if (sp->subsampling_force_desubsampling_inside_decompression!=0) + { + sp->subsampling_hor=1; + sp->subsampling_ver=1; + } + sp->subsamplingcorrect=0; + if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0)) + { + if (sp->subsampling_tag==0) + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%d,%d] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); + else + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%d,%d] does not match subsampling tag values [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); + } + if (sp->subsampling_force_desubsampling_inside_decompression!=0) + { + if (sp->subsampling_tag==0) + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data does not match default values [2,2] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression"); + else + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%d,%d] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); + } + if (sp->subsampling_force_desubsampling_inside_decompression==0) + { + if (sp->subsampling_horsubsampling_ver) + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); + } + } + sp->subsamplingcorrect_done=1; +} + +static int +OJPEGReadHeaderInfo(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfo"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(sp->readheader_done==0); + sp->image_width=tif->tif_dir.td_imagewidth; + sp->image_length=tif->tif_dir.td_imagelength; + if isTiled(tif) + { + sp->strile_width=tif->tif_dir.td_tilewidth; + sp->strile_length=tif->tif_dir.td_tilelength; + sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_length; + } + else + { + sp->strile_width=sp->image_width; + sp->strile_length=tif->tif_dir.td_rowsperstrip; + sp->strile_length_total=sp->image_length; + } + if (tif->tif_dir.td_samplesperpixel==1) + { + sp->samples_per_pixel=1; + sp->plane_sample_offset=0; + sp->samples_per_pixel_per_plane=sp->samples_per_pixel; + sp->subsampling_hor=1; + sp->subsampling_ver=1; + } + else + { + if (tif->tif_dir.td_samplesperpixel!=3) + { + TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); + return(0); + } + sp->samples_per_pixel=3; + sp->plane_sample_offset=0; + if (tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG) + sp->samples_per_pixel_per_plane=3; + else + sp->samples_per_pixel_per_plane=1; + } + if (sp->strile_lengthimage_length) + { + if (sp->strile_length%(sp->subsampling_ver*8)!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length"); + return(0); + } + sp->restart_interval=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8)); + } + if (OJPEGReadHeaderInfoSec(tif)==0) + return(0); + sp->sos_end[0].log=1; + sp->sos_end[0].in_buffer_source=sp->in_buffer_source; + sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile; + sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; + sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; + sp->readheader_done=1; + return(1); +} + +static int +OJPEGReadSecondarySos(TIFF* tif, uint16 s) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + assert(s>0); + assert(s<3); + assert(sp->sos_end[0].log!=0); + assert(sp->sos_end[s].log==0); + sp->plane_sample_offset=s-1; + while(sp->sos_end[sp->plane_sample_offset].log==0) + sp->plane_sample_offset--; + sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; + sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; + sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; + sp->in_buffer_file_pos_log=0; + sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; + sp->in_buffer_togo=0; + sp->in_buffer_cur=0; + while(sp->plane_sample_offsetplane_sample_offset++; + if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) + return(0); + sp->sos_end[sp->plane_sample_offset].log=1; + sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source; + sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile; + sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; + sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; + } + return(1); +} + +static int +OJPEGWriteHeaderInfo(TIFF* tif) +{ + static const char module[]="OJPEGWriteHeaderInfo"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8** m; + uint32 n; + /* if a previous attempt failed, don't try again */ + if (sp->libjpeg_session_active != 0) + return 0; + sp->out_state=ososSoi; + sp->restart_index=0; + jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); + sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage; + sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit; + sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr); + sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif; + if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) + return(0); + sp->libjpeg_session_active=1; + sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0; + sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource; + sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer; + sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData; + sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart; + sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource; + sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr); + if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0) + return(0); + if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_plane>1)) + { + sp->libjpeg_jpeg_decompress_struct.raw_data_out=1; +#if JPEG_LIB_VERSION >= 70 + sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; +#endif + sp->libjpeg_jpeg_query_style=0; + if (sp->subsampling_convert_log==0) + { + assert(sp->subsampling_convert_ycbcrbuf==0); + assert(sp->subsampling_convert_ycbcrimage==0); + sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8)*sp->subsampling_hor*8); + sp->subsampling_convert_ylines=sp->subsampling_ver*8; + sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor; + sp->subsampling_convert_clines=8; + sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines; + sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines; + sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuflen; + sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen); + if (sp->subsampling_convert_ycbcrbuf==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf; + sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; + sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; + sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_clines; + sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*)); + if (sp->subsampling_convert_ycbcrimage==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + m=sp->subsampling_convert_ycbcrimage; + *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); + *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); + *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_convert_clines); + for (n=0; nsubsampling_convert_ylines; n++) + *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; + for (n=0; nsubsampling_convert_clines; n++) + *m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen; + for (n=0; nsubsampling_convert_clines; n++) + *m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen; + sp->subsampling_convert_clinelenout=((sp->strile_width+sp->subsampling_hor-1)/sp->subsampling_hor); + sp->subsampling_convert_state=0; + sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2); + sp->lines_per_strile=((sp->strile_length+sp->subsampling_ver-1)/sp->subsampling_ver); + sp->subsampling_convert_log=1; + } + } + else + { + sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN; + sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN; + sp->libjpeg_jpeg_query_style=1; + sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width; + sp->lines_per_strile=sp->strile_length; + } + if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) + return(0); + sp->writeheader_done=1; + return(1); +} + +static void +OJPEGLibjpegSessionAbort(TIFF* tif) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(sp->libjpeg_session_active!=0); + jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct))); + sp->libjpeg_session_active=0; +} + +static int +OJPEGReadHeaderInfoSec(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfoSec"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + uint16 n; + uint8 o; + if (sp->file_size==0) + sp->file_size=TIFFGetFileSize(tif); + if (sp->jpeg_interchange_format!=0) + { + if (sp->jpeg_interchange_format>=sp->file_size) + { + sp->jpeg_interchange_format=0; + sp->jpeg_interchange_format_length=0; + } + else + { + if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size)) + sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; + } + } + sp->in_buffer_source=osibsNotSetYet; + sp->in_buffer_next_strile=0; + sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; + sp->in_buffer_file_togo=0; + sp->in_buffer_togo=0; + do + { + if (OJPEGReadBytePeek(sp,&m)==0) + return(0); + if (m!=255) + break; + OJPEGReadByteAdvance(sp); + do + { + if (OJPEGReadByte(sp,&m)==0) + return(0); + } while(m==255); + switch(m) + { + case JPEG_MARKER_SOI: + /* this type of marker has no data, and should be skipped */ + break; + case JPEG_MARKER_COM: + case JPEG_MARKER_APP0: + case JPEG_MARKER_APP0+1: + case JPEG_MARKER_APP0+2: + case JPEG_MARKER_APP0+3: + case JPEG_MARKER_APP0+4: + case JPEG_MARKER_APP0+5: + case JPEG_MARKER_APP0+6: + case JPEG_MARKER_APP0+7: + case JPEG_MARKER_APP0+8: + case JPEG_MARKER_APP0+9: + case JPEG_MARKER_APP0+10: + case JPEG_MARKER_APP0+11: + case JPEG_MARKER_APP0+12: + case JPEG_MARKER_APP0+13: + case JPEG_MARKER_APP0+14: + case JPEG_MARKER_APP0+15: + /* this type of marker has data, but it has no use to us (and no place here) and should be skipped */ + if (OJPEGReadWord(sp,&n)==0) + return(0); + if (n<2) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); + return(0); + } + if (n>2) + OJPEGReadSkip(sp,n-2); + break; + case JPEG_MARKER_DRI: + if (OJPEGReadHeaderInfoSecStreamDri(tif)==0) + return(0); + break; + case JPEG_MARKER_DQT: + if (OJPEGReadHeaderInfoSecStreamDqt(tif)==0) + return(0); + break; + case JPEG_MARKER_DHT: + if (OJPEGReadHeaderInfoSecStreamDht(tif)==0) + return(0); + break; + case JPEG_MARKER_SOF0: + case JPEG_MARKER_SOF1: + case JPEG_MARKER_SOF3: + if (OJPEGReadHeaderInfoSecStreamSof(tif,m)==0) + return(0); + if (sp->subsamplingcorrect!=0) + return(1); + break; + case JPEG_MARKER_SOS: + if (sp->subsamplingcorrect!=0) + return(1); + assert(sp->plane_sample_offset==0); + if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) + return(0); + break; + default: + TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); + return(0); + } + } while(m!=JPEG_MARKER_SOS); + if (sp->subsamplingcorrect) + return(1); + if (sp->sof_log==0) + { + if (OJPEGReadHeaderInfoSecTablesQTable(tif)==0) + return(0); + sp->sof_marker_id=JPEG_MARKER_SOF0; + for (o=0; osamples_per_pixel; o++) + sp->sof_c[o]=o; + sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); + for (o=1; osamples_per_pixel; o++) + sp->sof_hv[o]=17; + sp->sof_x=sp->strile_width; + sp->sof_y=sp->strile_length_total; + sp->sof_log=1; + if (OJPEGReadHeaderInfoSecTablesDcTable(tif)==0) + return(0); + if (OJPEGReadHeaderInfoSecTablesAcTable(tif)==0) + return(0); + for (o=1; osamples_per_pixel; o++) + sp->sos_cs[o]=o; + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamDri(TIFF* tif) +{ + /* this could easilly cause trouble in some cases... but no such cases have occured sofar */ + static const char module[]="OJPEGReadHeaderInfoSecStreamDri"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint16 m; + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m!=4) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DRI marker in JPEG data"); + return(0); + } + if (OJPEGReadWord(sp,&m)==0) + return(0); + sp->restart_interval=m; + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) +{ + /* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */ + static const char module[]="OJPEGReadHeaderInfoSecStreamDqt"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint16 m; + uint32 na; + uint8* nb; + uint8 o; + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m<=2) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + return(0); + } + if (sp->subsamplingcorrect!=0) + OJPEGReadSkip(sp,m-2); + else + { + m-=2; + do + { + if (m<65) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + return(0); + } + na=sizeof(uint32)+69; + nb=_TIFFmalloc(na); + if (nb==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + *(uint32*)nb=na; + nb[sizeof(uint32)]=255; + nb[sizeof(uint32)+1]=JPEG_MARKER_DQT; + nb[sizeof(uint32)+2]=0; + nb[sizeof(uint32)+3]=67; + if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { + _TIFFfree(nb); + return(0); + } + o=nb[sizeof(uint32)+4]&15; + if (3tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + _TIFFfree(nb); + return(0); + } + if (sp->qtable[o]!=0) + _TIFFfree(sp->qtable[o]); + sp->qtable[o]=nb; + m-=65; + } while(m>0); + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) +{ + /* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */ + /* TODO: the following assumes there is only one table in this marker... but i'm not quite sure that assumption is guaranteed correct */ + static const char module[]="OJPEGReadHeaderInfoSecStreamDht"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint16 m; + uint32 na; + uint8* nb; + uint8 o; + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m<=2) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + return(0); + } + if (sp->subsamplingcorrect!=0) + { + OJPEGReadSkip(sp,m-2); + } + else + { + na=sizeof(uint32)+2+m; + nb=_TIFFmalloc(na); + if (nb==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + *(uint32*)nb=na; + nb[sizeof(uint32)]=255; + nb[sizeof(uint32)+1]=JPEG_MARKER_DHT; + nb[sizeof(uint32)+2]=(m>>8); + nb[sizeof(uint32)+3]=(m&255); + if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) + return(0); + o=nb[sizeof(uint32)+4]; + if ((o&240)==0) + { + if (3tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + return(0); + } + if (sp->dctable[o]!=0) + _TIFFfree(sp->dctable[o]); + sp->dctable[o]=nb; + } + else + { + if ((o&240)!=16) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + return(0); + } + o&=15; + if (3tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + return(0); + } + if (sp->actable[o]!=0) + _TIFFfree(sp->actable[o]); + sp->actable[o]=nb; + } + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) +{ + /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ + static const char module[]="OJPEGReadHeaderInfoSecStreamSof"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint16 m; + uint16 n; + uint8 o; + uint16 p; + uint16 q; + if (sp->sof_log!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); + return(0); + } + if (sp->subsamplingcorrect==0) + sp->sof_marker_id=marker_id; + /* Lf: data length */ + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m<11) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); + return(0); + } + m-=8; + if (m%3!=0) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); + return(0); + } + n=m/3; + if (sp->subsamplingcorrect==0) + { + if (n!=sp->samples_per_pixel) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of samples"); + return(0); + } + } + /* P: Sample precision */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (o!=8) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of bits per sample"); + return(0); + } + /* Y: Number of lines, X: Number of samples per line */ + if (sp->subsamplingcorrect) + OJPEGReadSkip(sp,4); + else + { + /* Y: Number of lines */ + if (OJPEGReadWord(sp,&p)==0) + return(0); + if (((uint32)pimage_length) && ((uint32)pstrile_length_total)) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected height"); + return(0); + } + sp->sof_y=p; + /* X: Number of samples per line */ + if (OJPEGReadWord(sp,&p)==0) + return(0); + if (((uint32)pimage_width) && ((uint32)pstrile_width)) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width"); + return(0); + } + if ((uint32)p>sp->strile_width) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width"); + return(0); + } + sp->sof_x=p; + } + /* Nf: Number of image components in frame */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (o!=n) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); + return(0); + } + /* per component stuff */ + /* TODO: double-check that flow implies that n cannot be as big as to make us overflow sof_c, sof_hv and sof_tq arrays */ + for (q=0; qsubsamplingcorrect==0) + sp->sof_c[q]=o; + /* H: Horizontal sampling factor, and V: Vertical sampling factor */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (sp->subsamplingcorrect!=0) + { + if (q==0) + { + sp->subsampling_hor=(o>>4); + sp->subsampling_ver=(o&15); + if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || + ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) + sp->subsampling_force_desubsampling_inside_decompression=1; + } + else + { + if (o!=17) + sp->subsampling_force_desubsampling_inside_decompression=1; + } + } + else + { + sp->sof_hv[q]=o; + if (sp->subsampling_force_desubsampling_inside_decompression==0) + { + if (q==0) + { + if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver)) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values"); + return(0); + } + } + else + { + if (o!=17) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values"); + return(0); + } + } + } + } + /* Tq: Quantization table destination selector */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (sp->subsamplingcorrect==0) + sp->sof_tq[q]=o; + } + if (sp->subsamplingcorrect==0) + sp->sof_log=1; + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamSos(TIFF* tif) +{ + /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ + static const char module[]="OJPEGReadHeaderInfoSecStreamSos"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint16 m; + uint8 n; + uint8 o; + assert(sp->subsamplingcorrect==0); + if (sp->sof_log==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); + return(0); + } + /* Ls */ + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m!=6+sp->samples_per_pixel_per_plane*2) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); + return(0); + } + /* Ns */ + if (OJPEGReadByte(sp,&n)==0) + return(0); + if (n!=sp->samples_per_pixel_per_plane) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); + return(0); + } + /* Cs, Td, and Ta */ + for (o=0; osamples_per_pixel_per_plane; o++) + { + /* Cs */ + if (OJPEGReadByte(sp,&n)==0) + return(0); + sp->sos_cs[sp->plane_sample_offset+o]=n; + /* Td and Ta */ + if (OJPEGReadByte(sp,&n)==0) + return(0); + sp->sos_tda[sp->plane_sample_offset+o]=n; + } + /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as per LibJpeg source */ + OJPEGReadSkip(sp,3); + return(1); +} + +static int +OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfoSecTablesQTable"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + uint8 n; + uint32 oa; + uint8* ob; + uint32 p; + if (sp->qtable_offset[0]==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); + return(0); + } + sp->in_buffer_file_pos_log=0; + for (m=0; msamples_per_pixel; m++) + { + if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1]))) + { + for (n=0; nqtable_offset[m]==sp->qtable_offset[n]) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegQTables tag value"); + return(0); + } + } + oa=sizeof(uint32)+69; + ob=_TIFFmalloc(oa); + if (ob==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + *(uint32*)ob=oa; + ob[sizeof(uint32)]=255; + ob[sizeof(uint32)+1]=JPEG_MARKER_DQT; + ob[sizeof(uint32)+2]=0; + ob[sizeof(uint32)+3]=67; + ob[sizeof(uint32)+4]=m; + TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); + p=TIFFReadFile(tif,&ob[sizeof(uint32)+5],64); + if (p!=64) + return(0); + sp->qtable[m]=ob; + sp->sof_tq[m]=m; + } + else + sp->sof_tq[m]=sp->sof_tq[m-1]; + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfoSecTablesDcTable"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + uint8 n; + uint8 o[16]; + uint32 p; + uint32 q; + uint32 ra; + uint8* rb; + if (sp->dctable_offset[0]==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); + return(0); + } + sp->in_buffer_file_pos_log=0; + for (m=0; msamples_per_pixel; m++) + { + if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1]))) + { + for (n=0; ndctable_offset[m]==sp->dctable_offset[n]) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegDcTables tag value"); + return(0); + } + } + TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); + p=TIFFReadFile(tif,o,16); + if (p!=16) + return(0); + q=0; + for (n=0; n<16; n++) + q+=o[n]; + ra=sizeof(uint32)+21+q; + rb=_TIFFmalloc(ra); + if (rb==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + *(uint32*)rb=ra; + rb[sizeof(uint32)]=255; + rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; + rb[sizeof(uint32)+2]=((19+q)>>8); + rb[sizeof(uint32)+3]=((19+q)&255); + rb[sizeof(uint32)+4]=m; + for (n=0; n<16; n++) + rb[sizeof(uint32)+5+n]=o[n]; + p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + if (p!=q) + return(0); + sp->dctable[m]=rb; + sp->sos_tda[m]=(m<<4); + } + else + sp->sos_tda[m]=sp->sos_tda[m-1]; + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfoSecTablesAcTable"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + uint8 n; + uint8 o[16]; + uint32 p; + uint32 q; + uint32 ra; + uint8* rb; + if (sp->actable_offset[0]==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); + return(0); + } + sp->in_buffer_file_pos_log=0; + for (m=0; msamples_per_pixel; m++) + { + if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1]))) + { + for (n=0; nactable_offset[m]==sp->actable_offset[n]) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegAcTables tag value"); + return(0); + } + } + TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); + p=TIFFReadFile(tif,o,16); + if (p!=16) + return(0); + q=0; + for (n=0; n<16; n++) + q+=o[n]; + ra=sizeof(uint32)+21+q; + rb=_TIFFmalloc(ra); + if (rb==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + *(uint32*)rb=ra; + rb[sizeof(uint32)]=255; + rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; + rb[sizeof(uint32)+2]=((19+q)>>8); + rb[sizeof(uint32)+3]=((19+q)&255); + rb[sizeof(uint32)+4]=(16|m); + for (n=0; n<16; n++) + rb[sizeof(uint32)+5+n]=o[n]; + p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + if (p!=q) + return(0); + sp->actable[m]=rb; + sp->sos_tda[m]=(sp->sos_tda[m]|m); + } + else + sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15)); + } + return(1); +} + +static int +OJPEGReadBufferFill(OJPEGState* sp) +{ + uint16 m; + tmsize_t n; + /* TODO: double-check: when subsamplingcorrect is set, no call to TIFFErrorExt or TIFFWarningExt should be made + * in any other case, seek or read errors should be passed through */ + do + { + if (sp->in_buffer_file_togo!=0) + { + if (sp->in_buffer_file_pos_log==0) + { + TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET); + sp->in_buffer_file_pos_log=1; + } + m=OJPEG_BUFFER; + if ((uint64)m>sp->in_buffer_file_togo) + m=(uint16)sp->in_buffer_file_togo; + n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m); + if (n==0) + return(0); + assert(n>0); + assert(n<=OJPEG_BUFFER); + assert(n<65536); + assert((uint64)n<=sp->in_buffer_file_togo); + m=(uint16)n; + sp->in_buffer_togo=m; + sp->in_buffer_cur=sp->in_buffer; + sp->in_buffer_file_togo-=m; + sp->in_buffer_file_pos+=m; + break; + } + sp->in_buffer_file_pos_log=0; + switch(sp->in_buffer_source) + { + case osibsNotSetYet: + if (sp->jpeg_interchange_format!=0) + { + sp->in_buffer_file_pos=sp->jpeg_interchange_format; + sp->in_buffer_file_togo=sp->jpeg_interchange_format_length; + } + sp->in_buffer_source=osibsJpegInterchangeFormat; + break; + case osibsJpegInterchangeFormat: + sp->in_buffer_source=osibsStrile; + case osibsStrile: + if (!_TIFFFillStriles( sp->tif ) + || sp->tif->tif_dir.td_stripoffset == NULL + || sp->tif->tif_dir.td_stripbytecount == NULL) + return 0; + + if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) + sp->in_buffer_source=osibsEof; + else + { + sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; + if (sp->in_buffer_file_pos!=0) + { + if (sp->in_buffer_file_pos>=sp->file_size) + sp->in_buffer_file_pos=0; + else if (sp->tif->tif_dir.td_stripbytecount==NULL) + sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; + else + { + if (sp->tif->tif_dir.td_stripbytecount == 0) { + TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing"); + return(0); + } + sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; + if (sp->in_buffer_file_togo==0) + sp->in_buffer_file_pos=0; + else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) + sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; + } + } + sp->in_buffer_next_strile++; + } + break; + default: + return(0); + } + } while (1); + return(1); +} + +static int +OJPEGReadByte(OJPEGState* sp, uint8* byte) +{ + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + *byte=*(sp->in_buffer_cur); + sp->in_buffer_cur++; + sp->in_buffer_togo--; + return(1); +} + +static int +OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) +{ + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + *byte=*(sp->in_buffer_cur); + return(1); +} + +static void +OJPEGReadByteAdvance(OJPEGState* sp) +{ + assert(sp->in_buffer_togo>0); + sp->in_buffer_cur++; + sp->in_buffer_togo--; +} + +static int +OJPEGReadWord(OJPEGState* sp, uint16* word) +{ + uint8 m; + if (OJPEGReadByte(sp,&m)==0) + return(0); + *word=(m<<8); + if (OJPEGReadByte(sp,&m)==0) + return(0); + *word|=m; + return(1); +} + +static int +OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) +{ + uint16 mlen; + uint8* mmem; + uint16 n; + assert(len>0); + mlen=len; + mmem=mem; + do + { + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + n=mlen; + if (n>sp->in_buffer_togo) + n=sp->in_buffer_togo; + _TIFFmemcpy(mmem,sp->in_buffer_cur,n); + sp->in_buffer_cur+=n; + sp->in_buffer_togo-=n; + mlen-=n; + mmem+=n; + } while(mlen>0); + return(1); +} + +static void +OJPEGReadSkip(OJPEGState* sp, uint16 len) +{ + uint16 m; + uint16 n; + m=len; + n=m; + if (n>sp->in_buffer_togo) + n=sp->in_buffer_togo; + sp->in_buffer_cur+=n; + sp->in_buffer_togo-=n; + m-=n; + if (m>0) + { + assert(sp->in_buffer_togo==0); + n=m; + if ((uint64)n>sp->in_buffer_file_togo) + n=(uint16)sp->in_buffer_file_togo; + sp->in_buffer_file_pos+=n; + sp->in_buffer_file_togo-=n; + sp->in_buffer_file_pos_log=0; + /* we don't skip past jpeginterchangeformat/strile block... + * if that is asked from us, we're dealing with totally bazurk + * data anyway, and we've not seen this happening on any + * testfile, so we might as well likely cause some other + * meaningless error to be passed at some later time + */ + } +} + +static int +OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + *len=0; + do + { + assert(sp->out_state<=ososEoi); + switch(sp->out_state) + { + case ososSoi: + OJPEGWriteStreamSoi(tif,mem,len); + break; + case ososQTable0: + OJPEGWriteStreamQTable(tif,0,mem,len); + break; + case ososQTable1: + OJPEGWriteStreamQTable(tif,1,mem,len); + break; + case ososQTable2: + OJPEGWriteStreamQTable(tif,2,mem,len); + break; + case ososQTable3: + OJPEGWriteStreamQTable(tif,3,mem,len); + break; + case ososDcTable0: + OJPEGWriteStreamDcTable(tif,0,mem,len); + break; + case ososDcTable1: + OJPEGWriteStreamDcTable(tif,1,mem,len); + break; + case ososDcTable2: + OJPEGWriteStreamDcTable(tif,2,mem,len); + break; + case ososDcTable3: + OJPEGWriteStreamDcTable(tif,3,mem,len); + break; + case ososAcTable0: + OJPEGWriteStreamAcTable(tif,0,mem,len); + break; + case ososAcTable1: + OJPEGWriteStreamAcTable(tif,1,mem,len); + break; + case ososAcTable2: + OJPEGWriteStreamAcTable(tif,2,mem,len); + break; + case ososAcTable3: + OJPEGWriteStreamAcTable(tif,3,mem,len); + break; + case ososDri: + OJPEGWriteStreamDri(tif,mem,len); + break; + case ososSof: + OJPEGWriteStreamSof(tif,mem,len); + break; + case ososSos: + OJPEGWriteStreamSos(tif,mem,len); + break; + case ososCompressed: + if (OJPEGWriteStreamCompressed(tif,mem,len)==0) + return(0); + break; + case ososRst: + OJPEGWriteStreamRst(tif,mem,len); + break; + case ososEoi: + OJPEGWriteStreamEoi(tif,mem,len); + break; + } + } while (*len==0); + return(1); +} + +static void +OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_SOI; + *len=2; + *mem=(void*)sp->out_buffer; + sp->out_state++; +} + +static void +OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp->qtable[table_index]!=0) + { + *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); + *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); + } + sp->out_state++; +} + +static void +OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp->dctable[table_index]!=0) + { + *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); + *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); + } + sp->out_state++; +} + +static void +OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp->actable[table_index]!=0) + { + *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); + *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); + } + sp->out_state++; +} + +static void +OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=6); + if (sp->restart_interval!=0) + { + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_DRI; + sp->out_buffer[2]=0; + sp->out_buffer[3]=4; + sp->out_buffer[4]=(sp->restart_interval>>8); + sp->out_buffer[5]=(sp->restart_interval&255); + *len=6; + *mem=(void*)sp->out_buffer; + } + sp->out_state++; +} + +static void +OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); + assert(255>=8+sp->samples_per_pixel_per_plane*3); + sp->out_buffer[0]=255; + sp->out_buffer[1]=sp->sof_marker_id; + /* Lf */ + sp->out_buffer[2]=0; + sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3; + /* P */ + sp->out_buffer[4]=8; + /* Y */ + sp->out_buffer[5]=(sp->sof_y>>8); + sp->out_buffer[6]=(sp->sof_y&255); + /* X */ + sp->out_buffer[7]=(sp->sof_x>>8); + sp->out_buffer[8]=(sp->sof_x&255); + /* Nf */ + sp->out_buffer[9]=sp->samples_per_pixel_per_plane; + for (m=0; msamples_per_pixel_per_plane; m++) + { + /* C */ + sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m]; + /* H and V */ + sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m]; + /* Tq */ + sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m]; + } + *len=10+sp->samples_per_pixel_per_plane*3; + *mem=(void*)sp->out_buffer; + sp->out_state++; +} + +static void +OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); + assert(255>=6+sp->samples_per_pixel_per_plane*2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_SOS; + /* Ls */ + sp->out_buffer[2]=0; + sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2; + /* Ns */ + sp->out_buffer[4]=sp->samples_per_pixel_per_plane; + for (m=0; msamples_per_pixel_per_plane; m++) + { + /* Cs */ + sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m]; + /* Td and Ta */ + sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m]; + } + /* Ss */ + sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0; + /* Se */ + sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63; + /* Ah and Al */ + sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0; + *len=8+sp->samples_per_pixel_per_plane*2; + *mem=(void*)sp->out_buffer; + sp->out_state++; +} + +static int +OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + *len=sp->in_buffer_togo; + *mem=(void*)sp->in_buffer_cur; + sp->in_buffer_togo=0; + if (sp->in_buffer_file_togo==0) + { + switch(sp->in_buffer_source) + { + case osibsStrile: + if (sp->in_buffer_next_strilein_buffer_strile_count) + sp->out_state=ososRst; + else + sp->out_state=ososEoi; + break; + case osibsEof: + sp->out_state=ososEoi; + break; + default: + break; + } + } + return(1); +} + +static void +OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index; + sp->restart_index++; + if (sp->restart_index==8) + sp->restart_index=0; + *len=2; + *mem=(void*)sp->out_buffer; + sp->out_state=ososCompressed; +} + +static void +OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_EOI; + *len=2; + *mem=(void*)sp->out_buffer; +} + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) +{ + return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_create_decompress(cinfo),1)); +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) +{ + return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_header(cinfo,require_image),1)); +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) +{ + return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_start_decompress(cinfo),1)); +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines) +{ + return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_scanlines(cinfo,scanlines,max_lines),1)); +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines) +{ + return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_raw_data(cinfo,data,max_lines),1)); +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static void +jpeg_encap_unwind(TIFF* tif) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + LONGJMP(sp->exit_jmpbuf,1); +} +#endif + +static void +OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo,buffer); + TIFFWarningExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg","%s",buffer); +} + +static void +OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo,buffer); + TIFFErrorExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg","%s",buffer); + jpeg_encap_unwind((TIFF*)(cinfo->client_data)); +} + +static void +OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo) +{ + (void)cinfo; +} + +static boolean +OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo) +{ + TIFF* tif=(TIFF*)cinfo->client_data; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + void* mem=0; + uint32 len=0U; + if (OJPEGWriteStream(tif,&mem,&len)==0) + { + TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data"); + jpeg_encap_unwind(tif); + } + sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len; + sp->libjpeg_jpeg_source_mgr.next_input_byte=mem; + return(1); +} + +static void +OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes) +{ + TIFF* tif=(TIFF*)cinfo->client_data; + (void)num_bytes; + TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error"); + jpeg_encap_unwind(tif); +} + +static boolean +OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired) +{ + TIFF* tif=(TIFF*)cinfo->client_data; + (void)desired; + TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error"); + jpeg_encap_unwind(tif); + return(0); +} + +static void +OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo) +{ + (void)cinfo; +} + +#endif + + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_open.c b/libs/tiff-4.0.2/libtiff/tif_open.c similarity index 53% rename from libs/tiff-3.8.2/libtiff/tif_open.c rename to libs/tiff-4.0.2/libtiff/tif_open.c index c6e8b64565..8c88328cf2 100644 --- a/libs/tiff-3.8.2/libtiff/tif_open.c +++ b/libs/tiff-4.0.2/libtiff/tif_open.c @@ -1,4 +1,4 @@ -/* $Id: tif_open.c,v 1.31 2006/03/16 12:23:02 dron Exp $ */ +/* $Id: tif_open.c,v 1.46 2010-12-06 16:54:54 faxguy Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -29,90 +29,22 @@ */ #include "tiffiop.h" -static const long typemask[13] = { - (long)0L, /* TIFF_NOTYPE */ - (long)0x000000ffL, /* TIFF_BYTE */ - (long)0xffffffffL, /* TIFF_ASCII */ - (long)0x0000ffffL, /* TIFF_SHORT */ - (long)0xffffffffL, /* TIFF_LONG */ - (long)0xffffffffL, /* TIFF_RATIONAL */ - (long)0x000000ffL, /* TIFF_SBYTE */ - (long)0x000000ffL, /* TIFF_UNDEFINED */ - (long)0x0000ffffL, /* TIFF_SSHORT */ - (long)0xffffffffL, /* TIFF_SLONG */ - (long)0xffffffffL, /* TIFF_SRATIONAL */ - (long)0xffffffffL, /* TIFF_FLOAT */ - (long)0xffffffffL, /* TIFF_DOUBLE */ -}; -static const int bigTypeshift[13] = { - 0, /* TIFF_NOTYPE */ - 24, /* TIFF_BYTE */ - 0, /* TIFF_ASCII */ - 16, /* TIFF_SHORT */ - 0, /* TIFF_LONG */ - 0, /* TIFF_RATIONAL */ - 24, /* TIFF_SBYTE */ - 24, /* TIFF_UNDEFINED */ - 16, /* TIFF_SSHORT */ - 0, /* TIFF_SLONG */ - 0, /* TIFF_SRATIONAL */ - 0, /* TIFF_FLOAT */ - 0, /* TIFF_DOUBLE */ -}; -static const int litTypeshift[13] = { - 0, /* TIFF_NOTYPE */ - 0, /* TIFF_BYTE */ - 0, /* TIFF_ASCII */ - 0, /* TIFF_SHORT */ - 0, /* TIFF_LONG */ - 0, /* TIFF_RATIONAL */ - 0, /* TIFF_SBYTE */ - 0, /* TIFF_UNDEFINED */ - 0, /* TIFF_SSHORT */ - 0, /* TIFF_SLONG */ - 0, /* TIFF_SRATIONAL */ - 0, /* TIFF_FLOAT */ - 0, /* TIFF_DOUBLE */ -}; - /* * Dummy functions to fill the omitted client procedures. */ static int -_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize) { (void) fd; (void) pbase; (void) psize; return (0); } static void -_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size) { (void) fd; (void) base; (void) size; } -/* - * Initialize the shift & mask tables, and the - * byte swapping state according to the file - * contents and the machine architecture. - */ -static void -TIFFInitOrder(TIFF* tif, int magic) -{ - tif->tif_typemask = typemask; - if (magic == TIFF_BIGENDIAN) { - tif->tif_typeshift = bigTypeshift; -#ifndef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } else { - tif->tif_typeshift = litTypeshift; -#ifdef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } -} - int _TIFFgetMode(const char* mode, const char* module) { @@ -155,10 +87,36 @@ TIFFClientOpen( int m; const char* cp; + /* The following are configuration checks. They should be redundant, but should not + * compile to any actual code in an optimised release build anyway. If any of them + * fail, (makefile-based or other) configuration is not correct */ + assert(sizeof(uint8)==1); + assert(sizeof(int8)==1); + assert(sizeof(uint16)==2); + assert(sizeof(int16)==2); + assert(sizeof(uint32)==4); + assert(sizeof(int32)==4); + assert(sizeof(uint64)==8); + assert(sizeof(int64)==8); + assert(sizeof(tmsize_t)==sizeof(void*)); + { + union{ + uint8 a8[2]; + uint16 a16; + } n; + n.a8[0]=1; + n.a8[1]=0; + #ifdef WORDS_BIGENDIAN + assert(n.a16==256); + #else + assert(n.a16==1); + #endif + } + m = _TIFFgetMode(mode, module); if (m == -1) goto bad2; - tif = (TIFF *)_TIFFmalloc(sizeof (TIFF) + strlen(name) + 1); + tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + strlen(name) + 1)); if (tif == NULL) { TIFFErrorExt(clientdata, module, "%s: Out of memory (TIFF structure)", name); goto bad2; @@ -167,14 +125,14 @@ TIFFClientOpen( tif->tif_name = (char *)tif + sizeof (TIFF); strcpy(tif->tif_name, name); tif->tif_mode = m &~ (O_CREAT|O_TRUNC); - tif->tif_curdir = (tdir_t) -1; /* non-existent directory */ + tif->tif_curdir = (uint16) -1; /* non-existent directory */ tif->tif_curoff = 0; - tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */ + tif->tif_curstrip = (uint32) -1; /* invalid strip */ tif->tif_row = (uint32) -1; /* read/write pre-increment */ tif->tif_clientdata = clientdata; if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) { TIFFErrorExt(clientdata, module, - "One of the client procedures is NULL pointer."); + "One of the client procedures is NULL pointer."); goto bad2; } tif->tif_readproc = readproc; @@ -182,7 +140,7 @@ TIFFClientOpen( tif->tif_seekproc = seekproc; tif->tif_closeproc = closeproc; tif->tif_sizeproc = sizeproc; - if (mapproc) + if (mapproc) tif->tif_mapproc = mapproc; else tif->tif_mapproc = _tiffDummyMapProc; @@ -190,7 +148,7 @@ TIFFClientOpen( tif->tif_unmapproc = unmapproc; else tif->tif_unmapproc = _tiffDummyUnmapProc; - _TIFFSetDefaultCompressionState(tif); /* setup default state */ + _TIFFSetDefaultCompressionState(tif); /* setup default state */ /* * Default is to return data MSB2LSB and enable the * use of memory-mapped files and strip chopping when @@ -198,12 +156,12 @@ TIFFClientOpen( */ tif->tif_flags = FILLORDER_MSB2LSB; if (m == O_RDONLY ) - tif->tif_flags |= TIFF_MAPPED; + tif->tif_flags |= TIFF_MAPPED; -#ifdef STRIPCHOP_DEFAULT + #ifdef STRIPCHOP_DEFAULT if (m == O_RDONLY || m == O_RDWR) tif->tif_flags |= STRIPCHOP_DEFAULT; -#endif + #endif /* * Process library-specific flags in the open mode string. @@ -213,16 +171,18 @@ TIFFClientOpen( * TIFF but only supports some braindead idea of what the * vendor thinks TIFF is): * - * 'l' use little-endian byte order for creating a file - * 'b' use big-endian byte order for creating a file - * 'L' read/write information using LSB2MSB bit order - * 'B' read/write information using MSB2LSB bit order - * 'H' read/write information using host bit order - * 'M' enable use of memory-mapped files when supported - * 'm' disable use of memory-mapped files - * 'C' enable strip chopping support when reading - * 'c' disable strip chopping support - * 'h' read TIFF header only, do not load the first IFD + * 'l' use little-endian byte order for creating a file + * 'b' use big-endian byte order for creating a file + * 'L' read/write information using LSB2MSB bit order + * 'B' read/write information using MSB2LSB bit order + * 'H' read/write information using host bit order + * 'M' enable use of memory-mapped files when supported + * 'm' disable use of memory-mapped files + * 'C' enable strip chopping support when reading + * 'c' disable strip chopping support + * 'h' read TIFF header only, do not load the first IFD + * '4' ClassicTIFF for creating a file (default) + * '8' BigTIFF for creating a file * * The use of the 'l' and 'b' flags is strongly discouraged. * These flags are provided solely because numerous vendors, @@ -257,92 +217,120 @@ TIFFClientOpen( */ for (cp = mode; *cp; cp++) switch (*cp) { - case 'b': -#ifndef WORDS_BIGENDIAN - if (m&O_CREAT) - tif->tif_flags |= TIFF_SWAB; -#endif - break; - case 'l': -#ifdef WORDS_BIGENDIAN - if ((m&O_CREAT)) - tif->tif_flags |= TIFF_SWAB; -#endif - break; - case 'B': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - FILLORDER_MSB2LSB; - break; - case 'L': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - FILLORDER_LSB2MSB; - break; - case 'H': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - HOST_FILLORDER; - break; - case 'M': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_MAPPED; - break; - case 'm': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_MAPPED; - break; - case 'C': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_STRIPCHOP; - break; - case 'c': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_STRIPCHOP; - break; - case 'h': - tif->tif_flags |= TIFF_HEADERONLY; - break; + case 'b': + #ifndef WORDS_BIGENDIAN + if (m&O_CREAT) + tif->tif_flags |= TIFF_SWAB; + #endif + break; + case 'l': + #ifdef WORDS_BIGENDIAN + if ((m&O_CREAT)) + tif->tif_flags |= TIFF_SWAB; + #endif + break; + case 'B': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + FILLORDER_MSB2LSB; + break; + case 'L': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + FILLORDER_LSB2MSB; + break; + case 'H': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + HOST_FILLORDER; + break; + case 'M': + if (m == O_RDONLY) + tif->tif_flags |= TIFF_MAPPED; + break; + case 'm': + if (m == O_RDONLY) + tif->tif_flags &= ~TIFF_MAPPED; + break; + case 'C': + if (m == O_RDONLY) + tif->tif_flags |= TIFF_STRIPCHOP; + break; + case 'c': + if (m == O_RDONLY) + tif->tif_flags &= ~TIFF_STRIPCHOP; + break; + case 'h': + tif->tif_flags |= TIFF_HEADERONLY; + break; + case '8': + if (m&O_CREAT) + tif->tif_flags |= TIFF_BIGTIFF; + break; } /* * Read in TIFF header. */ - if (tif->tif_mode & O_TRUNC || - !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { + if ((m & O_TRUNC) || + !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeaderClassic))) { if (tif->tif_mode == O_RDONLY) { - TIFFErrorExt(tif->tif_clientdata, name, "Cannot read TIFF header"); + TIFFErrorExt(tif->tif_clientdata, name, + "Cannot read TIFF header"); goto bad; } /* * Setup header and write. */ -#ifdef WORDS_BIGENDIAN - tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB + #ifdef WORDS_BIGENDIAN + tif->tif_header.common.tiff_magic = tif->tif_flags & TIFF_SWAB ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN; -#else - tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB + #else + tif->tif_header.common.tiff_magic = tif->tif_flags & TIFF_SWAB ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN; -#endif - tif->tif_header.tiff_version = TIFF_VERSION; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&tif->tif_header.tiff_version); - tif->tif_header.tiff_diroff = 0; /* filled in later */ - - - /* - * The doc for "fopen" for some STD_C_LIBs says that if you - * open a file for modify ("+"), then you must fseek (or - * fflush?) between any freads and fwrites. This is not - * necessary on most systems, but has been shown to be needed - * on Solaris. - */ - TIFFSeekFile( tif, 0, SEEK_SET ); - - if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { - TIFFErrorExt(tif->tif_clientdata, name, "Error writing TIFF header"); + #endif + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC; + tif->tif_header.classic.tiff_diroff = 0; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&tif->tif_header.common.tiff_version); + tif->tif_header_size = sizeof(TIFFHeaderClassic); + } + else + { + tif->tif_header.common.tiff_version = TIFF_VERSION_BIG; + tif->tif_header.big.tiff_offsetsize = 8; + tif->tif_header.big.tiff_unused = 0; + tif->tif_header.big.tiff_diroff = 0; + if (tif->tif_flags & TIFF_SWAB) + { + TIFFSwabShort(&tif->tif_header.common.tiff_version); + TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize); + } + tif->tif_header_size = sizeof (TIFFHeaderBig); + } + /* + * The doc for "fopen" for some STD_C_LIBs says that if you + * open a file for modify ("+"), then you must fseek (or + * fflush?) between any freads and fwrites. This is not + * necessary on most systems, but has been shown to be needed + * on Solaris. + */ + TIFFSeekFile( tif, 0, SEEK_SET ); + if (!WriteOK(tif, &tif->tif_header, (tmsize_t)(tif->tif_header_size))) { + TIFFErrorExt(tif->tif_clientdata, name, + "Error writing TIFF header"); goto bad; } /* * Setup the byte order handling. */ - TIFFInitOrder(tif, tif->tif_header.tiff_magic); + if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) { + #ifndef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } else { + #ifdef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } /* * Setup default directory. */ @@ -350,99 +338,146 @@ TIFFClientOpen( goto bad; tif->tif_diroff = 0; tif->tif_dirlist = NULL; + tif->tif_dirlistsize = 0; tif->tif_dirnumber = 0; return (tif); } /* * Setup the byte order handling. */ - if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && - tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN -#if MDI_SUPPORT + if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN && + tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN + #if MDI_SUPPORT && -#if HOST_BIGENDIAN - tif->tif_header.tiff_magic != MDI_BIGENDIAN -#else - tif->tif_header.tiff_magic != MDI_LITTLEENDIAN -#endif + #if HOST_BIGENDIAN + tif->tif_header.common.tiff_magic != MDI_BIGENDIAN + #else + tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN + #endif ) { - TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF or MDI file, bad magic number %d (0x%x)", -#else - ) { - TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF file, bad magic number %d (0x%x)", -#endif - tif->tif_header.tiff_magic, - tif->tif_header.tiff_magic); - goto bad; - } - TIFFInitOrder(tif, tif->tif_header.tiff_magic); - /* - * Swap header if required. - */ - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabShort(&tif->tif_header.tiff_version); - TIFFSwabLong(&tif->tif_header.tiff_diroff); - } - /* - * Now check version (if needed, it's been byte-swapped). - * Note that this isn't actually a version number, it's a - * magic number that doesn't change (stupid). - */ - if (tif->tif_header.tiff_version == TIFF_BIGTIFF_VERSION) { TIFFErrorExt(tif->tif_clientdata, name, - "This is a BigTIFF file. This format not supported\n" - "by this version of libtiff." ); + "Not a TIFF or MDI file, bad magic number %d (0x%x)", + #else + ) { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF file, bad magic number %d (0x%x)", + #endif + tif->tif_header.common.tiff_magic, + tif->tif_header.common.tiff_magic); goto bad; } - if (tif->tif_header.tiff_version != TIFF_VERSION) { + if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) { + #ifndef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } else { + #ifdef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&tif->tif_header.common.tiff_version); + if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&& + (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) { TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF file, bad version number %d (0x%x)", - tif->tif_header.tiff_version, - tif->tif_header.tiff_version); + tif->tif_header.common.tiff_version, + tif->tif_header.common.tiff_version); goto bad; } + if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC) + { + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&tif->tif_header.classic.tiff_diroff); + tif->tif_header_size = sizeof(TIFFHeaderClassic); + } + else + { + if (!ReadOK(tif, ((uint8*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig)-sizeof(TIFFHeaderClassic)))) + { + TIFFErrorExt(tif->tif_clientdata, name, + "Cannot read TIFF header"); + goto bad; + } + if (tif->tif_flags & TIFF_SWAB) + { + TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize); + TIFFSwabLong8(&tif->tif_header.big.tiff_diroff); + } + if (tif->tif_header.big.tiff_offsetsize != 8) + { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)", + tif->tif_header.big.tiff_offsetsize, + tif->tif_header.big.tiff_offsetsize); + goto bad; + } + if (tif->tif_header.big.tiff_unused != 0) + { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF file, bad BigTIFF unused %d (0x%x)", + tif->tif_header.big.tiff_unused, + tif->tif_header.big.tiff_unused); + goto bad; + } + tif->tif_header_size = sizeof(TIFFHeaderBig); + tif->tif_flags |= TIFF_BIGTIFF; + } tif->tif_flags |= TIFF_MYBUFFER; tif->tif_rawcp = tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = 0; - /* - * Sometimes we do not want to read the first directory (for example, - * it may be broken) and want to proceed to other directories. I this - * case we use the TIFF_HEADERONLY flag to open file and return - * immediately after reading TIFF header. - */ - if (tif->tif_flags & TIFF_HEADERONLY) - return (tif); - - /* - * Setup initial directory. - */ switch (mode[0]) { - case 'r': - tif->tif_nextdiroff = tif->tif_header.tiff_diroff; - /* - * Try to use a memory-mapped file if the client - * has not explicitly suppressed usage with the - * 'm' flag in the open mode (see above). - */ - if ((tif->tif_flags & TIFF_MAPPED) && - !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) - tif->tif_flags &= ~TIFF_MAPPED; - if (TIFFReadDirectory(tif)) { - tif->tif_rawcc = -1; - tif->tif_flags |= TIFF_BUFFERSETUP; + case 'r': + if (!(tif->tif_flags&TIFF_BIGTIFF)) + tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff; + else + tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff; + /* + * Try to use a memory-mapped file if the client + * has not explicitly suppressed usage with the + * 'm' flag in the open mode (see above). + */ + if (tif->tif_flags & TIFF_MAPPED) + { + toff_t n; + if (TIFFMapFileContents(tif,(void**)(&tif->tif_base),&n)) + { + tif->tif_size=(tmsize_t)n; + assert((toff_t)tif->tif_size==n); + } + else + tif->tif_flags &= ~TIFF_MAPPED; + } + /* + * Sometimes we do not want to read the first directory (for example, + * it may be broken) and want to proceed to other directories. I this + * case we use the TIFF_HEADERONLY flag to open file and return + * immediately after reading TIFF header. + */ + if (tif->tif_flags & TIFF_HEADERONLY) + return (tif); + + /* + * Setup initial directory. + */ + if (TIFFReadDirectory(tif)) { + tif->tif_rawcc = (tmsize_t)-1; + tif->tif_flags |= TIFF_BUFFERSETUP; + return (tif); + } + break; + case 'a': + /* + * New directories are automatically append + * to the end of the directory chain when they + * are written out (see TIFFWriteDirectory). + */ + if (!TIFFDefaultDirectory(tif)) + goto bad; return (tif); - } - break; - case 'a': - /* - * New directories are automatically append - * to the end of the directory chain when they - * are written out (see TIFFWriteDirectory). - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - return (tif); } bad: tif->tif_mode = O_RDONLY; /* XXX avoid flush */ @@ -557,7 +592,7 @@ TIFFCurrentRow(TIFF* tif) /* * Return index of the current directory. */ -tdir_t +uint16 TIFFCurrentDirectory(TIFF* tif) { return (tif->tif_curdir); @@ -566,7 +601,7 @@ TIFFCurrentDirectory(TIFF* tif) /* * Return current strip. */ -tstrip_t +uint32 TIFFCurrentStrip(TIFF* tif) { return (tif->tif_curstrip); @@ -575,7 +610,7 @@ TIFFCurrentStrip(TIFF* tif) /* * Return current tile. */ -ttile_t +uint32 TIFFCurrentTile(TIFF* tif) { return (tif->tif_curtile); @@ -614,7 +649,7 @@ TIFFIsMSB2LSB(TIFF* tif) int TIFFIsBigEndian(TIFF* tif) { - return (tif->tif_header.tiff_magic == TIFF_BIGENDIAN); + return (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN); } /* @@ -681,3 +716,10 @@ TIFFGetUnmapFileProc(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_packbits.c b/libs/tiff-4.0.2/libtiff/tif_packbits.c similarity index 66% rename from libs/tiff-3.8.2/libtiff/tif_packbits.c rename to libs/tiff-4.0.2/libtiff/tif_packbits.c index 0225b3e612..a79abe860f 100644 --- a/libs/tiff-3.8.2/libtiff/tif_packbits.c +++ b/libs/tiff-4.0.2/libtiff/tif_packbits.c @@ -1,4 +1,4 @@ -/* $Id: tif_packbits.c,v 1.13 2006/02/07 11:03:29 dron Exp $ */ +/* $Id: tif_packbits.c,v 1.20 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,19 +34,19 @@ #include static int -PackBitsPreEncode(TIFF* tif, tsample_t s) +PackBitsPreEncode(TIFF* tif, uint16 s) { (void) s; - if (!(tif->tif_data = (tidata_t)_TIFFmalloc(sizeof(tsize_t)))) + if (!(tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t)))) return (0); /* * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) - *(tsize_t*)tif->tif_data = TIFFTileRowSize(tif); + *(tmsize_t*)tif->tif_data = TIFFTileRowSize(tif); else - *(tsize_t*)tif->tif_data = TIFFScanlineSize(tif); + *(tmsize_t*)tif->tif_data = TIFFScanlineSize(tif); return (1); } @@ -58,21 +58,16 @@ PackBitsPostEncode(TIFF* tif) return (1); } -/* - * NB: tidata is the type representing *(tidata_t); - * if tidata_t is made signed then this type must - * be adjusted accordingly. - */ -typedef unsigned char tidata; - /* * Encode a run of pixels. */ static int -PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { unsigned char* bp = (unsigned char*) buf; - tidata_t op, ep, lastliteral; + uint8* op; + uint8* ep; + uint8* lastliteral; long n, slop; int b; enum { BASE, LITERAL, RUN, LITERAL_RUN } state; @@ -98,8 +93,8 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * front of the buffer. */ if (state == LITERAL || state == LITERAL_RUN) { - slop = op - lastliteral; - tif->tif_rawcc += lastliteral - tif->tif_rawcp; + slop = (long)(op - lastliteral); + tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp); if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; @@ -107,7 +102,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) *op++ = *lastliteral++; lastliteral = tif->tif_rawcp; } else { - tif->tif_rawcc += op - tif->tif_rawcp; + tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp); if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; @@ -118,17 +113,17 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) if (n > 1) { state = RUN; if (n > 128) { - *op++ = (tidata) -127; - *op++ = (tidataval_t) b; + *op++ = (uint8) -127; + *op++ = (uint8) b; n -= 128; goto again; } - *op++ = (tidataval_t)(-(n-1)); - *op++ = (tidataval_t) b; + *op++ = (uint8)(-(n-1)); + *op++ = (uint8) b; } else { lastliteral = op; *op++ = 0; - *op++ = (tidataval_t) b; + *op++ = (uint8) b; state = LITERAL; } break; @@ -136,33 +131,33 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) if (n > 1) { state = LITERAL_RUN; if (n > 128) { - *op++ = (tidata) -127; - *op++ = (tidataval_t) b; + *op++ = (uint8) -127; + *op++ = (uint8) b; n -= 128; goto again; } - *op++ = (tidataval_t)(-(n-1)); /* encode run */ - *op++ = (tidataval_t) b; + *op++ = (uint8)(-(n-1)); /* encode run */ + *op++ = (uint8) b; } else { /* extend literal */ if (++(*lastliteral) == 127) state = BASE; - *op++ = (tidataval_t) b; + *op++ = (uint8) b; } break; case RUN: /* last object was run */ if (n > 1) { if (n > 128) { - *op++ = (tidata) -127; - *op++ = (tidataval_t) b; + *op++ = (uint8) -127; + *op++ = (uint8) b; n -= 128; goto again; } - *op++ = (tidataval_t)(-(n-1)); - *op++ = (tidataval_t) b; + *op++ = (uint8)(-(n-1)); + *op++ = (uint8) b; } else { lastliteral = op; *op++ = 0; - *op++ = (tidataval_t) b; + *op++ = (uint8) b; state = LITERAL; } break; @@ -173,7 +168,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * case we convert literal-run-literal * to a single literal. */ - if (n == 1 && op[-2] == (tidata) -1 && + if (n == 1 && op[-2] == (uint8) -1 && *lastliteral < 126) { state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL); @@ -183,7 +178,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) goto again; } } - tif->tif_rawcc += op - tif->tif_rawcp; + tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp); tif->tif_rawcp = op; return (1); } @@ -196,12 +191,12 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * when it was encoded by strips. */ static int -PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tsize_t rowsize = *(tsize_t*)tif->tif_data; + tmsize_t rowsize = *(tmsize_t*)tif->tif_data; - while ((long)cc > 0) { - int chunk = rowsize; + while (cc > 0) { + tmsize_t chunk = rowsize; if( cc < chunk ) chunk = cc; @@ -215,17 +210,18 @@ PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } static int -PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { + static const char module[] = "PackBitsDecode"; char *bp; - tsize_t cc; + tmsize_t cc; long n; int b; (void) s; bp = (char*) tif->tif_rawcp; cc = tif->tif_rawcc; - while (cc > 0 && (long)occ > 0) { + while (cc > 0 && occ > 0) { n = (long) *bp++, cc--; /* * Watch out for compilers that @@ -236,39 +232,37 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) if (n < 0) { /* replicate next byte -n+1 times */ if (n == -128) /* nop */ continue; - n = -n + 1; - if( occ < n ) - { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "PackBitsDecode: discarding %d bytes " - "to avoid buffer overrun", - n - occ); - n = occ; - } + n = -n + 1; + if( occ < (tmsize_t)n ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Discarding %lu bytes to avoid buffer overrun", + (unsigned long) ((tmsize_t)n - occ)); + n = (long)occ; + } occ -= n; - b = *bp++, cc--; + b = *bp++, cc--; /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */ while (n-- > 0) - *op++ = (tidataval_t) b; + *op++ = (uint8) b; } else { /* copy next n+1 bytes literally */ - if (occ < n + 1) - { - TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "PackBitsDecode: discarding %d bytes " - "to avoid buffer overrun", - n - occ + 1); - n = occ - 1; - } - _TIFFmemcpy(op, bp, ++n); + if (occ < (tmsize_t)(n + 1)) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Discarding %lu bytes to avoid buffer overrun", + (unsigned long) ((tmsize_t)n - occ + 1)); + n = (long)occ - 1; + } + _TIFFmemcpy(op, bp, ++n); /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */ op += n; occ -= n; bp += n; cc -= n; } } - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; if (occ > 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "PackBitsDecode: Not enough data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data for scanline %lu", + (unsigned long) tif->tif_row); return (0); } return (1); @@ -282,7 +276,7 @@ TIFFInitPackBits(TIFF* tif, int scheme) tif->tif_decodestrip = PackBitsDecode; tif->tif_decodetile = PackBitsDecode; tif->tif_preencode = PackBitsPreEncode; - tif->tif_postencode = PackBitsPostEncode; + tif->tif_postencode = PackBitsPostEncode; tif->tif_encoderow = PackBitsEncode; tif->tif_encodestrip = PackBitsEncodeChunk; tif->tif_encodetile = PackBitsEncodeChunk; @@ -291,3 +285,10 @@ TIFFInitPackBits(TIFF* tif, int scheme) #endif /* PACKBITS_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_pixarlog.c b/libs/tiff-4.0.2/libtiff/tif_pixarlog.c similarity index 79% rename from libs/tiff-3.8.2/libtiff/tif_pixarlog.c rename to libs/tiff-4.0.2/libtiff/tif_pixarlog.c index c68deb3dd0..c1b6ff2ed7 100644 --- a/libs/tiff-3.8.2/libtiff/tif_pixarlog.c +++ b/libs/tiff-4.0.2/libtiff/tif_pixarlog.c @@ -1,4 +1,4 @@ -/* $Id: tif_pixarlog.c,v 1.14 2006/03/16 12:38:24 dron Exp $ */ +/* $Id: tif_pixarlog.c,v 1.37 2012-05-24 23:21:45 fwarmerdam Exp $ */ /* * Copyright (c) 1996-1997 Sam Leffler @@ -83,7 +83,10 @@ * The codec also handle byte swapping the encoded values as necessary * since the library does not have the information necessary * to know the bit depth of the raw unencoded buffer. - * + * + * NOTE: This decoder does not appear to update tif_rawcp, and tif_rawcc. + * This can cause problems with the implementation of CHUNKY_STRIP_READ_SUPPORT + * as noted in http://trac.osgeo.org/gdal/ticket/3894. FrankW - Jan'11 */ #include "tif_predict.h" @@ -108,7 +111,7 @@ static float LogK1, LogK2; #define REPEAT(n, op) { int i; i=n; do { i--; op; } while (i>0); } static void -horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, +horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, float *ToLinearF) { register unsigned int cr, cg, cb, ca, mask; @@ -117,9 +120,9 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; + t0 = ToLinearF[cr = (wp[0] & mask)]; + t1 = ToLinearF[cg = (wp[1] & mask)]; + t2 = ToLinearF[cb = (wp[2] & mask)]; op[0] = t0; op[1] = t1; op[2] = t2; @@ -136,10 +139,10 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, op[2] = t2; } } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; - t3 = ToLinearF[ca = wp[3]]; + t0 = ToLinearF[cr = (wp[0] & mask)]; + t1 = ToLinearF[cg = (wp[1] & mask)]; + t2 = ToLinearF[cb = (wp[2] & mask)]; + t3 = ToLinearF[ca = (wp[3] & mask)]; op[0] = t0; op[1] = t1; op[2] = t2; @@ -183,9 +186,9 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; + t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; + t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; + t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; op[0] = CLAMP12(t0); op[1] = CLAMP12(t1); op[2] = CLAMP12(t2); @@ -202,10 +205,10 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, op[2] = CLAMP12(t2); } } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; - t3 = ToLinearF[ca = wp[3]] * SCALE12; + t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; + t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; + t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; + t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12; op[0] = CLAMP12(t0); op[1] = CLAMP12(t1); op[2] = CLAMP12(t2); @@ -247,9 +250,9 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; + op[0] = ToLinear16[cr = (wp[0] & mask)]; + op[1] = ToLinear16[cg = (wp[1] & mask)]; + op[2] = ToLinear16[cb = (wp[2] & mask)]; n -= 3; while (n > 0) { wp += 3; @@ -260,10 +263,10 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, op[2] = ToLinear16[(cb += wp[2]) & mask]; } } else if (stride == 4) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; - op[3] = ToLinear16[ca = wp[3]]; + op[0] = ToLinear16[cr = (wp[0] & mask)]; + op[1] = ToLinear16[cg = (wp[1] & mask)]; + op[2] = ToLinear16[cb = (wp[2] & mask)]; + op[3] = ToLinear16[ca = (wp[3] & mask)]; n -= 4; while (n > 0) { wp += 4; @@ -327,7 +330,7 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) while (n > 0) { REPEAT(stride, wp[stride] += *wp; *op = *wp&mask; wp++; op++) - n -= stride; + n -= stride; } } } @@ -342,9 +345,9 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; + op[0] = ToLinear8[cr = (wp[0] & mask)]; + op[1] = ToLinear8[cg = (wp[1] & mask)]; + op[2] = ToLinear8[cb = (wp[2] & mask)]; n -= 3; while (n > 0) { n -= 3; @@ -355,10 +358,10 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, op[2] = ToLinear8[(cb += wp[2]) & mask]; } } else if (stride == 4) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; - op[3] = ToLinear8[ca = wp[3]]; + op[0] = ToLinear8[cr = (wp[0] & mask)]; + op[1] = ToLinear8[cg = (wp[1] & mask)]; + op[2] = ToLinear8[cb = (wp[2] & mask)]; + op[3] = ToLinear8[ca = (wp[3] & mask)]; n -= 4; while (n > 0) { n -= 4; @@ -393,9 +396,9 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, mask = CODE_MASK; if (stride == 3) { op[0] = 0; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; + t1 = ToLinear8[cb = (wp[2] & mask)]; + t2 = ToLinear8[cg = (wp[1] & mask)]; + t3 = ToLinear8[cr = (wp[0] & mask)]; op[1] = t1; op[2] = t2; op[3] = t3; @@ -413,10 +416,10 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, op[3] = t3; } } else if (stride == 4) { - t0 = ToLinear8[ca = wp[3]]; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; + t0 = ToLinear8[ca = (wp[3] & mask)]; + t1 = ToLinear8[cb = (wp[2] & mask)]; + t2 = ToLinear8[cg = (wp[1] & mask)]; + t3 = ToLinear8[cr = (wp[0] & mask)]; op[0] = t0; op[1] = t1; op[2] = t2; @@ -587,13 +590,12 @@ PixarLogMakeTables(PixarLogState *sp) return 1; } -#define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) -#define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) +#define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) +#define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) -static int PixarLogEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int PixarLogDecode(TIFF*, tidata_t, tsize_t, tsample_t); +static int PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); -#define N(a) (sizeof(a)/sizeof(a[0])) #define PIXARLOGDATAFMT_UNKNOWN -1 static int @@ -631,10 +633,10 @@ PixarLogGuessDataFmt(TIFFDirectory *td) return guess; } -static uint32 -multiply(size_t m1, size_t m2) +static tmsize_t +multiply_ms(tmsize_t m1, tmsize_t m2) { - uint32 bytes = m1 * m2; + tmsize_t bytes = m1 * m2; if (m1 && bytes / m1 != m2) bytes = 0; @@ -642,29 +644,36 @@ multiply(size_t m1, size_t m2) return bytes; } +static int +PixarLogFixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} + static int PixarLogSetupDecode(TIFF* tif) { + static const char module[] = "PixarLogSetupDecode"; TIFFDirectory *td = &tif->tif_dir; PixarLogState* sp = DecoderState(tif); - tsize_t tbuf_size; - static const char module[] = "PixarLogSetupDecode"; + tmsize_t tbuf_size; assert(sp != NULL); /* Make sure no byte swapping happens on the data * after decompression. */ - tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_postdecode = _TIFFNoPostDecode; /* for some reason, we can't do this in TIFFInitPixarLog */ sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); - tbuf_size = multiply(multiply(multiply(sp->stride, td->td_imagewidth), + tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), td->td_rowsperstrip), sizeof(uint16)); if (tbuf_size == 0) - return (0); - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ + sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)); if (sp->tbuf == NULL) return (0); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) @@ -677,7 +686,7 @@ PixarLogSetupDecode(TIFF* tif) } if (inflateInit(&sp->stream) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg); return (0); } else { sp->state |= PLSTATE_INIT; @@ -689,24 +698,36 @@ PixarLogSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -PixarLogPreDecode(TIFF* tif, tsample_t s) +PixarLogPreDecode(TIFF* tif, uint16 s) { + static const char module[] = "PixarLogPreDecode"; PixarLogState* sp = DecoderState(tif); (void) s; assert(sp != NULL); sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ + sp->stream.avail_in = (uInt) tif->tif_rawcc; + if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } return (inflateReset(&sp->stream) == Z_OK); } static int -PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { + static const char module[] = "PixarLogDecode"; TIFFDirectory *td = &tif->tif_dir; PixarLogState* sp = DecoderState(tif); - static const char module[] = "PixarLogDecode"; - int i, nsamples, llen; + tmsize_t i; + tmsize_t nsamples; + int llen; uint16 *up; switch (sp->user_datafmt) { @@ -723,7 +744,7 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) nsamples = occ; break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "%d bit input not supported in PixarLog", td->td_bitspersample); return 0; @@ -734,7 +755,16 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) (void) s; assert(sp != NULL); sp->stream.next_out = (unsigned char *) sp->tbuf; - sp->stream.avail_out = nsamples * sizeof(uint16); + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ + sp->stream.avail_out = (uInt) (nsamples * sizeof(uint16)); + if (sp->stream.avail_out != nsamples * sizeof(uint16)) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } do { int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); if (state == Z_STREAM_END) { @@ -742,15 +772,15 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) } if (state == Z_DATA_ERROR) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Decoding error at scanline %d, %s", - tif->tif_name, tif->tif_row, sp->stream.msg); + "Decoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, sp->stream.msg); if (inflateSync(&sp->stream) != Z_OK) return (0); continue; } if (state != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg); return (0); } } while (sp->stream.avail_out > 0); @@ -758,8 +788,8 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) /* hopefully, we got all the bytes we needed */ if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Not enough data at scanline %d (short %d bytes)", - tif->tif_name, tif->tif_row, sp->stream.avail_out); + "Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)", + (unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out); return (0); } @@ -768,6 +798,18 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) if (tif->tif_flags & TIFF_SWAB) TIFFSwabArrayOfShort(up, nsamples); + /* + * if llen is not an exact multiple of nsamples, the decode operation + * may overflow the output buffer, so truncate it enough to prevent + * that but still salvage as much data as possible. + */ + if (nsamples % llen) { + TIFFWarningExt(tif->tif_clientdata, module, + "stride %lu is not a multiple of sample count, " + "%lu, data truncated.", (unsigned long) llen, (unsigned long) nsamples); + nsamples -= nsamples % llen; + } + for (i = 0; i < nsamples; i += llen, up += llen) { switch (sp->user_datafmt) { case PIXARLOGDATAFMT_FLOAT: @@ -801,8 +843,8 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) op += llen * sizeof(unsigned char); break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "PixarLogDecode: unsupported bits/sample: %d", + TIFFErrorExt(tif->tif_clientdata, module, + "Unsupported bits/sample: %d", td->td_bitspersample); return (0); } @@ -814,10 +856,10 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) static int PixarLogSetupEncode(TIFF* tif) { + static const char module[] = "PixarLogSetupEncode"; TIFFDirectory *td = &tif->tif_dir; PixarLogState* sp = EncoderState(tif); - tsize_t tbuf_size; - static const char module[] = "PixarLogSetupEncode"; + tmsize_t tbuf_size; assert(sp != NULL); @@ -825,10 +867,10 @@ PixarLogSetupEncode(TIFF* tif) sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); - tbuf_size = multiply(multiply(multiply(sp->stride, td->td_imagewidth), + tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), td->td_rowsperstrip), sizeof(uint16)); if (tbuf_size == 0) - return (0); + return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); if (sp->tbuf == NULL) return (0); @@ -840,7 +882,7 @@ PixarLogSetupEncode(TIFF* tif) } if (deflateInit(&sp->stream, sp->quality) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg); return (0); } else { sp->state |= PLSTATE_INIT; @@ -852,21 +894,30 @@ PixarLogSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -PixarLogPreEncode(TIFF* tif, tsample_t s) +PixarLogPreEncode(TIFF* tif, uint16 s) { + static const char module[] = "PixarLogPreEncode"; PixarLogState *sp = EncoderState(tif); (void) s; assert(sp != NULL); sp->stream.next_out = tif->tif_rawdata; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ sp->stream.avail_out = tif->tif_rawdatasize; + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } return (deflateReset(&sp->stream) == Z_OK); } static void horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) { - int32 r1, g1, b1, a1, r2, g2, b2, a2, mask; float fltsize = Fltsize; @@ -1031,12 +1082,14 @@ horizontalDifference8(unsigned char *ip, int n, int stride, * Encode a chunk of pixels. */ static int -PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { + static const char module[] = "PixarLogEncode"; TIFFDirectory *td = &tif->tif_dir; PixarLogState *sp = EncoderState(tif); - static const char module[] = "PixarLogEncode"; - int i, n, llen; + tmsize_t i; + tmsize_t n; + int llen; unsigned short * up; (void) s; @@ -1055,7 +1108,7 @@ PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) n = cc; break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "%d bit input not supported in PixarLog", td->td_bitspersample); return 0; @@ -1081,7 +1134,7 @@ PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) bp += llen * sizeof(unsigned char); break; default: - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "%d bit input not supported in PixarLog", td->td_bitspersample); return 0; @@ -1089,19 +1142,29 @@ PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } sp->stream.next_in = (unsigned char *) sp->tbuf; - sp->stream.avail_in = n * sizeof(uint16); + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ + sp->stream.avail_in = (uInt) (n * sizeof(uint16)); + if ((sp->stream.avail_in / sizeof(uint16)) != (uInt) n) + { + TIFFErrorExt(tif->tif_clientdata, module, + "ZLib cannot deal with buffers this size"); + return (0); + } do { if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Encoder error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "Encoder error: %s", + sp->stream.msg); return (0); } if (sp->stream.avail_out == 0) { tif->tif_rawcc = tif->tif_rawdatasize; TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in PixarLogPreEncode */ } } while (sp->stream.avail_in > 0); return (1); @@ -1115,8 +1178,8 @@ PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) static int PixarLogPostEncode(TIFF* tif) { - PixarLogState *sp = EncoderState(tif); static const char module[] = "PixarLogPostEncode"; + PixarLogState *sp = EncoderState(tif); int state; sp->stream.avail_in = 0; @@ -1126,17 +1189,17 @@ PixarLogPostEncode(TIFF* tif) switch (state) { case Z_STREAM_END: case Z_OK: - if (sp->stream.avail_out != (uint32)tif->tif_rawdatasize) { + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) { tif->tif_rawcc = tif->tif_rawdatasize - sp->stream.avail_out; TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in PixarLogPreEncode */ } break; default: - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg); return (0); } } while (state != Z_STREAM_END); @@ -1148,9 +1211,11 @@ PixarLogClose(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - /* In a really sneaky maneuver, on close, we covertly modify both - * bitspersample and sampleformat in the directory to indicate - * 8-bit linear. This way, the decode "just works" even for + /* In a really sneaky (and really incorrect, and untruthfull, and + * troublesome, and error-prone) maneuver that completely goes against + * the spirit of TIFF, and breaks TIFF, on close, we covertly + * modify both bitspersample and sampleformat in the directory to + * indicate 8-bit linear. This way, the decode "just works" even for * readers that don't know about PixarLog, or how to set * the PIXARLOGDATFMT pseudo-tag. */ @@ -1191,26 +1256,26 @@ PixarLogCleanup(TIFF* tif) } static int -PixarLogVSetField(TIFF* tif, ttag_t tag, va_list ap) +PixarLogVSetField(TIFF* tif, uint32 tag, va_list ap) { + static const char module[] = "PixarLogVSetField"; PixarLogState *sp = (PixarLogState *)tif->tif_data; int result; - static const char module[] = "PixarLogVSetField"; switch (tag) { case TIFFTAG_PIXARLOGQUALITY: - sp->quality = va_arg(ap, int); + sp->quality = (int) va_arg(ap, int); if (tif->tif_mode != O_RDONLY && (sp->state&PLSTATE_INIT)) { if (deflateParams(&sp->stream, sp->quality, Z_DEFAULT_STRATEGY) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg); return (0); } } return (1); case TIFFTAG_PIXARLOGDATAFMT: - sp->user_datafmt = va_arg(ap, int); + sp->user_datafmt = (int) va_arg(ap, int); /* Tweak the TIFF header so that the rest of libtiff knows what * size of data will be passed between app and library, and * assume that the app knows what it is doing and is not @@ -1242,7 +1307,7 @@ PixarLogVSetField(TIFF* tif, ttag_t tag, va_list ap) /* * Must recalculate sizes should bits/sample change. */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1); tif->tif_scanlinesize = TIFFScanlineSize(tif); result = 1; /* NB: pseudo tag */ break; @@ -1253,7 +1318,7 @@ PixarLogVSetField(TIFF* tif, ttag_t tag, va_list ap) } static int -PixarLogVGetField(TIFF* tif, ttag_t tag, va_list ap) +PixarLogVGetField(TIFF* tif, uint32 tag, va_list ap) { PixarLogState *sp = (PixarLogState *)tif->tif_data; @@ -1270,22 +1335,34 @@ PixarLogVGetField(TIFF* tif, ttag_t tag, va_list ap) return (1); } -static const TIFFFieldInfo pixarlogFieldInfo[] = { - {TIFFTAG_PIXARLOGDATAFMT,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""}, - {TIFFTAG_PIXARLOGQUALITY,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""} +static const TIFFField pixarlogFields[] = { + {TIFFTAG_PIXARLOGDATAFMT, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}, + {TIFFTAG_PIXARLOGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL} }; int TIFFInitPixarLog(TIFF* tif, int scheme) { + static const char module[] = "TIFFInitPixarLog"; + PixarLogState* sp; assert(scheme == COMPRESSION_PIXARLOG); + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, pixarlogFields, + TIFFArrayCount(pixarlogFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging PixarLog codec-specific tags failed"); + return 0; + } + /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (PixarLogState)); + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (PixarLogState)); if (tif->tif_data == NULL) goto bad; sp = (PixarLogState*) tif->tif_data; @@ -1296,22 +1373,22 @@ TIFFInitPixarLog(TIFF* tif, int scheme) /* * Install codec methods. */ + tif->tif_fixuptags = PixarLogFixupTags; tif->tif_setupdecode = PixarLogSetupDecode; tif->tif_predecode = PixarLogPreDecode; tif->tif_decoderow = PixarLogDecode; - tif->tif_decodestrip = PixarLogDecode; + tif->tif_decodestrip = PixarLogDecode; tif->tif_decodetile = PixarLogDecode; tif->tif_setupencode = PixarLogSetupEncode; tif->tif_preencode = PixarLogPreEncode; tif->tif_postencode = PixarLogPostEncode; - tif->tif_encoderow = PixarLogEncode; + tif->tif_encoderow = PixarLogEncode; tif->tif_encodestrip = PixarLogEncode; - tif->tif_encodetile = PixarLogEncode; + tif->tif_encodetile = PixarLogEncode; tif->tif_close = PixarLogClose; tif->tif_cleanup = PixarLogCleanup; /* Override SetField so we can handle our private pseudo-tag */ - _TIFFMergeFieldInfo(tif, pixarlogFieldInfo, N(pixarlogFieldInfo)); sp->vgetparent = tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_tagmethods.vsetfield; @@ -1333,10 +1410,17 @@ TIFFInitPixarLog(TIFF* tif, int scheme) return (1); bad: - TIFFErrorExt(tif->tif_clientdata, "TIFFInitPixarLog", + TIFFErrorExt(tif->tif_clientdata, module, "No space for PixarLog state block"); return (0); } #endif /* PIXARLOG_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_predict.c b/libs/tiff-4.0.2/libtiff/tif_predict.c similarity index 53% rename from libs/tiff-3.8.2/libtiff/tif_predict.c rename to libs/tiff-4.0.2/libtiff/tif_predict.c index d3e604d5d9..f93c6645f0 100644 --- a/libs/tiff-3.8.2/libtiff/tif_predict.c +++ b/libs/tiff-4.0.2/libtiff/tif_predict.c @@ -1,4 +1,4 @@ -/* $Id: tif_predict.c,v 1.11 2006/03/03 14:10:09 dron Exp $ */ +/* $Id: tif_predict.c,v 1.32 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,17 +34,20 @@ #define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) -static void horAcc8(TIFF*, tidata_t, tsize_t); -static void horAcc16(TIFF*, tidata_t, tsize_t); -static void swabHorAcc16(TIFF*, tidata_t, tsize_t); -static void horDiff8(TIFF*, tidata_t, tsize_t); -static void horDiff16(TIFF*, tidata_t, tsize_t); -static void fpAcc(TIFF*, tidata_t, tsize_t); -static void fpDiff(TIFF*, tidata_t, tsize_t); -static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, tsample_t); +static void horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc); +static void horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc); +static void horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc); +static void swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc); +static void swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc); +static void horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc); +static void horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc); +static void horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc); +static void fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc); +static void fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc); +static int PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); +static int PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); +static int PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s); static int PredictorSetup(TIFF* tif) @@ -60,25 +63,26 @@ PredictorSetup(TIFF* tif) return 1; case PREDICTOR_HORIZONTAL: if (td->td_bitspersample != 8 - && td->td_bitspersample != 16) { + && td->td_bitspersample != 16 + && td->td_bitspersample != 32) { TIFFErrorExt(tif->tif_clientdata, module, - "Horizontal differencing \"Predictor\" not supported with %d-bit samples", - td->td_bitspersample); + "Horizontal differencing \"Predictor\" not supported with %d-bit samples", + td->td_bitspersample); return 0; } break; case PREDICTOR_FLOATINGPOINT: if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d data format", - td->td_sampleformat); + "Floating point \"Predictor\" not supported with %d data format", + td->td_sampleformat); return 0; } break; default: TIFFErrorExt(tif->tif_clientdata, module, - "\"Predictor\" value %d not supported", - sp->predictor); + "\"Predictor\" value %d not supported", + sp->predictor); return 0; } sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? @@ -90,6 +94,8 @@ PredictorSetup(TIFF* tif) sp->rowsize = TIFFTileRowSize(tif); else sp->rowsize = TIFFScanlineSize(tif); + if (sp->rowsize == 0) + return 0; return 1; } @@ -105,19 +111,24 @@ PredictorSetupDecode(TIFF* tif) if (sp->predictor == 2) { switch (td->td_bitspersample) { - case 8: sp->pfunc = horAcc8; break; - case 16: sp->pfunc = horAcc16; break; + case 8: sp->decodepfunc = horAcc8; break; + case 16: sp->decodepfunc = horAcc16; break; + case 32: sp->decodepfunc = horAcc32; break; } /* * Override default decoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->codestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->codetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; + if( tif->tif_decoderow != PredictorDecodeRow ) + { + sp->decoderow = tif->tif_decoderow; + tif->tif_decoderow = PredictorDecodeRow; + sp->decodestrip = tif->tif_decodestrip; + tif->tif_decodestrip = PredictorDecodeTile; + sp->decodetile = tif->tif_decodetile; + tif->tif_decodetile = PredictorDecodeTile; + } + /* * If the data is horizontally differenced 16-bit data that * requires byte-swapping, then it must be byte swapped before @@ -126,25 +137,31 @@ PredictorSetupDecode(TIFF* tif) * the library setup when the directory was read. */ if (tif->tif_flags & TIFF_SWAB) { - if (sp->pfunc == horAcc16) { - sp->pfunc = swabHorAcc16; + if (sp->decodepfunc == horAcc16) { + sp->decodepfunc = swabHorAcc16; tif->tif_postdecode = _TIFFNoPostDecode; - } /* else handle 32-bit case... */ + } else if (sp->decodepfunc == horAcc32) { + sp->decodepfunc = swabHorAcc32; + tif->tif_postdecode = _TIFFNoPostDecode; + } } } else if (sp->predictor == 3) { - sp->pfunc = fpAcc; + sp->decodepfunc = fpAcc; /* * Override default decoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->codestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->codetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; + if( tif->tif_decoderow != PredictorDecodeRow ) + { + sp->decoderow = tif->tif_decoderow; + tif->tif_decoderow = PredictorDecodeRow; + sp->decodestrip = tif->tif_decodestrip; + tif->tif_decodestrip = PredictorDecodeTile; + sp->decodetile = tif->tif_decodetile; + tif->tif_decodetile = PredictorDecodeTile; + } /* * The data should not be swapped outside of the floating * point predictor, the accumulation routine should return @@ -173,33 +190,40 @@ PredictorSetupEncode(TIFF* tif) if (sp->predictor == 2) { switch (td->td_bitspersample) { - case 8: sp->pfunc = horDiff8; break; - case 16: sp->pfunc = horDiff16; break; + case 8: sp->encodepfunc = horDiff8; break; + case 16: sp->encodepfunc = horDiff16; break; + case 32: sp->encodepfunc = horDiff32; break; } /* * Override default encoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->codestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->codetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; + if( tif->tif_encoderow != PredictorEncodeRow ) + { + sp->encoderow = tif->tif_encoderow; + tif->tif_encoderow = PredictorEncodeRow; + sp->encodestrip = tif->tif_encodestrip; + tif->tif_encodestrip = PredictorEncodeTile; + sp->encodetile = tif->tif_encodetile; + tif->tif_encodetile = PredictorEncodeTile; + } } - + else if (sp->predictor == 3) { - sp->pfunc = fpDiff; + sp->encodepfunc = fpDiff; /* * Override default encoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->codestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->codetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; + if( tif->tif_encoderow != PredictorEncodeRow ) + { + sp->encoderow = tif->tif_encoderow; + tif->tif_encoderow = PredictorEncodeRow; + sp->encodestrip = tif->tif_encodestrip; + tif->tif_encodestrip = PredictorEncodeTile; + sp->encodetile = tif->tif_encodetile; + tif->tif_encodetile = PredictorEncodeTile; + } } return 1; @@ -207,7 +231,7 @@ PredictorSetupEncode(TIFF* tif) #define REPEAT4(n, op) \ switch (n) { \ - default: { int i; for (i = n-4; i > 0; i--) { op; } } \ + default: { tmsize_t i; for (i = n-4; i > 0; i--) { op; } } \ case 4: op; \ case 3: op; \ case 2: op; \ @@ -216,13 +240,13 @@ PredictorSetupEncode(TIFF* tif) } static void -horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc) +horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc) { - tsize_t stride = PredictorState(tif)->stride; + tmsize_t stride = PredictorState(tif)->stride; char* cp = (char*) cp0; + assert((cc%stride)==0); if (cc > stride) { - cc -= stride; /* * Pipeline the most common cases. */ @@ -230,40 +254,49 @@ horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc) unsigned int cr = cp[0]; unsigned int cg = cp[1]; unsigned int cb = cp[2]; - do { - cc -= 3, cp += 3; + cc -= 3; + cp += 3; + while (cc>0) { cp[0] = (char) (cr += cp[0]); cp[1] = (char) (cg += cp[1]); cp[2] = (char) (cb += cp[2]); - } while ((int32) cc > 0); + cc -= 3; + cp += 3; + } } else if (stride == 4) { unsigned int cr = cp[0]; unsigned int cg = cp[1]; unsigned int cb = cp[2]; unsigned int ca = cp[3]; - do { - cc -= 4, cp += 4; + cc -= 4; + cp += 4; + while (cc>0) { cp[0] = (char) (cr += cp[0]); cp[1] = (char) (cg += cp[1]); cp[2] = (char) (cb += cp[2]); cp[3] = (char) (ca += cp[3]); - } while ((int32) cc > 0); + cc -= 4; + cp += 4; + } } else { + cc -= stride; do { REPEAT4(stride, cp[stride] = (char) (cp[stride] + *cp); cp++) cc -= stride; - } while ((int32) cc > 0); + } while (cc>0); } } } static void -swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) +swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) { - tsize_t stride = PredictorState(tif)->stride; + tmsize_t stride = PredictorState(tif)->stride; uint16* wp = (uint16*) cp0; - tsize_t wc = cc / 2; + tmsize_t wc = cc / 2; + + assert((cc%(2*stride))==0); if (wc > stride) { TIFFSwabArrayOfShort(wp, wc); @@ -271,23 +304,62 @@ swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) do { REPEAT4(stride, wp[stride] += wp[0]; wp++) wc -= stride; - } while ((int32) wc > 0); + } while (wc > 0); } } static void -horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) +horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) { - tsize_t stride = PredictorState(tif)->stride; + tmsize_t stride = PredictorState(tif)->stride; uint16* wp = (uint16*) cp0; - tsize_t wc = cc / 2; + tmsize_t wc = cc / 2; + + assert((cc%(2*stride))==0); if (wc > stride) { wc -= stride; do { REPEAT4(stride, wp[stride] += wp[0]; wp++) wc -= stride; - } while ((int32) wc > 0); + } while (wc > 0); + } +} + +static void +swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) +{ + tmsize_t stride = PredictorState(tif)->stride; + uint32* wp = (uint32*) cp0; + tmsize_t wc = cc / 4; + + assert((cc%(4*stride))==0); + + if (wc > stride) { + TIFFSwabArrayOfLong(wp, wc); + wc -= stride; + do { + REPEAT4(stride, wp[stride] += wp[0]; wp++) + wc -= stride; + } while (wc > 0); + } +} + +static void +horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) +{ + tmsize_t stride = PredictorState(tif)->stride; + uint32* wp = (uint32*) cp0; + tmsize_t wc = cc / 4; + + assert((cc%(4*stride))==0); + + if (wc > stride) { + wc -= stride; + do { + REPEAT4(stride, wp[stride] += wp[0]; wp++) + wc -= stride; + } while (wc > 0); } } @@ -295,15 +367,17 @@ horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) * Floating point predictor accumulation routine. */ static void -fpAcc(TIFF* tif, tidata_t cp0, tsize_t cc) +fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) { - tsize_t stride = PredictorState(tif)->stride; + tmsize_t stride = PredictorState(tif)->stride; uint32 bps = tif->tif_dir.td_bitspersample / 8; - tsize_t wc = cc / bps; - tsize_t count = cc; + tmsize_t wc = cc / bps; + tmsize_t count = cc; uint8 *cp = (uint8 *) cp0; uint8 *tmp = (uint8 *)_TIFFmalloc(cc); + assert((cc%(bps*stride))==0); + if (!tmp) return; @@ -317,12 +391,12 @@ fpAcc(TIFF* tif, tidata_t cp0, tsize_t cc) for (count = 0; count < wc; count++) { uint32 byte; for (byte = 0; byte < bps; byte++) { -#if WORDS_BIGENDIAN + #if WORDS_BIGENDIAN cp[bps * count + byte] = tmp[byte * wc + count]; -#else + #else cp[bps * count + byte] = tmp[(bps - byte - 1) * wc + count]; -#endif + #endif } } _TIFFfree(tmp); @@ -332,16 +406,16 @@ fpAcc(TIFF* tif, tidata_t cp0, tsize_t cc) * Decode a scanline and apply the predictor routine. */ static int -PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); assert(sp != NULL); - assert(sp->coderow != NULL); - assert(sp->pfunc != NULL); + assert(sp->decoderow != NULL); + assert(sp->decodepfunc != NULL); - if ((*sp->coderow)(tif, op0, occ0, s)) { - (*sp->pfunc)(tif, op0, occ0); + if ((*sp->decoderow)(tif, op0, occ0, s)) { + (*sp->decodepfunc)(tif, op0, occ0); return 1; } else return 0; @@ -355,19 +429,20 @@ PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) * strip/tile dimensions. */ static int -PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); assert(sp != NULL); - assert(sp->codetile != NULL); + assert(sp->decodetile != NULL); - if ((*sp->codetile)(tif, op0, occ0, s)) { - tsize_t rowsize = sp->rowsize; + if ((*sp->decodetile)(tif, op0, occ0, s)) { + tmsize_t rowsize = sp->rowsize; assert(rowsize > 0); - assert(sp->pfunc != NULL); - while ((long)occ0 > 0) { - (*sp->pfunc)(tif, op0, (tsize_t) rowsize); + assert((occ0%rowsize)==0); + assert(sp->decodepfunc != NULL); + while (occ0 > 0) { + (*sp->decodepfunc)(tif, op0, rowsize); occ0 -= rowsize; op0 += rowsize; } @@ -377,12 +452,14 @@ PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) } static void -horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) +horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; + tmsize_t stride = sp->stride; char* cp = (char*) cp0; + assert((cc%stride)==0); + if (cc > stride) { cc -= stride; /* @@ -398,7 +475,7 @@ horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) g1 = cp[4]; cp[4] = g1-g2; g2 = g1; b1 = cp[5]; cp[5] = b1-b2; b2 = b1; cp += 3; - } while ((int32)(cc -= 3) > 0); + } while ((cc -= 3) > 0); } else if (stride == 4) { int r1, g1, b1, a1; int r2 = cp[0]; @@ -411,23 +488,25 @@ horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) b1 = cp[6]; cp[6] = b1-b2; b2 = b1; a1 = cp[7]; cp[7] = a1-a2; a2 = a1; cp += 4; - } while ((int32)(cc -= 4) > 0); + } while ((cc -= 4) > 0); } else { cp += cc - 1; do { REPEAT4(stride, cp[stride] -= cp[0]; cp--) - } while ((int32)(cc -= stride) > 0); + } while ((cc -= stride) > 0); } } } static void -horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) +horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; + tmsize_t stride = sp->stride; int16 *wp = (int16*) cp0; - tsize_t wc = cc/2; + tmsize_t wc = cc/2; + + assert((cc%(2*stride))==0); if (wc > stride) { wc -= stride; @@ -435,7 +514,27 @@ horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) do { REPEAT4(stride, wp[stride] -= wp[0]; wp--) wc -= stride; - } while ((int32) wc > 0); + } while (wc > 0); + } +} + +static void +horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) +{ + TIFFPredictorState* sp = PredictorState(tif); + tmsize_t stride = sp->stride; + int32 *wp = (int32*) cp0; + tmsize_t wc = cc/4; + + assert((cc%(4*stride))==0); + + if (wc > stride) { + wc -= stride; + wp += wc - 1; + do { + REPEAT4(stride, wp[stride] -= wp[0]; wp--) + wc -= stride; + } while (wc > 0); } } @@ -443,15 +542,17 @@ horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) * Floating point predictor differencing routine. */ static void -fpDiff(TIFF* tif, tidata_t cp0, tsize_t cc) +fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) { - tsize_t stride = PredictorState(tif)->stride; + tmsize_t stride = PredictorState(tif)->stride; uint32 bps = tif->tif_dir.td_bitspersample / 8; - tsize_t wc = cc / bps; - tsize_t count; + tmsize_t wc = cc / bps; + tmsize_t count; uint8 *cp = (uint8 *) cp0; uint8 *tmp = (uint8 *)_TIFFmalloc(cc); + assert((cc%(bps*stride))==0); + if (!tmp) return; @@ -459,12 +560,12 @@ fpDiff(TIFF* tif, tidata_t cp0, tsize_t cc) for (count = 0; count < wc; count++) { uint32 byte; for (byte = 0; byte < bps; byte++) { -#if WORDS_BIGENDIAN - cp[byte * wc + count] = tmp[bps * count + byte]; -#else + #if WORDS_BIGENDIAN + cp[byte * wc + count] = tmp[bps * count + byte]; + #else cp[(bps - byte - 1) * wc + count] = tmp[bps * count + byte]; -#endif + #endif } } _TIFFfree(tmp); @@ -476,50 +577,71 @@ fpDiff(TIFF* tif, tidata_t cp0, tsize_t cc) } static int -PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); assert(sp != NULL); - assert(sp->pfunc != NULL); - assert(sp->coderow != NULL); + assert(sp->encodepfunc != NULL); + assert(sp->encoderow != NULL); /* XXX horizontal differencing alters user's data XXX */ - (*sp->pfunc)(tif, bp, cc); - return (*sp->coderow)(tif, bp, cc, s); + (*sp->encodepfunc)(tif, bp, cc); + return (*sp->encoderow)(tif, bp, cc, s); } static int -PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s) +PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s) { + static const char module[] = "PredictorEncodeTile"; TIFFPredictorState *sp = PredictorState(tif); - tsize_t cc = cc0, rowsize; - unsigned char* bp = bp0; + uint8 *working_copy; + tmsize_t cc = cc0, rowsize; + unsigned char* bp; + int result_code; assert(sp != NULL); - assert(sp->pfunc != NULL); - assert(sp->codetile != NULL); + assert(sp->encodepfunc != NULL); + assert(sp->encodetile != NULL); + + /* + * Do predictor manipulation in a working buffer to avoid altering + * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965 + */ + working_copy = (uint8*) _TIFFmalloc(cc0); + if( working_copy == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Out of memory allocating " TIFF_SSIZE_FORMAT " byte temp buffer.", + cc0 ); + return 0; + } + memcpy( working_copy, bp0, cc0 ); + bp = working_copy; rowsize = sp->rowsize; assert(rowsize > 0); - while ((long)cc > 0) { - (*sp->pfunc)(tif, bp, (tsize_t) rowsize); + assert((cc0%rowsize)==0); + while (cc > 0) { + (*sp->encodepfunc)(tif, bp, rowsize); cc -= rowsize; bp += rowsize; } - return (*sp->codetile)(tif, bp0, cc0, s); + result_code = (*sp->encodetile)(tif, working_copy, cc0, s); + + _TIFFfree( working_copy ); + + return result_code; } #define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */ -static const TIFFFieldInfo predictFieldInfo[] = { - { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR, - FALSE, FALSE, "Predictor" }, +static const TIFFField predictFields[] = { + { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UINT16, FIELD_PREDICTOR, FALSE, FALSE, "Predictor", NULL }, }; -#define N(a) (sizeof (a) / sizeof (a[0])) static int -PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) +PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); @@ -528,7 +650,7 @@ PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) switch (tag) { case TIFFTAG_PREDICTOR: - sp->predictor = (uint16) va_arg(ap, int); + sp->predictor = (uint16) va_arg(ap, uint16_vap); TIFFSetFieldBit(tif, FIELD_PREDICTOR); break; default: @@ -539,7 +661,7 @@ PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) } static int -PredictorVGetField(TIFF* tif, ttag_t tag, va_list ap) +PredictorVGetField(TIFF* tif, uint32 tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); @@ -565,9 +687,9 @@ PredictorPrintDir(TIFF* tif, FILE* fd, long flags) if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { fprintf(fd, " Predictor: "); switch (sp->predictor) { - case 1: fprintf(fd, "none "); break; - case 2: fprintf(fd, "horizontal differencing "); break; - case 3: fprintf(fd, "floating point predictor "); break; + case 1: fprintf(fd, "none "); break; + case 2: fprintf(fd, "horizontal differencing "); break; + case 3: fprintf(fd, "floating point predictor "); break; } fprintf(fd, "%u (0x%x)\n", sp->predictor, sp->predictor); } @@ -583,16 +705,24 @@ TIFFPredictorInit(TIFF* tif) assert(sp != 0); /* - * Merge codec-specific tag information and - * override parent get/set field methods. + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, predictFields, + TIFFArrayCount(predictFields))) { + TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit", + "Merging Predictor codec-specific tags failed"); + return 0; + } + + /* + * Override parent get/set field methods. */ - _TIFFMergeFieldInfo(tif, predictFieldInfo, N(predictFieldInfo)); sp->vgetparent = tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield = PredictorVGetField;/* hook for predictor tag */ sp->vsetparent = tif->tif_tagmethods.vsetfield; tif->tif_tagmethods.vsetfield = - PredictorVSetField;/* hook for predictor tag */ + PredictorVSetField;/* hook for predictor tag */ sp->printdir = tif->tif_tagmethods.printdir; tif->tif_tagmethods.printdir = PredictorPrintDir; /* hook for predictor tag */ @@ -603,7 +733,8 @@ TIFFPredictorInit(TIFF* tif) tif->tif_setupencode = PredictorSetupEncode; sp->predictor = 1; /* default value */ - sp->pfunc = NULL; /* no predictor routine */ + sp->encodepfunc = NULL; /* no predictor routine */ + sp->decodepfunc = NULL; /* no predictor routine */ return 1; } @@ -624,3 +755,10 @@ TIFFPredictorCleanup(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_predict.h b/libs/tiff-4.0.2/libtiff/tif_predict.h similarity index 56% rename from libs/tiff-3.8.2/libtiff/tif_predict.h rename to libs/tiff-4.0.2/libtiff/tif_predict.h index ecc7c1b422..dc7144c69e 100644 --- a/libs/tiff-3.8.2/libtiff/tif_predict.h +++ b/libs/tiff-4.0.2/libtiff/tif_predict.h @@ -1,26 +1,26 @@ -/* $Id: tif_predict.h,v 1.3 2006/03/03 14:10:09 dron Exp $ */ +/* $Id: tif_predict.h,v 1.8 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1995-1997 Sam Leffler * Copyright (c) 1995-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -36,29 +36,42 @@ * the predictor code can cast tif_data to find its state. */ typedef struct { - int predictor; /* predictor tag value */ - int stride; /* sample stride over data */ - tsize_t rowsize; /* tile/strip row size */ + int predictor; /* predictor tag value */ + tmsize_t stride; /* sample stride over data */ + tmsize_t rowsize; /* tile/strip row size */ - TIFFPostMethod pfunc; /* horizontal differencer/accumulator */ - TIFFCodeMethod coderow; /* parent codec encode/decode row */ - TIFFCodeMethod codestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod codetile; /* parent codec encode/decode tile */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFBoolMethod setupdecode; /* super-class method */ - TIFFBoolMethod setupencode; /* super-class method */ + TIFFCodeMethod encoderow; /* parent codec encode/decode row */ + TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */ + TIFFCodeMethod encodetile; /* parent codec encode/decode tile */ + TIFFPostMethod encodepfunc; /* horizontal differencer */ + + TIFFCodeMethod decoderow; /* parent codec encode/decode row */ + TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */ + TIFFCodeMethod decodetile; /* parent codec encode/decode tile */ + TIFFPostMethod decodepfunc; /* horizontal accumulator */ + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ + TIFFBoolMethod setupdecode; /* super-class method */ + TIFFBoolMethod setupencode; /* super-class method */ } TIFFPredictorState; #if defined(__cplusplus) extern "C" { #endif -extern int TIFFPredictorInit(TIFF*); -extern int TIFFPredictorCleanup(TIFF*); +extern int TIFFPredictorInit(TIFF*); +extern int TIFFPredictorCleanup(TIFF*); #if defined(__cplusplus) } #endif #endif /* _TIFFPREDICT_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_print.c b/libs/tiff-4.0.2/libtiff/tif_print.c similarity index 66% rename from libs/tiff-3.8.2/libtiff/tif_print.c rename to libs/tiff-4.0.2/libtiff/tif_print.c index 7b8383c2d0..385622be0e 100644 --- a/libs/tiff-3.8.2/libtiff/tif_print.c +++ b/libs/tiff-4.0.2/libtiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.35 2006/03/13 07:53:28 dron Exp $ */ +/* $Id: tif_print.c,v 1.59 2012-06-13 01:08:51 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,6 +34,9 @@ #include +static void +_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars); + static const char *photoNames[] = { "min-is-white", /* PHOTOMETRIC_MINISWHITE */ "min-is-black", /* PHOTOMETRIC_MINISBLACK */ @@ -44,6 +47,8 @@ static const char *photoNames[] = { "YCbCr", /* PHOTOMETRIC_YCBCR */ "7 (0x7)", "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ + "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */ + "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */ }; #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) @@ -61,7 +66,7 @@ static const char *orientNames[] = { #define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) static void -_TIFFPrintField(FILE* fd, const TIFFFieldInfo *fip, +_TIFFPrintField(FILE* fd, const TIFFField *fip, uint32 value_count, void *raw_data) { uint32 j; @@ -73,7 +78,7 @@ _TIFFPrintField(FILE* fd, const TIFFFieldInfo *fip, fprintf(fd, "%u", ((uint8 *) raw_data)[j]); else if(fip->field_type == TIFF_UNDEFINED) fprintf(fd, "0x%x", - (unsigned int) ((unsigned char *) raw_data)[j]); + (unsigned int) ((unsigned char *) raw_data)[j]); else if(fip->field_type == TIFF_SBYTE) fprintf(fd, "%d", ((int8 *) raw_data)[j]); else if(fip->field_type == TIFF_SHORT) @@ -82,23 +87,46 @@ _TIFFPrintField(FILE* fd, const TIFFFieldInfo *fip, fprintf(fd, "%d", ((int16 *) raw_data)[j]); else if(fip->field_type == TIFF_LONG) fprintf(fd, "%lu", - (unsigned long)((uint32 *) raw_data)[j]); + (unsigned long)((uint32 *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG) fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]); + else if(fip->field_type == TIFF_IFD) + fprintf(fd, "0x%lx", + (unsigned long)((uint32 *) raw_data)[j]); else if(fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL || fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *) raw_data)[j]); - else if(fip->field_type == TIFF_IFD) - fprintf(fd, "0x%ulx", ((uint32 *) raw_data)[j]); + else if(fip->field_type == TIFF_LONG8) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + fprintf(fd, "%I64u", + (unsigned __int64)((uint64 *) raw_data)[j]); +#else + fprintf(fd, "%llu", + (unsigned long long)((uint64 *) raw_data)[j]); +#endif + else if(fip->field_type == TIFF_SLONG8) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + fprintf(fd, "%I64d", (__int64)((int64 *) raw_data)[j]); +#else + fprintf(fd, "%lld", (long long)((int64 *) raw_data)[j]); +#endif + else if(fip->field_type == TIFF_IFD8) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + fprintf(fd, "0x%I64x", + (unsigned __int64)((uint64 *) raw_data)[j]); +#else + fprintf(fd, "0x%llx", + (unsigned long long)((uint64 *) raw_data)[j]); +#endif + else if(fip->field_type == TIFF_FLOAT) + fprintf(fd, "%f", ((float *)raw_data)[j]); + else if(fip->field_type == TIFF_DOUBLE) + fprintf(fd, "%f", ((double *) raw_data)[j]); else if(fip->field_type == TIFF_ASCII) { fprintf(fd, "%s", (char *) raw_data); break; } - else if(fip->field_type == TIFF_DOUBLE) - fprintf(fd, "%f", ((double *) raw_data)[j]); - else if(fip->field_type == TIFF_FLOAT) - fprintf(fd, "%f", ((float *)raw_data)[j]); else { fprintf(fd, ""); break; @@ -112,16 +140,22 @@ _TIFFPrintField(FILE* fd, const TIFFFieldInfo *fip, } static int -_TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, +_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, uint32 value_count, void *raw_data) { - TIFFDirectory *td = &tif->tif_dir; + (void) tif; + /* do not try to pretty print auto-defined fields */ + if (strncmp(fip->field_name,"Tag ", 4) == 0) { + return 0; + } + switch (tag) { case TIFFTAG_INKSET: - fprintf(fd, " Ink Set: "); - switch (*((uint16*)raw_data)) { + if (value_count == 2 && fip->field_type == TIFF_SHORT) { + fprintf(fd, " Ink Set: "); + switch (*((uint16*)raw_data)) { case INKSET_CMYK: fprintf(fd, "CMYK\n"); break; @@ -130,30 +164,31 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, *((uint16*)raw_data), *((uint16*)raw_data)); break; + } + return 1; } - return 1; - case TIFFTAG_DOTRANGE: - fprintf(fd, " Dot Range: %u-%u\n", - ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]); - return 1; - case TIFFTAG_WHITEPOINT: - fprintf(fd, " White Point: %g-%g\n", - ((float *)raw_data)[0], ((float *)raw_data)[1]); return 1; - case TIFFTAG_REFERENCEBLACKWHITE: - { - uint16 i; + return 0; + + case TIFFTAG_DOTRANGE: + if (value_count == 2 && fip->field_type == TIFF_SHORT) { + fprintf(fd, " Dot Range: %u-%u\n", + ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]); + return 1; + } + return 0; + + case TIFFTAG_WHITEPOINT: + if (value_count == 2 && fip->field_type == TIFF_RATIONAL) { + fprintf(fd, " White Point: %g-%g\n", + ((float *)raw_data)[0], ((float *)raw_data)[1]); + return 1; + } + return 0; - fprintf(fd, " Reference Black/White:\n"); - for (i = 0; i < td->td_samplesperpixel; i++) - fprintf(fd, " %2d: %5g %5g\n", i, - ((float *)raw_data)[2*i+0], - ((float *)raw_data)[2*i+1]); - return 1; - } case TIFFTAG_XMLPACKET: { uint32 i; - + fprintf(fd, " XMLPacket (XMP Metadata):\n" ); for(i = 0; i < value_count; i++) fputc(((char *)raw_data)[i], fd); @@ -166,23 +201,29 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, * defined as array of LONG values. */ fprintf(fd, - " RichTIFFIPTC Data: , %lu bytes\n", - (unsigned long) value_count * 4); + " RichTIFFIPTC Data: , %lu bytes\n", + (unsigned long) value_count * 4); return 1; + case TIFFTAG_PHOTOSHOP: fprintf(fd, " Photoshop Data: , %lu bytes\n", - (unsigned long) value_count); + (unsigned long) value_count); return 1; + case TIFFTAG_ICCPROFILE: fprintf(fd, " ICC Profile: , %lu bytes\n", - (unsigned long) value_count); + (unsigned long) value_count); return 1; + case TIFFTAG_STONITS: - fprintf(fd, - " Sample to Nits conversion factor: %.4e\n", - *((double*)raw_data)); - return 1; - } + if (value_count == 1 && fip->field_type == TIFF_DOUBLE) { + fprintf(fd, + " Sample to Nits conversion factor: %.4e\n", + *((double*)raw_data)); + return 1; + } + return 0; + } return 0; } @@ -199,8 +240,15 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) uint16 i; long l, n; - fprintf(fd, "TIFF Directory at offset 0x%lx (%lu)\n", - (unsigned long)tif->tif_diroff, (unsigned long)tif->tif_diroff); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n", + (unsigned __int64) tif->tif_diroff, + (unsigned __int64) tif->tif_diroff); +#else + fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n", + (unsigned long long) tif->tif_diroff, + (unsigned long long) tif->tif_diroff); +#endif if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { fprintf(fd, " Subfile Type:"); sep = " "; @@ -344,9 +392,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " Ink Names: "); i = td->td_samplesperpixel; sep = ""; - for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) { + for (cp = td->td_inknames; + i > 0 && cp < td->td_inknames + td->td_inknameslen; + cp = strchr(cp,'\0')+1, i--) { + int max_chars = + td->td_inknameslen - (cp - td->td_inknames); fputs(sep, fd); - _TIFFprintAscii(fd, cp); + _TIFFprintAsciiBounded(fd, cp, max_chars); sep = ", "; } fputs("\n", fd); @@ -386,18 +438,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) { - /* - * For hacky reasons (see tif_jpeg.c - JPEGFixupTestSubsampling), - * we need to fetch this rather than trust what is in our - * structures. - */ - uint16 subsampling[2]; - - TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, - subsampling + 0, subsampling + 1 ); fprintf(fd, " YCbCr Subsampling: %u, %u\n", - subsampling[0], subsampling[1] ); - } + td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] ); + } if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { fprintf(fd, " YCbCr Positioning: "); switch (td->td_ycbcrpositioning) { @@ -437,12 +480,20 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); - if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) - fprintf(fd, " SMin Sample Value: %g\n", - td->td_sminsamplevalue); - if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) - fprintf(fd, " SMax Sample Value: %g\n", - td->td_smaxsamplevalue); + if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) { + int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; + fprintf(fd, " SMin Sample Value:"); + for (i = 0; i < count; ++i) + fprintf(fd, " %g", td->td_sminsamplevalue[i]); + fprintf(fd, "\n"); + } + if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) { + int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; + fprintf(fd, " SMax Sample Value:"); + for (i = 0; i < count; ++i) + fprintf(fd, " %g", td->td_smaxsamplevalue[i]); + fprintf(fd, "\n"); + } if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { fprintf(fd, " Planar Configuration: "); switch (td->td_planarconfig) { @@ -475,6 +526,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } else fprintf(fd, "(present)\n"); } + if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) { + fprintf(fd, " Reference Black/White:\n"); + for (i = 0; i < 3; i++) + fprintf(fd, " %2d: %5g %5g\n", i, + td->td_refblackwhite[2*i+0], + td->td_refblackwhite[2*i+1]); + } if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { fprintf(fd, " Transfer Function: "); if (flags & TIFFPRINT_CURVES) { @@ -491,127 +549,139 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } else fprintf(fd, "(present)\n"); } - if (TIFFFieldSet(tif, FIELD_SUBIFD)) { + if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++) - fprintf(fd, " %5lu", (long) td->td_subifd[i]); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + fprintf(fd, " %5I64u", + (unsigned __int64) td->td_subifd[i]); +#else + fprintf(fd, " %5llu", + (unsigned long long) td->td_subifd[i]); +#endif fputc('\n', fd); } - /* - ** Custom tag support. - */ - { - int i; - short count; + /* + ** Custom tag support. + */ + { + int i; + short count; - count = (short) TIFFGetTagListCount(tif); - for(i = 0; i < count; i++) { - ttag_t tag = TIFFGetTagListEntry(tif, i); - const TIFFFieldInfo *fip; - uint16 value_count; - int mem_alloc = 0; - void *raw_data; + count = (short) TIFFGetTagListCount(tif); + for(i = 0; i < count; i++) { + uint32 tag = TIFFGetTagListEntry(tif, i); + const TIFFField *fip; + uint32 value_count; + int mem_alloc = 0; + void *raw_data; - fip = TIFFFieldWithTag(tif, tag); - if(fip == NULL) - continue; - - if(fip->field_passcount) { - if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) + fip = TIFFFieldWithTag(tif, tag); + if(fip == NULL) continue; - } else { - if (fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2) - value_count = 1; - else if (fip->field_readcount == TIFF_SPP) - value_count = td->td_samplesperpixel; - else - value_count = fip->field_readcount; - if ((fip->field_type == TIFF_ASCII - || fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2 - || fip->field_readcount == TIFF_SPP - || value_count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - if(TIFFGetField(tif, tag, &raw_data) != 1) + + if(fip->field_passcount) { + if (fip->field_readcount == TIFF_VARIABLE ) { + if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) + continue; + } else if (fip->field_readcount == TIFF_VARIABLE2 ) { + uint16 small_value_count; + if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1) + continue; + value_count = small_value_count; + } else { + assert (fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2); continue; - } else if (fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - raw_data = _TIFFmalloc( - _TIFFDataSize(fip->field_type) - * value_count); - mem_alloc = 1; - if(TIFFGetField(tif, tag, raw_data) != 1) { - _TIFFfree(raw_data); - continue; - } + } } else { - /* - * XXX: Should be fixed and removed, see the - * notes related to TIFFTAG_PAGENUMBER, - * TIFFTAG_HALFTONEHINTS, - * TIFFTAG_YCBCRSUBSAMPLING and - * TIFFTAG_DOTRANGE tags in tif_dir.c. */ - char *tmp; - raw_data = _TIFFmalloc( - _TIFFDataSize(fip->field_type) - * value_count); - tmp = raw_data; - mem_alloc = 1; - if(TIFFGetField(tif, tag, tmp, - tmp + _TIFFDataSize(fip->field_type)) != 1) { - _TIFFfree(raw_data); - continue; + if (fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2) + value_count = 1; + else if (fip->field_readcount == TIFF_SPP) + value_count = td->td_samplesperpixel; + else + value_count = fip->field_readcount; + if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + handled this way ... likely best if we move it into + the directory structure with an explicit field in + libtiff 4.1 and assign it a FIELD_ value */ + static uint16 dotrange[2]; + raw_data = dotrange; + TIFFGetField(tif, tag, dotrange+0, dotrange+1); + } else if (fip->field_type == TIFF_ASCII + || fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2 + || fip->field_readcount == TIFF_SPP + || value_count > 1) { + if(TIFFGetField(tif, tag, &raw_data) != 1) + continue; + } else { + raw_data = _TIFFmalloc( + _TIFFDataSize(fip->field_type) + * value_count); + mem_alloc = 1; + if(TIFFGetField(tif, tag, raw_data) != 1) { + _TIFFfree(raw_data); + continue; + } } } - } - /* - * Catch the tags which needs to be specially handled and - * pretty print them. If tag not handled in - * _TIFFPrettyPrintField() fall down and print it as any other - * tag. - */ - if (_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data)) { + /* + * Catch the tags which needs to be specially handled + * and pretty print them. If tag not handled in + * _TIFFPrettyPrintField() fall down and print it as + * any other tag. + */ + if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data)) + _TIFFPrintField(fd, fip, value_count, raw_data); + if(mem_alloc) _TIFFfree(raw_data); - continue; } - else - _TIFFPrintField(fd, fip, value_count, raw_data); - - if(mem_alloc) - _TIFFfree(raw_data); - } - } + } if (tif->tif_tagmethods.printdir) (*tif->tif_tagmethods.printdir)(tif, fd, flags); + + _TIFFFillStriles( tif ); + if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { - tstrip_t s; + uint32 s; fprintf(fd, " %lu %s:\n", (long) td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (s = 0; s < td->td_nstrips; s++) - fprintf(fd, " %3lu: [%8lu, %8lu]\n", +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + fprintf(fd, " %3lu: [%8I64u, %8I64u]\n", (unsigned long) s, - (unsigned long) td->td_stripoffset[s], - (unsigned long) td->td_stripbytecount[s]); + (unsigned __int64) td->td_stripoffset[s], + (unsigned __int64) td->td_stripbytecount[s]); +#else + fprintf(fd, " %3lu: [%8llu, %8llu]\n", + (unsigned long) s, + (unsigned long long) td->td_stripoffset[s], + (unsigned long long) td->td_stripbytecount[s]); +#endif } } void _TIFFprintAscii(FILE* fd, const char* cp) { - for (; *cp != '\0'; cp++) { + _TIFFprintAsciiBounded( fd, cp, strlen(cp)); +} + +static void +_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars) +{ + for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) { const char* tp; if (isprint((int)*cp)) { @@ -637,3 +707,10 @@ _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_read.c b/libs/tiff-4.0.2/libtiff/tif_read.c new file mode 100644 index 0000000000..3ba31e3f86 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_read.c @@ -0,0 +1,1083 @@ +/* $Id: tif_read.c,v 1.40 2012-06-01 00:55:09 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * Scanline-oriented Read Support + */ +#include "tiffiop.h" +#include + +int TIFFFillStrip(TIFF* tif, uint32 strip); +int TIFFFillTile(TIFF* tif, uint32 tile); +static int TIFFStartStrip(TIFF* tif, uint32 strip); +static int TIFFStartTile(TIFF* tif, uint32 tile); +static int TIFFCheckRead(TIFF*, int); +static tmsize_t +TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,const char* module); + +#define NOSTRIP ((uint32)(-1)) /* undefined state */ +#define NOTILE ((uint32)(-1)) /* undefined state */ + +static int +TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) +{ + static const char module[] = "TIFFFillStripPartial"; + register TIFFDirectory *td = &tif->tif_dir; + uint64 unused_data; + uint64 read_offset; + tmsize_t cc, to_read; + tmsize_t bytecountm; + + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + + /* + * Expand raw data buffer, if needed, to hold data + * strip coming from file (perhaps should set upper + * bound on the size of a buffer we'll use?). + */ + + bytecountm=(tmsize_t) td->td_stripbytecount[strip]; + if (read_ahead*2 > tif->tif_rawdatasize) { + assert( restart ); + + tif->tif_curstrip = NOSTRIP; + if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Data buffer too small to hold part of strip %lu", + (unsigned long) strip); + return (0); + } + if (!TIFFReadBufferSetup(tif, 0, read_ahead*2)) + return (0); + } + + if( restart ) + { + tif->tif_rawdataloaded = 0; + tif->tif_rawdataoff = 0; + } + + /* + ** If we are reading more data, move any unused data to the + ** start of the buffer. + */ + if( tif->tif_rawdataloaded > 0 ) + unused_data = tif->tif_rawdataloaded - (tif->tif_rawcp - tif->tif_rawdata); + else + unused_data = 0; + + if( unused_data > 0 ) + { + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); + memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data ); + } + + /* + ** Seek to the point in the file where more data should be read. + */ + read_offset = td->td_stripoffset[strip] + + tif->tif_rawdataoff + tif->tif_rawdataloaded; + + if (!SeekOK(tif, read_offset)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Seek error at scanline %lu, strip %lu", + (unsigned long) tif->tif_row, (unsigned long) strip); + return 0; + } + + /* + ** How much do we want to read? + */ + to_read = tif->tif_rawdatasize - unused_data; + if( (uint64) to_read > td->td_stripbytecount[strip] + - tif->tif_rawdataoff - tif->tif_rawdataloaded ) + { + to_read = td->td_stripbytecount[strip] + - tif->tif_rawdataoff - tif->tif_rawdataloaded; + } + + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); + cc = TIFFReadFile(tif, tif->tif_rawdata + unused_data, to_read); + + if (cc != to_read) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at scanline %lu; got %I64u bytes, expected %I64u", + (unsigned long) tif->tif_row, + (unsigned __int64) cc, + (unsigned __int64) to_read); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at scanline %lu; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long long) cc, + (unsigned long long) to_read); +#endif + return 0; + } + + tif->tif_rawdataoff = tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data ; + tif->tif_rawdataloaded = unused_data + to_read; + + tif->tif_rawcp = tif->tif_rawdata; + + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) { + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); + TIFFReverseBits(tif->tif_rawdata + unused_data, to_read ); + } + + /* + ** When starting a strip from the beginning we need to + ** restart the decoder. + */ + if( restart ) + return TIFFStartStrip(tif, strip); + else + return 1; +} + +/* + * Seek to a random row+sample in a file. + * + * Only used by TIFFReadScanline, and is only used on + * strip organized files. We do some tricky stuff to try + * and avoid reading the whole compressed raw data for big + * strips. + */ +static int +TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) +{ + register TIFFDirectory *td = &tif->tif_dir; + uint32 strip; + int whole_strip; + tmsize_t read_ahead = 0; + + /* + ** Establish what strip we are working from. + */ + if (row >= td->td_imagelength) { /* out of range */ + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%lu: Row out of range, max %lu", + (unsigned long) row, + (unsigned long) td->td_imagelength); + return (0); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%lu: Sample out of range, max %lu", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + return (0); + } + strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; + } else + strip = row / td->td_rowsperstrip; + + /* + * Do we want to treat this strip as one whole chunk or + * read it a few lines at a time? + */ +#if defined(CHUNKY_STRIP_READ_SUPPORT) + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + whole_strip = tif->tif_dir.td_stripbytecount[strip] < 10 + || isMapped(tif); +#else + whole_strip = 1; +#endif + + if( !whole_strip ) + { + read_ahead = tif->tif_scanlinesize * 16 + 5000; + } + + /* + * If we haven't loaded this strip, do so now, possibly + * only reading the first part. + */ + if (strip != tif->tif_curstrip) { /* different strip, refill */ + + if( whole_strip ) + { + if (!TIFFFillStrip(tif, strip)) + return (0); + } + else + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + } + + /* + ** If we already have some data loaded, do we need to read some more? + */ + else if( !whole_strip ) + { + if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead + && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < td->td_stripbytecount[strip] ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,0) ) + return 0; + } + } + + if (row < tif->tif_row) { + /* + * Moving backwards within the same strip: backup + * to the start and then decode forward (below). + * + * NB: If you're planning on lots of random access within a + * strip, it's better to just read and decode the entire + * strip, and then access the decoded data in a random fashion. + */ + + if( tif->tif_rawdataoff != 0 ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + else + { + if (!TIFFStartStrip(tif, strip)) + return (0); + } + } + + if (row != tif->tif_row) { + /* + * Seek forward to the desired row. + */ + + /* TODO: Will this really work with partial buffers? */ + + if (!(*tif->tif_seek)(tif, row - tif->tif_row)) + return (0); + tif->tif_row = row; + } + + return (1); +} + +int +TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) +{ + int e; + + if (!TIFFCheckRead(tif, 0)) + return (-1); + if( (e = TIFFSeek(tif, row, sample)) != 0) { + /* + * Decompress desired row into user buffer. + */ + e = (*tif->tif_decoderow) + (tif, (uint8*) buf, tif->tif_scanlinesize, sample); + + /* we are now poised at the beginning of the next row */ + tif->tif_row = row + 1; + + if (e) + (*tif->tif_postdecode)(tif, (uint8*) buf, + tif->tif_scanlinesize); + } + return (e > 0 ? 1 : -1); +} + +/* + * Read a strip of data and decompress the specified + * amount into the user-supplied buffer. + */ +tmsize_t +TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) +{ + static const char module[] = "TIFFReadEncodedStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint32 rowsperstrip; + uint32 stripsperplane; + uint32 stripinplane; + uint16 plane; + uint32 rows; + tmsize_t stripsize; + if (!TIFFCheckRead(tif,0)) + return((tmsize_t)(-1)); + if (strip>=td->td_nstrips) + { + TIFFErrorExt(tif->tif_clientdata,module, + "%lu: Strip out of range, max %lu",(unsigned long)strip, + (unsigned long)td->td_nstrips); + return((tmsize_t)(-1)); + } + /* + * Calculate the strip size according to the number of + * rows in the strip (check for truncated last strip on any + * of the separations). + */ + rowsperstrip=td->td_rowsperstrip; + if (rowsperstrip>td->td_imagelength) + rowsperstrip=td->td_imagelength; + stripsperplane=((td->td_imagelength+rowsperstrip-1)/rowsperstrip); + stripinplane=(strip%stripsperplane); + plane=(strip/stripsperplane); + rows=td->td_imagelength-stripinplane*rowsperstrip; + if (rows>rowsperstrip) + rows=rowsperstrip; + stripsize=TIFFVStripSize(tif,rows); + if (stripsize==0) + return((tmsize_t)(-1)); + if ((size!=(tmsize_t)(-1))&&(sizetif_decodestrip)(tif,buf,stripsize,plane)<=0) + return((tmsize_t)(-1)); + (*tif->tif_postdecode)(tif,buf,stripsize); + return(stripsize); +} + +static tmsize_t +TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, + const char* module) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (!_TIFFFillStriles( tif )) + return ((tmsize_t)(-1)); + + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + if (!isMapped(tif)) { + tmsize_t cc; + + if (!SeekOK(tif, td->td_stripoffset[strip])) { + TIFFErrorExt(tif->tif_clientdata, module, + "Seek error at scanline %lu, strip %lu", + (unsigned long) tif->tif_row, (unsigned long) strip); + return ((tmsize_t)(-1)); + } + cc = TIFFReadFile(tif, buf, size); + if (cc != size) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at scanline %lu; got %I64u bytes, expected %I64u", + (unsigned long) tif->tif_row, + (unsigned __int64) cc, + (unsigned __int64) size); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at scanline %lu; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long long) cc, + (unsigned long long) size); +#endif + return ((tmsize_t)(-1)); + } + } else { + tmsize_t ma,mb; + tmsize_t n; + ma=(tmsize_t)td->td_stripoffset[strip]; + mb=ma+size; + if (((uint64)ma!=td->td_stripoffset[strip])||(ma>tif->tif_size)) + n=0; + else if ((mbtif->tif_size)) + n=tif->tif_size-ma; + else + n=size; + if (n!=size) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at scanline %lu, strip %lu; got %I64u bytes, expected %I64u", + (unsigned long) tif->tif_row, + (unsigned long) strip, + (unsigned __int64) n, + (unsigned __int64) size); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long) strip, + (unsigned long long) n, + (unsigned long long) size); +#endif + return ((tmsize_t)(-1)); + } + _TIFFmemcpy(buf, tif->tif_base + ma, + size); + } + return (size); +} + +/* + * Read a strip of data from the file. + */ +tmsize_t +TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) +{ + static const char module[] = "TIFFReadRawStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint64 bytecount; + tmsize_t bytecountm; + + if (!TIFFCheckRead(tif, 0)) + return ((tmsize_t)(-1)); + if (strip >= td->td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Strip out of range, max %lu", + (unsigned long) strip, + (unsigned long) td->td_nstrips); + return ((tmsize_t)(-1)); + } + if (tif->tif_flags&TIFF_NOREADRAW) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); + return ((tmsize_t)(-1)); + } + bytecount = td->td_stripbytecount[strip]; + if (bytecount <= 0) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "%I64u: Invalid strip byte count, strip %lu", + (unsigned __int64) bytecount, + (unsigned long) strip); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid strip byte count, strip %lu", + (unsigned long long) bytecount, + (unsigned long) strip); +#endif + return ((tmsize_t)(-1)); + } + bytecountm = (tmsize_t)bytecount; + if ((uint64)bytecountm!=bytecount) { + TIFFErrorExt(tif->tif_clientdata, module, "Integer overflow"); + return ((tmsize_t)(-1)); + } + if (size != (tmsize_t)(-1) && size < bytecountm) + bytecountm = size; + return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module)); +} + +/* + * Read the specified strip and setup for decoding. The data buffer is + * expanded, as necessary, to hold the strip's data. + */ +int +TIFFFillStrip(TIFF* tif, uint32 strip) +{ + static const char module[] = "TIFFFillStrip"; + TIFFDirectory *td = &tif->tif_dir; + + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + + if ((tif->tif_flags&TIFF_NOREADRAW)==0) + { + uint64 bytecount = td->td_stripbytecount[strip]; + if (bytecount <= 0) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid strip byte count %I64u, strip %lu", + (unsigned __int64) bytecount, + (unsigned long) strip); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid strip byte count %llu, strip %lu", + (unsigned long long) bytecount, + (unsigned long) strip); +#endif + return (0); + } + if (isMapped(tif) && + (isFillOrder(tif, td->td_fillorder) + || (tif->tif_flags & TIFF_NOBITREV))) { + /* + * The image is mapped into memory and we either don't + * need to flip bits or the compression routine is + * going to handle this operation itself. In this + * case, avoid copying the raw data and instead just + * reference the data from the memory mapped file + * image. This assumes that the decompression + * routines do not modify the contents of the raw data + * buffer (if they try to, the application will get a + * fault since the file is mapped read-only). + */ + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } + tif->tif_flags &= ~TIFF_MYBUFFER; + /* + * We must check for overflow, potentially causing + * an OOB read. Instead of simple + * + * td->td_stripoffset[strip]+bytecount > tif->tif_size + * + * comparison (which can overflow) we do the following + * two comparisons: + */ + if (bytecount > (uint64)tif->tif_size || + td->td_stripoffset[strip] > (uint64)tif->tif_size - bytecount) { + /* + * This error message might seem strange, but + * it's what would happen if a read were done + * instead. + */ +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + + "Read error on strip %lu; " + "got %I64u bytes, expected %I64u", + (unsigned long) strip, + (unsigned __int64) tif->tif_size - td->td_stripoffset[strip], + (unsigned __int64) bytecount); +#else + TIFFErrorExt(tif->tif_clientdata, module, + + "Read error on strip %lu; " + "got %llu bytes, expected %llu", + (unsigned long) strip, + (unsigned long long) tif->tif_size - td->td_stripoffset[strip], + (unsigned long long) bytecount); +#endif + tif->tif_curstrip = NOSTRIP; + return (0); + } + tif->tif_rawdatasize = (tmsize_t)bytecount; + tif->tif_rawdata = tif->tif_base + (tmsize_t)td->td_stripoffset[strip]; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = (tmsize_t) bytecount; + + /* + * When we have tif_rawdata reference directly into the memory mapped file + * we need to be pretty careful about how we use the rawdata. It is not + * a general purpose working buffer as it normally otherwise is. So we + * keep track of this fact to avoid using it improperly. + */ + tif->tif_flags |= TIFF_BUFFERMMAP; + } else { + /* + * Expand raw data buffer, if needed, to hold data + * strip coming from file (perhaps should set upper + * bound on the size of a buffer we'll use?). + */ + tmsize_t bytecountm; + bytecountm=(tmsize_t)bytecount; + if ((uint64)bytecountm!=bytecount) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + return(0); + } + if (bytecountm > tif->tif_rawdatasize) { + tif->tif_curstrip = NOSTRIP; + if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Data buffer too small to hold strip %lu", + (unsigned long) strip); + return (0); + } + if (!TIFFReadBufferSetup(tif, 0, bytecountm)) + return (0); + } + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_curstrip = NOSTRIP; + if (!TIFFReadBufferSetup(tif, 0, bytecountm)) + return (0); + } + if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, + bytecountm, module) != bytecountm) + return (0); + + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = bytecountm; + + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) + TIFFReverseBits(tif->tif_rawdata, bytecountm); + } + } + return (TIFFStartStrip(tif, strip)); +} + +/* + * Tile-oriented Read Support + * Contributed by Nancy Cam (Silicon Graphics). + */ + +/* + * Read and decompress a tile of data. The + * tile is selected by the (x,y,z,s) coordinates. + */ +tmsize_t +TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) +{ + if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) + return ((tmsize_t)(-1)); + return (TIFFReadEncodedTile(tif, + TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1))); +} + +/* + * Read a tile of data and decompress the specified + * amount into the user-supplied buffer. + */ +tmsize_t +TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) +{ + static const char module[] = "TIFFReadEncodedTile"; + TIFFDirectory *td = &tif->tif_dir; + tmsize_t tilesize = tif->tif_tilesize; + + if (!TIFFCheckRead(tif, 1)) + return ((tmsize_t)(-1)); + if (tile >= td->td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Tile out of range, max %lu", + (unsigned long) tile, (unsigned long) td->td_nstrips); + return ((tmsize_t)(-1)); + } + if (size == (tmsize_t)(-1)) + size = tilesize; + else if (size > tilesize) + size = tilesize; + if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, + (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8*) buf, size); + return (size); + } else + return ((tmsize_t)(-1)); +} + +static tmsize_t +TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (!_TIFFFillStriles( tif )) + return ((tmsize_t)(-1)); + + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + if (!isMapped(tif)) { + tmsize_t cc; + + if (!SeekOK(tif, td->td_stripoffset[tile])) { + TIFFErrorExt(tif->tif_clientdata, module, + "Seek error at row %lu, col %lu, tile %lu", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long) tile); + return ((tmsize_t)(-1)); + } + cc = TIFFReadFile(tif, buf, size); + if (cc != size) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at row %lu, col %lu; got %I64u bytes, expected %I64u", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned __int64) cc, + (unsigned __int64) size); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "Read error at row %lu, col %lu; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long long) cc, + (unsigned long long) size); +#endif + return ((tmsize_t)(-1)); + } + } else { + tmsize_t ma,mb; + tmsize_t n; + ma=(tmsize_t)td->td_stripoffset[tile]; + mb=ma+size; + if (((uint64)ma!=td->td_stripoffset[tile])||(ma>tif->tif_size)) + n=0; + else if ((mbtif->tif_size)) + n=tif->tif_size-ma; + else + n=size; + if (n!=size) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, +"Read error at row %lu, col %lu, tile %lu; got %I64u bytes, expected %I64u", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long) tile, + (unsigned __int64) n, + (unsigned __int64) size); +#else + TIFFErrorExt(tif->tif_clientdata, module, +"Read error at row %lu, col %lu, tile %lu; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long) tile, + (unsigned long long) n, + (unsigned long long) size); +#endif + return ((tmsize_t)(-1)); + } + _TIFFmemcpy(buf, tif->tif_base + ma, size); + } + return (size); +} + +/* + * Read a tile of data from the file. + */ +tmsize_t +TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) +{ + static const char module[] = "TIFFReadRawTile"; + TIFFDirectory *td = &tif->tif_dir; + uint64 bytecount64; + tmsize_t bytecountm; + + if (!TIFFCheckRead(tif, 1)) + return ((tmsize_t)(-1)); + if (tile >= td->td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Tile out of range, max %lu", + (unsigned long) tile, (unsigned long) td->td_nstrips); + return ((tmsize_t)(-1)); + } + if (tif->tif_flags&TIFF_NOREADRAW) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); + return ((tmsize_t)(-1)); + } + bytecount64 = td->td_stripbytecount[tile]; + if (size != (tmsize_t)(-1) && (uint64)size < bytecount64) + bytecount64 = (uint64)size; + bytecountm = (tmsize_t)bytecount64; + if ((uint64)bytecountm!=bytecount64) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + return ((tmsize_t)(-1)); + } + return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module)); +} + +/* + * Read the specified tile and setup for decoding. The data buffer is + * expanded, as necessary, to hold the tile's data. + */ +int +TIFFFillTile(TIFF* tif, uint32 tile) +{ + static const char module[] = "TIFFFillTile"; + TIFFDirectory *td = &tif->tif_dir; + + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + + if ((tif->tif_flags&TIFF_NOREADRAW)==0) + { + uint64 bytecount = td->td_stripbytecount[tile]; + if (bytecount <= 0) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "%I64u: Invalid tile byte count, tile %lu", + (unsigned __int64) bytecount, + (unsigned long) tile); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid tile byte count, tile %lu", + (unsigned long long) bytecount, + (unsigned long) tile); +#endif + return (0); + } + if (isMapped(tif) && + (isFillOrder(tif, td->td_fillorder) + || (tif->tif_flags & TIFF_NOBITREV))) { + /* + * The image is mapped into memory and we either don't + * need to flip bits or the compression routine is + * going to handle this operation itself. In this + * case, avoid copying the raw data and instead just + * reference the data from the memory mapped file + * image. This assumes that the decompression + * routines do not modify the contents of the raw data + * buffer (if they try to, the application will get a + * fault since the file is mapped read-only). + */ + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } + tif->tif_flags &= ~TIFF_MYBUFFER; + /* + * We must check for overflow, potentially causing + * an OOB read. Instead of simple + * + * td->td_stripoffset[tile]+bytecount > tif->tif_size + * + * comparison (which can overflow) we do the following + * two comparisons: + */ + if (bytecount > (uint64)tif->tif_size || + td->td_stripoffset[tile] > (uint64)tif->tif_size - bytecount) { + tif->tif_curtile = NOTILE; + return (0); + } + tif->tif_rawdatasize = (tmsize_t)bytecount; + tif->tif_rawdata = + tif->tif_base + (tmsize_t)td->td_stripoffset[tile]; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = (tmsize_t) bytecount; + tif->tif_flags |= TIFF_BUFFERMMAP; + } else { + /* + * Expand raw data buffer, if needed, to hold data + * tile coming from file (perhaps should set upper + * bound on the size of a buffer we'll use?). + */ + tmsize_t bytecountm; + bytecountm=(tmsize_t)bytecount; + if ((uint64)bytecountm!=bytecount) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + return(0); + } + if (bytecountm > tif->tif_rawdatasize) { + tif->tif_curtile = NOTILE; + if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Data buffer too small to hold tile %lu", + (unsigned long) tile); + return (0); + } + if (!TIFFReadBufferSetup(tif, 0, bytecountm)) + return (0); + } + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_curtile = NOTILE; + if (!TIFFReadBufferSetup(tif, 0, bytecountm)) + return (0); + } + + if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata, + bytecountm, module) != bytecountm) + return (0); + + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = bytecountm; + + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) + TIFFReverseBits(tif->tif_rawdata, + tif->tif_rawdataloaded); + } + } + return (TIFFStartTile(tif, tile)); +} + +/* + * Setup the raw data buffer in preparation for + * reading a strip of raw data. If the buffer + * is specified as zero, then a buffer of appropriate + * size is allocated by the library. Otherwise, + * the client must guarantee that the buffer is + * large enough to hold any individual strip of + * raw data. + */ +int +TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) +{ + static const char module[] = "TIFFReadBufferSetup"; + + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + tif->tif_flags &= ~TIFF_BUFFERMMAP; + + if (tif->tif_rawdata) { + if (tif->tif_flags & TIFF_MYBUFFER) + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } + if (bp) { + tif->tif_rawdatasize = size; + tif->tif_rawdata = (uint8*) bp; + tif->tif_flags &= ~TIFF_MYBUFFER; + } else { + tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024); + if (tif->tif_rawdatasize==0) + tif->tif_rawdatasize=(tmsize_t)(-1); + tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize); + tif->tif_flags |= TIFF_MYBUFFER; + } + if (tif->tif_rawdata == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "No space for data buffer at scanline %lu", + (unsigned long) tif->tif_row); + tif->tif_rawdatasize = 0; + return (0); + } + return (1); +} + +/* + * Set state to appear as if a + * strip has just been read in. + */ +static int +TIFFStartStrip(TIFF* tif, uint32 strip) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupdecode)(tif)) + return (0); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_curstrip = strip; + tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; + tif->tif_flags &= ~TIFF_BUF4WRITE; + + if (tif->tif_flags&TIFF_NOREADRAW) + { + tif->tif_rawcp = NULL; + tif->tif_rawcc = 0; + } + else + { + tif->tif_rawcp = tif->tif_rawdata; + tif->tif_rawcc = (tmsize_t)td->td_stripbytecount[strip]; + } + return ((*tif->tif_predecode)(tif, + (uint16)(strip / td->td_stripsperimage))); +} + +/* + * Set state to appear as if a + * tile has just been read in. + */ +static int +TIFFStartTile(TIFF* tif, uint32 tile) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupdecode)(tif)) + return (0); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_curtile = tile; + tif->tif_row = + (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) * + td->td_tilelength; + tif->tif_col = + (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) * + td->td_tilewidth; + tif->tif_flags &= ~TIFF_BUF4WRITE; + if (tif->tif_flags&TIFF_NOREADRAW) + { + tif->tif_rawcp = NULL; + tif->tif_rawcc = 0; + } + else + { + tif->tif_rawcp = tif->tif_rawdata; + tif->tif_rawcc = (tmsize_t)td->td_stripbytecount[tile]; + } + return ((*tif->tif_predecode)(tif, + (uint16)(tile/td->td_stripsperimage))); +} + +static int +TIFFCheckRead(TIFF* tif, int tiles) +{ + if (tif->tif_mode == O_WRONLY) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading"); + return (0); + } + if (tiles ^ isTiled(tif)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ? + "Can not read tiles from a stripped image" : + "Can not read scanlines from a tiled image"); + return (0); + } + return (1); +} + +void +_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) +{ + (void) tif; (void) buf; (void) cc; +} + +void +_TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc) +{ + (void) tif; + assert((cc & 1) == 0); + TIFFSwabArrayOfShort((uint16*) buf, cc/2); +} + +void +_TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc) +{ + (void) tif; + assert((cc % 3) == 0); + TIFFSwabArrayOfTriples((uint8*) buf, cc/3); +} + +void +_TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc) +{ + (void) tif; + assert((cc & 3) == 0); + TIFFSwabArrayOfLong((uint32*) buf, cc/4); +} + +void +_TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc) +{ + (void) tif; + assert((cc & 7) == 0); + TIFFSwabArrayOfDouble((double*) buf, cc/8); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tif_stream.cxx b/libs/tiff-4.0.2/libtiff/tif_stream.cxx new file mode 100644 index 0000000000..163447ebd0 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_stream.cxx @@ -0,0 +1,425 @@ +/* $Id: tif_stream.cxx,v 1.11 2010-12-11 23:12:29 faxguy Exp $ */ + +/* + * Copyright (c) 1988-1996 Sam Leffler + * Copyright (c) 1991-1996 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library UNIX-specific Routines. + */ +#include "tiffiop.h" +#include + +#ifndef __VMS +using namespace std; +#endif + +/* + ISO C++ uses a 'std::streamsize' type to define counts. This makes + it similar to, (but perhaps not the same as) size_t. + + The std::ios::pos_type is used to represent stream positions as used + by tellg(), tellp(), seekg(), and seekp(). This makes it similar to + (but perhaps not the same as) 'off_t'. The std::ios::streampos type + is used for character streams, but is documented to not be an + integral type anymore, so it should *not* be assigned to an integral + type. + + The std::ios::off_type is used to specify relative offsets needed by + the variants of seekg() and seekp() which accept a relative offset + argument. + + Useful prototype knowledge: + + Obtain read position + ios::pos_type basic_istream::tellg() + + Set read position + basic_istream& basic_istream::seekg(ios::pos_type) + basic_istream& basic_istream::seekg(ios::off_type, ios_base::seekdir) + + Read data + basic_istream& istream::read(char *str, streamsize count) + + Number of characters read in last unformatted read + streamsize istream::gcount(); + + Obtain write position + ios::pos_type basic_ostream::tellp() + + Set write position + basic_ostream& basic_ostream::seekp(ios::pos_type) + basic_ostream& basic_ostream::seekp(ios::off_type, ios_base::seekdir) + + Write data + basic_ostream& ostream::write(const char *str, streamsize count) +*/ + +struct tiffis_data; +struct tiffos_data; + +extern "C" { + + static tmsize_t _tiffosReadProc(thandle_t, void*, tmsize_t); + static tmsize_t _tiffisReadProc(thandle_t fd, void* buf, tmsize_t size); + static tmsize_t _tiffosWriteProc(thandle_t fd, void* buf, tmsize_t size); + static tmsize_t _tiffisWriteProc(thandle_t, void*, tmsize_t); + static uint64 _tiffosSeekProc(thandle_t fd, uint64 off, int whence); + static uint64 _tiffisSeekProc(thandle_t fd, uint64 off, int whence); + static uint64 _tiffosSizeProc(thandle_t fd); + static uint64 _tiffisSizeProc(thandle_t fd); + static int _tiffosCloseProc(thandle_t fd); + static int _tiffisCloseProc(thandle_t fd); + static int _tiffDummyMapProc(thandle_t , void** base, toff_t* size ); + static void _tiffDummyUnmapProc(thandle_t , void* base, toff_t size ); + static TIFF* _tiffStreamOpen(const char* name, const char* mode, void *fd); + +struct tiffis_data +{ + istream *stream; + ios::pos_type start_pos; +}; + +struct tiffos_data +{ + ostream *stream; + ios::pos_type start_pos; +}; + +static tmsize_t +_tiffosReadProc(thandle_t, void*, tmsize_t) +{ + return 0; +} + +static tmsize_t +_tiffisReadProc(thandle_t fd, void* buf, tmsize_t size) +{ + tiffis_data *data = reinterpret_cast(fd); + + // Verify that type does not overflow. + streamsize request_size = size; + if (static_cast(request_size) != size) + return static_cast(-1); + + data->stream->read((char *) buf, request_size); + + return static_cast(data->stream->gcount()); +} + +static tmsize_t +_tiffosWriteProc(thandle_t fd, void* buf, tmsize_t size) +{ + tiffos_data *data = reinterpret_cast(fd); + ostream *os = data->stream; + ios::pos_type pos = os->tellp(); + + // Verify that type does not overflow. + streamsize request_size = size; + if (static_cast(request_size) != size) + return static_cast(-1); + + os->write(reinterpret_cast(buf), request_size); + + return static_cast(os->tellp() - pos); +} + +static tmsize_t +_tiffisWriteProc(thandle_t, void*, tmsize_t) +{ + return 0; +} + +static uint64 +_tiffosSeekProc(thandle_t fd, uint64 off, int whence) +{ + tiffos_data *data = reinterpret_cast(fd); + ostream *os = data->stream; + + // if the stream has already failed, don't do anything + if( os->fail() ) + return static_cast(-1); + + switch(whence) { + case SEEK_SET: + { + // Compute 64-bit offset + uint64 new_offset = static_cast(data->start_pos) + off; + + // Verify that value does not overflow + ios::off_type offset = static_cast(new_offset); + if (static_cast(offset) != new_offset) + return static_cast(-1); + + os->seekp(offset, ios::beg); + break; + } + case SEEK_CUR: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); + + os->seekp(offset, ios::cur); + break; + } + case SEEK_END: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); + + os->seekp(offset, ios::end); + break; + } + } + + // Attempt to workaround problems with seeking past the end of the + // stream. ofstream doesn't have a problem with this but + // ostrstream/ostringstream does. In that situation, add intermediate + // '\0' characters. + if( os->fail() ) { +#ifdef __VMS + int old_state; +#else + ios::iostate old_state; +#endif + ios::pos_type origin; + + old_state = os->rdstate(); + // reset the fail bit or else tellp() won't work below + os->clear(os->rdstate() & ~ios::failbit); + switch( whence ) { + case SEEK_SET: + default: + origin = data->start_pos; + break; + case SEEK_CUR: + origin = os->tellp(); + break; + case SEEK_END: + os->seekp(0, ios::end); + origin = os->tellp(); + break; + } + // restore original stream state + os->clear(old_state); + + // only do something if desired seek position is valid + if( (static_cast(origin) + off) > static_cast(data->start_pos) ) { + uint64 num_fill; + + // clear the fail bit + os->clear(os->rdstate() & ~ios::failbit); + + // extend the stream to the expected size + os->seekp(0, ios::end); + num_fill = (static_cast(origin)) + off - os->tellp(); + for( uint64 i = 0; i < num_fill; i++ ) + os->put('\0'); + + // retry the seek + os->seekp(static_cast(static_cast(origin) + off), ios::beg); + } + } + + return static_cast(os->tellp()); +} + +static uint64 +_tiffisSeekProc(thandle_t fd, uint64 off, int whence) +{ + tiffis_data *data = reinterpret_cast(fd); + + switch(whence) { + case SEEK_SET: + { + // Compute 64-bit offset + uint64 new_offset = static_cast(data->start_pos) + off; + + // Verify that value does not overflow + ios::off_type offset = static_cast(new_offset); + if (static_cast(offset) != new_offset) + return static_cast(-1); + + data->stream->seekg(offset, ios::beg); + break; + } + case SEEK_CUR: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); + + data->stream->seekg(offset, ios::cur); + break; + } + case SEEK_END: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); + + data->stream->seekg(offset, ios::end); + break; + } + } + + return (uint64) (data->stream->tellg() - data->start_pos); +} + +static uint64 +_tiffosSizeProc(thandle_t fd) +{ + tiffos_data *data = reinterpret_cast(fd); + ostream *os = data->stream; + ios::pos_type pos = os->tellp(); + ios::pos_type len; + + os->seekp(0, ios::end); + len = os->tellp(); + os->seekp(pos); + + return (uint64) len; +} + +static uint64 +_tiffisSizeProc(thandle_t fd) +{ + tiffis_data *data = reinterpret_cast(fd); + ios::pos_type pos = data->stream->tellg(); + ios::pos_type len; + + data->stream->seekg(0, ios::end); + len = data->stream->tellg(); + data->stream->seekg(pos); + + return (uint64) len; +} + +static int +_tiffosCloseProc(thandle_t fd) +{ + // Our stream was not allocated by us, so it shouldn't be closed by us. + delete reinterpret_cast(fd); + return 0; +} + +static int +_tiffisCloseProc(thandle_t fd) +{ + // Our stream was not allocated by us, so it shouldn't be closed by us. + delete reinterpret_cast(fd); + return 0; +} + +static int +_tiffDummyMapProc(thandle_t , void** base, toff_t* size ) +{ + return (0); +} + +static void +_tiffDummyUnmapProc(thandle_t , void* base, toff_t size ) +{ +} + +/* + * Open a TIFF file descriptor for read/writing. + */ +static TIFF* +_tiffStreamOpen(const char* name, const char* mode, void *fd) +{ + TIFF* tif; + + if( strchr(mode, 'w') ) { + tiffos_data *data = new tiffos_data; + data->stream = reinterpret_cast(fd); + data->start_pos = data->stream->tellp(); + + // Open for writing. + tif = TIFFClientOpen(name, mode, + reinterpret_cast(data), + _tiffosReadProc, + _tiffosWriteProc, + _tiffosSeekProc, + _tiffosCloseProc, + _tiffosSizeProc, + _tiffDummyMapProc, + _tiffDummyUnmapProc); + } else { + tiffis_data *data = new tiffis_data; + data->stream = reinterpret_cast(fd); + data->start_pos = data->stream->tellg(); + // Open for reading. + tif = TIFFClientOpen(name, mode, + reinterpret_cast(data), + _tiffisReadProc, + _tiffisWriteProc, + _tiffisSeekProc, + _tiffisCloseProc, + _tiffisSizeProc, + _tiffDummyMapProc, + _tiffDummyUnmapProc); + } + + return (tif); +} + +} /* extern "C" */ + +TIFF* +TIFFStreamOpen(const char* name, ostream *os) +{ + // If os is either a ostrstream or ostringstream, and has no data + // written to it yet, then tellp() will return -1 which will break us. + // We workaround this by writing out a dummy character and + // then seek back to the beginning. + if( !os->fail() && static_cast(os->tellp()) < 0 ) { + *os << '\0'; + os->seekp(0); + } + + // NB: We don't support mapped files with streams so add 'm' + return _tiffStreamOpen(name, "wm", os); +} + +TIFF* +TIFFStreamOpen(const char* name, istream *is) +{ + // NB: We don't support mapped files with streams so add 'm' + return _tiffStreamOpen(name, "rm", is); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + Local Variables: + mode: c + indent-tabs-mode: true + c-basic-offset: 8 + End: +*/ diff --git a/libs/tiff-4.0.2/libtiff/tif_strip.c b/libs/tiff-4.0.2/libtiff/tif_strip.c new file mode 100644 index 0000000000..568e4898d3 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tif_strip.c @@ -0,0 +1,383 @@ +/* $Id: tif_strip.c,v 1.35 2012-06-06 05:33:55 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1991-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Strip-organized Image Support Routines. + */ +#include "tiffiop.h" + +/* + * Compute which strip a (row,sample) value is in. + */ +uint32 +TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) +{ + static const char module[] = "TIFFComputeStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint32 strip; + + strip = row / td->td_rowsperstrip; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Sample out of range, max %lu", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + return (0); + } + strip += (uint32)sample*td->td_stripsperimage; + } + return (strip); +} + +/* + * Compute how many strips are in an image. + */ +uint32 +TIFFNumberOfStrips(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + uint32 nstrips; + + nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel, + "TIFFNumberOfStrips"); + return (nstrips); +} + +/* + * Compute the # bytes in a variable height, row-aligned strip. + */ +uint64 +TIFFVStripSize64(TIFF* tif, uint32 nrows) +{ + static const char module[] = "TIFFVStripSize64"; + TIFFDirectory *td = &tif->tif_dir; + if (nrows==(uint32)(-1)) + nrows=td->td_imagelength; + if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& + (td->td_photometric == PHOTOMETRIC_YCBCR)&& + (!isUpSampled(tif))) + { + /* + * Packed YCbCr data contain one Cb+Cr for every + * HorizontalSampling*VerticalSampling Y values. + * Must also roundup width and height when calculating + * since images that are not a multiple of the + * horizontal/vertical subsampling area include + * YCbCr data for the extended image. + */ + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint32 samplingblocks_ver; + uint64 samplingrow_samples; + uint64 samplingrow_size; + if(td->td_samplesperpixel!=3) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid td_samplesperpixel value"); + return 0; + } + TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, + ycbcrsubsampling+1); + if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) + ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4)) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling (%dx%d)", + ycbcrsubsampling[0], + ycbcrsubsampling[1] ); + return 0; + } + samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]); + samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]); + samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module)); + return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module)); + } + else + return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module)); +} +tmsize_t +TIFFVStripSize(TIFF* tif, uint32 nrows) +{ + static const char module[] = "TIFFVStripSize"; + uint64 m; + tmsize_t n; + m=TIFFVStripSize64(tif,nrows); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + return(n); +} + +/* + * Compute the # bytes in a raw strip. + */ +uint64 +TIFFRawStripSize64(TIFF* tif, uint32 strip) +{ + static const char module[] = "TIFFRawStripSize64"; + TIFFDirectory* td = &tif->tif_dir; + uint64 bytecount = td->td_stripbytecount[strip]; + + if (bytecount == 0) + { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "%I64u: Invalid strip byte count, strip %lu", + (unsigned __int64) bytecount, + (unsigned long) strip); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid strip byte count, strip %lu", + (unsigned long long) bytecount, + (unsigned long) strip); +#endif + bytecount = (uint64) -1; + } + + return bytecount; +} +tmsize_t +TIFFRawStripSize(TIFF* tif, uint32 strip) +{ + static const char module[] = "TIFFRawStripSize"; + uint64 m; + tmsize_t n; + m=TIFFRawStripSize64(tif,strip); + if (m==(uint64)(-1)) + n=(tmsize_t)(-1); + else + { + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + } + return(n); +} + +/* + * Compute the # bytes in a (row-aligned) strip. + * + * Note that if RowsPerStrip is larger than the + * recorded ImageLength, then the strip size is + * truncated to reflect the actual space required + * to hold the strip. + */ +uint64 +TIFFStripSize64(TIFF* tif) +{ + TIFFDirectory* td = &tif->tif_dir; + uint32 rps = td->td_rowsperstrip; + if (rps > td->td_imagelength) + rps = td->td_imagelength; + return (TIFFVStripSize64(tif, rps)); +} +tmsize_t +TIFFStripSize(TIFF* tif) +{ + static const char module[] = "TIFFStripSize"; + uint64 m; + tmsize_t n; + m=TIFFStripSize64(tif); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + return(n); +} + +/* + * Compute a default strip size based on the image + * characteristics and a requested value. If the + * request is <1 then we choose a strip size according + * to certain heuristics. + */ +uint32 +TIFFDefaultStripSize(TIFF* tif, uint32 request) +{ + return (*tif->tif_defstripsize)(tif, request); +} + +uint32 +_TIFFDefaultStripSize(TIFF* tif, uint32 s) +{ + if ((int32) s < 1) { + /* + * If RowsPerStrip is unspecified, try to break the + * image up into strips that are approximately + * STRIP_SIZE_DEFAULT bytes long. + */ + uint64 scanlinesize; + uint64 rows; + scanlinesize=TIFFScanlineSize64(tif); + if (scanlinesize==0) + scanlinesize=1; + rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize; + if (rows==0) + rows=1; + else if (rows>0xFFFFFFFF) + rows=0xFFFFFFFF; + s=(uint32)rows; + } + return (s); +} + +/* + * Return the number of bytes to read/write in a call to + * one of the scanline-oriented i/o routines. Note that + * this number may be 1/samples-per-pixel if data is + * stored as separate planes. + * The ScanlineSize in case of YCbCrSubsampling is defined as the + * strip size divided by the strip height, i.e. the size of a pack of vertical + * subsampling lines divided by vertical subsampling. It should thus make + * sense when multiplied by a multiple of vertical subsampling. + */ +uint64 +TIFFScanlineSize64(TIFF* tif) +{ + static const char module[] = "TIFFScanlineSize64"; + TIFFDirectory *td = &tif->tif_dir; + uint64 scanline_size; + if (td->td_planarconfig==PLANARCONFIG_CONTIG) + { + if ((td->td_photometric==PHOTOMETRIC_YCBCR)&& + (td->td_samplesperpixel==3)&& + (!isUpSampled(tif))) + { + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint64 samplingrow_samples; + uint64 samplingrow_size; + if(td->td_samplesperpixel!=3) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid td_samplesperpixel value"); + return 0; + } + TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING, + ycbcrsubsampling+0, + ycbcrsubsampling+1); + if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) || + ((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4))) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling"); + return 0; + } + samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]); + samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8); + scanline_size = (samplingrow_size/ycbcrsubsampling[1]); + } + else + { + uint64 scanline_samples; + scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module); + scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8); + } + } + else + scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,td->td_imagewidth,td->td_bitspersample,module),8); + return(scanline_size); +} +tmsize_t +TIFFScanlineSize(TIFF* tif) +{ + static const char module[] = "TIFFScanlineSize"; + uint64 m; + tmsize_t n; + m=TIFFScanlineSize64(tif); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow"); + n=0; + } + return(n); +} + +/* + * Return the number of bytes required to store a complete + * decoded and packed raster scanline (as opposed to the + * I/O size returned by TIFFScanlineSize which may be less + * if data is store as separate planes). + */ +uint64 +TIFFRasterScanlineSize64(TIFF* tif) +{ + static const char module[] = "TIFFRasterScanlineSize64"; + TIFFDirectory *td = &tif->tif_dir; + uint64 scanline; + + scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module); + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module); + return (TIFFhowmany8_64(scanline)); + } else + return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline), + td->td_samplesperpixel, module)); +} +tmsize_t +TIFFRasterScanlineSize(TIFF* tif) +{ + static const char module[] = "TIFFRasterScanlineSize"; + uint64 m; + tmsize_t n; + m=TIFFRasterScanlineSize64(tif); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow"); + n=0; + } + return(n); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_swab.c b/libs/tiff-4.0.2/libtiff/tif_swab.c similarity index 74% rename from libs/tiff-3.8.2/libtiff/tif_swab.c rename to libs/tiff-4.0.2/libtiff/tif_swab.c index 97cc88825c..f37e33f1c9 100644 --- a/libs/tiff-3.8.2/libtiff/tif_swab.c +++ b/libs/tiff-4.0.2/libtiff/tif_swab.c @@ -1,4 +1,4 @@ -/* $Id: tif_swab.c,v 1.4 2005/04/13 14:06:21 dron Exp $ */ +/* $Id: tif_swab.c,v 1.13 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -37,7 +37,7 @@ TIFFSwabShort(uint16* wp) { register unsigned char* cp = (unsigned char*) wp; unsigned char t; - + assert(sizeof(uint16)==2); t = cp[1]; cp[1] = cp[0]; cp[0] = t; } #endif @@ -48,19 +48,33 @@ TIFFSwabLong(uint32* lp) { register unsigned char* cp = (unsigned char*) lp; unsigned char t; - + assert(sizeof(uint32)==4); t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } #endif +#ifndef TIFFSwabLong8 +void +TIFFSwabLong8(uint64* lp) +{ + register unsigned char* cp = (unsigned char*) lp; + unsigned char t; + assert(sizeof(uint64)==8); + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; +} +#endif + #ifndef TIFFSwabArrayOfShort void -TIFFSwabArrayOfShort(uint16* wp, register unsigned long n) +TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) { register unsigned char* cp; register unsigned char t; - + assert(sizeof(uint16)==2); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char*) wp; @@ -72,7 +86,7 @@ TIFFSwabArrayOfShort(uint16* wp, register unsigned long n) #ifndef TIFFSwabArrayOfTriples void -TIFFSwabArrayOfTriples(uint8* tp, unsigned long n) +TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) { unsigned char* cp; unsigned char t; @@ -88,11 +102,11 @@ TIFFSwabArrayOfTriples(uint8* tp, unsigned long n) #ifndef TIFFSwabArrayOfLong void -TIFFSwabArrayOfLong(register uint32* lp, register unsigned long n) +TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) { register unsigned char *cp; register unsigned char t; - + assert(sizeof(uint32)==4); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; @@ -103,30 +117,84 @@ TIFFSwabArrayOfLong(register uint32* lp, register unsigned long n) } #endif +#ifndef TIFFSwabArrayOfLong8 +void +TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n) +{ + register unsigned char *cp; + register unsigned char t; + assert(sizeof(uint64)==8); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)lp; + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; + lp++; + } +} +#endif + +#ifndef TIFFSwabFloat +void +TIFFSwabFloat(float* fp) +{ + register unsigned char* cp = (unsigned char*) fp; + unsigned char t; + assert(sizeof(float)==4); + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; +} +#endif + +#ifndef TIFFSwabArrayOfFloat +void +TIFFSwabArrayOfFloat(register float* fp, tmsize_t n) +{ + register unsigned char *cp; + register unsigned char t; + assert(sizeof(float)==4); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)fp; + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; + fp++; + } +} +#endif + #ifndef TIFFSwabDouble void TIFFSwabDouble(double *dp) { - register uint32* lp = (uint32*) dp; - uint32 t; - - TIFFSwabArrayOfLong(lp, 2); - t = lp[0]; lp[0] = lp[1]; lp[1] = t; + register unsigned char* cp = (unsigned char*) dp; + unsigned char t; + assert(sizeof(double)==8); + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; } #endif #ifndef TIFFSwabArrayOfDouble void -TIFFSwabArrayOfDouble(double* dp, register unsigned long n) +TIFFSwabArrayOfDouble(double* dp, tmsize_t n) { - register uint32* lp = (uint32*) dp; - register uint32 t; - - TIFFSwabArrayOfLong(lp, n + n); - while (n-- > 0) { - t = lp[0]; lp[0] = lp[1]; lp[1] = t; - lp += 2; - } + register unsigned char *cp; + register unsigned char t; + assert(sizeof(double)==8); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)dp; + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; + dp++; + } } #endif @@ -215,7 +283,7 @@ TIFFGetBitRevTable(int reversed) } void -TIFFReverseBits(register unsigned char* cp, register unsigned long n) +TIFFReverseBits(uint8* cp, tmsize_t n) { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; @@ -233,3 +301,10 @@ TIFFReverseBits(register unsigned char* cp, register unsigned long n) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_thunder.c b/libs/tiff-4.0.2/libtiff/tif_thunder.c similarity index 65% rename from libs/tiff-3.8.2/libtiff/tif_thunder.c rename to libs/tiff-4.0.2/libtiff/tif_thunder.c index 94496eccb1..390891c98b 100644 --- a/libs/tiff-3.8.2/libtiff/tif_thunder.c +++ b/libs/tiff-4.0.2/libtiff/tif_thunder.c @@ -1,4 +1,4 @@ -/* $Id: tif_thunder.c,v 1.5 2005/12/21 12:23:13 joris Exp $ */ +/* $Id: tif_thunder.c,v 1.12 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -25,6 +25,7 @@ */ #include "tiffiop.h" +#include #ifdef THUNDER_SUPPORT /* * TIFF Library. @@ -55,21 +56,42 @@ static const int twobitdeltas[4] = { 0, 1, 0, -1 }; static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; -#define SETPIXEL(op, v) { \ - lastpixel = (v) & 0xf; \ - if (npixels++ & 1) \ - *op++ |= lastpixel; \ - else \ - op[0] = (tidataval_t) (lastpixel << 4); \ +#define SETPIXEL(op, v) { \ + lastpixel = (v) & 0xf; \ + if ( npixels < maxpixels ) \ + { \ + if (npixels++ & 1) \ + *op++ |= lastpixel; \ + else \ + op[0] = (uint8) (lastpixel << 4); \ + } \ } static int -ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) +ThunderSetupDecode(TIFF* tif) { + static const char module[] = "ThunderSetupDecode"; + + if( tif->tif_dir.td_bitspersample != 4 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.", + (int) tif->tif_dir.td_bitspersample ); + return 0; + } + + + return (1); +} + +static int +ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) +{ + static const char module[] = "ThunderDecode"; register unsigned char *bp; - register tsize_t cc; + register tmsize_t cc; unsigned int lastpixel; - tsize_t npixels; + tmsize_t npixels; bp = (unsigned char *)tif->tif_rawcp; cc = tif->tif_rawcc; @@ -93,7 +115,7 @@ ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) npixels += n; if (npixels < maxpixels) { for (; n > 0; n -= 2) - *op++ = (tidataval_t) lastpixel; + *op++ = (uint8) lastpixel; } if (n == -1) *--op &= 0xf0; @@ -118,25 +140,43 @@ ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) break; } } - tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; if (npixels != maxpixels) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "ThunderDecode: %s data at scanline %ld (%lu != %lu)", - npixels < maxpixels ? "Not enough" : "Too much", - (long) tif->tif_row, (long) npixels, (long) maxpixels); +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "%s data at scanline %lu (%I64u != %I64u)", + npixels < maxpixels ? "Not enough" : "Too much", + (unsigned long) tif->tif_row, + (unsigned __int64) npixels, + (unsigned __int64) maxpixels); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "%s data at scanline %lu (%llu != %llu)", + npixels < maxpixels ? "Not enough" : "Too much", + (unsigned long) tif->tif_row, + (unsigned long long) npixels, + (unsigned long long) maxpixels); +#endif return (0); } - return (1); + + return (1); } static int -ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - tidata_t row = buf; + static const char module[] = "ThunderDecodeRow"; + uint8* row = buf; (void) s; - while ((long)occ > 0) { + if (occ % tif->tif_scanlinesize) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (0); + } + while (occ > 0) { if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) return (0); occ -= tif->tif_scanlinesize; @@ -149,10 +189,19 @@ int TIFFInitThunderScan(TIFF* tif, int scheme) { (void) scheme; + + tif->tif_setupdecode = ThunderSetupDecode; tif->tif_decoderow = ThunderDecodeRow; - tif->tif_decodestrip = ThunderDecodeRow; + tif->tif_decodestrip = ThunderDecodeRow; return (1); } #endif /* THUNDER_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_tile.c b/libs/tiff-4.0.2/libtiff/tif_tile.c similarity index 59% rename from libs/tiff-3.8.2/libtiff/tif_tile.c rename to libs/tiff-4.0.2/libtiff/tif_tile.c index 454fe5cd24..0ff7e85352 100644 --- a/libs/tiff-3.8.2/libtiff/tif_tile.c +++ b/libs/tiff-4.0.2/libtiff/tif_tile.c @@ -1,4 +1,4 @@ -/* $Id: tif_tile.c,v 1.12 2006/02/09 16:15:43 dron Exp $ */ +/* $Id: tif_tile.c,v 1.23 2012-06-06 05:33:55 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -31,47 +31,17 @@ */ #include "tiffiop.h" -static uint32 -summarize(TIFF* tif, size_t summand1, size_t summand2, const char* where) -{ - /* - * XXX: We are using casting to uint32 here, because sizeof(size_t) - * may be larger than sizeof(uint32) on 64-bit architectures. - */ - uint32 bytes = summand1 + summand2; - - if (bytes - summand1 != summand2) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - -static uint32 -multiply(TIFF* tif, size_t nmemb, size_t elem_size, const char* where) -{ - uint32 bytes = nmemb * elem_size; - - if (elem_size && bytes / elem_size != nmemb) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); - bytes = 0; - } - - return (bytes); -} - /* * Compute which tile an (x,y,z,s) value is in. */ -ttile_t -TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) +uint32 +TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; - ttile_t tile = 1; + uint32 tile = 1; if (td->td_imagedepth == 1) z = 0; @@ -82,9 +52,9 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) if (dz == (uint32) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { - uint32 xpt = TIFFhowmany(td->td_imagewidth, dx); - uint32 ypt = TIFFhowmany(td->td_imagelength, dy); - uint32 zpt = TIFFhowmany(td->td_imagedepth, dz); + uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx); + uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy); + uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + @@ -102,7 +72,7 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) * against the image bounds. */ int -TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) +TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) { TIFFDirectory *td = &tif->tif_dir; @@ -141,14 +111,14 @@ TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) /* * Compute how many tiles are in an image. */ -ttile_t +uint32 TIFFNumberOfTiles(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; - ttile_t ntiles; + uint32 ntiles; if (dx == (uint32) -1) dx = td->td_imagewidth; @@ -157,50 +127,66 @@ TIFFNumberOfTiles(TIFF* tif) if (dz == (uint32) -1) dz = td->td_imagedepth; ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : - multiply(tif, multiply(tif, TIFFhowmany(td->td_imagewidth, dx), - TIFFhowmany(td->td_imagelength, dy), - "TIFFNumberOfTiles"), - TIFFhowmany(td->td_imagedepth, dz), "TIFFNumberOfTiles"); + _TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx), + TIFFhowmany_32(td->td_imagelength, dy), + "TIFFNumberOfTiles"), + TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles"); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - ntiles = multiply(tif, ntiles, td->td_samplesperpixel, - "TIFFNumberOfTiles"); + ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel, + "TIFFNumberOfTiles"); return (ntiles); } /* * Compute the # bytes in each row of a tile. */ -tsize_t -TIFFTileRowSize(TIFF* tif) +uint64 +TIFFTileRowSize64(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - tsize_t rowsize; - + uint64 rowsize; + if (td->td_tilelength == 0 || td->td_tilewidth == 0) - return ((tsize_t) 0); - rowsize = multiply(tif, td->td_bitspersample, td->td_tilewidth, - "TIFFTileRowSize"); + return (0); + rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth, + "TIFFTileRowSize"); if (td->td_planarconfig == PLANARCONFIG_CONTIG) - rowsize = multiply(tif, rowsize, td->td_samplesperpixel, - "TIFFTileRowSize"); - return ((tsize_t) TIFFhowmany8(rowsize)); + rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel, + "TIFFTileRowSize"); + return (TIFFhowmany8_64(rowsize)); +} +tmsize_t +TIFFTileRowSize(TIFF* tif) +{ + static const char module[] = "TIFFTileRowSize"; + uint64 m; + tmsize_t n; + m=TIFFTileRowSize64(tif); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + return(n); } /* * Compute the # bytes in a variable length, row-aligned tile. */ -tsize_t -TIFFVTileSize(TIFF* tif, uint32 nrows) +uint64 +TIFFVTileSize64(TIFF* tif, uint32 nrows) { + static const char module[] = "TIFFVTileSize64"; TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize; - if (td->td_tilelength == 0 || td->td_tilewidth == 0 || td->td_tiledepth == 0) - return ((tsize_t) 0); - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { + return (0); + if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& + (td->td_photometric==PHOTOMETRIC_YCBCR)&& + (td->td_samplesperpixel==3)&& + (!isUpSampled(tif))) + { /* * Packed YCbCr data contain one Cb+Cr for every * HorizontalSampling*VerticalSampling Y values. @@ -209,38 +195,71 @@ TIFFVTileSize(TIFF* tif, uint32 nrows) * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - tsize_t w = - TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); - tsize_t rowsize = - TIFFhowmany8(multiply(tif, w, td->td_bitspersample, - "TIFFVTileSize")); - tsize_t samplingarea = - td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; - if (samplingarea == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Invalid YCbCr subsampling"); + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint32 samplingblocks_ver; + uint64 samplingrow_samples; + uint64 samplingrow_size; + TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, + ycbcrsubsampling+1); + if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) + ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4)) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling (%dx%d)", + ycbcrsubsampling[0], + ycbcrsubsampling[1] ); return 0; } - nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - tilesize = multiply(tif, nrows, rowsize, "TIFFVTileSize"); - tilesize = summarize(tif, tilesize, - multiply(tif, 2, tilesize / samplingarea, - "TIFFVTileSize"), - "TIFFVTileSize"); - } else - tilesize = multiply(tif, nrows, TIFFTileRowSize(tif), - "TIFFVTileSize"); - return ((tsize_t) - multiply(tif, tilesize, td->td_tiledepth, "TIFFVTileSize")); + samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]); + samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]); + samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module)); + return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module)); + } + else + return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module)); +} +tmsize_t +TIFFVTileSize(TIFF* tif, uint32 nrows) +{ + static const char module[] = "TIFFVTileSize"; + uint64 m; + tmsize_t n; + m=TIFFVTileSize64(tif,nrows); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + return(n); } /* * Compute the # bytes in a row-aligned tile. */ -tsize_t +uint64 +TIFFTileSize64(TIFF* tif) +{ + return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength)); +} +tmsize_t TIFFTileSize(TIFF* tif) { - return (TIFFVTileSize(tif, tif->tif_dir.td_tilelength)); + static const char module[] = "TIFFTileSize"; + uint64 m; + tmsize_t n; + m=TIFFTileSize64(tif); + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + return(n); } /* @@ -265,9 +284,16 @@ _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) *th = 256; /* roundup to a multiple of 16 per the spec */ if (*tw & 0xf) - *tw = TIFFroundup(*tw, 16); + *tw = TIFFroundup_32(*tw, 16); if (*th & 0xf) - *th = TIFFroundup(*th, 16); + *th = TIFFroundup_32(*th, 16); } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_unix.c b/libs/tiff-4.0.2/libtiff/tif_unix.c similarity index 68% rename from libs/tiff-3.8.2/libtiff/tif_unix.c rename to libs/tiff-4.0.2/libtiff/tif_unix.c index 28de5c9fe5..1387558fba 100644 --- a/libs/tiff-3.8.2/libtiff/tif_unix.c +++ b/libs/tiff-4.0.2/libtiff/tif_unix.c @@ -1,26 +1,26 @@ -/* $Id: tif_unix.c,v 1.12 2006/03/21 16:37:51 dron Exp $ */ +/* $Id: tif_unix.c,v 1.23 2012-06-01 21:40:59 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -28,12 +28,15 @@ * TIFF Library UNIX-specific Routines. These are should also work with the * Windows Common RunTime Library. */ + #include "tif_config.h" #ifdef HAVE_SYS_TYPES_H # include #endif +#include + #include #include #include @@ -52,55 +55,71 @@ #include "tiffiop.h" -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) +static tmsize_t +_tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { - return ((tsize_t) read((int) fd, buf, (size_t) size)); + size_t size_io = (size_t) size; + if ((tmsize_t) size_io != size) + { + errno=EINVAL; + return (tmsize_t) -1; + } + return ((tmsize_t) read((int) fd, buf, size_io)); } -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) +static tmsize_t +_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) { - return ((tsize_t) write((int) fd, buf, (size_t) size)); + size_t size_io = (size_t) size; + if ((tmsize_t) size_io != size) + { + errno=EINVAL; + return (tmsize_t) -1; + } + return ((tmsize_t) write((int) fd, buf, size_io)); } -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) +static uint64 +_tiffSeekProc(thandle_t fd, uint64 off, int whence) { - return ((toff_t) lseek((int) fd, (off_t) off, whence)); + off_t off_io = (off_t) off; + if ((uint64) off_io != off) + { + errno=EINVAL; + return (uint64) -1; /* this is really gross */ + } + return((uint64)lseek((int)fd,off_io,whence)); } static int _tiffCloseProc(thandle_t fd) { - return (close((int) fd)); + return(close((int)fd)); } - -static toff_t +static uint64 _tiffSizeProc(thandle_t fd) { -#ifdef _AM29K - long fsize; - return ((fsize = lseek((int) fd, 0, SEEK_END)) < 0 ? 0 : fsize); -#else struct stat sb; - return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -#endif + if (fstat((int)fd,&sb)<0) + return(0); + else + return((uint64)sb.st_size); } #ifdef HAVE_MMAP #include static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - toff_t size = _tiffSizeProc(fd); - if (size != (toff_t) -1) { - *pbase = (tdata_t) - mmap(0, size, PROT_READ, MAP_SHARED, (int) fd, 0); - if (*pbase != (tdata_t) -1) { - *psize = size; + uint64 size64 = _tiffSizeProc(fd); + tmsize_t sizem = (tmsize_t)size64; + if ((uint64)sizem==size64) { + *pbase = (void*) + mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, (int) fd, 0); + if (*pbase != (void*) -1) { + *psize = (tmsize_t)sizem; return (1); } } @@ -108,21 +127,21 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) } static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffUnmapProc(thandle_t fd, void* base, toff_t size) { (void) fd; (void) munmap(base, (off_t) size); } #else /* !HAVE_MMAP */ static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { (void) fd; (void) pbase; (void) psize; return (0); } static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffUnmapProc(thandle_t fd, void* base, toff_t size) { (void) fd; (void) base; (void) size; } @@ -154,24 +173,24 @@ TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; int m, fd; - TIFF* tif; + TIFF* tif; m = _TIFFgetMode(mode, module); if (m == -1) return ((TIFF*)0); -/* for cygwin and mingw */ +/* for cygwin and mingw */ #ifdef O_BINARY - m |= O_BINARY; -#endif - -#ifdef _AM29K - fd = open(name, m); -#else - fd = open(name, m, 0666); + m |= O_BINARY; #endif + + fd = open(name, m, 0666); if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); + if (errno > 0 && strerror(errno) != NULL ) { + TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) ); + } else { + TIFFErrorExt(0, module, "%s: Cannot open", name); + } return ((TIFF *)0); } @@ -199,11 +218,11 @@ TIFFOpenW(const wchar_t* name, const char* mode) if (m == -1) return ((TIFF*)0); -/* for cygwin and mingw */ +/* for cygwin and mingw */ #ifdef O_BINARY - m |= O_BINARY; -#endif - + m |= O_BINARY; +#endif + fd = _wopen(name, m, 0666); if (fd < 0) { TIFFErrorExt(0, module, "%s: Cannot open", name); @@ -236,37 +255,37 @@ TIFFOpenW(const wchar_t* name, const char* mode) #endif void* -_TIFFmalloc(tsize_t s) +_TIFFmalloc(tmsize_t s) { return (malloc((size_t) s)); } void -_TIFFfree(tdata_t p) +_TIFFfree(void* p) { free(p); } void* -_TIFFrealloc(tdata_t p, tsize_t s) +_TIFFrealloc(void* p, tmsize_t s) { return (realloc(p, (size_t) s)); } void -_TIFFmemset(tdata_t p, int v, tsize_t c) +_TIFFmemset(void* p, int v, tmsize_t c) { memset(p, v, (size_t) c); } void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) +_TIFFmemcpy(void* d, const void* s, tmsize_t c) { memcpy(d, s, (size_t) c); } int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) +_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) { return (memcmp(p1, p2, (size_t) c)); } @@ -291,3 +310,13 @@ unixErrorHandler(const char* module, const char* fmt, va_list ap) fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_version.c b/libs/tiff-4.0.2/libtiff/tif_version.c similarity index 91% rename from libs/tiff-3.8.2/libtiff/tif_version.c rename to libs/tiff-4.0.2/libtiff/tif_version.c index 1264b71591..f92c843d88 100644 --- a/libs/tiff-3.8.2/libtiff/tif_version.c +++ b/libs/tiff-4.0.2/libtiff/tif_version.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.2 2000/11/13 14:42:38 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.3 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1992-1997 Sam Leffler * Copyright (c) 1992-1997 Silicon Graphics, Inc. @@ -31,3 +31,10 @@ TIFFGetVersion(void) { return (TIFFVersion); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_warning.c b/libs/tiff-4.0.2/libtiff/tif_warning.c similarity index 94% rename from libs/tiff-3.8.2/libtiff/tif_warning.c rename to libs/tiff-4.0.2/libtiff/tif_warning.c index d593469d2d..423b636e6e 100644 --- a/libs/tiff-3.8.2/libtiff/tif_warning.c +++ b/libs/tiff-4.0.2/libtiff/tif_warning.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.2 2005/12/23 01:18:59 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.3 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -72,3 +72,10 @@ TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...) } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_win32.c b/libs/tiff-4.0.2/libtiff/tif_win32.c similarity index 61% rename from libs/tiff-3.8.2/libtiff/tif_win32.c rename to libs/tiff-4.0.2/libtiff/tif_win32.c index b0db116ff7..2cf1de93f2 100644 --- a/libs/tiff-3.8.2/libtiff/tif_win32.c +++ b/libs/tiff-4.0.2/libtiff/tif_win32.c @@ -1,4 +1,4 @@ -/* $Id: tif_win32.c,v 1.18 2006/02/07 11:03:29 dron Exp $ */ +/* $Id: tif_win32.c,v 1.39 2011-12-22 17:07:57 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -30,51 +30,93 @@ */ #include "tiffiop.h" -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) +#include + +static tmsize_t +_tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { - DWORD dwSizeRead; - if (!ReadFile(fd, buf, size, &dwSizeRead, NULL)) - return(0); - return ((tsize_t) dwSizeRead); + /* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes + * 32bit sizes, so we loop through the data in suitable 32bit sized + * chunks */ + uint8* ma; + uint64 mb; + DWORD n; + DWORD o; + tmsize_t p; + ma=(uint8*)buf; + mb=size; + p=0; + while (mb>0) + { + n=0x80000000UL; + if ((uint64)n>mb) + n=(DWORD)mb; + if (!ReadFile(fd,(LPVOID)ma,n,&o,NULL)) + return(0); + ma+=o; + mb-=o; + p+=o; + if (o!=n) + break; + } + return(p); } -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) +static tmsize_t +_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) { - DWORD dwSizeWritten; - if (!WriteFile(fd, buf, size, &dwSizeWritten, NULL)) - return(0); - return ((tsize_t) dwSizeWritten); + /* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes + * 32bit sizes, so we loop through the data in suitable 32bit sized + * chunks */ + uint8* ma; + uint64 mb; + DWORD n; + DWORD o; + tmsize_t p; + ma=(uint8*)buf; + mb=size; + p=0; + while (mb>0) + { + n=0x80000000UL; + if ((uint64)n>mb) + n=(DWORD)mb; + if (!WriteFile(fd,(LPVOID)ma,n,&o,NULL)) + return(0); + ma+=o; + mb-=o; + p+=o; + if (o!=n) + break; + } + return(p); } -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) +static uint64 +_tiffSeekProc(thandle_t fd, uint64 off, int whence) { - DWORD dwMoveMethod, dwMoveHigh; - - /* we use this as a special code, so avoid accepting it */ - if( off == 0xFFFFFFFF ) - return 0xFFFFFFFF; - + LARGE_INTEGER offli; + DWORD dwMoveMethod; + offli.QuadPart = off; switch(whence) { - case SEEK_SET: - dwMoveMethod = FILE_BEGIN; - break; - case SEEK_CUR: - dwMoveMethod = FILE_CURRENT; - break; - case SEEK_END: - dwMoveMethod = FILE_END; - break; - default: - dwMoveMethod = FILE_BEGIN; - break; + case SEEK_SET: + dwMoveMethod = FILE_BEGIN; + break; + case SEEK_CUR: + dwMoveMethod = FILE_CURRENT; + break; + case SEEK_END: + dwMoveMethod = FILE_END; + break; + default: + dwMoveMethod = FILE_BEGIN; + break; } - dwMoveHigh = 0; - return ((toff_t)SetFilePointer(fd, (LONG) off, (PLONG)&dwMoveHigh, - dwMoveMethod)); + offli.LowPart=SetFilePointer(fd,offli.LowPart,&offli.HighPart,dwMoveMethod); + if ((offli.LowPart==INVALID_SET_FILE_POINTER)&&(GetLastError()!=NO_ERROR)) + offli.QuadPart=0; + return(offli.QuadPart); } static int @@ -83,18 +125,20 @@ _tiffCloseProc(thandle_t fd) return (CloseHandle(fd) ? 0 : -1); } -static toff_t +static uint64 _tiffSizeProc(thandle_t fd) { - return ((toff_t)GetFileSize(fd, NULL)); + ULARGE_INTEGER m; + m.LowPart=GetFileSize(fd,&m.HighPart); + return(m.QuadPart); } -#ifdef __BORLANDC__ -#pragma argsused -#endif static int -_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize) { + (void) fd; + (void) pbase; + (void) psize; return (0); } @@ -110,14 +154,20 @@ _tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) * with Visual C++ 5.0 */ static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - toff_t size; + uint64 size; + tmsize_t sizem; HANDLE hMapFile; - if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF) + size = _tiffSizeProc(fd); + sizem = (tmsize_t)size; + if ((uint64)sizem!=size) return (0); - hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL); + + /* By passing in 0 for the maximum file size, it specifies that we + create a file mapping object for the full file size. */ + hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL); if (hMapFile == NULL) return (0); *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0); @@ -128,17 +178,19 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) return(1); } -#ifdef __BORLANDC__ -#pragma argsused -#endif static void -_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size) { + (void) fd; + (void) base; + (void) size; } static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffUnmapProc(thandle_t fd, void* base, toff_t size) { + (void) fd; + (void) size; UnmapViewOfFile(base); } @@ -151,8 +203,17 @@ TIFF* TIFFFdOpen(int ifd, const char* name, const char* mode) { TIFF* tif; - BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u')); - + int fSuppressMap; + int m; + fSuppressMap=0; + for (m=0; mode[m]!=0; m++) + { + if (mode[m]=='u') + { + fSuppressMap=1; + break; + } + } tif = TIFFClientOpen(name, mode, (thandle_t)ifd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, @@ -163,6 +224,8 @@ TIFFFdOpen(int ifd, const char* name, const char* mode) return (tif); } +#ifndef _WIN32_WCE + /* * Open a TIFF file for read/writing. */ @@ -177,26 +240,15 @@ TIFFOpen(const char* name, const char* mode) m = _TIFFgetMode(mode, module); - switch(m) - { - case O_RDONLY: - dwMode = OPEN_EXISTING; - break; - case O_RDWR: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR|O_CREAT: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR|O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - case O_RDWR|O_CREAT|O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - default: - return ((TIFF*)0); + switch(m) { + case O_RDONLY: dwMode = OPEN_EXISTING; break; + case O_RDWR: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break; + case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break; + default: return ((TIFF*)0); } + fd = (thandle_t)CreateFileA(name, (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, @@ -240,7 +292,7 @@ TIFFOpenW(const wchar_t* name, const char* mode) fd = (thandle_t)CreateFileW(name, (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE), - FILE_SHARE_READ, NULL, dwMode, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, NULL); if (fd == INVALID_HANDLE_VALUE) { @@ -272,68 +324,50 @@ TIFFOpenW(const wchar_t* name, const char* mode) return tif; } -tdata_t -_TIFFmalloc(tsize_t s) +#endif /* ndef _WIN32_WCE */ + +void* +_TIFFmalloc(tmsize_t s) { - return ((tdata_t)GlobalAlloc(GMEM_FIXED, s)); + return (malloc((size_t) s)); } void -_TIFFfree(tdata_t p) +_TIFFfree(void* p) { - GlobalFree(p); - return; + free(p); } -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) +void* +_TIFFrealloc(void* p, tmsize_t s) { - void* pvTmp; - tsize_t old; - - if(p == NULL) - return ((tdata_t)GlobalAlloc(GMEM_FIXED, s)); - - old = GlobalSize(p); - - if (old>=s) { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, s); - GlobalFree(p); - } - } else { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, old); - GlobalFree(p); - } - } - return ((tdata_t)pvTmp); + return (realloc(p, (size_t) s)); } void -_TIFFmemset(void* p, int v, tsize_t c) +_TIFFmemset(void* p, int v, tmsize_t c) { - FillMemory(p, c, (BYTE)v); + memset(p, v, (size_t) c); } void -_TIFFmemcpy(void* d, const tdata_t s, tsize_t c) +_TIFFmemcpy(void* d, const void* s, tmsize_t c) { - CopyMemory(d, s, c); + memcpy(d, s, (size_t) c); } int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) +_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) { - register const BYTE *pb1 = (const BYTE *) p1; - register const BYTE *pb2 = (const BYTE *) p2; - register DWORD dwTmp = c; - register int iTmp; - for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (int)*pb1++ - (int)*pb2++) - ; - return (iTmp); + return (memcmp(p1, p2, (size_t) c)); } +#ifndef _WIN32_WCE + +#if (_MSC_VER < 1500) +# define vsnprintf _vsnprintf +#endif + static void Win32WarningHandler(const char* module, const char* fmt, va_list ap) { @@ -343,14 +377,17 @@ Win32WarningHandler(const char* module, const char* fmt, va_list ap) LPCTSTR szTitleText = "%s Warning"; LPCTSTR szDefaultModule = "LIBTIFF"; LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module; - if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) + - strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL) + SIZE_T nBufSize = (strlen(szTmpModule) + + strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char); + + if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL) return; sprintf(szTitle, szTitleText, szTmpModule); szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char); - vsprintf(szTmp, fmt, ap); + vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap); MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION); LocalFree(szTitle); + return; #else if (module != NULL) @@ -371,12 +408,14 @@ Win32ErrorHandler(const char* module, const char* fmt, va_list ap) LPCTSTR szTitleText = "%s Error"; LPCTSTR szDefaultModule = "LIBTIFF"; LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module; - if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) + - strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL) + SIZE_T nBufSize = (strlen(szTmpModule) + + strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char); + + if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL) return; sprintf(szTitle, szTitleText, szTmpModule); szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char); - vsprintf(szTmp, fmt, ap); + vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap); MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION); LocalFree(szTitle); return; @@ -389,4 +428,13 @@ Win32ErrorHandler(const char* module, const char* fmt, va_list ap) } TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler; +#endif /* ndef _WIN32_WCE */ + /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_write.c b/libs/tiff-4.0.2/libtiff/tif_write.c similarity index 65% rename from libs/tiff-3.8.2/libtiff/tif_write.c rename to libs/tiff-4.0.2/libtiff/tif_write.c index e34cfabbd6..eaa1f8143c 100644 --- a/libs/tiff-3.8.2/libtiff/tif_write.c +++ b/libs/tiff-4.0.2/libtiff/tif_write.c @@ -1,26 +1,26 @@ -/* $Id: tif_write.c,v 1.21 2006/02/27 14:29:20 dron Exp $ */ +/* $Id: tif_write.c,v 1.36 2011-02-18 20:53:04 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,26 +32,26 @@ #include "tiffiop.h" #include -#define STRIPINCR 20 /* expansion factor on strip array */ +#define STRIPINCR 20 /* expansion factor on strip array */ -#define WRITECHECKSTRIPS(tif, module) \ +#define WRITECHECKSTRIPS(tif, module) \ (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module)) -#define WRITECHECKTILES(tif, module) \ +#define WRITECHECKTILES(tif, module) \ (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module)) -#define BUFFERCHECK(tif) \ +#define BUFFERCHECK(tif) \ ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ - TIFFWriteBufferSetup((tif), NULL, (tsize_t) -1)) + TIFFWriteBufferSetup((tif), NULL, (tmsize_t) -1)) -static int TIFFGrowStrips(TIFF*, int, const char*); -static int TIFFAppendToStrip(TIFF*, tstrip_t, tidata_t, tsize_t); +static int TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module); +static int TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc); int -TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) +TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) { static const char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int status, imagegrew = 0; - tstrip_t strip; + uint32 strip; if (!WRITECHECKSTRIPS(tif, module)) return (-1); @@ -62,6 +62,8 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (!BUFFERCHECK(tif)) return (-1); + tif->tif_flags |= TIFF_BUF4WRITE; /* not strictly sure this is right*/ + td = &tif->tif_dir; /* * Extend image length if needed @@ -69,8 +71,8 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (row >= td->td_imagelength) { /* extend image */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not change \"ImageLength\" when using separate planes"); + TIFFErrorExt(tif->tif_clientdata, module, + "Can not change \"ImageLength\" when using separate planes"); return (-1); } td->td_imagelength = row+1; @@ -81,9 +83,9 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%d: Sample out of range, max %d", - sample, td->td_samplesperpixel); + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Sample out of range, max %lu", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); return (-1); } strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; @@ -112,7 +114,7 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (strip >= td->td_stripsperimage && imagegrew) td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); + TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip); tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { @@ -161,10 +163,10 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) tif->tif_row = row; } - /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) buf, tif->tif_scanlinesize ); + /* swab if needed - note that source buffer will be altered */ + tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize ); - status = (*tif->tif_encoderow)(tif, (tidata_t) buf, + status = (*tif->tif_encoderow)(tif, (uint8*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ @@ -178,15 +180,15 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) * * NB: Image length must be setup before writing. */ -tsize_t -TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) +tmsize_t +TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - tsample_t sample; + uint16 sample; if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); + return ((tmsize_t) -1); /* * Check strip array to make sure there's space. * We don't support dynamically growing files that @@ -198,14 +200,14 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) */ if (strip >= td->td_nstrips) { if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, + "Can not grow image by strips when using separate planes"); + return ((tmsize_t) -1); } if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); + return ((tmsize_t) -1); td->td_stripsperimage = - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip); + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip); } /* * Handle delayed allocation of data buffer. This @@ -213,45 +215,46 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) * info. */ if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); + return ((tmsize_t) -1); + + tif->tif_flags |= TIFF_BUF4WRITE; tif->tif_curstrip = strip; + tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); + return ((tmsize_t) -1); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; + tif->tif_rawcp = tif->tif_rawdata; - if( td->td_stripbytecount[strip] > 0 ) + if( td->td_stripbytecount[strip] > 0 ) { - /* if we are writing over existing tiles, zero length. */ - td->td_stripbytecount[strip] = 0; - - /* this forces TIFFAppendToStrip() to do a seek */ + /* Force TIFFAppendToStrip() to consider placing data at end + of file. */ tif->tif_curoff = 0; } tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(strip / td->td_stripsperimage); + sample = (uint16)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); + return ((tmsize_t) -1); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) data, cc ); + tif->tif_postdecode( tif, (uint8*) data, cc ); - if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); + if (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample)) + return (0); if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); + return ((tmsize_t) -1); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); + return ((tmsize_t) -1); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); @@ -262,14 +265,14 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) * * NB: Image length must be setup before writing. */ -tsize_t -TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) +tmsize_t +TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawStrip"; TIFFDirectory *td = &tif->tif_dir; if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); + return ((tmsize_t) -1); /* * Check strip array to make sure there's space. * We don't support dynamically growing files that @@ -281,9 +284,9 @@ TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) */ if (strip >= td->td_nstrips) { if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, + "Can not grow image by strips when using separate planes"); + return ((tmsize_t) -1); } /* * Watch out for a growing image. The value of @@ -292,26 +295,25 @@ TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) */ if (strip >= td->td_stripsperimage) td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); + TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip); if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); + return ((tmsize_t) -1); } tif->tif_curstrip = strip; tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (tidata_t) data, cc) ? - cc : (tsize_t) -1); + return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ? + cc : (tmsize_t) -1); } /* * Write and compress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ -tsize_t -TIFFWriteTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) +tmsize_t +TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) { if (!TIFFCheckTile(tif, x, y, z, s)) - return (-1); + return ((tmsize_t)(-1)); /* * NB: A tile size of -1 is used instead of tif_tilesize knowing * that TIFFWriteEncodedTile will clamp this to the tile size. @@ -319,7 +321,7 @@ TIFFWriteTile(TIFF* tif, * after the output buffer is setup in TIFFWriteBufferSetup. */ return (TIFFWriteEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); + TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1))); } /* @@ -334,20 +336,20 @@ TIFFWriteTile(TIFF* tif, * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ -tsize_t -TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) +tmsize_t +TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; - tsample_t sample; + uint16 sample; if (!WRITECHECKTILES(tif, module)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); td = &tif->tif_dir; if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (unsigned long) tile, (unsigned long) td->td_nstrips); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, "Tile %lu out of range, max %lu", + (unsigned long) tile, (unsigned long) td->td_nstrips); + return ((tmsize_t)(-1)); } /* * Handle delayed allocation of data buffer. This @@ -355,18 +357,18 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) * directory information). */ if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); + + tif->tif_flags |= TIFF_BUF4WRITE; tif->tif_curtile = tile; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; - if( td->td_stripbytecount[tile] > 0 ) + if( td->td_stripbytecount[tile] > 0 ) { - /* if we are writing over existing tiles, zero length. */ - td->td_stripbytecount[tile] = 0; - - /* this forces TIFFAppendToStrip() to do a seek */ + /* Force TIFFAppendToStrip() to consider placing data at end + of file. */ tif->tif_curoff = 0; } @@ -374,20 +376,20 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) * Compute tiles per row & per column to compute * current row and column */ - tif->tif_row = (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) + tif->tif_row = (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) * td->td_tilelength; - tif->tif_col = (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) + tif->tif_col = (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) * td->td_tilewidth; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(tile/td->td_stripsperimage); + sample = (uint16)(tile/td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); /* * Clamp write amount to the tile size. This is mostly * done so that callers can pass in some large number @@ -397,18 +399,18 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) cc = tif->tif_tilesize; /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) data, cc ); + tif->tif_postdecode( tif, (uint8*) data, cc ); - if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); + if (!(*tif->tif_encodetile)(tif, (uint8*) data, cc, sample)) + return (0); if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((unsigned char *)tif->tif_rawdata, tif->tif_rawcc); + TIFFReverseBits((uint8*)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); @@ -423,21 +425,21 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ -tsize_t -TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) +tmsize_t +TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawTile"; if (!WRITECHECKTILES(tif, module)) - return ((tsize_t) -1); + return ((tmsize_t)(-1)); if (tile >= tif->tif_dir.td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (unsigned long) tile, + TIFFErrorExt(tif->tif_clientdata, module, "Tile %lu out of range, max %lu", + (unsigned long) tile, (unsigned long) tif->tif_dir.td_nstrips); - return ((tsize_t) -1); + return ((tmsize_t)(-1)); } - return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ? - cc : (tsize_t) -1); + return (TIFFAppendToStrip(tif, tile, (uint8*) data, cc) ? + cc : (tmsize_t)(-1)); } #define isUnspecified(tif, f) \ @@ -459,18 +461,18 @@ TIFFSetupStrips(TIFF* tif) td->td_nstrips = td->td_stripsperimage; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - td->td_stripbytecount = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); + td->td_stripoffset = (uint64 *) + _TIFFmalloc(td->td_nstrips * sizeof (uint64)); + td->td_stripbytecount = (uint64 *) + _TIFFmalloc(td->td_nstrips * sizeof (uint64)); if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) return (0); /* * Place data at the end-of-file * (by setting offsets to zero). */ - _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint32)); + _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint64)); + _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint64)); TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); @@ -487,16 +489,17 @@ int TIFFWriteCheck(TIFF* tif, int tiles, const char* module) { if (tif->tif_mode == O_RDONLY) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: File not open for writing", - tif->tif_name); + TIFFErrorExt(tif->tif_clientdata, module, "File not open for writing"); return (0); } if (tiles ^ isTiled(tif)) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ? + TIFFErrorExt(tif->tif_clientdata, module, tiles ? "Can not write tiles to a stripped image" : "Can not write scanlines to a tiled image"); return (0); } + + _TIFFFillStriles( tif ); /* * On the first write verify all the required information @@ -510,8 +513,7 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module) */ if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Must set \"ImageWidth\" before writing data", - tif->tif_name); + "Must set \"ImageWidth\" before writing data"); return (0); } if (tif->tif_dir.td_samplesperpixel == 1) { @@ -521,23 +523,32 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module) * because this field is used in other parts of library even * in the single band case. */ - tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG; + if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) + tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG; } else { if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Must set \"PlanarConfiguration\" before writing data", - tif->tif_name); + "Must set \"PlanarConfiguration\" before writing data"); return (0); } } if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { tif->tif_dir.td_nstrips = 0; - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for %s arrays", - tif->tif_name, isTiled(tif) ? "tile" : "strip"); + TIFFErrorExt(tif->tif_clientdata, module, "No space for %s arrays", + isTiled(tif) ? "tile" : "strip"); return (0); } - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; + if (isTiled(tif)) + { + tif->tif_tilesize = TIFFTileSize(tif); + if (tif->tif_tilesize == 0) + return (0); + } + else + tif->tif_tilesize = (tmsize_t)(-1); tif->tif_scanlinesize = TIFFScanlineSize(tif); + if (tif->tif_scanlinesize == 0) + return (0); tif->tif_flags |= TIFF_BEENWRITING; return (1); } @@ -546,7 +557,7 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module) * Setup the raw data buffer used for encoding. */ int -TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) +TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) { static const char module[] = "TIFFWriteBufferSetup"; @@ -557,7 +568,7 @@ TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) } tif->tif_rawdata = NULL; } - if (size == (tsize_t) -1) { + if (size == (tmsize_t)(-1)) { size = (isTiled(tif) ? tif->tif_tilesize : TIFFStripSize(tif)); /* @@ -570,14 +581,13 @@ TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) if (bp == NULL) { bp = _TIFFmalloc(size); if (bp == NULL) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for output buffer", - tif->tif_name); + TIFFErrorExt(tif->tif_clientdata, module, "No space for output buffer"); return (0); } tif->tif_flags |= TIFF_MYBUFFER; } else tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (tidata_t) bp; + tif->tif_rawdata = (uint8*) bp; tif->tif_rawdatasize = size; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; @@ -589,33 +599,35 @@ TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) * Grow the strip data structures by delta strips. */ static int -TIFFGrowStrips(TIFF* tif, int delta, const char* module) +TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) { - TIFFDirectory *td = &tif->tif_dir; - uint32 *new_stripoffset, *new_stripbytecount; + TIFFDirectory *td = &tif->tif_dir; + uint64* new_stripoffset; + uint64* new_stripbytecount; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint32*)_TIFFrealloc(td->td_stripoffset, - (td->td_nstrips + delta) * sizeof (uint32)); - new_stripbytecount = (uint32*)_TIFFrealloc(td->td_stripbytecount, - (td->td_nstrips + delta) * sizeof (uint32)); + new_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset, + (td->td_nstrips + delta) * sizeof (uint64)); + new_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount, + (td->td_nstrips + delta) * sizeof (uint64)); if (new_stripoffset == NULL || new_stripbytecount == NULL) { if (new_stripoffset) _TIFFfree(new_stripoffset); if (new_stripbytecount) _TIFFfree(new_stripbytecount); td->td_nstrips = 0; - TIFFErrorExt(tif->tif_clientdata, module, "%s: No space to expand strip arrays", - tif->tif_name); + TIFFErrorExt(tif->tif_clientdata, module, "No space to expand strip arrays"); return (0); } td->td_stripoffset = new_stripoffset; td->td_stripbytecount = new_stripbytecount; _TIFFmemset(td->td_stripoffset + td->td_nstrips, - 0, delta*sizeof (uint32)); + 0, delta*sizeof (uint64)); _TIFFmemset(td->td_stripbytecount + td->td_nstrips, - 0, delta*sizeof (uint32)); + 0, delta*sizeof (uint64)); td->td_nstrips += delta; + tif->tif_flags |= TIFF_DIRTYDIRECT; + return (1); } @@ -623,67 +635,72 @@ TIFFGrowStrips(TIFF* tif, int delta, const char* module) * Append the data to the specified strip. */ static int -TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) +TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) { - TIFFDirectory *td = &tif->tif_dir; static const char module[] = "TIFFAppendToStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint64 m; + int64 old_byte_count = -1; if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { - /* - * No current offset, set the current strip. - */ - assert(td->td_nstrips > 0); - if (td->td_stripoffset[strip] != 0) { - /* - * Prevent overlapping of the data chunks. We need - * this to enable in place updating of the compressed - * images. Larger blocks will be moved at the end of - * the file without any optimization of the spare - * space, so such scheme is not too much effective. - */ - if (td->td_stripbytecountsorted) { - if (strip == td->td_nstrips - 1 - || td->td_stripoffset[strip + 1] < - td->td_stripoffset[strip] + cc) { - td->td_stripoffset[strip] = - TIFFSeekFile(tif, (toff_t)0, - SEEK_END); - } - } else { - tstrip_t i; - for (i = 0; i < td->td_nstrips; i++) { - if (td->td_stripoffset[i] > - td->td_stripoffset[strip] - && td->td_stripoffset[i] < - td->td_stripoffset[strip] + cc) { - td->td_stripoffset[strip] = - TIFFSeekFile(tif, - (toff_t)0, - SEEK_END); - } - } - } + assert(td->td_nstrips > 0); - if (!SeekOK(tif, td->td_stripoffset[strip])) { - TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at scanline %lu", - tif->tif_name, - (unsigned long)tif->tif_row); - return (0); - } - } else - td->td_stripoffset[strip] = - TIFFSeekFile(tif, (toff_t) 0, SEEK_END); - tif->tif_curoff = td->td_stripoffset[strip]; + if( td->td_stripbytecount[strip] != 0 + && td->td_stripoffset[strip] != 0 + && td->td_stripbytecount[strip] >= (uint64) cc ) + { + /* + * There is already tile data on disk, and the new tile + * data we have will fit in the same space. The only + * aspect of this that is risky is that there could be + * more data to append to this strip before we are done + * depending on how we are getting called. + */ + if (!SeekOK(tif, td->td_stripoffset[strip])) { + TIFFErrorExt(tif->tif_clientdata, module, + "Seek error at scanline %lu", + (unsigned long)tif->tif_row); + return (0); + } + } + else + { + /* + * Seek to end of file, and set that as our location to + * write this strip. + */ + td->td_stripoffset[strip] = TIFFSeekFile(tif, 0, SEEK_END); + tif->tif_flags |= TIFF_DIRTYSTRIP; + } + + tif->tif_curoff = td->td_stripoffset[strip]; + + /* + * We are starting a fresh strip/tile, so set the size to zero. + */ + old_byte_count = td->td_stripbytecount[strip]; + td->td_stripbytecount[strip] = 0; } - if (!WriteOK(tif, data, cc)) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Write error at scanline %lu", - tif->tif_name, (unsigned long) tif->tif_row); + m = tif->tif_curoff+cc; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + m = (uint32)m; + if ((mtif_curoff)||(m<(uint64)cc)) + { + TIFFErrorExt(tif->tif_clientdata, module, "Maximum TIFF file size exceeded"); return (0); } - tif->tif_curoff += cc; + if (!WriteOK(tif, data, cc)) { + TIFFErrorExt(tif->tif_clientdata, module, "Write error at scanline %lu", + (unsigned long) tif->tif_row); + return (0); + } + tif->tif_curoff = m; td->td_stripbytecount[strip] += cc; + + if( (int64) td->td_stripbytecount[strip] != old_byte_count ) + tif->tif_flags |= TIFF_DIRTYSTRIP; + return (1); } @@ -695,10 +712,10 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) int TIFFFlushData1(TIFF* tif) { - if (tif->tif_rawcc > 0) { + if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE ) { if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((unsigned char *)tif->tif_rawdata, + TIFFReverseBits((uint8*)tif->tif_rawdata, tif->tif_rawcc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, @@ -723,3 +740,10 @@ TIFFSetWriteOffset(TIFF* tif, toff_t off) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tif_zip.c b/libs/tiff-4.0.2/libtiff/tif_zip.c similarity index 55% rename from libs/tiff-3.8.2/libtiff/tif_zip.c rename to libs/tiff-4.0.2/libtiff/tif_zip.c index 0535db89c1..f5aa2a9647 100644 --- a/libs/tiff-3.8.2/libtiff/tif_zip.c +++ b/libs/tiff-4.0.2/libtiff/tif_zip.c @@ -1,4 +1,4 @@ -/* $Id: tif_zip.c,v 1.10 2006/03/16 12:38:24 dron Exp $ */ +/* $Id: tif_zip.c,v 1.31 2011-01-06 16:00:23 fwarmerdam Exp $ */ /* * Copyright (c) 1995-1997 Sam Leffler @@ -65,36 +65,51 @@ * State block for each open TIFF * file using ZIP compression/decompression. */ -typedef struct { +typedef struct { TIFFPredictorState predict; - z_stream stream; - int zipquality; /* compression level */ - int state; /* state flags */ -#define ZSTATE_INIT 0x1 /* zlib setup successfully */ + z_stream stream; + int zipquality; /* compression level */ + int state; /* state flags */ +#define ZSTATE_INIT_DECODE 0x01 +#define ZSTATE_INIT_ENCODE 0x02 - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ } ZIPState; -#define ZState(tif) ((ZIPState*) (tif)->tif_data) -#define DecoderState(tif) ZState(tif) -#define EncoderState(tif) ZState(tif) +#define ZState(tif) ((ZIPState*) (tif)->tif_data) +#define DecoderState(tif) ZState(tif) +#define EncoderState(tif) ZState(tif) -static int ZIPEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int ZIPDecode(TIFF*, tidata_t, tsize_t, tsample_t); +static int ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); + +static int +ZIPFixupTags(TIFF* tif) +{ + (void) tif; + return (1); +} static int ZIPSetupDecode(TIFF* tif) { - ZIPState* sp = DecoderState(tif); static const char module[] = "ZIPSetupDecode"; + ZIPState* sp = DecoderState(tif); assert(sp != NULL); + + /* if we were last encoding, terminate this mode */ + if (sp->state & ZSTATE_INIT_ENCODE) { + deflateEnd(&sp->stream); + sp->state = 0; + } + if (inflateInit(&sp->stream) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg); return (0); } else { - sp->state |= ZSTATE_INIT; + sp->state |= ZSTATE_INIT_DECODE; return (1); } } @@ -103,66 +118,103 @@ ZIPSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -ZIPPreDecode(TIFF* tif, tsample_t s) +ZIPPreDecode(TIFF* tif, uint16 s) { + static const char module[] = "ZIPPreDecode"; ZIPState* sp = DecoderState(tif); (void) s; assert(sp != NULL); + + if( (sp->state & ZSTATE_INIT_DECODE) == 0 ) + tif->tif_setupdecode( tif ); + sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ + sp->stream.avail_in = (uInt) tif->tif_rawcc; + if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } return (inflateReset(&sp->stream) == Z_OK); } static int -ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - ZIPState* sp = DecoderState(tif); static const char module[] = "ZIPDecode"; + ZIPState* sp = DecoderState(tif); (void) s; assert(sp != NULL); + assert(sp->state == ZSTATE_INIT_DECODE); + + sp->stream.next_in = tif->tif_rawcp; + sp->stream.avail_in = (uInt) tif->tif_rawcc; + sp->stream.next_out = op; - sp->stream.avail_out = occ; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ + sp->stream.avail_out = (uInt) occ; + if ((tmsize_t)sp->stream.avail_out != occ) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } do { int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); if (state == Z_STREAM_END) break; if (state == Z_DATA_ERROR) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Decoding error at scanline %d, %s", - tif->tif_name, tif->tif_row, sp->stream.msg); + "Decoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, sp->stream.msg); if (inflateSync(&sp->stream) != Z_OK) return (0); continue; } if (state != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg); return (0); } } while (sp->stream.avail_out > 0); if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Not enough data at scanline %d (short %d bytes)", - tif->tif_name, tif->tif_row, sp->stream.avail_out); + "Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)", + (unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out); return (0); } + + tif->tif_rawcp = sp->stream.next_in; + tif->tif_rawcc = sp->stream.avail_in; + return (1); } static int ZIPSetupEncode(TIFF* tif) { - ZIPState* sp = EncoderState(tif); static const char module[] = "ZIPSetupEncode"; + ZIPState* sp = EncoderState(tif); assert(sp != NULL); + if (sp->state & ZSTATE_INIT_DECODE) { + inflateEnd(&sp->stream); + sp->state = 0; + } + if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg); return (0); } else { - sp->state |= ZSTATE_INIT; + sp->state |= ZSTATE_INIT_ENCODE; return (1); } } @@ -171,14 +223,27 @@ ZIPSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -ZIPPreEncode(TIFF* tif, tsample_t s) +ZIPPreEncode(TIFF* tif, uint16 s) { + static const char module[] = "ZIPPreEncode"; ZIPState *sp = EncoderState(tif); (void) s; assert(sp != NULL); + if( sp->state != ZSTATE_INIT_ENCODE ) + tif->tif_setupencode( tif ); + sp->stream.next_out = tif->tif_rawdata; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ sp->stream.avail_out = tif->tif_rawdatasize; + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } return (deflateReset(&sp->stream) == Z_OK); } @@ -186,25 +251,37 @@ ZIPPreEncode(TIFF* tif, tsample_t s) * Encode a chunk of pixels. */ static int -ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - ZIPState *sp = EncoderState(tif); static const char module[] = "ZIPEncode"; + ZIPState *sp = EncoderState(tif); + + assert(sp != NULL); + assert(sp->state == ZSTATE_INIT_ENCODE); (void) s; sp->stream.next_in = bp; - sp->stream.avail_in = cc; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + apropriately even before we simplify it */ + sp->stream.avail_in = (uInt) cc; + if ((tmsize_t)sp->stream.avail_in != cc) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } do { if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: Encoder error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "Encoder error: %s", + sp->stream.msg); return (0); } if (sp->stream.avail_out == 0) { tif->tif_rawcc = tif->tif_rawdatasize; TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */ } } while (sp->stream.avail_in > 0); return (1); @@ -217,8 +294,8 @@ ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) static int ZIPPostEncode(TIFF* tif) { - ZIPState *sp = EncoderState(tif); static const char module[] = "ZIPPostEncode"; + ZIPState *sp = EncoderState(tif); int state; sp->stream.avail_in = 0; @@ -227,19 +304,18 @@ ZIPPostEncode(TIFF* tif) switch (state) { case Z_STREAM_END: case Z_OK: - if ((int)sp->stream.avail_out != (int)tif->tif_rawdatasize) - { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - break; + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) + { + tif->tif_rawcc = tif->tif_rawdatasize - sp->stream.avail_out; + TIFFFlushData1(tif); + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */ + } + break; default: - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg); + return (0); } } while (state != Z_STREAM_END); return (1); @@ -257,12 +333,12 @@ ZIPCleanup(TIFF* tif) tif->tif_tagmethods.vgetfield = sp->vgetparent; tif->tif_tagmethods.vsetfield = sp->vsetparent; - if (sp->state&ZSTATE_INIT) { - /* NB: avoid problems in the library */ - if (tif->tif_mode == O_RDONLY) - inflateEnd(&sp->stream); - else - deflateEnd(&sp->stream); + if (sp->state & ZSTATE_INIT_ENCODE) { + deflateEnd(&sp->stream); + sp->state = 0; + } else if( sp->state & ZSTATE_INIT_DECODE) { + inflateEnd(&sp->stream); + sp->state = 0; } _TIFFfree(sp); tif->tif_data = NULL; @@ -271,19 +347,19 @@ ZIPCleanup(TIFF* tif) } static int -ZIPVSetField(TIFF* tif, ttag_t tag, va_list ap) +ZIPVSetField(TIFF* tif, uint32 tag, va_list ap) { - ZIPState* sp = ZState(tif); static const char module[] = "ZIPVSetField"; + ZIPState* sp = ZState(tif); switch (tag) { case TIFFTAG_ZIPQUALITY: - sp->zipquality = va_arg(ap, int); - if (tif->tif_mode != O_RDONLY && (sp->state&ZSTATE_INIT)) { + sp->zipquality = (int) va_arg(ap, int); + if ( sp->state&ZSTATE_INIT_ENCODE ) { if (deflateParams(&sp->stream, sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) { - TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg); return (0); } } @@ -295,7 +371,7 @@ ZIPVSetField(TIFF* tif, ttag_t tag, va_list ap) } static int -ZIPVGetField(TIFF* tif, ttag_t tag, va_list ap) +ZIPVGetField(TIFF* tif, uint32 tag, va_list ap) { ZIPState* sp = ZState(tif); @@ -309,23 +385,32 @@ ZIPVGetField(TIFF* tif, ttag_t tag, va_list ap) return (1); } -static const TIFFFieldInfo zipFieldInfo[] = { - { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, - TRUE, FALSE, "" }, +static const TIFFField zipFields[] = { + { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, }; int TIFFInitZIP(TIFF* tif, int scheme) { + static const char module[] = "TIFFInitZIP"; ZIPState* sp; assert( (scheme == COMPRESSION_DEFLATE) || (scheme == COMPRESSION_ADOBE_DEFLATE)); + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging Deflate codec-specific tags failed"); + return 0; + } + /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (ZIPState)); + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (ZIPState)); if (tif->tif_data == NULL) goto bad; sp = ZState(tif); @@ -335,10 +420,8 @@ TIFFInitZIP(TIFF* tif, int scheme) sp->stream.data_type = Z_BINARY; /* - * Merge codec-specific tag information and - * override parent get/set field methods. + * Override parent get/set field methods. */ - _TIFFMergeFieldInfo(tif, zipFieldInfo, TIFFArrayCount(zipFieldInfo)); sp->vgetparent = tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_tagmethods.vsetfield; @@ -351,11 +434,12 @@ TIFFInitZIP(TIFF* tif, int scheme) /* * Install codec methods. */ + tif->tif_fixuptags = ZIPFixupTags; tif->tif_setupdecode = ZIPSetupDecode; tif->tif_predecode = ZIPPreDecode; tif->tif_decoderow = ZIPDecode; tif->tif_decodestrip = ZIPDecode; - tif->tif_decodetile = ZIPDecode; + tif->tif_decodetile = ZIPDecode; tif->tif_setupencode = ZIPSetupEncode; tif->tif_preencode = ZIPPreEncode; tif->tif_postencode = ZIPPostEncode; @@ -369,10 +453,17 @@ TIFFInitZIP(TIFF* tif, int scheme) (void) TIFFPredictorInit(tif); return (1); bad: - TIFFErrorExt(tif->tif_clientdata, "TIFFInitZIP", + TIFFErrorExt(tif->tif_clientdata, module, "No space for ZIP state block"); return (0); } #endif /* ZIP_SUPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tiff.h b/libs/tiff-4.0.2/libtiff/tiff.h similarity index 86% rename from libs/tiff-3.8.2/libtiff/tiff.h rename to libs/tiff-4.0.2/libtiff/tiff.h index 6330795b6f..5882a7cff7 100644 --- a/libs/tiff-3.8.2/libtiff/tiff.h +++ b/libs/tiff-4.0.2/libtiff/tiff.h @@ -1,4 +1,4 @@ -/* $Id: tiff.h,v 1.42 2005/12/23 15:10:45 dron Exp $ */ +/* $Id: tiff.h,v 1.67 2011-01-24 21:06:32 olivier Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -39,87 +39,75 @@ * Suite 200 * Seattle, WA 98104 * 206-622-5500 - * + * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * - * For Big TIFF design notes see the following link - * http://gdal.maptools.org/twiki/bin/view/libtiff/BigTIFFDesign + * For BigTIFF design notes see the following links + * http://www.remotesensing.org/libtiff/bigtiffdesign.html + * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ -#define TIFF_VERSION 42 -#define TIFF_BIGTIFF_VERSION 43 -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 +#define TIFF_VERSION_CLASSIC 42 +#define TIFF_VERSION_BIG 43 + +#define TIFF_BIGENDIAN 0x4d4d +#define TIFF_LITTLEENDIAN 0x4949 +#define MDI_LITTLEENDIAN 0x5045 +#define MDI_BIGENDIAN 0x4550 + /* * Intrinsic data types required by the file format: * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * strings unsigned char* + * 8-bit quantities int8/uint8 + * 16-bit quantities int16/uint16 + * 32-bit quantities int32/uint32 + * 64-bit quantities int64/uint64 + * strings unsigned char* */ -#ifndef HAVE_INT8 -typedef signed char int8; /* NB: non-ANSI compilers may not grok */ -#endif -typedef unsigned char uint8; -#ifndef HAVE_INT16 -typedef short int16; -#endif -typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ -#if SIZEOF_INT == 4 -#ifndef HAVE_INT32 -typedef int int32; -#endif -typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ -#elif SIZEOF_LONG == 4 -#ifndef HAVE_INT32 -typedef long int32; -#endif -typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ -#endif +typedef TIFF_INT8_T int8; +typedef TIFF_UINT8_T uint8; -/* For TIFFReassignTagToIgnore */ -enum TIFFIgnoreSense /* IGNORE tag table */ -{ - TIS_STORE, - TIS_EXTRACT, - TIS_EMPTY -}; +typedef TIFF_INT16_T int16; +typedef TIFF_UINT16_T uint16; + +typedef TIFF_INT32_T int32; +typedef TIFF_UINT32_T uint32; + +typedef TIFF_INT64_T int64; +typedef TIFF_UINT64_T uint64; + +/* + * Some types as promoted in a variable argument list + * We use uint16_vap rather then directly using int, because this way + * we document the type we actually want to pass through, conceptually, + * rather then confusing the issue by merely stating the type it gets + * promoted to + */ + +typedef int uint16_vap; /* * TIFF header. */ -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ -#define TIFF_MAGIC_SIZE 2 - uint16 tiff_version; /* TIFF version number */ -#define TIFF_VERSION_SIZE 2 - uint32 tiff_diroff; /* byte offset to first directory */ -#define TIFF_DIROFFSET_SIZE 4 -} TIFFHeader; +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ +} TIFFHeaderCommon; +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ + uint32 tiff_diroff; /* byte offset to first directory */ +} TIFFHeaderClassic; +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ + uint16 tiff_offsetsize; /* size of offsets, should be 8 */ + uint16 tiff_unused; /* unused word, should be 0 */ + uint64 tiff_diroff; /* byte offset to first directory */ +} TIFFHeaderBig; -/* - * TIFF Image File Directories are comprised of a table of field - * descriptors of the form shown below. The table is sorted in - * ascending order by tag. The values associated with each entry are - * disjoint and may appear anywhere in the file (so long as they are - * placed on a word boundary). - * - * If the value is 4 bytes or less, then it is placed in the offset - * field to save space. If the value is less than 4 bytes, it is - * left-justified in the offset field. - */ -typedef struct { - uint16 tdir_tag; /* see below */ - uint16 tdir_type; /* data type; see below */ - uint32 tdir_count; /* number of items; length in spec */ - uint32 tdir_offset; /* byte offset to field data */ -} TIFFDirEntry; - /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, @@ -134,21 +122,24 @@ typedef struct { * * Note: RATIONALs are the ratio of two 32-bit integer values. */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */ +typedef enum { + TIFF_NOTYPE = 0, /* placeholder */ + TIFF_BYTE = 1, /* 8-bit unsigned integer */ + TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ + TIFF_SHORT = 3, /* 16-bit unsigned integer */ + TIFF_LONG = 4, /* 32-bit unsigned integer */ + TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ + TIFF_SBYTE = 6, /* !8-bit signed integer */ + TIFF_UNDEFINED = 7, /* !8-bit untyped data */ + TIFF_SSHORT = 8, /* !16-bit signed integer */ + TIFF_SLONG = 9, /* !32-bit signed integer */ + TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ + TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ + TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ + TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ + TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ + TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ + TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* @@ -175,6 +166,8 @@ typedef enum { #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ +#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ +#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ @@ -196,6 +189,7 @@ typedef enum { #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ +#define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ @@ -327,6 +321,30 @@ typedef enum { [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ +/* Tags 400-435 are from the TIFF/FX spec */ +#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ +#define TIFFTAG_PROFILETYPE 401 /* ! */ +#define PROFILETYPE_UNSPECIFIED 0 /* ! */ +#define PROFILETYPE_G3_FAX 1 /* ! */ +#define TIFFTAG_FAXPROFILE 402 /* ! */ +#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ +#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ +#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ +#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ +#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ +#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ +#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ +#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ +#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ +#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ +#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ +#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ +#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ +#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ +#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ +#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ +#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ +#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. @@ -348,6 +366,7 @@ typedef enum { #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ +#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ @@ -414,6 +433,7 @@ typedef enum { #define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */ /* tag 34750 is a private tag registered to Adobe? */ #define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */ +#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */ /* tag 34750 is a private tag registered to Pixel Magic */ #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ #define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ @@ -576,6 +596,10 @@ typedef enum { #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ +#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ +#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ +#define PERSAMPLE_MERGED 0 /* present as a single value */ +#define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags @@ -645,3 +669,10 @@ typedef enum { #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tiffconf.h.in b/libs/tiff-4.0.2/libtiff/tiffconf.h.in similarity index 82% rename from libs/tiff-3.8.2/libtiff/tiffconf.h.in rename to libs/tiff-4.0.2/libtiff/tiffconf.h.in index 1b266e8db7..6da9c5a654 100644 --- a/libs/tiff-3.8.2/libtiff/tiffconf.h.in +++ b/libs/tiff-4.0.2/libtiff/tiffconf.h.in @@ -7,6 +7,36 @@ #ifndef _TIFFCONF_ #define _TIFFCONF_ +/* Signed 16-bit type */ +#undef TIFF_INT16_T + +/* Signed 32-bit type */ +#undef TIFF_INT32_T + +/* Signed 64-bit type */ +#undef TIFF_INT64_T + +/* Signed 8-bit type */ +#undef TIFF_INT8_T + +/* Unsigned 16-bit type */ +#undef TIFF_UINT16_T + +/* Unsigned 32-bit type */ +#undef TIFF_UINT32_T + +/* Unsigned 64-bit type */ +#undef TIFF_UINT64_T + +/* Unsigned 8-bit type */ +#undef TIFF_UINT8_T + +/* Signed size type */ +#undef TIFF_SSIZE_T + +/* Pointer difference type */ +#undef TIFF_PTRDIFF_T + /* Define to 1 if the system has the type `int16'. */ #undef HAVE_INT16 @@ -16,12 +46,6 @@ /* Define to 1 if the system has the type `int8'. */ #undef HAVE_INT8 -/* The size of a `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of a `long', as computed by sizeof. */ -#undef SIZEOF_LONG - /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the @@ -41,6 +65,9 @@ /* Support JPEG compression (requires IJG JPEG library) */ #undef JPEG_SUPPORT +/* Support JBIG compression (requires JBIG-KIT library) */ +#undef JBIG_SUPPORT + /* Support LogLuv high dynamic range encoding */ #undef LOGLUV_SUPPORT diff --git a/libs/tiff-4.0.2/libtiff/tiffconf.vc.h b/libs/tiff-4.0.2/libtiff/tiffconf.vc.h new file mode 100644 index 0000000000..680f839f1e --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tiffconf.vc.h @@ -0,0 +1,160 @@ +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +/* Define to 1 if the system has the type `int16'. */ +/* #undef HAVE_INT16 */ + +/* Define to 1 if the system has the type `int32'. */ +/* #undef HAVE_INT32 */ + +/* Define to 1 if the system has the type `int8'. */ +/* #undef HAVE_INT8 */ + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* Signed 8-bit type */ +#define TIFF_INT8_T signed char + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T unsigned char + +/* Signed 16-bit type */ +#define TIFF_INT16_T signed short + +/* Unsigned 16-bit type */ +#define TIFF_UINT16_T unsigned short + +/* Signed 32-bit type formatter */ +#define TIFF_INT32_FORMAT "%d" + +/* Signed 32-bit type */ +#define TIFF_INT32_T signed int + +/* Unsigned 32-bit type formatter */ +#define TIFF_UINT32_FORMAT "%u" + +/* Unsigned 32-bit type */ +#define TIFF_UINT32_T unsigned int + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%I64d" + +/* Signed 64-bit type */ +#define TIFF_INT64_T signed __int64 + +/* Unsigned 64-bit type formatter */ +#define TIFF_UINT64_FORMAT "%I64u" + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned __int64 + +/* Signed size type */ +#if defined(_WIN64) +#define TIFF_SSIZE_T signed __int64 +#else +#define TIFF_SSIZE_T signed int +#endif + +/* Signed size type formatter */ +#if defined(_WIN64) +#define TIFF_SSIZE_FORMAT "%I64d" +#else +#define TIFF_SSIZE_FORMAT "%ld" +#endif + +/* Pointer difference type */ +#define TIFF_PTRDIFF_T long + +/* Compatibility stuff. */ + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian + (Intel) */ +#define HOST_BIGENDIAN 0 + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Support JPEG compression (requires IJG JPEG library) */ +/* #undef JPEG_SUPPORT */ + +/* Support JBIG compression (requires JBIG-KIT library) */ +/* #undef JBIG_SUPPORT */ + +/* Support LogLuv high dynamic range encoding */ +#define LOGLUV_SUPPORT 1 + +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 + +/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation + fails with unpatched IJG JPEG library) */ +/* #undef OJPEG_SUPPORT */ + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 + +/* Support Pixar log-format algorithm (requires Zlib) */ +/* #undef PIXARLOG_SUPPORT */ + +/* Support ThunderScan 4-bit RLE algorithm */ +#define THUNDER_SUPPORT 1 + +/* Support Deflate compression */ +/* #undef ZIP_SUPPORT */ + +/* Support strip chopping (whether or not to convert single-strip uncompressed + images to mutiple strips of ~8Kb to reduce memory usage) */ +#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP + +/* Enable SubIFD tag (330) support */ +#define SUBIFD_SUPPORT 1 + +/* Treat extra sample as alpha (default enabled). The RGBA interface will + treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many + packages produce RGBA files but don't mark the alpha properly. */ +#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 + +/* Support MS MDI magic number files as TIFF */ +/* #undef MDI_SUPPORT */ + +/* + * Feature support definitions. + * XXX: These macros are obsoleted. Don't use them in your apps! + * Macros stays here for backward compatibility and should be always defined. + */ +#define COLORIMETRY_SUPPORT +#define YCBCR_SUPPORT +#define CMYK_SUPPORT +#define ICC_SUPPORT +#define PHOTOSHOP_SUPPORT +#define IPTC_SUPPORT + +#endif /* _TIFFCONF_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tiffconf.h.vc b/libs/tiff-4.0.2/libtiff/tiffconf.wince.h similarity index 80% rename from libs/tiff-3.8.2/libtiff/tiffconf.h.vc rename to libs/tiff-4.0.2/libtiff/tiffconf.wince.h index 18c0a1b3f7..2ef3958a07 100644 --- a/libs/tiff-3.8.2/libtiff/tiffconf.h.vc +++ b/libs/tiff-4.0.2/libtiff/tiffconf.wince.h @@ -1,9 +1,29 @@ +/* $Id: tiffconf.wince.h,v 1.3 2010-03-10 18:56:49 bfriesen Exp $ */ + +/* + * Windows CE platform tiffconf.wince.h + * Created by Mateusz Loskot (mateusz@loskot.net) + * + * NOTE: Requires WCELIBCEX library with wceex_* functions, + * It's an extension to C library on Windows CE platform. + * For example, HAVE_STDIO_H definition indicates there are + * following files available: + * stdio.h - from Windows CE / Windows Mobile SDK + * wce_stdio.h - from WCELIBCEX library + */ + + /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions from this file in your programs. */ +#ifndef _WIN32_WCE +# error This version of tif_config.h header is dedicated for Windows CE platform! +#endif + + #ifndef _TIFFCONF_ #define _TIFFCONF_ @@ -19,9 +39,6 @@ /* The size of a `int', as computed by sizeof. */ #define SIZEOF_INT 4 -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the @@ -95,3 +112,10 @@ #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tiffio.h b/libs/tiff-4.0.2/libtiff/tiffio.h new file mode 100644 index 0000000000..c88ca190c9 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tiffio.h @@ -0,0 +1,550 @@ +/* $Id: tiffio.h,v 1.90 2012-06-06 04:58:00 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFIO_ +#define _TIFFIO_ + +/* + * TIFF I/O Library Definitions. + */ +#include "tiff.h" +#include "tiffvers.h" + +/* + * TIFF is defined as an incomplete type to hide the + * library's internal data structures from clients. + */ +typedef struct tiff TIFF; + +/* + * The following typedefs define the intrinsic size of + * data types used in the *exported* interfaces. These + * definitions depend on the proper definition of types + * in tiff.h. Note also that the varargs interface used + * to pass tag types and values uses the types defined in + * tiff.h directly. + * + * NB: ttag_t is unsigned int and not unsigned short because + * ANSI C requires that the type before the ellipsis be a + * promoted type (i.e. one of int, unsigned int, pointer, + * or double) and because we defined pseudo-tags that are + * outside the range of legal Aldus-assigned tags. + * NB: tsize_t is int32 and not uint32 because some functions + * return -1. + * NB: toff_t is not off_t for many reasons; TIFFs max out at + * 32-bit file offsets, and BigTIFF maxes out at 64-bit + * offsets being the most important, and to ensure use of + * a consistently unsigned type across architectures. + * Prior to libtiff 4.0, this was an unsigned 32 bit type. + */ +/* + * this is the machine addressing size type, only it's signed, so make it + * int32 on 32bit machines, int64 on 64bit machines + */ +typedef TIFF_SSIZE_T tmsize_t; +typedef uint64 toff_t; /* file offset */ +/* the following are deprecated and should be replaced by their defining + counterparts */ +typedef uint32 ttag_t; /* directory tag */ +typedef uint16 tdir_t; /* directory index */ +typedef uint16 tsample_t; /* sample number */ +typedef uint32 tstrile_t; /* strip or tile number */ +typedef tstrile_t tstrip_t; /* strip number */ +typedef tstrile_t ttile_t; /* tile number */ +typedef tmsize_t tsize_t; /* i/o size in bytes */ +typedef void* tdata_t; /* image data ref */ + +#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) +#define __WIN32__ +#endif + +/* + * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c + * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). + * + * By default tif_unix.c is assumed. + */ + +#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) +# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) +# define AVOID_WIN32_FILEIO +# endif +#endif + +#if defined(USE_WIN32_FILEIO) +# define VC_EXTRALEAN +# include +# ifdef __WIN32__ +DECLARE_HANDLE(thandle_t); /* Win32 file handle */ +# else +typedef HFILE thandle_t; /* client data handle */ +# endif /* __WIN32__ */ +#else +typedef void* thandle_t; /* client data handle */ +#endif /* USE_WIN32_FILEIO */ + +/* + * Flags to pass to TIFFPrintDirectory to control + * printing of data structures that are potentially + * very large. Bit-or these flags to enable printing + * multiple items. + */ +#define TIFFPRINT_NONE 0x0 /* no extra info */ +#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ +#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ +#define TIFFPRINT_COLORMAP 0x4 /* colormap */ +#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ +#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ +#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ + +/* + * Colour conversion stuff + */ + +/* reference white */ +#define D65_X0 (95.0470F) +#define D65_Y0 (100.0F) +#define D65_Z0 (108.8827F) + +#define D50_X0 (96.4250F) +#define D50_Y0 (100.0F) +#define D50_Z0 (82.4680F) + +/* Structure for holding information about a display device. */ + +typedef unsigned char TIFFRGBValue; /* 8-bit samples */ + +typedef struct { + float d_mat[3][3]; /* XYZ -> luminance matrix */ + float d_YCR; /* Light o/p for reference white */ + float d_YCG; + float d_YCB; + uint32 d_Vrwr; /* Pixel values for ref. white */ + uint32 d_Vrwg; + uint32 d_Vrwb; + float d_Y0R; /* Residual light for black pixel */ + float d_Y0G; + float d_Y0B; + float d_gammaR; /* Gamma values for the three guns */ + float d_gammaG; + float d_gammaB; +} TIFFDisplay; + +typedef struct { /* YCbCr->RGB support */ + TIFFRGBValue* clamptab; /* range clamping table */ + int* Cr_r_tab; + int* Cb_b_tab; + int32* Cr_g_tab; + int32* Cb_g_tab; + int32* Y_tab; +} TIFFYCbCrToRGB; + +typedef struct { /* CIE Lab 1976->RGB support */ + int range; /* Size of conversion table */ +#define CIELABTORGB_TABLE_RANGE 1500 + float rstep, gstep, bstep; + float X0, Y0, Z0; /* Reference white point */ + TIFFDisplay display; + float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ + float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ + float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ +} TIFFCIELabToRGB; + +/* + * RGBA-style image support. + */ +typedef struct _TIFFRGBAImage TIFFRGBAImage; +/* + * The image reading and conversion routines invoke + * ``put routines'' to copy/image/whatever tiles of + * raw image data. A default set of routines are + * provided to convert/copy raw image data to 8-bit + * packed ABGR format rasters. Applications can supply + * alternate routines that unpack the data into a + * different format or, for example, unpack the data + * and draw the unpacked raster on the display. + */ +typedef void (*tileContigRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*); +typedef void (*tileSeparateRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); +/* + * RGBA-reader state. + */ +struct _TIFFRGBAImage { + TIFF* tif; /* image handle */ + int stoponerr; /* stop on read error */ + int isContig; /* data is packed/separate */ + int alpha; /* type of alpha data present */ + uint32 width; /* image width */ + uint32 height; /* image height */ + uint16 bitspersample; /* image bits/sample */ + uint16 samplesperpixel; /* image samples/pixel */ + uint16 orientation; /* image orientation */ + uint16 req_orientation; /* requested orientation */ + uint16 photometric; /* image photometric interp */ + uint16* redcmap; /* colormap pallete */ + uint16* greencmap; + uint16* bluecmap; + /* get image data routine */ + int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); + /* put decoded strip/tile */ + union { + void (*any)(TIFFRGBAImage*); + tileContigRoutine contig; + tileSeparateRoutine separate; + } put; + TIFFRGBValue* Map; /* sample mapping array */ + uint32** BWmap; /* black&white map */ + uint32** PALmap; /* palette image map */ + TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ + TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ + + uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ + uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ + + int row_offset; + int col_offset; +}; + +/* + * Macros for extracting components from the + * packed ABGR form returned by TIFFReadRGBAImage. + */ +#define TIFFGetR(abgr) ((abgr) & 0xff) +#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) +#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) +#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) + +/* + * A CODEC is a software package that implements decoding, + * encoding, or decoding+encoding of a compression algorithm. + * The library provides a collection of builtin codecs. + * More codecs may be registered through calls to the library + * and/or the builtin implementations may be overridden. + */ +typedef int (*TIFFInitMethod)(TIFF*, int); +typedef struct { + char* name; + uint16 scheme; + TIFFInitMethod init; +} TIFFCodec; + +#include +#include + +/* share internal LogLuv conversion routines? */ +#ifndef LOGLUV_PUBLIC +#define LOGLUV_PUBLIC 1 +#endif + +#if !defined(__GNUC__) && !defined(__attribute__) +# define __attribute__(x) /*nothing*/ +#endif + +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif +typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); +typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); +typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); +typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); +typedef int (*TIFFCloseProc)(thandle_t); +typedef toff_t (*TIFFSizeProc)(thandle_t); +typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); +typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); +typedef void (*TIFFExtendProc)(TIFF*); + +extern const char* TIFFGetVersion(void); + +extern const TIFFCodec* TIFFFindCODEC(uint16); +extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern void TIFFUnRegisterCODEC(TIFFCodec*); +extern int TIFFIsCODECConfigured(uint16); +extern TIFFCodec* TIFFGetConfiguredCODECs(void); + +/* + * Auxiliary functions. + */ + +extern void* _TIFFmalloc(tmsize_t s); +extern void* _TIFFrealloc(void* p, tmsize_t s); +extern void _TIFFmemset(void* p, int v, tmsize_t c); +extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); +extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); +extern void _TIFFfree(void* p); + +/* +** Stuff, related to tag handling and creating custom tags. +*/ +extern int TIFFGetTagListCount( TIFF * ); +extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); + +#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ +#define TIFF_VARIABLE -1 /* marker for variable length tags */ +#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ + +#define FIELD_CUSTOM 65 + +typedef struct _TIFFField TIFFField; +typedef struct _TIFFFieldArray TIFFFieldArray; + +extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); +extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); +extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); + +typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); +typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); + +typedef struct { + TIFFVSetMethod vsetfield; /* tag set routine */ + TIFFVGetMethod vgetfield; /* tag get routine */ + TIFFPrintMethod printdir; /* directory print routine */ +} TIFFTagMethods; + +extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); +extern void *TIFFGetClientInfo(TIFF *, const char *); +extern void TIFFSetClientInfo(TIFF *, void *, const char *); + +extern void TIFFCleanup(TIFF* tif); +extern void TIFFClose(TIFF* tif); +extern int TIFFFlush(TIFF* tif); +extern int TIFFFlushData(TIFF* tif); +extern int TIFFGetField(TIFF* tif, uint32 tag, ...); +extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); +extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); +extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); +extern int TIFFReadDirectory(TIFF* tif); +extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); +extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); +extern uint64 TIFFScanlineSize64(TIFF* tif); +extern tmsize_t TIFFScanlineSize(TIFF* tif); +extern uint64 TIFFRasterScanlineSize64(TIFF* tif); +extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); +extern uint64 TIFFStripSize64(TIFF* tif); +extern tmsize_t TIFFStripSize(TIFF* tif); +extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); +extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); +extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); +extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); +extern uint64 TIFFTileRowSize64(TIFF* tif); +extern tmsize_t TIFFTileRowSize(TIFF* tif); +extern uint64 TIFFTileSize64(TIFF* tif); +extern tmsize_t TIFFTileSize(TIFF* tif); +extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); +extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); +extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); +extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); +extern int TIFFFileno(TIFF*); +extern int TIFFSetFileno(TIFF*, int); +extern thandle_t TIFFClientdata(TIFF*); +extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); +extern int TIFFGetMode(TIFF*); +extern int TIFFSetMode(TIFF*, int); +extern int TIFFIsTiled(TIFF*); +extern int TIFFIsByteSwapped(TIFF*); +extern int TIFFIsUpSampled(TIFF*); +extern int TIFFIsMSB2LSB(TIFF*); +extern int TIFFIsBigEndian(TIFF*); +extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); +extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); +extern TIFFSeekProc TIFFGetSeekProc(TIFF*); +extern TIFFCloseProc TIFFGetCloseProc(TIFF*); +extern TIFFSizeProc TIFFGetSizeProc(TIFF*); +extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); +extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); +extern uint32 TIFFCurrentRow(TIFF*); +extern uint16 TIFFCurrentDirectory(TIFF*); +extern uint16 TIFFNumberOfDirectories(TIFF*); +extern uint64 TIFFCurrentDirOffset(TIFF*); +extern uint32 TIFFCurrentStrip(TIFF*); +extern uint32 TIFFCurrentTile(TIFF* tif); +extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); +extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); +extern int TIFFSetupStrips(TIFF *); +extern int TIFFWriteCheck(TIFF*, int, const char *); +extern void TIFFFreeDirectory(TIFF*); +extern int TIFFCreateDirectory(TIFF*); +extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); +extern int TIFFCreateEXIFDirectory(TIFF*); +extern int TIFFLastDirectory(TIFF*); +extern int TIFFSetDirectory(TIFF*, uint16); +extern int TIFFSetSubDirectory(TIFF*, uint64); +extern int TIFFUnlinkDirectory(TIFF*, uint16); +extern int TIFFSetField(TIFF*, uint32, ...); +extern int TIFFVSetField(TIFF*, uint32, va_list); +extern int TIFFUnsetField(TIFF*, uint32); +extern int TIFFWriteDirectory(TIFF *); +extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); +extern int TIFFCheckpointDirectory(TIFF *); +extern int TIFFRewriteDirectory(TIFF *); + +#if defined(c_plusplus) || defined(__cplusplus) +extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, + int = ORIENTATION_BOTLEFT, int = 0); +#else +extern void TIFFPrintDirectory(TIFF*, FILE*, long); +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); +#endif + +extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); +extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); +extern int TIFFRGBAImageOK(TIFF*, char [1024]); +extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern void TIFFRGBAImageEnd(TIFFRGBAImage*); +extern TIFF* TIFFOpen(const char*, const char*); +# ifdef __WIN32__ +extern TIFF* TIFFOpenW(const wchar_t*, const char*); +# endif /* __WIN32__ */ +extern TIFF* TIFFFdOpen(int, const char*, const char*); +extern TIFF* TIFFClientOpen(const char*, const char*, + thandle_t, + TIFFReadWriteProc, TIFFReadWriteProc, + TIFFSeekProc, TIFFCloseProc, + TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc); +extern const char* TIFFFileName(TIFF*); +extern const char* TIFFSetFileName(TIFF*, const char *); +extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); +extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); +extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); +extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); +extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); +extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); +extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); +extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); +extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); +extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); +extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); +extern uint32 TIFFNumberOfTiles(TIFF*); +extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); +extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); +extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); +extern uint32 TIFFNumberOfStrips(TIFF*); +extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); +extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); +extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); +extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); +extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); +extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ +extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); +extern void TIFFSwabShort(uint16*); +extern void TIFFSwabLong(uint32*); +extern void TIFFSwabLong8(uint64*); +extern void TIFFSwabFloat(float*); +extern void TIFFSwabDouble(double*); +extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); +extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); +extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); +extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); +extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); +extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); +extern void TIFFReverseBits(uint8* cp, tmsize_t n); +extern const unsigned char* TIFFGetBitRevTable(int); + +#ifdef LOGLUV_PUBLIC +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. +extern double LogL16toY(int); +extern double LogL10toY(int); +extern void XYZtoRGB24(float*, uint8*); +extern int uv_decode(double*, double*, int); +extern void LogLuv24toXYZ(uint32, float*); +extern void LogLuv32toXYZ(uint32, float*); +#if defined(c_plusplus) || defined(__cplusplus) +extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); +extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); +extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); +extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); +#else +extern int LogL16fromY(double, int); +extern int LogL10fromY(double, int); +extern int uv_encode(double, double, int); +extern uint32 LogLuv24fromXYZ(float*, int); +extern uint32 LogLuv32fromXYZ(float*, int); +#endif +#endif /* LOGLUV_PUBLIC */ + +extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); +extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, + float *, float *, float *); +extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, + uint32 *, uint32 *, uint32 *); + +extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); +extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, + uint32 *, uint32 *, uint32 *); + +/**************************************************************************** + * O B S O L E T E D I N T E R F A C E S + * + * Don't use this stuff in your applications, it may be removed in the future + * libtiff versions. + ****************************************************************************/ +typedef struct { + ttag_t field_tag; /* field's tag */ + short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ + short field_writecount; /* write count/TIFF_VARIABLE */ + TIFFDataType field_type; /* type of associated data */ + unsigned short field_bit; /* bit in fieldsset bit vector */ + unsigned char field_oktochange; /* if true, can change while writing */ + unsigned char field_passcount; /* if true, pass dir count on set */ + char *field_name; /* ASCII name */ +} TIFFFieldInfo; + +extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); + +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + +#endif /* _TIFFIO_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tiffio.hxx b/libs/tiff-4.0.2/libtiff/tiffio.hxx similarity index 84% rename from libs/tiff-3.8.2/libtiff/tiffio.hxx rename to libs/tiff-4.0.2/libtiff/tiffio.hxx index ac7b9f2cd1..ed994f1156 100644 --- a/libs/tiff-3.8.2/libtiff/tiffio.hxx +++ b/libs/tiff-4.0.2/libtiff/tiffio.hxx @@ -1,4 +1,4 @@ -/* $Id: tiffio.hxx,v 1.1 2004/11/21 16:12:08 dron Exp $ */ +/* $Id: tiffio.hxx,v 1.3 2010-06-08 18:55:15 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,9 +34,16 @@ #include #include "tiff.h" -extern TIFF* TIFFStreamOpen(const char*, std::ostream *); -extern TIFF* TIFFStreamOpen(const char*, std::istream *); +extern TIFF* TIFFStreamOpen(const char*, std::ostream *); +extern TIFF* TIFFStreamOpen(const char*, std::istream *); #endif /* _TIFFIO_HXX_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/libtiff/tiffiop.h b/libs/tiff-4.0.2/libtiff/tiffiop.h new file mode 100644 index 0000000000..53357d8529 --- /dev/null +++ b/libs/tiff-4.0.2/libtiff/tiffiop.h @@ -0,0 +1,367 @@ +/* $Id: tiffiop.h,v 1.84 2012-05-30 01:50:17 fwarmerdam Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFIOP_ +#define _TIFFIOP_ +/* + * ``Library-private'' definitions. + */ + +#include "tif_config.h" + +#ifdef HAVE_FCNTL_H +# include +#endif + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + +#ifdef HAVE_STRING_H +# include +#endif + +#ifdef HAVE_ASSERT_H +# include +#else +# define assert(x) +#endif + +#ifdef HAVE_SEARCH_H +# include +#else +extern void *lfind(const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *)); +#endif + +#include "tiffio.h" + +#include "tif_dir.h" + +#ifndef STRIP_SIZE_DEFAULT +# define STRIP_SIZE_DEFAULT 8192 +#endif + +#define streq(a,b) (strcmp(a,b) == 0) + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +typedef struct client_info { + struct client_info *next; + void *data; + char *name; +} TIFFClientInfoLink; + +/* + * Typedefs for ``method pointers'' used internally. + * these are depriciated and provided only for backwards compatibility + */ +typedef unsigned char tidataval_t; /* internal image data value type */ +typedef tidataval_t* tidata_t; /* reference to internal image data */ + +typedef void (*TIFFVoidMethod)(TIFF*); +typedef int (*TIFFBoolMethod)(TIFF*); +typedef int (*TIFFPreMethod)(TIFF*, uint16); +typedef int (*TIFFCodeMethod)(TIFF* tif, uint8* buf, tmsize_t size, uint16 sample); +typedef int (*TIFFSeekMethod)(TIFF*, uint32); +typedef void (*TIFFPostMethod)(TIFF* tif, uint8* buf, tmsize_t size); +typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); +typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); + +struct tiff { + char* tif_name; /* name of open file */ + int tif_fd; /* open file descriptor */ + int tif_mode; /* open mode (O_*) */ + uint32 tif_flags; + #define TIFF_FILLORDER 0x00003 /* natural bit fill order for machine */ + #define TIFF_DIRTYHEADER 0x00004 /* header must be written on close */ + #define TIFF_DIRTYDIRECT 0x00008 /* current directory must be written */ + #define TIFF_BUFFERSETUP 0x00010 /* data buffers setup */ + #define TIFF_CODERSETUP 0x00020 /* encoder/decoder setup done */ + #define TIFF_BEENWRITING 0x00040 /* written 1+ scanlines to file */ + #define TIFF_SWAB 0x00080 /* byte swap file information */ + #define TIFF_NOBITREV 0x00100 /* inhibit bit reversal logic */ + #define TIFF_MYBUFFER 0x00200 /* my raw data buffer; free on close */ + #define TIFF_ISTILED 0x00400 /* file is tile, not strip- based */ + #define TIFF_MAPPED 0x00800 /* file is mapped into memory */ + #define TIFF_POSTENCODE 0x01000 /* need call to postencode routine */ + #define TIFF_INSUBIFD 0x02000 /* currently writing a subifd */ + #define TIFF_UPSAMPLED 0x04000 /* library is doing data up-sampling */ + #define TIFF_STRIPCHOP 0x08000 /* enable strip chopping support */ + #define TIFF_HEADERONLY 0x10000 /* read header only, do not process the first directory */ + #define TIFF_NOREADRAW 0x20000 /* skip reading of raw uncompressed image data */ + #define TIFF_INCUSTOMIFD 0x40000 /* currently writing a custom IFD */ + #define TIFF_BIGTIFF 0x80000 /* read/write bigtiff */ + #define TIFF_BUF4WRITE 0x100000 /* rawcc bytes are for writing */ + #define TIFF_DIRTYSTRIP 0x200000 /* stripoffsets/stripbytecount dirty*/ + #define TIFF_PERSAMPLE 0x400000 /* get/set per sample tags as arrays */ + #define TIFF_BUFFERMMAP 0x800000 /* read buffer (tif_rawdata) points into mmap() memory */ + uint64 tif_diroff; /* file offset of current directory */ + uint64 tif_nextdiroff; /* file offset of following directory */ + uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */ + uint16 tif_dirlistsize; /* number of entires in offset list */ + uint16 tif_dirnumber; /* number of already seen directories */ + TIFFDirectory tif_dir; /* internal rep of current directory */ + TIFFDirectory tif_customdir; /* custom IFDs are separated from the main ones */ + union { + TIFFHeaderCommon common; + TIFFHeaderClassic classic; + TIFFHeaderBig big; + } tif_header; + uint16 tif_header_size; /* file's header block and its length */ + uint32 tif_row; /* current scanline */ + uint16 tif_curdir; /* current directory (index) */ + uint32 tif_curstrip; /* current strip for read/write */ + uint64 tif_curoff; /* current offset for read/write */ + uint64 tif_dataoff; /* current offset for writing dir */ + /* SubIFD support */ + uint16 tif_nsubifd; /* remaining subifds to write */ + uint64 tif_subifdoff; /* offset for patching SubIFD link */ + /* tiling support */ + uint32 tif_col; /* current column (offset by row too) */ + uint32 tif_curtile; /* current tile for read/write */ + tmsize_t tif_tilesize; /* # of bytes in a tile */ + /* compression scheme hooks */ + int tif_decodestatus; + TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */ + TIFFBoolMethod tif_setupdecode; /* called once before predecode */ + TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ + TIFFBoolMethod tif_setupencode; /* called once before preencode */ + int tif_encodestatus; + TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ + TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ + TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ + TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ + TIFFCodeMethod tif_decodestrip; /* strip decoding routine */ + TIFFCodeMethod tif_encodestrip; /* strip encoding routine */ + TIFFCodeMethod tif_decodetile; /* tile decoding routine */ + TIFFCodeMethod tif_encodetile; /* tile encoding routine */ + TIFFVoidMethod tif_close; /* cleanup-on-close routine */ + TIFFSeekMethod tif_seek; /* position within a strip routine */ + TIFFVoidMethod tif_cleanup; /* cleanup state routine */ + TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */ + TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */ + uint8* tif_data; /* compression scheme private data */ + /* input/output buffering */ + tmsize_t tif_scanlinesize; /* # of bytes in a scanline */ + tmsize_t tif_scanlineskew; /* scanline skew for reading strips */ + uint8* tif_rawdata; /* raw data buffer */ + tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */ + tmsize_t tif_rawdataoff; /* rawdata offset within strip */ + tmsize_t tif_rawdataloaded;/* amount of data in rawdata */ + uint8* tif_rawcp; /* current spot in raw buffer */ + tmsize_t tif_rawcc; /* bytes unread from raw buffer */ + /* memory-mapped file support */ + uint8* tif_base; /* base of mapped file */ + tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */ + TIFFMapFileProc tif_mapproc; /* map file method */ + TIFFUnmapFileProc tif_unmapproc; /* unmap file method */ + /* input/output callback methods */ + thandle_t tif_clientdata; /* callback parameter */ + TIFFReadWriteProc tif_readproc; /* read method */ + TIFFReadWriteProc tif_writeproc; /* write method */ + TIFFSeekProc tif_seekproc; /* lseek method */ + TIFFCloseProc tif_closeproc; /* close method */ + TIFFSizeProc tif_sizeproc; /* filesize method */ + /* post-decoding support */ + TIFFPostMethod tif_postdecode; /* post decoding routine */ + /* tag support */ + TIFFField** tif_fields; /* sorted table of registered tags */ + size_t tif_nfields; /* # entries in registered tag table */ + const TIFFField* tif_foundfield; /* cached pointer to already found tag */ + TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */ + TIFFClientInfoLink* tif_clientinfo; /* extra client information. */ + /* Backward compatibility stuff. We need these two fields for + * setting up an old tag extension scheme. */ + TIFFFieldArray* tif_fieldscompat; + size_t tif_nfieldscompat; +}; + +#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ + +#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) +#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) +#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) +#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) +#define TIFFReadFile(tif, buf, size) \ + ((*(tif)->tif_readproc)((tif)->tif_clientdata,(buf),(size))) +#define TIFFWriteFile(tif, buf, size) \ + ((*(tif)->tif_writeproc)((tif)->tif_clientdata,(buf),(size))) +#define TIFFSeekFile(tif, off, whence) \ + ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(off),(whence))) +#define TIFFCloseFile(tif) \ + ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) +#define TIFFGetFileSize(tif) \ + ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) +#define TIFFMapFileContents(tif, paddr, psize) \ + ((*(tif)->tif_mapproc)((tif)->tif_clientdata,(paddr),(psize))) +#define TIFFUnmapFileContents(tif, addr, size) \ + ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,(addr),(size))) + +/* + * Default Read/Seek/Write definitions. + */ +#ifndef ReadOK +#define ReadOK(tif, buf, size) \ + (TIFFReadFile((tif),(buf),(size))==(size)) +#endif +#ifndef SeekOK +#define SeekOK(tif, off) \ + (TIFFSeekFile((tif),(off),SEEK_SET)==(off)) +#endif +#ifndef WriteOK +#define WriteOK(tif, buf, size) \ + (TIFFWriteFile((tif),(buf),(size))==(size)) +#endif + +/* NB: the uint32 casts are to silence certain ANSI-C compilers */ +#define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \ + ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \ + 0U) +#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +#define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y)) +#define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y))) +#define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(x)>>3) +#define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y)) + +/* Safe multiply which returns zero if there is an integer overflow */ +#define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0) + +#define TIFFmax(A,B) ((A)>(B)?(A):(B)) +#define TIFFmin(A,B) ((A)<(B)?(A):(B)) + +#define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0])) + +#if defined(__cplusplus) +extern "C" { +#endif +extern int _TIFFgetMode(const char* mode, const char* module); +extern int _TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); +extern int _TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); +extern int _TIFFNoTileEncode(TIFF*, uint8* pp, tmsize_t cc, uint16 s); +extern int _TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); +extern int _TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); +extern int _TIFFNoTileDecode(TIFF*, uint8* pp, tmsize_t cc, uint16 s); +extern void _TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc); +extern int _TIFFNoPreCode(TIFF* tif, uint16 s); +extern int _TIFFNoSeek(TIFF* tif, uint32 off); +extern void _TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc); +extern void _TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc); +extern void _TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc); +extern void _TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc); +extern int TIFFFlushData1(TIFF* tif); +extern int TIFFDefaultDirectory(TIFF* tif); +extern void _TIFFSetDefaultCompressionState(TIFF* tif); +extern int _TIFFRewriteField(TIFF *, uint16, TIFFDataType, tmsize_t, void *); +extern int TIFFSetCompressionScheme(TIFF* tif, int scheme); +extern int TIFFSetDefaultCompressionState(TIFF* tif); +extern uint32 _TIFFDefaultStripSize(TIFF* tif, uint32 s); +extern void _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th); +extern int _TIFFDataSize(TIFFDataType type); + +extern void _TIFFsetByteArray(void**, void*, uint32); +extern void _TIFFsetString(char**, char*); +extern void _TIFFsetShortArray(uint16**, uint16*, uint32); +extern void _TIFFsetLongArray(uint32**, uint32*, uint32); +extern void _TIFFsetFloatArray(float**, float*, uint32); +extern void _TIFFsetDoubleArray(double**, double*, uint32); + +extern void _TIFFprintAscii(FILE*, const char*); +extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); + +extern TIFFErrorHandler _TIFFwarningHandler; +extern TIFFErrorHandler _TIFFerrorHandler; +extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; +extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; + +extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*); +extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*); +extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*); +extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*); + +extern double _TIFFUInt64ToDouble(uint64); +extern float _TIFFUInt64ToFloat(uint64); + +extern int TIFFInitDumpMode(TIFF*, int); +#ifdef PACKBITS_SUPPORT +extern int TIFFInitPackBits(TIFF*, int); +#endif +#ifdef CCITT_SUPPORT +extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); +extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); +#endif +#ifdef THUNDER_SUPPORT +extern int TIFFInitThunderScan(TIFF*, int); +#endif +#ifdef NEXT_SUPPORT +extern int TIFFInitNeXT(TIFF*, int); +#endif +#ifdef LZW_SUPPORT +extern int TIFFInitLZW(TIFF*, int); +#endif +#ifdef OJPEG_SUPPORT +extern int TIFFInitOJPEG(TIFF*, int); +#endif +#ifdef JPEG_SUPPORT +extern int TIFFInitJPEG(TIFF*, int); +#endif +#ifdef JBIG_SUPPORT +extern int TIFFInitJBIG(TIFF*, int); +#endif +#ifdef ZIP_SUPPORT +extern int TIFFInitZIP(TIFF*, int); +#endif +#ifdef PIXARLOG_SUPPORT +extern int TIFFInitPixarLog(TIFF*, int); +#endif +#ifdef LOGLUV_SUPPORT +extern int TIFFInitSGILog(TIFF*, int); +#endif +#ifdef LZMA_SUPPORT +extern int TIFFInitLZMA(TIFF*, int); +#endif +#ifdef VMS +extern const TIFFCodec _TIFFBuiltinCODECS[]; +#else +extern TIFFCodec _TIFFBuiltinCODECS[]; +#endif + +#if defined(__cplusplus) +} +#endif +#endif /* _TIFFIOP_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/libtiff/tiffvers.h b/libs/tiff-4.0.2/libtiff/tiffvers.h similarity index 76% rename from libs/tiff-3.8.2/libtiff/tiffvers.h rename to libs/tiff-4.0.2/libtiff/tiffvers.h index 9744f8d308..38ee9fab34 100644 --- a/libs/tiff-3.8.2/libtiff/tiffvers.h +++ b/libs/tiff-4.0.2/libtiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.8.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a @@ -6,4 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20060323 +#define TIFFLIB_VERSION 20120615 diff --git a/libs/tiff-3.8.2/libtiff/uvcode.h b/libs/tiff-4.0.2/libtiff/uvcode.h similarity index 98% rename from libs/tiff-3.8.2/libtiff/uvcode.h rename to libs/tiff-4.0.2/libtiff/uvcode.h index 5b2d7d71fa..50f11d7e0a 100644 --- a/libs/tiff-3.8.2/libtiff/uvcode.h +++ b/libs/tiff-4.0.2/libtiff/uvcode.h @@ -171,3 +171,10 @@ static struct { { (float)0.016994, 31, 16237 }, { (float)0.023659, 21, 16268 }, }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/m4/acinclude.m4 b/libs/tiff-4.0.2/m4/acinclude.m4 new file mode 100644 index 0000000000..b54feb7061 --- /dev/null +++ b/libs/tiff-4.0.2/m4/acinclude.m4 @@ -0,0 +1,851 @@ +dnl --------------------------------------------------------------------------- +dnl Message output +dnl --------------------------------------------------------------------------- +AC_DEFUN([LOC_MSG],[echo "$1"]) + +dnl --------------------------------------------------------------------------- +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/vl_prog_cc_warnings.html +dnl --------------------------------------------------------------------------- + +dnl @synopsis VL_PROG_CC_WARNINGS([ANSI]) +dnl +dnl Enables a reasonable set of warnings for the C compiler. +dnl Optionally, if the first argument is nonempty, turns on flags which +dnl enforce and/or enable proper ANSI C if such are known with the +dnl compiler used. +dnl +dnl Currently this macro knows about GCC, Solaris C compiler, Digital +dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C +dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos +dnl 10.0.0.8) C compiler. +dnl +dnl @category C +dnl @author Ville Laurikari +dnl @version 2002-04-04 +dnl @license AllPermissive + +AC_DEFUN([VL_PROG_CC_WARNINGS], [ + ansi=$1 + if test -z "$ansi"; then + msg="for C compiler warning flags" + else + msg="for C compiler warning and ANSI conformance flags" + fi + AC_CACHE_CHECK($msg, vl_cv_prog_cc_warnings, [ + if test -n "$CC"; then + cat > conftest.c <&1 | grep -i "WorkShop" > /dev/null 2>&1 && + $CC -c -v -Xc conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="-v" + else + vl_cv_prog_cc_warnings="-v -Xc" + fi + + dnl Digital Unix C compiler + elif $CC -V 2>&1 | grep -i "Digital UNIX Compiler" > /dev/null 2>&1 && + $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos" + else + vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1" + fi + + dnl C for AIX Compiler + elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 && + $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" + else + vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi" + fi + + dnl IRIX C compiler + elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 && + $CC -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="-fullwarn" + else + vl_cv_prog_cc_warnings="-fullwarn -ansi -ansiE" + fi + + dnl HP-UX C compiler + elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 && + $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="+w1" + else + vl_cv_prog_cc_warnings="+w1 -Aa" + fi + + dnl The NEC SX-5 (Super-UX 10) C compiler + elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 && + $CC -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="-pvctl[,]fullmsg" + else + vl_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc" + fi + + dnl The Cray C compiler (Unicos) + elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 && + $CC -c -h msglevel 2 conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + vl_cv_prog_cc_warnings="-h msglevel 2" + else + vl_cv_prog_cc_warnings="-h msglevel 2 -h conform" + fi + + fi + rm -f conftest.* + fi + if test -n "$vl_cv_prog_cc_warnings"; then + CFLAGS="$CFLAGS $vl_cv_prog_cc_warnings" + else + vl_cv_prog_cc_warnings="unknown" + fi + ]) +])dnl + +dnl --------------------------------------------------------------------------- +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://autoconf-archive.cryp.to/ax_lang_compiler_ms.html +dnl --------------------------------------------------------------------------- + +dnl @synopsis AX_LANG_COMPILER_MS +dnl +dnl Check whether the compiler for the current language is Microsoft. +dnl +dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU +dnl Autoconf implementation. +dnl +dnl @category InstalledPackages +dnl @author Braden McDaniel +dnl @version 2004-11-15 +dnl @license AllPermissive + +AC_DEFUN([AX_LANG_COMPILER_MS], +[AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler], + [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms], +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER + choke me +#endif +]])], + [ax_compiler_ms=yes], + [ax_compiler_ms=no]) +ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms +])]) + +dnl --------------------------------------------------------------------------- +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html +dnl --------------------------------------------------------------------------- + +dnl SYNOPSIS +dnl +dnl AX_CHECK_GL +dnl +dnl DESCRIPTION +dnl +dnl Check for an OpenGL implementation. If GL is found, the required +dnl compiler and linker flags are included in the output variables +dnl "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation +dnl is found, "no_gl" is set to "yes". +dnl +dnl If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the +dnl header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These +dnl preprocessor definitions may not be mutually exclusive. +dnl +dnl LICENSE +dnl +dnl Copyright (c) 2009 Braden McDaniel +dnl +dnl This program is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU General Public License as published by the +dnl Free Software Foundation; either version 2 of the License, or (at your +dnl option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program. If not, see . +dnl +dnl As a special exception, the respective Autoconf Macro's copyright owner +dnl gives unlimited permission to copy, distribute and modify the configure +dnl scripts that are the output of Autoconf when processing the Macro. You +dnl need not follow the terms of the GNU General Public License when using +dnl or distributing such scripts, even though portions of the text of the +dnl Macro appear in them. The GNU General Public License (GPL) does govern +dnl all other use of the material that constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the Autoconf +dnl Macro released by the Autoconf Archive. When you make and distribute a +dnl modified version of the Autoconf Macro, you may extend this special +dnl exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_CHECK_GL], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PATH_X])dnl +AC_REQUIRE([AX_PTHREAD])dnl + +AC_LANG_PUSH([C]) +AX_LANG_COMPILER_MS +AS_IF([test X$ax_compiler_ms = Xno], + [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"]) + +dnl +dnl Use x_includes and x_libraries if they have been set (presumably by +dnl AC_PATH_X). +dnl +AS_IF([test "X$no_x" != "Xyes"], + [AS_IF([test -n "$x_includes"], + [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])] + AS_IF([test -n "$x_libraries"], + [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"])) + +ax_save_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" +AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h]) +CPPFLAGS="${ax_save_CPPFLAGS}" + +AC_CHECK_HEADERS([windows.h]) + +m4_define([AX_CHECK_GL_PROGRAM], + [AC_LANG_PROGRAM([[ +# if defined(HAVE_WINDOWS_H) && defined(_WIN32) +# include +# endif +# ifdef HAVE_GL_GL_H +# include +# elif defined(HAVE_OPENGL_GL_H) +# include +# else +# error no gl.h +# endif]], + [[glBegin(0)]])]) + +AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl], +[ax_cv_check_gl_libgl="no" +case $host_cpu in + x86_64) ax_check_gl_libdir=lib64 ;; + *) ax_check_gl_libdir=lib ;; +esac +ax_save_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" +ax_save_LIBS="${LIBS}" +LIBS="" +ax_check_libs="-lopengl32 -lGL" +for ax_lib in ${ax_check_libs}; do + AS_IF([test X$ax_compiler_ms = Xyes], + [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`], + [ax_try_lib="${ax_lib}"]) + LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" +AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM], + [ax_cv_check_gl_libgl="${ax_try_lib}"; break], + [ax_check_gl_nvidia_flags="-L/usr/${ax_check_gl_libdir}/nvidia" LIBS="${ax_try_lib} ${ax_check_gl_nvidia_flags} ${GL_LIBS} ${ax_save_LIBS}" +AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM], + [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_nvidia_flags}"; break], + [ax_check_gl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib' LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}" +AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM], + [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])]) +done + +AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes], +[LIBS='-framework OpenGL' +AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM], + [ax_cv_check_gl_libgl="$LIBS"])]) + +LIBS=${ax_save_LIBS} +CPPFLAGS=${ax_save_CPPFLAGS}]) + +AS_IF([test "X$ax_cv_check_gl_libgl" = Xno], + [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""], + [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"]) +AC_LANG_POP([C]) + +AC_SUBST([GL_CFLAGS]) +AC_SUBST([GL_LIBS]) +])dnl + +dnl --------------------------------------------------------------------------- +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html +dnl --------------------------------------------------------------------------- + +dnl SYNOPSIS +dnl +dnl AX_CHECK_GLU +dnl +dnl DESCRIPTION +dnl +dnl Check for GLU. If GLU is found, the required preprocessor and linker +dnl flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS", +dnl respectively. If no GLU implementation is found, "no_glu" is set to +dnl "yes". +dnl +dnl If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the +dnl header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These +dnl preprocessor definitions may not be mutually exclusive. +dnl +dnl Some implementations (in particular, some versions of Mac OS X) are +dnl known to treat the GLU tesselator callback function type as "GLvoid +dnl (*)(...)" rather than the standard "GLvoid (*)()". If the former +dnl condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB". +dnl +dnl LICENSE +dnl +dnl Copyright (c) 2009 Braden McDaniel +dnl +dnl This program is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU General Public License as published by the +dnl Free Software Foundation; either version 2 of the License, or (at your +dnl option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program. If not, see . +dnl +dnl As a special exception, the respective Autoconf Macro's copyright owner +dnl gives unlimited permission to copy, distribute and modify the configure +dnl scripts that are the output of Autoconf when processing the Macro. You +dnl need not follow the terms of the GNU General Public License when using +dnl or distributing such scripts, even though portions of the text of the +dnl Macro appear in them. The GNU General Public License (GPL) does govern +dnl all other use of the material that constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the Autoconf +dnl Macro released by the Autoconf Archive. When you make and distribute a +dnl modified version of the Autoconf Macro, you may extend this special +dnl exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_CHECK_GLU], +[AC_REQUIRE([AX_CHECK_GL])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +GLU_CFLAGS="${GL_CFLAGS}" + +ax_save_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" +AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h]) +CPPFLAGS="${ax_save_CPPFLAGS}" + +m4_define([AX_CHECK_GLU_PROGRAM], + [AC_LANG_PROGRAM([[ +# if defined(HAVE_WINDOWS_H) && defined(_WIN32) +# include +# endif +# ifdef HAVE_GL_GLU_H +# include +# elif defined(HAVE_OPENGL_GLU_H) +# include +# else +# error no glu.h +# endif]], + [[gluBeginCurve(0)]])]) + +AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu], +[ax_cv_check_glu_libglu="no" +ax_save_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" +ax_save_LIBS="${LIBS}" + +dnl +dnl First, check for the possibility that everything we need is already in +dnl GL_LIBS. +dnl +LIBS="${GL_LIBS} ${ax_save_LIBS}" +dnl +dnl libGLU typically links with libstdc++ on POSIX platforms. +dnl However, setting the language to C++ means that test program +dnl source is named "conftest.cc"; and Microsoft cl doesn't know what +dnl to do with such a file. +dnl +AC_LANG_PUSH([C++]) +AS_IF([test X$ax_compiler_ms = Xyes], + [AC_LANG_PUSH([C])]) +AC_LINK_IFELSE( +[AX_CHECK_GLU_PROGRAM], +[ax_cv_check_glu_libglu=yes], +[LIBS="" +ax_check_libs="-lglu32 -lGLU" +for ax_lib in ${ax_check_libs}; do + AS_IF([test X$ax_compiler_ms = Xyes], + [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`], + [ax_try_lib="${ax_lib}"]) + LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" + AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM], + [ax_cv_check_glu_libglu="${ax_try_lib}"; break]) +done +]) +AS_IF([test X$ax_compiler_ms = Xyes], + [AC_LANG_POP([C])]) +AC_LANG_POP([C++]) + +LIBS=${ax_save_LIBS} +CPPFLAGS=${ax_save_CPPFLAGS}]) +AS_IF([test "X$ax_cv_check_glu_libglu" = Xno], + [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""], + [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes], + [GLU_LIBS="$GL_LIBS"], + [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])]) +AC_SUBST([GLU_CFLAGS]) +AC_SUBST([GLU_LIBS]) + +dnl +dnl Some versions of Mac OS X include a broken interpretation of the GLU +dnl tesselation callback function signature. +dnl +AS_IF([test "X$ax_cv_check_glu_libglu" != Xno], +[AC_CACHE_CHECK([for varargs GLU tesselator callback function type], + [ax_cv_varargs_glu_tesscb], +[ax_cv_varargs_glu_tesscb=no +ax_save_CFLAGS="$CFLAGS" +CFLAGS="$GL_CFLAGS $CFLAGS" +AC_COMPILE_IFELSE( +[AC_LANG_PROGRAM([[ +# ifdef HAVE_GL_GLU_H +# include +# else +# include +# endif]], + [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])], +[ax_cv_varargs_glu_tesscb=yes]) +CFLAGS="$ax_save_CFLAGS"]) +AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes], + [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1], + [Use nonstandard varargs form for the GLU tesselator callback])])]) +]) + +dnl --------------------------------------------------------------------------- +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html +dnl --------------------------------------------------------------------------- + +dnl +dnl SYNOPSIS +dnl +dnl AX_CHECK_GLUT +dnl +dnl DESCRIPTION +dnl +dnl Check for GLUT. If GLUT is found, the required compiler and linker flags +dnl are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS", +dnl respectively. If GLUT is not found, "no_glut" is set to "yes". +dnl +dnl If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the +dnl header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These +dnl preprocessor definitions may not be mutually exclusive. +dnl +dnl LICENSE +dnl +dnl Copyright (c) 2009 Braden McDaniel +dnl +dnl This program is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU General Public License as published by the +dnl Free Software Foundation; either version 2 of the License, or (at your +dnl option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program. If not, see . +dnl +dnl As a special exception, the respective Autoconf Macro's copyright owner +dnl gives unlimited permission to copy, distribute and modify the configure +dnl scripts that are the output of Autoconf when processing the Macro. You +dnl need not follow the terms of the GNU General Public License when using +dnl or distributing such scripts, even though portions of the text of the +dnl Macro appear in them. The GNU General Public License (GPL) does govern +dnl all other use of the material that constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the Autoconf +dnl Macro released by the Autoconf Archive. When you make and distribute a +dnl modified version of the Autoconf Macro, you may extend this special +dnl exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_CHECK_GLUT], +[AC_REQUIRE([AX_CHECK_GLU])dnl +AC_REQUIRE([AC_PATH_XTRA])dnl + +ax_save_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}" +AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h]) +CPPFLAGS="${ax_save_CPPFLAGS}" + +GLUT_CFLAGS=${GLU_CFLAGS} +GLUT_LIBS=${GLU_LIBS} + +m4_define([AX_CHECK_GLUT_PROGRAM], + [AC_LANG_PROGRAM([[ +# if HAVE_WINDOWS_H && defined(_WIN32) +# include +# endif +# ifdef HAVE_GL_GLUT_H +# include +# elif defined(HAVE_GLUT_GLUT_H) +# include +# else +# error no glut.h +# endif]], + [[glutMainLoop()]])]) + +dnl +dnl If X is present, assume GLUT depends on it. +dnl +AS_IF([test X$no_x != Xyes], + [GLUT_LIBS="${X_PRE_LIBS} -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"]) + +AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut], +[ax_cv_check_glut_libglut="no" +AC_LANG_PUSH(C) +ax_save_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}" +ax_save_LIBS="${LIBS}" +LIBS="" +ax_check_libs="-lglut32 -lglut" +for ax_lib in ${ax_check_libs}; do + AS_IF([test X$ax_compiler_ms = Xyes], + [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`], + [ax_try_lib="${ax_lib}"]) + LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}" + AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM], + [ax_cv_check_glut_libglut="${ax_try_lib}"; break]) +done + +AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes], +[LIBS='-framework GLUT' +AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM], + [ax_cv_check_glut_libglut="$LIBS"])]) + +CPPFLAGS="${ax_save_CPPFLAGS}" +LIBS="${ax_save_LIBS}" +AC_LANG_POP(C)]) + +AS_IF([test "X$ax_cv_check_glut_libglut" = Xno], + [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""], + [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"]) + +AC_SUBST([GLUT_CFLAGS]) +AC_SUBST([GLUT_LIBS]) +])dnl + +dnl --------------------------------------------------------------------------- +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/autoconf-archive/ax_pthread.html +dnl --------------------------------------------------------------------------- + +dnl SYNOPSIS +dnl +dnl AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl DESCRIPTION +dnl +dnl This macro figures out how to build C programs using POSIX threads. It +dnl sets the PTHREAD_LIBS output variable to the threads library and linker +dnl flags, and the PTHREAD_CFLAGS output variable to any special C compiler +dnl flags that are needed. (The user can also force certain compiler +dnl flags/libs to be tested by setting these environment variables.) +dnl +dnl Also sets PTHREAD_CC to any special C compiler that is needed for +dnl multi-threaded programs (defaults to the value of CC otherwise). (This +dnl is necessary on AIX to use the special cc_r compiler alias.) +dnl +dnl NOTE: You are assumed to not only compile your program with these flags, +dnl but also link it with them as well. e.g. you should link with +dnl $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +dnl +dnl If you are only building threads programs, you may wish to use these +dnl variables in your default LIBS, CFLAGS, and CC: +dnl +dnl LIBS="$PTHREAD_LIBS $LIBS" +dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +dnl CC="$PTHREAD_CC" +dnl +dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +dnl has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name +dnl (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +dnl +dnl ACTION-IF-FOUND is a list of shell commands to run if a threads library +dnl is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +dnl is not found. If ACTION-IF-FOUND is not specified, the default action +dnl will define HAVE_PTHREAD. +dnl +dnl Please let the authors know if this macro fails on any platform, or if +dnl you have any other suggestions or comments. This macro was based on work +dnl by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +dnl from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +dnl Alejandro Forero Cuervo to the autoconf macro repository. We are also +dnl grateful for the helpful feedback of numerous users. +dnl +dnl LICENSE +dnl +dnl Copyright (c) 2008 Steven G. Johnson +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU General Public License as published by the +dnl Free Software Foundation, either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program. If not, see . +dnl +dnl As a special exception, the respective Autoconf Macro's copyright owner +dnl gives unlimited permission to copy, distribute and modify the configure +dnl scripts that are the output of Autoconf when processing the Macro. You +dnl need not follow the terms of the GNU General Public License when using +dnl or distributing such scripts, even though portions of the text of the +dnl Macro appear in them. The GNU General Public License (GPL) does govern +dnl all other use of the material that constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the Autoconf +dnl Macro released by the Autoconf Archive. When you make and distribute a +dnl modified version of the Autoconf Macro, you may extend this special +dnl exception to the GPL to apply to your modified version as well. + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +ax_pthread_ok=no + +dnl We used to check for pthread.h first, but this fails if pthread.h +dnl requires special compiler flags (e.g. on True64 or Sequent). +dnl It gets checked for in the link test anyway. + +dnl First of all, check if the user has set any of the PTHREAD_LIBS, +dnl etcetera environment variables, and if threads linking works using +dnl them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) + AC_MSG_RESULT($ax_pthread_ok) + if test x"$ax_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +dnl We must check for the threads library under a number of different +dnl names; the ordering is very important because some systems +dnl (e.g. DEC) have both -lpthread and -lpthreads, where one of the +dnl libraries is broken (non-POSIX). + +dnl Create a list of thread flags to try. Items starting with a "-" are +dnl C compiler flags, and other items are library names, except for "none" +dnl which indicates that we try without any flags at all, and "pthread-config" +dnl which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +dnl The ordering *is* (sometimes) important. Some notes on the +dnl individual items follow: + +dnl pthreads: AIX (must check this before -lpthread) +dnl none: in case threads are in libc; should be tried before -Kthread and +dnl other compiler flags to prevent continual compiler warnings +dnl -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +dnl -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +dnl lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +dnl -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +dnl -pthreads: Solaris/gcc +dnl -mthreads: Mingw32/gcc, Lynx/gcc +dnl -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +dnl doesn't hurt to check since this sometimes defines pthreads too; +dnl also defines -D_REENTRANT) +dnl ... -mt is also the pthreads flag for HP/aCC +dnl pthread: Linux, etcetera +dnl --thread-safe: KAI C++ +dnl pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + dnl On Solaris (at least, for some versions), libc contains stubbed + dnl (non-functional) versions of the pthreads routines, so link-based + dnl tests will erroneously succeed. (We need to link with -pthreads/-mt/ + dnl -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + dnl a function called by this macro, so we could check for that, but + dnl who knows whether they'll stub that too in a future libc.) So, + dnl we'll just look for -pthreads and -lpthread first: + + ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" + ;; + + *-darwin*) + ax_pthread_flags="-pthread $ax_pthread_flags" + ;; +esac + +if test x"$ax_pthread_ok" = xno; then +for flag in $ax_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) + if test x"$ax_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + dnl Check for various functions. We must include pthread.h, + dnl since some functions may be macros. (On the Sequent, we + dnl need a special flag -Kthread to make this header compile.) + dnl We check for pthread_join because it is in -lpthread on IRIX + dnl while pthread_create is in libc. We check for pthread_attr_init + dnl due to DEC craziness with -lpthreads. We check for + dnl pthread_cleanup_push because it is one of the few pthread + dnl functions on Solaris that doesn't have a non-functional libc stub. + dnl We try pthread_create on general principles. + AC_TRY_LINK([#include + static void routine(void* a) {a=0;} + static void* start_routine(void* a) {return a;}], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th,0,start_routine,0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0); ], + [ax_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($ax_pthread_ok) + if test "x$ax_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +dnl Various other checks: +if test "x$ax_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + dnl Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_TRY_LINK([#include ], [int attr=$attr; return attr;], + [attr_name=$attr; break]) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + dnl More AIX lossage: must compile with xlc_r or cc_r + if test x"$GCC" != xyes; then + AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) + else + PTHREAD_CC=$CC + fi +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl AX_PTHREAD diff --git a/libs/tiff-3.8.2/man/Makefile.am b/libs/tiff-4.0.2/man/Makefile.am similarity index 99% rename from libs/tiff-3.8.2/man/Makefile.am rename to libs/tiff-4.0.2/man/Makefile.am index 657fe0ab34..745912bfe1 100644 --- a/libs/tiff-3.8.2/man/Makefile.am +++ b/libs/tiff-4.0.2/man/Makefile.am @@ -41,6 +41,7 @@ dist_man1_MANS = \ tiff2rgba.1 \ tiffcmp.1 \ tiffcp.1 \ + tiffcrop.1 \ tiffdither.1 \ tiffdump.1 \ tiffgt.1 \ diff --git a/libs/tiff-3.8.2/man/TIFFClose.3tiff b/libs/tiff-4.0.2/man/TIFFClose.3tiff similarity index 95% rename from libs/tiff-3.8.2/man/TIFFClose.3tiff rename to libs/tiff-4.0.2/man/TIFFClose.3tiff index 6dce01fe66..bcb760443e 100644 --- a/libs/tiff-3.8.2/man/TIFFClose.3tiff +++ b/libs/tiff-4.0.2/man/TIFFClose.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFClose.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFClose.3tiff,v 1.3 2009-08-24 19:13:40 bfriesen Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -40,7 +40,7 @@ Any buffered data are flushed to the file, including the contents of the current directory (if modified); and all resources are reclaimed. .SH DIAGNOSTICS All error messages are directed to the -.bR TIFFError (3TIFF) +.BR TIFFError (3TIFF) routine. Likewise, warning messages are directed to the .BR TIFFWarning (3TIFF) diff --git a/libs/tiff-3.8.2/man/TIFFDataWidth.3tiff b/libs/tiff-4.0.2/man/TIFFDataWidth.3tiff similarity index 96% rename from libs/tiff-3.8.2/man/TIFFDataWidth.3tiff rename to libs/tiff-4.0.2/man/TIFFDataWidth.3tiff index 614e69be21..cb274d891d 100644 --- a/libs/tiff-3.8.2/man/TIFFDataWidth.3tiff +++ b/libs/tiff-4.0.2/man/TIFFDataWidth.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFDataWidth.3tiff,v 1.3 2006/03/23 14:54:02 dron Exp $ +.\" $Id: TIFFDataWidth.3tiff,v 1.3 2006-03-23 14:54:02 dron Exp $ .\" .\" Copyright (c) 2002, Andrey Kiselev .\" diff --git a/libs/tiff-3.8.2/man/TIFFError.3tiff b/libs/tiff-4.0.2/man/TIFFError.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFError.3tiff rename to libs/tiff-4.0.2/man/TIFFError.3tiff index 677a1df7b3..761ff08c47 100644 --- a/libs/tiff-3.8.2/man/TIFFError.3tiff +++ b/libs/tiff-4.0.2/man/TIFFError.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFError.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFError.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFFlush.3tiff b/libs/tiff-4.0.2/man/TIFFFlush.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFFlush.3tiff rename to libs/tiff-4.0.2/man/TIFFFlush.3tiff index 9d8f2a0607..af3235036a 100644 --- a/libs/tiff-3.8.2/man/TIFFFlush.3tiff +++ b/libs/tiff-4.0.2/man/TIFFFlush.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFFlush.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFFlush.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFGetField.3tiff b/libs/tiff-4.0.2/man/TIFFGetField.3tiff similarity index 96% rename from libs/tiff-3.8.2/man/TIFFGetField.3tiff rename to libs/tiff-4.0.2/man/TIFFGetField.3tiff index 907cc4b491..0624ee9bff 100644 --- a/libs/tiff-3.8.2/man/TIFFGetField.3tiff +++ b/libs/tiff-4.0.2/man/TIFFGetField.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFGetField.3tiff,v 1.4 2006/01/02 23:50:44 bfriesen Exp $ +.\" $Id: TIFFGetField.3tiff,v 1.6 2012-05-19 23:15:22 bfriesen Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -147,7 +147,7 @@ TIFFTAG_PHOTOSHOP 2 uint32*,void** count, data TIFFTAG_PLANARCONFIG 1 uint16* TIFFTAG_PREDICTOR 1 uint16* TIFFTAG_PRIMARYCHROMATICITIES 1 float** 6-entry array -TIFFTAG_REFERENCEBLACKWHITE 1 float** 2*SamplesPerPixel array +TIFFTAG_REFERENCEBLACKWHITE 1 float** 6-entry array TIFFTAG_RESOLUTIONUNIT 1 uint16* TIFFTAG_RICHTIFFIPTC 2 uint32*,void** count, data TIFFTAG_ROWSPERSTRIP 1 uint32* @@ -188,14 +188,16 @@ is one, then a single array is returned; otherwise three arrays are returned. Annex B.3 "Embedding ICC Profiles in TIFF Files" (available at http://www.color.org) for an explanation. .SH AUTOREGISTERED TAGS -If you can't find the tag in the table above that means this is unsupported -tag. But you still be able to read it's value if you know the data type of +If you can't find the tag in the table above that means this is an unsupported +tag and is not directly supported by +.BR libtiff(3TIFF) +library. You will still be able to read it's value if you know the data type of that tag. For example, if you want to read the LONG value from the tag 33424 and ASCII string from the tag 36867 you can use the following code: .PP .RS .nf -uint16 count; +uint32 count; void *data; TIFFGetField(tiff, 33424, &count, &data); @@ -205,11 +207,6 @@ printf("Tag %d: %s, count %d\n", 36867, (char *)data, count); .fi .RE .PP - - -is not supported by -.BR libtiff(3TIFF), -library .SH RETURN VALUES 1 is returned if the tag is defined in the current directory; otherwise a 0 is returned. diff --git a/libs/tiff-3.8.2/man/TIFFOpen.3tiff b/libs/tiff-4.0.2/man/TIFFOpen.3tiff similarity index 99% rename from libs/tiff-3.8.2/man/TIFFOpen.3tiff rename to libs/tiff-4.0.2/man/TIFFOpen.3tiff index dfb4c454d7..f420931386 100644 --- a/libs/tiff-3.8.2/man/TIFFOpen.3tiff +++ b/libs/tiff-4.0.2/man/TIFFOpen.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFOpen.3tiff,v 1.2 2005/07/01 12:36:22 dron Exp $ +.\" $Id: TIFFOpen.3tiff,v 1.2 2005-07-01 12:36:22 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFPrintDirectory.3tiff b/libs/tiff-4.0.2/man/TIFFPrintDirectory.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFPrintDirectory.3tiff rename to libs/tiff-4.0.2/man/TIFFPrintDirectory.3tiff index 73cc734823..437b09e2c6 100644 --- a/libs/tiff-3.8.2/man/TIFFPrintDirectory.3tiff +++ b/libs/tiff-4.0.2/man/TIFFPrintDirectory.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFPrintDirectory.3tiff,v 1.1 2004/11/11 14:39:16 dron Exp $ +.\" $Id: TIFFPrintDirectory.3tiff,v 1.1 2004-11-11 14:39:16 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFRGBAImage.3tiff b/libs/tiff-4.0.2/man/TIFFRGBAImage.3tiff similarity index 99% rename from libs/tiff-3.8.2/man/TIFFRGBAImage.3tiff rename to libs/tiff-4.0.2/man/TIFFRGBAImage.3tiff index 5a9f83b924..ef1a85cb4a 100644 --- a/libs/tiff-3.8.2/man/TIFFRGBAImage.3tiff +++ b/libs/tiff-4.0.2/man/TIFFRGBAImage.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFRGBAImage.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFRGBAImage.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadDirectory.3tiff b/libs/tiff-4.0.2/man/TIFFReadDirectory.3tiff similarity index 94% rename from libs/tiff-3.8.2/man/TIFFReadDirectory.3tiff rename to libs/tiff-4.0.2/man/TIFFReadDirectory.3tiff index a86bd829d3..000bf0ae09 100644 --- a/libs/tiff-3.8.2/man/TIFFReadDirectory.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadDirectory.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadDirectory.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadDirectory.3tiff,v 1.3 2010-12-12 01:45:35 faxguy Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -119,20 +119,20 @@ This error is not fatal. An unknown tag was encountered in the directory; the library ignores all such tags. .PP -\fBTIFF directory is missing requred "ImageLength" field\fP. +\fBTIFF directory is missing required "ImageLength" field\fP. The image violates the specification by not having a necessary field. There is no way for the library to recover from this error. .PP -\fBTIFF directory is missing requred "PlanarConfig" field\fP. +\fBTIFF directory is missing required "PlanarConfig" field\fP. The image violates the specification by not having a necessary field. There is no way for the library to recover from this error. .PP -\fBTIFF directory is missing requred "StripOffsets" field\fP. +\fBTIFF directory is missing required "StripOffsets" field\fP. The image has multiple strips, but is missing the tag that specifies the file offset to each strip of data. There is no way for the library to recover from this error. .PP -\fBTIFF directory is missing requred "TileOffsets" field\fP. +\fBTIFF directory is missing required "TileOffsets" field\fP. The image has multiple tiles, but is missing the tag that specifies the file offset to each tile of data. There is no way for the library to recover from this error. diff --git a/libs/tiff-3.8.2/man/TIFFReadEncodedStrip.3tiff b/libs/tiff-4.0.2/man/TIFFReadEncodedStrip.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFReadEncodedStrip.3tiff rename to libs/tiff-4.0.2/man/TIFFReadEncodedStrip.3tiff index 83a2644af6..d2d7b67461 100644 --- a/libs/tiff-3.8.2/man/TIFFReadEncodedStrip.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadEncodedStrip.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadEncodedStrip.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadEncodedStrip.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadEncodedTile.3tiff b/libs/tiff-4.0.2/man/TIFFReadEncodedTile.3tiff similarity index 92% rename from libs/tiff-3.8.2/man/TIFFReadEncodedTile.3tiff rename to libs/tiff-4.0.2/man/TIFFReadEncodedTile.3tiff index ed6b59ccec..5f6d900897 100644 --- a/libs/tiff-3.8.2/man/TIFFReadEncodedTile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadEncodedTile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadEncodedTile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadEncodedTile.3tiff,v 1.3 2006-10-13 07:22:01 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -23,7 +23,7 @@ .\" OF THIS SOFTWARE. .\" .if n .po 0 -.TH TIFFReadEncodedTile 3TIFF "October 15, 1995" "libtiff" +.TH TIFFReadEncodedTile 3TIFF "October 13, 2006" "libtiff" .SH NAME TIFFReadEncodedTile \- read and decode a tile of data from an open .SM TIFF @@ -31,7 +31,7 @@ file .SH SYNOPSIS .B "#include " .sp -.BI "int TIFFReadEncodedTile(TIFF *" tif ", u_long " tile ", u_char *" buf ", u_long " size ")" +.BI "int TIFFReadEncodedTile(TIFF *" tif ", ttile_t " tile ", tdata_t " buf ", tsize_t " size ")" .SH DESCRIPTION Read the specified tile of data and place up to .I size diff --git a/libs/tiff-3.8.2/man/TIFFReadRGBAImage.3tiff b/libs/tiff-4.0.2/man/TIFFReadRGBAImage.3tiff similarity index 94% rename from libs/tiff-3.8.2/man/TIFFReadRGBAImage.3tiff rename to libs/tiff-4.0.2/man/TIFFReadRGBAImage.3tiff index 5af8295d52..5d43ce3962 100644 --- a/libs/tiff-3.8.2/man/TIFFReadRGBAImage.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadRGBAImage.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadRGBAImage.3tiff,v 1.3 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadRGBAImage.3tiff,v 1.4 2006-10-13 07:22:01 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -23,7 +23,7 @@ .\" OF THIS SOFTWARE. .\" .if n .po 0 -.TH TIFFReadRGBAImage 3TIFF "October 29, 2004" "libtiff" +.TH TIFFReadRGBAImage 3TIFF "October 13, 2006" "libtiff" .SH NAME TIFFReadRGBAImage, TIFFReadRGBAImageOriented \- read and decode an image into a fixed-format raster @@ -38,9 +38,9 @@ into a fixed-format raster .br .B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" .sp -.BI "int TIFFReadRGBAImage(TIFF *" tif ", u_long " width ", u_long " height ", u_long *" raster ", int " stopOnError ")" +.BI "int TIFFReadRGBAImage(TIFF *" tif ", uint32 " width ", uint32 " height ", uint32 *" raster ", int " stopOnError ")" .br -.BI "int TIFFReadRGBAImageOriented(TIFF *" tif ", u_long " width ", u_long " height ", u_long *" raster ", int " orientation ", int " stopOnError ")" +.BI "int TIFFReadRGBAImageOriented(TIFF *" tif ", uint32 " width ", uint32 " height ", uint32 *" raster ", int " orientation ", int " stopOnError ")" .br .SH DESCRIPTION .IR TIFFReadRGBAImage diff --git a/libs/tiff-3.8.2/man/TIFFReadRGBAStrip.3tiff b/libs/tiff-4.0.2/man/TIFFReadRGBAStrip.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFReadRGBAStrip.3tiff rename to libs/tiff-4.0.2/man/TIFFReadRGBAStrip.3tiff index 2d8b067a58..a8bb189955 100644 --- a/libs/tiff-3.8.2/man/TIFFReadRGBAStrip.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadRGBAStrip.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadRGBAStrip.3tiff,v 1.3 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadRGBAStrip.3tiff,v 1.3 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadRGBATile.3tiff b/libs/tiff-4.0.2/man/TIFFReadRGBATile.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFReadRGBATile.3tiff rename to libs/tiff-4.0.2/man/TIFFReadRGBATile.3tiff index 9b52f3d8a6..dfae1a9a22 100644 --- a/libs/tiff-3.8.2/man/TIFFReadRGBATile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadRGBATile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadRGBATile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadRGBATile.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadRawStrip.3tiff b/libs/tiff-4.0.2/man/TIFFReadRawStrip.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFReadRawStrip.3tiff rename to libs/tiff-4.0.2/man/TIFFReadRawStrip.3tiff index 1d4cac895f..1f2d1d1eb0 100644 --- a/libs/tiff-3.8.2/man/TIFFReadRawStrip.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadRawStrip.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadRawStrip.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadRawStrip.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadRawTile.3tiff b/libs/tiff-4.0.2/man/TIFFReadRawTile.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFReadRawTile.3tiff rename to libs/tiff-4.0.2/man/TIFFReadRawTile.3tiff index 5d4a56eab4..3945dd904f 100644 --- a/libs/tiff-3.8.2/man/TIFFReadRawTile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadRawTile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadRawTile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadRawTile.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadScanline.3tiff b/libs/tiff-4.0.2/man/TIFFReadScanline.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFReadScanline.3tiff rename to libs/tiff-4.0.2/man/TIFFReadScanline.3tiff index 0a46d584ed..7baf651998 100644 --- a/libs/tiff-3.8.2/man/TIFFReadScanline.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadScanline.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadScanline.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadScanline.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFReadTile.3tiff b/libs/tiff-4.0.2/man/TIFFReadTile.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFReadTile.3tiff rename to libs/tiff-4.0.2/man/TIFFReadTile.3tiff index 512092d20c..4a9b20d586 100644 --- a/libs/tiff-3.8.2/man/TIFFReadTile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFReadTile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFReadTile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFReadTile.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFSetDirectory.3tiff b/libs/tiff-4.0.2/man/TIFFSetDirectory.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFSetDirectory.3tiff rename to libs/tiff-4.0.2/man/TIFFSetDirectory.3tiff index cdd8e4628d..162d3107d1 100644 --- a/libs/tiff-3.8.2/man/TIFFSetDirectory.3tiff +++ b/libs/tiff-4.0.2/man/TIFFSetDirectory.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFSetDirectory.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFSetDirectory.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFSetField.3tiff b/libs/tiff-4.0.2/man/TIFFSetField.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFSetField.3tiff rename to libs/tiff-4.0.2/man/TIFFSetField.3tiff index cd70005fd6..33e94717f2 100644 --- a/libs/tiff-3.8.2/man/TIFFSetField.3tiff +++ b/libs/tiff-4.0.2/man/TIFFSetField.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFSetField.3tiff,v 1.4 2006/01/02 23:50:44 bfriesen Exp $ +.\" $Id: TIFFSetField.3tiff,v 1.5 2010-05-06 02:54:46 olivier Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -146,7 +146,7 @@ TIFFTAG_PHOTOSHOP ? uint32,void* count, data TIFFTAG_PLANARCONFIG 1 uint16 \(dg TIFFTAG_PREDICTOR 1 uint16 \(dg TIFFTAG_PRIMARYCHROMATICITIES 1 float* 6-entry array -TIFFTAG_REFERENCEBLACKWHITE 1 float* \(dg 2*SamplesPerPixel array +TIFFTAG_REFERENCEBLACKWHITE 1 float* \(dg 6-entry array TIFFTAG_RESOLUTIONUNIT 1 uint16 TIFFTAG_RICHTIFFIPTC 2 uint32,void* count, data TIFFTAG_ROWSPERSTRIP 1 uint32 \(dg must be > 0 diff --git a/libs/tiff-3.8.2/man/TIFFWarning.3tiff b/libs/tiff-4.0.2/man/TIFFWarning.3tiff similarity index 96% rename from libs/tiff-3.8.2/man/TIFFWarning.3tiff rename to libs/tiff-4.0.2/man/TIFFWarning.3tiff index 0a7142910f..32339aa131 100644 --- a/libs/tiff-3.8.2/man/TIFFWarning.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWarning.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWarning.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWarning.3tiff,v 1.3 2012-06-01 22:02:44 fwarmerdam Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -31,7 +31,7 @@ TIFFWarning, TIFFSetWarningHandler \- library warning interface .sp .BI "void TIFFWarning(const char *" module ", const char *" fmt ", " ... ")" .sp -.B "#include " +.B "#include " .sp .BI "typedef void (*TIFFWarningHandler)(const char *" module ", const char *" fmt ", va_list " ap ");" .sp diff --git a/libs/tiff-3.8.2/man/TIFFWriteDirectory.3tiff b/libs/tiff-4.0.2/man/TIFFWriteDirectory.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFWriteDirectory.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteDirectory.3tiff index 85b267b6e1..b8de6bf58e 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteDirectory.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteDirectory.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteDirectory.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteDirectory.3tiff,v 1.3 2010-12-12 01:45:35 faxguy Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -61,7 +61,7 @@ have an established location in the file. It will rewrite the directory, but instead of place it at it's old location (as .IR TIFFWriteDirectory would) it will place them at the end of the file, correcting the pointer from -the preceeding directory or file header to point to it's new location. This +the preceding directory or file header to point to it's new location. This is particularly important in cases where the size of the directory and pointed to data has grown, so it won't fit in the space available at the old location. diff --git a/libs/tiff-3.8.2/man/TIFFWriteEncodedStrip.3tiff b/libs/tiff-4.0.2/man/TIFFWriteEncodedStrip.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFWriteEncodedStrip.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteEncodedStrip.3tiff index 0427fa27e5..41306343cc 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteEncodedStrip.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteEncodedStrip.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteEncodedStrip.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteEncodedStrip.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFWriteEncodedTile.3tiff b/libs/tiff-4.0.2/man/TIFFWriteEncodedTile.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFWriteEncodedTile.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteEncodedTile.3tiff index 20cd1aa2b2..4bb471f8ce 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteEncodedTile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteEncodedTile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteEncodedTile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteEncodedTile.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFWriteRawStrip.3tiff b/libs/tiff-4.0.2/man/TIFFWriteRawStrip.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFWriteRawStrip.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteRawStrip.3tiff index 43b4a17bdc..0fed3aa371 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteRawStrip.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteRawStrip.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteRawStrip.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteRawStrip.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFWriteRawTile.3tiff b/libs/tiff-4.0.2/man/TIFFWriteRawTile.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFWriteRawTile.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteRawTile.3tiff index c6dbd87a18..d422e588c9 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteRawTile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteRawTile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteRawTile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteRawTile.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFWriteScanline.3tiff b/libs/tiff-4.0.2/man/TIFFWriteScanline.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFWriteScanline.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteScanline.3tiff index c8042f968c..0dd35f51bc 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteScanline.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteScanline.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteScanline.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteScanline.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFWriteTile.3tiff b/libs/tiff-4.0.2/man/TIFFWriteTile.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFWriteTile.3tiff rename to libs/tiff-4.0.2/man/TIFFWriteTile.3tiff index c6516af804..08250f7ce3 100644 --- a/libs/tiff-3.8.2/man/TIFFWriteTile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFWriteTile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFWriteTile.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFWriteTile.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFbuffer.3tiff b/libs/tiff-4.0.2/man/TIFFbuffer.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFbuffer.3tiff rename to libs/tiff-4.0.2/man/TIFFbuffer.3tiff index 5b4595305c..a4446cd960 100644 --- a/libs/tiff-3.8.2/man/TIFFbuffer.3tiff +++ b/libs/tiff-4.0.2/man/TIFFbuffer.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFbuffer.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFbuffer.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1995 Sam Leffler .\" Copyright (c) 1995 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFcodec.3tiff b/libs/tiff-4.0.2/man/TIFFcodec.3tiff similarity index 95% rename from libs/tiff-3.8.2/man/TIFFcodec.3tiff rename to libs/tiff-4.0.2/man/TIFFcodec.3tiff index 55d0d38310..78a0f02e97 100644 --- a/libs/tiff-3.8.2/man/TIFFcodec.3tiff +++ b/libs/tiff-4.0.2/man/TIFFcodec.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFcodec.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFcodec.3tiff,v 1.3 2011-08-02 14:09:43 bfriesen Exp $ .\" .\" Copyright (c) 1995 Sam Leffler .\" Copyright (c) 1995 Silicon Graphics, Inc. @@ -61,7 +61,7 @@ If the specified already has a registered codec then it is .I overridden and any images with data encoded with this -compression scheme will be decoded using the supplied coded. +compression scheme will be decoded using the supplied codec. .PP .I TIFFIsCODECConfigured returns 1 if the codec is configured and working. Otherwise 0 will be returned. diff --git a/libs/tiff-3.8.2/man/TIFFcolor.3tiff b/libs/tiff-4.0.2/man/TIFFcolor.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFcolor.3tiff rename to libs/tiff-4.0.2/man/TIFFcolor.3tiff index a3faf79fcb..e5d27270ea 100644 --- a/libs/tiff-3.8.2/man/TIFFcolor.3tiff +++ b/libs/tiff-4.0.2/man/TIFFcolor.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFcolor.3tiff,v 1.3 2006/03/23 14:54:02 dron Exp $ +.\" $Id: TIFFcolor.3tiff,v 1.4 2009-11-30 12:22:26 fwarmerdam Exp $ .\" .\" Copyright (c) 2003, Andrey Kiselev .\" @@ -33,7 +33,7 @@ TIFFXYZToRGB \- color conversion routines. .br .BI "void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *" ycbcr ", uint32 " Y ", int32 " Cb ", int32 " Cr ", uint32 *" R ", uint32 *" G ", uint32 *" B " );" .sp -.BI "int TIFFCIELabToRGBInit(TIFFCIELabToRGB *" cielab ", TIFFDisplay *" display ", float *" refWhite ");" +.BI "int TIFFCIELabToRGBInit(TIFFCIELabToRGB *" cielab ", const TIFFDisplay *" display ", float *" refWhite ");" .br .BI "void TIFFCIELabToXYZ(TIFFCIELabToRGB *" cielab ", uint32 " L ", int32 " a ", int32 " b ", float *" X ", float *" Y ", float *" Z ");" .br diff --git a/libs/tiff-3.8.2/man/TIFFmemory.3tiff b/libs/tiff-4.0.2/man/TIFFmemory.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFmemory.3tiff rename to libs/tiff-4.0.2/man/TIFFmemory.3tiff index eaca15f08d..55f446b44c 100644 --- a/libs/tiff-3.8.2/man/TIFFmemory.3tiff +++ b/libs/tiff-4.0.2/man/TIFFmemory.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFmemory.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFmemory.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1995 Sam Leffler .\" Copyright (c) 1995 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFquery.3tiff b/libs/tiff-4.0.2/man/TIFFquery.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFquery.3tiff rename to libs/tiff-4.0.2/man/TIFFquery.3tiff index 7e84097385..8bddc889fc 100644 --- a/libs/tiff-3.8.2/man/TIFFquery.3tiff +++ b/libs/tiff-4.0.2/man/TIFFquery.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFquery.3tiff,v 1.1 2004/11/11 14:39:16 dron Exp $ +.\" $Id: TIFFquery.3tiff,v 1.1 2004-11-11 14:39:16 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFsize.3tiff b/libs/tiff-4.0.2/man/TIFFsize.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFsize.3tiff rename to libs/tiff-4.0.2/man/TIFFsize.3tiff index ae6346c5a6..6de9084ad7 100644 --- a/libs/tiff-3.8.2/man/TIFFsize.3tiff +++ b/libs/tiff-4.0.2/man/TIFFsize.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFsize.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFsize.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFstrip.3tiff b/libs/tiff-4.0.2/man/TIFFstrip.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFstrip.3tiff rename to libs/tiff-4.0.2/man/TIFFstrip.3tiff index 7c383c1c6d..bb9658e50b 100644 --- a/libs/tiff-3.8.2/man/TIFFstrip.3tiff +++ b/libs/tiff-4.0.2/man/TIFFstrip.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFstrip.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFstrip.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1992-1997 Sam Leffler .\" Copyright (c) 1992-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFswab.3tiff b/libs/tiff-4.0.2/man/TIFFswab.3tiff similarity index 97% rename from libs/tiff-3.8.2/man/TIFFswab.3tiff rename to libs/tiff-4.0.2/man/TIFFswab.3tiff index a72ea1bdf3..d6432fa527 100644 --- a/libs/tiff-3.8.2/man/TIFFswab.3tiff +++ b/libs/tiff-4.0.2/man/TIFFswab.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFswab.3tiff,v 1.2 2005/11/02 11:07:18 dron Exp $ +.\" $Id: TIFFswab.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/TIFFtile.3tiff b/libs/tiff-4.0.2/man/TIFFtile.3tiff similarity index 98% rename from libs/tiff-3.8.2/man/TIFFtile.3tiff rename to libs/tiff-4.0.2/man/TIFFtile.3tiff index 94bab6c041..5431f31a80 100644 --- a/libs/tiff-3.8.2/man/TIFFtile.3tiff +++ b/libs/tiff-4.0.2/man/TIFFtile.3tiff @@ -1,4 +1,4 @@ -.\" $Id: TIFFtile.3tiff,v 1.2 2005/11/02 11:07:19 dron Exp $ +.\" $Id: TIFFtile.3tiff,v 1.2 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/bmp2tiff.1 b/libs/tiff-4.0.2/man/bmp2tiff.1 similarity index 93% rename from libs/tiff-3.8.2/man/bmp2tiff.1 rename to libs/tiff-4.0.2/man/bmp2tiff.1 index f63ed867e2..f5d68ce011 100644 --- a/libs/tiff-3.8.2/man/bmp2tiff.1 +++ b/libs/tiff-4.0.2/man/bmp2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: bmp2tiff.1,v 1.6 2006/03/23 14:54:02 dron Exp $ +.\" $Id: bmp2tiff.1,v 1.7 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 2004, Andrey Kiselev .\" @@ -32,7 +32,10 @@ file from a Microsoft Windows Device Independent Bitmap image file [ .I options ] -.I input.bmp [input2.bmp ...] +.I input.bmp +[ +.I input2.bmp ...\& +] .I output.tiff .SH DESCRIPTION .I bmp2tiff @@ -45,7 +48,7 @@ output file will be created. By default, the image is created with data samples packed (\c .IR PlanarConfiguration =1), compressed with the PackBits algorithm (\c -.IR Compression = 32773), +.IR Compression =32773), and with each strip no more than 8 kilobytes. These characteristics can overridden, or explicitly specified with the options described below. @@ -55,17 +58,17 @@ with the options described below. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm (the default), -.B "-c jpeg" +.B "\-c jpeg" for the baseline JPEG compression algorithm, -.B "-c zip +.B "\-c zip" for the Deflate compression algorithm, and .B "\-c lzw" for Lempel-Ziv & Welch. .TP -.B \-r +.BI \-r " number" Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. diff --git a/libs/tiff-3.8.2/man/fax2ps.1 b/libs/tiff-4.0.2/man/fax2ps.1 similarity index 97% rename from libs/tiff-3.8.2/man/fax2ps.1 rename to libs/tiff-4.0.2/man/fax2ps.1 index 9482d8cf05..9525f20b0c 100644 --- a/libs/tiff-3.8.2/man/fax2ps.1 +++ b/libs/tiff-4.0.2/man/fax2ps.1 @@ -1,4 +1,4 @@ -.\" $Id: fax2ps.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: fax2ps.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -22,6 +22,7 @@ .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" +.ds Ps PostScript .if n .po 0 .TH FAX2PS 1 "November 2, 2005" "libtiff" .SH NAME @@ -33,7 +34,7 @@ facsimile to compressed \*(Ps\(tm [ .I options ] [ -.IR file ... +.I file ...\& ] .SH DESCRIPTION .I fax2ps @@ -88,7 +89,7 @@ This algorithm can, however, be ineffective for continuous-tone and white-on-black images. For these images, it sometimes is more efficient to send the raster bitmap image directly; see -.IR tiff2ps (1). +.BR tiff2ps (1). .SH OPTIONS .TP 10 .BI \-p " number" diff --git a/libs/tiff-3.8.2/man/fax2tiff.1 b/libs/tiff-4.0.2/man/fax2tiff.1 similarity index 99% rename from libs/tiff-3.8.2/man/fax2tiff.1 rename to libs/tiff-4.0.2/man/fax2tiff.1 index 060fa2bc96..873cab176a 100644 --- a/libs/tiff-3.8.2/man/fax2tiff.1 +++ b/libs/tiff-4.0.2/man/fax2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: fax2tiff.1,v 1.6 2005/11/02 11:07:19 dron Exp $ +.\" $Id: fax2tiff.1,v 1.7 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1990-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -223,7 +223,7 @@ is specified), attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip (with except of G3/G4 compression schemes). If you specify special value -.B -1 +.B \-1 it will results in infinite number of the rows per strip. The entire image will be the one strip in that case. This is default in case of G3/G4 output compression schemes. diff --git a/libs/tiff-3.8.2/man/gif2tiff.1 b/libs/tiff-4.0.2/man/gif2tiff.1 similarity index 96% rename from libs/tiff-3.8.2/man/gif2tiff.1 rename to libs/tiff-4.0.2/man/gif2tiff.1 index d52b275081..5f01d8dcdf 100644 --- a/libs/tiff-3.8.2/man/gif2tiff.1 +++ b/libs/tiff-4.0.2/man/gif2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: gif2tiff.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: gif2tiff.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -52,9 +52,9 @@ with the options described below. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm, -.B "-c zip" +.B "\-c zip" for the Deflate compression algorithm, and .B "\-c lzw" diff --git a/libs/tiff-3.8.2/man/libtiff.3tiff b/libs/tiff-4.0.2/man/libtiff.3tiff similarity index 99% rename from libs/tiff-3.8.2/man/libtiff.3tiff rename to libs/tiff-4.0.2/man/libtiff.3tiff index 0d8885f04a..710f9085ee 100644 --- a/libs/tiff-3.8.2/man/libtiff.3tiff +++ b/libs/tiff-4.0.2/man/libtiff.3tiff @@ -1,4 +1,4 @@ -.\" $Id: libtiff.3tiff,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: libtiff.3tiff,v 1.3 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/pal2rgb.1 b/libs/tiff-4.0.2/man/pal2rgb.1 similarity index 98% rename from libs/tiff-3.8.2/man/pal2rgb.1 rename to libs/tiff-4.0.2/man/pal2rgb.1 index 8dd87ace64..0ac2e5af41 100644 --- a/libs/tiff-3.8.2/man/pal2rgb.1 +++ b/libs/tiff-4.0.2/man/pal2rgb.1 @@ -1,4 +1,4 @@ -.\" $Id: pal2rgb.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: pal2rgb.1,v 1.3 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1990-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/ppm2tiff.1 b/libs/tiff-4.0.2/man/ppm2tiff.1 similarity index 98% rename from libs/tiff-3.8.2/man/ppm2tiff.1 rename to libs/tiff-4.0.2/man/ppm2tiff.1 index b951444ed3..882fd0451d 100644 --- a/libs/tiff-3.8.2/man/ppm2tiff.1 +++ b/libs/tiff-4.0.2/man/ppm2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: ppm2tiff.1,v 1.5 2006/03/01 11:20:33 dron Exp $ +.\" $Id: ppm2tiff.1,v 1.5 2006-03-01 11:20:33 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/ras2tiff.1 b/libs/tiff-4.0.2/man/ras2tiff.1 similarity index 96% rename from libs/tiff-3.8.2/man/ras2tiff.1 rename to libs/tiff-4.0.2/man/ras2tiff.1 index 57dd034ea9..0c78ddb621 100644 --- a/libs/tiff-3.8.2/man/ras2tiff.1 +++ b/libs/tiff-4.0.2/man/ras2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: ras2tiff.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: ras2tiff.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1990-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -65,11 +65,11 @@ is 24 or 1 (min-is-black) if the depth is not 24. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm, -.B "-c jpeg" +.B "\-c jpeg" for the baseline JPEG compression algorithm, -.B "-c zip +.B "\-c zip for the Deflate compression algorithm, and .B "\-c lzw" diff --git a/libs/tiff-3.8.2/man/raw2tiff.1 b/libs/tiff-4.0.2/man/raw2tiff.1 similarity index 86% rename from libs/tiff-3.8.2/man/raw2tiff.1 rename to libs/tiff-4.0.2/man/raw2tiff.1 index dd68447c70..3e832df28e 100644 --- a/libs/tiff-3.8.2/man/raw2tiff.1 +++ b/libs/tiff-4.0.2/man/raw2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: raw2tiff.1,v 1.5 2005/11/02 11:07:19 dron Exp $ +.\" $Id: raw2tiff.1,v 1.7 2009-08-24 19:13:40 bfriesen Exp $ .\" .\" Copyright (c) 1990-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -44,99 +44,102 @@ By default, the image is created with data samples packed (\c .IR PlanarConfiguration =1), compressed with the PackBits algorithm (\c -.IR Compression = 32773), +.IR Compression =32773), and with each strip no more than 8 kilobytes. These characteristics can overridden, or explicitly specified with the options described below. .SH OPTIONS .TP -.B \-H +.BI \-H " number" size of input image file header in bytes (0 by default). This amount of data just will be skipped from the start of file while reading. .TP -.B \-w +.BI \-w " number" width of input image in pixels (can be guessed, see .SM .B "GUESSING THE IMAGE GEOMETRY" below). .TP -.B \-l -length of input image in lines(can be guessed, see +.BI \-l " number" +length of input image in lines (can be guessed, see .SM .B "GUESSING THE IMAGE GEOMETRY" below). .TP -.B \-b +.BI \-b " number" number of bands in input image (1 by default). .TP -.B \-d data_type +.BI \-d " data_type" type of samples in input image, where -.B data_type +.I data_type may be: +.ta \w'\fBdouble \fR'u .br -.I byte\t\t +.B byte\t 8-bit unsigned integer (default), .br -.I short\t +.B short\t 16-bit unsigned integer, .br -.I long\t\t +.B long\t 32-bit unsigned integer, .br -.I sbyte\t +.B sbyte\t 8-bit signed integer, .br -.I sshort\t +.B sshort\t 16-bit signed integer, .br -.I slong\t +.B slong\t 32-bit signed integer, .br -.I float\t +.B float\t 32-bit IEEE floating point, .br -.I double\t -64-bit IEEE floating point, +.B double\t +64-bit IEEE floating point. .TP -.B \-i config +.BI \-i " config" type of samples interleaving in input image, where -.B config +.I config may be: +.ta \w'\fBpixel \fR'u .br -.I pixel\t +.B pixel\t pixel interleaved data (default), .br -.I band\t\t +.B band\t band interleaved data. .TP -.B \-p photo +.BI \-p " photo" photometric interpretation (color space) of the input image, where -.B photo +.I photo may be: +.ta \w'\fBminiswhite \fR'u .br -.I miniswhite +.B miniswhite\t white color represented with 0 value, .br -.I minisblack +.B minisblack\t black color represented with 0 value (default), .br -.I rgb\t\t +.B rgb\t image has RGB color model, .br -.I cmyk\t\t +.B cmyk\t image has CMYK (separated) color model, .br -.I ycbcr\t\t +.B ycbcr\t image has YCbCr color model, .br -.I cielab\t +.B cielab\t image has CIE L*a*b color model, .br -.I icclab\t +.B icclab\t image has ICC L*a*b color model, .br -.I itulab\t -image has ITU L*a*b color model, +.B itulab\t +image has ITU L*a*b color model. .TP .B \-s swap bytes fetched from the input file. @@ -151,17 +154,17 @@ input data has MSB2LSB bit order. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm (the default), -.B "-c jpeg" +.B "\-c jpeg" for the baseline JPEG compression algorithm, -.B "-c zip +.B "\-c zip" for the Deflate compression algorithm, and .B "\-c lzw" for Lempel-Ziv & Welch. .TP -.B \-r +.BI \-r " number" Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. @@ -184,7 +187,7 @@ There is no magic, it is just a mathematical statistics, so it can be wrong in some cases. But for most ordinary images guessing method will work fine. .SH "SEE ALSO" .BR pal2rgb (1), -.bR tiffinfo (1), +.BR tiffinfo (1), .BR tiffcp (1), .BR tiffmedian (1), .BR libtiff (3) diff --git a/libs/tiff-3.8.2/man/rgb2ycbcr.1 b/libs/tiff-4.0.2/man/rgb2ycbcr.1 similarity index 95% rename from libs/tiff-3.8.2/man/rgb2ycbcr.1 rename to libs/tiff-4.0.2/man/rgb2ycbcr.1 index 487e5b6835..01a332ca07 100644 --- a/libs/tiff-3.8.2/man/rgb2ycbcr.1 +++ b/libs/tiff-4.0.2/man/rgb2ycbcr.1 @@ -1,4 +1,4 @@ -.\" $Header: /cvs/maptools/cvsroot/libtiff/man/rgb2ycbcr.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Header: /cvs/maptools/cvsroot/libtiff/man/rgb2ycbcr.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -70,11 +70,11 @@ rows per strip. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm (the default), -.B "-c jpeg" +.B "\-c jpeg" for the JPEG compression algorithm, -.B "-c zip" +.B "\-c zip" for the deflate compression algorithm, and .B "\-c lzw" diff --git a/libs/tiff-3.8.2/man/sgi2tiff.1 b/libs/tiff-4.0.2/man/sgi2tiff.1 similarity index 96% rename from libs/tiff-3.8.2/man/sgi2tiff.1 rename to libs/tiff-4.0.2/man/sgi2tiff.1 index 6494d27acf..650adb3cca 100644 --- a/libs/tiff-3.8.2/man/sgi2tiff.1 +++ b/libs/tiff-4.0.2/man/sgi2tiff.1 @@ -1,4 +1,4 @@ -.\" $Id: sgi2tiff.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: sgi2tiff.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1991-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -58,11 +58,11 @@ with the options described below. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm), -.B "-c jpeg" +.B "\-c jpeg" for the baseline JPEG compression algorithm, -.B "-c zip +.B "\-c zip for the Deflate compression algorithm, and .B "\-c lzw" diff --git a/libs/tiff-3.8.2/man/thumbnail.1 b/libs/tiff-4.0.2/man/thumbnail.1 similarity index 98% rename from libs/tiff-3.8.2/man/thumbnail.1 rename to libs/tiff-4.0.2/man/thumbnail.1 index e9d6213d0b..f4172bb6f5 100644 --- a/libs/tiff-3.8.2/man/thumbnail.1 +++ b/libs/tiff-4.0.2/man/thumbnail.1 @@ -1,4 +1,4 @@ -.\" $Id: thumbnail.1,v 1.2 2005/11/02 11:07:19 dron Exp $ +.\" $Id: thumbnail.1,v 1.2 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1994-1997 Sam Leffler .\" Copyright (c) 1994-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/tiff2bw.1 b/libs/tiff-4.0.2/man/tiff2bw.1 similarity index 95% rename from libs/tiff-3.8.2/man/tiff2bw.1 rename to libs/tiff-4.0.2/man/tiff2bw.1 index 01135bee1d..ccbe7e8fa0 100644 --- a/libs/tiff-3.8.2/man/tiff2bw.1 +++ b/libs/tiff-4.0.2/man/tiff2bw.1 @@ -1,4 +1,4 @@ -.\" $Id: tiff2bw.1,v 1.2 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiff2bw.1,v 1.3 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -31,7 +31,7 @@ image to greyscale .SH SYNOPSIS .B tiff2bw [ -options +.I options ] .I input.tif .I output.tif @@ -58,13 +58,13 @@ options may be used. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm, -.B "-c zip +.B "\-c zip for the Deflate compression algorithm, -.B "-c g3 +.B "\-c g3 for the CCITT Group 3 compression algorithm, -.B "-c g4 +.B "\-c g4 for the CCITT Group 4 compression algorithm, and .B "\-c lzw" diff --git a/libs/tiff-3.8.2/man/tiff2pdf.1 b/libs/tiff-4.0.2/man/tiff2pdf.1 similarity index 81% rename from libs/tiff-3.8.2/man/tiff2pdf.1 rename to libs/tiff-4.0.2/man/tiff2pdf.1 index a52c56b571..ba670cfba0 100644 --- a/libs/tiff-3.8.2/man/tiff2pdf.1 +++ b/libs/tiff-4.0.2/man/tiff2pdf.1 @@ -1,4 +1,4 @@ -.\" $Id: tiff2pdf.1,v 1.4 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiff2pdf.1,v 1.7 2010-12-11 22:47:49 faxguy Exp $ .\" .\" Copyright (c) 2003 Ross Finlayson .\" @@ -24,16 +24,17 @@ .\" Process this file with .\" groff -man -Tascii tiff2pdf.1 .\" -.TH TIFF2PDF 1 "November 2, 2005" "libtiff" +.TH TIFF2PDF 1 "April 20, 2006" "libtiff" .SH NAME -tiff2pdf - convert a TIFF image to a PDF document +tiff2pdf \- convert a TIFF image to a PDF document .SH SYNOPSIS -.B tiff2pdf [ +.B tiff2pdf +[ .I options -.B ] +] .I input.tiff .SH DESCRIPTION -.B tiff2pdf +.I tiff2pdf opens a TIFF image and writes a PDF document to standard output. .PP The program converts one TIFF file to one PDF file, including multiple page @@ -50,7 +51,7 @@ If the input TIFF file is of huge dimensions (greater than 10000 pixels height or width) convert the input image to a tiled TIFF if it is not already. .PP The standard output is standard output. Set the output file name with the -.BI -o output.pdf +.BI \-o " output.pdf" option. .PP All black and white files are compressed into a single strip CCITT G4 Fax @@ -107,11 +108,11 @@ length can be set by the option, the default unit is inch. .PP Various items of the output document information can be set with the -.B \-e, -.B \-c, -.B \-a, -.B \-t, -.B \-s, +.BR \-e , +.BR \-c , +.BR \-a , +.BR \-t , +.BR \-s , and .B \-k options. Setting the argument of the option to "" for these @@ -123,17 +124,23 @@ The Portable Document Format (PDF) specification is copyrighted by Adobe Systems, Incorporated. .SH OPTIONS .TP -.BI \-o output-file -Set the output to go to file +.BI \-o " output-file" +Set the output to go to file. .I output-file .TP .B \-j -Compress with JPEG (requires libjpeg configured with libtiff). +Compress with JPEG (requires +.I libjpeg +configured with +.IR libtiff ). .TP .B \-z -Compress with Zip/Deflate (requires zlib configured with libtiff). +Compress with Zip/Deflate (requires +.I zlib +configured with +.IR libtiff ). .TP -.BI \-q quality +.BI \-q " quality" Set the compression quality, 1-100 for JPEG. .TP .B \-n @@ -141,7 +148,7 @@ Do not allow data to be converted without uncompressing, no compressed data passthrough. .TP .BI \-b -Set PDF "Interpolate" user preference. +Set PDF ``Interpolate'' user preference. .TP .B \-d Do not compress (decompress). @@ -149,95 +156,98 @@ Do not compress (decompress). .B \-i Invert colors. .TP -.BI \-p paper-size -Set paper size, eg "letter", "legal", "A4". +.BI \-p " paper-size" +Set paper size, e.g., +.BR letter , +.BR legal , +.BR A4 . .TP -.BI \-u [i|m] +.B \-F +Cause the tiff to fill the PDF page. +.TP +.BR \-u " [" i | m ] Set distance unit, -.I i +.B i for inch, -.I m +.B m for centimeter. .TP -.BI \-w width +.BI \-w " width" Set width in units. .TP -.BI \-l length +.BI \-l " length" Set length in units. .TP -.BI \-x xres +.BI \-x " xres" Set x/width resolution default. .TP -.BI \-y yres +.BI \-y " yres" Set y/length resolution default. .TP -.BI \-r [d|o] +.BR \-r " [" d | o ] Set -.I d +.B d for resolution default for images without resolution, -.I o for resolution override for all images. +.B o +for resolution override for all images. .TP .BI \-f -Set PDF "Fit Window" user preference. +Set PDF ``Fit Window'' user preference. .TP -.BI \-e YYYYMMDDHHMMSS +.BI \-e " YYYYMMDDHHMMSS" Set document information date, overrides image or current date/time default, .I YYYYMMDDHHMMSS. .TP -.BI \-c creator +.BI \-c " creator" Set document information creator, overrides image software default. .TP -.BI \-a author -Set document information author, overrides image artist default +.BI \-a " author" +Set document information author, overrides image artist default. .TP -.BI \-t title -Set document information title, overrides image document name default +.BI \-t " title" +Set document information title, overrides image document name default. .TP -.BI \-s subject -Set document information subject, overrides image image description default +.BI \-s " subject" +Set document information subject, overrides image image description default. .TP -.BI \-k keywords +.BI \-k " keywords" Set document information keywords. .TP .B \-h List usage reminder to stderr and exit. -.TP .SH EXAMPLES .TP The following example would generate the file output.pdf from input.tiff. -.PP .RS -.NF -tiff2pdf -o output.pdf input.tiff -.FI +.nf +tiff2pdf \-o output.pdf input.tiff +.fi .RE .PP The following example would generate PDF output from input.tiff and write it to standard output. -.PP .RS -.NF +.nf tiff2pdf input.tiff -.FI +.fi .RE .PP The following example would generate the file output.pdf from input.tiff, putting the image pages on a letter sized page, compressing the output -with JPEG, with JPEG quality 75, setting the title to "Document", and setting -the "Fit Window" option. -.PP +with JPEG, with JPEG quality 75, setting the title to ``Document'', and setting +the ``Fit Window'' option. .RS -.NF -tiff2pdf -p letter -j -q 75 -t "Document" -f -o output.pdf input.tiff -.FI +.nf +tiff2pdf \-p letter \-j \-q 75 \-t "Document" \-f \-o output.pdf input.tiff +.fi .RE .SH BUGS Please report bugs via the web interface at .IP \%http://bugzilla.remotesensing.org/enter_bug.cgi?product=libtiff .SH "SEE ALSO" -.BR libtiff (3) , -.BR tiffcp (1) , +.BR libtiff (3), +.BR tiffcp (1), .BR tiff2ps (1) .PP Libtiff library home page: diff --git a/libs/tiff-3.8.2/man/tiff2ps.1 b/libs/tiff-4.0.2/man/tiff2ps.1 similarity index 83% rename from libs/tiff-3.8.2/man/tiff2ps.1 rename to libs/tiff-4.0.2/man/tiff2ps.1 index 87548e4278..c3a9bacf6b 100644 --- a/libs/tiff-3.8.2/man/tiff2ps.1 +++ b/libs/tiff-4.0.2/man/tiff2ps.1 @@ -1,4 +1,4 @@ -.\" $Id: tiff2ps.1,v 1.8 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiff2ps.1,v 1.10 2009-01-12 02:05:19 bfriesen Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -22,12 +22,13 @@ .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" +.ds Ps PostScript .if n .po 0 .TH TIFF2PS 1 "November 2, 2005" "libtiff" .SH NAME tiff2ps \- convert a .SM TIFF -image to \*(Ps\(tm +image to \*(Ps\*(Tm .SH SYNOPSIS .B tiff2ps [ @@ -108,18 +109,23 @@ the height of the printed image. .TP .B \-c Center the image in the output. This option only shows an effect if both -the -w and the -h option are given. +the +.B \-w +and the +.B \-h +option are given. .TP .B \-d Set the initial .SM TIFF directory to the specified directory number. -(NB: directories are numbered starting at zero.) +(NB: Directories are numbered starting at zero.) This option is useful for selecting individual pages in a multi-page (e.g. facsimile) file. .TP .B \-e -Force the generation of Encapsulated \*(Ps (implies -z). +Force the generation of Encapsulated \*(Ps (implies +.BR \-z ). .TP .B \-h Specify the vertical size of the printed area (in inches). @@ -130,6 +136,13 @@ be split in several pages. Option .B \-L may be used for specifying size of split images overlapping. .TP +.B \-W +Specify the maximum width of image (in inches). Images with larger sizes will +be split in several pages. Options +.B \-L +and +.B \-W +are mutually exclusive. .B \-i Enable/disable pixel interpolation. This option requires a single numeric value: zero to disable pixel interpolation and @@ -139,6 +152,8 @@ non-zero to enable. The default is enabled. Specify the size of overlapping for split images (in inches). Used in conjunction with .B \-H +option and +.B \-W option. .TP .B \-l @@ -147,14 +162,17 @@ the width of the printed image. .TP .B \-m Where possible render using the -.B imagemask -\*(Ps operator instead of the image operator. When this option is specified +.I imagemask +\*(Ps operator instead of the +.I image +operator. When this option is specified .I tiff2ps will use -.B imagemask +.I imagemask for rendering 1 bit deep images. If this option is not specified -or if the image depth is greater than 1 then the image operator -is used. +or if the image depth is greater than 1 then the +.I image +operator is used. .TP .B \-o Set the initial @@ -163,13 +181,18 @@ directory to the .SM IFD at the specified file offset. This option is useful for selecting thumbnail images and the -like which are hidden using the SubIFD tag. +like which are hidden using the +.I SubIFD +tag. .TP .B \-p Force the generation of (non-Encapsulated) \*(Ps. .TP -.B \-r -Rotate image by 180 degrees. +.B \-r 90|180|270|auto +Rotate image by 90, 180, 270 degrees or auto. Auto picks the best +fit for the image on the specified paper size (eg portrait +or landscape) if -h or -w is specified. Rotation is in degrees +counterclockwise. Auto rotates 90 degrees ccw to produce landscape. .TP .B \-s Generate output for a single IFD (page) in the input file. @@ -195,7 +218,7 @@ page and this option has no affect. The following generates \*(Ps Level 2 for all pages of a facsimile: .RS .nf -tiff2ps -a2 fax.tif | lpr +tiff2ps \-a2 fax.tif | lpr .fi .RE Note also that if you have version 2.6.1 or newer of Ghostscript then you @@ -205,15 +228,15 @@ To generate Encapsulated \*(Ps for a the image at directory 2 of an image use: .RS .nf -tiff2ps -d 1 foo.tif +tiff2ps \-d 1 foo.tif .fi .RE -(notice that directories are numbered starting at zero.) +(Notice that directories are numbered starting at zero.) .PP If you have a long image, it may be split in several pages: .RS .nf -tiff2ps -h11 -w8.5 -H14 -L.5 foo.tif > foo.ps +tiff2ps \-h11 \-w8.5 \-H14 \-L.5 foo.tif > foo.ps .fi .RE The page size is set to 8.5x11 by @@ -234,8 +257,8 @@ This conversion results in output that is six times bigger than the original image and which takes a long time to send to a printer over a serial line. Matters are even worse for 4-, 2-, and 1-bit palette images. -.SH BUGS -Does not handle tiled images when generating PS Level I output. +.PP +Does not handle tiled images when generating \*(Ps Level I output. .SH "SEE ALSO" .BR pal2rgb (1), .BR tiffinfo (1), diff --git a/libs/tiff-3.8.2/man/tiff2rgba.1 b/libs/tiff-4.0.2/man/tiff2rgba.1 similarity index 92% rename from libs/tiff-3.8.2/man/tiff2rgba.1 rename to libs/tiff-4.0.2/man/tiff2rgba.1 index a71d2d659c..c551656387 100644 --- a/libs/tiff-3.8.2/man/tiff2rgba.1 +++ b/libs/tiff-4.0.2/man/tiff2rgba.1 @@ -1,4 +1,4 @@ -.\" $Id: tiff2rgba.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiff2rgba.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -31,7 +31,7 @@ image to RGBA color space .SH SYNOPSIS .B tiff2rgba [ -options +.I options ] .I input.tif .I output.tif @@ -50,7 +50,9 @@ esoteric combinations of BitsPerSample, photometric interpretation, block organization and planar configuration. .P The generated images are stripped images with four samples per pixel -(red, green, blue and alpha) or if the -n flag is used, three samples +(red, green, blue and alpha) or if the +.B \-n +flag is used, three samples per pixel (red, green, and blue). The resulting images are always planar configuration contiguous. For this reason, this program is a useful utility for transform exotic TIFF files into a form ingestible by almost any TIFF @@ -61,11 +63,11 @@ supporting software. Specify a compression scheme to use when writing image data: .B "\-c none" for no compression (the default), -.B "-c packbits" +.B "\-c packbits" for the PackBits compression algorithm, -.B "-c zip +.B "\-c zip" for the Deflate compression algorithm, -.B "-c jpeg +.B "\-c jpeg" for the JPEG compression algorithm, and .B "\-c lzw" @@ -83,7 +85,9 @@ images on systems with limited RAM. .TP .B \-n Drop the alpha component from the output file, producing a pure RGB file. -Currently this does not work if the -b flag is also in effect. +Currently this does not work if the +.B \-b +flag is also in effect. .SH "SEE ALSO" .BR tiff2bw (1), .BR TIFFReadRGBAImage (3t), diff --git a/libs/tiff-3.8.2/man/tiffcmp.1 b/libs/tiff-4.0.2/man/tiffcmp.1 similarity index 91% rename from libs/tiff-3.8.2/man/tiffcmp.1 rename to libs/tiff-4.0.2/man/tiffcmp.1 index 185a0e62ce..961d81223b 100644 --- a/libs/tiff-3.8.2/man/tiffcmp.1 +++ b/libs/tiff-4.0.2/man/tiffcmp.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffcmp.1,v 1.4 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffcmp.1,v 1.6 2009-08-24 19:13:40 bfriesen Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -61,7 +61,7 @@ will terminate if it encounters any difference. .B \-l List each byte of image data that differs between the files. .TP -.B \-z number +.BI \-z " number" List specified number of image data bytes that differs between the files. .TP .B \-t @@ -70,14 +70,15 @@ Ignore any differences in directory tags. Tags that are not recognized by the library are not compared; they may also generate spurious diagnostics. .PP -The image data of tiled files is not compared, since the TIFFReadScanline() -function is used. A error will be reported for tiled files. +The image data of tiled files is not compared, since the +.I TIFFReadScanline() +function is used. An error will be reported for tiled files. .PP The pixel and/or sample number reported in differences may be off in some exotic cases. .SH "SEE ALSO" .BR pal2rgb (1), -.bR tiffinfo (1), +.BR tiffinfo (1), .BR tiffcp (1), .BR tiffmedian (1), .BR libtiff (3TIFF) diff --git a/libs/tiff-3.8.2/man/tiffcp.1 b/libs/tiff-4.0.2/man/tiffcp.1 similarity index 73% rename from libs/tiff-3.8.2/man/tiffcp.1 rename to libs/tiff-4.0.2/man/tiffcp.1 index ffad8ea339..5fdcc474d5 100644 --- a/libs/tiff-3.8.2/man/tiffcp.1 +++ b/libs/tiff-4.0.2/man/tiffcp.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffcp.1,v 1.6 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffcp.1,v 1.12 2010-12-23 13:38:47 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -23,7 +23,7 @@ .\" OF THIS SOFTWARE. .\" .if n .po 0 -.TH TIFFCP 1 "September 20, 2005" "libtiff" +.TH TIFFCP 1 "February 24, 2007" "libtiff" .SH NAME tiffcp \- copy (and possibly convert) a .SM TIFF @@ -60,7 +60,7 @@ in a file, but it is explicitly intended to not alter or convert the image data content in any way. .SH OPTIONS .TP -.B \-b image +.BI \-b " image" subtract the following monochrome image from all others processed. This can be used to remove a noise bias from a set of images. This bias image is typically an @@ -83,10 +83,12 @@ for no compression, for PackBits compression, .B lzw for Lempel-Ziv & Welch compression, -.B jpeg -for baseline JPEG compression, .B zip for Deflate compression, +.B lzma +for LZMA2 compression, +.B jpeg +for baseline JPEG compression, .B g3 for CCITT Group 3 (T.4) compression, and @@ -118,20 +120,33 @@ list to the ``g3'' option; e.g. .B "\-c g3:2d:fill" to get 2D-encoded data with byte-aligned EOL codes. .IP -.SM LZW +.SM LZW, Deflate +and +.SM LZMA2 compression can be specified together with a .I predictor -value. -A predictor value of 2 causes -each scanline of the output image to undergo horizontal -differencing before it is encoded; a value -of 1 forces each scanline to be encoded without differencing. -LZW-specific options are specified by appending a ``:''-separated -list to the ``lzw'' option; e.g. +value. A predictor value of 2 causes each scanline of the output image to +undergo horizontal differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. A value 3 is for floating point +predictor which you can use if the encoded data are in floating point format. +LZW-specific options are specified by appending a ``:''-separated list to the +``lzw'' option; e.g. .B "\-c lzw:2" for .SM LZW compression with horizontal differencing. +.IP +.SM Deflate +and +.SM LZMA2 +encoders support various compression levels (or encoder presets) set as +character ``p'' and a preset number. ``p1'' is the fastest one with the worst +compression ratio and ``p9'' is the slowest but with the best possible ratio; +e.g. +.B "\-c zip:3:p9" +for +.SM Deflate +encoding with maximum compression level and floating point predictor. .TP .B \-f Specify the bit fill order to use in writing output data. @@ -147,6 +162,9 @@ while will force data to be written with the FillOrder tag set to .SM MSB2LSB. .TP +.B \-i +Ignore non-fatal read errors and continue processing of the input file. +.TP .B \-l Specify the length of a tile (in pixels). .I tiffcp @@ -185,7 +203,7 @@ is specified), attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip. If you specify special value -.B -1 +.B \-1 it will results in infinite number of the rows per strip. The entire image will be the one strip in that case. .TP @@ -194,32 +212,38 @@ Force the output file to be written with data organized in strips (rather than tiles). .TP .B \-t -Force the output file to be written with data organized in tiles -(rather than strips). -options can be used to force the resultant image to be written -as strips or tiles of data, respectively. +Force the output file to be written with data organized in tiles (rather than +strips). options can be used to force the resultant image to be written as +strips or tiles of data, respectively. .TP .B \-w Specify the width of a tile (in pixels). .I tiffcp -attempts to set the tile dimensions so -that no more than 8 kilobytes of data appear in a tile. +attempts to set the tile dimensions so that no more than 8 kilobytes of data +appear in a tile. .I tiffcp -attempts to set the tile dimensions so -that no more than 8 kilobytes of data appear in a tile. +attempts to set the tile dimensions so that no more than 8 kilobytes of data +appear in a tile. .TP -.B \-,={character} -substitute {character} for ',' in parsing image directory indices +.B \-x +Force the output file to be written with PAGENUMBER value in sequence. +.TP +.BI \-,= character +substitute +.I character +for `,' in parsing image directory indices in files. This is necessary if filenames contain commas. -Note that ',=' with whitespace immediately following will disable -the special meaning of the ',' entirely. See examples. +Note that +.B \-,= +with whitespace immediately following will disable +the special meaning of the `,' entirely. See examples. .SH EXAMPLES The following concatenates two files and writes the result using .SM LZW encoding: .RS .nf -tiffcp -c lzw a.tif b.tif result.tif +tiffcp \-c lzw a.tif b.tif result.tif .fi .RE .PP @@ -228,39 +252,48 @@ To convert a G3 1d-encoded to a single strip of G4-encoded data the following might be used: .RS .nf -tiffcp -c g4 -r 10000 g3.tif g4.tif +tiffcp \-c g4 \-r 10000 g3.tif g4.tif .fi .RE (1000 is just a number that is larger than the number of rows in the source file.) -To extract a selected set of images from a multi-image -TIFF file, the file name may be immediately followed by a ',' -separated list of image directory indices. The first image -is always in directory 0. Thus, to copy the 1st and 3rd -images of image file "album.tif" to "result.tif": +To extract a selected set of images from a multi-image TIFF file, the file +name may be immediately followed by a `,' separated list of image directory +indices. The first image is always in directory 0. Thus, to copy the 1st and +3rd images of image file ``album.tif'' to ``result.tif'': .RS .nf tiffcp album.tif,0,2 result.tif .fi .RE -Given file "CCD.tif" whose first image is a noise bias +A trailing comma denotes remaining images in sequence. The following command +will copy all image with except the first one: +.RS +.nf +tiffcp album.tif,1, result.tif +.fi +.RE + +Given file ``CCD.tif'' whose first image is a noise bias followed by images which include that bias, subtract the noise from all those images following it (while decompressing) with the command: .RS .nf -tiffcp -c none -b CCD.tif CCD.tif,1, result.tif +tiffcp \-c none \-b CCD.tif CCD.tif,1, result.tif .fi .RE -If the file above were named "CCD,X.tif", the "-,=" option would +If the file above were named ``CCD,X.tif'', the +.B \-,= +option would be required to correctly parse this filename with image numbers, as follows: .RS .nf -tiffcp -c none -,=% -b CCD,X.tif CCD,X%1%.tif result.tif +tiffcp \-c none \-,=% \-b CCD,X.tif CCD,X%1%.tif result.tif .SH "SEE ALSO" .BR pal2rgb (1), .BR tiffinfo (1), diff --git a/libs/tiff-4.0.2/man/tiffcrop.1 b/libs/tiff-4.0.2/man/tiffcrop.1 new file mode 100644 index 0000000000..0423fb2f5b --- /dev/null +++ b/libs/tiff-4.0.2/man/tiffcrop.1 @@ -0,0 +1,571 @@ +.\" $Id: tiffcrop.1,v 1.7 2010-12-12 01:45:35 faxguy Exp $ +.\" tiffcrop -- a port of tiffcp.c extended to include extended processing of images +.\" +.\" Original code: +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.\" Additional code Copyright (c) 2006-2009 Richard Nolde +.\" Lasted Updated 9/2009 +.\" .if n .po 0 +.TH "TIFFCROP" "1" "December, 2008" "libtiff" "" +.SH "NAME" +tiffcrop \- select, copy, crop, convert, extract, and/or process one or more +.SM TIFF +files. +.SH "SYNOPSIS" +.B tiffcrop +[ +.I options +] +.I "src1.tif ... srcN.tif dst.tif" +.SH "DESCRIPTION" +.I Tiffcrop +processes one or more files created according +to the Tag Image File Format, Revision 6.0, specification +into one or more +.SM TIFF +file(s). +.I Tiffcrop +is most often used to extract portions of an image for processing +with bar code recognizer or OCR software when that software cannot +restrict the region of interest to a specific portion of the image +or to improve efficiency when the regions of interest must be rotated. +It can also be used to subdivide all or part of a processed image into +smaller sections and export individual images or sections of images +as separate files or separate images within one or more files derived +from the original input image or images. +.PP +The available functions can be grouped broadly into three classes: +.IP +Those that select individual images or sections of images from the input files. +The options \-N for sequences or lists of individual images in the input files, +\-Z for zones, \-z for regions, \-X and \-Y for fixed sized selections, +\-m for margins, \-U for units, and \-E for edge reference provide a variety of +ways to specify portions of the input image. +.IP +Those that allow the individual images or selections to be exported to one or +more output files in different groupings and control the organization of the +data in the output images. The options \-P for page size grouping, \-S for +subdivision into columns and rows and \-e for export mode options that produce +one or more files from each input image. The options \-r, \-s, \-t, \-w control +strip and tile format and sizes while \-B \-L \-c \-f modify the endian addressing +scheme, the compression options, and the bit fill sequence of images as they +are written. +.IP +Those that perform some action on each image that is selected from the input file. +The options include \-R for rotate, \-I for inversion of the photometric +interpretation and/or data values, and \-F to flip (mirror) the image horizontally +or vertically. +.PP + +Functions are applied to the input image(s) in the following order: +cropping, fixed area extraction, zone and region extraction, +inversion, mirroring, rotation. +.PP +Functions are applied to the output image(s) in the following order: +export mode options for grouping zones, regions, or images into +one or more files, +.I or +row and column divisions with output margins, +.I or +page size divisions with page orientation options. +.PP +Finally, strip, tile, byte order, output resolution, and compression options are +applied to all output images. +.PP +The output file(s) may be organized and compressed using a different +algorithm from the input files. +By default, +.I tiffcrop +will copy all the understood tags in a +.SM TIFF +directory of an input file to the associated directory in the output file. +Options can be used to force the resultant image to be written as strips +or tiles of data, respectively. +.PP +.I Tiffcrop +can be used to reorganize the storage characteristics of data +in a file, and to reorganize, extract, rotate, and otherwise +process the image data as specified at the same time whereas +tiffcp does not alter the image data within the file. +.PP +Using the options for selecting individual input images and the +options for exporting images and/or segments defined as zones or +regions of each input image, +.I tiffcrop +can perform the functions of tiffcp and tiffsplit in a single pass +while applying multiple operations to individual selections or images. +.PP +.SH "OPTIONS" +.TP +.B \-h +Display the syntax summary for tiffcrop. +.TP +.B \-v +Report the current version and last modification date for tiffcrop. +.TP +.B \-N odd|even|#,#\-#,#|last +Specify one or more series or range(s) of images within each file to process. +The words +.B odd +or +.B even +may be used to specify all odd or even numbered images counting from one. +Note that internally, TIFF images are numbered from zero rather than one +but since this convention is not obvious to most users, tiffcrop used 1 +to specifiy the first image in a multipage file. The word +.B last +may be used in place of a number in the sequence to indicate the +final image in the file without knowing how many images there are. +Ranges of images may be specified with a dash and multiple sets +can be indicated by joining them in a comma\-separated list. eg. use +.B \-N 1,5\-7,last +to process the 1st, 5th through 7th, and final image in the file. +.TP +.B \-E top|bottom|left|right +Specify the top, bottom, left, or right edge as the reference from +which to calcuate the width and length of crop regions or sequence +of postions for zones. When used with the \-e option for exporting +zones or regions, the reference edge determines how composite images +are arranged. Using \-E left or right causes successive zones or +regions to be merged horizontally whereas using \-E top or bottom +causes successive zones or regions to be arranged vertically. This +option has no effect on export layout when multiple zones or regions +are not being exported to composite images. Edges may be abbreviated +to the first letter. +.TP +.B \-e combined|divided|image|multiple|separate +Specify the export mode for images and selections from input images. +The final filename on the command line is considered to be the +destination file or filename stem for automatically generated +sequences of files. Modes may be abbreviated to the first letter. +.IP +combined All images and selections are written to a single file with +multiple selections from one image combined into a single image (default) +.IP +divided All images and selections are written to a single file +with each selection from one image written to a new image +.IP +image Each input image is written to a new file (numeric filename sequence) +with multiple selections from the image combined into one image +.IP +multiple Each input image is written to a new file (numeric filename sequence) +with each selection from the image written to a new image +.IP +separate Individual selections from each image are written to separate files +.TP +.B \-U in|cm|px +Specify the type of units to apply to dimensions for margins and +crop regions for input and output images. Inches or centimeters +are converted to pixels using the resolution unit specified in the +TIFF file (which defaults to inches if not specified in the IFD). +.TP +.B \-m #,#,#,# +Specify margins to be removed from the input image. The order must +be top, left, bottom, right with only commas separating the elements +of the list. Margins are scaled according to the current units and +removed before any other extractions are computed.. +.TP +.B \-X # +Set the horizontal (X\-axis) dimension of a region to extract relative to +the specified origin reference. If the origin is the top or bottom +edge, the X axis value will be assumed to start at the left edge. +.TP +.B \-Y # +Set the vertical (Y\-axis) dimension of a region to extract relative to +the specified origin reference. If the origin is the left or right +edge, the Y axis value will be assumed to start at the top. +.TP +.B \-Z #:#,#:# +Specify zones of the image designated as position X of Y equal sized portions +measured from the reference edge, eg 1:3 would be first third of the +image starting from the reference edge minus any margins specified +for the confining edges. Multiple zones can be specified as a comma +separated list but they must reference the same edge. To extract the +top quarter and the bottom third of an image you would use +.B \-Z 1:4,3:3. +.TP +.B \-z x1,y1,x2,y2: ... :xN,yN,xN+1,yN+1 +Specify a series of coordinates to define regions for processing and exporting. +The coordinates represent the top left and lower right corners of each region +in the current units, eg inch, cm, or pixels. Pixels are counted from one to +width or height and inches or cm are calculated from image resolution data. + +Each colon delimited series of four values represents the horizontal and vertical +offsets from the top and left edges of the image, regardless of the edge specified +with the \-E option. The first and third values represent the horizontal offsets of +the corner points from the left edge while the second and fourth values represent +the vertical offsets from the top edge. +.TP +.B \-F horiz|vert +Flip, ie mirror, the image or extracted region horizontally or vertically. +.TP +.B \-R 90|180|270 +Rotate the image or extracted region 90, 180, or 270 degrees clockwise. +.TP +.B \\-I [black|white|data|both] +Invert color space, eg dark to light for bilevel and grayscale images. +This can be used to modify negative images to positive or to correct +images that have the PHOTOMETRIC_INTERPRETATIN tag set incorrectly. +If the value is black or white, the PHOTOMETRIC_INTERPRETATION tag is set to +MinIsBlack or MinIsWhite, without altering the image data. If the argument +is data or both, the data values of the image are modified. Specifying both +inverts the data and the PHOTOMETRIC_INTERPRETATION tag, whereas using data +inverts the data but not the PHOTOMETRIC_INTERPRETATION tag. +No support for modifying the color space of color images in this release. +.TP +.B \-H # +Set the horizontal resolution of output images to # +expressed in the current units. +.TP +.B \-V # +Set the vertical resolution of the output images to # +expressed in the current units. +.TP +.B \-J # +Set the horizontal margin of an output page size to # +expressed in the current units when sectioning image into columns x rows +subimages using the \-S cols:rows option. +.TP +.B \-K # +Set the vertical margin of an output page size to # +expressed in the current units when sectioning image into columns x rows +submiages using the \-S cols:rows option. +.TP +.B \-O portrait|landscape|auto +Set the output orientation of the pages or sections. +Auto will use the arrangement that requires the fewest pages. +This option is only meaningful in conjunction with the -P +option to format an image to fit on a specific paper size. +.TP +.B \-P page +Format the output images to fit on page size paper. Use +\-P list to show the supported page sizes and dimensions. +You can define a custom page size by entering the width and length of the +page in the current units with the following format #.#x#.#. +.TP +.B \-S cols:rows +Divide each image into cols across and rows down equal sections. +.TP +.B \-B +Force output to be written with Big\-Endian byte order. +This option only has an effect when the output file is created or +overwritten and not when it is appended to. +.TP +.B \-C +Suppress the use of ``strip chopping'' when reading images +that have a single strip/tile of uncompressed data. +.TP +.B \-c +Specify the compression to use for data written to the output file: +.B none +for no compression, +.B packbits +for PackBits compression, +.B lzw +for Lempel\-Ziv & Welch compression, +.B jpeg +for baseline JPEG compression. +.B zip +for Deflate compression, +.B g3 +for CCITT Group 3 (T.4) compression, +and +.B g4 +for CCITT Group 4 (T.6) compression. +By default +.I tiffcrop +will compress data according to the value of the +.I Compression +tag found in the source file. +.IP +The +.SM CCITT +Group 3 and Group 4 compression algorithms can only +be used with bilevel data. +.IP +Group 3 compression can be specified together with several +T.4\-specific options: +.B 1d +for 1\-dimensional encoding, +.B 2d +for 2\-dimensional encoding, +and +.B fill +to force each encoded scanline to be zero\-filled so that the +terminating EOL code lies on a byte boundary. +Group 3\-specific options are specified by appending a ``:''\-separated +list to the ``g3'' option; e.g. +.B "\-c g3:2d:fill" +to get 2D\-encoded data with byte\-aligned EOL codes. +.IP +.SM LZW +compression can be specified together with a +.I predictor +value. +A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value +of 1 forces each scanline to be encoded without differencing. +LZW\-specific options are specified by appending a ``:''\-separated +list to the ``lzw'' option; e.g. +.B "\-c lzw:2" +for +.SM LZW +compression with horizontal differencing. +.TP +.B \-f +Specify the bit fill order to use in writing output data. +By default, +.I tiffcrop +will create a new file with the same fill order as the original. +Specifying +.B "\-f lsb2msb" +will force data to be written with the FillOrder tag set to +.SM LSB2MSB, +while +.B "\-f msb2lsb" +will force data to be written with the FillOrder tag set to +.SM MSB2LSB. +.TP +.B \-i +Ignore non\-fatal read errors and continue processing of the input file. +.TP +.B \-l +Specify the length of a tile (in pixels). +.I Tiffcrop +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.TP +.B \-L +Force output to be written with Little\-Endian byte order. +This option only has an effect when the output file is created or +overwritten and not when it is appended to. +.TP +.B \-M +Suppress the use of memory\-mapped files when reading images. +.TP +.B \-p +Specify the planar configuration to use in writing image data +that has more than one sample per pixel. +By default, +.I tiffcrop +will create a new file with the same planar configuration as +the original. +Specifying +.B "\-p contig" +will force data to be written with multi\-sample data packed +together, while +.B "\-p separate" +will force samples to be written in separate planes. +.TP +.B \-r +Specify the number of rows (scanlines) in each strip of data +written to the output file. +By default (or when value +.B 0 +is specified), +.I tiffcrop +attempts to set the rows/strip that no more than 8 kilobytes of +data appear in a strip. If you specify the special value +.B \-1 +it will results in infinite number of the rows per strip. The entire image +will be the one strip in that case. +.TP +.B \-s +Force the output file to be written with data organized in strips +(rather than tiles). +.TP +.B \-t +Force the output file to be written with data organized in tiles +(rather than strips). +.TP +.B \-w +Specify the width of a tile (in pixels). +.I tiffcrop +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.I tiffcrop +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.TP +Debug and dump facility +.B \-D opt1:value1,opt2:value2,opt3:value3:opt4:value4 +Display program progress and/or dump raw data to non\-TIFF files. +Options include the following and must be joined as a comma +separated list. The use of this option is generally limited to +program debugging and development of future options. An equal sign +may be substituted for the colon in option:value pairs. +.IP +debug:N Display limited program progress indicators where larger N +increase the level of detail. +.IP +format:txt|raw Format any logged data as ASCII text or raw binary +values. ASCII text dumps include strings of ones and zeroes representing +the binary values in the image data plus identifying headers. +.IP +level:N Specify the level of detail presented in the dump files. +This can vary from dumps of the entire input or output image data to dumps +of data processed by specific functions. Current range of levels is 1 to 3. +.IP +input:full\-path\-to\-directory/input\-dumpname +.IP +output:full\-path\-to\-directory/output\-dumpname +.IP +When dump files are being written, each image will be written to a separate +file with the name built by adding a numeric sequence value to the dumpname +and an extension of .txt for ASCII dumps or .bin for binary dumps. + +The four debug/dump options are independent, though it makes little sense to +specify a dump file without specifying a detail level. +.IP +Note: Tiffcrop may be compiled with -DDEVELMODE to enable additional very + low level debug reporting. +.SH "EXAMPLES" +The following concatenates two files and writes the result using +.SM LZW +encoding: +.RS +.nf +tiffcrop \-c lzw a.tif b.tif result.tif +.fi +.RE +.PP +To convert a G3 1d\-encoded +.SM TIFF +to a single strip of G4\-encoded data the following might be used: +.RS +.nf +tiffcrop \-c g4 \-r 10000 g3.tif g4.tif +.fi +.RE +(1000 is just a number that is larger than the number of rows in +the source file.) + +To extract a selected set of images from a multi\-image TIFF file +use the \-N option described above. Thus, to copy the 1st and 3rd +images of image file "album.tif" to "result.tif": +.RS +.nf +tiffcrop \-N 1,3 album.tif result.tif +.fi +.RE +.PP +Invert a bilevel image scan of a microfilmed document and crop off margins of +0.25 inches on the left and right, 0.5 inch on the top, and 0.75 inch on the +bottom. From the remaining portion of the image, select the second and third +quarters, ie, one half of the area left from the center to each margin. +.RS +tiffcrop \-U in \-m 0.5,0.25,0.75,0.25 \-E left \-Z 2:4,3:4 \-I both MicrofilmNegative.tif MicrofilmPostiveCenter.tif +.fi +.RE +.PP +Extract only the final image of a large Architectural E sized +multipage TIFF file and rotate it 90 degrees clockwise while +reformatting the output to fit on tabloid sized sheets with one +quarter of an inch on each side: +.RS +tiffcrop \-N last \-R 90 \-O auto \-P tabloid \-U in \-J 0.25 \-K 0.25 \-H 300 \-V 300 Big\-PlatMap.tif BigPlatMap\-Tabloid.tif +.fi +.RE +The output images will have a specified resolution of 300 dpi in both +directions. The orientation of each page will be determined by whichever +choice requires the fewest pages. To specify a specific orientation, use +the portrait or landscape option. The paper size option does not resample +the image. It breaks each original image into a series of smaller images +that will fit on the target paper size at the specified resolution. +.fi +.RE +.PP +Extract two regions 2048 pixels wide by 2048 pixels high from each page of +a multi\-page input file and write each region to a separate output file. +.RS +tiffcrop \-U px \-z 1,1,2048,2048:1,2049,2048,4097 \-e separate CheckScans.tiff Check +.fi +.RE +The output file names will use the stem Check with a numeric suffix which is +incremented for each region of each image, eg Check\-001.tiff, Check\-002.tiff ... +Check\-NNN.tiff. To produce a unique file for each page of the input image +with one new image for each region of the input image on that page, change +the export option to \-e multiple. + +.SH "NOTES" +.PP +In general, bilevel, grayscale, palette and RGB(A) data with bit depths +from 1 to 32 bits should work in both interleaved and separate plane +formats. Unlike tiffcp, tiffcrop can read and write tiled images with +bits per sample that are not a multiple of 8 in both interleaved and +separate planar format. Floating point data types are supported at +bit depts of 16, 24, 32 and 64 bits per sample. +.PP +Not all images can be converted from one compression scheme to another. +Data with some photometric interpretations and/or bit depths are tied to +specific compression schemes and vice-versa, e.g. Group 3/4 compression +is only usable for bilevel data. JPEG compression is only usable on 8 +bit per sample data (or 12 bit if +.I LibTIFF +was compiled with 12 bit JPEG support). Support for OJPEG compressed +images is problematic at best. Since OJPEG compression is no longer +supported for writing images with LibTIFF, these images will be updated +to the newer JPEG compression when they are copied or processed. This +may cause the image to appear color shifted or distorted after conversion. +In some cases, it is possible to remove the original compression from +image data using the option -cnone. +.PP +Tiffcrop does not currently provide options to up or downsample data to +different bit depths or convert data from one photometric interpretation +to another, e.g. 16 bits per sample to 8 bits per sample or RGB to grayscale. +.PP +Tiffcrop is very loosely derived from code in +.I tiffcp +with extensive modifications and additions to support the selection of input +images and regions and the exporting of them to one or more output files in +various groupings. The image manipulation routines are entirely new and +additional ones may be added in the future. It will handle tiled images with +bit depths that are not a multiple of eight that tiffcp may refuse to read. +.PP +.I Tiffcrop +was designed to handle large files containing many moderate sized images +with memory usage that is independent of the number of images in the file. +In order to support compression modes that are not based on individual +scanlines, e.g. JPEG, it now reads images by strip or tile rather than by +indvidual scanlines. In addition to the memory required by the input and +output buffers associated with +.I LibTIFF +one or more buffers at least as large as the largest image to be read are +required. The design favors large volume document processing uses over +scientific or graphical manipulation of large datasets as might be found +in research or remote sensing scenarios. +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcmp (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR tiffsplit (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.remotesensing.org/libtiff/ + diff --git a/libs/tiff-3.8.2/man/tiffdither.1 b/libs/tiff-4.0.2/man/tiffdither.1 similarity index 95% rename from libs/tiff-3.8.2/man/tiffdither.1 rename to libs/tiff-4.0.2/man/tiffdither.1 index 248d53c8b1..ab0d32a789 100644 --- a/libs/tiff-3.8.2/man/tiffdither.1 +++ b/libs/tiff-4.0.2/man/tiffdither.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffdither.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffdither.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1990-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -102,11 +102,15 @@ By default, will create a new file with the same fill order as the original. Specifying .B "\-f lsb2msb" -will force data to be written with the FillOrder tag set to +will force data to be written with the +.I Fill\%Order +tag set to .SM LSB2MSB , while .B "\-f msb2lsb" -will force data to be written with the FillOrder tag set to +will force data to be written with the +.I Fill\%Order +tag set to .SM MSB2LSB . .TP .B \-t diff --git a/libs/tiff-3.8.2/man/tiffdump.1 b/libs/tiff-4.0.2/man/tiffdump.1 similarity index 96% rename from libs/tiff-3.8.2/man/tiffdump.1 rename to libs/tiff-4.0.2/man/tiffdump.1 index 0002a68105..076f9ffeed 100644 --- a/libs/tiff-3.8.2/man/tiffdump.1 +++ b/libs/tiff-4.0.2/man/tiffdump.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffdump.1,v 1.4 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffdump.1,v 1.5 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -63,11 +63,11 @@ does not understand. Force numeric data to be printed in hexadecimal rather than the default decimal. .TP -.B \-m " items" +.BI \-m " items" Change the number of indirect data items that are printed. By default, this will be 24. .TP -.B \-o " offset" +.BI \-o " offset" Dump the contents of the .SM IFD at the a particular file offset. diff --git a/libs/tiff-3.8.2/man/tiffgt.1 b/libs/tiff-4.0.2/man/tiffgt.1 similarity index 93% rename from libs/tiff-3.8.2/man/tiffgt.1 rename to libs/tiff-4.0.2/man/tiffgt.1 index 0c14503a25..680a49a042 100644 --- a/libs/tiff-3.8.2/man/tiffgt.1 +++ b/libs/tiff-4.0.2/man/tiffgt.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffgt.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffgt.1,v 1.4 2006-04-20 12:17:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -56,11 +56,11 @@ correctly handles files with any of the following characteristics: .in +0.5i .ta \w'\fIPhotometricInterpretation\fP 'u .nf -BitsPerSample 1, 2, 4, 8, 16 -SamplesPerPixel 1, 3, 4 (the 4th sample is ignored) -PhotometricInterpretation 0 (min-is-white), 1 (min-is-black), 2 (RGB), 3 (palette), 6 (YCbCr) -PlanarConfiguration 1 (contiguous), 2 (separate) -Orientation 1 (top-left), 4 (bottom-left) +\fIBitsPerSample\fP 1, 2, 4, 8, 16 +\fISamplesPerPixel\fP 1, 3, 4 (the 4th sample is ignored) +\fIPhotometricInterpretation\fP 0 (min-is-white), 1 (min-is-black), 2 (RGB), 3 (palette), 6 (YCbCr) +\fIPlanarConfiguration\fP 1 (contiguous), 2 (separate) +\fIOrientation\fP 1 (top-left), 4 (bottom-left) .fi .in -0.5i .sp .5 @@ -199,15 +199,15 @@ i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. Override the value of the .I PhotometricInterpretation tag; the parameter may be one of: -.IR miniswhite , -.IR minisblack , -.IR rgb , -.IR palette , -.IR mask , -.IR separated , -.IR ycbcr , +.BR miniswhite , +.BR minisblack , +.BR rgb , +.BR palette , +.BR mask , +.BR separated , +.BR ycbcr , and -.IR cielab . +.BR cielab . .TP .B \-r Force image display in a full color window. diff --git a/libs/tiff-3.8.2/man/tiffinfo.1 b/libs/tiff-4.0.2/man/tiffinfo.1 similarity index 97% rename from libs/tiff-3.8.2/man/tiffinfo.1 rename to libs/tiff-4.0.2/man/tiffinfo.1 index 764e473682..2d57375206 100644 --- a/libs/tiff-3.8.2/man/tiffinfo.1 +++ b/libs/tiff-4.0.2/man/tiffinfo.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffinfo.1,v 1.2 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffinfo.1,v 1.2 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/tiffmedian.1 b/libs/tiff-4.0.2/man/tiffmedian.1 similarity index 98% rename from libs/tiff-3.8.2/man/tiffmedian.1 rename to libs/tiff-4.0.2/man/tiffmedian.1 index ffa6d04ab2..c584b97fe2 100644 --- a/libs/tiff-3.8.2/man/tiffmedian.1 +++ b/libs/tiff-4.0.2/man/tiffmedian.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffmedian.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffmedian.1,v 1.3 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1990-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/man/tiffset.1 b/libs/tiff-4.0.2/man/tiffset.1 similarity index 77% rename from libs/tiff-3.8.2/man/tiffset.1 rename to libs/tiff-4.0.2/man/tiffset.1 index 1245152b01..ed0d12fb01 100644 --- a/libs/tiff-3.8.2/man/tiffset.1 +++ b/libs/tiff-4.0.2/man/tiffset.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffset.1,v 1.2 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffset.1,v 1.5 2011-03-26 12:07:20 fwarmerdam Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -31,7 +31,7 @@ header .SH SYNOPSIS .B tiffset [ -options +.I options ] .I filename.tif .SH DESCRIPTION @@ -41,10 +41,16 @@ sets the value of a header to a specified value. .SH OPTIONS .TP -.B \-s tagnumber [count] value ... +.BI \-d " dirnumber" +change the current directory (starting at 0). +.TP +.BI \-s " tagnumber" "\fR [\fP" " count" "\fR ]\fP" " value ..." Set the value of the named tag to the value or values specified. .TP -.B \-sf tagnumber filename +.BI \-sd " diroffset" +change the current directory by offset. +.TP +.BI \-sf " tagnumber filename" Set the value of the tag to the contents of filename. This option is supported for ASCII tags only. .SH EXAMPLES @@ -52,24 +58,32 @@ The following example sets the image description tag (270) of a.tif to the contents of the file descrip: .RS .nf -tiffset -sf 270 descrip a.tif +tiffset \-sf 270 descrip a.tif .fi .RE .PP The following example sets the artist tag (315) of a.tif to the string -"Anonymous": +``Anonymous'': .RS .nf -tiffset -s 305 Anonymous a.tif +tiffset \-s 315 Anonymous a.tif .fi .RE .PP This example sets the resolution of the file a.tif to 300 dpi: .RS .nf -tiffset -s 296 2 a.tif -tiffset -s 282 300.0 a.tif -tiffset -s 283 300.0 a.tif +tiffset \-s 296 2 a.tif +tiffset \-s 282 300.0 a.tif +tiffset \-s 283 300.0 a.tif +.fi +.RE +.PP +Set the photometric interpretation of the third page of a.tif to +min-is-black (ie. inverts it): +.RS +.nf +tiffset -d 2 -s 262 1 a.tif .fi .RE .SH "SEE ALSO" diff --git a/libs/tiff-3.8.2/man/tiffsplit.1 b/libs/tiff-4.0.2/man/tiffsplit.1 similarity index 96% rename from libs/tiff-3.8.2/man/tiffsplit.1 rename to libs/tiff-4.0.2/man/tiffsplit.1 index 6495d463fa..411ebf488c 100644 --- a/libs/tiff-3.8.2/man/tiffsplit.1 +++ b/libs/tiff-4.0.2/man/tiffsplit.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffsplit.1,v 1.5 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffsplit.1,v 1.6 2009-08-24 19:13:40 bfriesen Exp $ .\" .\" Copyright (c) 1992-1997 Sam Leffler .\" Copyright (c) 1992-1997 Silicon Graphics, Inc. @@ -50,7 +50,7 @@ suffix in the range [\fIaaa\fP-\fIzzz\fP], the suffix (e.g. .IR xaaa.tif , .IR xaab.tif , -\... +.IR ... , .IR xzzz.tif ). If a prefix is not specified on the command line, the default prefix of diff --git a/libs/tiff-3.8.2/man/tiffsv.1 b/libs/tiff-4.0.2/man/tiffsv.1 similarity index 98% rename from libs/tiff-3.8.2/man/tiffsv.1 rename to libs/tiff-4.0.2/man/tiffsv.1 index 6e0214ed54..206df5676a 100644 --- a/libs/tiff-3.8.2/man/tiffsv.1 +++ b/libs/tiff-4.0.2/man/tiffsv.1 @@ -1,4 +1,4 @@ -.\" $Id: tiffsv.1,v 1.3 2005/11/02 11:07:19 dron Exp $ +.\" $Id: tiffsv.1,v 1.3 2005-11-02 11:07:19 dron Exp $ .\" .\" Copyright (c) 1988-1997 Sam Leffler .\" Copyright (c) 1991-1997 Silicon Graphics, Inc. diff --git a/libs/tiff-3.8.2/nmake.opt b/libs/tiff-4.0.2/nmake.opt similarity index 88% rename from libs/tiff-3.8.2/nmake.opt rename to libs/tiff-4.0.2/nmake.opt index f5ad2d93c3..1eeb8ea25e 100644 --- a/libs/tiff-3.8.2/nmake.opt +++ b/libs/tiff-4.0.2/nmake.opt @@ -1,4 +1,4 @@ -# $Id: nmake.opt,v 1.16 2006/03/23 14:54:01 dron Exp $ +# $Id: nmake.opt,v 1.18 2006-06-07 16:33:45 dron Exp $ # # Copyright (C) 2004, Andrey Kiselev # @@ -59,12 +59,6 @@ LOGLUV_SUPPORT = 1 #JPEG_INCLUDE = -I$(JPEGDIR) #JPEG_LIB = $(JPEGDIR)/Release/jpeg.lib -# -# Uncomment following lines to enable Old JPEG support -# (modified IJG JPEG library required, read the contrib\ojpeg\README first). -# -#OJPEG_SUPPORT = 1 - # # Uncomment and edit following lines to enable ZIP support # (required for Deflate compression and Pixar log-format) @@ -74,6 +68,14 @@ LOGLUV_SUPPORT = 1 #ZLIB_INCLUDE = -I$(ZLIBDIR) #ZLIB_LIB = $(ZLIBDIR)/zlib.lib +# +# Uncomment and edit following lines to enable ISO JBIG support +# +#JBIG_SUPPORT = 1 +#JBIGDIR = d:/projects/jbigkit +#JBIG_INCLUDE = -I$(JBIGDIR)/libjbig +#JBIG_LIB = $(JBIGDIR)/libjbig/jbig.lib + # # Uncomment following line to enable Pixar log-format algorithm # (Zlib required). @@ -110,9 +112,9 @@ CHECK_JPEG_YCBCR_SUBSAMPLING = 1 # # Pick debug or optimized build flags. We default to an optimized build # with no debugging information. -# NOTE: /GX option required if you want to build the C++ stream API +# NOTE: /EHsc option required if you want to build the C++ stream API # -OPTFLAGS = /Ox /MD /GX /W3 +OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE #OPTFLAGS = /Zi # @@ -181,10 +183,7 @@ EXTRAFLAGS = -DLOGLUV_SUPPORT $(EXTRAFLAGS) !IFDEF JPEG_SUPPORT LIBS = $(LIBS) $(JPEG_LIB) -EXTRAFLAGS = -DJPEG_SUPPORT $(EXTRAFLAGS) -!IFDEF OJPEG_SUPPORT -EXTRAFLAGS = -DOJPEG_SUPPORT $(EXTRAFLAGS) -!ENDIF +EXTRAFLAGS = -DJPEG_SUPPORT -DOJPEG_SUPPORT $(EXTRAFLAGS) !ENDIF !IFDEF ZIP_SUPPORT @@ -195,6 +194,11 @@ EXTRAFLAGS = -DPIXARLOG_SUPPORT $(EXTRAFLAGS) !ENDIF !ENDIF +!IFDEF JBIG_SUPPORT +LIBS = $(LIBS) $(JBIG_LIB) +EXTRAFLAGS = -DJBIG_SUPPORT $(EXTRAFLAGS) +!ENDIF + !IFDEF STRIPCHOP_SUPPORT EXTRAFLAGS = -DSTRIPCHOP_DEFAULT=TIFF_STRIPCHOP -DSTRIP_SIZE_DEFAULT=$(STRIP_SIZE_DEFAULT) $(EXTRAFLAGS) !ENDIF diff --git a/libs/tiff-3.8.2/port/Makefile.am b/libs/tiff-4.0.2/port/Makefile.am similarity index 94% rename from libs/tiff-3.8.2/port/Makefile.am rename to libs/tiff-4.0.2/port/Makefile.am index 110dd85d66..94504fd809 100644 --- a/libs/tiff-3.8.2/port/Makefile.am +++ b/libs/tiff-4.0.2/port/Makefile.am @@ -23,9 +23,9 @@ # Process this file with automake to produce Makefile.in. -EXTRA_DIST = Makefile.vc +EXTRA_DIST = Makefile.vc libport.h noinst_LTLIBRARIES = libport.la -libport_la_SOURCES = dummy.c +libport_la_SOURCES = dummy.c libport.h libport_la_LIBADD = @LTLIBOBJS@ diff --git a/libs/tiff-3.8.2/port/Makefile.vc b/libs/tiff-4.0.2/port/Makefile.vc similarity index 96% rename from libs/tiff-3.8.2/port/Makefile.vc rename to libs/tiff-4.0.2/port/Makefile.vc index f5c85c6ba9..fa98f3f82b 100644 --- a/libs/tiff-3.8.2/port/Makefile.vc +++ b/libs/tiff-4.0.2/port/Makefile.vc @@ -1,4 +1,4 @@ -# $Id: Makefile.vc,v 1.4 2006/03/23 14:54:02 dron Exp $ +# $Id: Makefile.vc,v 1.4 2006-03-23 14:54:02 dron Exp $ # # Copyright (C) 2004, Andrey Kiselev # diff --git a/libs/tiff-3.8.2/port/dummy.c b/libs/tiff-4.0.2/port/dummy.c similarity index 66% rename from libs/tiff-3.8.2/port/dummy.c rename to libs/tiff-4.0.2/port/dummy.c index ec8f91bd82..923ee7b1fe 100644 --- a/libs/tiff-3.8.2/port/dummy.c +++ b/libs/tiff-4.0.2/port/dummy.c @@ -1,10 +1,10 @@ -/* $Id: dummy.c,v 1.2 2005/07/07 15:21:52 dron Exp $ */ +/* $Id: dummy.c,v 1.3 2007-03-21 14:54:16 dron Exp $ */ /* * Dummy function, just to be ensure that the library always will be created. */ -static void +void libport_dummy_function() { return; diff --git a/libs/tiff-3.8.2/port/getopt.c b/libs/tiff-4.0.2/port/getopt.c similarity index 97% rename from libs/tiff-3.8.2/port/getopt.c rename to libs/tiff-4.0.2/port/getopt.c index 0138c89e30..6eff8ee524 100644 --- a/libs/tiff-3.8.2/port/getopt.c +++ b/libs/tiff-4.0.2/port/getopt.c @@ -1,4 +1,4 @@ -/* $Id: getopt.c,v 1.2 2005/07/07 16:34:06 dron Exp $ */ +/* $Id: getopt.c,v 1.3 2009-01-22 20:53:07 fwarmerdam Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -36,6 +36,7 @@ __RCSID("$NetBSD: getopt.c,v 1.26 2003/08/07 16:43:40 agc Exp $"); #include #include +#include "libport.h" int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ diff --git a/libs/tiff-3.8.2/port/lfind.c b/libs/tiff-4.0.2/port/lfind.c similarity index 94% rename from libs/tiff-3.8.2/port/lfind.c rename to libs/tiff-4.0.2/port/lfind.c index d2f14ee079..22d9798036 100644 --- a/libs/tiff-3.8.2/port/lfind.c +++ b/libs/tiff-4.0.2/port/lfind.c @@ -1,4 +1,4 @@ -/* $Id: lfind.c,v 1.3 2005/12/27 15:08:22 dron Exp $ */ +/* $Id: lfind.c,v 1.4 2007-01-15 18:40:39 mloskot Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,11 @@ static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93"; __RCSID("$NetBSD: lsearch.c,v 1.2 2005/07/06 15:47:15 drochner Exp $"); #endif -#include +#ifdef _WIN32_WCE +# include +#else +# include +#endif #ifndef NULL # define NULL 0 diff --git a/libs/tiff-4.0.2/port/libport.h b/libs/tiff-4.0.2/port/libport.h new file mode 100644 index 0000000000..802f478bd4 --- /dev/null +++ b/libs/tiff-4.0.2/port/libport.h @@ -0,0 +1,51 @@ +/* $Id: libport.h,v 1.2 2009-11-02 14:44:13 bfriesen Exp $ */ + +/* + * Copyright (c) 2009 Frank Warmerdam + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _LIBPORT_ +#define _LIBPORT_ + +int getopt(int argc, char * const argv[], const char *optstring); +extern char *optarg; +extern int opterr; +extern int optind; +extern int optopt; + +int strcasecmp(const char *s1, const char *s2); + +#ifndef HAVE_GETOPT +# define HAVE_GETOPT 1 +#endif + +#if 0 +unsigned long strtoul(const char *nptr, char **endptr, int base); +#endif + +#if 0 +void * +lfind(const void *key, const void *base, size_t *nmemb, size_t size, + int(*compar)(const void *, const void *)); +#endif + +#endif /* ndef _LIBPORT_ */ diff --git a/libs/tiff-3.8.2/port/strcasecmp.c b/libs/tiff-4.0.2/port/strcasecmp.c similarity index 95% rename from libs/tiff-3.8.2/port/strcasecmp.c rename to libs/tiff-4.0.2/port/strcasecmp.c index 2422304b12..1ff4312b9d 100644 --- a/libs/tiff-3.8.2/port/strcasecmp.c +++ b/libs/tiff-4.0.2/port/strcasecmp.c @@ -1,4 +1,4 @@ -/* $Id: strcasecmp.c,v 1.2 2005/07/07 16:34:06 dron Exp $ */ +/* $Id: strcasecmp.c,v 1.3 2009-01-22 20:53:07 fwarmerdam Exp $ */ /* * Copyright (c) 1987, 1993 @@ -36,6 +36,7 @@ __RCSID("$NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc Exp $"); #include #include +#include "libport.h" int strcasecmp(const char *s1, const char *s2) diff --git a/libs/tiff-3.8.2/port/strtoul.c b/libs/tiff-4.0.2/port/strtoul.c similarity index 98% rename from libs/tiff-3.8.2/port/strtoul.c rename to libs/tiff-4.0.2/port/strtoul.c index f7a9a1a565..84ab2155e0 100644 --- a/libs/tiff-3.8.2/port/strtoul.c +++ b/libs/tiff-4.0.2/port/strtoul.c @@ -1,4 +1,4 @@ -/* $Id: strtoul.c,v 1.2 2005/07/07 16:34:06 dron Exp $ */ +/* $Id: strtoul.c,v 1.2 2005-07-07 16:34:06 dron Exp $ */ /* * Copyright (c) 1990, 1993 diff --git a/libs/tiff-4.0.2/port/strtoull.c b/libs/tiff-4.0.2/port/strtoull.c new file mode 100644 index 0000000000..fb7739cc56 --- /dev/null +++ b/libs/tiff-4.0.2/port/strtoull.c @@ -0,0 +1,116 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. 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 acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 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. + */ + +#include +#include +#include +#include + +/* + * Convert a string to an unsigned long long integer. + * + * Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long long +strtoull(const char *nptr, char **endptr, int base) +{ + const char *s; + unsigned long long acc; + char c; + unsigned long long cutoff; + int neg, any, cutlim; + + /* + * See strtoq for comments as to the logic used. + */ + s = nptr; + do { + c = *s++; + } while (isspace((unsigned char)c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= '0' && s[1] <= '9') || + (s[1] >= 'A' && s[1] <= 'F') || + (s[1] >= 'a' && s[1] <= 'f'))) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + acc = any = 0; + if (base < 2 || base > 36) + goto noconv; + + cutoff = ULLONG_MAX / base; + cutlim = ULLONG_MAX % base; + for ( ; ; c = *s++) { + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULLONG_MAX; + errno = ERANGE; + } else if (!any) { +noconv: + errno = EINVAL; + } else if (neg) + acc = -acc; + if (endptr != NULL) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); +} diff --git a/libs/tiff-4.0.2/test/Makefile.am b/libs/tiff-4.0.2/test/Makefile.am new file mode 100644 index 0000000000..e7d45482e6 --- /dev/null +++ b/libs/tiff-4.0.2/test/Makefile.am @@ -0,0 +1,292 @@ +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Process this file with automake to produce Makefile.in. + +AUTOMAKE_OPTIONS = 1.11 color-tests parallel-tests foreign + +LIBTIFF = $(top_builddir)/libtiff/libtiff.la + +# Environment parameters to be used during tests +TESTS_ENVIRONMENT = \ + MAKE="$(MAKE)" \ + MAKEFLAGS="$(MAKEFLAGS)" \ + MEMCHECK="$(MEMCHECK)" + +EXTRA_DIST = \ + $(TESTSCRIPTS) \ + $(IMAGES_EXTRA_DIST) \ + common.sh + +# All of the tests to execute via 'make check' +TESTS = $(check_PROGRAMS) $(TESTSCRIPTS) + +# Tests which are expected to fail +XFAIL_TESTS = + +# Extra files which should be cleaned by 'make clean' +CLEANFILES = test_packbits.tif o-* + +# Executable programs which need to be built in order to support tests +check_PROGRAMS = ascii_tag long_tag short_tag strip_rw rewrite raw_decode custom_dir + +# Test scripts to execute +TESTSCRIPTS = \ + bmp2tiff_palette.sh \ + bmp2tiff_rgb.sh \ + gif2tiff.sh \ + ppm2tiff_pbm.sh \ + ppm2tiff_pgm.sh \ + ppm2tiff_ppm.sh \ + tiffcp-g3.sh \ + tiffcp-g3-1d.sh \ + tiffcp-g3-1d-fill.sh \ + tiffcp-g3-2d.sh \ + tiffcp-g3-2d-fill.sh \ + tiffcp-g4.sh \ + tiffcp-logluv.sh \ + tiffcp-thumbnail.sh \ + tiffdump.sh \ + tiffinfo.sh \ + tiffcp-split.sh \ + tiffcp-split-join.sh \ + tiff2ps-PS1.sh \ + tiff2ps-PS2.sh \ + tiff2ps-PS3.sh \ + tiff2ps-EPS1.sh \ + tiff2pdf.sh \ + tiffcrop-doubleflip-logluv-3c-16b.sh \ + tiffcrop-doubleflip-minisblack-1c-16b.sh \ + tiffcrop-doubleflip-minisblack-1c-8b.sh \ + tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh \ + tiffcrop-doubleflip-miniswhite-1c-1b.sh \ + tiffcrop-doubleflip-palette-1c-1b.sh \ + tiffcrop-doubleflip-palette-1c-4b.sh \ + tiffcrop-doubleflip-palette-1c-8b.sh \ + tiffcrop-doubleflip-rgb-3c-16b.sh \ + tiffcrop-doubleflip-rgb-3c-8b.sh \ + tiffcrop-extract-logluv-3c-16b.sh \ + tiffcrop-extract-minisblack-1c-16b.sh \ + tiffcrop-extract-minisblack-1c-8b.sh \ + tiffcrop-extract-minisblack-2c-8b-alpha.sh \ + tiffcrop-extract-miniswhite-1c-1b.sh \ + tiffcrop-extract-palette-1c-1b.sh \ + tiffcrop-extract-palette-1c-4b.sh \ + tiffcrop-extract-palette-1c-8b.sh \ + tiffcrop-extract-rgb-3c-16b.sh \ + tiffcrop-extract-rgb-3c-8b.sh \ + tiffcrop-extractz14-logluv-3c-16b.sh \ + tiffcrop-extractz14-minisblack-1c-16b.sh \ + tiffcrop-extractz14-minisblack-1c-8b.sh \ + tiffcrop-extractz14-minisblack-2c-8b-alpha.sh \ + tiffcrop-extractz14-miniswhite-1c-1b.sh \ + tiffcrop-extractz14-palette-1c-1b.sh \ + tiffcrop-extractz14-palette-1c-4b.sh \ + tiffcrop-extractz14-palette-1c-8b.sh \ + tiffcrop-extractz14-rgb-3c-16b.sh \ + tiffcrop-extractz14-rgb-3c-8b.sh \ + tiffcrop-R90-logluv-3c-16b.sh \ + tiffcrop-R90-minisblack-1c-16b.sh \ + tiffcrop-R90-minisblack-1c-8b.sh \ + tiffcrop-R90-minisblack-2c-8b-alpha.sh \ + tiffcrop-R90-miniswhite-1c-1b.sh \ + tiffcrop-R90-palette-1c-1b.sh \ + tiffcrop-R90-palette-1c-4b.sh \ + tiffcrop-R90-palette-1c-8b.sh \ + tiffcrop-R90-rgb-3c-16b.sh \ + tiffcrop-R90-rgb-3c-8b.sh \ + tiff2rgba-logluv-3c-16b.sh \ + tiff2rgba-minisblack-1c-16b.sh \ + tiff2rgba-minisblack-1c-8b.sh \ + tiff2rgba-minisblack-2c-8b-alpha.sh \ + tiff2rgba-miniswhite-1c-1b.sh \ + tiff2rgba-palette-1c-1b.sh \ + tiff2rgba-palette-1c-4b.sh \ + tiff2rgba-palette-1c-8b.sh \ + tiff2rgba-rgb-3c-16b.sh \ + tiff2rgba-rgb-3c-8b.sh \ + tiff2rgba-quad-tile.jpg.sh + +# This list should contain all of the TIFF files in the 'images' +# subdirectory which are intended to be used as input images for +# tests. All of these files should use the extension ".tiff". +TIFFIMAGES = \ + images/logluv-3c-16b.tiff \ + images/minisblack-1c-16b.tiff \ + images/minisblack-1c-8b.tiff \ + images/minisblack-2c-8b-alpha.tiff \ + images/miniswhite-1c-1b.tiff \ + images/palette-1c-1b.tiff \ + images/palette-1c-4b.tiff \ + images/palette-1c-8b.tiff \ + images/rgb-3c-16b.tiff \ + images/rgb-3c-8b.tiff \ + images/quad-tile.jpg.tiff + +BMPIMAGES = \ + images/palette-1c-8b.bmp \ + images/rgb-3c-8b.bmp + +GIFIMAGES = \ + images/palette-1c-8b.gif + +PNMIMAGES = \ + images/minisblack-1c-8b.pgm \ + images/miniswhite-1c-1b.pbm \ + images/rgb-3c-8b.ppm + +# This list should include all of the files in the 'images' +# subdirectory which are intended to be distributed. This may include +# files which are not currently used by the tests. +IMAGES_EXTRA_DIST = \ + images/README.txt \ + $(BMPIMAGES) \ + $(GIFIMAGES) \ + $(PNMIMAGES) \ + $(TIFFIMAGES) + +noinst_HEADERS = tifftest.h + +ascii_tag_SOURCES = ascii_tag.c +ascii_tag_LDADD = $(LIBTIFF) +long_tag_SOURCES = long_tag.c check_tag.c +long_tag_LDADD = $(LIBTIFF) +short_tag_SOURCES = short_tag.c check_tag.c +short_tag_LDADD = $(LIBTIFF) +strip_rw_SOURCES = strip_rw.c strip.c test_arrays.c test_arrays.h +strip_rw_LDADD = $(LIBTIFF) +rewrite_SOURCES = rewrite_tag.c +rewrite_LDADD = $(LIBTIFF) +raw_decode_SOURCES = raw_decode.c +raw_decode_LDADD = $(LIBTIFF) +custom_dir_SOURCES = custom_dir.c +custom_dir_LDADD = $(LIBTIFF) + +INCLUDES = -I$(top_srcdir)/libtiff + +# memcheck: valgrind's memory access checker +memcheck: + $(MAKE) MEMCHECK='valgrind --tool=memcheck --leak-check=full --read-var-info=yes --track-origins=yes --num-callers=12 --quiet $(VALGRIND_EXTRA_OPTS)' check + +# ptrcheck: valgrind's experimental pointer checking tool. +ptrcheck: + $(MAKE) MEMCHECK='valgrind --tool=exp-ptrcheck --quiet $(VALGRIND_EXTRA_OPTS)' check + +generate-tiff2rgba-tests: + for file in $(TIFFIMAGES) ; \ + do \ + base=`basename $$file .tiff` ; \ + testscript=$(srcdir)/tiff2rgba-$$base.sh ; \ + ( \ + echo "#!/bin/sh" ; \ + echo "# Generated file, master is Makefile.am" ; \ + echo ". \$${srcdir:-.}/common.sh" ; \ + echo "infile=\"\$$srcdir/$$file\"" ; \ + echo "outfile=\"o-tiff2rgba-$$base.tiff\"" ; \ + echo "f_test_convert \"\$$TIFF2RGBA\" \$$infile \$$outfile" ; \ + echo "f_tiffinfo_validate \$$outfile" ; \ + ) > $$testscript ; \ + chmod +x $$testscript ; \ + done + +# Test rotations +generate-tiffcrop-R90-tests: + for file in $(TIFFIMAGES) ; \ + do \ + base=`basename $$file .tiff` ; \ + testscript=$(srcdir)/tiffcrop-R90-$$base.sh ; \ + ( \ + echo "#!/bin/sh" ; \ + echo "# Generated file, master is Makefile.am" ; \ + echo ". \$${srcdir:-.}/common.sh" ; \ + echo "infile=\"\$$srcdir/$$file\"" ; \ + echo "outfile=\"o-tiffcrop-R90-$$base.tiff\"" ; \ + echo "f_test_convert \"\$$TIFFCROP -R90\" \$$infile \$$outfile" ; \ + echo "f_tiffinfo_validate \$$outfile" ; \ + ) > $$testscript ; \ + chmod +x $$testscript ; \ + done + +# Test flip (mirror) +generate-tiffcrop-doubleflip-tests: + for file in $(TIFFIMAGES) ; \ + do \ + base=`basename $$file .tiff` ; \ + testscript=$(srcdir)/tiffcrop-doubleflip-$$base.sh ; \ + ( \ + echo "#!/bin/sh" ; \ + echo "# Generated file, master is Makefile.am" ; \ + echo ". \$${srcdir:-.}/common.sh" ; \ + echo "infile=\"\$$srcdir/$$file\"" ; \ + echo "outfile=\"o-tiffcrop-doubleflip-$$base.tiff\"" ; \ + echo "f_test_convert \"\$$TIFFCROP -F both\" \$$infile \$$outfile" ; \ + echo "f_tiffinfo_validate \$$outfile" ; \ + ) > $$testscript ; \ + chmod +x $$testscript ; \ + done + +# Test extracting a section 100 pixels wide and 100 pixels high +generate-tiffcrop-extract-tests: + for file in $(TIFFIMAGES) ; \ + do \ + base=`basename $$file .tiff` ; \ + testscript=$(srcdir)/tiffcrop-extract-$$base.sh ; \ + ( \ + echo "#!/bin/sh" ; \ + echo "# Generated file, master is Makefile.am" ; \ + echo ". \$${srcdir:-.}/common.sh" ; \ + echo "infile=\"\$$srcdir/$$file\"" ; \ + echo "outfile=\"o-tiffcrop-extract-$$base.tiff\"" ; \ + echo "f_test_convert \"\$$TIFFCROP -U px -E top -X 60 -Y 60\" \$$infile \$$outfile" ; \ + echo "f_tiffinfo_validate \$$outfile" ; \ + ) > $$testscript ; \ + chmod +x $$testscript ; \ + done + +# Test extracting the first and fourth quarters from the left side. +generate-tiffcrop-extractz14-tests: + for file in $(TIFFIMAGES) ; \ + do \ + base=`basename $$file .tiff` ; \ + testscript=$(srcdir)/tiffcrop-extractz14-$$base.sh ; \ + ( \ + echo "#!/bin/sh" ; \ + echo "# Generated file, master is Makefile.am" ; \ + echo ". \$${srcdir:-.}/common.sh" ; \ + echo "infile=\"\$$srcdir/$$file\"" ; \ + echo "outfile=\"o-tiffcrop-extractz14-$$base.tiff\"" ; \ + echo "f_test_convert \"\$$TIFFCROP -E left -Z1:4,2:4\" \$$infile \$$outfile" ; \ + echo "f_tiffinfo_validate \$$outfile" ; \ + ) > $$testscript ; \ + chmod +x $$testscript ; \ + done + +generate-tiffcrop-tests: \ + generate-tiffcrop-R90-tests \ + generate-tiffcrop-doubleflip-tests \ + generate-tiffcrop-extract-tests \ + generate-tiffcrop-extractz14-tests + +generate-tests: \ + generate-tiff2rgba-tests \ + generate-tiffcrop-tests diff --git a/libs/tiff-3.8.2/test/ascii_tag.c b/libs/tiff-4.0.2/test/ascii_tag.c similarity index 79% rename from libs/tiff-3.8.2/test/ascii_tag.c rename to libs/tiff-4.0.2/test/ascii_tag.c index a6cd45b945..124ef29a90 100644 --- a/libs/tiff-3.8.2/test/ascii_tag.c +++ b/libs/tiff-4.0.2/test/ascii_tag.c @@ -1,4 +1,4 @@ -/* $Id: ascii_tag.c,v 1.5 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: ascii_tag.c,v 1.7 2008-04-15 13:32:12 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -40,9 +40,9 @@ #include "tiffio.h" -const char *filename = "ascii_test.tiff"; +static const char filename[] = "ascii_test.tiff"; -static struct Tags { +static const struct { ttag_t tag; const char *value; } ascii_tags[] = { @@ -56,21 +56,23 @@ static struct Tags { { TIFFTAG_ARTIST, "Andrey V. Kiselev" }, { TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)" }, { TIFFTAG_TARGETPRINTER, "No printer" }, - { TIFFTAG_PIXAR_TEXTUREFORMAT, "No texture" }, - { TIFFTAG_PIXAR_WRAPMODES, "No wrap" }, - { TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" } + { TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" }, + { TIFFTAG_FAXSUBADDRESS, "Fax subaddress" }, + /* DGN tags */ + { TIFFTAG_UNIQUECAMERAMODEL, "No camera" }, + { TIFFTAG_CAMERASERIALNUMBER, "1234567890" } }; #define NTAGS (sizeof (ascii_tags) / sizeof (ascii_tags[0])) -const char *ink_names = "Red\0Green\0Blue"; +static const char ink_names[] = "Red\0Green\0Blue"; const int ink_names_size = 15; int -main(int argc, char **argv) +main() { TIFF *tif; - int i; - unsigned char buf[3] = { 0, 127, 255 }; + size_t i; + unsigned char buf[] = { 0, 127, 255 }; char *value; /* Test whether we can write tags. */ @@ -92,7 +94,7 @@ main(int argc, char **argv) fprintf (stderr, "Can't set BitsPerSample tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3)) { + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf))) { fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); goto failure; } @@ -108,19 +110,21 @@ main(int argc, char **argv) for (i = 0; i < NTAGS; i++) { if (!TIFFSetField(tif, ascii_tags[i].tag, ascii_tags[i].value)) { - fprintf(stderr, "Can't set tag %d.\n", - (int)ascii_tags[i].tag); + fprintf(stderr, "Can't set tag %lu.\n", + (unsigned long)ascii_tags[i].tag); goto failure; } } /* InkNames tag has special form, so we handle it separately. */ if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3)) { - fprintf (stderr, "Can't set tag %d.\n", TIFFTAG_NUMBEROFINKS); + fprintf (stderr, "Can't set tag %d (NUMBEROFINKS).\n", + TIFFTAG_NUMBEROFINKS); goto failure; } if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names)) { - fprintf (stderr, "Can't set tag %d.\n", TIFFTAG_INKNAMES); + fprintf (stderr, "Can't set tag %d (INKNAMES).\n", + TIFFTAG_INKNAMES); goto failure; } @@ -142,15 +146,16 @@ main(int argc, char **argv) for (i = 0; i < NTAGS; i++) { if (!TIFFGetField(tif, ascii_tags[i].tag, &value) || strcmp(value, ascii_tags[i].value)) { - fprintf(stderr, "Can't get tag %d.\n", - (int)ascii_tags[i].tag); + fprintf(stderr, "Can't get tag %lu.\n", + (unsigned long)ascii_tags[i].tag); goto failure; } } if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value) || memcmp(value, ink_names, ink_names_size)) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_INKNAMES); + fprintf (stderr, "Can't get tag %d (INKNAMES).\n", + TIFFTAG_INKNAMES); goto failure; } @@ -161,9 +166,11 @@ main(int argc, char **argv) return 0; failure: - /* Something goes wrong; close file and return unsuccessful status. */ + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ TIFFClose(tif); - unlink(filename); return 1; } diff --git a/libs/tiff-4.0.2/test/bmp2tiff_palette.sh b/libs/tiff-4.0.2/test/bmp2tiff_palette.sh new file mode 100755 index 0000000000..1992623e16 --- /dev/null +++ b/libs/tiff-4.0.2/test/bmp2tiff_palette.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$IMG_PALETTE_1C_8B_BMP" +outfile="o-bmp2tiff_palette.tiff" +f_test_convert "$BMP2TIFF" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/bmp2tiff_rgb.sh b/libs/tiff-4.0.2/test/bmp2tiff_rgb.sh new file mode 100755 index 0000000000..2e940ce433 --- /dev/null +++ b/libs/tiff-4.0.2/test/bmp2tiff_rgb.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$IMG_RGB_3C_8B_BMP" +outfile="o-bmp2tiff_rgb.tiff" +f_test_convert "$BMP2TIFF" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-3.8.2/test/check_tag.c b/libs/tiff-4.0.2/test/check_tag.c similarity index 72% rename from libs/tiff-3.8.2/test/check_tag.c rename to libs/tiff-4.0.2/test/check_tag.c index 7e7d08f2b9..6275ac01ad 100644 --- a/libs/tiff-3.8.2/test/check_tag.c +++ b/libs/tiff-4.0.2/test/check_tag.c @@ -1,4 +1,4 @@ -/* $Id: check_tag.c,v 1.2 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: check_tag.c,v 1.3 2008-04-15 14:19:37 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -26,15 +26,15 @@ /* * TIFF Library * - * Module to test LONG tags read/write functions. + * Helper testing routines. */ #include "tiffio.h" int -CheckShortField(TIFF *tif, ttag_t field, uint16 value) +CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) { - uint16 tmp = 0; + uint16 tmp = 123; if (!TIFFGetField(tif, field, &tmp)) { fprintf (stderr, "Problem fetching tag %lu.\n", @@ -51,9 +51,28 @@ CheckShortField(TIFF *tif, ttag_t field, uint16 value) } int -CheckLongField(TIFF *tif, ttag_t field, uint32 value) +CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) { - uint32 tmp = 0; + uint16 tmp[2] = { 123, 456 }; + + if (!TIFFGetField(tif, field, tmp, tmp + 1)) { + fprintf (stderr, "Problem fetching tag %lu.\n", + (unsigned long) field); + return -1; + } + if (tmp[0] != values[0] || tmp[1] != values[1]) { + fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n", + (unsigned long) field); + return -1; + } + + return 0; +} + +int +CheckLongField(TIFF *tif, const ttag_t field, const uint32 value) +{ + uint32 tmp = 123; if (!TIFFGetField(tif, field, &tmp)) { fprintf (stderr, "Problem fetching tag %lu.\n", diff --git a/libs/tiff-4.0.2/test/common.sh b/libs/tiff-4.0.2/test/common.sh new file mode 100644 index 0000000000..643104b277 --- /dev/null +++ b/libs/tiff-4.0.2/test/common.sh @@ -0,0 +1,129 @@ +# Common code fragment for tests +# +srcdir=${srcdir:-.} +BUILDDIR=`pwd` +SRCDIR=`dirname $0` +SRCDIR=`cd $SRCDIR && pwd` +TOPSRCDIR=`cd $srcdir/.. && pwd` +TOOLS=`cd ../tools && pwd` +IMAGES="${SRCDIR}/images" + +# Aliases for built tools +BMP2TIFF=${TOOLS}/bmp2tiff +FAX2PS=${TOOLS}/fax2ps +FAX2TIFF=${TOOLS}/fax2tiff +GIF2TIFF=${TOOLS}/gif2tiff +PAL2RGB=${TOOLS}/pal2rgb +PPM2TIFF=${TOOLS}/ppm2tiff +RAS2TIFF=${TOOLS}/ras2tiff +RAW2TIFF=${TOOLS}/raw2tiff +RGB2YCBCR=${TOOLS}/rgb2ycbcr +THUMBNAIL=${TOOLS}/thumbnail +TIFF2BW=${TOOLS}/tiff2bw +TIFF2PDF=${TOOLS}/tiff2pdf +TIFF2PS=${TOOLS}/tiff2ps +TIFF2RGBA=${TOOLS}/tiff2rgba +TIFFCMP=${TOOLS}/tiffcmp +TIFFCP=${TOOLS}/tiffcp +TIFFCROP=${TOOLS}/tiffcrop +TIFFDITHER=${TOOLS}/tiffdither +TIFFDUMP=${TOOLS}/tiffdump +TIFFINFO=${TOOLS}/tiffinfo +TIFFMEDIAN=${TOOLS}/tiffmedian +TIFFSET=${TOOLS}/tiffset +TIFFSPLIT=${TOOLS}/tiffsplit + +# Aliases for input test files +IMG_MINISBLACK_1C_16B=${IMAGES}/minisblack-1c-16b.tiff +IMG_MINISBLACK_1C_8B=${IMAGES}/minisblack-1c-8b.tiff +IMG_MINISWHITE_1C_1B=${IMAGES}/miniswhite-1c-1b.tiff +IMG_PALETTE_1C_1B=${IMAGES}/palette-1c-1b.tiff +IMG_PALETTE_1C_4B=${IMAGES}/palette-1c-4b.tiff +IMG_PALETTE_1C_8B=${IMAGES}/palette-1c-8b.tiff +IMG_RGB_3C_16B=${IMAGES}/rgb-3c-16b.tiff +IMG_RGB_3C_8B=${IMAGES}/rgb-3c-8b.tiff +IMG_MINISBLACK_2C_8B_ALPHA=${IMAGES}/minisblack-2c-8b-alpha.tiff + +IMG_PALETTE_1C_8B_BMP=${IMAGES}/palette-1c-8b.bmp +IMG_RGB_3C_8B_BMP=${IMAGES}/rgb-3c-8b.bmp + +IMG_PALETTE_1C_8B_GIF=${IMAGES}/palette-1c-8b.gif + +IMG_MINISWHITE_1C_1B_PBM=${IMAGES}/miniswhite-1c-1b.pbm +IMG_MINISBLACK_1C_8B_PGM=${IMAGES}/minisblack-1c-8b.pgm +IMG_RGB_3C_8B_PPM=${IMAGES}/rgb-3c-8b.ppm + +# All uncompressed image files +IMG_UNCOMPRESSED="${IMG_MINISBLACK_1C_16B} ${IMG_MINISBLACK_1C_8B} ${IMG_MINISWHITE_1C_1B} ${IMG_PALETTE_1C_1B} ${IMG_PALETTE_1C_4B} ${IMG_PALETTE_1C_4B} ${IMG_PALETTE_1C_8B} ${IMG_RGB_3C_8B}" + +# +# Test a simple convert-like command. +# +# f_test_convert command infile outfile +f_test_convert () +{ + command=$1 + infile=$2 + outfile=$3 + rm -f $outfile + echo "$MEMCHECK $command $infile $outfile" + eval $MEMCHECK $command $infile $outfile + status=$? + if [ $status != 0 ] ; then + echo "Returned failed status $status!" + echo "Output (if any) is in \"${outfile}\"." + exit $status + fi +} + +# +# Test a simple command which sends output to stdout +# +# f_test_stdout command infile outfile +f_test_stdout () +{ + command=$1 + infile=$2 + outfile=$3 + rm -f $outfile + echo "$MEMCHECK $command $infile > $outfile" + eval $MEMCHECK $command $infile > $outfile + status=$? + if [ $status != 0 ] ; then + echo "Returned failed status $status!" + echo "Output (if any) is in \"${outfile}\"." + exit $status + fi +} + +# +# Execute a simple command (e.g. tiffinfo) with one input file +# +# f_test_exec command infile +f_test_reader () +{ + command=$1 + infile=$2 + echo "$MEMCHECK $command $infile" + eval $MEMCHECK $command $infile + status=$? + if [ $status != 0 ] ; then + echo "Returned failed status $status!" + exit $status + fi +} + +# +# Execute tiffinfo on a specified file to validate it +# +# f_tiffinfo_validate infile +f_tiffinfo_validate () +{ + f_test_reader "$TIFFINFO -D" $1 +} + +if test "$VERBOSE" = TRUE +then + set -x +fi + diff --git a/libs/tiff-4.0.2/test/custom_dir.c b/libs/tiff-4.0.2/test/custom_dir.c new file mode 100644 index 0000000000..8e44830634 --- /dev/null +++ b/libs/tiff-4.0.2/test/custom_dir.c @@ -0,0 +1,247 @@ +/* $Id: custom_dir.c,v 1.2 2012-06-06 05:26:37 fwarmerdam Exp $ */ + +/* + * Copyright (c) 2012, Frank Warmerdam + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * Module to handling of custom directories like EXIF. + */ + +#include "tif_config.h" +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "tiffio.h" +#include "tif_dir.h" +#include "tifftest.h" + +static const char filename[] = "custom_dir.tif"; + +#define SPP 3 /* Samples per pixel */ +const uint16 width = 1; +const uint16 length = 1; +const uint16 bps = 8; +const uint16 photometric = PHOTOMETRIC_RGB; +const uint16 rows_per_strip = 1; +const uint16 planarconfig = PLANARCONFIG_CONTIG; + +static TIFFField +customFields[] = { + { TIFFTAG_IMAGEWIDTH, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom1", NULL }, + { TIFFTAG_DOTRANGE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom2", NULL }, +}; + +static TIFFFieldArray customFieldArray = { tfiatOther, 0, 2, customFields }; + +int +main() +{ + TIFF *tif; + unsigned char buf[SPP] = { 0, 127, 255 }; + uint64 dir_offset = 0, dir_offset2 = 0; + uint64 read_dir_offset = 0, read_dir_offset2 = 0; + uint64 *dir_offset2_ptr = NULL; + char *ascii_value; + uint16 count16 = 0; + + + /* We write the main directory as a simple image. */ + tif = TIFFOpen(filename, "w+"); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } + + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) { + fprintf (stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } + + /* Write dummy pixel data. */ + if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } + + if (!TIFFWriteDirectory( tif )) { + fprintf (stderr, "TIFFWriteDirectory() failed.\n"); + goto failure; + } + + /* + * Now create an EXIF directory. + */ + if (TIFFCreateEXIFDirectory(tif) != 0) { + fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFSetField( tif, EXIFTAG_SPECTRALSENSITIVITY, "EXIF Spectral Sensitivity")) { + fprintf (stderr, "Can't write SPECTRALSENSITIVITY\n" ); + goto failure; + } + + if (!TIFFWriteCustomDirectory( tif, &dir_offset )) { + fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); + goto failure; + } + + /* + * Now create a custom directory with tags that conflict with mainline + * TIFF tags. + */ + + TIFFFreeDirectory( tif ); + if (TIFFCreateCustomDirectory(tif, &customFieldArray) != 0) { + fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, "*Custom1")) { /* not really IMAGEWIDTH */ + fprintf (stderr, "Can't write pseudo-IMAGEWIDTH.\n" ); + goto failure; + } + + if (!TIFFSetField( tif, TIFFTAG_DOTRANGE, "*Custom2")) { /* not really DOTWIDTH */ + fprintf (stderr, "Can't write pseudo-DOTWIDTH.\n" ); + goto failure; + } + + if (!TIFFWriteCustomDirectory( tif, &dir_offset2 )) { + fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); + goto failure; + } + + /* + * Go back to the first directory, and add the EXIFIFD pointer. + */ + TIFFSetDirectory(tif, 0); + TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset ); + TIFFSetField(tif, TIFFTAG_SUBIFD, 1, &dir_offset2 ); + + TIFFClose(tif); + + /* Ok, now test whether we can read written values in the EXIF directory. */ + tif = TIFFOpen(filename, "r"); + + TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset ); + if( read_dir_offset != dir_offset ) { + fprintf (stderr, "Did not get expected EXIFIFD.\n" ); + goto failure; + } + + TIFFGetField(tif, TIFFTAG_SUBIFD, &count16, &dir_offset2_ptr ); + read_dir_offset2 = dir_offset2_ptr[0]; + if( read_dir_offset2 != dir_offset2 || count16 != 1) { + fprintf (stderr, "Did not get expected SUBIFD.\n" ); + goto failure; + } + + if( !TIFFReadEXIFDirectory(tif, read_dir_offset) ) { + fprintf (stderr, "TIFFReadEXIFDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFGetField( tif, EXIFTAG_SPECTRALSENSITIVITY, &ascii_value) ) { + fprintf (stderr, "reading SPECTRALSENSITIVITY failed.\n" ); + goto failure; + } + + if( strcmp(ascii_value,"EXIF Spectral Sensitivity") != 0) { + fprintf (stderr, "got wrong SPECTRALSENSITIVITY value.\n" ); + goto failure; + } + + /* Try reading the Custom directory */ + + if( !TIFFReadCustomDirectory(tif, read_dir_offset2, &customFieldArray) ) { + fprintf (stderr, "TIFFReadCustomDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &ascii_value) ) { + fprintf (stderr, "reading pseudo-IMAGEWIDTH failed.\n" ); + goto failure; + } + + if( strcmp(ascii_value,"*Custom1") != 0) { + fprintf (stderr, "got wrong pseudo-IMAGEWIDTH value.\n" ); + goto failure; + } + + if (!TIFFGetField( tif, TIFFTAG_DOTRANGE, &ascii_value) ) { + fprintf (stderr, "reading pseudo-DOTRANGE failed.\n" ); + goto failure; + } + + if( strcmp(ascii_value,"*Custom2") != 0) { + fprintf (stderr, "got wrong pseudo-DOTRANGE value.\n" ); + goto failure; + } + + TIFFClose(tif); + + /* All tests passed; delete file and exit with success status. */ + unlink(filename); + return 0; + +failure: + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ + TIFFClose(tif); + return 1; +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-4.0.2/test/gif2tiff.sh b/libs/tiff-4.0.2/test/gif2tiff.sh new file mode 100755 index 0000000000..6bf9a1241f --- /dev/null +++ b/libs/tiff-4.0.2/test/gif2tiff.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$IMG_PALETTE_1C_8B_GIF" +outfile="o-gif2tiff.tiff" +f_test_convert "$GIF2TIFF" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/images/README.txt b/libs/tiff-4.0.2/test/images/README.txt new file mode 100644 index 0000000000..17f6292ecf --- /dev/null +++ b/libs/tiff-4.0.2/test/images/README.txt @@ -0,0 +1,29 @@ +The test files in this directory mostly have dimension 157x151. +The naming convention is + + photometric-channels-bits.tiff + +minisblack-1c-16b.tiff +minisblack-1c-8b.tiff +miniswhite-1c-1b.tiff +palette-1c-1b.tiff +palette-1c-4b.tiff +palette-1c-8b.tiff +rgb-3c-16b.tiff +rgb-3c-8b.tiff + +logluv-3c-16b.tiff: logluv compression/photometric interp +minisblack-2c-8b-alpha.tiff: grey+alpha + +BMP files (anchient BMPv2 since v3 does not work): + + palette-1c-8b.bmp + rgb-3c-8b.bmp + +GIF files (anchient GIF '87 since modern GIF does not work): + palette-1c-8b.gif + +PNM files: + minisblack-1c-8b.pgm + miniswhite-1c-1b.pbm + rgb-3c-8b.ppm diff --git a/libs/tiff-4.0.2/test/images/logluv-3c-16b.tiff b/libs/tiff-4.0.2/test/images/logluv-3c-16b.tiff new file mode 100644 index 0000000000..d43680f9ee Binary files /dev/null and b/libs/tiff-4.0.2/test/images/logluv-3c-16b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/minisblack-1c-16b.tiff b/libs/tiff-4.0.2/test/images/minisblack-1c-16b.tiff new file mode 100644 index 0000000000..a8dbae7f27 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/minisblack-1c-16b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/minisblack-1c-8b.pgm b/libs/tiff-4.0.2/test/images/minisblack-1c-8b.pgm new file mode 100644 index 0000000000..0faca40f04 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/minisblack-1c-8b.pgm differ diff --git a/libs/tiff-4.0.2/test/images/minisblack-1c-8b.tiff b/libs/tiff-4.0.2/test/images/minisblack-1c-8b.tiff new file mode 100644 index 0000000000..ea0f9ac312 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/minisblack-1c-8b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/minisblack-2c-8b-alpha.tiff b/libs/tiff-4.0.2/test/images/minisblack-2c-8b-alpha.tiff new file mode 100644 index 0000000000..5fe8f5835b Binary files /dev/null and b/libs/tiff-4.0.2/test/images/minisblack-2c-8b-alpha.tiff differ diff --git a/libs/tiff-4.0.2/test/images/miniswhite-1c-1b.pbm b/libs/tiff-4.0.2/test/images/miniswhite-1c-1b.pbm new file mode 100644 index 0000000000..6cff9292bd Binary files /dev/null and b/libs/tiff-4.0.2/test/images/miniswhite-1c-1b.pbm differ diff --git a/libs/tiff-4.0.2/test/images/miniswhite-1c-1b.tiff b/libs/tiff-4.0.2/test/images/miniswhite-1c-1b.tiff new file mode 100644 index 0000000000..bfc0838162 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/miniswhite-1c-1b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/palette-1c-1b.tiff b/libs/tiff-4.0.2/test/images/palette-1c-1b.tiff new file mode 100644 index 0000000000..25a1a32443 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/palette-1c-1b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/palette-1c-4b.tiff b/libs/tiff-4.0.2/test/images/palette-1c-4b.tiff new file mode 100644 index 0000000000..38ba3253f0 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/palette-1c-4b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/palette-1c-8b.bmp b/libs/tiff-4.0.2/test/images/palette-1c-8b.bmp new file mode 100644 index 0000000000..215f4c50da Binary files /dev/null and b/libs/tiff-4.0.2/test/images/palette-1c-8b.bmp differ diff --git a/libs/tiff-4.0.2/test/images/palette-1c-8b.gif b/libs/tiff-4.0.2/test/images/palette-1c-8b.gif new file mode 100644 index 0000000000..f83dfa3825 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/palette-1c-8b.gif differ diff --git a/libs/tiff-4.0.2/test/images/palette-1c-8b.tiff b/libs/tiff-4.0.2/test/images/palette-1c-8b.tiff new file mode 100644 index 0000000000..b87685a1d5 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/palette-1c-8b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/quad-tile.jpg.tiff b/libs/tiff-4.0.2/test/images/quad-tile.jpg.tiff new file mode 100644 index 0000000000..99b0bc2e74 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/quad-tile.jpg.tiff differ diff --git a/libs/tiff-4.0.2/test/images/rgb-3c-16b.tiff b/libs/tiff-4.0.2/test/images/rgb-3c-16b.tiff new file mode 100644 index 0000000000..f1a0279a19 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/rgb-3c-16b.tiff differ diff --git a/libs/tiff-4.0.2/test/images/rgb-3c-8b.bmp b/libs/tiff-4.0.2/test/images/rgb-3c-8b.bmp new file mode 100644 index 0000000000..e6a86dcbf2 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/rgb-3c-8b.bmp differ diff --git a/libs/tiff-4.0.2/test/images/rgb-3c-8b.ppm b/libs/tiff-4.0.2/test/images/rgb-3c-8b.ppm new file mode 100644 index 0000000000..6eca0354c5 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/rgb-3c-8b.ppm differ diff --git a/libs/tiff-4.0.2/test/images/rgb-3c-8b.tiff b/libs/tiff-4.0.2/test/images/rgb-3c-8b.tiff new file mode 100644 index 0000000000..f64d4044b2 Binary files /dev/null and b/libs/tiff-4.0.2/test/images/rgb-3c-8b.tiff differ diff --git a/libs/tiff-3.8.2/test/long_tag.c b/libs/tiff-4.0.2/test/long_tag.c similarity index 97% rename from libs/tiff-3.8.2/test/long_tag.c rename to libs/tiff-4.0.2/test/long_tag.c index f70ea51a86..5c3c680049 100644 --- a/libs/tiff-3.8.2/test/long_tag.c +++ b/libs/tiff-4.0.2/test/long_tag.c @@ -1,4 +1,4 @@ -/* $Id: long_tag.c,v 1.3 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: long_tag.c,v 1.4 2008-03-28 01:42:06 bfriesen Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -60,8 +60,10 @@ int main(int argc, char **argv) { TIFF *tif; - int i; + unsigned int i; unsigned char buf[3] = { 0, 127, 255 }; + (void) argc; + (void) argv; /* Test whether we can write tags. */ tif = TIFFOpen(filename, "w"); diff --git a/libs/tiff-4.0.2/test/ppm2tiff_pbm.sh b/libs/tiff-4.0.2/test/ppm2tiff_pbm.sh new file mode 100755 index 0000000000..68d9e4590b --- /dev/null +++ b/libs/tiff-4.0.2/test/ppm2tiff_pbm.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$IMG_MINISWHITE_1C_1B_PBM" +outfile="o-ppm2tiff_pbm.tiff" +f_test_convert "$PPM2TIFF" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/ppm2tiff_pgm.sh b/libs/tiff-4.0.2/test/ppm2tiff_pgm.sh new file mode 100755 index 0000000000..001ec70648 --- /dev/null +++ b/libs/tiff-4.0.2/test/ppm2tiff_pgm.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$IMG_MINISBLACK_1C_8B_PGM" +outfile="o-ppm2tiff_pgm.tiff" +f_test_convert "$PPM2TIFF" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/ppm2tiff_ppm.sh b/libs/tiff-4.0.2/test/ppm2tiff_ppm.sh new file mode 100755 index 0000000000..8a81527bc9 --- /dev/null +++ b/libs/tiff-4.0.2/test/ppm2tiff_ppm.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$IMG_RGB_3C_8B_PPM" +outfile="o-ppm2tiff_ppm.tiff" +f_test_convert "$PPM2TIFF" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/raw_decode.c b/libs/tiff-4.0.2/test/raw_decode.c new file mode 100644 index 0000000000..e73ee48611 --- /dev/null +++ b/libs/tiff-4.0.2/test/raw_decode.c @@ -0,0 +1,216 @@ +/* $Id: raw_decode.c,v 1.1 2012-06-01 21:04:22 fwarmerdam Exp $ */ + +/* + * Copyright (c) 2012, Frank Warmerdam + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * The objective of this test suite is to test the JPEGRawDecode() + * interface via TIFReadEncodedTile(). This function with YCbCr subsampling + * is a frequent source of bugs. + */ + +#include "tif_config.h" + +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "tiffio.h" + +static unsigned char cluster_0[] = { 0, 0, 2, 0, 138, 139 }; +static unsigned char cluster_64[] = { 0, 0, 9, 6, 134, 119 }; +static unsigned char cluster_128[] = { 44, 40, 63, 59, 230, 95 }; + +static int check_cluster( int cluster, unsigned char *buffer, unsigned char *expected_cluster ) { + unsigned char *target = buffer + cluster*6; + + if (memcmp(target, expected_cluster, 6) == 0) { + return 0; + } + + fprintf( stderr, "Cluster %d did not match expected results.\n", cluster ); + fprintf( stderr, + "Expect: %3d %3d %3d %3d\n" + " %3d %3d\n", + expected_cluster[0], expected_cluster[1], + expected_cluster[4], expected_cluster[5], + expected_cluster[2], expected_cluster[3] ); + fprintf( stderr, + " Got: %3d %3d %3d %3d\n" + " %3d %3d\n", + target[0], target[1], + target[4], target[5], + target[2], target[3] ); + return 1; +} + +static int check_rgb_pixel( int pixel, int red, int green, int blue, unsigned char *buffer ) { + unsigned char *rgb = buffer + 3 * pixel; + + if( rgb[0] == red && rgb[1] == green && rgb[2] == blue ) { + return 0; + } + + fprintf( stderr, "Pixel %d did not match expected results.\n", pixel ); + fprintf( stderr, "Expect: %3d %3d %3d\n", red, green, blue ); + fprintf( stderr, " Got: %3d %3d %3d\n", rgb[0], rgb[1], rgb[2] ); + return 1; +} + +static int check_rgba_pixel( int pixel, int red, int green, int blue, int alpha, unsigned char *buffer ) { + /* RGBA images are upside down - adjust for normal ordering */ + int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128; + unsigned char *rgba = buffer + 4 * adjusted_pixel; + + if( rgba[0] == red && rgba[1] == green && rgba[2] == blue && rgba[3] == alpha ) { + return 0; + } + + fprintf( stderr, "Pixel %d did not match expected results.\n", pixel ); + fprintf( stderr, "Expect: %3d %3d %3d %3d\n", red, green, blue, alpha ); + fprintf( stderr, " Got: %3d %3d %3d %3d\n", rgba[0], rgba[1], rgba[2], rgba[3] ); + return 1; +} + +int +main(int argc, char **argv) +{ + TIFF *tif; + static const char *srcfile = "images/quad-tile.jpg.tiff"; + unsigned short h, v; + int status; + unsigned char *buffer; + tsize_t sz, szout; + + (void) argc; + (void) argv; + + tif = TIFFOpen(srcfile,"r"); + if ( tif == NULL ) { + fprintf( stderr, "Could not open %s\n", srcfile); + exit( 1 ); + } + + status = TIFFGetField(tif,TIFFTAG_YCBCRSUBSAMPLING, &h, &v); + if ( status == 0 || h != 2 || v != 2) { + fprintf( stderr, "Could not retrieve subsampling tag.\n" ); + exit(1); + } + + /* + * What is the appropriate size of a YCbCr encoded tile? + */ + sz = TIFFTileSize(tif); + if( sz != 24576) { + fprintf(stderr, "tiles are %d bytes\n", (int)sz); + exit(1); + } + + buffer = (unsigned char *) malloc(sz); + + /* + * Read a tile in decompressed form, but still YCbCr subsampled. + */ + szout = TIFFReadEncodedTile(tif,9,buffer,sz); + if (szout != sz) { + fprintf( stderr, + "Did not get expected result code from TIFFReadEncodedTile()(%d instead of %d)\n", + (int) szout, (int) sz ); + return 1; + } + + if( check_cluster( 0, buffer, cluster_0 ) + || check_cluster( 64, buffer, cluster_64 ) + || check_cluster( 128, buffer, cluster_128 ) ) { + exit(1); + } + free(buffer); + + /* + * Read a tile using the built-in conversion to RGB format provided by the JPEG library. + */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + + sz = TIFFTileSize(tif); + if( sz != 128*128*3) { + fprintf(stderr, "tiles are %d bytes\n", (int)sz); + exit(1); + } + + buffer = (unsigned char *) malloc(sz); + + szout = TIFFReadEncodedTile(tif,9,buffer,sz); + if (szout != sz) { + fprintf( stderr, + "Did not get expected result code from TIFFReadEncodedTile()(%d instead of %d)\n", + (int) szout, (int) sz ); + return 1; + } + + if (check_rgb_pixel( 0, 15, 0, 18, buffer ) + || check_rgb_pixel( 64, 0, 0, 2, buffer ) + || check_rgb_pixel( 512, 6, 36, 182, buffer ) ) { + exit(1); + } + + free( buffer ); + + TIFFClose(tif); + + /* + * Reopen and test reading using the RGBA interface. + */ + tif = TIFFOpen(srcfile,"r"); + + sz = 128 * 128 * 4; + buffer = (unsigned char *) malloc(sz); + + if (!TIFFReadRGBATile( tif, 1*128, 2*128, (uint32 *) buffer )) { + fprintf( stderr, "TIFFReadRGBATile() returned failure code.\n" ); + return 1; + } + + /* + * Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this + * trivally matches the last results. Eventually we should actually + * accomplish it from the YCbCr subsampled buffer ourselves in which + * case the results may be subtly different but similar. + */ + if (check_rgba_pixel( 0, 15, 0, 18, 255, buffer ) + || check_rgba_pixel( 64, 0, 0, 2, 255, buffer ) + || check_rgba_pixel( 512, 6, 36, 182, 255, buffer ) ) { + exit(1); + } + + free( buffer ); + TIFFClose(tif); + + exit( 0 ); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-4.0.2/test/rewrite_tag.c b/libs/tiff-4.0.2/test/rewrite_tag.c new file mode 100644 index 0000000000..1023f1668d --- /dev/null +++ b/libs/tiff-4.0.2/test/rewrite_tag.c @@ -0,0 +1,346 @@ +/* $Id: rewrite_tag.c,v 1.5 2012-06-13 04:38:55 fwarmerdam Exp $ */ + +/* + * Copyright (c) 2007, Frank Warmerdam + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * Module to test _TIFFRewriteField(). + */ + +#include "tif_config.h" + +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "tiffio.h" +#include "tiffiop.h" + +const uint32 width = 10; +const uint32 length = 40; +const uint32 rows_per_strip = 1; + +int test_packbits() + +{ + TIFF *tif; + int i; + unsigned char buf[10] = {0,0,0,0,0,0,0,0,0,0}; + + int length = 20; + const char *filename = "test_packbits.tif"; + + /* Test whether we can write tags. */ + tif = TIFFOpen(filename, "w"); + + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } + + if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS)) { + fprintf (stderr, "Can't set Compression tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + + for (i = 0; i < length; i++ ) + { + if( !TIFFWriteEncodedStrip( tif, i, buf, 10 ) ) + { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } + } + + TIFFClose(tif); + + /* Test whether we can write tags. */ + + tif = TIFFOpen(filename, "r+"); + + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } + + buf[3] = 17; + buf[6] = 12; + + if( !TIFFWriteEncodedStrip( tif, 6, buf, 10 ) ) + { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } + + TIFFClose(tif); + + unlink(filename); + + return 0; + + failure: + /* Something goes wrong; close file and return unsuccessful status. */ + TIFFClose(tif); + /* unlink(filename); */ + + return 1; + +} + +/************************************************************************/ +/* rewrite_test() */ +/************************************************************************/ +int rewrite_test( const char *filename, int length, int bigtiff, + uint64 base_value ) + +{ + TIFF *tif; + int i; + unsigned char buf[10] = {5,6,7,8,9,10,11,12,13,14}; + uint64 *rowoffset, *rowbytes; + uint64 *upd_rowoffset; + uint64 *upd_bytecount; + + /* Test whether we can write tags. */ + if( bigtiff ) + tif = TIFFOpen(filename, "w8"); + else + tif = TIFFOpen(filename, "w4"); + + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } + + if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS)) { + fprintf (stderr, "Can't set Compression tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + + for (i = 0; i < length; i++ ) + { + if( !TIFFWriteScanline( tif, buf, i, 0 ) ) + { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } + } + + TIFFClose(tif); + + /* Ok, now test whether we can read written values. */ + tif = TIFFOpen(filename, "r+"); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); + return 1; + } + + if( !TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &rowoffset ) ) + { + fprintf (stderr, "Can't fetch STRIPOFFSETS.\n"); + goto failure; + } + + if( !TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &rowbytes ) ) + { + fprintf (stderr, "Can't fetch STRIPBYTECOUNTS.\n"); + goto failure; + } + + upd_rowoffset = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + for( i = 0; i < length; i++ ) + upd_rowoffset[i] = base_value + i*10; + + if( !_TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8, + length, upd_rowoffset ) ) + { + fprintf (stderr, "Can't rewrite STRIPOFFSETS.\n"); + goto failure; + } + + _TIFFfree( upd_rowoffset ); + + upd_bytecount = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + for( i = 0; i < length; i++ ) + upd_bytecount[i] = 100 + i*10; + + if( !_TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8, + length, upd_bytecount ) ) + { + fprintf (stderr, "Can't rewrite STRIPBYTECOUNTS.\n"); + goto failure; + } + + _TIFFfree( upd_bytecount ); + + TIFFClose(tif); + + /* Reopen file and read back to verify contents */ + + tif = TIFFOpen(filename, "r"); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); + return 1; + } + + if( !TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &rowoffset ) ) + { + fprintf (stderr, "Can't fetch STRIPOFFSETS.\n"); + goto failure; + } + + for( i = 0; i < length; i++ ) + { + uint64 expect = base_value + i*10; + + if( rowoffset[i] != expect ) + { + fprintf( stderr, + "%s:STRIPOFFSETS[%d]: Got %X:%08X instead of %X:%08X.\n", + filename, i, + (int) (rowoffset[i] >> 32), + (int) (rowoffset[i]&0xFFFFFFFF), + (int) (expect >> 32), + (int) (expect & 0xFFFFFFFF) ); + goto failure; + } + } + + if( !TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &rowbytes ) ) + { + fprintf (stderr, "Can't fetch STRIPBYTECOUNTS.\n"); + goto failure; + } + + for( i = 0; i < length; i++ ) + { + uint64 expect = 100 + i*10; + + if( rowbytes[i] != expect ) + { + fprintf( stderr, + "%s:STRIPBYTECOUNTS[%d]: Got %X:%08X instead of %X:%08X.\n", + filename, i, + (int) (rowbytes[i] >> 32), + (int) (rowbytes[i] & 0xFFFFFFFF), + (int) (expect >> 32), + (int) (expect & 0xFFFFFFFF) ); + goto failure; + } + } + + TIFFClose( tif ); + + /* All tests passed; delete file and exit with success status. */ + unlink(filename); + return 0; + + failure: + /* Something goes wrong; close file and return unsuccessful status. */ + TIFFClose(tif); + /* unlink(filename); */ + + return 1; + +} + +/************************************************************************/ +/* main() */ +/************************************************************************/ +int +main(int argc, char **argv) +{ + (void) argc; + (void) argv; + int failure = 0; + + failure |= test_packbits(); + + /* test fairly normal use */ + failure |= rewrite_test( "rewrite1.tif", 10, 0, 100 ); + failure |= rewrite_test( "rewrite2.tif", 10, 1, 100 ); + + /* test case of fitting all in directory entry */ + failure |= rewrite_test( "rewrite3.tif", 1, 0, 100 ); + failure |= rewrite_test( "rewrite4.tif", 1, 1, 100 ); + + /* test with very large values that don't fit in 4bytes (bigtiff only) */ + failure |= rewrite_test( "rewrite5.tif", 1000, 1, 0x6000000000ULL ); + failure |= rewrite_test( "rewrite6.tif", 1, 1, 0x6000000000ULL ); + + return failure; +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libs/tiff-3.8.2/test/short_tag.c b/libs/tiff-4.0.2/test/short_tag.c similarity index 78% rename from libs/tiff-3.8.2/test/short_tag.c rename to libs/tiff-4.0.2/test/short_tag.c index 94ef1fddba..7b832281b1 100644 --- a/libs/tiff-3.8.2/test/short_tag.c +++ b/libs/tiff-4.0.2/test/short_tag.c @@ -1,4 +1,4 @@ -/* $Id: short_tag.c,v 1.6 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: short_tag.c,v 1.8 2008-04-15 14:20:30 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -38,10 +38,9 @@ #endif #include "tiffio.h" +#include "tifftest.h" -extern int CheckShortField(TIFF *, ttag_t, uint16); - -const char *filename = "short_test.tiff"; +static const char filename[] = "short_test.tiff"; #define SPP 3 /* Samples per pixel */ const uint16 width = 1; @@ -51,30 +50,39 @@ const uint16 photometric = PHOTOMETRIC_RGB; const uint16 rows_per_strip = 1; const uint16 planarconfig = PLANARCONFIG_CONTIG; -static struct SingleTags { - ttag_t tag; - uint16 value; +static const struct { + const ttag_t tag; + const uint16 value; } short_single_tags[] = { { TIFFTAG_COMPRESSION, COMPRESSION_NONE }, { TIFFTAG_FILLORDER, FILLORDER_MSB2LSB }, { TIFFTAG_ORIENTATION, ORIENTATION_BOTRIGHT }, { TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH }, - { TIFFTAG_INKSET, INKSET_MULTIINK }, { TIFFTAG_MINSAMPLEVALUE, 23 }, { TIFFTAG_MAXSAMPLEVALUE, 241 }, + { TIFFTAG_INKSET, INKSET_MULTIINK }, { TIFFTAG_NUMBEROFINKS, SPP }, { TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT } - /*{ TIFFTAG_IMAGEDEPTH, 1 }, - { TIFFTAG_TILEDEPTH, 1 }*/ }; #define NSINGLETAGS (sizeof(short_single_tags) / sizeof(short_single_tags[0])) +static const struct { + const ttag_t tag; + const uint16 values[2]; +} short_paired_tags[] = { + { TIFFTAG_PAGENUMBER, {1, 1} }, + { TIFFTAG_HALFTONEHINTS, {0, 255} }, + { TIFFTAG_DOTRANGE, {8, 16} }, + { TIFFTAG_YCBCRSUBSAMPLING, {2, 1} } +}; +#define NPAIREDTAGS (sizeof(short_paired_tags) / sizeof(short_paired_tags[0])) + int -main(int argc, char **argv) +main() { TIFF *tif; - int i; - unsigned char buf[3] = { 0, 127, 255 }; + size_t i; + unsigned char buf[SPP] = { 0, 127, 255 }; /* Test whether we can write tags. */ tif = TIFFOpen(filename, "w"); @@ -115,8 +123,18 @@ main(int argc, char **argv) for (i = 0; i < NSINGLETAGS; i++) { if (!TIFFSetField(tif, short_single_tags[i].tag, short_single_tags[i].value)) { - fprintf(stderr, "Can't set tag %d.\n", - (int)short_single_tags[i].tag); + fprintf(stderr, "Can't set tag %lu.\n", + (unsigned long)short_single_tags[i].tag); + goto failure; + } + } + + for (i = 0; i < NPAIREDTAGS; i++) { + if (!TIFFSetField(tif, short_paired_tags[i].tag, + short_paired_tags[i].values[0], + short_paired_tags[i].values[1])) { + fprintf(stderr, "Can't set tag %lu.\n", + (unsigned long)short_paired_tags[i].tag); goto failure; } } @@ -163,6 +181,12 @@ main(int argc, char **argv) goto failure; } + for (i = 0; i < NPAIREDTAGS; i++) { + if (CheckShortPairedField(tif, short_paired_tags[i].tag, + short_paired_tags[i].values) < 0) + goto failure; + } + TIFFClose(tif); /* All tests passed; delete file and exit with success status. */ @@ -170,9 +194,11 @@ main(int argc, char **argv) return 0; failure: - /* Something goes wrong; close file and return unsuccessful status. */ + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ TIFFClose(tif); - unlink(filename); return 1; } diff --git a/libs/tiff-3.8.2/test/strip.c b/libs/tiff-4.0.2/test/strip.c similarity index 95% rename from libs/tiff-3.8.2/test/strip.c rename to libs/tiff-4.0.2/test/strip.c index e722647daf..b01e8fa099 100644 --- a/libs/tiff-3.8.2/test/strip.c +++ b/libs/tiff-4.0.2/test/strip.c @@ -1,4 +1,4 @@ -/* $Id: strip.c,v 1.3 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: strip.c,v 1.4 2008-03-28 01:42:06 bfriesen Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -174,8 +174,8 @@ openfailure: " ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" " BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" " PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", - name, width, length, rowsperstrip, compression, - bps, spp, sampleformat, planarconfig, + name, (long) width, (long) length, (long) rowsperstrip, + compression, bps, spp, sampleformat, planarconfig, photometric); return -1; } @@ -252,8 +252,8 @@ openfailure: " ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" " BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" " PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", - name, width, length, rowsperstrip, compression, - bps, spp, sampleformat, planarconfig, + name, (long) width, (long) length, (long) rowsperstrip, + compression, bps, spp, sampleformat, planarconfig, photometric); return -1; } @@ -263,6 +263,7 @@ write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) { uint32 length, row; tsize_t scanlinesize, offset; + (void) size; if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &length)) { fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); @@ -278,7 +279,7 @@ write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) for (offset = 0, row = 0; row < length; offset+=scanlinesize, row++) { if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) < 0) { fprintf (stderr, - "Can't write image data at row %lu.\n", row); + "Can't write image data at row %lu.\n", (long) row); return -1; } } diff --git a/libs/tiff-3.8.2/test/strip_rw.c b/libs/tiff-4.0.2/test/strip_rw.c similarity index 97% rename from libs/tiff-3.8.2/test/strip_rw.c rename to libs/tiff-4.0.2/test/strip_rw.c index d93d865940..9eeeb51879 100644 --- a/libs/tiff-3.8.2/test/strip_rw.c +++ b/libs/tiff-4.0.2/test/strip_rw.c @@ -1,4 +1,4 @@ -/* $Id: strip_rw.c,v 1.5 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: strip_rw.c,v 1.6 2008-03-28 01:42:07 bfriesen Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -57,6 +57,8 @@ main(int argc, char **argv) uint32 rowsperstrip; uint16 compression; uint16 spp, bps, photometric, sampleformat, planarconfig; + (void) argc; + (void) argv; /* * Test two special cases: image consisting from single line and image diff --git a/libs/tiff-3.8.2/test/test_arrays.c b/libs/tiff-4.0.2/test/test_arrays.c similarity index 99% rename from libs/tiff-3.8.2/test/test_arrays.c rename to libs/tiff-4.0.2/test/test_arrays.c index 83767662b3..03580fb86b 100644 --- a/libs/tiff-3.8.2/test/test_arrays.c +++ b/libs/tiff-4.0.2/test/test_arrays.c @@ -1,4 +1,4 @@ -/* $Id: test_arrays.c,v 1.3 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: test_arrays.c,v 1.3 2006-03-23 14:54:02 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev diff --git a/libs/tiff-3.8.2/test/test_arrays.h b/libs/tiff-4.0.2/test/test_arrays.h similarity index 96% rename from libs/tiff-3.8.2/test/test_arrays.h rename to libs/tiff-4.0.2/test/test_arrays.h index 5131b2310c..2cdf9a9997 100644 --- a/libs/tiff-3.8.2/test/test_arrays.h +++ b/libs/tiff-4.0.2/test/test_arrays.h @@ -1,4 +1,4 @@ -/* $Id: test_arrays.h,v 1.3 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: test_arrays.h,v 1.3 2006-03-23 14:54:02 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev diff --git a/libs/tiff-4.0.2/test/tiff2pdf.sh b/libs/tiff-4.0.2/test/tiff2pdf.sh new file mode 100755 index 0000000000..76699895c9 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2pdf.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiff2pdf +# +. ${srcdir:-.}/common.sh +f_test_stdout "${TIFF2PDF}" "${IMG_MINISWHITE_1C_1B}" "o-tiff2pdf.pdf" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiff2ps-EPS1.sh b/libs/tiff-4.0.2/test/tiff2ps-EPS1.sh new file mode 100755 index 0000000000..ebe6f04b67 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2ps-EPS1.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffps with PostScript Level 1 encapsulated output +# +. ${srcdir:-.}/common.sh +f_test_stdout "${TIFF2PS} -e -1" "${IMG_MINISWHITE_1C_1B}" "o-tiff2ps-EPS1.ps" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiff2ps-PS1.sh b/libs/tiff-4.0.2/test/tiff2ps-PS1.sh new file mode 100755 index 0000000000..6592159775 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2ps-PS1.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffps with PostScript Level 1 output +# +. ${srcdir:-.}/common.sh +f_test_stdout "${TIFF2PS} -a -p -1" "${IMG_MINISWHITE_1C_1B}" "o-tiff2ps-PS1.ps" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiff2ps-PS2.sh b/libs/tiff-4.0.2/test/tiff2ps-PS2.sh new file mode 100755 index 0000000000..2a21606971 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2ps-PS2.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffps with PostScript Level 2 output +# +. ${srcdir:-.}/common.sh +f_test_stdout "${TIFF2PS} -a -p -2" "${IMG_MINISWHITE_1C_1B}" "o-tiff2ps-PS2.ps" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiff2ps-PS3.sh b/libs/tiff-4.0.2/test/tiff2ps-PS3.sh new file mode 100755 index 0000000000..f9f34b6681 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2ps-PS3.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffps with PostScript Level 3 output +# +. ${srcdir:-.}/common.sh +f_test_stdout "${TIFF2PS} -a -p -3" "${IMG_MINISWHITE_1C_1B}" "o-tiff2ps-PS3.ps" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiff2rgba-logluv-3c-16b.sh b/libs/tiff-4.0.2/test/tiff2rgba-logluv-3c-16b.sh new file mode 100755 index 0000000000..bc9b31181d --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-logluv-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/logluv-3c-16b.tiff" +outfile="o-tiff2rgba-logluv-3c-16b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-minisblack-1c-16b.sh b/libs/tiff-4.0.2/test/tiff2rgba-minisblack-1c-16b.sh new file mode 100755 index 0000000000..5be7e65b61 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-minisblack-1c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-16b.tiff" +outfile="o-tiff2rgba-minisblack-1c-16b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-minisblack-1c-8b.sh b/libs/tiff-4.0.2/test/tiff2rgba-minisblack-1c-8b.sh new file mode 100755 index 0000000000..ce0507bcbb --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-minisblack-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-8b.tiff" +outfile="o-tiff2rgba-minisblack-1c-8b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-minisblack-2c-8b-alpha.sh b/libs/tiff-4.0.2/test/tiff2rgba-minisblack-2c-8b-alpha.sh new file mode 100755 index 0000000000..2cbe81d5ed --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-minisblack-2c-8b-alpha.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-2c-8b-alpha.tiff" +outfile="o-tiff2rgba-minisblack-2c-8b-alpha.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-miniswhite-1c-1b.sh b/libs/tiff-4.0.2/test/tiff2rgba-miniswhite-1c-1b.sh new file mode 100755 index 0000000000..3601502812 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-miniswhite-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/miniswhite-1c-1b.tiff" +outfile="o-tiff2rgba-miniswhite-1c-1b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-1b.sh b/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-1b.sh new file mode 100755 index 0000000000..091d798834 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-1b.tiff" +outfile="o-tiff2rgba-palette-1c-1b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-4b.sh b/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-4b.sh new file mode 100755 index 0000000000..ee3898eb4c --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-4b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-4b.tiff" +outfile="o-tiff2rgba-palette-1c-4b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-8b.sh b/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-8b.sh new file mode 100755 index 0000000000..b1db606f5f --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-palette-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-8b.tiff" +outfile="o-tiff2rgba-palette-1c-8b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-quad-tile.jpg.sh b/libs/tiff-4.0.2/test/tiff2rgba-quad-tile.jpg.sh new file mode 100755 index 0000000000..e921b97304 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-quad-tile.jpg.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/quad-tile.jpg.tiff" +outfile="o-tiff2rgba-quad-tile.jpg.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-rgb-3c-16b.sh b/libs/tiff-4.0.2/test/tiff2rgba-rgb-3c-16b.sh new file mode 100755 index 0000000000..954eb4fda2 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-rgb-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-16b.tiff" +outfile="o-tiff2rgba-rgb-3c-16b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiff2rgba-rgb-3c-8b.sh b/libs/tiff-4.0.2/test/tiff2rgba-rgb-3c-8b.sh new file mode 100755 index 0000000000..24f5cb0360 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiff2rgba-rgb-3c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-8b.tiff" +outfile="o-tiff2rgba-rgb-3c-8b.tiff" +f_test_convert "$TIFF2RGBA" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcp-g3-1d-fill.sh b/libs/tiff-4.0.2/test/tiffcp-g3-1d-fill.sh new file mode 100755 index 0000000000..ee12498361 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-g3-1d-fill.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with G3 compression, 1 dimensional +# encoding, and zero-filled boundaries. +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c g3:1d:fill" "${IMG_MINISWHITE_1C_1B}" "o-tiffcp-g3-1d-fill.tiff" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-g3-1d.sh b/libs/tiff-4.0.2/test/tiffcp-g3-1d.sh new file mode 100755 index 0000000000..c11ef97f05 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-g3-1d.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with G3 compression and 1 dimensional encoding. +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c g3:1d" "${IMG_MINISWHITE_1C_1B}" "o-tiffcp-g3-1d.tiff" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-g3-2d-fill.sh b/libs/tiff-4.0.2/test/tiffcp-g3-2d-fill.sh new file mode 100755 index 0000000000..c25825dabf --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-g3-2d-fill.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with G3 compression, 2 dimensional +# encoding, and zero-filled boundaries. +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c g3:2d:fill" "${IMG_MINISWHITE_1C_1B}" "o-tiffcp-g3-2d-fill.tiff" diff --git a/libs/tiff-4.0.2/test/tiffcp-g3-2d.sh b/libs/tiff-4.0.2/test/tiffcp-g3-2d.sh new file mode 100755 index 0000000000..5a59dd2b76 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-g3-2d.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with G3 compression and 2 dimensional encoding. +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c g3:2d" "${IMG_MINISWHITE_1C_1B}" "o-tiffcp-g3-2d.tiff" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-g3.sh b/libs/tiff-4.0.2/test/tiffcp-g3.sh new file mode 100755 index 0000000000..d7a0107a89 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-g3.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with G3 compression +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c g3" "${IMG_MINISWHITE_1C_1B}" "o-tiffcp-g3.tiff" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-g4.sh b/libs/tiff-4.0.2/test/tiffcp-g4.sh new file mode 100755 index 0000000000..fb8967afbe --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-g4.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with G4 compression +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c g4" "${IMG_MINISWHITE_1C_1B}" "o-tiffcp-g4.tiff" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-logluv.sh b/libs/tiff-4.0.2/test/tiffcp-logluv.sh new file mode 100755 index 0000000000..3f62f57b67 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-logluv.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp with logluv compression +# +. ${srcdir:-.}/common.sh +f_test_convert "${TIFFCP} -c none" "${srcdir}/images/logluv-3c-16b.tiff" "o-tiffcp-logluv-raw.tiff" +f_test_convert "${TIFFCP} -c sgilog" "o-tiffcp-logluv-raw.tiff" "o-tiffcp-logluv-sgilog.tiff" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-split-join.sh b/libs/tiff-4.0.2/test/tiffcp-split-join.sh new file mode 100755 index 0000000000..d1e407c92a --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-split-join.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp + tiffsplit + tiffcp +# +# First we use tiffcp to join our test files into a multi-frame TIFF +# then we use tiffsplit to split them out again, and then we use +# tiffcp to recombine again. + +. ${srcdir:-.}/common.sh +conjoined=o-tiffcp-split-join-conjoined.tif +reconjoined=o-tiffcp-split-join-reconjoined.tif +splitfile=o-tiffcp-split-join-split- + +f_test_convert "${TIFFCP}" "${IMG_UNCOMPRESSED}" "${conjoined}" +f_test_convert "${TIFFSPLIT}" "${conjoined}" "${splitfile}" +f_test_convert "${TIFFCP}" "${splitfile}*" "${reconjoined}" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-split.sh b/libs/tiff-4.0.2/test/tiffcp-split.sh new file mode 100755 index 0000000000..a2f98e33ea --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-split.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# Basic sanity check for tiffcp + tiffsplit +# +# First we use tiffcp to join our test files into a multi-frame TIFF +# and then we use tiffsplit to split them out again. +# +. ${srcdir:-.}/common.sh +conjoined=o-tiffcp-split-conjoined.tif +splitfile=o-tiffcp-split-split- + +f_test_convert "${TIFFCP}" "${IMG_UNCOMPRESSED}" "${conjoined}" +f_test_convert "${TIFFSPLIT}" "${conjoined}" "${splitfile}" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcp-thumbnail.sh b/libs/tiff-4.0.2/test/tiffcp-thumbnail.sh new file mode 100755 index 0000000000..789cd802b6 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcp-thumbnail.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Basic sanity check for thumbnail +# +. ${srcdir:-.}/common.sh + +outfile1=o-tiffcp-thumbnail-in.tif +outfile2=o-tiffcp-thumbnail-out.tif +f_test_convert "${TIFFCP} -c g3:1d" "${IMG_MINISWHITE_1C_1B}" "${outfile1}" +f_test_convert "${THUMBNAIL}" "${outfile1}" "${outfile2}" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-logluv-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-logluv-3c-16b.sh new file mode 100755 index 0000000000..9ed219e32b --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-logluv-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/logluv-3c-16b.tiff" +outfile="o-tiffcrop-R90-logluv-3c-16b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-1c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-1c-16b.sh new file mode 100755 index 0000000000..faee731e92 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-1c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-16b.tiff" +outfile="o-tiffcrop-R90-minisblack-1c-16b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-1c-8b.sh new file mode 100755 index 0000000000..7acd5e79f4 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-8b.tiff" +outfile="o-tiffcrop-R90-minisblack-1c-8b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-2c-8b-alpha.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-2c-8b-alpha.sh new file mode 100755 index 0000000000..2ef903916c --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-minisblack-2c-8b-alpha.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-2c-8b-alpha.tiff" +outfile="o-tiffcrop-R90-minisblack-2c-8b-alpha.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-miniswhite-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-miniswhite-1c-1b.sh new file mode 100755 index 0000000000..cae85f2213 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-miniswhite-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/miniswhite-1c-1b.tiff" +outfile="o-tiffcrop-R90-miniswhite-1c-1b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-1b.sh new file mode 100755 index 0000000000..ca68b88db3 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-1b.tiff" +outfile="o-tiffcrop-R90-palette-1c-1b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-4b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-4b.sh new file mode 100755 index 0000000000..3cd96ebf19 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-4b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-4b.tiff" +outfile="o-tiffcrop-R90-palette-1c-4b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-8b.sh new file mode 100755 index 0000000000..daccfd3f3a --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-palette-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-8b.tiff" +outfile="o-tiffcrop-R90-palette-1c-8b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-rgb-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-rgb-3c-16b.sh new file mode 100755 index 0000000000..b1dddc308e --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-rgb-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-16b.tiff" +outfile="o-tiffcrop-R90-rgb-3c-16b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-R90-rgb-3c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-R90-rgb-3c-8b.sh new file mode 100755 index 0000000000..0a502c8c8e --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-R90-rgb-3c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-8b.tiff" +outfile="o-tiffcrop-R90-rgb-3c-8b.tiff" +f_test_convert "$TIFFCROP -R90" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-logluv-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-logluv-3c-16b.sh new file mode 100755 index 0000000000..c1b19b9928 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-logluv-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/logluv-3c-16b.tiff" +outfile="o-tiffcrop-doubleflip-logluv-3c-16b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-1c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-1c-16b.sh new file mode 100755 index 0000000000..1e2c4c96bf --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-1c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-16b.tiff" +outfile="o-tiffcrop-doubleflip-minisblack-1c-16b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-1c-8b.sh new file mode 100755 index 0000000000..77798d92cf --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-8b.tiff" +outfile="o-tiffcrop-doubleflip-minisblack-1c-8b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh new file mode 100755 index 0000000000..b5b9db6844 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-2c-8b-alpha.tiff" +outfile="o-tiffcrop-doubleflip-minisblack-2c-8b-alpha.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-miniswhite-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-miniswhite-1c-1b.sh new file mode 100755 index 0000000000..07aab91f73 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-miniswhite-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/miniswhite-1c-1b.tiff" +outfile="o-tiffcrop-doubleflip-miniswhite-1c-1b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-1b.sh new file mode 100755 index 0000000000..581f7eb62a --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-1b.tiff" +outfile="o-tiffcrop-doubleflip-palette-1c-1b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-4b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-4b.sh new file mode 100755 index 0000000000..d09b2aa5e2 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-4b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-4b.tiff" +outfile="o-tiffcrop-doubleflip-palette-1c-4b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-8b.sh new file mode 100755 index 0000000000..53a08aef70 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-palette-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-8b.tiff" +outfile="o-tiffcrop-doubleflip-palette-1c-8b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-rgb-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-rgb-3c-16b.sh new file mode 100755 index 0000000000..7165ad52d3 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-rgb-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-16b.tiff" +outfile="o-tiffcrop-doubleflip-rgb-3c-16b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-doubleflip-rgb-3c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-rgb-3c-8b.sh new file mode 100755 index 0000000000..6bfa067009 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-doubleflip-rgb-3c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-8b.tiff" +outfile="o-tiffcrop-doubleflip-rgb-3c-8b.tiff" +f_test_convert "$TIFFCROP -F both" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-logluv-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-logluv-3c-16b.sh new file mode 100755 index 0000000000..821694bd62 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-logluv-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/logluv-3c-16b.tiff" +outfile="o-tiffcrop-extract-logluv-3c-16b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-1c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-1c-16b.sh new file mode 100755 index 0000000000..603fc1ccd3 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-1c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-16b.tiff" +outfile="o-tiffcrop-extract-minisblack-1c-16b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-1c-8b.sh new file mode 100755 index 0000000000..6e473c5c90 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-8b.tiff" +outfile="o-tiffcrop-extract-minisblack-1c-8b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-2c-8b-alpha.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-2c-8b-alpha.sh new file mode 100755 index 0000000000..976e888e68 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-minisblack-2c-8b-alpha.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-2c-8b-alpha.tiff" +outfile="o-tiffcrop-extract-minisblack-2c-8b-alpha.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-miniswhite-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-miniswhite-1c-1b.sh new file mode 100755 index 0000000000..ca2b63cc7e --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-miniswhite-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/miniswhite-1c-1b.tiff" +outfile="o-tiffcrop-extract-miniswhite-1c-1b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-1b.sh new file mode 100755 index 0000000000..e4aca8e53a --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-1b.tiff" +outfile="o-tiffcrop-extract-palette-1c-1b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-4b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-4b.sh new file mode 100755 index 0000000000..18884e45eb --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-4b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-4b.tiff" +outfile="o-tiffcrop-extract-palette-1c-4b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-8b.sh new file mode 100755 index 0000000000..cd418e0ece --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-palette-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-8b.tiff" +outfile="o-tiffcrop-extract-palette-1c-8b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-rgb-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-rgb-3c-16b.sh new file mode 100755 index 0000000000..a3899d3985 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-rgb-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-16b.tiff" +outfile="o-tiffcrop-extract-rgb-3c-16b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extract-rgb-3c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-extract-rgb-3c-8b.sh new file mode 100755 index 0000000000..c03b03755f --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extract-rgb-3c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-8b.tiff" +outfile="o-tiffcrop-extract-rgb-3c-8b.tiff" +f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-logluv-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-logluv-3c-16b.sh new file mode 100755 index 0000000000..a617ad9d79 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-logluv-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/logluv-3c-16b.tiff" +outfile="o-tiffcrop-extractz14-logluv-3c-16b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-1c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-1c-16b.sh new file mode 100755 index 0000000000..320fd5ac20 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-1c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-16b.tiff" +outfile="o-tiffcrop-extractz14-minisblack-1c-16b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-1c-8b.sh new file mode 100755 index 0000000000..8df8578389 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-1c-8b.tiff" +outfile="o-tiffcrop-extractz14-minisblack-1c-8b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-2c-8b-alpha.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-2c-8b-alpha.sh new file mode 100755 index 0000000000..3e8ee15716 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-minisblack-2c-8b-alpha.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/minisblack-2c-8b-alpha.tiff" +outfile="o-tiffcrop-extractz14-minisblack-2c-8b-alpha.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-miniswhite-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-miniswhite-1c-1b.sh new file mode 100755 index 0000000000..2cbffaad04 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-miniswhite-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/miniswhite-1c-1b.tiff" +outfile="o-tiffcrop-extractz14-miniswhite-1c-1b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-1b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-1b.sh new file mode 100755 index 0000000000..e0b305f42f --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-1b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-1b.tiff" +outfile="o-tiffcrop-extractz14-palette-1c-1b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-4b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-4b.sh new file mode 100755 index 0000000000..980b2bb370 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-4b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-4b.tiff" +outfile="o-tiffcrop-extractz14-palette-1c-4b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-8b.sh new file mode 100755 index 0000000000..af2e04ccc3 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-palette-1c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/palette-1c-8b.tiff" +outfile="o-tiffcrop-extractz14-palette-1c-8b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-rgb-3c-16b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-rgb-3c-16b.sh new file mode 100755 index 0000000000..9bc76e3580 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-rgb-3c-16b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-16b.tiff" +outfile="o-tiffcrop-extractz14-rgb-3c-16b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffcrop-extractz14-rgb-3c-8b.sh b/libs/tiff-4.0.2/test/tiffcrop-extractz14-rgb-3c-8b.sh new file mode 100755 index 0000000000..21f76b8284 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffcrop-extractz14-rgb-3c-8b.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Generated file, master is Makefile.am +. ${srcdir:-.}/common.sh +infile="$srcdir/images/rgb-3c-8b.tiff" +outfile="o-tiffcrop-extractz14-rgb-3c-8b.tiff" +f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile +f_tiffinfo_validate $outfile diff --git a/libs/tiff-4.0.2/test/tiffdump.sh b/libs/tiff-4.0.2/test/tiffdump.sh new file mode 100755 index 0000000000..3cd7c10b6c --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffdump.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffdump +# +. ${srcdir:-.}/common.sh +f_test_reader "${TIFFDUMP}" "${IMG_MINISWHITE_1C_1B}" \ No newline at end of file diff --git a/libs/tiff-4.0.2/test/tiffinfo.sh b/libs/tiff-4.0.2/test/tiffinfo.sh new file mode 100755 index 0000000000..cb572483c9 --- /dev/null +++ b/libs/tiff-4.0.2/test/tiffinfo.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Basic sanity check for tiffinfo. +# +. ${srcdir:-.}/common.sh +f_test_reader "${TIFFINFO} -c -D -d -j -s " "${IMG_MINISBLACK_1C_16B}" diff --git a/libs/tiff-3.8.2/libtiff/tif_flush.c b/libs/tiff-4.0.2/test/tifftest.h similarity index 51% rename from libs/tiff-3.8.2/libtiff/tif_flush.c rename to libs/tiff-4.0.2/test/tifftest.h index 5ff56e9a81..889c6447a4 100644 --- a/libs/tiff-3.8.2/libtiff/tif_flush.c +++ b/libs/tiff-4.0.2/test/tifftest.h @@ -1,8 +1,7 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3 2000/09/15 20:52:42 warmerda Exp $ */ +/* $Id: tifftest.h,v 1.1 2008-04-15 14:18:36 dron Exp $ */ /* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * Copyright (c) 2008, Andrey Kiselev * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided @@ -24,44 +23,20 @@ * OF THIS SOFTWARE. */ -/* - * TIFF Library. - */ -#include "tiffiop.h" - -int -TIFFFlush(TIFF* tif) -{ - - if (tif->tif_mode != O_RDONLY) { - if (!TIFFFlushData(tif)) - return (0); - if ((tif->tif_flags & TIFF_DIRTYDIRECT) && - !TIFFWriteDirectory(tif)) - return (0); - } - return (1); -} +#ifndef _TIFFTEST_ +#define _TIFFTEST_ /* - * Flush buffered data to the file. + * TIFF Library * - * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING - * is not set, so that TIFFFlush() will proceed to write out the directory. - * The documentation says returning 1 is an error indicator, but not having - * been writing isn't exactly a an error. Hopefully this doesn't cause - * problems for other people. + * Header file for helper testing routines. */ -int -TIFFFlushData(TIFF* tif) -{ - if ((tif->tif_flags & TIFF_BEENWRITING) == 0) - return (0); - if (tif->tif_flags & TIFF_POSTENCODE) { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) - return (0); - } - return (TIFFFlushData1(tif)); -} + +#include "tiffio.h" + +int CheckShortField(TIFF *, const ttag_t, const uint16); +int CheckShortPairedField(TIFF *, const ttag_t, const uint16*); +int CheckLongField(TIFF *, const ttag_t, const uint32); + +#endif /* _TIFFTEST_ */ diff --git a/libs/tiff-3.8.2/tools/Makefile.am b/libs/tiff-4.0.2/tools/Makefile.am similarity index 97% rename from libs/tiff-3.8.2/tools/Makefile.am rename to libs/tiff-4.0.2/tools/Makefile.am index 544110aaeb..c2b735c445 100644 --- a/libs/tiff-3.8.2/tools/Makefile.am +++ b/libs/tiff-4.0.2/tools/Makefile.am @@ -45,6 +45,7 @@ bin_PROGRAMS = \ tiff2rgba \ tiffcmp \ tiffcp \ + tiffcrop \ tiffdither \ tiffdump \ tiffinfo \ @@ -109,6 +110,9 @@ tiffcmp_LDADD = $(LIBTIFF) $(LIBPORT) tiffcp_SOURCES = tiffcp.c tiffcp_LDADD = $(LIBTIFF) $(LIBPORT) +tiffcrop_SOURCES = tiffcrop.c +tiffcrop_LDADD = $(LIBTIFF) $(LIBPORT) + tiffdither_SOURCES = tiffdither.c tiffdither_LDADD = $(LIBTIFF) $(LIBPORT) diff --git a/libs/tiff-3.8.2/tools/Makefile.vc b/libs/tiff-4.0.2/tools/Makefile.vc similarity index 82% rename from libs/tiff-3.8.2/tools/Makefile.vc rename to libs/tiff-4.0.2/tools/Makefile.vc index 351db7d722..c8d69cddf2 100644 --- a/libs/tiff-3.8.2/tools/Makefile.vc +++ b/libs/tiff-4.0.2/tools/Makefile.vc @@ -1,4 +1,4 @@ -# $Id: Makefile.vc,v 1.11 2006/03/23 14:54:02 dron Exp $ +# $Id: Makefile.vc,v 1.15 2009-01-22 20:53:07 fwarmerdam Exp $ # # Copyright (C) 2004, Andrey Kiselev # @@ -28,13 +28,14 @@ !INCLUDE ..\nmake.opt -TARGETS = bmp2tiff.exe tiffcp.exe tiffinfo.exe tiffdump.exe \ - fax2tiff.exe fax2ps.exe gif2tiff.exe pal2rgb.exe ppm2tiff.exe \ +TARGETS = bmp2tiff.exe tiffinfo.exe tiffdump.exe fax2tiff.exe \ + fax2ps.exe gif2tiff.exe pal2rgb.exe ppm2tiff.exe \ rgb2ycbcr.exe thumbnail.exe ras2tiff.exe raw2tiff.exe \ tiff2bw.exe tiff2rgba.exe tiff2pdf.exe tiff2ps.exe \ - tiffcmp.exe tiffdither.exe tiffmedian.exe tiffsplit.exe + tiffcmp.exe tiffcp.exe tiffcrop.exe tiffdither.exe \ + tiffmedian.exe tiffset.exe tiffsplit.exe -INCL = -I..\libtiff +INCL = -I..\libtiff -I..\port -DNEED_LIBPORT LIBS = $(LIBS) ..\port\libport.lib ..\libtiff\libtiff.lib default: $(TARGETS) @@ -47,4 +48,5 @@ tiffgt.exe: clean: -del *.exe + -del *.exe.manifest -del *.obj diff --git a/libs/tiff-3.8.2/tools/bmp2tiff.c b/libs/tiff-4.0.2/tools/bmp2tiff.c similarity index 98% rename from libs/tiff-3.8.2/tools/bmp2tiff.c rename to libs/tiff-4.0.2/tools/bmp2tiff.c index a2aea26970..c66a8d2178 100644 --- a/libs/tiff-3.8.2/tools/bmp2tiff.c +++ b/libs/tiff-4.0.2/tools/bmp2tiff.c @@ -1,4 +1,4 @@ -/* $Id: bmp2tiff.c,v 1.20 2006/03/23 14:54:02 dron Exp $ +/* $Id: bmp2tiff.c,v 1.23 2010-03-10 18:56:49 bfriesen Exp $ * * Project: libtiff tools * Purpose: Convert Windows BMP files in TIFF. @@ -52,6 +52,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #ifndef O_BINARY @@ -428,7 +432,7 @@ main(int argc, char* argv[]) read(fd, clr_tbl, n_clr_elems * clr_tbl_size); red_tbl = (unsigned short*) - _TIFFmalloc(1< #endif +#ifdef HAVE_FCNTL_H +# include +#endif + #ifdef HAVE_IO_H # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" float defxres = 204.; /* default x resolution (pixels/inch) */ @@ -269,9 +277,9 @@ findPage(TIFF* tif, uint16 pageNumber) uint16 pn = (uint16) -1; uint16 ptotal = (uint16) -1; if (GetPageNumber(tif)) { - while (pn != pageNumber && TIFFReadDirectory(tif) && GetPageNumber(tif)) + while (pn != (pageNumber-1) && TIFFReadDirectory(tif) && GetPageNumber(tif)) ; - return (pn == pageNumber); + return (pn == (pageNumber-1)); } else return (TIFFSetDirectory(tif, (tdir_t)(pageNumber-1))); } @@ -376,10 +384,12 @@ main(int argc, char** argv) fd = tmpfile(); if (fd == NULL) { - fprintf(stderr, "Could not create temporary file, exiting.\n"); - fclose(fd); + fprintf(stderr, "Could not obtain temporary file.\n"); exit(-2); } +#if defined(HAVE_SETMODE) && defined(O_BINARY) + setmode(fileno(stdin), O_BINARY); +#endif while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0) write(fileno(fd), buf, n); lseek(fileno(fd), 0, SEEK_SET); @@ -430,3 +440,10 @@ usage(int code) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/fax2tiff.c b/libs/tiff-4.0.2/tools/fax2tiff.c similarity index 97% rename from libs/tiff-3.8.2/tools/fax2tiff.c rename to libs/tiff-4.0.2/tools/fax2tiff.c index a18835ee8e..8881e5fc70 100644 --- a/libs/tiff-3.8.2/tools/fax2tiff.c +++ b/libs/tiff-4.0.2/tools/fax2tiff.c @@ -1,4 +1,4 @@ -/* $Id: fax2tiff.c,v 1.18 2006/03/21 16:37:51 dron Exp $ */ +/* $Id: fax2tiff.c,v 1.22 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -44,12 +44,12 @@ # include #endif -#include "tiffiop.h" - -#ifndef BINMODE -# define BINMODE +#ifdef NEED_LIBPORT +# include "libport.h" #endif +#include "tiffiop.h" + #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 #endif @@ -258,7 +258,7 @@ main(int argc, char* argv[]) else if (compression_in == COMPRESSION_CCITTFAX4) TIFFSetField(faxTIFF, TIFFTAG_GROUP4OPTIONS, group4options_in); for (pn = 0; optind < argc; pn++, optind++) { - in = fopen(argv[optind], "r" BINMODE); + in = fopen(argv[optind], "rb"); if (in == NULL) { fprintf(stderr, "%s: %s: Can not open\n", argv[0], argv[optind]); @@ -351,7 +351,7 @@ copyFaxFile(TIFF* tifin, TIFF* tifout) uint16 badrun; int ok; - tifin->tif_rawdatasize = TIFFGetFileSize(tifin); + tifin->tif_rawdatasize = (tmsize_t)TIFFGetFileSize(tifin); tifin->tif_rawdata = _TIFFmalloc(tifin->tif_rawdatasize); if (tifin->tif_rawdata == NULL) { TIFFError(tifin->tif_name, "Not enough memory"); @@ -460,3 +460,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/gif2tiff.c b/libs/tiff-4.0.2/tools/gif2tiff.c similarity index 96% rename from libs/tiff-3.8.2/tools/gif2tiff.c rename to libs/tiff-4.0.2/tools/gif2tiff.c index 8e0ebd9dd0..17f7a19e6e 100644 --- a/libs/tiff-3.8.2/tools/gif2tiff.c +++ b/libs/tiff-4.0.2/tools/gif2tiff.c @@ -1,4 +1,4 @@ -/* $Id: gif2tiff.c,v 1.8 2004/09/02 14:36:33 dron Exp $ */ +/* $Id: gif2tiff.c,v 1.12 2010-12-15 00:22:44 faxguy Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -44,6 +44,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #define GIFGAMMA (1.5) /* smaller makes output img brighter */ @@ -250,7 +254,7 @@ readscreen(void) global = buf[4] & 0x80; if (global) { globalbits = (buf[4] & 0x07) + 1; - fread(globalmap,3,1< height-row) { + rowsperstrip = height-row; + stripsize = TIFFVStripSize(tif, rowsperstrip); + } if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0) break; strip++; @@ -513,3 +521,10 @@ rasterize(int interleaved, char* mode) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/pal2rgb.c b/libs/tiff-4.0.2/tools/pal2rgb.c similarity index 98% rename from libs/tiff-3.8.2/tools/pal2rgb.c rename to libs/tiff-4.0.2/tools/pal2rgb.c index 8f353123a6..8608aad1ed 100644 --- a/libs/tiff-3.8.2/tools/pal2rgb.c +++ b/libs/tiff-4.0.2/tools/pal2rgb.c @@ -1,4 +1,4 @@ -/* $Id: pal2rgb.c,v 1.10 2006/01/11 17:03:43 fwarmerdam Exp $ */ +/* $Id: pal2rgb.c,v 1.13 2010-07-02 12:02:56 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -35,6 +35,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) @@ -361,7 +365,7 @@ static struct cpTag { { TIFFTAG_DATETIME, 1, TIFF_ASCII }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, 1, TIFF_RATIONAL }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, @@ -422,3 +426,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/ppm2tiff.c b/libs/tiff-4.0.2/tools/ppm2tiff.c similarity index 95% rename from libs/tiff-3.8.2/tools/ppm2tiff.c rename to libs/tiff-4.0.2/tools/ppm2tiff.c index c775574861..f78d5d4ec6 100644 --- a/libs/tiff-3.8.2/tools/ppm2tiff.c +++ b/libs/tiff-4.0.2/tools/ppm2tiff.c @@ -1,4 +1,4 @@ -/* $Id: ppm2tiff.c,v 1.12 2006/03/01 10:41:24 dron Exp $ */ +/* $Id: ppm2tiff.c,v 1.16 2010-04-10 19:22:34 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -35,18 +35,24 @@ # include #endif +#ifdef HAVE_FCNTL_H +# include +#endif + +#ifdef HAVE_IO_H +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #ifndef HAVE_GETOPT extern int getopt(int, char**, char*); #endif -#if defined(_WINDOWS) || defined(MSDOS) -#define BINMODE "b" -#else -#define BINMODE -#endif - #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) @@ -116,7 +122,7 @@ main(int argc, char* argv[]) */ if (argc - optind > 1) { infile = argv[optind++]; - in = fopen(infile, "r" BINMODE); + in = fopen(infile, "rb"); if (in == NULL) { fprintf(stderr, "%s: Can not open.\n", infile); return (-1); @@ -124,6 +130,9 @@ main(int argc, char* argv[]) } else { infile = ""; in = stdin; +#if defined(HAVE_SETMODE) && defined(O_BINARY) + setmode(fileno(stdin), O_BINARY); +#endif } if (fgetc(in) != 'P') @@ -164,7 +173,7 @@ main(int argc, char* argv[]) if (c == '#') { do { c = fgetc(in); - } while(!strchr("\r\n", c) || feof(in)); + } while(!(strchr("\r\n", c) || feof(in))); continue; } @@ -348,3 +357,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/ras2tiff.c b/libs/tiff-4.0.2/tools/ras2tiff.c similarity index 96% rename from libs/tiff-3.8.2/tools/ras2tiff.c rename to libs/tiff-4.0.2/tools/ras2tiff.c index 4b14b1ed99..ec8a071256 100644 --- a/libs/tiff-3.8.2/tools/ras2tiff.c +++ b/libs/tiff-4.0.2/tools/ras2tiff.c @@ -1,4 +1,4 @@ -/* $Id: ras2tiff.c,v 1.14 2006/01/11 17:03:43 fwarmerdam Exp $ */ +/* $Id: ras2tiff.c,v 1.18 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -35,6 +35,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "rasterfile.h" #include "tiffio.h" @@ -44,10 +48,6 @@ #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) -#ifndef BINMODE -#define BINMODE -#endif - static uint16 compression = (uint16) -1; static int jpegcolormode = JPEGCOLORMODE_RGB; static int quality = 75; /* JPEG quality */ @@ -87,13 +87,14 @@ main(int argc, char* argv[]) } if (argc - optind != 2) usage(); - in = fopen(argv[optind], "r" BINMODE); + in = fopen(argv[optind], "rb"); if (in == NULL) { fprintf(stderr, "%s: Can not open.\n", argv[optind]); return (-1); } if (fread(&h, sizeof (h), 1, in) != 1) { fprintf(stderr, "%s: Can not read header.\n", argv[optind]); + fclose(in); return (-2); } if (strcmp(h.ras_magic, RAS_MAGIC) == 0) { @@ -118,11 +119,15 @@ main(int argc, char* argv[]) #endif } else { fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]); + fclose(in); return (-3); } out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) + { + fclose(in); return (-4); + } TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) h.ras_width); TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h.ras_height); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); @@ -224,6 +229,7 @@ main(int argc, char* argv[]) break; } (void) TIFFClose(out); + fclose(in); return (0); } @@ -301,3 +307,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/rasterfile.h b/libs/tiff-4.0.2/tools/rasterfile.h similarity index 97% rename from libs/tiff-3.8.2/tools/rasterfile.h rename to libs/tiff-4.0.2/tools/rasterfile.h index c194e4993e..7fb33dbc10 100644 --- a/libs/tiff-3.8.2/tools/rasterfile.h +++ b/libs/tiff-4.0.2/tools/rasterfile.h @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/tools/rasterfile.h,v 1.3 2003/11/12 19:14:33 dron Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/tools/rasterfile.h,v 1.3 2003-11-12 19:14:33 dron Exp $ */ /* * Description of header for files containing raster images diff --git a/libs/tiff-3.8.2/tools/raw2tiff.c b/libs/tiff-4.0.2/tools/raw2tiff.c similarity index 98% rename from libs/tiff-3.8.2/tools/raw2tiff.c rename to libs/tiff-4.0.2/tools/raw2tiff.c index 45cc28099b..9ab980e51c 100644 --- a/libs/tiff-3.8.2/tools/raw2tiff.c +++ b/libs/tiff-4.0.2/tools/raw2tiff.c @@ -1,4 +1,4 @@ -/* $Id: raw2tiff.c,v 1.23 2006/03/23 14:54:02 dron Exp $ +/* $Id: raw2tiff.c,v 1.25 2010-03-10 18:56:49 bfriesen Exp $ * * Project: libtiff tools * Purpose: Convert raw byte sequences in TIFF images @@ -53,6 +53,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #ifndef HAVE_GETOPT @@ -638,3 +642,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/rgb2ycbcr.c b/libs/tiff-4.0.2/tools/rgb2ycbcr.c similarity index 90% rename from libs/tiff-3.8.2/tools/rgb2ycbcr.c rename to libs/tiff-4.0.2/tools/rgb2ycbcr.c index 3376ba7c86..162aac10e0 100644 --- a/libs/tiff-3.8.2/tools/rgb2ycbcr.c +++ b/libs/tiff-4.0.2/tools/rgb2ycbcr.c @@ -1,4 +1,4 @@ -/* $Id: rgb2ycbcr.c,v 1.9 2004/09/03 07:57:13 dron Exp $ */ +/* $Id: rgb2ycbcr.c,v 1.14 2011-05-31 17:03:16 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -34,6 +34,11 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#include "tiffiop.h" #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) @@ -254,6 +259,7 @@ cvtRaster(TIFF* tif, uint32* raster, uint32 width, uint32 height) cc = rnrows*rwidth + 2*((rnrows*rwidth) / (horizSubSampling*vertSubSampling)); buf = (unsigned char*)_TIFFmalloc(cc); + // FIXME unchecked malloc for (y = height; (int32) y > 0; y -= nrows) { uint32 nr = (y > nrows ? nrows : y); cvtStrip(buf, raster + (y-1)*width, nr, width); @@ -278,14 +284,32 @@ tiffcvt(TIFF* in, TIFF* out) float floatv; char *stringv; uint32 longv; + int result; + size_t pixel_count; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); - raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32)); - if (raster == 0) { - TIFFError(TIFFFileName(in), "No space for raster buffer"); - return (0); - } + pixel_count = width * height; + + /* XXX: Check the integer overflow. */ + if (!width || !height || pixel_count / width != height) { + TIFFError(TIFFFileName(in), + "Malformed input file; " + "can't allocate buffer for raster of %lux%lu size", + (unsigned long)width, (unsigned long)height); + return 0; + } + + raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), + "raster buffer"); + if (raster == 0) { + TIFFError(TIFFFileName(in), + "Failed to allocate buffer (%lu elements of %lu each)", + (unsigned long)pixel_count, + (unsigned long)sizeof(uint32)); + return (0); + } + if (!TIFFReadRGBAImage(in, width, height, raster, 0)) { _TIFFfree(raster); return (0); @@ -322,7 +346,9 @@ tiffcvt(TIFF* in, TIFF* out) rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - return (cvtRaster(out, raster, width, height)); + result = cvtRaster(out, raster, width, height); + _TIFFfree(raster); + return result; } char* stuff[] = { @@ -355,3 +381,10 @@ usage(int code) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/sgi2tiff.c b/libs/tiff-4.0.2/tools/sgi2tiff.c similarity index 98% rename from libs/tiff-3.8.2/tools/sgi2tiff.c rename to libs/tiff-4.0.2/tools/sgi2tiff.c index 40bfa7df66..227e62107f 100644 --- a/libs/tiff-3.8.2/tools/sgi2tiff.c +++ b/libs/tiff-4.0.2/tools/sgi2tiff.c @@ -1,4 +1,4 @@ -/* $Id: sgi2tiff.c,v 1.5 2006/01/11 16:59:36 fwarmerdam Exp $ */ +/* $Id: sgi2tiff.c,v 1.6 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -326,3 +326,10 @@ usage(void) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/sgisv.c b/libs/tiff-4.0.2/tools/sgisv.c similarity index 89% rename from libs/tiff-3.8.2/tools/sgisv.c rename to libs/tiff-4.0.2/tools/sgisv.c index 13e5dd7422..e0d91e06fa 100644 --- a/libs/tiff-3.8.2/tools/sgisv.c +++ b/libs/tiff-4.0.2/tools/sgisv.c @@ -1,4 +1,4 @@ -/* $Id: sgisv.c,v 1.4 2004/07/24 19:05:13 dron Exp $ */ +/* $Id: sgisv.c,v 1.6 2010-03-10 18:56:49 bfriesen Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -33,8 +33,8 @@ #include "tiffio.h" -typedef unsigned char u_char; -typedef unsigned long u_long; +typedef unsigned char unsigned char; +typedef unsigned long uint32; #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) @@ -151,16 +151,16 @@ usage(void) } static void -svRGBSeparate(TIFF* tif, u_long* ss, int xsize, int ysize) +svRGBSeparate(TIFF* tif, uint32* ss, int xsize, int ysize) { tsize_t stripsize = TIFFStripSize(tif); - u_char *rbuf = (u_char *)_TIFFmalloc(3*stripsize); - u_char *gbuf = rbuf + stripsize; - u_char *bbuf = gbuf + stripsize; + unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3*stripsize); + unsigned char *gbuf = rbuf + stripsize; + unsigned char *bbuf = gbuf + stripsize; register int y; for (y = 0; y <= ysize; y += rowsperstrip) { - u_char *rp, *gp, *bp; + unsigned char *rp, *gp, *bp; register int x; register uint32 n; @@ -170,7 +170,7 @@ svRGBSeparate(TIFF* tif, u_long* ss, int xsize, int ysize) rp = rbuf; gp = gbuf; bp = bbuf; do { for (x = 0; x <= xsize; x++) { - u_long v = ss[x]; + uint32 v = ss[x]; rp[x] = v; gp[x] = v >> 8; bp[x] = v >> 16; @@ -192,14 +192,14 @@ svRGBSeparate(TIFF* tif, u_long* ss, int xsize, int ysize) } static void -svRGBContig(TIFF* tif, u_long* ss, int xsize, int ysize) +svRGBContig(TIFF* tif, uint32* ss, int xsize, int ysize) { register int x, y; tsize_t stripsize = TIFFStripSize(tif); - u_char *strip = (u_char *)_TIFFmalloc(stripsize); + unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize); for (y = 0; y <= ysize; y += rowsperstrip) { - register u_char *pp = strip; + register unsigned char *pp = strip; register uint32 n; n = rowsperstrip; @@ -207,7 +207,7 @@ svRGBContig(TIFF* tif, u_long* ss, int xsize, int ysize) n = ysize-y+1; do { for (x = 0; x <= xsize; x++) { - u_long v = ss[x]; + uint32 v = ss[x]; pp[0] = v; pp[1] = v >> 8; pp[2] = v >> 16; @@ -231,14 +231,14 @@ svRGBContig(TIFF* tif, u_long* ss, int xsize, int ysize) #define BLUE CVT(11) /* 11% */ static void -svGrey(TIFF* tif, u_long* ss, int xsize, int ysize) +svGrey(TIFF* tif, uint32* ss, int xsize, int ysize) { register int x, y; - u_char *buf = (u_char *)_TIFFmalloc(TIFFScanlineSize(tif)); + unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif)); for (y = 0; y <= ysize; y++) { for (x = 0; x <= xsize; x++) { - u_char *cp = (u_char *)&ss[x]; + unsigned char *cp = (unsigned char *)&ss[x]; buf[x] = (RED*cp[3] + GREEN*cp[2] + BLUE*cp[1]) >> 8; } if (TIFFWriteScanline(tif, buf, (uint32) y, 0) < 0) @@ -257,7 +257,7 @@ tiffsv(char* name, int x1, int x2, int y1, int y2) TIFF *tif; int xsize, ysize; int xorg, yorg; - u_long *scrbuf; + uint32 *scrbuf; xorg = MIN(x1,x2); yorg = MIN(y1,y2); @@ -295,7 +295,7 @@ tiffsv(char* name, int x1, int x2, int y1, int y2) TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT); rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - scrbuf = (u_long *)_TIFFmalloc((xsize+1)*(ysize+1)*sizeof (u_long)); + scrbuf = (uint32 *)_TIFFmalloc((xsize+1)*(ysize+1)*sizeof (uint32)); readdisplay(xorg, yorg, xorg+xsize, yorg+ysize, scrbuf, RD_FREEZE); if (photometric == PHOTOMETRIC_RGB) { if (config == PLANARCONFIG_SEPARATE) @@ -307,3 +307,10 @@ tiffsv(char* name, int x1, int x2, int y1, int y2) (void) TIFFClose(tif); _TIFFfree((char *)scrbuf); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/thumbnail.c b/libs/tiff-4.0.2/tools/thumbnail.c similarity index 93% rename from libs/tiff-3.8.2/tools/thumbnail.c rename to libs/tiff-4.0.2/tools/thumbnail.c index 51b397c913..fd1cba5755 100644 --- a/libs/tiff-3.8.2/tools/thumbnail.c +++ b/libs/tiff-4.0.2/tools/thumbnail.c @@ -1,4 +1,4 @@ -/* $Id: thumbnail.c,v 1.9 2005/06/23 10:54:02 dron Exp $ */ +/* $Id: thumbnail.c,v 1.16 2010-07-02 12:02:56 dron Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -35,6 +35,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #ifndef HAVE_GETOPT @@ -100,6 +104,8 @@ main(int argc, char* argv[]) if (out == NULL) return 2; in = TIFFOpen(argv[optind], "r"); + if( in == NULL ) + return 2; thumbnail = (uint8*) _TIFFmalloc(tnw * tnh); if (!thumbnail) { @@ -159,6 +165,16 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) CopyField(tag, longv); } break; + case TIFF_LONG8: + { uint64 longv8; + CopyField(tag, longv8); + } + break; + case TIFF_SLONG8: + { int64 longv8; + CopyField(tag, longv8); + } + break; case TIFF_RATIONAL: if (count == 1) { float floatv; @@ -182,7 +198,11 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) CopyField(tag, doubleav); } break; - default: + case TIFF_IFD8: + { toff_t ifd8; + CopyField(tag, ifd8); + } + break; default: TIFFError(TIFFFileName(in), "Data type %d is not supported, tag %d skipped.", tag, type); @@ -230,7 +250,7 @@ static struct cpTag { { TIFFTAG_DATETIME, 1, TIFF_ASCII }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, 1, TIFF_RATIONAL }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, @@ -266,18 +286,18 @@ cpStrips(TIFF* in, TIFF* out) if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); - tsize_t *bytecounts; + uint64 *bytecounts; TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); for (s = 0; s < ns; s++) { - if (bytecounts[s] > bufsize) { - buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]); + if (bytecounts[s] > (uint64) bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); if (!buf) goto bad; - bufsize = bytecounts[s]; + bufsize = (tmsize_t)bytecounts[s]; } - if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 || - TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) { + if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 || + TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) { _TIFFfree(buf); return 0; } @@ -300,18 +320,18 @@ cpTiles(TIFF* in, TIFF* out) if (buf) { ttile_t t, nt = TIFFNumberOfTiles(in); - tsize_t *bytecounts; + uint64 *bytecounts; TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); for (t = 0; t < nt; t++) { - if (bytecounts[t] > bufsize) { - buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]); + if (bytecounts[t] > (uint64) bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); if (!buf) goto bad; - bufsize = bytecounts[t]; + bufsize = (tmsize_t)bytecounts[t]; } - if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 || - TIFFWriteRawTile(out, t, buf, bytecounts[t]) < 0) { + if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 || + TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) { _TIFFfree(buf); return 0; } @@ -553,7 +573,7 @@ generateThumbnail(TIFF* in, TIFF* out) uint16 bps, spp; tsize_t rowsize, rastersize; tstrip_t s, ns = TIFFNumberOfStrips(in); - uint32 diroff[1]; + toff_t diroff[1]; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &sw); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &sh); @@ -594,7 +614,7 @@ generateThumbnail(TIFF* in, TIFF* out) cpTag(in, out, TIFFTAG_IMAGEDESCRIPTION, (uint16) -1, TIFF_ASCII); cpTag(in, out, TIFFTAG_DATETIME, (uint16) -1, TIFF_ASCII); cpTag(in, out, TIFFTAG_HOSTCOMPUTER, (uint16) -1, TIFF_ASCII); - diroff[0] = 0; + diroff[0] = 0UL; TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff); return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw*tnh) != -1 && TIFFWriteDirectory(out) != -1); @@ -630,3 +650,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiff2bw.c b/libs/tiff-4.0.2/tools/tiff2bw.c similarity index 98% rename from libs/tiff-3.8.2/tools/tiff2bw.c rename to libs/tiff-4.0.2/tools/tiff2bw.c index cfd19903dd..bda754a0a1 100644 --- a/libs/tiff-3.8.2/tools/tiff2bw.c +++ b/libs/tiff-4.0.2/tools/tiff2bw.c @@ -1,4 +1,4 @@ -/* $Id: tiff2bw.c,v 1.12 2006/01/11 17:03:43 fwarmerdam Exp $ */ +/* $Id: tiff2bw.c,v 1.15 2010-07-02 12:02:56 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -35,6 +35,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #define streq(a,b) (strcmp((a),(b)) == 0) @@ -395,7 +399,7 @@ static struct cpTag { { TIFFTAG_DATETIME, 1, TIFF_ASCII }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, 1, TIFF_RATIONAL }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, { TIFFTAG_INKSET, 1, TIFF_SHORT }, @@ -458,3 +462,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiff2pdf.c b/libs/tiff-4.0.2/tools/tiff2pdf.c similarity index 74% rename from libs/tiff-3.8.2/tools/tiff2pdf.c rename to libs/tiff-4.0.2/tools/tiff2pdf.c index f20942f317..8143143643 100644 --- a/libs/tiff-3.8.2/tools/tiff2pdf.c +++ b/libs/tiff-4.0.2/tools/tiff2pdf.c @@ -1,4 +1,4 @@ -/* $Id: tiff2pdf.c,v 1.30 2006/03/21 16:37:51 dron Exp $ +/* $Id: tiff2pdf.c,v 1.67 2012-06-15 21:51:54 fwarmerdam Exp $ * * tiff2pdf - converts a TIFF image to a PDF document * @@ -31,40 +31,53 @@ #include #include #include - -#include "tiffiop.h" +#include #if HAVE_UNISTD_H # include #endif -#ifndef NULL -#define NULL ((void*)0) +#ifdef HAVE_FCNTL_H +# include #endif -#if defined(VMS) -#define unlink remove +#ifdef HAVE_IO_H +# include #endif -#if defined(_WIN32) && defined(USE_WIN32_FILEIO) -#include -#include -#define unlink DeleteFileA + +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#include "tiffiop.h" +#include "tiffio.h" + +#ifndef HAVE_GETOPT +extern int getopt(int, char**, char*); +#endif + +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 #endif #define TIFF2PDF_MODULE "tiff2pdf" -#define T2P_VERSION "d" + +#define PS_UNIT_SIZE 72.0F /* This type is of PDF color spaces. */ -typedef enum{ - T2P_CS_BILEVEL=0x01, /* Bilevel, black and white */ - T2P_CS_GRAY=0x02, /* Single channel */ - T2P_CS_RGB=0x04, /* Three channel tristimulus RGB */ - T2P_CS_CMYK=0x08, /* Four channel CMYK print inkset */ - T2P_CS_LAB=0x10, /* Three channel L*a*b* color space */ - T2P_CS_PALETTE=0x1000 /* One of the above with a color map */ - , T2P_CS_CALGRAY=0x20 /* Calibrated single channel */ - , T2P_CS_CALRGB=0x40 /* Calibrated three channel tristimulus RGB */ - , T2P_CS_ICCBASED=0x80 /* ICC profile color specification */ +typedef enum { + T2P_CS_BILEVEL = 0x01, /* Bilevel, black and white */ + T2P_CS_GRAY = 0x02, /* Single channel */ + T2P_CS_RGB = 0x04, /* Three channel tristimulus RGB */ + T2P_CS_CMYK = 0x08, /* Four channel CMYK print inkset */ + T2P_CS_LAB = 0x10, /* Three channel L*a*b* color space */ + T2P_CS_PALETTE = 0x1000,/* One of the above with a color map */ + T2P_CS_CALGRAY = 0x20, /* Calibrated single channel */ + T2P_CS_CALRGB = 0x40, /* Calibrated three channel tristimulus RGB */ + T2P_CS_ICCBASED = 0x80 /* ICC profile color specification */ } t2p_cs_t; /* This type is of PDF compression types. */ @@ -160,9 +173,6 @@ typedef struct { uint16 tiff_orientation; toff_t tiff_dataoffset; tsize_t tiff_datasize; - TIFFReadWriteProc tiff_readproc; - TIFFReadWriteProc tiff_writeproc; - TIFFSeekProc tiff_seekproc; uint16 tiff_resunit; uint16 pdf_centimeters; uint16 pdf_overrideres; @@ -177,6 +187,7 @@ typedef struct { float pdf_pagelength; float pdf_imagewidth; float pdf_imagelength; + int pdf_image_fillpage; /* 0 (default: no scaling, 1:scale imagesize to pagesize */ T2P_BOX pdf_mediabox; T2P_BOX pdf_imagebox; uint16 pdf_majorversion; @@ -187,13 +198,20 @@ typedef struct { uint32 pdf_palettecs; uint16 pdf_fitwindow; uint32 pdf_startxref; - char* pdf_fileid; - char* pdf_datetime; - char* pdf_creator; - char* pdf_author; - char* pdf_title; - char* pdf_subject; - char* pdf_keywords; +#define TIFF2PDF_FILEID_SIZE 33 + char pdf_fileid[TIFF2PDF_FILEID_SIZE]; +#define TIFF2PDF_DATETIME_SIZE 17 + char pdf_datetime[TIFF2PDF_DATETIME_SIZE]; +#define TIFF2PDF_CREATOR_SIZE 512 + char pdf_creator[TIFF2PDF_CREATOR_SIZE]; +#define TIFF2PDF_AUTHOR_SIZE 512 + char pdf_author[TIFF2PDF_AUTHOR_SIZE]; +#define TIFF2PDF_TITLE_SIZE 512 + char pdf_title[TIFF2PDF_TITLE_SIZE]; +#define TIFF2PDF_SUBJECT_SIZE 512 + char pdf_subject[TIFF2PDF_SUBJECT_SIZE]; +#define TIFF2PDF_KEYWORDS_SIZE 512 + char pdf_keywords[TIFF2PDF_KEYWORDS_SIZE]; t2p_cs_t pdf_colorspace; uint16 pdf_colorspace_invert; uint16 pdf_switchdecode; @@ -225,6 +243,11 @@ typedef struct { uint32 pdf_icccs; uint32 tiff_iccprofilelength; tdata_t tiff_iccprofile; + + /* fields for custom read/write procedures */ + FILE *outputfile; + int outputdisable; + tsize_t outputwritten; } T2P; /* These functions are called by main. */ @@ -247,10 +270,6 @@ void t2p_free(T2P*); } #endif -tsize_t t2p_empty_readproc(thandle_t, tdata_t, tsize_t); -tsize_t t2p_empty_writeproc(thandle_t, tdata_t, tsize_t); -toff_t t2p_empty_seekproc(thandle_t, toff_t, int); -int t2p_empty_closeproc(thandle_t); void t2p_read_tiff_init(T2P*, TIFF*); int t2p_cmp_t2p_page(const void*, const void*); void t2p_read_tiff_data(T2P*, TIFF*); @@ -279,7 +298,7 @@ tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32); tsize_t t2p_write_pdf_header(T2P*, TIFF*); tsize_t t2p_write_pdf_obj_start(uint32, TIFF*); tsize_t t2p_write_pdf_obj_end(TIFF*); -tsize_t t2p_write_pdf_name(char*, TIFF*); +tsize_t t2p_write_pdf_name(unsigned char*, TIFF*); tsize_t t2p_write_pdf_string(char*, TIFF*); tsize_t t2p_write_pdf_stream(tdata_t, tsize_t, TIFF*); tsize_t t2p_write_pdf_stream_start(TIFF*); @@ -313,6 +332,137 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t, T2P*, TIFF*); tsize_t t2p_write_pdf_xreftable(T2P*, TIFF*); tsize_t t2p_write_pdf_trailer(T2P*, TIFF*); +static void +t2p_disable(TIFF *tif) +{ + T2P *t2p = (T2P*) TIFFClientdata(tif); + t2p->outputdisable = 1; +} + +static void +t2p_enable(TIFF *tif) +{ + T2P *t2p = (T2P*) TIFFClientdata(tif); + t2p->outputdisable = 0; +} + +/* + * Procs for TIFFClientOpen + */ + +static tmsize_t +t2pReadFile(TIFF *tif, tdata_t data, tmsize_t size) +{ + thandle_t client = TIFFClientdata(tif); + TIFFReadWriteProc proc = TIFFGetReadProc(tif); + if (proc) + return proc(client, data, size); + return -1; +} + +static tmsize_t +t2pWriteFile(TIFF *tif, tdata_t data, tmsize_t size) +{ + thandle_t client = TIFFClientdata(tif); + TIFFReadWriteProc proc = TIFFGetWriteProc(tif); + if (proc) + return proc(client, data, size); + return -1; +} + +static uint64 +t2pSeekFile(TIFF *tif, toff_t offset, int whence) +{ + thandle_t client = TIFFClientdata(tif); + TIFFSeekProc proc = TIFFGetSeekProc(tif); + if (proc) + return proc(client, offset, whence); + return -1; +} + +static tmsize_t +t2p_readproc(thandle_t handle, tdata_t data, tmsize_t size) +{ + (void) handle, (void) data, (void) size; + return -1; +} + +static tmsize_t +t2p_writeproc(thandle_t handle, tdata_t data, tmsize_t size) +{ + T2P *t2p = (T2P*) handle; + if (t2p->outputdisable <= 0 && t2p->outputfile) { + tsize_t written = fwrite(data, 1, size, t2p->outputfile); + t2p->outputwritten += written; + return written; + } + return size; +} + +static uint64 +t2p_seekproc(thandle_t handle, uint64 offset, int whence) +{ + T2P *t2p = (T2P*) handle; + if (t2p->outputdisable <= 0 && t2p->outputfile) + return fseek(t2p->outputfile, (long) offset, whence); + return offset; +} + +static int +t2p_closeproc(thandle_t handle) +{ + (void) handle; + return 0; +} + +static uint64 +t2p_sizeproc(thandle_t handle) +{ + (void) handle; + return -1; +} + +static int +t2p_mapproc(thandle_t handle, void **data, toff_t *offset) +{ + (void) handle, (void) data, (void) offset; + return -1; +} + +static void +t2p_unmapproc(thandle_t handle, void *data, toff_t offset) +{ + (void) handle, (void) data, (void) offset; +} + +static uint64 +checkAdd64(uint64 summand1, uint64 summand2, T2P* t2p) +{ + uint64 bytes = summand1 + summand2; + + if (bytes - summand1 != summand2) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + bytes = 0; + } + + return bytes; +} + +static uint64 +checkMultiply64(uint64 first, uint64 second, T2P* t2p) +{ + uint64 bytes = first * second; + + if (second && bytes / second != first) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + bytes = 0; + } + + return bytes; +} + /* This is the main function. @@ -385,23 +535,22 @@ tsize_t t2p_write_pdf_trailer(T2P*, TIFF*); options: -o: output to file name - -j compress with JPEG (requires libjpeg configured with libtiff) - -z compress with Zip/Deflate (requires zlib configured with libtiff) + -j: compress with JPEG (requires libjpeg configured with libtiff) + -z: compress with Zip/Deflate (requires zlib configured with libtiff) -q: compression quality - -n no compressed data passthrough - -d do not compress (decompress) - - -i invert colors - + -n: no compressed data passthrough + -d: do not compress (decompress) + -i: invert colors -u: set distance unit, 'i' for inch, 'm' for centimeter -x: set x resolution default -y: set y resolution default -w: width in units -l: length in units -r: 'd' for resolution default, 'o' for resolution override - -p: paper size, eg "letter", "legal", "A4" - -f set PDF "Fit Window" user preference - -b set PDF "Interpolate" user preference + -p: paper size, eg "letter", "legal", "a4" + -F: make the tiff fill the PDF page + -f: set pdf "fit window" user preference + -b: set PDF "Interpolate" user preference -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS -c: creator, overrides image software default -a: author, overrides image artist default @@ -409,7 +558,7 @@ tsize_t t2p_write_pdf_trailer(T2P*, TIFF*); -s: subject, overrides image image description default -k: keywords - -h usage + -h: usage examples: @@ -419,17 +568,17 @@ tsize_t t2p_write_pdf_trailer(T2P*, TIFF*); tiff2pdf input.tiff - The above example would generate PDF output from input.tiff and write it + The above example would generate PDF output from input.tiff and write it to standard output. tiff2pdf -j -p letter -o output.pdf input.tiff - The above example would generate the file output.pdf from input.tiff, - putting the image pages on a letter sized page, compressing the output + The above example would generate the file output.pdf from input.tiff, + putting the image pages on a letter sized page, compressing the output with JPEG. Please report bugs through: - + http://bugzilla.remotesensing.org/buglist.cgi?product=libtiff See also libtiff.3t, tiffcp. @@ -437,24 +586,23 @@ tsize_t t2p_write_pdf_trailer(T2P*, TIFF*); int main(int argc, char** argv){ - extern int optind; extern char *optarg; + extern int optind; + const char *outfilename = NULL; T2P *t2p = NULL; TIFF *input = NULL, *output = NULL; - const char *outfilename = NULL; - tsize_t written=0; - int c=0; - + int c, ret = EXIT_SUCCESS; + t2p = t2p_init(); if (t2p == NULL){ - TIFFError( - TIFF2PDF_MODULE, - "Can't initialize context"); - goto failexit; + TIFFError(TIFF2PDF_MODULE, "Can't initialize context"); + goto fail; } - while ((c = getopt(argc, argv, "o:q:u:x:y:w:l:r:p:e:c:a:t:s:k:jzndifbh")) != -1){ + while (argv && + (c = getopt(argc, argv, + "o:q:u:x:y:w:l:r:p:e:c:a:t:s:k:jzndifbhF")) != -1){ switch (c) { case 'o': outfilename = optarg; @@ -508,12 +656,12 @@ int main(int argc, char** argv){ case 'w': t2p->pdf_overridepagesize=1; t2p->pdf_defaultpagewidth = - ((float)atof(optarg) * 72.0F) / (t2p->pdf_centimeters?2.54F:1.0F); + ((float)atof(optarg) * PS_UNIT_SIZE) / (t2p->pdf_centimeters?2.54F:1.0F); break; case 'l': t2p->pdf_overridepagesize=1; t2p->pdf_defaultpagelength = - ((float)atof(optarg) * 72.0F) / (t2p->pdf_centimeters?2.54F:1.0F); + ((float)atof(optarg) * PS_UNIT_SIZE) / (t2p->pdf_centimeters?2.54F:1.0F); break; case 'r': if(optarg[0]=='o'){ @@ -535,210 +683,133 @@ int main(int argc, char** argv){ case 'i': t2p->pdf_colorspace_invert=1; break; + case 'F': + t2p->pdf_image_fillpage = 1; + break; case 'f': t2p->pdf_fitwindow=1; break; case 'e': - t2p->pdf_datetime = (char*)_TIFFmalloc(17); - if(t2p->pdf_datetime==NULL){ - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for main", - 17); - goto failfreet2p; - } - if(strlen(optarg)==0){ - t2p->pdf_datetime[0]=0; + if (strlen(optarg) == 0) { + t2p->pdf_datetime[0] = '\0'; } else { - if(strlen(optarg)>14){optarg[14]=0;} - t2p->pdf_datetime[0]='D'; - t2p->pdf_datetime[1]=':'; - strcpy(&(t2p->pdf_datetime[2]), optarg); + t2p->pdf_datetime[0] = 'D'; + t2p->pdf_datetime[1] = ':'; + strncpy(t2p->pdf_datetime + 2, optarg, + sizeof(t2p->pdf_datetime) - 3); + t2p->pdf_datetime[sizeof(t2p->pdf_datetime) - 1] = '\0'; } break; case 'c': - t2p->pdf_creator = - (char *)_TIFFmalloc(strlen(optarg) + 1); - if(t2p->pdf_creator==NULL){ - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for main", - strlen(optarg)+1); - goto failfreet2p; - } - strcpy(t2p->pdf_creator, optarg); - t2p->pdf_creator[strlen(optarg)]=0; + strncpy(t2p->pdf_creator, optarg, sizeof(t2p->pdf_creator) - 1); + t2p->pdf_creator[sizeof(t2p->pdf_creator) - 1] = '\0'; break; case 'a': - t2p->pdf_author = - (char *)_TIFFmalloc(strlen(optarg) + 1); - if(t2p->pdf_author==NULL){ - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for main", - strlen(optarg)+1); - goto failfreet2p; - } - strcpy(t2p->pdf_author, optarg); - t2p->pdf_author[strlen(optarg)]=0; + strncpy(t2p->pdf_author, optarg, sizeof(t2p->pdf_author) - 1); + t2p->pdf_author[sizeof(t2p->pdf_author) - 1] = '\0'; break; case 't': - t2p->pdf_title= (char*)_TIFFmalloc(strlen(optarg)+1); - if(t2p->pdf_title==NULL){ - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for main", - strlen(optarg)+1); - goto failfreet2p; - } - strcpy(t2p->pdf_title, optarg); - t2p->pdf_title[strlen(optarg)]=0; + strncpy(t2p->pdf_title, optarg, sizeof(t2p->pdf_title) - 1); + t2p->pdf_title[sizeof(t2p->pdf_title) - 1] = '\0'; break; case 's': - t2p->pdf_subject= (char*)_TIFFmalloc(strlen(optarg)+1); - if(t2p->pdf_subject==NULL){ - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for main", - strlen(optarg)+1); - goto failfreet2p; - } - strcpy(t2p->pdf_subject, optarg); - t2p->pdf_subject[strlen(optarg)]=0; + strncpy(t2p->pdf_subject, optarg, sizeof(t2p->pdf_subject) - 1); + t2p->pdf_subject[sizeof(t2p->pdf_subject) - 1] = '\0'; break; case 'k': - t2p->pdf_keywords= (char*)_TIFFmalloc(strlen(optarg)+1); - if(t2p->pdf_keywords==NULL){ - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for main", - strlen(optarg)+1); - goto failfreet2p; - } - strcpy(t2p->pdf_keywords, optarg); - t2p->pdf_keywords[strlen(optarg)]=0; - break; + strncpy(t2p->pdf_keywords, optarg, sizeof(t2p->pdf_keywords) - 1); + t2p->pdf_keywords[sizeof(t2p->pdf_keywords) - 1] = '\0'; + break; case 'b': t2p->pdf_image_interpolate = 1; break; case 'h': case '?': tiff2pdf_usage(); - goto failfreet2p; + goto success; break; } } - t2p_validate(t2p); - - if(argc>optind){ + /* + * Input + */ + if(argc > optind) { input = TIFFOpen(argv[optind++], "r"); - if(input==NULL){ - TIFFError( - TIFF2PDF_MODULE, - "Can't open input file %s for reading", - argv[optind-1]); - goto failfreet2p; - } - } else { - TIFFError( - TIFF2PDF_MODULE, - "No input file specified"); - tiff2pdf_usage(); - goto failfreet2p; - } - - if(argc>optind){ - TIFFError( - TIFF2PDF_MODULE, - "No support for multiple input files"); - tiff2pdf_usage(); - goto failcloseinput; - } - - if (outfilename) { - output = TIFFOpen(outfilename, "w"); - if(output == NULL) { + if (input==NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't open output file %s for writing", - optarg); - goto failfreet2p; - } - if(output->tif_seekproc != NULL) { - TIFFSeekFile(output, (toff_t) 0, SEEK_SET); - } - } else { -#if !defined(_WIN32) || defined(AVOID_WIN32_FILEIO) - output = TIFFFdOpen((int)fileno(tmpfile()), "-", "w"); -#else - { - TCHAR temppath[MAX_PATH]; - TCHAR tempfile[MAX_PATH]; - GetTempPath((DWORD)MAX_PATH, (LPTSTR)temppath); - GetTempFileName((LPCTSTR)temppath, (LPTSTR) "t2p", 0, (LPTSTR)tempfile); - output = TIFFFdOpen( (int)CreateFile( - (LPCTSTR)tempfile, - GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_FLAG_DELETE_ON_CLOSE, - NULL), - "-", "w"); - } -#endif - if(output==NULL){ - TIFFError(TIFF2PDF_MODULE, - "Can't open temporary output file for writing to stdout", + "Can't open input file %s for reading", argv[optind-1]); - goto failcloseinput; + goto fail; } - TIFFFlush(output); - output->tif_readproc=t2p_empty_readproc; - output->tif_seekproc=t2p_empty_seekproc; - output->tif_closeproc=t2p_empty_closeproc; -#if !defined(_WIN32) || defined(AVOID_WIN32_FILEIO) - close(output->tif_fd); - output->tif_fd=(int)fileno(stdout); -#else - CloseHandle((HANDLE) output->tif_fd); - output->tif_fd=(int)GetStdHandle(STD_OUTPUT_HANDLE); -#endif - output->tif_clientdata=(thandle_t)output->tif_fd; + } else { + TIFFError(TIFF2PDF_MODULE, "No input file specified"); + tiff2pdf_usage(); + goto fail; } - written = t2p_write_pdf(t2p, input, output); - - if(t2p->t2p_error != 0){ - TIFFError( - TIFF2PDF_MODULE, - "An error occurred in converting TIFF %s to PDF %s", - TIFFFileName(input), - TIFFFileName(output) - ); - goto failcloseinput; + if(argc > optind) { + TIFFError(TIFF2PDF_MODULE, + "No support for multiple input files"); + tiff2pdf_usage(); + goto fail; } - if(input != NULL){ + /* + * Output + */ + t2p->outputdisable = 0; + if (outfilename) { + t2p->outputfile = fopen(outfilename, "wb"); + if (t2p->outputfile == NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't open output file %s for writing", + outfilename); + goto fail; + } + } else { + outfilename = "-"; + t2p->outputfile = stdout; + } + + output = TIFFClientOpen(outfilename, "w", (thandle_t) t2p, + t2p_readproc, t2p_writeproc, t2p_seekproc, + t2p_closeproc, t2p_sizeproc, + t2p_mapproc, t2p_unmapproc); + if (output == NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't initialize output descriptor"); + goto fail; + } + + /* + * Validate + */ + t2p_validate(t2p); + t2pSeekFile(output, (toff_t) 0, SEEK_SET); + + /* + * Write + */ + t2p_write_pdf(t2p, input, output); + if (t2p->t2p_error != 0) { + TIFFError(TIFF2PDF_MODULE, + "An error occurred creating output PDF file"); + goto fail; + } + + goto success; +fail: + ret = EXIT_FAILURE; +success: + if(input != NULL) TIFFClose(input); - } - if(output != NULL){ + if (output != NULL) TIFFClose(output); - } - if(t2p != NULL){ + if (t2p != NULL) t2p_free(t2p); - } - - return(EXIT_SUCCESS); - -failcloseinput: - if(input != NULL){ - TIFFClose(input); - } -failfreet2p: - if(t2p != NULL){ - t2p_free(t2p); - } -failexit: - return(EXIT_FAILURE); + return ret; + } void tiff2pdf_usage(){ @@ -747,14 +818,15 @@ void tiff2pdf_usage(){ "options:", " -o: output to file name", #ifdef JPEG_SUPPORT - " -j compress with JPEG", + " -j: compress with JPEG", #endif #ifdef ZIP_SUPPORT - " -z compress with Zip/Deflate", + " -z: compress with Zip/Deflate", #endif " -q: compression quality", - " -n no compressed data passthrough", - " -d do not compress (decompress)", + " -n: no compressed data passthrough", + " -d: do not compress (decompress)", + " -i: invert colors", " -u: set distance unit, 'i' for inch, 'm' for centimeter", " -x: set x resolution default in dots per unit", " -y: set y resolution default in dots per unit", @@ -762,15 +834,16 @@ void tiff2pdf_usage(){ " -l: length in units", " -r: 'd' for resolution default, 'o' for resolution override", " -p: paper size, eg \"letter\", \"legal\", \"A4\"", - " -f set PDF \"Fit Window\" user preference", + " -F: make the tiff fill the PDF page", + " -f: set PDF \"Fit Window\" user preference", " -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS", " -c: sets document creator, overrides image software default", " -a: sets document author, overrides image artist default", " -t: sets document title, overrides image document name default", " -s: sets document subject, overrides image image description default", " -k: sets document keywords", - " -b set PDF \"Interpolate\" user preference", - " -h usage", + " -b: set PDF \"Interpolate\" user preference", + " -h: usage", NULL }; int i=0; @@ -785,8 +858,7 @@ void tiff2pdf_usage(){ int tiff2pdf_match_paper_size(float* width, float* length, char* papersize){ - int i=0; - int len=0; + size_t i, len; const char* sizes[]={ "LETTER", "A4", "LEGAL", "EXECUTIVE", "LETTER", "LEGAL", "LEDGER", "TABLOID", @@ -845,17 +917,17 @@ int tiff2pdf_match_paper_size(float* width, float* length, char* papersize){ } /* - This function allocates and initializes a T2P context struct pointer. -*/ - -T2P* t2p_init(){ + * This function allocates and initializes a T2P context struct pointer. + */ +T2P* t2p_init() +{ T2P* t2p = (T2P*) _TIFFmalloc(sizeof(T2P)); if(t2p==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_init", - sizeof(T2P)); + "Can't allocate %lu bytes of memory for t2p_init", + (unsigned long) sizeof(T2P)); return( (T2P*) NULL ); } _TIFFmemset(t2p, 0x00, sizeof(T2P)); @@ -871,14 +943,14 @@ T2P* t2p_init(){ } /* - This function frees a T2P context struct pointer and any allocated data fields of it. -*/ + * This function frees a T2P context struct pointer and any allocated data fields of it. + */ -void t2p_free(T2P* t2p){ +void t2p_free(T2P* t2p) +{ + int i = 0; - int i=0; - - if(t2p != NULL){ + if (t2p != NULL) { if(t2p->pdf_xrefoffsets != NULL){ _TIFFfree( (tdata_t) t2p->pdf_xrefoffsets); } @@ -896,27 +968,6 @@ void t2p_free(T2P* t2p){ if(t2p->pdf_palette != NULL){ _TIFFfree( (tdata_t) t2p->pdf_palette); } - if(t2p->pdf_fileid != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_fileid); - } - if(t2p->pdf_datetime != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_datetime); - } - if(t2p->pdf_creator != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_creator); - } - if(t2p->pdf_author != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_author); - } - if(t2p->pdf_title != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_title); - } - if(t2p->pdf_subject != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_subject); - } - if(t2p->pdf_keywords != NULL){ - _TIFFfree( (tdata_t) t2p->pdf_keywords); - } #ifdef OJPEG_SUPPORT if(t2p->pdf_ojpegdata != NULL){ _TIFFfree( (tdata_t) t2p->pdf_ojpegdata); @@ -937,7 +988,7 @@ void t2p_validate(T2P* t2p){ #ifdef JPEG_SUPPORT if(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){ - if(t2p->pdf_defaultcompressionquality<100 || + if(t2p->pdf_defaultcompressionquality>100 || t2p->pdf_defaultcompressionquality<1){ t2p->pdf_defaultcompressionquality=0; } @@ -945,25 +996,17 @@ void t2p_validate(T2P* t2p){ #endif #ifdef ZIP_SUPPORT if(t2p->pdf_defaultcompression==T2P_COMPRESS_ZIP){ - switch (t2p->pdf_defaultcompressionquality){ - case 1: case 10: case 11: case 12: case 13: case 14: case 15: - case 101: case 110: case 111: case 112: case 113: case 114: case 115: - case 201: case 210: case 211: case 212: case 213: case 214: case 215: - case 301: case 310: case 311: case 312: case 313: case 314: case 315: - case 401: case 410: case 411: case 412: case 413: case 414: case 415: - case 501: case 510: case 511: case 512: case 513: case 514: case 515: - case 601: case 610: case 611: case 612: case 613: case 614: case 615: - case 701: case 710: case 711: case 712: case 713: case 714: case 715: - case 801: case 810: case 811: case 812: case 813: case 814: case 815: - case 901: case 910: case 911: case 912: case 913: case 914: case 915: - break; - default: - t2p->pdf_defaultcompressionquality=0; + uint16 m=t2p->pdf_defaultcompressionquality%100; + if(t2p->pdf_defaultcompressionquality/100 > 9 || + (m>1 && m<10) || m>15){ + t2p->pdf_defaultcompressionquality=0; } if(t2p->pdf_defaultcompressionquality%100 !=0){ + t2p->pdf_defaultcompressionquality/=100; + t2p->pdf_defaultcompressionquality*=100; TIFFError( TIFF2PDF_MODULE, - "PNG Group predictor differencing not implemented, assuming compresion quality %u", + "PNG Group predictor differencing not implemented, assuming compression quality %u", t2p->pdf_defaultcompressionquality); } t2p->pdf_defaultcompressionquality%=100; @@ -996,8 +1039,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(t2p->tiff_pages==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for tiff_pages array, %s", - directorycount * sizeof(T2P_PAGE), + "Can't allocate %lu bytes of memory for tiff_pages array, %s", + (unsigned long) directorycount * sizeof(T2P_PAGE), TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1007,8 +1050,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(t2p->tiff_tiles==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for tiff_tiles array, %s", - directorycount * sizeof(T2P_TILES), + "Can't allocate %lu bytes of memory for tiff_tiles array, %s", + (unsigned long) directorycount * sizeof(T2P_TILES), TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1139,8 +1182,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if( t2p->tiff_tiles[i].tiles_tiles == NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_read_tiff_init, %s", - t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE), + "Can't allocate %lu bytes of memory for t2p_read_tiff_init, %s", + (unsigned long) t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE), TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1152,8 +1195,9 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ } /* - This function is used by qsort to sort a T2P_PAGE* array of page structures by page number. -*/ + * This function is used by qsort to sort a T2P_PAGE* array of page structures + * by page number. + */ int t2p_cmp_t2p_page(const void* e1, const void* e2){ @@ -1379,8 +1423,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ TIFFError( TIFF2PDF_MODULE, "No support for palettized image %s with not one sample per pixel", - TIFFFileName(input), - t2p->tiff_samplesperpixel); + TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; } @@ -1449,8 +1492,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ TIFFError( TIFF2PDF_MODULE, "No support for palettized CMYK image %s with not one sample per pixel", - TIFFFileName(input), - t2p->tiff_samplesperpixel); + TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; } @@ -1483,7 +1525,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ t2p->pdf_palette[(i*4)] = (unsigned char) (r[i]>>8); t2p->pdf_palette[(i*4)+1]= (unsigned char) (g[i]>>8); t2p->pdf_palette[(i*4)+2]= (unsigned char) (b[i]>>8); - t2p->pdf_palette[(i*4)+2]= (unsigned char) (a[i]>>8); + t2p->pdf_palette[(i*4)+3]= (unsigned char) (a[i]>>8); } t2p->pdf_palettesize *= 4; break; @@ -1529,8 +1571,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ TIFFError( TIFF2PDF_MODULE, "No support for %s with photometric interpretation LogL/LogLuv", - TIFFFileName(input), - t2p->tiff_photometric); + TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; default: @@ -1591,13 +1632,15 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(TIFFGetField(input, TIFFTAG_YRESOLUTION, &(t2p->tiff_yres) ) == 0){ t2p->tiff_yres=0.0; } - TIFFGetFieldDefaulted(input, TIFFTAG_RESOLUTIONUNIT, &(t2p->tiff_resunit) ); - if(t2p->tiff_resunit==RESUNIT_CENTIMETER){ - t2p->tiff_xres*=2.54F; - t2p->tiff_yres*=2.54F; - } else if (t2p->tiff_resunit!=RESUNIT_INCH && t2p->pdf_centimeters!=0){ - t2p->tiff_xres*=2.54F; - t2p->tiff_yres*=2.54F; + TIFFGetFieldDefaulted(input, TIFFTAG_RESOLUTIONUNIT, + &(t2p->tiff_resunit)); + if(t2p->tiff_resunit == RESUNIT_CENTIMETER) { + t2p->tiff_xres *= 2.54F; + t2p->tiff_yres *= 2.54F; + } else if (t2p->tiff_resunit != RESUNIT_INCH + && t2p->pdf_centimeters != 0) { + t2p->tiff_xres *= 2.54F; + t2p->tiff_yres *= 2.54F; } t2p_compose_pdf_page(t2p); @@ -1755,29 +1798,26 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ - uint32* sbc=NULL; + uint64* sbc=NULL; #if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT) unsigned char* jpt=NULL; - uint16 xuint16=0; tstrip_t i=0; tstrip_t stripcount=0; #endif -#ifdef OJPEG_SUPPORT - tsize_t k = 0; -#endif + uint64 k = 0; if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ #ifdef CCITT_SUPPORT if(t2p->pdf_compression == T2P_COMPRESS_G4 ){ TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); - t2p->tiff_datasize=sbc[0]; + t2p->tiff_datasize=(tmsize_t)sbc[0]; return; } #endif #ifdef ZIP_SUPPORT if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); - t2p->tiff_datasize=sbc[0]; + t2p->tiff_datasize=(tmsize_t)sbc[0]; return; } #endif @@ -1792,19 +1832,25 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ } stripcount=TIFFNumberOfStrips(input); for(i=0;itiff_dataoffset))){ if(t2p->tiff_dataoffset != 0){ if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){ - if(t2p->tiff_datasize < k) { - t2p->pdf_ojpegiflength=t2p->tiff_datasize; - t2p->tiff_datasize+=k; - t2p->tiff_datasize+=6; - t2p->tiff_datasize+=2*stripcount; + if((uint64)t2p->tiff_datasize < k) { TIFFWarning(TIFF2PDF_MODULE, "Input file %s has short JPEG interchange file byte count", TIFFFileName(input)); + t2p->pdf_ojpegiflength=t2p->tiff_datasize; + k = checkAdd64(k, t2p->tiff_datasize, t2p); + k = checkAdd64(k, 6, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } return; } return; @@ -1817,21 +1863,27 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ } } } - t2p->tiff_datasize+=k; - t2p->tiff_datasize+=2*stripcount; - t2p->tiff_datasize+=2048; + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, 2048, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } return; } #endif #ifdef JPEG_SUPPORT - if(t2p->tiff_compression == COMPRESSION_JPEG){ - if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &xuint16, &jpt) != 0 ){ - if(xuint16>4){ - t2p->tiff_datasize+= xuint16; - t2p->tiff_datasize -=2; /* don't use EOI of header */ + if(t2p->tiff_compression == COMPRESSION_JPEG) { + uint32 count = 0; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){ + if(count > 4){ + k += count; + k -= 2; /* don't use EOI of header */ } } else { - t2p->tiff_datasize=2; /* SOI for first strip */ + k = 2; /* SOI for first strip */ } stripcount=TIFFNumberOfStrips(input); if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ @@ -1842,17 +1894,33 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ return; } for(i=0;itiff_datasize += sbc[i]; - t2p->tiff_datasize -=4; /* don't use SOI or EOI of strip */ + k = checkAdd64(k, sbc[i], t2p); + k -=4; /* don't use SOI or EOI of strip */ } - t2p->tiff_datasize +=2; /* use EOI of last strip */ + k = checkAdd64(k, 2, t2p); /* use EOI of last strip */ + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; } #endif (void) 0; } - t2p->tiff_datasize=TIFFScanlineSize(input) * t2p->tiff_length; + k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p); if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ - t2p->tiff_datasize*= t2p->tiff_samplesperpixel; + k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); + } + if (k == 0) { + /* Assume we had overflow inside TIFFScanlineSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } + + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; } return; @@ -1865,12 +1933,12 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ - uint32* tbc = NULL; + uint64* tbc = NULL; uint16 edge=0; #ifdef JPEG_SUPPORT - uint16 xuint16=0; unsigned char* jpt; #endif + uint64 k; edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); @@ -1882,41 +1950,60 @@ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ #endif ){ t2p->tiff_datasize=TIFFTileSize(input); + if (t2p->tiff_datasize == 0) { + /* Assume we had overflow inside TIFFTileSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } return; } else { TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc); - t2p->tiff_datasize=tbc[tile]; + k=tbc[tile]; #ifdef OJPEG_SUPPORT if(t2p->tiff_compression==COMPRESSION_OJPEG){ - t2p->tiff_datasize+=2048; - return; + k = checkAdd64(k, 2048, t2p); } #endif #ifdef JPEG_SUPPORT - if(t2p->tiff_compression==COMPRESSION_JPEG){ - if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &xuint16, &jpt)!=0){ - if(xuint16>4){ - t2p->tiff_datasize+=xuint16; - t2p->tiff_datasize-=4; /* don't use EOI of header or SOI of tile */ + if(t2p->tiff_compression==COMPRESSION_JPEG) { + uint32 count = 0; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt)!=0){ + if(count > 4){ + k = checkAdd64(k, count, t2p); + k -= 2; /* don't use EOI of header or SOI of tile */ } } } #endif + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } return; } } - t2p->tiff_datasize=TIFFTileSize(input); + k = TIFFTileSize(input); if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ - t2p->tiff_datasize*= t2p->tiff_samplesperpixel; + k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); + } + if (k == 0) { + /* Assume we had overflow inside TIFFTileSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } + + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; } return; } /* - This functions returns a non-zero value when the tile is on the right edge - and does not have full imaged tile width. -*/ + * This functions returns a non-zero value when the tile is on the right edge + * and does not have full imaged tile width. + */ int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){ @@ -1926,15 +2013,12 @@ int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){ } else { return(0); } - - return(0); - } /* - This functions returns a non-zero value when the tile is on the bottom edge - and does not have full imaged tile length. -*/ + * This functions returns a non-zero value when the tile is on the bottom edge + * and does not have full imaged tile length. + */ int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){ @@ -1944,14 +2028,12 @@ int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){ } else { return(0); } - - return(0); } /* - This function returns a non-zero value when the tile is a right edge tile or a bottom - edge tile. -*/ + * This function returns a non-zero value when the tile is a right edge tile + * or a bottom edge tile. + */ int t2p_tile_is_edge(T2P_TILES tiles, ttile_t tile){ @@ -1968,52 +2050,6 @@ int t2p_tile_is_corner_edge(T2P_TILES tiles, ttile_t tile){ return(t2p_tile_is_right_edge(tiles, tile) & t2p_tile_is_bottom_edge(tiles, tile) ); } -/* - This function is an empty (dummy) TIFFReadWriteProc that returns the amount - requested to be read without reading anything. -*/ - -tsize_t t2p_empty_readproc(thandle_t fd, tdata_t buf, tsize_t size){ - - (void) fd; (void) buf; (void) size; - - return (size); -} - -/* - This function is an empty (dummy) TIFFReadWriteProc that returns the amount - requested to be written without writing anything. -*/ - -tsize_t t2p_empty_writeproc(thandle_t fd, tdata_t buf, tsize_t size){ - - (void) fd; (void) buf; (void) size; - - return (size); -} - -/* - This function is an empty (dummy) TIFFSeekProc that returns off. -*/ - -toff_t t2p_empty_seekproc(thandle_t fd, toff_t off, int whence){ - - (void) fd; (void) off; (void) whence; - - return( off ); -} - -/* - This function is an empty (dummy) TIFFCloseProc that returns 0. -*/ - -int t2p_empty_closeproc(thandle_t fd){ - - (void) fd; - - return(0); -} - /* This function reads the raster image data from the input TIFF for an image and writes @@ -2044,87 +2080,115 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ #endif #ifdef JPEG_SUPPORT unsigned char* jpt; - uint16 xuint16_1=0; - uint16 xuint16_2=0; float* xfloatp; - uint32* sbc; + uint64* sbc; unsigned char* stripbuffer; tsize_t striplength=0; uint32 max_striplength=0; #endif + /* Fail if prior error (in particular, can't trust tiff_datasize) */ + if (t2p->t2p_error != T2P_ERR_OK) + return(0); + if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ #ifdef CCITT_SUPPORT if(t2p->pdf_compression == T2P_COMPRESS_G4){ - buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - if(buffer==NULL){ + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if (buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - TIFFReadRawStrip(input, 0, (tdata_t) buffer, t2p->tiff_datasize); + TIFFReadRawStrip(input, 0, (tdata_t) buffer, + t2p->tiff_datasize); if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ - /* make sure is lsb-to-msb bit-endianness fill order */ - TIFFReverseBits(buffer, t2p->tiff_datasize); + /* + * make sure is lsb-to-msb + * bit-endianness fill order + */ + TIFFReverseBits(buffer, + t2p->tiff_datasize); } - TIFFWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + t2pWriteFile(output, (tdata_t) buffer, + t2p->tiff_datasize); _TIFFfree(buffer); return(t2p->tiff_datasize); } #endif #ifdef ZIP_SUPPORT - if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ - buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); - if(buffer==NULL){ + if (t2p->pdf_compression == T2P_COMPRESS_ZIP) { + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if(buffer == NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - TIFFReadRawStrip(input, 0, (tdata_t) buffer, t2p->tiff_datasize); - if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ - TIFFReverseBits(buffer, t2p->tiff_datasize); + memset(buffer, 0, t2p->tiff_datasize); + TIFFReadRawStrip(input, 0, (tdata_t) buffer, + t2p->tiff_datasize); + if (t2p->tiff_fillorder==FILLORDER_LSB2MSB) { + TIFFReverseBits(buffer, + t2p->tiff_datasize); } - TIFFWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + t2pWriteFile(output, (tdata_t) buffer, + t2p->tiff_datasize); _TIFFfree(buffer); return(t2p->tiff_datasize); } #endif #ifdef OJPEG_SUPPORT - if(t2p->tiff_compression == COMPRESSION_OJPEG){ + if(t2p->tiff_compression == COMPRESSION_OJPEG) { - if(t2p->tiff_dataoffset != 0){ - buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); - if(buffer==NULL){ + if(t2p->tiff_dataoffset != 0) { + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if(buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } + memset(buffer, 0, t2p->tiff_datasize); if(t2p->pdf_ojpegiflength==0){ - inputoffset=TIFFSeekFile(input, 0, SEEK_CUR); - TIFFSeekFile(input, t2p->tiff_dataoffset, SEEK_SET); - TIFFReadFile(input, (tdata_t) buffer, t2p->tiff_datasize); - TIFFSeekFile(input, inputoffset, SEEK_SET); - TIFFWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + inputoffset=t2pSeekFile(input, 0, + SEEK_CUR); + t2pSeekFile(input, + t2p->tiff_dataoffset, + SEEK_SET); + t2pReadFile(input, (tdata_t) buffer, + t2p->tiff_datasize); + t2pSeekFile(input, inputoffset, + SEEK_SET); + t2pWriteFile(output, (tdata_t) buffer, + t2p->tiff_datasize); _TIFFfree(buffer); return(t2p->tiff_datasize); } else { - inputoffset=TIFFSeekFile(input, 0, SEEK_CUR); - TIFFSeekFile(input, t2p->tiff_dataoffset, SEEK_SET); - bufferoffset=TIFFReadFile(input, (tdata_t) buffer, t2p->pdf_ojpegiflength); - t2p->pdf_ojpegiflength=0; - TIFFSeekFile(input, inputoffset, SEEK_SET); - TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &h_samp, &v_samp); + inputoffset=t2pSeekFile(input, 0, + SEEK_CUR); + t2pSeekFile(input, + t2p->tiff_dataoffset, + SEEK_SET); + bufferoffset = t2pReadFile(input, + (tdata_t) buffer, + t2p->pdf_ojpegiflength); + t2p->pdf_ojpegiflength = 0; + t2pSeekFile(input, inputoffset, + SEEK_SET); + TIFFGetField(input, + TIFFTAG_YCBCRSUBSAMPLING, + &h_samp, &v_samp); buffer[bufferoffset++]= 0xff; buffer[bufferoffset++]= 0xdd; buffer[bufferoffset++]= 0x00; @@ -2132,7 +2196,9 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ h_samp*=8; v_samp*=8; ri=(t2p->tiff_width+h_samp-1) / h_samp; - TIFFGetField(input, TIFFTAG_ROWSPERSTRIP, &rows); + TIFFGetField(input, + TIFFTAG_ROWSPERSTRIP, + &rows); ri*=(rows+v_samp-1)/v_samp; buffer[bufferoffset++]= (ri>>8) & 0xff; buffer[bufferoffset++]= ri & 0xff; @@ -2147,28 +2213,29 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ (tdata_t) &(((unsigned char*)buffer)[bufferoffset]), -1); } - TIFFWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); _TIFFfree(buffer); return(bufferoffset); } } else { if(! t2p->pdf_ojpegdata){ TIFFError(TIFF2PDF_MODULE, - "No support for OJPEG image %s with bad tables", + "No support for OJPEG image %s with bad tables", TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - buffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } + memset(buffer, 0, t2p->tiff_datasize); _TIFFmemcpy(buffer, t2p->pdf_ojpegdata, t2p->pdf_ojpegdatalength); bufferoffset=t2p->pdf_ojpegdatalength; stripcount=TIFFNumberOfStrips(input); @@ -2186,11 +2253,11 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer[bufferoffset++]=0xff; buffer[bufferoffset++]=0xd9; } - TIFFWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); _TIFFfree(buffer); return(bufferoffset); TIFFError(TIFF2PDF_MODULE, - "No support for OJPEG image %s with no JPEG File Interchange offset", + "No support for OJPEG image %s with no JPEG File Interchange offset", TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2199,21 +2266,23 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ } #endif #ifdef JPEG_SUPPORT - if(t2p->tiff_compression == COMPRESSION_JPEG){ - buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); + if(t2p->tiff_compression == COMPRESSION_JPEG) { + uint32 count = 0; + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &xuint16_1, &jpt) != 0){ - if(xuint16_1>4){ - _TIFFmemcpy(buffer, jpt, xuint16_1); - bufferoffset+=xuint16_1-2; + memset(buffer, 0, t2p->tiff_datasize); + if (TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) { + if(count > 4) { + _TIFFmemcpy(buffer, jpt, count); + bufferoffset += count - 2; } } stripcount=TIFFNumberOfStrips(input); @@ -2221,10 +2290,11 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ for(i=0;imax_striplength) max_striplength=sbc[i]; } - stripbuffer=(unsigned char*) _TIFFmalloc(max_striplength); + stripbuffer = (unsigned char*) + _TIFFmalloc(max_striplength); if(stripbuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", max_striplength, TIFFFileName(input)); _TIFFfree(buffer); @@ -2241,7 +2311,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ i, t2p->tiff_length)){ TIFFError(TIFF2PDF_MODULE, - "Can't process JPEG data in input file %s", + "Can't process JPEG data in input file %s", TIFFFileName(input)); _TIFFfree(samplebuffer); _TIFFfree(buffer); @@ -2251,7 +2321,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ } buffer[bufferoffset++]=0xff; buffer[bufferoffset++]=0xd9; - TIFFWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); _TIFFfree(stripbuffer); _TIFFfree(buffer); return(bufferoffset); @@ -2262,15 +2332,15 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ if(t2p->pdf_sample==T2P_SAMPLE_NOTHING){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } + memset(buffer, 0, t2p->tiff_datasize); stripsize=TIFFStripSize(input); stripcount=TIFFNumberOfStrips(input); for(i=0;itiff_samplesperpixel; buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } + memset(buffer, 0, t2p->tiff_datasize); samplebuffer = (unsigned char*) _TIFFmalloc(stripsize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2328,7 +2398,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ sepstripsize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %u of %s", i + j*stripcount, TIFFFileName(input)); _TIFFfree(buffer); @@ -2349,15 +2419,15 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ } buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); - memset(buffer, 0, t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } + memset(buffer, 0, t2p->tiff_datasize); stripsize=TIFFStripSize(input); stripcount=TIFFNumberOfStrips(input); for(i=0;ipdf_sample & T2P_SAMPLE_REALIZE_PALETTE){ + // FIXME: overflow? samplebuffer=(unsigned char*)_TIFFrealloc( (tdata_t) buffer, t2p->tiff_datasize * t2p->tiff_samplesperpixel); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2415,8 +2486,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_width*t2p->tiff_length*4); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2432,7 +2503,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ ORIENTATION_TOPLEFT, 0)){ TIFFError(TIFF2PDF_MODULE, - "Can't use TIFFReadRGBAImageOriented to extract RGB image from %s", + "Can't use TIFFReadRGBAImageOriented to extract RGB image from %s", TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2450,11 +2521,9 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ } } - dataready: - - t2p->tiff_writeproc=output->tif_writeproc; - output->tif_writeproc=t2p_empty_writeproc; +dataready: + t2p_disable(output); TIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric); TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample); TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel); @@ -2475,10 +2544,11 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ #endif #ifdef JPEG_SUPPORT case T2P_COMPRESS_JPEG: - if(t2p->tiff_photometric==PHOTOMETRIC_YCBCR){ - if(TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &xuint16_1, &xuint16_2)!=0){ - if(xuint16_1 != 0 && xuint16_2 != 0){ - TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, xuint16_1, xuint16_2); + if(t2p->tiff_photometric==PHOTOMETRIC_YCBCR) { + uint16 hor = 0, ver = 0; + if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver) !=0 ) { + if(hor != 0 && ver != 0){ + TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver); } } if(TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, &xfloatp)!=0){ @@ -2487,7 +2557,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ } if(TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_JPEG)==0){ TIFFError(TIFF2PDF_MODULE, - "Unable to use JPEG compression for input %s and output %s", + "Unable to use JPEG compression for input %s and output %s", TIFFFileName(input), TIFFFileName(output)); _TIFFfree(buffer); @@ -2536,37 +2606,44 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ default: break; } - - output->tif_writeproc=t2p->tiff_writeproc; + + t2p_enable(output); + t2p->outputwritten = 0; #ifdef JPEG_SUPPORT - if(t2p->pdf_compression==T2P_COMPRESS_JPEG && t2p->tiff_photometric==PHOTOMETRIC_YCBCR){ - bufferoffset=TIFFWriteEncodedStrip(output, (tstrip_t)0, buffer,stripsize*stripcount); + if(t2p->pdf_compression == T2P_COMPRESS_JPEG + && t2p->tiff_photometric == PHOTOMETRIC_YCBCR){ + bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, + buffer, + stripsize * stripcount); } else #endif - bufferoffset=TIFFWriteEncodedStrip(output, (tstrip_t)0, buffer, t2p->tiff_datasize); - if(buffer != NULL){ + { + bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, + buffer, + t2p->tiff_datasize); + } + if (buffer != NULL) { _TIFFfree(buffer); buffer=NULL; } - if(bufferoffset==(tsize_t)-1){ + if (bufferoffset == (tsize_t)-1) { TIFFError(TIFF2PDF_MODULE, - "Error writing encoded strip to output PDF %s", - TIFFFileName(output)); + "Error writing encoded strip to output PDF %s", + TIFFFileName(output)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - written= output->tif_dir.td_stripbytecount[0]; - + written = t2p->outputwritten; return(written); } /* - This function reads the raster image data from the input TIFF for an image tile and writes - the data to the output PDF XObject image dictionary stream for the tile. It returns the - amount written or zero on error. -*/ + * This function reads the raster image data from the input TIFF for an image + * tile and writes the data to the output PDF XObject image dictionary stream + * for the tile. It returns the amount written or zero on error. + */ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_t tile){ @@ -2584,12 +2661,14 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ tsize_t septilesize=0; #ifdef JPEG_SUPPORT unsigned char* jpt; - uint16 xuint16_1=0; - uint16 xuint16_2=0; float* xfloatp; uint32 xuint32=0; #endif + /* Fail if prior error (in particular, can't trust tiff_datasize) */ + if (t2p->t2p_error != T2P_ERR_OK) + return(0); + edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); @@ -2604,9 +2683,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2615,7 +2694,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ TIFFReverseBits(buffer, t2p->tiff_datasize); } - TIFFWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + t2pWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); _TIFFfree(buffer); return(t2p->tiff_datasize); } @@ -2625,9 +2704,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2636,7 +2715,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ TIFFReverseBits(buffer, t2p->tiff_datasize); } - TIFFWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + t2pWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); _TIFFfree(buffer); return(t2p->tiff_datasize); } @@ -2654,9 +2733,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2683,7 +2762,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ -1); ((unsigned char*)buffer)[bufferoffset++]=0xff; ((unsigned char*)buffer)[bufferoffset++]=0xd9; - TIFFWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); _TIFFfree(buffer); return(bufferoffset); } @@ -2691,24 +2770,25 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ #ifdef JPEG_SUPPORT if(t2p->tiff_compression == COMPRESSION_JPEG){ unsigned char table_end[2]; + uint32 count = 0; buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &xuint16_1, &jpt) != 0) { - if(xuint16_1 > 0){ - _TIFFmemcpy(buffer, jpt, xuint16_1); - bufferoffset += xuint16_1 - 2; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) { + if (count > 0) { + _TIFFmemcpy(buffer, jpt, count); + bufferoffset += count - 2; table_end[0] = buffer[bufferoffset-2]; table_end[1] = buffer[bufferoffset-1]; } - if(xuint16_1 > 0) { + if (count > 0) { xuint32 = bufferoffset; bufferoffset += TIFFReadRawTile( input, @@ -2725,7 +2805,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ -1); } } - TIFFWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); _TIFFfree(buffer); return(bufferoffset); } @@ -2737,9 +2817,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for " + "Can't allocate %lu bytes of memory for " "t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2770,9 +2850,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2780,9 +2860,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ samplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2819,9 +2899,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory " + "Can't allocate %lu bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, + (unsigned long) t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2882,9 +2962,8 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); } - t2p->tiff_writeproc=output->tif_writeproc; - output->tif_writeproc=t2p_empty_writeproc; + t2p_disable(output); TIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric); TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample); TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel); @@ -2932,10 +3011,11 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ #endif #ifdef JPEG_SUPPORT case T2P_COMPRESS_JPEG: - if(t2p->tiff_photometric==PHOTOMETRIC_YCBCR){ - if(TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &xuint16_1, &xuint16_2)!=0){ - if(xuint16_1 != 0 && xuint16_2 != 0){ - TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, xuint16_1, xuint16_2); + if (t2p->tiff_photometric==PHOTOMETRIC_YCBCR) { + uint16 hor = 0, ver = 0; + if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver)!=0) { + if (hor != 0 && ver != 0) { + TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver); } } if(TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, &xfloatp)!=0){ @@ -2983,22 +3063,24 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ default: break; } - - output->tif_writeproc=t2p->tiff_writeproc; - bufferoffset=TIFFWriteEncodedStrip(output, (tstrip_t) 0, buffer, TIFFStripSize(output)); - if(buffer != NULL){ + + t2p_enable(output); + t2p->outputwritten = 0; + bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t) 0, buffer, + TIFFStripSize(output)); + if (buffer != NULL) { _TIFFfree(buffer); - buffer=NULL; + buffer = NULL; } - if(bufferoffset==-1){ + if (bufferoffset == -1) { TIFFError(TIFF2PDF_MODULE, - "Error writing encoded tile to output PDF %s", - TIFFFileName(output)); + "Error writing encoded tile to output PDF %s", + TIFFFileName(output)); t2p->t2p_error = T2P_ERR_ERROR; return(0); } - written= output->tif_dir.td_stripbytecount[0]; + written = t2p->outputwritten; return(written); } @@ -3267,6 +3349,9 @@ int t2p_process_jpeg_strip( while(i<(*striplength)){ switch( strip[i] ){ case 0xd8: + /* SOI - start of image */ + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), 2); + *bufferoffset+=2; i+=2; break; case 0xc0: @@ -3348,11 +3433,11 @@ void t2p_tile_collapse_left( uint32 edgetilewidth, uint32 tilelength){ - uint32 i=0; + uint32 i; tsize_t edgescanwidth=0; edgescanwidth = (scanwidth * edgetilewidth + (tilewidth - 1))/ tilewidth; - for(i=i;itiff_writeproc=output->tif_writeproc; - output->tif_writeproc=t2p_empty_writeproc; - t2p->tiff_readproc=output->tif_readproc; - output->tif_readproc=t2p_empty_readproc; - t2p->tiff_seekproc=output->tif_seekproc; - output->tif_seekproc=t2p_empty_seekproc; - output->tif_header.tiff_diroff=0; +void +t2p_write_advance_directory(T2P* t2p, TIFF* output) +{ + t2p_disable(output); if(!TIFFWriteDirectory(output)){ TIFFError(TIFF2PDF_MODULE, "Error writing virtual directory to output PDF %s", @@ -3385,10 +3465,7 @@ void t2p_write_advance_directory(T2P* t2p, TIFF* output){ t2p->t2p_error = T2P_ERR_ERROR; return; } - output->tif_writeproc=t2p->tiff_writeproc; - output->tif_readproc=t2p->tiff_readproc; - output->tif_seekproc=t2p->tiff_seekproc; - + t2p_enable(output); return; } @@ -3484,11 +3561,10 @@ t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount) for (i = 0; i < samplecount; i++) { sample=((uint32*)data)[i]; - alpha=(uint8)((255 - (sample & 0xff))); - ((uint8 *)data)[i * 3] = (uint8) ((sample >> 24) & 0xff) + alpha; - ((uint8 *)data)[i * 3 + 1] = (uint8) ((sample >> 16) & 0xff) + alpha; - ((uint8 *)data)[i * 3 + 2] = (uint8) ((sample >> 8) & 0xff) + alpha; - + alpha=(uint8)((255 - ((sample >> 24) & 0xff))); + ((uint8 *)data)[i * 3] = (uint8) ((sample >> 16) & 0xff) + alpha; + ((uint8 *)data)[i * 3 + 1] = (uint8) ((sample >> 8) & 0xff) + alpha; + ((uint8 *)data)[i * 3 + 2] = (uint8) (sample & 0xff) + alpha; } return (i * 3); @@ -3532,8 +3608,8 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){ int buflen=0; buflen=sprintf(buffer, "%%PDF-%u.%u ", t2p->pdf_majorversion&0xff, t2p->pdf_minorversion&0xff); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t)"\r%\342\343\317\323\r\n", 8); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t)"\n%\342\343\317\323\n", 7); return(written); } @@ -3549,8 +3625,8 @@ tsize_t t2p_write_pdf_obj_start(uint32 number, TIFF* output){ int buflen=0; buflen=sprintf(buffer, "%lu", (unsigned long)number); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen ); - written += TIFFWriteFile(output, (tdata_t) " 0 obj\r", 7); + written += t2pWriteFile(output, (tdata_t) buffer, buflen ); + written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7); return(written); } @@ -3563,7 +3639,7 @@ tsize_t t2p_write_pdf_obj_end(TIFF* output){ tsize_t written=0; - written += TIFFWriteFile(output, (tdata_t) "endobj\r", 7); + written += t2pWriteFile(output, (tdata_t) "endobj\n", 7); return(written); } @@ -3572,136 +3648,149 @@ tsize_t t2p_write_pdf_obj_end(TIFF* output){ This function writes a PDF name object to output. */ -tsize_t t2p_write_pdf_name(char* name, TIFF* output){ +tsize_t t2p_write_pdf_name(unsigned char* name, TIFF* output){ tsize_t written=0; uint32 i=0; - char buffer[4]; + char buffer[64]; uint16 nextchar=0; - uint32 namelen=0; + size_t namelen=0; - namelen=strlen(name); + namelen = strlen((char *)name); if (namelen>126) { namelen=126; } - written += TIFFWriteFile(output, (tdata_t) "/", 1); + written += t2pWriteFile(output, (tdata_t) "/", 1); for (i=0;i 0x7E){ - sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + sprintf(buffer, "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); nextchar=1; } if (nextchar==0){ switch (name[i]){ case 0x23: - sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + sprintf(buffer, "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x25: - sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + sprintf(buffer, "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x28: - sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + sprintf(buffer, "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x29: sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x2F: sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x3C: sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x3E: - sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + sprintf(buffer, "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x5B: sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x5D: - sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + sprintf(buffer, "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x7B: sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; case 0x7D: sprintf(buffer, "#%.2X", name[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 3); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); break; default: - written += TIFFWriteFile(output, (tdata_t) &name[i], 1); + written += t2pWriteFile(output, (tdata_t) &name[i], 1); } } nextchar=0; } - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) " ", 1); return(written); } /* - This function writes a PDF string object to output. -*/ + * This function writes a PDF string object to output. + */ -tsize_t t2p_write_pdf_string(char* pdfstr, TIFF* output){ - - tsize_t written=0; - uint32 i=0; - char buffer[5]; - uint32 len=0; +tsize_t t2p_write_pdf_string(char* pdfstr, TIFF* output) +{ + tsize_t written = 0; + uint32 i = 0; + char buffer[64]; + size_t len = 0; - len=strlen(pdfstr); - written += TIFFWriteFile(output, (tdata_t) "(", 1); - for (i=0;i>\r", 4); + written += t2pWriteFile(output, (tdata_t) " >>\n", 4); return(written); } @@ -3805,34 +3894,35 @@ tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){ int buflen=0; buflen=sprintf(buffer, "%lu", (unsigned long)len); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n", 1); return(written); } /* - This function writes the PDF Catalog structure to output. -*/ + * This function writes the PDF Catalog structure to output. + */ -tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output){ - - tsize_t written=0; +tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output) +{ + tsize_t written = 0; char buffer[16]; - int buflen=0; + int buflen = 0; - written += TIFFWriteFile(output, - (tdata_t)"<< \r/Type /Catalog \r/Pages ", + written += t2pWriteFile(output, + (tdata_t)"<< \n/Type /Catalog \n/Pages ", 27); - buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_pages); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen ); - written += TIFFWriteFile(output, (tdata_t) " 0 R \r", 6); + buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + written += t2pWriteFile(output, (tdata_t) buffer, + TIFFmin((size_t)buflen, sizeof(buffer) - 1)); + written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); if(t2p->pdf_fitwindow){ - written += TIFFWriteFile(output, - (tdata_t) "/ViewerPreferences <>\r", + written += t2pWriteFile(output, + (tdata_t) "/ViewerPreferences <>\n", 39); } - written += TIFFWriteFile(output, (tdata_t)">>\r", 3); + written += t2pWriteFile(output, (tdata_t)">>\n", 3); return(written); } @@ -3841,148 +3931,130 @@ tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output){ This function writes the PDF Info structure to output. */ -tsize_t t2p_write_pdf_info(T2P* t2p, TIFF* input, TIFF* output){ - - tsize_t written=0; +tsize_t t2p_write_pdf_info(T2P* t2p, TIFF* input, TIFF* output) +{ + tsize_t written = 0; char* info; char buffer[512]; - int buflen=0; - - if(t2p->pdf_datetime==NULL){ + + if(t2p->pdf_datetime[0] == '\0') t2p_pdf_tifftime(t2p, input); - } - if(strlen(t2p->pdf_datetime) > 0){ - written += TIFFWriteFile(output, (tdata_t) "<< \r/CreationDate ", 18); + if (strlen(t2p->pdf_datetime) > 0) { + written += t2pWriteFile(output, (tdata_t) "<< \n/CreationDate ", 18); written += t2p_write_pdf_string(t2p->pdf_datetime, output); - written += TIFFWriteFile(output, (tdata_t) "\r/ModDate ", 10); + written += t2pWriteFile(output, (tdata_t) "\n/ModDate ", 10); written += t2p_write_pdf_string(t2p->pdf_datetime, output); } - written += TIFFWriteFile(output, (tdata_t) "\r/Producer ", 11); - _TIFFmemset((tdata_t)buffer, 0x00, 512); - buflen=sprintf(buffer, "libtiff / tiff2pdf - %d / %s", TIFFLIB_VERSION, T2P_VERSION); + written += t2pWriteFile(output, (tdata_t) "\n/Producer ", 11); + _TIFFmemset((tdata_t)buffer, 0x00, sizeof(buffer)); + snprintf(buffer, sizeof(buffer), "libtiff / tiff2pdf - %d", TIFFLIB_VERSION); written += t2p_write_pdf_string(buffer, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - if(t2p->pdf_creator != NULL){ - if(strlen(t2p->pdf_creator)>0){ - if(strlen(t2p->pdf_creator)>511){t2p->pdf_creator[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Creator ", 9); - written += t2p_write_pdf_string(t2p->pdf_creator, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - } - } else{ - if( TIFFGetField(input, TIFFTAG_SOFTWARE, &info) != 0){ - if(strlen(info)>511){info[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Creator ", 9); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + if (t2p->pdf_creator[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Creator ", 9); + written += t2p_write_pdf_string(t2p->pdf_creator, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } else { + if (TIFFGetField(input, TIFFTAG_SOFTWARE, &info) != 0 && info) { + if(strlen(info) >= sizeof(t2p->pdf_creator)) + info[sizeof(t2p->pdf_creator) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) "/Creator ", 9); written += t2p_write_pdf_string(info, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + written += t2pWriteFile(output, (tdata_t) "\n", 1); } } - if(t2p->pdf_author != NULL){ - if(strlen(t2p->pdf_author)>0){ - if(strlen(t2p->pdf_author)>511){t2p->pdf_author[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Author ", 8); - written += t2p_write_pdf_string(t2p->pdf_author, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - } - } else{ - if( TIFFGetField(input, TIFFTAG_ARTIST, &info) != 0){ - if(strlen(info)>511){info[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Author ", 8); + if (t2p->pdf_author[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Author ", 8); + written += t2p_write_pdf_string(t2p->pdf_author, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } else { + if ((TIFFGetField(input, TIFFTAG_ARTIST, &info) != 0 + || TIFFGetField(input, TIFFTAG_COPYRIGHT, &info) != 0) + && info) { + if (strlen(info) >= sizeof(t2p->pdf_author)) + info[sizeof(t2p->pdf_author) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) "/Author ", 8); written += t2p_write_pdf_string(info, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - } else if ( TIFFGetField(input, TIFFTAG_COPYRIGHT, &info) != 0){ - if(strlen(info)>511){info[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Author ", 8); - written += t2p_write_pdf_string(info, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - } - } - if(t2p->pdf_title != NULL){ - if(strlen(t2p->pdf_title)>0){ - if(strlen(t2p->pdf_title)>511){t2p->pdf_title[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Title ", 7); - written += t2p_write_pdf_string(t2p->pdf_title, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - } - } else{ - if( TIFFGetField(input, TIFFTAG_DOCUMENTNAME, &info) != 0){ - if(strlen(info)>511){info[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Title ", 7); - written += t2p_write_pdf_string(info, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + written += t2pWriteFile(output, (tdata_t) "\n", 1); } } - if(t2p->pdf_subject != NULL){ - if(strlen(t2p->pdf_subject)>0){ - if(strlen(t2p->pdf_subject)>511){t2p->pdf_subject[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Subject ", 9); - written += t2p_write_pdf_string(t2p->pdf_subject, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); - } - } else{ - if( TIFFGetField(input, TIFFTAG_IMAGEDESCRIPTION, &info) != 0){ - if(strlen(info)>511){info[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Subject ", 9); + if (t2p->pdf_title[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Title ", 7); + written += t2p_write_pdf_string(t2p->pdf_title, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } else { + if (TIFFGetField(input, TIFFTAG_DOCUMENTNAME, &info) != 0){ + if(strlen(info) > 511) { + info[512] = '\0'; + } + written += t2pWriteFile(output, (tdata_t) "/Title ", 7); written += t2p_write_pdf_string(info, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + written += t2pWriteFile(output, (tdata_t) "\n", 1); } } - if(t2p->pdf_keywords != NULL){ - if(strlen(t2p->pdf_keywords)>0){ - if(strlen(t2p->pdf_keywords)>511){t2p->pdf_keywords[512]=(char)0;} - written += TIFFWriteFile(output, (tdata_t) "/Keywords ", 10); - written += t2p_write_pdf_string(t2p->pdf_keywords, output); - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + if (t2p->pdf_subject[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Subject ", 9); + written += t2p_write_pdf_string(t2p->pdf_subject, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } else { + if (TIFFGetField(input, TIFFTAG_IMAGEDESCRIPTION, &info) != 0 && info) { + if (strlen(info) >= sizeof(t2p->pdf_subject)) + info[sizeof(t2p->pdf_subject) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) "/Subject ", 9); + written += t2p_write_pdf_string(info, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); } } - written += TIFFWriteFile(output, (tdata_t) ">> \r", 4); + if (t2p->pdf_keywords[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Keywords ", 10); + written += t2p_write_pdf_string(t2p->pdf_keywords, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + written += t2pWriteFile(output, (tdata_t) ">> \n", 4); return(written); } /* - This function fills a string of a T2P struct with the current time as a PDF date string, - it is called by t2p_pdf_tifftime. -*/ - -void t2p_pdf_currenttime(T2P* t2p){ + * This function fills a string of a T2P struct with the current time as a PDF + * date string, it is called by t2p_pdf_tifftime. + */ +void t2p_pdf_currenttime(T2P* t2p) +{ struct tm* currenttime; time_t timenow; - timenow=time(0); - currenttime=localtime(&timenow); - sprintf(t2p->pdf_datetime, "D:%.4d%.2d%.2d%.2d%.2d%.2d", - (currenttime->tm_year+1900) % 65536, - (currenttime->tm_mon+1) % 256, - (currenttime->tm_mday) % 256, - (currenttime->tm_hour) % 256, - (currenttime->tm_min) % 256, - (currenttime->tm_sec) % 256); + if (time(&timenow) == (time_t) -1) { + TIFFError(TIFF2PDF_MODULE, + "Can't get the current time: %s", strerror(errno)); + timenow = (time_t) 0; + } + + currenttime = localtime(&timenow); + snprintf(t2p->pdf_datetime, sizeof(t2p->pdf_datetime), + "D:%.4d%.2d%.2d%.2d%.2d%.2d", + (currenttime->tm_year + 1900) % 65536, + (currenttime->tm_mon + 1) % 256, + (currenttime->tm_mday) % 256, + (currenttime->tm_hour) % 256, + (currenttime->tm_min) % 256, + (currenttime->tm_sec) % 256); return; } /* - This function fills a string of a T2P struct with the date and time of a TIFF file if it - exists or the current time as a PDF date string. -*/ - -void t2p_pdf_tifftime(T2P* t2p, TIFF* input){ + * This function fills a string of a T2P struct with the date and time of a + * TIFF file if it exists or the current time as a PDF date string. + */ +void t2p_pdf_tifftime(T2P* t2p, TIFF* input) +{ char* datetime; - t2p->pdf_datetime= (char*) _TIFFmalloc(19); - if(t2p->pdf_datetime==NULL){ - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_pdf_tiff_time", - 17); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_datetime[16]=0; - if( TIFFGetField(input, TIFFTAG_DATETIME, &datetime) != 0 - && (strlen(datetime) >= 19) ){ + if (TIFFGetField(input, TIFFTAG_DATETIME, &datetime) != 0 + && (strlen(datetime) >= 19) ){ t2p->pdf_datetime[0]='D'; t2p->pdf_datetime[1]=':'; t2p->pdf_datetime[2]=datetime[0]; @@ -3999,6 +4071,7 @@ void t2p_pdf_tifftime(T2P* t2p, TIFF* input){ t2p->pdf_datetime[13]=datetime[15]; t2p->pdf_datetime[14]=datetime[17]; t2p->pdf_datetime[15]=datetime[18]; + t2p->pdf_datetime[16] = '\0'; } else { t2p_pdf_currenttime(t2p); } @@ -4007,28 +4080,26 @@ void t2p_pdf_tifftime(T2P* t2p, TIFF* input){ } /* - This function writes a PDF Pages Tree structure to output. -*/ - -tsize_t t2p_write_pdf_pages(T2P* t2p, - TIFF* output){ + * This function writes a PDF Pages Tree structure to output. + */ +tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output) +{ tsize_t written=0; tdir_t i=0; char buffer[16]; int buflen=0; int page=0; - written += TIFFWriteFile(output, - (tdata_t) "<< \r/Type /Pages \r/Kids [ ", - 26); + written += t2pWriteFile(output, + (tdata_t) "<< \n/Type /Pages \n/Kids [ ", 26); page = t2p->pdf_pages+1; for (i=0;itiff_pagecount;i++){ buflen=sprintf(buffer, "%d", page); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); if ( ((i+1)%8)==0 ) { - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + written += t2pWriteFile(output, (tdata_t) "\n", 1); } page +=3; page += t2p->tiff_pages[i].page_extra; @@ -4038,11 +4109,11 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, page +=2; } } - written += TIFFWriteFile(output, (tdata_t) "] \r/Count ", 10); + written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10); _TIFFmemset(buffer, 0x00, 16); buflen=sprintf(buffer, "%d", t2p->tiff_pagecount); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " \r>> \r", 6); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6); return(written); } @@ -4057,87 +4128,87 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ tsize_t written=0; char buffer[16]; int buflen=0; - - written += TIFFWriteFile(output, (tdata_t) "<<\r/Type /Page \r/Parent ", 24); + + written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_pages); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R \r", 6); - written += TIFFWriteFile(output, (tdata_t) "/MediaBox [", 11); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); + written += t2pWriteFile(output, (tdata_t) "/MediaBox [", 11); buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.x1); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.y1); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.x2); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.y2); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "] \r", 3); - written += TIFFWriteFile(output, (tdata_t) "/Contents ", 10); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "] \n", 3); + written += t2pWriteFile(output, (tdata_t) "/Contents ", 10); buflen=sprintf(buffer, "%lu", (unsigned long)(object + 1)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R \r", 6); - written += TIFFWriteFile(output, (tdata_t) "/Resources << \r", 15); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); + written += t2pWriteFile(output, (tdata_t) "/Resources << \n", 15); if( t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount != 0 ){ - written += TIFFWriteFile(output, (tdata_t) "/XObject <<\r", 12); + written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); for(i=0;itiff_tiles[t2p->pdf_page].tiles_tilecount;i++){ - written += TIFFWriteFile(output, (tdata_t) "/Im", 3); + written += t2pWriteFile(output, (tdata_t) "/Im", 3); buflen = sprintf(buffer, "%u", t2p->pdf_page+1); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "_", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "_", 1); buflen = sprintf(buffer, "%u", i+1); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); buflen = sprintf( buffer, "%lu", (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); if(i%4==3){ - written += TIFFWriteFile(output, (tdata_t) "\r", 1); + written += t2pWriteFile(output, (tdata_t) "\n", 1); } } - written += TIFFWriteFile(output, (tdata_t) ">>\r", 3); + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); } else { - written += TIFFWriteFile(output, (tdata_t) "/XObject <<\r", 12); - written += TIFFWriteFile(output, (tdata_t) "/Im", 3); + written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); + written += t2pWriteFile(output, (tdata_t) "/Im", 3); buflen = sprintf(buffer, "%u", t2p->pdf_page+1); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); buflen = sprintf( buffer, "%lu", (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); - written += TIFFWriteFile(output, (tdata_t) ">>\r", 3); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); } if(t2p->tiff_transferfunctioncount != 0) { - written += TIFFWriteFile(output, (tdata_t) "/ExtGState <<", 13); - TIFFWriteFile(output, (tdata_t) "/GS1 ", 5); + written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13); + t2pWriteFile(output, (tdata_t) "/GS1 ", 5); buflen = sprintf( buffer, "%lu", (unsigned long)(object + 3)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); - written += TIFFWriteFile(output, (tdata_t) ">> \r", 4); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) ">> \n", 4); } - written += TIFFWriteFile(output, (tdata_t) "/ProcSet [ ", 11); + written += t2pWriteFile(output, (tdata_t) "/ProcSet [ ", 11); if(t2p->pdf_colorspace == T2P_CS_BILEVEL || t2p->pdf_colorspace == T2P_CS_GRAY ){ - written += TIFFWriteFile(output, (tdata_t) "/ImageB ", 8); + written += t2pWriteFile(output, (tdata_t) "/ImageB ", 8); } else { - written += TIFFWriteFile(output, (tdata_t) "/ImageC ", 8); + written += t2pWriteFile(output, (tdata_t) "/ImageC ", 8); if(t2p->pdf_colorspace & T2P_CS_PALETTE){ - written += TIFFWriteFile(output, (tdata_t) "/ImageI ", 8); + written += t2pWriteFile(output, (tdata_t) "/ImageI ", 8); } } - written += TIFFWriteFile(output, (tdata_t) "]\r>>\r>>\r", 8); + written += t2pWriteFile(output, (tdata_t) "]\n>>\n>>\n", 8); return(written); } @@ -4158,22 +4229,40 @@ void t2p_compose_pdf_page(T2P* t2p){ uint32 tilelength=0; int istiled=0; float f=0; + float width_ratio=0; + float length_ratio=0; t2p->pdf_xres = t2p->tiff_xres; t2p->pdf_yres = t2p->tiff_yres; - if(t2p->pdf_overrideres){ + if(t2p->pdf_overrideres) { t2p->pdf_xres = t2p->pdf_defaultxres; t2p->pdf_yres = t2p->pdf_defaultyres; } - if(t2p->pdf_xres==0.0){ + if(t2p->pdf_xres == 0.0) t2p->pdf_xres = t2p->pdf_defaultxres; - } - if(t2p->pdf_yres==0.0){ + if(t2p->pdf_yres == 0.0) t2p->pdf_yres = t2p->pdf_defaultyres; + if (t2p->pdf_image_fillpage) { + width_ratio = t2p->pdf_defaultpagewidth/t2p->tiff_width; + length_ratio = t2p->pdf_defaultpagelength/t2p->tiff_length; + if (width_ratio < length_ratio ) { + t2p->pdf_imagewidth = t2p->pdf_defaultpagewidth; + t2p->pdf_imagelength = t2p->tiff_length * width_ratio; + } else { + t2p->pdf_imagewidth = t2p->tiff_width * length_ratio; + t2p->pdf_imagelength = t2p->pdf_defaultpagelength; + } + } else if (t2p->tiff_resunit != RESUNIT_CENTIMETER /* RESUNIT_NONE and */ + && t2p->tiff_resunit != RESUNIT_INCH) { /* other cases */ + t2p->pdf_imagewidth = ((float)(t2p->tiff_width))/t2p->pdf_xres; + t2p->pdf_imagelength = ((float)(t2p->tiff_length))/t2p->pdf_yres; + } else { + t2p->pdf_imagewidth = + ((float)(t2p->tiff_width))*PS_UNIT_SIZE/t2p->pdf_xres; + t2p->pdf_imagelength = + ((float)(t2p->tiff_length))*PS_UNIT_SIZE/t2p->pdf_yres; } - t2p->pdf_imagewidth=((float)(t2p->tiff_width)) *72.0F / t2p->pdf_xres; - t2p->pdf_imagelength=((float)(t2p->tiff_length)) *72.0F / t2p->pdf_yres; - if(t2p->pdf_overridepagesize != 0){ + if(t2p->pdf_overridepagesize != 0) { t2p->pdf_pagewidth = t2p->pdf_defaultpagewidth; t2p->pdf_pagelength = t2p->pdf_defaultpagelength; } else { @@ -4476,7 +4565,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ for(i=0;itiff_tiles[t2p->pdf_page].tiles_tilecount; i++){ box=t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box; buflen=sprintf(buffer, - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\r", + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\n", t2p->tiff_transferfunctioncount?"/GS1 gs ":"", box.mat[0], box.mat[1], @@ -4491,7 +4580,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ } else { box=t2p->pdf_imagebox; buflen=sprintf(buffer, - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\r", + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\n", t2p->tiff_transferfunctioncount?"/GS1 gs ":"", box.mat[0], box.mat[1], @@ -4519,17 +4608,17 @@ tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, int buflen=0; written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount+1, output); - written += TIFFWriteFile(output, - (tdata_t) "/Type /XObject \r/Subtype /Image \r/Name /Im", + written += t2pWriteFile(output, + (tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im", 42); buflen=sprintf(buffer, "%u", t2p->pdf_page+1); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); if(tile != 0){ - written += TIFFWriteFile(output, (tdata_t) "_", 1); + written += t2pWriteFile(output, (tdata_t) "_", 1); buflen=sprintf(buffer, "%lu", (unsigned long)tile); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); } - written += TIFFWriteFile(output, (tdata_t) "\r/Width ", 8); + written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8); _TIFFmemset((tdata_t)buffer, 0x00, 16); if(tile==0){ buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_width); @@ -4546,8 +4635,8 @@ tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); } } - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "\r/Height ", 9); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9); _TIFFmemset((tdata_t)buffer, 0x00, 16); if(tile==0){ buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_length); @@ -4564,16 +4653,16 @@ tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); } } - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "\r/BitsPerComponent ", 19); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19); _TIFFmemset((tdata_t)buffer, 0x00, 16); buflen=sprintf(buffer, "%u", t2p->tiff_bitspersample); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "\r/ColorSpace ", 13); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13); written += t2p_write_pdf_xobject_cs(t2p, output); if (t2p->pdf_image_interpolate) - written += TIFFWriteFile(output, - (tdata_t) "\r/Interpolate true", 18); + written += t2pWriteFile(output, + (tdata_t) "\n/Interpolate true", 18); if( (t2p->pdf_switchdecode != 0) #ifdef CCITT_SUPPORT && ! (t2p->pdf_colorspace == T2P_CS_BILEVEL @@ -4607,66 +4696,58 @@ tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){ return(written); } if( (t2p->pdf_colorspace & T2P_CS_PALETTE) != 0){ - written += TIFFWriteFile(output, (tdata_t) "[ /Indexed ", 11); + written += t2pWriteFile(output, (tdata_t) "[ /Indexed ", 11); t2p->pdf_colorspace ^= T2P_CS_PALETTE; written += t2p_write_pdf_xobject_cs(t2p, output); t2p->pdf_colorspace |= T2P_CS_PALETTE; buflen=sprintf(buffer, "%u", (0x0001 << t2p->tiff_bitspersample)-1 ); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " ", 1); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); _TIFFmemset(buffer, 0x00, 16); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_palettecs ); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ]\r", 7); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7); return(written); } if(t2p->pdf_colorspace & T2P_CS_BILEVEL){ - written += TIFFWriteFile(output, (tdata_t) "/DeviceGray \r", 13); + written += t2pWriteFile(output, (tdata_t) "/DeviceGray \n", 13); } if(t2p->pdf_colorspace & T2P_CS_GRAY){ if(t2p->pdf_colorspace & T2P_CS_CALGRAY){ written += t2p_write_pdf_xobject_calcs(t2p, output); } else { - written += TIFFWriteFile(output, (tdata_t) "/DeviceGray \r", 13); + written += t2pWriteFile(output, (tdata_t) "/DeviceGray \n", 13); } } if(t2p->pdf_colorspace & T2P_CS_RGB){ if(t2p->pdf_colorspace & T2P_CS_CALRGB){ written += t2p_write_pdf_xobject_calcs(t2p, output); } else { - written += TIFFWriteFile(output, (tdata_t) "/DeviceRGB \r", 12); + written += t2pWriteFile(output, (tdata_t) "/DeviceRGB \n", 12); } } if(t2p->pdf_colorspace & T2P_CS_CMYK){ - written += TIFFWriteFile(output, (tdata_t) "/DeviceCMYK \r", 13); + written += t2pWriteFile(output, (tdata_t) "/DeviceCMYK \n", 13); } if(t2p->pdf_colorspace & T2P_CS_LAB){ - written += TIFFWriteFile(output, (tdata_t) "[/Lab << \r", 10); - written += TIFFWriteFile(output, (tdata_t) "/WhitePoint ", 12); + written += t2pWriteFile(output, (tdata_t) "[/Lab << \n", 10); + written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); X_W = t2p->tiff_whitechromaticities[0]; Y_W = t2p->tiff_whitechromaticities[1]; Z_W = 1.0F - (X_W + Y_W); X_W /= Y_W; Z_W /= Y_W; Y_W = 1.0F; - buflen=sprintf(buffer, "[%.4f %.4f %.4f] \r", X_W, Y_W, Z_W); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - X_W = 0.3457F; /* 0.3127F; */ /* D50, commented D65 */ - Y_W = 0.3585F; /* 0.3290F; */ - Z_W = 1.0F - (X_W + Y_W); - X_W /= Y_W; - Z_W /= Y_W; - Y_W = 1.0F; - buflen=sprintf(buffer, "[%.4f %.4f %.4f] \r", X_W, Y_W, Z_W); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "/Range ", 7); - buflen=sprintf(buffer, "[%d %d %d %d] \r", + buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Range ", 7); + buflen=sprintf(buffer, "[%d %d %d %d] \n", t2p->pdf_labrange[0], t2p->pdf_labrange[1], t2p->pdf_labrange[2], t2p->pdf_labrange[3]); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) ">>] \r", 5); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) ">>] \n", 5); } @@ -4679,30 +4760,30 @@ tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){ char buffer[16]; int buflen=0; - written += TIFFWriteFile(output, (tdata_t) "<< /Type /ExtGState \r/TR ", 25); + written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25); if(t2p->tiff_transferfunctioncount == 1){ buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 1)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); } else { - written += TIFFWriteFile(output, (tdata_t) "[ ", 2); + written += t2pWriteFile(output, (tdata_t) "[ ", 2); buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 1)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 2)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 3)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R ", 5); - written += TIFFWriteFile(output, (tdata_t) "/Identity ] ", 12); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) "/Identity ] ", 12); } - written += TIFFWriteFile(output, (tdata_t) " >> \r", 5); + written += t2pWriteFile(output, (tdata_t) " >> \n", 5); return(written); } @@ -4712,15 +4793,15 @@ tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){ tsize_t written=0; char buffer[32]; int buflen=0; - (void)i; // XXX + (void)i; /* XXX */ - written += TIFFWriteFile(output, (tdata_t) "/FunctionType 0 \r", 17); - written += TIFFWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \r", 19); - written += TIFFWriteFile(output, (tdata_t) "/Range [0.0 1.0] \r", 18); - buflen=sprintf(buffer, "/Size [%u] \r", (1<tiff_bitspersample)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "/BitsPerSample 16 \r", 19); - written += t2p_write_pdf_stream_dict(1<<(t2p->tiff_bitspersample+1), 0, output); + written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17); + written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19); + written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18); + buflen=sprintf(buffer, "/Size [%u] \n", (1<tiff_bitspersample)); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19); + written += t2p_write_pdf_stream_dict(((tsize_t)1)<<(t2p->tiff_bitspersample+1), 0, output); return(written); } @@ -4731,7 +4812,7 @@ tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16 i){ written += t2p_write_pdf_stream( t2p->tiff_transferfunction[i], - (1<<(t2p->tiff_bitspersample+1)), + (((tsize_t)1)<<(t2p->tiff_bitspersample+1)), output); return(written); @@ -4772,9 +4853,9 @@ tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){ float G=1.0; float B=1.0; - written += TIFFWriteFile(output, (tdata_t) "[", 1); + written += t2pWriteFile(output, (tdata_t) "[", 1); if(t2p->pdf_colorspace & T2P_CS_CALGRAY){ - written += TIFFWriteFile(output, (tdata_t) "/CalGray ", 9); + written += t2pWriteFile(output, (tdata_t) "/CalGray ", 9); X_W = t2p->tiff_whitechromaticities[0]; Y_W = t2p->tiff_whitechromaticities[1]; Z_W = 1.0F - (X_W + Y_W); @@ -4783,7 +4864,7 @@ tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){ Y_W = 1.0F; } if(t2p->pdf_colorspace & T2P_CS_CALRGB){ - written += TIFFWriteFile(output, (tdata_t) "/CalRGB ", 8); + written += t2pWriteFile(output, (tdata_t) "/CalRGB ", 8); x_w = t2p->tiff_whitechromaticities[0]; y_w = t2p->tiff_whitechromaticities[1]; x_r = t2p->tiff_primarychromaticities[0]; @@ -4809,26 +4890,26 @@ tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){ Z_W /= Y_W; Y_W = 1.0; } - written += TIFFWriteFile(output, (tdata_t) "<< \r", 4); + written += t2pWriteFile(output, (tdata_t) "<< \n", 4); if(t2p->pdf_colorspace & T2P_CS_CALGRAY){ - written += TIFFWriteFile(output, (tdata_t) "/WhitePoint ", 12); - buflen=sprintf(buffer, "[%.4f %.4f %.4f] \r", X_W, Y_W, Z_W); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "/Gamma 2.2 \r", 12); + written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); + buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Gamma 2.2 \n", 12); } if(t2p->pdf_colorspace & T2P_CS_CALRGB){ - written += TIFFWriteFile(output, (tdata_t) "/WhitePoint ", 12); - buflen=sprintf(buffer, "[%.4f %.4f %.4f] \r", X_W, Y_W, Z_W); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "/Matrix ", 8); - buflen=sprintf(buffer, "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \r", + written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); + buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Matrix ", 8); + buflen=sprintf(buffer, "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n", X_R, Y_R, Z_R, X_G, Y_G, Z_G, X_B, Y_B, Z_B); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "/Gamma [2.2 2.2 2.2] \r", 22); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Gamma [2.2 2.2 2.2] \n", 22); } - written += TIFFWriteFile(output, (tdata_t) ">>] \r", 5); + written += t2pWriteFile(output, (tdata_t) ">>] \n", 5); return(written); } @@ -4843,10 +4924,10 @@ tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){ char buffer[16]; int buflen=0; - written += TIFFWriteFile(output, (tdata_t) "[/ICCBased ", 11); + written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_icccs); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " 0 R] \r", 7); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7); return(written); } @@ -4857,10 +4938,10 @@ tsize_t t2p_write_pdf_xobject_icccs_dict(T2P* t2p, TIFF* output){ char buffer[16]; int buflen=0; - written += TIFFWriteFile(output, (tdata_t) "/N ", 3); - buflen=sprintf(buffer, "%u \r", t2p->tiff_samplesperpixel); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) "/Alternate ", 11); + written += t2pWriteFile(output, (tdata_t) "/N ", 3); + buflen=sprintf(buffer, "%u \n", t2p->tiff_samplesperpixel); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11); t2p->pdf_colorspace ^= T2P_CS_ICCBASED; written += t2p_write_pdf_xobject_cs(t2p, output); t2p->pdf_colorspace |= T2P_CS_ICCBASED; @@ -4906,11 +4987,11 @@ tsize_t t2p_write_pdf_xobject_decode(T2P* t2p, TIFF* output){ tsize_t written=0; int i=0; - written += TIFFWriteFile(output, (tdata_t) "/Decode [ ", 10); + written += t2pWriteFile(output, (tdata_t) "/Decode [ ", 10); for (i=0;itiff_samplesperpixel;i++){ - written += TIFFWriteFile(output, (tdata_t) "1 0 ", 4); + written += t2pWriteFile(output, (tdata_t) "1 0 ", 4); } - written += TIFFWriteFile(output, (tdata_t) "]\r", 2); + written += t2pWriteFile(output, (tdata_t) "]\n", 2); return(written); } @@ -4929,93 +5010,93 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output if(t2p->pdf_compression==T2P_COMPRESS_NONE){ return(written); } - written += TIFFWriteFile(output, (tdata_t) "/Filter ", 8); + written += t2pWriteFile(output, (tdata_t) "/Filter ", 8); switch(t2p->pdf_compression){ #ifdef CCITT_SUPPORT case T2P_COMPRESS_G4: - written += TIFFWriteFile(output, (tdata_t) "/CCITTFaxDecode ", 16); - written += TIFFWriteFile(output, (tdata_t) "/DecodeParms ", 13); - written += TIFFWriteFile(output, (tdata_t) "<< /K -1 ", 9); + written += t2pWriteFile(output, (tdata_t) "/CCITTFaxDecode ", 16); + written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); + written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9); if(tile==0){ - written += TIFFWriteFile(output, (tdata_t) "/Columns ", 9); + written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_width); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " /Rows ", 7); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_length); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ - written += TIFFWriteFile(output, (tdata_t) "/Columns ", 9); + written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); buflen=sprintf( buffer, "%lu", (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { - written += TIFFWriteFile(output, (tdata_t) "/Columns ", 9); + written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); buflen=sprintf( buffer, "%lu", (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); } if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ - written += TIFFWriteFile(output, (tdata_t) " /Rows ", 7); + written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); buflen=sprintf( buffer, "%lu", (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { - written += TIFFWriteFile(output, (tdata_t) " /Rows ", 7); + written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); buflen=sprintf( buffer, "%lu", (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); } } if(t2p->pdf_switchdecode == 0){ - written += TIFFWriteFile(output, (tdata_t) " /BlackIs1 true ", 16); + written += t2pWriteFile(output, (tdata_t) " /BlackIs1 true ", 16); } - written += TIFFWriteFile(output, (tdata_t) ">>\r", 3); + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); break; #endif #ifdef JPEG_SUPPORT case T2P_COMPRESS_JPEG: - written += TIFFWriteFile(output, (tdata_t) "/DCTDecode ", 11); + written += t2pWriteFile(output, (tdata_t) "/DCTDecode ", 11); if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR) { - written += TIFFWriteFile(output, (tdata_t) "/DecodeParms ", 13); - written += TIFFWriteFile(output, (tdata_t) "<< /ColorTransform 0 >>\r", 24); + written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); + written += t2pWriteFile(output, (tdata_t) "<< /ColorTransform 0 >>\n", 24); } break; #endif #ifdef ZIP_SUPPORT case T2P_COMPRESS_ZIP: - written += TIFFWriteFile(output, (tdata_t) "/FlateDecode ", 13); + written += t2pWriteFile(output, (tdata_t) "/FlateDecode ", 13); if(t2p->pdf_compressionquality%100){ - written += TIFFWriteFile(output, (tdata_t) "/DecodeParms ", 13); - written += TIFFWriteFile(output, (tdata_t) "<< /Predictor ", 14); + written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); + written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14); _TIFFmemset(buffer, 0x00, 16); buflen=sprintf(buffer, "%u", t2p->pdf_compressionquality%100); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " /Columns ", 10); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /Columns ", 10); _TIFFmemset(buffer, 0x00, 16); buflen = sprintf(buffer, "%lu", (unsigned long)t2p->tiff_width); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " /Colors ", 9); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /Colors ", 9); _TIFFmemset(buffer, 0x00, 16); buflen=sprintf(buffer, "%u", t2p->tiff_samplesperpixel); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " /BitsPerComponent ", 19); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19); _TIFFmemset(buffer, 0x00, 16); buflen=sprintf(buffer, "%u", t2p->tiff_bitspersample); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) ">>\r", 3); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); } break; #endif @@ -5037,21 +5118,21 @@ tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){ int buflen=0; uint32 i=0; - written += TIFFWriteFile(output, (tdata_t) "xref\r0 ", 7); + written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7); buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 1)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); - written += TIFFWriteFile(output, (tdata_t) " \r0000000000 65535 f\r\n", 22); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22); for (i=0;ipdf_xrefcount;i++){ - sprintf(buffer, "%.10lu 00000 n\r\n", + sprintf(buffer, "%.10lu 00000 n \n", (unsigned long)t2p->pdf_xrefoffsets[i]); - written += TIFFWriteFile(output, (tdata_t) buffer, 20); + written += t2pWriteFile(output, (tdata_t) buffer, 20); } return(written); } /* - * This function writes a PDF trailer to output. + * This function writes a PDF trailer to output. */ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) @@ -5060,46 +5141,34 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) tsize_t written = 0; char buffer[32]; int buflen = 0; - char fileidbuf[16]; - int i = 0; + size_t i = 0; - ((int*)fileidbuf)[0] = rand(); - ((int*)fileidbuf)[1] = rand(); - ((int*)fileidbuf)[2] = rand(); - ((int*)fileidbuf)[3] = rand(); - t2p->pdf_fileid = (char*)_TIFFmalloc(33); - if(t2p->pdf_fileid == NULL) { - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_write_pdf_trailer", - 33 ); - t2p->t2p_error = T2P_ERR_ERROR; - return(0); - } - _TIFFmemset(t2p->pdf_fileid, 0x00, 33); - for (i=0; i<16; i++) - sprintf(&(t2p->pdf_fileid[2*i]), "%.2hhX", fileidbuf[i]); - written += TIFFWriteFile(output, (tdata_t) "trailer\r<<\r/Size ", 17); + for (i = 0; i < sizeof(t2p->pdf_fileid) - 8; i += 8) + snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand()); + + written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17); buflen = sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount+1)); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); _TIFFmemset(buffer, 0x00, 32); - written += TIFFWriteFile(output, (tdata_t) "\r/Root ", 7); + written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_catalog); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); _TIFFmemset(buffer, 0x00, 32); - written += TIFFWriteFile(output, (tdata_t) " 0 R \r/Info ", 12); + written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_info); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); _TIFFmemset(buffer, 0x00, 32); - written += TIFFWriteFile(output, (tdata_t) " 0 R \r/ID[<", 11); - written += TIFFWriteFile(output, (tdata_t) t2p->pdf_fileid, 32); - written += TIFFWriteFile(output, (tdata_t) "><", 2); - written += TIFFWriteFile(output, (tdata_t) t2p->pdf_fileid, 32); - written += TIFFWriteFile(output, (tdata_t) ">]\r>>\rstartxref\r", 16); + written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11); + written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, + sizeof(t2p->pdf_fileid) - 1); + written += t2pWriteFile(output, (tdata_t) "><", 2); + written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, + sizeof(t2p->pdf_fileid) - 1); + written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_startxref); - written += TIFFWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); _TIFFmemset(buffer, 0x00, 32); - written += TIFFWriteFile(output, (tdata_t) "\r%%EOF\r", 7); + written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7); return(written); } @@ -5113,7 +5182,7 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) library, and TIFFWriteEncodedStrip can be used to write compressed data to the output. The output is not actually a TIFF file, it is a PDF file. - This function uses only TIFFWriteFile and TIFFWriteEncodedStrip to write to + This function uses only t2pWriteFile and TIFFWriteEncodedStrip to write to the output TIFF file. When libtiff would otherwise be writing data to the output file, the write procedure of the TIFF structure is replaced with an empty implementation. @@ -5134,7 +5203,7 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) assert(output != NULL); if(output->tif_seekproc != NULL){ - TIFFSeekFile(output, (toff_t) 0, SEEK_SET); + t2pSeekFile(output, (toff_t) 0, SEEK_SET); } This function returns the file size of the output PDF file. On error it @@ -5157,8 +5226,8 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ if(t2p->pdf_xrefoffsets==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_write_pdf", - t2p->pdf_xrefcount * sizeof(uint32) ); + "Can't allocate %u bytes of memory for t2p_write_pdf", + (unsigned int) (t2p->pdf_xrefcount * sizeof(uint32)) ); return(written); } t2p->pdf_xrefcount=0; @@ -5298,13 +5367,19 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ written += t2p_write_pdf_obj_end(output); } } - t2p->pdf_startxref=written; + t2p->pdf_startxref = written; written += t2p_write_pdf_xreftable(t2p, output); written += t2p_write_pdf_trailer(t2p, output); - t2p->tiff_writeproc=output->tif_writeproc; - output->tif_writeproc=t2p_empty_writeproc; + t2p_disable(output); return(written); } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/tools/tiff2ps.c b/libs/tiff-4.0.2/tools/tiff2ps.c new file mode 100644 index 0000000000..372230a9a9 --- /dev/null +++ b/libs/tiff-4.0.2/tools/tiff2ps.c @@ -0,0 +1,3073 @@ +/* $Id: tiff2ps.c,v 1.49 2011-05-31 17:10:18 bfriesen Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tif_config.h" + +#include +#include /* for atof */ +#include +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#include "tiffio.h" + +/* + * Revision history + * + * 2010-Sep-17 + * Richard Nolde: Reinstate code from Feb 2009 that never got + * accepted into CVS with major modifications to handle -H and -W + * options. Replaced original PlaceImage function with several + * new functions that make support for multiple output pages + * from a single image easier to understand. Added additional + * warning messages for incompatible command line options. + * Add new command line options to specify PageOrientation + * Document Structuring Comment for landscape or portrait + * and code to determine the values from ouput width and height + * if not specified on the command line. + * Add new command line option to specify document creator + * as an alterntive to the string "tiff2ps" following model + * of patch submitted by Thomas Jarosch for specifiying a + * document title which is also supported now. + * + * 2009-Feb-11 + * Richard Nolde: Added support for rotations of 90, 180, 270 + * and auto using -r <90|180|270|auto>. Auto picks the best + * fit for the image on the specified paper size (eg portrait + * or landscape) if -h or -w is specified. Rotation is in + * degrees counterclockwise since that is how Postscript does + * it. The auto opption rotates the image 90 degrees ccw to + * produce landscape if that is a better fit than portait. + * + * Cleaned up code in TIFF2PS and broke into smaller functions + * to simplify rotations. + * + * Identified incompatible options and returned errors, eg + * -i for imagemask operator is only available for Level2 or + * Level3 Postscript in the current implmentation since there + * is a difference in the way the operands are called for Level1 + * and there is no function to provide the Level1 version. + * -H was not handled properly if -h and/or -w were specified. + * It should only clip the masked images if the scaled image + * exceeds the maxPageHeight specified with -H. + * + * New design allows for all of the following combinations: + * Conversion of TIFF to Postscript with optional rotations + * of 90, 180, 270, or auto degrees counterclockwise + * Conversion of TIFF to Postscript with entire image scaled + * to maximum of values spedified with -h or -w while + * maintaining aspect ratio. Same rotations apply. + * Conversion of TIFF to Postscript with clipping of output + * viewport to height specified with -H, producing multiple + * pages at this height and original width as needed. + * Same rotations apply. + * Conversion of TIFF to Postscript with image scaled to + * maximum specified by -h and -w and the resulting scaled + * image is presented in an output viewport clipped by -H height. + * The same rotations apply. + * + * Added maxPageWidth option using -W flag. MaxPageHeight and + * MaxPageWidth are mutually exclusive since the aspect ratio + * cannot be maintained if you set both. + * Rewrote PlaceImage to allow maxPageHeight and maxPageWidth + * options to work with values smaller or larger than the + * physical paper size and still preserve the aspect ratio. + * This is accomplished by creating multiple pages across + * as well as down if need be. + * + * 2001-Mar-21 + * I (Bruce A. Mallett) added this revision history comment ;) + * + * Fixed PS_Lvl2page() code which outputs non-ASCII85 raw + * data. Moved test for when to output a line break to + * *after* the output of a character. This just serves + * to fix an eye-nuisance where the first line of raw + * data was one character shorter than subsequent lines. + * + * Added an experimental ASCII85 encoder which can be used + * only when there is a single buffer of bytes to be encoded. + * This version is much faster at encoding a straight-line + * buffer of data because it can avoid a lot of the loop + * overhead of the byte-by-byte version. To use this version + * you need to define EXP_ASCII85ENCODER (experimental ...). + * + * Added bug fix given by Michael Schmidt to PS_Lvl2page() + * in which an end-of-data marker ('>') was not being output + * when producing non-ASCII85 encoded PostScript Level 2 + * data. + * + * Fixed PS_Lvl2colorspace() so that it no longer assumes that + * a TIFF having more than 2 planes is a CMYK. This routine + * no longer looks at the samples per pixel but instead looks + * at the "photometric" value. This change allows support of + * CMYK TIFFs. + * + * Modified the PostScript L2 imaging loop so as to test if + * the input stream is still open before attempting to do a + * flushfile on it. This was done because some RIPs close + * the stream after doing the image operation. + * + * Got rid of the realloc() being done inside a loop in the + * PSRawDataBW() routine. The code now walks through the + * byte-size array outside the loop to determine the largest + * size memory block that will be needed. + * + * Added "-m" switch to ask tiff2ps to, where possible, use the + * "imagemask" operator instead of the "image" operator. + * + * Added the "-i #" switch to allow interpolation to be disabled. + * + * Unrolled a loop or two to improve performance. + */ + +/* + * Define EXP_ASCII85ENCODER if you want to use an experimental + * version of the ASCII85 encoding routine. The advantage of + * using this routine is that tiff2ps will convert to ASCII85 + * encoding at between 3 and 4 times the speed as compared to + * using the old (non-experimental) encoder. The disadvantage + * is that you will be using a new (and unproven) encoding + * routine. So user beware, you have been warned! + */ + +#define EXP_ASCII85ENCODER + +/* + * NB: this code assumes uint32 works with printf's %l[ud]. + */ +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +int ascii85 = FALSE; /* use ASCII85 encoding */ +int interpolate = TRUE; /* interpolate level2 image */ +int level2 = FALSE; /* generate PostScript level 2 */ +int level3 = FALSE; /* generate PostScript level 3 */ +int printAll = FALSE; /* print all images in file */ +int generateEPSF = TRUE; /* generate Encapsulated PostScript */ +int PSduplex = FALSE; /* enable duplex printing */ +int PStumble = FALSE; /* enable top edge binding */ +int PSavoiddeadzone = TRUE; /* enable avoiding printer deadzone */ +double maxPageHeight = 0; /* maximum height to select from image and print per page */ +double maxPageWidth = 0; /* maximum width to select from image and print per page */ +double splitOverlap = 0; /* amount for split pages to overlag */ +int rotation = 0; /* optional value for rotation angle */ +int auto_rotate = 0; /* rotate image for best fit on the page */ +char *filename = NULL; /* input filename */ +char *title = NULL; /* optional document title string */ +char *creator = NULL; /* optional document creator string */ +char pageOrientation[12]; /* set optional PageOrientation DSC to Landscape or Portrait */ +int useImagemask = FALSE; /* Use imagemask instead of image operator */ +uint16 res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */ + +/* + * ASCII85 Encoding Support. + */ +unsigned char ascii85buf[10]; +int ascii85count; +int ascii85breaklen; + +int TIFF2PS(FILE*, TIFF*, double, double, double, double, int); +void PSpage(FILE*, TIFF*, uint32, uint32); +void PSColorContigPreamble(FILE*, uint32, uint32, int); +void PSColorSeparatePreamble(FILE*, uint32, uint32, int); +void PSDataColorContig(FILE*, TIFF*, uint32, uint32, int); +void PSDataColorSeparate(FILE*, TIFF*, uint32, uint32, int); +void PSDataPalette(FILE*, TIFF*, uint32, uint32); +void PSDataBW(FILE*, TIFF*, uint32, uint32); +void PSRawDataBW(FILE*, TIFF*, uint32, uint32); +void Ascii85Init(void); +void Ascii85Put(unsigned char code, FILE* fd); +void Ascii85Flush(FILE* fd); +void PSHead(FILE*, double, double, double, double); +void PSTail(FILE*, int); +int psStart(FILE *, int, int, int *, double *, double, double, double, + double, double, double, double, double, double, double); +int psPageSize(FILE *, int, double, double, double, double, double, double); +int psRotateImage(FILE *, int, double, double, double, double); +int psMaskImage(FILE *, TIFF *, int, int, int *, double, double, + double, double, double, double, double, double, double); +int psScaleImage(FILE *, double, int, int, double, double, double, double, + double, double); +int get_viewport (double, double, double, double, double *, double *, int); +int exportMaskedImage(FILE *, double, double, double, double, int, int, + double, double, double, int, int); + +#if defined( EXP_ASCII85ENCODER) +tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l ); +#endif + +static void usage(int); + +int +main(int argc, char* argv[]) +{ + int dirnum = -1, c, np = 0; + int centered = 0; + double bottommargin = 0; + double leftmargin = 0; + double pageWidth = 0; + double pageHeight = 0; + uint32 diroff = 0; + extern char *optarg; + extern int optind; + FILE* output = stdout; + + pageOrientation[0] = '\0'; + + while ((c = getopt(argc, argv, "b:d:h:H:W:L:i:w:l:o:O:P:C:r:t:acemxyzps1238DT")) != -1) + switch (c) { + case 'b': + bottommargin = atof(optarg); + break; + case 'c': + centered = 1; + break; + case 'C': + creator = optarg; + break; + case 'd': /* without -a, this only processes one image at this IFD */ + dirnum = atoi(optarg); + break; + case 'D': + PSduplex = TRUE; + break; + case 'i': + interpolate = atoi(optarg) ? TRUE:FALSE; + break; + case 'T': + PStumble = TRUE; + break; + case 'e': + PSavoiddeadzone = FALSE; + generateEPSF = TRUE; + break; + case 'h': + pageHeight = atof(optarg); + break; + case 'H': + maxPageHeight = atof(optarg); + break; + case 'W': + maxPageWidth = atof(optarg); + break; + case 'L': + splitOverlap = atof(optarg); + break; + case 'm': + useImagemask = TRUE; + break; + case 'o': + switch (optarg[0]) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': diroff = (uint32) strtoul(optarg, NULL, 0); + break; + default: TIFFError ("-o", "Offset must be a numeric value."); + exit (1); + } + break; + case 'O': /* XXX too bad -o is already taken */ + output = fopen(optarg, "w"); + if (output == NULL) { + fprintf(stderr, + "%s: %s: Cannot open output file.\n", + argv[0], optarg); + exit(-2); + } + break; + case 'P': + switch (optarg[0]) + { + case 'l': + case 'L': strcpy (pageOrientation, "Landscape"); + break; + case 'p': + case 'P': strcpy (pageOrientation, "Portrait"); + break; + default: TIFFError ("-P", "Page orientation must be Landscape or Portrait"); + exit (-1); + } + break; + case 'l': + leftmargin = atof(optarg); + break; + case 'a': /* removed fall through to generate warning below, R Nolde 09-01-2010 */ + printAll = TRUE; + break; + case 'p': + generateEPSF = FALSE; + break; + case 'r': + if (strcmp (optarg, "auto") == 0) + { + rotation = 0; + auto_rotate = TRUE; + } + else + { + rotation = atoi(optarg); + auto_rotate = FALSE; + } + switch (rotation) + { + case 0: + case 90: + case 180: + case 270: + break; + default: + fprintf (stderr, "Rotation angle must be 90, 180, 270 (degrees ccw) or auto\n"); + exit (-1); + } + break; + case 's': + printAll = FALSE; + break; + case 't': + title = optarg; + break; + case 'w': + pageWidth = atof(optarg); + break; + case 'z': + PSavoiddeadzone = FALSE; + break; + case '1': + level2 = FALSE; + level3 = FALSE; + ascii85 = FALSE; + break; + case '2': + level2 = TRUE; + ascii85 = TRUE; /* default to yes */ + break; + case '3': + level3 = TRUE; + ascii85 = TRUE; /* default to yes */ + break; + case '8': + ascii85 = FALSE; + break; + case 'x': + res_unit = RESUNIT_CENTIMETER; + break; + case 'y': + res_unit = RESUNIT_INCH; + break; + case '?': + usage(-1); + } + + if (useImagemask == TRUE) + { + if ((level2 == FALSE) && (level3 == FALSE)) + { + TIFFError ("-m "," imagemask operator requres Postscript Level2 or Level3"); + exit (1); + } + } + + if (pageWidth && (maxPageWidth > pageWidth)) + { + TIFFError ("-W", "Max viewport width cannot exceed page width"); + exit (1); + } + + if (pageHeight && (maxPageHeight > pageHeight)) + { + TIFFError ("-H", "Max viewport height cannot exceed page height"); + exit (1); + } + + /* auto rotate requires a specified page width and height */ + if (auto_rotate == TRUE) + { + if ((pageWidth == 0) || (pageHeight == 0)) + TIFFWarning ("-r auto", " requires page height and width specified with -h and -w"); + + if ((maxPageWidth > 0) || (maxPageHeight > 0)) + { + TIFFError ("-r auto", " is incompatible with maximum page width/height specified by -H or -W"); + exit (1); + } + } + if ((maxPageWidth > 0) && (maxPageHeight > 0)) + { + TIFFError ("-H and -W", " Use only one of -H or -W to define a viewport"); + exit (1); + } + + if ((generateEPSF == TRUE) && (printAll == TRUE)) + { + TIFFError(" -e and -a", "Warning: Cannot generate Encapsulated Postscript for multiple images"); + generateEPSF = FALSE; + } + + if ((generateEPSF == TRUE) && (PSduplex == TRUE)) + { + TIFFError(" -e and -D", "Warning: Encapsulated Postscript does not support Duplex option"); + PSduplex = FALSE; + } + + if ((generateEPSF == TRUE) && (PStumble == TRUE)) + { + TIFFError(" -e and -T", "Warning: Encapsulated Postscript does not support Top Edge Binding option"); + PStumble = FALSE; + } + + if ((generateEPSF == TRUE) && (PSavoiddeadzone == TRUE)) + PSavoiddeadzone = FALSE; + + for (; argc - optind > 0; optind++) { + TIFF* tif = TIFFOpen(filename = argv[optind], "r"); + if (tif != NULL) { + if (dirnum != -1 + && !TIFFSetDirectory(tif, (tdir_t)dirnum)) + return (-1); + else if (diroff != 0 && + !TIFFSetSubDirectory(tif, diroff)) + return (-1); + np = TIFF2PS(output, tif, pageWidth, pageHeight, + leftmargin, bottommargin, centered); + if (np < 0) + { + TIFFError("Error", "Unable to process %s", filename); + } + TIFFClose(tif); + } + } + if (np) + PSTail(output, np); + else + usage(-1); + if (output != stdout) + fclose(output); + return (0); +} + +static uint16 samplesperpixel; +static uint16 bitspersample; +static uint16 planarconfiguration; +static uint16 photometric; +static uint16 compression; +static uint16 extrasamples; +static int alpha; + +static int +checkImage(TIFF* tif) +{ + switch (photometric) { + case PHOTOMETRIC_YCBCR: + if ((compression == COMPRESSION_JPEG || compression == COMPRESSION_OJPEG) + && planarconfiguration == PLANARCONFIG_CONTIG) { + /* can rely on libjpeg to convert to RGB */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, + JPEGCOLORMODE_RGB); + photometric = PHOTOMETRIC_RGB; + } else { + if (level2 || level3) + break; + TIFFError(filename, "Can not handle image with %s", + "PhotometricInterpretation=YCbCr"); + return (0); + } + /* fall thru... */ + case PHOTOMETRIC_RGB: + if (alpha && bitspersample != 8) { + TIFFError(filename, + "Can not handle %d-bit/sample RGB image with alpha", + bitspersample); + return (0); + } + /* fall thru... */ + case PHOTOMETRIC_SEPARATED: + case PHOTOMETRIC_PALETTE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_MINISWHITE: + break; + case PHOTOMETRIC_LOGL: + case PHOTOMETRIC_LOGLUV: + if (compression != COMPRESSION_SGILOG && + compression != COMPRESSION_SGILOG24) { + TIFFError(filename, + "Can not handle %s data with compression other than SGILog", + (photometric == PHOTOMETRIC_LOGL) ? + "LogL" : "LogLuv" + ); + return (0); + } + /* rely on library to convert to RGB/greyscale */ + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + photometric = (photometric == PHOTOMETRIC_LOGL) ? + PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB; + bitspersample = 8; + break; + case PHOTOMETRIC_CIELAB: + /* fall thru... */ + default: + TIFFError(filename, + "Can not handle image with PhotometricInterpretation=%d", + photometric); + return (0); + } + switch (bitspersample) { + case 1: case 2: + case 4: case 8: + case 16: + break; + default: + TIFFError(filename, "Can not handle %d-bit/sample image", + bitspersample); + return (0); + } + if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0) + TIFFWarning(filename, "Ignoring extra samples"); + return (1); +} + +#define PS_UNIT_SIZE 72.0F +#define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res))) + +static char RGBcolorimage[] = "\ +/bwproc {\n\ + rgbproc\n\ + dup length 3 idiv string 0 3 0\n\ + 5 -1 roll {\n\ + add 2 1 roll 1 sub dup 0 eq {\n\ + pop 3 idiv\n\ + 3 -1 roll\n\ + dup 4 -1 roll\n\ + dup 3 1 roll\n\ + 5 -1 roll put\n\ + 1 add 3 0\n\ + } { 2 1 roll } ifelse\n\ + } forall\n\ + pop pop pop\n\ +} def\n\ +/colorimage where {pop} {\n\ + /colorimage {pop pop /rgbproc exch def {bwproc} image} bind def\n\ +} ifelse\n\ +"; + +/* + * Adobe Photoshop requires a comment line of the form: + * + * %ImageData:
      + * <1 for binary|2 for hex> "data start" + * + * It is claimed to be part of some future revision of the EPS spec. + */ +static void +PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline) +{ + fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"", + (long) w, (long) h, bitspersample, nc, bs); + fprintf(fd, startline, nc); + fprintf(fd, "\"\n"); +} + +/* Convert pixel width and height pw, ph, to points pprw, pprh + * using image resolution and resolution units from TIFF tags. + * pw : image width in pixels + * ph : image height in pixels + * pprw : image width in PS units (72 dpi) + * pprh : image height in PS units (72 dpi) + */ +static void +setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh) +{ + float xres = 0.0F, yres = 0.0F; + + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, pw); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, ph); + if (res_unit == 0) /* Not specified as command line option */ + if (!TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &res_unit)) + res_unit = RESUNIT_INCH; + /* + * Calculate printable area. + */ + if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) + || fabs(xres) < 0.0000001) + xres = PS_UNIT_SIZE; + if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) + || fabs(yres) < 0.0000001) + yres = PS_UNIT_SIZE; + switch (res_unit) { + case RESUNIT_CENTIMETER: + xres *= 2.54F, yres *= 2.54F; + break; + case RESUNIT_INCH: + break; + case RESUNIT_NONE: /* Subsequent code assumes we have converted to inches! */ + res_unit = RESUNIT_INCH; + break; + default: /* Last ditch guess for unspecified RESUNIT case + * check that the resolution is not inches before scaling it. + * Moved to end of function with additional check, RJN, 08-31-2010 + * if (xres != PS_UNIT_SIZE || yres != PS_UNIT_SIZE) + * xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE; + */ + break; + } + /* This is a hack to deal with images that have no meaningful Resolution Size + * but may have x and/or y resolutions of 1 pixel per undefined unit. + */ + if ((xres > 1.0) && (xres != PS_UNIT_SIZE)) + *pprw = PSUNITS(*pw, xres); + else + *pprw = PSUNITS(*pw, PS_UNIT_SIZE); + if ((yres > 1.0) && (yres != PS_UNIT_SIZE)) + *pprh = PSUNITS(*ph, yres); + else + *pprh = PSUNITS(*ph, PS_UNIT_SIZE); +} + +static int +isCCITTCompression(TIFF* tif) +{ + uint16 compress; + TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); + return (compress == COMPRESSION_CCITTFAX3 || + compress == COMPRESSION_CCITTFAX4 || + compress == COMPRESSION_CCITTRLE || + compress == COMPRESSION_CCITTRLEW); +} + +static tsize_t tf_bytesperrow; +static tsize_t ps_bytesperrow; +static tsize_t tf_rowsperstrip; +static tsize_t tf_numberstrips; +static char *hex = "0123456789abcdef"; + +/* + * Pagewidth and pageheight are the output size in points, + * may refer to values specified with -h and -w, or to + * values read from the image if neither -h nor -w are used. + * Imagewidth and imageheight are image size in points. + * Ximages and Yimages are number of pages across and down. + * Only one of maxPageHeight or maxPageWidth can be used. + * These are global variables unfortunately. + */ +int get_subimage_count(double pagewidth, double pageheight, + double imagewidth, double imageheight, + int *ximages, int *yimages, + int rotation, double scale) +{ + int pages = 1; + double splitheight = 0; /* Requested Max Height in points */ + double splitwidth = 0; /* Requested Max Width in points */ + double overlap = 0; /* Repeated edge width in points */ + + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; + overlap = splitOverlap * PS_UNIT_SIZE; + pagewidth *= PS_UNIT_SIZE; + pageheight *= PS_UNIT_SIZE; + + if ((imagewidth < 1.0) || (imageheight < 1.0)) + { + TIFFError("get_subimage_count", "Invalid image width or height"); + return (0); + } + + switch (rotation) + { + case 0: + case 180: if (splitheight > 0) /* -H maxPageHeight */ + { + if (imageheight > splitheight) /* More than one vertical image segment */ + { + if (pagewidth) + *ximages = (int)ceil((scale * imagewidth) / (pagewidth - overlap)); + else + *ximages = 1; + *yimages = (int)ceil((scale * imageheight) / (splitheight - overlap)); /* Max vert pages needed */ + } + else + { + if (pagewidth) + *ximages = (int)ceil((scale * imagewidth) / (pagewidth - overlap)); /* Max horz pages needed */ + else + *ximages = 1; + *yimages = 1; /* Max vert pages needed */ + } + } + else + { + if (splitwidth > 0) /* -W maxPageWidth */ + { + if (imagewidth >splitwidth) + { + *ximages = (int)ceil((scale * imagewidth) / (splitwidth - overlap)); /* Max horz pages needed */ + if (pageheight) + *yimages = (int)ceil((scale * imageheight) / (pageheight - overlap)); /* Max vert pages needed */ + else + *yimages = 1; + } + else + { + *ximages = 1; /* Max vert pages needed */ + if (pageheight) + *yimages = (int)ceil((scale * imageheight) / (pageheight - overlap)); /* Max vert pages needed */ + else + *yimages = 1; + } + } + else + { + *ximages = 1; + *yimages = 1; + } + } + break; + case 90: + case 270: if (splitheight > 0) /* -H maxPageHeight */ + { + if (imagewidth > splitheight) /* More than one vertical image segment */ + { + *yimages = (int)ceil((scale * imagewidth) / (splitheight - overlap)); /* Max vert pages needed */ + if (pagewidth) + *ximages = (int)ceil((scale * imageheight) / (pagewidth - overlap)); /* Max horz pages needed */ + else + *ximages = 1; + } + else + { + *yimages = 1; /* Max vert pages needed */ + if (pagewidth) + *ximages = (int)ceil((scale * imageheight) / (pagewidth - overlap)); /* Max horz pages needed */ + else + *ximages = 1; + } + } + else + { + if (splitwidth > 0) /* -W maxPageWidth */ + { + if (imageheight > splitwidth) + { + if (pageheight) + *yimages = (int)ceil((scale * imagewidth) / (pageheight - overlap)); /* Max vert pages needed */ + else + *yimages = 1; + *ximages = (int)ceil((scale * imageheight) / (splitwidth - overlap)); /* Max horz pages needed */ + } + else + { + if (pageheight) + *yimages = (int)ceil((scale * imagewidth) / (pageheight - overlap)); /* Max horz pages needed */ + else + *yimages = 1; + *ximages = 1; /* Max vert pages needed */ + } + } + else + { + *ximages = 1; + *yimages = 1; + } + } + break; + default: *ximages = 1; + *yimages = 1; + } + pages = (*ximages) * (*yimages); + return (pages); + } + +/* New version of PlaceImage that handles only the translation and rotation + * for a single output page. + */ +int exportMaskedImage(FILE *fp, double pagewidth, double pageheight, + double imagewidth, double imageheight, + int row, int column, + double left_offset, double bott_offset, + double scale, int center, int rotation) + { + double xtran = 0.0; + double ytran = 0.0; + + double xscale = 1.0; + double yscale = 1.0; + + double splitheight = 0; /* Requested Max Height in points */ + double splitwidth = 0; /* Requested Max Width in points */ + double overlap = 0; /* Repeated edge width in points */ + double subimage_height = 0.0; + + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; + overlap = splitOverlap * PS_UNIT_SIZE; + xscale = scale * imagewidth; + yscale = scale * imageheight; + + if ((xscale < 0.0) || (yscale < 0.0)) + { + TIFFError("exportMaskedImage", "Invalid parameters."); + return (-1); + } + + /* If images are cropped to a vewport with -H or -W, the output pages are shifted to + * the top of each output page rather than the Postscript default lower edge. + */ + switch (rotation) + { + case 0: + case 180: if (splitheight > 0) /* -H maxPageHeight */ + { + if (splitheight < imageheight) /* More than one vertical image segments */ + { + xtran = -1.0 * column * (pagewidth - overlap); + subimage_height = imageheight - ((splitheight - overlap) * row); + ytran = pageheight - subimage_height * (pageheight / splitheight); + } + else /* Only one page in vertical direction */ + { + xtran = -1.0 * column * (pagewidth - overlap); + ytran = splitheight - imageheight; + } + } + else + { + if (splitwidth > 0) /* maxPageWidth */ + { + if (splitwidth < imagewidth) + { + xtran = -1.0 * column * splitwidth; + ytran = -1.0 * row * (pageheight - overlap); + } + else /* Only one page in horizontal direction */ + { + ytran = -1.0 * row * (pageheight - overlap); + xtran = 0; + } + } + else /* Simple case, no splitting */ + { + ytran = pageheight - imageheight; + xtran = 0; + } + } + bott_offset += ytran / (center ? 2 : 1); + left_offset += xtran / (center ? 2 : 1); + break; + case 90: + case 270: if (splitheight > 0) /* -H maxPageHeight */ + { + if (splitheight < imagewidth) /* More than one vertical image segments */ + { + xtran = -1.0 * column * (pageheight - overlap); + /* Commented code places image at bottom of page instead of top. + ytran = -1.0 * row * splitheight; + */ + if (row == 0) + ytran = -1.0 * (imagewidth - splitheight); + else + ytran = -1.0 * (imagewidth - (splitheight - overlap) * (row + 1)); + } + else /* Only one page in vertical direction */ + { + xtran = -1.0 * column * (pageheight - overlap); + ytran = splitheight - imagewidth; + } + } + else + { + if (splitwidth > 0) /* maxPageWidth */ + { + if (splitwidth < imageheight) + { + xtran = -1.0 * column * splitwidth; + ytran = -1.0 * row * (pagewidth - overlap); + } + else /* Only one page in horizontal direction */ + { + ytran = -1.0 * row * (pagewidth - overlap); + xtran = 0; + } + } + else /* Simple case, no splitting */ + { + ytran = pageheight - imageheight; + xtran = 0; /* pagewidth - imagewidth; */ + } + } + bott_offset += ytran / (center ? 2 : 1); + left_offset += xtran / (center ? 2 : 1); + break; + default: xtran = 0; + ytran = 0; + } + + switch (rotation) + { + case 0: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n", xscale, yscale); + break; + case 180: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n1 1 translate 180 rotate\n", xscale, yscale); + break; + case 90: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n1 0 translate 90 rotate\n", yscale, xscale); + break; + case 270: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n0 1 translate 270 rotate\n", yscale, xscale); + break; + default: TIFFError ("exportMaskedImage", "Unsupported rotation angle %d. No rotation", rotation); + fprintf( fp, "%f %f scale\n", xscale, yscale); + break; + } + + return (0); + } + +/* Rotate an image without scaling or clipping */ +int psRotateImage (FILE * fd, int rotation, double pswidth, double psheight, + double left_offset, double bottom_offset) + { + if ((left_offset != 0.0) || (bottom_offset != 0)) + fprintf (fd, "%f %f translate\n", left_offset, bottom_offset); + + /* Exchange width and height for 90/270 rotations */ + switch (rotation) + { + case 0: fprintf (fd, "%f %f scale\n", pswidth, psheight); + break; + case 90: fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight, pswidth); + break; + case 180: fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth, psheight); + break; + case 270: fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight, pswidth); + break; + default: TIFFError ("psRotateImage", "Unsupported rotation %d.", rotation); + fprintf( fd, "%f %f scale\n", pswidth, psheight); + return (1); + } + return (0); + } + +/* Scale and rotate an image to a single output page. */ +int psScaleImage(FILE * fd, double scale, int rotation, int center, + double reqwidth, double reqheight, double pswidth, double psheight, + double left_offset, double bottom_offset) + { + double hcenter = 0.0, vcenter = 0.0; + + /* Adjust offsets for centering */ + if (center) + { + switch (rotation) + { + case 90: vcenter = (reqheight - pswidth * scale) / 2; + hcenter = (reqwidth - psheight * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight * scale, pswidth * scale); + break; + case 180: hcenter = (reqwidth - pswidth * scale) / 2; + vcenter = (reqheight - psheight * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth * scale, psheight * scale); + break; + case 270: vcenter = (reqheight - pswidth * scale) / 2; + hcenter = (reqwidth - psheight * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight * scale, pswidth * scale); + break; + case 0: + default: hcenter = (reqwidth - pswidth * scale) / 2; + vcenter = (reqheight - psheight * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale); + break; + } + } + else /* Not centered */ + { + switch (rotation) + { + case 0: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (psheight * scale)); + fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale); + break; + case 90: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (pswidth * scale)); + fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight * scale, pswidth * scale); + break; + case 180: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (psheight * scale)); + fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth * scale, psheight * scale); + break; + case 270: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (pswidth * scale)); + fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight * scale, pswidth * scale); + break; + default: TIFFError ("psScaleImage", "Unsupported rotation %d", rotation); + fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale); + return (1); + } + } + + return (0); + } + +/* This controls the visible portion of the page which is displayed. + * N.B. Setting maxPageHeight no longer sets pageheight if not set explicitly + */ +int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, + double reqwidth, double reqheight, double pswidth, double psheight) + { + double xscale = 1.0, yscale = 1.0, scale = 1.0; + double splitheight; + double splitwidth; + double new_width; + double new_height; + + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; + + switch (rotation) + { + case 0: + case 180: if ((splitheight > 0) || (splitwidth > 0)) + { + if (pgwidth != 0 || pgheight != 0) + { + xscale = reqwidth / (splitwidth ? splitwidth : pswidth); + yscale = reqheight / (splitheight ? splitheight : psheight); + scale = (xscale < yscale) ? xscale : yscale; + } + new_width = splitwidth ? splitwidth : scale * pswidth; + new_height = splitheight ? splitheight : scale * psheight; + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + new_width, new_height); + } + else /* No viewport defined with -H or -W */ + { + if ((pgwidth == 0) && (pgheight == 0)) /* Image not scaled */ + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (pswidth > psheight) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)pswidth, (long)psheight); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + pswidth, psheight); + } + else /* Image scaled */ + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + reqwidth, reqheight); + } + } + break; + case 90: + case 270: if ((splitheight > 0) || (splitwidth > 0)) + { + if (pgwidth != 0 || pgheight != 0) + { + xscale = reqwidth / (splitwidth ? splitwidth : pswidth); + yscale = reqheight / (splitheight ? splitheight : psheight); + scale = (xscale < yscale) ? xscale : yscale; + } + new_width = splitwidth ? splitwidth : scale * psheight; + new_height = splitheight ? splitheight : scale * pswidth; + + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + new_width, new_height); + } + else + { + if ((pgwidth == 0) && (pgheight == 0)) /* Image not scaled */ + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (psheight > pswidth) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)psheight, (long)pswidth); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + psheight, pswidth); + } + else /* Image scaled */ + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + reqwidth, reqheight); + } + } + break; + default: TIFFError ("psPageSize", "Invalid rotation %d", rotation); + return (1); + } + fputs("<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n", fd); + + return (0); + } /* end psPageSize */ + +/* Mask an image as a series of pages, each only showing a section defined + * by the maxPageHeight or maxPageWidth options. + */ +int psMaskImage(FILE *fd, TIFF *tif, int rotation, int center, + int *npages, double pixwidth, double pixheight, + double left_margin, double bottom_margin, + double pgwidth, double pgheight, + double pswidth, double psheight, double scale) + { + int i, j; + int ximages = 1, yimages = 1; + int pages = *npages; + double view_width = 0; + double view_height = 0; + + if (get_viewport (pgwidth, pgheight, pswidth, psheight, &view_width, &view_height, rotation)) + { + TIFFError ("get_viewport", "Unable to set image viewport"); + return (-1); + } + + if (get_subimage_count(pgwidth, pgheight, pswidth, psheight, + &ximages, &yimages, rotation, scale) < 1) + { + TIFFError("get_subimage_count", "Invalid image count: %d columns, %d rows", ximages, yimages); + return (-1); + } + + for (i = 0; i < yimages; i++) + { + for (j = 0; j < ximages; j++) + { + pages++; + *npages = pages; + fprintf(fd, "%%%%Page: %d %d\n", pages, pages); + + /* Write out the PageSize info for non EPS files */ + if (!generateEPSF && ( level2 || level3 )) + { + if (psPageSize(fd, rotation, pgwidth, pgheight, + view_width, view_height, pswidth, psheight)) + return (-1); + } + fprintf(fd, "gsave\n"); + fprintf(fd, "100 dict begin\n"); + if (exportMaskedImage(fd, view_width, view_height, pswidth, psheight, + i, j, left_margin, bottom_margin, + scale, center, rotation)) + { + TIFFError("exportMaskedImage", "Invalid image parameters."); + return (-1); + } + PSpage(fd, tif, pixwidth, pixheight); + fprintf(fd, "end\n"); + fprintf(fd, "grestore\n"); + fprintf(fd, "showpage\n"); + } + } + + return (pages); + } + +/* Compute scale factor and write out file header */ +int psStart(FILE *fd, int npages, int auto_rotate, int *rotation, double *scale, + double ox, double oy, double pgwidth, double pgheight, + double reqwidth, double reqheight, double pswidth, double psheight, + double left_offset, double bottom_offset) + { + double maxsource = 0.0; /* Used for auto rotations */ + double maxtarget = 0.0; + double xscale = 1.0, yscale = 1.0; + double splitheight; + double splitwidth; + double view_width = 0.0, view_height = 0.0; + double page_width = 0.0, page_height = 0.0; + + /* Splitheight and splitwidth are in inches */ + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; + + page_width = pgwidth * PS_UNIT_SIZE; + page_height = pgheight * PS_UNIT_SIZE; + + /* If user has specified a page width and height and requested the + * image to be auto-rotated to fit on that media, we match the + * longest dimension of the image to the longest dimension of the + * target media but we have to ignore auto rotate if user specified + * maxPageHeight since this makes life way too complicated. */ + if (auto_rotate) + { + if ((splitheight != 0) || (splitwidth != 0)) + { + TIFFError ("psStart", "Auto-rotate is incompatible with page splitting "); + return (1); + } + + /* Find longest edges in image and output media */ + maxsource = (pswidth >= psheight) ? pswidth : psheight; + maxtarget = (reqwidth >= reqheight) ? reqwidth : reqheight; + + if (((maxsource == pswidth) && (maxtarget != reqwidth)) || + ((maxsource == psheight) && (maxtarget != reqheight))) + { /* optimal orientaion does not match input orientation */ + *rotation = 90; + xscale = (reqwidth - left_offset)/psheight; + yscale = (reqheight - bottom_offset)/pswidth; + } + else /* optimal orientaion matches input orientation */ + { + xscale = (reqwidth - left_offset)/pswidth; + yscale = (reqheight - bottom_offset)/psheight; + } + *scale = (xscale < yscale) ? xscale : yscale; + + /* Do not scale image beyound original size */ + if (*scale > 1.0) + *scale = 1.0; + + /* Set the size of the displayed image to requested page size + * and optimal orientation. + */ + if (!npages) + PSHead(fd, reqwidth, reqheight, ox, oy); + + return (0); + } + + /* N.B. If pgwidth or pgheight are set from maxPageHeight/Width, + * we have a problem with the tests below under splitheight. + */ + + switch (*rotation) /* Auto rotate has NOT been specified */ + { + case 0: + case 180: if ((splitheight != 0) || (splitwidth != 0)) + { /* Viewport clipped to maxPageHeight or maxPageWidth */ + if ((page_width != 0) || (page_height != 0)) /* Image scaled */ + { + xscale = (reqwidth - left_offset) / (page_width ? page_width : pswidth); + yscale = (reqheight - bottom_offset) / (page_height ? page_height : psheight); + *scale = (xscale < yscale) ? xscale : yscale; + /* + if (*scale > 1.0) + *scale = 1.0; + */ + } + else /* Image clipped but not scaled */ + *scale = 1.0; + + view_width = splitwidth ? splitwidth : *scale * pswidth; + view_height = splitheight ? splitheight: *scale * psheight; + } + else /* Viewport not clipped to maxPageHeight or maxPageWidth */ + { + if ((page_width != 0) || (page_height != 0)) + { /* Image scaled */ + xscale = (reqwidth - left_offset) / pswidth; + yscale = (reqheight - bottom_offset) / psheight; + + view_width = reqwidth; + view_height = reqheight; + } + else + { /* Image not scaled */ + xscale = (pswidth - left_offset)/pswidth; + yscale = (psheight - bottom_offset)/psheight; + + view_width = pswidth; + view_height = psheight; + } + } + break; + case 90: + case 270: if ((splitheight != 0) || (splitwidth != 0)) + { /* Viewport clipped to maxPageHeight or maxPageWidth */ + if ((page_width != 0) || (page_height != 0)) /* Image scaled */ + { + xscale = (reqwidth - left_offset)/ psheight; + yscale = (reqheight - bottom_offset)/ pswidth; + *scale = (xscale < yscale) ? xscale : yscale; + /* + if (*scale > 1.0) + *scale = 1.0; + */ + } + else /* Image clipped but not scaled */ + *scale = 1.0; + view_width = splitwidth ? splitwidth : *scale * psheight; + view_height = splitheight ? splitheight : *scale * pswidth; + } + else /* Viewport not clipped to maxPageHeight or maxPageWidth */ + { + if ((page_width != 0) || (page_height != 0)) /* Image scaled */ + { + xscale = (reqwidth - left_offset) / psheight; + yscale = (reqheight - bottom_offset) / pswidth; + + view_width = reqwidth; + view_height = reqheight; + } + else + { + xscale = (pswidth - left_offset)/ psheight; + yscale = (psheight - bottom_offset)/ pswidth; + + view_width = psheight; + view_height = pswidth; + } + } + break; + default: TIFFError ("psPageSize", "Invalid rotation %d", *rotation); + return (1); + } + + if (!npages) + PSHead(fd, (page_width ? page_width : view_width), (page_height ? page_height : view_height), ox, oy); + + *scale = (xscale < yscale) ? xscale : yscale; + if (*scale > 1.0) + *scale = 1.0; + + return (0); + } + +int get_viewport (double pgwidth, double pgheight, double pswidth, double psheight, + double *view_width, double *view_height, int rotation) + { + /* Only one of maxPageHeight or maxPageWidth can be specified */ + if (maxPageHeight != 0) /* Clip the viewport to maxPageHeight on each page */ + { + *view_height = maxPageHeight * PS_UNIT_SIZE; + /* + * if (res_unit == RESUNIT_CENTIMETER) + * *view_height /= 2.54F; + */ + } + else + { + if (pgheight != 0) /* User has set PageHeight with -h flag */ + { + *view_height = pgheight * PS_UNIT_SIZE; /* Postscript size for Page Height in inches */ + /* if (res_unit == RESUNIT_CENTIMETER) + * *view_height /= 2.54F; + */ + } + else /* If no width or height are specified, use the original size from image */ + switch (rotation) + { + default: + case 0: + case 180: *view_height = psheight; + break; + case 90: + case 270: *view_height = pswidth; + break; + } + } + + if (maxPageWidth != 0) /* Clip the viewport to maxPageWidth on each page */ + { + *view_width = maxPageWidth * PS_UNIT_SIZE; + /* if (res_unit == RESUNIT_CENTIMETER) + * *view_width /= 2.54F; + */ + } + else + { + if (pgwidth != 0) /* User has set PageWidth with -w flag */ + { + *view_width = pgwidth * PS_UNIT_SIZE; /* Postscript size for Page Width in inches */ + /* if (res_unit == RESUNIT_CENTIMETER) + * *view_width /= 2.54F; + */ + } + else /* If no width or height are specified, use the original size from image */ + switch (rotation) + { + default: + case 0: + case 180: *view_width = pswidth; + break; + case 90: + case 270: *view_width = psheight; /* (*view_height / psheight) * psheight; */ + break; + } + } + + return (0); + } + +/* pgwidth and pgheight specify page width and height in inches from -h and -w flags + * lm and bm are the LeftMargin and BottomMargin in inches + * center causes the image to be centered on the page if the paper size is + * larger than the image size + * returns the sequence number of the page processed or -1 on error + */ + +int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, double bm, int center) + { + uint32 pixwidth = 0, pixheight = 0; /* Image width and height in pixels */ + double ox = 0.0, oy = 0.0; /* Offset from current Postscript origin */ + double pswidth, psheight; /* Original raw image width and height in points */ + double view_width, view_height; /* Viewport width and height in points */ + double scale = 1.0; + double left_offset = lm * PS_UNIT_SIZE; + double bottom_offset = bm * PS_UNIT_SIZE; + uint32 subfiletype; + uint16* sampleinfo; + static int npages = 0; + + if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox)) + ox = 0; + if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy)) + oy = 0; + + /* Consolidated all the tag information into one code segment, Richard Nolde */ + do { + tf_numberstrips = TIFFNumberOfStrips(tif); + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &tf_rowsperstrip); + TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); + TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfiguration); + TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); + TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &sampleinfo); + alpha = (extrasamples == 1 && sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) + { + switch (samplesperpixel - extrasamples) + { + case 1: if (isCCITTCompression(tif)) + photometric = PHOTOMETRIC_MINISWHITE; + else + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: photometric = PHOTOMETRIC_RGB; + break; + case 4: photometric = PHOTOMETRIC_SEPARATED; + break; + } + } + + /* Read image tags for width and height in pixels pixwidth, pixheight, + * and convert to points pswidth, psheight + */ + setupPageState(tif, &pixwidth, &pixheight, &pswidth, &psheight); + view_width = pswidth; + view_height = psheight; + + if (get_viewport (pgwidth, pgheight, pswidth, psheight, &view_width, &view_height, rotation)) + { + TIFFError("get_viewport", "Unable to set image viewport"); + return (1); + } + + /* Write the Postscript file header with Bounding Box and Page Size definitions */ + if (psStart(fd, npages, auto_rotate, &rotation, &scale, ox, oy, + pgwidth, pgheight, view_width, view_height, pswidth, psheight, + left_offset, bottom_offset)) + return (-1); + + if (checkImage(tif)) /* Aborts if unsupported image parameters */ + { + tf_bytesperrow = TIFFScanlineSize(tif); + + /* Set viewport clipping and scaling options */ + if ((maxPageHeight) || (maxPageWidth) || (pgwidth != 0) || (pgheight != 0)) + { + if ((maxPageHeight) || (maxPageWidth)) /* used -H or -W option */ + { + if (psMaskImage(fd, tif, rotation, center, &npages, pixwidth, pixheight, + left_offset, bottom_offset, pgwidth, pgheight, + pswidth, psheight, scale) < 0) + return (-1); + } + else /* N.B. Setting maxPageHeight no longer sets pgheight */ + { + if (pgwidth != 0 || pgheight != 0) + { + /* User did not specify a maxium page height or width using -H or -W flag + * but did use -h or -w flag to scale to a specific size page. + */ + npages++; + fprintf(fd, "%%%%Page: %d %d\n", npages, npages); + + if (!generateEPSF && ( level2 || level3 )) + { + /* Write out the PageSize info for non EPS files */ + if (psPageSize(fd, rotation, pgwidth, pgheight, + view_width, view_height, pswidth, psheight)) + return (-1); + } + fprintf(fd, "gsave\n"); + fprintf(fd, "100 dict begin\n"); + if (psScaleImage(fd, scale, rotation, center, view_width, view_height, + pswidth, psheight, left_offset, bottom_offset)) + return (-1); + + PSpage(fd, tif, pixwidth, pixheight); + fprintf(fd, "end\n"); + fprintf(fd, "grestore\n"); + fprintf(fd, "showpage\n"); + } + } + } + else /* Simple rotation: user did not use -H, -W, -h or -w */ + { + npages++; + fprintf(fd, "%%%%Page: %d %d\n", npages, npages); + + if (!generateEPSF && ( level2 || level3 )) + { + /* Write out the PageSize info for non EPS files */ + if (psPageSize(fd, rotation, pgwidth, pgheight, + view_width, view_height, pswidth, psheight)) + return (-1); + } + fprintf(fd, "gsave\n"); + fprintf(fd, "100 dict begin\n"); + if (psRotateImage(fd, rotation, pswidth, psheight, left_offset, bottom_offset)) + return (-1); + + PSpage(fd, tif, pixwidth, pixheight); + fprintf(fd, "end\n"); + fprintf(fd, "grestore\n"); + fprintf(fd, "showpage\n"); + } + } + if (generateEPSF) + break; + TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype); + } while (((subfiletype & FILETYPE_PAGE) || printAll) && TIFFReadDirectory(tif)); + +return(npages); +} + +static char DuplexPreamble[] = "\ +%%BeginFeature: *Duplex True\n\ +systemdict begin\n\ + /languagelevel where { pop languagelevel } { 1 } ifelse\n\ + 2 ge { 1 dict dup /Duplex true put setpagedevice }\n\ + { statusdict /setduplex known { statusdict begin setduplex true end } if\n\ + } ifelse\n\ +end\n\ +%%EndFeature\n\ +"; + +static char TumblePreamble[] = "\ +%%BeginFeature: *Tumble True\n\ +systemdict begin\n\ + /languagelevel where { pop languagelevel } { 1 } ifelse\n\ + 2 ge { 1 dict dup /Tumble true put setpagedevice }\n\ + { statusdict /settumble known { statusdict begin true settumble end } if\n\ + } ifelse\n\ +end\n\ +%%EndFeature\n\ +"; + +static char AvoidDeadZonePreamble[] = "\ +gsave newpath clippath pathbbox grestore\n\ + 4 2 roll 2 copy translate\n\ + exch 3 1 roll sub 3 1 roll sub exch\n\ + currentpagedevice /PageSize get aload pop\n\ + exch 3 1 roll div 3 1 roll div abs exch abs\n\ + 2 copy gt { exch } if pop\n\ + dup 1 lt { dup scale } { pop } ifelse\n\ +"; + +void +PSHead(FILE *fd, double pagewidth, double pageheight, double xoff, double yoff) +{ + time_t t; + + t = time(0); + fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : ""); + fprintf(fd, "%%%%Creator: %s\n", creator ? creator : "tiff2ps"); + fprintf(fd, "%%%%Title: %s\n", title ? title : filename); + fprintf(fd, "%%%%CreationDate: %s", ctime(&t)); + fprintf(fd, "%%%%DocumentData: Clean7Bit\n"); + /* NB: should use PageBoundingBox for each page instead of BoundingBox * + * PageBoundingBox DSC added in PSPageSize function, R Nolde 09-01-2010 + */ + fprintf(fd, "%%%%Origin: %ld %ld\n", (long) xoff, (long) yoff); + fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n", + (long) ceil(pagewidth), (long) ceil(pageheight)); + + fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1))); + if (generateEPSF == TRUE) + fprintf(fd, "%%%%Pages: 1 1\n"); + else + fprintf(fd, "%%%%Pages: (atend)\n"); + fprintf(fd, "%%%%EndComments\n"); + if (generateEPSF == FALSE) + { + fprintf(fd, "%%%%BeginSetup\n"); + if (PSduplex) + fprintf(fd, "%s", DuplexPreamble); + if (PStumble) + fprintf(fd, "%s", TumblePreamble); + if (PSavoiddeadzone && (level2 || level3)) + fprintf(fd, "%s", AvoidDeadZonePreamble); + fprintf(fd, "%%%%EndSetup\n"); + } +} + +void +PSTail(FILE *fd, int npages) +{ + fprintf(fd, "%%%%Trailer\n"); + if (generateEPSF == FALSE) + fprintf(fd, "%%%%Pages: %d\n", npages); + fprintf(fd, "%%%%EOF\n"); +} + +static int +checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) +{ + (void) tif; + while (n-- > 0) + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return (16); + TIFFWarning(filename, "Assuming 8-bit colormap"); + return (8); +} + +static void +PS_Lvl2colorspace(FILE* fd, TIFF* tif) +{ + uint16 *rmap, *gmap, *bmap; + int i, num_colors; + const char * colorspace_p; + + switch ( photometric ) + { + case PHOTOMETRIC_SEPARATED: + colorspace_p = "CMYK"; + break; + + case PHOTOMETRIC_RGB: + colorspace_p = "RGB"; + break; + + default: + colorspace_p = "Gray"; + } + + /* + * Set up PostScript Level 2 colorspace according to + * section 4.8 in the PostScript refenence manual. + */ + fputs("% PostScript Level 2 only.\n", fd); + if (photometric != PHOTOMETRIC_PALETTE) { + if (photometric == PHOTOMETRIC_YCBCR) { + /* MORE CODE HERE */ + } + fprintf(fd, "/Device%s setcolorspace\n", colorspace_p ); + return; + } + + /* + * Set up an indexed/palette colorspace + */ + num_colors = (1 << bitspersample); + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { + TIFFError(filename, + "Palette image w/o \"Colormap\" tag"); + return; + } + if (checkcmap(tif, num_colors, rmap, gmap, bmap) == 16) { + /* + * Convert colormap to 8-bits values. + */ +#define CVT(x) (((x) * 255) / ((1L<<16)-1)) + for (i = 0; i < num_colors; i++) { + rmap[i] = CVT(rmap[i]); + gmap[i] = CVT(gmap[i]); + bmap[i] = CVT(bmap[i]); + } +#undef CVT + } + fprintf(fd, "[ /Indexed /DeviceRGB %d", num_colors - 1); + if (ascii85) { + Ascii85Init(); + fputs("\n<~", fd); + ascii85breaklen -= 2; + } else + fputs(" <", fd); + for (i = 0; i < num_colors; i++) { + if (ascii85) { + Ascii85Put((unsigned char)rmap[i], fd); + Ascii85Put((unsigned char)gmap[i], fd); + Ascii85Put((unsigned char)bmap[i], fd); + } else { + fputs((i % 8) ? " " : "\n ", fd); + fprintf(fd, "%02x%02x%02x", + rmap[i], gmap[i], bmap[i]); + } + } + if (ascii85) + Ascii85Flush(fd); + else + fputs(">\n", fd); + fputs("] setcolorspace\n", fd); +} + +static int +PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + int use_rawdata; + uint32 tile_width, tile_height; + uint16 predictor, minsamplevalue, maxsamplevalue; + int repeat_count; + char im_h[64], im_x[64], im_y[64]; + char * imageOp = "image"; + + if ( useImagemask && (bitspersample == 1) ) + imageOp = "imagemask"; + + (void)strcpy(im_x, "0"); + (void)sprintf(im_y, "%lu", (long) h); + (void)sprintf(im_h, "%lu", (long) h); + tile_width = w; + tile_height = h; + if (TIFFIsTiled(tif)) { + repeat_count = TIFFNumberOfTiles(tif); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tile_width); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &tile_height); + if (tile_width > w || tile_height > h || + (w % tile_width) != 0 || (h % tile_height != 0)) { + /* + * The tiles does not fit image width and height. + * Set up a clip rectangle for the image unit square. + */ + fputs("0 0 1 1 rectclip\n", fd); + } + if (tile_width < w) { + fputs("/im_x 0 def\n", fd); + (void)strcpy(im_x, "im_x neg"); + } + if (tile_height < h) { + fputs("/im_y 0 def\n", fd); + (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h); + } + } else { + repeat_count = tf_numberstrips; + tile_height = tf_rowsperstrip; + if (tile_height > h) + tile_height = h; + if (repeat_count > 1) { + fputs("/im_y 0 def\n", fd); + fprintf(fd, "/im_h %lu def\n", + (unsigned long) tile_height); + (void)strcpy(im_h, "im_h"); + (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h); + } + } + + /* + * Output start of exec block + */ + fputs("{ % exec\n", fd); + + if (repeat_count > 1) + fprintf(fd, "%d { %% repeat\n", repeat_count); + + /* + * Output filter options and image dictionary. + */ + if (ascii85) + fputs(" /im_stream currentfile /ASCII85Decode filter def\n", + fd); + fputs(" <<\n", fd); + fputs(" /ImageType 1\n", fd); + fprintf(fd, " /Width %lu\n", (unsigned long) tile_width); + /* + * Workaround for some software that may crash when last strip + * of image contains fewer number of scanlines than specified + * by the `/Height' variable. So for stripped images with multiple + * strips we will set `/Height' as `im_h', because one is + * recalculated for each strip - including the (smaller) final strip. + * For tiled images and images with only one strip `/Height' will + * contain number of scanlines in tile (or image height in case of + * one-stripped image). + */ + if (TIFFIsTiled(tif) || tf_numberstrips == 1) + fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); + else + fprintf(fd, " /Height im_h\n"); + + if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) + fputs(" /MultipleDataSources true\n", fd); + fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n", + (unsigned long) w, - (long)h, im_x, im_y); + fprintf(fd, " /BitsPerComponent %d\n", bitspersample); + fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false"); + + switch (samplesperpixel - extrasamples) { + case 1: + switch (photometric) { + case PHOTOMETRIC_MINISBLACK: + fputs(" /Decode [0 1]\n", fd); + break; + case PHOTOMETRIC_MINISWHITE: + switch (compression) { + case COMPRESSION_CCITTRLE: + case COMPRESSION_CCITTRLEW: + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + /* + * Manage inverting with /Blackis1 flag + * since there migth be uncompressed parts + */ + fputs(" /Decode [0 1]\n", fd); + break; + default: + /* + * ERROR... + */ + fputs(" /Decode [1 0]\n", fd); + break; + } + break; + case PHOTOMETRIC_PALETTE: + TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE, + &minsamplevalue); + TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, + &maxsamplevalue); + fprintf(fd, " /Decode [%u %u]\n", + minsamplevalue, maxsamplevalue); + break; + default: + /* + * ERROR ? + */ + fputs(" /Decode [0 1]\n", fd); + break; + } + break; + case 3: + switch (photometric) { + case PHOTOMETRIC_RGB: + fputs(" /Decode [0 1 0 1 0 1]\n", fd); + break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + default: + /* + * ERROR?? + */ + fputs(" /Decode [0 1 0 1 0 1]\n", fd); + break; + } + break; + case 4: + /* + * ERROR?? + */ + fputs(" /Decode [0 1 0 1 0 1 0 1]\n", fd); + break; + } + fputs(" /DataSource", fd); + if (planarconfiguration == PLANARCONFIG_SEPARATE && + samplesperpixel > 1) + fputs(" [", fd); + if (ascii85) + fputs(" im_stream", fd); + else + fputs(" currentfile /ASCIIHexDecode filter", fd); + + use_rawdata = TRUE; + switch (compression) { + case COMPRESSION_NONE: /* 1: uncompressed */ + break; + case COMPRESSION_CCITTRLE: /* 2: CCITT modified Huffman RLE */ + case COMPRESSION_CCITTRLEW: /* 32771: #1 w/ word alignment */ + case COMPRESSION_CCITTFAX3: /* 3: CCITT Group 3 fax encoding */ + case COMPRESSION_CCITTFAX4: /* 4: CCITT Group 4 fax encoding */ + fputs("\n\t<<\n", fd); + if (compression == COMPRESSION_CCITTFAX3) { + uint32 g3_options; + + fputs("\t /EndOfLine true\n", fd); + fputs("\t /EndOfBlock false\n", fd); + if (!TIFFGetField(tif, TIFFTAG_GROUP3OPTIONS, + &g3_options)) + g3_options = 0; + if (g3_options & GROUP3OPT_2DENCODING) + fprintf(fd, "\t /K %s\n", im_h); + if (g3_options & GROUP3OPT_UNCOMPRESSED) + fputs("\t /Uncompressed true\n", fd); + if (g3_options & GROUP3OPT_FILLBITS) + fputs("\t /EncodedByteAlign true\n", fd); + } + if (compression == COMPRESSION_CCITTFAX4) { + uint32 g4_options; + + fputs("\t /K -1\n", fd); + TIFFGetFieldDefaulted(tif, TIFFTAG_GROUP4OPTIONS, + &g4_options); + if (g4_options & GROUP4OPT_UNCOMPRESSED) + fputs("\t /Uncompressed true\n", fd); + } + if (!(tile_width == w && w == 1728U)) + fprintf(fd, "\t /Columns %lu\n", + (unsigned long) tile_width); + fprintf(fd, "\t /Rows %s\n", im_h); + if (compression == COMPRESSION_CCITTRLE || + compression == COMPRESSION_CCITTRLEW) { + fputs("\t /EncodedByteAlign true\n", fd); + fputs("\t /EndOfBlock false\n", fd); + } + if (photometric == PHOTOMETRIC_MINISBLACK) + fputs("\t /BlackIs1 true\n", fd); + fprintf(fd, "\t>> /CCITTFaxDecode filter"); + break; + case COMPRESSION_LZW: /* 5: Lempel-Ziv & Welch */ + TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); + if (predictor == 2) { + fputs("\n\t<<\n", fd); + fprintf(fd, "\t /Predictor %u\n", predictor); + fprintf(fd, "\t /Columns %lu\n", + (unsigned long) tile_width); + fprintf(fd, "\t /Colors %u\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %u\n", + bitspersample); + fputs("\t>>", fd); + } + fputs(" /LZWDecode filter", fd); + break; + case COMPRESSION_DEFLATE: /* 5: ZIP */ + case COMPRESSION_ADOBE_DEFLATE: + if ( level3 ) { + TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); + if (predictor > 1) { + fprintf(fd, "\t %% PostScript Level 3 only."); + fputs("\n\t<<\n", fd); + fprintf(fd, "\t /Predictor %u\n", predictor); + fprintf(fd, "\t /Columns %lu\n", + (unsigned long) tile_width); + fprintf(fd, "\t /Colors %u\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %u\n", + bitspersample); + fputs("\t>>", fd); + } + fputs(" /FlateDecode filter", fd); + } else { + use_rawdata = FALSE ; + } + break; + case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */ + fputs(" /RunLengthDecode filter", fd); + use_rawdata = TRUE; + break; + case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */ + case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */ +#ifdef notdef + /* + * Code not tested yet + */ + fputs(" /DCTDecode filter", fd); + use_rawdata = TRUE; +#else + use_rawdata = FALSE; +#endif + break; + case COMPRESSION_NEXT: /* 32766: NeXT 2-bit RLE */ + case COMPRESSION_THUNDERSCAN: /* 32809: ThunderScan RLE */ + case COMPRESSION_PIXARFILM: /* 32908: Pixar companded 10bit LZW */ + case COMPRESSION_JBIG: /* 34661: ISO JBIG */ + use_rawdata = FALSE; + break; + case COMPRESSION_SGILOG: /* 34676: SGI LogL or LogLuv */ + case COMPRESSION_SGILOG24: /* 34677: SGI 24-bit LogLuv */ + use_rawdata = FALSE; + break; + default: + /* + * ERROR... + */ + use_rawdata = FALSE; + break; + } + if (planarconfiguration == PLANARCONFIG_SEPARATE && + samplesperpixel > 1) { + uint16 i; + + /* + * NOTE: This code does not work yet... + */ + for (i = 1; i < samplesperpixel; i++) + fputs(" dup", fd); + fputs(" ]", fd); + } + + fprintf( fd, "\n >> %s\n", imageOp ); + if (ascii85) + fputs(" im_stream status { im_stream flushfile } if\n", fd); + if (repeat_count > 1) { + if (tile_width < w) { + fprintf(fd, " /im_x im_x %lu add def\n", + (unsigned long) tile_width); + if (tile_height < h) { + fprintf(fd, " im_x %lu ge {\n", + (unsigned long) w); + fputs(" /im_x 0 def\n", fd); + fprintf(fd, " /im_y im_y %lu add def\n", + (unsigned long) tile_height); + fputs(" } if\n", fd); + } + } + if (tile_height < h) { + if (tile_width >= w) { + fprintf(fd, " /im_y im_y %lu add def\n", + (unsigned long) tile_height); + if (!TIFFIsTiled(tif)) { + fprintf(fd, " /im_h %lu im_y sub", + (unsigned long) h); + fprintf(fd, " dup %lu gt { pop", + (unsigned long) tile_height); + fprintf(fd, " %lu } if def\n", + (unsigned long) tile_height); + } + } + } + fputs("} repeat\n", fd); + } + /* + * End of exec function + */ + fputs("}\n", fd); + + return(use_rawdata); +} + +/* Flip the byte order of buffers with 16 bit samples */ +static void +PS_FlipBytes(unsigned char* buf, tsize_t count) +{ + int i; + unsigned char temp; + + if (count <= 0 || bitspersample <= 8) { + return; + } + + count--; + + for (i = 0; i < count; i += 2) { + temp = buf[i]; + buf[i] = buf[i + 1]; + buf[i + 1] = temp; + } +} + +#define MAXLINE 36 + +int +PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + uint16 fillorder; + int use_rawdata, tiled_image, breaklen = MAXLINE; + uint32 chunk_no, num_chunks; + uint64 *bc; + unsigned char *buf_data, *cp; + tsize_t chunk_size, byte_count; + +#if defined( EXP_ASCII85ENCODER ) + tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ + uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ +#endif + + PS_Lvl2colorspace(fd, tif); + use_rawdata = PS_Lvl2ImageDict(fd, tif, w, h); + +/* See http://bugzilla.remotesensing.org/show_bug.cgi?id=80 */ +#ifdef ENABLE_BROKEN_BEGINENDDATA + fputs("%%BeginData:\n", fd); +#endif + fputs("exec\n", fd); + + tiled_image = TIFFIsTiled(tif); + if (tiled_image) { + num_chunks = TIFFNumberOfTiles(tif); + TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc); + } else { + num_chunks = TIFFNumberOfStrips(tif); + TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); + } + + if (use_rawdata) { + chunk_size = (tsize_t) bc[0]; + for (chunk_no = 1; chunk_no < num_chunks; chunk_no++) + if ((tsize_t) bc[chunk_no] > chunk_size) + chunk_size = (tsize_t) bc[chunk_no]; + } else { + if (tiled_image) + chunk_size = TIFFTileSize(tif); + else + chunk_size = TIFFStripSize(tif); + } + buf_data = (unsigned char *)_TIFFmalloc(chunk_size); + if (!buf_data) { + TIFFError(filename, "Can't alloc %lu bytes for %s.", + (unsigned long) chunk_size, tiled_image ? "tiles" : "strips"); + return(FALSE); + } + +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85 ) { + /* + * Allocate a buffer to hold the ASCII85 encoded data. Note + * that it is allocated with sufficient room to hold the + * encoded data (5*chunk_size/4) plus the EOD marker (+8) + * and formatting line breaks. The line breaks are more + * than taken care of by using 6*chunk_size/4 rather than + * 5*chunk_size/4. + */ + + ascii85_p = _TIFFmalloc( (chunk_size+(chunk_size/2)) + 8 ); + + if ( !ascii85_p ) { + _TIFFfree( buf_data ); + + TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); + return ( FALSE ); + } + } +#endif + + TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); + for (chunk_no = 0; chunk_no < num_chunks; chunk_no++) { + if (ascii85) + Ascii85Init(); + else + breaklen = MAXLINE; + if (use_rawdata) { + if (tiled_image) + byte_count = TIFFReadRawTile(tif, chunk_no, + buf_data, chunk_size); + else + byte_count = TIFFReadRawStrip(tif, chunk_no, + buf_data, chunk_size); + if (fillorder == FILLORDER_LSB2MSB) + TIFFReverseBits(buf_data, byte_count); + } else { + if (tiled_image) + byte_count = TIFFReadEncodedTile(tif, + chunk_no, buf_data, + chunk_size); + else + byte_count = TIFFReadEncodedStrip(tif, + chunk_no, buf_data, + chunk_size); + } + if (byte_count < 0) { + TIFFError(filename, "Can't read %s %d.", + tiled_image ? "tile" : "strip", chunk_no); + if (ascii85) + Ascii85Put('\0', fd); + } + /* + * for 16 bits, the two bytes must be most significant + * byte first + */ + if (bitspersample == 16 && !TIFFIsBigEndian(tif)) { + PS_FlipBytes(buf_data, byte_count); + } + /* + * For images with alpha, matte against a white background; + * i.e. Cback * (1 - Aimage) where Cback = 1. We will fill the + * lower part of the buffer with the modified values. + * + * XXX: needs better solution + */ + if (alpha) { + int adjust, i, j = 0; + int ncomps = samplesperpixel - extrasamples; + for (i = 0; i < byte_count; i+=samplesperpixel) { + adjust = 255 - buf_data[i + ncomps]; + switch (ncomps) { + case 1: + buf_data[j++] = buf_data[i] + adjust; + break; + case 2: + buf_data[j++] = buf_data[i] + adjust; + buf_data[j++] = buf_data[i+1] + adjust; + break; + case 3: + buf_data[j++] = buf_data[i] + adjust; + buf_data[j++] = buf_data[i+1] + adjust; + buf_data[j++] = buf_data[i+2] + adjust; + break; + } + } + byte_count -= j; + } + + if (ascii85) { +#if defined( EXP_ASCII85ENCODER ) + ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, buf_data, byte_count ); + + if ( ascii85_l > 0 ) + fwrite( ascii85_p, ascii85_l, 1, fd ); +#else + for (cp = buf_data; byte_count > 0; byte_count--) + Ascii85Put(*cp++, fd); +#endif + } + else + { + for (cp = buf_data; byte_count > 0; byte_count--) { + putc(hex[((*cp)>>4)&0xf], fd); + putc(hex[(*cp)&0xf], fd); + cp++; + + if (--breaklen <= 0) { + putc('\n', fd); + breaklen = MAXLINE; + } + } + } + + if ( !ascii85 ) { + if ( level2 || level3 ) + putc( '>', fd ); + putc('\n', fd); + } +#if !defined( EXP_ASCII85ENCODER ) + else + Ascii85Flush(fd); +#endif + } + +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85_p ) + _TIFFfree( ascii85_p ); +#endif + + _TIFFfree(buf_data); +#ifdef ENABLE_BROKEN_BEGINENDDATA + fputs("%%EndData\n", fd); +#endif + return(TRUE); +} + +void +PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + char * imageOp = "image"; + + if ( useImagemask && (bitspersample == 1) ) + imageOp = "imagemask"; + + if ((level2 || level3) && PS_Lvl2page(fd, tif, w, h)) + return; + ps_bytesperrow = tf_bytesperrow - (extrasamples * bitspersample / 8)*w; + switch (photometric) { + case PHOTOMETRIC_RGB: + if (planarconfiguration == PLANARCONFIG_CONTIG) { + fprintf(fd, "%s", RGBcolorimage); + PSColorContigPreamble(fd, w, h, 3); + PSDataColorContig(fd, tif, w, h, 3); + } else { + PSColorSeparatePreamble(fd, w, h, 3); + PSDataColorSeparate(fd, tif, w, h, 3); + } + break; + case PHOTOMETRIC_SEPARATED: + /* XXX should emit CMYKcolorimage */ + if (planarconfiguration == PLANARCONFIG_CONTIG) { + PSColorContigPreamble(fd, w, h, 4); + PSDataColorContig(fd, tif, w, h, 4); + } else { + PSColorSeparatePreamble(fd, w, h, 4); + PSDataColorSeparate(fd, tif, w, h, 4); + } + break; + case PHOTOMETRIC_PALETTE: + fprintf(fd, "%s", RGBcolorimage); + PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); + fprintf(fd, "/scanLine %ld string def\n", + (long) ps_bytesperrow * 3L); + fprintf(fd, "%lu %lu 8\n", + (unsigned long) w, (unsigned long) h); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); + fprintf(fd, "false 3 colorimage\n"); + PSDataPalette(fd, tif, w, h); + break; + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_MINISWHITE: + PhotoshopBanner(fd, w, h, 1, 1, imageOp); + fprintf(fd, "/scanLine %ld string def\n", + (long) ps_bytesperrow); + fprintf(fd, "%lu %lu %d\n", + (unsigned long) w, (unsigned long) h, bitspersample); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, + "{currentfile scanLine readhexstring pop} bind\n"); + fprintf(fd, "%s\n", imageOp); + PSDataBW(fd, tif, w, h); + break; + } + putc('\n', fd); +} + +void +PSColorContigPreamble(FILE* fd, uint32 w, uint32 h, int nc) +{ + ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); + PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); + fprintf(fd, "/line %ld string def\n", (long) ps_bytesperrow); + fprintf(fd, "%lu %lu %d\n", + (unsigned long) w, (unsigned long) h, bitspersample); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "{currentfile line readhexstring pop} bind\n"); + fprintf(fd, "false %d colorimage\n", nc); +} + +void +PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc) +{ + int i; + + PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); + for (i = 0; i < nc; i++) + fprintf(fd, "/line%d %ld string def\n", + i, (long) ps_bytesperrow); + fprintf(fd, "%lu %lu %d\n", + (unsigned long) w, (unsigned long) h, bitspersample); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + for (i = 0; i < nc; i++) + fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); + fprintf(fd, "true %d colorimage\n", nc); +} + +#define DOBREAK(len, howmany, fd) \ + if (((len) -= (howmany)) <= 0) { \ + putc('\n', fd); \ + (len) = MAXLINE-(howmany); \ + } +#define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd) + +void +PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) +{ + uint32 row; + int breaklen = MAXLINE, es = samplesperpixel - nc; + tsize_t cc; + unsigned char *tf_buf; + unsigned char *cp, c; + + (void) w; + tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + for (row = 0; row < h; row++) { + if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) + break; + cp = tf_buf; + /* + * for 16 bits, the two bytes must be most significant + * byte first + */ + if (bitspersample == 16 && !HOST_BIGENDIAN) { + PS_FlipBytes(cp, tf_bytesperrow); + } + if (alpha) { + int adjust; + cc = 0; + for (; cc < tf_bytesperrow; cc += samplesperpixel) { + DOBREAK(breaklen, nc, fd); + /* + * For images with alpha, matte against + * a white background; i.e. + * Cback * (1 - Aimage) + * where Cback = 1. + */ + adjust = 255 - cp[nc]; + switch (nc) { + case 4: c = *cp++ + adjust; PUTHEX(c,fd); + case 3: c = *cp++ + adjust; PUTHEX(c,fd); + case 2: c = *cp++ + adjust; PUTHEX(c,fd); + case 1: c = *cp++ + adjust; PUTHEX(c,fd); + } + cp += es; + } + } else { + cc = 0; + for (; cc < tf_bytesperrow; cc += samplesperpixel) { + DOBREAK(breaklen, nc, fd); + switch (nc) { + case 4: c = *cp++; PUTHEX(c,fd); + case 3: c = *cp++; PUTHEX(c,fd); + case 2: c = *cp++; PUTHEX(c,fd); + case 1: c = *cp++; PUTHEX(c,fd); + } + cp += es; + } + } + } + _TIFFfree((char *) tf_buf); +} + +void +PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) +{ + uint32 row; + int breaklen = MAXLINE; + tsize_t cc; + tsample_t s, maxs; + unsigned char *tf_buf; + unsigned char *cp, c; + + (void) w; + tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + maxs = (samplesperpixel > nc ? nc : samplesperpixel); + for (row = 0; row < h; row++) { + for (s = 0; s < maxs; s++) { + if (TIFFReadScanline(tif, tf_buf, row, s) < 0) + break; + for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { + DOBREAK(breaklen, 1, fd); + c = *cp++; + PUTHEX(c,fd); + } + } + } + _TIFFfree((char *) tf_buf); +} + +#define PUTRGBHEX(c,fd) \ + PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd) + +void +PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + uint16 *rmap, *gmap, *bmap; + uint32 row; + int breaklen = MAXLINE, nc; + tsize_t cc; + unsigned char *tf_buf; + unsigned char *cp, c; + + (void) w; + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { + TIFFError(filename, "Palette image w/o \"Colormap\" tag"); + return; + } + switch (bitspersample) { + case 8: case 4: case 2: case 1: + break; + default: + TIFFError(filename, "Depth %d not supported", bitspersample); + return; + } + nc = 3 * (8 / bitspersample); + tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + if (checkcmap(tif, 1<= 0; i--) { + rmap[i] = CVT(rmap[i]); + gmap[i] = CVT(gmap[i]); + bmap[i] = CVT(bmap[i]); + } +#undef CVT + } + for (row = 0; row < h; row++) { + if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) + break; + for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { + DOBREAK(breaklen, nc, fd); + switch (bitspersample) { + case 8: + c = *cp++; PUTRGBHEX(c, fd); + break; + case 4: + c = *cp++; PUTRGBHEX(c&0xf, fd); + c >>= 4; PUTRGBHEX(c, fd); + break; + case 2: + c = *cp++; PUTRGBHEX(c&0x3, fd); + c >>= 2; PUTRGBHEX(c&0x3, fd); + c >>= 2; PUTRGBHEX(c&0x3, fd); + c >>= 2; PUTRGBHEX(c, fd); + break; + case 1: + c = *cp++; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c, fd); + break; + } + } + } + _TIFFfree((char *) tf_buf); +} + +void +PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + int breaklen = MAXLINE; + unsigned char* tf_buf; + unsigned char* cp; + tsize_t stripsize = TIFFStripSize(tif); + tstrip_t s; + +#if defined( EXP_ASCII85ENCODER ) + tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ + uint8 *ascii85_p = 0; /* Holds ASCII85 encoded data */ +#endif + + (void) w; (void) h; + tf_buf = (unsigned char *) _TIFFmalloc(stripsize); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + + // FIXME + memset(tf_buf, 0, stripsize); + +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85 ) { + /* + * Allocate a buffer to hold the ASCII85 encoded data. Note + * that it is allocated with sufficient room to hold the + * encoded data (5*stripsize/4) plus the EOD marker (+8) + * and formatting line breaks. The line breaks are more + * than taken care of by using 6*stripsize/4 rather than + * 5*stripsize/4. + */ + + ascii85_p = _TIFFmalloc( (stripsize+(stripsize/2)) + 8 ); + + if ( !ascii85_p ) { + _TIFFfree( tf_buf ); + + TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); + return; + } + } +#endif + + if (ascii85) + Ascii85Init(); + + for (s = 0; s < TIFFNumberOfStrips(tif); s++) { + tmsize_t cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize); + if (cc < 0) { + TIFFError(filename, "Can't read strip"); + break; + } + cp = tf_buf; + if (photometric == PHOTOMETRIC_MINISWHITE) { + for (cp += cc; --cp >= tf_buf;) + *cp = ~*cp; + cp++; + } + /* + * for 16 bits, the two bytes must be most significant + * byte first + */ + if (bitspersample == 16 && !HOST_BIGENDIAN) { + PS_FlipBytes(cp, cc); + } + if (ascii85) { +#if defined( EXP_ASCII85ENCODER ) + if (alpha) { + int adjust, i; + for (i = 0; i < cc; i+=2) { + adjust = 255 - cp[i + 1]; + cp[i / 2] = cp[i] + adjust; + } + cc /= 2; + } + + ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, cp, cc ); + + if ( ascii85_l > 0 ) + fwrite( ascii85_p, ascii85_l, 1, fd ); +#else + while (cc-- > 0) + Ascii85Put(*cp++, fd); +#endif /* EXP_ASCII85_ENCODER */ + } else { + unsigned char c; + + if (alpha) { + int adjust; + while (cc-- > 0) { + DOBREAK(breaklen, 1, fd); + /* + * For images with alpha, matte against + * a white background; i.e. + * Cback * (1 - Aimage) + * where Cback = 1. + */ + adjust = 255 - cp[1]; + c = *cp++ + adjust; PUTHEX(c,fd); + cp++, cc--; + } + } else { + while (cc-- > 0) { + c = *cp++; + DOBREAK(breaklen, 1, fd); + PUTHEX(c, fd); + } + } + } + } + + if ( !ascii85 ) + { + if ( level2 || level3) + fputs(">\n", fd); + } +#if !defined( EXP_ASCII85ENCODER ) + else + Ascii85Flush(fd); +#else + if ( ascii85_p ) + _TIFFfree( ascii85_p ); +#endif + + _TIFFfree(tf_buf); +} + +void +PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + uint64 *bc; + uint32 bufsize; + int breaklen = MAXLINE; + tmsize_t cc; + uint16 fillorder; + unsigned char *tf_buf; + unsigned char *cp, c; + tstrip_t s; + +#if defined( EXP_ASCII85ENCODER ) + tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ + uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ +#endif + + (void) w; (void) h; + TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); + TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); + + /* + * Find largest strip: + */ + + bufsize = (uint32) bc[0]; + + for ( s = 0; ++s < (tstrip_t)tf_numberstrips; ) { + if ( bc[s] > bufsize ) + bufsize = (uint32) bc[s]; + } + + tf_buf = (unsigned char*) _TIFFmalloc(bufsize); + if (tf_buf == NULL) { + TIFFError(filename, "No space for strip buffer"); + return; + } + +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85 ) { + /* + * Allocate a buffer to hold the ASCII85 encoded data. Note + * that it is allocated with sufficient room to hold the + * encoded data (5*bufsize/4) plus the EOD marker (+8) + * and formatting line breaks. The line breaks are more + * than taken care of by using 6*bufsize/4 rather than + * 5*bufsize/4. + */ + + ascii85_p = _TIFFmalloc( (bufsize+(bufsize/2)) + 8 ); + + if ( !ascii85_p ) { + _TIFFfree( tf_buf ); + + TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); + return; + } + } +#endif + + for (s = 0; s < (tstrip_t) tf_numberstrips; s++) { + cc = TIFFReadRawStrip(tif, s, tf_buf, (tmsize_t) bc[s]); + if (cc < 0) { + TIFFError(filename, "Can't read strip"); + break; + } + if (fillorder == FILLORDER_LSB2MSB) + TIFFReverseBits(tf_buf, cc); + if (!ascii85) { + for (cp = tf_buf; cc > 0; cc--) { + DOBREAK(breaklen, 1, fd); + c = *cp++; + PUTHEX(c, fd); + } + fputs(">\n", fd); + breaklen = MAXLINE; + } else { + Ascii85Init(); +#if defined( EXP_ASCII85ENCODER ) + ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, tf_buf, cc ); + + if ( ascii85_l > 0 ) + fwrite( ascii85_p, ascii85_l, 1, fd ); +#else + for (cp = tf_buf; cc > 0; cc--) + Ascii85Put(*cp++, fd); + Ascii85Flush(fd); +#endif /* EXP_ASCII85ENCODER */ + } + } + _TIFFfree((char *) tf_buf); + +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85_p ) + _TIFFfree( ascii85_p ); +#endif +} + +void +Ascii85Init(void) +{ + ascii85breaklen = 2*MAXLINE; + ascii85count = 0; +} + +static char* +Ascii85Encode(unsigned char* raw) +{ + static char encoded[6]; + uint32 word; + + word = (((raw[0]<<8)+raw[1])<<16) + (raw[2]<<8) + raw[3]; + if (word != 0L) { + uint32 q; + uint16 w1; + + q = word / (85L*85*85*85); /* actually only a byte */ + encoded[0] = (char) (q + '!'); + + word -= q * (85L*85*85*85); q = word / (85L*85*85); + encoded[1] = (char) (q + '!'); + + word -= q * (85L*85*85); q = word / (85*85); + encoded[2] = (char) (q + '!'); + + w1 = (uint16) (word - q*(85L*85)); + encoded[3] = (char) ((w1 / 85) + '!'); + encoded[4] = (char) ((w1 % 85) + '!'); + encoded[5] = '\0'; + } else + encoded[0] = 'z', encoded[1] = '\0'; + return (encoded); +} + +void +Ascii85Put(unsigned char code, FILE* fd) +{ + ascii85buf[ascii85count++] = code; + if (ascii85count >= 4) { + unsigned char* p; + int n; + + for (n = ascii85count, p = ascii85buf; n >= 4; n -= 4, p += 4) { + char* cp; + for (cp = Ascii85Encode(p); *cp; cp++) { + putc(*cp, fd); + if (--ascii85breaklen == 0) { + putc('\n', fd); + ascii85breaklen = 2*MAXLINE; + } + } + } + _TIFFmemcpy(ascii85buf, p, n); + ascii85count = n; + } +} + +void +Ascii85Flush(FILE* fd) +{ + if (ascii85count > 0) { + char* res; + _TIFFmemset(&ascii85buf[ascii85count], 0, 3); + res = Ascii85Encode(ascii85buf); + fwrite(res[0] == 'z' ? "!!!!" : res, ascii85count + 1, 1, fd); + } + fputs("~>\n", fd); +} +#if defined( EXP_ASCII85ENCODER) + +#define A85BREAKCNTR ascii85breaklen +#define A85BREAKLEN (2*MAXLINE) + +/***************************************************************************** +* +* Name: Ascii85EncodeBlock( ascii85_p, f_eod, raw_p, raw_l ) +* +* Description: This routine will encode the raw data in the buffer described +* by raw_p and raw_l into ASCII85 format and store the encoding +* in the buffer given by ascii85_p. +* +* Parameters: ascii85_p - A buffer supplied by the caller which will +* contain the encoded ASCII85 data. +* f_eod - Flag: Nz means to end the encoded buffer with +* an End-Of-Data marker. +* raw_p - Pointer to the buffer of data to be encoded +* raw_l - Number of bytes in raw_p[] to be encoded +* +* Returns: (int) < 0 Error, see errno +* >= 0 Number of bytes written to ascii85_p[]. +* +* Notes: An external variable given by A85BREAKCNTR is used to +* determine when to insert newline characters into the +* encoded data. As each byte is placed into ascii85_p this +* external is decremented. If the variable is decrement to +* or past zero then a newline is inserted into ascii85_p +* and the A85BREAKCNTR is then reset to A85BREAKLEN. +* Note: for efficiency reasons the A85BREAKCNTR variable +* is not actually checked on *every* character +* placed into ascii85_p but often only for every +* 5 characters. +* +* THE CALLER IS RESPONSIBLE FOR ENSURING THAT ASCII85_P[] IS +* SUFFICIENTLY LARGE TO THE ENCODED DATA! +* You will need at least 5 * (raw_l/4) bytes plus space for +* newline characters and space for an EOD marker (if +* requested). A safe calculation is to use 6*(raw_l/4) + 8 +* to size ascii85_p. +* +*****************************************************************************/ + +tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l ) + +{ + char ascii85[5]; /* Encoded 5 tuple */ + tsize_t ascii85_l; /* Number of bytes written to ascii85_p[] */ + int rc; /* Return code */ + uint32 val32; /* Unencoded 4 tuple */ + + ascii85_l = 0; /* Nothing written yet */ + + if ( raw_p ) + { + --raw_p; /* Prepare for pre-increment fetches */ + + for ( ; raw_l > 3; raw_l -= 4 ) + { + val32 = *(++raw_p) << 24; + val32 += *(++raw_p) << 16; + val32 += *(++raw_p) << 8; + val32 += *(++raw_p); + + if ( val32 == 0 ) /* Special case */ + { + ascii85_p[ascii85_l] = 'z'; + rc = 1; + } + + else + { + ascii85[4] = (char) ((val32 % 85) + 33); + val32 /= 85; + + ascii85[3] = (char) ((val32 % 85) + 33); + val32 /= 85; + + ascii85[2] = (char) ((val32 % 85) + 33); + val32 /= 85; + + ascii85[1] = (char) ((val32 % 85) + 33); + ascii85[0] = (char) ((val32 / 85) + 33); + + _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, sizeof(ascii85) ); + rc = sizeof(ascii85); + } + + ascii85_l += rc; + + if ( (A85BREAKCNTR -= rc) <= 0 ) + { + ascii85_p[ascii85_l] = '\n'; + ++ascii85_l; + A85BREAKCNTR = A85BREAKLEN; + } + } + + /* + * Output any straggler bytes: + */ + + if ( raw_l > 0 ) + { + tsize_t len; /* Output this many bytes */ + + len = raw_l + 1; + val32 = *++raw_p << 24; /* Prime the pump */ + + if ( --raw_l > 0 ) val32 += *(++raw_p) << 16; + if ( --raw_l > 0 ) val32 += *(++raw_p) << 8; + + val32 /= 85; + + ascii85[3] = (char) ((val32 % 85) + 33); + val32 /= 85; + + ascii85[2] = (char) ((val32 % 85) + 33); + val32 /= 85; + + ascii85[1] = (char) ((val32 % 85) + 33); + ascii85[0] = (char) ((val32 / 85) + 33); + + _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, len ); + ascii85_l += len; + } + } + + /* + * If requested add an ASCII85 End Of Data marker: + */ + + if ( f_eod ) + { + ascii85_p[ascii85_l++] = '~'; + ascii85_p[ascii85_l++] = '>'; + ascii85_p[ascii85_l++] = '\n'; + } + + return ( ascii85_l ); + +} /* Ascii85EncodeBlock() */ + +#endif /* EXP_ASCII85ENCODER */ + + +char* stuff[] = { +"usage: tiff2ps [options] input.tif ...", +"where options are:", +" -1 generate PostScript Level 1 (default)", +" -2 generate PostScript Level 2", +" -3 generate PostScript Level 3", +" -8 disable use of ASCII85 encoding with PostScript Level 2/3", +" -a convert all directories in file (default is first), Not EPS", +" -b # set the bottom margin to # inches", +" -c center image (-b and -l still add to this)", +" -d # set initial directory to # counting from zero", +" -D enable duplex printing (two pages per sheet of paper)", +" -e generate Encapsulated PostScript (EPS) (implies -z)", +" -h # set printed page height to # inches (no default)", +" -w # set printed page width to # inches (no default)", +" -H # split image if height is more than # inches", +" -P L or P set optional PageOrientation DSC comment to Landscape or Portrait", +" -W # split image if width is more than # inches", +" -L # overLap split images by # inches", +" -i # enable/disable (Nz/0) pixel interpolation (default: enable)", +" -l # set the left margin to # inches", +" -m use \"imagemask\" operator instead of \"image\"", +" -o # convert directory at file offset # bytes", +" -O file write PostScript to file instead of standard output", +" -p generate regular PostScript", +" -r # or auto rotate by 90, 180, 270 degrees or auto", +" -s generate PostScript for a single image", +" -t name set postscript document title. Otherwise the filename is used", +" -T print pages for top edge binding", +" -x override resolution units as centimeters", +" -y override resolution units as inches", +" -z enable printing in the deadzone (only for PostScript Level 2/3)", +NULL +}; + +static void +usage(int code) +{ + char buf[BUFSIZ]; + int i; + + setbuf(stderr, buf); + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(code); +} + diff --git a/libs/tiff-3.8.2/tools/tiff2rgba.c b/libs/tiff-4.0.2/tools/tiff2rgba.c similarity index 75% rename from libs/tiff-3.8.2/tools/tiff2rgba.c rename to libs/tiff-4.0.2/tools/tiff2rgba.c index a4f4d44896..737167c7a5 100644 --- a/libs/tiff-3.8.2/tools/tiff2rgba.c +++ b/libs/tiff-4.0.2/tools/tiff2rgba.c @@ -1,4 +1,4 @@ -/* $Id: tiff2rgba.c,v 1.11 2004/11/03 00:28:24 fwarmerdam Exp $ */ +/* $Id: tiff2rgba.c,v 1.19 2011-02-23 21:46:09 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -11,16 +11,16 @@ * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -34,6 +34,11 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#include "tiffiop.h" #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) @@ -45,83 +50,89 @@ #endif #define roundup(x, y) (howmany(x,y)*((uint32)(y))) -uint16 compression = COMPRESSION_PACKBITS; -uint32 rowsperstrip = (uint32) -1; -int process_by_block = 0; /* default is whole image at once */ -int no_alpha = 0; +uint16 compression = COMPRESSION_PACKBITS; +uint32 rowsperstrip = (uint32) -1; +int process_by_block = 0; /* default is whole image at once */ +int no_alpha = 0; +int bigtiff_output = 0; -static int tiffcvt(TIFF* in, TIFF* out); -static void usage(int code); +static int tiffcvt(TIFF* in, TIFF* out); +static void usage(int code); int main(int argc, char* argv[]) { - TIFF *in, *out; - int c; - extern int optind; - extern char *optarg; + TIFF *in, *out; + int c; + extern int optind; + extern char *optarg; - while ((c = getopt(argc, argv, "c:r:t:bn")) != -1) - switch (c) { - case 'b': - process_by_block = 1; - break; - - case 'c': - if (streq(optarg, "none")) - compression = COMPRESSION_NONE; - else if (streq(optarg, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (streq(optarg, "lzw")) - compression = COMPRESSION_LZW; - else if (streq(optarg, "jpeg")) - compression = COMPRESSION_JPEG; - else if (streq(optarg, "zip")) - compression = COMPRESSION_DEFLATE; - else - usage(-1); - break; + while ((c = getopt(argc, argv, "c:r:t:bn8")) != -1) + switch (c) { + case 'b': + process_by_block = 1; + break; - case 'r': - rowsperstrip = atoi(optarg); - break; + case 'c': + if (streq(optarg, "none")) + compression = COMPRESSION_NONE; + else if (streq(optarg, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (streq(optarg, "lzw")) + compression = COMPRESSION_LZW; + else if (streq(optarg, "jpeg")) + compression = COMPRESSION_JPEG; + else if (streq(optarg, "zip")) + compression = COMPRESSION_DEFLATE; + else + usage(-1); + break; - case 't': - rowsperstrip = atoi(optarg); - break; - - case 'n': - no_alpha = 1; - break; - - case '?': - usage(0); - /*NOTREACHED*/ - } + case 'r': + rowsperstrip = atoi(optarg); + break; - if (argc - optind < 2) - usage(-1); + case 't': + rowsperstrip = atoi(optarg); + break; - out = TIFFOpen(argv[argc-1], "w"); - if (out == NULL) - return (-2); + case 'n': + no_alpha = 1; + break; - for (; optind < argc-1; optind++) { - in = TIFFOpen(argv[optind], "r"); - if (in != NULL) { - do { - if (!tiffcvt(in, out) || - !TIFFWriteDirectory(out)) { - (void) TIFFClose(out); - return (1); - } - } while (TIFFReadDirectory(in)); - (void) TIFFClose(in); - } - } - (void) TIFFClose(out); - return (0); + case '8': + bigtiff_output = 1; + break; + + case '?': + usage(0); + /*NOTREACHED*/ + } + + if (argc - optind < 2) + usage(-1); + + out = TIFFOpen(argv[argc-1], bigtiff_output?"w8":"w"); + if (out == NULL) + return (-2); + + for (; optind < argc-1; optind++) { + in = TIFFOpen(argv[optind], "r"); + if (in != NULL) { + do { + if (!tiffcvt(in, out) || + !TIFFWriteDirectory(out)) { + (void) TIFFClose(out); + (void) TIFFClose(in); + return (1); + } + } while (TIFFReadDirectory(in)); + (void) TIFFClose(in); + } + } + (void) TIFFClose(out); + return (0); } static int @@ -181,6 +192,15 @@ cvt_by_tile( TIFF *in, TIFF *out ) break; } + + /* + * XXX: raster array has 4-byte unsigned integer type, that is why + * we should rearrange it here. + */ +#if HOST_BIGENDIAN + TIFFSwabArrayOfLong(raster, tile_width * tile_height); +#endif + /* * For some reason the TIFFReadRGBATile() function chooses the * lower left corner as the origin. Vertically mirror scanlines. @@ -270,6 +290,14 @@ cvt_by_strip( TIFF *in, TIFF *out ) break; } + /* + * XXX: raster array has 4-byte unsigned integer type, that is why + * we should rearrange it here. + */ +#if HOST_BIGENDIAN + TIFFSwabArrayOfLong(raster, width * rowsperstrip); +#endif + /* * Figure out the number of scanlines actually in this strip. */ @@ -328,16 +356,27 @@ cvt_whole_image( TIFF *in, TIFF *out ) uint32* raster; /* retrieve RGBA image */ uint32 width, height; /* image width & height */ uint32 row; + size_t pixel_count; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); + pixel_count = width * height; + + /* XXX: Check the integer overflow. */ + if (!width || !height || pixel_count / width != height) { + TIFFError(TIFFFileName(in), + "Malformed input file; can't allocate buffer for raster of %lux%lu size", + (unsigned long)width, (unsigned long)height); + return 0; + } rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32)); + raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), "raster buffer"); if (raster == 0) { - TIFFError(TIFFFileName(in), "No space for raster buffer"); + TIFFError(TIFFFileName(in), "Failed to allocate buffer (%lu elements of %lu each)", + (unsigned long)pixel_count, (unsigned long)sizeof(uint32)); return (0); } @@ -349,34 +388,42 @@ cvt_whole_image( TIFF *in, TIFF *out ) } /* - ** Do we want to strip away alpha components? - */ - if( no_alpha ) + * XXX: raster array has 4-byte unsigned integer type, that is why + * we should rearrange it here. + */ +#if HOST_BIGENDIAN + TIFFSwabArrayOfLong(raster, width * height); +#endif + + /* + * Do we want to strip away alpha components? + */ + if (no_alpha) { - int pixel_count = width * height; + size_t count = pixel_count; unsigned char *src, *dst; - src = (unsigned char *) raster; - dst = (unsigned char *) raster; - while( pixel_count > 0 ) + src = dst = (unsigned char *) raster; + while (count > 0) { - *(dst++) = *(src++); - *(dst++) = *(src++); - *(dst++) = *(src++); - src++; - pixel_count--; + *(dst++) = *(src++); + *(dst++) = *(src++); + *(dst++) = *(src++); + src++; + count--; } } - /* Write out the result in strips */ - - for( row = 0; row < height; row += rowsperstrip ) + /* + * Write out the result in strips + */ + for (row = 0; row < height; row += rowsperstrip) { unsigned char * raster_strip; int rows_to_write; int bytes_per_pixel; - if( no_alpha ) + if (no_alpha) { raster_strip = ((unsigned char *) raster) + 3 * row * width; bytes_per_pixel = 3; @@ -456,7 +503,7 @@ tiffcvt(TIFF* in, TIFF* out) } static char* stuff[] = { - "usage: tiff2rgba [-c comp] [-r rows] [-b] input... output", + "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] input... output", "where comp is one of the following compression algorithms:", " jpeg\t\tJPEG encoding", " zip\t\tLempel-Ziv & Welch encoding", @@ -467,6 +514,7 @@ static char* stuff[] = { " -r\trows/strip", " -b (progress by block rather than as a whole image)", " -n don't emit alpha component.", + " -8 write BigTIFF file instead of ClassicTIFF", NULL }; @@ -484,3 +532,10 @@ usage(int code) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffcmp.c b/libs/tiff-4.0.2/tools/tiffcmp.c similarity index 98% rename from libs/tiff-3.8.2/tools/tiffcmp.c rename to libs/tiff-4.0.2/tools/tiffcmp.c index 392702fd7c..bc7dac9417 100644 --- a/libs/tiff-3.8.2/tools/tiffcmp.c +++ b/libs/tiff-4.0.2/tools/tiffcmp.c @@ -1,4 +1,4 @@ -/* $Id: tiffcmp.c,v 1.12 2005/12/29 00:15:57 bfriesen Exp $ */ +/* $Id: tiffcmp.c,v 1.16 2010-03-10 18:56:50 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -29,11 +29,16 @@ #include #include #include +#include #ifdef HAVE_UNISTD_H # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #ifndef HAVE_GETOPT @@ -51,7 +56,7 @@ static uint32 imagelength; static void usage(void); static int tiffcmp(TIFF*, TIFF*); static int cmptags(TIFF*, TIFF*); -static int ContigCompare(int, uint32, unsigned char*, unsigned char*, int); +static int ContigCompare(int, uint32, unsigned char*, unsigned char*, tsize_t); static int SeparateCompare(int, int, uint32, unsigned char*, unsigned char*); static void PrintIntDiff(uint32, int, uint32, uint32, uint32); static void PrintFloatDiff(uint32, int, uint32, double, double); @@ -308,7 +313,7 @@ cmptags(TIFF* tif1, TIFF* tif2) static int ContigCompare(int sample, uint32 row, - unsigned char* p1, unsigned char* p2, int size) + unsigned char* p1, unsigned char* p2, tsize_t size) { uint32 pix; int ppb = 8 / bitspersample; @@ -383,7 +388,7 @@ ContigCompare(int sample, uint32 row, int s; for(s = 0; s < samples_to_test; s++) { - if (*pix1 != *pix2) { + if (fabs(*pix1 - *pix2) < 0.000000000001) { PrintFloatDiff(row, sample, pix, *pix1, *pix2); } @@ -630,3 +635,10 @@ leof(const char* name, uint32 row, int s) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffcp.c b/libs/tiff-4.0.2/tools/tiffcp.c similarity index 57% rename from libs/tiff-3.8.2/tools/tiffcp.c rename to libs/tiff-4.0.2/tools/tiffcp.c index 0b51b7bbbc..0f81b19d4a 100644 --- a/libs/tiff-3.8.2/tools/tiffcp.c +++ b/libs/tiff-4.0.2/tools/tiffcp.c @@ -1,4 +1,4 @@ -/* $Id: tiffcp.c,v 1.34 2006/03/21 16:24:33 dron Exp $ */ +/* $Id: tiffcp.c,v 1.49 2010-12-23 13:38:47 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -53,8 +53,12 @@ #include "tiffio.h" +#ifndef HAVE_GETOPT +extern int getopt(int, char**, char*); +#endif + #if defined(VMS) -#define unlink delete +# define unlink delete #endif #define streq(a,b) (strcmp(a,b) == 0) @@ -63,31 +67,34 @@ #define TRUE 1 #define FALSE 0 -static int outtiled = -1; -static uint32 tilewidth; -static uint32 tilelength; +static int outtiled = -1; +static uint32 tilewidth; +static uint32 tilelength; -static uint16 config; -static uint16 compression; -static uint16 predictor; -static uint16 fillorder; -static uint16 orientation; -static uint32 rowsperstrip; -static uint32 g3opts; -static int ignore = FALSE; /* if true, ignore read errors */ -static uint32 defg3opts = (uint32) -1; -static int quality = 75; /* JPEG quality */ -static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint16 defcompression = (uint16) -1; -static uint16 defpredictor = (uint16) -1; +static uint16 config; +static uint16 compression; +static uint16 predictor; +static int preset; +static uint16 fillorder; +static uint16 orientation; +static uint32 rowsperstrip; +static uint32 g3opts; +static int ignore = FALSE; /* if true, ignore read errors */ +static uint32 defg3opts = (uint32) -1; +static int quality = 75; /* JPEG quality */ +static int jpegcolormode = JPEGCOLORMODE_RGB; +static uint16 defcompression = (uint16) -1; +static uint16 defpredictor = (uint16) -1; +static int defpreset = -1; -static int tiffcp(TIFF*, TIFF*); -static int processCompressOptions(char*); -static void usage(void); +static int tiffcp(TIFF*, TIFF*); +static int processCompressOptions(char*); +static void usage(void); static char comma = ','; /* (default) comma separator character */ static TIFF* bias = NULL; static int pageNum = 0; +static int pageInSeq = 0; static int nextSrcImage (TIFF *tif, char **imageSpec) /* @@ -96,27 +103,27 @@ static int nextSrcImage (TIFF *tif, char **imageSpec) *imageSpec=NULL if subsequent images should be processed in sequence */ { - if (**imageSpec == comma) { /* if not @comma, we've done all images */ - char *start = *imageSpec + 1; - tdir_t nextImage = (tdir_t)strtol(start, imageSpec, 0); - if (start == *imageSpec) nextImage = TIFFCurrentDirectory (tif); - if (**imageSpec) - { - if (**imageSpec == comma) { - /* a trailing comma denotes remaining images in sequence */ - if ((*imageSpec)[1] == '\0') *imageSpec = NULL; - }else{ - fprintf (stderr, - "Expected a %c separated image # list after %s\n", - comma, TIFFFileName (tif)); - exit (-4); /* syntax error */ - } - } - if (TIFFSetDirectory (tif, nextImage)) return 1; - fprintf (stderr, "%s%c%d not found!\n", - TIFFFileName(tif), comma, (int) nextImage); - } - return 0; + if (**imageSpec == comma) { /* if not @comma, we've done all images */ + char *start = *imageSpec + 1; + tdir_t nextImage = (tdir_t)strtol(start, imageSpec, 0); + if (start == *imageSpec) nextImage = TIFFCurrentDirectory (tif); + if (**imageSpec) + { + if (**imageSpec == comma) { + /* a trailing comma denotes remaining images in sequence */ + if ((*imageSpec)[1] == '\0') *imageSpec = NULL; + }else{ + fprintf (stderr, + "Expected a %c separated image # list after %s\n", + comma, TIFFFileName (tif)); + exit (-4); /* syntax error */ + } + } + if (TIFFSetDirectory (tif, nextImage)) return 1; + fprintf (stderr, "%s%c%d not found!\n", + TIFFFileName(tif), comma, (int) nextImage); + } + return 0; } @@ -127,27 +134,26 @@ static TIFF* openSrcImage (char **imageSpec) no images specified, or a pointer to the next image number text */ { - TIFF *tif; - char *fn = *imageSpec; - *imageSpec = strchr (fn, comma); - if (*imageSpec) { /* there is at least one image number specifier */ - **imageSpec = '\0'; - tif = TIFFOpen (fn, "r"); - /* but, ignore any single trailing comma */ - if (!(*imageSpec)[1]) {*imageSpec = NULL; return tif;} - if (tif) { - **imageSpec = comma; /* replace the comma */ - if (!nextSrcImage(tif, imageSpec)) { - TIFFClose (tif); - tif = NULL; - } - } - }else - tif = TIFFOpen (fn, "r"); - return tif; + TIFF *tif; + char *fn = *imageSpec; + *imageSpec = strchr (fn, comma); + if (*imageSpec) { /* there is at least one image number specifier */ + **imageSpec = '\0'; + tif = TIFFOpen (fn, "r"); + /* but, ignore any single trailing comma */ + if (!(*imageSpec)[1]) {*imageSpec = NULL; return tif;} + if (tif) { + **imageSpec = comma; /* replace the comma */ + if (!nextSrcImage(tif, imageSpec)) { + TIFFClose (tif); + tif = NULL; + } + } + }else + tif = TIFFOpen (fn, "r"); + return tif; } - int main(int argc, char* argv[]) { @@ -156,7 +162,7 @@ main(int argc, char* argv[]) uint32 deftilewidth = (uint32) -1; uint32 deftilelength = (uint32) -1; uint32 defrowsperstrip = (uint32) 0; - uint32 diroff = 0; + uint64 diroff = 0; TIFF* in; TIFF* out; char mode[10]; @@ -167,41 +173,41 @@ main(int argc, char* argv[]) *mp++ = 'w'; *mp = '\0'; - while ((c = getopt(argc, argv, ",:b:c:f:l:o:z:p:r:w:aistBLMC")) != -1) + while ((c = getopt(argc, argv, ",:b:c:f:l:o:z:p:r:w:aistBLMC8x")) != -1) switch (c) { - case ',': - if (optarg[0] != '=') usage(); - comma = optarg[1]; - break; - case 'b': /* this file is bias image subtracted from others */ - if (bias) { - fputs ("Only 1 bias image may be specified\n", stderr); - exit (-2); - } - { - uint16 samples = (uint16) -1; - char **biasFn = &optarg; - bias = openSrcImage (biasFn); - if (!bias) exit (-5); - if (TIFFIsTiled (bias)) { - fputs ("Bias image must be organized in strips\n", stderr); - exit (-7); - } - TIFFGetField(bias, TIFFTAG_SAMPLESPERPIXEL, &samples); - if (samples != 1) { - fputs ("Bias image must be monochrome\n", stderr); - exit (-7); - } - } - break; - case 'a': /* append to output */ + case ',': + if (optarg[0] != '=') usage(); + comma = optarg[1]; + break; + case 'b': /* this file is bias image subtracted from others */ + if (bias) { + fputs ("Only 1 bias image may be specified\n", stderr); + exit (-2); + } + { + uint16 samples = (uint16) -1; + char **biasFn = &optarg; + bias = openSrcImage (biasFn); + if (!bias) exit (-5); + if (TIFFIsTiled (bias)) { + fputs ("Bias image must be organized in strips\n", stderr); + exit (-7); + } + TIFFGetField(bias, TIFFTAG_SAMPLESPERPIXEL, &samples); + if (samples != 1) { + fputs ("Bias image must be monochrome\n", stderr); + exit (-7); + } + } + break; + case 'a': /* append to output */ mode[0] = 'a'; break; - case 'c': /* compression scheme */ + case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; - case 'f': /* fill order */ + case 'f': /* fill order */ if (streq(optarg, "lsb2msb")) deffillorder = FILLORDER_LSB2MSB; else if (streq(optarg, "msb2lsb")) @@ -209,17 +215,17 @@ main(int argc, char* argv[]) else usage(); break; - case 'i': /* ignore errors */ + case 'i': /* ignore errors */ ignore = TRUE; break; - case 'l': /* tile length */ + case 'l': /* tile length */ outtiled = TRUE; deftilelength = atoi(optarg); break; - case 'o': /* initial directory offset */ + case 'o': /* initial directory offset */ diroff = strtoul(optarg, NULL, 0); break; - case 'p': /* planar configuration */ + case 'p': /* planar configuration */ if (streq(optarg, "separate")) defconfig = PLANARCONFIG_SEPARATE; else if (streq(optarg, "contig")) @@ -227,16 +233,16 @@ main(int argc, char* argv[]) else usage(); break; - case 'r': /* rows/strip */ + case 'r': /* rows/strip */ defrowsperstrip = atol(optarg); break; - case 's': /* generate stripped output */ + case 's': /* generate stripped output */ outtiled = FALSE; break; - case 't': /* generate tiled output */ + case 't': /* generate tiled output */ outtiled = TRUE; break; - case 'w': /* tile width */ + case 'w': /* tile width */ outtiled = TRUE; deftilewidth = atoi(optarg); break; @@ -252,6 +258,12 @@ main(int argc, char* argv[]) case 'C': *mp++ = 'c'; *mp = '\0'; break; + case '8': + *mp++ = '8'; *mp = '\0'; + break; + case 'x': + pageInSeq = 1; + break; case '?': usage(); /*NOTREACHED*/ @@ -262,43 +274,63 @@ main(int argc, char* argv[]) if (out == NULL) return (-2); if ((argc - optind) == 2) - pageNum = -1; + pageNum = -1; for (; optind < argc-1 ; optind++) { - char *imageCursor = argv[optind]; + char *imageCursor = argv[optind]; in = openSrcImage (&imageCursor); - if (in == NULL) + if (in == NULL) { + (void) TIFFClose(out); return (-3); + } if (diroff != 0 && !TIFFSetSubDirectory(in, diroff)) { TIFFError(TIFFFileName(in), - "Error, setting subdirectory at %#x", diroff); + "Error, setting subdirectory at " TIFF_UINT64_FORMAT, diroff); + (void) TIFFClose(in); (void) TIFFClose(out); return (1); } - for (;;) { - config = defconfig; - compression = defcompression; - predictor = defpredictor; - fillorder = deffillorder; - rowsperstrip = defrowsperstrip; - tilewidth = deftilewidth; - tilelength = deftilelength; - g3opts = defg3opts; - if (!tiffcp(in, out) || !TIFFWriteDirectory(out)) { - TIFFClose(out); - return (1); - } - if (imageCursor) { /* seek next image directory */ - if (!nextSrcImage(in, &imageCursor)) break; - }else - if (!TIFFReadDirectory(in)) break; + for (;;) { + config = defconfig; + compression = defcompression; + predictor = defpredictor; + preset = defpreset; + fillorder = deffillorder; + rowsperstrip = defrowsperstrip; + tilewidth = deftilewidth; + tilelength = deftilelength; + g3opts = defg3opts; + if (!tiffcp(in, out) || !TIFFWriteDirectory(out)) { + (void) TIFFClose(in); + (void) TIFFClose(out); + return (1); + } + if (imageCursor) { /* seek next image directory */ + if (!nextSrcImage(in, &imageCursor)) break; + }else + if (!TIFFReadDirectory(in)) break; } - TIFFClose(in); + (void) TIFFClose(in); } - TIFFClose(out); - return (0); + (void) TIFFClose(out); + return (0); } +static void +processZIPOptions(char* cp) +{ + if ( (cp = strchr(cp, ':')) ) { + do { + cp++; + if (isdigit((int)*cp)) + defpredictor = atoi(cp); + else if (*cp == 'p') + defpreset = atoi(++cp); + else + usage(); + } while( (cp = strchr(cp, ':')) ); + } +} static void processG3Options(char* cp) @@ -330,18 +362,18 @@ processCompressOptions(char* opt) } else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); - defcompression = COMPRESSION_JPEG; - while( cp ) - { - if (isdigit((int)cp[1])) - quality = atoi(cp+1); - else if (cp[1] == 'r' ) - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(); + defcompression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(); - cp = strchr(cp+1,':'); - } + cp = strchr(cp+1,':'); + } } else if (strneq(opt, "g3", 2)) { processG3Options(opt); defcompression = COMPRESSION_CCITTFAX3; @@ -353,10 +385,15 @@ processCompressOptions(char* opt) defpredictor = atoi(cp+1); defcompression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { - char* cp = strchr(opt, ':'); - if (cp) - defpredictor = atoi(cp+1); + processZIPOptions(opt); defcompression = COMPRESSION_ADOBE_DEFLATE; + } else if (strneq(opt, "lzma", 4)) { + processZIPOptions(opt); + defcompression = COMPRESSION_LZMA; + } else if (strneq(opt, "jbig", 4)) { + defcompression = COMPRESSION_JBIG; + } else if (strneq(opt, "sgilog", 6)) { + defcompression = COMPRESSION_SGILOG; } else return (0); return (1); @@ -365,45 +402,53 @@ processCompressOptions(char* opt) char* stuff[] = { "usage: tiffcp [options] input... output", "where options are:", -" -a append to output instead of overwriting", -" -o offset set initial directory offset", -" -p contig pack samples contiguously (e.g. RGBRGB...)", -" -p separate store samples separately (e.g. RRR...GGG...BBB...)", -" -s write output in strips", -" -t write output in tiles", -" -i ignore read errors", -" -b file[,#] bias (dark) monochrome image to be subtracted from all others", -" -,=% use % rather than , to separate image #'s (per Note below)", +" -a append to output instead of overwriting", +" -o offset set initial directory offset", +" -p contig pack samples contiguously (e.g. RGBRGB...)", +" -p separate store samples separately (e.g. RRR...GGG...BBB...)", +" -s write output in strips", +" -t write output in tiles", +" -8 write BigTIFF instead of default ClassicTIFF", +" -i ignore read errors", +" -b file[,#] bias (dark) monochrome image to be subtracted from all others", +" -,=% use % rather than , to separate image #'s (per Note below)", "", -" -r # make each strip have no more than # rows", -" -w # set output tile width (pixels)", -" -l # set output tile length (pixels)", +" -r # make each strip have no more than # rows", +" -w # set output tile width (pixels)", +" -l # set output tile length (pixels)", "", -" -f lsb2msb force lsb-to-msb FillOrder for output", -" -f msb2lsb force msb-to-lsb FillOrder for output", +" -f lsb2msb force lsb-to-msb FillOrder for output", +" -f msb2lsb force msb-to-lsb FillOrder for output", "", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c jpeg[:opts] compress output with JPEG encoding", -" -c packbits compress output with packbits encoding", -" -c g3[:opts] compress output with CCITT Group 3 encoding", -" -c g4 compress output with CCITT Group 4 encoding", -" -c none use no compression algorithm on output", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c lzma[:opts] compress output with LZMA2 encoding", +" -c jpeg[:opts] compress output with JPEG encoding", +" -c jbig compress output with ISO JBIG encoding", +" -c packbits compress output with packbits encoding", +" -c g3[:opts] compress output with CCITT Group 3 encoding", +" -c g4 compress output with CCITT Group 4 encoding", +" -c sgilog compress output with SGILOG encoding", +" -c none use no compression algorithm on output", +" -x force the merged tiff pages in sequence", "", "Group 3 options:", -" 1d use default CCITT Group 3 1D-encoding", -" 2d use optional CCITT Group 3 2D-encoding", -" fill byte-align EOL codes", +" 1d use default CCITT Group 3 1D-encoding", +" 2d use optional CCITT Group 3 2D-encoding", +" fill byte-align EOL codes", "For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", "", "JPEG options:", -" # set compression quality level (0-100, default 75)", -" r output color image as RGB rather than YCbCr", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", "", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +"LZW, Deflate (ZIP) and LZMA2 options:", +" # set predictor value", +" p# set compression level (preset)", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing,", +"-c zip:3:p9 for Deflate encoding with maximum compression level and floating", +"point predictor.", "", "Note that input filenames may be of the form filename,x,y,z", "where x, y, and z specify image numbers in the filename to copy.", @@ -419,7 +464,7 @@ usage(void) int i; setbuf(stderr, buf); - fprintf(stderr, "%s\n\n", TIFFGetVersion()); + fprintf(stderr, "%s\n\n", TIFFGetVersion()); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); @@ -482,16 +527,16 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) CopyField(tag, doubleav); } break; - default: - TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped.", - tag, type); + default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped.", + tag, type); } } static struct cpTag { - uint16 tag; - uint16 count; + uint16 tag; + uint16 count; TIFFDataType type; } tags[] = { { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, @@ -536,10 +581,13 @@ typedef int (*copyFunc) (TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel); static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16); +/* PODD */ + static int tiffcp(TIFF* in, TIFF* out) { uint16 bitspersample, samplesperpixel; + uint16 input_compression, input_photometric; copyFunc cf; uint32 width, length; struct cpTag* p; @@ -552,31 +600,35 @@ tiffcp(TIFF* in, TIFF* out) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else CopyField(TIFFTAG_COMPRESSION, compression); - if (compression == COMPRESSION_JPEG) { - uint16 input_compression, input_photometric; + TIFFGetFieldDefaulted(in, TIFFTAG_COMPRESSION, &input_compression); + TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric); + if (input_compression == COMPRESSION_JPEG) { + /* Force conversion to RGB */ + TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } else if (input_photometric == PHOTOMETRIC_YCBCR) { + /* Otherwise, can't handle subsampled input */ + uint16 subsamplinghor,subsamplingver; - if (TIFFGetField(in, TIFFTAG_COMPRESSION, &input_compression) - && input_compression == COMPRESSION_JPEG) { - TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - } - if (TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) { - if(input_photometric == PHOTOMETRIC_RGB) { - if (jpegcolormode == JPEGCOLORMODE_RGB) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - PHOTOMETRIC_YCBCR); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - PHOTOMETRIC_RGB); - } else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - input_photometric); - } - } + TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, + &subsamplinghor, &subsamplingver); + if (subsamplinghor!=1 || subsamplingver!=1) { + fprintf(stderr, "tiffcp: %s: Can't copy/convert subsampled image.\n", + TIFFFileName(in)); + return FALSE; + } + } + if (compression == COMPRESSION_JPEG) { + if (input_photometric == PHOTOMETRIC_RGB && + jpegcolormode == JPEGCOLORMODE_RGB) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); + } else if (compression == COMPRESSION_SGILOG - || compression == COMPRESSION_SGILOG24) + || compression == COMPRESSION_SGILOG24) TIFFSetField(out, TIFFTAG_PHOTOMETRIC, samplesperpixel == 1 ? - PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); else CopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT); if (fillorder != 0) @@ -636,11 +688,11 @@ tiffcp(TIFF* in, TIFF* out) */ if (rowsperstrip == (uint32) 0) { if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, - &rowsperstrip)) { + &rowsperstrip)) { rowsperstrip = - TIFFDefaultStripSize(out, rowsperstrip); + TIFFDefaultStripSize(out, rowsperstrip); } - if (rowsperstrip > length) + if (rowsperstrip > length && rowsperstrip != (uint32)-1) rowsperstrip = length; } else if (rowsperstrip == (uint32) -1) @@ -656,68 +708,92 @@ tiffcp(TIFF* in, TIFF* out) CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); /* SMinSampleValue & SMaxSampleValue */ switch (compression) { - case COMPRESSION_JPEG: - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != (uint16)-1) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - else - CopyField(TIFFTAG_PREDICTOR, predictor); - break; - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - if (compression == COMPRESSION_CCITTFAX3) { - if (g3opts != (uint32) -1) - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, - g3opts); + case COMPRESSION_JPEG: + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_JBIG: + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + CopyTag(TIFFTAG_FAXDCS, 1, TIFF_ASCII); + break; + case COMPRESSION_LZW: + case COMPRESSION_ADOBE_DEFLATE: + case COMPRESSION_DEFLATE: + case COMPRESSION_LZMA: + if (predictor != (uint16)-1) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); else - CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); - } else - CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); - CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); - CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); - break; - } - { uint32 len32; - void** data; - if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) - TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); - } - { uint16 ninks; - const char* inknames; - if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { - TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); - if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { - int inknameslen = strlen(inknames) + 1; - const char* cp = inknames; - while (ninks > 1) { - cp = strchr(cp, '\0'); - if (cp) { - cp++; - inknameslen += (strlen(cp) + 1); - } - ninks--; - } - TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); - } - } + CopyField(TIFFTAG_PREDICTOR, predictor); + if (preset != -1) { + if (compression == COMPRESSION_ADOBE_DEFLATE + || compression == COMPRESSION_DEFLATE) + TIFFSetField(out, TIFFTAG_ZIPQUALITY, preset); + else if (compression == COMPRESSION_LZMA) + TIFFSetField(out, TIFFTAG_LZMAPRESET, preset); + } + break; + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + if (compression == COMPRESSION_CCITTFAX3) { + if (g3opts != (uint32) -1) + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, + g3opts); + else + CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); + } else + CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); + CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); + CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + break; } { - unsigned short pg0, pg1; - if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { - if (pageNum < 0) /* only one input file */ - TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); - else - TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); - } + uint32 len32; + void** data; + if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) + TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + } + { + uint16 ninks; + const char* inknames; + if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { + TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); + if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { + int inknameslen = strlen(inknames) + 1; + const char* cp = inknames; + while (ninks > 1) { + cp = strchr(cp, '\0'); + cp++; + inknameslen += (strlen(cp) + 1); + ninks--; + } + TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); + } + } + } + { + unsigned short pg0, pg1; + + if (pageInSeq == 1) { + if (pageNum < 0) /* only one input file */ { + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) + TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); + } else + TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); + + } else { + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { + if (pageNum < 0) /* only one input file */ + TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); + else + TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); + } + } } for (p = tags; p < &tags[NTAGS]; p++) @@ -749,9 +825,14 @@ typedef int (*writeFunc)(TIFF*, uint8*, uint32, uint32, tsample_t); */ DECLAREcpFunc(cpContig2ContigByRow) { - tdata_t buf = _TIFFmalloc(TIFFScanlineSize(in)); + tsize_t scanlinesize = TIFFScanlineSize(in); + tdata_t buf; uint32 row; + buf = _TIFFmalloc(scanlinesize); + if (!buf) + return 0; + _TIFFmemset(buf, 0, scanlinesize); (void) imagewidth; (void) spp; for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { @@ -794,12 +875,12 @@ subtract(32) static biasFn *lineSubtractFn (unsigned bits) { - switch (bits) { - case 8: return subtract8; - case 16: return subtract16; - case 32: return subtract32; - } - return NULL; + switch (bits) { + case 8: return subtract8; + case 16: return subtract16; + case 32: return subtract32; + } + return NULL; } /* @@ -808,72 +889,72 @@ static biasFn *lineSubtractFn (unsigned bits) DECLAREcpFunc(cpBiasedContig2Contig) { if (spp == 1) { - tsize_t biasSize = TIFFScanlineSize(bias); - tsize_t bufSize = TIFFScanlineSize(in); - tdata_t buf, biasBuf; - uint32 biasWidth = 0, biasLength = 0; - TIFFGetField(bias, TIFFTAG_IMAGEWIDTH, &biasWidth); - TIFFGetField(bias, TIFFTAG_IMAGELENGTH, &biasLength); - if (biasSize == bufSize && - imagelength == biasLength && imagewidth == biasWidth) { - uint16 sampleBits = 0; - biasFn *subtractLine; - TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &sampleBits); - subtractLine = lineSubtractFn (sampleBits); - if (subtractLine) { - uint32 row; - buf = _TIFFmalloc(bufSize); - biasBuf = _TIFFmalloc(bufSize); - for (row = 0; row < imagelength; row++) { - if (TIFFReadScanline(in, buf, row, 0) < 0 - && !ignore) { - TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); - goto bad; + tsize_t biasSize = TIFFScanlineSize(bias); + tsize_t bufSize = TIFFScanlineSize(in); + tdata_t buf, biasBuf; + uint32 biasWidth = 0, biasLength = 0; + TIFFGetField(bias, TIFFTAG_IMAGEWIDTH, &biasWidth); + TIFFGetField(bias, TIFFTAG_IMAGELENGTH, &biasLength); + if (biasSize == bufSize && + imagelength == biasLength && imagewidth == biasWidth) { + uint16 sampleBits = 0; + biasFn *subtractLine; + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &sampleBits); + subtractLine = lineSubtractFn (sampleBits); + if (subtractLine) { + uint32 row; + buf = _TIFFmalloc(bufSize); + biasBuf = _TIFFmalloc(bufSize); + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(in, buf, row, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + goto bad; + } + if (TIFFReadScanline(bias, biasBuf, row, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read biased scanline %lu", + (unsigned long) row); + goto bad; + } + subtractLine (buf, biasBuf, imagewidth); + if (TIFFWriteScanline(out, buf, row, 0) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write scanline %lu", + (unsigned long) row); + goto bad; + } } - if (TIFFReadScanline(bias, biasBuf, row, 0) < 0 - && !ignore) { - TIFFError(TIFFFileName(in), - "Error, can't read biased scanline %lu", - (unsigned long) row); - goto bad; - } - subtractLine (buf, biasBuf, imagewidth); - if (TIFFWriteScanline(out, buf, row, 0) < 0) { - TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); - goto bad; - } - } - - _TIFFfree(buf); - _TIFFfree(biasBuf); - TIFFSetDirectory(bias, - TIFFCurrentDirectory(bias)); /* rewind */ - return 1; + + _TIFFfree(buf); + _TIFFfree(biasBuf); + TIFFSetDirectory(bias, + TIFFCurrentDirectory(bias)); /* rewind */ + return 1; bad: - _TIFFfree(buf); - _TIFFfree(biasBuf); - return 0; - } else { - TIFFError(TIFFFileName(in), - "No support for biasing %d bit pixels\n", - sampleBits); - return 0; - } - } - TIFFError(TIFFFileName(in), + _TIFFfree(buf); + _TIFFfree(biasBuf); + return 0; + } else { + TIFFError(TIFFFileName(in), + "No support for biasing %d bit pixels\n", + sampleBits); + return 0; + } + } + TIFFError(TIFFFileName(in), "Bias image %s,%d\nis not the same size as %s,%d\n", TIFFFileName(bias), TIFFCurrentDirectory(bias), TIFFFileName(in), TIFFCurrentDirectory(in)); - return 0; + return 0; } else { - TIFFError(TIFFFileName(in), + TIFFError(TIFFFileName(in), "Can't bias %s,%d as it has >1 Sample/Pixel\n", TIFFFileName(in), TIFFCurrentDirectory(in)); - return 0; + return 0; } } @@ -891,20 +972,21 @@ DECLAREcpFunc(cpDecodedStrips) if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); uint32 row = 0; + _TIFFmemset(buf, 0, stripsize); for (s = 0; s < ns; s++) { tsize_t cc = (row + rowsperstrip > imagelength) ? TIFFVStripSize(in, imagelength - row) : stripsize; if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read strip %lu", - (unsigned long) s); + "Error, can't read strip %lu", + (unsigned long) s); goto bad; } if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %lu", - (unsigned long) s); + "Error, can't write strip %lu", + (unsigned long) s); goto bad; } row += rowsperstrip; @@ -913,8 +995,8 @@ DECLAREcpFunc(cpDecodedStrips) return 1; } else { TIFFError(TIFFFileName(in), - "Error, can't allocate memory buffer of size %lu " - "to read strips", (unsigned long) stripsize); + "Error, can't allocate memory buffer of size %lu " + "to read strips", (unsigned long) stripsize); return 0; } @@ -928,23 +1010,28 @@ bad: */ DECLAREcpFunc(cpSeparate2SeparateByRow) { - tdata_t buf = _TIFFmalloc(TIFFScanlineSize(in)); + tsize_t scanlinesize = TIFFScanlineSize(in); + tdata_t buf; uint32 row; tsample_t s; (void) imagewidth; + buf = _TIFFmalloc(scanlinesize); + if (!buf) + return 0; + _TIFFmemset(buf, 0, scanlinesize); for (s = 0; s < spp; s++) { for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %lu", + (unsigned long) row); goto bad; } if (TIFFWriteScanline(out, buf, row, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %lu", + (unsigned long) row); goto bad; } } @@ -961,21 +1048,29 @@ bad: */ DECLAREcpFunc(cpContig2SeparateByRow) { - tdata_t inbuf = _TIFFmalloc(TIFFScanlineSize(in)); - tdata_t outbuf = _TIFFmalloc(TIFFScanlineSize(out)); + tsize_t scanlinesizein = TIFFScanlineSize(in); + tsize_t scanlinesizeout = TIFFScanlineSize(out); + tdata_t inbuf; + tdata_t outbuf; register uint8 *inp, *outp; register uint32 n; uint32 row; tsample_t s; + inbuf = _TIFFmalloc(scanlinesizein); + outbuf = _TIFFmalloc(scanlinesizeout); + if (!inbuf || !outbuf) + return 0; + _TIFFmemset(inbuf, 0, scanlinesizein); + _TIFFmemset(outbuf, 0, scanlinesizeout); /* unpack channels */ for (s = 0; s < spp; s++) { for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %lu", + (unsigned long) row); goto bad; } inp = ((uint8*)inbuf) + s; @@ -986,8 +1081,8 @@ DECLAREcpFunc(cpContig2SeparateByRow) } if (TIFFWriteScanline(out, outbuf, row, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %lu", + (unsigned long) row); goto bad; } } @@ -1006,21 +1101,29 @@ bad: */ DECLAREcpFunc(cpSeparate2ContigByRow) { - tdata_t inbuf = _TIFFmalloc(TIFFScanlineSize(in)); - tdata_t outbuf = _TIFFmalloc(TIFFScanlineSize(out)); + tsize_t scanlinesizein = TIFFScanlineSize(in); + tsize_t scanlinesizeout = TIFFScanlineSize(out); + tdata_t inbuf; + tdata_t outbuf; register uint8 *inp, *outp; register uint32 n; uint32 row; tsample_t s; + inbuf = _TIFFmalloc(scanlinesizein); + outbuf = _TIFFmalloc(scanlinesizeout); + if (!inbuf || !outbuf) + return 0; + _TIFFmemset(inbuf, 0, scanlinesizein); + _TIFFmemset(outbuf, 0, scanlinesizeout); for (row = 0; row < imagelength; row++) { /* merge channels */ for (s = 0; s < spp; s++) { if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %lu", + (unsigned long) row); goto bad; } inp = (uint8*)inbuf; @@ -1032,8 +1135,8 @@ DECLAREcpFunc(cpSeparate2ContigByRow) } if (TIFFWriteScanline(out, outbuf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %lu", + (unsigned long) row); goto bad; } } @@ -1048,7 +1151,7 @@ bad: static void cpStripToTile(uint8* out, uint8* in, - uint32 rows, uint32 cols, int outskew, int inskew) + uint32 rows, uint32 cols, int outskew, int inskew) { while (rows-- > 0) { uint32 j = cols; @@ -1061,20 +1164,20 @@ cpStripToTile(uint8* out, uint8* in, static void cpContigBufToSeparateBuf(uint8* out, uint8* in, - uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, - int bytes_per_sample ) + uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, + int bytes_per_sample ) { while (rows-- > 0) { uint32 j = cols; while (j-- > 0) - { - int n = bytes_per_sample; + { + int n = bytes_per_sample; - while( n-- ) { - *out++ = *in++; - } - in += (spp-1) * bytes_per_sample; - } + while( n-- ) { + *out++ = *in++; + } + in += (spp-1) * bytes_per_sample; + } out += outskew; in += inskew; } @@ -1082,19 +1185,19 @@ cpContigBufToSeparateBuf(uint8* out, uint8* in, static void cpSeparateBufToContigBuf(uint8* out, uint8* in, - uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, - int bytes_per_sample) + uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, + int bytes_per_sample) { while (rows-- > 0) { uint32 j = cols; while (j-- > 0) { - int n = bytes_per_sample; + int n = bytes_per_sample; - while( n-- ) { - *out++ = *in++; - } - out += (spp-1)*bytes_per_sample; - } + while( n-- ) { + *out++ = *in++; + } + out += (spp-1)*bytes_per_sample; + } out += outskew; in += inskew; } @@ -1107,24 +1210,24 @@ cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout, int status = 0; tdata_t buf = NULL; tsize_t scanlinesize = TIFFRasterScanlineSize(in); - tsize_t bytes = scanlinesize * (tsize_t)imagelength; - /* - * XXX: Check for integer overflow. - */ - if (scanlinesize + tsize_t bytes = scanlinesize * (tsize_t)imagelength; + /* + * XXX: Check for integer overflow. + */ + if (scanlinesize && imagelength && bytes / (tsize_t)imagelength == scanlinesize) { - buf = _TIFFmalloc(bytes); + buf = _TIFFmalloc(bytes); if (buf) { - if ((*fin)(in, (uint8*)buf, imagelength, - imagewidth, spp)) { + if ((*fin)(in, (uint8*)buf, imagelength, + imagewidth, spp)) { status = (*fout)(out, (uint8*)buf, - imagelength, imagewidth, spp); + imagelength, imagewidth, spp); } _TIFFfree(buf); } else { TIFFError(TIFFFileName(in), - "Error, can't allocate space for image buffer"); + "Error, can't allocate space for image buffer"); } } else { TIFFError(TIFFFileName(in), "Error, no space for image buffer"); @@ -1144,8 +1247,8 @@ DECLAREreadFunc(readContigStripsIntoBuffer) if (TIFFReadScanline(in, (tdata_t) bufp, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %lu", + (unsigned long) row); return 0; } bufp += scanlinesize; @@ -1158,10 +1261,14 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer) { int status = 1; tsize_t scanlinesize = TIFFScanlineSize(in); - tdata_t scanline = _TIFFmalloc(scanlinesize); + tdata_t scanline; if (!scanlinesize) return 0; + scanline = _TIFFmalloc(scanlinesize); + if (!scanline) + return 0; + _TIFFmemset(scanline, 0, scanlinesize); (void) imagewidth; if (scanline) { uint8* bufp = (uint8*) buf; @@ -1172,14 +1279,14 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer) for (s = 0; s < spp; s++) { uint8* bp = bufp + s; tsize_t n = scanlinesize; - uint8* sbuf = scanline; + uint8* sbuf = scanline; if (TIFFReadScanline(in, scanline, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); - status = 0; + "Error, can't read scanline %lu", + (unsigned long) row); + status = 0; goto done; } while (n-- > 0) @@ -1197,7 +1304,8 @@ done: DECLAREreadFunc(readContigTilesIntoBuffer) { int status = 1; - tdata_t tilebuf = _TIFFmalloc(TIFFTileSize(in)); + tsize_t tilesize = TIFFTileSize(in); + tdata_t tilebuf; uint32 imagew = TIFFScanlineSize(in); uint32 tilew = TIFFTileRowSize(in); int iskew = imagew - tilew; @@ -1206,8 +1314,10 @@ DECLAREreadFunc(readContigTilesIntoBuffer) uint32 row; (void) spp; + tilebuf = _TIFFmalloc(tilesize); if (tilebuf == 0) return 0; + _TIFFmemset(tilebuf, 0, tilesize); (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); @@ -1220,9 +1330,9 @@ DECLAREreadFunc(readContigTilesIntoBuffer) if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at %lu %lu", - (unsigned long) col, - (unsigned long) row); + "Error, can't read tile at %lu %lu", + (unsigned long) col, + (unsigned long) row); status = 0; goto done; } @@ -1230,12 +1340,12 @@ DECLAREreadFunc(readContigTilesIntoBuffer) uint32 width = imagew - colb; uint32 oskew = tilew - width; cpStripToTile(bufp + colb, - tilebuf, nrow, width, - oskew + iskew, oskew ); + tilebuf, nrow, width, + oskew + iskew, oskew ); } else cpStripToTile(bufp + colb, - tilebuf, nrow, tilew, - iskew, 0); + tilebuf, nrow, tilew, + iskew, 0); colb += tilew; } bufp += imagew * nrow; @@ -1251,19 +1361,22 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) uint32 imagew = TIFFRasterScanlineSize(in); uint32 tilew = TIFFTileRowSize(in); int iskew = imagew - tilew*spp; - tdata_t tilebuf = _TIFFmalloc(TIFFTileSize(in)); + tsize_t tilesize = TIFFTileSize(in); + tdata_t tilebuf; uint8* bufp = (uint8*) buf; uint32 tw, tl; uint32 row; - uint16 bps, bytes_per_sample; + uint16 bps, bytes_per_sample; + tilebuf = _TIFFmalloc(tilesize); if (tilebuf == 0) return 0; + _TIFFmemset(tilebuf, 0, tilesize); (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); - assert( bps % 8 == 0 ); - bytes_per_sample = bps/8; + assert( bps % 8 == 0 ); + bytes_per_sample = bps/8; for (row = 0; row < imagelength; row += tl) { uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; @@ -1277,11 +1390,11 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at %lu %lu, " - "sample %lu", - (unsigned long) col, - (unsigned long) row, - (unsigned long) s); + "Error, can't read tile at %lu %lu, " + "sample %lu", + (unsigned long) col, + (unsigned long) row, + (unsigned long) s); status = 0; goto done; } @@ -1293,18 +1406,18 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) uint32 width = imagew - colb; int oskew = tilew*spp - width; cpSeparateBufToContigBuf( - bufp+colb+s*bytes_per_sample, + bufp+colb+s*bytes_per_sample, tilebuf, nrow, - width/(spp*bytes_per_sample), + width/(spp*bytes_per_sample), oskew + iskew, - oskew/spp, spp, - bytes_per_sample); + oskew/spp, spp, + bytes_per_sample); } else cpSeparateBufToContigBuf( - bufp+colb+s*bytes_per_sample, + bufp+colb+s*bytes_per_sample, tilebuf, nrow, tw, iskew, 0, spp, - bytes_per_sample); + bytes_per_sample); } colb += tilew*spp; } @@ -1328,7 +1441,7 @@ DECLAREwriteFunc(writeBufferToContigStrips) tsize_t stripsize = TIFFVStripSize(out, nrows); if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %lu", strip - 1); + "Error, can't write strip %u", strip - 1); return 0; } buf += stripsize; @@ -1340,12 +1453,15 @@ DECLAREwriteFunc(writeBufferToSeparateStrips) { uint32 rowsize = imagewidth * spp; uint32 rowsperstrip; - tdata_t obuf = _TIFFmalloc(TIFFStripSize(out)); + tsize_t stripsize = TIFFStripSize(out); + tdata_t obuf; tstrip_t strip = 0; tsample_t s; + obuf = _TIFFmalloc(stripsize); if (obuf == NULL) return (0); + _TIFFmemset(obuf, 0, stripsize); (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); for (s = 0; s < spp; s++) { uint32 row; @@ -1355,12 +1471,12 @@ DECLAREwriteFunc(writeBufferToSeparateStrips) tsize_t stripsize = TIFFVStripSize(out, nrows); cpContigBufToSeparateBuf( - obuf, (uint8*) buf + row*rowsize + s, + obuf, (uint8*) buf + row*rowsize + s, nrows, imagewidth, 0, 0, spp, 1); if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %lu", - strip - 1); + "Error, can't write strip %u", + strip - 1); _TIFFfree(obuf); return 0; } @@ -1376,14 +1492,18 @@ DECLAREwriteFunc(writeBufferToContigTiles) uint32 imagew = TIFFScanlineSize(out); uint32 tilew = TIFFTileRowSize(out); int iskew = imagew - tilew; - tdata_t obuf = _TIFFmalloc(TIFFTileSize(out)); + tsize_t tilesize = TIFFTileSize(out); + tdata_t obuf; uint8* bufp = (uint8*) buf; uint32 tl, tw; uint32 row; (void) spp; + + obuf = _TIFFmalloc(TIFFTileSize(out)); if (obuf == NULL) return 0; + _TIFFmemset(obuf, 0, tilesize); (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); for (row = 0; row < imagelength; row += tilelength) { @@ -1406,9 +1526,9 @@ DECLAREwriteFunc(writeBufferToContigTiles) 0, iskew); if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write tile at %lu %lu", - (unsigned long) col, - (unsigned long) row); + "Error, can't write tile at %lu %lu", + (unsigned long) col, + (unsigned long) row); _TIFFfree(obuf); return 0; } @@ -1426,20 +1546,23 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) tsize_t tilew = TIFFTileRowSize(out); uint32 iimagew = TIFFRasterScanlineSize(out); int iskew = iimagew - tilew*spp; - tdata_t obuf = _TIFFmalloc(TIFFTileSize(out)); + tsize_t tilesize = TIFFTileSize(out); + tdata_t obuf; uint8* bufp = (uint8*) buf; uint32 tl, tw; uint32 row; - uint16 bps, bytes_per_sample; + uint16 bps, bytes_per_sample; + obuf = _TIFFmalloc(TIFFTileSize(out)); if (obuf == NULL) return 0; + _TIFFmemset(obuf, 0, tilesize); (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); - assert( bps % 8 == 0 ); - bytes_per_sample = bps/8; - + assert( bps % 8 == 0 ); + bytes_per_sample = bps/8; + for (row = 0; row < imagelength; row += tl) { uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; uint32 colb = 0; @@ -1460,20 +1583,20 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) bufp + (colb*spp) + s, nrow, width/bytes_per_sample, oskew, (oskew*spp)+iskew, spp, - bytes_per_sample); + bytes_per_sample); } else cpContigBufToSeparateBuf(obuf, bufp + (colb*spp) + s, nrow, tilewidth, 0, iskew, spp, - bytes_per_sample); + bytes_per_sample); if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write tile at %lu %lu " - "sample %lu", - (unsigned long) col, - (unsigned long) row, - (unsigned long) s); + "Error, can't write tile at %lu %lu " + "sample %lu", + (unsigned long) col, + (unsigned long) row, + (unsigned long) s); _TIFFfree(obuf); return 0; } @@ -1631,93 +1754,93 @@ pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel) (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv); if (shortv != config && bitspersample != 8 && samplesperpixel > 1) { fprintf(stderr, -"%s: Cannot handle different planar configuration w/ bits/sample != 8\n", + "%s: Cannot handle different planar configuration w/ bits/sample != 8\n", TIFFFileName(in)); return (NULL); } TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &l); - if (!(TIFFIsTiled(out) || TIFFIsTiled(in))) { - uint32 irps = (uint32) -1L; - TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps); - /* if biased, force decoded copying to allow image subtraction */ - bychunk = !bias && (rowsperstrip == irps); + if (!(TIFFIsTiled(out) || TIFFIsTiled(in))) { + uint32 irps = (uint32) -1L; + TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps); + /* if biased, force decoded copying to allow image subtraction */ + bychunk = !bias && (rowsperstrip == irps); }else{ /* either in or out is tiled */ - if (bias) { - fprintf(stderr, -"%s: Cannot handle tiled configuration w/bias image\n", - TIFFFileName(in)); - return (NULL); - } - if (TIFFIsTiled(out)) { - if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw)) - tw = w; - if (!TIFFGetField(in, TIFFTAG_TILELENGTH, &tl)) - tl = l; - bychunk = (tw == tilewidth && tl == tilelength); - } else { /* out's not, so in must be tiled */ - TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); - bychunk = (tw == w && tl == rowsperstrip); - } + if (bias) { + fprintf(stderr, + "%s: Cannot handle tiled configuration w/bias image\n", + TIFFFileName(in)); + return (NULL); + } + if (TIFFIsTiled(out)) { + if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw)) + tw = w; + if (!TIFFGetField(in, TIFFTAG_TILELENGTH, &tl)) + tl = l; + bychunk = (tw == tilewidth && tl == tilelength); + } else { /* out's not, so in must be tiled */ + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + bychunk = (tw == w && tl == rowsperstrip); + } } #define T 1 #define F 0 #define pack(a,b,c,d,e) ((long)(((a)<<11)|((b)<<3)|((c)<<2)|((d)<<1)|(e))) switch(pack(shortv,config,TIFFIsTiled(in),TIFFIsTiled(out),bychunk)) { -/* Strips -> Tiles */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,T): - return cpContigStrips2ContigTiles; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,T): - return cpContigStrips2SeparateTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,T): - return cpSeparateStrips2ContigTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,T): - return cpSeparateStrips2SeparateTiles; -/* Tiles -> Tiles */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,T): - return cpContigTiles2ContigTiles; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,T): - return cpContigTiles2SeparateTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,T): - return cpSeparateTiles2ContigTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,T): - return cpSeparateTiles2SeparateTiles; -/* Tiles -> Strips */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,T): - return cpContigTiles2ContigStrips; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,T): - return cpContigTiles2SeparateStrips; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,T): - return cpSeparateTiles2ContigStrips; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,T): - return cpSeparateTiles2SeparateStrips; -/* Strips -> Strips */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,F): - return bias ? cpBiasedContig2Contig : cpContig2ContigByRow; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,T): - return cpDecodedStrips; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,T): - return cpContig2SeparateByRow; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,T): - return cpSeparate2ContigByRow; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,T): - return cpSeparate2SeparateByRow; + /* Strips -> Tiles */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,T): + return cpContigStrips2ContigTiles; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,T): + return cpContigStrips2SeparateTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,T): + return cpSeparateStrips2ContigTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,T): + return cpSeparateStrips2SeparateTiles; + /* Tiles -> Tiles */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,T): + return cpContigTiles2ContigTiles; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,T): + return cpContigTiles2SeparateTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,T): + return cpSeparateTiles2ContigTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,T): + return cpSeparateTiles2SeparateTiles; + /* Tiles -> Strips */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,T): + return cpContigTiles2ContigStrips; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,T): + return cpContigTiles2SeparateStrips; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,T): + return cpSeparateTiles2ContigStrips; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,T): + return cpSeparateTiles2SeparateStrips; + /* Strips -> Strips */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,F): + return bias ? cpBiasedContig2Contig : cpContig2ContigByRow; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,T): + return cpDecodedStrips; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,T): + return cpContig2SeparateByRow; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,T): + return cpSeparate2ContigByRow; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,T): + return cpSeparate2SeparateByRow; } #undef pack #undef F @@ -1728,3 +1851,10 @@ pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-4.0.2/tools/tiffcrop.c b/libs/tiff-4.0.2/tools/tiffcrop.c new file mode 100644 index 0000000000..9cd5d86fe7 --- /dev/null +++ b/libs/tiff-4.0.2/tools/tiffcrop.c @@ -0,0 +1,9066 @@ +/* $Id: tiffcrop.c,v 1.20 2010-12-14 02:03:24 faxguy Exp $ */ + +/* tiffcrop.c -- a port of tiffcp.c extended to include manipulations of + * the image data through additional options listed below + * + * Original code: + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * Additions (c) Richard Nolde 2006-2010 + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS OR ANY OTHER COPYRIGHT + * HOLDERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL + * DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE + * OR PERFORMANCE OF THIS SOFTWARE. + * + * Some portions of the current code are derived from tiffcp, primarly in + * the areas of lowlevel reading and writing of TAGS, scanlines and tiles though + * some of the original functions have been extended to support arbitrary bit + * depths. These functions are presented at the top of this file. + * + * Add support for the options below to extract sections of image(s) + * and to modify the whole image or selected portions of each image by + * rotations, mirroring, and colorscale/colormap inversion of selected + * types of TIFF images when appropriate. Some color model dependent + * functions are restricted to bilevel or 8 bit per sample data. + * See the man page for the full explanations. + * + * New Options: + * -h Display the syntax guide. + * -v Report the version and last build date for tiffcrop and libtiff. + * -z x1,y1,x2,y2:x3,y3,x4,y4:..xN,yN,xN + 1, yN + 1 + * Specify a series of coordinates to define rectangular + * regions by the top left and lower right corners. + * -e c|d|i|m|s export mode for images and selections from input images + * combined All images and selections are written to a single file (default) + * with multiple selections from one image combined into a single image + * divided All images and selections are written to a single file + * with each selection from one image written to a new image + * image Each input image is written to a new file (numeric filename sequence) + * with multiple selections from the image combined into one image + * multiple Each input image is written to a new file (numeric filename sequence) + * with each selection from the image written to a new image + * separated Individual selections from each image are written to separate files + * -U units [in, cm, px ] inches, centimeters or pixels + * -H # Set horizontal resolution of output images to # + * -V # Set vertical resolution of output images to # + * -J # Horizontal margin of output page to # expressed in current + * units when sectioning image into columns x rows + * using the -S cols:rows option. + * -K # Vertical margin of output page to # expressed in current + * units when sectioning image into columns x rows + * using the -S cols:rows option. + * -X # Horizontal dimension of region to extract expressed in current + * units + * -Y # Vertical dimension of region to extract expressed in current + * units + * -O orient Orientation for output image, portrait, landscape, auto + * -P page Page size for output image segments, eg letter, legal, tabloid, + * etc. + * -S cols:rows Divide the image into equal sized segments using cols across + * and rows down + * -E t|l|r|b Edge to use as origin + * -m #,#,#,# Margins from edges for selection: top, left, bottom, right + * (commas separated) + * -Z #:#,#:# Zones of the image designated as zone X of Y, + * eg 1:3 would be first of three equal portions measured + * from reference edge + * -N odd|even|#,#-#,#|last + * Select sequences and/or ranges of images within file + * to process. The words odd or even may be used to specify + * all odd or even numbered images the word last may be used + * in place of a number in the sequence to indicate the final + * image in the file without knowing how many images there are. + * -R # Rotate image or crop selection by 90,180,or 270 degrees + * clockwise + * -F h|v Flip (mirror) image or crop selection horizontally + * or vertically + * -I [black|white|data|both] + * Invert color space, eg dark to light for bilevel and grayscale images + * If argument is white or black, set the PHOTOMETRIC_INTERPRETATION + * tag to MinIsBlack or MinIsWhite without altering the image data + * If the argument is data or both, the image data are modified: + * both inverts the data and the PHOTOMETRIC_INTERPRETATION tag, + * data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag + * -D input:,output:,format:,level:N,debug:N + * Dump raw data for input and/or output images to individual files + * in raw (binary) format or text (ASCII) representing binary data + * as strings of 1s and 0s. The filename arguments are used as stems + * from which individual files are created for each image. Text format + * includes annotations for image parameters and scanline info. Level + * selects which functions dump data, with higher numbers selecting + * lower level, scanline level routines. Debug reports a limited set + * of messages to monitor progess without enabling dump logs. + */ + +static char tiffcrop_version_id[] = "2.4"; +static char tiffcrop_rev_date[] = "12-13-2010"; + +#include "tif_config.h" +#include "tiffiop.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef HAVE_STDINT_H +# include +#endif + +#ifndef HAVE_GETOPT +extern int getopt(int, char**, char*); +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#include "tiffio.h" + +#if defined(VMS) +# define unlink delete +#endif + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +#ifndef streq +#define streq(a,b) (strcmp((a),(b)) == 0) +#endif +#define strneq(a,b,n) (strncmp((a),(b),(n)) == 0) + +#define TRUE 1 +#define FALSE 0 + +#ifndef TIFFhowmany +#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) +#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +#endif + +/* + * Definitions and data structures required to support cropping and image + * manipulations. + */ + +#define EDGE_TOP 1 +#define EDGE_LEFT 2 +#define EDGE_BOTTOM 3 +#define EDGE_RIGHT 4 +#define EDGE_CENTER 5 + +#define MIRROR_HORIZ 1 +#define MIRROR_VERT 2 +#define MIRROR_BOTH 3 +#define ROTATECW_90 8 +#define ROTATECW_180 16 +#define ROTATECW_270 32 +#define ROTATE_ANY ROTATECW_90 || ROTATECW_180 || ROTATECW_270 + +#define CROP_NONE 0 +#define CROP_MARGINS 1 +#define CROP_WIDTH 2 +#define CROP_LENGTH 4 +#define CROP_ZONES 8 +#define CROP_REGIONS 16 +#define CROP_ROTATE 32 +#define CROP_MIRROR 64 +#define CROP_INVERT 128 + +/* Modes for writing out images and selections */ +#define ONE_FILE_COMPOSITE 0 /* One file, sections combined sections */ +#define ONE_FILE_SEPARATED 1 /* One file, sections to new IFDs */ +#define FILE_PER_IMAGE_COMPOSITE 2 /* One file per image, combined sections */ +#define FILE_PER_IMAGE_SEPARATED 3 /* One file per input image */ +#define FILE_PER_SELECTION 4 /* One file per selection */ + +#define COMPOSITE_IMAGES 0 /* Selections combined into one image */ +#define SEPARATED_IMAGES 1 /* Selections saved to separate images */ + +#define STRIP 1 +#define TILE 2 + +#define MAX_REGIONS 8 /* number of regions to extract from a single page */ +#define MAX_OUTBUFFS 8 /* must match larger of zones or regions */ +#define MAX_SECTIONS 32 /* number of sections per page to write to output */ +#define MAX_IMAGES 2048 /* number of images in descrete list, not in the file */ +#define MAX_SAMPLES 8 /* maximum number of samples per pixel supported */ +#define MAX_BITS_PER_SAMPLE 64 /* maximum bit depth supported */ +#define MAX_EXPORT_PAGES 999999 /* maximum number of export pages per file */ + +#define DUMP_NONE 0 +#define DUMP_TEXT 1 +#define DUMP_RAW 2 + +/* Offsets into buffer for margins and fixed width and length segments */ +struct offset { + uint32 tmargin; + uint32 lmargin; + uint32 bmargin; + uint32 rmargin; + uint32 crop_width; + uint32 crop_length; + uint32 startx; + uint32 endx; + uint32 starty; + uint32 endy; +}; + +/* Description of a zone within the image. Position 1 of 3 zones would be + * the first third of the image. These are computed after margins and + * width/length requests are applied so that you can extract multiple + * zones from within a larger region for OCR or barcode recognition. + */ + +struct buffinfo { + uint32 size; /* size of this buffer */ + unsigned char *buffer; /* address of the allocated buffer */ +}; + +struct zone { + int position; /* ordinal of segment to be extracted */ + int total; /* total equal sized divisions of crop area */ + }; + +struct pageseg { + uint32 x1; /* index of left edge */ + uint32 x2; /* index of right edge */ + uint32 y1; /* index of top edge */ + uint32 y2; /* index of bottom edge */ + int position; /* ordinal of segment to be extracted */ + int total; /* total equal sized divisions of crop area */ + uint32 buffsize; /* size of buffer needed to hold the cropped zone */ +}; + +struct coordpairs { + double X1; /* index of left edge in current units */ + double X2; /* index of right edge in current units */ + double Y1; /* index of top edge in current units */ + double Y2; /* index of bottom edge in current units */ +}; + +struct region { + uint32 x1; /* pixel offset of left edge */ + uint32 x2; /* pixel offset of right edge */ + uint32 y1; /* pixel offset of top edge */ + uint32 y2; /* picel offset of bottom edge */ + uint32 width; /* width in pixels */ + uint32 length; /* length in pixels */ + uint32 buffsize; /* size of buffer needed to hold the cropped region */ + unsigned char *buffptr; /* address of start of the region */ +}; + +/* Cropping parameters from command line and image data + * Note: This should be renamed to proc_opts and expanded to include all current globals + * if possible, but each function that accesses global variables will have to be redone. + */ +struct crop_mask { + double width; /* Selection width for master crop region in requested units */ + double length; /* Selection length for master crop region in requesed units */ + double margins[4]; /* Top, left, bottom, right margins */ + float xres; /* Horizontal resolution read from image*/ + float yres; /* Vertical resolution read from image */ + uint32 combined_width; /* Width of combined cropped zones */ + uint32 combined_length; /* Length of combined cropped zones */ + uint32 bufftotal; /* Size of buffer needed to hold all the cropped region */ + uint16 img_mode; /* Composite or separate images created from zones or regions */ + uint16 exp_mode; /* Export input images or selections to one or more files */ + uint16 crop_mode; /* Crop options to be applied */ + uint16 res_unit; /* Resolution unit for margins and selections */ + uint16 edge_ref; /* Reference edge for sections extraction and combination */ + uint16 rotation; /* Clockwise rotation of the extracted region or image */ + uint16 mirror; /* Mirror extracted region or image horizontally or vertically */ + uint16 invert; /* Invert the color map of image or region */ + uint16 photometric; /* Status of photometric interpretation for inverted image */ + uint16 selections; /* Number of regions or zones selected */ + uint16 regions; /* Number of regions delimited by corner coordinates */ + struct region regionlist[MAX_REGIONS]; /* Regions within page or master crop region */ + uint16 zones; /* Number of zones delimited by Ordinal:Total requested */ + struct zone zonelist[MAX_REGIONS]; /* Zones indices to define a region */ + struct coordpairs corners[MAX_REGIONS]; /* Coordinates of upper left and lower right corner */ +}; + +#define MAX_PAPERNAMES 49 +#define MAX_PAPERNAME_LENGTH 15 +#define DEFAULT_RESUNIT RESUNIT_INCH +#define DEFAULT_PAGE_HEIGHT 14.0 +#define DEFAULT_PAGE_WIDTH 8.5 +#define DEFAULT_RESOLUTION 300 +#define DEFAULT_PAPER_SIZE "legal" + +#define ORIENTATION_NONE 0 +#define ORIENTATION_PORTRAIT 1 +#define ORIENTATION_LANDSCAPE 2 +#define ORIENTATION_SEASCAPE 4 +#define ORIENTATION_AUTO 16 + +#define PAGE_MODE_NONE 0 +#define PAGE_MODE_RESOLUTION 1 +#define PAGE_MODE_PAPERSIZE 2 +#define PAGE_MODE_MARGINS 4 +#define PAGE_MODE_ROWSCOLS 8 + +#define INVERT_DATA_ONLY 10 +#define INVERT_DATA_AND_TAG 11 + +struct paperdef { + char name[MAX_PAPERNAME_LENGTH]; + double width; + double length; + double asratio; + }; + +/* European page sizes corrected from update sent by + * thomas . jarosch @ intra2net . com on 5/7/2010 + * Paper Size Width Length Aspect Ratio */ +struct paperdef PaperTable[MAX_PAPERNAMES] = { + {"default", 8.500, 14.000, 0.607}, + {"pa4", 8.264, 11.000, 0.751}, + {"letter", 8.500, 11.000, 0.773}, + {"legal", 8.500, 14.000, 0.607}, + {"half-letter", 8.500, 5.514, 1.542}, + {"executive", 7.264, 10.528, 0.690}, + {"tabloid", 11.000, 17.000, 0.647}, + {"11x17", 11.000, 17.000, 0.647}, + {"ledger", 17.000, 11.000, 1.545}, + {"archa", 9.000, 12.000, 0.750}, + {"archb", 12.000, 18.000, 0.667}, + {"archc", 18.000, 24.000, 0.750}, + {"archd", 24.000, 36.000, 0.667}, + {"arche", 36.000, 48.000, 0.750}, + {"csheet", 17.000, 22.000, 0.773}, + {"dsheet", 22.000, 34.000, 0.647}, + {"esheet", 34.000, 44.000, 0.773}, + {"superb", 11.708, 17.042, 0.687}, + {"commercial", 4.139, 9.528, 0.434}, + {"monarch", 3.889, 7.528, 0.517}, + {"envelope-dl", 4.333, 8.681, 0.499}, + {"envelope-c5", 6.389, 9.028, 0.708}, + {"europostcard", 4.139, 5.833, 0.710}, + {"a0", 33.110, 46.811, 0.707}, + {"a1", 23.386, 33.110, 0.706}, + {"a2", 16.535, 23.386, 0.707}, + {"a3", 11.693, 16.535, 0.707}, + {"a4", 8.268, 11.693, 0.707}, + {"a5", 5.827, 8.268, 0.705}, + {"a6", 4.134, 5.827, 0.709}, + {"a7", 2.913, 4.134, 0.705}, + {"a8", 2.047, 2.913, 0.703}, + {"a9", 1.457, 2.047, 0.712}, + {"a10", 1.024, 1.457, 0.703}, + {"b0", 39.370, 55.669, 0.707}, + {"b1", 27.835, 39.370, 0.707}, + {"b2", 19.685, 27.835, 0.707}, + {"b3", 13.898, 19.685, 0.706}, + {"b4", 9.843, 13.898, 0.708}, + {"b5", 6.929, 9.843, 0.704}, + {"b6", 4.921, 6.929, 0.710}, + {"c0", 36.102, 51.063, 0.707}, + {"c1", 25.512, 36.102, 0.707}, + {"c2", 18.031, 25.512, 0.707}, + {"c3", 12.756, 18.031, 0.707}, + {"c4", 9.016, 12.756, 0.707}, + {"c5", 6.378, 9.016, 0.707}, + {"c6", 4.488, 6.378, 0.704}, + {"", 0.000, 0.000, 1.000} +}; + +/* Structure to define input image parameters */ +struct image_data { + float xres; + float yres; + uint32 width; + uint32 length; + uint16 res_unit; + uint16 bps; + uint16 spp; + uint16 planar; + uint16 photometric; + uint16 orientation; + uint16 compression; + uint16 adjustments; +}; + +/* Structure to define the output image modifiers */ +struct pagedef { + char name[16]; + double width; /* width in pixels */ + double length; /* length in pixels */ + double hmargin; /* margins to subtract from width of sections */ + double vmargin; /* margins to subtract from height of sections */ + double hres; /* horizontal resolution for output */ + double vres; /* vertical resolution for output */ + uint32 mode; /* bitmask of modifiers to page format */ + uint16 res_unit; /* resolution unit for output image */ + unsigned int rows; /* number of section rows */ + unsigned int cols; /* number of section cols */ + unsigned int orient; /* portrait, landscape, seascape, auto */ +}; + +struct dump_opts { + int debug; + int format; + int level; + char mode[4]; + char infilename[PATH_MAX + 1]; + char outfilename[PATH_MAX + 1]; + FILE *infile; + FILE *outfile; + }; + +/* globals */ +static int outtiled = -1; +static uint32 tilewidth = 0; +static uint32 tilelength = 0; + +static uint16 config = 0; +static uint16 compression = 0; +static uint16 predictor = 0; +static uint16 fillorder = 0; +static uint32 rowsperstrip = 0; +static uint32 g3opts = 0; +static int ignore = FALSE; /* if true, ignore read errors */ +static uint32 defg3opts = (uint32) -1; +static int quality = 100; /* JPEG quality */ +/* static int jpegcolormode = -1; was JPEGCOLORMODE_RGB; */ +static int jpegcolormode = JPEGCOLORMODE_RGB; +static uint16 defcompression = (uint16) -1; +static uint16 defpredictor = (uint16) -1; +static int pageNum = 0; +static int little_endian = 1; + +/* Functions adapted from tiffcp with additions or significant modifications */ +static int readContigStripsIntoBuffer (TIFF*, uint8*); +static int readSeparateStripsIntoBuffer (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int readContigTilesIntoBuffer (TIFF*, uint8*, uint32, uint32, uint32, uint32, tsample_t, uint16); +static int readSeparateTilesIntoBuffer (TIFF*, uint8*, uint32, uint32, uint32, uint32, tsample_t, uint16); +static int writeBufferToContigStrips (TIFF*, uint8*, uint32); +static int writeBufferToContigTiles (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int writeBufferToSeparateStrips (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int writeBufferToSeparateTiles (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int extractContigSamplesToBuffer (uint8 *, uint8 *, uint32, uint32, tsample_t, + uint16, uint16, struct dump_opts *); +static int processCompressOptions(char*); +static void usage(void); + +/* All other functions by Richard Nolde, not found in tiffcp */ +static void initImageData (struct image_data *); +static void initCropMasks (struct crop_mask *); +static void initPageSetup (struct pagedef *, struct pageseg *, struct buffinfo []); +static void initDumpOptions(struct dump_opts *); + +/* Command line and file naming functions */ +void process_command_opts (int, char *[], char *, char *, uint32 *, + uint16 *, uint16 *, uint32 *, uint32 *, uint32 *, + struct crop_mask *, struct pagedef *, + struct dump_opts *, + unsigned int *, unsigned int *); +static int update_output_file (TIFF **, char *, int, char *, unsigned int *); + + +/* * High level functions for whole image manipulation */ +static int get_page_geometry (char *, struct pagedef*); +static int computeInputPixelOffsets(struct crop_mask *, struct image_data *, + struct offset *); +static int computeOutputPixelOffsets (struct crop_mask *, struct image_data *, + struct pagedef *, struct pageseg *, + struct dump_opts *); +static int loadImage(TIFF *, struct image_data *, struct dump_opts *, unsigned char **); +static int correct_orientation(struct image_data *, unsigned char **); +static int getCropOffsets(struct image_data *, struct crop_mask *, struct dump_opts *); +static int processCropSelections(struct image_data *, struct crop_mask *, + unsigned char **, struct buffinfo []); +static int writeSelections(TIFF *, TIFF **, struct crop_mask *, struct image_data *, + struct dump_opts *, struct buffinfo [], + char *, char *, unsigned int*, unsigned int); + +/* Section functions */ +static int createImageSection(uint32, unsigned char **); +static int extractImageSection(struct image_data *, struct pageseg *, + unsigned char *, unsigned char *); +static int writeSingleSection(TIFF *, TIFF *, struct image_data *, + struct dump_opts *, uint32, uint32, + double, double, unsigned char *); +static int writeImageSections(TIFF *, TIFF *, struct image_data *, + struct pagedef *, struct pageseg *, + struct dump_opts *, unsigned char *, + unsigned char **); +/* Whole image functions */ +static int createCroppedImage(struct image_data *, struct crop_mask *, + unsigned char **, unsigned char **); +static int writeCroppedImage(TIFF *, TIFF *, struct image_data *image, + struct dump_opts * dump, + uint32, uint32, unsigned char *, int, int); + +/* Image manipulation functions */ +static int rotateContigSamples8bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateContigSamples16bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateContigSamples24bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateContigSamples32bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateImage(uint16, struct image_data *, uint32 *, uint32 *, + unsigned char **); +static int mirrorImage(uint16, uint16, uint16, uint32, uint32, + unsigned char *); +static int invertImage(uint16, uint16, uint16, uint32, uint32, + unsigned char *); + +/* Functions to reverse the sequence of samples in a scanline */ +static int reverseSamples8bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples16bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples24bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples32bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamplesBytes (uint16, uint16, uint32, uint8 *, uint8 *); + +/* Functions for manipulating individual samples in an image */ +static int extractSeparateRegion(struct image_data *, struct crop_mask *, + unsigned char *, unsigned char *, int); +static int extractCompositeRegions(struct image_data *, struct crop_mask *, + unsigned char *, unsigned char *); +static int extractContigSamples8bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamples16bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamples24bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamples32bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamplesBytes (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamplesShifted8bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesShifted16bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesShifted24bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesShifted32bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesToTileBuffer(uint8 *, uint8 *, uint32, uint32, + uint32, uint32, tsample_t, uint16, + uint16, uint16, struct dump_opts *); + +/* Functions to combine separate planes into interleaved planes */ +static int combineSeparateSamples8bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamples16bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamples24bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamples32bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamplesBytes (unsigned char *[], unsigned char *, + uint32, uint32, tsample_t, uint16, + FILE *, int, int); + +static int combineSeparateTileSamples8bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamples16bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamples24bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamples32bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamplesBytes (unsigned char *[], unsigned char *, + uint32, uint32, uint32, uint32, + tsample_t, uint16, FILE *, int, int); + +/* Dump functions for debugging */ +static void dump_info (FILE *, int, char *, char *, ...); +static int dump_data (FILE *, int, char *, unsigned char *, uint32); +static int dump_byte (FILE *, int, char *, unsigned char); +static int dump_short (FILE *, int, char *, uint16); +static int dump_long (FILE *, int, char *, uint32); +static int dump_wide (FILE *, int, char *, uint64); +static int dump_buffer (FILE *, int, uint32, uint32, uint32, unsigned char *); + +/* End function declarations */ +/* Functions derived in whole or in part from tiffcp */ +/* The following functions are taken largely intact from tiffcp */ + +static char* usage_info[] = { +"usage: tiffcrop [options] source1 ... sourceN destination", +"where options are:", +" -h Print this syntax listing", +" -v Print tiffcrop version identifier and last revision date", +" ", +" -a Append to output instead of overwriting", +" -d offset Set initial directory offset, counting first image as one, not zero", +" -p contig Pack samples contiguously (e.g. RGBRGB...)", +" -p separate Store samples separately (e.g. RRR...GGG...BBB...)", +" -s Write output in strips", +" -t Write output in tiles", +" -i Ignore read errors", +" ", +" -r # Make each strip have no more than # rows", +" -w # Set output tile width (pixels)", +" -l # Set output tile length (pixels)", +" ", +" -f lsb2msb Force lsb-to-msb FillOrder for output", +" -f msb2lsb Force msb-to-lsb FillOrder for output", +"", +" -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] Compress output with deflate encoding", +" -c jpeg[:opts] Compress output with JPEG encoding", +" -c packbits Compress output with packbits encoding", +" -c g3[:opts] Compress output with CCITT Group 3 encoding", +" -c g4 Compress output with CCITT Group 4 encoding", +" -c none Use no compression algorithm on output", +" ", +"Group 3 options:", +" 1d Use default CCITT Group 3 1D-encoding", +" 2d Use optional CCITT Group 3 2D-encoding", +" fill Byte-align EOL codes", +"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", +" ", +"JPEG options:", +" # Set compression quality level (0-100, default 100)", +" raw Output color image as raw YCbCr", +" rgb Output color image as RGB", +"For example, -c jpeg:rgb:50 to get JPEG-encoded RGB data with 50% comp. quality", +" ", +"LZW and deflate options:", +" # Set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +" ", +"Page and selection options:", +" -N odd|even|#,#-#,#|last sequences and ranges of images within file to process", +" The words odd or even may be used to specify all odd or even numbered images.", +" The word last may be used in place of a number in the sequence to indicate.", +" The final image in the file without knowing how many images there are.", +" Numbers are counted from one even though TIFF IFDs are counted from zero.", +" ", +" -E t|l|r|b edge to use as origin for width and length of crop region", +" -U units [in, cm, px ] inches, centimeters or pixels", +" ", +" -m #,#,#,# margins from edges for selection: top, left, bottom, right separated by commas", +" -X # horizontal dimension of region to extract expressed in current units", +" -Y # vertical dimension of region to extract expressed in current units", +" -Z #:#,#:# zones of the image designated as position X of Y,", +" eg 1:3 would be first of three equal portions measured from reference edge", +" -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1", +" regions of the image designated by upper left and lower right coordinates", +"", +"Export grouping options:", +" -e c|d|i|m|s export mode for images and selections from input images.", +" When exporting a composite image from multiple zones or regions", +" (combined and image modes), the selections must have equal sizes", +" for the axis perpendicular to the edge specified with -E.", +" c|combined All images and selections are written to a single file (default).", +" with multiple selections from one image combined into a single image.", +" d|divided All images and selections are written to a single file", +" with each selection from one image written to a new image.", +" i|image Each input image is written to a new file (numeric filename sequence)", +" with multiple selections from the image combined into one image.", +" m|multiple Each input image is written to a new file (numeric filename sequence)", +" with each selection from the image written to a new image.", +" s|separated Individual selections from each image are written to separate files.", +"", +"Output options:", +" -H # Set horizontal resolution of output images to #", +" -V # Set vertical resolution of output images to #", +" -J # Set horizontal margin of output page to # expressed in current units", +" when sectioning image into columns x rows using the -S cols:rows option", +" -K # Set verticalal margin of output page to # expressed in current units", +" when sectioning image into columns x rows using the -S cols:rows option", +" ", +" -O orient orientation for output image, portrait, landscape, auto", +" -P page page size for output image segments, eg letter, legal, tabloid, etc", +" use #.#x#.# to specify a custom page size in the currently defined units", +" where #.# represents the width and length", +" -S cols:rows Divide the image into equal sized segments using cols across and rows down.", +" ", +" -F hor|vert|both", +" flip (mirror) image or region horizontally, vertically, or both", +" -R # [90,180,or 270] degrees clockwise rotation of image or extracted region", +" -I [black|white|data|both]", +" invert color space, eg dark to light for bilevel and grayscale images", +" If argument is white or black, set the PHOTOMETRIC_INTERPRETATION ", +" tag to MinIsBlack or MinIsWhite without altering the image data", +" If the argument is data or both, the image data are modified:", +" both inverts the data and the PHOTOMETRIC_INTERPRETATION tag,", +" data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag", +" ", +"-D opt1:value1,opt2:value2,opt3:value3:opt4:value4", +" Debug/dump program progress and/or data to non-TIFF files.", +" Options include the following and must be joined as a comma", +" separate list. The use of this option is generally limited to", +" program debugging and development of future options.", +" ", +" debug:N Display limited program progress indicators where larger N", +" increase the level of detail. Note: Tiffcrop may be compiled with", +" -DDEVELMODE to enable additional very low level debug reporting.", +"", +" Format:txt|raw Format any logged data as ASCII text or raw binary ", +" values. ASCII text dumps include strings of ones and zeroes", +" representing the binary values in the image data plus identifying headers.", +" ", +" level:N Specify the level of detail presented in the dump files.", +" This can vary from dumps of the entire input or output image data to dumps", +" of data processed by specific functions. Current range of levels is 1 to 3.", +" ", +" input:full-path-to-directory/input-dumpname", +" ", +" output:full-path-to-directory/output-dumpnaem", +" ", +" When dump files are being written, each image will be written to a separate", +" file with the name built by adding a numeric sequence value to the dumpname", +" and an extension of .txt for ASCII dumps or .bin for binary dumps.", +" ", +" The four debug/dump options are independent, though it makes little sense to", +" specify a dump file without specifying a detail level.", +" ", +NULL +}; + +/* This function could be modified to pass starting sample offset + * and number of samples as args to select fewer than spp + * from input image. These would then be passed to individual + * extractContigSampleXX routines. + */ +static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, + uint32 imagelength, + uint32 imagewidth, + uint32 tw, uint32 tl, + tsample_t spp, uint16 bps) + { + int status = 1; + tsample_t sample = 0; + tsample_t count = spp; + uint32 row, col, trow; + uint32 nrow, ncol; + uint32 dst_rowsize, shift_width; + uint32 bytes_per_sample, bytes_per_pixel; + uint32 trailing_bits, prev_trailing_bits; + uint32 tile_rowsize = TIFFTileRowSize(in); + uint32 src_offset, dst_offset; + uint32 row_offset, col_offset; + uint8 *bufp = (uint8*) buf; + unsigned char *src = NULL; + unsigned char *dst = NULL; + tsize_t tbytes = 0, tile_buffsize = 0; + tsize_t tilesize = TIFFTileSize(in); + unsigned char *tilebuf = NULL; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + + tile_buffsize = tilesize; + + if (tilesize < (tsize_t)(tl * tile_rowsize)) + { +#ifdef DEBUG2 + TIFFError("readContigTilesIntoBuffer", + "Tilesize %lu is too small, using alternate calculation %u", + tilesize, tl * tile_rowsize); +#endif + tile_buffsize = tl * tile_rowsize; + } + + tilebuf = _TIFFmalloc(tile_buffsize); + if (tilebuf == 0) + return 0; + + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + for (row = 0; row < imagelength; row += tl) + { + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + tbytes = TIFFReadTile(in, tilebuf, col, row, 0, 0); + if (tbytes < tilesize && !ignore) + { + TIFFError(TIFFFileName(in), + "Error, can't read tile at row %lu col %lu, Read %lu bytes of %lu", + (unsigned long) col, (unsigned long) row, (unsigned long)tbytes, + (unsigned long)tilesize); + status = 0; + _TIFFfree(tilebuf); + return status; + } + + row_offset = row * dst_rowsize; + col_offset = ((col * bps * spp) + 7)/ 8; + bufp = buf + row_offset + col_offset; + + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + /* Each tile scanline will start on a byte boundary but it + * has to be merged into the scanline for the entire + * image buffer and the previous segment may not have + * ended on a byte boundary + */ + /* Optimization for common bit depths, all samples */ + if (((bps % 8) == 0) && (count == spp)) + { + for (trow = 0; trow < nrow; trow++) + { + src_offset = trow * tile_rowsize; + _TIFFmemcpy (bufp, tilebuf + src_offset, (ncol * spp * bps) / 8); + bufp += (imagewidth * bps * spp) / 8; + } + } + else + { + /* Bit depths not a multiple of 8 and/or extract fewer than spp samples */ + prev_trailing_bits = trailing_bits = 0; + trailing_bits = (ncol * bps * spp) % 8; + + /* for (trow = 0; tl < nrow; trow++) */ + for (trow = 0; trow < nrow; trow++) + { + src_offset = trow * tile_rowsize; + src = tilebuf + src_offset; + dst_offset = (row + trow) * dst_rowsize; + dst = buf + dst_offset + col_offset; + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, ncol, sample, + spp, bps, count, 0, ncol)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + default: TIFFError("readContigTilesIntoBuffer", "Unsupported bit depth %d", bps); + return 1; + } + } + prev_trailing_bits += trailing_bits; + if (prev_trailing_bits > 7) + prev_trailing_bits-= 8; + } + } + } + + _TIFFfree(tilebuf); + return status; + } + +static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, + uint32 imagelength, uint32 imagewidth, + uint32 tw, uint32 tl, + uint16 spp, uint16 bps) + { + int i, status = 1, sample; + int shift_width, bytes_per_pixel; + uint16 bytes_per_sample; + uint32 row, col; /* Current row and col of image */ + uint32 nrow, ncol; /* Number of rows and cols in current tile */ + uint32 row_offset, col_offset; /* Output buffer offsets */ + tsize_t tbytes = 0, tilesize = TIFFTileSize(in); + tsample_t s; + uint8* bufp = (uint8*)obuf; + unsigned char *srcbuffs[MAX_SAMPLES]; + unsigned char *tbuff = NULL; + + bytes_per_sample = (bps + 7) / 8; + + for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + { + srcbuffs[sample] = NULL; + tbuff = (unsigned char *)_TIFFmalloc(tilesize + 8); + if (!tbuff) + { + TIFFError ("readSeparateTilesIntoBuffer", + "Unable to allocate tile read buffer for sample %d", sample); + for (i = 0; i < sample; i++) + _TIFFfree (srcbuffs[i]); + return 0; + } + srcbuffs[sample] = tbuff; + } + /* Each tile contains only the data for a single plane + * arranged in scanlines of tw * bytes_per_sample bytes. + */ + for (row = 0; row < imagelength; row += tl) + { + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + for (s = 0; s < spp; s++) + { /* Read each plane of a tile set into srcbuffs[s] */ + tbytes = TIFFReadTile(in, srcbuffs[s], col, row, 0, s); + if (tbytes < 0 && !ignore) + { + TIFFError(TIFFFileName(in), + "Error, can't read tile for row %lu col %lu, " + "sample %lu", + (unsigned long) col, (unsigned long) row, + (unsigned long) s); + status = 0; + for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + { + tbuff = srcbuffs[sample]; + if (tbuff != NULL) + _TIFFfree(tbuff); + } + return status; + } + } + /* Tiles on the right edge may be padded out to tw + * which must be a multiple of 16. + * Ncol represents the visible (non padding) portion. + */ + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + row_offset = row * (((imagewidth * spp * bps) + 7) / 8); + col_offset = ((col * spp * bps) + 7) / 8; + bufp = obuf + row_offset + col_offset; + + if ((bps % 8) == 0) + { + if (combineSeparateTileSamplesBytes(srcbuffs, bufp, ncol, nrow, imagewidth, + tw, spp, bps, NULL, 0, 0)) + { + status = 0; + break; + } + } + else + { + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + switch (shift_width) + { + case 1: if (combineSeparateTileSamples8bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + case 2: if (combineSeparateTileSamples16bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + case 3: if (combineSeparateTileSamples24bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + case 4: + case 5: + case 6: + case 7: + case 8: if (combineSeparateTileSamples32bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %d", bps); + status = 0; + break; + } + } + } + } + + for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + { + tbuff = srcbuffs[sample]; + if (tbuff != NULL) + _TIFFfree(tbuff); + } + + return status; + } + +static int writeBufferToContigStrips(TIFF* out, uint8* buf, uint32 imagelength) + { + uint32 row, nrows, rowsperstrip; + tstrip_t strip = 0; + tsize_t stripsize; + + TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + for (row = 0; row < imagelength; row += rowsperstrip) + { + nrows = (row + rowsperstrip > imagelength) ? + imagelength - row : rowsperstrip; + stripsize = TIFFVStripSize(out, nrows); + if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) + { + TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + return 1; + } + buf += stripsize; + } + + return 0; + } + +/* Abandon plans to modify code so that plannar orientation separate images + * do not have all samples for each channel written before all samples + * for the next channel have been abandoned. + * Libtiff internals seem to depend on all data for a given sample + * being contiguous within a strip or tile when PLANAR_CONFIG is + * separate. All strips or tiles of a given plane are written + * before any strips or tiles of a different plane are stored. + */ +static int +writeBufferToSeparateStrips (TIFF* out, uint8* buf, + uint32 length, uint32 width, uint16 spp, + struct dump_opts *dump) + { + uint8 *src; + uint16 bps; + uint32 row, nrows, rowsize, rowsperstrip; + uint32 bytes_per_sample; + tsample_t s; + tstrip_t strip = 0; + tsize_t stripsize = TIFFStripSize(out); + tsize_t rowstripsize, scanlinesize = TIFFScanlineSize(out); + tsize_t total_bytes = 0; + tdata_t obuf; + + (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); + bytes_per_sample = (bps + 7) / 8; + rowsize = ((bps * spp * width) + 7) / 8; /* source has interleaved samples */ + rowstripsize = rowsperstrip * bytes_per_sample * (width + 1); + + obuf = _TIFFmalloc (rowstripsize); + if (obuf == NULL) + return 1; + + for (s = 0; s < spp; s++) + { + for (row = 0; row < length; row += rowsperstrip) + { + nrows = (row + rowsperstrip > length) ? length - row : rowsperstrip; + + stripsize = TIFFVStripSize(out, nrows); + src = buf + (row * rowsize); + total_bytes += stripsize; + memset (obuf, '\0', rowstripsize); + if (extractContigSamplesToBuffer(obuf, src, nrows, width, s, spp, bps, dump)) + { + _TIFFfree(obuf); + return 1; + } + if ((dump->outfile != NULL) && (dump->level == 1)) + { + dump_info(dump->outfile, dump->format,"", + "Sample %2d, Strip: %2d, bytes: %4d, Row %4d, bytes: %4d, Input offset: %6d", + s + 1, strip + 1, stripsize, row + 1, scanlinesize, src - buf); + dump_buffer(dump->outfile, dump->format, nrows, scanlinesize, row, obuf); + } + + if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) + { + TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + _TIFFfree(obuf); + return 1; + } + } + } + + _TIFFfree(obuf); + return 0; +} + +/* Extract all planes from contiguous buffer into a single tile buffer + * to be written out as a tile. + */ +static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, + uint32 imagewidth, tsample_t spp, + struct dump_opts* dump) + { + uint16 bps; + uint32 tl, tw; + uint32 row, col, nrow, ncol; + uint32 src_rowsize, col_offset; + uint32 tile_rowsize = TIFFTileRowSize(out); + uint8* bufp = (uint8*) buf; + tsize_t tile_buffsize = 0; + tsize_t tilesize = TIFFTileSize(out); + unsigned char *tilebuf = NULL; + + TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); + TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); + + tile_buffsize = tilesize; + if (tilesize < (tsize_t)(tl * tile_rowsize)) + { +#ifdef DEBUG2 + TIFFError("writeBufferToContigTiles", + "Tilesize %lu is too small, using alternate calculation %u", + tilesize, tl * tile_rowsize); +#endif + tile_buffsize = tl * tile_rowsize; + } + + tilebuf = _TIFFmalloc(tile_buffsize); + if (tilebuf == 0) + return 1; + + src_rowsize = ((imagewidth * spp * bps) + 7) / 8; + for (row = 0; row < imagelength; row += tl) + { + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + /* Calculate visible portion of tile. */ + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + col_offset = (((col * bps * spp) + 7) / 8); + bufp = buf + (row * src_rowsize) + col_offset; + if (extractContigSamplesToTileBuffer(tilebuf, bufp, nrow, ncol, imagewidth, + tw, 0, spp, spp, bps, dump) > 0) + { + TIFFError("writeBufferToContigTiles", + "Unable to extract data to tile for row %lu, col %lu", + (unsigned long) row, (unsigned long)col); + _TIFFfree(tilebuf); + return 1; + } + + if (TIFFWriteTile(out, tilebuf, col, row, 0, 0) < 0) + { + TIFFError("writeBufferToContigTiles", + "Cannot write tile at %lu %lu", + (unsigned long) col, (unsigned long) row); + _TIFFfree(tilebuf); + return 1; + } + } + } + _TIFFfree(tilebuf); + + return 0; + } /* end writeBufferToContigTiles */ + +/* Extract each plane from contiguous buffer into a single tile buffer + * to be written out as a tile. + */ +static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength, + uint32 imagewidth, tsample_t spp, + struct dump_opts * dump) + { + tdata_t obuf = _TIFFmalloc(TIFFTileSize(out)); + uint32 tl, tw; + uint32 row, col, nrow, ncol; + uint32 src_rowsize, col_offset; + uint16 bps; + tsample_t s; + uint8* bufp = (uint8*) buf; + + if (obuf == NULL) + return 1; + + TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); + TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); + src_rowsize = ((imagewidth * spp * bps) + 7) / 8; + + for (row = 0; row < imagelength; row += tl) + { + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + /* Calculate visible portion of tile. */ + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + col_offset = (((col * bps * spp) + 7) / 8); + bufp = buf + (row * src_rowsize) + col_offset; + + for (s = 0; s < spp; s++) + { + if (extractContigSamplesToTileBuffer(obuf, bufp, nrow, ncol, imagewidth, + tw, s, 1, spp, bps, dump) > 0) + { + TIFFError("writeBufferToSeparateTiles", + "Unable to extract data to tile for row %lu, col %lu sample %d", + (unsigned long) row, (unsigned long)col, (int)s); + _TIFFfree(obuf); + return 1; + } + + if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) + { + TIFFError("writeBufferToseparateTiles", + "Cannot write tile at %lu %lu sample %lu", + (unsigned long) col, (unsigned long) row, + (unsigned long) s); + _TIFFfree(obuf); + return 1; + } + } + } + } + _TIFFfree(obuf); + + return 0; + } /* end writeBufferToSeparateTiles */ + +static void +processG3Options(char* cp) +{ + if( (cp = strchr(cp, ':')) ) { + if (defg3opts == (uint32) -1) + defg3opts = 0; + do { + cp++; + if (strneq(cp, "1d", 2)) + defg3opts &= ~GROUP3OPT_2DENCODING; + else if (strneq(cp, "2d", 2)) + defg3opts |= GROUP3OPT_2DENCODING; + else if (strneq(cp, "fill", 4)) + defg3opts |= GROUP3OPT_FILLBITS; + else + usage(); + } while( (cp = strchr(cp, ':')) ); + } +} + +static int +processCompressOptions(char* opt) + { + char* cp = NULL; + + if (strneq(opt, "none",4)) + { + defcompression = COMPRESSION_NONE; + } + else if (streq(opt, "packbits")) + { + defcompression = COMPRESSION_PACKBITS; + } + else if (strneq(opt, "jpeg", 4)) + { + cp = strchr(opt, ':'); + defcompression = COMPRESSION_JPEG; + + while (cp) + { + if (isdigit((int)cp[1])) + quality = atoi(cp + 1); + else if (strneq(cp + 1, "raw", 3 )) + jpegcolormode = JPEGCOLORMODE_RAW; + else if (strneq(cp + 1, "rgb", 3 )) + jpegcolormode = JPEGCOLORMODE_RGB; + else + usage(); + cp = strchr(cp + 1, ':'); + } + } + else if (strneq(opt, "g3", 2)) + { + processG3Options(opt); + defcompression = COMPRESSION_CCITTFAX3; + } + else if (streq(opt, "g4")) + { + defcompression = COMPRESSION_CCITTFAX4; + } + else if (strneq(opt, "lzw", 3)) + { + cp = strchr(opt, ':'); + if (cp) + defpredictor = atoi(cp+1); + defcompression = COMPRESSION_LZW; + } + else if (strneq(opt, "zip", 3)) + { + cp = strchr(opt, ':'); + if (cp) + defpredictor = atoi(cp+1); + defcompression = COMPRESSION_ADOBE_DEFLATE; + } + else + return (0); + + return (1); + } + +static void +usage(void) + { + int i; + + fprintf(stderr, "\n%s\n", TIFFGetVersion()); + for (i = 0; usage_info[i] != NULL; i++) + fprintf(stderr, "%s\n", usage_info[i]); + exit(-1); + } + +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) +#define CopyField4(tag, v1, v2, v3, v4) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) + +static void +cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +{ + switch (type) { + case TIFF_SHORT: + if (count == 1) { + uint16 shortv; + CopyField(tag, shortv); + } else if (count == 2) { + uint16 shortv1, shortv2; + CopyField2(tag, shortv1, shortv2); + } else if (count == 4) { + uint16 *tr, *tg, *tb, *ta; + CopyField4(tag, tr, tg, tb, ta); + } else if (count == (uint16) -1) { + uint16 shortv1; + uint16* shortav; + CopyField2(tag, shortv1, shortav); + } + break; + case TIFF_LONG: + { uint32 longv; + CopyField(tag, longv); + } + break; + case TIFF_RATIONAL: + if (count == 1) { + float floatv; + CopyField(tag, floatv); + } else if (count == (uint16) -1) { + float* floatav; + CopyField(tag, floatav); + } + break; + case TIFF_ASCII: + { char* stringv; + CopyField(tag, stringv); + } + break; + case TIFF_DOUBLE: + if (count == 1) { + double doublev; + CopyField(tag, doublev); + } else if (count == (uint16) -1) { + double* doubleav; + CopyField(tag, doubleav); + } + break; + default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped", + tag, type); + } +} + +static struct cpTag { + uint16 tag; + uint16 count; + TIFFDataType type; +} tags[] = { + { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, + { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, + { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, + { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, + { TIFFTAG_MAKE, 1, TIFF_ASCII }, + { TIFFTAG_MODEL, 1, TIFF_ASCII }, + { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, (uint16) -1, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, +}; +#define NTAGS (sizeof (tags) / sizeof (tags[0])) + +#define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) + +/* Functions written by Richard Nolde, with exceptions noted. */ +void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 *dirnum, + uint16 *defconfig, uint16 *deffillorder, uint32 *deftilewidth, + uint32 *deftilelength, uint32 *defrowsperstrip, + struct crop_mask *crop_data, struct pagedef *page, + struct dump_opts *dump, + unsigned int *imagelist, unsigned int *image_count ) + { + int c, good_args = 0; + char *opt_offset = NULL; /* Position in string of value sought */ + char *opt_ptr = NULL; /* Pointer to next token in option set */ + char *sep = NULL; /* Pointer to a token separator */ + unsigned int i, j, start, end; + extern int optind; + extern char* optarg; + + *mp++ = 'w'; + *mp = '\0'; + while ((c = getopt(argc, argv, + "ac:d:e:f:hil:m:p:r:stvw:z:BCD:E:F:H:I:J:K:LMN:O:P:R:S:U:V:X:Y:Z:")) != -1) + { + good_args++; + switch (c) { + case 'a': mode[0] = 'a'; /* append to output */ + break; + case 'c': if (!processCompressOptions(optarg)) /* compression scheme */ + { + TIFFError ("Unknown compression option", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'd': start = strtoul(optarg, NULL, 0); /* initial IFD offset */ + if (start == 0) + { + TIFFError ("","Directory offset must be greater than zero"); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + *dirnum = start - 1; + break; + case 'e': switch (tolower(optarg[0])) /* image export modes*/ + { + case 'c': crop_data->exp_mode = ONE_FILE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Composite */ + case 'd': crop_data->exp_mode = ONE_FILE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Divided */ + case 'i': crop_data->exp_mode = FILE_PER_IMAGE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Image */ + case 'm': crop_data->exp_mode = FILE_PER_IMAGE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Multiple */ + case 's': crop_data->exp_mode = FILE_PER_SELECTION; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Sections */ + default: TIFFError ("Unknown export mode","%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'f': if (streq(optarg, "lsb2msb")) /* fill order */ + *deffillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + *deffillorder = FILLORDER_MSB2LSB; + else + { + TIFFError ("Unknown fill order", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'h': usage(); + break; + case 'i': ignore = TRUE; /* ignore errors */ + break; + case 'l': outtiled = TRUE; /* tile length */ + *deftilelength = atoi(optarg); + break; + case 'p': /* planar configuration */ + if (streq(optarg, "separate")) + *defconfig = PLANARCONFIG_SEPARATE; + else if (streq(optarg, "contig")) + *defconfig = PLANARCONFIG_CONTIG; + else + { + TIFFError ("Unkown planar configuration", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'r': /* rows/strip */ + *defrowsperstrip = atol(optarg); + break; + case 's': /* generate stripped output */ + outtiled = FALSE; + break; + case 't': /* generate tiled output */ + outtiled = TRUE; + break; + case 'v': TIFFError("Library Release", "%s", TIFFGetVersion()); + TIFFError ("Tiffcrop version", "%s, last updated: %s", + tiffcrop_version_id, tiffcrop_rev_date); + TIFFError ("Tiffcp code", "Copyright (c) 1988-1997 Sam Leffler"); + TIFFError (" ", "Copyright (c) 1991-1997 Silicon Graphics, Inc"); + TIFFError ("Tiffcrop additions", "Copyright (c) 2007-2010 Richard Nolde"); + exit (0); + break; + case 'w': /* tile width */ + outtiled = TRUE; + *deftilewidth = atoi(optarg); + break; + case 'z': /* regions of an image specified as x1,y1,x2,y2:x3,y3,x4,y4 etc */ + crop_data->crop_mode |= CROP_REGIONS; + for (i = 0, opt_ptr = strtok (optarg, ":"); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, ":")), i++) + { + crop_data->regions++; + if (sscanf(opt_ptr, "%lf,%lf,%lf,%lf", + &crop_data->corners[i].X1, &crop_data->corners[i].Y1, + &crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4) + { + TIFFError ("Unable to parse coordinates for region", "%d %s", i, optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + } + /* check for remaining elements over MAX_REGIONS */ + if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) + { + TIFFError ("Region list exceeds limit of", "%d regions %s", MAX_REGIONS, optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1);; + } + break; + /* options for file open modes */ + case 'B': *mp++ = 'b'; *mp = '\0'; + break; + case 'L': *mp++ = 'l'; *mp = '\0'; + break; + case 'M': *mp++ = 'm'; *mp = '\0'; + break; + case 'C': *mp++ = 'c'; *mp = '\0'; + break; + /* options for Debugging / data dump */ + case 'D': for (i = 0, opt_ptr = strtok (optarg, ","); + (opt_ptr != NULL); + (opt_ptr = strtok (NULL, ",")), i++) + { + opt_offset = strpbrk(opt_ptr, ":="); + if (opt_offset == NULL) + { + TIFFError("Invalid dump option", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + + *opt_offset = '\0'; + /* convert option to lowercase */ + end = strlen (opt_ptr); + for (i = 0; i < end; i++) + *(opt_ptr + i) = tolower(*(opt_ptr + i)); + /* Look for dump format specification */ + if (strncmp(opt_ptr, "for", 3) == 0) + { + /* convert value to lowercase */ + end = strlen (opt_offset + 1); + for (i = 1; i <= end; i++) + *(opt_offset + i) = tolower(*(opt_offset + i)); + /* check dump format value */ + if (strncmp (opt_offset + 1, "txt", 3) == 0) + { + dump->format = DUMP_TEXT; + strcpy (dump->mode, "w"); + } + else + { + if (strncmp(opt_offset + 1, "raw", 3) == 0) + { + dump->format = DUMP_RAW; + strcpy (dump->mode, "wb"); + } + else + { + TIFFError("parse_command_opts", "Unknown dump format %s", opt_offset + 1); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + } + } + else + { /* Look for dump level specification */ + if (strncmp (opt_ptr, "lev", 3) == 0) + dump->level = atoi(opt_offset + 1); + /* Look for input data dump file name */ + if (strncmp (opt_ptr, "in", 2) == 0) + { + strncpy (dump->infilename, opt_offset + 1, PATH_MAX - 20); + dump->infilename[PATH_MAX - 20] = '\0'; + } + /* Look for output data dump file name */ + if (strncmp (opt_ptr, "out", 3) == 0) + { + strncpy (dump->outfilename, opt_offset + 1, PATH_MAX - 20); + dump->outfilename[PATH_MAX - 20] = '\0'; + } + if (strncmp (opt_ptr, "deb", 3) == 0) + dump->debug = atoi(opt_offset + 1); + } + } + if ((strlen(dump->infilename)) || (strlen(dump->outfilename))) + { + if (dump->level == 1) + TIFFError("","Defaulting to dump level 1, no data."); + if (dump->format == DUMP_NONE) + { + TIFFError("", "You must specify a dump format for dump files"); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + } + break; + + /* image manipulation routine options */ + case 'm': /* margins to exclude from selection, uppercase M was already used */ + /* order of values must be TOP, LEFT, BOTTOM, RIGHT */ + crop_data->crop_mode |= CROP_MARGINS; + for (i = 0, opt_ptr = strtok (optarg, ",:"); + ((opt_ptr != NULL) && (i < 4)); + (opt_ptr = strtok (NULL, ",:")), i++) + { + crop_data->margins[i] = atof(opt_ptr); + } + break; + case 'E': /* edge reference */ + switch (tolower(optarg[0])) + { + case 't': crop_data->edge_ref = EDGE_TOP; + break; + case 'b': crop_data->edge_ref = EDGE_BOTTOM; + break; + case 'l': crop_data->edge_ref = EDGE_LEFT; + break; + case 'r': crop_data->edge_ref = EDGE_RIGHT; + break; + default: TIFFError ("Edge reference must be top, bottom, left, or right", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'F': /* flip eg mirror image or cropped segment, M was already used */ + crop_data->crop_mode |= CROP_MIRROR; + switch (tolower(optarg[0])) + { + case 'h': crop_data->mirror = MIRROR_HORIZ; + break; + case 'v': crop_data->mirror = MIRROR_VERT; + break; + case 'b': crop_data->mirror = MIRROR_BOTH; + break; + default: TIFFError ("Flip mode must be horiz, vert, or both", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'H': /* set horizontal resolution to new value */ + page->hres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'I': /* invert the color space, eg black to white */ + crop_data->crop_mode |= CROP_INVERT; + /* The PHOTOMETIC_INTERPRETATION tag may be updated */ + if (streq(optarg, "black")) + { + crop_data->photometric = PHOTOMETRIC_MINISBLACK; + continue; + } + if (streq(optarg, "white")) + { + crop_data->photometric = PHOTOMETRIC_MINISWHITE; + continue; + } + if (streq(optarg, "data")) + { + crop_data->photometric = INVERT_DATA_ONLY; + continue; + } + if (streq(optarg, "both")) + { + crop_data->photometric = INVERT_DATA_AND_TAG; + continue; + } + + TIFFError("Missing or unknown option for inverting PHOTOMETRIC_INTERPRETATION", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + break; + case 'J': /* horizontal margin for sectioned ouput pages */ + page->hmargin = atof(optarg); + page->mode |= PAGE_MODE_MARGINS; + break; + case 'K': /* vertical margin for sectioned ouput pages*/ + page->vmargin = atof(optarg); + page->mode |= PAGE_MODE_MARGINS; + break; + case 'N': /* list of images to process */ + for (i = 0, opt_ptr = strtok (optarg, ","); + ((opt_ptr != NULL) && (i < MAX_IMAGES)); + (opt_ptr = strtok (NULL, ","))) + { /* We do not know how many images are in file yet + * so we build a list to include the maximum allowed + * and follow it until we hit the end of the file. + * Image count is not accurate for odd, even, last + * so page numbers won't be valid either. + */ + if (streq(opt_ptr, "odd")) + { + for (j = 1; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = (MAX_IMAGES - 1) / 2; + break; + } + else + { + if (streq(opt_ptr, "even")) + { + for (j = 2; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = MAX_IMAGES / 2; + break; + } + else + { + if (streq(opt_ptr, "last")) + imagelist[i++] = MAX_IMAGES; + else /* single value between commas */ + { + sep = strpbrk(opt_ptr, ":-"); + if (!sep) + imagelist[i++] = atoi(opt_ptr); + else + { + *sep = '\0'; + start = atoi (opt_ptr); + if (!strcmp((sep + 1), "last")) + end = MAX_IMAGES; + else + end = atoi (sep + 1); + for (j = start; j <= end && j - start + i < MAX_IMAGES; j++) + imagelist[i++] = j; + } + } + } + } + } + *image_count = i; + break; + case 'O': /* page orientation */ + switch (tolower(optarg[0])) + { + case 'a': page->orient = ORIENTATION_AUTO; + break; + case 'p': page->orient = ORIENTATION_PORTRAIT; + break; + case 'l': page->orient = ORIENTATION_LANDSCAPE; + break; + default: TIFFError ("Orientation must be portrait, landscape, or auto.", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'P': /* page size selection */ + if (sscanf(optarg, "%lfx%lf", &page->width, &page->length) == 2) + { + strcpy (page->name, "Custom"); + page->mode |= PAGE_MODE_PAPERSIZE; + break; + } + if (get_page_geometry (optarg, page)) + { + if (!strcmp(optarg, "list")) + { + TIFFError("", "Name Width Length (in inches)"); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("", "%-15.15s %5.2f %5.2f", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (-1); + } + + TIFFError ("Invalid paper size", "%s", optarg); + TIFFError ("", "Select one of:"); + TIFFError("", "Name Width Length (in inches)"); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("", "%-15.15s %5.2f %5.2f", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (-1); + } + else + { + page->mode |= PAGE_MODE_PAPERSIZE; + } + break; + case 'R': /* rotate image or cropped segment */ + crop_data->crop_mode |= CROP_ROTATE; + switch (strtoul(optarg, NULL, 0)) + { + case 90: crop_data->rotation = (uint16)90; + break; + case 180: crop_data->rotation = (uint16)180; + break; + case 270: crop_data->rotation = (uint16)270; + break; + default: TIFFError ("Rotation must be 90, 180, or 270 degrees clockwise", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'S': /* subdivide into Cols:Rows sections, eg 3:2 would be 3 across and 2 down */ + sep = strpbrk(optarg, ",:"); + if (sep) + { + *sep = '\0'; + page->cols = atoi(optarg); + page->rows = atoi(sep +1); + } + else + { + page->cols = atoi(optarg); + page->rows = atoi(optarg); + } + if ((page->cols * page->rows) > MAX_SECTIONS) + { + TIFFError ("Limit for subdivisions, ie rows x columns, exceeded", "%d", MAX_SECTIONS); + exit (-1); + } + page->mode |= PAGE_MODE_ROWSCOLS; + break; + case 'U': /* units for measurements and offsets */ + if (streq(optarg, "in")) + { + crop_data->res_unit = RESUNIT_INCH; + page->res_unit = RESUNIT_INCH; + } + else if (streq(optarg, "cm")) + { + crop_data->res_unit = RESUNIT_CENTIMETER; + page->res_unit = RESUNIT_CENTIMETER; + } + else if (streq(optarg, "px")) + { + crop_data->res_unit = RESUNIT_NONE; + page->res_unit = RESUNIT_NONE; + } + else + { + TIFFError ("Illegal unit of measure","%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + } + break; + case 'V': /* set vertical resolution to new value */ + page->vres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'X': /* selection width */ + crop_data->crop_mode |= CROP_WIDTH; + crop_data->width = atof(optarg); + break; + case 'Y': /* selection length */ + crop_data->crop_mode |= CROP_LENGTH; + crop_data->length = atof(optarg); + break; + case 'Z': /* zones of an image X:Y read as zone X of Y */ + crop_data->crop_mode |= CROP_ZONES; + for (i = 0, opt_ptr = strtok (optarg, ","); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, ",")), i++) + { + crop_data->zones++; + opt_offset = strchr(opt_ptr, ':'); + *opt_offset = '\0'; + crop_data->zonelist[i].position = atoi(opt_ptr); + crop_data->zonelist[i].total = atoi(opt_offset + 1); + } + /* check for remaining elements over MAX_REGIONS */ + if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) + { + TIFFError("Zone list exceeds region limit", "%d", MAX_REGIONS); + exit (-1); + } + break; + case '?': TIFFError ("For valid options type", "tiffcrop -h"); + exit (-1); + /*NOTREACHED*/ + } + } + } /* end process_command_opts */ + +/* Start a new output file if one has not been previously opened or + * autoindex is set to non-zero. Update page and file counters + * so TIFFTAG PAGENUM will be correct in image. + */ +static int +update_output_file (TIFF **tiffout, char *mode, int autoindex, + char *outname, unsigned int *page) + { + static int findex = 0; /* file sequence indicator */ + char *sep; + char filenum[16]; + char export_ext[16]; + char exportname[PATH_MAX]; + + if (autoindex && (*tiffout != NULL)) + { + /* Close any export file that was previously opened */ + TIFFClose (*tiffout); + *tiffout = NULL; + } + + strcpy (export_ext, ".tiff"); + memset (exportname, '\0', PATH_MAX); + + /* Leave room for page number portion of the new filename */ + strncpy (exportname, outname, PATH_MAX - 16); + if (*tiffout == NULL) /* This is a new export file */ + { + if (autoindex) + { /* create a new filename for each export */ + findex++; + if ((sep = strstr(exportname, ".tif")) || (sep = strstr(exportname, ".TIF"))) + { + strncpy (export_ext, sep, 5); + *sep = '\0'; + } + else + strncpy (export_ext, ".tiff", 5); + export_ext[5] = '\0'; + + /* MAX_EXPORT_PAGES limited to 6 digits to prevent string overflow of pathname */ + if (findex > MAX_EXPORT_PAGES) + { + TIFFError("update_output_file", "Maximum of %d pages per file exceeded", MAX_EXPORT_PAGES); + return 1; + } + + sprintf (filenum, "-%03d%s", findex, export_ext); + filenum[14] = '\0'; + strncat (exportname, filenum, 15); + } + exportname[PATH_MAX - 1] = '\0'; + + *tiffout = TIFFOpen(exportname, mode); + if (*tiffout == NULL) + { + TIFFError("update_output_file", "Unable to open output file %s", exportname); + return 1; + } + *page = 0; + + return 0; + } + else + (*page)++; + + return 0; + } /* end update_output_file */ + + +int +main(int argc, char* argv[]) + { + extern int optind; + uint16 defconfig = (uint16) -1; + uint16 deffillorder = 0; + uint32 deftilewidth = (uint32) 0; + uint32 deftilelength = (uint32) 0; + uint32 defrowsperstrip = (uint32) 0; + uint32 dirnum = 0; + + TIFF *in = NULL; + TIFF *out = NULL; + char mode[10]; + char *mp = mode; + + /** RJN additions **/ + struct image_data image; /* Image parameters for one image */ + struct crop_mask crop; /* Cropping parameters for all images */ + struct pagedef page; /* Page definition for output pages */ + struct pageseg sections[MAX_SECTIONS]; /* Sections of one output page */ + struct buffinfo seg_buffs[MAX_SECTIONS]; /* Segment buffer sizes and pointers */ + struct dump_opts dump; /* Data dump options */ + unsigned char *read_buff = NULL; /* Input image data buffer */ + unsigned char *crop_buff = NULL; /* Crop area buffer */ + unsigned char *sect_buff = NULL; /* Image section buffer */ + unsigned char *sect_src = NULL; /* Image section buffer pointer */ + unsigned int imagelist[MAX_IMAGES + 1]; /* individually specified images */ + unsigned int image_count = 0; + unsigned int dump_images = 0; + unsigned int next_image = 0; + unsigned int next_page = 0; + unsigned int total_pages = 0; + unsigned int total_images = 0; + unsigned int end_of_input = FALSE; + int seg, length; + char temp_filename[PATH_MAX + 1]; + + little_endian = *((unsigned char *)&little_endian) & '1'; + + initImageData(&image); + initCropMasks(&crop); + initPageSetup(&page, sections, seg_buffs); + initDumpOptions(&dump); + + process_command_opts (argc, argv, mp, mode, &dirnum, &defconfig, + &deffillorder, &deftilewidth, &deftilelength, &defrowsperstrip, + &crop, &page, &dump, imagelist, &image_count); + + if (argc - optind < 2) + usage(); + + if ((argc - optind) == 2) + pageNum = -1; + else + total_images = 0; + /* read multiple input files and write to output file(s) */ + while (optind < argc - 1) + { + in = TIFFOpen (argv[optind], "r"); + if (in == NULL) + return (-3); + + /* If only one input file is specified, we can use directory count */ + total_images = TIFFNumberOfDirectories(in); + if (image_count == 0) + { + dirnum = 0; + total_pages = total_images; /* Only valid with single input file */ + } + else + { + dirnum = (tdir_t)(imagelist[next_image] - 1); + next_image++; + + /* Total pages only valid for enumerated list of pages not derived + * using odd, even, or last keywords. + */ + if (image_count > total_images) + image_count = total_images; + + total_pages = image_count; + } + + /* MAX_IMAGES is used for special case "last" in selection list */ + if (dirnum == (MAX_IMAGES - 1)) + dirnum = total_images - 1; + + if (dirnum > (total_images)) + { + TIFFError (TIFFFileName(in), + "Invalid image number %d, File contains only %d images", + (int)dirnum + 1, total_images); + if (out != NULL) + (void) TIFFClose(out); + return (1); + } + + if (dirnum != 0 && !TIFFSetDirectory(in, (tdir_t)dirnum)) + { + TIFFError(TIFFFileName(in),"Error, setting subdirectory at %d", dirnum); + if (out != NULL) + (void) TIFFClose(out); + return (1); + } + + end_of_input = FALSE; + while (end_of_input == FALSE) + { + config = defconfig; + compression = defcompression; + predictor = defpredictor; + fillorder = deffillorder; + rowsperstrip = defrowsperstrip; + tilewidth = deftilewidth; + tilelength = deftilelength; + g3opts = defg3opts; + + if (dump.format != DUMP_NONE) + { + /* manage input and/or output dump files here */ + dump_images++; + length = strlen(dump.infilename); + if (length > 0) + { + if (dump.infile != NULL) + fclose (dump.infile); + + /* dump.infilename is guaranteed to be NUL termimated and have 20 bytes + fewer than PATH_MAX */ + memset (temp_filename, '\0', PATH_MAX + 1); + sprintf (temp_filename, "%s-read-%03d.%s", dump.infilename, dump_images, + (dump.format == DUMP_TEXT) ? "txt" : "raw"); + if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL) + { + TIFFError ("Unable to open dump file for writing", "%s", temp_filename); + exit (-1); + } + dump_info(dump.infile, dump.format, "Reading image","%d from %s", + dump_images, TIFFFileName(in)); + } + length = strlen(dump.outfilename); + if (length > 0) + { + if (dump.outfile != NULL) + fclose (dump.outfile); + + /* dump.outfilename is guaranteed to be NUL termimated and have 20 bytes + fewer than PATH_MAX */ + memset (temp_filename, '\0', PATH_MAX + 1); + sprintf (temp_filename, "%s-write-%03d.%s", dump.outfilename, dump_images, + (dump.format == DUMP_TEXT) ? "txt" : "raw"); + if ((dump.outfile = fopen(temp_filename, dump.mode)) == NULL) + { + TIFFError ("Unable to open dump file for writing", "%s", temp_filename); + exit (-1); + } + dump_info(dump.outfile, dump.format, "Writing image","%d from %s", + dump_images, TIFFFileName(in)); + } + } + + if (dump.debug) + TIFFError("main", "Reading image %4d of %4d total pages.", dirnum + 1, total_pages); + + if (loadImage(in, &image, &dump, &read_buff)) + { + TIFFError("main", "Unable to load source image"); + exit (-1); + } + + /* Correct the image orientation if it was not ORIENTATION_TOPLEFT. + */ + if (image.adjustments != 0) + { + if (correct_orientation(&image, &read_buff)) + TIFFError("main", "Unable to correct image orientation"); + } + + if (getCropOffsets(&image, &crop, &dump)) + { + TIFFError("main", "Unable to define crop regions"); + exit (-1); + } + + if (crop.selections > 0) + { + if (processCropSelections(&image, &crop, &read_buff, seg_buffs)) + { + TIFFError("main", "Unable to process image selections"); + exit (-1); + } + } + else /* Single image segment without zones or regions */ + { + if (createCroppedImage(&image, &crop, &read_buff, &crop_buff)) + { + TIFFError("main", "Unable to create output image"); + exit (-1); + } + } + if (page.mode == PAGE_MODE_NONE) + { /* Whole image or sections not based on output page size */ + if (crop.selections > 0) + { + writeSelections(in, &out, &crop, &image, &dump, seg_buffs, + mp, argv[argc - 1], &next_page, total_pages); + } + else /* One file all images and sections */ + { + if (update_output_file (&out, mp, crop.exp_mode, argv[argc - 1], + &next_page)) + exit (1); + if (writeCroppedImage(in, out, &image, &dump,crop.combined_width, + crop.combined_length, crop_buff, next_page, total_pages)) + { + TIFFError("main", "Unable to write new image"); + exit (-1); + } + } + } + else + { + /* If we used a crop buffer, our data is there, otherwise it is + * in the read_buffer + */ + if (crop_buff != NULL) + sect_src = crop_buff; + else + sect_src = read_buff; + /* Break input image into pages or rows and columns */ + if (computeOutputPixelOffsets(&crop, &image, &page, sections, &dump)) + { + TIFFError("main", "Unable to compute output section data"); + exit (-1); + } + /* If there are multiple files on the command line, the final one is assumed + * to be the output filename into which the images are written. + */ + if (update_output_file (&out, mp, crop.exp_mode, argv[argc - 1], &next_page)) + exit (1); + + if (writeImageSections(in, out, &image, &page, sections, &dump, sect_src, §_buff)) + { + TIFFError("main", "Unable to write image sections"); + exit (-1); + } + } + + /* No image list specified, just read the next image */ + if (image_count == 0) + dirnum++; + else + { + dirnum = (tdir_t)(imagelist[next_image] - 1); + next_image++; + } + + if (dirnum == MAX_IMAGES - 1) + dirnum = TIFFNumberOfDirectories(in) - 1; + + if (!TIFFSetDirectory(in, (tdir_t)dirnum)) + end_of_input = TRUE; + } + TIFFClose(in); + optind++; + } + + /* If we did not use the read buffer as the crop buffer */ + if (read_buff) + _TIFFfree(read_buff); + + if (crop_buff) + _TIFFfree(crop_buff); + + if (sect_buff) + _TIFFfree(sect_buff); + + /* Clean up any segment buffers used for zones or regions */ + for (seg = 0; seg < crop.selections; seg++) + _TIFFfree (seg_buffs[seg].buffer); + + if (dump.format != DUMP_NONE) + { + if (dump.infile != NULL) + fclose (dump.infile); + + if (dump.outfile != NULL) + { + dump_info (dump.outfile, dump.format, "", "Completed run for %s", TIFFFileName(out)); + fclose (dump.outfile); + } + } + + TIFFClose(out); + + return (0); + } /* end main */ + + +/* Debugging functions */ +static int dump_data (FILE *dumpfile, int format, char *dump_tag, unsigned char *data, uint32 count) + { + int j, k; + uint32 i; + char dump_array[10]; + unsigned char bitset; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + if (format == DUMP_TEXT) + { + fprintf (dumpfile," %s ", dump_tag); + for (i = 0; i < count; i++) + { + for (j = 0, k = 7; j < 8; j++, k--) + { + bitset = (*(data + i)) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + } + dump_array[8] = '\0'; + fprintf (dumpfile," %s", dump_array); + } + fprintf (dumpfile,"\n"); + } + else + { + if ((fwrite (data, 1, count, dumpfile)) != count) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } + } + + return (0); + } + +static int dump_byte (FILE *dumpfile, int format, char *dump_tag, unsigned char data) + { + int j, k; + char dump_array[10]; + unsigned char bitset; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + if (format == DUMP_TEXT) + { + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 7; j < 8; j++, k--) + { + bitset = data & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + } + dump_array[8] = '\0'; + fprintf (dumpfile," %s\n", dump_array); + } + else + { + if ((fwrite (&data, 1, 1, dumpfile)) != 1) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } + } + + return (0); + } + +static int dump_short (FILE *dumpfile, int format, char *dump_tag, uint16 data) + { + int j, k; + char dump_array[20]; + unsigned char bitset; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + if (format == DUMP_TEXT) + { + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 15; k >= 0; j++, k--) + { + bitset = data & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + if ((k % 8) == 0) + sprintf(&dump_array[++j], " "); + } + dump_array[17] = '\0'; + fprintf (dumpfile," %s\n", dump_array); + } + else + { + if ((fwrite (&data, 2, 1, dumpfile)) != 2) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } + } + + return (0); + } + +static int dump_long (FILE *dumpfile, int format, char *dump_tag, uint32 data) + { + int j, k; + char dump_array[40]; + unsigned char bitset; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + if (format == DUMP_TEXT) + { + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 31; k >= 0; j++, k--) + { + bitset = data & (((uint32)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + if ((k % 8) == 0) + sprintf(&dump_array[++j], " "); + } + dump_array[35] = '\0'; + fprintf (dumpfile," %s\n", dump_array); + } + else + { + if ((fwrite (&data, 4, 1, dumpfile)) != 4) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } + } + return (0); + } + +static int dump_wide (FILE *dumpfile, int format, char *dump_tag, uint64 data) + { + int j, k; + char dump_array[80]; + unsigned char bitset; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + if (format == DUMP_TEXT) + { + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 63; k >= 0; j++, k--) + { + bitset = data & (((uint64)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + if ((k % 8) == 0) + sprintf(&dump_array[++j], " "); + } + dump_array[71] = '\0'; + fprintf (dumpfile," %s\n", dump_array); + } + else + { + if ((fwrite (&data, 8, 1, dumpfile)) != 8) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } + } + + return (0); + } + +static void dump_info(FILE *dumpfile, int format, char *prefix, char *msg, ...) + { + if (format == DUMP_TEXT) + { + va_list ap; + va_start(ap, msg); + fprintf(dumpfile, "%s ", prefix); + vfprintf(dumpfile, msg, ap); + fprintf(dumpfile, "\n"); + } + } + +static int dump_buffer (FILE* dumpfile, int format, uint32 rows, uint32 width, + uint32 row, unsigned char *buff) + { + int j, k; + uint32 i; + unsigned char * dump_ptr; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + for (i = 0; i < rows; i++) + { + dump_ptr = buff + (i * width); + if (format == DUMP_TEXT) + dump_info (dumpfile, format, "", + "Row %4d, %d bytes at offset %d", + row + i + 1, width, row * width); + + for (j = 0, k = width; k >= 10; j += 10, k -= 10, dump_ptr += 10) + dump_data (dumpfile, format, "", dump_ptr, 10); + if (k > 0) + dump_data (dumpfile, format, "", dump_ptr, k); + } + return (0); + } + +/* Extract one or more samples from an interleaved buffer. If count == 1, + * only the sample plane indicated by sample will be extracted. If count > 1, + * count samples beginning at sample will be extracted. Portions of a + * scanline can be extracted by specifying a start and end value. + */ + +static int +extractContigSamplesBytes (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int i, bytes_per_sample, sindex; + uint32 col, dst_rowsize, bit_offset; + uint32 src_byte, src_bit; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamplesBytes","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesBytes", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesBytes", + "Invalid end column value %d ignored", end); + end = cols; + } + + dst_rowsize = (bps * (end - start) * count) / 8; + + bytes_per_sample = (bps + 7) / 8; + /* Optimize case for copying all samples */ + if (count == spp) + { + src = in + (start * spp * bytes_per_sample); + _TIFFmemcpy (dst, src, dst_rowsize); + } + else + { + for (col = start; col < end; col++) + { + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + bit_offset = col * bps * spp; + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + src = in + src_byte; + for (i = 0; i < bytes_per_sample; i++) + *dst++ = *src++; + } + } + } + + return (0); + } /* end extractContigSamplesBytes */ + +static int +extractContigSamples8bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamples8bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples8bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples8bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = 0; + maskbits = (uint8)-1 >> ( 8 - bps); + buff1 = buff2 = 0; + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (8 - src_bit - bps); + buff1 = ((*src) & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + } + else + buff2 = (buff2 | (buff1 >> ready_bits)); + ready_bits += bps; + } + } + + while (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples8bits */ + +static int +extractContigSamples16bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamples16bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples16bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples16bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = 0; + maskbits = (uint16)-1 >> (16 - bps); + + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (16 - src_bit - bps); + + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + + buff1 = (buff1 & matchbits) << (src_bit); + if (ready_bits < 8) /* add another bps bits to the buffer */ + { + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples16bits */ + + +static int +extractContigSamples24bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamples24bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples24bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples24bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = 0; + maskbits = (uint32)-1 >> ( 32 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (32 - src_bit - bps); + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + if (ready_bits < 16) /* add another bps bits to the buffer */ + { + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples24bits */ + +static int +extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0, shift_width = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamples32bits","Invalid input or output buffer"); + return (1); + } + + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples32bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples32bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + shift_width = ((bps + 7) / 8) + 1; + ready_bits = 0; + maskbits = (uint64)-1 >> ( 64 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 32) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples32bits */ + +static int +extractContigSamplesShifted8bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamplesShifted8bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted8bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted8bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = shift; + maskbits = (uint8)-1 >> ( 8 - bps); + buff1 = buff2 = 0; + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (8 - src_bit - bps); + buff1 = ((*src) & matchbits) << (src_bit); + if ((col == start) && (sindex == sample)) + buff2 = *src & ((uint8)-1) << (shift); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ |= buff2; + buff2 = buff1; + ready_bits -= 8; + } + else + buff2 = buff2 | (buff1 >> ready_bits); + ready_bits += bps; + } + } + + while (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted8bits */ + +static int +extractContigSamplesShifted16bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamplesShifted16bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted16bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted16bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = shift; + maskbits = (uint16)-1 >> (16 - bps); + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (16 - src_bit - bps); + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + + if ((col == start) && (sindex == sample)) + buff2 = buff1 & ((uint16)-1) << (8 - shift); + + buff1 = (buff1 & matchbits) << (src_bit); + + if (ready_bits < 8) /* add another bps bits to the buffer */ + buff2 = buff2 | (buff1 >> ready_bits); + else /* If we have a full buffer's worth, write it out */ + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + } + + ready_bits += bps; + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted16bits */ + + +static int +extractContigSamplesShifted24bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamplesShifted24bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted24bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted24bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = shift; + maskbits = (uint32)-1 >> ( 32 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (32 - src_bit - bps); + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + + if ((col == start) && (sindex == sample)) + buff2 = buff1 & ((uint32)-1) << (16 - shift); + + buff1 = (buff1 & matchbits) << (src_bit); + + if (ready_bits < 16) /* add another bps bits to the buffer */ + { + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted24bits */ + +static int +extractContigSamplesShifted32bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0, shift_width = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamplesShifted32bits","Invalid input or output buffer"); + return (1); + } + + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted32bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted32bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + shift_width = ((bps + 7) / 8) + 1; + ready_bits = shift; + maskbits = (uint64)-1 >> ( 64 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + if ((col == start) && (sindex == sample)) + buff2 = buff3 & ((uint64)-1) << (32 - shift); + + buff1 = (buff3 & matchbits) << (src_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted32bits */ + +static int +extractContigSamplesToBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + struct dump_opts *dump) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 src_rowsize, src_offset, row, first_col = 0; + uint32 dst_rowsize, dst_offset; + tsample_t count = 1; + uint8 *src, *dst; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + src_rowsize = ((bps * spp * cols) + 7) / 8; + dst_rowsize = ((bps * cols) + 7) / 8; + + if ((dump->outfile != NULL) && (dump->level == 4)) + { + dump_info (dump->outfile, dump->format, "extractContigSamplesToBuffer", + "Sample %d, %d rows", sample + 1, rows + 1); + } + for (row = 0; row < rows; row++) + { + src_offset = row * src_rowsize; + dst_offset = row * dst_rowsize; + src = in + src_offset; + dst = out + dst_offset; + + /* pack the data into the scanline */ + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + case 1: if (bps == 1) + { + if (extractContigSamples8bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + } + else + if (extractContigSamples16bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + case 2: if (extractContigSamples24bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + case 3: + case 4: + case 5: if (extractContigSamples32bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + default: TIFFError ("extractContigSamplesToBuffer", "Unsupported bit depth: %d", bps); + return (1); + } + if ((dump->outfile != NULL) && (dump->level == 4)) + dump_buffer(dump->outfile, dump->format, 1, dst_rowsize, row, dst); + } + + return (0); + } /* end extractContigSamplesToBuffer */ + +static int +extractContigSamplesToTileBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, + uint32 imagewidth, uint32 tilewidth, tsample_t sample, + uint16 count, uint16 spp, uint16 bps, struct dump_opts *dump) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 src_rowsize, src_offset, row; + uint32 dst_rowsize, dst_offset; + uint8 *src, *dst; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + + if ((dump->outfile != NULL) && (dump->level == 4)) + { + dump_info (dump->outfile, dump->format, "extractContigSamplesToTileBuffer", + "Sample %d, %d rows", sample + 1, rows + 1); + } + + src_rowsize = ((bps * spp * imagewidth) + 7) / 8; + dst_rowsize = ((bps * tilewidth * count) + 7) / 8; + + for (row = 0; row < rows; row++) + { + src_offset = row * src_rowsize; + dst_offset = row * dst_rowsize; + src = in + src_offset; + dst = out + dst_offset; + + /* pack the data into the scanline */ + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + case 1: if (bps == 1) + { + if (extractContigSamples8bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + } + else + if (extractContigSamples16bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + case 2: if (extractContigSamples24bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + case 3: + case 4: + case 5: if (extractContigSamples32bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + default: TIFFError ("extractContigSamplesToTileBuffer", "Unsupported bit depth: %d", bps); + return (1); + } + if ((dump->outfile != NULL) && (dump->level == 4)) + dump_buffer(dump->outfile, dump->format, 1, dst_rowsize, row, dst); + } + + return (0); + } /* end extractContigSamplesToTileBuffer */ + +static int readContigStripsIntoBuffer (TIFF* in, uint8* buf) + { + uint8* bufp = buf; + int32 bytes_read = 0; + uint16 strip, nstrips = TIFFNumberOfStrips(in); + uint32 stripsize = TIFFStripSize(in); + uint32 rows = 0; + uint32 rps = TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); + tsize_t scanline_size = TIFFScanlineSize(in); + + for (strip = 0; strip < nstrips; strip++) + { + bytes_read = TIFFReadEncodedStrip (in, strip, bufp, -1); + rows = bytes_read / scanline_size; + if ((strip < (nstrips - 1)) && (bytes_read != (int32)stripsize)) + TIFFError("", "Strip %d: read %lu bytes, strip size %lu", + (int)strip + 1, (unsigned long) bytes_read, (unsigned long)stripsize); + + if (bytes_read < 0 && !ignore) + { + TIFFError("", "Error reading strip %lu after %lu rows", + (unsigned long) strip, (unsigned long)rows); + return 0; + } + bufp += bytes_read; + } + + return 1; + } /* end readContigStripsIntoBuffer */ + +static int +combineSeparateSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, + uint32 cols, uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int i, bytes_per_sample; + uint32 row, col, col_offset, src_rowsize, dst_rowsize, row_offset; + unsigned char *src; + unsigned char *dst; + tsample_t s; + + src = srcbuffs[0]; + dst = out; + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateSamplesBytes","Invalid buffer address"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * spp * cols) + 7) / 8; + for (row = 0; row < rows; row++) + { + if ((dumpfile != NULL) && (level == 2)) + { + for (s = 0; s < spp; s++) + { + dump_info (dumpfile, format, "combineSeparateSamplesBytes","Input data, Sample %d", s); + dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); + } + } + dst = out + (row * dst_rowsize); + row_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + col_offset = row_offset + (col * (bps / 8)); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + src = srcbuffs[s] + col_offset; + for (i = 0; i < bytes_per_sample; i++) + *(dst + i) = *(src + i); + src += bytes_per_sample; + dst += bytes_per_sample; + } + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamplesBytes","Output data, combined samples"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateSamplesBytes */ + +static int +combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + int bytes_per_sample = 0; + uint32 src_rowsize, dst_rowsize, src_offset; + uint32 bit_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[32]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateSamples8bits","Invalid input or output buffer"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint8)-1 >> ( 8 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (8 - src_bit - bps); + /* load up next sample from each plane */ + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + buff1 = ((*src) & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + strcpy (action, "Flush"); + } + else + { + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Match bits", matchbits); + dump_byte (dumpfile, format, "Src bits", *src); + dump_byte (dumpfile, format, "Buff1 bits", buff1); + dump_byte (dumpfile, format, "Buff2 bits", buff2); + dump_info (dumpfile, format, "","%s", action); + } + } + } + + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", buff1); + } + } + + if ((dumpfile != NULL) && (level >= 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples8bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateSamples8bits */ + +static int +combineSeparateSamples16bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0, bytes_per_sample = 0; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateSamples16bits","Invalid input or output buffer"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint16)-1 >> (16 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (16 - src_bit - bps); + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + + dump_short (dumpfile, format, "Match bits", matchbits); + dump_data (dumpfile, format, "Src bits", src, 2); + dump_short (dumpfile, format, "Buff1 bits", buff1); + dump_short (dumpfile, format, "Buff2 bits", buff2); + dump_byte (dumpfile, format, "Write byte", bytebuff); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + if (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", bytebuff); + } + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples16bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateSamples16bits */ + +static int +combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0, bytes_per_sample = 0; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateSamples24bits","Invalid input or output buffer"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint32)-1 >> ( 32 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (32 - src_bit - bps); + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 16) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples24bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateSamples24bits */ + +static int +combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0, bytes_per_sample = 0, shift_width = 0; + uint32 src_rowsize, dst_rowsize, bit_offset, src_offset; + uint32 src_byte = 0, src_bit = 0; + uint32 row, col; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateSamples32bits","Invalid input or output buffer"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint64)-1 >> ( 64 - bps); + shift_width = ((bps + 7) / 8) + 1; + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (64 - src_bit - bps); + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 32) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_wide (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 8); + dump_wide (dumpfile, format, "Buff1 bits ", buff1); + dump_wide (dumpfile, format, "Buff2 bits ", buff2); + dump_info (dumpfile, format, "", "Ready bits: %d, %s", ready_bits, action); + } + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples32bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out); + } + } + + return (0); + } /* end combineSeparateSamples32bits */ + +static int +combineSeparateTileSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, + uint32 cols, uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int i, bytes_per_sample; + uint32 row, col, col_offset, src_rowsize, dst_rowsize, src_offset; + unsigned char *src; + unsigned char *dst; + tsample_t s; + + src = srcbuffs[0]; + dst = out; + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamplesBytes","Invalid buffer address"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = imagewidth * bytes_per_sample * spp; + for (row = 0; row < rows; row++) + { + if ((dumpfile != NULL) && (level == 2)) + { + for (s = 0; s < spp; s++) + { + dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Input data, Sample %d", s); + dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); + } + } + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; +#ifdef DEVELMODE + TIFFError("","Tile row %4d, Src offset %6d Dst offset %6d", + row, src_offset, dst - out); +#endif + for (col = 0; col < cols; col++) + { + col_offset = src_offset + (col * (bps / 8)); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + src = srcbuffs[s] + col_offset; + for (i = 0; i < bytes_per_sample; i++) + *(dst + i) = *(src + i); + dst += bytes_per_sample; + } + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Output data, combined samples"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateTileSamplesBytes */ + +static int +combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + uint32 src_rowsize, dst_rowsize, src_offset; + uint32 bit_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[32]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples8bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint8)-1 >> ( 8 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (8 - src_bit - bps); + /* load up next sample from each plane */ + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + buff1 = ((*src) & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + strcpy (action, "Flush"); + } + else + { + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Match bits", matchbits); + dump_byte (dumpfile, format, "Src bits", *src); + dump_byte (dumpfile, format, "Buff1 bits", buff1); + dump_byte (dumpfile, format, "Buff2 bits", buff2); + dump_info (dumpfile, format, "","%s", action); + } + } + } + + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", buff1); + } + } + + if ((dumpfile != NULL) && (level >= 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples8bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateTileSamples8bits */ + +static int +combineSeparateTileSamples16bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples16bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint16)-1 >> (16 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (16 - src_bit - bps); + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + + dump_short (dumpfile, format, "Match bits", matchbits); + dump_data (dumpfile, format, "Src bits", src, 2); + dump_short (dumpfile, format, "Buff1 bits", buff1); + dump_short (dumpfile, format, "Buff2 bits", buff2); + dump_byte (dumpfile, format, "Write byte", bytebuff); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + if (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", bytebuff); + } + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples16bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateTileSamples16bits */ + +static int +combineSeparateTileSamples24bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples24bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint32)-1 >> ( 32 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (32 - src_bit - bps); + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 16) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples24bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateTileSamples24bits */ + +static int +combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0, shift_width = 0; + uint32 src_rowsize, dst_rowsize, bit_offset, src_offset; + uint32 src_byte = 0, src_bit = 0; + uint32 row, col; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples32bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint64)-1 >> ( 64 - bps); + shift_width = ((bps + 7) / 8) + 1; + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (64 - src_bit - bps); + for (s = 0; s < spp; s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 32) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_wide (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 8); + dump_wide (dumpfile, format, "Buff1 bits ", buff1); + dump_wide (dumpfile, format, "Buff2 bits ", buff2); + dump_info (dumpfile, format, "", "Ready bits: %d, %s", ready_bits, action); + } + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples32bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out); + } + } + + return (0); + } /* end combineSeparateTileSamples32bits */ + + +static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, + uint32 width, uint16 spp, + struct dump_opts *dump) + { + int i, j, bytes_per_sample, bytes_per_pixel, shift_width, result = 1; + int32 bytes_read = 0; + uint16 bps, nstrips, planar, strips_per_sample; + uint32 src_rowsize, dst_rowsize, rows_processed, rps; + uint32 rows_this_strip = 0; + tsample_t s; + tstrip_t strip; + tsize_t scanlinesize = TIFFScanlineSize(in); + tsize_t stripsize = TIFFStripSize(in); + unsigned char *srcbuffs[MAX_SAMPLES]; + unsigned char *buff = NULL; + unsigned char *dst = NULL; + + if (obuf == NULL) + { + TIFFError("readSeparateStripsIntoBuffer","Invalid buffer argument"); + return (0); + } + + memset (srcbuffs, '\0', sizeof(srcbuffs)); + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); + TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); + if (rps > length) + rps = length; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + src_rowsize = ((bps * width) + 7) / 8; + dst_rowsize = ((bps * width * spp) + 7) / 8; + dst = obuf; + + if ((dump->infile != NULL) && (dump->level == 3)) + { + dump_info (dump->infile, dump->format, "", + "Image width %d, length %d, Scanline size, %4d bytes", + width, length, scanlinesize); + dump_info (dump->infile, dump->format, "", + "Bits per sample %d, Samples per pixel %d, Shift width %d", + bps, spp, shift_width); + } + + /* Libtiff seems to assume/require that data for separate planes are + * written one complete plane after another and not interleaved in any way. + * Multiple scanlines and possibly strips of the same plane must be + * written before data for any other plane. + */ + nstrips = TIFFNumberOfStrips(in); + strips_per_sample = nstrips /spp; + + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + srcbuffs[s] = NULL; + buff = _TIFFmalloc(stripsize); + if (!buff) + { + TIFFError ("readSeparateStripsIntoBuffer", + "Unable to allocate strip read buffer for sample %d", s); + for (i = 0; i < s; i++) + _TIFFfree (srcbuffs[i]); + return 0; + } + srcbuffs[s] = buff; + } + + rows_processed = 0; + for (j = 0; (j < strips_per_sample) && (result == 1); j++) + { + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + buff = srcbuffs[s]; + strip = (s * strips_per_sample) + j; + bytes_read = TIFFReadEncodedStrip (in, strip, buff, stripsize); + rows_this_strip = bytes_read / src_rowsize; + if (bytes_read < 0 && !ignore) + { + TIFFError(TIFFFileName(in), + "Error, can't read strip %lu for sample %d", + (unsigned long) strip, s + 1); + result = 0; + break; + } +#ifdef DEVELMODE + TIFFError("", "Strip %2d, read %5d bytes for %4d scanlines, shift width %d", + strip, bytes_read, rows_this_strip, shift_width); +#endif + } + + if (rps > rows_this_strip) + rps = rows_this_strip; + dst = obuf + (dst_rowsize * rows_processed); + if ((bps % 8) == 0) + { + if (combineSeparateSamplesBytes (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + } + else + { + switch (shift_width) + { + case 1: if (combineSeparateSamples8bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + case 2: if (combineSeparateSamples16bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + case 3: if (combineSeparateSamples24bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + case 4: + case 5: + case 6: + case 7: + case 8: if (combineSeparateSamples32bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + default: TIFFError ("readSeparateStripsIntoBuffer", "Unsupported bit depth: %d", bps); + result = 0; + break; + } + } + + if ((rows_processed + rps) > length) + { + rows_processed = length; + rps = length - rows_processed; + } + else + rows_processed += rps; + } + + /* free any buffers allocated for each plane or scanline and + * any temporary buffers + */ + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + buff = srcbuffs[s]; + if (buff != NULL) + _TIFFfree(buff); + } + + return (result); + } /* end readSeparateStripsIntoBuffer */ + +static int +get_page_geometry (char *name, struct pagedef *page) + { + char *ptr; + int n; + + for (ptr = name; *ptr; ptr++) + *ptr = (char)tolower((int)*ptr); + + for (n = 0; n < MAX_PAPERNAMES; n++) + { + if (strcmp(name, PaperTable[n].name) == 0) + { + page->width = PaperTable[n].width; + page->length = PaperTable[n].length; + strncpy (page->name, PaperTable[n].name, 15); + page->name[15] = '\0'; + return (0); + } + } + + return (1); + } + + +static void +initPageSetup (struct pagedef *page, struct pageseg *pagelist, + struct buffinfo seg_buffs[]) + { + int i; + + strcpy (page->name, ""); + page->mode = PAGE_MODE_NONE; + page->res_unit = RESUNIT_NONE; + page->hres = 0.0; + page->vres = 0.0; + page->width = 0.0; + page->length = 0.0; + page->hmargin = 0.0; + page->vmargin = 0.0; + page->rows = 0; + page->cols = 0; + page->orient = ORIENTATION_NONE; + + for (i = 0; i < MAX_SECTIONS; i++) + { + pagelist[i].x1 = (uint32)0; + pagelist[i].x2 = (uint32)0; + pagelist[i].y1 = (uint32)0; + pagelist[i].y2 = (uint32)0; + pagelist[i].buffsize = (uint32)0; + pagelist[i].position = 0; + pagelist[i].total = 0; + } + + for (i = 0; i < MAX_OUTBUFFS; i++) + { + seg_buffs[i].size = 0; + seg_buffs[i].buffer = NULL; + } + } + +static void +initImageData (struct image_data *image) + { + image->xres = 0.0; + image->yres = 0.0; + image->width = 0; + image->length = 0; + image->res_unit = RESUNIT_NONE; + image->bps = 0; + image->spp = 0; + image->planar = 0; + image->photometric = 0; + image->orientation = 0; + image->compression = COMPRESSION_NONE; + image->adjustments = 0; + } + +static void +initCropMasks (struct crop_mask *cps) + { + int i; + + cps->crop_mode = CROP_NONE; + cps->res_unit = RESUNIT_NONE; + cps->edge_ref = EDGE_TOP; + cps->width = 0; + cps->length = 0; + for (i = 0; i < 4; i++) + cps->margins[i] = 0.0; + cps->bufftotal = (uint32)0; + cps->combined_width = (uint32)0; + cps->combined_length = (uint32)0; + cps->rotation = (uint16)0; + cps->photometric = INVERT_DATA_AND_TAG; + cps->mirror = (uint16)0; + cps->invert = (uint16)0; + cps->zones = (uint32)0; + cps->regions = (uint32)0; + for (i = 0; i < MAX_REGIONS; i++) + { + cps->corners[i].X1 = 0.0; + cps->corners[i].X2 = 0.0; + cps->corners[i].Y1 = 0.0; + cps->corners[i].Y2 = 0.0; + cps->regionlist[i].x1 = 0; + cps->regionlist[i].x2 = 0; + cps->regionlist[i].y1 = 0; + cps->regionlist[i].y2 = 0; + cps->regionlist[i].width = 0; + cps->regionlist[i].length = 0; + cps->regionlist[i].buffsize = 0; + cps->regionlist[i].buffptr = NULL; + cps->zonelist[i].position = 0; + cps->zonelist[i].total = 0; + } + cps->exp_mode = ONE_FILE_COMPOSITE; + cps->img_mode = COMPOSITE_IMAGES; + } + +static void initDumpOptions(struct dump_opts *dump) + { + dump->debug = 0; + dump->format = DUMP_NONE; + dump->level = 1; + sprintf (dump->mode, "w"); + memset (dump->infilename, '\0', PATH_MAX + 1); + memset (dump->outfilename, '\0',PATH_MAX + 1); + dump->infile = NULL; + dump->outfile = NULL; + } + +/* Compute pixel offsets into the image for margins and fixed regions */ +static int +computeInputPixelOffsets(struct crop_mask *crop, struct image_data *image, + struct offset *off) + { + double scale; + float xres, yres; + /* Values for these offsets are in pixels from start of image, not bytes, + * and are indexed from zero to width - 1 or length - 1 */ + uint32 tmargin, bmargin, lmargin, rmargin; + uint32 startx, endx; /* offsets of first and last columns to extract */ + uint32 starty, endy; /* offsets of first and last row to extract */ + uint32 width, length, crop_width, crop_length; + uint32 i, max_width, max_length, zwidth, zlength, buffsize; + uint32 x1, x2, y1, y2; + + if (image->res_unit != RESUNIT_INCH && image->res_unit != RESUNIT_CENTIMETER) + { + xres = 1.0; + yres = 1.0; + } + else + { + if (((image->xres == 0) || (image->yres == 0)) && + (crop->res_unit != RESUNIT_NONE) && + ((crop->crop_mode & CROP_REGIONS) || (crop->crop_mode & CROP_MARGINS) || + (crop->crop_mode & CROP_LENGTH) || (crop->crop_mode & CROP_WIDTH))) + { + TIFFError("computeInputPixelOffsets", "Cannot compute margins or fixed size sections without image resolution"); + TIFFError("computeInputPixelOffsets", "Specify units in pixels and try again"); + return (-1); + } + xres = image->xres; + yres = image->yres; + } + + /* Translate user units to image units */ + scale = 1.0; + switch (crop->res_unit) { + case RESUNIT_CENTIMETER: + if (image->res_unit == RESUNIT_INCH) + scale = 1.0/2.54; + break; + case RESUNIT_INCH: + if (image->res_unit == RESUNIT_CENTIMETER) + scale = 2.54; + break; + case RESUNIT_NONE: /* Dimensions in pixels */ + default: + break; + } + + if (crop->crop_mode & CROP_REGIONS) + { + max_width = max_length = 0; + for (i = 0; i < crop->regions; i++) + { + if ((crop->res_unit == RESUNIT_INCH) || (crop->res_unit == RESUNIT_CENTIMETER)) + { + x1 = (uint32) (crop->corners[i].X1 * scale * xres); + x2 = (uint32) (crop->corners[i].X2 * scale * xres); + y1 = (uint32) (crop->corners[i].Y1 * scale * yres); + y2 = (uint32) (crop->corners[i].Y2 * scale * yres); + } + else + { + x1 = (uint32) (crop->corners[i].X1); + x2 = (uint32) (crop->corners[i].X2); + y1 = (uint32) (crop->corners[i].Y1); + y2 = (uint32) (crop->corners[i].Y2); + } + if (x1 < 1) + crop->regionlist[i].x1 = 0; + else + crop->regionlist[i].x1 = (uint32) (x1 - 1); + + if (x2 > image->width - 1) + crop->regionlist[i].x2 = image->width - 1; + else + crop->regionlist[i].x2 = (uint32) (x2 - 1); + zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; + + if (y1 < 1) + crop->regionlist[i].y1 = 0; + else + crop->regionlist[i].y1 = (uint32) (y1 - 1); + + if (y2 > image->length - 1) + crop->regionlist[i].y2 = image->length - 1; + else + crop->regionlist[i].y2 = (uint32) (y2 - 1); + + zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; + + if (zwidth > max_width) + max_width = zwidth; + if (zlength > max_length) + max_length = zlength; + + buffsize = (uint32) + (((zwidth * image->bps * image->spp + 7 ) / 8) * (zlength + 1)); + + crop->regionlist[i].buffsize = buffsize; + crop->bufftotal += buffsize; + if (crop->img_mode == COMPOSITE_IMAGES) + { + switch (crop->edge_ref) + { + case EDGE_LEFT: + case EDGE_RIGHT: + crop->combined_length = zlength; + crop->combined_width += zwidth; + break; + case EDGE_BOTTOM: + case EDGE_TOP: /* width from left, length from top */ + default: + crop->combined_width = zwidth; + crop->combined_length += zlength; + break; + } + } + } + return (0); + } + + /* Convert crop margins into offsets into image + * Margins are expressed as pixel rows and columns, not bytes + */ + if (crop->crop_mode & CROP_MARGINS) + { + if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) + { /* User has specified pixels as reference unit */ + tmargin = (uint32)(crop->margins[0]); + lmargin = (uint32)(crop->margins[1]); + bmargin = (uint32)(crop->margins[2]); + rmargin = (uint32)(crop->margins[3]); + } + else + { /* inches or centimeters specified */ + tmargin = (uint32)(crop->margins[0] * scale * yres); + lmargin = (uint32)(crop->margins[1] * scale * xres); + bmargin = (uint32)(crop->margins[2] * scale * yres); + rmargin = (uint32)(crop->margins[3] * scale * xres); + } + + if ((lmargin + rmargin) > image->width) + { + TIFFError("computeInputPixelOffsets", "Combined left and right margins exceed image width"); + lmargin = (uint32) 0; + rmargin = (uint32) 0; + return (-1); + } + if ((tmargin + bmargin) > image->length) + { + TIFFError("computeInputPixelOffsets", "Combined top and bottom margins exceed image length"); + tmargin = (uint32) 0; + bmargin = (uint32) 0; + return (-1); + } + } + else + { /* no margins requested */ + tmargin = (uint32) 0; + lmargin = (uint32) 0; + bmargin = (uint32) 0; + rmargin = (uint32) 0; + } + + /* Width, height, and margins are expressed as pixel offsets into image */ + if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) + { + if (crop->crop_mode & CROP_WIDTH) + width = (uint32)crop->width; + else + width = image->width - lmargin - rmargin; + + if (crop->crop_mode & CROP_LENGTH) + length = (uint32)crop->length; + else + length = image->length - tmargin - bmargin; + } + else + { + if (crop->crop_mode & CROP_WIDTH) + width = (uint32)(crop->width * scale * image->xres); + else + width = image->width - lmargin - rmargin; + + if (crop->crop_mode & CROP_LENGTH) + length = (uint32)(crop->length * scale * image->yres); + else + length = image->length - tmargin - bmargin; + } + + off->tmargin = tmargin; + off->bmargin = bmargin; + off->lmargin = lmargin; + off->rmargin = rmargin; + + /* Calculate regions defined by margins, width, and length. + * Coordinates expressed as 0 to imagewidth - 1, imagelength - 1, + * since they are used to compute offsets into buffers */ + switch (crop->edge_ref) { + case EDGE_BOTTOM: + startx = lmargin; + if ((startx + width) >= (image->width - rmargin)) + endx = image->width - rmargin - 1; + else + endx = startx + width - 1; + + endy = image->length - bmargin - 1; + if ((endy - length) <= tmargin) + starty = tmargin; + else + starty = endy - length + 1; + break; + case EDGE_RIGHT: + endx = image->width - rmargin - 1; + if ((endx - width) <= lmargin) + startx = lmargin; + else + startx = endx - width + 1; + + starty = tmargin; + if ((starty + length) >= (image->length - bmargin)) + endy = image->length - bmargin - 1; + else + endy = starty + length - 1; + break; + case EDGE_TOP: /* width from left, length from top */ + case EDGE_LEFT: + default: + startx = lmargin; + if ((startx + width) >= (image->width - rmargin)) + endx = image->width - rmargin - 1; + else + endx = startx + width - 1; + + starty = tmargin; + if ((starty + length) >= (image->length - bmargin)) + endy = image->length - bmargin - 1; + else + endy = starty + length - 1; + break; + } + off->startx = startx; + off->starty = starty; + off->endx = endx; + off->endy = endy; + + crop_width = endx - startx + 1; + crop_length = endy - starty + 1; + + if (crop_width <= 0) + { + TIFFError("computeInputPixelOffsets", + "Invalid left/right margins and /or image crop width requested"); + return (-1); + } + if (crop_width > image->width) + crop_width = image->width; + + if (crop_length <= 0) + { + TIFFError("computeInputPixelOffsets", + "Invalid top/bottom margins and /or image crop length requested"); + return (-1); + } + if (crop_length > image->length) + crop_length = image->length; + + off->crop_width = crop_width; + off->crop_length = crop_length; + + return (0); + } /* end computeInputPixelOffsets */ + +/* + * Translate crop options into pixel offsets for one or more regions of the image. + * Options are applied in this order: margins, specific width and length, zones, + * but all are optional. Margins are relative to each edge. Width, length and + * zones are relative to the specified reference edge. Zones are expressed as + * X:Y where X is the ordinal value in a set of Y equal sized portions. eg. + * 2:3 would indicate the middle third of the region qualified by margins and + * any explicit width and length specified. Regions are specified by coordinates + * of the top left and lower right corners with range 1 to width or height. + */ + +static int +getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opts *dump) + { + struct offset offsets; + int i; + int32 test; + uint32 seg, total, need_buff = 0; + uint32 buffsize; + uint32 zwidth, zlength; + + memset(&offsets, '\0', sizeof(struct offset)); + crop->bufftotal = 0; + crop->combined_width = (uint32)0; + crop->combined_length = (uint32)0; + crop->selections = 0; + + /* Compute pixel offsets if margins or fixed width or length specified */ + if ((crop->crop_mode & CROP_MARGINS) || + (crop->crop_mode & CROP_REGIONS) || + (crop->crop_mode & CROP_LENGTH) || + (crop->crop_mode & CROP_WIDTH)) + { + if (computeInputPixelOffsets(crop, image, &offsets)) + { + TIFFError ("getCropOffsets", "Unable to compute crop margins"); + return (-1); + } + need_buff = TRUE; + crop->selections = crop->regions; + /* Regions are only calculated from top and left edges with no margins */ + if (crop->crop_mode & CROP_REGIONS) + return (0); + } + else + { /* cropped area is the full image */ + offsets.tmargin = 0; + offsets.lmargin = 0; + offsets.bmargin = 0; + offsets.rmargin = 0; + offsets.crop_width = image->width; + offsets.crop_length = image->length; + offsets.startx = 0; + offsets.endx = image->width - 1; + offsets.starty = 0; + offsets.endy = image->length - 1; + need_buff = FALSE; + } + + if (dump->outfile != NULL) + { + dump_info (dump->outfile, dump->format, "", "Margins: Top: %d Left: %d Bottom: %d Right: %d", + offsets.tmargin, offsets.lmargin, offsets.bmargin, offsets.rmargin); + dump_info (dump->outfile, dump->format, "", "Crop region within margins: Adjusted Width: %6d Length: %6d", + offsets.crop_width, offsets.crop_length); + } + + if (!(crop->crop_mode & CROP_ZONES)) /* no crop zones requested */ + { + if (need_buff == FALSE) /* No margins or fixed width or length areas */ + { + crop->selections = 0; + crop->combined_width = image->width; + crop->combined_length = image->length; + return (0); + } + else + { + /* Use one region for margins and fixed width or length areas + * even though it was not formally declared as a region. + */ + crop->selections = 1; + crop->zones = 1; + crop->zonelist[0].total = 1; + crop->zonelist[0].position = 1; + } + } + else + crop->selections = crop->zones; + + for (i = 0; i < crop->zones; i++) + { + seg = crop->zonelist[i].position; + total = crop->zonelist[i].total; + + switch (crop->edge_ref) + { + case EDGE_LEFT: /* zones from left to right, length from top */ + zlength = offsets.crop_length; + crop->regionlist[i].y1 = offsets.starty; + crop->regionlist[i].y2 = offsets.endy; + + crop->regionlist[i].x1 = offsets.startx + + (uint32)(offsets.crop_width * 1.0 * (seg - 1) / total); + test = (int32)offsets.startx + + (int32)(offsets.crop_width * 1.0 * seg / total); + if (test < 1 ) + crop->regionlist[i].x2 = 0; + else + { + if (test > (int32)(image->width - 1)) + crop->regionlist[i].x2 = image->width - 1; + else + crop->regionlist[i].x2 = test - 1; + } + zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; + + /* This is passed to extractCropZone or extractCompositeZones */ + crop->combined_length = (uint32)zlength; + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_width += (uint32)zwidth; + else + crop->combined_width = (uint32)zwidth; + break; + case EDGE_BOTTOM: /* width from left, zones from bottom to top */ + zwidth = offsets.crop_width; + crop->regionlist[i].x1 = offsets.startx; + crop->regionlist[i].x2 = offsets.endx; + + test = offsets.endy - (uint32)(offsets.crop_length * 1.0 * seg / total); + if (test < 1 ) + crop->regionlist[i].y1 = 0; + else + crop->regionlist[i].y1 = test + 1; + + test = offsets.endy - (offsets.crop_length * 1.0 * (seg - 1) / total); + if (test < 1 ) + crop->regionlist[i].y2 = 0; + else + { + if (test > (int32)(image->length - 1)) + crop->regionlist[i].y2 = image->length - 1; + else + crop->regionlist[i].y2 = test; + } + zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; + + /* This is passed to extractCropZone or extractCompositeZones */ + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_length += (uint32)zlength; + else + crop->combined_length = (uint32)zlength; + crop->combined_width = (uint32)zwidth; + break; + case EDGE_RIGHT: /* zones from right to left, length from top */ + zlength = offsets.crop_length; + crop->regionlist[i].y1 = offsets.starty; + crop->regionlist[i].y2 = offsets.endy; + + crop->regionlist[i].x1 = offsets.startx + + (uint32)(offsets.crop_width * (total - seg) * 1.0 / total); + test = offsets.startx + + (offsets.crop_width * (total - seg + 1) * 1.0 / total); + if (test < 1 ) + crop->regionlist[i].x2 = 0; + else + { + if (test > (int32)(image->width - 1)) + crop->regionlist[i].x2 = image->width - 1; + else + crop->regionlist[i].x2 = test - 1; + } + zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; + + /* This is passed to extractCropZone or extractCompositeZones */ + crop->combined_length = (uint32)zlength; + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_width += (uint32)zwidth; + else + crop->combined_width = (uint32)zwidth; + break; + case EDGE_TOP: /* width from left, zones from top to bottom */ + default: + zwidth = offsets.crop_width; + crop->regionlist[i].x1 = offsets.startx; + crop->regionlist[i].x2 = offsets.endx; + + crop->regionlist[i].y1 = offsets.starty + (uint32)(offsets.crop_length * 1.0 * (seg - 1) / total); + test = offsets.starty + (uint32)(offsets.crop_length * 1.0 * seg / total); + if (test < 1 ) + crop->regionlist[i].y2 = 0; + else + { + if (test > (int32)(image->length - 1)) + crop->regionlist[i].y2 = image->length - 1; + else + crop->regionlist[i].y2 = test - 1; + } + zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; + + /* This is passed to extractCropZone or extractCompositeZones */ + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_length += (uint32)zlength; + else + crop->combined_length = (uint32)zlength; + crop->combined_width = (uint32)zwidth; + break; + } /* end switch statement */ + + buffsize = (uint32) + ((((zwidth * image->bps * image->spp) + 7 ) / 8) * (zlength + 1)); + crop->regionlist[i].width = (uint32) zwidth; + crop->regionlist[i].length = (uint32) zlength; + crop->regionlist[i].buffsize = buffsize; + crop->bufftotal += buffsize; + + + if (dump->outfile != NULL) + dump_info (dump->outfile, dump->format, "", "Zone %d, width: %4d, length: %4d, x1: %4d x2: %4d y1: %4d y2: %4d", + i + 1, (uint32)zwidth, (uint32)zlength, + crop->regionlist[i].x1, crop->regionlist[i].x2, + crop->regionlist[i].y1, crop->regionlist[i].y2); + } + + return (0); + } /* end getCropOffsets */ + + +static int +computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, + struct pagedef *page, struct pageseg *sections, + struct dump_opts* dump) + { + double scale; + double pwidth, plength; /* Output page width and length in user units*/ + uint32 iwidth, ilength; /* Input image width and length in pixels*/ + uint32 owidth, olength; /* Output image width and length in pixels*/ + uint32 orows, ocols; /* rows and cols for output */ + uint32 hmargin, vmargin; /* Horizontal and vertical margins */ + uint32 x1, x2, y1, y2, line_bytes; + unsigned int orientation; + uint32 i, j, k; + + scale = 1.0; + if (page->res_unit == RESUNIT_NONE) + page->res_unit = image->res_unit; + + switch (image->res_unit) { + case RESUNIT_CENTIMETER: + if (page->res_unit == RESUNIT_INCH) + scale = 1.0/2.54; + break; + case RESUNIT_INCH: + if (page->res_unit == RESUNIT_CENTIMETER) + scale = 2.54; + break; + case RESUNIT_NONE: /* Dimensions in pixels */ + default: + break; + } + + /* get width, height, resolutions of input image selection */ + if (crop->combined_width > 0) + iwidth = crop->combined_width; + else + iwidth = image->width; + if (crop->combined_length > 0) + ilength = crop->combined_length; + else + ilength = image->length; + + if (page->hres <= 1.0) + page->hres = image->xres; + if (page->vres <= 1.0) + page->vres = image->yres; + + if ((page->hres < 1.0) || (page->vres < 1.0)) + { + TIFFError("computeOutputPixelOffsets", + "Invalid horizontal or vertical resolution specified or read from input image"); + return (1); + } + + /* If no page sizes are being specified, we just use the input image size to + * calculate maximum margins that can be taken from image. + */ + if (page->width <= 0) + pwidth = iwidth; + else + pwidth = page->width; + + if (page->length <= 0) + plength = ilength; + else + plength = page->length; + + if (dump->debug) + { + TIFFError("", "Page size: %s, Vres: %3.2f, Hres: %3.2f, " + "Hmargin: %3.2f, Vmargin: %3.2f", + page->name, page->vres, page->hres, + page->hmargin, page->vmargin); + TIFFError("", "Res_unit: %d, Scale: %3.2f, Page width: %3.2f, length: %3.2f", + page->res_unit, scale, pwidth, plength); + } + + /* compute margins at specified unit and resolution */ + if (page->mode & PAGE_MODE_MARGINS) + { + if (page->res_unit == RESUNIT_INCH || page->res_unit == RESUNIT_CENTIMETER) + { /* inches or centimeters specified */ + hmargin = (uint32)(page->hmargin * scale * page->hres * ((image->bps + 7)/ 8)); + vmargin = (uint32)(page->vmargin * scale * page->vres * ((image->bps + 7)/ 8)); + } + else + { /* Otherwise user has specified pixels as reference unit */ + hmargin = (uint32)(page->hmargin * scale * ((image->bps + 7)/ 8)); + vmargin = (uint32)(page->vmargin * scale * ((image->bps + 7)/ 8)); + } + + if ((hmargin * 2.0) > (pwidth * page->hres)) + { + TIFFError("computeOutputPixelOffsets", + "Combined left and right margins exceed page width"); + hmargin = (uint32) 0; + return (-1); + } + if ((vmargin * 2.0) > (plength * page->vres)) + { + TIFFError("computeOutputPixelOffsets", + "Combined top and bottom margins exceed page length"); + vmargin = (uint32) 0; + return (-1); + } + } + else + { + hmargin = 0; + vmargin = 0; + } + + if (page->mode & PAGE_MODE_ROWSCOLS ) + { + /* Maybe someday but not for now */ + if (page->mode & PAGE_MODE_MARGINS) + TIFFError("computeOutputPixelOffsets", + "Output margins cannot be specified with rows and columns"); + + owidth = TIFFhowmany(iwidth, page->cols); + olength = TIFFhowmany(ilength, page->rows); + } + else + { + if (page->mode & PAGE_MODE_PAPERSIZE ) + { + owidth = (uint32)((pwidth * page->hres) - (hmargin * 2)); + olength = (uint32)((plength * page->vres) - (vmargin * 2)); + } + else + { + owidth = (uint32)(iwidth - (hmargin * 2 * page->hres)); + olength = (uint32)(ilength - (vmargin * 2 * page->vres)); + } + } + + if (owidth > iwidth) + owidth = iwidth; + if (olength > ilength) + olength = ilength; + + /* Compute the number of pages required for Portrait or Landscape */ + switch (page->orient) + { + case ORIENTATION_NONE: + case ORIENTATION_PORTRAIT: + ocols = TIFFhowmany(iwidth, owidth); + orows = TIFFhowmany(ilength, olength); + orientation = ORIENTATION_PORTRAIT; + break; + + case ORIENTATION_LANDSCAPE: + ocols = TIFFhowmany(iwidth, olength); + orows = TIFFhowmany(ilength, owidth); + x1 = olength; + olength = owidth; + owidth = x1; + orientation = ORIENTATION_LANDSCAPE; + break; + + case ORIENTATION_AUTO: + default: + x1 = TIFFhowmany(iwidth, owidth); + x2 = TIFFhowmany(ilength, olength); + y1 = TIFFhowmany(iwidth, olength); + y2 = TIFFhowmany(ilength, owidth); + + if ( (x1 * x2) < (y1 * y2)) + { /* Portrait */ + ocols = x1; + orows = x2; + orientation = ORIENTATION_PORTRAIT; + } + else + { /* Landscape */ + ocols = y1; + orows = y2; + x1 = olength; + olength = owidth; + owidth = x1; + orientation = ORIENTATION_LANDSCAPE; + } + } + + if (ocols < 1) + ocols = 1; + if (orows < 1) + orows = 1; + + /* If user did not specify rows and cols, set them from calcuation */ + if (page->rows < 1) + page->rows = orows; + if (page->cols < 1) + page->cols = ocols; + + line_bytes = TIFFhowmany8(owidth * image->bps) * image->spp; + + if ((page->rows * page->cols) > MAX_SECTIONS) + { + TIFFError("computeOutputPixelOffsets", + "Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections"); + return (-1); + } + + /* build the list of offsets for each output section */ + for (k = 0, i = 0 && k <= MAX_SECTIONS; i < orows; i++) + { + y1 = (uint32)(olength * i); + y2 = (uint32)(olength * (i + 1) - 1); + if (y2 >= ilength) + y2 = ilength - 1; + for (j = 0; j < ocols; j++, k++) + { + x1 = (uint32)(owidth * j); + x2 = (uint32)(owidth * (j + 1) - 1); + if (x2 >= iwidth) + x2 = iwidth - 1; + sections[k].x1 = x1; + sections[k].x2 = x2; + sections[k].y1 = y1; + sections[k].y2 = y2; + sections[k].buffsize = line_bytes * olength; + sections[k].position = k + 1; + sections[k].total = orows * ocols; + } + } + return (0); + } /* end computeOutputPixelOffsets */ + +static int +loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned char **read_ptr) + { + uint32 i; + float xres = 0.0, yres = 0.0; + uint16 nstrips = 0, ntiles = 0, planar = 0; + uint16 bps = 0, spp = 0, res_unit = 0; + uint16 orientation = 0; + uint16 input_compression = 0, input_photometric = 0; + uint16 subsampling_horiz, subsampling_vert; + uint32 width = 0, length = 0; + uint32 stsize = 0, tlsize = 0, buffsize = 0, scanlinesize = 0; + uint32 tw = 0, tl = 0; /* Tile width and length */ + uint32 tile_rowsize = 0; + unsigned char *read_buff = NULL; + unsigned char *new_buff = NULL; + int readunit = 0; + static uint32 prev_readsize = 0; + + TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); + TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &spp); + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); + TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation); + if (! TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) + TIFFError("loadImage","Image lacks Photometric interpreation tag"); + if (! TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width)) + TIFFError("loadimage","Image lacks image width tag"); + if(! TIFFGetField(in, TIFFTAG_IMAGELENGTH, &length)) + TIFFError("loadimage","Image lacks image length tag"); + TIFFGetFieldDefaulted(in, TIFFTAG_XRESOLUTION, &xres); + TIFFGetFieldDefaulted(in, TIFFTAG_YRESOLUTION, &yres); + if (!TIFFGetFieldDefaulted(in, TIFFTAG_RESOLUTIONUNIT, &res_unit)) + res_unit = RESUNIT_INCH; + if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &input_compression)) + input_compression = COMPRESSION_NONE; + +#ifdef DEBUG2 + char compressionid[16]; + + switch (input_compression) + { + case COMPRESSION_NONE: /* 1 dump mode */ + strcpy (compressionid, "None/dump"); + break; + case COMPRESSION_CCITTRLE: /* 2 CCITT modified Huffman RLE */ + strcpy (compressionid, "Huffman RLE"); + break; + case COMPRESSION_CCITTFAX3: /* 3 CCITT Group 3 fax encoding */ + strcpy (compressionid, "Group3 Fax"); + break; + case COMPRESSION_CCITTFAX4: /* 4 CCITT Group 4 fax encoding */ + strcpy (compressionid, "Group4 Fax"); + break; + case COMPRESSION_LZW: /* 5 Lempel-Ziv & Welch */ + strcpy (compressionid, "LZW"); + break; + case COMPRESSION_OJPEG: /* 6 !6.0 JPEG */ + strcpy (compressionid, "Old Jpeg"); + break; + case COMPRESSION_JPEG: /* 7 %JPEG DCT compression */ + strcpy (compressionid, "New Jpeg"); + break; + case COMPRESSION_NEXT: /* 32766 NeXT 2-bit RLE */ + strcpy (compressionid, "Next RLE"); + break; + case COMPRESSION_CCITTRLEW: /* 32771 #1 w/ word alignment */ + strcpy (compressionid, "CITTRLEW"); + break; + case COMPRESSION_PACKBITS: /* 32773 Macintosh RLE */ + strcpy (compressionid, "Mac Packbits"); + break; + case COMPRESSION_THUNDERSCAN: /* 32809 ThunderScan RLE */ + strcpy (compressionid, "Thunderscan"); + break; + case COMPRESSION_IT8CTPAD: /* 32895 IT8 CT w/padding */ + strcpy (compressionid, "IT8 padded"); + break; + case COMPRESSION_IT8LW: /* 32896 IT8 Linework RLE */ + strcpy (compressionid, "IT8 RLE"); + break; + case COMPRESSION_IT8MP: /* 32897 IT8 Monochrome picture */ + strcpy (compressionid, "IT8 mono"); + break; + case COMPRESSION_IT8BL: /* 32898 IT8 Binary line art */ + strcpy (compressionid, "IT8 lineart"); + break; + case COMPRESSION_PIXARFILM: /* 32908 Pixar companded 10bit LZW */ + strcpy (compressionid, "Pixar 10 bit"); + break; + case COMPRESSION_PIXARLOG: /* 32909 Pixar companded 11bit ZIP */ + strcpy (compressionid, "Pixar 11bit"); + break; + case COMPRESSION_DEFLATE: /* 32946 Deflate compression */ + strcpy (compressionid, "Deflate"); + break; + case COMPRESSION_ADOBE_DEFLATE: /* 8 Deflate compression */ + strcpy (compressionid, "Adobe deflate"); + break; + default: + strcpy (compressionid, "None/unknown"); + break; + } + TIFFError("loadImage", "Input compression %s", compressionid); +#endif + + scanlinesize = TIFFScanlineSize(in); + image->bps = bps; + image->spp = spp; + image->planar = planar; + image->width = width; + image->length = length; + image->xres = xres; + image->yres = yres; + image->res_unit = res_unit; + image->compression = input_compression; + image->photometric = input_photometric; +#ifdef DEBUG2 + char photometricid[12]; + + switch (input_photometric) + { + case PHOTOMETRIC_MINISWHITE: + strcpy (photometricid, "MinIsWhite"); + break; + case PHOTOMETRIC_MINISBLACK: + strcpy (photometricid, "MinIsBlack"); + break; + case PHOTOMETRIC_RGB: + strcpy (photometricid, "RGB"); + break; + case PHOTOMETRIC_PALETTE: + strcpy (photometricid, "Palette"); + break; + case PHOTOMETRIC_MASK: + strcpy (photometricid, "Mask"); + break; + case PHOTOMETRIC_SEPARATED: + strcpy (photometricid, "Separated"); + break; + case PHOTOMETRIC_YCBCR: + strcpy (photometricid, "YCBCR"); + break; + case PHOTOMETRIC_CIELAB: + strcpy (photometricid, "CIELab"); + break; + case PHOTOMETRIC_ICCLAB: + strcpy (photometricid, "ICCLab"); + break; + case PHOTOMETRIC_ITULAB: + strcpy (photometricid, "ITULab"); + break; + case PHOTOMETRIC_LOGL: + strcpy (photometricid, "LogL"); + break; + case PHOTOMETRIC_LOGLUV: + strcpy (photometricid, "LOGLuv"); + break; + default: + strcpy (photometricid, "Unknown"); + break; + } + TIFFError("loadImage", "Input photometric interpretation %s", photometricid); + +#endif + image->orientation = orientation; + switch (orientation) + { + case 0: + case ORIENTATION_TOPLEFT: + image->adjustments = 0; + break; + case ORIENTATION_TOPRIGHT: + image->adjustments = MIRROR_HORIZ; + break; + case ORIENTATION_BOTRIGHT: + image->adjustments = ROTATECW_180; + break; + case ORIENTATION_BOTLEFT: + image->adjustments = MIRROR_VERT; + break; + case ORIENTATION_LEFTTOP: + image->adjustments = MIRROR_VERT | ROTATECW_90; + break; + case ORIENTATION_RIGHTTOP: + image->adjustments = ROTATECW_90; + break; + case ORIENTATION_RIGHTBOT: + image->adjustments = MIRROR_VERT | ROTATECW_270; + break; + case ORIENTATION_LEFTBOT: + image->adjustments = ROTATECW_270; + break; + default: + image->adjustments = 0; + image->orientation = ORIENTATION_TOPLEFT; + } + + if ((bps == 0) || (spp == 0)) + { + TIFFError("loadImage", "Invalid samples per pixel (%d) or bits per sample (%d)", + spp, bps); + return (-1); + } + + if (TIFFIsTiled(in)) + { + readunit = TILE; + tlsize = TIFFTileSize(in); + ntiles = TIFFNumberOfTiles(in); + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + + tile_rowsize = TIFFTileRowSize(in); + buffsize = tlsize * ntiles; + + + if (buffsize < (uint32)(ntiles * tl * tile_rowsize)) + { + buffsize = ntiles * tl * tile_rowsize; +#ifdef DEBUG2 + TIFFError("loadImage", + "Tilesize %u is too small, using ntiles * tilelength * tilerowsize %lu", + tlsize, (unsigned long)buffsize); +#endif + } + + if (dump->infile != NULL) + dump_info (dump->infile, dump->format, "", + "Tilesize: %u, Number of Tiles: %u, Tile row size: %u", + tlsize, ntiles, tile_rowsize); + } + else + { + readunit = STRIP; + TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + stsize = TIFFStripSize(in); + nstrips = TIFFNumberOfStrips(in); + buffsize = stsize * nstrips; + + if (buffsize < (uint32) (((length * width * spp * bps) + 7) / 8)) + { + buffsize = ((length * width * spp * bps) + 7) / 8; +#ifdef DEBUG2 + TIFFError("loadImage", + "Stripsize %u is too small, using imagelength * width * spp * bps / 8 = %lu", + stsize, (unsigned long)buffsize); +#endif + } + + if (dump->infile != NULL) + dump_info (dump->infile, dump->format, "", + "Stripsize: %u, Number of Strips: %u, Rows per Strip: %u, Scanline size: %u", + stsize, nstrips, rowsperstrip, scanlinesize); + } + + if (input_compression == COMPRESSION_JPEG) + { /* Force conversion to RGB */ + jpegcolormode = JPEGCOLORMODE_RGB; + TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + /* The clause up to the read statement is taken from Tom Lane's tiffcp patch */ + else + { /* Otherwise, can't handle subsampled input */ + if (input_photometric == PHOTOMETRIC_YCBCR) + { + TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, + &subsampling_horiz, &subsampling_vert); + if (subsampling_horiz != 1 || subsampling_vert != 1) + { + TIFFError("loadImage", + "Can't copy/convert subsampled image with subsampling %d horiz %d vert", + subsampling_horiz, subsampling_vert); + return (-1); + } + } + } + + read_buff = *read_ptr; + if (!read_buff) + read_buff = (unsigned char *)_TIFFmalloc(buffsize); + else + { + if (prev_readsize < buffsize) + { + new_buff = _TIFFrealloc(read_buff, buffsize); + if (!new_buff) + { + free (read_buff); + read_buff = (unsigned char *)_TIFFmalloc(buffsize); + } + else + read_buff = new_buff; + } + } + + if (!read_buff) + { + TIFFError("loadImage", "Unable to allocate/reallocate read buffer"); + return (-1); + } + + prev_readsize = buffsize; + *read_ptr = read_buff; + + /* N.B. The read functions used copy separate plane data into a buffer as interleaved + * samples rather than separate planes so the same logic works to extract regions + * regardless of the way the data are organized in the input file. + */ + switch (readunit) { + case STRIP: + if (planar == PLANARCONFIG_CONTIG) + { + if (!(readContigStripsIntoBuffer(in, read_buff))) + { + TIFFError("loadImage", "Unable to read contiguous strips into buffer"); + return (-1); + } + } + else + { + if (!(readSeparateStripsIntoBuffer(in, read_buff, length, width, spp, dump))) + { + TIFFError("loadImage", "Unable to read separate strips into buffer"); + return (-1); + } + } + break; + + case TILE: + if (planar == PLANARCONFIG_CONTIG) + { + if (!(readContigTilesIntoBuffer(in, read_buff, length, width, tw, tl, spp, bps))) + { + TIFFError("loadImage", "Unable to read contiguous tiles into buffer"); + return (-1); + } + } + else + { + if (!(readSeparateTilesIntoBuffer(in, read_buff, length, width, tw, tl, spp, bps))) + { + TIFFError("loadImage", "Unable to read separate tiles into buffer"); + return (-1); + } + } + break; + default: TIFFError("loadImage", "Unsupported image file format"); + return (-1); + break; + } + if ((dump->infile != NULL) && (dump->level == 2)) + { + dump_info (dump->infile, dump->format, "loadImage", + "Image width %d, length %d, Raw image data, %4d bytes", + width, length, buffsize); + dump_info (dump->infile, dump->format, "", + "Bits per sample %d, Samples per pixel %d", bps, spp); + + for (i = 0; i < length; i++) + dump_buffer(dump->infile, dump->format, 1, scanlinesize, + i, read_buff + (i * scanlinesize)); + } + return (0); + } /* end loadImage */ + +static int correct_orientation(struct image_data *image, unsigned char **work_buff_ptr) + { + uint16 mirror, rotation; + unsigned char *work_buff; + + work_buff = *work_buff_ptr; + if ((image == NULL) || (work_buff == NULL)) + { + TIFFError ("correct_orientatin", "Invalid image or buffer pointer"); + return (-1); + } + + if ((image->adjustments & MIRROR_HORIZ) || (image->adjustments & MIRROR_VERT)) + { + mirror = (uint16)(image->adjustments & MIRROR_BOTH); + if (mirrorImage(image->spp, image->bps, mirror, + image->width, image->length, work_buff)) + { + TIFFError ("correct_orientation", "Unable to mirror image"); + return (-1); + } + } + + if (image->adjustments & ROTATE_ANY) + { + if (image->adjustments & ROTATECW_90) + rotation = (uint16) 90; + else + if (image->adjustments & ROTATECW_180) + rotation = (uint16) 180; + else + if (image->adjustments & ROTATECW_270) + rotation = (uint16) 270; + else + { + TIFFError ("correct_orientation", "Invalid rotation value: %d", + image->adjustments & ROTATE_ANY); + return (-1); + } + + if (rotateImage(rotation, image, &image->width, &image->length, work_buff_ptr)) + { + TIFFError ("correct_orientation", "Unable to rotate image"); + return (-1); + } + image->orientation = ORIENTATION_TOPLEFT; + } + + return (0); + } /* end correct_orientation */ + + +/* Extract multiple zones from an image and combine into a single composite image */ +static int +extractCompositeRegions(struct image_data *image, struct crop_mask *crop, + unsigned char *read_buff, unsigned char *crop_buff) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 i, trailing_bits, prev_trailing_bits; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_rowsize, dst_rowsize, src_offset, dst_offset; + uint32 crop_width, crop_length, img_width, img_length; + uint32 prev_length, prev_width, composite_width; + uint16 bps, spp; + uint8 *src, *dst; + tsample_t count, sample = 0; /* Update to extract one or more samples */ + + img_width = image->width; + img_length = image->length; + bps = image->bps; + spp = image->spp; + count = spp; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + src = read_buff; + dst = crop_buff; + + /* These are setup for adding additional sections */ + prev_width = prev_length = 0; + prev_trailing_bits = trailing_bits = 0; + composite_width = crop->combined_width; + crop->combined_width = 0; + crop->combined_length = 0; + + for (i = 0; i < crop->selections; i++) + { + /* rows, columns, width, length are expressed in pixels */ + first_row = crop->regionlist[i].y1; + last_row = crop->regionlist[i].y2; + first_col = crop->regionlist[i].x1; + last_col = crop->regionlist[i].x2; + + crop_width = last_col - first_col + 1; + crop_length = last_row - first_row + 1; + + /* These should not be needed for composite images */ + crop->regionlist[i].width = crop_width; + crop->regionlist[i].length = crop_length; + crop->regionlist[i].buffptr = crop_buff; + + src_rowsize = ((img_width * bps * spp) + 7) / 8; + dst_rowsize = (((crop_width * bps * count) + 7) / 8); + + switch (crop->edge_ref) + { + default: + case EDGE_TOP: + case EDGE_BOTTOM: + if ((i > 0) && (crop_width != crop->regionlist[i - 1].width)) + { + TIFFError ("extractCompositeRegions", + "Only equal width regions can be combined for -E top or bottom"); + return (1); + } + + crop->combined_width = crop_width; + crop->combined_length += crop_length; + + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + (prev_length * dst_rowsize); + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, sample, + spp, bps, count, first_col, + last_col + 1)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + return (1); + } + } + prev_length += crop_length; + break; + case EDGE_LEFT: /* splice the pieces of each row together, side by side */ + case EDGE_RIGHT: + if ((i > 0) && (crop_length != crop->regionlist[i - 1].length)) + { + TIFFError ("extractCompositeRegions", + "Only equal length regions can be combined for -E left or right"); + return (1); + } + crop->combined_width += crop_width; + crop->combined_length = crop_length; + dst_rowsize = (((composite_width * bps * count) + 7) / 8); + trailing_bits = (crop_width * bps * count) % 8; + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + prev_width; + + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + return (1); + } + } + prev_width += (crop_width * bps * count) / 8; + prev_trailing_bits += trailing_bits; + if (prev_trailing_bits > 7) + prev_trailing_bits-= 8; + break; + } + } + if (crop->combined_width != composite_width) + TIFFError("combineSeparateRegions","Combined width does not match composite width"); + + return (0); + } /* end extractCompositeRegions */ + +/* Copy a single region of input buffer to an output buffer. + * The read functions used copy separate plane data into a buffer + * as interleaved samples rather than separate planes so the same + * logic works to extract regions regardless of the way the data + * are organized in the input file. This function can be used to + * extract one or more samples from the input image by updating the + * parameters for starting sample and number of samples to copy in the + * fifth and eighth arguments of the call to extractContigSamples. + * They would be passed as new elements of the crop_mask struct. + */ + +static int +extractSeparateRegion(struct image_data *image, struct crop_mask *crop, + unsigned char *read_buff, unsigned char *crop_buff, + int region) + { + int shift_width, prev_trailing_bits = 0; + uint32 bytes_per_sample, bytes_per_pixel; + uint32 src_rowsize, dst_rowsize; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_offset, dst_offset; + uint32 crop_width, crop_length, img_width, img_length; + uint16 bps, spp; + uint8 *src, *dst; + tsample_t count, sample = 0; /* Update to extract more or more samples */ + + img_width = image->width; + img_length = image->length; + bps = image->bps; + spp = image->spp; + count = spp; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; /* Byte aligned data only */ + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + + /* rows, columns, width, length are expressed in pixels */ + first_row = crop->regionlist[region].y1; + last_row = crop->regionlist[region].y2; + first_col = crop->regionlist[region].x1; + last_col = crop->regionlist[region].x2; + + crop_width = last_col - first_col + 1; + crop_length = last_row - first_row + 1; + + crop->regionlist[region].width = crop_width; + crop->regionlist[region].length = crop_length; + crop->regionlist[region].buffptr = crop_buff; + + src = read_buff; + dst = crop_buff; + src_rowsize = ((img_width * bps * spp) + 7) / 8; + dst_rowsize = (((crop_width * bps * spp) + 7) / 8); + + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset; + + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, sample, + spp, bps, count, first_col, + last_col + 1)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + default: TIFFError("extractSeparateRegion", "Unsupported bit depth %d", bps); + return (1); + } + } + + return (0); + } /* end extractSeparateRegion */ + +static int +extractImageSection(struct image_data *image, struct pageseg *section, + unsigned char *src_buff, unsigned char *sect_buff) + { + unsigned char bytebuff1, bytebuff2; + unsigned char *src, *dst; + + uint32 img_width, img_length, img_rowsize; + uint32 j, shift1, shift2, trailing_bits; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_offset, dst_offset, row_offset, col_offset; + uint32 offset1, offset2, full_bytes; + uint32 sect_width, sect_length; + uint16 bps, spp; + +#ifdef DEVELMODE + int k; + unsigned char bitset; + static char *bitarray = NULL; +#endif + + img_width = image->width; + img_length = image->length; + bps = image->bps; + spp = image->spp; + + src = src_buff; + dst = sect_buff; + src_offset = 0; + dst_offset = 0; + +#ifdef DEVELMODE + if (bitarray == NULL) + { + if ((bitarray = (char *)malloc(img_width)) == NULL) + { + TIFFError ("", "DEBUG: Unable to allocate debugging bitarray"); + return (-1); + } + } +#endif + + /* rows, columns, width, length are expressed in pixels */ + first_row = section->y1; + last_row = section->y2; + first_col = section->x1; + last_col = section->x2; + + sect_width = last_col - first_col + 1; + sect_length = last_row - first_row + 1; + img_rowsize = ((img_width * bps + 7) / 8) * spp; + full_bytes = (sect_width * spp * bps) / 8; /* number of COMPLETE bytes per row in section */ + trailing_bits = (sect_width * bps) % 8; + +#ifdef DEVELMODE + TIFFError ("", "First row: %d, last row: %d, First col: %d, last col: %d\n", + first_row, last_row, first_col, last_col); + TIFFError ("", "Image width: %d, Image length: %d, bps: %d, spp: %d\n", + img_width, img_length, bps, spp); + TIFFError ("", "Sect width: %d, Sect length: %d, full bytes: %d trailing bits %d\n", + sect_width, sect_length, full_bytes, trailing_bits); +#endif + + if ((bps % 8) == 0) + { + col_offset = first_col * spp * bps / 8; + for (row = first_row; row <= last_row; row++) + { + /* row_offset = row * img_width * spp * bps / 8; */ + row_offset = row * img_rowsize; + src_offset = row_offset + col_offset; + +#ifdef DEVELMODE + TIFFError ("", "Src offset: %8d, Dst offset: %8d", src_offset, dst_offset); +#endif + _TIFFmemcpy (sect_buff + dst_offset, src_buff + src_offset, full_bytes); + dst_offset += full_bytes; + } + } + else + { /* bps != 8 */ + shift1 = spp * ((first_col * bps) % 8); + shift2 = spp * ((last_col * bps) % 8); + for (row = first_row; row <= last_row; row++) + { + /* pull out the first byte */ + row_offset = row * img_rowsize; + offset1 = row_offset + (first_col * bps / 8); + offset2 = row_offset + (last_col * bps / 8); + +#ifdef DEVELMODE + for (j = 0, k = 7; j < 8; j++, k--) + { + bitset = *(src_buff + offset1) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + sprintf(&bitarray[8], " "); + sprintf(&bitarray[9], " "); + for (j = 10, k = 7; j < 18; j++, k--) + { + bitset = *(src_buff + offset2) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[18] = '\0'; + TIFFError ("", "Row: %3d Offset1: %d, Shift1: %d, Offset2: %d, Shift2: %d\n", + row, offset1, shift1, offset2, shift2); +#endif + + bytebuff1 = bytebuff2 = 0; + if (shift1 == 0) /* the region is byte and sample alligned */ + { + _TIFFmemcpy (sect_buff + dst_offset, src_buff + offset1, full_bytes); + +#ifdef DEVELMODE + TIFFError ("", " Alligned data src offset1: %8d, Dst offset: %8d\n", offset1, dst_offset); + sprintf(&bitarray[18], "\n"); + sprintf(&bitarray[19], "\t"); + for (j = 20, k = 7; j < 28; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[28] = ' '; + bitarray[29] = ' '; +#endif + dst_offset += full_bytes; + + if (trailing_bits != 0) + { + bytebuff2 = src_buff[offset2] & ((unsigned char)255 << (7 - shift2)); + sect_buff[dst_offset] = bytebuff2; +#ifdef DEVELMODE + TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", + offset2, dst_offset); + for (j = 30, k = 7; j < 38; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[38] = '\0'; + TIFFError ("", "\tFirst and last bytes before and after masking:\n\t%s\n\n", bitarray); +#endif + dst_offset++; + } + } + else /* each destination byte will have to be built from two source bytes*/ + { +#ifdef DEVELMODE + TIFFError ("", " Unalligned data src offset: %8d, Dst offset: %8d\n", offset1 , dst_offset); +#endif + for (j = 0; j <= full_bytes; j++) + { + bytebuff1 = src_buff[offset1 + j] & ((unsigned char)255 >> shift1); + bytebuff2 = src_buff[offset1 + j + 1] & ((unsigned char)255 << (7 - shift1)); + sect_buff[dst_offset + j] = (bytebuff1 << shift1) | (bytebuff2 >> (8 - shift1)); + } +#ifdef DEVELMODE + sprintf(&bitarray[18], "\n"); + sprintf(&bitarray[19], "\t"); + for (j = 20, k = 7; j < 28; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[28] = ' '; + bitarray[29] = ' '; +#endif + dst_offset += full_bytes; + + if (trailing_bits != 0) + { +#ifdef DEVELMODE + TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", offset1 + full_bytes, dst_offset); +#endif + if (shift2 > shift1) + { + bytebuff1 = src_buff[offset1 + full_bytes] & ((unsigned char)255 << (7 - shift2)); + bytebuff2 = bytebuff1 & ((unsigned char)255 << shift1); + sect_buff[dst_offset] = bytebuff2; +#ifdef DEVELMODE + TIFFError ("", " Shift2 > Shift1\n"); +#endif + } + else + { + if (shift2 < shift1) + { + bytebuff2 = ((unsigned char)255 << (shift1 - shift2 - 1)); + sect_buff[dst_offset] &= bytebuff2; +#ifdef DEVELMODE + TIFFError ("", " Shift2 < Shift1\n"); +#endif + } +#ifdef DEVELMODE + else + TIFFError ("", " Shift2 == Shift1\n"); +#endif + } + } +#ifdef DEVELMODE + sprintf(&bitarray[28], " "); + sprintf(&bitarray[29], " "); + for (j = 30, k = 7; j < 38; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[38] = '\0'; + TIFFError ("", "\tFirst and last bytes before and after masking:\n\t%s\n\n", bitarray); +#endif + dst_offset++; + } + } + } + + return (0); + } /* end extractImageSection */ + +static int +writeSelections(TIFF *in, TIFF **out, struct crop_mask *crop, + struct image_data *image, struct dump_opts *dump, + struct buffinfo seg_buffs[], char *mp, char *filename, + unsigned int *page, unsigned int total_pages) + { + int i, page_count; + int autoindex = 0; + unsigned char *crop_buff = NULL; + + /* Where we open a new file depends on the export mode */ + switch (crop->exp_mode) + { + case ONE_FILE_COMPOSITE: /* Regions combined into single image */ + autoindex = 0; + crop_buff = seg_buffs[0].buffer; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + page_count = total_pages; + if (writeCroppedImage(in, *out, image, dump, + crop->combined_width, + crop->combined_length, + crop_buff, *page, total_pages)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + break; + case ONE_FILE_SEPARATED: /* Regions as separated images */ + autoindex = 0; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + page_count = crop->selections * total_pages; + for (i = 0; i < crop->selections; i++) + { + crop_buff = seg_buffs[i].buffer; + if (writeCroppedImage(in, *out, image, dump, + crop->regionlist[i].width, + crop->regionlist[i].length, + crop_buff, *page, page_count)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + } + break; + case FILE_PER_IMAGE_COMPOSITE: /* Regions as composite image */ + autoindex = 1; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + + crop_buff = seg_buffs[0].buffer; + if (writeCroppedImage(in, *out, image, dump, + crop->combined_width, + crop->combined_length, + crop_buff, *page, total_pages)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + break; + case FILE_PER_IMAGE_SEPARATED: /* Regions as separated images */ + autoindex = 1; + page_count = crop->selections; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + + for (i = 0; i < crop->selections; i++) + { + crop_buff = seg_buffs[i].buffer; + /* Write the current region to the current file */ + if (writeCroppedImage(in, *out, image, dump, + crop->regionlist[i].width, + crop->regionlist[i].length, + crop_buff, *page, page_count)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + } + break; + case FILE_PER_SELECTION: + autoindex = 1; + page_count = 1; + for (i = 0; i < crop->selections; i++) + { + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + + crop_buff = seg_buffs[i].buffer; + /* Write the current region to the current file */ + if (writeCroppedImage(in, *out, image, dump, + crop->regionlist[i].width, + crop->regionlist[i].length, + crop_buff, *page, page_count)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + } + break; + default: return (1); + } + + return (0); + } /* end writeRegions */ + +static int +writeImageSections(TIFF *in, TIFF *out, struct image_data *image, + struct pagedef *page, struct pageseg *sections, + struct dump_opts * dump, unsigned char *src_buff, + unsigned char **sect_buff_ptr) + { + double hres, vres; + uint32 i, k, width, length, sectsize; + unsigned char *sect_buff = *sect_buff_ptr; + + hres = page->hres; + vres = page->vres; + + k = page->cols * page->rows; + if ((k < 1) || (k > MAX_SECTIONS)) + { + TIFFError("writeImageSections", + "%d Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections", k); + return (-1); + } + + for (i = 0; i < k; i++) + { + width = sections[i].x2 - sections[i].x1 + 1; + length = sections[i].y2 - sections[i].y1 + 1; + sectsize = (uint32) + ceil((width * image->bps + 7) / (double)8) * image->spp * length; + /* allocate a buffer if we don't have one already */ + if (createImageSection(sectsize, sect_buff_ptr)) + { + TIFFError("writeImageSections", "Unable to allocate section buffer"); + exit (-1); + } + sect_buff = *sect_buff_ptr; + + if (extractImageSection (image, §ions[i], src_buff, sect_buff)) + { + TIFFError("writeImageSections", "Unable to extract image sections"); + exit (-1); + } + + /* call the write routine here instead of outside the loop */ + if (writeSingleSection(in, out, image, dump, width, length, hres, vres, sect_buff)) + { + TIFFError("writeImageSections", "Unable to write image section"); + exit (-1); + } + } + + return (0); + } /* end writeImageSections */ + +/* Code in this function is heavily indebted to code in tiffcp + * with modifications by Richard Nolde to handle orientation correctly. + * It will have to be updated significantly if support is added to + * extract one or more samples from original image since the + * original code assumes we are always copying all samples. + */ +static int +writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, + struct dump_opts *dump, uint32 width, uint32 length, + double hres, double vres, + unsigned char *sect_buff) + { + uint16 bps, spp; + uint16 input_compression, input_photometric; + uint16 input_planar; + struct cpTag* p; + + /* Calling this seems to reset the compression mode on the TIFF *in file. + TIFFGetField(in, TIFFTAG_JPEGCOLORMODE, &input_jpeg_colormode); + */ + input_compression = image->compression; + input_photometric = image->photometric; + + spp = image->spp; + bps = image->bps; + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bps); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); + +#ifdef DEBUG2 + TIFFError("writeSingleSection", "Input compression: %s", + (input_compression == COMPRESSION_OJPEG) ? "Old Jpeg" : + ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" : "Non Jpeg")); +#endif + /* This is the global variable compression which is set + * if the user has specified a command line option for + * a compression option. Should be passed around in one + * of the parameters instead of as a global. If no user + * option specified it will still be (uint16) -1. */ + if (compression != (uint16)-1) + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + else + { /* OJPEG is no longer supported for writing so upgrade to JPEG */ + if (input_compression == COMPRESSION_OJPEG) + { + compression = COMPRESSION_JPEG; + jpegcolormode = JPEGCOLORMODE_RAW; + TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + } + else /* Use the compression from the input file */ + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + } + + if (compression == COMPRESSION_JPEG) + { + if ((input_photometric == PHOTOMETRIC_PALETTE) || /* color map indexed */ + (input_photometric == PHOTOMETRIC_MASK)) /* holdout mask */ + { + TIFFError ("writeSingleSection", + "JPEG compression cannot be used with %s image data", + (input_photometric == PHOTOMETRIC_PALETTE) ? + "palette" : "mask"); + return (-1); + } + if ((input_photometric == PHOTOMETRIC_RGB) && + (jpegcolormode == JPEGCOLORMODE_RGB)) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); + } + else + { + if (compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, spp == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, image->photometric); + } + +#ifdef DEBUG2 + TIFFError("writeSingleSection", "Input photometric: %s", + (input_photometric == PHOTOMETRIC_RGB) ? "RGB" : + ((input_photometric == PHOTOMETRIC_YCBCR) ? "YCbCr" : "Not RGB or YCbCr")); +#endif + + if (((input_photometric == PHOTOMETRIC_LOGL) || + (input_photometric == PHOTOMETRIC_LOGLUV)) && + ((compression != COMPRESSION_SGILOG) && + (compression != COMPRESSION_SGILOG24))) + { + TIFFError("writeSingleSection", + "LogL and LogLuv source data require SGI_LOG or SGI_LOG24 compression"); + return (-1); + } + + if (fillorder != 0) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + else + CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); + + /* The loadimage function reads input orientation and sets + * image->orientation. The correct_image_orientation function + * applies the required rotation and mirror operations to + * present the data in TOPLEFT orientation and updates + * image->orientation if any transforms are performed, + * as per EXIF standard. + */ + TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation); + + /* + * Choose tiles/strip for the output image according to + * the command line arguments (-tiles, -strips) and the + * structure of the input image. + */ + if (outtiled == -1) + outtiled = TIFFIsTiled(in); + if (outtiled) { + /* + * Setup output file's tile width&height. If either + * is not specified, use either the value from the + * input image or, if nothing is defined, use the + * library default. + */ + if (tilewidth == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); + if (tilelength == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); + + if (tilewidth == 0 || tilelength == 0) + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); + TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); + } else { + /* + * RowsPerStrip is left unspecified: use either the + * value from the input image or, if nothing is defined, + * use the library default. + */ + if (rowsperstrip == (uint32) 0) + { + if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + if (compression != COMPRESSION_JPEG) + { + if (rowsperstrip > length) + rowsperstrip = length; + } + } + else + if (rowsperstrip == (uint32) -1) + rowsperstrip = length; + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + } + + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); + if (config != (uint16) -1) + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + else + CopyField(TIFFTAG_PLANARCONFIG, config); + if (spp <= 4) + CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); + CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); + +/* SMinSampleValue & SMaxSampleValue */ + switch (compression) { + /* These are references to GLOBAL variables set by defaults + * and /or the compression flag + */ + case COMPRESSION_JPEG: + if (((bps % 8) == 0) || ((bps % 12) == 0)) + { + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + else + { + TIFFError("writeSingleSection", + "JPEG compression requires 8 or 12 bits per sample"); + return (-1); + } + break; + case COMPRESSION_LZW: + case COMPRESSION_ADOBE_DEFLATE: + case COMPRESSION_DEFLATE: + if (predictor != (uint16)-1) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + else + CopyField(TIFFTAG_PREDICTOR, predictor); + break; + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + if (compression == COMPRESSION_CCITTFAX3) { + if (g3opts != (uint32) -1) + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); + else + CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); + } else + CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); + CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); + CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + break; + } + { uint32 len32; + void** data; + if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) + TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + } + { uint16 ninks; + const char* inknames; + if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { + TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); + if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { + int inknameslen = strlen(inknames) + 1; + const char* cp = inknames; + while (ninks > 1) { + cp = strchr(cp, '\0'); + if (cp) { + cp++; + inknameslen += (strlen(cp) + 1); + } + ninks--; + } + TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); + } + } + } + { + unsigned short pg0, pg1; + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { + if (pageNum < 0) /* only one input file */ + TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); + else + TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); + } + } + + for (p = tags; p < &tags[NTAGS]; p++) + CopyTag(p->tag, p->count, p->type); + + /* Update these since they are overwritten from input res by loop above */ + TIFFSetField(out, TIFFTAG_XRESOLUTION, (float)hres); + TIFFSetField(out, TIFFTAG_YRESOLUTION, (float)vres); + + /* Compute the tile or strip dimensions and write to disk */ + if (outtiled) + { + if (config == PLANARCONFIG_CONTIG) + writeBufferToContigTiles (out, sect_buff, length, width, spp, dump); + else + writeBufferToSeparateTiles (out, sect_buff, length, width, spp, dump); + } + else + { + if (config == PLANARCONFIG_CONTIG) + writeBufferToContigStrips (out, sect_buff, length); + else + writeBufferToSeparateStrips(out, sect_buff, length, width, spp, dump); + } + + if (!TIFFWriteDirectory(out)) + { + TIFFClose(out); + return (-1); + } + + return (0); + } /* end writeSingleSection */ + + +/* Create a buffer to write one section at a time */ +static int +createImageSection(uint32 sectsize, unsigned char **sect_buff_ptr) + { + unsigned char *sect_buff = NULL; + unsigned char *new_buff = NULL; + static uint32 prev_sectsize = 0; + + sect_buff = *sect_buff_ptr; + + if (!sect_buff) + { + sect_buff = (unsigned char *)_TIFFmalloc(sectsize); + *sect_buff_ptr = sect_buff; + _TIFFmemset(sect_buff, 0, sectsize); + } + else + { + if (prev_sectsize < sectsize) + { + new_buff = _TIFFrealloc(sect_buff, sectsize); + if (!new_buff) + { + free (sect_buff); + sect_buff = (unsigned char *)_TIFFmalloc(sectsize); + } + else + sect_buff = new_buff; + + _TIFFmemset(sect_buff, 0, sectsize); + } + } + + if (!sect_buff) + { + TIFFError("createImageSection", "Unable to allocate/reallocate section buffer"); + return (-1); + } + prev_sectsize = sectsize; + *sect_buff_ptr = sect_buff; + + return (0); + } /* end createImageSection */ + + +/* Process selections defined by regions, zones, margins, or fixed sized areas */ +static int +processCropSelections(struct image_data *image, struct crop_mask *crop, + unsigned char **read_buff_ptr, struct buffinfo seg_buffs[]) + { + int i; + uint32 width, length, total_width, total_length; + tsize_t cropsize; + unsigned char *crop_buff = NULL; + unsigned char *read_buff = NULL; + unsigned char *next_buff = NULL; + tsize_t prev_cropsize = 0; + + read_buff = *read_buff_ptr; + + if (crop->img_mode == COMPOSITE_IMAGES) + { + cropsize = crop->bufftotal; + crop_buff = seg_buffs[0].buffer; + if (!crop_buff) + crop_buff = (unsigned char *)_TIFFmalloc(cropsize); + else + { + prev_cropsize = seg_buffs[0].size; + if (prev_cropsize < cropsize) + { + next_buff = _TIFFrealloc(crop_buff, cropsize); + if (! next_buff) + { + _TIFFfree (crop_buff); + crop_buff = (unsigned char *)_TIFFmalloc(cropsize); + } + else + crop_buff = next_buff; + } + } + + if (!crop_buff) + { + TIFFError("processCropSelections", "Unable to allocate/reallocate crop buffer"); + return (-1); + } + + _TIFFmemset(crop_buff, 0, cropsize); + seg_buffs[0].buffer = crop_buff; + seg_buffs[0].size = cropsize; + + /* Checks for matching width or length as required */ + if (extractCompositeRegions(image, crop, read_buff, crop_buff) != 0) + return (1); + + if (crop->crop_mode & CROP_INVERT) + { + switch (crop->photometric) + { + /* Just change the interpretation */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + image->photometric = crop->photometric; + break; + case INVERT_DATA_ONLY: + case INVERT_DATA_AND_TAG: + if (invertImage(image->photometric, image->spp, image->bps, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("processCropSelections", + "Failed to invert colorspace for composite regions"); + return (-1); + } + if (crop->photometric == INVERT_DATA_AND_TAG) + { + switch (image->photometric) + { + case PHOTOMETRIC_MINISWHITE: + image->photometric = PHOTOMETRIC_MINISBLACK; + break; + case PHOTOMETRIC_MINISBLACK: + image->photometric = PHOTOMETRIC_MINISWHITE; + break; + default: + break; + } + } + break; + default: break; + } + } + + /* Mirror and Rotate will not work with multiple regions unless they are the same width */ + if (crop->crop_mode & CROP_MIRROR) + { + if (mirrorImage(image->spp, image->bps, crop->mirror, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("processCropSelections", "Failed to mirror composite regions %s", + (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); + return (-1); + } + } + + if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ + { + if (rotateImage(crop->rotation, image, &crop->combined_width, + &crop->combined_length, &crop_buff)) + { + TIFFError("processCropSelections", + "Failed to rotate composite regions by %d degrees", crop->rotation); + return (-1); + } + seg_buffs[0].buffer = crop_buff; + seg_buffs[0].size = (((crop->combined_width * image->bps + 7 ) / 8) + * image->spp) * crop->combined_length; + } + } + else /* Separated Images */ + { + total_width = total_length = 0; + for (i = 0; i < crop->selections; i++) + { + cropsize = crop->bufftotal; + crop_buff = seg_buffs[i].buffer; + if (!crop_buff) + crop_buff = (unsigned char *)_TIFFmalloc(cropsize); + else + { + prev_cropsize = seg_buffs[0].size; + if (prev_cropsize < cropsize) + { + next_buff = _TIFFrealloc(crop_buff, cropsize); + if (! next_buff) + { + _TIFFfree (crop_buff); + crop_buff = (unsigned char *)_TIFFmalloc(cropsize); + } + else + crop_buff = next_buff; + } + } + + if (!crop_buff) + { + TIFFError("processCropSelections", "Unable to allocate/reallocate crop buffer"); + return (-1); + } + + _TIFFmemset(crop_buff, 0, cropsize); + seg_buffs[i].buffer = crop_buff; + seg_buffs[i].size = cropsize; + + if (extractSeparateRegion(image, crop, read_buff, crop_buff, i)) + { + TIFFError("processCropSelections", "Unable to extract cropped region %d from image", i); + return (-1); + } + + width = crop->regionlist[i].width; + length = crop->regionlist[i].length; + + if (crop->crop_mode & CROP_INVERT) + { + switch (crop->photometric) + { + /* Just change the interpretation */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + image->photometric = crop->photometric; + break; + case INVERT_DATA_ONLY: + case INVERT_DATA_AND_TAG: + if (invertImage(image->photometric, image->spp, image->bps, + width, length, crop_buff)) + { + TIFFError("processCropSelections", + "Failed to invert colorspace for region"); + return (-1); + } + if (crop->photometric == INVERT_DATA_AND_TAG) + { + switch (image->photometric) + { + case PHOTOMETRIC_MINISWHITE: + image->photometric = PHOTOMETRIC_MINISBLACK; + break; + case PHOTOMETRIC_MINISBLACK: + image->photometric = PHOTOMETRIC_MINISWHITE; + break; + default: + break; + } + } + break; + default: break; + } + } + + if (crop->crop_mode & CROP_MIRROR) + { + if (mirrorImage(image->spp, image->bps, crop->mirror, + width, length, crop_buff)) + { + TIFFError("processCropSelections", "Failed to mirror crop region %s", + (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); + return (-1); + } + } + + if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ + { + if (rotateImage(crop->rotation, image, &crop->regionlist[i].width, + &crop->regionlist[i].length, &crop_buff)) + { + TIFFError("processCropSelections", + "Failed to rotate crop region by %d degrees", crop->rotation); + return (-1); + } + total_width += crop->regionlist[i].width; + total_length += crop->regionlist[i].length; + crop->combined_width = total_width; + crop->combined_length = total_length; + seg_buffs[i].buffer = crop_buff; + seg_buffs[i].size = (((crop->regionlist[i].width * image->bps + 7 ) / 8) + * image->spp) * crop->regionlist[i].length; + } + } + } + return (0); + } /* end processCropSelections */ + +/* Copy the crop section of the data from the current image into a buffer + * and adjust the IFD values to reflect the new size. If no cropping is + * required, use the origial read buffer as the crop buffer. + * + * There is quite a bit of redundancy between this routine and the more + * specialized processCropSelections, but this provides + * the most optimized path when no Zones or Regions are required. + */ +static int +createCroppedImage(struct image_data *image, struct crop_mask *crop, + unsigned char **read_buff_ptr, unsigned char **crop_buff_ptr) + { + tsize_t cropsize; + unsigned char *read_buff = NULL; + unsigned char *crop_buff = NULL; + unsigned char *new_buff = NULL; + static tsize_t prev_cropsize = 0; + + read_buff = *read_buff_ptr; + + /* process full image, no crop buffer needed */ + crop_buff = read_buff; + *crop_buff_ptr = read_buff; + crop->combined_width = image->width; + crop->combined_length = image->length; + + cropsize = crop->bufftotal; + crop_buff = *crop_buff_ptr; + if (!crop_buff) + { + crop_buff = (unsigned char *)_TIFFmalloc(cropsize); + *crop_buff_ptr = crop_buff; + _TIFFmemset(crop_buff, 0, cropsize); + prev_cropsize = cropsize; + } + else + { + if (prev_cropsize < cropsize) + { + new_buff = _TIFFrealloc(crop_buff, cropsize); + if (!new_buff) + { + free (crop_buff); + crop_buff = (unsigned char *)_TIFFmalloc(cropsize); + } + else + crop_buff = new_buff; + _TIFFmemset(crop_buff, 0, cropsize); + } + } + + if (!crop_buff) + { + TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer"); + return (-1); + } + *crop_buff_ptr = crop_buff; + + if (crop->crop_mode & CROP_INVERT) + { + switch (crop->photometric) + { + /* Just change the interpretation */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + image->photometric = crop->photometric; + break; + case INVERT_DATA_ONLY: + case INVERT_DATA_AND_TAG: + if (invertImage(image->photometric, image->spp, image->bps, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("createCroppedImage", + "Failed to invert colorspace for image or cropped selection"); + return (-1); + } + if (crop->photometric == INVERT_DATA_AND_TAG) + { + switch (image->photometric) + { + case PHOTOMETRIC_MINISWHITE: + image->photometric = PHOTOMETRIC_MINISBLACK; + break; + case PHOTOMETRIC_MINISBLACK: + image->photometric = PHOTOMETRIC_MINISWHITE; + break; + default: + break; + } + } + break; + default: break; + } + } + + if (crop->crop_mode & CROP_MIRROR) + { + if (mirrorImage(image->spp, image->bps, crop->mirror, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("createCroppedImage", "Failed to mirror image or cropped selection %s", + (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); + return (-1); + } + } + + if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ + { + if (rotateImage(crop->rotation, image, &crop->combined_width, + &crop->combined_length, crop_buff_ptr)) + { + TIFFError("createCroppedImage", + "Failed to rotate image or cropped selection by %d degrees", crop->rotation); + return (-1); + } + } + + if (crop_buff == read_buff) /* we used the read buffer for the crop buffer */ + *read_buff_ptr = NULL; /* so we don't try to free it later */ + + return (0); + } /* end createCroppedImage */ + + +/* Code in this function is heavily indebted to code in tiffcp + * with modifications by Richard Nolde to handle orientation correctly. + * It will have to be updated significantly if support is added to + * extract one or more samples from original image since the + * original code assumes we are always copying all samples. + * Use of global variables for config, compression and others + * should be replaced by addition to the crop_mask struct (which + * will be renamed to proc_opts indicating that is controlls + * user supplied processing options, not just cropping) and + * then passed in as an argument. + */ +static int +writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, + struct dump_opts *dump, uint32 width, uint32 length, + unsigned char *crop_buff, int pagenum, int total_pages) + { + uint16 bps, spp; + uint16 input_compression, input_photometric; + uint16 input_planar; + struct cpTag* p; + + input_compression = image->compression; + input_photometric = image->photometric; + spp = image->spp; + bps = image->bps; + + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bps); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); + +#ifdef DEBUG2 + TIFFError("writeCroppedImage", "Input compression: %s", + (input_compression == COMPRESSION_OJPEG) ? "Old Jpeg" : + ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" : "Non Jpeg")); +#endif + + if (compression != (uint16)-1) + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + else + { + if (input_compression == COMPRESSION_OJPEG) + { + compression = COMPRESSION_JPEG; + jpegcolormode = JPEGCOLORMODE_RAW; + TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + } + else + CopyField(TIFFTAG_COMPRESSION, compression); + } + + if (compression == COMPRESSION_JPEG) + { + if ((input_photometric == PHOTOMETRIC_PALETTE) || /* color map indexed */ + (input_photometric == PHOTOMETRIC_MASK)) /* $holdout mask */ + { + TIFFError ("writeCroppedImage", + "JPEG compression cannot be used with %s image data", + (input_photometric == PHOTOMETRIC_PALETTE) ? + "palette" : "mask"); + return (-1); + } + if ((input_photometric == PHOTOMETRIC_RGB) && + (jpegcolormode == JPEGCOLORMODE_RGB)) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); + } + else + { + if (compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24) + { + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, spp == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + } + else + { + if (input_compression == COMPRESSION_SGILOG || + input_compression == COMPRESSION_SGILOG24) + { + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, spp == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + } + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, image->photometric); + } + } + + if (((input_photometric == PHOTOMETRIC_LOGL) || + (input_photometric == PHOTOMETRIC_LOGLUV)) && + ((compression != COMPRESSION_SGILOG) && + (compression != COMPRESSION_SGILOG24))) + { + TIFFError("writeCroppedImage", + "LogL and LogLuv source data require SGI_LOG or SGI_LOG24 compression"); + return (-1); + } + + if (fillorder != 0) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + else + CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); + + /* The loadimage function reads input orientation and sets + * image->orientation. The correct_image_orientation function + * applies the required rotation and mirror operations to + * present the data in TOPLEFT orientation and updates + * image->orientation if any transforms are performed, + * as per EXIF standard. + */ + TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation); + + /* + * Choose tiles/strip for the output image according to + * the command line arguments (-tiles, -strips) and the + * structure of the input image. + */ + if (outtiled == -1) + outtiled = TIFFIsTiled(in); + if (outtiled) { + /* + * Setup output file's tile width&height. If either + * is not specified, use either the value from the + * input image or, if nothing is defined, use the + * library default. + */ + if (tilewidth == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); + if (tilelength == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); + + if (tilewidth == 0 || tilelength == 0) + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); + TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); + } else { + /* + * RowsPerStrip is left unspecified: use either the + * value from the input image or, if nothing is defined, + * use the library default. + */ + if (rowsperstrip == (uint32) 0) + { + if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + if (compression != COMPRESSION_JPEG) + { + if (rowsperstrip > length) + rowsperstrip = length; + } + } + else + if (rowsperstrip == (uint32) -1) + rowsperstrip = length; + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + } + + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); + if (config != (uint16) -1) + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + else + CopyField(TIFFTAG_PLANARCONFIG, config); + if (spp <= 4) + CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); + CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); + +/* SMinSampleValue & SMaxSampleValue */ + switch (compression) { + case COMPRESSION_JPEG: + if (((bps % 8) == 0) || ((bps % 12) == 0)) + { + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + else + { + TIFFError("writeCroppedImage", + "JPEG compression requires 8 or 12 bits per sample"); + return (-1); + } + break; + case COMPRESSION_LZW: + case COMPRESSION_ADOBE_DEFLATE: + case COMPRESSION_DEFLATE: + if (predictor != (uint16)-1) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + else + CopyField(TIFFTAG_PREDICTOR, predictor); + break; + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + if (bps != 1) + { + TIFFError("writeCroppedImage", + "Group 3/4 compression is not usable with bps > 1"); + return (-1); + } + if (compression == COMPRESSION_CCITTFAX3) { + if (g3opts != (uint32) -1) + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); + else + CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); + } else + CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); + CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); + CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + break; + case COMPRESSION_NONE: + break; + default: break; + } + { uint32 len32; + void** data; + if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) + TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + } + { uint16 ninks; + const char* inknames; + if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { + TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); + if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { + int inknameslen = strlen(inknames) + 1; + const char* cp = inknames; + while (ninks > 1) { + cp = strchr(cp, '\0'); + if (cp) { + cp++; + inknameslen += (strlen(cp) + 1); + } + ninks--; + } + TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); + } + } + } + { + unsigned short pg0, pg1; + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { + TIFFSetField(out, TIFFTAG_PAGENUMBER, pagenum, total_pages); + } + } + + for (p = tags; p < &tags[NTAGS]; p++) + CopyTag(p->tag, p->count, p->type); + + /* Compute the tile or strip dimensions and write to disk */ + if (outtiled) + { + if (config == PLANARCONFIG_CONTIG) + { + if (writeBufferToContigTiles (out, crop_buff, length, width, spp, dump)) + TIFFError("","Unable to write contiguous tile data for page %d", pagenum); + } + else + { + if (writeBufferToSeparateTiles (out, crop_buff, length, width, spp, dump)) + TIFFError("","Unable to write separate tile data for page %d", pagenum); + } + } + else + { + if (config == PLANARCONFIG_CONTIG) + { + if (writeBufferToContigStrips (out, crop_buff, length)) + TIFFError("","Unable to write contiguous strip data for page %d", pagenum); + } + else + { + if (writeBufferToSeparateStrips(out, crop_buff, length, width, spp, dump)) + TIFFError("","Unable to write separate strip data for page %d", pagenum); + } + } + + if (!TIFFWriteDirectory(out)) + { + TIFFError("","Failed to write IFD for page number %d", pagenum); + TIFFClose(out); + return (-1); + } + + return (0); + } /* end writeCroppedImage */ + +static int +rotateContigSamples8bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0; + uint32 src_byte = 0, src_bit = 0; + uint32 row, rowsize = 0, bit_offset = 0; + uint8 matchbits = 0, maskbits = 0; + uint8 buff1 = 0, buff2 = 0; + uint8 *next; + tsample_t sample; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples8bits","Invalid src or destination buffer"); + return (1); + } + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint8)-1 >> ( 8 - bps); + buff1 = buff2 = 0; + + for (row = 0; row < length ; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (8 - src_bit - bps); + buff1 = ((*next) & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + } + else + { + buff2 = (buff2 | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + } + + return (0); + } /* end rotateContigSamples8bits */ + + +static int +rotateContigSamples16bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0; + uint32 row, rowsize, bit_offset; + uint32 src_byte = 0, src_bit = 0; + uint16 matchbits = 0, maskbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + uint8 *next; + tsample_t sample; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples16bits","Invalid src or destination buffer"); + return (1); + } + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint16)-1 >> (16 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (16 - src_bit - bps); + if (little_endian) + buff1 = (next[0] << 8) | next[1]; + else + buff1 = (next[1] << 8) | next[0]; + + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + } + else + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + if (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + } + + return (0); + } /* end rotateContigSamples16bits */ + +static int +rotateContigSamples24bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0; + uint32 row, rowsize, bit_offset; + uint32 src_byte = 0, src_bit = 0; + uint32 matchbits = 0, maskbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + uint8 *next; + tsample_t sample; + + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples24bits","Invalid src or destination buffer"); + return (1); + } + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint32)-1 >> (32 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (32 - src_bit - bps); + if (little_endian) + buff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | next[3]; + else + buff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | next[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 16) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end rotateContigSamples24bits */ + +static int +rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0, shift_width = 0; + int bytes_per_sample, bytes_per_pixel; + uint32 row, rowsize, bit_offset; + uint32 src_byte, src_bit; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *next; + tsample_t sample; + + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples24bits","Invalid src or destination buffer"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint64)-1 >> (64 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | next[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | next[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end rotateContigSamples32bits */ + + +/* Rotate an image by a multiple of 90 degrees clockwise */ +static int +rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, + uint32 *img_length, unsigned char **ibuff_ptr) + { + int shift_width; + uint32 bytes_per_pixel, bytes_per_sample; + uint32 row, rowsize, src_offset, dst_offset; + uint32 i, col, width, length; + uint32 colsize, buffsize, col_offset, pix_offset; + unsigned char *ibuff; + unsigned char *src; + unsigned char *dst; + uint16 spp, bps; + float res_temp; + unsigned char *rbuff = NULL; + + width = *img_width; + length = *img_length; + spp = image->spp; + bps = image->bps; + + rowsize = ((bps * spp * width) + 7) / 8; + colsize = ((bps * spp * length) + 7) / 8; + if ((colsize * width) > (rowsize * length)) + buffsize = (colsize + 1) * width; + else + buffsize = (rowsize + 1) * length; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + switch (rotation) + { + case 0: + case 360: return (0); + case 90: + case 180: + case 270: break; + default: TIFFError("rotateImage", "Invalid rotation angle %d", rotation); + return (-1); + } + + if (!(rbuff = (unsigned char *)_TIFFmalloc(buffsize))) + { + TIFFError("rotateImage", "Unable to allocate rotation buffer of %1u bytes", buffsize); + return (-1); + } + _TIFFmemset(rbuff, '\0', buffsize); + + ibuff = *ibuff_ptr; + switch (rotation) + { + case 180: if ((bps % 8) == 0) /* byte alligned data */ + { + src = ibuff; + pix_offset = (spp * bps) / 8; + for (row = 0; row < length; row++) + { + dst_offset = (length - row - 1) * rowsize; + for (col = 0; col < width; col++) + { + col_offset = (width - col - 1) * pix_offset; + dst = rbuff + dst_offset + col_offset; + + for (i = 0; i < bytes_per_pixel; i++) + *dst++ = *src++; + } + } + } + else + { /* non 8 bit per sample data */ + for (row = 0; row < length; row++) + { + src_offset = row * rowsize; + dst_offset = (length - row - 1) * rowsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + switch (shift_width) + { + case 1: if (bps == 1) + { + if (reverseSamples8bits(spp, bps, width, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + } + if (reverseSamples16bits(spp, bps, width, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 2: if (reverseSamples24bits(spp, bps, width, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 3: + case 4: + case 5: if (reverseSamples32bits(spp, bps, width, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + _TIFFfree(rbuff); + return (-1); + } + } + } + _TIFFfree(ibuff); + *(ibuff_ptr) = rbuff; + break; + + case 90: if ((bps % 8) == 0) /* byte aligned data */ + { + for (col = 0; col < width; col++) + { + src_offset = ((length - 1) * rowsize) + (col * bytes_per_pixel); + dst_offset = col * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + for (row = length; row > 0; row--) + { + for (i = 0; i < bytes_per_pixel; i++) + *dst++ = *(src + i); + src -= rowsize; + } + } + } + else + { /* non 8 bit per sample data */ + for (col = 0; col < width; col++) + { + src_offset = (length - 1) * rowsize; + dst_offset = col * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + switch (shift_width) + { + case 1: if (bps == 1) + { + if (rotateContigSamples8bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + } + if (rotateContigSamples16bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 2: if (rotateContigSamples24bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 3: + case 4: + case 5: if (rotateContigSamples32bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + _TIFFfree(rbuff); + return (-1); + } + } + } + _TIFFfree(ibuff); + *(ibuff_ptr) = rbuff; + + *img_width = length; + *img_length = width; + image->width = length; + image->length = width; + res_temp = image->xres; + image->xres = image->yres; + image->yres = res_temp; + break; + + case 270: if ((bps % 8) == 0) /* byte aligned data */ + { + for (col = 0; col < width; col++) + { + src_offset = col * bytes_per_pixel; + dst_offset = (width - col - 1) * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + for (row = length; row > 0; row--) + { + for (i = 0; i < bytes_per_pixel; i++) + *dst++ = *(src + i); + src += rowsize; + } + } + } + else + { /* non 8 bit per sample data */ + for (col = 0; col < width; col++) + { + src_offset = 0; + dst_offset = (width - col - 1) * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + switch (shift_width) + { + case 1: if (bps == 1) + { + if (rotateContigSamples8bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + } + if (rotateContigSamples16bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 2: if (rotateContigSamples24bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 3: + case 4: + case 5: if (rotateContigSamples32bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + _TIFFfree(rbuff); + return (-1); + } + } + } + _TIFFfree(ibuff); + *(ibuff_ptr) = rbuff; + + *img_width = length; + *img_length = width; + image->width = length; + image->length = width; + res_temp = image->xres; + image->xres = image->yres; + image->yres = res_temp; + break; + default: + break; + } + + return (0); + } /* end rotateImage */ + +static int +reverseSamples8bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0; + uint32 col; + uint32 src_byte, src_bit; + uint32 bit_offset = 0; + uint8 match_bits = 0, mask_bits = 0; + uint8 buff1 = 0, buff2 = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) + { + TIFFError("reverseSamples8bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint8)-1 >> ( 8 - bps); + dst = obuff; + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (8 - src_bit - bps); + buff1 = ((*src) & match_bits) << (src_bit); + + if (ready_bits < 8) + buff2 = (buff2 | (buff1 >> ready_bits)); + else /* If we have a full buffer's worth, write it out */ + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + } + ready_bits += bps; + } + } + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + } + + return (0); + } /* end reverseSamples8bits */ + + +static int +reverseSamples16bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0; + uint32 col; + uint32 src_byte = 0, high_bit = 0; + uint32 bit_offset = 0; + uint16 match_bits = 0, mask_bits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) + { + TIFFError("reverseSample16bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint16)-1 >> (16 - bps); + dst = obuff; + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + high_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + high_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (16 - high_bit - bps); + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + buff1 = (buff1 & match_bits) << (high_bit); + + if (ready_bits < 8) + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + if (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + } + + return (0); + } /* end reverseSamples16bits */ + +static int +reverseSamples24bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0; + uint32 col; + uint32 src_byte = 0, high_bit = 0; + uint32 bit_offset = 0; + uint32 match_bits = 0, mask_bits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) + { + TIFFError("reverseSamples24bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint32)-1 >> (32 - bps); + dst = obuff; + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + high_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + high_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (32 - high_bit - bps); + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + buff1 = (buff1 & match_bits) << (high_bit); + + if (ready_bits < 16) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end reverseSamples24bits */ + + +static int +reverseSamples32bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0, shift_width = 0; + int bytes_per_sample, bytes_per_pixel; + uint32 bit_offset; + uint32 src_byte = 0, high_bit = 0; + uint32 col; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 mask_bits = 0, match_bits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) + { + TIFFError("reverseSamples32bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint64)-1 >> (64 - bps); + dst = obuff; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + high_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + high_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (64 - high_bit - bps); + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & match_bits) << (high_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end reverseSamples32bits */ + +static int +reverseSamplesBytes (uint16 spp, uint16 bps, uint32 width, + uint8 *src, uint8 *dst) + { + int i; + uint32 col, bytes_per_pixel, col_offset; + uint8 bytebuff1; + unsigned char swapbuff[32]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("reverseSamplesBytes","Invalid input or output buffer"); + return (1); + } + + bytes_per_pixel = ((bps * spp) + 7) / 8; + switch (bps / 8) + { + case 8: /* Use memcpy for multiple bytes per sample data */ + case 4: + case 3: + case 2: for (col = 0; col < (width / 2); col++) + { + col_offset = col * bytes_per_pixel; + _TIFFmemcpy (swapbuff, src + col_offset, bytes_per_pixel); + _TIFFmemcpy (src + col_offset, dst - col_offset - bytes_per_pixel, bytes_per_pixel); + _TIFFmemcpy (dst - col_offset - bytes_per_pixel, swapbuff, bytes_per_pixel); + } + break; + case 1: /* Use byte copy only for single byte per sample data */ + for (col = 0; col < (width / 2); col++) + { + for (i = 0; i < spp; i++) + { + bytebuff1 = *src; + *src++ = *(dst - spp + i); + *(dst - spp + i) = bytebuff1; + } + dst -= spp; + } + break; + default: TIFFError("reverseSamplesBytes","Unsupported bit depth %d", bps); + return (1); + } + return (0); + } /* end reverseSamplesBytes */ + + +/* Mirror an image horizontally or vertically */ +static int +mirrorImage(uint16 spp, uint16 bps, uint16 mirror, uint32 width, uint32 length, unsigned char *ibuff) + { + int shift_width; + uint32 bytes_per_pixel, bytes_per_sample; + uint32 row, rowsize, row_offset; + unsigned char *line_buff = NULL; + unsigned char *src; + unsigned char *dst; + + src = ibuff; + rowsize = ((width * bps * spp) + 7) / 8; + switch (mirror) + { + case MIRROR_BOTH: + case MIRROR_VERT: + line_buff = (unsigned char *)_TIFFmalloc(rowsize); + if (line_buff == NULL) + { + TIFFError ("mirrorImage", "Unable to allocate mirror line buffer of %1u bytes", rowsize); + return (-1); + } + + dst = ibuff + (rowsize * (length - 1)); + for (row = 0; row < length / 2; row++) + { + _TIFFmemcpy(line_buff, src, rowsize); + _TIFFmemcpy(src, dst, rowsize); + _TIFFmemcpy(dst, line_buff, rowsize); + src += (rowsize); + dst -= (rowsize); + } + if (line_buff) + _TIFFfree(line_buff); + if (mirror == MIRROR_VERT) + break; + case MIRROR_HORIZ : + if ((bps % 8) == 0) /* byte alligned data */ + { + for (row = 0; row < length; row++) + { + row_offset = row * rowsize; + src = ibuff + row_offset; + dst = ibuff + row_offset + rowsize; + if (reverseSamplesBytes(spp, bps, width, src, dst)) + { + return (-1); + } + } + } + else + { /* non 8 bit per sample data */ + if (!(line_buff = (unsigned char *)_TIFFmalloc(rowsize + 1))) + { + TIFFError("mirrorImage", "Unable to allocate mirror line buffer"); + return (-1); + } + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + for (row = 0; row < length; row++) + { + row_offset = row * rowsize; + src = ibuff + row_offset; + _TIFFmemset (line_buff, '\0', rowsize); + switch (shift_width) + { + case 1: if (reverseSamples16bits(spp, bps, width, src, line_buff)) + { + _TIFFfree(line_buff); + return (-1); + } + _TIFFmemcpy (src, line_buff, rowsize); + break; + case 2: if (reverseSamples24bits(spp, bps, width, src, line_buff)) + { + _TIFFfree(line_buff); + return (-1); + } + _TIFFmemcpy (src, line_buff, rowsize); + break; + case 3: + case 4: + case 5: if (reverseSamples32bits(spp, bps, width, src, line_buff)) + { + _TIFFfree(line_buff); + return (-1); + } + _TIFFmemcpy (src, line_buff, rowsize); + break; + default: TIFFError("mirrorImage","Unsupported bit depth %d", bps); + _TIFFfree(line_buff); + return (-1); + } + } + if (line_buff) + _TIFFfree(line_buff); + } + break; + + default: TIFFError ("mirrorImage", "Invalid mirror axis %d", mirror); + return (-1); + break; + } + + return (0); + } + +/* Invert the light and dark values for a bilevel or grayscale image */ +static int +invertImage(uint16 photometric, uint16 spp, uint16 bps, uint32 width, uint32 length, unsigned char *work_buff) + { + uint32 row, col; + unsigned char bytebuff1, bytebuff2, bytebuff3, bytebuff4; + unsigned char *src; + uint16 *src_uint16; + uint32 *src_uint32; + + if (spp != 1) + { + TIFFError("invertImage", "Image inversion not supported for more than one sample per pixel"); + return (-1); + } + + if (photometric != PHOTOMETRIC_MINISWHITE && photometric != PHOTOMETRIC_MINISBLACK) + { + TIFFError("invertImage", "Only black and white and grayscale images can be inverted"); + return (-1); + } + + src = work_buff; + if (src == NULL) + { + TIFFError ("invertImage", "Invalid crop buffer passed to invertImage"); + return (-1); + } + + switch (bps) + { + case 32: src_uint32 = (uint32 *)src; + for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + *src_uint32 = (uint32)0xFFFFFFFF - *src_uint32; + src_uint32++; + } + break; + case 16: src_uint16 = (uint16 *)src; + for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + *src_uint16 = (uint16)0xFFFF - *src_uint16; + src_uint16++; + } + break; + case 8: for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + *src = (uint8)255 - *src; + src++; + } + break; + case 4: for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + bytebuff1 = 16 - (uint8)(*src & 240 >> 4); + bytebuff2 = 16 - (*src & 15); + *src = bytebuff1 << 4 & bytebuff2; + src++; + } + break; + case 2: for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + bytebuff1 = 4 - (uint8)(*src & 192 >> 6); + bytebuff2 = 4 - (uint8)(*src & 48 >> 4); + bytebuff3 = 4 - (uint8)(*src & 12 >> 2); + bytebuff4 = 4 - (uint8)(*src & 3); + *src = (bytebuff1 << 6) || (bytebuff2 << 4) || (bytebuff3 << 2) || bytebuff4; + src++; + } + break; + case 1: for (row = 0; row < length; row++) + for (col = 0; col < width; col += 8 /(spp * bps)) + { + *src = ~(*src); + src++; + } + break; + default: TIFFError("invertImage", "Unsupported bit depth %d", bps); + return (-1); + } + + return (0); + } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffdither.c b/libs/tiff-4.0.2/tools/tiffdither.c similarity index 96% rename from libs/tiff-3.8.2/tools/tiffdither.c rename to libs/tiff-4.0.2/tools/tiffdither.c index f337c27256..3a377ac0a9 100644 --- a/libs/tiff-3.8.2/tools/tiffdither.c +++ b/libs/tiff-4.0.2/tools/tiffdither.c @@ -1,4 +1,4 @@ -/* $Id: tiffdither.c,v 1.9 2005/04/27 18:37:19 dron Exp $ */ +/* $Id: tiffdither.c,v 1.12 2010-03-10 18:56:50 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,6 +34,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) @@ -77,7 +81,8 @@ fsdither(TIFF* in, TIFF* out) * Get first line */ if (TIFFReadScanline(in, inputline, 0, 0) <= 0) - return; + goto skip_on_error; + inptr = inputline; nextptr = nextline; for (j = 0; j < imagewidth; ++j) @@ -128,6 +133,7 @@ fsdither(TIFF* in, TIFF* out) if (TIFFWriteScanline(out, outline, i-1, 0) < 0) break; } + skip_on_error: _TIFFfree(inputline); _TIFFfree(thisline); _TIFFfree(nextline); @@ -191,7 +197,6 @@ main(int argc, char* argv[]) float floatv; char thing[1024]; uint32 rowsperstrip = (uint32) -1; - int onestrip = 0; uint16 fillorder = 0; int c; extern int optind; @@ -213,7 +218,6 @@ main(int argc, char* argv[]) break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); - onestrip = 0; break; case 't': threshold = atoi(optarg); @@ -263,10 +267,7 @@ main(int argc, char* argv[]) CopyField(TIFFTAG_XRESOLUTION, floatv); CopyField(TIFFTAG_YRESOLUTION, floatv); CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); - if (onestrip) - rowsperstrip = imagelength-1; - else - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); switch (compression) { case COMPRESSION_CCITTFAX3: @@ -323,3 +324,10 @@ usage(void) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffdump.c b/libs/tiff-4.0.2/tools/tiffdump.c similarity index 52% rename from libs/tiff-3.8.2/tools/tiffdump.c rename to libs/tiff-4.0.2/tools/tiffdump.c index 9bbe9ecf74..c1caafbc74 100644 --- a/libs/tiff-3.8.2/tools/tiffdump.c +++ b/libs/tiff-4.0.2/tools/tiffdump.c @@ -1,4 +1,4 @@ -/* $Id: tiffdump.c,v 1.13 2005/11/21 03:35:06 fwarmerdam Exp $ */ +/* $Id: tiffdump.c,v 1.26 2012-06-15 21:51:54 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -46,35 +46,57 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#ifndef HAVE_GETOPT +extern int getopt(int, char**, char*); +#endif + #include "tiffio.h" #ifndef O_BINARY # define O_BINARY 0 #endif -char* appname; -char* curfile; -int swabflag; -int bigendian; -int typeshift[14]; /* data type shift counts */ -long typemask[14]; /* data type masks */ -uint32 maxitems = 24; /* maximum indirect data items to print */ +static union +{ + TIFFHeaderClassic classic; + TIFFHeaderBig big; + TIFFHeaderCommon common; +} hdr; +char* appname; +char* curfile; +int swabflag; +int bigendian; +int bigtiff; +uint32 maxitems = 24; /* maximum indirect data items to print */ -char* bytefmt = "%s%#02x"; /* BYTE */ -char* sbytefmt = "%s%d"; /* SBYTE */ -char* shortfmt = "%s%u"; /* SHORT */ -char* sshortfmt = "%s%d"; /* SSHORT */ -char* longfmt = "%s%lu"; /* LONG */ -char* slongfmt = "%s%ld"; /* SLONG */ -char* rationalfmt = "%s%g"; /* RATIONAL */ -char* srationalfmt = "%s%g"; /* SRATIONAL */ -char* floatfmt = "%s%g"; /* FLOAT */ -char* doublefmt = "%s%g"; /* DOUBLE */ -char* ifdfmt = "%s%#04x"; /* IFD offset */ +const char* bytefmt = "%s%#02x"; /* BYTE */ +const char* sbytefmt = "%s%d"; /* SBYTE */ +const char* shortfmt = "%s%u"; /* SHORT */ +const char* sshortfmt = "%s%d"; /* SSHORT */ +const char* longfmt = "%s%lu"; /* LONG */ +const char* slongfmt = "%s%ld"; /* SLONG */ +const char* ifdfmt = "%s%#04lx"; /* IFD offset */ +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) +const char* long8fmt = "%s%I64u"; /* LONG8 */ +const char* slong8fmt = "%s%I64d"; /* SLONG8 */ +const char* ifd8fmt = "%s%#08I64x"; /* IFD offset8*/ +#else +const char* long8fmt = "%s%llu"; /* LONG8 */ +const char* slong8fmt = "%s%lld"; /* SLONG8 */ +const char* ifd8fmt = "%s%#08llx"; /* IFD offset8*/ +#endif +const char* rationalfmt = "%s%g"; /* RATIONAL */ +const char* srationalfmt = "%s%g"; /* SRATIONAL */ +const char* floatfmt = "%s%g"; /* FLOAT */ +const char* doublefmt = "%s%g"; /* DOUBLE */ -static void dump(int, off_t); -extern int optind; -extern char* optarg; +static void dump(int, uint64); +extern int optind; +extern char* optarg; void usage() @@ -89,7 +111,7 @@ main(int argc, char* argv[]) int one = 1, fd; int multiplefiles = (argc > 1); int c; - uint32 diroff = (uint32) 0; + uint64 diroff = 0; bigendian = (*(char *)&one == 0); appname = argv[0]; @@ -102,7 +124,7 @@ main(int argc, char* argv[]) slongfmt = "%s%#lx"; break; case 'o': - diroff = (uint32) strtoul(optarg, NULL, 0); + diroff = (uint64) strtoul(optarg, NULL, 0); break; case 'm': maxitems = strtoul(optarg, NULL, 0); @@ -123,107 +145,83 @@ main(int argc, char* argv[]) printf("%s:\n", argv[optind]); curfile = argv[optind]; swabflag = 0; + bigtiff = 0; dump(fd, diroff); close(fd); } return (0); } -static TIFFHeader hdr; +#define ord(e) ((int)e) -#define ord(e) ((int)e) - -/* - * Initialize shift & mask tables and byte - * swapping state according to the file - * byte order. - */ -static void -InitByteOrder(int magic) -{ - typemask[0] = 0; - typemask[ord(TIFF_BYTE)] = 0xff; - typemask[ord(TIFF_SBYTE)] = 0xff; - typemask[ord(TIFF_UNDEFINED)] = 0xff; - typemask[ord(TIFF_SHORT)] = 0xffff; - typemask[ord(TIFF_SSHORT)] = 0xffff; - typemask[ord(TIFF_LONG)] = 0xffffffff; - typemask[ord(TIFF_SLONG)] = 0xffffffff; - typemask[ord(TIFF_IFD)] = 0xffffffff; - typemask[ord(TIFF_RATIONAL)] = 0xffffffff; - typemask[ord(TIFF_SRATIONAL)] = 0xffffffff; - typemask[ord(TIFF_FLOAT)] = 0xffffffff; - typemask[ord(TIFF_DOUBLE)] = 0xffffffff; - typeshift[0] = 0; - typeshift[ord(TIFF_LONG)] = 0; - typeshift[ord(TIFF_SLONG)] = 0; - typeshift[ord(TIFF_IFD)] = 0; - typeshift[ord(TIFF_RATIONAL)] = 0; - typeshift[ord(TIFF_SRATIONAL)] = 0; - typeshift[ord(TIFF_FLOAT)] = 0; - typeshift[ord(TIFF_DOUBLE)] = 0; - if (magic == TIFF_BIGENDIAN || magic == MDI_BIGENDIAN) { - typeshift[ord(TIFF_BYTE)] = 24; - typeshift[ord(TIFF_SBYTE)] = 24; - typeshift[ord(TIFF_SHORT)] = 16; - typeshift[ord(TIFF_SSHORT)] = 16; - swabflag = !bigendian; - } else { - typeshift[ord(TIFF_BYTE)] = 0; - typeshift[ord(TIFF_SBYTE)] = 0; - typeshift[ord(TIFF_SHORT)] = 0; - typeshift[ord(TIFF_SSHORT)] = 0; - swabflag = bigendian; - } -} - -static off_t ReadDirectory(int, unsigned, off_t); -static void ReadError(char*); -static void Error(const char*, ...); -static void Fatal(const char*, ...); +static uint64 ReadDirectory(int, unsigned, uint64); +static void ReadError(char*); +static void Error(const char*, ...); +static void Fatal(const char*, ...); static void -dump(int fd, off_t diroff) +dump(int fd, uint64 diroff) { unsigned i; lseek(fd, (off_t) 0, 0); - if (read(fd, (char*) &hdr, sizeof (hdr)) != sizeof (hdr)) + if (read(fd, (char*) &hdr, sizeof (TIFFHeaderCommon)) != sizeof (TIFFHeaderCommon)) ReadError("TIFF header"); - /* - * Setup the byte order handling. - */ - if (hdr.tiff_magic != TIFF_BIGENDIAN && hdr.tiff_magic != TIFF_LITTLEENDIAN && + if (hdr.common.tiff_magic != TIFF_BIGENDIAN + && hdr.common.tiff_magic != TIFF_LITTLEENDIAN && #if HOST_BIGENDIAN - // MDI is sensitive to the host byte order, unlike TIFF - MDI_BIGENDIAN != hdr.tiff_magic ) + /* MDI is sensitive to the host byte order, unlike TIFF */ + MDI_BIGENDIAN != hdr.common.tiff_magic #else - MDI_LITTLEENDIAN != hdr.tiff_magic ) + MDI_LITTLEENDIAN != hdr.common.tiff_magic #endif + ) { Fatal("Not a TIFF or MDI file, bad magic number %u (%#x)", - hdr.tiff_magic, hdr.tiff_magic); - InitByteOrder(hdr.tiff_magic); - /* - * Swap header if required. - */ - if (swabflag) { - TIFFSwabShort(&hdr.tiff_version); - TIFFSwabLong(&hdr.tiff_diroff); + hdr.common.tiff_magic, hdr.common.tiff_magic); } - /* - * Now check version (if needed, it's been byte-swapped). - * Note that this isn't actually a version number, it's a - * magic number that doesn't change (stupid). - */ - if (hdr.tiff_version != TIFF_VERSION) + if (hdr.common.tiff_magic == TIFF_BIGENDIAN + || hdr.common.tiff_magic == MDI_BIGENDIAN) + swabflag = !bigendian; + else + swabflag = bigendian; + if (swabflag) + TIFFSwabShort(&hdr.common.tiff_version); + if (hdr.common.tiff_version==42) + { + if (read(fd, (char*) &hdr.classic.tiff_diroff, 4) != 4) + ReadError("TIFF header"); + if (swabflag) + TIFFSwabLong(&hdr.classic.tiff_diroff); + printf("Magic: %#x <%s-endian> Version: %#x <%s>\n", + hdr.classic.tiff_magic, + hdr.classic.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", + 42,"ClassicTIFF"); + if (diroff == 0) + diroff = hdr.classic.tiff_diroff; + } + else if (hdr.common.tiff_version==43) + { + if (read(fd, (char*) &hdr.big.tiff_offsetsize, 12) != 12) + ReadError("TIFF header"); + if (swabflag) + { + TIFFSwabShort(&hdr.big.tiff_offsetsize); + TIFFSwabShort(&hdr.big.tiff_unused); + TIFFSwabLong8(&hdr.big.tiff_diroff); + } + printf("Magic: %#x <%s-endian> Version: %#x <%s>\n", + hdr.big.tiff_magic, + hdr.big.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", + 43,"BigTIFF"); + printf("OffsetSize: %#x Unused: %#x\n", + hdr.big.tiff_offsetsize,hdr.big.tiff_unused); + if (diroff == 0) + diroff = hdr.big.tiff_diroff; + bigtiff = 1; + } + else Fatal("Not a TIFF file, bad version number %u (%#x)", - hdr.tiff_version, hdr.tiff_version); - printf("Magic: %#x <%s-endian> Version: %#x\n", - hdr.tiff_magic, - hdr.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", - hdr.tiff_version); - if (diroff == 0) - diroff = hdr.tiff_diroff; + hdr.common.tiff_version, hdr.common.tiff_version); for (i = 0; diroff != 0; i++) { if (i > 0) putchar('\n'); @@ -231,161 +229,289 @@ dump(int fd, off_t diroff) } } -static int datawidth[] = { - 0, /* nothing */ - 1, /* TIFF_BYTE */ - 1, /* TIFF_ASCII */ - 2, /* TIFF_SHORT */ - 4, /* TIFF_LONG */ - 8, /* TIFF_RATIONAL */ - 1, /* TIFF_SBYTE */ - 1, /* TIFF_UNDEFINED */ - 2, /* TIFF_SSHORT */ - 4, /* TIFF_SLONG */ - 8, /* TIFF_SRATIONAL */ - 4, /* TIFF_FLOAT */ - 8, /* TIFF_DOUBLE */ - 4 /* TIFF_IFD */ +static const int datawidth[] = { + 0, /* 00 = undefined */ + 1, /* 01 = TIFF_BYTE */ + 1, /* 02 = TIFF_ASCII */ + 2, /* 03 = TIFF_SHORT */ + 4, /* 04 = TIFF_LONG */ + 8, /* 05 = TIFF_RATIONAL */ + 1, /* 06 = TIFF_SBYTE */ + 1, /* 07 = TIFF_UNDEFINED */ + 2, /* 08 = TIFF_SSHORT */ + 4, /* 09 = TIFF_SLONG */ + 8, /* 10 = TIFF_SRATIONAL */ + 4, /* 11 = TIFF_FLOAT */ + 8, /* 12 = TIFF_DOUBLE */ + 4, /* 13 = TIFF_IFD */ + 0, /* 14 = undefined */ + 0, /* 15 = undefined */ + 8, /* 16 = TIFF_LONG8 */ + 8, /* 17 = TIFF_SLONG8 */ + 8, /* 18 = TIFF_IFD8 */ }; -#define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0])) -static int TIFFFetchData(int, TIFFDirEntry*, void*); -static void PrintTag(FILE*, uint16); -static void PrintType(FILE*, uint16); -static void PrintData(FILE*, uint16, uint32, unsigned char*); -static void PrintByte(FILE*, const char*, TIFFDirEntry*); -static void PrintShort(FILE*, const char*, TIFFDirEntry*); -static void PrintLong(FILE*, const char*, TIFFDirEntry*); +#define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0])) +static void PrintTag(FILE*, uint16); +static void PrintType(FILE*, uint16); +static void PrintData(FILE*, uint16, uint32, unsigned char*); /* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ -static off_t -ReadDirectory(int fd, unsigned ix, off_t off) +static uint64 +ReadDirectory(int fd, unsigned int ix, uint64 off) { - register TIFFDirEntry *dp; - register unsigned int n; - TIFFDirEntry *dir = 0; uint16 dircount; - int space; - uint32 nextdiroff = 0; + uint32 direntrysize; + void* dirmem = NULL; + uint64 nextdiroff = 0; + uint32 n; + uint8* dp; if (off == 0) /* no more directories */ goto done; - if (lseek(fd, (off_t) off, 0) != off) { +#if defined(__WIN32__) && defined(_MSC_VER) + if (_lseeki64(fd, (__int64)off, SEEK_SET) != (__int64)off) { +#else + if (lseek(fd, (off_t)off, SEEK_SET) != (off_t)off) { +#endif Fatal("Seek error accessing TIFF directory"); goto done; } - if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) { - ReadError("directory count"); - goto done; + if (!bigtiff) { + if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) { + ReadError("directory count"); + goto done; + } + if (swabflag) + TIFFSwabShort(&dircount); + direntrysize = 12; + } else { + uint64 dircount64 = 0; + if (read(fd, (char*) &dircount64, sizeof (uint64)) != sizeof (uint64)) { + ReadError("directory count"); + goto done; + } + if (swabflag) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) { + Error("Sanity check on directory count failed"); + goto done; + } + dircount = (uint16)dircount64; + direntrysize = 20; } - if (swabflag) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)_TIFFmalloc(dircount * sizeof (TIFFDirEntry)); - if (dir == NULL) { + dirmem = _TIFFmalloc(dircount * direntrysize); + if (dirmem == NULL) { Fatal("No space for TIFF directory"); goto done; } - n = read(fd, (char*) dir, dircount*sizeof (*dp)); - if (n != dircount*sizeof (*dp)) { - n /= sizeof (*dp); + n = read(fd, (char*) dirmem, dircount*direntrysize); + if (n != dircount*direntrysize) { + n /= direntrysize; Error( - "Could only read %u of %u entries in directory at offset %#lx", - n, dircount, (unsigned long) off); +#if defined(__WIN32__) && defined(_MSC_VER) + "Could only read %lu of %u entries in directory at offset %#I64x", + (unsigned long)n, dircount, (unsigned __int64) off); +#else + "Could only read %lu of %u entries in directory at offset %#llx", + (unsigned long)n, dircount, (unsigned long long) off); +#endif dircount = n; - } - if (read(fd, (char*) &nextdiroff, sizeof (uint32)) != sizeof (uint32)) nextdiroff = 0; - if (swabflag) - TIFFSwabLong(&nextdiroff); - printf("Directory %u: offset %lu (%#lx) next %lu (%#lx)\n", ix, - (unsigned long)off, (unsigned long)off, - (unsigned long)nextdiroff, (unsigned long)nextdiroff); - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (swabflag) { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - PrintTag(stdout, dp->tdir_tag); - putchar(' '); - PrintType(stdout, dp->tdir_type); - putchar(' '); - printf("%lu<", (unsigned long) dp->tdir_count); - if (dp->tdir_type >= NWIDTHS) { - printf(">\n"); - continue; - } - space = dp->tdir_count * datawidth[dp->tdir_type]; - if (space <= 0) { - printf(">\n"); - Error("Invalid count for tag %u", dp->tdir_tag); - continue; - } - if (space <= 4) { - switch (dp->tdir_type) { - case TIFF_FLOAT: - case TIFF_UNDEFINED: - case TIFF_ASCII: { - unsigned char data[4]; - _TIFFmemcpy(data, &dp->tdir_offset, 4); - if (swabflag) - TIFFSwabLong((uint32*) data); - PrintData(stdout, - dp->tdir_type, dp->tdir_count, data); - break; - } - case TIFF_BYTE: - PrintByte(stdout, bytefmt, dp); - break; - case TIFF_SBYTE: - PrintByte(stdout, sbytefmt, dp); - break; - case TIFF_SHORT: - PrintShort(stdout, shortfmt, dp); - break; - case TIFF_SSHORT: - PrintShort(stdout, sshortfmt, dp); - break; - case TIFF_LONG: - PrintLong(stdout, longfmt, dp); - break; - case TIFF_SLONG: - PrintLong(stdout, slongfmt, dp); - break; - case TIFF_IFD: - PrintLong(stdout, ifdfmt, dp); - break; - } + } else { + if (!bigtiff) { + uint32 nextdiroff32; + if (read(fd, (char*) &nextdiroff32, sizeof (uint32)) != sizeof (uint32)) + nextdiroff32 = 0; + if (swabflag) + TIFFSwabLong(&nextdiroff32); + nextdiroff = nextdiroff32; } else { - unsigned char *data = (unsigned char *)_TIFFmalloc(space); - if (data) { - if (TIFFFetchData(fd, dp, data)) { - if (dp->tdir_count > maxitems) { - PrintData(stdout, dp->tdir_type, - maxitems, data); - printf(" ..."); - } else - PrintData(stdout, dp->tdir_type, - dp->tdir_count, data); - } - _TIFFfree(data); + if (read(fd, (char*) &nextdiroff, sizeof (uint64)) != sizeof (uint64)) + nextdiroff = 0; + if (swabflag) + TIFFSwabLong8(&nextdiroff); + } + } +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + printf("Directory %u: offset %I64u (%#I64x) next %I64u (%#I64x)\n", ix, + (unsigned __int64)off, (unsigned __int64)off, + (unsigned __int64)nextdiroff, (unsigned __int64)nextdiroff); +#else + printf("Directory %u: offset %llu (%#llx) next %llu (%#llx)\n", ix, + (unsigned long long)off, (unsigned long long)off, + (unsigned long long)nextdiroff, (unsigned long long)nextdiroff); +#endif + for (dp = (uint8*)dirmem, n = dircount; n > 0; n--) { + uint16 tag; + uint16 type; + uint16 typewidth; + uint64 count; + uint64 datasize; + int datafits; + void* datamem; + uint64 dataoffset; + int datatruncated; + tag = *(uint16*)dp; + if (swabflag) + TIFFSwabShort(&tag); + dp += sizeof(uint16); + type = *(uint16*)dp; + dp += sizeof(uint16); + if (swabflag) + TIFFSwabShort(&type); + PrintTag(stdout, tag); + putchar(' '); + PrintType(stdout, type); + putchar(' '); + if (!bigtiff) + { + uint32 count32; + count32 = *(uint32*)dp; + if (swabflag) + TIFFSwabLong(&count32); + dp += sizeof(uint32); + count = count32; + } + else + { + count = *(uint64*)dp; + if (swabflag) + TIFFSwabLong8(&count); + dp += sizeof(uint64); + } +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + printf("%I64u<", (unsigned __int64)count); +#else + printf("%llu<", (unsigned long long)count); +#endif + if (type >= NWIDTHS) + typewidth = 0; + else + typewidth = datawidth[type]; + datasize = count*typewidth; + datafits = 1; + datamem = dp; + dataoffset = 0; + datatruncated = 0; + if (!bigtiff) + { + if (datasize>4) + { + uint32 dataoffset32; + datafits = 0; + datamem = NULL; + dataoffset32 = *(uint32*)dp; + if (swabflag) + TIFFSwabLong(&dataoffset32); + dataoffset = dataoffset32; + } + dp += sizeof(uint32); + } + else + { + if (datasize>8) + { + datafits = 0; + datamem = NULL; + dataoffset = *(uint64*)dp; + if (swabflag) + TIFFSwabLong8(&dataoffset); + } + dp += sizeof(uint64); + } + if (datasize>0x10000) + { + datatruncated = 1; + count = 0x10000/typewidth; + datasize = count*typewidth; + } + if (count>maxitems) + { + datatruncated = 1; + count = maxitems; + datasize = count*typewidth; + } + if (!datafits) + { + datamem = _TIFFmalloc((uint32)datasize); + if (datamem) { +#if defined(__WIN32__) && defined(_MSC_VER) + if (_lseeki64(fd, (__int64)dataoffset, SEEK_SET) + != (__int64)dataoffset) +#else + if (lseek(fd, (off_t)dataoffset, 0) != + (off_t)dataoffset) +#endif + { + Error( + "Seek error accessing tag %u value", tag); + _TIFFfree(datamem); + datamem = NULL; + } + if (read(fd, datamem, (size_t)datasize) != (TIFF_SSIZE_T)datasize) + { + Error( + "Read error accessing tag %u value", tag); + _TIFFfree(datamem); + datamem = NULL; + } } else - Error("No space for data for tag %u", - dp->tdir_tag); + Error("No space for data for tag %u",tag); + } + if (datamem) + { + if (swabflag) + { + switch (type) + { + case TIFF_BYTE: + case TIFF_ASCII: + case TIFF_SBYTE: + case TIFF_UNDEFINED: + break; + case TIFF_SHORT: + case TIFF_SSHORT: + TIFFSwabArrayOfShort((uint16*)datamem,(tmsize_t)count); + break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + TIFFSwabArrayOfLong((uint32*)datamem,(tmsize_t)count); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + TIFFSwabArrayOfLong((uint32*)datamem,(tmsize_t)count*2); + break; + case TIFF_DOUBLE: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + TIFFSwabArrayOfLong8((uint64*)datamem,(tmsize_t)count); + break; + } + } + PrintData(stdout,type,(uint32)count,datamem); + if (datatruncated) + printf(" ..."); + if (!datafits) + _TIFFfree(datamem); } printf(">\n"); } done: - if (dir) - _TIFFfree((char *)dir); + if (dirmem) + _TIFFfree((char *)dirmem); return (nextdiroff); } -static struct tagname { - uint16 tag; - char* name; +static const struct tagname { + uint16 tag; + const char* name; } tagnames[] = { { TIFFTAG_SUBFILETYPE, "SubFileType" }, { TIFFTAG_OSUBFILETYPE, "OldSubFileType" }, @@ -484,7 +610,7 @@ static struct tagname { static void PrintTag(FILE* fd, uint16 tag) { - register struct tagname *tp; + const struct tagname *tp; for (tp = tagnames; tp < &tagnames[NTAGS]; tp++) if (tp->tag == tag) { @@ -497,7 +623,7 @@ PrintTag(FILE* fd, uint16 tag) static void PrintType(FILE* fd, uint16 type) { - static char *typenames[] = { + static const char *typenames[] = { "0", "BYTE", "ASCII", @@ -510,7 +636,13 @@ PrintType(FILE* fd, uint16 type) "SLONG", "SRATIONAL", "FLOAT", - "DOUBLE" + "DOUBLE", + "IFD", + "14", + "15", + "LONG8", + "SLONG8", + "IFD8" }; #define NTYPES (sizeof (typenames) / sizeof (typenames[0])) @@ -521,60 +653,6 @@ PrintType(FILE* fd, uint16 type) } #undef NTYPES -static void -PrintByte(FILE* fd, const char* fmt, TIFFDirEntry* dp) -{ - char* sep = ""; - - if (hdr.tiff_magic == TIFF_BIGENDIAN) { - switch ((int)dp->tdir_count) { - case 4: fprintf(fd, fmt, sep, dp->tdir_offset&0xff); - sep = " "; - case 3: fprintf(fd, fmt, sep, (dp->tdir_offset>>8)&0xff); - sep = " "; - case 2: fprintf(fd, fmt, sep, (dp->tdir_offset>>16)&0xff); - sep = " "; - case 1: fprintf(fd, fmt, sep, dp->tdir_offset>>24); - } - } else { - switch ((int)dp->tdir_count) { - case 4: fprintf(fd, fmt, sep, dp->tdir_offset>>24); - sep = " "; - case 3: fprintf(fd, fmt, sep, (dp->tdir_offset>>16)&0xff); - sep = " "; - case 2: fprintf(fd, fmt, sep, (dp->tdir_offset>>8)&0xff); - sep = " "; - case 1: fprintf(fd, fmt, sep, dp->tdir_offset&0xff); - } - } -} - -static void -PrintShort(FILE* fd, const char* fmt, TIFFDirEntry* dp) -{ - char *sep = ""; - - if (hdr.tiff_magic == TIFF_BIGENDIAN) { - switch (dp->tdir_count) { - case 2: fprintf(fd, fmt, sep, dp->tdir_offset&0xffff); - sep = " "; - case 1: fprintf(fd, fmt, sep, dp->tdir_offset>>16); - } - } else { - switch (dp->tdir_count) { - case 2: fprintf(fd, fmt, sep, dp->tdir_offset>>16); - sep = " "; - case 1: fprintf(fd, fmt, sep, dp->tdir_offset&0xffff); - } - } -} - -static void -PrintLong(FILE* fd, const char* fmt, TIFFDirEntry* dp) -{ - fprintf(fd, fmt, "", (long) dp->tdir_offset); -} - #include static void @@ -646,6 +724,28 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) fprintf(fd, slongfmt, sep, (long) *lp++), sep = " "; break; } + case TIFF_LONG8: { + uint64 *llp = (uint64*)data; + while (count-- > 0) { +#if defined(__WIN32__) && defined(_MSC_VER) + fprintf(fd, long8fmt, sep, (unsigned __int64) *llp++); +#else + fprintf(fd, long8fmt, sep, (unsigned long long) *llp++); +#endif + sep = " "; + } + break; + } + case TIFF_SLONG8: { + int64 *llp = (int64*)data; + while (count-- > 0) +#if defined(__WIN32__) && defined(_MSC_VER) + fprintf(fd, slong8fmt, sep, (__int64) *llp++), sep = " "; +#else + fprintf(fd, slong8fmt, sep, (long long) *llp++), sep = " "; +#endif + break; + } case TIFF_RATIONAL: { uint32 *lp = (uint32*)data; while (count-- > 0) { @@ -695,49 +795,19 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) } break; } - } -} - -/* - * Fetch a contiguous directory item. - */ -static int -TIFFFetchData(int fd, TIFFDirEntry* dir, void* cp) -{ - int cc, w; - - w = (dir->tdir_type < NWIDTHS ? datawidth[dir->tdir_type] : 0); - cc = dir->tdir_count * w; - if (lseek(fd, (off_t)dir->tdir_offset, 0) != (off_t)-1 - && read(fd, cp, cc) != -1) { - if (swabflag) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, - dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - case TIFF_IFD: - TIFFSwabArrayOfLong((uint32*) cp, - dir->tdir_count); - break; - case TIFF_RATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, - 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, - dir->tdir_count); - break; - } + case TIFF_IFD8: { + uint64 *llp = (uint64*)data; + while (count-- > 0) { +#if defined(__WIN32__) && defined(_MSC_VER) + fprintf(fd, ifd8fmt, sep, (unsigned __int64) *llp++); +#else + fprintf(fd, ifd8fmt, sep, (unsigned long long) *llp++); +#endif + sep = " "; } - return (cc); + break; + } } - Error("Error while reading data for tag %u", dir->tdir_tag); - return (0); } static void @@ -776,3 +846,10 @@ Fatal(const char* fmt, ...) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffgt.c b/libs/tiff-4.0.2/tools/tiffgt.c similarity index 94% rename from libs/tiff-3.8.2/tools/tiffgt.c rename to libs/tiff-4.0.2/tools/tiffgt.c index ebd66b89b5..de420396c6 100644 --- a/libs/tiff-3.8.2/tools/tiffgt.c +++ b/libs/tiff-4.0.2/tools/tiffgt.c @@ -1,4 +1,4 @@ -/* $Id: tiffgt.c,v 1.7 2006/03/23 14:54:02 dron Exp $ */ +/* $Id: tiffgt.c,v 1.10 2010-07-01 15:56:56 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -40,6 +40,7 @@ #endif #include "tiffio.h" +#include "tiffiop.h" #ifndef HAVE_GETOPT extern int getopt(int, char**, char*); @@ -204,7 +205,7 @@ initImage(void) if (photo != (uint16) -1) TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) { - TIFFError(filelist[fileindex], title); + TIFFError(filelist[fileindex], "%s", title); TIFFClose(tif); tif = NULL; return -1; @@ -224,21 +225,24 @@ initImage(void) w = xmax; } - if (w != width || h != height) { - if (raster != NULL) - _TIFFfree(raster), raster = NULL; - raster = (uint32*) _TIFFmalloc(img.width * img.height * sizeof (uint32)); - if (raster == NULL) { - width = height = 0; - TIFFError(filelist[fileindex], "No space for raster buffer"); - cleanup_and_exit(); - } - width = w; - height = h; - } - TIFFRGBAImageGet(&img, raster, img.width, img.height); + if (w != width || h != height) { + uint32 rastersize = + _TIFFMultiply32(tif, img.width, img.height, "allocating raster buffer"); + if (raster != NULL) + _TIFFfree(raster), raster = NULL; + raster = (uint32*) _TIFFCheckMalloc(tif, rastersize, sizeof (uint32), + "allocating raster buffer"); + if (raster == NULL) { + width = height = 0; + TIFFError(filelist[fileindex], "No space for raster buffer"); + cleanup_and_exit(); + } + width = w; + height = h; + } + TIFFRGBAImageGet(&img, raster, img.width, img.height); #if HOST_BIGENDIAN - TIFFSwabArrayOfLong(raster,img.width*img.height); + TIFFSwabArrayOfLong(raster,img.width*img.height); #endif return 0; } @@ -453,3 +457,10 @@ photoArg(const char* arg) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffinfo.c b/libs/tiff-4.0.2/tools/tiffinfo.c similarity index 84% rename from libs/tiff-3.8.2/tools/tiffinfo.c rename to libs/tiff-4.0.2/tools/tiffinfo.c index 1d7364eaa4..ae1a5f62e5 100644 --- a/libs/tiff-3.8.2/tools/tiffinfo.c +++ b/libs/tiff-4.0.2/tools/tiffinfo.c @@ -1,4 +1,4 @@ -/* $Id: tiffinfo.c,v 1.8 2005/12/09 14:52:48 dron Exp $ */ +/* $Id: tiffinfo.c,v 1.21 2012-06-06 06:05:29 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -38,18 +38,30 @@ # include #endif -#include "tiffio.h" +#ifdef NEED_LIBPORT +# include "libport.h" +#endif -#define streq(a,b) (strcasecmp(a,b) == 0) +#include "tiffiop.h" -int showdata = 0; /* show data */ -int rawdata = 0; /* show raw/decoded data */ -int showwords = 0; /* show data as bytes/words */ -int readdata = 0; /* read data in file */ -int stoponerr = 1; /* stop on first read error */ +static TIFFErrorHandler old_error_handler = 0; +static int status = 0; /* exit status */ +static int showdata = 0; /* show data */ +static int rawdata = 0; /* show raw/decoded data */ +static int showwords = 0; /* show data as bytes/words */ +static int readdata = 0; /* read data in file */ +static int stoponerr = 1; /* stop on first read error */ static void usage(void); -static void tiffinfo(TIFF*, uint16, long); +static void tiffinfo(TIFF*, uint16, long, int); + +static void +PrivateErrorHandler(const char* module, const char* fmt, va_list ap) +{ + if (old_error_handler) + (*old_error_handler)(module,fmt,ap); + status = 1; +} int main(int argc, char* argv[]) @@ -60,7 +72,7 @@ main(int argc, char* argv[]) extern int optind; extern char* optarg; long flags = 0; - uint32 diroff = 0; + uint64 diroff = 0; int chopstrips = 0; /* disable strip chopping */ while ((c = getopt(argc, argv, "f:o:cdDSjilmrsvwz0123456789")) != -1) @@ -116,6 +128,9 @@ main(int argc, char* argv[]) } if (optind >= argc) usage(); + + old_error_handler = TIFFSetErrorHandler(PrivateErrorHandler); + multiplefiles = (argc - optind > 1); for (; optind < argc; optind++) { if (multiplefiles) @@ -124,26 +139,27 @@ main(int argc, char* argv[]) if (tif != NULL) { if (dirnum != -1) { if (TIFFSetDirectory(tif, (tdir_t) dirnum)) - tiffinfo(tif, order, flags); + tiffinfo(tif, order, flags, 1); } else if (diroff != 0) { if (TIFFSetSubDirectory(tif, diroff)) - tiffinfo(tif, order, flags); + tiffinfo(tif, order, flags, 1); } else { do { - uint32 offset; + toff_t offset; - tiffinfo(tif, order, flags); + tiffinfo(tif, order, flags, 1); if (TIFFGetField(tif, TIFFTAG_EXIFIFD, &offset)) { - if (TIFFReadEXIFDirectory(tif, offset)) - tiffinfo(tif, order, flags); + if (TIFFReadEXIFDirectory(tif, offset)) { + tiffinfo(tif, order, flags, 0); + } } } while (TIFFReadDirectory(tif)); } TIFFClose(tif); } } - return (0); + return (status); } char* stuff[] = { @@ -202,7 +218,7 @@ TIFFReadContigStripData(TIFF* tif) buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); if (buf) { - uint32 row, h; + uint32 row, h=0; uint32 rowsperstrip = (uint32)-1; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); @@ -254,7 +270,7 @@ TIFFReadSeparateStripData(TIFF* tif) static void ShowTile(uint32 row, uint32 col, tsample_t sample, - unsigned char* pp, uint32 nrow, uint32 rowsize) + unsigned char* pp, uint32 nrow, tsize_t rowsize) { uint32 cc; @@ -263,7 +279,7 @@ ShowTile(uint32 row, uint32 col, tsample_t sample, printf(",%u", sample); printf("):\n"); while (nrow-- > 0) { - for (cc = 0; cc < rowsize; cc++) { + for (cc = 0; cc < (uint32) rowsize; cc++) { printf(" %02x", *pp++); if (((cc+1) % 24) == 0) putchar('\n'); @@ -335,7 +351,7 @@ TIFFReadSeparateTileData(TIFF* tif) void TIFFReadData(TIFF* tif) { - uint16 config; + uint16 config = PLANARCONFIG_CONTIG; TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); if (TIFFIsTiled(tif)) { @@ -382,18 +398,18 @@ TIFFReadRawData(TIFF* tif, int bitrev) { tstrip_t nstrips = TIFFNumberOfStrips(tif); const char* what = TIFFIsTiled(tif) ? "Tile" : "Strip"; - uint32* stripbc; + uint64* stripbc; TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc); if (nstrips > 0) { - uint32 bufsize = stripbc[0]; + uint32 bufsize = (uint32) stripbc[0]; tdata_t buf = _TIFFmalloc(bufsize); tstrip_t s; for (s = 0; s < nstrips; s++) { if (stripbc[s] > bufsize) { - buf = _TIFFrealloc(buf, stripbc[s]); - bufsize = stripbc[s]; + buf = _TIFFrealloc(buf, (tmsize_t)stripbc[s]); + bufsize = (uint32) stripbc[s]; } if (buf == NULL) { fprintf(stderr, @@ -401,23 +417,23 @@ TIFFReadRawData(TIFF* tif, int bitrev) (unsigned long) s); break; } - if (TIFFReadRawStrip(tif, s, buf, stripbc[s]) < 0) { + if (TIFFReadRawStrip(tif, s, buf, (tmsize_t) stripbc[s]) < 0) { fprintf(stderr, "Error reading strip %lu\n", (unsigned long) s); if (stoponerr) break; } else if (showdata) { if (bitrev) { - TIFFReverseBits(buf, stripbc[s]); + TIFFReverseBits(buf, (tmsize_t)stripbc[s]); printf("%s %lu: (bit reversed)\n ", what, (unsigned long) s); } else printf("%s %lu:\n ", what, (unsigned long) s); if (showwords) - ShowRawWords((uint16*) buf, stripbc[s]>>1); + ShowRawWords((uint16*) buf, (uint32) stripbc[s]>>1); else - ShowRawBytes((unsigned char*) buf, stripbc[s]); + ShowRawBytes((unsigned char*) buf, (uint32) stripbc[s]); } } if (buf != NULL) @@ -426,10 +442,10 @@ TIFFReadRawData(TIFF* tif, int bitrev) } static void -tiffinfo(TIFF* tif, uint16 order, long flags) +tiffinfo(TIFF* tif, uint16 order, long flags, int is_image) { TIFFPrintDirectory(tif, stdout, flags); - if (!readdata) + if (!readdata || !is_image) return; if (rawdata) { if (order) { @@ -447,3 +463,10 @@ tiffinfo(TIFF* tif, uint16 order, long flags) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffmedian.c b/libs/tiff-4.0.2/tools/tiffmedian.c similarity index 99% rename from libs/tiff-3.8.2/tools/tiffmedian.c rename to libs/tiff-4.0.2/tools/tiffmedian.c index d0a2f5a2fb..6501494b8d 100644 --- a/libs/tiff-3.8.2/tools/tiffmedian.c +++ b/libs/tiff-4.0.2/tools/tiffmedian.c @@ -1,4 +1,4 @@ -/* $Id: tiffmedian.c,v 1.8 2004/09/09 18:06:14 fwarmerdam Exp $ */ +/* $Id: tiffmedian.c,v 1.10 2010-03-10 18:56:50 bfriesen Exp $ */ /* * Apply median cut on an image. @@ -50,6 +50,10 @@ # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" #define MAX_CMAP_SIZE 256 @@ -893,3 +897,10 @@ bad: _TIFFfree(nextline); _TIFFfree(outline); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffset.c b/libs/tiff-4.0.2/tools/tiffset.c similarity index 86% rename from libs/tiff-3.8.2/tools/tiffset.c rename to libs/tiff-4.0.2/tools/tiffset.c index 08ae726fe0..b9e58364f9 100644 --- a/libs/tiff-3.8.2/tools/tiffset.c +++ b/libs/tiff-4.0.2/tools/tiffset.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: tiffset.c,v 1.11 2005/09/13 14:13:42 dron Exp $ + * $Id: tiffset.c,v 1.16 2011-03-26 12:07:20 fwarmerdam Exp $ * * Project: libtiff tools * Purpose: Mainline for setting metadata in existing TIFF files. @@ -27,14 +27,6 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. ****************************************************************************** - * - * $Log: tiffset.c,v $ - * Revision 1.11 2005/09/13 14:13:42 dron - * Avoid warnings. - * - * Revision 1.10 2005/02/24 14:47:11 fwarmerdam - * Updated header. - * */ @@ -43,11 +35,14 @@ #include #include "tiffio.h" +#include "tif_dir.h" static char* usageMsg[] = { "usage: tiffset [options] filename", "where options are:", " -s [count] ... set the tag value", +" -d set the directory", +" -sd set the subdirectory", " -sf read the tag value from file (for ASCII tags only)", NULL }; @@ -61,10 +56,10 @@ usage(void) exit(-1); } -static const TIFFFieldInfo * +static const TIFFField * GetField(TIFF *tiff, const char *tagname) { - const TIFFFieldInfo *fip; + const TIFFField *fip; if( atoi(tagname) > 0 ) fip = TIFFFieldWithTag(tiff, (ttag_t)atoi(tagname)); @@ -72,8 +67,8 @@ GetField(TIFF *tiff, const char *tagname) fip = TIFFFieldWithName(tiff, tagname); if (!fip) { - fprintf( stderr, "Field name %s not recognised.\n", tagname ); - return (TIFFFieldInfo *)NULL; + fprintf( stderr, "Field name \"%s\" is not recognised.\n", tagname ); + return (TIFFField *)NULL; } return fip; @@ -93,8 +88,26 @@ main(int argc, char* argv[]) return 2; for( arg_index = 1; arg_index < argc-1; arg_index++ ) { + if (strcmp(argv[arg_index],"-d") == 0 && arg_index < argc-2) { + arg_index++; + if( TIFFSetDirectory(tiff, atoi(argv[arg_index]) ) != 1 ) + { + fprintf( stderr, "Failed to set directory=%s\n", argv[arg_index] ); + return 6; + } + arg_index++; + } + if (strcmp(argv[arg_index],"-sd") == 0 && arg_index < argc-2) { + arg_index++; + if( TIFFSetSubDirectory(tiff, atoi(argv[arg_index]) ) != 1 ) + { + fprintf( stderr, "Failed to set sub directory=%s\n", argv[arg_index] ); + return 7; + } + arg_index++; + } if (strcmp(argv[arg_index],"-s") == 0 && arg_index < argc-3) { - const TIFFFieldInfo *fip; + const TIFFField *fip; const char *tagname; arg_index++; @@ -109,7 +122,8 @@ main(int argc, char* argv[]) if (TIFFSetField(tiff, fip->field_tag, argv[arg_index]) != 1) fprintf( stderr, "Failed to set %s=%s\n", fip->field_name, argv[arg_index] ); - } else if (fip->field_writecount > 0) { + } else if (fip->field_writecount > 0 + || fip->field_writecount == TIFF_VARIABLE) { int ret = 1; short wc; @@ -215,7 +229,18 @@ main(int argc, char* argv[]) if (fip->field_passcount) { ret = TIFFSetField(tiff, fip->field_tag, wc, array); - } else { + } else if (fip->field_tag == TIFFTAG_PAGENUMBER + || fip->field_tag == TIFFTAG_HALFTONEHINTS + || fip->field_tag == TIFFTAG_YCBCRSUBSAMPLING + || fip->field_tag == TIFFTAG_DOTRANGE) { + if (fip->field_type == TIFF_BYTE) { + ret = TIFFSetField(tiff, fip->field_tag, + ((uint8 *)array)[0], ((uint8 *)array)[1]); + } else if (fip->field_type == TIFF_SHORT) { + ret = TIFFSetField(tiff, fip->field_tag, + ((uint16 *)array)[0], ((uint16 *)array)[1]); + } + } else { ret = TIFFSetField(tiff, fip->field_tag, array); } @@ -257,9 +282,9 @@ main(int argc, char* argv[]) } } else if (strcmp(argv[arg_index],"-sf") == 0 && arg_index < argc-3) { FILE *fp; - const TIFFFieldInfo *fip; + const TIFFField *fip; char *text; - int len; + size_t len; arg_index++; fip = GetField(tiff, argv[arg_index]); @@ -307,3 +332,10 @@ main(int argc, char* argv[]) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/tiffsplit.c b/libs/tiff-4.0.2/tools/tiffsplit.c similarity index 79% rename from libs/tiff-3.8.2/tools/tiffsplit.c rename to libs/tiff-4.0.2/tools/tiffsplit.c index 13e86f2ec9..fa43d63fa8 100644 --- a/libs/tiff-3.8.2/tools/tiffsplit.c +++ b/libs/tiff-4.0.2/tools/tiffsplit.c @@ -1,4 +1,4 @@ -/* $Id: tiffsplit.c,v 1.14 2005/12/06 22:18:13 dron Exp $ */ +/* $Id: tiffsplit.c,v 1.22 2011-10-22 17:03:01 bfriesen Exp $ */ /* * Copyright (c) 1992-1997 Sam Leffler @@ -43,7 +43,11 @@ extern int getopt(int, char**, char*); #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) -static char fname[1024+1]; +#define PATH_LENGTH 8192 + +static const char TIFF_SUFFIX[] = ".tif"; + +static char fname[PATH_LENGTH]; static int tiffcp(TIFF*, TIFF*); static void newfilename(void); @@ -60,16 +64,26 @@ main(int argc, char* argv[]) fprintf(stderr, "usage: tiffsplit input.tif [prefix]\n"); return (-3); } - if (argc > 2) - strcpy(fname, argv[2]); + if (argc > 2) { + strncpy(fname, argv[2], sizeof(fname)); + fname[sizeof(fname) - 1] = '\0'; + } in = TIFFOpen(argv[1], "r"); if (in != NULL) { do { - char path[1024+1]; + size_t path_len; + char *path; + newfilename(); - strcpy(path, fname); - strcat(path, ".tif"); + + path_len = strlen(fname) + sizeof(TIFF_SUFFIX); + path = (char *) _TIFFmalloc(path_len); + strncpy(path, fname, path_len); + path[path_len - 1] = '\0'; + strncat(path, TIFF_SUFFIX, path_len - strlen(path) - 1); out = TIFFOpen(path, TIFFIsBigEndian(in)?"wb":"wl"); + _TIFFfree(path); + if (out == NULL) return (-2); if (!tiffcp(in, out)) @@ -158,7 +172,7 @@ tiffcp(TIFF* in, TIFF* out) CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); CopyField(TIFFTAG_COMPRESSION, compression); if (compression == COMPRESSION_JPEG) { - uint16 count = 0; + uint32 count = 0; void *table = NULL; if (TIFFGetField(in, TIFFTAG_JPEGTABLES, &count, &table) && count > 0 && table) { @@ -183,7 +197,7 @@ tiffcp(TIFF* in, TIFF* out) CopyField(TIFFTAG_YPOSITION, floatv); CopyField(TIFFTAG_IMAGEDEPTH, longv); CopyField(TIFFTAG_TILEDEPTH, longv); - CopyField(TIFFTAG_SAMPLEFORMAT, longv); + CopyField(TIFFTAG_SAMPLEFORMAT, shortv); CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav); { uint16 *red, *green, *blue; CopyField3(TIFFTAG_COLORMAP, red, green, blue); @@ -216,23 +230,26 @@ tiffcp(TIFF* in, TIFF* out) static int cpStrips(TIFF* in, TIFF* out) { - tsize_t bufsize = TIFFStripSize(in); + tmsize_t bufsize = TIFFStripSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); - uint32 *bytecounts; + uint64 *bytecounts; - TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); + if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) { + fprintf(stderr, "tiffsplit: strip byte counts are missing\n"); + return (0); + } for (s = 0; s < ns; s++) { - if (bytecounts[s] > (uint32)bufsize) { - buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]); + if (bytecounts[s] > (uint64)bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); if (!buf) return (0); - bufsize = bytecounts[s]; + bufsize = (tmsize_t)bytecounts[s]; } - if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 || - TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) { + if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 || + TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) { _TIFFfree(buf); return (0); } @@ -246,23 +263,26 @@ cpStrips(TIFF* in, TIFF* out) static int cpTiles(TIFF* in, TIFF* out) { - tsize_t bufsize = TIFFTileSize(in); + tmsize_t bufsize = TIFFTileSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf) { ttile_t t, nt = TIFFNumberOfTiles(in); - uint32 *bytecounts; + uint64 *bytecounts; - TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); + if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) { + fprintf(stderr, "tiffsplit: tile byte counts are missing\n"); + return (0); + } for (t = 0; t < nt; t++) { - if (bytecounts[t] > (uint32) bufsize) { - buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]); + if (bytecounts[t] > (uint64) bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); if (!buf) return (0); - bufsize = bytecounts[t]; + bufsize = (tmsize_t)bytecounts[t]; } - if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 || - TIFFWriteRawTile(out, t, buf, bytecounts[t]) < 0) { + if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 || + TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) { _TIFFfree(buf); return (0); } @@ -274,3 +294,10 @@ cpTiles(TIFF* in, TIFF* out) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/tiff-3.8.2/tools/ycbcr.c b/libs/tiff-4.0.2/tools/ycbcr.c similarity index 97% rename from libs/tiff-3.8.2/tools/ycbcr.c rename to libs/tiff-4.0.2/tools/ycbcr.c index 01982fd519..8f72447d04 100644 --- a/libs/tiff-3.8.2/tools/ycbcr.c +++ b/libs/tiff-4.0.2/tools/ycbcr.c @@ -159,3 +159,10 @@ check(int R, int G, int B) eCodes++; eBits += abs(eR) + abs(eG) + abs(eB); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/libs/win32/Download libjpeg.2008.vcproj b/libs/win32/Download libjpeg.2008.vcproj new file mode 100644 index 0000000000..f458505fc9 --- /dev/null +++ b/libs/win32/Download libjpeg.2008.vcproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/win32/Download libjpeg.2010.vcxproj b/libs/win32/Download libjpeg.2010.vcxproj new file mode 100644 index 0000000000..56844e037c --- /dev/null +++ b/libs/win32/Download libjpeg.2010.vcxproj @@ -0,0 +1,81 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + Download libjpeg + {652AD5F7-8488-489F-AAD0-7FBE064703B6} + Download libjpeg + Win32Proj + + + + Utility + MultiByte + + + Utility + MultiByte + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(PlatformName)\jpeg-8d\$(Configuration)\ + $(PlatformName)\jpeg-8d\$(Configuration)\ + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + $(IntDir)BuildLog $(ProjectName).htm + + + + + + + + + + + + + Document + Downloading libjpeg. + if not exist "$(ProjectDir)..\jpeg-8d" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://www.ijg.org/files/jpegsrc.v8d.tar.gz "$(ProjectDir).." + + $(ProjectDir)..\jpeg-8d;%(Outputs) + Downloading libjpeg. + if not exist "$(ProjectDir)..\jpeg-8d" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://www.ijg.org/files/jpegsrc.v8d.tar.gz "$(ProjectDir).." + + $(ProjectDir)..\jpeg-8d;%(Outputs) + + + + + + \ No newline at end of file diff --git a/libs/win32/libjpeg/libjpeg.2008.vcproj b/libs/win32/libjpeg/libjpeg.2008.vcproj new file mode 100644 index 0000000000..881078ca9b --- /dev/null +++ b/libs/win32/libjpeg/libjpeg.2008.vcproj @@ -0,0 +1,531 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/win32/libjpeg/libjpeg.2010.vcxproj b/libs/win32/libjpeg/libjpeg.2010.vcxproj new file mode 100644 index 0000000000..437fb66198 --- /dev/null +++ b/libs/win32/libjpeg/libjpeg.2010.vcxproj @@ -0,0 +1,232 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + Disabled + Disabled + Disabled + false + false + false + false + + + + libjpeg + {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} + Win32Proj + libjpeg + + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + ..\..\jpeg-8d;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + if not exist "$(ProjectDir)..\..\jpeg-8d\jconfig.h" type "$(ProjectDir)..\..\jpeg-8d\jconfig.vc" > "$(ProjectDir)..\..\jpeg-8d\jconfig.h" + + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + ..\..\jpeg-8d;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + if not exist "$(ProjectDir)..\..\jpeg-8d\jconfig.h" type "$(ProjectDir)..\..\jpeg-8d\jconfig.vc" > "$(ProjectDir)..\..\jpeg-8d\jconfig.h" + + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + ..\..\jpeg-8d;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + if not exist "$(ProjectDir)..\..\jpeg-8d\jconfig.h" type "$(ProjectDir)..\..\jpeg-8d\jconfig.vc" > "$(ProjectDir)..\..\jpeg-8d\jconfig.h" + + + + + Level3 + NotUsing + Full + true + false + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS + true + true + ..\..\jpeg-8d;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + if not exist "$(ProjectDir)..\..\jpeg-8d\jconfig.h" type "$(ProjectDir)..\..\jpeg-8d\jconfig.vc" > "$(ProjectDir)..\..\jpeg-8d\jconfig.h" + + + + + + \ No newline at end of file diff --git a/libs/win32/libjpeg/libjpeg.2010.vcxproj.filters b/libs/win32/libjpeg/libjpeg.2010.vcxproj.filters new file mode 100644 index 0000000000..6a63450cb4 --- /dev/null +++ b/libs/win32/libjpeg/libjpeg.2010.vcxproj.filters @@ -0,0 +1,186 @@ + + + + + {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 + + + + + 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 + + + \ No newline at end of file diff --git a/libs/win32/util.vbs b/libs/win32/util.vbs index ace3fd6998..2c35dfdcb7 100644 --- a/libs/win32/util.vbs +++ b/libs/win32/util.vbs @@ -262,6 +262,83 @@ Sub FindReplaceInFile(FileName, sFind, sReplace) fNewFile.Close End Sub +Function ExecAndGetResult(tmpFolder, VersionDir, execStr) + + Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpExec.Bat", True) + MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote) + MyFile.WriteLine("@" & execStr) + MyFile.Close + + Set oExec = WshShell.Exec("cmd /C " & quote & tmpFolder & "tmpExec.Bat" & quote) + + ExecAndGetResult = Trim(OExec.StdOut.ReadLine()) + + Do + Loop While Not OExec.StdOut.atEndOfStream + + FSO.DeleteFile(tmpFolder & "tmpExec.Bat") + +End Function + +Function ExecAndGetExitCode(tmpFolder, VersionDir, execStr) + + Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpExec.Bat", True) + MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote) + MyFile.WriteLine("@" & execStr) + MyFile.WriteLine("@exit %ERRORLEVEL%") + MyFile.Close + + ExecAndGetExitCode = WshShell.Run("cmd /C " & quote & tmpFolder & "tmpExec.Bat" & quote, 0, True) + + FSO.DeleteFile(tmpFolder & "tmpExec.Bat") + +End Function + +Function pd(n, totalDigits) + If totalDigits > len(n) then + pd = String(totalDigits-len(n),"0") & n + Else + pd = n + End If +End Function + +Function GetTimeUTC() + + iOffset = WshShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias") + + If IsNumeric(iOffset) Then + GetTimeUTC = DateAdd("n", iOffset, Now()) + Else + GetTimeUTC = Now() + End If + +End Function + +Function GetWeekDay(DateTime) + + DayOfWeek = DatePart("w", DateTime) + + Select Case DayOfWeek + Case 1 GetWeekDay = "Sun" + Case 2 GetWeekDay = "Mon" + Case 3 GetWeekDay = "Tue" + Case 4 GetWeekDay = "Wed" + Case 5 GetWeekDay = "Thu" + Case 6 GetWeekDay = "Fri" + Case 7 GetWeekDay = "Sat" + End Select + +End Function + +Function GetMonthName(DateTime) + + Val = MonthName(Month(DateTime), True) + Val = UCase(Left(Val, 1)) & Mid(Val, 2, 4) + + GetMonthName = Val + +End Function + Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest) Dim oExec @@ -269,96 +346,63 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest) strVerMinor = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MINOR") strVerMicro = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MICRO") strVerRev = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_REVISION") + strVerHuman = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_REVISION_HUMAN") - If Right(tmpFolder, 1) <> "\" Then tmpFolder = tmpFolder & "\" End If - If Not FSO.FileExists(tmpFolder & "fs_svnversion.exe") Then - Wget ToolsBase & "fs_svnversion.exe", tmpFolder - End If - - If Not FSO.FileExists(tmpFolder & "libdb44.dll") Then - Wget ToolsBase & "libdb44.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libsvn_diff-1.dll") Then - Wget ToolsBase & "libsvn_diff-1.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libsvn_subr-1.dll") Then - Wget ToolsBase & "libsvn_subr-1.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libsvn_wc-1.dll") Then - Wget ToolsBase & "libsvn_wc-1.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "intl3_svn.dll") Then - Wget ToolsBase & "intl3_svn.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libapr-1.dll") Then - Wget ToolsBase & "libapr-1.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libaprutil-1.dll") Then - Wget ToolsBase & "libaprutil-1.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libapriconv-1.dll") Then - Wget ToolsBase & "libapriconv-1.dll", tmpFolder - End If - If Not FSO.FileExists(tmpFolder & "libsvn_delta-1.dll") Then - Wget ToolsBase & "libsvn_delta-1.dll", tmpFolder - End If - - Dim sLastFile - Const OverwriteIfExist = -1 - Const ForReading = 1 - - if strVerRev = "" Then - if FSO.FolderExists(VersionDir & ".svn") Then - VersionCmd="fs_svnversion " & quote & VersionDir & "." & quote & " -n" - Set MyFile = fso.CreateTextFile(tmpFolder & "tmpVersion.Bat", True) - MyFile.WriteLine("@" & "cd " & quote & tmpFolder & quote ) - MyFile.WriteLine("@" & VersionCmd) - MyFile.Close - Set oExec = WshShell.Exec("cmd /C " & quote & tmpFolder & "tmpVersion.Bat" & quote) - Do - strFromProc = OExec.StdOut.ReadLine() - VERSION="svn-" & strFromProc - Loop While Not OExec.StdOut.atEndOfStream - sLastVersion = "" - Set sLastFile = FSO.OpenTextFile(tmpFolder & "lastversion", ForReading, true, OpenAsASCII) - If Not sLastFile.atEndOfStream Then - sLastVersion = sLastFile.ReadLine() - End If - sLastFile.Close - End If - - if FSO.FolderExists(VersionDir & ".git") Then - VersionCmd="git log --format=" & quote & "%%h %%ci" & quote & " -1 HEAD" - Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpVersion.Bat", True) - MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote) - MyFile.WriteLine("@" & VersionCmd) - MyFile.Close - Set oExec = WshShell.Exec("cmd /C " & quote & tmpFolder & "tmpVersion.Bat" & quote) - Do - strFromProc = Trim(OExec.StdOut.ReadLine()) - VERSION="git-" & strFromProc - Loop While Not OExec.StdOut.atEndOfStream - sLastVersion = "" - Set sLastFile = FSO.OpenTextFile(tmpFolder & "lastversion", ForReading, true, OpenAsASCII) - If Not sLastFile.atEndOfStream Then - sLastVersion = sLastFile.ReadLine() - End If - sLastFile.Close - VERSION = Replace(VERSION, ":", "-") - End If - End If - - if strVerRev <> "" Then + 'Set version to the one reported by configure.in + If strVerRev <> "" Then VERSION = strVerRev End If - If VERSION = "" Then - VERSION = "UNKNOWN" - End If + Dim sLastFile + Const ForReading = 1 + Const ShowUnclean = False 'Don't show unclean state for now - If VERSION <> sLastVersion Then + 'Try To read revision from git + If FSO.FolderExists(VersionDir & ".git") Then + 'Get timestamp for last commit + strFromProc = ExecAndGetResult(tmpFolder, VersionDir, "git log -n1 --format=" & quote & "%%ct" & quote & " HEAD") + If IsNumeric(strFromProc) Then + lastChangedDateTime = DateAdd("s", strFromProc, "01/01/1970 00:00:00") + strLastCommit = YEAR(lastChangedDateTime) & Pd(Month(lastChangedDateTime), 2) & Pd(DAY(lastChangedDateTime), 2) & "T" & Pd(Hour(lastChangedDateTime), 2) & Pd(Minute(lastChangedDateTime), 2) & Pd(Second(lastChangedDateTime), 2) & "Z" + strLastCommitHuman = GetWeekDay(lastChangedDateTime) & ", " & Pd(DAY(lastChangedDateTime), 2) & " " & GetMonthName(lastChangedDateTime) & " " & YEAR(lastChangedDateTime) & " " & Pd(Hour(lastChangedDateTime), 2) & ":" & Pd(Minute(lastChangedDateTime), 2) & ":" & Pd(Second(lastChangedDateTime), 2) & " Z" + Else + strLastCommit = "" + strLastCommitHuman = "" + End If + + 'Get revision hash + strRevision = ExecAndGetResult(tmpFolder, VersionDir, "git rev-list -n1 --abbrev=10 --abbrev-commit HEAD") + + If strLastCommit <> "" And strLastCommitHuman <> "" And strRevision <> "" Then + 'Bild version string + strGitVer = "+git~" & strLastCommit & "~" & strRevision + strVerHuman = strVerRev & "; git at commit " & strRevision & " on " & strLastCommitHuman + + 'Check for local changes, if found, append to git revision string + If ShowUnclean Then + If ExecAndGetExitCode(tmpFolder, VersionDir, "git diff-index --quiet HEAD") <> 0 Then + lastChangedDateTime = GetTimeUTC() + strGitVer = strGitVer & "+unclean~" & YEAR(lastChangedDateTime) & Pd(Month(lastChangedDateTime), 2) & Pd(DAY(lastChangedDateTime), 2) & "T" & Pd(Hour(lastChangedDateTime), 2) & Pd(Minute(lastChangedDateTime), 2) & Pd(Second(lastChangedDateTime), 2) & "Z" + End If + End If + Else + strGitVer = "" + strVerHuman = "" + End If + + VERSION=VERSION & strGitVer + + sLastVersion = "" + Set sLastFile = FSO.OpenTextFile(tmpFolder & "lastversion", ForReading, true, OpenAsASCII) + If Not sLastFile.atEndOfStream Then + sLastVersion = sLastFile.ReadLine() + End If + sLastFile.Close + End If + + If VERSION & " " & strVerHuman <> sLastVersion Then Set MyFile = fso.CreateTextFile(tmpFolder & "lastversion", True) - MyFile.WriteLine(VERSION) + MyFile.WriteLine(VERSION & " " & strVerHuman) MyFile.Close FSO.CopyFile includebase, includedest, true @@ -366,7 +410,7 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest) FindReplaceInFile includedest, "@SWITCH_VERSION_MAJOR@", strVerMajor FindReplaceInFile includedest, "@SWITCH_VERSION_MINOR@", strVerMinor FindReplaceInFile includedest, "@SWITCH_VERSION_MICRO@", strVerMicro - + FindReplaceInFile includedest, "@SWITCH_VERSION_REVISION_HUMAN@", strVerHuman End If End Sub diff --git a/scripts/c/socket2me/socket2me.c b/scripts/c/socket2me/socket2me.c index 1b3aa0c6f2..9bb9551742 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, Anthony Minessale II + * Copyright (C) 2007-2012, Anthony Minessale II */ #include diff --git a/scripts/ci/common.sh b/scripts/ci/common.sh new file mode 100755 index 0000000000..059def200e --- /dev/null +++ b/scripts/ci/common.sh @@ -0,0 +1,139 @@ +#!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- + +src_repo="$(pwd)" +tmp_dir=${TMP_DIR:="/tmp"} + +zgrep () { (echo "$2" | grep -e "$1" >/dev/null); } + +parse_version () { + local ver="$1" major="" minor="" micro="" rev="" + local next=major + for x in $(echo "$1" | sed -e 's/\([._~-]\)/ \1 /g'); do + if [ $next = rev ]; then + rev="${rev}${x}" + elif [ "$x" = "." ] || [ "$x" = "_" ] || [ "$x" = "~" ] || [ "$x" = "-" ]; then + if [ "$x" = "_" ] || [ "$x" = "~" ] || [ "$x" = "-" ]; then + next=rev + eval $next='$x' + else + case $next in + major) next=minor;; + minor) next=micro;; + micro) next=rev;; + esac + fi + else + local tmp="$(eval echo \$$next)" + eval $next='${tmp}${x}' + fi + done + # The major version should never be null + if [ -z "$major" ]; then + echo "WARNING: parse_version was called with '$1' which is missing a major version number" >&2 + fi + # If someone asks for the minor or micro specificially, they + # probably expect that it won't be null. Also, vX.Y should never be + # different from vX.Y.0 (that would be crazy), so we don't lose + # meaningful generality by setting minor or micro to zero on vX or + # vX.Y style versions. + minor="${minor:-0}" + micro="${micro:-0}" + # centos-style versions (don't mess with the argument given for now) + # TODO: what is the CentOS version number policy? + local cmajor cminor cmicro crev cver + cmajor="${major:-0}" + cminor="${minor:-0}" + cmicro="${micro:-0}" + crev="$(echo "$rev" | sed -e 's/[._~-]//')" + cver="${cmajor}.${cminor}.${cmicro}" + [ -n "$crev" ] && cver="${cver}.${crev}" + # fix up if the revision was passed in the minor or micro number + if zgrep '^\(alpha\|beta\|rc\)' "$minor"; then + rev="-${minor}" + minor="0" + micro="0" + ver="${major}${rev}" + fi + if zgrep '^\(alpha\|beta\|rc\)' "$micro"; then + rev="-${micro}" + micro="0" + ver="${major}.${minor}${rev}" + fi + # git-style versions + local gmajor gminor gmicro grev gver + gver="$(echo "$ver" | sed -e 's/[~_]/-/')" + grev="$(echo "$rev" | sed -e 's/[~_]/-/')" + gmajor="$major" + gminor="$minor" + gmicro="$micro" + # debian-style versions + local dmajor dminor dmicro drev dver + dver="$(echo "$ver" | sed -e 's/[-_]/~/')" + drev="$(echo "$rev" | sed -e 's/[-_]/~/')" + dmajor="$major" + dminor="$minor" + dmicro="$micro" + # return variables + echo "ver='$ver'" + echo "major='$major'" + echo "minor='$minor'" + echo "micro='$micro'" + echo "rev='$rev'" + echo "gver='$gver'" + echo "gmajor='$gmajor'" + echo "gminor='$gminor'" + echo "gmicro='$gmicro'" + echo "grev='$grev'" + echo "dver='$dver'" + echo "dmajor='$dmajor'" + echo "dminor='$dminor'" + echo "dmicro='$dmicro'" + echo "drev='$drev'" + echo "cver='$cver'" + echo "cmajor='$cmajor'" + echo "cminor='$cminor'" + echo "cmicro='$cmicro'" + echo "crev='$crev'" +} + +set_fs_ver () { + local ver="$1" major="$2" minor="$3" micro="$4" rev="$5" hrev="$6" + sed -e "s|\(AC_SUBST(SWITCH_VERSION_MAJOR, \[\).*\(\])\)|\1$major\2|" \ + -e "s|\(AC_SUBST(SWITCH_VERSION_MINOR, \[\).*\(\])\)|\1$minor\2|" \ + -e "s|\(AC_SUBST(SWITCH_VERSION_MICRO, \[\).*\(\])\)|\1$micro\2|" \ + -e "s|\(AC_INIT(\[freeswitch\], \[\).*\(\], BUG-REPORT-ADDRESS)\)|\1$ver\2|" \ + -i configure.in + 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\)|\1|" \ + -e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION_HUMAN\)|\1|" \ + -i configure.in + fi +} + +gnuize () { + ./bootstrap.sh + mv bootstrap.sh rebootstrap.sh + rm -f docs/AUTHORS + rm -f docs/COPYING + rm -f docs/ChangeLog + rm -rf .git +} + +check_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 +} + +check_input_ver_build () { + if [ -z "$1" ]; then + echo "usage: $0 " 1>&2 + exit 1; + fi +} + diff --git a/scripts/ci/debsrcbuilder.sh b/scripts/ci/debsrcbuilder.sh index ee83b6325b..1b81566fe8 100755 --- a/scripts/ci/debsrcbuilder.sh +++ b/scripts/ci/debsrcbuilder.sh @@ -1,60 +1,85 @@ -#!/bin/bash +#!/bin/sh ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- -src_repo="$(pwd)" +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh -if [ ! -d .git ]; then - echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2 - exit 1; +check_pwd +check_input_ver_build $@ +in_ver="$1" +if [ "$in_ver" = "auto" ]; then + in_ver="$(cat build/next-release.txt)" fi +eval $(parse_version "$in_ver") +datestamp="$(date +%Y%m%dT%H%M%SZ)" +nightly="n${datestamp}" +build="b${2-0}" +distro="${3-unstable}" +codename="${4-sid}" -if [ -z "$1" ]; then - echo "usage: ./scripts/ci/debbuilder.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi +fver="${dver}~${nightly}~${build}" +fname="freeswitch-$fver" +orig="freeswitch_$fver.orig" +ddir=$src_repo/debbuild +bdir=$src_repo/debbuild/$fname -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) +mkdir -p $ddir +git clone . $bdir +cd $bdir +set_fs_ver "$gver" "$gmajor" "$gminor" "$gmicro" "$grev" +echo "$gver" > .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 -build="$2" -input_distro=$3 -distro=${input_distro:="unstable"} +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 ? -dst_version="$major.$minor.$micro" -dst_name="freeswitch-$dst_version" -dst_parent="/tmp/" -dst_dir="/tmp/$dst_name" -dst_full_version="$dst_version.$build" -dst_full_name="freeswitch-$dst_full_version" - -mkdir -p $src_repo/debbuild/ - -tar xjf src_dist/$dst_name.tar.bz2 -C $src_repo/debbuild/ -mv $src_repo/debbuild/$dst_name $src_repo/debbuild/$dst_full_name -mv src_dist/$dst_name.tar.bz2 $src_repo/debbuild/freeswitch_${dst_full_version}.orig.tar.bz2 - -# Build the debian source package first, from the source tar file. -echo "changing directory to $src_repo/debbuild/$dst_full_name" - -cd $src_repo/debbuild/$dst_full_name - -dch -v "${dst_full_version}-1" -M --force-distribution -D "$distro" "Nightly Build" - -dpkg-buildpackage -rfakeroot -S -us -uc - -status=$? - -if [ $status -gt 0 ]; then - exit $status -else - cat 1>&2 <&2 <&2 - exit 1; -fi - -if [ -z "$1" ]; then - echo "usage: ./scripts/ci/rpmbuilder.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh +check_pwd +check_input_ver_build $@ +eval $(parse_version "$1") build="$2" -dst_name="freeswitch-$major.$minor.$micro" +dst_name="freeswitch-$cmajor.$cminor.$cmicro" dst_parent="/tmp/" dst_dir="/tmp/$dst_name" -mkdir -p $src_repo/rpmbuild/{SOURCES,BUILD,BUILDROOT,i386,x86_64,SPECS} +(mkdir -p rpmbuild && cd rpmbuild && mkdir -p SOURCES BUILD BUILDROOT i386 x86_64 SPECS) cd $src_repo +cp -a src_dist/* rpmbuild/SOURCES/ || true -rpmbuild --define "VERSION_NUMBER $ver" \ +rpmbuild --define "VERSION_NUMBER $cver" \ --define "BUILD_NUMBER $build" \ --define "_topdir %(pwd)/rpmbuild" \ --define "_rpmdir %{_topdir}" \ @@ -46,7 +36,7 @@ mv $src_repo/rpmbuild/*/*.rpm $src_repo/RPMS/. cat 1>&2 <&2 - exit 1; -fi - -if [ -z "$1" ]; then - echo "usage: ./scripts/ci/rpmbuilder.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh +check_pwd +check_input_ver_build $@ +eval $(parse_version "$1") build="$2" cd rpmbuild/SOURCES diff --git a/scripts/ci/sounds-music.sh b/scripts/ci/sounds-music.sh index 118d6b717f..70e61eabec 100755 --- a/scripts/ci/sounds-music.sh +++ b/scripts/ci/sounds-music.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- src_repo="$(pwd)" diff --git a/scripts/ci/sounds-ru-ru-elena.sh b/scripts/ci/sounds-ru-ru-elena.sh index 93da3228f7..33a4f9d004 100755 --- a/scripts/ci/sounds-ru-ru-elena.sh +++ b/scripts/ci/sounds-ru-ru-elena.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- src_repo="$(pwd)" diff --git a/scripts/ci/src_tarball.sh b/scripts/ci/src_tarball.sh index 1055c6c481..1c79f2fca1 100755 --- a/scripts/ci/src_tarball.sh +++ b/scripts/ci/src_tarball.sh @@ -1,30 +1,15 @@ -#!/bin/bash +#!/bin/sh ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- -src_repo="$(pwd)" +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh -if [ ! -d .git ]; then - echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2 - exit 1; -fi +check_pwd +check_input_ver_build $@ +eval $(parse_version "$1") -if [ -z "$1" ]; then - echo "usage: ./scripts/dailys.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) - -tmp_dir=${TMP_DIR:="/tmp"} - -build="$2" - -dst_name="freeswitch-$major.$minor.$micro" -dst_parent="${tmp_dir}/jenkis.$$/" +dst_name="freeswitch-$cmajor.$cminor.$cmicro" dst_dir="${tmp_dir}/jenkins.$$/$dst_name" if [ -d "$dst_dir" ]; then @@ -32,64 +17,29 @@ if [ -d "$dst_dir" ]; then exit 1; fi -# save local changes -#ret=$(git stash save "Save uncommitted changes before tagging.") -#if echo $ret | grep "^Saved"; then - #stash_saved=1 -#fi - -sed -e "s|\(AC_SUBST(SWITCH_VERSION_MAJOR, \[\).*\(\])\)|\1$major\2|" \ - -e "s|\(AC_SUBST(SWITCH_VERSION_MINOR, \[\).*\(\])\)|\1$minor\2|" \ - -e "s|\(AC_SUBST(SWITCH_VERSION_MICRO, \[\).*\(\])\)|\1$micro\2|" \ - -e "s|\(AC_INIT(\[freeswitch\], \[\).*\(\], BUG-REPORT-ADDRESS)\)|\1$major.$minor.$micro\2|" \ - -i configure.in - -if [ -n "$rev" ]; then - sed -e "s|\(AC_SUBST(SWITCH_VERSION_REVISION, \[\).*\(\])\)|\1$rev\2|" \ - -e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION\)|\1|" \ - -i configure.in -fi - -#git add configure.in -#git commit -m "Release freeswitch-$ver" -#git tag -a -m "freeswitch-$ver release" v$ver - -#git clone $src_repo $dst_dir -#if [ -n "$stash_saved" ]; then -# git stash pop -#fi - mkdir -p $dst_dir cp -r . $dst_dir cd $dst_dir - -./bootstrap.sh -mv bootstrap.sh rebootstrap.sh -rm -f docs/AUTHORS -rm -f docs/COPYING -rm -f docs/ChangeLog -rm -rf .git +set_fs_ver "$gver" "$gmajor" "$gminor" "$gmicro" "$grev" +echo "$gver" > .version +gnuize cd .. - -cd $dst_parent - ls +tar -cvf ${dst_name}.tar $dst_name -tar -cvf $dst_name.tar $dst_name +# 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" -# 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" +rm -rf ${dst_name}.tar $dst_dir -rm -rf $dst_name.tar $dst_dir - -mkdir -p $src_repo/src_dist -mv -f $dst_name.tar.* $src_repo/src_dist +mkdir -p ${src_repo}/src_dist +mv -f ${dst_name}.tar.* ${src_repo}/src_dist cat 1>&2 </dev/null || exit 1 + -config "${TMPFILE}.cfg" -nodes -days ${DAYS} -sha1 >/dev/null || exit 1 cat "${CONFDIR}/CA/cacert.pem" > "${CONFDIR}/cafile.pem" rm "${TMPFILE}.cfg" diff --git a/scripts/javascript/api.js b/scripts/javascript/api.js index 47c5770353..56a37a5cd8 100644 --- a/scripts/javascript/api.js +++ b/scripts/javascript/api.js @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/javascript/js_modules/SpeechTools.jm b/scripts/javascript/js_modules/SpeechTools.jm index 4e9628b2f5..84e6363743 100644 --- a/scripts/javascript/js_modules/SpeechTools.jm +++ b/scripts/javascript/js_modules/SpeechTools.jm @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2006, Anthony Minessale II + * Copyright (C) 2005/2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/javascript/pizza.js b/scripts/javascript/pizza.js index 9807f5bc8d..57c8f2b116 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/javascript/ps_pizza.js b/scripts/javascript/ps_pizza.js index 7fd405e009..646128e308 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/scripts/perl/cnam.cgi b/scripts/perl/cnam.cgi new file mode 100755 index 0000000000..5f777cc5e3 --- /dev/null +++ b/scripts/perl/cnam.cgi @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# +# OpenCNAM front end because they only take 10 digits and can't filter 11 on their side. +# + +use Data::Dumper; +use CGI qw/:standard/; +use LWP::UserAgent; +use SDBM_File; +use Fcntl; + +my %params = map { $_ => get_data( $_ ) } param; + +$ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, timeout => 3 }); + +sub get_data { + my $name = shift; + my @values = param( $name ); + return @values > 1 + ? \@values + : $values[0]; +} + +print "Content-Type: text/plain\n\n"; + +tie (my %cache, 'SDBM_File', 'cnam.dbm', O_RDWR|O_CREAT, 0640) || die $!; + +my $number = $params{number}; + + +if($number =~ m/1?\d{10}/) { + if($number =~ m/^1(\d{10})$/) { + $number = $1; + } + + if($cache{"$number"}) { + print $cache{"$number"}; + untie %cache; + exit; + } + + my $url = "https://api.opencnam.com/v1/phone/$number?format=text"; + my $res = $ua->get( $url ); + my $code = $res->code; + + if ($code eq '200') { + my $content = $res->decoded_content; + $cache{"$number"} = $content; + print $content; + } else { + print "UNKNOWN"; + } +} + +untie %cache; diff --git a/scripts/python/freepy/__init__.py b/scripts/python/freepy/__init__.py index cebe48a0ab..2274cdc474 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-2011, Anthony Minessale II +Copyright (C) 2005-2012, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/fseventlistener.py b/scripts/python/freepy/fseventlistener.py index 6e3455f62f..fb1b430f5d 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-2011, Anthony Minessale II +Copyright (C) 2005-2012, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/fshelper.py b/scripts/python/freepy/fshelper.py index 090abce9d6..d258461629 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-2011, Anthony Minessale II +Copyright (C) 2005-2012, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/models.py b/scripts/python/freepy/models.py index 3dfb105424..37e595946f 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-2011, Anthony Minessale II +Copyright (C) 2005-2012, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/python/freepy/request.py b/scripts/python/freepy/request.py index d76fe2942c..787482be3a 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-2011, Anthony Minessale II +Copyright (C) 2005-2012, Anthony Minessale II Version: MPL 1.1 diff --git a/scripts/rss/rss2ivr.pl b/scripts/rss/rss2ivr.pl index ed5aabd3a3..489fc1609f 100755 --- a/scripts/rss/rss2ivr.pl +++ b/scripts/rss/rss2ivr.pl @@ -2,7 +2,7 @@ ########################################################################## # rss2ivr.pl -- A Script to turn an RSS feed into audio files. # -# Copyright (C) 2006, Anthony Minessale +# Copyright (C) 2006-2012, Anthony Minessale # # Anthony Minessale # diff --git a/scripts/setup-git.sh b/scripts/setup-git.sh index f9f709ff7f..df3cd73b6c 100755 --- a/scripts/setup-git.sh +++ b/scripts/setup-git.sh @@ -34,13 +34,14 @@ if ! git config user.email >/dev/null 2>&1; then git config --global user.email "$email" fi +git config pull.rebase true git config branch.master.rebase true cat 1>&2 <&2 - exit 1; -fi +check_pwd showusage() { - echo "usage: ./scripts/tagscript.sh [-s] MAJOR.MINOR.MICRO[.REVISION]" 1>&2 - exit 1; + cat >&2 < + +DESCRIPTION + Creates a new FreeSWITCH tag after performing some sanity checks. + The tag is optionally signed if '-s' is provided, but you should + really sign any public release tags, so pass '-s'. + + follows the format: + + 1.2-alpha3 + 1.2-beta3 + 1.2-rc3 + 1.2 + 1.2.13-rc4 + 1.2.13 + etc. + + This tool will take care of correctly naming the tag to be + consistent with FreeSWITCH git policy from there. + +OPTIONS + -s + Signs the resulting tag. + + -d + Debug mode. Remove the tag after creating it and don't warn about + the lack of a signature. + +EOF + exit 1; } -while getopts "s" o; do - case "$o" in - s) opts="-s" ;; - esac +opts="" +debug=false +while getopts "ds" o; do + case "$o" in + d) debug=true ;; + s) opts="-s" ;; + esac done shift $(($OPTIND-1)) if [ -z "$1" ]; then - showusage + showusage fi -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) +eval $(parse_version "$1") +ngrep () { (echo "$2" | grep -e "$1" >/dev/null); } +err () { echo "$1" >&2; exit 1; } -dst_name="freeswitch-$major.$minor.$micro" -dst_dir="$src_repo/../$dst_name" +ngrep '^[1-9]*$' "$gmajor" || \ + err "The major version '$gmajor' appears invalid." +ngrep '^[0-9]*$' "$gminor" || \ + err "The minor version '$gminor' appears invalid." +[ -z "$gmicro" ] || ngrep '^[0-9]*$' "$gmicro" || \ + err "The micro version '$gmicro' appears invalid." +[ -z "$grev" ] || ngrep '^[.-]' "$grev" || \ + err "The revision '$grev' appears invalid." -if [ -d "$dst_dir" ]; then - echo "error: destination directory $dst_dir already exists." 1>&2 - exit 1; +echo "We're going to release freeswitch v$gver" >&2 +echo >&2 + +if ! ($debug || ngrep '-s' "$opts"); then + cat >&2 <&2 + read r + [ -z "$r" ] && continue + if [ "$r" = yes ] || [ "$r" = y ]; then + (echo; echo "OK, I believe you."; echo) >&2 + break + else + (echo; echo "This is a bad idea then."; echo) >&2 + fi + while true; do + echo -n "Are you really really sure? (yes/no): " >&2 + read r + [ -z "$r" ] && continue + if [ "$r" = yes ] || [ "$r" = y ]; then + (echo; echo "As you wish, you've been warned."; echo) >&2 + break + else + (echo; echo "Great; go setup a GPG key and try again with -s"; echo) >&2 + exit 1 + fi + break + done + break + done fi -# save local changes +echo "Saving uncommitted changes before tagging..." >&2 ret=$(git stash save "Save uncommitted changes before tagging.") -if echo $ret | grep "^Saved"; then - stash_saved=1 +if (ngrep '^Saved' "$ret"); then + stash_saved=1 fi -sed -e "s|\(AC_SUBST(SWITCH_VERSION_MAJOR, \[\).*\(\])\)|\1$major\2|" \ - -e "s|\(AC_SUBST(SWITCH_VERSION_MINOR, \[\).*\(\])\)|\1$minor\2|" \ - -e "s|\(AC_SUBST(SWITCH_VERSION_MICRO, \[\).*\(\])\)|\1$micro\2|" \ - -e "s|\(AC_INIT(\[freeswitch\], \[\).*\(\], BUG-REPORT-ADDRESS)\)|\1$major.$minor.$micro\2|" \ - -i configure.in - -if [ -n "$rev" ]; then - sed -e "s|\(AC_SUBST(SWITCH_VERSION_REVISION, \[\).*\(\])\)|\1$rev\2|" \ - -e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION\)|\1|" \ - -i configure.in +echo "Determining next-release (release+1) version..." >&2 +if [ -n "$grev" ] && ngrep '[0-9]*$' "$grev"; then + rev_ver="$(echo "$grev" | sed -e 's/^[^0-9]*\([0-9]*\)$/\1/')" + next_rev="$((rev_ver+1))" + next_ver="${gver%%$rev_ver}${next_rev}" +elif [ -n "$grev" ]; then + next_ver="${gver}1" +elif ! [ "$gmicro" = "0" ]; then + next_ver="${gver%%$micro}$((micro+1))" +else + next_ver="${gmajor}.$((gminor+1))-rc1" fi +echo "Setting next-release version ($next_ver)..." >&2 +echo "${next_ver}" > build/next-release.txt +git add build/next-release.txt +echo "Changing the version of configure.in..." >&2 +set_fs_ver "$gver" "$gmajor" "$gminor" "$gmicro" "$grev" + +echo "Committing the new version..." >&2 git add configure.in -git commit -m "Release freeswitch-$ver" -git tag -a ${opts} -m "freeswitch-$ver release" v$ver +if ! (git commit --allow-empty -m "release FreeSWITCH $gver"); then + cat >&2 <&2 +if ! (git tag -a ${opts} -m "FreeSWITCH $gver" "v$gver"); then + cat >&2 < $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" -rm -rf $dst_name.tar $dst_dir +EOF + err "Stopping here." +fi + +if $debug; then + (echo; echo "We're in debug mode, so we're cleaning up...") >&2 + git tag -d "v$gver" || true + git reset --hard HEAD^ || true +fi + +if [ -n "$stash_saved" ]; then + echo "Restoring your uncommitted changes to your working directory..." >&2 + git stash pop >/dev/null +fi cat 1>&2 < + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -98,7 +98,8 @@ typedef enum { SSF_READ_TRANSCODE = (1 << 5), SSF_WRITE_TRANSCODE = (1 << 6), SSF_READ_CODEC_RESET = (1 << 7), - SSF_WRITE_CODEC_RESET = (1 << 8) + SSF_WRITE_CODEC_RESET = (1 << 8), + SSF_DESTROYABLE = (1 << 9) } switch_session_flag_t; @@ -120,6 +121,7 @@ struct switch_core_session { switch_codec_t *video_write_codec; switch_codec_implementation_t read_impl; + switch_codec_implementation_t real_read_impl; switch_codec_implementation_t write_impl; switch_codec_implementation_t video_read_impl; switch_codec_implementation_t video_write_impl; @@ -171,6 +173,8 @@ struct switch_core_session { uint32_t soft_lock; switch_ivr_dmachine_t *dmachine[2]; plc_state_t *plc; + uint8_t recur_buffer[SWITCH_RECOMMENDED_BUFFER_SIZE]; + switch_size_t recur_buffer_len; }; struct switch_media_bug { @@ -199,6 +203,7 @@ struct switch_media_bug { uint32_t record_pre_buffer_count; uint32_t record_pre_buffer_max; switch_frame_t *ping_frame; + switch_frame_t *read_demux_frame; struct switch_media_bug *next; }; @@ -209,6 +214,8 @@ typedef enum { struct switch_runtime { switch_time_t initiated; + switch_time_t mono_initiated; + switch_time_t mono_reference; switch_time_t reference; int64_t offset; switch_event_t *global_vars; @@ -243,6 +250,11 @@ struct switch_runtime { char *odbc_user; char *odbc_pass; char *dbname; + char *recovery_odbc_dsn; + char *recovery_odbc_user; + char *recovery_odbc_pass; + char *recovery_dbname; + switch_dbtype_t recovery_odbc_dbtype; uint32_t debug_level; uint32_t runlevel; uint32_t tipping_point; @@ -261,6 +273,10 @@ struct switch_runtime { uint32_t db_handle_timeout; int cpu_count; uint32_t time_sync; + char *core_db_pre_trans_execute; + char *core_db_post_trans_execute; + char *core_db_inner_pre_trans_execute; + char *core_db_inner_post_trans_execute; }; extern struct switch_runtime runtime; @@ -272,6 +288,12 @@ struct switch_session_manager { uint32_t session_count; uint32_t session_limit; switch_size_t session_id; + switch_queue_t *thread_queue; + switch_thread_t *manager_thread; + switch_mutex_t *mutex; + int ready; + int running; + int busy; }; extern struct switch_session_manager session_manager; diff --git a/src/include/switch.h b/src/include/switch.h index de099f1b94..3e1bfbb77f 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index a49487c5e2..bd19353991 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -1443,6 +1443,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollset(switch_pollfd_t ** */ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **pollfd, switch_socket_t *sock, int16_t flags, void *client_data, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t ** result, switch_memory_pool_t *p); +SWITCH_DECLARE(switch_status_t) switch_os_sock_get(switch_os_socket_t *thesock, switch_socket_t *sock); SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock); /** diff --git a/src/include/switch_bitpack.h b/src/include/switch_bitpack.h index 3209cbc282..af32b9025d 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_buffer.h b/src/include/switch_buffer.h index 751439d1ad..920d3965fe 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index 09ff57beb6..3618858819 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 37bb6f1102..2348a4cc54 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -641,6 +641,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_api_on(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); SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_config.h b/src/include/switch_config.h index b0ef805b52..fab6832e20 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_console.h b/src/include/switch_console.h index 5585a041c1..9a88f3c229 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 1e3bfcba76..50ec7a965e 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -137,6 +137,11 @@ SWITCH_DECLARE(void) switch_core_session_disable_heartbeat(switch_core_session_t #define switch_core_session_get_name(_s) switch_channel_get_name(switch_core_session_get_channel(_s)) +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_pop(switch_core_session_t *orig_session, const char *function, switch_media_bug_t **pop); + +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session, + const char *function, switch_media_bug_exec_cb_t cb, void *user_data); +SWITCH_DECLARE(uint32_t) switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function); /*! \brief Add a media bug to the session \param session the session to add the bug to @@ -193,7 +198,7 @@ SWITCH_DECLARE(void) switch_core_media_bug_set_write_replace_frame(_In_ switch_m \param bug the bug to get the data from */ SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_read_replace_frame(_In_ switch_media_bug_t *bug); - +SWITCH_DECLARE(void) switch_core_media_bug_set_read_demux_frame(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame); /*! \brief Obtain the session from a media bug \param bug the bug to get the data from @@ -225,6 +230,7 @@ SWITCH_DECLARE(uint32_t) switch_core_cpu_count(void); \param bug bug to remove \return SWITCH_STATUS_SUCCESS if the operation was a success */ + SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(_In_ switch_core_session_t *session, _Inout_ switch_media_bug_t **bug); SWITCH_DECLARE(uint32_t) switch_core_media_bug_prune(switch_core_session_t *session); @@ -247,7 +253,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_close(_Inout_ switch_media \param session the session to remove the bugs from \return SWITCH_STATUS_SUCCESS if the operation was a success */ -SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all(_In_ switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all_function(_In_ switch_core_session_t *session, const char *function); + +#define switch_core_media_bug_remove_all(_s) switch_core_media_bug_remove_all_function(_s, NULL) SWITCH_DECLARE(switch_status_t) switch_core_media_bug_enumerate(switch_core_session_t *session, switch_stream_handle_t *stream); SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session); @@ -315,6 +323,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_free_port(_In_ switch SWITCH_DECLARE(void) switch_core_port_allocator_destroy(_Inout_ switch_core_port_allocator_t **alloc); ///\} + +SWITCH_DECLARE(int) switch_core_test_flag(int flag); + ///\defgroup ss Startup/Shutdown ///\ingroup core1 ///\{ @@ -662,6 +673,7 @@ SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(_In_ switch_core_sessio \return the total number of allocated sessions since core startup */ SWITCH_DECLARE(switch_size_t) switch_core_session_id(void); +SWITCH_DECLARE(switch_size_t) switch_core_session_id_dec(void); /*! \brief Allocate and return a new session from the core based on a given endpoint module name @@ -679,6 +691,9 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_ */ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(_In_ switch_core_session_t *session); + +SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session); + /*! \brief Retrieve a pointer to the channel object associated with a given session \param session the session to retrieve from @@ -731,13 +746,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_codec_slin(switch_core_s */ SWITCH_DECLARE(char *) switch_core_get_uuid(void); -#ifdef SWITCH_DEBUG_RWLOCKS -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line); -#endif -#ifdef SWITCH_DEBUG_RWLOCKS +SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line); SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line); -#endif + /*! \brief Locate a session based on it's uuid @@ -745,11 +757,8 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate \return the session or NULL \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock() */ -#ifdef SWITCH_DEBUG_RWLOCKS + #define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__) -#else -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(_In_z_ const char *uuid_str); -#endif /*! \brief Locate a session based on it's uuid even if the channel is not ready @@ -757,11 +766,9 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(_In_z_ const \return the session or NULL \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock() */ -#ifdef SWITCH_DEBUG_RWLOCKS + #define switch_core_session_force_locate(uuid_str) switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__) -#else -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_force_locate(_In_z_ const char *uuid_str); -#endif + /*! \brief Retrieve a global variable from the core @@ -820,7 +827,10 @@ SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_i \param partner [out] The session's partner, or NULL if it wasnt found \return SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if this session isn't bridged */ -SWITCH_DECLARE(switch_status_t) switch_core_session_get_partner(switch_core_session_t *session, switch_core_session_t **partner); +SWITCH_DECLARE(switch_status_t) switch_core_session_perform_get_partner(switch_core_session_t *session, switch_core_session_t **partner, + const char *file, const char *func, int line); + +#define switch_core_session_get_partner(_session, _partner) switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__) /*! \brief Send a message to another session using it's uuid @@ -1022,10 +1032,6 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(_In_opt _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); -SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name, - _Inout_ switch_core_session_t **new_session, - _Inout_ switch_memory_pool_t **pool, _In_ void *data); - /*! \brief Receive a message on a given session \param session the session to receive the message from @@ -1492,6 +1498,7 @@ SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_sess SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); @@ -1639,6 +1646,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(_In_ switch_file_handle_t SWITCH_DECLARE(switch_status_t) switch_core_file_write(_In_ switch_file_handle_t *fh, void *data, switch_size_t *len); /*! + \brief Write media to a file handle + \param fh the file handle to write to + \param data the buffer to write + \param len the amount of data to write from the buffer + \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful +*/ +SWITCH_DECLARE(switch_status_t) switch_core_file_write_video(_In_ switch_file_handle_t *fh, void *data, switch_size_t *len); + +/*! \brief Seek a position in a file \param fh the file handle to seek \param cur_pos the current position in the file @@ -2098,6 +2114,7 @@ SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_m \return the current epoch time in microseconds */ SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void); +SWITCH_DECLARE(switch_time_t) switch_mono_micro_time_now(void); SWITCH_DECLARE(void) switch_core_memory_reclaim(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void); @@ -2111,6 +2128,7 @@ SWITCH_DECLARE(void) switch_time_sync(void); \return The current epoch time */ SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t); +SWITCH_DECLARE(const char *) switch_lookup_timezone(const char *tz_name); SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime); SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime); SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload); @@ -2121,6 +2139,7 @@ SWITCH_DECLARE(void) switch_time_set_timerfd(switch_bool_t 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); +SWITCH_DECLARE(void) switch_time_set_use_system_time(switch_bool_t enable); SWITCH_DECLARE(uint32_t) switch_core_min_dtmf_duration(uint32_t duration); SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration); SWITCH_DECLARE(double) switch_core_min_idle_cpu(double new_limit); @@ -2133,11 +2152,13 @@ SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t); SWITCH_DECLARE(void) switch_cond_next(void); SWITCH_DECLARE(switch_status_t) switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to, - const char *subject, const char *body, const char *type, const char *hint); + const char *subject, const char *body, const char *type, const char *hint, switch_bool_t blocking); SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, switch_event_t *message_event); SWITCH_DECLARE(switch_status_t) switch_core_chat_deliver(const char *dest_proto, switch_event_t **message_event); SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_session_t *session, const char *cmds); +SWITCH_DECLARE(void) switch_core_sqldb_stop_thread(void); +SWITCH_DECLARE(void) switch_core_sqldb_start_thread(void); ///\} @@ -2268,6 +2289,8 @@ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh) SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream); SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line); #define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__) +SWITCH_DECLARE(switch_status_t) _switch_core_recovery_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line); +#define switch_core_recovery_db_handle(_a) _switch_core_recovery_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__) SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql); @@ -2291,10 +2314,12 @@ SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number) \param [in] network_ip \param [in] network_port \param [in] network_proto - one of tls, tcp, udp + \param [in] metadata - generic metadata supplied by module \param [out] err - Error if it exists */ SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires, - const char *network_ip, const char *network_port, const char *network_proto); + const char *network_ip, const char *network_port, const char *network_proto, + const char *metadata); /*! \brief Delete user registration \param [in] user @@ -2319,6 +2344,15 @@ SWITCH_DECLARE(switch_status_t) switch_say_file_handle_create(switch_say_file_ha SWITCH_DECLARE(void) switch_say_file(switch_say_file_handle_t *sh, const char *fmt, ...); SWITCH_DECLARE(int) switch_max_file_desc(void); SWITCH_DECLARE(void) switch_close_extra_files(int *keep, int keep_ttl); +SWITCH_DECLARE(switch_status_t) switch_core_thread_set_cpu_affinity(int cpu); +SWITCH_DECLARE(void) switch_os_yield(void); +SWITCH_DECLARE(switch_status_t) switch_core_get_stacksizes(switch_size_t *cur, switch_size_t *max); + + +SWITCH_DECLARE(int) switch_core_recovery_recover(const char *technology, const char *profile_name); +SWITCH_DECLARE(void) switch_core_recovery_untrack(switch_core_session_t *session, switch_bool_t force); +SWITCH_DECLARE(void) switch_core_recovery_track(switch_core_session_t *session); +SWITCH_DECLARE(void) switch_core_recovery_flush(const char *technology, const char *profile_name); SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_core_db.h b/src/include/switch_core_db.h index f72c3c5f45..e5fbf76a95 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 ff836b3978..24932f004b 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -46,7 +46,6 @@ typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t; typedef struct switch_io_event_hook_recv_dtmf switch_io_event_hook_recv_dtmf_t; typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t; typedef struct switch_io_event_hook_state_run switch_io_event_hook_state_run_t; -typedef struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t; typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t); typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *); @@ -60,7 +59,6 @@ typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, con typedef switch_status_t (*switch_recv_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction); typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *); typedef switch_status_t (*switch_state_run_hook_t) (switch_core_session_t *); -typedef switch_call_cause_t (*switch_resurrect_session_hook_t) (switch_core_session_t **, switch_memory_pool_t **, void *); /*! \brief Node in which to store custom receive message callback hooks */ struct switch_io_event_hook_outgoing_channel { @@ -146,11 +144,6 @@ struct switch_io_event_hook_state_run { }; -struct switch_io_event_hook_resurrect_session { - switch_resurrect_session_hook_t resurrect_session; - struct switch_io_event_hook_resurrect_session *next; -}; - /*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */ struct switch_io_event_hooks { /*! a list of outgoing channel hooks */ @@ -176,7 +169,6 @@ struct switch_io_event_hooks { /*! a list of state change hooks */ switch_io_event_hook_state_change_t *state_change; switch_io_event_hook_state_run_t *state_run; - switch_io_event_hook_resurrect_session_t *resurrect_session; }; extern switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session); @@ -236,7 +228,6 @@ NEW_HOOK_DECL_ADD_P(video_write_frame); NEW_HOOK_DECL_ADD_P(kill_channel); NEW_HOOK_DECL_ADD_P(send_dtmf); NEW_HOOK_DECL_ADD_P(recv_dtmf); -NEW_HOOK_DECL_ADD_P(resurrect_session); NEW_HOOK_DECL_REM_P(outgoing_channel); NEW_HOOK_DECL_REM_P(receive_message); @@ -250,7 +241,6 @@ NEW_HOOK_DECL_REM_P(video_write_frame); NEW_HOOK_DECL_REM_P(kill_channel); NEW_HOOK_DECL_REM_P(send_dtmf); NEW_HOOK_DECL_REM_P(recv_dtmf); -NEW_HOOK_DECL_REM_P(resurrect_session); SWITCH_END_EXTERN_C diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 44e85185a6..83adac6867 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -186,7 +186,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod switch_event_node_t *enodes[SWITCH_EVENT_ALL + 1]; uint32_t node_index; - SWITCH_DECLARE_CONSTRUCTOR EventConsumer(const char *event_name = NULL, const char *subclass_name = ""); + SWITCH_DECLARE_CONSTRUCTOR EventConsumer(const char *event_name = NULL, const char *subclass_name = "", int len = 5000); SWITCH_DECLARE_CONSTRUCTOR ~ EventConsumer(); SWITCH_DECLARE(int) bind(const char *event_name, const char *subclass_name = ""); SWITCH_DECLARE(Event *) pop(int block = 0, int timeout = 0); diff --git a/src/include/switch_curl.h b/src/include/switch_curl.h index a404bffb34..73cfef7474 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-2010, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_event.h b/src/include/switch_event.h index 13debb4b6b..d0474a6929 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -402,6 +402,9 @@ SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event); SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t *vars_map); SWITCH_DECLARE(int) switch_event_check_permission_list(switch_event_t *list, const char *name); +SWITCH_DECLARE(void) switch_event_add_presence_data_cols(switch_channel_t *channel, switch_event_t *event, const char *prefix); +SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max); + ///\} SWITCH_END_EXTERN_C diff --git a/src/include/switch_frame.h b/src/include/switch_frame.h index edc4f8be6c..91910f85dd 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 0fb3c83e7f..9299c584d9 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -41,6 +41,7 @@ #define SWITCH_IVR_H #include +#include "switch_json.h" SWITCH_BEGIN_EXTERN_C struct switch_unicast_conninfo { switch_core_session_t *session; @@ -82,6 +83,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_ char *local_ip, switch_port_t local_port, char *remote_ip, switch_port_t remote_port, char *transport, char *flags); +/*! + \brief Generate an JSON CDR report. + \param session the session to get the data from. + \param json_cdr pointer to the json object + \return SWITCH_STATUS_SUCCESS if successful + \note on success the json object must be freed +*/ +SWITCH_DECLARE(switch_status_t) switch_ivr_generate_json_cdr(switch_core_session_t *session, cJSON **json_cdr, switch_bool_t urlencode); /*! \brief Generate an XML CDR report. @@ -269,6 +278,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_start_input_timers(swit */ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh); + +SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_pop_eavesdropper(switch_core_session_t *session, switch_core_session_t **sessionp); +SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_exec_all(switch_core_session_t *session, const char *app, const char *arg); +SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_update_display(switch_core_session_t *session, const char *name, const char *number); + /*! \brief Eavesdrop on a another session \param session our session @@ -956,6 +970,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *se SWITCH_DECLARE(switch_status_t) switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto); SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name); SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause); +SWITCH_DECLARE(switch_status_t) switch_ivr_blind_transfer_ack(switch_core_session_t *session, switch_bool_t success); /** @} */ diff --git a/src/include/switch_limit.h b/src/include/switch_limit.h index 4488b8caf0..fa9d1181fc 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index 62fcac2343..3edc4dc8a7 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -115,6 +115,8 @@ SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoin */ SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name); +SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit); + /*! \brief Retrieve the dialplan interface by it's registered name \param name the name of the dialplan diff --git a/src/include/switch_log.h b/src/include/switch_log.h index 170425a2a4..a44aa29a01 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index acb85407c7..b3dddc7171 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -118,7 +118,6 @@ typedef switch_status_t (*switch_io_state_change_t) (switch_core_session_t *); typedef switch_status_t (*switch_io_state_run_t) (switch_core_session_t *); typedef switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int); typedef switch_status_t (*switch_io_write_video_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int); -typedef switch_call_cause_t (*switch_io_resurrect_session_t) (switch_core_session_t **, switch_memory_pool_t **, void *); typedef enum { SWITCH_IO_OUTGOING_CHANNEL, @@ -131,7 +130,6 @@ typedef enum { SWITCH_IO_STATE_CHANGE, SWITCH_IO_READ_VIDEO_FRAME, SWITCH_IO_WRITE_VIDEO_FRAME, - SWITCH_IO_RESURRECT_SESSION } switch_io_routine_name_t; /*! \brief A table of i/o routines that an endpoint interface can implement */ @@ -158,8 +156,6 @@ struct switch_io_routines { switch_io_write_video_frame_t write_video_frame; /*! change a sessions channel run state */ switch_io_state_run_t state_run; - /*! resurrect a session */ - switch_io_resurrect_session_t resurrect_session; void *padding[10]; }; @@ -188,8 +184,12 @@ struct switch_endpoint_interface { /* parent */ switch_loadable_module_interface_t *parent; + /* to facilitate linking */ struct switch_endpoint_interface *next; + + switch_core_recover_callback_t recover_callback; + }; /*! \brief Abstract handler to a timer module */ @@ -273,6 +273,10 @@ struct switch_file_interface { /*! function to write from the file */ switch_status_t (*file_write) (switch_file_handle_t *, void *data, switch_size_t *len); /*! function to seek to a certian position in the file */ + switch_status_t (*file_read_video) (switch_file_handle_t *, void *data, switch_size_t *len); + /*! function to write from the file */ + switch_status_t (*file_write_video) (switch_file_handle_t *, void *data, switch_size_t *len); + /*! function to seek to a certian position in the file */ switch_status_t (*file_seek) (switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence); /*! function to set meta data */ switch_status_t (*file_set_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char *string); diff --git a/src/include/switch_nat.h b/src/include/switch_nat.h index 492dbfb29d..dae74073ff 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_odbc.h b/src/include/switch_odbc.h index 103fe0f0d7..fd3ff888ef 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index 17c972c989..a011850748 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -258,8 +258,12 @@ typedef intptr_t switch_ssize_t; #endif #ifndef TIME_T_FMT +#if defined(__FreeBSD__) && SIZEOF_VOIDP == 4 +#define TIME_T_FMT "d" +#else #define TIME_T_FMT "ld" #endif +#endif #endif diff --git a/src/include/switch_regex.h b/src/include/switch_regex.h index 6558299b53..393341fd43 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index 3dff620c4b..f85a61f065 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -170,7 +170,7 @@ SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t s ///\} SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples); - +SWITCH_DECLARE(uint32_t) switch_unmerge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples); SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, uint32_t channels); SWITCH_END_EXTERN_C diff --git a/src/include/switch_rtcp_frame.h b/src/include/switch_rtcp_frame.h index 5d06294304..7e034169e1 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 0951498c37..602889f3d6 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -215,7 +215,8 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session); \brief Acvite ICE on an RTP session \return SWITCH_STATUS_SUCCESS */ -SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin); +SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin, const char *password); +SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp_ice(switch_rtp_t *rtp_session, char *login, char *rlogin, const char *password); /*! \brief Activate sending RTCP Sender Reports (SR's) @@ -268,7 +269,7 @@ SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp \return the socket from the RTP session */ SWITCH_DECLARE(switch_socket_t *) switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session); - +SWITCH_DECLARE(void) switch_rtp_ping(switch_rtp_t *rtp_session); /*! \brief Get the default samples per interval for a given RTP session \param rtp_session the RTP session to get the samples per interval from diff --git a/src/include/switch_scheduler.h b/src/include/switch_scheduler.h index 8db9696f4a..6a69371d59 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_ssl.h b/src/include/switch_ssl.h index 46cdd5cbbe..70d675e16b 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-2010, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_stun.h b/src/include/switch_stun.h index 426eb49628..fbf6b3270f 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -57,6 +57,8 @@ SWITCH_BEGIN_EXTERN_C SWITCH_STUN_DATA_INDICATION = 0x0115 } switch_stun_message_t; +#define STUN_MAGIC_COOKIE 0x2112A442 + typedef enum { SWITCH_STUN_ATTR_MAPPED_ADDRESS = 0x0001, /* Address */ SWITCH_STUN_ATTR_RESPONSE_ADDRESS = 0x0002, /* Address */ @@ -77,7 +79,8 @@ typedef enum { SWITCH_STUN_ATTR_DESTINATION_ADDRESS = 0x0011, /* Address */ SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, /* Address */ SWITCH_STUN_ATTR_DATA = 0x0013, /* ByteString */ - SWITCH_STUN_ATTR_OPTIONS = 0x8001 /* UInt32 */ + SWITCH_STUN_ATTR_OPTIONS = 0x8001, /* UInt32 */ + SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS = 0x0020, /* Address */ } switch_stun_attribute_t; typedef enum { @@ -101,7 +104,8 @@ typedef enum { typedef struct { uint16_t type; uint16_t length; - char id[16]; + uint32_t cookie; + char id[12]; } switch_stun_packet_header_t; typedef struct { @@ -185,6 +189,7 @@ SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_build_header(switch_st \return true or false */ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_packet_t *packet, char *username, uint16_t ulen); +SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_password(switch_stun_packet_t *packet, char *password, uint16_t ulen); /*! @@ -195,6 +200,7 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_pa \return true or false */ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr, uint16_t port); +SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_xor_binded_address(switch_stun_packet_t *packet, char *ipstr, uint16_t port); /*! \brief Perform a stun lookup diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 185fdb64af..6104999c4c 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -26,6 +26,7 @@ * Anthony Minessale II * Bret McDanel * Joseph Sullivan + * Raymond Chandler * * switch_types.h -- Data Types * @@ -129,7 +130,9 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE "enable_heartbeat_events" #define SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE "bypass_media_after_bridge" #define SWITCH_READ_RESULT_VARIABLE "read_result" +#define SWITCH_ATT_XFER_RESULT_VARIABLE "att_xfer_result" #define SWITCH_COPY_XML_CDR_VARIABLE "copy_xml_cdr" +#define SWITCH_COPY_JSON_CDR_VARIABLE "copy_json_cdr" #define SWITCH_CURRENT_APPLICATION_VARIABLE "current_application" #define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause" #define SWITCH_TRANSFER_HISTORY_VARIABLE "transfer_history" @@ -141,6 +144,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE "execute_on_ring" #define SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE "execute_on_tone_detect" #define SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE "execute_on_originate" +#define SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE "execute_on_post_originate" #define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE "api_on_answer" #define SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE "api_on_pre_answer" @@ -148,6 +152,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_CHANNEL_API_ON_RING_VARIABLE "api_on_ring" #define SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE "api_on_tone_detect" #define SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE "api_on_originate" +#define SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE "api_on_post_originate" #define SWITCH_CALL_TIMEOUT_VARIABLE "call_timeout" #define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid" @@ -168,6 +173,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME "__cache_speech_handles_obj__" #define SWITCH_BYPASS_MEDIA_VARIABLE "bypass_media" #define SWITCH_PROXY_MEDIA_VARIABLE "proxy_media" +#define SWITCH_ZRTP_PASSTHRU_VARIABLE "zrtp_passthru" #define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition" #define SWITCH_HOLD_MUSIC_VARIABLE "hold_music" #define SWITCH_TEMP_HOLD_MUSIC_VARIABLE "temp_hold_music" @@ -180,6 +186,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_LAST_BRIDGE_VARIABLE "last_bridge_to" #define SWITCH_SIGNAL_BRIDGE_VARIABLE "signal_bridge_to" #define SWITCH_SIGNAL_BOND_VARIABLE "signal_bond" +#define SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE "originate_signal_bond" #define SWITCH_ORIGINATOR_VARIABLE "originator" #define SWITCH_ORIGINATOR_CODEC_VARIABLE "originator_codec" #define SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE "originator_video_codec" @@ -287,7 +294,8 @@ typedef enum { ED_NONE = 0, ED_MUX_READ = (1 << 0), ED_MUX_WRITE = (1 << 1), - ED_DTMF = (1 << 2) + ED_DTMF = (1 << 2), + ED_COPY_DISPLAY = (1 << 3) } switch_eavesdrop_flag_enum_t; typedef uint32_t switch_eavesdrop_flag_t; @@ -315,7 +323,9 @@ typedef enum { SCF_THREADED_SYSTEM_EXEC = (1 << 18), SCF_SYNC_CLOCK_REQUESTED = (1 << 19), SCF_CORE_ODBC_REQ = (1 << 20), - SCF_DEBUG_SQL = (1 << 21) + SCF_DEBUG_SQL = (1 << 21), + SCF_API_EXPANSION = (1 << 22), + SCF_SESSION_THREAD_POOL = (1 << 23) } switch_core_flag_enum_t; typedef uint32_t switch_core_flag_t; @@ -534,6 +544,7 @@ typedef struct { switch_size_t raw_bytes; switch_size_t media_bytes; switch_size_t packet_count; + switch_size_t period_packet_count; switch_size_t media_packet_count; switch_size_t skip_packet_count; switch_size_t jb_packet_count; @@ -546,13 +557,15 @@ typedef struct { typedef struct { uint32_t packet_count; - uint32_t octet_count; + uint32_t octet_count; + uint32_t peer_ssrc; } switch_rtcp_numbers_t; typedef struct { switch_rtp_numbers_t inbound; switch_rtp_numbers_t outbound; switch_rtcp_numbers_t rtcp; + uint32_t read_count; } switch_rtp_stats_t; typedef enum { @@ -703,7 +716,7 @@ typedef enum { */ - RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8) + RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8), /* Some RTP endpoints (and by some we mean *cough* _SONUS_!) do not like it when the timestamps jump forward or backwards in time. @@ -717,6 +730,12 @@ typedef enum { */ + RTP_BUG_CHANGE_SSRC_ON_MARKER = (1 << 9) + + /* + By default FS will change the SSRC when the marker is set and it detects a timestamp reset. + If this setting is enabled it will NOT do this (old behaviour). + */ } switch_rtp_bug_flag_t; @@ -882,8 +901,11 @@ typedef enum { SWITCH_MESSAGE_INDICATE_JITTER_BUFFER, SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH, SWITCH_MESSAGE_INDICATE_SIGNAL_DATA, + SWITCH_MESSAGE_INDICATE_MESSAGE, SWITCH_MESSAGE_INDICATE_INFO, SWITCH_MESSAGE_INDICATE_AUDIO_DATA, + SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, + SWITCH_MESSAGE_INDICATE_STUN_ERROR, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; @@ -1209,8 +1231,20 @@ typedef enum { CF_VIDEO_REFRESH_REQ, CF_SERVICE_AUDIO, CF_SERVICE_VIDEO, + CF_ZRTP_PASSTHRU_REQ, + CF_ZRTP_PASSTHRU, CF_ZRTP_HASH, - CF_ZRTP_PASS, + CF_CHANNEL_SWAP, + CF_PICKUP, + CF_CONFIRM_BLIND_TRANSFER, + CF_NO_PRESENCE, + CF_CONFERENCE, + CF_RECOVERING, + CF_RECOVERING_BRIDGE, + CF_TRACKED, + CF_TRACKABLE, + CF_NO_CDR, + CF_EARLY_OK, /* 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 @@ -1431,7 +1465,8 @@ typedef enum { SMBF_THREAD_LOCK = (1 << 7), SMBF_PRUNE = (1 << 8), SMBF_NO_PAUSE = (1 << 9), - SMBF_STEREO_SWAP = (1 << 10) + SMBF_STEREO_SWAP = (1 << 10), + SMBF_LOCK = (1 << 11) } switch_media_bug_flag_enum_t; typedef uint32_t switch_media_bug_flag_t; @@ -1631,6 +1666,10 @@ typedef enum { SWITCH_EVENT_SOCKET_DATA, SWITCH_EVENT_MEDIA_BUG_START, SWITCH_EVENT_MEDIA_BUG_STOP, + SWITCH_EVENT_CONFERENCE_DATA_QUERY, + SWITCH_EVENT_CONFERENCE_DATA, + SWITCH_EVENT_CALL_SETUP_REQ, + SWITCH_EVENT_CALL_SETUP_RESULT, SWITCH_EVENT_ALL } switch_event_types_t; @@ -1746,12 +1785,21 @@ typedef enum { SCSC_THREADED_SYSTEM_EXEC, SCSC_SYNC_CLOCK_WHEN_IDLE, SCSC_DEBUG_SQL, + SCSC_SQL, + SCSC_API_EXPANSION, + SCSC_RECOVER } switch_session_ctl_t; typedef enum { SSH_FLAG_STICKY = (1 << 0) } switch_state_handler_flag_t; +#ifdef WIN32 +typedef SOCKET switch_os_socket_t; +#else +typedef int switch_os_socket_t; +#endif + typedef struct apr_pool_t switch_memory_pool_t; typedef uint16_t switch_port_t; typedef uint8_t switch_payload_t; @@ -1818,6 +1866,8 @@ struct switch_console_callback_match { }; typedef struct switch_console_callback_match switch_console_callback_match_t; +typedef void (*switch_media_bug_exec_cb_t)(switch_media_bug_t *bug, void *user_data); + typedef void (*switch_cap_callback_t) (const char *var, const char *val, void *user_data); typedef switch_status_t (*switch_console_complete_callback_t) (const char *, const char *, switch_console_callback_match_t **matches); typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t); @@ -1850,6 +1900,7 @@ typedef switch_status_t (*switch_chat_application_function_t) (switch_event_t *, typedef void (*switch_application_function_t) (switch_core_session_t *, const char *); #define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data) +typedef int (*switch_core_recover_callback_t)(switch_core_session_t *session); typedef void (*switch_event_callback_t) (switch_event_t *); typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *, switch_caller_profile_t *); #define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t *name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index cce5abfa2d..6b1824a153 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -837,6 +837,16 @@ SWITCH_DECLARE(char *) switch_format_number(const char *num); SWITCH_DECLARE(unsigned int) switch_atoui(const char *nptr); SWITCH_DECLARE(unsigned long) switch_atoul(const char *nptr); +/** + * Portable version of strerror_r(), work around for the incompatible + * return type of GNU and XSI variants. + * \param[in] errnum Error number + * \param[both] buf Buffer for error message + * \param[in] buflen Size of message buffer + * \return Pointer to message buffer, returning error message or "Unknown error xxx" if none found + */ +SWITCH_DECLARE(char *) switch_strerror_r(int errnum, char *buf, switch_size_t buflen); + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/include/switch_version.h.cmake b/src/include/switch_version.h.cmake index 6510dba154..c722c2221d 100644 --- a/src/include/switch_version.h.cmake +++ b/src/include/switch_version.h.cmake @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2006, Anthony Minessale II + * Copyright (C) 2005/2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -41,7 +41,9 @@ extern "C" { #define SWITCH_VERSION_MINOR "@freeswitch_MINOR_VERSION@" #define SWITCH_VERSION_MICRO "@freeswitch_PATCH_LEVEL@" #define SWITCH_VERSION_REVISION "@Project_WC_REVISION@" -#define SWITCH_VERSION_FULL SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO " (" SWITCH_VERSION_REVISION ")" +#define SWITCH_VERSION_REVISION_HUMAN "@Project_WC_REVISION@" +#define SWITCH_VERSION_FULL SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO SWITCH_VERSION_REVISION +#define SWITCH_VERSION_FULL_HUMAN SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO SWITCH_VERSION_REVISION_HUMAN #ifdef __cplusplus } diff --git a/src/include/switch_version.h.template b/src/include/switch_version.h.template index c0e75b526e..dfec6e091e 100644 --- a/src/include/switch_version.h.template +++ b/src/include/switch_version.h.template @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2006, Anthony Minessale II + * Copyright (C) 2005/2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -41,7 +41,9 @@ extern "C" { #define SWITCH_VERSION_MINOR "@SWITCH_VERSION_MINOR@" #define SWITCH_VERSION_MICRO "@SWITCH_VERSION_MICRO@" #define SWITCH_VERSION_REVISION "@SWITCH_VERSION_REVISION@" -#define SWITCH_VERSION_FULL SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO " (" SWITCH_VERSION_REVISION ")" +#define SWITCH_VERSION_REVISION_HUMAN "@SWITCH_VERSION_REVISION_HUMAN@" +#define SWITCH_VERSION_FULL SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO SWITCH_VERSION_REVISION +#define SWITCH_VERSION_FULL_HUMAN SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO SWITCH_VERSION_REVISION_HUMAN #ifdef __cplusplus } diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index 558b8522f4..f2a6eb3220 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_xml_config.h b/src/include/switch_xml_config.h index 49986c9211..fc669e4fc1 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/timerfd_wrap.h b/src/include/timerfd_wrap.h index bb751c93a2..7196a6c1e0 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/.gitignore b/src/mod/.gitignore index 064b64c73d..af97a2c162 100644 --- a/src/mod/.gitignore +++ b/src/mod/.gitignore @@ -28,6 +28,7 @@ /asr_tts/mod_unimrcp/Makefile /asr_tts/mod_unimrcp/Makefile.in /asr_tts/mod_unimrcp/mod_unimrcp.log +/asr_tts/mod_flite/*/*/mod_flite_manifest.rc /dialplans/mod_dialplan_asterisk/Makefile /dialplans/mod_dialplan_xml/Makefile /endpoints/mod_portaudio/Makefile @@ -42,6 +43,8 @@ /endpoints/mod_sofia/Makefile /endpoints/mod_sofia/Makefile.in /endpoints/mod_sofia/mod_sofia.log +/endpoints/mod_html5/Makefile +/endpoints/mod_html5/Makefile.in /event_handlers/mod_erlang_event/Makefile /event_handlers/mod_event_socket/Makefile /formats/mod_native_file/Makefile @@ -63,5 +66,7 @@ /loggers/mod_logfile/Makefile /loggers/mod_syslog/Makefile /say/mod_say_en/Makefile +/say/mod_say_ja/Makefile /say/mod_say_ru/Makefile +/timers/mod_posix_timer/Makefile /timers/mod_timerfd/Makefile diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 30bdf9c2b3..df8670f2ee 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -1466,6 +1466,8 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "ignore_early_media", "true"); switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "origination_uuid", "%s", agent_uuid_str); + switch_channel_process_export(member_channel, NULL, ovars, "cc_export_vars"); + t_agent_called = local_epoch_time_now(NULL); dialstr = switch_mprintf("%s", 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); @@ -1534,7 +1536,7 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa /* Wait for the real channel to be fully bridged */ switch_channel_wait_for_flag(other_loopback_channel, CF_BRIDGED, SWITCH_TRUE, 5000, member_channel); - real_uuid = switch_channel_get_variable(other_loopback_channel, SWITCH_SIGNAL_BOND_VARIABLE); + real_uuid = switch_channel_get_partner_uuid(other_loopback_channel); switch_channel_set_variable(other_loopback_channel, "cc_member_pre_answer_uuid", NULL); /* Switch the agent session */ diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 289f6d3b02..19817c83c3 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -33,6 +33,7 @@ * Massimo Cetra * Rupa Schomaker * Joseph Sullivan + * Raymond Chandler * * * mod_commands.c -- Misc. Command Module @@ -285,7 +286,7 @@ SWITCH_STANDARD_API(shutdown_function) SWITCH_STANDARD_API(version_function) { - stream->write_function(stream, "FreeSWITCH Version %s\n", SWITCH_VERSION_FULL); + stream->write_function(stream, "FreeSWITCH Version %s (%s)\n", SWITCH_VERSION_FULL, SWITCH_VERSION_FULL_HUMAN); return SWITCH_STATUS_SUCCESS; } @@ -1559,27 +1560,22 @@ SWITCH_STANDARD_API(regex_function) goto error; } - if ((proceed = switch_regex_perform(argv[0], argv[1], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { - if (argc > 2) { - len = (strlen(argv[0]) + strlen(argv[2]) + 10) * proceed; - substituted = malloc(len); - switch_assert(substituted); - memset(substituted, 0, len); - switch_replace_char(argv[2], '%', '$', SWITCH_FALSE); - switch_perform_substitution(re, proceed, argv[2], argv[0], substituted, len, ovector); + proceed = switch_regex_perform(argv[0], argv[1], &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - stream->write_function(stream, "%s", substituted); - free(substituted); - } else { - stream->write_function(stream, "true"); - } + if (argc > 2) { + len = (strlen(argv[0]) + strlen(argv[2]) + 10) * proceed; + substituted = malloc(len); + switch_assert(substituted); + memset(substituted, 0, len); + switch_replace_char(argv[2], '%', '$', SWITCH_FALSE); + switch_perform_substitution(re, proceed, argv[2], argv[0], substituted, len, ovector); + + stream->write_function(stream, "%s", substituted); + free(substituted); } else { - if (argc > 2) { - stream->write_function(stream, "%s", argv[0]); - } else { - stream->write_function(stream, "false"); - } + stream->write_function(stream, proceed ? "true" : "false"); } + goto ok; error: @@ -1733,6 +1729,7 @@ SWITCH_STANDARD_API(status_function) char *http = NULL; int sps = 0, last_sps = 0; const char *var; + switch_size_t cur = 0, max = 0; switch_core_measure_time(switch_core_uptime(), &duration); @@ -1769,6 +1766,11 @@ SWITCH_STANDARD_API(status_function) stream->write_function(stream, "%d session(s) max\n", switch_core_session_limit(0)); stream->write_function(stream, "min idle cpu %0.2f/%0.2f\n", switch_core_min_idle_cpu(-1.0), switch_core_idle_cpu()); + + if (switch_core_get_stacksizes(&cur, &max) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "Current Stack Size/Max %ldK/%ldK\n", cur / 1024, max / 1024); + } + if (html) { stream->write_function(stream, "\n"); } @@ -1788,7 +1790,7 @@ SWITCH_STANDARD_API(status_function) return SWITCH_STATUS_SUCCESS; } -#define CTL_SYNTAX "[send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]]" +#define CTL_SYNTAX "[recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]]" SWITCH_STANDARD_API(ctl_function) { int argc; @@ -1807,6 +1809,13 @@ SWITCH_STANDARD_API(ctl_function) arg = 1; switch_core_session_ctl(SCSC_HUPALL, &arg); stream->write_function(stream, "+OK\n"); + } else if (!strcasecmp(argv[0], "recover")) { + int r = switch_core_session_ctl(SCSC_RECOVER, argv[1]); + if (r < 0){ + stream->write_function(stream, "+OK flushed\n"); + } else { + stream->write_function(stream, "+OK %d session(s) recovered in total\n", r); + } } else if (!strcasecmp(argv[0], "flush_db_handles")) { switch_core_session_ctl(SCSC_FLUSH_DB_HANDLES, NULL); stream->write_function(stream, "+OK\n"); @@ -1853,6 +1862,15 @@ SWITCH_STANDARD_API(ctl_function) switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &arg); stream->write_function(stream, "+OK verbose_events is %s \n", arg ? "on" : "off"); + } else if (!strcasecmp(argv[0], "api_expansion")) { + arg = -1; + if (argv[1]) { + arg = switch_true(argv[1]); + } + + switch_core_session_ctl(SCSC_API_EXPANSION, &arg); + + stream->write_function(stream, "+OK api_expansion is %s \n", arg ? "on" : "off"); } else if (!strcasecmp(argv[0], "threaded_system_exec")) { arg = -1; if (argv[1]) { @@ -1914,6 +1932,16 @@ SWITCH_STANDARD_API(ctl_function) switch_core_session_ctl(SCSC_DEBUG_SQL, &x); stream->write_function(stream, "+OK SQL DEBUG [%s]\n", x ? "on" : "off"); + } else if (!strcasecmp(argv[0], "sql")) { + if (argv[1]) { + int x = 0; + if (!strcasecmp(argv[1], "start")) { + x = 1; + } + switch_core_session_ctl(SCSC_SQL, &x); + stream->write_function(stream, "+OK\n"); + } + } else if (!strcasecmp(argv[0], "reclaim_mem")) { switch_core_session_ctl(SCSC_RECLAIM, &arg); stream->write_function(stream, "+OK\n"); @@ -2649,9 +2677,10 @@ SWITCH_STANDARD_API(sched_hangup_function) char *cause_str = argv[2]; time_t when; switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; + int sec = atol(argv[0] + 1); if (*argv[0] == '+') { - when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + sec; } else { when = atol(argv[0]); } @@ -2661,7 +2690,13 @@ SWITCH_STANDARD_API(sched_hangup_function) } if ((hsession = switch_core_session_locate(uuid))) { - switch_ivr_schedule_hangup(when, uuid, cause, SWITCH_FALSE); + if (sec == 0) { + switch_channel_t *hchannel = switch_core_session_get_channel(hsession); + switch_channel_hangup(hchannel, cause); + } else { + switch_ivr_schedule_hangup(when, uuid, cause, SWITCH_FALSE); + } + stream->write_function(stream, "+OK\n"); switch_core_session_rwunlock(hsession); } else { @@ -2704,6 +2739,55 @@ SWITCH_STANDARD_API(uuid_media_function) return SWITCH_STATUS_SUCCESS; } +SWITCH_STANDARD_API(uuid_early_ok_function) +{ + char *uuid = (char *) cmd; + switch_core_session_t *xsession; + + if (uuid && (xsession = switch_core_session_locate(uuid))) { + switch_channel_t *channel = switch_core_session_get_channel(xsession); + switch_channel_set_flag(channel, CF_EARLY_OK); + switch_core_session_rwunlock(xsession); + } else { + stream->write_function(stream, "-ERROR\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_STANDARD_API(uuid_pre_answer_function) +{ + char *uuid = (char *) cmd; + switch_core_session_t *xsession; + + if (uuid && (xsession = switch_core_session_locate(uuid))) { + switch_channel_t *channel = switch_core_session_get_channel(xsession); + switch_channel_pre_answer(channel); + switch_core_session_rwunlock(xsession); + } else { + stream->write_function(stream, "-ERROR\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_STANDARD_API(uuid_answer_function) +{ + char *uuid = (char *) cmd; + switch_core_session_t *xsession; + + if (uuid && (xsession = switch_core_session_locate(uuid))) { + switch_channel_t *channel = switch_core_session_get_channel(xsession); + switch_channel_answer(channel); + switch_core_session_rwunlock(xsession); + } else { + stream->write_function(stream, "-ERROR\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + + #define BROADCAST_SYNTAX " [aleg|bleg|holdb|both]" SWITCH_STANDARD_API(uuid_broadcast_function) { @@ -3048,6 +3132,49 @@ SWITCH_STANDARD_API(uuid_phone_event_function) return SWITCH_STATUS_SUCCESS; } +#define SEND_MESSAGE_SYNTAX " " +SWITCH_STANDARD_API(uuid_send_message_function) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + char *mycmd = NULL, *argv[2] = { 0 }; + int argc = 0; + + if (!zstr(cmd) && (mycmd = strdup(cmd))) { + argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + if (argc < 2) { + stream->write_function(stream, "-USAGE: %s\n", SEND_MESSAGE_SYNTAX); + goto end; + } else { + switch_core_session_message_t msg = { 0 }; + switch_core_session_t *lsession = NULL; + + msg.message_id = SWITCH_MESSAGE_INDICATE_MESSAGE; + msg.string_array_arg[2] = argv[1]; + msg.from = __FILE__; + + if ((lsession = switch_core_session_locate(argv[0]))) { + status = switch_core_session_receive_message(lsession, &msg); + switch_core_session_rwunlock(lsession); + } else { + stream->write_function(stream, "-ERR Unable to find session for UUID\n"); + goto end; + } + } + + if (status == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK Success\n"); + } else { + stream->write_function(stream, "-ERR Operation Failed\n"); + } + + end: + switch_safe_free(mycmd); + + return SWITCH_STATUS_SUCCESS; +} + #define INFO_SYNTAX "" SWITCH_STANDARD_API(uuid_send_info_function) { @@ -3087,6 +3214,45 @@ SWITCH_STANDARD_API(uuid_send_info_function) } +#define VIDEO_REFRESH_SYNTAX "" +SWITCH_STANDARD_API(uuid_video_refresh_function) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + char *mycmd = NULL, *argv[2] = { 0 }; + int argc = 0; + + if (!zstr(cmd) && (mycmd = strdup(cmd))) { + argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + if (argc < 1) { + stream->write_function(stream, "-USAGE: %s\n", VIDEO_REFRESH_SYNTAX); + } else { + switch_core_session_message_t msg = { 0 }; + switch_core_session_t *lsession = NULL; + + msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ; + msg.string_array_arg[2] = argv[1]; + msg.from = __FILE__; + + if ((lsession = switch_core_session_locate(argv[0]))) { + status = switch_core_session_receive_message(lsession, &msg); + switch_core_session_rwunlock(lsession); + } + } + + if (status == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK Success\n"); + } else { + stream->write_function(stream, "-ERR Operation Failed\n"); + } + + switch_safe_free(mycmd); + + return SWITCH_STATUS_SUCCESS; +} + + #define DEBUG_AUDIO_SYNTAX " " SWITCH_STANDARD_API(uuid_debug_audio_function) { @@ -3398,7 +3564,7 @@ SWITCH_STANDARD_API(break_function) channel = switch_core_session_get_channel(psession); if (both) { - const char *quuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *quuid = switch_channel_get_partner_uuid(channel); if (quuid && (qsession = switch_core_session_locate(quuid))) { qchannel = switch_core_session_get_channel(qsession); } @@ -3869,10 +4035,50 @@ struct holder { uint32_t count; int print_title; switch_xml_t xml; + cJSON *json; int rows; int justcount; }; +static int show_as_json_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + struct holder *holder = (struct holder *) pArg; + cJSON *row; + int x; + + if (holder->count == 0) { + if (!(holder->json = cJSON_CreateArray())) { + return -1; + } + } + + if (holder->justcount) { + holder->count++; + return 0; + } + + if (!(row = cJSON_CreateObject())) { + return -1; + } + + cJSON_AddItemToArray(holder->json, row); + + for (x = 0; x < argc; x++) { + char *name = columnNames[x]; + char *val = switch_str_nil(argv[x]); + + if (!name) { + name = "undefined"; + } + + cJSON_AddItemToObject(row, name, cJSON_CreateString(val)); + } + + holder->count++; + + return 0; +} + static int show_as_xml_callback(void *pArg, int argc, char **argv, char **columnNames) { struct holder *holder = (struct holder *) pArg; @@ -4243,6 +4449,45 @@ SWITCH_STANDARD_API(show_function) } else { holder.stream->write_function(holder.stream, "\n"); } + } else if (!strcasecmp(as, "json")) { + + switch_cache_db_execute_sql_callback(db, sql, show_as_json_callback, &holder, &errmsg); + + if (errmsg) { + stream->write_function(stream, "-ERR SQL Error [%s]\n", errmsg); + free(errmsg); + errmsg = NULL; + } + + if (holder.json) { + cJSON *result; + + if (!(result = cJSON_CreateObject())) { + cJSON_Delete(holder.json); + holder.json = NULL; + holder.stream->write_function(holder.stream, "-ERR Error creating json object!\n"); + } else { + char *json_text; + + cJSON_AddItemToObject(result, "row_count", cJSON_CreateNumber(holder.count)); + cJSON_AddItemToObject(result, "rows", holder.json); + + json_text = cJSON_PrintUnformatted(result); + + if (!json_text) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); + holder.stream->write_function(holder.stream, "-ERR Memory Error!\n"); + } else { + holder.stream->write_function(holder.stream, json_text); + } + cJSON_Delete(result); + switch_safe_free(json_text); + } + + } else { + holder.stream->write_function(holder.stream, "{\"row_count\": 0}\n"); + } + } else { holder.stream->write_function(holder.stream, "-ERR Cannot find format %s\n", as); } @@ -4705,6 +4950,8 @@ SWITCH_STANDARD_API(uuid_dump_function) switch_core_session_rwunlock(psession); goto done; } + } else if (!strcasecmp(format, "json")) { + switch_event_serialize_json(event, &buf); } else { switch_event_serialize(event, &buf, strcasecmp(format, "plain")); } @@ -5415,7 +5662,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "url_decode", "url decode a string", url_decode_function, ""); SWITCH_ADD_API(commands_api_interface, "url_encode", "url encode a string", url_encode_function, ""); SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "@ [var|param|attr] "); + SWITCH_ADD_API(commands_api_interface, "uuid_early_ok", "stop ignoring early media", uuid_early_ok_function, ""); SWITCH_ADD_API(commands_api_interface, "user_exists", "find a user", user_exists_function, " "); + SWITCH_ADD_API(commands_api_interface, "uuid_answer", "answer", uuid_answer_function, ""); SWITCH_ADD_API(commands_api_interface, "uuid_audio", "uuid_audio", session_audio_function, AUDIO_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_break", "Break", break_function, BREAK_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_bridge", "uuid_bridge", uuid_bridge_function, ""); @@ -5433,7 +5682,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX); 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_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); SWITCH_ADD_API(commands_api_interface, "uuid_limit_release", "Release limit resource", uuid_limit_release_function, LIMIT_RELEASE_SYNTAX); @@ -5441,6 +5692,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_park", "Park Channel", park_function, PARK_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_phone_event", "Send and event to the phone", uuid_phone_event_function, PHONE_EVENT_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "uuid_pre_answer", "pre_answer", uuid_pre_answer_function, ""); SWITCH_ADD_API(commands_api_interface, "uuid_preprocess", "Pre-process Channel", preprocess_function, PREPROCESS_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_record", "session record", session_record_function, SESS_REC_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_recovery_refresh", "Send a recovery_refresh", uuid_recovery_refresh, UUID_RECOVERY_REFRESH_SYNTAX); @@ -5498,6 +5750,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add fsctl pause_check inbound"); switch_console_set_complete("add fsctl pause_check outbound"); switch_console_set_complete("add fsctl ready_check"); + switch_console_set_complete("add fsctl recover"); switch_console_set_complete("add fsctl shutdown_check"); switch_console_set_complete("add fsctl shutdown"); switch_console_set_complete("add fsctl shutdown asap"); @@ -5563,6 +5816,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add uuid_displace ::console::list_uuid"); switch_console_set_complete("add uuid_display ::console::list_uuid"); switch_console_set_complete("add uuid_dump ::console::list_uuid"); + switch_console_set_complete("add uuid_answer ::console::list_uuid"); + switch_console_set_complete("add uuid_pre_answer ::console::list_uuid"); + switch_console_set_complete("add uuid_early_ok ::console::list_uuid"); switch_console_set_complete("add uuid_exists ::console::list_uuid"); switch_console_set_complete("add uuid_fileman ::console::list_uuid"); switch_console_set_complete("add uuid_flush_dtmf ::console::list_uuid"); @@ -5598,6 +5854,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add uuid_simplify ::console::list_uuid"); switch_console_set_complete("add uuid_transfer ::console::list_uuid"); switch_console_set_complete("add uuid_dual_transfer ::console::list_uuid"); + switch_console_set_complete("add uuid_video_refresh ::console::list_uuid"); switch_console_set_complete("add version"); switch_console_set_complete("add uuid_warning ::console::list_uuid"); switch_console_set_complete("add ..."); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 89182fa6de..cd3a7d0504 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -43,16 +43,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown); SWITCH_MODULE_DEFINITION(mod_conference, mod_conference_load, mod_conference_shutdown, NULL); -typedef struct conference_cdr_node_s { - switch_caller_profile_t *cp; - char *record_path; - switch_time_t join_time; - switch_time_t leave_time; - struct conference_cdr_node_s *next; -} conference_cdr_node_t; - - - typedef enum { CONF_SILENT_REQ = (1 << 0), CONF_SILENT_DONE = (1 << 1) @@ -107,13 +97,40 @@ static struct { uint32_t id_pool; int32_t running; uint32_t threads; - switch_event_node_t *node; } globals; /* forward declaration for conference_obj and caller_control */ struct conference_member; typedef struct conference_member conference_member_t; + +typedef struct conference_cdr_node_s { + switch_caller_profile_t *cp; + char *record_path; + switch_time_t join_time; + switch_time_t leave_time; + uint32_t flags; + uint32_t id; + conference_member_t *member; + struct conference_cdr_node_s *next; +} conference_cdr_node_t; + +typedef enum { + CDRR_LOCKED = 1, + CDRR_PIN, + CDRR_MAXMEMBERS +} cdr_reject_reason_t; + +typedef struct conference_cdr_reject_s { + switch_caller_profile_t *cp; + switch_time_t reject_time; + cdr_reject_reason_t reason; + struct conference_cdr_reject_s *next; +} conference_cdr_reject_t; + + + + struct call_list { char *string; int iteration; @@ -156,7 +173,8 @@ typedef enum { MFLAG_INDICATE_UNMUTE = (1 << 18), MFLAG_NOMOH = (1 << 19), MFLAG_VIDEO_BRIDGE = (1 << 20), - MFLAG_INDICATE_MUTE_DETECT = (1 << 21) + MFLAG_INDICATE_MUTE_DETECT = (1 << 21), + MFLAG_PAUSE_RECORDING = (1 << 22) } member_flag_t; typedef enum { @@ -175,7 +193,9 @@ typedef enum { CFLAG_EXIT_SOUND = (1 << 12), CFLAG_ENTER_SOUND = (1 << 13), CFLAG_VIDEO_BRIDGE = (1 << 14), - CFLAG_AUDIO_ALWAYS = (1 << 15) + CFLAG_AUDIO_ALWAYS = (1 << 15), + CFLAG_ENDCONF_FORCED = (1 << 16), + CFLAG_RFC4579 = (1 << 17) } conf_flag_t; typedef enum { @@ -217,7 +237,8 @@ typedef enum { EFLAG_FLOOR_CHANGE = (1 << 25), EFLAG_MUTE_DETECT = (1 << 26), EFLAG_RECORD = (1 << 27), - EFLAG_HUP_MEMBER = (1 << 28) + EFLAG_HUP_MEMBER = (1 << 28), + EFLAG_PLAY_FILE_DONE = (1 << 29), } event_type_t; typedef struct conference_file_node { @@ -232,6 +253,12 @@ typedef struct conference_file_node { char *file; } conference_file_node_t; +typedef enum { + REC_ACTION_STOP = 1, + REC_ACTION_PAUSE, + REC_ACTION_RESUME +} recording_action_type_t; + /* conference xml config sections */ typedef struct conf_xml_cfg { switch_xml_t profile; @@ -247,6 +274,7 @@ struct vid_helper { /* Conference Object */ typedef struct conference_obj { char *name; + char *desc; char *timer_name; char *tts_engine; char *tts_voice; @@ -270,8 +298,10 @@ typedef struct conference_obj { char *special_announce; char *auto_record; char *record_filename; + char *outcall_templ; uint32_t terminate_on_silence; uint32_t max_members; + uint32_t doc_version; char *maxmember_sound; uint32_t announce_count; char *pin; @@ -331,10 +361,12 @@ typedef struct conference_obj { uint32_t originating; switch_call_cause_t cancel_cause; conference_cdr_node_t *cdr_nodes; + conference_cdr_reject_t *cdr_rejected; switch_time_t start_time; switch_time_t end_time; char *log_dir; struct vid_helper vh[2]; + struct vid_helper mh; } conference_obj_t; /* Relationship with another member */ @@ -443,7 +475,7 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char * static void conference_send_all_dtmf(conference_member_t *member, conference_obj_t *conference, const char *dtmf); static switch_status_t conference_say(conference_obj_t *conference, const char *text, uint32_t leadin); static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim); -static conference_obj_t *conference_find(char *name); +static conference_obj_t *conference_find(char *name, char *domain); static void member_bind_controls(conference_member_t *member, const char *controls); static void conference_send_presence(conference_obj_t *conference); @@ -458,11 +490,11 @@ static switch_status_t conference_outcall(conference_obj_t *conference, char *cid_num, char *profile, switch_call_cause_t *cause, - switch_call_cause_t *cancel_cause); + switch_call_cause_t *cancel_cause, switch_event_t *var_event); static switch_status_t conference_outcall_bg(conference_obj_t *conference, char *conference_name, switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name, - const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause); + const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause, switch_event_t **var_event); SWITCH_STANDARD_APP(conference_function); static void launch_conference_thread(conference_obj_t *conference); static void launch_conference_video_thread(conference_obj_t *conference); @@ -477,7 +509,8 @@ static switch_status_t chat_send(switch_event_t *message_event); static void launch_conference_record_thread(conference_obj_t *conference, char *path); -static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b); +static int launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b); +static void launch_conference_video_mirror_thread(conference_member_t *member_a); typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **); typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *); @@ -485,11 +518,14 @@ typedef switch_status_t (*conf_api_text_cmd_t) (conference_obj_t *, switch_strea static void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, uint8_t non_mod, conf_api_member_cmd_t pfncallback, void *data); 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_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); static switch_status_t conference_add_event_member_data(conference_member_t *member, switch_event_t *event); +static switch_status_t conf_api_sub_floor(conference_member_t *member, switch_stream_handle_t *stream, void *data); +static switch_status_t conf_api_sub_enforce_floor(conference_member_t *member, switch_stream_handle_t *stream, void *data); #define lock_member(_member) switch_mutex_lock(_member->write_mutex); switch_mutex_lock(_member->read_mutex) @@ -502,6 +538,8 @@ static switch_status_t conference_add_event_member_data(conference_member_t *mem static void conference_cdr_del(conference_member_t *member) { member->cdr_node->leave_time = switch_epoch_time_now(NULL); + member->cdr_node->flags = member->flags; + member->cdr_node->member = NULL; } static void conference_cdr_add(conference_member_t *member) @@ -515,6 +553,7 @@ static void conference_cdr_add(conference_member_t *member) np->next = member->conference->cdr_nodes; member->conference->cdr_nodes = member->cdr_node = np; member->cdr_node->join_time = switch_epoch_time_now(NULL); + member->cdr_node->member = member; if (!member->session) { member->cdr_node->record_path = switch_core_strdup(member->conference->pool, member->rec_path); @@ -528,12 +567,300 @@ static void conference_cdr_add(conference_member_t *member) } member->cdr_node->cp = switch_caller_profile_dup(member->conference->pool, cp); + + member->cdr_node->id = member->id; + + + +} + +static void conference_cdr_rejected(conference_obj_t *conference, switch_channel_t *channel, cdr_reject_reason_t reason) +{ + conference_cdr_reject_t *rp; + switch_caller_profile_t *cp; + + rp = switch_core_alloc(conference->pool, sizeof(*rp)); + + rp->next = conference->cdr_rejected; + conference->cdr_rejected = rp; + rp->reason = reason; + rp->reject_time = switch_epoch_time_now(NULL); + + if (!(cp = switch_channel_get_caller_profile(channel))) { + return; + } + + rp->cp = switch_caller_profile_dup(conference->pool, cp); +} + +static char *conference_rfc4579_render(conference_obj_t *conference, switch_event_t *event, switch_event_t *revent) +{ + switch_xml_t xml, x_tag, x_tag1, x_tag2, x_tag3, x_tag4; + char tmp[30]; + const char *domain; const char *name; + char *dup_domain = NULL; + char *uri; + int off = 0, off1 = 0, off2 = 0, off3 = 0, off4 = 0; + conference_cdr_node_t *np; + char *tmpp = tmp; + char *xml_text = NULL; + + if (!(xml = switch_xml_new("conference-info"))) { + abort(); + } + + switch_mutex_lock(conference->mutex); + switch_snprintf(tmp, sizeof(tmp), "%u", conference->doc_version); + conference->doc_version++; + switch_mutex_unlock(conference->mutex); + + if (!event || !(name = switch_event_get_header(event, "conference-name"))) { + if (!(name = conference->name)) { + name = "conference"; + } + } + + if (!event || !(domain = switch_event_get_header(event, "conference-domain"))) { + if (!(domain = conference->domain)) { + dup_domain = switch_core_get_variable_dup("domain"); + if (!(domain = dup_domain)) { + domain = "cluecon.com"; + } + } + } + + switch_xml_set_attr_d(xml, "version", tmpp); + + switch_xml_set_attr_d(xml, "state", "full"); + switch_xml_set_attr_d(xml, "xmlns", "urn:ietf:params:xml:ns:conference-info"); + + + uri = switch_mprintf("sip:%s@%s", name, domain); + switch_xml_set_attr_d(xml, "entity", uri); + + if (!(x_tag = switch_xml_add_child_d(xml, "conference-description", off++))) { + abort(); + } + + if (!(x_tag1 = switch_xml_add_child_d(x_tag, "display-text", off1++))) { + abort(); + } + switch_xml_set_txt_d(x_tag1, conference->desc ? conference->desc : "FreeSWITCH Conference"); + + + if (!(x_tag1 = switch_xml_add_child_d(x_tag, "conf-uris", off1++))) { + abort(); + } + + if (!(x_tag2 = switch_xml_add_child_d(x_tag1, "entry", off2++))) { + abort(); + } + + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "uri", off3++))) { + abort(); + } + switch_xml_set_txt_d(x_tag3, uri); + + + + if (!(x_tag = switch_xml_add_child_d(xml, "conference-state", off++))) { + abort(); + } + if (!(x_tag1 = switch_xml_add_child_d(x_tag, "user-count", off1++))) { + abort(); + } + switch_snprintf(tmp, sizeof(tmp), "%u", conference->count); + switch_xml_set_txt_d(x_tag1, tmpp); + +#if 0 + if (conference->count == 0) { + switch_event_add_header(revent, SWITCH_STACK_BOTTOM, "notfound", "true"); + } +#endif + + if (!(x_tag1 = switch_xml_add_child_d(x_tag, "active", off1++))) { + abort(); + } + switch_xml_set_txt_d(x_tag1, "true"); + + off1 = off2 = off3 = off4 = 0; + + if (!(x_tag = switch_xml_add_child_d(xml, "users", off++))) { + abort(); + } + + switch_mutex_lock(conference->member_mutex); + + for (np = conference->cdr_nodes; np; np = np->next) { + char *user_uri = NULL; + switch_channel_t *channel = NULL; + + if (!np->cp || (np->member && !np->member->session) || np->leave_time) { /* for now we'll remove participants when the leave */ + continue; + } + + if (np->member && np->member->session) { + channel = switch_core_session_get_channel(np->member->session); + } + + if (!(x_tag1 = switch_xml_add_child_d(x_tag, "user", off1++))) { + abort(); + } + + if (channel) { + const char *uri = switch_channel_get_variable_dup(channel, "conference_invite_uri", SWITCH_FALSE, -1); + + if (uri) { + user_uri = strdup(uri); + } + } + + if (!user_uri) { + user_uri = switch_mprintf("sip:%s@%s", np->cp->caller_id_number, domain); + } + + + switch_xml_set_attr_d(x_tag1, "state", "full"); + switch_xml_set_attr_d(x_tag1, "entity", user_uri); + + if (!(x_tag2 = switch_xml_add_child_d(x_tag1, "display-text", off2++))) { + abort(); + } + switch_xml_set_txt_d(x_tag2, np->cp->caller_id_name); + + + if (!(x_tag2 = switch_xml_add_child_d(x_tag1, "endpoint", off2++))) { + abort(); + } + switch_xml_set_attr_d(x_tag2, "entity", user_uri); + + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "display-text", off3++))) { + abort(); + } + switch_xml_set_txt_d(x_tag3, np->cp->caller_id_name); + + + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "status", off3++))) { + abort(); + } + switch_xml_set_txt_d(x_tag3, np->leave_time ? "disconnected" : "connected"); + + + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "joining-info", off3++))) { + abort(); + } + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "when", off4++))) { + abort(); + } else { + switch_time_exp_t tm; + switch_size_t retsize; + const char *fmt = "%Y-%m-%dT%H:%M:%S%z"; + char *p; + + switch_time_exp_lt(&tm, (switch_time_t) conference->start_time * 1000000); + switch_strftime_nocheck(tmp, &retsize, sizeof(tmp), fmt, &tm); + p = end_of_p(tmpp) -1; + snprintf(p, 4, ":00"); + + + switch_xml_set_txt_d(x_tag4, tmpp); + } + + + + + /** ok so this is in the rfc but not the xsd + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "joining-method", off3++))) { + abort(); + } + switch_xml_set_txt_d(x_tag3, np->cp->direction == SWITCH_CALL_DIRECTION_INBOUND ? "dialed-in" : "dialed-out"); + */ + + if (np->member) { + const char *var; + //char buf[1024]; + + //switch_snprintf(buf, sizeof(buf), "conf_%s_%s_%s", conference->name, conference->domain, np->cp->caller_id_number); + //switch_channel_set_variable(channel, "conference_call_key", buf); + + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "media", off3++))) { + abort(); + } + + snprintf(tmp, sizeof(tmp), "%ua", np->member->id); + switch_xml_set_attr_d(x_tag3, "id", tmpp); + + + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "type", off4++))) { + abort(); + } + switch_xml_set_txt_d(x_tag4, "audio"); + + if ((var = switch_channel_get_variable(channel, "rtp_use_ssrc"))) { + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "src-id", off4++))) { + abort(); + } + switch_xml_set_txt_d(x_tag4, var); + } + + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "status", off4++))) { + abort(); + } + switch_xml_set_txt_d(x_tag4, switch_channel_test_flag(channel, CF_HOLD) ? "sendonly" : "sendrecv"); + + + if (switch_channel_test_flag(channel, CF_VIDEO)) { + off4 = 0; + + if (!(x_tag3 = switch_xml_add_child_d(x_tag2, "media", off3++))) { + abort(); + } + + snprintf(tmp, sizeof(tmp), "%uv", np->member->id); + switch_xml_set_attr_d(x_tag3, "id", tmpp); + + + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "type", off4++))) { + abort(); + } + switch_xml_set_txt_d(x_tag4, "video"); + + if ((var = switch_channel_get_variable(channel, "rtp_use_video_ssrc"))) { + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "src-id", off4++))) { + abort(); + } + switch_xml_set_txt_d(x_tag4, var); + } + + if (!(x_tag4 = switch_xml_add_child_d(x_tag3, "status", off4++))) { + abort(); + } + switch_xml_set_txt_d(x_tag4, switch_channel_test_flag(channel, CF_HOLD) ? "sendonly" : "sendrecv"); + + } + } + + switch_safe_free(user_uri); + } + + switch_mutex_unlock(conference->member_mutex); + + off1 = off2 = off3 = off4 = 0; + + xml_text = switch_xml_toxml(xml, SWITCH_TRUE); + switch_xml_free(xml); + + switch_safe_free(dup_domain); + switch_safe_free(uri); + + return xml_text; } static void conference_cdr_render(conference_obj_t *conference) { - switch_xml_t cdr, x_ptr, x_member, x_members, x_conference, x_cp; + switch_xml_t cdr, x_ptr, x_member, x_members, x_conference, x_cp, x_flags, x_tag, x_rejected, x_attempt; conference_cdr_node_t *np; + conference_cdr_reject_t *rp; int cdr_off = 0, conf_off = 0; char str[512]; char *path, *xml_text; @@ -541,7 +868,7 @@ static void conference_cdr_render(conference_obj_t *conference) if (zstr(conference->log_dir)) return; - if (!conference->cdr_nodes) return; + if (!conference->cdr_nodes && !conference->cdr_rejected) return; if (!(cdr = switch_xml_new("cdr"))) { abort(); @@ -580,18 +907,20 @@ static void conference_cdr_render(conference_obj_t *conference) if (!(x_ptr = switch_xml_add_child_d(x_conference, "end_time", conf_off++))) { abort(); } + switch_xml_set_attr_d(x_ptr, "endconf_forced", switch_test_flag(conference, CFLAG_ENDCONF_FORCED) ? "true" : "false"); switch_xml_set_attr_d(x_ptr, "type", "UNIX-epoch"); switch_snprintf(str, sizeof(str), "%ld", (long)conference->end_time); switch_xml_set_txt_d(x_ptr, str); + if (!(x_members = switch_xml_add_child_d(x_conference, "members", conf_off++))) { abort(); } - for (np = conference->cdr_nodes; np; np = np->next) { int member_off = 0; + int flag_off = 0; if (!(x_member = switch_xml_add_child_d(x_members, "member", conf_off++))) { @@ -616,6 +945,18 @@ static void conference_cdr_render(conference_obj_t *conference) switch_xml_set_txt_d(x_ptr, str); if (np->cp) { + x_flags = switch_xml_add_child_d(x_member, "flags", member_off++); + switch_assert(x_flags); + + x_tag = switch_xml_add_child_d(x_flags, "is_moderator", flag_off++); + switch_xml_set_txt_d(x_tag, switch_test_flag(np, MFLAG_MOD) ? "true" : "false"); + + x_tag = switch_xml_add_child_d(x_flags, "end_conference", flag_off++); + switch_xml_set_txt_d(x_tag, switch_test_flag(np, MFLAG_ENDCONF) ? "true" : "false"); + + x_tag = switch_xml_add_child_d(x_flags, "was_kicked", flag_off++); + switch_xml_set_txt_d(x_tag, switch_test_flag(np, MFLAG_KICKED) ? "true" : "false"); + if (!(x_cp = switch_xml_add_child_d(x_member, "caller_profile", member_off++))) { abort(); } @@ -628,8 +969,47 @@ static void conference_cdr_render(conference_obj_t *conference) } switch_xml_set_txt_d(x_ptr, np->record_path); } + + } + if (!(x_rejected = switch_xml_add_child_d(x_conference, "rejected", conf_off++))) { + abort(); + } + + for (rp = conference->cdr_rejected; rp; rp = rp->next) { + int attempt_off = 0; + int tag_off = 0; + + if (!(x_attempt = switch_xml_add_child_d(x_rejected, "attempt", attempt_off++))) { + abort(); + } + + if (!(x_ptr = switch_xml_add_child_d(x_attempt, "reason", tag_off++))) { + abort(); + } + if (rp->reason == CDRR_LOCKED) { + switch_xml_set_txt_d(x_ptr, "conference_locked"); + } else if (rp->reason == CDRR_MAXMEMBERS) { + switch_xml_set_txt_d(x_ptr, "max_members_reached"); + } else if (rp->reason == CDRR_PIN) { + switch_xml_set_txt_d(x_ptr, "invalid_pin"); + } + + if (!(x_ptr = switch_xml_add_child_d(x_attempt, "reject_time", tag_off++))) { + abort(); + } + switch_xml_set_attr_d(x_ptr, "type", "UNIX-epoch"); + switch_snprintf(str, sizeof(str), "%ld", (long) rp->reject_time); + switch_xml_set_txt_d(x_ptr, str); + + if (rp->cp) { + if (!(x_cp = switch_xml_add_child_d(x_attempt, "caller_profile", attempt_off++))) { + abort(); + } + switch_ivr_set_xml_profile_data(x_cp, rp->cp, 0); + } + } xml_text = switch_xml_toxml(cdr, SWITCH_TRUE); @@ -650,17 +1030,14 @@ static void conference_cdr_render(conference_obj_t *conference) fd = -1; } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } - + switch_safe_free(path); switch_safe_free(xml_text); + switch_xml_free(cdr); } @@ -709,6 +1086,7 @@ static switch_status_t conference_add_event_member_data(conference_member_t *mem switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-Type", "%s", switch_test_flag(member, MFLAG_MOD) ? "moderator" : "member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Current-Energy", "%d", member->score); return status; } @@ -814,6 +1192,40 @@ static switch_status_t conference_record_stop(conference_obj_t *conference, char switch_mutex_unlock(conference->member_mutex); return count; } +/* stop/pause/resume the specified recording */ +static switch_status_t conference_record_action(conference_obj_t *conference, char *path, recording_action_type_t action) +{ + conference_member_t *member = NULL; + int count = 0; + //switch_file_handle_t *fh = NULL; + + switch_assert(conference != NULL); + 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))) + { + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Action: %d\n", action); + switch (action) + { + case REC_ACTION_STOP: + switch_clear_flag_locked(member, MFLAG_RUNNING); + count++; + break; + case REC_ACTION_PAUSE: + switch_set_flag_locked(member, MFLAG_PAUSE_RECORDING); + count = 1; + break; + case REC_ACTION_RESUME: + switch_clear_flag_locked(member, MFLAG_PAUSE_RECORDING); + count = 1; + break; + } + } + } + switch_mutex_unlock(conference->member_mutex); + return count; +} /* Add a custom relationship to a member */ @@ -871,6 +1283,88 @@ static switch_status_t member_del_relationship(conference_member_t *member, uint return status; } +static void send_rfc_event(conference_obj_t *conference) +{ + switch_event_t *event; + char *body; + char *name = NULL, *domain = NULL, *dup_domain = NULL; + + if (!switch_test_flag(conference, CFLAG_RFC4579)) { + return; + } + + if (!(name = conference->name)) { + name = "conference"; + } + + if (!(domain = conference->domain)) { + dup_domain = switch_core_get_variable_dup("domain"); + if (!(domain = dup_domain)) { + domain = "cluecon.com"; + } + } + + + if (switch_event_create(&event, SWITCH_EVENT_CONFERENCE_DATA) == SWITCH_STATUS_SUCCESS) { + event->flags |= EF_UNIQ_HEADERS; + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "conference-name", name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "conference-domain", domain); + + body = conference_rfc4579_render(conference, NULL, event); + switch_event_add_body(event, "%s", body); + free(body); + switch_event_fire(&event); + } + + switch_safe_free(dup_domain); + +} + + + +static void send_conference_notify(conference_obj_t *conference, const char *status, switch_bool_t final) +{ + switch_event_t *event; + char *name = NULL, *domain = NULL, *dup_domain = NULL; + + if (!switch_test_flag(conference, CFLAG_RFC4579)) { + return; + } + + if (!(name = conference->name)) { + name = "conference"; + } + + if (!(domain = conference->domain)) { + dup_domain = switch_core_get_variable_dup("domain"); + if (!(domain = dup_domain)) { + domain = "cluecon.com"; + } + } + + + if (switch_event_create(&event, SWITCH_EVENT_CONFERENCE_DATA) == SWITCH_STATUS_SUCCESS) { + event->flags |= EF_UNIQ_HEADERS; + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "conference-name", name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "conference-domain", domain); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "conference-event", "refer"); + + if (final) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "final", "true"); + } + + + switch_event_add_body(event, "%s", status); + switch_event_fire(&event); + } + + switch_safe_free(dup_domain); + +} + + /* Gain exclusive access and add the member to the list */ static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member) { @@ -919,6 +1413,14 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe switch_channel_set_variable(channel, "conference_recording", conference->record_filename); switch_channel_set_variable(channel, CONFERENCE_UUID_VARIABLE, conference->uuid_str); + + if (!switch_channel_get_variable(channel, "conference_call_key")) { + char *key = switch_core_session_sprintf(member->session, "conf_%s_%s_%s", + conference->name, conference->domain, switch_channel_get_variable(channel, "caller_id_number")); + switch_channel_set_variable(channel, "conference_call_key", key); + } + + if (switch_test_flag(conference, CFLAG_WAIT_MOD) && switch_test_flag(member, MFLAG_MOD)) { switch_clear_flag(conference, CFLAG_WAIT_MOD); } @@ -1014,9 +1516,14 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe switch_mutex_unlock(member->audio_out_mutex); switch_mutex_unlock(member->audio_in_mutex); + send_rfc_event(conference); + switch_mutex_unlock(conference->mutex); status = SWITCH_STATUS_SUCCESS; + + + return status; } @@ -1116,6 +1623,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe member->conference = NULL; if (!switch_test_flag(member, MFLAG_NOCHANNEL)) { + switch_channel_t *channel = switch_core_session_get_channel(member->session); conference->count--; if (switch_test_flag(member, MFLAG_ENDCONF)) { @@ -1127,17 +1635,18 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe conference_send_presence(conference); + switch_channel_set_variable(channel, "conference_call_key", NULL); if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min) || (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0)) { switch_set_flag(conference, CFLAG_DESTRUCT); } else { if (!exit_sound && conference->exit_sound && switch_test_flag(conference, CFLAG_EXIT_SOUND)) { - conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session), 0); + conference_play_file(conference, conference->exit_sound, 0, channel, 0); } if (conference->count == 1 && conference->alone_sound && !switch_test_flag(conference, CFLAG_WAIT_MOD)) { conference_stop_file(conference, FILE_STOP_ASYNC); - conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session), 1); + conference_play_file(conference, conference->alone_sound, 0, channel, 1); } } @@ -1153,6 +1662,11 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe unlock_member(member); switch_mutex_unlock(member->audio_out_mutex); switch_mutex_unlock(member->audio_in_mutex); + + + send_rfc_event(conference); + + switch_mutex_unlock(conference->mutex); status = SWITCH_STATUS_SUCCESS; @@ -1221,6 +1735,62 @@ static void *SWITCH_THREAD_FUNC conference_video_bridge_thread_run(switch_thread } + +static void *SWITCH_THREAD_FUNC conference_video_mirror_thread_run(switch_thread_t *thread, void *obj) +{ + struct vid_helper *vh = obj; + switch_core_session_t *session_a = vh->member_a->session; + switch_channel_t *channel_a = switch_core_session_get_channel(session_a); + switch_status_t status; + switch_frame_t *read_frame; + conference_obj_t *conference = vh->member_a->conference; + switch_core_session_message_t msg = { 0 }; + + switch_thread_rwlock_rdlock(conference->rwlock); + switch_thread_rwlock_rdlock(vh->member_a->rwlock); + + /* Acquire locks for both sessions so the helper object and member structures don't get destroyed before we exit */ + switch_core_session_read_lock(session_a); + + /* Tell the channel to request a fresh vid frame */ + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ; + switch_core_session_receive_message(session_a, &msg); + + vh->up = 1; + while (vh->up > 0 && switch_test_flag(vh->member_a, MFLAG_RUNNING) && + switch_channel_ready(channel_a)) { + + if (vh->up == 1) { + status = switch_core_session_read_video_frame(session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0); + if (!SWITCH_READ_ACCEPTABLE(status)) { + break; + } + + if (!switch_test_flag(read_frame, SFF_CNG)) { + if (switch_core_session_write_video_frame(session_a, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { + break; + } + } + } else { + switch_yield(100000); + } + } + + + switch_thread_rwlock_unlock(vh->member_a->rwlock); + + switch_core_session_rwunlock(session_a); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s video mirror thread ended.\n", switch_channel_get_name(channel_a)); + + switch_thread_rwlock_unlock(conference->rwlock); + + vh->up = 0; + return NULL; +} + + /* Main video monitor thread (1 per distinct conference room) */ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thread, void *obj) { @@ -1283,7 +1853,14 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr want_refresh = 0; for (imember = conference->members; imember; imember = imember->next) { - switch_channel_t *ichannel = switch_core_session_get_channel(imember->session); + switch_core_session_t *isession = imember->session; + switch_channel_t *ichannel; + + if (!isession || switch_core_session_read_lock(isession) != SWITCH_STATUS_SUCCESS) { + continue; + } + + ichannel = switch_core_session_get_channel(imember->session); if (switch_channel_test_flag(ichannel, CF_VIDEO_REFRESH_REQ)) { want_refresh++; @@ -1294,6 +1871,8 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr has_vid++; switch_core_session_write_video_frame(imember->session, vid_frame, SWITCH_IO_FLAG_NONE, 0); } + + switch_core_session_rwunlock(isession); } if (want_refresh) { @@ -1523,8 +2102,22 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_channel_ready(switch_core_session_get_channel(video_bridge_members[0]->session)) && switch_channel_ready(switch_core_session_get_channel(video_bridge_members[1]->session)) ) { + conference->mh.up = 2; + if (launch_conference_video_bridge_thread(video_bridge_members[0], video_bridge_members[1])) { + conference->mh.up = 1; + } else { + conference->mh.up = -1; + } + } else if (conference->vh[0].up == 0 && + conference->vh[1].up == 0 && + conference->mh.up == 0 && + video_bridge_members[0] && + !video_bridge_members[1] && + switch_test_flag(video_bridge_members[0], MFLAG_RUNNING) && + switch_channel_ready(switch_core_session_get_channel(video_bridge_members[0]->session)) + ) { - launch_conference_video_bridge_thread(video_bridge_members[0], video_bridge_members[1]); + launch_conference_video_mirror_thread(video_bridge_members[0]); } } @@ -1548,7 +2141,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } if (file_sample_len <= 0) { - if (test_eflag(conference, EFLAG_PLAY_FILE) && + 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"); @@ -1617,7 +2210,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (x <= file_sample_len) { main_frame[x] = (int32_t) bptr[x]; } else { - main_frame[x] = 255; + memset(&main_frame[x], 255, sizeof(main_frame[x])); } } } @@ -1761,7 +2354,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_epoch_time_now(NULL) - conference->endconf_time > conference->endconf_grace_time) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Conference %s: endconf grace time exceeded (%u)\n", conference->name, conference->endconf_grace_time); - switch_set_flag(conference, CFLAG_DESTRUCT); + switch_set_flag(conference, CFLAG_DESTRUCT | CFLAG_ENDCONF_FORCED); } switch_mutex_unlock(conference->mutex); @@ -1889,6 +2482,20 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v return NULL; } +static void conference_loop_fn_floor_toggle(conference_member_t *member, caller_control_action_t *action) +{ + if (member == NULL) return; + + conf_api_sub_floor(member, NULL, NULL); +} + +static void conference_loop_fn_enforce_floor(conference_member_t *member, caller_control_action_t *action) +{ + if (member == NULL) return; + + conf_api_sub_enforce_floor(member, NULL, NULL); +} + static void conference_loop_fn_mute_toggle(conference_member_t *member, caller_control_action_t *action) { if (member == NULL) @@ -2673,7 +3280,7 @@ 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)) { + && switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD) && member->conference->count > 1) { switch_audio_resampler_t *read_resampler = member->read_resampler; void *data; uint32_t datalen; @@ -2915,7 +3522,7 @@ static void conference_loop_output(conference_member_t *member) char *dial_str = switch_mprintf("%s%s", switch_str_nil(prefix), argv[x]); switch_assert(dial_str); conference_outcall_bg(member->conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num, NULL, - profile, &member->conference->cancel_cause); + profile, &member->conference->cancel_cause, NULL); switch_safe_free(dial_str); } switch_safe_free(cpstr); @@ -3338,11 +3945,13 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th len = (switch_size_t) samples; } - if (!len || switch_core_file_write(&fh, data_buf, &len) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Failed\n"); - switch_clear_flag_locked(member, MFLAG_RUNNING); + if (!switch_test_flag(member, MFLAG_PAUSE_RECORDING)) { + if (!len || switch_core_file_write(&fh, data_buf, &len) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Failed\n"); + switch_clear_flag_locked(member, MFLAG_RUNNING); + } } - + loop: switch_core_timer_next(&timer); @@ -4012,6 +4621,7 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str switch_clear_flag_locked(member, MFLAG_TALKING); switch_set_flag(member, MFLAG_INDICATE_MUTE); + member->score_iir = 0; if (stream != NULL) { stream->write_function(stream, "OK mute %u\n", member->id); @@ -4027,6 +4637,20 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str return SWITCH_STATUS_SUCCESS; } + +static switch_status_t conf_api_sub_tmute(conference_member_t *member, switch_stream_handle_t *stream, void *data) +{ + + if (member == NULL) + return SWITCH_STATUS_GENERR; + + if (switch_test_flag(member, MFLAG_CAN_SPEAK)) { + return conf_api_sub_mute(member, stream, data); + } + + return conf_api_sub_unmute(member, stream, data); +} + static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { int level; @@ -4343,13 +4967,96 @@ static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_st if (conference == NULL) { switch_mutex_lock(globals.hash_mutex); for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) { + int fcount = 0; switch_hash_this(hi, NULL, NULL, &val); conference = (conference_obj_t *) val; - stream->write_function(stream, "Conference %s (%u member%s rate: %u%s)\n", + stream->write_function(stream, "Conference %s (%u member%s rate: %u%s flags: ", conference->name, conference->count, conference->count == 1 ? "" : "s", conference->rate, switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : ""); + + if (switch_test_flag(conference, CFLAG_LOCKED)) { + stream->write_function(stream, "%slocked", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_DESTRUCT)) { + stream->write_function(stream, "%sdestruct", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_WAIT_MOD)) { + stream->write_function(stream, "%swait_mod", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_AUDIO_ALWAYS)) { + stream->write_function(stream, "%saudio_always", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_RUNNING)) { + stream->write_function(stream, "%srunning", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_ANSWERED)) { + stream->write_function(stream, "%sanswered", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_ENFORCE_MIN)) { + stream->write_function(stream, "%senforce_min", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_BRIDGE_TO)) { + stream->write_function(stream, "%sbridge_to", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_DYNAMIC)) { + stream->write_function(stream, "%sdynamic", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_EXIT_SOUND)) { + stream->write_function(stream, "%sexit_sound", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_ENTER_SOUND)) { + stream->write_function(stream, "%senter_sound", fcount ? "|" : ""); + fcount++; + } + + if (conference->record_count > 0) { + stream->write_function(stream, "%srecording", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) { + stream->write_function(stream, "%svideo_bridge", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_VID_FLOOR)) { + stream->write_function(stream, "%svideo_floor_only", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_RFC4579)) { + stream->write_function(stream, "%svideo_rfc4579", fcount ? "|" : ""); + fcount++; + } + + if (!fcount) { + stream->write_function(stream, "none"); + } + + stream->write_function(stream, ")\n"); + count++; if (!summary) { if (pretty) { @@ -4380,6 +5087,97 @@ static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_st return ret_status; } +static switch_status_t conf_api_sub_floor(conference_member_t *member, switch_stream_handle_t *stream, void *data) +{ + switch_event_t *event; + + if (member == NULL) + return SWITCH_STATUS_GENERR; + + switch_mutex_lock(member->conference->mutex); + + if (member->conference->floor_holder == member) { + member->conference->floor_holder = NULL; + if (test_eflag(member->conference, EFLAG_FLOOR_CHANGE)) { + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT); + conference_add_event_data(member->conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "floor-change"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-ID", "%d", member->id); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-ID", "none"); + switch_event_fire(&event); + if (stream != NULL) { + stream->write_function(stream, "OK floor none\n"); + } + } + } else if (member->conference->floor_holder == NULL) { + member->conference->floor_holder = member; + if (test_eflag(member->conference, EFLAG_FLOOR_CHANGE)) { + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT); + conference_add_event_data(member->conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "floor-change"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-ID", "none"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-ID", "%d", member->id); + switch_event_fire(&event); + if (stream != NULL) { + stream->write_function(stream, "OK floor %u\n", member->id); + } + + if (switch_core_session_read_lock(member->session) == SWITCH_STATUS_SUCCESS) { + /* Tell the channel to request a fresh vid frame */ + switch_channel_set_flag(switch_core_session_get_channel(member->session), CF_VIDEO_REFRESH_REQ); + switch_core_session_rwunlock(member->session); + } + } + } else { + if (stream != NULL) { + stream->write_function(stream, "ERR floor is held by %u\n", member->conference->floor_holder->id); + } + } + + switch_mutex_unlock(member->conference->mutex); + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t conf_api_sub_enforce_floor(conference_member_t *member, switch_stream_handle_t *stream, void *data) +{ + switch_event_t *event; + + if (member == NULL) + return SWITCH_STATUS_GENERR; + + switch_mutex_lock(member->conference->mutex); + + if (member->conference->floor_holder != member) { + conference_member_t *old_member = member->conference->floor_holder; + member->conference->floor_holder = member; + if (test_eflag(member->conference, EFLAG_FLOOR_CHANGE)) { + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT); + conference_add_event_data(member->conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "floor-change"); + if (old_member == NULL) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-ID", "none"); + } else { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-ID", "%d", old_member->id); + } + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-ID", "%d", member->id); + switch_event_fire(&event); + if (stream != NULL) { + stream->write_function(stream, "OK floor %u\n", member->id); + } + } + + if (switch_core_session_read_lock(member->session) == SWITCH_STATUS_SUCCESS) { + /* Tell the channel to request a fresh vid frame */ + switch_channel_set_flag(switch_core_session_get_channel(member->session), CF_VIDEO_REFRESH_REQ); + switch_core_session_rwunlock(member->session); + } + } + + switch_mutex_unlock(member->conference->mutex); + + return SWITCH_STATUS_SUCCESS; +} static switch_xml_t add_x_tag(switch_xml_t x_member, const char *name, const char *value, int off) { @@ -4469,6 +5267,18 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer switch_xml_set_attr_d(x_conference, "endconf_grace_time", ival); } + if (switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) { + switch_xml_set_attr_d(x_conference, "video_bridge", "true"); + } + + if (switch_test_flag(conference, CFLAG_VID_FLOOR)) { + switch_xml_set_attr_d(x_conference, "video_floor_only", "true"); + } + + if (switch_test_flag(conference, CFLAG_RFC4579)) { + switch_xml_set_attr_d(x_conference, "video_rfc4579", "true"); + } + switch_snprintf(i, sizeof(i), "%d", switch_epoch_time_now(NULL) - conference->run_time); switch_xml_set_attr_d(x_conference, "run_time", ival); @@ -4503,6 +5313,9 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer */ x_tag = switch_xml_add_child_d(x_member, "record_path", count++); + if (switch_test_flag(member, MFLAG_PAUSE_RECORDING)) { + switch_xml_set_attr_d(x_tag, "status", "paused"); + } switch_xml_set_txt_d(x_tag, member->rec_path); x_tag = switch_xml_add_child_d(x_member, "join_time", count++); @@ -4521,6 +5334,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer x_member = switch_xml_add_child_d(x_members, "member", moff++); switch_assert(x_member); + switch_xml_set_attr_d(x_member, "type", "caller"); switch_snprintf(i, sizeof(i), "%d", member->id); @@ -4563,6 +5377,9 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer x_tag = switch_xml_add_child_d(x_flags, "has_video", count++); switch_xml_set_txt_d(x_tag, switch_channel_test_flag(switch_core_session_get_channel(member->session), CF_VIDEO) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "video_bridge", count++); + switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_VIDEO_BRIDGE) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "has_floor", count++); switch_xml_set_txt_d(x_tag, (member == member->conference->floor_holder) ? "true" : "false"); @@ -5054,9 +5871,9 @@ static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_st } if (conference) { - conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &cause, NULL); + conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &cause, NULL, NULL); } else { - conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &cause, NULL); + conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &cause, NULL, NULL); } stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause)); @@ -5079,9 +5896,9 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_ switch_uuid_format(uuid_str, &uuid); if (conference) { - conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL); + conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL, NULL); } else { - conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL); + conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL, NULL); } stream->write_function(stream, "OK Job-UUID: %s\n", uuid_str); @@ -5215,6 +6032,85 @@ static switch_status_t conf_api_sub_norecord(conference_obj_t *conference, switc return SWITCH_STATUS_SUCCESS; } +static switch_status_t conf_api_sub_pauserec(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) +{ + switch_event_t *event; + recording_action_type_t action; + + switch_assert(conference != NULL); + switch_assert(stream != NULL); + + if (argc <= 2) + return SWITCH_STATUS_GENERR; + + if (strcasecmp(argv[1], "pause") == 0) { + action = REC_ACTION_PAUSE; + } else if (strcasecmp(argv[1], "resume") == 0) { + action = REC_ACTION_RESUME; + } else { + return SWITCH_STATUS_GENERR; + } + stream->write_function(stream, "%s recording file %s\n", + action == REC_ACTION_PAUSE ? "Pause" : "Resume", argv[2]); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s recording file %s\n", + action == REC_ACTION_PAUSE ? "Pause" : "Resume", argv[2]); + + if (!conference_record_action(conference, argv[2], action)) { + stream->write_function(stream, "non-existant recording '%s'\n", argv[2]); + } else { + 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); + if (action == REC_ACTION_PAUSE) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "pause-recording"); + } else { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "resume-recording"); + } + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Path", argv[2]); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Other-Recordings", conference->record_count ? "true" : "false"); + switch_event_fire(&event); + } + } + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t conf_api_sub_recording(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) +{ + switch_assert(conference != NULL); + switch_assert(stream != NULL); + + if (argc <= 3) { + /* It means that old syntax is used */ + return conf_api_sub_record(conference,stream,argc,argv); + } else { + /* for new syntax call existing functions with fixed parameter list */ + if (strcasecmp(argv[2], "start") == 0) { + argv[1] = argv[2]; + argv[2] = argv[3]; + return conf_api_sub_record(conference,stream,4,argv); + } else if (strcasecmp(argv[2], "stop") == 0) { + argv[1] = argv[2]; + argv[2] = argv[3]; + return conf_api_sub_norecord(conference,stream,4,argv); + } else if (strcasecmp(argv[2], "check") == 0) { + argv[1] = argv[2]; + argv[2] = argv[3]; + return conf_api_sub_check_record(conference,stream,4,argv); + } else if (strcasecmp(argv[2], "pause") == 0) { + argv[1] = argv[2]; + argv[2] = argv[3]; + return conf_api_sub_pauserec(conference,stream,4,argv); + } else if (strcasecmp(argv[2], "resume") == 0) { + argv[1] = argv[2]; + argv[2] = argv[3]; + return conf_api_sub_pauserec(conference,stream,4,argv); + } else { + 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); @@ -5372,6 +6268,7 @@ static api_command_t conf_api_sub_commands[] = { {"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "kick", "<[member_id|all|last|non_moderator]> []"}, {"hup", (void_fn_t) & conf_api_sub_hup, CONF_API_SUB_MEMBER_TARGET, "hup", "<[member_id|all|last|non_moderator]>"}, {"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "mute", "<[member_id|all]|last|non_moderator>"}, + {"tmute", (void_fn_t) & conf_api_sub_tmute, CONF_API_SUB_MEMBER_TARGET, "tmute", "<[member_id|all]|last|non_moderator>"}, {"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>"}, @@ -5385,12 +6282,17 @@ static api_command_t conf_api_sub_commands[] = { {"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "record", ""}, {"chkrecord", (void_fn_t) & conf_api_sub_check_record, CONF_API_SUB_ARGS_SPLIT, "chkrecord", ""}, {"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "norecord", "<[filename|all]>"}, + {"pause", (void_fn_t) & conf_api_sub_pauserec, CONF_API_SUB_ARGS_SPLIT, "pause", ""}, + {"resume", (void_fn_t) & conf_api_sub_pauserec, CONF_API_SUB_ARGS_SPLIT, "resume", ""}, + {"recording", (void_fn_t) & conf_api_sub_recording, CONF_API_SUB_ARGS_SPLIT, "recording", "[start|stop|check|pause|resume] [|all]"}, {"exit_sound", (void_fn_t) & conf_api_sub_exit_sound, CONF_API_SUB_ARGS_SPLIT, "exit_sound", "on|off|none|file "}, {"enter_sound", (void_fn_t) & conf_api_sub_enter_sound, CONF_API_SUB_ARGS_SPLIT, "enter_sound", "on|off|none|file "}, {"pin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "pin", ""}, {"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", " "}, + {"floor", (void_fn_t) & conf_api_sub_floor, CONF_API_SUB_MEMBER_TARGET, "floor", ""}, + {"enforce_floor", (void_fn_t) & conf_api_sub_enforce_floor, CONF_API_SUB_MEMBER_TARGET, "enforce_floor", ""}, }; #define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0])) @@ -5546,7 +6448,7 @@ SWITCH_STANDARD_API(conf_api_main) if (argc && argv[0]) { conference_obj_t *conference = NULL; - if ((conference = conference_find(argv[0]))) { + if ((conference = conference_find(argv[0], NULL))) { if (argc >= 2) { conf_api_dispatch(conference, stream, argc, argv, cmd, 1); } else { @@ -5602,7 +6504,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference, char *cid_num, char *profile, switch_call_cause_t *cause, - switch_call_cause_t *cancel_cause) + switch_call_cause_t *cancel_cause, switch_event_t *var_event) { switch_core_session_t *peer_session = NULL; switch_channel_t *peer_channel; @@ -5611,12 +6513,18 @@ static switch_status_t conference_outcall(conference_obj_t *conference, char appdata[512]; int rdlock = 0; switch_bool_t have_flags = SWITCH_FALSE; + const char *outcall_flags; + int track = 0; + + if (var_event && switch_true(switch_event_get_header(var_event, "conference_track_status"))) { + track++; + } *cause = SWITCH_CAUSE_NORMAL_CLEARING; if (conference == NULL) { char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto); - status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NO_LIMITS, NULL); + status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, var_event, SOF_NO_LIMITS, NULL); switch_safe_free(dialstr); if (status != SWITCH_STATUS_SUCCESS) { @@ -5652,7 +6560,13 @@ static switch_status_t conference_outcall(conference_obj_t *conference, switch_mutex_lock(conference->mutex); conference->originating++; switch_mutex_unlock(conference->mutex); - status = switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NO_LIMITS, cancel_cause); + + if (track) { + send_conference_notify(conference, "SIP/2.0 100 Trying\r\n", SWITCH_FALSE); + } + + + status = switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, var_event, SOF_NO_LIMITS, cancel_cause); switch_mutex_lock(conference->mutex); conference->originating--; switch_mutex_unlock(conference->mutex); @@ -5663,9 +6577,18 @@ static switch_status_t conference_outcall(conference_obj_t *conference, if (caller_channel) { switch_channel_hangup(caller_channel, *cause); } + + if (track) { + send_conference_notify(conference, "SIP/2.0 481 Failure\r\n", SWITCH_TRUE); + } + goto done; } + if (track) { + send_conference_notify(conference, "SIP/2.0 200 OK\r\n", SWITCH_TRUE); + } + rdlock = 1; peer_channel = switch_core_session_get_channel(peer_session); @@ -5696,6 +6619,12 @@ static switch_status_t conference_outcall(conference_obj_t *conference, goto done; } + if ((outcall_flags = switch_channel_get_variable(peer_channel, "outcall_flags"))) { + if (!zstr(outcall_flags)) { + flags = (char *)outcall_flags; + } + } + if (flags && strcasecmp(flags, "none")) { have_flags = SWITCH_TRUE; } @@ -5738,6 +6667,7 @@ struct bg_call { char *uuid; char *profile; switch_call_cause_t *cancel_cause; + switch_event_t *var_event; switch_memory_pool_t *pool; }; @@ -5749,8 +6679,10 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, switch_call_cause_t cause; switch_event_t *event; + conference_outcall(call->conference, call->conference_name, - call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, call->profile, &cause, call->cancel_cause); + call->session, call->bridgeto, call->timeout, + call->flags, call->cid_name, call->cid_num, call->profile, &cause, call->cancel_cause, call->var_event); if (call->conference && test_eflag(call->conference, EFLAG_BGDIAL_RESULT) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { @@ -5760,6 +6692,11 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-UUID", call->uuid); switch_event_fire(&event); } + + if (call->var_event) { + switch_event_destroy(&call->var_event); + } + switch_safe_free(call->bridgeto); switch_safe_free(call->flags); switch_safe_free(call->cid_name); @@ -5779,7 +6716,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, static switch_status_t conference_outcall_bg(conference_obj_t *conference, char *conference_name, switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name, - const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause) + const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause, switch_event_t **var_event) { struct bg_call *call = NULL; switch_thread_t *thread; @@ -5795,6 +6732,11 @@ static switch_status_t conference_outcall_bg(conference_obj_t *conference, call->timeout = timeout; call->cancel_cause = cancel_cause; + if (var_event) { + call->var_event = *var_event; + var_event = NULL; + } + if (conference) { pool = conference->pool; } else { @@ -5970,7 +6912,11 @@ 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], "rfc-4579")) { + *f |= CFLAG_RFC4579; } + + } free(dup); @@ -6027,6 +6973,8 @@ static void clear_eflags(char *events, uint32_t *f) *f &= ~EFLAG_VOLUME_OUT_MEMBER; } else if (!strcmp(event, "play-file")) { *f &= ~EFLAG_PLAY_FILE; + } else if (!strcmp(event, "play-file-done")) { + *f &= ~EFLAG_PLAY_FILE; } else if (!strcmp(event, "play-file-member")) { *f &= ~EFLAG_PLAY_FILE_MEMBER; } else if (!strcmp(event, "speak-text")) { @@ -6219,30 +7167,34 @@ SWITCH_STANDARD_APP(conference_function) switch_channel_set_app_flag_key("conf_silent", channel, CONF_SILENT_REQ); } + switch_channel_set_flag(channel, CF_CONFERENCE); + if (switch_channel_answer(channel) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Channel answer failed.\n"); - return; + goto end; } /* Save the original read codec. */ if (!(read_codec = switch_core_session_get_read_codec(session))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Channel has no media!\n"); - return; + goto end; } if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Invalid arguments\n"); - return; + goto end; } mydata = switch_core_session_strdup(session, data); if (!mydata) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Pool Failure\n"); - return; + goto end; } + + if ((flags_str = strstr(mydata, flags_prefix))) { char *p; *((char *) flags_str) = '\0'; @@ -6331,7 +7283,7 @@ SWITCH_STANDARD_APP(conference_function) conf_name = uuid; } - if ((conference = conference_find(conf_name))) { + if ((conference = conference_find(conf_name, NULL))) { switch_thread_rwlock_unlock(conference->rwlock); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Conference %s already exists!\n", conf_name); goto done; @@ -6371,7 +7323,7 @@ SWITCH_STANDARD_APP(conference_function) enforce_security = switch_true(pvar); } - if ((conference = conference_find(conf_name))) { + if ((conference = conference_find(conf_name, NULL))) { if (locked) { switch_mutex_unlock(globals.setup_mutex); locked = 0; @@ -6533,6 +7485,7 @@ SWITCH_STANDARD_APP(conference_function) } if (!pin_valid) { + conference_cdr_rejected(conference, channel, CDRR_PIN); goto done; } } @@ -6544,6 +7497,7 @@ SWITCH_STANDARD_APP(conference_function) /* don't allow more callers if the conference is locked, unless we invited them */ if (switch_test_flag(conference, CFLAG_LOCKED) && enforce_security) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Conference %s is locked.\n", conf_name); + conference_cdr_rejected(conference, channel, CDRR_LOCKED); if (conference->locked_sound) { /* Answer the channel */ switch_channel_answer(channel); @@ -6558,6 +7512,7 @@ SWITCH_STANDARD_APP(conference_function) */ if ((conference->max_members > 0) && (conference->count >= conference->max_members)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Conference %s is full.\n", conf_name); + conference_cdr_rejected(conference, channel, CDRR_MAXMEMBERS); if (conference->maxmember_sound) { /* Answer the channel */ switch_channel_answer(channel); @@ -6577,7 +7532,7 @@ SWITCH_STANDARD_APP(conference_function) /* if we're using "bridge:" make an outbound call and bridge it in */ if (!zstr(bridgeto) && strcasecmp(bridgeto, "none")) { switch_call_cause_t cause; - if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, NULL, &cause, NULL) != SWITCH_STATUS_SUCCESS) { + if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, NULL, &cause, NULL, NULL) != SWITCH_STATUS_SUCCESS) { goto done; } } else { @@ -6726,6 +7681,11 @@ SWITCH_STANDARD_APP(conference_function) } switch_channel_set_variable(channel, "last_transfered_conference", NULL); + + end: + + switch_channel_clear_flag(channel, CF_CONFERENCE); + } /* Create a thread for the conference and launch it */ @@ -6764,11 +7724,11 @@ static void launch_conference_video_thread(conference_obj_t *conference) } /* Create a video thread for the conference and launch it */ -static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b) +static int launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b) { conference_obj_t *conference = member_a->conference; switch_memory_pool_t *pool = conference->pool; - int sanity = 10000; + int sanity = 10000, r = 0; memset(conference->vh, 0, sizeof(conference->vh)); @@ -6787,14 +7747,33 @@ static void launch_conference_video_bridge_thread(conference_member_t *member_a, if (conference->vh[0].up == 1 && conference->vh[1].up != 1) { conference->vh[0].up = -1; + r = -1; } if (conference->vh[1].up == 1 && conference->vh[0].up != 1) { conference->vh[1].up = -1; + r = -1; } + + return r; } + + +/* Create a video thread for the conference and launch it */ +static void launch_conference_video_mirror_thread(conference_member_t *member_a) +{ + conference_obj_t *conference = member_a->conference; + switch_memory_pool_t *pool = conference->pool; + + memset(&conference->mh, 0, sizeof(conference->mh)); + + conference->mh.member_a = member_a; + + launch_thread_detached(conference_video_mirror_thread_run, pool, &conference->mh); +} + static void launch_conference_record_thread(conference_obj_t *conference, char *path) { switch_thread_t *thread; @@ -6861,8 +7840,8 @@ static switch_status_t chat_send(switch_event_t *message_event) switch_copy_string(name, to, sizeof(name)); } - if (!(conference = conference_find(name))) { - switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL); + if (!(conference = conference_find(name, NULL))) { + switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL, SWITCH_FALSE); return SWITCH_STATUS_FALSE; } @@ -6880,14 +7859,14 @@ static switch_status_t chat_send(switch_event_t *message_event) switch_safe_free(lbuf); - switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL); + switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL, SWITCH_FALSE); switch_safe_free(stream.data); switch_thread_rwlock_unlock(conference->rwlock); return SWITCH_STATUS_SUCCESS; } -static conference_obj_t *conference_find(char *name) +static conference_obj_t *conference_find(char *name, char *domain) { conference_obj_t *conference; @@ -6897,6 +7876,8 @@ static conference_obj_t *conference_find(char *name) switch_core_hash_delete(globals.conference_hash, conference->name); switch_clear_flag(conference, CFLAG_INHASH); conference = NULL; + } else if (!zstr(domain) && conference->domain && strcasecmp(domain, conference->domain)) { + conference = NULL; } } if (conference) { @@ -6917,6 +7898,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c switch_xml_t xml_kvp; char *timer_name = NULL; char *domain = NULL; + char *desc = NULL; char *name_domain = NULL; char *tts_engine = NULL; char *tts_voice = NULL; @@ -6947,6 +7929,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c char *conference_flags = NULL; char *perpetual_sound = NULL; char *moh_sound = NULL; + char *outcall_templ = NULL; uint32_t max_members = 0; uint32_t announce_count = 0; char *maxmember_sound = NULL; @@ -7040,6 +8023,8 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c } } else if (!strcasecmp(var, "domain") && !zstr(val)) { domain = val; + } else if (!strcasecmp(var, "description") && !zstr(val)) { + desc = val; } else if (!force_interval_i && !strcasecmp(var, "interval") && !zstr(val)) { uint32_t tmp = atoi(val); @@ -7063,6 +8048,8 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c tts_voice = val; } else if (!strcasecmp(var, "enter-sound") && !zstr(val)) { enter_sound = val; + } else if (!strcasecmp(var, "outcall-templ") && !zstr(val)) { + outcall_templ = val; } else if (!strcasecmp(var, "exit-sound") && !zstr(val)) { exit_sound = val; } else if (!strcasecmp(var, "alone-sound") && !zstr(val)) { @@ -7229,6 +8216,9 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number); conference->caller_controls = switch_core_strdup(conference->pool, caller_controls); conference->moderator_controls = switch_core_strdup(conference->pool, moderator_controls); + if (outcall_templ) { + conference->outcall_templ = switch_core_strdup(conference->pool, outcall_templ); + } conference->run_time = switch_epoch_time_now(NULL); if (!zstr(conference_log_dir)) { @@ -7375,14 +8365,14 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c conference->name = switch_core_strdup(conference->pool, name); - if (presence_id && (name_domain = strchr(presence_id, '@'))) { - name_domain++; - conference->domain = switch_core_strdup(conference->pool, name_domain); - } else if ((name_domain = strchr(conference->name, '@'))) { + if ((name_domain = strchr(conference->name, '@'))) { name_domain++; conference->domain = switch_core_strdup(conference->pool, name_domain); } else if (domain) { conference->domain = switch_core_strdup(conference->pool, domain); + } else if (presence_id && (name_domain = strchr(presence_id, '@'))) { + name_domain++; + conference->domain = switch_core_strdup(conference->pool, name_domain); } else { conference->domain = "cluecon.com"; } @@ -7400,6 +8390,11 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c if (!zstr(auto_record)) { conference->auto_record = switch_core_strdup(conference->pool, auto_record); } + + if (!zstr(desc)) { + conference->desc = switch_core_strdup(conference->pool, desc); + } + if (!zstr(terminate_on_silence)) { conference->terminate_on_silence = atoi(terminate_on_silence); } @@ -7475,6 +8470,127 @@ static void conference_send_presence(conference_obj_t *conference) } +static void kickall_matching_var(conference_obj_t *conference, const char *var, const char *val) +{ + conference_member_t *member = NULL; + const char *vval = NULL; + switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->member_mutex); + + for (member = conference->members; member; member = member->next) { + switch_channel_t *channel = NULL; + + if (switch_test_flag(member, MFLAG_NOCHANNEL)) { + continue; + } + + channel = switch_core_session_get_channel(member->session); + vval = switch_channel_get_variable(channel, var); + + if (vval && !strcmp(vval, val)) { + switch_set_flag_locked(member, MFLAG_KICKED); + switch_clear_flag_locked(member, MFLAG_RUNNING); + switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK); + } + + } + + switch_mutex_unlock(conference->member_mutex); + switch_mutex_unlock(conference->mutex); +} + +static void call_setup_event_handler(switch_event_t *event) +{ + conference_obj_t *conference = NULL; + char *conf = switch_event_get_header(event, "Target-Component"); + char *domain = switch_event_get_header(event, "Target-Domain"); + char *dial_str = switch_event_get_header(event, "Request-Target"); + char *dial_uri = switch_event_get_header(event, "Request-Target-URI"); + char *action = switch_event_get_header(event, "Request-Action"); + char *ext = switch_event_get_header(event, "Request-Target-Extension"); + char *full_url = switch_event_get_header(event, "full_url"); + + if (!ext) ext = dial_str; + + if (!zstr(conf) && !zstr(dial_str) && !zstr(action) && (conference = conference_find(conf, domain))) { + switch_event_t *var_event; + switch_event_header_t *hp; + + if (switch_test_flag(conference, CFLAG_RFC4579)) { + char *key = switch_mprintf("conf_%s_%s_%s", conference->name, conference->domain, ext); + char *expanded = NULL, *ostr = dial_str;; + + if (!strcasecmp(action, "call")) { + + if (switch_event_create_plain(&var_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) { + abort(); + } + + for(hp = event->headers; hp; hp = hp->next) { + if (!strncasecmp(hp->name, "var_", 4)) { + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, hp->name + 4, hp->value); + } + } + + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "conference_call_key", key); + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "conference_destination_number", ext); + + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "conference_invite_uri", dial_uri); + + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "conference_track_status", "true"); + + if (!strncasecmp(ostr, "url+", 4)) { + ostr += 4; + } else if (!switch_true(full_url) && conference->outcall_templ) { + if ((expanded = switch_event_expand_headers(var_event, conference->outcall_templ))) { + ostr = expanded; + } + } + + conference_outcall_bg(conference, NULL, NULL, ostr, 60, NULL, NULL, NULL, NULL, NULL, NULL, &var_event); + + if (expanded && expanded != conference->outcall_templ) { + switch_safe_free(expanded); + } + + } else if (!strcasecmp(action, "end")) { + //switch_core_session_hupall_matching_var("conference_call_key", key, SWITCH_CAUSE_NORMAL_CLEARING); + kickall_matching_var(conference, "conference_call_key", key); + } + + switch_safe_free(key); + } + + + switch_thread_rwlock_unlock(conference->rwlock); + } + +} + +static void conf_data_event_handler(switch_event_t *event) +{ + switch_event_t *revent; + char *name = switch_event_get_header(event, "conference-name"); + char *domain = switch_event_get_header(event, "conference-domain"); + conference_obj_t *conference = NULL; + char *body = NULL; + + if (!zstr(name) && (conference = conference_find(name, domain))) { + if (switch_test_flag(conference, CFLAG_RFC4579)) { + switch_event_dup(&revent, event); + revent->event_id = SWITCH_EVENT_CONFERENCE_DATA; + revent->flags |= EF_UNIQ_HEADERS; + switch_event_add_header(revent, SWITCH_STACK_TOP, "Event-Name", "CONFERENCE_DATA"); + + body = conference_rfc4579_render(conference, event, revent); + switch_event_add_body(revent, "%s", body); + switch_event_fire(&revent); + switch_safe_free(body); + } + switch_thread_rwlock_unlock(conference->rwlock); + } +} + static void pres_event_handler(switch_event_t *event) { @@ -7501,7 +8617,7 @@ static void pres_event_handler(switch_event_t *event) dup_conf_name = switch_mprintf("%q@%q", conf_name, domain_name); - if ((conference = conference_find(conf_name)) || (conference = conference_find(dup_conf_name))) { + if ((conference = conference_find(conf_name, NULL)) || (conference = conference_find(dup_conf_name, NULL))) { if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name); @@ -7659,7 +8775,9 @@ static struct _mapping control_mappings[] = { {"event", conference_loop_fn_event}, {"lock", conference_loop_fn_lock_toggle}, {"transfer", conference_loop_fn_transfer}, - {"execute_application", conference_loop_fn_exec_app} + {"execute_application", conference_loop_fn_exec_app}, + {"floor", conference_loop_fn_floor_toggle}, + {"enforce_floor", conference_loop_fn_enforce_floor}, }; #define MAPPING_LEN (sizeof(control_mappings)/sizeof(control_mappings[0])) @@ -7791,10 +8909,16 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load) switch_mutex_init(&globals.setup_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool); /* Subscribe to presence request events */ - if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.node) != - SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n"); - return SWITCH_STATUS_GENERR; + } + + if (switch_event_bind(modname, SWITCH_EVENT_CONFERENCE_DATA_QUERY, SWITCH_EVENT_SUBCLASS_ANY, conf_data_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to conference data query events!\n"); + } + + if (switch_event_bind(modname, SWITCH_EVENT_CALL_SETUP_REQ, SWITCH_EVENT_SUBCLASS_ANY, call_setup_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to conference data query events!\n"); } SWITCH_ADD_API(api_interface, "conference", "Conference module commands", conf_api_main, p); @@ -7825,7 +8949,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown) switch_yield(100000); } - switch_event_unbind(&globals.node); + switch_event_unbind_callback(pres_event_handler); + switch_event_unbind_callback(conf_data_event_handler); + switch_event_unbind_callback(call_setup_event_handler); switch_event_free_subclass(CONF_EVENT_MAINT); /* free api interface help ".syntax" field string */ diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index d40e74d017..b481ca9f05 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -30,7 +30,7 @@ * Bret McDanel * Luke Dashjr (OpenMethods, LLC) * Cesar Cepeda - * Chris Rienzo + * Christopher M. Rienzo * * mod_dptools.c -- Raw Audio File Streaming Application Module * @@ -38,7 +38,8 @@ #include SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load); -SWITCH_MODULE_DEFINITION(mod_dptools, mod_dptools_load, NULL, NULL); +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown); +SWITCH_MODULE_DEFINITION(mod_dptools, mod_dptools_load, mod_dptools_shutdown, NULL); SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt) { @@ -464,6 +465,7 @@ SWITCH_STANDARD_APP(play_and_detect_speech_function) char *lbuf = NULL; const char *response = "DONE"; char *detect = NULL; + char *s; switch_channel_set_variable(channel, "detect_speech_result", ""); @@ -474,6 +476,12 @@ SWITCH_STANDARD_APP(play_and_detect_speech_function) goto done; } + /* trim any trailing space */ + s = detect; + while (--s >= lbuf && switch_isspace(*s)) { + *s = '\0'; + } + /* split input at "detect:" */ detect[0] = '\0'; detect += 7; @@ -966,7 +974,7 @@ SWITCH_STANDARD_APP(transfer_function) if (bleg || both) { const char *uuid; switch_channel_t *channel = switch_core_session_get_channel(session); - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if ((uuid = switch_channel_get_partner_uuid(channel))) { switch_core_session_t *b_session; if ((b_session = switch_core_session_locate(uuid))) { switch_ivr_session_transfer(b_session, argv[1], argv[2], argv[3]); @@ -1021,9 +1029,10 @@ SWITCH_STANDARD_APP(sched_hangup_function) time_t when; switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; switch_bool_t bleg = SWITCH_FALSE; + int sec = atol(argv[0] + 1); if (*argv[0] == '+') { - when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + sec; } else { when = atol(argv[0]); } @@ -1036,7 +1045,11 @@ SWITCH_STANDARD_APP(sched_hangup_function) bleg = SWITCH_TRUE; } - switch_ivr_schedule_hangup(when, switch_core_session_get_uuid(session), cause, bleg); + if (sec == 0) { + switch_channel_hangup(switch_core_session_get_channel(session), cause); + } else { + switch_ivr_schedule_hangup(when, switch_core_session_get_uuid(session), cause, bleg); + } } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No time specified.\n"); } @@ -1132,6 +1145,18 @@ SWITCH_STANDARD_APP(set_name_function) SWITCH_STANDARD_APP(answer_function) { switch_channel_t *channel = switch_core_session_get_channel(session); + const char *arg = (char *) data; + + if (zstr(arg)) { + arg = switch_channel_get_variable(channel, "answer_flags"); + } + + if (!zstr(arg)) { + if (switch_stristr("is_conference", arg)) { + switch_channel_set_flag(channel, CF_CONFERENCE); + } + } + switch_channel_answer(channel); } @@ -1169,6 +1194,18 @@ SWITCH_STANDARD_APP(redirect_function) msg.from = __FILE__; msg.string_arg = data; msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT; + msg.numeric_arg = 1; + switch_core_session_receive_message(session, &msg); +} + +SWITCH_STANDARD_APP(video_refresh_function) +{ + switch_core_session_message_t msg = { 0 }; + + /* Tell the channel to refresh video */ + msg.from = __FILE__; + msg.string_arg = data; + msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ; switch_core_session_receive_message(session, &msg); } @@ -1215,6 +1252,7 @@ SWITCH_STANDARD_APP(respond_function) msg.from = __FILE__; msg.string_arg = data; msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND; + msg.numeric_arg = -1; switch_core_session_receive_message(session, &msg); } @@ -1288,6 +1326,33 @@ static void base_set (switch_core_session_t *session, const char *data, switch_s } } +SWITCH_STANDARD_APP(multiset_function) +{ + char delim = ' '; + char *arg = (char *) data; + + if (!zstr(arg) && *arg == '^' && *(arg+1) == '^') { + arg += 2; + delim = *arg++; + } + + if (arg) { + char *array[256] = {0}; + int i, argc; + + arg = switch_core_session_strdup(session, arg); + argc = switch_split(arg, delim, array); + + for(i = 0; i < argc; i++) { + base_set(session, array[i], SWITCH_STACK_BOTTOM); + } + + + } else { + base_set(session, data, SWITCH_STACK_BOTTOM); + } +} + SWITCH_STANDARD_APP(set_function) { base_set(session, data, SWITCH_STACK_BOTTOM); @@ -1365,7 +1430,7 @@ SWITCH_STANDARD_APP(export_function) } } - switch_channel_export_variable(channel, var, val, SWITCH_EXPORT_VARS_VARIABLE); + switch_channel_export_variable_var_check(channel, var, val, SWITCH_EXPORT_VARS_VARIABLE, SWITCH_FALSE); } } @@ -1682,7 +1747,7 @@ SWITCH_STANDARD_API(chat_api_function) if (!zstr(cmd) && (lbuf = strdup(cmd)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) { - if (switch_core_chat_send_args(argv[0], "global", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "") == SWITCH_STATUS_SUCCESS) { + if (switch_core_chat_send_args(argv[0], "global", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "", SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "Sent"); } else { stream->write_function(stream, "Error! Message Not Sent"); @@ -2088,6 +2153,32 @@ static switch_status_t xfer_on_dtmf(switch_core_session_t *session, void *input, return SWITCH_STATUS_SUCCESS; } +static switch_status_t tmp_hanguphook(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_channel_state_t state = switch_channel_get_state(channel); + + if (state == CS_HANGUP || state == CS_ROUTING) { + const char *bond = switch_channel_get_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE); + + if (!zstr(bond)) { + switch_core_session_t *b_session; + + if ((b_session = switch_core_session_locate(bond))) { + switch_channel_t *b_channel = switch_core_session_get_channel(b_session); + if (switch_channel_up(b_channel)) { + switch_channel_set_flag(b_channel, CF_REDIRECT); + } + switch_core_session_rwunlock(b_session); + } + } + + switch_core_event_hook_remove_state_change(session, tmp_hanguphook); + } + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t hanguphook(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -2109,6 +2200,12 @@ static switch_status_t hanguphook(switch_core_session_t *session) return SWITCH_STATUS_SUCCESS; } + +static void att_xfer_set_result(switch_channel_t *channel, switch_status_t status) +{ + switch_channel_set_variable(channel, SWITCH_ATT_XFER_RESULT_VARIABLE, status == SWITCH_STATUS_SUCCESS ? "success" : "failure"); +} + SWITCH_STANDARD_APP(att_xfer_function) { switch_core_session_t *peer_session = NULL; @@ -2116,14 +2213,13 @@ SWITCH_STANDARD_APP(att_xfer_function) switch_channel_t *channel, *peer_channel = NULL; const char *bond = NULL; switch_core_session_t *b_session = NULL; - + channel = switch_core_session_get_channel(session); - if ((bond = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { - bond = switch_core_session_strdup(session, bond); - } - + bond = switch_channel_get_partner_uuid(channel); switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond); + switch_core_event_hook_add_state_change(session, tmp_hanguphook); + if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS || !peer_session) { @@ -2154,7 +2250,8 @@ SWITCH_STANDARD_APP(att_xfer_function) if (!switch_channel_down(peer_channel)) { if (!switch_channel_ready(channel)) { - switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond); + switch_status_t status = switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond); + att_xfer_set_result(peer_channel, status); br++; } else if ((b_session = switch_core_session_locate(bond))) { switch_channel_t *b_channel = switch_core_session_get_channel(b_session); @@ -2172,7 +2269,8 @@ SWITCH_STANDARD_APP(att_xfer_function) } if (!br) { - switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond); + switch_status_t status = switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond); + att_xfer_set_result(channel, status); } } @@ -2180,6 +2278,9 @@ SWITCH_STANDARD_APP(att_xfer_function) switch_core_session_rwunlock(peer_session); end: + + switch_core_event_hook_remove_state_change(session, tmp_hanguphook); + switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, NULL); switch_channel_clear_flag(channel, CF_XFER_ZOMBIE); } @@ -2831,8 +2932,12 @@ SWITCH_STANDARD_APP(audio_bridge_function) camp_data = (char *) data; } - if (!(moh = switch_channel_get_hold_music(caller_channel))) { - moh = switch_channel_get_variable(caller_channel, "campon_hold_music"); + if (!(moh = switch_channel_get_variable(caller_channel, "campon_hold_music"))) { + moh = switch_channel_get_hold_music(caller_channel); + } + + if (!zstr(moh) && !strcasecmp(moh, "silence")) { + moh = NULL; } do { @@ -3037,7 +3142,8 @@ SWITCH_STANDARD_APP(audio_bridge_function) } } } - if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && switch_channel_get_state(caller_channel) != CS_ROUTING) { + if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_CONFIRM_BLIND_TRANSFER) && + switch_channel_get_state(caller_channel) != CS_ROUTING) { switch_channel_hangup(caller_channel, cause); } return; @@ -3087,6 +3193,489 @@ SWITCH_STANDARD_APP(audio_bridge_function) } } +static struct { + switch_memory_pool_t *pool; + switch_hash_t *pickup_hash; + switch_mutex_t *pickup_mutex; + switch_hash_t *mutex_hash; + switch_mutex_t *mutex_mutex; +} globals; + +/* pickup channel */ + + + +typedef struct pickup_node_s { + char *key; + char *uuid; + struct pickup_node_s *next; +} pickup_node_t; + + +#define PICKUP_PROTO "pickup" +static int EC = 0; + +static int pickup_count(const char *key_name) +{ + int count = 0; + pickup_node_t *head, *np; + + switch_mutex_lock(globals.pickup_mutex); + if ((head = switch_core_hash_find(globals.pickup_hash, key_name))) { + for (np = head; np; np = np->next) count++; + } + switch_mutex_unlock(globals.pickup_mutex); + + return count; + +} + +static void pickup_send_presence(const char *key_name) +{ + + char *domain_name, *dup_key_name = NULL, *dup_domain_name = NULL, *dup_id = NULL; + switch_event_t *event; + int count; + + + dup_key_name = strdup(key_name); + key_name = dup_key_name; + + if ((domain_name = strchr(dup_key_name, '@'))) { + *domain_name++ = '\0'; + } + + if (zstr(domain_name)) { + dup_domain_name = switch_core_get_variable_dup("domain"); + domain_name = dup_domain_name; + } + + if (zstr(domain_name)) { + domain_name = "cluecon.com"; + } + + dup_id = switch_mprintf("%s@%s", key_name, domain_name); + + count = pickup_count(dup_id); + + if (count > 0) { + if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id); + + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%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", key_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); + } + } else { + if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id); + + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown"); + 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", dup_id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); + switch_event_fire(&event); + } + } + + switch_safe_free(dup_domain_name); + switch_safe_free(dup_key_name); + switch_safe_free(dup_id); + +} + +static void pickup_pres_event_handler(switch_event_t *event) +{ + char *to = switch_event_get_header(event, "to"); + char *dup_to = NULL, *key_name, *dup_key_name = NULL, *domain_name, *dup_domain_name = NULL; + int count = 0; + + if (!to || strncasecmp(to, "pickup+", 7) || !strchr(to, '@')) { + return; + } + + if (!(dup_to = strdup(to))) { + return; + } + + key_name = dup_to + 7; + + if ((domain_name = strchr(key_name, '@'))) { + *domain_name++ = '\0'; + } else { + dup_domain_name = switch_core_get_variable_dup("domain"); + domain_name = dup_domain_name; + } + + if (zstr(domain_name)) { + switch_safe_free(dup_to); + return; + } + + dup_key_name = switch_mprintf("%q@%q", key_name, domain_name); + count = pickup_count(dup_key_name); + + switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN); + + if (count) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name); + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%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", key_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"); + } else { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name); + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown"); + 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", key_name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); + + } + + switch_event_fire(&event); + switch_safe_free(dup_to); + switch_safe_free(dup_key_name); + switch_safe_free(dup_domain_name); +} + + + +static void pickup_add_session(switch_core_session_t *session, const char *key) +{ + pickup_node_t *head, *node, *np; + char *dup_key = NULL; + + if (!strchr(key, '@')) { + dup_key = switch_mprintf("%s@%s", key, switch_core_get_variable("domain")); + key = dup_key; + } + + node = malloc(sizeof(*node)); + node->key = strdup(key); + node->uuid = strdup(switch_core_session_get_uuid(session)); + node->next = NULL; + + switch_mutex_lock(globals.pickup_mutex); + head = switch_core_hash_find(globals.pickup_hash, key); + + if (head) { + for (np = head; np && np->next; np = np->next); + np->next = node; + } else { + head = node; + switch_core_hash_insert(globals.pickup_hash, key, head); + } + + switch_mutex_unlock(globals.pickup_mutex); + + pickup_send_presence(key); + + switch_safe_free(dup_key); +} + +static char *pickup_pop_uuid(const char *key, const char *uuid) +{ + pickup_node_t *node = NULL, *head; + char *r = NULL; + char *dup_key = NULL; + + if (!strchr(key, '@')) { + dup_key = switch_mprintf("%s@%s", key, switch_core_get_variable("domain")); + key = dup_key; + } + + switch_mutex_lock(globals.pickup_mutex); + + if ((head = switch_core_hash_find(globals.pickup_hash, key))) { + + switch_core_hash_delete(globals.pickup_hash, key); + + if (uuid) { + pickup_node_t *np, *lp = NULL; + + for(np = head; np; np = np->next) { + if (!strcmp(np->uuid, uuid)) { + if (lp) { + lp->next = np->next; + } else { + head = np->next; + } + + node = np; + break; + } + + lp = np; + } + + } else { + node = head; + head = head->next; + } + + + if (head) { + switch_core_hash_insert(globals.pickup_hash, key, head); + } + } + + if (node) { + r = node->uuid; + free(node->key); + free(node); + } + + switch_mutex_unlock(globals.pickup_mutex); + + if (r) pickup_send_presence(key); + + switch_safe_free(dup_key); + + return r; +} + + +typedef struct pickup_pvt_s { + char *key; + switch_event_t *vars; +} pickup_pvt_t; + +switch_endpoint_interface_t *pickup_endpoint_interface; +static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *session, + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); +switch_io_routines_t pickup_io_routines = { + /*.outgoing_channel */ pickup_outgoing_channel +}; + +static switch_status_t pickup_event_handler(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_channel_state_t state = switch_channel_get_running_state(channel); + pickup_pvt_t *tech_pvt = switch_core_session_get_private(session); + + switch(state) { + case CS_DESTROY: + if (tech_pvt->vars) { + switch_event_destroy(&tech_pvt->vars); + } + break; + case CS_REPORTING: + return SWITCH_STATUS_FALSE; + case CS_HANGUP: + { + + if (switch_channel_test_flag(channel, CF_CHANNEL_SWAP)) { + const char *key = switch_channel_get_variable(channel, "channel_swap_uuid"); + switch_core_session_t *swap_session; + + if ((swap_session = switch_core_session_locate(key))) { + switch_channel_t *swap_channel = switch_core_session_get_channel(swap_session); + switch_channel_hangup(swap_channel, SWITCH_CAUSE_PICKED_OFF); + switch_core_session_rwunlock(swap_session); + } + switch_channel_clear_flag(channel, CF_CHANNEL_SWAP); + } + + pickup_pop_uuid(tech_pvt->key, switch_core_session_get_uuid(session)); + } + break; + default: + break; + } + + + return SWITCH_STATUS_SUCCESS; +} + +switch_state_handler_table_t pickup_event_handlers = { + /*.on_init */ pickup_event_handler, + /*.on_routing */ pickup_event_handler, + /*.on_execute */ pickup_event_handler, + /*.on_hangup */ pickup_event_handler, + /*.on_exchange_media */ pickup_event_handler, + /*.on_soft_execute */ pickup_event_handler, + /*.on_consume_media */ pickup_event_handler, + /*.on_hibernate */ pickup_event_handler, + /*.on_reset */ pickup_event_handler, + /*.on_park */ pickup_event_handler, + /*.on_reporting */ pickup_event_handler, + /*.on_destroy */ pickup_event_handler +}; + +static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *session, + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause) +{ + char *pickup; + switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + switch_core_session_t *nsession; + switch_channel_t *nchannel; + char *name; + pickup_pvt_t *tech_pvt; + switch_caller_profile_t *caller_profile; + + if (zstr(outbound_profile->destination_number)) { + goto done; + } + + pickup = outbound_profile->destination_number; + + + if (!(nsession = switch_core_session_request(pickup_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n"); + goto error; + } + + tech_pvt = switch_core_session_alloc(nsession, sizeof(*tech_pvt)); + tech_pvt->key = switch_core_session_strdup(nsession, pickup); + + + switch_core_session_set_private(nsession, tech_pvt); + + nchannel = switch_core_session_get_channel(nsession); + caller_profile = switch_caller_profile_clone(nsession, outbound_profile); + switch_channel_set_caller_profile(nchannel, caller_profile); + + switch_channel_set_state(nchannel, CS_ROUTING); + + + + *new_session = nsession; + cause = SWITCH_CAUSE_SUCCESS; + name = switch_core_session_sprintf(nsession, "pickup/%s", pickup); + switch_channel_set_name(nchannel, name); + switch_channel_set_variable(nchannel, "process_cdr", "false"); + switch_channel_set_variable(nchannel, "presence_id", NULL); + + switch_event_del_header(var_event, "presence_id"); + + pickup_add_session(nsession, pickup); + switch_channel_set_flag(nchannel, CF_PICKUP); + switch_channel_set_flag(nchannel, CF_NO_PRESENCE); + + switch_event_dup(&tech_pvt->vars, var_event); + + goto done; + + error: + + if (nsession) { + switch_core_session_destroy(&nsession); + } + + if (pool) { + *pool = NULL; + } + + done: + + + return cause; +} + +#define PICKUP_SYNTAX "[]" +SWITCH_STANDARD_APP(pickup_function) +{ + char *uuid = NULL; + switch_core_session_t *pickup_session; + switch_channel_t *channel = switch_core_session_get_channel(session); + + if (zstr(data)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing data. Usage: pickup %s\n", PICKUP_SYNTAX); + return; + } + + if ((uuid = pickup_pop_uuid((char *)data, NULL))) { + if ((pickup_session = switch_core_session_locate(uuid))) { + switch_channel_t *pickup_channel = switch_core_session_get_channel(pickup_session); + switch_caller_profile_t *pickup_caller_profile = switch_channel_get_caller_profile(pickup_channel), + *caller_profile = switch_channel_get_caller_profile(channel); + const char *name, *num; + switch_event_t *event; + switch_event_header_t *hp; + pickup_pvt_t *tech_pvt = switch_core_session_get_private(pickup_session); + + for(hp = tech_pvt->vars->headers; hp; hp = hp->next) { + switch_channel_set_variable(channel, hp->name, hp->value); + } + + + switch_channel_set_flag(pickup_channel, CF_CHANNEL_SWAP); + switch_channel_set_variable(pickup_channel, "channel_swap_uuid", switch_core_session_get_uuid(session)); + + name = caller_profile->caller_id_name; + num = caller_profile->caller_id_number; + + caller_profile->caller_id_name = switch_core_strdup(caller_profile->pool, pickup_caller_profile->caller_id_name); + caller_profile->caller_id_number = switch_core_strdup(caller_profile->pool, pickup_caller_profile->caller_id_number); + + caller_profile->callee_id_name = name; + caller_profile->callee_id_number = num; + + if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) { + const char *uuid = switch_channel_get_partner_uuid(channel); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV"); + + if (uuid) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid); + } + switch_channel_event_set_data(channel, event); + switch_event_fire(&event); + } + + + switch_channel_set_state(channel, CS_HIBERNATE); + + switch_channel_mark_answered(pickup_channel); + switch_core_session_rwunlock(pickup_session); + } + free(uuid); + } +} + + + + + /* fake chan_error */ switch_endpoint_interface_t *error_endpoint_interface; static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session, @@ -3573,7 +4162,7 @@ static switch_status_t api_chat_send(switch_event_t *message_event) switch_api_execute(cmd, arg, NULL, &stream); if (proto) { - switch_core_chat_send_args(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL); + switch_core_chat_send_args(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL, SWITCH_TRUE); } switch_safe_free(stream.data); @@ -3962,6 +4551,366 @@ static char *file_string_supported_formats[SWITCH_MAX_CODECS] = { 0 }; /* /FILE STRING INTERFACE */ +SWITCH_STANDARD_APP(blind_transfer_ack_function) +{ + switch_bool_t val = 0; + + if (data) { + val = switch_true((char *) val); + } + + switch_ivr_blind_transfer_ack(session, val); +} + +/* /// mutex /// */ + +typedef struct mutex_node_s { + char *uuid; + struct mutex_node_s *next; +} mutex_node_t; + +typedef enum { + MUTEX_FLAG_WAIT = (1 << 0), + MUTEX_FLAG_SET = (1 << 1) +} mutex_flag_t; + +struct read_frame_data { + const char *dp; + const char *exten; + const char *context; + const char *key; + long to; +}; + +typedef struct master_mutex_s { + mutex_node_t *list; + char *key; +} master_mutex_t; + +static switch_status_t mutex_hanguphook(switch_core_session_t *session); +static void advance(master_mutex_t *master, switch_bool_t pop_current); + +static switch_status_t read_frame_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + struct read_frame_data *rf = (struct read_frame_data *) user_data; + + if (rf->to && --rf->to <= 0) { + rf->to = -1; + return SWITCH_STATUS_FALSE; + } + + return switch_channel_test_app_flag_key(rf->key, channel, MUTEX_FLAG_WAIT) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; + +} + +static void free_node(mutex_node_t **npp) +{ + mutex_node_t *np; + + if (npp) { + np = *npp; + *npp = NULL; + switch_safe_free(np->uuid); + free(np); + } +} + +static void cancel(switch_core_session_t *session, master_mutex_t *master) +{ + mutex_node_t *np, *lp = NULL; + const char *uuid = switch_core_session_get_uuid(session); + + switch_mutex_lock(globals.mutex_mutex); + for (np = master->list; np; np = np->next) { + if (np && !strcmp(np->uuid, uuid)) { + switch_core_event_hook_remove_state_change(session, mutex_hanguphook); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s canceled\n", + switch_core_session_get_uuid(session), + switch_core_session_get_name(session), master->key); + + if (lp) { + lp->next = np->next; + } else { + if ((master->list = np->next)) { + advance(master, SWITCH_FALSE); + } + } + + free_node(&np); + + break; + } + + lp = np; + } + + switch_mutex_unlock(globals.mutex_mutex); + +} + +static void advance(master_mutex_t *master, switch_bool_t pop_current) +{ + + switch_mutex_lock(globals.mutex_mutex); + + if (!master || !master->list) { + goto end; + } + + while (master->list) { + mutex_node_t *np; + + + if (!pop_current) { + pop_current++; + } else { + np = master->list; + master->list = master->list->next; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ADVANCE POP %p\n", (void *)np); + free_node(&np); + } + + + if (master->list) { + switch_core_session_t *session; + + if ((session = switch_core_session_locate(master->list->uuid))) { + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "%s mutex %s advanced\n", switch_channel_get_name(channel), master->key); + switch_channel_set_app_flag_key(master->key, channel, MUTEX_FLAG_SET); + switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_WAIT); + switch_core_event_hook_add_state_change(session, mutex_hanguphook); + switch_core_session_rwunlock(session); + break; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "uuid %s already gone\n", master->list->uuid); + } + } + } + + + end: + + switch_mutex_unlock(globals.mutex_mutex); + + +} + +static void confirm(switch_core_session_t *session, master_mutex_t *master) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + + if (!master) { + if (!(master = switch_channel_get_private(channel, "_mutex_master"))) { + return; + } + } + + switch_mutex_lock(globals.mutex_mutex); + + if (master->list) { + if (!strcmp(master->list->uuid, switch_core_session_get_uuid(session))) { + switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_SET); + switch_core_event_hook_remove_state_change(session, mutex_hanguphook); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s cleared\n", + switch_core_session_get_uuid(session), + switch_channel_get_name(channel), master->key); + advance(master, SWITCH_TRUE); + } else { + cancel(session, master); + } + } + + switch_mutex_unlock(globals.mutex_mutex); +} + + + +static switch_status_t mutex_hanguphook(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_channel_state_t state = switch_channel_get_state(channel); + + if (state != CS_HANGUP) { + return SWITCH_STATUS_SUCCESS; + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s mutex hangup hook\n", switch_channel_get_name(channel)); + + confirm(session, NULL); + switch_core_event_hook_remove_state_change(session, mutex_hanguphook); + + return SWITCH_STATUS_SUCCESS; +} + +static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, switch_bool_t on) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + const char *feedback, *var; + switch_input_args_t args = { 0 }; + master_mutex_t *master = NULL; + mutex_node_t *node, *np; + int used; + struct read_frame_data rf = { 0 }; + long to_val = 0; + + if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { + return SWITCH_FALSE; + } + + switch_mutex_lock(globals.mutex_mutex); + used = switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT) || switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_SET); + + if ((on && used) || (!on && !used)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID STATE\n"); + switch_mutex_unlock(globals.mutex_mutex); + return SWITCH_FALSE; + } + + if (!(master = switch_core_hash_find(globals.mutex_hash, key))) { + master = switch_core_alloc(globals.pool, sizeof(*master)); + master->key = switch_core_strdup(globals.pool, key); + master->list = NULL; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NEW MASTER %s %p\n", key, (void *) master); + switch_core_hash_insert(globals.mutex_hash, key, master); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXIST MASTER %s %p\n", key, (void *) master); + } + + if (on) { + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "HIT ON\n"); + + switch_zmalloc(node, sizeof(*node)); + node->uuid = strdup(switch_core_session_get_uuid(session)); + node->next = NULL; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CHECK MASTER LIST %p\n", (void *) master->list); + + for (np = master->list; np && np->next; np = np->next); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "HIT ON np %p\n", (void *) np); + + if (np) { + np->next = node; + switch_channel_set_app_flag_key(key, channel, MUTEX_FLAG_WAIT); + } else { + master->list = node; + switch_channel_set_app_flag_key(key, channel, MUTEX_FLAG_SET); + switch_channel_clear_app_flag_key(key, channel, MUTEX_FLAG_WAIT); + switch_channel_set_private(channel, "_mutex_master", master); + switch_core_event_hook_add_state_change(session, mutex_hanguphook); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n", + switch_core_session_get_uuid(session), + switch_channel_get_name(channel), key); + switch_mutex_unlock(globals.mutex_mutex); + return SWITCH_TRUE; + } + } else { + confirm(session, master); + + switch_mutex_unlock(globals.mutex_mutex); + return SWITCH_TRUE; + } + + switch_mutex_unlock(globals.mutex_mutex); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s mutex %s is busy, waiting...\n", switch_channel_get_name(channel), key); + + if (!(feedback = switch_channel_get_variable(channel, "mutex_feedback"))) { + if ((var = switch_channel_get_variable(channel, "ringback"))) { + feedback = switch_core_session_sprintf(session, "tone_stream://%s;loops=-1", var); + } else { + feedback = switch_channel_get_hold_music(channel); + } + } + + if (zstr(feedback) || !strcasecmp(feedback, "silence")) { + feedback = "silence_stream://-1"; + } + + + if ((rf.exten = switch_channel_get_variable(channel, "mutex_orbit_exten"))) { + to_val = 60; + } + + if ((var = switch_channel_get_variable(channel, "mutex_timeout"))) { + long tmp = atol(var); + + if (tmp > 0) { + to_val = tmp; + } + } + + if (to_val) { + switch_codec_implementation_t read_impl; + switch_core_session_get_read_impl(session, &read_impl); + + rf.to = (1000 / (read_impl.microseconds_per_packet / 1000)) * to_val; + rf.dp = switch_channel_get_variable(channel, "mutex_orbit_dialplan"); + rf.context = switch_channel_get_variable(channel, "mutex_orbit_context"); + } + + rf.key = key; + + args.read_frame_callback = read_frame_callback; + args.user_data = &rf; + + while(switch_channel_ready(channel) && switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT)) { + switch_status_t st = switch_ivr_play_file(session, NULL, feedback, &args); + + if (st != SWITCH_STATUS_SUCCESS) { + break; + } + } + + switch_mutex_lock(globals.mutex_mutex); + if (switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT) || !switch_channel_up(channel)) { + cancel(session, master); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n", + switch_core_session_get_uuid(session), + switch_channel_get_name(channel), key); + switch_core_event_hook_add_state_change(session, mutex_hanguphook); + switch_channel_set_private(channel, "_mutex_master", master); + } + switch_mutex_unlock(globals.mutex_mutex); + + return SWITCH_TRUE; +} + +#define MUTEX_SYNTAX "[ on|off]" +SWITCH_STANDARD_APP(mutex_function) +{ + char *key; + char *arg; + switch_bool_t on = SWITCH_TRUE; + + if (zstr(data)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing keyname\n"); + return; + } + + key = switch_core_session_sprintf(session, "_mutex_key_%s", (char *)data); + + if ((arg = strchr(key, ' '))) { + *arg++ = '\0'; + + if (!strcasecmp(arg, "off")) { + on = SWITCH_FALSE; + } + } + + do_mutex(session, key, on); + + +} + +/* /// mutex /// */ + #define SPEAK_DESC "Speak text to a channel via the tts interface" #define DISPLACE_DESC "Displace audio from a file to the channels input" @@ -3978,6 +4927,14 @@ static char *file_string_supported_formats[SWITCH_MAX_CODECS] = { 0 }; #define LOG_LONG_DESC "Logs a channel variable for the channel calling the application." #define TRANSFER_LONG_DESC "Immediately transfer the calling channel to a new extension" #define SLEEP_LONG_DESC "Pause the channel for a given number of milliseconds, consuming the audio for that period of time." + +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown) +{ + switch_event_unbind_callback(pickup_pres_event_handler); + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) { switch_api_interface_t *api_interface; @@ -3986,9 +4943,18 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) switch_chat_interface_t *chat_interface; switch_file_interface_t *file_interface; + globals.pool = pool; + switch_core_hash_init(&globals.pickup_hash, globals.pool); + switch_mutex_init(&globals.pickup_mutex, SWITCH_MUTEX_NESTED, globals.pool); + switch_core_hash_init(&globals.mutex_hash, globals.pool); + switch_mutex_init(&globals.mutex_mutex, SWITCH_MUTEX_NESTED, globals.pool); + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); + switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pickup_pres_event_handler, NULL); + + file_string_supported_formats[0] = "file_string"; file_interface = (switch_file_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); @@ -4012,6 +4978,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) user_endpoint_interface->interface_name = "user"; user_endpoint_interface->io_routines = &user_io_routines; + pickup_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + pickup_endpoint_interface->interface_name = "pickup"; + pickup_endpoint_interface->io_routines = &pickup_io_routines; + pickup_endpoint_interface->state_handler = &pickup_event_handlers; + SWITCH_ADD_CHAT(chat_interface, "event", event_chat_send); SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send); @@ -4021,6 +4992,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, ""); SWITCH_ADD_API(api_interface, "presence", "presence", presence_api_function, PRESENCE_USAGE); + SWITCH_ADD_APP(app_interface, "blind_transfer_ack", "", "", blind_transfer_ack_function, "[true|false]", SAF_NONE); + SWITCH_ADD_APP(app_interface, "bind_digit_action", "bind a key sequence or regex to an action", "bind a key sequence or regex to an action", bind_digit_action_function, BIND_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA); @@ -4042,6 +5015,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "flush_dtmf", "flush any queued dtmf", "flush any queued dtmf", flush_dtmf_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "hold", "Send a hold message", "Send a hold message", hold_function, HOLD_SYNTAX, SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "unhold", "Send a un-hold message", "Send a un-hold message", unhold_function, UNHOLD_SYNTAX, SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "mutex", "block on a call flow only allowing one at a time", "", mutex_function, MUTEX_SYNTAX, SAF_NONE); SWITCH_ADD_APP(app_interface, "transfer", "Transfer a channel", TRANSFER_LONG_DESC, transfer_function, " [ ]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", "Check an ip against an ACL list", check_acl_function, @@ -4077,6 +5051,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "multiset", "Set many channel variables", SET_LONG_DESC, multiset_function, "[^^]= =", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "push", "Set a channel variable", SET_LONG_DESC, push_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); @@ -4097,6 +5074,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "video_refresh", "Send video refresh.", "Send video refresh.", video_refresh_function, "", + SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "send_info", "Send info", "Send info", send_info_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "jitterbuffer", "Send session jitterbuffer", "Send a jitterbuffer message to a session.", jitterbuffer_function, "", SAF_SUPPORT_NOMEDIA); @@ -4186,6 +5165,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "limit_execute", "Limit", LIMITEXECUTE_DESC, limit_execute_function, LIMITEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "limit_hash_execute", "Limit", LIMITHASHEXECUTE_DESC, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "pickup", "Pickup", "Pickup a call", pickup_function, PICKUP_SYNTAX, SAF_SUPPORT_NOMEDIA); + + SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt); /* indicate that the module should continue to be loaded */ diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index c0cf904da2..c40e6443f0 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -24,6 +24,7 @@ * Contributor(s): * * Anthony Minessale II + * Jay Binks * * mod_enum.c -- ENUM * @@ -35,6 +36,8 @@ #endif #include +#define ENUM_MAXNAMESERVERS 10 /* max nameservers that will be used */ + SWITCH_MODULE_LOAD_FUNCTION(mod_enum_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown); SWITCH_MODULE_DEFINITION(mod_enum, mod_enum_load, mod_enum_shutdown, NULL); @@ -72,6 +75,7 @@ static struct { int timeout; int retries; int random; + char *nameserver[ENUM_MAXNAMESERVERS]; } globals; SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_root, globals.root); @@ -102,6 +106,7 @@ static void add_route(char *service, char *regex, char *replace) static switch_status_t load_config(void) { char *cf = "enum.conf"; + int inameserver = 0; switch_xml_t cfg, xml = NULL, param, settings, route, routes; switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -135,6 +140,11 @@ static switch_status_t load_config(void) globals.random = switch_true(val); } else if (!strcasecmp(var, "default-isn-root")) { set_global_isn_root(val); + } else if (!strcasecmp(var, "nameserver")) { + if ( inameserver < ENUM_MAXNAMESERVERS ) { + globals.nameserver[inameserver] = (char *) val; + inameserver++; + } } else if (!strcasecmp(var, "log-level-trace")) { } @@ -442,8 +452,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t return; } - -switch_status_t ldns_lookup(const char *number, const char *root, const char *server_name, enum_record_t **results) +switch_status_t ldns_lookup(const char *number, const char *root, char *server_name[ENUM_MAXNAMESERVERS] , enum_record_t **results) { ldns_resolver *res = NULL; ldns_rdf *domain = NULL; @@ -454,6 +463,8 @@ switch_status_t ldns_lookup(const char *number, const char *root, const char *se switch_status_t status = SWITCH_STATUS_FALSE; char *name = NULL; struct timeval to = { 0, 0}; + int inameserver = 0; + int added_server = 0; if (!(name = reverse_number(number, root))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Parse Error!\n"); @@ -463,16 +474,24 @@ switch_status_t ldns_lookup(const char *number, const char *root, const char *se if (!(domain = ldns_dname_new_frm_str(name))) { goto end; } - - if (!zstr(server_name)) { + + if (server_name) { res = ldns_resolver_new(); switch_assert(res); - if ((serv_rdf = ldns_rdf_new_addr_frm_str(server_name))) { - s = ldns_resolver_push_nameserver(res, serv_rdf); - ldns_rdf_deep_free(serv_rdf); + for(inameserver=0; inameserverdestination_number); - if (enum_lookup(dp, caller_profile->destination_number, &results) == SWITCH_STATUS_SUCCESS) { + if (enum_lookup(dp, caller_profile->destination_number, &results, channel, session) == SWITCH_STATUS_SUCCESS) { if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); free_results(&results); @@ -624,7 +683,7 @@ SWITCH_STANDARD_APP(enum_app_function) if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { dest = argv[0]; root = argv[1]; - if (enum_lookup(root, dest, &results) == SWITCH_STATUS_SUCCESS) { + if (enum_lookup(root, dest, &results, channel, session) == SWITCH_STATUS_SUCCESS) { switch_event_t *vars; if (switch_channel_get_variables(channel, &vars) == SWITCH_STATUS_SUCCESS) { @@ -692,7 +751,7 @@ SWITCH_STANDARD_API(enum_api) dest = argv[0]; root = argv[1]; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Looking up %s@%s\n", dest, root); - if (enum_lookup(root, dest, &results) == SWITCH_STATUS_SUCCESS) { + if (enum_lookup(root, dest, &results, NULL, session) == SWITCH_STATUS_SUCCESS) { for (rp = results; rp; rp = rp->next) { if (!rp->supported) { continue; @@ -770,7 +829,7 @@ SWITCH_STANDARD_API(enum_function) } - if (!enum_lookup(root, dest, &results) == SWITCH_STATUS_SUCCESS) { + if (!enum_lookup(root, dest, &results, NULL, session) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "No Match!\n"); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index 5414b9d8df..9d9aabdbae 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -199,9 +199,9 @@ SWITCH_STANDARD_APP(bcast_function) rtp_port, mcast_ip, mcast_port, - read_impl.ianacode, - read_impl.samples_per_packet, - read_impl.microseconds_per_packet, (switch_rtp_flag_t) flags, "soft", &err, switch_core_session_get_pool(session)); + 0, + 8000, + 20, (switch_rtp_flag_t) 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"); diff --git a/src/mod/applications/mod_fax/Makefile.am b/src/mod/applications/mod_fax/Makefile.am deleted file mode 100644 index c71c5b9da5..0000000000 --- a/src/mod/applications/mod_fax/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_fax - -TIFF_DIR=$(switch_srcdir)/libs/tiff-3.8.2 -TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-3.8.2 -TIFF_LA=$(TIFF_BUILDDIR)/libtiff/libtiff.la - -SPANDSP_DIR=$(switch_srcdir)/libs/spandsp -SPANDSP_BUILDDIR=$(switch_builddir)/libs/spandsp -SPANDSP_LA=$(SPANDSP_BUILDDIR)/src/libspandsp.la - -mod_LTLIBRARIES = mod_fax.la -mod_fax_la_SOURCES = mod_fax.c udptl.c -mod_fax_la_CFLAGS = $(AM_CFLAGS) -I$(SPANDSP_DIR)/src -I$(TIFF_DIR)/libtiff -I$(SPANDSP_BUILDDIR)/src -I$(TIFF_BUILDDIR)/libtiff -I. -mod_fax_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SPANDSP_LA) $(TIFF_LA) -mod_fax_la_LDFLAGS = -avoid-version -module -no-undefined -shared -ljpeg - -$(SPANDSP_LA): $(TIFF_LA) $(SPANDSP_DIR) $(SPANDSP_DIR)/.update - cd $(SPANDSP_BUILDDIR) && $(MAKE) -j1 - $(TOUCH_TARGET) - -$(TIFF_LA): $(TIFF_DIR) $(TIFF_DIR)/.update - cd $(TIFF_BUILDDIR) && $(MAKE) -j1 - $(TOUCH_TARGET) diff --git a/src/mod/applications/mod_fax/mod_fax.c b/src/mod/applications/mod_fax/mod_fax.c deleted file mode 100644 index 7eac2520b3..0000000000 --- a/src/mod/applications/mod_fax/mod_fax.c +++ /dev/null @@ -1,1945 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II - * - * 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 mod_fax. - * - * The Initial Developer of the Original Code is - * Massimo Cetra - * - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Brian West - * Anthony Minessale II - * Steve Underwood - * Antonio Gallo - * mod_fax.c -- Fax applications provided by SpanDSP - * - */ - -#include -#ifdef WIN32 -#define FAX_INVALID_SOCKET INVALID_HANDLE_VALUE -typedef HANDLE zap_socket_t; -#else -#define FAX_INVALID_SOCKET -1 -typedef int zap_socket_t; -#endif - -#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES -#include -#include - -#include "udptl.h" - -#define LOCAL_FAX_MAX_DATAGRAM 400 -#define MAX_FEC_ENTRIES 4 -#define MAX_FEC_SPAN 4 - -/***************************************************************************** - OUR DEFINES AND STRUCTS -*****************************************************************************/ - -typedef enum { - FUNCTION_TX, - FUNCTION_RX, - FUNCTION_GW -} application_mode_t; - -typedef enum { - T38_MODE, - AUDIO_MODE, - T38_GATEWAY_MODE -} transport_mode_t; - -typedef enum { - T38_MODE_UNKNOWN = 0, - T38_MODE_NEGOTIATED = 1, - T38_MODE_REQUESTED = 2, - T38_MODE_REFUSED = -1, -} t38_mode_t; - -/* The global stuff */ -static struct { - switch_memory_pool_t *pool; - switch_mutex_t *mutex; - - uint32_t total_sessions; - - short int use_ecm; - short int verbose; - short int disable_v17; - short int enable_t38; - short int enable_t38_request; - short int enable_t38_insist; - char ident[20]; - char header[50]; - char *prepend_string; - char *spool; -} globals; - -struct pvt_s { - switch_core_session_t *session; - - application_mode_t app_mode; - - fax_state_t *fax_state; - t38_terminal_state_t *t38_state; - t38_gateway_state_t *t38_gateway_state; - t38_core_state_t *t38_core; - - udptl_state_t *udptl_state; - - char *filename; - char *ident; - char *header; - - int use_ecm; - int disable_v17; - int verbose; - int caller; - - int tx_page_start; - int tx_page_end; - - int done; - - t38_mode_t t38_mode; - - struct pvt_s *next; -}; - -typedef struct pvt_s pvt_t; - -static void launch_timer_thread(void); - -static struct { - pvt_t *head; - switch_mutex_t *mutex; - switch_thread_t *thread; - int thread_running; -} t38_state_list; - -static int add_pvt(pvt_t *pvt) -{ - int r = 0; - uint32_t sanity = 50; - - switch_mutex_lock(t38_state_list.mutex); - if (!t38_state_list.thread_running) { - - launch_timer_thread(); - - while(--sanity && !t38_state_list.thread_running) { - switch_yield(10000); - } - } - switch_mutex_unlock(t38_state_list.mutex); - - if (t38_state_list.thread_running) { - switch_mutex_lock(t38_state_list.mutex); - pvt->next = t38_state_list.head; - t38_state_list.head = pvt; - switch_mutex_unlock(t38_state_list.mutex); - } - - return r; - -} - - -static int del_pvt(pvt_t *del_pvt) -{ - pvt_t *p, *l = NULL; - int r = 0; - - if (!t38_state_list.thread_running) goto end; - - switch_mutex_lock(t38_state_list.mutex); - for (p = t38_state_list.head; p; p = p->next) { - if (p == del_pvt) { - if (l) { - l->next = p->next; - } else { - t38_state_list.head = p->next; - } - p->next = NULL; - r = 1; - goto end; - } - - l = p; - } - - end: - - switch_mutex_unlock(t38_state_list.mutex); - - return r; - -} - -static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void *obj) -{ - switch_timer_t timer = { 0 }; - pvt_t *pvt; - int samples = 240; - int ms = 30; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "timer thread started.\n"); - - if (switch_core_timer_init(&timer, "soft", ms, samples, NULL) != SWITCH_STATUS_SUCCESS) { - return NULL; - } - - t38_state_list.thread_running = 1; - - while(t38_state_list.thread_running) { - - switch_mutex_lock(t38_state_list.mutex); - - if (!t38_state_list.head) { - switch_mutex_unlock(t38_state_list.mutex); - goto end; - } - - for (pvt = t38_state_list.head; pvt; pvt = pvt->next) { - if (pvt->udptl_state) { - t38_terminal_send_timeout(pvt->t38_state, samples); - } - } - - switch_mutex_unlock(t38_state_list.mutex); - - switch_core_timer_next(&timer); - } - - end: - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "timer thread ended.\n"); - - t38_state_list.thread_running = 0; - switch_core_timer_destroy(&timer); - - return NULL; -} - -static void launch_timer_thread(void) -{ - - switch_threadattr_t *thd_attr = NULL; - - switch_threadattr_create(&thd_attr, globals.pool); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&t38_state_list.thread, thd_attr, timer_thread_run, NULL, globals.pool); -} - - -/***************************************************************************** - LOGGING AND HELPER FUNCTIONS -*****************************************************************************/ - -static void counter_increment(void) -{ - switch_mutex_lock(globals.mutex); - globals.total_sessions++; - switch_mutex_unlock(globals.mutex); -} - -static void spanfax_log_message(int level, const char *msg) -{ - int fs_log_level; - - switch (level) { - case SPAN_LOG_NONE: - return; - case SPAN_LOG_ERROR: - case SPAN_LOG_PROTOCOL_ERROR: - fs_log_level = SWITCH_LOG_ERROR; - break; - case SPAN_LOG_WARNING: - case SPAN_LOG_PROTOCOL_WARNING: - fs_log_level = SWITCH_LOG_WARNING; - break; - case SPAN_LOG_FLOW: - case SPAN_LOG_FLOW_2: - case SPAN_LOG_FLOW_3: - default: /* SPAN_LOG_DEBUG, SPAN_LOG_DEBUG_2, SPAN_LOG_DEBUG_3 */ - fs_log_level = SWITCH_LOG_DEBUG; - break; - } - - if (!zstr(msg)) { - switch_log_printf(SWITCH_CHANNEL_LOG, fs_log_level, "%s", msg); - } -} - -/* - * Called at the end of the document - */ -static void phase_e_handler(t30_state_t *s, void *user_data, int result) -{ - t30_stats_t t; - const char *local_ident; - const char *far_ident; - switch_core_session_t *session; - switch_channel_t *channel; - pvt_t *pvt; - char *tmp; - - pvt = (pvt_t *) user_data; - switch_assert(pvt); - - session = pvt->session; - switch_assert(session); - - channel = switch_core_session_get_channel(session); - switch_assert(channel); - - t30_get_transfer_statistics(s, &t); - local_ident = switch_str_nil(t30_get_tx_ident(s)); - far_ident = switch_str_nil(t30_get_rx_ident(s)); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n"); - - if (result == T30_ERR_OK) { - if (pvt->app_mode == FUNCTION_TX) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax successfully sent.\n"); - } else if (pvt->app_mode == FUNCTION_RX) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax successfully received.\n"); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax successfully managed. How ?\n"); - } - switch_channel_set_variable(channel, "fax_success", "1"); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax processing not successful - result (%d) %s.\n", result, - t30_completion_code_to_str(result)); - switch_channel_set_variable(channel, "fax_success", "0"); - } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote station id: %s\n", far_ident); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local station id: %s\n", local_ident); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Pages transferred: %i\n", - pvt->app_mode == FUNCTION_TX ? t.pages_tx : t.pages_rx); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Total fax pages: %i\n", t.pages_in_file); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image resolution: %ix%i\n", t.x_resolution, t.y_resolution); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ECM status %s\n", (t.error_correcting_mode) ? "on" : "off"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote country: %s\n", switch_str_nil(t30_get_rx_country(s))); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(s))); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(s))); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n"); - - /* - Set our channel variables - */ - - tmp = switch_mprintf("%i", result); - if (tmp) { - switch_channel_set_variable(channel, "fax_result_code", tmp); - switch_safe_free(tmp); - } - - switch_channel_set_variable(channel, "fax_result_text", t30_completion_code_to_str(result)); - - switch_channel_set_variable(channel, "fax_ecm_used", (t.error_correcting_mode) ? "on" : "off"); - switch_channel_set_variable(channel, "fax_local_station_id", local_ident); - switch_channel_set_variable(channel, "fax_remote_station_id", far_ident); - - tmp = switch_mprintf("%i", pvt->app_mode == FUNCTION_TX ? t.pages_tx : t.pages_rx); - if (tmp) { - switch_channel_set_variable(channel, "fax_document_transferred_pages", tmp); - switch_safe_free(tmp); - } - - tmp = switch_mprintf("%i", t.pages_in_file); - if (tmp) { - switch_channel_set_variable(channel, "fax_document_total_pages", tmp); - switch_safe_free(tmp); - } - - tmp = switch_mprintf("%ix%i", t.x_resolution, t.y_resolution); - if (tmp) { - switch_channel_set_variable(channel, "fax_image_resolution", tmp); - switch_safe_free(tmp); - } - - tmp = switch_mprintf("%d", t.image_size); - if (tmp) { - switch_channel_set_variable(channel, "fax_image_size", tmp); - switch_safe_free(tmp); - } - - tmp = switch_mprintf("%d", t.bad_rows); - if (tmp) { - switch_channel_set_variable(channel, "fax_bad_rows", tmp); - switch_safe_free(tmp); - } - - tmp = switch_mprintf("%i", t.bit_rate); - if (tmp) { - switch_channel_set_variable(channel, "fax_transfer_rate", tmp); - switch_safe_free(tmp); - } - - /* switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); */ - - pvt->done = 1; - - /* - TODO Fire events - */ -} - -static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count) -{ - switch_frame_t out_frame = { 0 }; - switch_core_session_t *session; - switch_channel_t *channel; - pvt_t *pvt; - uint8_t pkt[LOCAL_FAX_MAX_DATAGRAM]; - int x; - int r = 0; - - pvt = (pvt_t *) user_data; - session = pvt->session; - channel = switch_core_session_get_channel(session); - - /* we need to build a real packet here and make write_frame.packet and write_frame.packetlen point to it */ - out_frame.flags = SFF_UDPTL_PACKET | SFF_PROXY_PACKET; - out_frame.packet = pkt; - out_frame.packetlen = udptl_build_packet(pvt->udptl_state, pkt, buf, len); - - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "WRITE %d udptl bytes\n", out_frame.packetlen); - - for (x = 0; x < count; x++) { - if (switch_core_session_write_frame(session, &out_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - r = -1; - break; - } - } - - return r; -} - -static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) -{ - - switch_core_session_t *session; - switch_channel_t *channel; - fax_state_t *fax; - t38_terminal_state_t *t38; - t30_state_t *t30; - - - session = (switch_core_session_t *) pvt->session; - switch_assert(session); - - channel = switch_core_session_get_channel(session); - switch_assert(channel); - - - switch (trans_mode) { - case AUDIO_MODE: - if (pvt->fax_state == NULL) { - pvt->fax_state = (fax_state_t *) switch_core_session_alloc(pvt->session, sizeof(fax_state_t)); - } - if (pvt->fax_state == NULL) { - return SWITCH_STATUS_FALSE; - } - - fax = pvt->fax_state; - t30 = fax_get_t30_state(fax); - - memset(fax, 0, sizeof(fax_state_t)); - if (fax_init(fax, pvt->caller) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my fax structs\n"); - return SWITCH_STATUS_FALSE; - } - - fax_set_transmit_on_idle(fax, TRUE); - - span_log_set_message_handler(&fax->logging, spanfax_log_message); - span_log_set_message_handler(&t30->logging, spanfax_log_message); - - if (pvt->verbose) { - span_log_set_level(&fax->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - } - break; - case T38_MODE: - if (pvt->t38_state == NULL) { - pvt->t38_state = (t38_terminal_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_terminal_state_t)); - } - if (pvt->t38_state == NULL) { - return SWITCH_STATUS_FALSE; - } - if (pvt->udptl_state == NULL) { - pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t)); - } - if (pvt->udptl_state == NULL) { - t38_terminal_free(pvt->t38_state); - pvt->t38_state = NULL; - return SWITCH_STATUS_FALSE; - } - - /* add to timer thread processing */ - add_pvt(pvt); - - t38 = pvt->t38_state; - t30 = t38_terminal_get_t30_state(t38); - - memset(t38, 0, sizeof(t38_terminal_state_t)); - - if (t38_terminal_init(t38, pvt->caller, t38_tx_packet_handler, pvt) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); - return SWITCH_STATUS_FALSE; - } - - pvt->t38_core = t38_terminal_get_t38_core_state(pvt->t38_state); - - if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, - (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); - return SWITCH_STATUS_FALSE; - } - - span_log_set_message_handler(&t38->logging, spanfax_log_message); - span_log_set_message_handler(&t30->logging, spanfax_log_message); - - if (pvt->verbose) { - span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - } - break; - case T38_GATEWAY_MODE: - if (pvt->t38_gateway_state == NULL) { - pvt->t38_gateway_state = (t38_gateway_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_gateway_state_t)); - } - - if (pvt->udptl_state == NULL) { - pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t)); - } - - if (t38_gateway_init(pvt->t38_gateway_state, t38_tx_packet_handler, pvt) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); - t38_gateway_free(pvt->t38_gateway_state); - pvt->t38_gateway_state = NULL; - - return SWITCH_STATUS_FALSE; - } - - pvt->t38_core = t38_gateway_get_t38_core_state(pvt->t38_gateway_state); - - if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, - (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); - t38_gateway_free(pvt->t38_gateway_state); - udptl_release(pvt->udptl_state); - pvt->udptl_state = NULL; - return SWITCH_STATUS_FALSE; - } - - t38_gateway_set_transmit_on_idle(pvt->t38_gateway_state, TRUE); - - if (switch_true(switch_channel_get_variable(channel, "fax_v17_disabled"))) { - t38_gateway_set_supported_modems(pvt->t38_gateway_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); - } else { - t38_gateway_set_supported_modems(pvt->t38_gateway_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); - } - - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, pvt->use_ecm); - switch_channel_set_variable(channel, "fax_ecm_requested", pvt->use_ecm ? "true" : "false"); - - if (switch_true(switch_channel_get_variable(channel, "FAX_DISABLE_ECM"))) { - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, FALSE); - } else { - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, TRUE); - } - - - span_log_set_message_handler(&pvt->t38_gateway_state->logging, spanfax_log_message); - span_log_set_message_handler(&pvt->t38_core->logging, spanfax_log_message); - - if (pvt->verbose) { - span_log_set_level(&pvt->t38_gateway_state->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&pvt->t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - } - - t38_set_t38_version(pvt->t38_core, 0); - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, 1); - - return SWITCH_STATUS_SUCCESS; - - default: - assert(0); /* What? */ - return SWITCH_STATUS_SUCCESS; - } /* Switch trans mode */ - - /* All the things which are common to audio and T.38 FAX setup */ - t30_set_tx_ident(t30, pvt->ident); - t30_set_tx_page_header_info(t30, pvt->header); - - t30_set_phase_e_handler(t30, phase_e_handler, pvt); - - t30_set_supported_image_sizes(t30, - T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH - | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); - t30_set_supported_resolutions(t30, - T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION - | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); - - if (pvt->disable_v17) { - t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); - switch_channel_set_variable(channel, "fax_v17_disabled", "1"); - } else { - t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER | T30_SUPPORT_V17); - switch_channel_set_variable(channel, "fax_v17_disabled", "0"); - } - - if (pvt->use_ecm) { - t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); - t30_set_ecm_capability(t30, TRUE); - switch_channel_set_variable(channel, "fax_ecm_requested", "1"); - } else { - t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION); - switch_channel_set_variable(channel, "fax_ecm_requested", "0"); - } - - if (pvt->app_mode == FUNCTION_TX) { - t30_set_tx_file(t30, pvt->filename, pvt->tx_page_start, pvt->tx_page_end); - } else { - t30_set_rx_file(t30, pvt->filename, -1); - } - switch_channel_set_variable(channel, "fax_filename", pvt->filename); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t spanfax_destroy(pvt_t *pvt) -{ - int terminate; - t30_state_t *t30; - - if (!pvt) return SWITCH_STATUS_FALSE; - - if (pvt->fax_state) { - if (pvt->t38_state) { - terminate = 0; - } else { - terminate = 1; - } - - t30 = fax_get_t30_state(pvt->fax_state); - if (terminate && t30) { - t30_terminate(t30); - } - - fax_release(pvt->fax_state); - } - - if (pvt->t38_state) { - - /* remove from timer thread processing */ - del_pvt(pvt); - - if (pvt->t38_state) { - terminate = 1; - } else { - terminate = 0; - } - - t30 = t38_terminal_get_t30_state(pvt->t38_state); - - if (terminate && t30) { - t30_terminate(t30); - } - - t38_terminal_release(pvt->t38_state); - } - - if (pvt->t38_gateway_state) { - t38_gateway_release(pvt->t38_gateway_state); - } - - if (pvt->udptl_state) { - udptl_release(pvt->udptl_state); - } - return SWITCH_STATUS_SUCCESS; -} - -static t38_mode_t configure_t38(pvt_t *pvt) -{ - switch_core_session_t *session = pvt->session; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options"); - int method = 2; - - if (!t38_options || !pvt || !pvt->t38_core) { - pvt->t38_mode = T38_MODE_REFUSED; - return pvt->t38_mode; - } - - t38_set_t38_version(pvt->t38_core, t38_options->T38FaxVersion); - t38_set_max_buffer_size(pvt->t38_core, t38_options->T38FaxMaxBuffer); - t38_set_fastest_image_data_rate(pvt->t38_core, t38_options->T38MaxBitRate); - t38_set_fill_bit_removal(pvt->t38_core, t38_options->T38FaxFillBitRemoval); - t38_set_mmr_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingMMR); - t38_set_jbig_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingJBIG); - t38_set_max_datagram_size(pvt->t38_core, t38_options->T38FaxMaxDatagram); - - if (t38_options->T38FaxRateManagement) { - if (!strcasecmp(t38_options->T38FaxRateManagement, "transferredTCF")) { - method = 2; - } else { - method = 1; - } - } - - t38_set_data_rate_management_method(pvt->t38_core, method); - - - //t38_set_data_transport_protocol(pvt->t38_core, int data_transport_protocol); - //t38_set_redundancy_control(pvt->t38_core, int category, int setting); - - return pvt->t38_mode; -} - -static t38_mode_t negotiate_t38(pvt_t *pvt) -{ - switch_core_session_t *session = pvt->session; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_core_session_message_t msg = { 0 }; - switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options"); - int enabled = 0, insist = 0; - const char *v; - - pvt->t38_mode = T38_MODE_REFUSED; - - if (pvt->app_mode == FUNCTION_GW) { - enabled = 1; - } else if ((v = switch_channel_get_variable(channel, "fax_enable_t38"))) { - enabled = switch_true(v); - } else { - enabled = globals.enable_t38; - } - - if (!(enabled && t38_options)) { - /* if there is no t38_options the endpoint will refuse the transition */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s NO T38 options detected.\n", switch_channel_get_name(channel)); - switch_channel_set_private(channel, "t38_options", NULL); - } else { - pvt->t38_mode = T38_MODE_NEGOTIATED; - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxVersion = %d\n", t38_options->T38FaxVersion); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38MaxBitRate = %d\n", t38_options->T38MaxBitRate); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxFillBitRemoval = %d\n", t38_options->T38FaxFillBitRemoval); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxTranscodingMMR = %d\n", t38_options->T38FaxTranscodingMMR); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxTranscodingJBIG = %d\n", t38_options->T38FaxTranscodingJBIG); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxRateManagement = '%s'\n", t38_options->T38FaxRateManagement); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxBuffer = %d\n", t38_options->T38FaxMaxBuffer); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxDatagram = %d\n", t38_options->T38FaxMaxDatagram); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxUdpEC = '%s'\n", t38_options->T38FaxUdpEC); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38VendorInfo = '%s'\n", switch_str_nil(t38_options->T38VendorInfo)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ip = '%s'\n", t38_options->remote_ip ? t38_options->remote_ip : "Not specified"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "port = %d\n", t38_options->remote_port); - - /* Time to practice our negotiating skills, by editing the t38_options */ - - if (t38_options->T38FaxVersion > 3) { - t38_options->T38FaxVersion = 3; - } - t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400; - t38_options->T38FaxFillBitRemoval = 1; - t38_options->T38FaxTranscodingMMR = 0; - t38_options->T38FaxTranscodingJBIG = 0; - t38_options->T38FaxRateManagement = "transferredTCF"; - t38_options->T38FaxMaxBuffer = 2000; - t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM; - if (strcasecmp(t38_options->T38FaxUdpEC, "t38UDPRedundancy") == 0 - || - strcasecmp(t38_options->T38FaxUdpEC, "t38UDPFEC") == 0) { - t38_options->T38FaxUdpEC = "t38UDPRedundancy"; - } else { - t38_options->T38FaxUdpEC = NULL; - } - t38_options->T38VendorInfo = "0 0 0"; - } - - if ((v = switch_channel_get_variable(channel, "fax_enable_t38_insist"))) { - insist = switch_true(v); - } else { - insist = globals.enable_t38_insist; - } - - /* This will send the options back in a response */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION; - msg.numeric_arg = insist; - switch_core_session_receive_message(session, &msg); - - return pvt->t38_mode; -} - - - -static t38_mode_t request_t38(pvt_t *pvt) -{ - switch_core_session_t *session = pvt->session; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_core_session_message_t msg = { 0 }; - switch_t38_options_t *t38_options = NULL; - int enabled = 0, insist = 0; - const char *v; - - pvt->t38_mode = T38_MODE_UNKNOWN; - - if (pvt->app_mode == FUNCTION_GW) { - enabled = 1; - } else if ((v = switch_channel_get_variable(channel, "fax_enable_t38"))) { - enabled = switch_true(v); - } else { - enabled = globals.enable_t38; - } - - if (enabled) { - if ((v = switch_channel_get_variable(channel, "fax_enable_t38_request"))) { - enabled = switch_true(v); - } else { - enabled = globals.enable_t38_request; - } - } - - - if ((v = switch_channel_get_variable(channel, "fax_enable_t38_insist"))) { - insist = switch_true(v); - } else { - insist = globals.enable_t38_insist; - } - - if (enabled) { - t38_options = switch_core_session_alloc(session, sizeof(*t38_options)); - - t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400; - t38_options->T38FaxVersion = 0; - t38_options->T38FaxFillBitRemoval = 1; - t38_options->T38FaxTranscodingMMR = 0; - t38_options->T38FaxTranscodingJBIG = 0; - t38_options->T38FaxRateManagement = "transferredTCF"; - t38_options->T38FaxMaxBuffer = 2000; - t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM; - t38_options->T38FaxUdpEC = "t38UDPRedundancy"; - t38_options->T38VendorInfo = "0 0 0"; - - switch_channel_set_private(channel, "t38_options", t38_options); - pvt->t38_mode = T38_MODE_REQUESTED; - - /* This will send a request for t.38 mode */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA; - msg.numeric_arg = insist; - switch_core_session_receive_message(session, &msg); - } - - return pvt->t38_mode; -} - -/***************************************************************************** - MAIN FAX PROCESSING -*****************************************************************************/ - -static pvt_t *pvt_init(switch_core_session_t *session, application_mode_t app_mode) -{ - switch_channel_t *channel; - pvt_t *pvt = NULL; - const char *tmp; - - /* Make sure we have a valid channel when starting the FAX application */ - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - if (!switch_channel_media_ready(channel)) { - switch_channel_answer(channel); - } - - /* Allocate our structs */ - pvt = switch_core_session_alloc(session, sizeof(pvt_t)); - pvt->session = session; - - pvt->app_mode = app_mode; - - pvt->tx_page_start = -1; - pvt->tx_page_end = -1; - - - switch(pvt->app_mode) { - - case FUNCTION_TX: - pvt->caller = 1; - break; - case FUNCTION_RX: - pvt->caller = 0; - break; - case FUNCTION_GW: - break; - } - - /* Retrieving our settings from the channel variables */ - - if ((tmp = switch_channel_get_variable(channel, "fax_use_ecm"))) { - pvt->use_ecm = switch_true(tmp); - } else { - pvt->use_ecm = globals.use_ecm; - } - - if ((tmp = switch_channel_get_variable(channel, "fax_disable_v17"))) { - pvt->disable_v17 = switch_true(tmp); - } else { - pvt->disable_v17 = globals.disable_v17; - } - - if ((tmp = switch_channel_get_variable(channel, "fax_verbose"))) { - pvt->verbose = switch_true(tmp); - } else { - pvt->verbose = globals.verbose; - } - - if ((tmp = switch_channel_get_variable(channel, "fax_force_caller"))) { - if (switch_true(tmp)) { - pvt->caller = 1; - } else { - pvt->caller = 0; - } - } - - if ((tmp = switch_channel_get_variable(channel, "fax_ident"))) { - pvt->ident = switch_core_session_strdup(session, tmp); - } else { - pvt->ident = switch_core_session_strdup(session, globals.ident); - } - - if ((tmp = switch_channel_get_variable(channel, "fax_header"))) { - pvt->header = switch_core_session_strdup(session, tmp); - } else { - pvt->header = switch_core_session_strdup(session, globals.header); - } - - if (pvt->app_mode == FUNCTION_TX) { - if ((tmp = switch_channel_get_variable(channel, "fax_start_page"))) { - pvt->tx_page_start = atoi(tmp); - } - - if ((tmp = switch_channel_get_variable(channel, "fax_end_page"))) { - pvt->tx_page_end = atoi(tmp); - } - - if (pvt->tx_page_end < -1) { - pvt->tx_page_end = -1; - } - - if (pvt->tx_page_start < -1) { - pvt->tx_page_start = -1; - } - - if ((pvt->tx_page_end < pvt->tx_page_start) && (pvt->tx_page_end != -1)) { - pvt->tx_page_end = pvt->tx_page_start; - } - } - - return pvt; -} - -void process_fax(switch_core_session_t *session, const char *data, application_mode_t app_mode) -{ - pvt_t *pvt; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_codec_t read_codec = { 0 }; - switch_codec_t write_codec = { 0 }; - switch_frame_t *read_frame = { 0 }; - switch_frame_t write_frame = { 0 }; - switch_codec_implementation_t read_impl = { 0 }; - int16_t *buf = NULL; - - switch_core_session_get_read_impl(session, &read_impl); - - counter_increment(); - - - pvt = pvt_init(session, app_mode); - - - buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); - - if (!zstr(data)) { - pvt->filename = switch_core_session_strdup(session, data); - if (pvt->app_mode == FUNCTION_TX) { - if ((switch_file_exists(pvt->filename, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot send inexistant fax file [%s]\n", - switch_str_nil(pvt->filename)); - goto done; - } - } - } else { - if (pvt->app_mode == FUNCTION_TX) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Fax TX filename not set.\n"); - goto done; - } else if (pvt->app_mode == FUNCTION_RX) { - char *fname; - const char *prefix; - switch_time_t time; - - time = switch_time_now(); - - if (!(prefix = switch_channel_get_variable(channel, "fax_prefix"))) { - prefix = globals.prepend_string; - } - - fname = switch_mprintf("%s/%s-%ld-%ld.tif", globals.spool, prefix, globals.total_sessions, time); - if (fname) { - pvt->filename = switch_core_session_strdup(session, fname); - switch_safe_free(fname); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot automatically set fax RX destination file\n"); - goto done; - } - } else { - assert(0); /* UH ?? */ - } - } - - /* - *** Initialize the SpanDSP elements *** - - Note: we could analyze if a fax was already detected in previous stages - and if so, when T.38 will be supported, send a reinvite in T38_MODE, - bypassing AUDIO_MODE. - */ - - if ((spanfax_init(pvt, AUDIO_MODE) != SWITCH_STATUS_SUCCESS)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize Fax engine\n"); - return; - } - - /* - Note: Disable echocan on the channel, remember to call app "disable_ec" in the dialplan - before invoking fax applications - */ - - /* - Note: we are disabling the Jitterbuffer, here, before we answer. - If you have set it to something else and the channel is pre-answered, - it will have no effect. Make sure that if you want more reliable - faxes, it is disabled. - */ - switch_channel_set_variable(channel, "jitterbuffer_msec", "0"); - - - /* We store the original channel codec before switching both - * legs of the calls to a linear 16 bit codec that is the one - * used internally by spandsp and FS will do the transcoding - * from G.711 or any other original codec - */ - if (switch_core_codec_init(&read_codec, - "L16", - NULL, - read_impl.samples_per_second, - read_impl.microseconds_per_packet / 1000, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw read codec activation Success L16 %u\n", - read_codec.implementation->microseconds_per_packet); - switch_core_session_set_read_codec(session, &read_codec); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Raw read codec activation Failed L16\n"); - goto done; - } - - if (switch_core_codec_init(&write_codec, - "L16", - NULL, - read_impl.samples_per_second, - read_impl.microseconds_per_packet / 1000, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw write codec activation Success L16\n"); - write_frame.codec = &write_codec; - write_frame.data = buf; - write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Raw write codec activation Failed L16\n"); - goto done; - } - - switch_ivr_sleep(session, 250, SWITCH_TRUE, NULL); - - - /* If you have the means, I highly recommend picking one up. ...*/ - request_t38(pvt); - - - while (switch_channel_ready(channel)) { - int tx = 0; - switch_status_t status; - - /* - 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. - The only thing we need, then, in this loop, is: - - read a frame without blocking - - eventually feed that frame in spandsp, - - call t38_terminal_send_timeout(), sleep for a while - - The T.38 stuff can be placed here (and the audio stuff can be skipped) - */ - - /* read new audio frame from the channel */ - status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - - if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) { - /* Our duty is over */ - goto done; - } - - switch (pvt->t38_mode) { - case T38_MODE_REQUESTED: - { - if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - switch_core_session_message_t msg = { 0 }; - pvt->t38_mode = T38_MODE_NEGOTIATED; - spanfax_init(pvt, T38_MODE); - configure_t38(pvt); - - /* This will change the rtp stack to udptl mode */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; - switch_core_session_receive_message(session, &msg); - } - continue; - } - break; - case T38_MODE_UNKNOWN: - { - if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - if (negotiate_t38(pvt) == T38_MODE_NEGOTIATED) { - /* is is safe to call this again, it was already called above in AUDIO_MODE */ - /* but this is the only way to set up the t38 stuff */ - spanfax_init(pvt, T38_MODE); - continue; - } - } - } - break; - case T38_MODE_NEGOTIATED: - { - /* do what we need to do when we are in t38 mode */ - if (switch_test_flag(read_frame, SFF_CNG)) { - /* dunno what to do, most likely you will not get too many of these since we turn off the timer in udptl mode */ - continue; - } - - if (switch_test_flag(read_frame, SFF_UDPTL_PACKET)) { - /* now we know we can cast frame->packet to a udptl structure */ - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "READ %d udptl bytes\n", read_frame->packetlen); - - udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); - - - } - } - continue; - default: - break; - } - - /* Skip CNG frames (auto-generated by FreeSWITCH, usually) */ - if (switch_test_flag(read_frame, SFF_CNG)) { - /* We have no real signal data for the FAX software, but we have a space in time if we have a CNG indication. - Do a fill-in operation in the FAX machine, to keep things rolling along. */ - if (fax_rx_fillin(pvt->fax_state, read_frame->samples)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx_fillin reported an error\n"); - goto done; - } - } else { - /* Pass the new incoming audio frame to the fax_rx function */ - if (fax_rx(pvt->fax_state, (int16_t *) read_frame->data, read_frame->samples)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx reported an error\n"); - goto done; - } - } - - if ((tx = fax_tx(pvt->fax_state, buf, write_codec.implementation->samples_per_packet)) < 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_tx reported an error\n"); - goto done; - } - - if (!tx) { - /* switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No audio samples to send\n"); */ - continue; - } else { - /* Set our write_frame data */ - write_frame.datalen = tx * sizeof(int16_t); - write_frame.samples = tx; - } - - if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - goto done; - } - - } - - done: - /* Destroy the SpanDSP structures */ - spanfax_destroy(pvt); - - /* restore the original codecs over the channel */ - - switch_core_session_set_read_codec(session, NULL); - - if (switch_core_codec_ready(&read_codec)) { - switch_core_codec_destroy(&read_codec); - } - - if (switch_core_codec_ready(&write_codec)) { - switch_core_codec_destroy(&write_codec); - } -} - -/* ************************************************************************** - CONFIGURATION - ************************************************************************* */ - -void load_configuration(switch_bool_t reload) -{ - switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL; - - if ((xml = switch_xml_open_cfg("fax.conf", &cfg, NULL))) { - if ((x_lists = switch_xml_child(cfg, "settings"))) { - for (x_list = switch_xml_child(x_lists, "param"); x_list; x_list = x_list->next) { - const char *name = switch_xml_attr(x_list, "name"); - const char *value = switch_xml_attr(x_list, "value"); - - if (zstr(name)) { - continue; - } - - if (zstr(value)) { - continue; - } - - if (!strcmp(name, "use-ecm")) { - if (switch_true(value)) - globals.use_ecm = 1; - else - globals.use_ecm = 0; - } else if (!strcmp(name, "verbose")) { - if (switch_true(value)) - globals.verbose = 1; - else - globals.verbose = 0; - } else if (!strcmp(name, "disable-v17")) { - if (switch_true(value)) - globals.disable_v17 = 1; - else - globals.disable_v17 = 0; - } else if (!strcmp(name, "enable-t38")) { - if (switch_true(value)) { - globals.enable_t38= 1; - } else { - globals.enable_t38 = 0; - } - } else if (!strcmp(name, "enable-t38-request")) { - if (switch_true(value)) { - globals.enable_t38_request = 1; - } else { - globals.enable_t38_request = 0; - } - } else if (!strcmp(name, "ident")) { - strncpy(globals.ident, value, sizeof(globals.ident) - 1); - } else if (!strcmp(name, "header")) { - strncpy(globals.header, value, sizeof(globals.header) - 1); - } else if (!strcmp(name, "spool-dir")) { - globals.spool = switch_core_strdup(globals.pool, value); - } else if (!strcmp(name, "file-prefix")) { - globals.prepend_string = switch_core_strdup(globals.pool, value); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown parameter %s\n", name); - } - - } - } - - switch_xml_free(xml); - } -} - -static void event_handler(switch_event_t *event) -{ - load_configuration(1); -} - - - - - - -typedef struct { - switch_core_session_t *session; - dtmf_rx_state_t *dtmf_detect; -} switch_inband_dtmf_t; - -static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) -{ - switch_inband_dtmf_t *pvt = (switch_inband_dtmf_t *) user_data; - switch_frame_t *frame = NULL; - char digit_str[80]; - switch_channel_t *channel = switch_core_session_get_channel(pvt->session); - - switch (type) { - case SWITCH_ABC_TYPE_INIT: - pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL); - break; - case SWITCH_ABC_TYPE_CLOSE: - if (pvt->dtmf_detect) { - dtmf_rx_free(pvt->dtmf_detect); - } - break; - case SWITCH_ABC_TYPE_READ_REPLACE: - if ((frame = switch_core_media_bug_get_read_replace_frame(bug))) { - dtmf_rx(pvt->dtmf_detect, frame->data, frame->samples); - dtmf_rx_get(pvt->dtmf_detect, digit_str, sizeof(digit_str)); - if (digit_str[0]) { - char *p = digit_str; - while (p && *p) { - switch_dtmf_t dtmf = {0}; - dtmf.digit = *p; - dtmf.duration = switch_core_default_dtmf_duration(0); - switch_channel_queue_dtmf(channel, &dtmf); - p++; - } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", - digit_str); - } - switch_core_media_bug_set_read_replace_frame(bug, frame); - } - break; - case SWITCH_ABC_TYPE_WRITE: - default: - break; - } - - return SWITCH_TRUE; -} - -switch_status_t spandsp_stop_inband_dtmf_session(switch_core_session_t *session) -{ - switch_media_bug_t *bug; - switch_channel_t *channel = switch_core_session_get_channel(session); - - if ((bug = switch_channel_get_private(channel, "dtmf"))) { - switch_channel_set_private(channel, "dtmf", NULL); - switch_core_media_bug_remove(session, &bug); - return SWITCH_STATUS_SUCCESS; - } - return SWITCH_STATUS_FALSE; -} - -switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_media_bug_t *bug; - switch_status_t status; - switch_inband_dtmf_t *pvt; - switch_codec_implementation_t read_impl = { 0 }; - - switch_core_session_get_read_impl(session, &read_impl); - - if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) { - return SWITCH_STATUS_MEMERR; - } - - - pvt->session = session; - - - if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_FALSE; - } - - if ((status = switch_core_media_bug_add(session, "spandsp_dtmf_detect", NULL, - inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) { - return status; - } - - switch_channel_set_private(channel, "dtmf", bug); - - return SWITCH_STATUS_SUCCESS; -} - -/* ************************************************************************** - FREESWITCH MODULE DEFINITIONS - ************************************************************************* */ - -#define SPANFAX_RX_USAGE "" -#define SPANFAX_TX_USAGE "" - -SWITCH_MODULE_LOAD_FUNCTION(mod_fax_init); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fax_shutdown); -SWITCH_MODULE_DEFINITION(mod_fax, mod_fax_init, mod_fax_shutdown, NULL); - -static switch_event_node_t *NODE = NULL; - -SWITCH_STANDARD_APP(spanfax_tx_function) -{ - process_fax(session, data, FUNCTION_TX); -} - -SWITCH_STANDARD_APP(spanfax_rx_function) -{ - process_fax(session, data, FUNCTION_RX); -} - - -SWITCH_STANDARD_APP(dtmf_session_function) -{ - spandsp_inband_dtmf_session(session); -} - -SWITCH_STANDARD_APP(stop_dtmf_session_function) -{ - spandsp_stop_inband_dtmf_session(session); -} - -static const switch_state_handler_table_t t38_gateway_state_handlers; - -static switch_status_t t38_gateway_on_soft_execute(switch_core_session_t *session) -{ - switch_core_session_t *other_session; - - switch_channel_t *other_channel, *channel = switch_core_session_get_channel(session); - pvt_t *pvt; - const char *peer_uuid = switch_channel_get_variable(channel, "t38_peer"); - switch_core_session_message_t msg = { 0 }; - switch_status_t status; - switch_frame_t *read_frame = { 0 }; - - if (!(other_session = switch_core_session_locate(peer_uuid))) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot locate channel with uuid %s", - switch_channel_get_name(channel), peer_uuid); - goto end; - } - - other_channel = switch_core_session_get_channel(other_session); - - pvt = pvt_init(session, FUNCTION_GW); - request_t38(pvt); - - msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); - - while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - - if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) { - /* Our duty is over */ - goto end_unlock; - } - - if (switch_test_flag(read_frame, SFF_CNG)) { - continue; - } - - if (switch_core_session_write_frame(other_session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - goto end_unlock; - } - } - - if (!(switch_channel_ready(channel) && switch_channel_up(other_channel))) { - goto end_unlock; - } - - if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel)); - goto end_unlock; - } - - if (pvt->t38_mode == T38_MODE_REQUESTED) { - spanfax_init(pvt, T38_GATEWAY_MODE); - configure_t38(pvt); - pvt->t38_mode = T38_MODE_NEGOTIATED; - } else { - if (negotiate_t38(pvt) != T38_MODE_NEGOTIATED) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end_unlock; - } - - spanfax_init(pvt, T38_GATEWAY_MODE); - } - - /* This will change the rtp stack to udptl mode */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; - switch_core_session_receive_message(session, &msg); - - - /* wake up the audio side */ - switch_channel_set_private(channel, "_t38_pvt", pvt); - switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38); - - - while (switch_channel_ready(channel) && switch_channel_up(other_channel)) { - - status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - - if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) { - /* Our duty is over */ - goto end_unlock; - } - - if (switch_test_flag(read_frame, SFF_CNG)) { - continue; - } - - if (switch_test_flag(read_frame, SFF_UDPTL_PACKET)) { - udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); - } - } - - end_unlock: - - - msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); - - switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING); - switch_core_session_rwunlock(other_session); - - end: - - switch_channel_clear_state_handler(channel, &t38_gateway_state_handlers); - switch_channel_set_variable(channel, "t38_peer", NULL); - - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *session) -{ - switch_core_session_t *other_session; - switch_channel_t *other_channel, *channel = switch_core_session_get_channel(session); - const char *peer_uuid = switch_channel_get_variable(channel, "t38_peer"); - pvt_t *pvt = NULL; - switch_codec_t read_codec = { 0 }; - switch_codec_t write_codec = { 0 }; - switch_frame_t *read_frame = { 0 }; - switch_frame_t write_frame = { 0 }; - switch_codec_implementation_t read_impl = { 0 }; - int16_t *buf = NULL; - switch_status_t status; - switch_size_t tx; - const char *t38_trace = switch_channel_get_variable(channel, "t38_trace"); - char *trace_read, *trace_write; - zap_socket_t read_fd = FAX_INVALID_SOCKET, write_fd = FAX_INVALID_SOCKET; - switch_core_session_message_t msg = { 0 }; - switch_event_t *event; - - switch_core_session_get_read_impl(session, &read_impl); - - buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); - - if (!(other_session = switch_core_session_locate(peer_uuid))) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end; - } - - other_channel = switch_core_session_get_channel(other_session); - - msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); - - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(channel, event); - switch_event_fire(&event); - } - - while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - - if (!SWITCH_READ_ACCEPTABLE(status)) { - /* Our duty is over */ - goto end_unlock; - } - - if (switch_test_flag(read_frame, SFF_CNG)) { - continue; - } - - if (switch_core_session_write_frame(other_session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - goto end_unlock; - } - } - - if (!(switch_channel_ready(channel) && switch_channel_up(other_channel))) { - goto end_unlock; - } - - if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end_unlock; - } - - if (!(pvt = switch_channel_get_private(other_channel, "_t38_pvt"))) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end_unlock; - } - - if (switch_core_codec_init(&read_codec, - "L16", - NULL, - read_impl.samples_per_second, - read_impl.microseconds_per_packet / 1000, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw read codec activation Success L16 %u\n", - read_codec.implementation->microseconds_per_packet); - switch_core_session_set_read_codec(session, &read_codec); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Raw read codec activation Failed L16\n"); - goto end_unlock; - } - - if (switch_core_codec_init(&write_codec, - "L16", - NULL, - read_impl.samples_per_second, - read_impl.microseconds_per_packet / 1000, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw write codec activation Success L16\n"); - write_frame.codec = &write_codec; - write_frame.data = buf; - write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Raw write codec activation Failed L16\n"); - goto end_unlock; - } - - switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL); - - if (switch_true(t38_trace)) { - trace_read = switch_core_session_sprintf(session, "%s%s%s_read.raw", SWITCH_GLOBAL_dirs.temp_dir, - SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing inbound audio to %s\n", trace_read); - switch_channel_set_variable(channel, "t38_trace_read", trace_read); - - trace_write = switch_core_session_sprintf(session, "%s%s%s_write.raw", SWITCH_GLOBAL_dirs.temp_dir, - SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing outbound audio to %s\n", trace_write); - switch_channel_set_variable(channel, "t38_trace_read", trace_write); - - - if ((write_fd = open(trace_read, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) != FAX_INVALID_SOCKET) { - if ((read_fd = open(trace_write, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) == FAX_INVALID_SOCKET) { - close(write_fd); - write_fd = FAX_INVALID_SOCKET; - } - } - } - - while (switch_channel_ready(channel) && switch_channel_up(other_channel)) { - status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - - if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) { - /* Our duty is over */ - goto end_unlock; - } - - - /* Skip CNG frames (auto-generated by FreeSWITCH, usually) */ - if (!switch_test_flag(read_frame, SFF_CNG)) { - - if (read_fd != FAX_INVALID_SOCKET) { - int w = write(read_fd, read_frame->data, read_frame->datalen); - if (w <= 0) { - close(read_fd); - read_fd = FAX_INVALID_SOCKET; - } - } - if (t38_gateway_rx(pvt->t38_gateway_state, (int16_t *) read_frame->data, read_frame->samples)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx reported an error\n"); - goto end_unlock; - } - } - - if ((tx = t38_gateway_tx(pvt->t38_gateway_state, buf, write_codec.implementation->samples_per_packet)) < 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_tx reported an error\n"); - goto end_unlock; - } - - if (!tx) { - /* switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No audio samples to send\n"); */ - continue; - } else { - /* Set our write_frame data */ - write_frame.datalen = tx * sizeof(int16_t); - write_frame.samples = tx; - } - - if (write_fd != FAX_INVALID_SOCKET) { - int w = write(write_fd, write_frame.data, write_frame.datalen); - if (w <= 0) { - close(write_fd); - write_fd = FAX_INVALID_SOCKET; - } - } - - if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - goto end_unlock; - } - } - - end_unlock: - - msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); - - - if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(channel, event); - switch_event_fire(&event); - } - - if (read_fd != FAX_INVALID_SOCKET) { - close(read_fd); - read_fd = FAX_INVALID_SOCKET; - } - - if (write_fd != FAX_INVALID_SOCKET) { - close(write_fd); - write_fd = FAX_INVALID_SOCKET; - } - - - switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING); - switch_core_session_rwunlock(other_session); - - switch_core_session_set_read_codec(session, NULL); - - if (switch_core_codec_ready(&read_codec)) { - switch_core_codec_destroy(&read_codec); - } - - if (switch_core_codec_ready(&write_codec)) { - switch_core_codec_destroy(&write_codec); - } - - - end: - - switch_channel_clear_state_handler(channel, &t38_gateway_state_handlers); - switch_channel_set_variable(channel, "t38_peer", NULL); - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t t38_gateway_on_reset(switch_core_session_t *session) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - - switch_channel_set_variable(channel, "rtp_autoflush_during_bridge", "false"); - - switch_channel_clear_flag(channel, CF_REDIRECT); - - if (switch_channel_test_app_flag(channel, CF_APP_TAGGED)) { - switch_channel_clear_app_flag(channel, CF_APP_TAGGED); - switch_channel_set_state(channel, CS_CONSUME_MEDIA); - } else { - switch_channel_set_state(channel, CS_SOFT_EXECUTE); - } - - return SWITCH_STATUS_SUCCESS; -} - -static const switch_state_handler_table_t t38_gateway_state_handlers = { - /*.on_init */ NULL, - /*.on_routing */ NULL, - /*.on_execute */ NULL, - /*.on_hangup */ NULL, - /*.on_exchange_media */ NULL, - /*.on_soft_execute */ t38_gateway_on_soft_execute, - /*.on_consume_media */ t38_gateway_on_consume_media, - /*.on_hibernate */ NULL, - /*.on_reset */ t38_gateway_on_reset, - /*.on_park */ NULL, - /*.on_reporting */ NULL, - /*.on_destroy */ NULL, - SSH_FLAG_STICKY -}; - -static switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app, const char *data) -{ - switch_channel_t *other_channel = NULL, *channel = switch_core_session_get_channel(session); - switch_core_session_t *other_session = NULL; - int peer = app && !strcasecmp(app, "peer"); - - if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { - other_channel = switch_core_session_get_channel(other_session); - - switch_channel_set_variable(channel, "t38_peer", switch_core_session_get_uuid(other_session)); - switch_channel_set_variable(other_channel, "t38_peer", switch_core_session_get_uuid(session)); - - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s starting gateway mode to %s\n", - switch_channel_get_name(peer ? channel : other_channel), - switch_channel_get_name(peer ? other_channel : channel)); - - - switch_channel_clear_state_handler(channel, NULL); - switch_channel_clear_state_handler(other_channel, NULL); - - switch_channel_add_state_handler(channel, &t38_gateway_state_handlers); - switch_channel_add_state_handler(other_channel, &t38_gateway_state_handlers); - - switch_channel_set_app_flag(peer ? channel : other_channel, CF_APP_TAGGED); - switch_channel_clear_app_flag(peer ? other_channel : channel, CF_APP_TAGGED); - - switch_channel_set_flag(channel, CF_REDIRECT); - switch_channel_set_state(channel, CS_RESET); - - switch_channel_set_flag(other_channel, CF_REDIRECT); - switch_channel_set_state(other_channel, CS_RESET); - - switch_core_session_rwunlock(other_session); - - } - - return SWITCH_FALSE; -} - - -SWITCH_STANDARD_APP(t38_gateway_function) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - time_t timeout = switch_epoch_time_now(NULL) + 20; - const char *var; - - if (zstr(data) || strcasecmp(data, "self")) { - data = "peer"; - } - - switch_channel_set_variable(channel, "t38_leg", data); - - if ((var = switch_channel_get_variable(channel, "t38_gateway_detect_timeout"))) { - long to = atol(var); - if (to > -1) { - timeout = (time_t) (switch_epoch_time_now(NULL) + to); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s invalid timeout value.\n", switch_channel_get_name(channel)); - } - } - - switch_ivr_tone_detect_session(session, "t38", "1100.0", "rw", timeout, 1, data, NULL, t38_gateway_start); -} - - -SWITCH_MODULE_LOAD_FUNCTION(mod_fax_init) -{ - switch_application_interface_t *app_interface; - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - - SWITCH_ADD_APP(app_interface, "t38_gateway", "Convert to T38 Gateway if tones are heard", "Convert to T38 Gateway if tones are heard", - t38_gateway_function, "", SAF_MEDIA_TAP); - - SWITCH_ADD_APP(app_interface, "rxfax", "FAX Receive Application", "FAX Receive Application", spanfax_rx_function, SPANFAX_RX_USAGE, - SAF_SUPPORT_NOMEDIA); - SWITCH_ADD_APP(app_interface, "txfax", "FAX Transmit Application", "FAX Transmit Application", spanfax_tx_function, SPANFAX_TX_USAGE, - SAF_SUPPORT_NOMEDIA); - - 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); - - memset(&globals, 0, sizeof(globals)); - memset(&t38_state_list, 0, sizeof(t38_state_list)); - switch_core_new_memory_pool(&globals.pool); - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); - switch_mutex_init(&t38_state_list.mutex, SWITCH_MUTEX_NESTED, globals.pool); - - globals.enable_t38 = 1; - globals.total_sessions = 0; - globals.verbose = 1; - globals.use_ecm = 1; - globals.disable_v17 = 0; - globals.prepend_string = switch_core_strdup(globals.pool, "fax"); - globals.spool = switch_core_strdup(globals.pool, "/tmp"); - strncpy(globals.ident, "SpanDSP Fax Ident", sizeof(globals.ident) - 1); - strncpy(globals.header, "SpanDSP Fax Header", sizeof(globals.header) - 1); - - load_configuration(0); - - if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our reloadxml handler!\n"); - /* Not such severe to prevent loading */ - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_fax loaded, using spandsp library version [%s]\n", SPANDSP_RELEASE_DATETIME_STRING); - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fax_shutdown) -{ - switch_memory_pool_t *pool = globals.pool; - - switch_event_unbind(&NODE); - - switch_core_destroy_memory_pool(&pool); - memset(&globals, 0, sizeof(globals)); - - return SWITCH_STATUS_UNLOAD; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:nil - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4: - */ diff --git a/src/mod/applications/mod_fax/udptl.c b/src/mod/applications/mod_fax/udptl.c deleted file mode 100644 index a2651513f0..0000000000 --- a/src/mod/applications/mod_fax/udptl.c +++ /dev/null @@ -1,563 +0,0 @@ -//#define UDPTL_DEBUG -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2009, Steve Underwood - * - * 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. - * - * Contributor(s): - * - * Steve Underwood - * - * udptl.c -- UDPTL handling for T.38 - * - */ - -#include -#include -#include -#include -#include - -#include "udptl.h" - -#define FALSE 0 -#define TRUE (!FALSE) - -static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue) -{ - if (*len >= limit) - return -1; - if ((buf[*len] & 0x80) == 0) { - *pvalue = buf[(*len)++]; - return 0; - } - if ((buf[*len] & 0x40) == 0) { - if (*len >= limit - 1) - return -1; - *pvalue = (buf[(*len)++] & 0x3F) << 8; - *pvalue |= buf[(*len)++]; - return 0; - } - *pvalue = (buf[(*len)++] & 0x3F) << 14; - /* Indicate we have a fragment */ - return 1; -} - -/*- End of function --------------------------------------------------------*/ - -static int decode_open_type(const uint8_t *buf, int limit, int *len, const uint8_t ** p_object, int *p_num_octets) -{ - int octet_cnt; - int octet_idx; - int stat; - int i; - const uint8_t **pbuf; - - for (octet_idx = 0, *p_num_octets = 0;; octet_idx += octet_cnt) { - if ((stat = decode_length(buf, limit, len, &octet_cnt)) < 0) - return -1; - if (octet_cnt > 0) { - *p_num_octets += octet_cnt; - - pbuf = &p_object[octet_idx]; - i = 0; - /* Make sure the buffer contains at least the number of bits requested */ - if ((*len + octet_cnt) > limit) - return -1; - - *pbuf = &buf[*len]; - *len += octet_cnt; - } - if (stat == 0) - break; - } - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -static int encode_length(uint8_t *buf, int *len, int value) -{ - int multiplier; - - if (value < 0x80) { - /* 1 octet */ - buf[(*len)++] = value; - return value; - } - if (value < 0x4000) { - /* 2 octets */ - /* Set the first bit of the first octet */ - buf[(*len)++] = ((0x8000 | value) >> 8) & 0xFF; - buf[(*len)++] = value & 0xFF; - return value; - } - /* Fragmentation */ - multiplier = (value < 0x10000) ? (value >> 14) : 4; - /* Set the first 2 bits of the octet */ - buf[(*len)++] = 0xC0 | multiplier; - return multiplier << 14; -} - -/*- End of function --------------------------------------------------------*/ - -static int encode_open_type(uint8_t *buf, int *len, const uint8_t *data, int num_octets) -{ - int enclen; - int octet_idx; - uint8_t zero_byte; - - /* If open type is of zero length, add a single zero byte (10.1) */ - if (num_octets == 0) { - zero_byte = 0; - data = &zero_byte; - num_octets = 1; - } - /* Encode the open type */ - for (octet_idx = 0;; num_octets -= enclen, octet_idx += enclen) { - if ((enclen = encode_length(buf, len, num_octets)) < 0) - return -1; - if (enclen > 0) { - memcpy(&buf[*len], &data[octet_idx], enclen); - *len += enclen; - } - if (enclen >= num_octets) - break; - } - - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len) -{ - int stat; - int stat2; - int i; - int j; - int k; - int l; - int m; - int x; - int limit; - int which; - int ptr; - int count; - int total_count; - int seq_no; - const uint8_t *msg; - const uint8_t *data; - int msg_len; - int repaired[16]; - const uint8_t *bufs[16]; - int lengths[16]; - int span; - int entries; - - ptr = 0; - /* Decode seq_number */ - if (ptr + 2 > len) - return -1; - seq_no = (buf[0] << 8) | buf[1]; - ptr += 2; - /* Break out the primary packet */ - if ((stat = decode_open_type(buf, len, &ptr, &msg, &msg_len)) != 0) - return -1; - /* Decode error_recovery */ - if (ptr + 1 > len) - return -1; - /* Our buffers cannot tolerate overlength packets */ - if (msg_len > LOCAL_FAX_MAX_DATAGRAM) - return -1; - /* Update any missed slots in the buffer */ - for (i = s->rx_seq_no; seq_no > i; i++) { - x = i & UDPTL_BUF_MASK; - s->rx[x].buf_len = -1; - s->rx[x].fec_len[0] = 0; - s->rx[x].fec_span = 0; - s->rx[x].fec_entries = 0; - } - /* Save the new packet. Pure redundancy mode won't use this, but some systems will switch - into FEC mode after sending some redundant packets. */ - x = seq_no & UDPTL_BUF_MASK; - memcpy(s->rx[x].buf, msg, msg_len); - s->rx[x].buf_len = msg_len; - s->rx[x].fec_len[0] = 0; - s->rx[x].fec_span = 0; - s->rx[x].fec_entries = 0; - if ((buf[ptr++] & 0x80) == 0) { - /* Secondary packet mode for error recovery */ - /* We might have the packet we want, but we need to check through - the redundant stuff, and verify the integrity of the UDPTL. - This greatly reduces our chances of accepting garbage. */ - total_count = 0; - do { - if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0) - return -1; - for (i = 0; i < count; i++) { - if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0) - return -1; - } - total_count += count; - } - while (stat2 > 0); - /* We should now be exactly at the end of the packet. If not, this is a fault. */ - if (ptr != len) - return -1; - if (seq_no > s->rx_seq_no) { - /* We received a later packet than we expected, so we need to check if we can fill in the gap from the - secondary packets. */ - /* Step through in reverse order, so we go oldest to newest */ - for (i = total_count; i > 0; i--) { - if (seq_no - i >= s->rx_seq_no) { - /* This one wasn't seen before */ - /* Decode the secondary packet */ -#if defined(UDPTL_DEBUG) - fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]); -#endif - /* Save the new packet. Redundancy mode won't use this, but some systems will switch into - FEC mode after sending some redundant packets, and this may then be important. */ - x = (seq_no - i) & UDPTL_BUF_MASK; - memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]); - s->rx[x].buf_len = lengths[i - 1]; - s->rx[x].fec_len[0] = 0; - s->rx[x].fec_span = 0; - s->rx[x].fec_entries = 0; - if (s->rx_packet_handler(s->user_data, bufs[i - 1], lengths[i - 1], seq_no - i) < 0) - fprintf(stderr, "Bad IFP\n"); - } - } - } - } else { - /* FEC mode for error recovery */ - - /* Decode the FEC packets */ - /* The span is defined as an unconstrained integer, but will never be more - than a small value. */ - if (ptr + 2 > len) - return -1; - if (buf[ptr++] != 1) - return -1; - span = buf[ptr++]; - - x = seq_no & UDPTL_BUF_MASK; - - s->rx[x].fec_span = span; - - memset(repaired, 0, sizeof(repaired)); - repaired[x] = TRUE; - - /* The number of entries is defined as a length, but will only ever be a small - value. Treat it as such. */ - if (ptr + 1 > len) - return -1; - entries = buf[ptr++]; - s->rx[x].fec_entries = entries; - - /* Decode the elements */ - for (i = 0; i < entries; i++) { - if ((stat = decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i])) != 0) - return -1; - if (s->rx[x].fec_len[i] > LOCAL_FAX_MAX_DATAGRAM) - return -1; - - /* Save the new FEC data */ - memcpy(s->rx[x].fec[i], data, s->rx[x].fec_len[i]); -#if 0 - fprintf(stderr, "FEC: "); - for (j = 0; j < s->rx[x].fec_len[i]; j++) - fprintf(stderr, "%02X ", data[j]); - fprintf(stderr, "\n"); -#endif - } - /* We should now be exactly at the end of the packet. If not, this is a fault. */ - if (ptr != len) - return -1; - /* See if we can reconstruct anything which is missing */ - /* TODO: this does not comprehensively hunt back and repair everything that is possible */ - for (l = x; l != ((x - (16 - span * entries)) & UDPTL_BUF_MASK); l = (l - 1) & UDPTL_BUF_MASK) { - if (s->rx[l].fec_len[0] <= 0) - continue; - for (m = 0; m < s->rx[l].fec_entries; m++) { - limit = (l + m) & UDPTL_BUF_MASK; - for (which = -1, k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; - k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK) { - if (s->rx[k].buf_len <= 0) - which = (which == -1) ? k : -2; - } - if (which >= 0) { - /* Repairable */ - for (j = 0; j < s->rx[l].fec_len[m]; j++) { - s->rx[which].buf[j] = s->rx[l].fec[m][j]; - for (k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; - k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK) - s->rx[which].buf[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0; - } - s->rx[which].buf_len = s->rx[l].fec_len[m]; - repaired[which] = TRUE; - } - } - } - /* Now play any new packets forwards in time */ - for (l = (x + 1) & UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) & UDPTL_BUF_MASK, j++) { - if (repaired[l]) { -#if defined(UDPTL_DEBUG) - fprintf(stderr, "Fixed packet %d, len %d\n", j, l); -#endif - if (s->rx_packet_handler(s->user_data, s->rx[l].buf, s->rx[l].buf_len, j) < 0) - fprintf(stderr, "Bad IFP\n"); - } - } - } - /* If packets are received out of sequence, we may have already processed this packet from the error - recovery information in a packet already received. */ - if (seq_no >= s->rx_seq_no) { - /* Decode the primary packet */ -#if defined(UDPTL_DEBUG) - fprintf(stderr, "Primary packet %d, len %d\n", seq_no, msg_len); -#endif - if (s->rx_packet_handler(s->user_data, msg, msg_len, seq_no) < 0) - fprintf(stderr, "Bad IFP\n"); - } - - s->rx_seq_no = (seq_no + 1) & 0xFFFF; - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len) -{ - uint8_t fec[LOCAL_FAX_MAX_DATAGRAM]; - int i; - int j; - int seq; - int entry; - int entries; - int span; - int m; - int len; - int limit; - int high_tide; - - /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their - maximum length. */ - if (msg_len < 1 || msg_len > LOCAL_FAX_MAX_DATAGRAM) - return -1; - seq = s->tx_seq_no & 0xFFFF; - - /* Map the sequence number to an entry in the circular buffer */ - entry = seq & UDPTL_BUF_MASK; - - /* We save the message in a circular buffer, for generating FEC or - redundancy sets later on. */ - s->tx[entry].buf_len = msg_len; - memcpy(s->tx[entry].buf, msg, msg_len); - - /* Build the UDPTL packet */ - - len = 0; - /* Encode the sequence number */ - buf[len++] = (seq >> 8) & 0xFF; - buf[len++] = seq & 0xFF; - - /* Encode the primary packet */ - if (encode_open_type(buf, &len, msg, msg_len) < 0) - return -1; - - /* Encode the appropriate type of error recovery information */ - switch (s->error_correction_scheme) { - case UDPTL_ERROR_CORRECTION_NONE: - /* Encode the error recovery type */ - buf[len++] = 0x00; - /* The number of entries will always be zero, so it is pointless allowing - for the fragmented case here. */ - if (encode_length(buf, &len, 0) < 0) - return -1; - break; - case UDPTL_ERROR_CORRECTION_REDUNDANCY: - /* Encode the error recovery type */ - buf[len++] = 0x00; - if (s->tx_seq_no > s->error_correction_entries) - entries = s->error_correction_entries; - else - entries = s->tx_seq_no; - /* The number of entries will always be small, so it is pointless allowing - for the fragmented case here. */ - if (encode_length(buf, &len, entries) < 0) - return -1; - /* Encode the elements */ - for (i = 0; i < entries; i++) { - j = (entry - i - 1) & UDPTL_BUF_MASK; - if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0) - return -1; - } - break; - case UDPTL_ERROR_CORRECTION_FEC: - span = s->error_correction_span; - entries = s->error_correction_entries; - if (seq < s->error_correction_span * s->error_correction_entries) { - /* In the initial stages, wind up the FEC smoothly */ - entries = seq / s->error_correction_span; - if (seq < s->error_correction_span) - span = 0; - } - /* Encode the error recovery type */ - buf[len++] = 0x80; - /* Span is defined as an inconstrained integer, which it dumb. It will only - ever be a small value. Treat it as such. */ - buf[len++] = 1; - buf[len++] = span; - /* The number of entries is defined as a length, but will only ever be a small - value. Treat it as such. */ - buf[len++] = entries; - for (m = 0; m < entries; m++) { - /* Make an XOR'ed entry the maximum length */ - limit = (entry + m) & UDPTL_BUF_MASK; - high_tide = 0; - for (i = (limit - span * entries) & UDPTL_BUF_MASK; i != limit; i = (i + entries) & UDPTL_BUF_MASK) { - if (high_tide < s->tx[i].buf_len) { - for (j = 0; j < high_tide; j++) - fec[j] ^= s->tx[i].buf[j]; - for (; j < s->tx[i].buf_len; j++) - fec[j] = s->tx[i].buf[j]; - high_tide = s->tx[i].buf_len; - } else { - for (j = 0; j < s->tx[i].buf_len; j++) - fec[j] ^= s->tx[i].buf[j]; - } - } - if (encode_open_type(buf, &len, fec, high_tide) < 0) - return -1; - } - break; - } - - if (s->verbose) - fprintf(stderr, "\n"); - s->tx_seq_no++; - return len; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_set_error_correction(udptl_state_t *s, int ec_scheme, int span, int entries) -{ - switch (ec_scheme) { - case UDPTL_ERROR_CORRECTION_FEC: - case UDPTL_ERROR_CORRECTION_REDUNDANCY: - case UDPTL_ERROR_CORRECTION_NONE: - s->error_correction_scheme = ec_scheme; - break; - case -1: - /* Just don't change the scheme */ - break; - default: - return -1; - } - if (span >= 0) - s->error_correction_span = span; - if (entries >= 0) - s->error_correction_entries = entries; - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_get_error_correction(udptl_state_t *s, int *ec_scheme, int *span, int *entries) -{ - if (ec_scheme) - *ec_scheme = s->error_correction_scheme; - if (span) - *span = s->error_correction_span; - if (entries) - *entries = s->error_correction_entries; - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram) -{ - s->local_max_datagram_size = max_datagram; - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_get_local_max_datagram(udptl_state_t *s) -{ - return s->local_max_datagram_size; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram) -{ - s->far_max_datagram_size = max_datagram; - return 0; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_get_far_max_datagram(udptl_state_t *s) -{ - return s->far_max_datagram_size; -} - -/*- End of function --------------------------------------------------------*/ - -udptl_state_t *udptl_init(udptl_state_t *s, int ec_scheme, int span, int entries, udptl_rx_packet_handler_t rx_packet_handler, void *user_data) -{ - int i; - - if (rx_packet_handler == NULL) - return NULL; - - if (s == NULL) { - if ((s = (udptl_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; - } - memset(s, 0, sizeof(*s)); - - s->error_correction_scheme = ec_scheme; - s->error_correction_span = span; - s->error_correction_entries = entries; - - s->far_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM; - s->local_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM; - - memset(&s->rx, 0, sizeof(s->rx)); - memset(&s->tx, 0, sizeof(s->tx)); - for (i = 0; i <= UDPTL_BUF_MASK; i++) { - s->rx[i].buf_len = -1; - s->tx[i].buf_len = -1; - } - - s->rx_packet_handler = rx_packet_handler; - s->user_data = user_data; - - return s; -} - -/*- End of function --------------------------------------------------------*/ - -int udptl_release(udptl_state_t *s) -{ - return 0; -} - -/*- End of function --------------------------------------------------------*/ -/*- End of file ------------------------------------------------------------*/ diff --git a/src/mod/applications/mod_fax/udptl.h b/src/mod/applications/mod_fax/udptl.h deleted file mode 100644 index 39740353d1..0000000000 --- a/src/mod/applications/mod_fax/udptl.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2009, Steve Underwood - * - * 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. - * - * Contributor(s): - * - * Steve Underwood - * - * udptl.h -- UDPTL handling for T.38 - * - */ - -#if !defined(FREESWITCH_UDPTL_H) -#define FREESWITCH_UDPTL_H - -#define LOCAL_FAX_MAX_DATAGRAM 400 -#define LOCAL_FAX_MAX_FEC_PACKETS 5 - -#define UDPTL_BUF_MASK 15 - -typedef int (udptl_rx_packet_handler_t) (void *user_data, const uint8_t msg[], int len, int seq_no); - -typedef struct { - int buf_len; - uint8_t buf[LOCAL_FAX_MAX_DATAGRAM]; -} udptl_fec_tx_buffer_t; - -typedef struct { - int buf_len; - uint8_t buf[LOCAL_FAX_MAX_DATAGRAM]; - int fec_len[LOCAL_FAX_MAX_FEC_PACKETS]; - uint8_t fec[LOCAL_FAX_MAX_FEC_PACKETS][LOCAL_FAX_MAX_DATAGRAM]; - int fec_span; - int fec_entries; -} udptl_fec_rx_buffer_t; - -struct udptl_state_s { - udptl_rx_packet_handler_t *rx_packet_handler; - void *user_data; - - /*! This option indicates the error correction scheme used in transmitted UDPTL - packets. */ - int error_correction_scheme; - - /*! This option indicates the number of error correction entries transmitted in - UDPTL packets. */ - int error_correction_entries; - - /*! This option indicates the span of the error correction entries in transmitted - UDPTL packets (FEC only). */ - int error_correction_span; - - /*! This option indicates the maximum size of a datagram that can be accepted by - the remote device. */ - int far_max_datagram_size; - - /*! This option indicates the maximum size of a datagram that we are prepared to - accept. */ - int local_max_datagram_size; - - int verbose; - - int tx_seq_no; - int rx_seq_no; - int rx_expected_seq_no; - - udptl_fec_tx_buffer_t tx[UDPTL_BUF_MASK + 1]; - udptl_fec_rx_buffer_t rx[UDPTL_BUF_MASK + 1]; -}; - -enum { - UDPTL_ERROR_CORRECTION_NONE, - UDPTL_ERROR_CORRECTION_FEC, - UDPTL_ERROR_CORRECTION_REDUNDANCY -}; - -typedef struct udptl_state_s udptl_state_t; - -#if defined(__cplusplus) -extern "C" { -#endif - -/*! \brief Process an arriving UDPTL packet. - \param s The UDPTL context. - \param buf The UDPTL packet buffer. - \param len The length of the packet. - \return 0 for OK. */ - int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len); - -/*! \brief Construct a UDPTL packet, ready for transmission. - \param s The UDPTL context. - \param buf The UDPTL packet buffer. - \param msg The primary packet. - \param len The length of the primary packet. - \return The length of the constructed UDPTL packet. */ - int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len); - -/*! \brief Change the error correction settings of a UDPTL context. - \param s The UDPTL context. - \param ec_scheme One of the optional error correction schemes. - \param span The packet span over which error correction should be applied. - \param entries The number of error correction entries to include in packets. - \return 0 for OK. */ - int udptl_set_error_correction(udptl_state_t *s, int ec_scheme, int span, int entries); - -/*! \brief Check the error correction settings of a UDPTL context. - \param s The UDPTL context. - \param ec_scheme One of the optional error correction schemes. - \param span The packet span over which error correction is being applied. - \param entries The number of error correction being included in packets. - \return 0 for OK. */ - int udptl_get_error_correction(udptl_state_t *s, int *ec_scheme, int *span, int *entries); - - int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram); - - int udptl_get_local_max_datagram(udptl_state_t *s); - - int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram); - - int udptl_get_far_max_datagram(udptl_state_t *s); - -/*! \brief Initialise a UDPTL context. - \param s The UDPTL context. - \param ec_scheme One of the optional error correction schemes. - \param span The packet span over which error correction should be applied. - \param entries The number of error correction entries to include in packets. - \param rx_packet_handler The callback function, used to report arriving IFP packets. - \param user_data An opaque pointer supplied to rx_packet_handler. - \return A pointer to the UDPTL context, or NULL if there was a problem. */ - udptl_state_t *udptl_init(udptl_state_t *s, int ec_scheme, int span, int entries, udptl_rx_packet_handler_t rx_packet_handler, void *user_data); - -/*! \brief Release a UDPTL context. - \param s The UDPTL context. - \return 0 for OK. */ - int udptl_release(udptl_state_t *s); - -#if defined(__cplusplus) -} -#endif -#endif -/*- End of file ------------------------------------------------------------*/ diff --git a/src/mod/applications/mod_fsk/fsk_callerid.h b/src/mod/applications/mod_fsk/fsk_callerid.h index 9018201ce5..59f6cc5e52 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 1c09365175..01160f6f7f 100644 --- a/src/mod/applications/mod_fsv/mod_fsv.c +++ b/src/mod/applications/mod_fsv/mod_fsv.c @@ -24,10 +24,13 @@ * Contributor(s): * * Anthony Minessale II + * Seven Du * * mod_fsv -- FS Video File Format * + * */ + #include @@ -273,6 +276,11 @@ SWITCH_STANDARD_APP(record_fsv_function) } } + if (fd > -1) { + close(fd); + } + + switch_core_session_set_read_codec(session, NULL); switch_core_codec_destroy(&codec); @@ -406,6 +414,8 @@ SWITCH_STANDARD_APP(play_fsv_function) if (switch_channel_test_flag(channel, CF_VIDEO)) { switch_byte_t *data = (switch_byte_t *) vid_frame.packet; + vid_frame.m = hdr->m; + vid_frame.timestamp = ts; vid_frame.data = data + 12; vid_frame.datalen = vid_frame.packetlen - 12; switch_core_session_write_video_frame(session, &vid_frame, SWITCH_IO_FLAG_NONE, 0); @@ -482,13 +492,279 @@ SWITCH_STANDARD_APP(play_fsv_function) } } +struct fsv_file_context { + switch_file_t *fd; + char *path; + switch_mutex_t *mutex; +}; + +typedef struct fsv_file_context fsv_file_context; + +static switch_status_t fsv_file_open(switch_file_handle_t *handle, const char *path) +{ + fsv_file_context *context; + char *ext; + unsigned int flags = 0; + + if ((ext = strrchr(path, '.')) == 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n"); + return SWITCH_STATUS_GENERR; + } + ext++; + + if ((context = switch_core_alloc(handle->memory_pool, sizeof(*context))) == 0) { + return SWITCH_STATUS_MEMERR; + } + + switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, handle->memory_pool); + + if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { + flags |= SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE; + if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND) || switch_test_flag(handle, SWITCH_FILE_WRITE_OVER)) { + flags |= SWITCH_FOPEN_READ; + } else { + flags |= SWITCH_FOPEN_TRUNCATE; + } + + } + + if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) { + flags |= SWITCH_FOPEN_READ; + } + + if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path); + return SWITCH_STATUS_GENERR; + } + + context->path = switch_core_strdup(handle->memory_pool, path); + + if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) { + int64_t samples = 0; + switch_file_seek(context->fd, SEEK_END, &samples); + handle->pos = samples; + } + + handle->samples = 0; + handle->samplerate = 8000; + handle->channels = 1; + handle->format = 0; + handle->sections = 0; + handle->seekable = 0; + handle->speed = 0; + handle->pos = 0; + handle->private_info = context; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate); + + if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { + struct file_header h; + size_t len = sizeof(h); + + memset(&h, 0, sizeof(h)); + + h.version = VERSION; + h.created = switch_micro_time_now(); + + switch_set_string(h.video_codec_name, "H264"); /* FIXME: hard coded */ + + h.audio_rate = handle->samplerate; + h.audio_ptime = 20; /* FIXME: hard coded */ + + if (switch_file_write(context->fd, &h, &len) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File write failed\n"); + return SWITCH_STATUS_GENERR; + } + } else if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) { + struct file_header h; + size_t size = sizeof(h); + + if (switch_file_read(context->fd, &h, &size) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error reading file header\n"); + return SWITCH_STATUS_GENERR; + } + + if (h.version != VERSION) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "File version does not match!\n"); + return SWITCH_STATUS_GENERR; + } + + handle->samplerate = h.audio_rate; + } + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t fsv_file_truncate(switch_file_handle_t *handle, int64_t offset) +{ + fsv_file_context *context = handle->private_info; + switch_status_t status; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "truncate file [%s]\n", context->path); + + if ((status = switch_file_trunc(context->fd, offset)) == SWITCH_STATUS_SUCCESS) { + handle->pos = 0; + } + + return status; + +} + +static switch_status_t fsv_file_close(switch_file_handle_t *handle) +{ + fsv_file_context *context = handle->private_info; + + if (context->fd) { + switch_file_close(context->fd); + context->fd = NULL; + } + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t fsv_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence) +{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Seek not implemented\n"); + return SWITCH_STATUS_FALSE; +} + +static switch_status_t fsv_file_read(switch_file_handle_t *handle, void *data, size_t *len) +{ + switch_status_t status; + size_t need = *len; + uint32_t size; + size_t bytes = sizeof(size); + fsv_file_context *context = handle->private_info; + +again: + + status = switch_file_read(context->fd, &size, &bytes); + + if (status != SWITCH_STATUS_SUCCESS) { + goto end; + } + + if (size & VID_BIT) { /* video */ + *len = size & ~VID_BIT; + /* TODO: read video data */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "discarding video data %d\n", (int)*len); + status = switch_file_read(context->fd, data, len); + + if (status != SWITCH_STATUS_SUCCESS) { + goto end; + } + + handle->pos += *len + bytes; + goto again; + } + + if (size > need) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "size %u > need %u\n", (unsigned int)size, (int)need); + goto end; + } + + *len = size; + + status = switch_file_read(context->fd, data, len); + + *len /= 2; + +end: + + return status; +} + +static switch_status_t fsv_file_write(switch_file_handle_t *handle, void *data, size_t *len) +{ + uint32_t datalen = *len * 2; + size_t size; + switch_status_t status; + + fsv_file_context *context = handle->private_info; + + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "writing: %ld\n", (long)(*len)); */ + + if (*len > 160) { /* when sample rate is 8000 */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You are asking to write %d bytes of data which is not supported. Please set enable_file_write_buffering=false to use .fsv format\n", (int)(*len)); + return SWITCH_STATUS_GENERR; + } + + switch_mutex_lock(context->mutex); + + size = sizeof(datalen); + if (switch_file_write(context->fd, &datalen, &size) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "write error\n"); + return SWITCH_STATUS_FALSE; + } + + *len = datalen; + status = switch_file_write(context->fd, data, len); + switch_mutex_unlock(context->mutex); + + return status; +} + +static switch_status_t fsv_file_write_video(switch_file_handle_t *handle, void *data, size_t *len) +{ + uint32_t datalen = *len; + uint32_t bytes = datalen | VID_BIT; + size_t size; + switch_status_t status = SWITCH_STATUS_SUCCESS; + + fsv_file_context *context = handle->private_info; + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "writing: %ld\n", (long)(*len)); */ + + switch_mutex_lock(context->mutex); + + size = sizeof(bytes); + if (switch_file_write(context->fd, &bytes, &size) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "write error\n"); + return SWITCH_STATUS_FALSE; + } + + *len = datalen; + status = switch_file_write(context->fd, data, len); + switch_mutex_unlock(context->mutex); + + return status; +} + +static switch_status_t fsv_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string) +{ + return SWITCH_STATUS_FALSE; +} + +static switch_status_t fsv_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string) +{ + return SWITCH_STATUS_FALSE; +} + +/* Registration */ + +static char *supported_formats[2] = { 0 }; + SWITCH_MODULE_LOAD_FUNCTION(mod_fsv_load) { switch_application_interface_t *app_interface; + switch_file_interface_t *file_interface; + + supported_formats[0] = "fsv"; /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); + file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); + file_interface->interface_name = modname; + file_interface->extens = supported_formats; + file_interface->file_open = fsv_file_open; + file_interface->file_close = fsv_file_close; + file_interface->file_truncate = fsv_file_truncate; + file_interface->file_read = fsv_file_read; + file_interface->file_write = fsv_file_write; + file_interface->file_write_video = fsv_file_write_video; + file_interface->file_seek = fsv_file_seek; + file_interface->file_set_string = fsv_file_set_string; + file_interface->file_get_string = fsv_file_get_string; + SWITCH_ADD_APP(app_interface, "play_fsv", "play an fsv file", "play an fsv file", play_fsv_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "record_fsv", "record an fsv file", "record an fsv file", record_fsv_function, "", SAF_NONE); diff --git a/src/mod/applications/mod_hash/mod_hash.c b/src/mod/applications/mod_hash/mod_hash.c index 3a93062ada..5905116883 100644 --- a/src/mod/applications/mod_hash/mod_hash.c +++ b/src/mod/applications/mod_hash/mod_hash.c @@ -451,8 +451,6 @@ SWITCH_STANDARD_APP(hash_function) value = strdup(argv[3]); switch_assert(value); switch_core_hash_insert(globals.db_hash, hash_key, value); - } else { - switch_safe_free(value); } } else if (!strcasecmp(argv[0], "delete")) { @@ -466,9 +464,9 @@ SWITCH_STANDARD_APP(hash_function) } if ((value = switch_core_hash_find(globals.db_hash, hash_key))) { if(!strcmp(argv[3], value)) { + switch_safe_free(value); switch_core_hash_delete(globals.db_hash, hash_key); } - switch_safe_free(value); } } else { goto usage; @@ -527,7 +525,6 @@ SWITCH_STANDARD_API(hash_api_function) switch_thread_rwlock_wrlock(globals.db_hash_rwlock); if ((value = switch_core_hash_find(globals.db_hash, hash_key))) { stream->write_function(stream, "-ERR key already exists\n"); - switch_safe_free(value); } else { value = strdup(argv[3]); switch_assert(value); @@ -552,12 +549,12 @@ SWITCH_STANDARD_API(hash_api_function) switch_thread_rwlock_wrlock(globals.db_hash_rwlock); if ((value = switch_core_hash_find(globals.db_hash, hash_key))) { if(!strcmp(argv[3],value)) { + switch_safe_free(value); switch_core_hash_delete(globals.db_hash, hash_key); stream->write_function(stream, "+OK\n"); } else { stream->write_function(stream, "-ERR Doesn't match\n"); } - switch_safe_free(value); } else { stream->write_function(stream, "-ERR Not found\n"); } diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index bc1731d21e..887dae3891 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -553,7 +553,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw do { if (speak) { - status = switch_ivr_speak_text(client->session, tts_engine, tts_voice, (char *)body, args); + status = switch_ivr_speak_text(client->session, tts_engine, tts_voice, (char *)file, args); } else if (say) { status = switch_ivr_say(client->session, body, say_lang, say_type, say_method, say_gender, args); } else if (play) { @@ -597,8 +597,8 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw switch_ivr_play_file(client->session, NULL, error_file, &nullargs); switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, name, "invalid"); switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "input_type", "invalid"); - status = SWITCH_STATUS_SUCCESS; } + status = SWITCH_STATUS_SUCCESS; } else if (status == SWITCH_STATUS_FOUND) { status = SWITCH_STATUS_SUCCESS; submit = 1; @@ -887,7 +887,7 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit const char *digit_timeout_ = switch_xml_attr(tag, "digit-timeout"); char *loops_ = (char *) switch_xml_attr(tag, "loops"); int loops = 0; - switch_status_t status = SWITCH_STATUS_FALSE; + switch_status_t status = SWITCH_STATUS_SUCCESS; switch_ivr_dmachine_t *dmachine = NULL; switch_input_args_t *args = NULL, myargs = { 0 }; long digit_timeout = 1500; @@ -1022,6 +1022,10 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit status = switch_ivr_record_file(client->session, &fh, tmp_record_path, args, record_limit); } + if (switch_channel_ready(client->channel)) { + status = SWITCH_STATUS_SUCCESS; + } + if (client->matching_action_binding) { if (client->matching_action_binding->action) { sub_action = client->matching_action_binding->action; @@ -1326,7 +1330,6 @@ static void cleanup_attachments(client_t *client) for (hp = client->params->headers; hp; hp = hp->next) { if (!strncasecmp(hp->name, "attach_file:", 12)) { if (switch_file_exists(hp->value, client->pool) == SWITCH_STATUS_SUCCESS) { - printf("DELETE %s\n", hp->value); unlink(hp->value); } } @@ -2161,6 +2164,7 @@ SWITCH_STANDARD_APP(httapi_function) if (!zstr(url) && switch_stristr("://", url)) { if (!params) { switch_event_create(¶ms, SWITCH_EVENT_CLONE); + params->flags |= EF_UNIQ_HEADERS; } switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "url", url); } @@ -2272,7 +2276,9 @@ static char *load_cache_data(http_file_context_t *context, const char *url) if ((p = strchr(meta_buffer, ':'))) { *p++ = '\0'; - context->expires = (time_t) atol(meta_buffer); + if (context->expires != 1) { + context->expires = (time_t) atol(meta_buffer); + } context->metadata = switch_core_strdup(context->pool, p); } } @@ -2518,7 +2524,7 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char load_cache_data(context, url); - if (context->expires && now < context->expires) { + if (context->expires > 1 && now < context->expires) { return SWITCH_STATUS_SUCCESS; } @@ -2610,7 +2616,13 @@ static switch_status_t http_file_file_open(switch_file_handle_t *handle, const c switch_event_create_brackets(pdup, '(', ')', ',', &context->url_params, &parsed, SWITCH_FALSE); if (context->url_params) { + const char *var; context->ua = switch_event_get_header(context->url_params, "ua"); + + if ((var = switch_event_get_header(context->url_params, "cache")) && !switch_true(var)) { + context->expires = 1; + } + } if (parsed) path = parsed; diff --git a/src/mod/applications/mod_http_cache/conf/autoload_configs/http_cache.conf.xml b/src/mod/applications/mod_http_cache/conf/autoload_configs/http_cache.conf.xml index 4150d6472e..d4b5475ec9 100644 --- a/src/mod/applications/mod_http_cache/conf/autoload_configs/http_cache.conf.xml +++ b/src/mod/applications/mod_http_cache/conf/autoload_configs/http_cache.conf.xml @@ -3,6 +3,9 @@ + + + diff --git a/src/mod/applications/mod_http_cache/conf/cacert.pem b/src/mod/applications/mod_http_cache/conf/cacert.pem new file mode 100644 index 0000000000..72e14177c9 --- /dev/null +++ b/src/mod/applications/mod_http_cache/conf/cacert.pem @@ -0,0 +1,3366 @@ +## +## ca-bundle.crt -- Bundle of CA Root Certificates +## +## Certificate data from Mozilla as of: Sun Feb 19 04:03:37 2012 +## +## This is a bundle of X.509 certificates of public Certificate Authorities +## (CA). These were automatically extracted from Mozilla's root certificates +## file (certdata.txt). This file can be found in the mozilla source tree: +## http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1 +## +## It contains the certificates in PEM format and therefore +## can be directly used with curl / libcurl / php_curl, or with +## an Apache+mod_ssl webserver for SSL client authentication. +## Just configure this file as the SSLCACertificateFile. +## + +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.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 the Netscape security libraries. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1994-2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** +# @(#) $RCSfile: certdata.txt,v $ $Revision: 1.82 $ $Date: 2012/02/18 21:41:46 $ + +GTE CyberTrust Global Root +========================== +-----BEGIN CERTIFICATE----- +MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9HVEUg +Q29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNvbHV0aW9ucywgSW5jLjEjMCEG +A1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJvb3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEz +MjM1OTAwWjB1MQswCQYDVQQGEwJVUzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQL +Ex5HVEUgQ3liZXJUcnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0 +IEdsb2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrHiM3dFw4u +sJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTSr41tiGeA5u2ylc9yMcql +HHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X404Wqk2kmhXBIgD8SFcd5tB8FLztimQID +AQABMA0GCSqGSIb3DQEBBAUAA4GBAG3rGwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMW +M4ETCJ57NE7fQMh017l93PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OF +NMQkpw0PlZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ +-----END CERTIFICATE----- + +Thawte Server CA +================ +-----BEGIN CERTIFICATE----- +MIIDEzCCAnygAwIBAgIBATANBgkqhkiG9w0BAQQFADCBxDELMAkGA1UEBhMCWkExFTATBgNVBAgT +DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3Vs +dGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcGA1UE +AxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5j +b20wHhcNOTYwODAxMDAwMDAwWhcNMjAxMjMxMjM1OTU5WjCBxDELMAkGA1UEBhMCWkExFTATBgNV +BAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29u +c3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcG +A1UEAxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0 +ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANOkUG7I/1Zr5s9dtuoMaHVHoqrC2oQl +/Kj0R1HahbUgdJSGHg91yekIYfUGbTBuFRkC6VLAYttNmZ7iagxEOM3+vuNkCXDF/rFrKbYvScg7 +1CcEJRCXL+eQbcAoQpnXTEPew/UhbVSfXcNY4cDk2VuwuNy0e982OsK1ZiIS1ocNAgMBAAGjEzAR +MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAB/pMaVz7lcxG7oWDTSEwjsrZqG9J +GubaUeNgcGyEYRGhGshIPllDfU+VPaGLtwtimHp1it2ITk6eQNuozDJ0uW8NxuOzRAvZim+aKZuZ +GCg70eNAKJpaPNW15yAbi8qkq43pUdniTCxZqdq5snUb9kLy78fyGPmJvKP/iiMucEc= +-----END CERTIFICATE----- + +Thawte Premium Server CA +======================== +-----BEGIN CERTIFICATE----- +MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkExFTATBgNVBAgT +DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3Vs +dGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UE +AxMYVGhhd3RlIFByZW1pdW0gU2VydmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZl +ckB0aGF3dGUuY29tMB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYT +AlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU +VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2 +aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNlcnZlciBDQTEoMCYGCSqGSIb3DQEJARYZ +cHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2 +aovXwlue2oFBYo847kkEVdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIh +Udib0GfQug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMRuHM/ +qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQAm +SCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUIhfzJATj/Tb7yFkJD57taRvvBxhEf +8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JMpAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7t +UCemDaYj+bvLpgcUQg== +-----END CERTIFICATE----- + +Equifax Secure CA +================= +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJVUzEQMA4GA1UE +ChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5 +MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoT +B0VxdWlmYXgxLTArBgNVBAsTJEVxdWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCB +nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPR +fM6fBeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+AcJkVV5MW +8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kCAwEAAaOCAQkwggEFMHAG +A1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UE +CxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoG +A1UdEAQTMBGBDzIwMTgwODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvS +spXXR9gjIBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQFMAMB +Af8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUAA4GBAFjOKer89961 +zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y7qj/WsjTVbJmcVfewCHrPSqnI0kB +BIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee95 +70+sB3c4 +-----END CERTIFICATE----- + +Digital Signature Trust Co. Global CA 1 +======================================= +-----BEGIN CERTIFICATE----- +MIIDKTCCApKgAwIBAgIENnAVljANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJVUzEkMCIGA1UE +ChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMREwDwYDVQQLEwhEU1RDQSBFMTAeFw05ODEy +MTAxODEwMjNaFw0xODEyMTAxODQwMjNaMEYxCzAJBgNVBAYTAlVTMSQwIgYDVQQKExtEaWdpdGFs +IFNpZ25hdHVyZSBUcnVzdCBDby4xETAPBgNVBAsTCERTVENBIEUxMIGdMA0GCSqGSIb3DQEBAQUA +A4GLADCBhwKBgQCgbIGpzzQeJN3+hijM3oMv+V7UQtLodGBmE5gGHKlREmlvMVW5SXIACH7TpWJE +NySZj9mDSI+ZbZUTu0M7LklOiDfBu1h//uG9+LthzfNHwJmm8fOR6Hh8AMthyUQncWlVSn5JTe2i +o74CTADKAqjuAQIxZA9SLRN0dja1erQtcQIBA6OCASQwggEgMBEGCWCGSAGG+EIBAQQEAwIABzBo +BgNVHR8EYTBfMF2gW6BZpFcwVTELMAkGA1UEBhMCVVMxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0 +dXJlIFRydXN0IENvLjERMA8GA1UECxMIRFNUQ0EgRTExDTALBgNVBAMTBENSTDEwKwYDVR0QBCQw +IoAPMTk5ODEyMTAxODEwMjNagQ8yMDE4MTIxMDE4MTAyM1owCwYDVR0PBAQDAgEGMB8GA1UdIwQY +MBaAFGp5fpFpRhgTCgJ3pVlbYJglDqL4MB0GA1UdDgQWBBRqeX6RaUYYEwoCd6VZW2CYJQ6i+DAM +BgNVHRMEBTADAQH/MBkGCSqGSIb2fQdBAAQMMAobBFY0LjADAgSQMA0GCSqGSIb3DQEBBQUAA4GB +ACIS2Hod3IEGtgllsofIH160L+nEHvI8wbsEkBFKg05+k7lNQseSJqBcNJo4cvj9axY+IO6CizEq +kzaFI4iKPANo08kJD038bKTaKHKTDomAsH3+gG9lbRgzl4vCa4nuYD3Im+9/KzJic5PLPON74nZ4 +RbyhkwS7hp86W0N6w4pl +-----END CERTIFICATE----- + +Digital Signature Trust Co. Global CA 3 +======================================= +-----BEGIN CERTIFICATE----- +MIIDKTCCApKgAwIBAgIENm7TzjANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJVUzEkMCIGA1UE +ChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMREwDwYDVQQLEwhEU1RDQSBFMjAeFw05ODEy +MDkxOTE3MjZaFw0xODEyMDkxOTQ3MjZaMEYxCzAJBgNVBAYTAlVTMSQwIgYDVQQKExtEaWdpdGFs +IFNpZ25hdHVyZSBUcnVzdCBDby4xETAPBgNVBAsTCERTVENBIEUyMIGdMA0GCSqGSIb3DQEBAQUA +A4GLADCBhwKBgQC/k48Xku8zExjrEH9OFr//Bo8qhbxe+SSmJIi2A7fBw18DW9Fvrn5C6mYjuGOD +VvsoLeE4i7TuqAHhzhy2iCoiRoX7n6dwqUcUP87eZfCocfdPJmyMvMa1795JJ/9IKn3oTQPMx7JS +xhcxEzu1TdvIxPbDDyQq2gyd55FbgM2UnQIBA6OCASQwggEgMBEGCWCGSAGG+EIBAQQEAwIABzBo +BgNVHR8EYTBfMF2gW6BZpFcwVTELMAkGA1UEBhMCVVMxJDAiBgNVBAoTG0RpZ2l0YWwgU2lnbmF0 +dXJlIFRydXN0IENvLjERMA8GA1UECxMIRFNUQ0EgRTIxDTALBgNVBAMTBENSTDEwKwYDVR0QBCQw +IoAPMTk5ODEyMDkxOTE3MjZagQ8yMDE4MTIwOTE5MTcyNlowCwYDVR0PBAQDAgEGMB8GA1UdIwQY +MBaAFB6CTShlgDzJQW6sNS5ay97u+DlbMB0GA1UdDgQWBBQegk0oZYA8yUFurDUuWsve7vg5WzAM +BgNVHRMEBTADAQH/MBkGCSqGSIb2fQdBAAQMMAobBFY0LjADAgSQMA0GCSqGSIb3DQEBBQUAA4GB +AEeNg61i8tuwnkUiBbmi1gMOOHLnnvx75pO2mqWilMg0HZHRxdf0CiUPPXiBng+xZ8SQTGPdXqfi +up/1902lMXucKS1M/mQ+7LZT/uqb7YLbdHVLB3luHtgZg3Pe9T7Qtd7nS2h9Qy4qIOF+oHhEngj1 +mPnHfxsb1gYgAlihw6ID +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority +======================================================= +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx +FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow +XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz +IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 +f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol +hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA +TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah +WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf +Tqj/ZA1k +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority - G2 +============================================================ +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz +dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz +dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO +FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71 +lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB +MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT +1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD +Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9 +-----END CERTIFICATE----- + +GlobalSign Root CA +================== +-----BEGIN CERTIFICATE----- +MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx +GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds +b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV +BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD +VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa +DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc +THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb +Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP +c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX +gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF +AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj +Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG +j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH +hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC +X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== +-----END CERTIFICATE----- + +GlobalSign Root CA - R2 +======================= +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv +YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh +bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT +aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln +bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6 +ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp +s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN +S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL +TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C +ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E +FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i +YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN +BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp +9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu +01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7 +9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 +TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== +-----END CERTIFICATE----- + +ValiCert Class 1 VA +=================== +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp +b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh +bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNTIy +MjM0OFoXDTE5MDYyNTIyMjM0OFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0 +d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDEg +UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0 +LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDYWYJ6ibiWuqYvaG9YLqdUHAZu9OqNSLwxlBfw8068srg1knaw0KWlAdcAAxIi +GQj4/xEjm84H9b9pGib+TunRf50sQB1ZaG6m+FiwnRqP0z/x3BkGgagO4DrdyFNFCQbmD3DD+kCm +DuJWBQ8YTfwggtFzVXSNdnKgHZ0dwN0/cQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFBoPUn0LBwG +lN+VYH+Wexf+T3GtZMjdd9LvWVXoP+iOBSoh8gfStadS/pyxtuJbdxdA6nLWI8sogTLDAHkY7FkX +icnGah5xyf23dKUlRWnFSKsZ4UWKJWsZ7uW7EvV/96aNUcPwnXS3qT6gpf+2SQMT2iLM7XGCK5nP +Orf1LXLI +-----END CERTIFICATE----- + +ValiCert Class 2 VA +=================== +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp +b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh +bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAw +MTk1NFoXDTE5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0 +d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIg +UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0 +LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDOOnHK5avIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVC +CSRrCl6zfN1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7Rf +ZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9vUJSZ +SWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTuIYEZoDJJKPTEjlbV +UjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8 +W9ViH0Pd +-----END CERTIFICATE----- + +RSA Root Certificate 1 +====================== +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp +b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDMgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh +bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAw +MjIzM1oXDTE5MDYyNjAwMjIzM1owgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0 +d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDMg +UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0 +LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDjmFGWHOjVsQaBalfDcnWTq8+epvzzFlLWLU2fNUSoLgRNB0mKOCn1dzfnt6td +3zZxFJmP3MKS8edgkpfs2Ejcv8ECIMYkpChMMFp2bbFc893enhBxoYjHW5tBbcqwuI4V7q0zK89H +BFx1cQqYJJgpp0lZpd34t0NiYfPT4tBVPwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFa7AliEZwgs +3x/be0kz9dNnnfS0ChCzycUs4pJqcXgn8nCDQtM+z6lU9PHYkhaM0QTLS6vJn0WuPIqpsHEzXcjF +V9+vqDWzf4mH6eglkrh/hXqu1rweN1gqZ8mRzyqBPu3GOd/APhmcGcwTTYJBtYze4D1gCCAPRX5r +on+jjBXu +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority - G3 +============================================================ +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy +dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1 +EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc +cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw +EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj +055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f +j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC +/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0 +xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa +t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== +-----END CERTIFICATE----- + +Verisign Class 4 Public Primary Certification Authority - G3 +============================================================ +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy +dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS +tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM +8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW +Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX +Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt +mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm +fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd +RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG +UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg== +-----END CERTIFICATE----- + +Entrust.net Secure Server CA +============================ +-----BEGIN CERTIFICATE----- +MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMCVVMxFDASBgNV +BAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5uZXQvQ1BTIGluY29ycC4gYnkg +cmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRl +ZDE6MDgGA1UEAxMxRW50cnVzdC5uZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhv +cml0eTAeFw05OTA1MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIG +A1UEChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBi +eSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1p +dGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQ +aO2f55M28Qpku0f1BBc/I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5 +gXpa0zf3wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OCAdcw +ggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHboIHYpIHVMIHSMQsw +CQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5l +dC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF +bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENl +cnRpZmljYXRpb24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu +dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0MFqBDzIwMTkw +NTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8BdiE1U9s/8KAGv7UISX8+1i0Bow +HQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAaMAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EA +BAwwChsEVjQuMAMCBJAwDQYJKoZIhvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyN +Ewr75Ji174z4xRAN95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9 +n9cd2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI= +-----END CERTIFICATE----- + +Entrust.net Premium 2048 Secure Server CA +========================================= +-----BEGIN CERTIFICATE----- +MIIEXDCCA0SgAwIBAgIEOGO5ZjANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u +ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp +bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV +BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx +NzUwNTFaFw0xOTEyMjQxODIwNTFaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3 +d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl +MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u +ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL +Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr +hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW +nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi +VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo3QwcjARBglghkgBhvhC +AQEEBAMCAAcwHwYDVR0jBBgwFoAUVeSB0RGAvtiJuQijMfmhJAkWuXAwHQYDVR0OBBYEFFXkgdER +gL7YibkIozH5oSQJFrlwMB0GCSqGSIb2fQdBAAQQMA4bCFY1LjA6NC4wAwIEkDANBgkqhkiG9w0B +AQUFAAOCAQEAWUesIYSKF8mciVMeuoCFGsY8Tj6xnLZ8xpJdGGQC49MGCBFhfGPjK50xA3B20qMo +oPS7mmNz7W3lKtvtFKkrxjYR0CvrB4ul2p5cGZ1WEvVUKcgF7bISKo30Axv/55IQh7A6tcOdBTcS +o8f0FbnVpDkWm1M6I5HxqIKiaohowXkCIryqptau37AUX7iH0N18f3v/rxzP5tsHrV7bhZ3QKw0z +2wTR5klAEyt2+z7pnIkPFc4YsIV4IU9rTw76NmfNB/L/CNDi3tm/Kq+4h4YhPATKt5Rof8886ZjX +OP/swNlQ8C5LWK5Gb9Auw2DaclVyvUxFnmG6v4SBkgPR0ml8xQ== +-----END CERTIFICATE----- + +Baltimore CyberTrust Root +========================= +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE +ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li +ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC +SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs +dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME +uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB +UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C +G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9 +XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr +l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI +VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB +BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh +cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5 +hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa +Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H +RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp +-----END CERTIFICATE----- + +Equifax Secure Global eBusiness CA +================================== +-----BEGIN CERTIFICATE----- +MIICkDCCAfmgAwIBAgIBATANBgkqhkiG9w0BAQQFADBaMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +RXF1aWZheCBTZWN1cmUgSW5jLjEtMCsGA1UEAxMkRXF1aWZheCBTZWN1cmUgR2xvYmFsIGVCdXNp +bmVzcyBDQS0xMB4XDTk5MDYyMTA0MDAwMFoXDTIwMDYyMTA0MDAwMFowWjELMAkGA1UEBhMCVVMx +HDAaBgNVBAoTE0VxdWlmYXggU2VjdXJlIEluYy4xLTArBgNVBAMTJEVxdWlmYXggU2VjdXJlIEds +b2JhbCBlQnVzaW5lc3MgQ0EtMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuucXkAJlsTRV +PEnCUdXfp9E3j9HngXNBUmCbnaEXJnitx7HoJpQytd4zjTov2/KaelpzmKNc6fuKcxtc58O/gGzN +qfTWK8D3+ZmqY6KxRwIP1ORROhI8bIpaVIRw28HFkM9yRcuoWcDNM50/o5brhTMhHD4ePmBudpxn +hcXIw2ECAwEAAaNmMGQwEQYJYIZIAYb4QgEBBAQDAgAHMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0j +BBgwFoAUvqigdHJQa0S3ySPY+6j/s1draGwwHQYDVR0OBBYEFL6ooHRyUGtEt8kj2Puo/7NXa2hs +MA0GCSqGSIb3DQEBBAUAA4GBADDiAVGqx+pf2rnQZQ8w1j7aDRRJbpGTJxQx78T3LUX47Me/okEN +I7SS+RkAZ70Br83gcfxaz2TE4JaY0KNA4gGK7ycH8WUBikQtBmV1UsCGECAhX2xrD2yuCRyv8qIY +NMR1pHMc8Y3c7635s3a0kr/clRAevsvIO1qEYBlWlKlV +-----END CERTIFICATE----- + +Equifax Secure eBusiness CA 1 +============================= +-----BEGIN CERTIFICATE----- +MIICgjCCAeugAwIBAgIBBDANBgkqhkiG9w0BAQQFADBTMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +RXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNzIENB +LTEwHhcNOTkwNjIxMDQwMDAwWhcNMjAwNjIxMDQwMDAwWjBTMQswCQYDVQQGEwJVUzEcMBoGA1UE +ChMTRXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNz +IENBLTEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM4vGbwXt3fek6lfWg0XTzQaDJj0ItlZ +1MRoRvC0NcWFAyDGr0WlIVFFQesWWDYyb+JQYmT5/VGcqiTZ9J2DKocKIdMSODRsjQBuWqDZQu4a +IZX5UkxVWsUPOE9G+m34LjXWHXzr4vCwdYDIqROsvojvOm6rXyo4YgKwEnv+j6YDAgMBAAGjZjBk +MBEGCWCGSAGG+EIBAQQEAwIABzAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFEp4MlIR21kW +Nl7fwRQ2QGpHfEyhMB0GA1UdDgQWBBRKeDJSEdtZFjZe38EUNkBqR3xMoTANBgkqhkiG9w0BAQQF +AAOBgQB1W6ibAxHm6VZMzfmpTMANmvPMZWnmJXbMWbfWVMMdzZmsGd20hdXgPfxiIKeES1hl8eL5 +lSE/9dR+WB5Hh1Q+WKG1tfgq73HnvMP2sUlG4tega+VWeponmHxGYhTnyfxuAxJ5gDgdSIKN/Bf+ +KpYrtWKmpj29f5JZzVoqgrI3eQ== +-----END CERTIFICATE----- + +Equifax Secure eBusiness CA 2 +============================= +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIEN3DPtTANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJVUzEXMBUGA1UE +ChMORXF1aWZheCBTZWN1cmUxJjAkBgNVBAsTHUVxdWlmYXggU2VjdXJlIGVCdXNpbmVzcyBDQS0y +MB4XDTk5MDYyMzEyMTQ0NVoXDTE5MDYyMzEyMTQ0NVowTjELMAkGA1UEBhMCVVMxFzAVBgNVBAoT +DkVxdWlmYXggU2VjdXJlMSYwJAYDVQQLEx1FcXVpZmF4IFNlY3VyZSBlQnVzaW5lc3MgQ0EtMjCB +nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5Dk5kx5SBhsoNviyoynF7Y6yEb3+6+e0dMKP/wXn +2Z0GvxLIPw7y1tEkshHe0XMJitSxLJgJDR5QRrKDpkWNYmi7hRsgcDKqQM2mll/EcTc/BPO3QSQ5 +BxoeLmFYoBIL5aXfxavqN3HMHMg3OrmXUqesxWoklE6ce8/AatbfIb0CAwEAAaOCAQkwggEFMHAG +A1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEXMBUGA1UEChMORXF1aWZheCBTZWN1cmUx +JjAkBgNVBAsTHUVxdWlmYXggU2VjdXJlIGVCdXNpbmVzcyBDQS0yMQ0wCwYDVQQDEwRDUkwxMBoG +A1UdEAQTMBGBDzIwMTkwNjIzMTIxNDQ1WjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUUJ4L6q9e +uSBIplBqy/3YIHqngnYwHQYDVR0OBBYEFFCeC+qvXrkgSKZQasv92CB6p4J2MAwGA1UdEwQFMAMB +Af8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUAA4GBAAyGgq3oThr1 +jokn4jVYPSm0B482UJW/bsGe68SQsoWou7dC4A8HOd/7npCy0cE+U58DRLB+S/Rv5Hwf5+Kx5Lia +78O9zt4LMjTZ3ijtM2vE1Nc9ElirfQkty3D1E4qUoSek1nDFbZS1yX2doNLGCEnZZpum0/QL3MUm +V+GRMOrN +-----END CERTIFICATE----- + +AddTrust Low-Value Services Root +================================ +-----BEGIN CERTIFICATE----- +MIIEGDCCAwCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYDVQQDExhBZGRU +cnVzdCBDbGFzcyAxIENBIFJvb3QwHhcNMDAwNTMwMTAzODMxWhcNMjAwNTMwMTAzODMxWjBlMQsw +CQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBO +ZXR3b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCWltQhSWDia+hBBwzexODcEyPNwTXH+9ZOEQpnXvUGW2ulCDtbKRY6 +54eyNAbFvAWlA3yCyykQruGIgb3WntP+LVbBFc7jJp0VLhD7Bo8wBN6ntGO0/7Gcrjyvd7ZWxbWr +oulpOj0OM3kyP3CCkplhbY0wCI9xP6ZIVxn4JdxLZlyldI+Yrsj5wAYi56xz36Uu+1LcsRVlIPo1 +Zmne3yzxbrww2ywkEtvrNTVokMsAsJchPXQhI2U0K7t4WaPW4XY5mqRJjox0r26kmqPZm9I4XJui +GMx1I4S+6+JNM3GOGvDC+Mcdoq0Dlyz4zyXG9rgkMbFjXZJ/Y/AlyVMuH79NAgMBAAGjgdIwgc8w +HQYDVR0OBBYEFJWxtPCUtr3H2tERCSG+wa9J/RB7MAsGA1UdDwQEAwIBBjAPBgNVHRMBAf8EBTAD +AQH/MIGPBgNVHSMEgYcwgYSAFJWxtPCUtr3H2tERCSG+wa9J/RB7oWmkZzBlMQswCQYDVQQGEwJT +RTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEw +HwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBACxt +ZBsfzQ3duQH6lmM0MkhHma6X7f1yFqZzR1r0693p9db7RcwpiURdv0Y5PejuvE1Uhh4dbOMXJ0Ph +iVYrqW9yTkkz43J8KiOavD7/KCrto/8cI7pDVwlnTUtiBi34/2ydYB7YHEt9tTEv2dB8Xfjea4MY +eDdXL+gzB2ffHsdrKpV2ro9Xo/D0UrSpUwjP4E/TelOL/bscVjby/rK25Xa71SJlpz/+0WatC7xr +mYbvP33zGDLKe8bjq2RGlfgmadlVg3sslgf/WSxEo8bl6ancoWOAWiFeIc9TVPC6b4nbqKqVz4vj +ccweGyBECMB6tkD9xOQ14R0WHNC8K47Wcdk= +-----END CERTIFICATE----- + +AddTrust External Root +====================== +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYD +VQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEw +NDgzOFowbzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRU +cnVzdCBFeHRlcm5hbCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0Eg +Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvtH7xsD821 ++iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9uMq/NzgtHj6RQa1wVsfw +Tz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzXmk6vBbOmcZSccbNQYArHE504B4YCqOmo +aSYYkKtMsE8jqzpPhNjfzp/haW+710LXa0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy +2xSoRcRdKn23tNbE7qzNE0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv7 +7+ldU9U0WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYDVR0P +BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0Jvf6xCZU7wO94CTL +VBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRk +VHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB +IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZl +j7DYd7usQWxHYINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 +6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvCNr4TDea9Y355 +e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEXc4g/VhsxOBi0cQ+azcgOno4u +G+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5amnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= +-----END CERTIFICATE----- + +AddTrust Public Services Root +============================= +-----BEGIN CERTIFICATE----- +MIIEFTCCAv2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSAwHgYDVQQDExdBZGRU +cnVzdCBQdWJsaWMgQ0EgUm9vdDAeFw0wMDA1MzAxMDQxNTBaFw0yMDA1MzAxMDQxNTBaMGQxCzAJ +BgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5l +dHdvcmsxIDAeBgNVBAMTF0FkZFRydXN0IFB1YmxpYyBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEA6Rowj4OIFMEg2Dybjxt+A3S72mnTRqX4jsIMEZBRpS9mVEBV6tsfSlbu +nyNu9DnLoblv8n75XYcmYZ4c+OLspoH4IcUkzBEMP9smcnrHAZcHF/nXGCwwfQ56HmIexkvA/X1i +d9NEHif2P0tEs7c42TkfYNVRknMDtABp4/MUTu7R3AnPdzRGULD4EfL+OHn3Bzn+UZKXC1sIXzSG +Aa2Il+tmzV7R/9x98oTaunet3IAIx6eH1lWfl2royBFkuucZKT8Rs3iQhCBSWxHveNCD9tVIkNAw +HM+A+WD+eeSI8t0A65RF62WUaUC6wNW0uLp9BBGo6zEFlpROWCGOn9Bg/QIDAQABo4HRMIHOMB0G +A1UdDgQWBBSBPjfYkrAfd59ctKtzquf2NGAv+jALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB +/zCBjgYDVR0jBIGGMIGDgBSBPjfYkrAfd59ctKtzquf2NGAv+qFopGYwZDELMAkGA1UEBhMCU0Ux +FDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRUcnVzdCBUVFAgTmV0d29yazEgMB4G +A1UEAxMXQWRkVHJ1c3QgUHVibGljIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBAAP3FUr4 +JNojVhaTdt02KLmuG7jD8WS6IBh4lSknVwW8fCr0uVFV2ocC3g8WFzH4qnkuCRO7r7IgGRLlk/lL ++YPoRNWyQSW/iHVv/xD8SlTQX/D67zZzfRs2RcYhbbQVuE7PnFylPVoAjgbjPGsye/Kf8Lb93/Ao +GEjwxrzQvzSAlsJKsW2Ox5BF3i9nrEUEo3rcVZLJR2bYGozH7ZxOmuASu7VqTITh4SINhwBk/ox9 +Yjllpu9CtoAlEmEBqCQTcAARJl/6NVDFSMwGR+gn2HCNX2TmoUQmXiLsks3/QppEIW1cxeMiHV9H +EufOX1362KqxMy3ZdvJOOjMMK7MtkAY= +-----END CERTIFICATE----- + +AddTrust Qualified Certificates Root +==================================== +-----BEGIN CERTIFICATE----- +MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSMwIQYDVQQDExpBZGRU +cnVzdCBRdWFsaWZpZWQgQ0EgUm9vdDAeFw0wMDA1MzAxMDQ0NTBaFw0yMDA1MzAxMDQ0NTBaMGcx +CzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQ +IE5ldHdvcmsxIzAhBgNVBAMTGkFkZFRydXN0IFF1YWxpZmllZCBDQSBSb290MIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5B6a/twJWoekn0e+EV+vhDTbYjx5eLfpMLXsDBwqxBb/4Oxx +64r1EW7tTw2R0hIYLUkVAcKkIhPHEWT/IhKauY5cLwjPcWqzZwFZ8V1G87B4pfYOQnrjfxvM0PC3 +KP0q6p6zsLkEqv32x7SxuCqg+1jxGaBvcCV+PmlKfw8i2O+tCBGaKZnhqkRFmhJePp1tUvznoD1o +L/BLcHwTOK28FSXx1s6rosAx1i+f4P8UWfyEk9mHfExUE+uf0S0R+Bg6Ot4l2ffTQO2kBhLEO+GR +wVY18BTcZTYJbqukB8c10cIDMzZbdSZtQvESa0NvS3GU+jQd7RNuyoB/mC9suWXY6QIDAQABo4HU +MIHRMB0GA1UdDgQWBBQ5lYtii1zJ1IC6WA+XPxUIQ8yYpzALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zCBkQYDVR0jBIGJMIGGgBQ5lYtii1zJ1IC6WA+XPxUIQ8yYp6FrpGkwZzELMAkGA1UE +BhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRUcnVzdCBUVFAgTmV0d29y +azEjMCEGA1UEAxMaQWRkVHJ1c3QgUXVhbGlmaWVkIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQAD +ggEBABmrder4i2VhlRO6aQTvhsoToMeqT2QbPxj2qC0sVY8FtzDqQmodwCVRLae/DLPt7wh/bDxG +GuoYQ992zPlmhpwsaPXpF/gxsxjE1kh9I0xowX67ARRvxdlu3rsEQmr49lx95dr6h+sNNVJn0J6X +dgWTP5XHAeZpVTh/EGGZyeNfpso+gmNIquIISD6q8rKFYqa0p9m9N5xotS1WfbC3P6CxB9bpT9ze +RXEwMn8bLgn5v1Kh7sKAPgZcLlVAwRv1cEWw3F369nJad9Jjzc9YiQBCYz95OdBEsIJuQRno3eDB +iFrRHnGTHyQwdOUeqN48Jzd/g66ed8/wMLH/S5noxqE= +-----END CERTIFICATE----- + +Entrust Root Certification Authority +==================================== +-----BEGIN CERTIFICATE----- +MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV +BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw +b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG +A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0 +MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu +MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu +Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v +dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz +A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww +Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68 +j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN +rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw +DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1 +MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH +hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA +A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM +Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa +v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS +W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0 +tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8 +-----END CERTIFICATE----- + +RSA Security 2048 v3 +==================== +-----BEGIN CERTIFICATE----- +MIIDYTCCAkmgAwIBAgIQCgEBAQAAAnwAAAAKAAAAAjANBgkqhkiG9w0BAQUFADA6MRkwFwYDVQQK +ExBSU0EgU2VjdXJpdHkgSW5jMR0wGwYDVQQLExRSU0EgU2VjdXJpdHkgMjA0OCBWMzAeFw0wMTAy +MjIyMDM5MjNaFw0yNjAyMjIyMDM5MjNaMDoxGTAXBgNVBAoTEFJTQSBTZWN1cml0eSBJbmMxHTAb +BgNVBAsTFFJTQSBTZWN1cml0eSAyMDQ4IFYzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAt49VcdKA3XtpeafwGFAyPGJn9gqVB93mG/Oe2dJBVGutn3y+Gc37RqtBaB4Y6lXIL5F4iSj7 +Jylg/9+PjDvJSZu1pJTOAeo+tWN7fyb9Gd3AIb2E0S1PRsNO3Ng3OTsor8udGuorryGlwSMiuLgb +WhOHV4PR8CDn6E8jQrAApX2J6elhc5SYcSa8LWrg903w8bYqODGBDSnhAMFRD0xS+ARaqn1y07iH +KrtjEAMqs6FPDVpeRrc9DvV07Jmf+T0kgYim3WBU6JU2PcYJk5qjEoAAVZkZR73QpXzDuvsf9/UP ++Ky5tfQ3mBMY3oVbtwyCO4dvlTlYMNpuAWgXIszACwIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/ +MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQHw1EwpKrpRa41JPr/JCwz0LGdjDAdBgNVHQ4E +FgQUB8NRMKSq6UWuNST6/yQsM9CxnYwwDQYJKoZIhvcNAQEFBQADggEBAF8+hnZuuDU8TjYcHnmY +v/3VEhF5Ug7uMYm83X/50cYVIeiKAVQNOvtUudZj1LGqlk2iQk3UUx+LEN5/Zb5gEydxiKRz44Rj +0aRV4VCT5hsOedBnvEbIvz8XDZXmxpBp3ue0L96VfdASPz0+f00/FGj1EVDVwfSQpQgdMWD/YIwj +VAqv/qFuxdF6Kmh4zx6CCiC0H63lhbJqaHVOrSU3lIW+vaHU6rcMSzyd6BIA8F+sDeGscGNz9395 +nzIlQnQFgCi/vcEkllgVsRch6YlL2weIZ/QVrXA+L02FO8K32/6YaCOJ4XQP3vTFhGMpG8zLB8kA +pKnXwiJPZ9d37CAFYd4= +-----END CERTIFICATE----- + +GeoTrust Global CA +================== +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK +Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw +MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j +LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo +BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet +8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc +T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU +vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD +AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk +DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q +zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4 +d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2 +mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p +XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm +Mw== +-----END CERTIFICATE----- + +GeoTrust Global CA 2 +==================== +-----BEGIN CERTIFICATE----- +MIIDZjCCAk6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBEMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN +R2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFsIENBIDIwHhcNMDQwMzA0MDUw +MDAwWhcNMTkwMzA0MDUwMDAwWjBEMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j +LjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFsIENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDvPE1APRDfO1MA4Wf+lGAVPoWI8YkNkMgoI5kF6CsgncbzYEbYwbLVjDHZ3CB5JIG/ +NTL8Y2nbsSpr7iFY8gjpeMtvy/wWUsiRxP89c96xPqfCfWbB9X5SJBri1WeR0IIQ13hLTytCOb1k +LUCgsBDTOEhGiKEMuzozKmKY+wCdE1l/bztyqu6mD4b5BWHqZ38MN5aL5mkWRxHCJ1kDs6ZgwiFA +Vvqgx306E+PsV8ez1q6diYD3Aecs9pYrEw15LNnA5IZ7S4wMcoKK+xfNAGw6EzywhIdLFnopsk/b +HdQL82Y3vdj2V7teJHq4PIu5+pIaGoSe2HSPqht/XvT+RSIhAgMBAAGjYzBhMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFHE4NvICMVNHK266ZUapEBVYIAUJMB8GA1UdIwQYMBaAFHE4NvICMVNH +K266ZUapEBVYIAUJMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAQEAA/e1K6tdEPx7 +srJerJsOflN4WT5CBP51o62sgU7XAotexC3IUnbHLB/8gTKY0UvGkpMzNTEv/NgdRN3ggX+d6Yvh +ZJFiCzkIjKx0nVnZellSlxG5FntvRdOW2TF9AjYPnDtuzywNA0ZF66D0f0hExghAzN4bcLUprbqL +OzRldRtxIR0sFAqwlpW41uryZfspuk/qkZN0abby/+Ea0AzRdoXLiiW9l14sbxWZJue2Kf8i7MkC +x1YAzUm5s2x7UwQa4qjJqhIFI8LO57sEAszAR6LkxCkvW0VXiVHuPOtSCP8HNR6fNWpHSlaY0VqF +H4z1Ir+rzoPz4iIprn2DQKi6bA== +-----END CERTIFICATE----- + +GeoTrust Universal CA +===================== +-----BEGIN CERTIFICATE----- +MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN +R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1 +MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu +Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t +JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e +RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs +7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d +8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V +qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga +Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB +Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu +KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08 +ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0 +XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB +hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc +aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2 +qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL +oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK +xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF +KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2 +DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK +xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU +p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI +P/rmMuGNG2+k5o7Y+SlIis5z/iw= +-----END CERTIFICATE----- + +GeoTrust Universal CA 2 +======================= +-----BEGIN CERTIFICATE----- +MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN +R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0 +MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg +SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA +A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0 +DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17 +j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q +JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a +QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2 +WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP +20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn +ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC +SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG +8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2 ++/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E +BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z +dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ +4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+ +mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq +A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg +Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP +pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d +FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp +gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm +X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS +-----END CERTIFICATE----- + +America Online Root Certification Authority 1 +============================================= +-----BEGIN CERTIFICATE----- +MIIDpDCCAoygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +QW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBPbmxpbmUgUm9vdCBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyODA2MDAwMFoXDTM3MTExOTIwNDMwMFowYzELMAkG +A1UEBhMCVVMxHDAaBgNVBAoTE0FtZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2Eg +T25saW5lIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAKgv6KRpBgNHw+kqmP8ZonCaxlCyfqXfaE0bfA+2l2h9LaaLl+lkhsmj76CG +v2BlnEtUiMJIxUo5vxTjWVXlGbR0yLQFOVwWpeKVBeASrlmLojNoWBym1BW32J/X3HGrfpq/m44z +DyL9Hy7nBzbvYjnF3cu6JRQj3gzGPTzOggjmZj7aUTsWOqMFf6Dch9Wc/HKpoH145LcxVR5lu9Rh +sCFg7RAycsWSJR74kEoYeEfffjA3PlAb2xzTa5qGUwew76wGePiEmf4hjUyAtgyC9mZweRrTT6PP +8c9GsEsPPt2IYriMqQkoO3rHl+Ee5fSfwMCuJKDIodkP1nsmgmkyPacCAwEAAaNjMGEwDwYDVR0T +AQH/BAUwAwEB/zAdBgNVHQ4EFgQUAK3Zo/Z59m50qX8zPYEX10zPM94wHwYDVR0jBBgwFoAUAK3Z +o/Z59m50qX8zPYEX10zPM94wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IBAQB8itEf +GDeC4Liwo+1WlchiYZwFos3CYiZhzRAW18y0ZTTQEYqtqKkFZu90821fnZmv9ov761KyBZiibyrF +VL0lvV+uyIbqRizBs73B6UlwGBaXCBOMIOAbLjpHyx7kADCVW/RFo8AasAFOq73AI25jP4BKxQft +3OJvx8Fi8eNy1gTIdGcL+oiroQHIb/AUr9KZzVGTfu0uOMe9zkZQPXLjeSWdm4grECDdpbgyn43g +Kd8hdIaC2y+CMMbHNYaz+ZZfRtsMRf3zUMNvxsNIrUam4SdHCh0Om7bCd39j8uB9Gr784N/Xx6ds +sPmuujz9dLQR6FgNgLzTqIA6me11zEZ7 +-----END CERTIFICATE----- + +America Online Root Certification Authority 2 +============================================= +-----BEGIN CERTIFICATE----- +MIIFpDCCA4ygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +QW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBPbmxpbmUgUm9vdCBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyODA2MDAwMFoXDTM3MDkyOTE0MDgwMFowYzELMAkG +A1UEBhMCVVMxHDAaBgNVBAoTE0FtZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2Eg +T25saW5lIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAMxBRR3pPU0Q9oyxQcngXssNt79Hc9PwVU3dxgz6sWYFas14tNwC206B89en +fHG8dWOgXeMHDEjsJcQDIPT/DjsS/5uN4cbVG7RtIuOx238hZK+GvFciKtZHgVdEglZTvYYUAQv8 +f3SkWq7xuhG1m1hagLQ3eAkzfDJHA1zEpYNI9FdWboE2JxhP7JsowtS013wMPgwr38oE18aO6lhO +qKSlGBxsRZijQdEt0sdtjRnxrXm3gT+9BoInLRBYBbV4Bbkv2wxrkJB+FFk4u5QkE+XRnRTf04JN +RvCAOVIyD+OEsnpD8l7eXz8d3eOyG6ChKiMDbi4BFYdcpnV1x5dhvt6G3NRI270qv0pV2uh9UPu0 +gBe4lL8BPeraunzgWGcXuVjgiIZGZ2ydEEdYMtA1fHkqkKJaEBEjNa0vzORKW6fIJ/KD3l67Xnfn +6KVuY8INXWHQjNJsWiEOyiijzirplcdIz5ZvHZIlyMbGwcEMBawmxNJ10uEqZ8A9W6Wa6897Gqid +FEXlD6CaZd4vKL3Ob5Rmg0gp2OpljK+T2WSfVVcmv2/LNzGZo2C7HK2JNDJiuEMhBnIMoVxtRsX6 +Kc8w3onccVvdtjc+31D1uAclJuW8tf48ArO3+L5DwYcRlJ4jbBeKuIonDFRH8KmzwICMoCfrHRnj +B453cMor9H124HhnAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFE1FwWg4u3Op +aaEg5+31IqEjFNeeMB8GA1UdIwQYMBaAFE1FwWg4u3OpaaEg5+31IqEjFNeeMA4GA1UdDwEB/wQE +AwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAZ2sGuV9FOypLM7PmG2tZTiLMubekJcmnxPBUlgtk87FY +T15R/LKXeydlwuXK5w0MJXti4/qftIe3RUavg6WXSIylvfEWK5t2LHo1YGwRgJfMqZJS5ivmae2p ++DYtLHe/YUjRYwu5W1LtGLBDQiKmsXeu3mnFzcccobGlHBD7GL4acN3Bkku+KVqdPzW+5X1R+FXg +JXUjhx5c3LqdsKyzadsXg8n33gy8CNyRnqjQ1xU3c6U1uPx+xURABsPr+CKAXEfOAuMRn0T//Zoy +zH1kUQ7rVyZ2OuMeIjzCpjbdGe+n/BLzJsBZMYVMnNjP36TMzCmT/5RtdlwTCJfy7aULTd3oyWgO +ZtMADjMSW7yV5TKQqLPGbIOtd+6Lfn6xqavT4fG2wLHqiMDn05DpKJKUe2h7lyoKZy2FAjgQ5ANh +1NolNscIWC2hp1GvMApJ9aZphwctREZ2jirlmjvXGKL8nDgQzMY70rUXOm/9riW99XJZZLF0Kjhf +GEzfz3EEWjbUvy+ZnOjZurGV5gJLIaFb1cFPj65pbVPbAZO1XB4Y3WRayhgoPmMEEf0cjQAPuDff +Z4qdZqkCapH/E8ovXYO8h5Ns3CRRFgQlZvqz2cK6Kb6aSDiCmfS/O0oxGfm/jiEzFMpPVF/7zvuP +cX/9XhmgD0uRuMRUvAawRY8mkaKO/qk= +-----END CERTIFICATE----- + +Visa eCommerce Root +=================== +-----BEGIN CERTIFICATE----- +MIIDojCCAoqgAwIBAgIQE4Y1TR0/BvLB+WUF1ZAcYjANBgkqhkiG9w0BAQUFADBrMQswCQYDVQQG +EwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2Ug +QXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNvbW1lcmNlIFJvb3QwHhcNMDIwNjI2MDIxODM2 +WhcNMjIwNjI0MDAxNjEyWjBrMQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMm +VmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNv +bW1lcmNlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvV95WHm6h2mCxlCfL +F9sHP4CFT8icttD0b0/Pmdjh28JIXDqsOTPHH2qLJj0rNfVIsZHBAk4ElpF7sDPwsRROEW+1QK8b +RaVK7362rPKgH1g/EkZgPI2h4H3PVz4zHvtH8aoVlwdVZqW1LS7YgFmypw23RuwhY/81q6UCzyr0 +TP579ZRdhE2o8mCP2w4lPJ9zcc+U30rq299yOIzzlr3xF7zSujtFWsan9sYXiwGd/BmoKoMWuDpI +/k4+oKsGGelT84ATB+0tvz8KPFUgOSwsAGl0lUq8ILKpeeUYiZGo3BxN77t+Nwtd/jmliFKMAGzs +GHxBvfaLdXe6YJ2E5/4tAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEG +MB0GA1UdDgQWBBQVOIMPPyw/cDMezUb+B4wg4NfDtzANBgkqhkiG9w0BAQUFAAOCAQEAX/FBfXxc +CLkr4NWSR/pnXKUTwwMhmytMiUbPWU3J/qVAtmPN3XEolWcRzCSs00Rsca4BIGsDoo8Ytyk6feUW +YFN4PMCvFYP3j1IzJL1kk5fui/fbGKhtcbP3LBfQdCVp9/5rPJS+TUtBjE7ic9DjkCJzQ83z7+pz +zkWKsKZJ/0x9nXGIxHYdkFsd7v3M9+79YKWxehZx0RbQfBI8bGmX265fOZpwLwU8GUYEmSA20GBu +YQa7FkKMcPcw++DbZqMAAb3mLNqRX6BGi01qnD093QVG/na/oAo85ADmJ7f/hC3euiInlhBx6yLt +398znM/jra6O1I7mT1GvFpLgXPYHDw== +-----END CERTIFICATE----- + +Certum Root CA +============== +-----BEGIN CERTIFICATE----- +MIIDDDCCAfSgAwIBAgIDAQAgMA0GCSqGSIb3DQEBBQUAMD4xCzAJBgNVBAYTAlBMMRswGQYDVQQK +ExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBDQTAeFw0wMjA2MTExMDQ2Mzla +Fw0yNzA2MTExMDQ2MzlaMD4xCzAJBgNVBAYTAlBMMRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8u +by4xEjAQBgNVBAMTCUNlcnR1bSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM6x +wS7TT3zNJc4YPk/EjG+AanPIW1H4m9LcuwBcsaD8dQPugfCI7iNS6eYVM42sLQnFdvkrOYCJ5JdL +kKWoePhzQ3ukYbDYWMzhbGZ+nPMJXlVjhNWo7/OxLjBos8Q82KxujZlakE403Daaj4GIULdtlkIJ +89eVgw1BS7Bqa/j8D35in2fE7SZfECYPCE/wpFcozo+47UX2bu4lXapuOb7kky/ZR6By6/qmW6/K +Uz/iDsaWVhFu9+lmqSbYf5VT7QqFiLpPKaVCjF62/IUgAKpoC6EahQGcxEZjgoi2IrHu/qpGWX7P +NSzVttpd90gzFFS269lvzs2I1qsb2pY7HVkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkq +hkiG9w0BAQUFAAOCAQEAuI3O7+cUus/usESSbLQ5PqKEbq24IXfS1HeCh+YgQYHu4vgRt2PRFze+ +GXYkHAQaTOs9qmdvLdTN/mUxcMUbpgIKumB7bVjCmkn+YzILa+M6wKyrO7Do0wlRjBCDxjTgxSvg +GrZgFCdsMneMvLJymM/NzD+5yCRCFNZX/OYmQ6kd5YCQzgNUKD73P9P4Te1qCjqTE5s7FCMTY5w/ +0YcneeVMUeMBrYVdGjux1XMQpNPyvG5k9VpWkKjHDkx0Dy5xO/fIR/RpbxXyEV6DHpx8Uq79AtoS +qFlnGNu8cN2bsWntgM6JQEhqDjXKKWYVIZQs6GAqm4VKQPNriiTsBhYscw== +-----END CERTIFICATE----- + +Comodo AAA Services root +======================== +-----BEGIN CERTIFICATE----- +MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS +R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg +TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw +MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl +c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV +BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG +C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs +i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW +Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH +Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK +Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f +BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl +cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz +LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm +7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz +Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z +8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C +12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== +-----END CERTIFICATE----- + +Comodo Secure Services root +=========================== +-----BEGIN CERTIFICATE----- +MIIEPzCCAyegAwIBAgIBATANBgkqhkiG9w0BAQUFADB+MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS +R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg +TGltaXRlZDEkMCIGA1UEAwwbU2VjdXJlIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAw +MDAwMFoXDTI4MTIzMTIzNTk1OVowfjELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFu +Y2hlc3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxJDAi +BgNVBAMMG1NlY3VyZSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAMBxM4KK0HDrc4eCQNUd5MvJDkKQ+d40uaG6EfQlhfPMcm3ye5drswfxdySRXyWP +9nQ95IDC+DwN879A6vfIUtFyb+/Iq0G4bi4XKpVpDM3SHpR7LZQdqnXXs5jLrLxkU0C8j6ysNstc +rbvd4JQX7NFc0L/vpZXJkMWwrPsbQ996CF23uPJAGysnnlDOXmWCiIxe004MeuoIkbY2qitC++rC +oznl2yY4rYsK7hljxxwk3wN42ubqwUcaCwtGCd0C/N7Lh1/XMGNooa7cMqG6vv5Eq2i2pRcV/b3V +p6ea5EQz6YiO/O1R65NxTq0B50SOqy3LqP4BSUjwwN3HaNiS/j0CAwEAAaOBxzCBxDAdBgNVHQ4E +FgQUPNiTiMLAggnMAZkGkyDpnnAJY08wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w +gYEGA1UdHwR6MHgwO6A5oDeGNWh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL1NlY3VyZUNlcnRpZmlj +YXRlU2VydmljZXMuY3JsMDmgN6A1hjNodHRwOi8vY3JsLmNvbW9kby5uZXQvU2VjdXJlQ2VydGlm +aWNhdGVTZXJ2aWNlcy5jcmwwDQYJKoZIhvcNAQEFBQADggEBAIcBbSMdflsXfcFhMs+P5/OKlFlm +4J4oqF7Tt/Q05qo5spcWxYJvMqTpjOev/e/C6LlLqqP05tqNZSH7uoDrJiiFGv45jN5bBAS0VPmj +Z55B+glSzAVIqMk/IQQezkhr/IXownuvf7fM+F86/TXGDe+X3EyrEeFryzHRbPtIgKvcnDe4IRRL +DXE97IMzbtFuMhbsmMcWi1mmNKsFVy2T96oTy9IT4rcuO81rUBcJaD61JlfutuC23bkpgHl9j6Pw +pCikFcSF9CfUa7/lXORlAnZUtOM3ZiTTGWHIUhDlizeauan5Hb/qmZJhlv8BzaFfDbxxvA6sCx1H +RR3B7Hzs/Sk= +-----END CERTIFICATE----- + +Comodo Trusted Services root +============================ +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIBATANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS +R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg +TGltaXRlZDElMCMGA1UEAwwcVHJ1c3RlZCBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczAeFw0wNDAxMDEw +MDAwMDBaFw0yODEyMzEyMzU5NTlaMH8xCzAJBgNVBAYTAkdCMRswGQYDVQQIDBJHcmVhdGVyIE1h +bmNoZXN0ZXIxEDAOBgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoMEUNvbW9kbyBDQSBMaW1pdGVkMSUw +IwYDVQQDDBxUcnVzdGVkIENlcnRpZmljYXRlIFNlcnZpY2VzMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA33FvNlhTWvI2VFeAxHQIIO0Yfyod5jWaHiWsnOWWfnJSoBVC21ndZHoa0Lh7 +3TkVvFVIxO06AOoxEbrycXQaZ7jPM8yoMa+j49d/vzMtTGo87IvDktJTdyR0nAducPy9C1t2ul/y +/9c3S0pgePfw+spwtOpZqqPOSC+pw7ILfhdyFgymBwwbOM/JYrc/oJOlh0Hyt3BAd9i+FHzjqMB6 +juljatEPmsbS9Is6FARW1O24zG71++IsWL1/T2sr92AkWCTOJu80kTrV44HQsvAEAtdbtz6SrGsS +ivnkBbA7kUlcsutT6vifR4buv5XAwAaf0lteERv0xwQ1KdJVXOTt6wIDAQABo4HJMIHGMB0GA1Ud +DgQWBBTFe1i97doladL3WRaoszLAeydb9DAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB +/zCBgwYDVR0fBHwwejA8oDqgOIY2aHR0cDovL2NybC5jb21vZG9jYS5jb20vVHJ1c3RlZENlcnRp +ZmljYXRlU2VydmljZXMuY3JsMDqgOKA2hjRodHRwOi8vY3JsLmNvbW9kby5uZXQvVHJ1c3RlZENl +cnRpZmljYXRlU2VydmljZXMuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQDIk4E7ibSvuIQSTI3S8Ntw +uleGFTQQuS9/HrCoiWChisJ3DFBKmwCL2Iv0QeLQg4pKHBQGsKNoBXAxMKdTmw7pSqBYaWcOrp32 +pSxBvzwGa+RZzG0Q8ZZvH9/0BAKkn0U+yNj6NkZEUD+Cl5EfKNsYEYwq5GWDVxISjBc/lDb+XbDA +BHcTuPQV1T84zJQ6VdCsmPW6AF/ghhmBeC8owH7TzEIK9a5QoNE+xqFx7D+gIIxmOom0jtTYsU0l +R+4viMi14QVFwL4Ucd56/Y57fU0IlqUSc/AtyjcndBInTMu2l+nZrghtWjlA3QVHdWpaIbOjGM9O +9y5Xt5hwXsjEeLBi +-----END CERTIFICATE----- + +QuoVadis Root CA +================ +-----BEGIN CERTIFICATE----- +MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE +ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 +eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz +MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp +cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD +EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk +J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL +F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL +YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen +AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w +PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y +ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7 +MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj +YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs +ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh +Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW +Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu +BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw +FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6 +tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo +fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul +LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x +gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi +5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi +5nrQNiOKSnQ2+Q== +-----END CERTIFICATE----- + +QuoVadis Root CA 2 +================== +-----BEGIN CERTIFICATE----- +MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT +EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx +ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6 +XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk +lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB +lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy +lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt +66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn +wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh +D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy +BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie +J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud +DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU +a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT +ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv +Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3 +UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm +VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK ++JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW +IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1 +WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X +f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II +4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8 +VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u +-----END CERTIFICATE----- + +QuoVadis Root CA 3 +================== +-----BEGIN CERTIFICATE----- +MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT +EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx +OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg +DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij +KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K +DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv +BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp +p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8 +nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX +MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM +Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz +uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT +BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj +YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0 +aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB +BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD +VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4 +ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE +AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV +qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s +hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z +POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2 +Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp +8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC +bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu +g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p +vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr +qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto= +-----END CERTIFICATE----- + +Security Communication Root CA +============================== +-----BEGIN CERTIFICATE----- +MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP +U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw +HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP +U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw +8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM +DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX +5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd +DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2 +JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw +DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g +0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a +mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ +s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ +6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi +FL39vmwLAw== +-----END CERTIFICATE----- + +Sonera Class 2 Root CA +====================== +-----BEGIN CERTIFICATE----- +MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG +U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw +NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh +IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3 +/Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT +dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG +f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P +tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH +nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT +XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt +0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI +cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph +Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx +EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH +llpwrN9M +-----END CERTIFICATE----- + +Staat der Nederlanden Root CA +============================= +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgIEAJiWijANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJOTDEeMBwGA1UE +ChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSYwJAYDVQQDEx1TdGFhdCBkZXIgTmVkZXJsYW5kZW4g +Um9vdCBDQTAeFw0wMjEyMTcwOTIzNDlaFw0xNTEyMTYwOTE1MzhaMFUxCzAJBgNVBAYTAk5MMR4w +HAYDVQQKExVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xJjAkBgNVBAMTHVN0YWF0IGRlciBOZWRlcmxh +bmRlbiBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmNK1URF6gaYUmHFt +vsznExvWJw56s2oYHLZhWtVhCb/ekBPHZ+7d89rFDBKeNVU+LCeIQGv33N0iYfXCxw719tV2U02P +jLwYdjeFnejKScfST5gTCaI+Ioicf9byEGW07l8Y1Rfj+MX94p2i71MOhXeiD+EwR+4A5zN9RGca +C1Hoi6CeUJhoNFIfLm0B8mBF8jHrqTFoKbt6QZ7GGX+UtFE5A3+y3qcym7RHjm+0Sq7lr7HcsBth +vJly3uSJt3omXdozSVtSnA71iq3DuD3oBmrC1SoLbHuEvVYFy4ZlkuxEK7COudxwC0barbxjiDn6 +22r+I/q85Ej0ZytqERAhSQIDAQABo4GRMIGOMAwGA1UdEwQFMAMBAf8wTwYDVR0gBEgwRjBEBgRV +HSAAMDwwOgYIKwYBBQUHAgEWLmh0dHA6Ly93d3cucGtpb3ZlcmhlaWQubmwvcG9saWNpZXMvcm9v +dC1wb2xpY3kwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSofeu8Y6R0E3QA7Jbg0zTBLL9s+DAN +BgkqhkiG9w0BAQUFAAOCAQEABYSHVXQ2YcG70dTGFagTtJ+k/rvuFbQvBgwp8qiSpGEN/KtcCFtR +EytNwiphyPgJWPwtArI5fZlmgb9uXJVFIGzmeafR2Bwp/MIgJ1HI8XxdNGdphREwxgDS1/PTfLbw +MVcoEoJz6TMvplW0C5GUR5z6u3pCMuiufi3IvKwUv9kP2Vv8wfl6leF9fpb8cbDCTMjfRTTJzg3y +nGQI0DvDKcWy7ZAEwbEpkcUwb8GpcjPM/l0WFywRaed+/sWDCN+83CI6LiBpIzlWYGeQiy52OfsR +iJf2fL1LuCAWZwWN4jvBcj+UlTfHXbme2JOhF4//DGYVwSR8MnwDHTuhWEUykw== +-----END CERTIFICATE----- + +TDC Internet Root CA +==================== +-----BEGIN CERTIFICATE----- +MIIEKzCCAxOgAwIBAgIEOsylTDANBgkqhkiG9w0BAQUFADBDMQswCQYDVQQGEwJESzEVMBMGA1UE +ChMMVERDIEludGVybmV0MR0wGwYDVQQLExRUREMgSW50ZXJuZXQgUm9vdCBDQTAeFw0wMTA0MDUx +NjMzMTdaFw0yMTA0MDUxNzAzMTdaMEMxCzAJBgNVBAYTAkRLMRUwEwYDVQQKEwxUREMgSW50ZXJu +ZXQxHTAbBgNVBAsTFFREQyBJbnRlcm5ldCBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEAxLhAvJHVYx/XmaCLDEAedLdInUaMArLgJF/wGROnN4NrXceO+YQwzho7+vvOi20j +xsNuZp+Jpd/gQlBn+h9sHvTQBda/ytZO5GhgbEaqHF1j4QeGDmUApy6mcca8uYGoOn0a0vnRrEvL +znWv3Hv6gXPU/Lq9QYjUdLP5Xjg6PEOo0pVOd20TDJ2PeAG3WiAfAzc14izbSysseLlJ28TQx5yc +5IogCSEWVmb/Bexb4/DPqyQkXsN/cHoSxNK1EKC2IeGNeGlVRGn1ypYcNIUXJXfi9i8nmHj9eQY6 +otZaQ8H/7AQ77hPv01ha/5Lr7K7a8jcDR0G2l8ktCkEiu7vmpwIDAQABo4IBJTCCASEwEQYJYIZI +AYb4QgEBBAQDAgAHMGUGA1UdHwReMFwwWqBYoFakVDBSMQswCQYDVQQGEwJESzEVMBMGA1UEChMM +VERDIEludGVybmV0MR0wGwYDVQQLExRUREMgSW50ZXJuZXQgUm9vdCBDQTENMAsGA1UEAxMEQ1JM +MTArBgNVHRAEJDAigA8yMDAxMDQwNTE2MzMxN1qBDzIwMjEwNDA1MTcwMzE3WjALBgNVHQ8EBAMC +AQYwHwYDVR0jBBgwFoAUbGQBx/2FbazI2p5QCIUItTxWqFAwHQYDVR0OBBYEFGxkAcf9hW2syNqe +UAiFCLU8VqhQMAwGA1UdEwQFMAMBAf8wHQYJKoZIhvZ9B0EABBAwDhsIVjUuMDo0LjADAgSQMA0G +CSqGSIb3DQEBBQUAA4IBAQBOQ8zR3R0QGwZ/t6T609lN+yOfI1Rb5osvBCiLtSdtiaHsmGnc540m +gwV5dOy0uaOXwTUA/RXaOYE6lTGQ3pfphqiZdwzlWqCE/xIWrG64jcN7ksKsLtB9KOy282A4aW8+ +2ARVPp7MVdK6/rtHBNcK2RYKNCn1WBPVT8+PVkuzHu7TmHnaCB4Mb7j4Fifvwm899qNLPg7kbWzb +O0ESm70NRyN/PErQr8Cv9u8btRXE64PECV90i9kR+8JWsTz4cMo0jUNAE4z9mQNUecYu6oah9jrU +Cbz0vGbMPVjQV0kK7iXiQe4T+Zs4NNEA9X7nlB38aQNiuJkFBT1reBK9sG9l +-----END CERTIFICATE----- + +TDC OCES Root CA +================ +-----BEGIN CERTIFICATE----- +MIIFGTCCBAGgAwIBAgIEPki9xDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJESzEMMAoGA1UE +ChMDVERDMRQwEgYDVQQDEwtUREMgT0NFUyBDQTAeFw0wMzAyMTEwODM5MzBaFw0zNzAyMTEwOTA5 +MzBaMDExCzAJBgNVBAYTAkRLMQwwCgYDVQQKEwNUREMxFDASBgNVBAMTC1REQyBPQ0VTIENBMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArGL2YSCyz8DGhdfjeebM7fI5kqSXLmSjhFuH +nEz9pPPEXyG9VhDr2y5h7JNp46PMvZnDBfwGuMo2HP6QjklMxFaaL1a8z3sM8W9Hpg1DTeLpHTk0 +zY0s2RKY+ePhwUp8hjjEqcRhiNJerxomTdXkoCJHhNlktxmW/OwZ5LKXJk5KTMuPJItUGBxIYXvV +iGjaXbXqzRowwYCDdlCqT9HU3Tjw7xb04QxQBr/q+3pJoSgrHPb8FTKjdGqPqcNiKXEx5TukYBde +dObaE+3pHx8b0bJoc8YQNHVGEBDjkAB2QMuLt0MJIf+rTpPGWOmlgtt3xDqZsXKVSQTwtyv6e1mO +3QIDAQABo4ICNzCCAjMwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwgewGA1UdIASB +5DCB4TCB3gYIKoFQgSkBAQEwgdEwLwYIKwYBBQUHAgEWI2h0dHA6Ly93d3cuY2VydGlmaWthdC5k +ay9yZXBvc2l0b3J5MIGdBggrBgEFBQcCAjCBkDAKFgNUREMwAwIBARqBgUNlcnRpZmlrYXRlciBm +cmEgZGVubmUgQ0EgdWRzdGVkZXMgdW5kZXIgT0lEIDEuMi4yMDguMTY5LjEuMS4xLiBDZXJ0aWZp +Y2F0ZXMgZnJvbSB0aGlzIENBIGFyZSBpc3N1ZWQgdW5kZXIgT0lEIDEuMi4yMDguMTY5LjEuMS4x +LjARBglghkgBhvhCAQEEBAMCAAcwgYEGA1UdHwR6MHgwSKBGoESkQjBAMQswCQYDVQQGEwJESzEM +MAoGA1UEChMDVERDMRQwEgYDVQQDEwtUREMgT0NFUyBDQTENMAsGA1UEAxMEQ1JMMTAsoCqgKIYm +aHR0cDovL2NybC5vY2VzLmNlcnRpZmlrYXQuZGsvb2Nlcy5jcmwwKwYDVR0QBCQwIoAPMjAwMzAy +MTEwODM5MzBagQ8yMDM3MDIxMTA5MDkzMFowHwYDVR0jBBgwFoAUYLWF7FZkfhIZJ2cdUBVLc647 ++RIwHQYDVR0OBBYEFGC1hexWZH4SGSdnHVAVS3OuO/kSMB0GCSqGSIb2fQdBAAQQMA4bCFY2LjA6 +NC4wAwIEkDANBgkqhkiG9w0BAQUFAAOCAQEACromJkbTc6gJ82sLMJn9iuFXehHTuJTXCRBuo7E4 +A9G28kNBKWKnctj7fAXmMXAnVBhOinxO5dHKjHiIzxvTkIvmI/gLDjNDfZziChmPyQE+dF10yYsc +A+UYyAFMP8uXBV2YcaaYb7Z8vTd/vuGTJW1v8AqtFxjhA7wHKcitJuj4YfD9IQl+mo6paH1IYnK9 +AOoBmbgGglGBTvH1tJFUuSN6AJqfXY3gPGS5GhKSKseCRHI53OI8xthV9RVOyAUO28bQYqbsFbS1 +AoLbrIyigfCbmTH1ICCoiGEKB5+U/NDXG8wuF/MEJ3Zn61SD/aSQfgY9BKNDLdr8C2LqL19iUw== +-----END CERTIFICATE----- + +UTN DATACorp SGC Root CA +======================== +-----BEGIN CERTIFICATE----- +MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UE +BhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwGA1UEChMVVGhl +IFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZ +BgNVBAMTElVUTiAtIERBVEFDb3JwIFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBa +MIGTMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4w +HAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cudXNlcnRy +dXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ys +raP6LnD43m77VkIVni5c7yPeIbkFdicZD0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlo +wHDyUwDAXlCCpVZvNvlK4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA +9P4yPykqlXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulWbfXv +33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQABo4GrMIGoMAsGA1Ud +DwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRTMtGzz3/64PGgXYVOktKeRR20TzA9 +BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3JsLnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dD +LmNybDAqBgNVHSUEIzAhBggrBgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3 +DQEBBQUAA4IBAQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft +Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyjj98C5OBxOvG0 +I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVHKWss5nbZqSl9Mt3JNjy9rjXx +EZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwP +DPafepE39peC4N1xaf92P2BNPM/3mfnGV/TJVTl4uix5yaaIK/QI +-----END CERTIFICATE----- + +UTN USERFirst Hardware Root CA +============================== +-----BEGIN CERTIFICATE----- +MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCBlzELMAkGA1UE +BhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwGA1UEChMVVGhl +IFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAd +BgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgx +OTIyWjCBlzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0 +eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVz +ZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdhcmUwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlI +wrthdBKWHTxqctU8EGc6Oe0rE81m65UJM6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFd +tqdt++BxF2uiiPsA3/4aMXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8 +i4fDidNdoI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqIDsjf +Pe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9KsyoUhbAgMBAAGjgbkw +gbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFKFyXyYbKJhDlV0HN9WF +lp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNF +UkZpcnN0LUhhcmR3YXJlLmNybDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUF +BwMGBggrBgEFBQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM +//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28GpgoiskliCE7/yMgUsogW +XecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gECJChicsZUN/KHAG8HQQZexB2 +lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kn +iCrVWFCVH/A7HFe7fRQ5YiuayZSSKqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67 +nfhmqA== +-----END CERTIFICATE----- + +Camerfirma Chambers of Commerce Root +==================================== +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBADANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJFVTEnMCUGA1UEChMe +QUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1i +ZXJzaWduLm9yZzEiMCAGA1UEAxMZQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdDAeFw0wMzA5MzAx +NjEzNDNaFw0zNzA5MzAxNjEzNDRaMH8xCzAJBgNVBAYTAkVVMScwJQYDVQQKEx5BQyBDYW1lcmZp +cm1hIFNBIENJRiBBODI3NDMyODcxIzAhBgNVBAsTGmh0dHA6Ly93d3cuY2hhbWJlcnNpZ24ub3Jn +MSIwIAYDVQQDExlDaGFtYmVycyBvZiBDb21tZXJjZSBSb290MIIBIDANBgkqhkiG9w0BAQEFAAOC +AQ0AMIIBCAKCAQEAtzZV5aVdGDDg2olUkfzIx1L4L1DZ77F1c2VHfRtbunXF/KGIJPov7coISjlU +xFF6tdpg6jg8gbLL8bvZkSM/SAFwdakFKq0fcfPJVD0dBmpAPrMMhe5cG3nCYsS4No41XQEMIwRH +NaqbYE6gZj3LJgqcQKH0XZi/caulAGgq7YN6D6IUtdQis4CwPAxaUWktWBiP7Zme8a7ileb2R6jW +DA+wWFjbw2Y3npuRVDM30pQcakjJyfKl2qUMI/cjDpwyVV5xnIQFUZot/eZOKjRa3spAN2cMVCFV +d9oKDMyXroDclDZK9D7ONhMeU+SsTjoF7Nuucpw4i9A5O4kKPnf+dQIBA6OCAUQwggFAMBIGA1Ud +EwEB/wQIMAYBAf8CAQwwPAYDVR0fBDUwMzAxoC+gLYYraHR0cDovL2NybC5jaGFtYmVyc2lnbi5v +cmcvY2hhbWJlcnNyb290LmNybDAdBgNVHQ4EFgQU45T1sU3p26EpW1eLTXYGduHRooowDgYDVR0P +AQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzAnBgNVHREEIDAegRxjaGFtYmVyc3Jvb3RAY2hh +bWJlcnNpZ24ub3JnMCcGA1UdEgQgMB6BHGNoYW1iZXJzcm9vdEBjaGFtYmVyc2lnbi5vcmcwWAYD +VR0gBFEwTzBNBgsrBgEEAYGHLgoDATA+MDwGCCsGAQUFBwIBFjBodHRwOi8vY3BzLmNoYW1iZXJz +aWduLm9yZy9jcHMvY2hhbWJlcnNyb290Lmh0bWwwDQYJKoZIhvcNAQEFBQADggEBAAxBl8IahsAi +fJ/7kPMa0QOx7xP5IV8EnNrJpY0nbJaHkb5BkAFyk+cefV/2icZdp0AJPaxJRUXcLo0waLIJuvvD +L8y6C98/d3tGfToSJI6WjzwFCm/SlCgdbQzALogi1djPHRPH8EjX1wWnz8dHnjs8NMiAT9QUu/wN +UPf6s+xCX6ndbcj0dc97wXImsQEcXCz9ek60AcUFV7nnPKoF2YjpB0ZBzu9Bga5Y34OirsrXdx/n +ADydb47kMgkdTXg0eDQ8lJsm7U9xxhl6vSAiSFr+S30Dt+dYvsYyTnQeaN2oaFuzPu5ifdmA6Ap1 +erfutGWaIZDgqtCYvDi1czyL+Nw= +-----END CERTIFICATE----- + +Camerfirma Global Chambersign Root +================================== +-----BEGIN CERTIFICATE----- +MIIExTCCA62gAwIBAgIBADANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJFVTEnMCUGA1UEChMe +QUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1i +ZXJzaWduLm9yZzEgMB4GA1UEAxMXR2xvYmFsIENoYW1iZXJzaWduIFJvb3QwHhcNMDMwOTMwMTYx +NDE4WhcNMzcwOTMwMTYxNDE4WjB9MQswCQYDVQQGEwJFVTEnMCUGA1UEChMeQUMgQ2FtZXJmaXJt +YSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEg +MB4GA1UEAxMXR2xvYmFsIENoYW1iZXJzaWduIFJvb3QwggEgMA0GCSqGSIb3DQEBAQUAA4IBDQAw +ggEIAoIBAQCicKLQn0KuWxfH2H3PFIP8T8mhtxOviteePgQKkotgVvq0Mi+ITaFgCPS3CU6gSS9J +1tPfnZdan5QEcOw/Wdm3zGaLmFIoCQLfxS+EjXqXd7/sQJ0lcqu1PzKY+7e3/HKE5TWH+VX6ox8O +by4o3Wmg2UIQxvi1RMLQQ3/bvOSiPGpVeAp3qdjqGTK3L/5cPxvusZjsyq16aUXjlg9V9ubtdepl +6DJWk0aJqCWKZQbua795B9Dxt6/tLE2Su8CoX6dnfQTyFQhwrJLWfQTSM/tMtgsL+xrJxI0DqX5c +8lCrEqWhz0hQpe/SyBoT+rB/sYIcd2oPX9wLlY/vQ37mRQklAgEDo4IBUDCCAUwwEgYDVR0TAQH/ +BAgwBgEB/wIBDDA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3JsLmNoYW1iZXJzaWduLm9yZy9j +aGFtYmVyc2lnbnJvb3QuY3JsMB0GA1UdDgQWBBRDnDafsJ4wTcbOX60Qq+UDpfqpFDAOBgNVHQ8B +Af8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgAHMCoGA1UdEQQjMCGBH2NoYW1iZXJzaWducm9vdEBj +aGFtYmVyc2lnbi5vcmcwKgYDVR0SBCMwIYEfY2hhbWJlcnNpZ25yb290QGNoYW1iZXJzaWduLm9y +ZzBbBgNVHSAEVDBSMFAGCysGAQQBgYcuCgEBMEEwPwYIKwYBBQUHAgEWM2h0dHA6Ly9jcHMuY2hh +bWJlcnNpZ24ub3JnL2Nwcy9jaGFtYmVyc2lnbnJvb3QuaHRtbDANBgkqhkiG9w0BAQUFAAOCAQEA +PDtwkfkEVCeR4e3t/mh/YV3lQWVPMvEYBZRqHN4fcNs+ezICNLUMbKGKfKX0j//U2K0X1S0E0T9Y +gOKBWYi+wONGkyT+kL0mojAt6JcmVzWJdJYY9hXiryQZVgICsroPFOrGimbBhkVVi76SvpykBMdJ +PJ7oKXqJ1/6v/2j1pReQvayZzKWGVwlnRtvWFsJG8eSpUPWP0ZIV018+xgBJOm5YstHRJw0lyDL4 +IBHNfTIzSJRUTN3cecQwn+uOuFW114hcxWokPbLTBQNRxgfvzBRydD1ucs4YKIxKoHflCStFREes +t2d/AYoFWpO+ocH/+OcOZ6RHSXZddZAa9SaP8A== +-----END CERTIFICATE----- + +NetLock Notary (Class A) Root +============================= +-----BEGIN CERTIFICATE----- +MIIGfTCCBWWgAwIBAgICAQMwDQYJKoZIhvcNAQEEBQAwga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQI +EwdIdW5nYXJ5MREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6 +dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9j +ayBLb3pqZWd5em9pIChDbGFzcyBBKSBUYW51c2l0dmFueWtpYWRvMB4XDTk5MDIyNDIzMTQ0N1oX +DTE5MDIxOTIzMTQ0N1owga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQIEwdIdW5nYXJ5MREwDwYDVQQH +EwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6dG9uc2FnaSBLZnQuMRowGAYD +VQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9jayBLb3pqZWd5em9pIChDbGFz +cyBBKSBUYW51c2l0dmFueWtpYWRvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvHSM +D7tM9DceqQWC2ObhbHDqeLVu0ThEDaiDzl3S1tWBxdRL51uUcCbbO51qTGL3cfNk1mE7PetzozfZ +z+qMkjvN9wfcZnSX9EUi3fRc4L9t875lM+QVOr/bmJBVOMTtplVjC7B4BPTjbsE/jvxReB+SnoPC +/tmwqcm8WgD/qaiYdPv2LD4VOQ22BFWoDpggQrOxJa1+mm9dU7GrDPzr4PN6s6iz/0b2Y6LYOph7 +tqyF/7AlT3Rj5xMHpQqPBffAZG9+pyeAlt7ULoZgx2srXnN7F+eRP2QM2EsiNCubMvJIH5+hCoR6 +4sKtlz2O1cH5VqNQ6ca0+pii7pXmKgOM3wIDAQABo4ICnzCCApswDgYDVR0PAQH/BAQDAgAGMBIG +A1UdEwEB/wQIMAYBAf8CAQQwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaC +Ak1GSUdZRUxFTSEgRXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pv +bGdhbHRhdGFzaSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQu +IEEgaGl0ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2Vn +LWJpenRvc2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0 +ZXRlbGUgYXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFz +IGxlaXJhc2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGphbiBh +IGh0dHBzOi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRvIGF6IGVsbGVu +b3J6ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRoZSBpc3N1YW5jZSBh +bmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3QgdG8gdGhlIE5ldExvY2sg +Q1BTIGF2YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFp +bCBhdCBjcHNAbmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUAA4IBAQBIJEb3ulZv+sgoA0BO5TE5 +ayZrU3/b39/zcT0mwBQOxmd7I6gMc90Bu8bKbjc5VdXHjFYgDigKDtIqpLBJUsY4B/6+CgmM0ZjP +ytoUMaFP0jn8DxEsQ8Pdq5PHVT5HfBgaANzze9jyf1JsIPQLX2lS9O74silg6+NJMSEN1rUQQeJB +CWziGppWS3cC9qCbmieH6FUpccKQn0V4GuEVZD3QDtigdp+uxdAu6tYPVuxkf1qbFFgBJ34TUMdr +KuZoPL9coAob4Q566eKAw+np9v1sEZ7Q5SgnK1QyQhSCdeZK8CtmdWOMovsEPoMOmzbwGOQmIMOM +8CgHrTwXZoi1/baI +-----END CERTIFICATE----- + +NetLock Business (Class B) Root +=============================== +-----BEGIN CERTIFICATE----- +MIIFSzCCBLSgAwIBAgIBaTANBgkqhkiG9w0BAQQFADCBmTELMAkGA1UEBhMCSFUxETAPBgNVBAcT +CEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0b25zYWdpIEtmdC4xGjAYBgNV +BAsTEVRhbnVzaXR2YW55a2lhZG9rMTIwMAYDVQQDEylOZXRMb2NrIFV6bGV0aSAoQ2xhc3MgQikg +VGFudXNpdHZhbnlraWFkbzAeFw05OTAyMjUxNDEwMjJaFw0xOTAyMjAxNDEwMjJaMIGZMQswCQYD +VQQGEwJIVTERMA8GA1UEBxMIQnVkYXBlc3QxJzAlBgNVBAoTHk5ldExvY2sgSGFsb3phdGJpenRv +bnNhZ2kgS2Z0LjEaMBgGA1UECxMRVGFudXNpdHZhbnlraWFkb2sxMjAwBgNVBAMTKU5ldExvY2sg +VXpsZXRpIChDbGFzcyBCKSBUYW51c2l0dmFueWtpYWRvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB +iQKBgQCx6gTsIKAjwo84YM/HRrPVG/77uZmeBNwcf4xKgZjupNTKihe5In+DCnVMm8Bp2GQ5o+2S +o/1bXHQawEfKOml2mrriRBf8TKPV/riXiK+IA4kfpPIEPsgHC+b5sy96YhQJRhTKZPWLgLViqNhr +1nGTLbO/CVRY7QbrqHvcQ7GhaQIDAQABo4ICnzCCApswEgYDVR0TAQH/BAgwBgEB/wIBBDAOBgNV +HQ8BAf8EBAMCAAYwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1GSUdZ +RUxFTSEgRXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pvbGdhbHRh +dGFzaSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQuIEEgaGl0 +ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2VnLWJpenRv +c2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUg +YXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFzIGxlaXJh +c2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGphbiBhIGh0dHBz +Oi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRvIGF6IGVsbGVub3J6ZXNA +bmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRoZSBpc3N1YW5jZSBhbmQgdGhl +IHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3QgdG8gdGhlIE5ldExvY2sgQ1BTIGF2 +YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBj +cHNAbmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUAA4GBAATbrowXr/gOkDFOzT4JwG06sPgzTEdM +43WIEJessDgVkcYplswhwG08pXTP2IKlOcNl40JwuyKQ433bNXbhoLXan3BukxowOR0w2y7jfLKR +stE3Kfq51hdcR0/jHTjrn9V7lagonhVK0dHQKwCXoOKSNitjrFgBazMpUIaD8QFI +-----END CERTIFICATE----- + +NetLock Express (Class C) Root +============================== +-----BEGIN CERTIFICATE----- +MIIFTzCCBLigAwIBAgIBaDANBgkqhkiG9w0BAQQFADCBmzELMAkGA1UEBhMCSFUxETAPBgNVBAcT +CEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0b25zYWdpIEtmdC4xGjAYBgNV +BAsTEVRhbnVzaXR2YW55a2lhZG9rMTQwMgYDVQQDEytOZXRMb2NrIEV4cHJlc3N6IChDbGFzcyBD +KSBUYW51c2l0dmFueWtpYWRvMB4XDTk5MDIyNTE0MDgxMVoXDTE5MDIyMDE0MDgxMVowgZsxCzAJ +BgNVBAYTAkhVMREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6 +dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE0MDIGA1UEAxMrTmV0TG9j +ayBFeHByZXNzeiAoQ2xhc3MgQykgVGFudXNpdHZhbnlraWFkbzCBnzANBgkqhkiG9w0BAQEFAAOB +jQAwgYkCgYEA6+ywbGGKIyWvYCDj2Z/8kwvbXY2wobNAOoLO/XXgeDIDhlqGlZHtU/qdQPzm6N3Z +W3oDvV3zOwzDUXmbrVWg6dADEK8KuhRC2VImESLH0iDMgqSaqf64gXadarfSNnU+sYYJ9m5tfk63 +euyucYT2BDMIJTLrdKwWRMbkQJMdf60CAwEAAaOCAp8wggKbMBIGA1UdEwEB/wQIMAYBAf8CAQQw +DgYDVR0PAQH/BAQDAgAGMBEGCWCGSAGG+EIBAQQEAwIABzCCAmAGCWCGSAGG+EIBDQSCAlEWggJN +RklHWUVMRU0hIEV6ZW4gdGFudXNpdHZhbnkgYSBOZXRMb2NrIEtmdC4gQWx0YWxhbm9zIFN6b2xn +YWx0YXRhc2kgRmVsdGV0ZWxlaWJlbiBsZWlydCBlbGphcmFzb2sgYWxhcGphbiBrZXN6dWx0LiBB +IGhpdGVsZXNpdGVzIGZvbHlhbWF0YXQgYSBOZXRMb2NrIEtmdC4gdGVybWVrZmVsZWxvc3NlZy1i +aXp0b3NpdGFzYSB2ZWRpLiBBIGRpZ2l0YWxpcyBhbGFpcmFzIGVsZm9nYWRhc2FuYWsgZmVsdGV0 +ZWxlIGF6IGVsb2lydCBlbGxlbm9yemVzaSBlbGphcmFzIG1lZ3RldGVsZS4gQXogZWxqYXJhcyBs +ZWlyYXNhIG1lZ3RhbGFsaGF0byBhIE5ldExvY2sgS2Z0LiBJbnRlcm5ldCBob25sYXBqYW4gYSBo +dHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIGNpbWVuIHZhZ3kga2VyaGV0byBheiBlbGxlbm9y +emVzQG5ldGxvY2submV0IGUtbWFpbCBjaW1lbi4gSU1QT1JUQU5UISBUaGUgaXNzdWFuY2UgYW5k +IHRoZSB1c2Ugb2YgdGhpcyBjZXJ0aWZpY2F0ZSBpcyBzdWJqZWN0IHRvIHRoZSBOZXRMb2NrIENQ +UyBhdmFpbGFibGUgYXQgaHR0cHM6Ly93d3cubmV0bG9jay5uZXQvZG9jcyBvciBieSBlLW1haWwg +YXQgY3BzQG5ldGxvY2submV0LjANBgkqhkiG9w0BAQQFAAOBgQAQrX/XDDKACtiG8XmYta3UzbM2 +xJZIwVzNmtkFLp++UOv0JhQQLdRmF/iewSf98e3ke0ugbLWrmldwpu2gpO0u9f38vf5NNwgMvOOW +gyL1SRt/Syu0VMGAfJlOHdCM7tCs5ZL6dVb+ZKATj7i4Fp1hBWeAyNDYpQcCNJgEjTME1A== +-----END CERTIFICATE----- + +XRamp Global CA Root +==================== +-----BEGIN CERTIFICATE----- +MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE +BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj +dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx +HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg +U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu +IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx +foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE +zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs +AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry +xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud +EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap +oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC +AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc +/Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt +qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n +nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz +8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw= +-----END CERTIFICATE----- + +Go Daddy Class 2 CA +=================== +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY +VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG +A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g +RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD +ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv +2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32 +qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j +YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY +vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O +BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o +atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu +MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG +A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim +PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt +I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI +Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b +vZ8= +-----END CERTIFICATE----- + +Starfield Class 2 CA +==================== +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc +U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo +MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG +A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG +SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY +bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ +JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm +epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN +F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF +MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f +hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo +bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g +QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs +afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM +PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl +xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD +KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3 +QBFGmh95DmK/D5fs4C8fF5Q= +-----END CERTIFICATE----- + +StartCom Certification Authority +================================ +-----BEGIN CERTIFICATE----- +MIIHyTCCBbGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMN +U3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmlu +ZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0 +NjM2WhcNMzYwOTE3MTk0NjM2WjB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRk +LjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMg +U3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw +ggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZkpMyONvg45iPwbm2xPN1y +o4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rfOQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/ +Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/CJi/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/d +eMotHweXMAEtcnn6RtYTKqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt +2PZE4XNiHzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMMAv+Z +6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w+2OqqGwaVLRcJXrJ +osmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/ +untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVc +UjyJthkqcwEKDwOzEmDyei+B26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT +37uMdBNSSwIDAQABo4ICUjCCAk4wDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAa4wHQYDVR0OBBYE +FE4L7xqkQFulF2mHMMo0aEPQQa7yMGQGA1UdHwRdMFswLKAqoCiGJmh0dHA6Ly9jZXJ0LnN0YXJ0 +Y29tLm9yZy9zZnNjYS1jcmwuY3JsMCugKaAnhiVodHRwOi8vY3JsLnN0YXJ0Y29tLm9yZy9zZnNj +YS1jcmwuY3JsMIIBXQYDVR0gBIIBVDCCAVAwggFMBgsrBgEEAYG1NwEBATCCATswLwYIKwYBBQUH +AgEWI2h0dHA6Ly9jZXJ0LnN0YXJ0Y29tLm9yZy9wb2xpY3kucGRmMDUGCCsGAQUFBwIBFilodHRw +Oi8vY2VydC5zdGFydGNvbS5vcmcvaW50ZXJtZWRpYXRlLnBkZjCB0AYIKwYBBQUHAgIwgcMwJxYg +U3RhcnQgQ29tbWVyY2lhbCAoU3RhcnRDb20pIEx0ZC4wAwIBARqBl0xpbWl0ZWQgTGlhYmlsaXR5 +LCByZWFkIHRoZSBzZWN0aW9uICpMZWdhbCBMaW1pdGF0aW9ucyogb2YgdGhlIFN0YXJ0Q29tIENl +cnRpZmljYXRpb24gQXV0aG9yaXR5IFBvbGljeSBhdmFpbGFibGUgYXQgaHR0cDovL2NlcnQuc3Rh +cnRjb20ub3JnL3BvbGljeS5wZGYwEQYJYIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilT +dGFydENvbSBGcmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOC +AgEAFmyZ9GYMNPXQhV59CuzaEE44HF7fpiUFS5Eyweg78T3dRAlbB0mKKctmArexmvclmAk8jhvh +3TaHK0u7aNM5Zj2gJsfyOZEdUauCe37Vzlrk4gNXcGmXCPleWKYK34wGmkUWFjgKXlf2Ysd6AgXm +vB618p70qSmD+LIU424oh0TDkBreOKk8rENNZEXO3SipXPJzewT4F+irsfMuXGRuczE6Eri8sxHk +fY+BUZo7jYn0TZNmezwD7dOaHZrzZVD1oNB1ny+v8OqCQ5j4aZyJecRDjkZy42Q2Eq/3JR44iZB3 +fsNrarnDy0RLrHiQi+fHLB5LEUTINFInzQpdn4XBidUaePKVEFMy3YCEZnXZtWgo+2EuvoSoOMCZ +EoalHmdkrQYuL6lwhceWD3yJZfWOQ1QOq92lgDmUYMA0yZZwLKMS9R9Ie70cfmu3nZD0Ijuu+Pwq +yvqCUqDvr0tVk+vBtfAii6w0TiYiBKGHLHVKt+V9E9e4DGTANtLJL4YSjCMJwRuCO3NJo2pXh5Tl +1njFmUNj403gdy3hZZlyaQQaRwnmDwFWJPsfvw55qVguucQJAX6Vum0ABj6y6koQOdjQK/W/7HW/ +lwLFCRsI3FU34oH7N4RDYiDK51ZLZer+bMEkkyShNOsF/5oirpt9P/FlUQqmMGqz9IgcgA38coro +g14= +-----END CERTIFICATE----- + +Taiwan GRCA +=========== +-----BEGIN CERTIFICATE----- +MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQG +EwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4X +DTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1owPzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dv +dmVybm1lbnQgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qN +w8XRIePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1qgQdW8or5 +BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKyyhwOeYHWtXBiCAEuTk8O +1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAtsF/tnyMKtsc2AtJfcdgEWFelq16TheEfO +htX7MfP6Mb40qij7cEwdScevLJ1tZqa2jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wov +J5pGfaENda1UhhXcSTvxls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7 +Q3hub/FCVGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHKYS1t +B6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoHEgKXTiCQ8P8NHuJB +O9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThNXo+EHWbNxWCWtFJaBYmOlXqYwZE8 +lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1UdDgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNV +HRMEBTADAQH/MDkGBGcqBwAEMTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg2 +09yewDL7MTqKUWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ +TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyfqzvS/3WXy6Tj +Zwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaKZEk9GhiHkASfQlK3T8v+R0F2 +Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFEJPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlU +D7gsL0u8qV1bYH+Mh6XgUmMqvtg7hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6Qz +DxARvBMB1uUO07+1EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+Hbk +Z6MmnD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WXudpVBrkk +7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44VbnzssQwmSNOXfJIoRIM3BKQ +CZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDeLMDDav7v3Aun+kbfYNucpllQdSNpc5Oy ++fwC00fmcc4QAu4njIT/rEUNE1yDMuAlpYYsfPQS +-----END CERTIFICATE----- + +Firmaprofesional Root CA +======================== +-----BEGIN CERTIFICATE----- +MIIEVzCCAz+gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBnTELMAkGA1UEBhMCRVMxIjAgBgNVBAcT +GUMvIE11bnRhbmVyIDI0NCBCYXJjZWxvbmExQjBABgNVBAMTOUF1dG9yaWRhZCBkZSBDZXJ0aWZp +Y2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODEmMCQGCSqGSIb3DQEJARYXY2FA +ZmlybWFwcm9mZXNpb25hbC5jb20wHhcNMDExMDI0MjIwMDAwWhcNMTMxMDI0MjIwMDAwWjCBnTEL +MAkGA1UEBhMCRVMxIjAgBgNVBAcTGUMvIE11bnRhbmVyIDI0NCBCYXJjZWxvbmExQjBABgNVBAMT +OUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2 +ODEmMCQGCSqGSIb3DQEJARYXY2FAZmlybWFwcm9mZXNpb25hbC5jb20wggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDnIwNvbyOlXnjOlSztlB5uCp4Bx+ow0Syd3Tfom5h5VtP8c9/Qit5V +j1H5WuretXDE7aTt/6MNbg9kUDGvASdYrv5sp0ovFy3Tc9UTHI9ZpTQsHVQERc1ouKDAA6XPhUJH +lShbz++AbOCQl4oBPB3zhxAwJkh91/zpnZFx/0GaqUC1N5wpIE8fUuOgfRNtVLcK3ulqTgesrBlf +3H5idPayBQC6haD9HThuy1q7hryUZzM1gywfI834yJFxzJeL764P3CkDG8A563DtwW4O2GcLiam8 +NeTvtjS0pbbELaW+0MOUJEjb35bTALVmGotmBQ/dPz/LP6pemkr4tErvlTcbAgMBAAGjgZ8wgZww +KgYDVR0RBCMwIYYfaHR0cDovL3d3dy5maXJtYXByb2Zlc2lvbmFsLmNvbTASBgNVHRMBAf8ECDAG +AQH/AgEBMCsGA1UdEAQkMCKADzIwMDExMDI0MjIwMDAwWoEPMjAxMzEwMjQyMjAwMDBaMA4GA1Ud +DwEB/wQEAwIBBjAdBgNVHQ4EFgQUMwugZtHq2s7eYpMEKFK1FH84aLcwDQYJKoZIhvcNAQEFBQAD +ggEBAEdz/o0nVPD11HecJ3lXV7cVVuzH2Fi3AQL0M+2TUIiefEaxvT8Ub/GzR0iLjJcG1+p+o1wq +u00vR+L4OQbJnC4xGgN49Lw4xiKLMzHwFgQEffl25EvXwOaD7FnMP97/T2u3Z36mhoEyIwOdyPdf +wUpgpZKpsaSgYMN4h7Mi8yrrW6ntBas3D7Hi05V2Y1Z0jFhyGzflZKG+TQyTmAyX9odtsz/ny4Cm +7YjHX1BiAuiZdBbQ5rQ58SfLyEDW44YQqSMSkuBpQWOnryULwMWSyx6Yo1q6xTMPoJcB3X/ge9YG +VM+h4k0460tQtcsm9MracEpqoeJ5quGnM/b9Sh/22WA= +-----END CERTIFICATE----- + +Wells Fargo Root CA +=================== +-----BEGIN CERTIFICATE----- +MIID5TCCAs2gAwIBAgIEOeSXnjANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UEBhMCVVMxFDASBgNV +BAoTC1dlbGxzIEZhcmdvMSwwKgYDVQQLEyNXZWxscyBGYXJnbyBDZXJ0aWZpY2F0aW9uIEF1dGhv +cml0eTEvMC0GA1UEAxMmV2VsbHMgRmFyZ28gUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN +MDAxMDExMTY0MTI4WhcNMjEwMTE0MTY0MTI4WjCBgjELMAkGA1UEBhMCVVMxFDASBgNVBAoTC1dl +bGxzIEZhcmdvMSwwKgYDVQQLEyNXZWxscyBGYXJnbyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEv +MC0GA1UEAxMmV2VsbHMgRmFyZ28gUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVqDM7Jvk0/82bfuUER84A4n135zHCLielTWi5MbqNQ1mX +x3Oqfz1cQJ4F5aHiidlMuD+b+Qy0yGIZLEWukR5zcUHESxP9cMIlrCL1dQu3U+SlK93OvRw6esP3 +E48mVJwWa2uv+9iWsWCaSOAlIiR5NM4OJgALTqv9i86C1y8IcGjBqAr5dE8Hq6T54oN+J3N0Prj5 +OEL8pahbSCOz6+MlsoCultQKnMJ4msZoGK43YjdeUXWoWGPAUe5AeH6orxqg4bB4nVCMe+ez/I4j +sNtlAHCEAQgAFG5Uhpq6zPk3EPbg3oQtnaSFN9OH4xXQwReQfhkhahKpdv0SAulPIV4XAgMBAAGj +YTBfMA8GA1UdEwEB/wQFMAMBAf8wTAYDVR0gBEUwQzBBBgtghkgBhvt7hwcBCzAyMDAGCCsGAQUF +BwIBFiRodHRwOi8vd3d3LndlbGxzZmFyZ28uY29tL2NlcnRwb2xpY3kwDQYJKoZIhvcNAQEFBQAD +ggEBANIn3ZwKdyu7IvICtUpKkfnRLb7kuxpo7w6kAOnu5+/u9vnldKTC2FJYxHT7zmu1Oyl5GFrv +m+0fazbuSCUlFLZWohDo7qd/0D+j0MNdJu4HzMPBJCGHHt8qElNvQRbn7a6U+oxy+hNH8Dx+rn0R +OhPs7fpvcmR7nX1/Jv16+yWt6j4pf0zjAFcysLPp7VMX2YuyFA4w6OXVE8Zkr8QA1dhYJPz1j+zx +x32l2w8n0cbyQIjmH/ZhqPRCyLk306m+LFZ4wnKbWV01QIroTmMatukgalHizqSQ33ZwmVxwQ023 +tqcZZE6St8WRPH9IFmV7Fv3L/PvZ1dZPIWU7Sn9Ho/s= +-----END CERTIFICATE----- + +Swisscom Root CA 1 +================== +-----BEGIN CERTIFICATE----- +MIIF2TCCA8GgAwIBAgIQXAuFXAvnWUHfV8w/f52oNjANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQG +EwJjaDERMA8GA1UEChMIU3dpc3Njb20xJTAjBgNVBAsTHERpZ2l0YWwgQ2VydGlmaWNhdGUgU2Vy +dmljZXMxGzAZBgNVBAMTElN3aXNzY29tIFJvb3QgQ0EgMTAeFw0wNTA4MTgxMjA2MjBaFw0yNTA4 +MTgyMjA2MjBaMGQxCzAJBgNVBAYTAmNoMREwDwYDVQQKEwhTd2lzc2NvbTElMCMGA1UECxMcRGln +aXRhbCBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczEbMBkGA1UEAxMSU3dpc3Njb20gUm9vdCBDQSAxMIIC +IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0LmwqAzZuz8h+BvVM5OAFmUgdbI9m2BtRsiM +MW8Xw/qabFbtPMWRV8PNq5ZJkCoZSx6jbVfd8StiKHVFXqrWW/oLJdihFvkcxC7mlSpnzNApbjyF +NDhhSbEAn9Y6cV9Nbc5fuankiX9qUvrKm/LcqfmdmUc/TilftKaNXXsLmREDA/7n29uj/x2lzZAe +AR81sH8A25Bvxn570e56eqeqDFdvpG3FEzuwpdntMhy0XmeLVNxzh+XTF3xmUHJd1BpYwdnP2IkC +b6dJtDZd0KTeByy2dbcokdaXvij1mB7qWybJvbCXc9qukSbraMH5ORXWZ0sKbU/Lz7DkQnGMU3nn +7uHbHaBuHYwadzVcFh4rUx80i9Fs/PJnB3r1re3WmquhsUvhzDdf/X/NTa64H5xD+SpYVUNFvJbN +cA78yeNmuk6NO4HLFWR7uZToXTNShXEuT46iBhFRyePLoW4xCGQMwtI89Tbo19AOeCMgkckkKmUp +WyL3Ic6DXqTz3kvTaI9GdVyDCW4pa8RwjPWd1yAv/0bSKzjCL3UcPX7ape8eYIVpQtPM+GP+HkM5 +haa2Y0EQs3MevNP6yn0WR+Kn1dCjigoIlmJWbjTb2QK5MHXjBNLnj8KwEUAKrNVxAmKLMb7dxiNY +MUJDLXT5xp6mig/p/r+D5kNXJLrvRjSq1xIBOO0CAwEAAaOBhjCBgzAOBgNVHQ8BAf8EBAMCAYYw +HQYDVR0hBBYwFDASBgdghXQBUwABBgdghXQBUwABMBIGA1UdEwEB/wQIMAYBAf8CAQcwHwYDVR0j +BBgwFoAUAyUv3m+CATpcLNwroWm1Z9SM0/0wHQYDVR0OBBYEFAMlL95vggE6XCzcK6FptWfUjNP9 +MA0GCSqGSIb3DQEBBQUAA4ICAQA1EMvspgQNDQ/NwNurqPKIlwzfky9NfEBWMXrrpA9gzXrzvsMn +jgM+pN0S734edAY8PzHyHHuRMSG08NBsl9Tpl7IkVh5WwzW9iAUPWxAaZOHHgjD5Mq2eUCzneAXQ +MbFamIp1TpBcahQq4FJHgmDmHtqBsfsUC1rxn9KVuj7QG9YVHaO+htXbD8BJZLsuUBlL0iT43R4H +VtA4oJVwIHaM190e3p9xxCPvgxNcoyQVTSlAPGrEqdi3pkSlDfTgnXceQHAm/NrZNuR55LU/vJtl +vrsRls/bxig5OgjOR1tTWsWZ/l2p3e9M1MalrQLmjAcSHm8D0W+go/MpvRLHUKKwf4ipmXeascCl +OS5cfGniLLDqN2qk4Vrh9VDlg++luyqI54zb/W1elxmofmZ1a3Hqv7HHb6D0jqTsNFFbjCYDcKF3 +1QESVwA12yPeDooomf2xEG9L/zgtYE4snOtnta1J7ksfrK/7DZBaZmBwXarNeNQk7shBoJMBkpxq +nvy5JMWzFYJ+vq6VK+uxwNrjAWALXmmshFZhvnEX/h0TD/7Gh0Xp/jKgGg0TpJRVcaUWi7rKibCy +x/yP2FS1k2Kdzs9Z+z0YzirLNRWCXf9UIltxUvu3yf5gmwBBZPCqKuy2QkPOiWaByIufOVQDJdMW +NY6E0F/6MBr1mmz0DlP5OlvRHA== +-----END CERTIFICATE----- + +DigiCert Assured ID Root CA +=========================== +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw +IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx +MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL +ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO +9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy +UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW +/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy +oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf +GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF +66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq +hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc +EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn +SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i +8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe ++o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g== +-----END CERTIFICATE----- + +DigiCert Global Root CA +======================= +-----BEGIN CERTIFICATE----- +MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw +HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw +MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3 +dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq +hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn +TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5 +BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H +4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y +7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB +o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm +8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF +BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr +EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt +tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886 +UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk +CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= +-----END CERTIFICATE----- + +DigiCert High Assurance EV Root CA +================================== +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw +KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw +MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ +MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu +Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t +Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS +OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3 +MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ +NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe +h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB +Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY +JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ +V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp +myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK +mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe +vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K +-----END CERTIFICATE----- + +Certplus Class 2 Primary CA +=========================== +-----BEGIN CERTIFICATE----- +MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAwPTELMAkGA1UE +BhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFzcyAyIFByaW1hcnkgQ0EwHhcN +OTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2Vy +dHBsdXMxGzAZBgNVBAMTEkNsYXNzIDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBANxQltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR +5aiRVhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyLkcAbmXuZ +Vg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCdEgETjdyAYveVqUSISnFO +YFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yasH7WLO7dDWWuwJKZtkIvEcupdM5i3y95e +e++U8Rs+yskhwcWYAqqi9lt3m/V+llU0HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRME +CDAGAQH/AgEKMAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJ +YIZIAYb4QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMuY29t +L0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/AN9WM2K191EBkOvD +P9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8yfFC82x/xXp8HVGIutIKPidd3i1R +TtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMRFcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+ +7UCmnYR0ObncHoUW2ikbhiMAybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW +//1IMwrh3KWBkJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7 +l7+ijrRU +-----END CERTIFICATE----- + +DST Root CA X3 +============== +-----BEGIN CERTIFICATE----- +MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK +ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X +DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1 +cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT +rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9 +UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy +xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d +utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T +AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ +MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug +dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE +GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw +RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS +fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ +-----END CERTIFICATE----- + +DST ACES CA X6 +============== +-----BEGIN CERTIFICATE----- +MIIECTCCAvGgAwIBAgIQDV6ZCtadt3js2AdWO4YV2TANBgkqhkiG9w0BAQUFADBbMQswCQYDVQQG +EwJVUzEgMB4GA1UEChMXRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QxETAPBgNVBAsTCERTVCBBQ0VT +MRcwFQYDVQQDEw5EU1QgQUNFUyBDQSBYNjAeFw0wMzExMjAyMTE5NThaFw0xNzExMjAyMTE5NTha +MFsxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdDERMA8GA1UE +CxMIRFNUIEFDRVMxFzAVBgNVBAMTDkRTVCBBQ0VTIENBIFg2MIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAuT31LMmU3HWKlV1j6IR3dma5WZFcRt2SPp/5DgO0PWGSvSMmtWPuktKe1jzI +DZBfZIGxqAgNTNj50wUoUrQBJcWVHAx+PhCEdc/BGZFjz+iokYi5Q1K7gLFViYsx+tC3dr5BPTCa +pCIlF3PoHuLTrCq9Wzgh1SpL11V94zpVvddtawJXa+ZHfAjIgrrep4c9oW24MFbCswKBXy314pow +GCi4ZtPLAZZv6opFVdbgnf9nKxcCpk4aahELfrd755jWjHZvwTvbUJN+5dCOHze4vbrGn2zpfDPy +MjwmR/onJALJfh1biEITajV8fTXpLmaRcpPVMibEdPVTo7NdmvYJywIDAQABo4HIMIHFMA8GA1Ud +EwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgHGMB8GA1UdEQQYMBaBFHBraS1vcHNAdHJ1c3Rkc3Qu +Y29tMGIGA1UdIARbMFkwVwYKYIZIAWUDAgEBATBJMEcGCCsGAQUFBwIBFjtodHRwOi8vd3d3LnRy +dXN0ZHN0LmNvbS9jZXJ0aWZpY2F0ZXMvcG9saWN5L0FDRVMtaW5kZXguaHRtbDAdBgNVHQ4EFgQU +CXIGThhDD+XWzMNqizF7eI+og7gwDQYJKoZIhvcNAQEFBQADggEBAKPYjtay284F5zLNAdMEA+V2 +5FYrnJmQ6AgwbN99Pe7lv7UkQIRJ4dEorsTCOlMwiPH1d25Ryvr/ma8kXxug/fKshMrfqfBfBC6t +Fr8hlxCBPeP/h40y3JTlR4peahPJlJU90u7INJXQgNStMgiAVDzgvVJT11J8smk/f3rPanTK+gQq +nExaBqXpIK1FZg9p8d2/6eMyi/rgwYZNcjwu2JN4Cir42NInPRmJX1p7ijvMDNpRrscL9yuwNwXs +vFcj4jjSm2jzVhKIT0J8uDHEtdvkyCE06UgRNe76x5JXxZ805Mf29w4LTJxoeHtxMcfrHuBnQfO3 +oKfN5XozNmr6mis= +-----END CERTIFICATE----- + +TURKTRUST Certificate Services Provider Root 1 +============================================== +-----BEGIN CERTIFICATE----- +MIID+zCCAuOgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBtzE/MD0GA1UEAww2VMOcUktUUlVTVCBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGDAJUUjEP +MA0GA1UEBwwGQU5LQVJBMVYwVAYDVQQKDE0oYykgMjAwNSBUw5xSS1RSVVNUIEJpbGdpIMSwbGV0 +acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjAeFw0wNTA1MTMx +MDI3MTdaFw0xNTAzMjIxMDI3MTdaMIG3MT8wPQYDVQQDDDZUw5xSS1RSVVNUIEVsZWt0cm9uaWsg +U2VydGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLExCzAJBgNVBAYMAlRSMQ8wDQYDVQQHDAZB +TktBUkExVjBUBgNVBAoMTShjKSAyMDA1IFTDnFJLVFJVU1QgQmlsZ2kgxLBsZXRpxZ9pbSB2ZSBC +aWxpxZ9pbSBHw7x2ZW5sacSfaSBIaXptZXRsZXJpIEEuxZ4uMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAylIF1mMD2Bxf3dJ7XfIMYGFbazt0K3gNfUW9InTojAPBxhEqPZW8qZSwu5GX +yGl8hMW0kWxsE2qkVa2kheiVfrMArwDCBRj1cJ02i67L5BuBf5OI+2pVu32Fks66WJ/bMsW9Xe8i +Si9BB35JYbOG7E6mQW6EvAPs9TscyB/C7qju6hJKjRTP8wrgUDn5CDX4EVmt5yLqS8oUBt5CurKZ +8y1UiBAG6uEaPj1nH/vO+3yC6BFdSsG5FOpU2WabfIl9BJpiyelSPJ6c79L1JuTm5Rh8i27fbMx4 +W09ysstcP4wFjdFMjK2Sx+F4f2VsSQZQLJ4ywtdKxnWKWU51b0dewQIDAQABoxAwDjAMBgNVHRME +BTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAV9VX/N5aAWSGk/KEVTCD21F/aAyT8z5Aa9CEKmu46 +sWrv7/hg0Uw2ZkUd82YCdAR7kjCo3gp2D++Vbr3JN+YaDayJSFvMgzbC9UZcWYJWtNX+I7TYVBxE +q8Sn5RTOPEFhfEPmzcSBCYsk+1Ql1haolgxnB2+zUEfjHCQo3SqYpGH+2+oSN7wBGjSFvW5P55Fy +B0SFHljKVETd96y5y4khctuPwGkplyqjrhgjlxxBKot8KsF8kOipKMDTkcatKIdAaLX/7KfS0zgY +nNN9aV3wxqUeJBujR/xpB2jn5Jq07Q+hh4cCzofSSE7hvP/L8XKSRGQDJereW26fyfJOrN3H +-----END CERTIFICATE----- + +TURKTRUST Certificate Services Provider Root 2 +============================================== +-----BEGIN CERTIFICATE----- +MIIEPDCCAySgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBvjE/MD0GA1UEAww2VMOcUktUUlVTVCBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJUUjEP +MA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUg +QmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLiAoYykgS2FzxLFtIDIwMDUwHhcN +MDUxMTA3MTAwNzU3WhcNMTUwOTE2MTAwNzU3WjCBvjE/MD0GA1UEAww2VMOcUktUUlVTVCBFbGVr +dHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJUUjEPMA0G +A1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmls +acWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLiAoYykgS2FzxLFtIDIwMDUwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpNn7DkUNMwxmYCMjHWHtPFoylzkkBH3MOrHUTpvqe +LCDe2JAOCtFp0if7qnefJ1Il4std2NiDUBd9irWCPwSOtNXwSadktx4uXyCcUHVPr+G1QRT0mJKI +x+XlZEdhR3n9wFHxwZnn3M5q+6+1ATDcRhzviuyV79z/rxAc653YsKpqhRgNF8k+v/Gb0AmJQv2g +QrSdiVFVKc8bcLyEVK3BEx+Y9C52YItdP5qtygy/p1Zbj3e41Z55SZI/4PGXJHpsmxcPbe9TmJEr +5A++WXkHeLuXlfSfadRYhwqp48y2WBmfJiGxxFmNskF1wK1pzpwACPI2/z7woQ8arBT9pmAPAgMB +AAGjQzBBMB0GA1UdDgQWBBTZN7NOBf3Zz58SFq62iS/rJTqIHDAPBgNVHQ8BAf8EBQMDBwYAMA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHJglrfJ3NgpXiOFX7KzLXb7iNcX/ntt +Rbj2hWyfIvwqECLsqrkw9qtY1jkQMZkpAL2JZkH7dN6RwRgLn7Vhy506vvWolKMiVW4XSf/SKfE4 +Jl3vpao6+XF75tpYHdN0wgH6PmlYX63LaL4ULptswLbcoCb6dxriJNoaN+BnrdFzgw2lGh1uEpJ+ +hGIAF728JRhX8tepb1mIvDS3LoV4nZbcFMMsilKbloxSZj2GFotHuFEJjOp9zYhys2AzsfAKRO8P +9Qk3iCQOLGsgOqL6EfJANZxEaGM7rDNvY7wsu/LSy3Z9fYjYHcgFHW68lKlmjHdxx/qR+i9Rnuk5 +UrbnBEI= +-----END CERTIFICATE----- + +SwissSign Gold CA - G2 +====================== +-----BEGIN CERTIFICATE----- +MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw +EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN +MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp +c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq +t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C +jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg +vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF +ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR +AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend +jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO +peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR +7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi +GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw +AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64 +OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov +L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm +5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr +44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf +Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m +Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp +mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk +vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf +KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br +NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj +viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ +-----END CERTIFICATE----- + +SwissSign Silver CA - G2 +======================== +-----BEGIN CERTIFICATE----- +MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT +BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X +DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3 +aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG +9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644 +N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm ++/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH +6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu +MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h +qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5 +FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs +ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc +celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X +CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB +tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0 +cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P +4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F +kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L +3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx +/uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa +DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP +e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu +WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ +DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub +DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u +-----END CERTIFICATE----- + +GeoTrust Primary Certification Authority +======================================== +-----BEGIN CERTIFICATE----- +MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG +EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx +CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ +cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN +b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9 +nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge +RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt +tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD +AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI +hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K +Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN +NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa +Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG +1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk= +-----END CERTIFICATE----- + +thawte Primary Root CA +====================== +-----BEGIN CERTIFICATE----- +MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE +BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2 +aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3 +MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg +SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv +KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT +FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs +oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ +1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc +q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K +aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p +afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD +VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF +AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE +uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX +xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89 +jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH +z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA== +-----END CERTIFICATE----- + +VeriSign Class 3 Public Primary Certification Authority - G5 +============================================================ +-----BEGIN CERTIFICATE----- +MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk +IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln +biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh +dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt +YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz +j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD +Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/ +Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r +fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/ +BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv +Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy +aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG +SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+ +X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE +KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC +Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE +ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq +-----END CERTIFICATE----- + +SecureTrust CA +============== +-----BEGIN CERTIFICATE----- +MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG +EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy +dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe +BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC +ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX +OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t +DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH +GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b +01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH +ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/ +BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj +aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ +KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu +SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf +mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ +nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR +3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= +-----END CERTIFICATE----- + +Secure Global CA +================ +-----BEGIN CERTIFICATE----- +MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG +EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH +bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg +MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg +Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx +YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ +bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g +8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV +HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi +0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud +EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn +oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA +MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+ +OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn +CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5 +3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc +f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW +-----END CERTIFICATE----- + +COMODO Certification Authority +============================== +-----BEGIN CERTIFICATE----- +MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE +BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG +A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1 +dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb +MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD +T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH ++7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww +xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV +4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA +1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI +rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E +BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k +b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC +AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP +OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/ +RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc +IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN ++8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ== +-----END CERTIFICATE----- + +Network Solutions Certificate Authority +======================================= +-----BEGIN CERTIFICATE----- +MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG +EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr +IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx +MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu +MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx +jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT +aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT +crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc +/Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB +AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv +bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA +A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q +4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/ +GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv +wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD +ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey +-----END CERTIFICATE----- + +WellsSecure Public Root Certificate Authority +============================================= +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoM +F1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYw +NAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN +MDcxMjEzMTcwNzU0WhcNMjIxMjE0MDAwNzU0WjCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dl +bGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYD +VQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDub7S9eeKPCCGeOARBJe+rWxxTkqxtnt3CxC5FlAM1 +iGd0V+PfjLindo8796jE2yljDpFoNoqXjopxaAkH5OjUDk/41itMpBb570OYj7OeUt9tkTmPOL13 +i0Nj67eT/DBMHAGTthP796EfvyXhdDcsHqRePGj4S78NuR4uNuip5Kf4D8uCdXw1LSLWwr8L87T8 +bJVhHlfXBIEyg1J55oNjz7fLY4sR4r1e6/aN7ZVyKLSsEmLpSjPmgzKuBXWVvYSV2ypcm44uDLiB +K0HmOFafSZtsdvqKXfcBeYF8wYNABf5x/Qw/zE5gCQ5lRxAvAcAFP4/4s0HvWkJ+We/SlwxlAgMB +AAGjggE0MIIBMDAPBgNVHRMBAf8EBTADAQH/MDkGA1UdHwQyMDAwLqAsoCqGKGh0dHA6Ly9jcmwu +cGtpLndlbGxzZmFyZ28uY29tL3dzcHJjYS5jcmwwDgYDVR0PAQH/BAQDAgHGMB0GA1UdDgQWBBQm +lRkQ2eihl5H/3BnZtQQ+0nMKajCBsgYDVR0jBIGqMIGngBQmlRkQ2eihl5H/3BnZtQQ+0nMKaqGB +i6SBiDCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRww +GgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMg +Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCAQEwDQYJKoZIhvcNAQEFBQADggEBALkVsUSRzCPI +K0134/iaeycNzXK7mQDKfGYZUMbVmO2rvwNa5U3lHshPcZeG1eMd/ZDJPHV3V3p9+N701NX3leZ0 +bh08rnyd2wIDBSxxSyU+B+NemvVmFymIGjifz6pBA4SXa5M4esowRBskRDPQ5NHcKDj0E0M1NSlj +qHyita04pO2t/caaH/+Xc/77szWnk4bGdpEA5qxRFsQnMlzbc9qlk1eOPm01JghZ1edE13YgY+es +E2fDbbFwRnzVlhE9iW9dqKHrjQrawx0zbKPqZxmamX9LPYNRKh3KL4YMon4QLSvUFpULB6ouFJJJ +tylv2G0xffX8oRAHh84vWdw+WNs= +-----END CERTIFICATE----- + +COMODO ECC Certification Authority +================================== +-----BEGIN CERTIFICATE----- +MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC +R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE +ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix +GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR +Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo +b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X +4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni +wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E +BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG +FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA +U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= +-----END CERTIFICATE----- + +IGC/A +===== +-----BEGIN CERTIFICATE----- +MIIEAjCCAuqgAwIBAgIFORFFEJQwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkZSMQ8wDQYD +VQQIEwZGcmFuY2UxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQTS9TR0ROMQ4wDAYDVQQLEwVE +Q1NTSTEOMAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2LmZy +MB4XDTAyMTIxMzE0MjkyM1oXDTIwMTAxNzE0MjkyMlowgYUxCzAJBgNVBAYTAkZSMQ8wDQYDVQQI +EwZGcmFuY2UxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQTS9TR0ROMQ4wDAYDVQQLEwVEQ1NT +STEOMAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2LmZyMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsh/R0GLFMzvABIaIs9z4iPf930Pfeo2aSVz2 +TqrMHLmh6yeJ8kbpO0px1R2OLc/mratjUMdUC24SyZA2xtgv2pGqaMVy/hcKshd+ebUyiHDKcMCW +So7kVc0dJ5S/znIq7Fz5cyD+vfcuiWe4u0dzEvfRNWk68gq5rv9GQkaiv6GFGvm/5P9JhfejcIYy +HF2fYPepraX/z9E0+X1bF8bc1g4oa8Ld8fUzaJ1O/Id8NhLWo4DoQw1VYZTqZDdH6nfK0LJYBcNd +frGoRpAxVs5wKpayMLh35nnAvSk7/ZR3TL0gzUEl4C7HG7vupARB0l2tEmqKm0f7yd1GQOGdPDPQ +tQIDAQABo3cwdTAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBRjAVBgNVHSAEDjAMMAoGCCqB +egF5AQEBMB0GA1UdDgQWBBSjBS8YYFDCiQrdKyFP/45OqDAxNjAfBgNVHSMEGDAWgBSjBS8YYFDC +iQrdKyFP/45OqDAxNjANBgkqhkiG9w0BAQUFAAOCAQEABdwm2Pp3FURo/C9mOnTgXeQp/wYHE4RK +q89toB9RlPhJy3Q2FLwV3duJL92PoF189RLrn544pEfMs5bZvpwlqwN+Mw+VgQ39FuCIvjfwbF3Q +MZsyK10XZZOYYLxuj7GoPB7ZHPOpJkL5ZB3C55L29B5aqhlSXa/oovdgoPaN8In1buAKBQGVyYsg +Crpa/JosPL3Dt8ldeCUFP1YUmwza+zpI/pdpXsoQhvdOlgQITeywvl3cO45Pwf2aNjSaTFR+FwNI +lQgRHAdvhQh+XU3Endv7rs6y0bO4g2wdsrN58dhwmX7wEwLOXt1R0982gaEbeC9xs/FZTEYYKKuF +0mBWWg== +-----END CERTIFICATE----- + +Security Communication EV RootCA1 +================================= +-----BEGIN CERTIFICATE----- +MIIDfTCCAmWgAwIBAgIBADANBgkqhkiG9w0BAQUFADBgMQswCQYDVQQGEwJKUDElMCMGA1UEChMc +U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEqMCgGA1UECxMhU2VjdXJpdHkgQ29tbXVuaWNh +dGlvbiBFViBSb290Q0ExMB4XDTA3MDYwNjAyMTIzMloXDTM3MDYwNjAyMTIzMlowYDELMAkGA1UE +BhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xKjAoBgNVBAsTIVNl +Y3VyaXR5IENvbW11bmljYXRpb24gRVYgUm9vdENBMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALx/7FebJOD+nLpCeamIivqA4PUHKUPqjgo0No0c+qe1OXj/l3X3L+SqawSERMqm4miO +/VVQYg+kcQ7OBzgtQoVQrTyWb4vVog7P3kmJPdZkLjjlHmy1V4qe70gOzXppFodEtZDkBp2uoQSX +WHnvIEqCa4wiv+wfD+mEce3xDuS4GBPMVjZd0ZoeUWs5bmB2iDQL87PRsJ3KYeJkHcFGB7hj3R4z +ZbOOCVVSPbW9/wfrrWFVGCypaZhKqkDFMxRldAD5kd6vA0jFQFTcD4SQaCDFkpbcLuUCRarAX1T4 +bepJz11sS6/vmsJWXMY1VkJqMF/Cq/biPT+zyRGPMUzXn0kCAwEAAaNCMEAwHQYDVR0OBBYEFDVK +9U2vP9eCOKyrcWUXdYydVZPmMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqG +SIb3DQEBBQUAA4IBAQCoh+ns+EBnXcPBZsdAS5f8hxOQWsTvoMpfi7ent/HWtWS3irO4G8za+6xm +iEHO6Pzk2x6Ipu0nUBsCMCRGef4Eh3CXQHPRwMFXGZpppSeZq51ihPZRwSzJIxXYKLerJRO1RuGG +Av8mjMSIkh1W/hln8lXkgKNrnKt34VFxDSDbEJrbvXZ5B3eZKK2aXtqxT0QsNY6llsf9g/BYxnnW +mHyojf6GPgcWkuF75x3sM3Z+Qi5KhfmRiWiEA4Glm5q+4zfFVKtWOxgtQaQM+ELbmaDgcm+7XeEW +T1MKZPlO9L9OVL14bIjqv5wTJMJwaaJ/D8g8rQjJsJhAoyrniIPtd490 +-----END CERTIFICATE----- + +OISTE WISeKey Global Root GA CA +=============================== +-----BEGIN CERTIFICATE----- +MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UE +BhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHlyaWdodCAoYykgMjAwNTEiMCAG +A1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBH +bG9iYWwgUm9vdCBHQSBDQTAeFw0wNTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYD +VQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIw +IAYDVQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5 +IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0+zAJs9 +Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxRVVuuk+g3/ytr6dTqvirdqFEr12bDYVxg +Asj1znJ7O7jyTmUIms2kahnBAbtzptf2w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbD +d50kc3vkDIzh2TbhmYsFmQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ +/yxViJGg4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t94B3R +LoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw +AwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ +KoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOxSPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vIm +MMkQyh2I+3QZH4VFvbBsUfk2ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4 ++vg1YFkCExh8vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa +hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZiFj4A4xylNoEY +okxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ/L7fCg0= +-----END CERTIFICATE----- + +Microsec e-Szigno Root CA +========================= +-----BEGIN CERTIFICATE----- +MIIHqDCCBpCgAwIBAgIRAMy4579OKRr9otxmpRwsDxEwDQYJKoZIhvcNAQEFBQAwcjELMAkGA1UE +BhMCSFUxETAPBgNVBAcTCEJ1ZGFwZXN0MRYwFAYDVQQKEw1NaWNyb3NlYyBMdGQuMRQwEgYDVQQL +EwtlLVN6aWdubyBDQTEiMCAGA1UEAxMZTWljcm9zZWMgZS1Temlnbm8gUm9vdCBDQTAeFw0wNTA0 +MDYxMjI4NDRaFw0xNzA0MDYxMjI4NDRaMHIxCzAJBgNVBAYTAkhVMREwDwYDVQQHEwhCdWRhcGVz +dDEWMBQGA1UEChMNTWljcm9zZWMgTHRkLjEUMBIGA1UECxMLZS1Temlnbm8gQ0ExIjAgBgNVBAMT +GU1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQDtyADVgXvNOABHzNuEwSFpLHSQDCHZU4ftPkNEU6+r+ICbPHiN1I2uuO/TEdyB5s87lozWbxXG +d36hL+BfkrYn13aaHUM86tnsL+4582pnS4uCzyL4ZVX+LMsvfUh6PXX5qqAnu3jCBspRwn5mS6/N +oqdNAoI/gqyFxuEPkEeZlApxcpMqyabAvjxWTHOSJ/FrtfX9/DAFYJLG65Z+AZHCabEeHXtTRbjc +QR/Ji3HWVBTji1R4P770Yjtb9aPs1ZJ04nQw7wHb4dSrmZsqa/i9phyGI0Jf7Enemotb9HI6QMVJ +PqW+jqpx62z69Rrkav17fVVA71hu5tnVvCSrwe+3AgMBAAGjggQ3MIIEMzBnBggrBgEFBQcBAQRb +MFkwKAYIKwYBBQUHMAGGHGh0dHBzOi8vcmNhLmUtc3ppZ25vLmh1L29jc3AwLQYIKwYBBQUHMAKG +IWh0dHA6Ly93d3cuZS1zemlnbm8uaHUvUm9vdENBLmNydDAPBgNVHRMBAf8EBTADAQH/MIIBcwYD +VR0gBIIBajCCAWYwggFiBgwrBgEEAYGoGAIBAQEwggFQMCgGCCsGAQUFBwIBFhxodHRwOi8vd3d3 +LmUtc3ppZ25vLmh1L1NaU1ovMIIBIgYIKwYBBQUHAgIwggEUHoIBEABBACAAdABhAG4A+gBzAO0A +dAB2AOEAbgB5ACAA6QByAHQAZQBsAG0AZQB6AOkAcwDpAGgAZQB6ACAA6QBzACAAZQBsAGYAbwBn +AGEAZADhAHMA4QBoAG8AegAgAGEAIABTAHoAbwBsAGcA4QBsAHQAYQB0APMAIABTAHoAbwBsAGcA +4QBsAHQAYQB0AOEAcwBpACAAUwB6AGEAYgDhAGwAeQB6AGEAdABhACAAcwB6AGUAcgBpAG4AdAAg +AGsAZQBsAGwAIABlAGwAagDhAHIAbgBpADoAIABoAHQAdABwADoALwAvAHcAdwB3AC4AZQAtAHMA +egBpAGcAbgBvAC4AaAB1AC8AUwBaAFMAWgAvMIHIBgNVHR8EgcAwgb0wgbqggbeggbSGIWh0dHA6 +Ly93d3cuZS1zemlnbm8uaHUvUm9vdENBLmNybIaBjmxkYXA6Ly9sZGFwLmUtc3ppZ25vLmh1L0NO +PU1pY3Jvc2VjJTIwZS1Temlnbm8lMjBSb290JTIwQ0EsT1U9ZS1Temlnbm8lMjBDQSxPPU1pY3Jv +c2VjJTIwTHRkLixMPUJ1ZGFwZXN0LEM9SFU/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdDtiaW5h +cnkwDgYDVR0PAQH/BAQDAgEGMIGWBgNVHREEgY4wgYuBEGluZm9AZS1zemlnbm8uaHWkdzB1MSMw +IQYDVQQDDBpNaWNyb3NlYyBlLVN6aWduw7MgUm9vdCBDQTEWMBQGA1UECwwNZS1TemlnbsOzIEhT +WjEWMBQGA1UEChMNTWljcm9zZWMgS2Z0LjERMA8GA1UEBxMIQnVkYXBlc3QxCzAJBgNVBAYTAkhV +MIGsBgNVHSMEgaQwgaGAFMegSXUWYYTbMUuE0vE3QJDvTtz3oXakdDByMQswCQYDVQQGEwJIVTER +MA8GA1UEBxMIQnVkYXBlc3QxFjAUBgNVBAoTDU1pY3Jvc2VjIEx0ZC4xFDASBgNVBAsTC2UtU3pp +Z25vIENBMSIwIAYDVQQDExlNaWNyb3NlYyBlLVN6aWdubyBSb290IENBghEAzLjnv04pGv2i3Gal +HCwPETAdBgNVHQ4EFgQUx6BJdRZhhNsxS4TS8TdAkO9O3PcwDQYJKoZIhvcNAQEFBQADggEBANMT +nGZjWS7KXHAM/IO8VbH0jgdsZifOwTsgqRy7RlRw7lrMoHfqaEQn6/Ip3Xep1fvj1KcExJW4C+FE +aGAHQzAxQmHl7tnlJNUb3+FKG6qfx1/4ehHqE5MAyopYse7tDk2016g2JnzgOsHVV4Lxdbb9iV/a +86g4nzUGCM4ilb7N1fy+W955a9x6qWVmvrElWl/tftOsRm1M9DKHtCAE4Gx4sHfRhUZLphK3dehK +yVZs15KrnfVJONJPU+NVkBHbmJbGSfI+9J8b4PeI3CVimUTYc78/MPMMNz7UwiiAc7EBt51alhQB +S6kRnSlqLtBdgcDPsiBDxwPgN05dCtxZICU= +-----END CERTIFICATE----- + +Certigna +======== +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw +EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3 +MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI +Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q +XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH +GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p +ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg +DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf +Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ +tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ +BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J +SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA +hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+ +ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu +PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY +1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw +WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg== +-----END CERTIFICATE----- + +AC Ra\xC3\xADz Certic\xC3\xA1mara S.A. +====================================== +-----BEGIN CERTIFICATE----- +MIIGZjCCBE6gAwIBAgIPB35Sk3vgFeNX8GmMy+wMMA0GCSqGSIb3DQEBBQUAMHsxCzAJBgNVBAYT +AkNPMUcwRQYDVQQKDD5Tb2NpZWRhZCBDYW1lcmFsIGRlIENlcnRpZmljYWNpw7NuIERpZ2l0YWwg +LSBDZXJ0aWPDoW1hcmEgUy5BLjEjMCEGA1UEAwwaQUMgUmHDrXogQ2VydGljw6FtYXJhIFMuQS4w +HhcNMDYxMTI3MjA0NjI5WhcNMzAwNDAyMjE0MjAyWjB7MQswCQYDVQQGEwJDTzFHMEUGA1UECgw+ +U29jaWVkYWQgQ2FtZXJhbCBkZSBDZXJ0aWZpY2FjacOzbiBEaWdpdGFsIC0gQ2VydGljw6FtYXJh +IFMuQS4xIzAhBgNVBAMMGkFDIFJhw616IENlcnRpY8OhbWFyYSBTLkEuMIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAq2uJo1PMSCMI+8PPUZYILrgIem08kBeGqentLhM0R7LQcNzJPNCN +yu5LF6vQhbCnIwTLqKL85XXbQMpiiY9QngE9JlsYhBzLfDe3fezTf3MZsGqy2IiKLUV0qPezuMDU +2s0iiXRNWhU5cxh0T7XrmafBHoi0wpOQY5fzp6cSsgkiBzPZkc0OnB8OIMfuuzONj8LSWKdf/WU3 +4ojC2I+GdV75LaeHM/J4Ny+LvB2GNzmxlPLYvEqcgxhaBvzz1NS6jBUJJfD5to0EfhcSM2tXSExP +2yYe68yQ54v5aHxwD6Mq0Do43zeX4lvegGHTgNiRg0JaTASJaBE8rF9ogEHMYELODVoqDA+bMMCm +8Ibbq0nXl21Ii/kDwFJnmxL3wvIumGVC2daa49AZMQyth9VXAnow6IYm+48jilSH5L887uvDdUhf +HjlvgWJsxS3EF1QZtzeNnDeRyPYL1epjb4OsOMLzP96a++EjYfDIJss2yKHzMI+ko6Kh3VOz3vCa +Mh+DkXkwwakfU5tTohVTP92dsxA7SH2JD/ztA/X7JWR1DhcZDY8AFmd5ekD8LVkH2ZD6mq093ICK +5lw1omdMEWux+IBkAC1vImHFrEsm5VoQgpukg3s0956JkSCXjrdCx2bD0Omk1vUgjcTDlaxECp1b +czwmPS9KvqfJpxAe+59QafMCAwEAAaOB5jCB4zAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE +AwIBBjAdBgNVHQ4EFgQU0QnQ6dfOeXRU+Tows/RtLAMDG2gwgaAGA1UdIASBmDCBlTCBkgYEVR0g +ADCBiTArBggrBgEFBQcCARYfaHR0cDovL3d3dy5jZXJ0aWNhbWFyYS5jb20vZHBjLzBaBggrBgEF +BQcCAjBOGkxMaW1pdGFjaW9uZXMgZGUgZ2FyYW507WFzIGRlIGVzdGUgY2VydGlmaWNhZG8gc2Ug +cHVlZGVuIGVuY29udHJhciBlbiBsYSBEUEMuMA0GCSqGSIb3DQEBBQUAA4ICAQBclLW4RZFNjmEf +AygPU3zmpFmps4p6xbD/CHwso3EcIRNnoZUSQDWDg4902zNc8El2CoFS3UnUmjIz75uny3XlesuX +EpBcunvFm9+7OSPI/5jOCk0iAUgHforA1SBClETvv3eiiWdIG0ADBaGJ7M9i4z0ldma/Jre7Ir5v +/zlXdLp6yQGVwZVR6Kss+LGGIOk/yzVb0hfpKv6DExdA7ohiZVvVO2Dpezy4ydV/NgIlqmjCMRW3 +MGXrfx1IebHPOeJCgBbT9ZMj/EyXyVo3bHwi2ErN0o42gzmRkBDI8ck1fj+404HGIGQatlDCIaR4 +3NAvO2STdPCWkPHv+wlaNECW8DYSwaN0jJN+Qd53i+yG2dIPPy3RzECiiWZIHiCznCNZc6lEc7wk +eZBWN7PGKX6jD/EpOe9+XCgycDWs2rjIdWb8m0w5R44bb5tNAlQiM+9hup4phO9OSzNHdpdqy35f +/RWmnkJDW2ZaiogN9xa5P1FlK2Zqi9E4UqLWRhH6/JocdJ6PlwsCT2TG9WjTSy3/pDceiz+/RL5h +RqGEPQgnTIEgd4kI6mdAXmwIUV80WoyWaM3X94nCHNMyAK9Sy9NgWyo6R35rMDOhYil/SrnhLecU +Iw4OGEfhefwVVdCx/CVxY3UzHCMrr1zZ7Ud3YA47Dx7SwNxkBYn8eNZcLCZDqQ== +-----END CERTIFICATE----- + +TC TrustCenter Class 2 CA II +============================ +-----BEGIN CERTIFICATE----- +MIIEqjCCA5KgAwIBAgIOLmoAAQACH9dSISwRXDswDQYJKoZIhvcNAQEFBQAwdjELMAkGA1UEBhMC +REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxIjAgBgNVBAsTGVRDIFRydXN0Q2VudGVy +IENsYXNzIDIgQ0ExJTAjBgNVBAMTHFRDIFRydXN0Q2VudGVyIENsYXNzIDIgQ0EgSUkwHhcNMDYw +MTEyMTQzODQzWhcNMjUxMjMxMjI1OTU5WjB2MQswCQYDVQQGEwJERTEcMBoGA1UEChMTVEMgVHJ1 +c3RDZW50ZXIgR21iSDEiMCAGA1UECxMZVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMiBDQTElMCMGA1UE +AxMcVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMiBDQSBJSTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKuAh5uO8MN8h9foJIIRszzdQ2Lu+MNF2ujhoF/RKrLqk2jftMjWQ+nEdVl//OEd+DFw +IxuInie5e/060smp6RQvkL4DUsFJzfb95AhmC1eKokKguNV/aVyQMrKXDcpK3EY+AlWJU+MaWss2 +xgdW94zPEfRMuzBwBJWl9jmM/XOBCH2JXjIeIqkiRUuwZi4wzJ9l/fzLganx4Duvo4bRierERXlQ +Xa7pIXSSTYtZgo+U4+lK8edJsBTj9WLL1XK9H7nSn6DNqPoByNkN39r8R52zyFTfSUrxIan+GE7u +SNQZu+995OKdy1u2bv/jzVrndIIFuoAlOMvkaZ6vQaoahPUCAwEAAaOCATQwggEwMA8GA1UdEwEB +/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTjq1RMgKHbVkO3kUrL84J6E1wIqzCB +7QYDVR0fBIHlMIHiMIHfoIHcoIHZhjVodHRwOi8vd3d3LnRydXN0Y2VudGVyLmRlL2NybC92Mi90 +Y19jbGFzc18yX2NhX0lJLmNybIaBn2xkYXA6Ly93d3cudHJ1c3RjZW50ZXIuZGUvQ049VEMlMjBU +cnVzdENlbnRlciUyMENsYXNzJTIwMiUyMENBJTIwSUksTz1UQyUyMFRydXN0Q2VudGVyJTIwR21i +SCxPVT1yb290Y2VydHMsREM9dHJ1c3RjZW50ZXIsREM9ZGU/Y2VydGlmaWNhdGVSZXZvY2F0aW9u +TGlzdD9iYXNlPzANBgkqhkiG9w0BAQUFAAOCAQEAjNfffu4bgBCzg/XbEeprS6iSGNn3Bzn1LL4G +dXpoUxUc6krtXvwjshOg0wn/9vYua0Fxec3ibf2uWWuFHbhOIprtZjluS5TmVfwLG4t3wVMTZonZ +KNaL80VKY7f9ewthXbhtvsPcW3nS7Yblok2+XnR8au0WOB9/WIFaGusyiC2y8zl3gK9etmF1Kdsj +TYjKUCjLhdLTEKJZbtOTVAB6okaVhgWcqRmY5TFyDADiZ9lA4CQze28suVyrZZ0srHbqNZn1l7kP +JOzHdiEoZa5X6AeIdUpWoNIFOqTmjZKILPPy4cHGYdtBxceb9w4aUUXCYWvcZCcXjFq32nQozZfk +vQ== +-----END CERTIFICATE----- + +TC TrustCenter Class 3 CA II +============================ +-----BEGIN CERTIFICATE----- +MIIEqjCCA5KgAwIBAgIOSkcAAQAC5aBd1j8AUb8wDQYJKoZIhvcNAQEFBQAwdjELMAkGA1UEBhMC +REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxIjAgBgNVBAsTGVRDIFRydXN0Q2VudGVy +IENsYXNzIDMgQ0ExJTAjBgNVBAMTHFRDIFRydXN0Q2VudGVyIENsYXNzIDMgQ0EgSUkwHhcNMDYw +MTEyMTQ0MTU3WhcNMjUxMjMxMjI1OTU5WjB2MQswCQYDVQQGEwJERTEcMBoGA1UEChMTVEMgVHJ1 +c3RDZW50ZXIgR21iSDEiMCAGA1UECxMZVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMyBDQTElMCMGA1UE +AxMcVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMyBDQSBJSTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALTgu1G7OVyLBMVMeRwjhjEQY0NVJz/GRcekPewJDRoeIMJWHt4bNwcwIi9v8Qbxq63W +yKthoy9DxLCyLfzDlml7forkzMA5EpBCYMnMNWju2l+QVl/NHE1bWEnrDgFPZPosPIlY2C8u4rBo +6SI7dYnWRBpl8huXJh0obazovVkdKyT21oQDZogkAHhg8fir/gKya/si+zXmFtGt9i4S5Po1auUZ +uV3bOx4a+9P/FRQI2AlqukWdFHlgfa9Aigdzs5OW03Q0jTo3Kd5c7PXuLjHCINy+8U9/I1LZW+Jk +2ZyqBwi1Rb3R0DHBq1SfqdLDYmAD8bs5SpJKPQq5ncWg/jcCAwEAAaOCATQwggEwMA8GA1UdEwEB +/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTUovyfs8PYA9NXXAek0CSnwPIA1DCB +7QYDVR0fBIHlMIHiMIHfoIHcoIHZhjVodHRwOi8vd3d3LnRydXN0Y2VudGVyLmRlL2NybC92Mi90 +Y19jbGFzc18zX2NhX0lJLmNybIaBn2xkYXA6Ly93d3cudHJ1c3RjZW50ZXIuZGUvQ049VEMlMjBU +cnVzdENlbnRlciUyMENsYXNzJTIwMyUyMENBJTIwSUksTz1UQyUyMFRydXN0Q2VudGVyJTIwR21i +SCxPVT1yb290Y2VydHMsREM9dHJ1c3RjZW50ZXIsREM9ZGU/Y2VydGlmaWNhdGVSZXZvY2F0aW9u +TGlzdD9iYXNlPzANBgkqhkiG9w0BAQUFAAOCAQEANmDkcPcGIEPZIxpC8vijsrlNirTzwppVMXzE +O2eatN9NDoqTSheLG43KieHPOh6sHfGcMrSOWXaiQYUlN6AT0PV8TtXqluJucsG7Kv5sbviRmEb8 +yRtXW+rIGjs/sFGYPAfaLFkB2otE6OF0/ado3VS6g0bsyEa1+K+XwDsJHI/OcpY9M1ZwvJbL2NV9 +IJqDnxrcOfHFcqMRA/07QlIp2+gB95tejNaNhk4Z+rwcvsUhpYeeeC422wlxo3I0+GzjBgnyXlal +092Y+tTmBvTwtiBjS+opvaqCZh77gaqnN60TGOaSw4HBM7uIHqHn4rS9MWwOUT1v+5ZWgOI2F9Hc +5A== +-----END CERTIFICATE----- + +TC TrustCenter Universal CA I +============================= +-----BEGIN CERTIFICATE----- +MIID3TCCAsWgAwIBAgIOHaIAAQAC7LdggHiNtgYwDQYJKoZIhvcNAQEFBQAweTELMAkGA1UEBhMC +REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxJDAiBgNVBAsTG1RDIFRydXN0Q2VudGVy +IFVuaXZlcnNhbCBDQTEmMCQGA1UEAxMdVEMgVHJ1c3RDZW50ZXIgVW5pdmVyc2FsIENBIEkwHhcN +MDYwMzIyMTU1NDI4WhcNMjUxMjMxMjI1OTU5WjB5MQswCQYDVQQGEwJERTEcMBoGA1UEChMTVEMg +VHJ1c3RDZW50ZXIgR21iSDEkMCIGA1UECxMbVEMgVHJ1c3RDZW50ZXIgVW5pdmVyc2FsIENBMSYw +JAYDVQQDEx1UQyBUcnVzdENlbnRlciBVbml2ZXJzYWwgQ0EgSTCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAKR3I5ZEr5D0MacQ9CaHnPM42Q9e3s9B6DGtxnSRJJZ4Hgmgm5qVSkr1YnwC +qMqs+1oEdjneX/H5s7/zA1hV0qq34wQi0fiU2iIIAI3TfCZdzHd55yx4Oagmcw6iXSVphU9VDprv +xrlE4Vc93x9UIuVvZaozhDrzznq+VZeujRIPFDPiUHDDSYcTvFHe15gSWu86gzOSBnWLknwSaHtw +ag+1m7Z3W0hZneTvWq3zwZ7U10VOylY0Ibw+F1tvdwxIAUMpsN0/lm7mlaoMwCC2/T42J5zjXM9O +gdwZu5GQfezmlwQek8wiSdeXhrYTCjxDI3d+8NzmzSQfO4ObNDqDNOMCAwEAAaNjMGEwHwYDVR0j +BBgwFoAUkqR1LKSevoFE63n8isWVpesQdXMwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AYYwHQYDVR0OBBYEFJKkdSyknr6BROt5/IrFlaXrEHVzMA0GCSqGSIb3DQEBBQUAA4IBAQAo0uCG +1eb4e/CX3CJrO5UUVg8RMKWaTzqwOuAGy2X17caXJ/4l8lfmXpWMPmRgFVp/Lw0BxbFg/UU1z/Cy +vwbZ71q+s2IhtNerNXxTPqYn8aEt2hojnczd7Dwtnic0XQ/CNnm8yUpiLe1r2X1BQ3y2qsrtYbE3 +ghUJGooWMNjsydZHcnhLEEYUjl8Or+zHL6sQ17bxbuyGssLoDZJz3KL0Dzq/YSMQiZxIQG5wALPT +ujdEWBF6AmqI8Dc08BnprNRlc/ZpjGSUOnmFKbAWKwyCPwacx/0QK54PLLae4xW/2TYcuiUaUj0a +7CIMHOCkoj3w6DnPgcB77V0fb8XQC9eY +-----END CERTIFICATE----- + +Deutsche Telekom Root CA 2 +========================== +-----BEGIN CERTIFICATE----- +MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEcMBoGA1UEChMT +RGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2VjIFRydXN0IENlbnRlcjEjMCEG +A1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENBIDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5 +MjM1OTAwWjBxMQswCQYDVQQGEwJERTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0G +A1UECxMWVC1UZWxlU2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBS +b290IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEUha88EOQ5 +bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhCQN/Po7qCWWqSG6wcmtoI +KyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1MjwrrFDa1sPeg5TKqAyZMg4ISFZbavva4VhY +AUlfckE8FQYBjl2tqriTtM2e66foai1SNNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aK +Se5TBY8ZTNXeWHmb0mocQqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTV +jlsB9WoHtxa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAPBgNV +HRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAlGRZrTlk5ynr +E/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756AbrsptJh6sTtU6zkXR34ajgv8HzFZMQSy +zhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpaIzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8 +rZ7/gFnkm0W09juwzTkZmDLl6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4G +dyd1Lx+4ivn+xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU +Cm26OWMohpLzGITY+9HPBVZkVw== +-----END CERTIFICATE----- + +ComSign Secured CA +================== +-----BEGIN CERTIFICATE----- +MIIDqzCCApOgAwIBAgIRAMcoRwmzuGxFjB36JPU2TukwDQYJKoZIhvcNAQEFBQAwPDEbMBkGA1UE +AxMSQ29tU2lnbiBTZWN1cmVkIENBMRAwDgYDVQQKEwdDb21TaWduMQswCQYDVQQGEwJJTDAeFw0w +NDAzMjQxMTM3MjBaFw0yOTAzMTYxNTA0NTZaMDwxGzAZBgNVBAMTEkNvbVNpZ24gU2VjdXJlZCBD +QTEQMA4GA1UEChMHQ29tU2lnbjELMAkGA1UEBhMCSUwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDGtWhfHZQVw6QIVS3joFd67+l0Kru5fFdJGhFeTymHDEjWaueP1H5XJLkGieQcPOqs +49ohgHMhCu95mGwfCP+hUH3ymBvJVG8+pSjsIQQPRbsHPaHA+iqYHU4Gk/v1iDurX8sWv+bznkqH +7Rnqwp9D5PGBpX8QTz7RSmKtUxvLg/8HZaWSLWapW7ha9B20IZFKF3ueMv5WJDmyVIRD9YTC2LxB +kMyd1mja6YJQqTtoz7VdApRgFrFD2UNd3V2Hbuq7s8lr9gOUCXDeFhF6K+h2j0kQmHe5Y1yLM5d1 +9guMsqtb3nQgJT/j8xH5h2iGNXHDHYwt6+UarA9z1YJZQIDTAgMBAAGjgacwgaQwDAYDVR0TBAUw +AwEB/zBEBgNVHR8EPTA7MDmgN6A1hjNodHRwOi8vZmVkaXIuY29tc2lnbi5jby5pbC9jcmwvQ29t +U2lnblNlY3VyZWRDQS5jcmwwDgYDVR0PAQH/BAQDAgGGMB8GA1UdIwQYMBaAFMFL7XC29z58ADsA +j8c+DkWfHl3sMB0GA1UdDgQWBBTBS+1wtvc+fAA7AI/HPg5Fnx5d7DANBgkqhkiG9w0BAQUFAAOC +AQEAFs/ukhNQq3sUnjO2QiBq1BW9Cav8cujvR3qQrFHBZE7piL1DRYHjZiM/EoZNGeQFsOY3wo3a +BijJD4mkU6l1P7CW+6tMM1X5eCZGbxs2mPtCdsGCuY7e+0X5YxtiOzkGynd6qDwJz2w2PQ8KRUtp +FhpFfTMDZflScZAmlaxMDPWLkz/MdXSFmLr/YnpNH4n+rr2UAJm/EaXc4HnFFgt9AmEd6oX5AhVP +51qJThRv4zdLhfXBPGHg/QVBspJ/wx2g0K5SZGBrGMYmnNj1ZOQ2GmKfig8+/21OGVZOIJFsnzQz +OjRXUDpvgV4GxvU+fE6OK85lBi5d0ipTdF7Tbieejw== +-----END CERTIFICATE----- + +Cybertrust Global Root +====================== +-----BEGIN CERTIFICATE----- +MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li +ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4 +MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD +ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA ++Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW +0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL +AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin +89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT +8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2 +MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G +A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO +lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi +5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2 +hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T +X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW +WL1WMRJOEcgh4LMRkWXbtKaIOM5V +-----END CERTIFICATE----- + +ePKI Root Certification Authority +================================= +-----BEGIN CERTIFICATE----- +MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG +EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg +Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx +MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq +MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs +IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi +lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv +qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX +12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O +WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+ +ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao +lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/ +vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi +Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi +MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH +ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0 +1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq +KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV +xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP +NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r +GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE +xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx +gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy +sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD +BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw= +-----END CERTIFICATE----- + +T\xc3\x9c\x42\xC4\xB0TAK UEKAE K\xC3\xB6k Sertifika Hizmet Sa\xC4\x9Flay\xc4\xb1\x63\xc4\xb1s\xc4\xb1 - S\xC3\xBCr\xC3\xBCm 3 +============================================================================================================================= +-----BEGIN CERTIFICATE----- +MIIFFzCCA/+gAwIBAgIBETANBgkqhkiG9w0BAQUFADCCASsxCzAJBgNVBAYTAlRSMRgwFgYDVQQH +DA9HZWJ6ZSAtIEtvY2FlbGkxRzBFBgNVBAoMPlTDvHJraXllIEJpbGltc2VsIHZlIFRla25vbG9q +aWsgQXJhxZ90xLFybWEgS3VydW11IC0gVMOcQsSwVEFLMUgwRgYDVQQLDD9VbHVzYWwgRWxla3Ry +b25payB2ZSBLcmlwdG9sb2ppIEFyYcWfdMSxcm1hIEVuc3RpdMO8c8O8IC0gVUVLQUUxIzAhBgNV +BAsMGkthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppMUowSAYDVQQDDEFUw5xCxLBUQUsgVUVLQUUg +S8O2ayBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsSAtIFPDvHLDvG0gMzAeFw0wNzA4 +MjQxMTM3MDdaFw0xNzA4MjExMTM3MDdaMIIBKzELMAkGA1UEBhMCVFIxGDAWBgNVBAcMD0dlYnpl +IC0gS29jYWVsaTFHMEUGA1UECgw+VMO8cmtpeWUgQmlsaW1zZWwgdmUgVGVrbm9sb2ppayBBcmHF +n3TEsXJtYSBLdXJ1bXUgLSBUw5xCxLBUQUsxSDBGBgNVBAsMP1VsdXNhbCBFbGVrdHJvbmlrIHZl +IEtyaXB0b2xvamkgQXJhxZ90xLFybWEgRW5zdGl0w7xzw7wgLSBVRUtBRTEjMCEGA1UECwwaS2Ft +dSBTZXJ0aWZpa2FzeW9uIE1lcmtlemkxSjBIBgNVBAMMQVTDnELEsFRBSyBVRUtBRSBLw7ZrIFNl +cnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxIC0gU8O8csO8bSAzMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAim1L/xCIOsP2fpTo6iBkcK4hgb46ezzb8R1Sf1n68yJMlaCQvEhO +Eav7t7WNeoMojCZG2E6VQIdhn8WebYGHV2yKO7Rm6sxA/OOqbLLLAdsyv9Lrhc+hDVXDWzhXcLh1 +xnnRFDDtG1hba+818qEhTsXOfJlfbLm4IpNQp81McGq+agV/E5wrHur+R84EpW+sky58K5+eeROR +6Oqeyjh1jmKwlZMq5d/pXpduIF9fhHpEORlAHLpVK/swsoHvhOPc7Jg4OQOFCKlUAwUp8MmPi+oL +hmUZEdPpCSPeaJMDyTYcIW7OjGbxmTDY17PDHfiBLqi9ggtm/oLL4eAagsNAgQIDAQABo0IwQDAd +BgNVHQ4EFgQUvYiHyY/2pAoLquvF/pEjnatKijIwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF +MAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAB18+kmPNOm3JpIWmgV050vQbTlswyb2zrgxvMTfvCr4 +N5EY3ATIZJkrGG2AA1nJrvhY0D7twyOfaTyGOBye79oneNGEN3GKPEs5z35FBtYt2IpNeBLWrcLT +y9LQQfMmNkqblWwM7uXRQydmwYj3erMgbOqwaSvHIOgMA8RBBZniP+Rr+KCGgceExh/VS4ESshYh +LBOhgLJeDEoTniDYYkCrkOpkSi+sDQESeUWoL4cZaMjihccwsnX5OD+ywJO0a+IDRM5noN+J1q2M +dqMTw5RhK2vZbMEHCiIHhWyFJEapvj+LeISCfiQMnf2BN+MlqO02TpUsyZyQ2uypQjyttgI= +-----END CERTIFICATE----- + +Buypass Class 2 CA 1 +==================== +-----BEGIN CERTIFICATE----- +MIIDUzCCAjugAwIBAgIBATANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMiBDQSAxMB4XDTA2 +MTAxMzEwMjUwOVoXDTE2MTAxMzEwMjUwOVowSzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBh +c3MgQVMtOTgzMTYzMzI3MR0wGwYDVQQDDBRCdXlwYXNzIENsYXNzIDIgQ0EgMTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAIs8B0XY9t/mx8q6jUPFR42wWsE425KEHK8T1A9vNkYgxC7M +cXA0ojTTNy7Y3Tp3L8DrKehc0rWpkTSHIln+zNvnma+WwajHQN2lFYxuyHyXA8vmIPLXl18xoS83 +0r7uvqmtqEyeIWZDO6i88wmjONVZJMHCR3axiFyCO7srpgTXjAePzdVBHfCuuCkslFJgNJQ72uA4 +0Z0zPhX0kzLFANq1KWYOOngPIVJfAuWSeyXTkh4vFZ2B5J2O6O+JzhRMVB0cgRJNcKi+EAUXfh/R +uFdV7c27UsKwHnjCTTZoy1YmwVLBvXb3WNVyfh9EdrsAiR0WnVE1703CVu9r4Iw7DekCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUP42aWYv8e3uco684sDntkHGA1sgwDgYDVR0P +AQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQAVGn4TirnoB6NLJzKyQJHyIdFkhb5jatLPgcIV +1Xp+DCmsNx4cfHZSldq1fyOhKXdlyTKdqC5Wq2B2zha0jX94wNWZUYN/Xtm+DKhQ7SLHrQVMdvvt +7h5HZPb3J31cKA9FxVxiXqaakZG3Uxcu3K1gnZZkOb1naLKuBctN518fV4bVIJwo+28TOPX2EZL2 +fZleHwzoq0QkKXJAPTZSr4xYkHPB7GEseaHsh7U/2k3ZIQAw3pDaDtMaSKk+hQsUi4y8QZ5q9w5w +wDX3OaJdZtB7WZ+oRxKaJyOkLY4ng5IgodcVf/EuGO70SH8vf/GhGLWhC5SgYiAynB321O+/TIho +-----END CERTIFICATE----- + +Buypass Class 3 CA 1 +==================== +-----BEGIN CERTIFICATE----- +MIIDUzCCAjugAwIBAgIBAjANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMyBDQSAxMB4XDTA1 +MDUwOTE0MTMwM1oXDTE1MDUwOTE0MTMwM1owSzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBh +c3MgQVMtOTgzMTYzMzI3MR0wGwYDVQQDDBRCdXlwYXNzIENsYXNzIDMgQ0EgMTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAKSO13TZKWTeXx+HgJHqTjnmGcZEC4DVC69TB4sSveZn8AKx +ifZgisRbsELRwCGoy+Gb72RRtqfPFfV0gGgEkKBYouZ0plNTVUhjP5JW3SROjvi6K//zNIqeKNc0 +n6wv1g/xpC+9UrJJhW05NfBEMJNGJPO251P7vGGvqaMU+8IXF4Rs4HyI+MkcVyzwPX6UvCWThOia +AJpFBUJXgPROztmuOfbIUxAMZTpHe2DC1vqRycZxbL2RhzyRhkmr8w+gbCZ2Xhysm3HljbybIR6c +1jh+JIAVMYKWsUnTYjdbiAwKYjT+p0h+mbEwi5A3lRyoH6UsjfRVyNvdWQrCrXig9IsCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUOBTmyPCppAP0Tj4io1vy1uCtQHQwDgYDVR0P +AQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQABZ6OMySU9E2NdFm/soT4JXJEVKirZgCFPBdy7 +pYmrEzMqnji3jG8CcmPHc3ceCQa6Oyh7pEfJYWsICCD8igWKH7y6xsL+z27sEzNxZy5p+qksP2bA +EllNC1QCkoS72xLvg3BweMhT+t/Gxv/ciC8HwEmdMldg0/L2mSlf56oBzKwzqBwKu5HEA6BvtjT5 +htOzdlSY9EqBs1OdTUDs5XcTRa9bqh/YL0yCe/4qxFi7T/ye/QNlGioOw6UgFpRreaaiErS7GqQj +el/wroQk5PMr+4okoyeYZdowdXb8GZHo2+ubPzK/QJcHJrrM85SFSnonk8+QQtS4Wxam58tAA915 +-----END CERTIFICATE----- + +EBG Elektronik Sertifika Hizmet Sa\xC4\x9Flay\xc4\xb1\x63\xc4\xb1s\xc4\xb1 +========================================================================== +-----BEGIN CERTIFICATE----- +MIIF5zCCA8+gAwIBAgIITK9zQhyOdAIwDQYJKoZIhvcNAQEFBQAwgYAxODA2BgNVBAMML0VCRyBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMTcwNQYDVQQKDC5FQkcg +QmlsacWfaW0gVGVrbm9sb2ppbGVyaSB2ZSBIaXptZXRsZXJpIEEuxZ4uMQswCQYDVQQGEwJUUjAe +Fw0wNjA4MTcwMDIxMDlaFw0xNjA4MTQwMDMxMDlaMIGAMTgwNgYDVQQDDC9FQkcgRWxla3Ryb25p +ayBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsTE3MDUGA1UECgwuRUJHIEJpbGnFn2lt +IFRla25vbG9qaWxlcmkgdmUgSGl6bWV0bGVyaSBBLsWeLjELMAkGA1UEBhMCVFIwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQDuoIRh0DpqZhAy2DE4f6en5f2h4fuXd7hxlugTlkaDT7by +X3JWbhNgpQGR4lvFzVcfd2NR/y8927k/qqk153nQ9dAktiHq6yOU/im/+4mRDGSaBUorzAzu8T2b +gmmkTPiab+ci2hC6X5L8GCcKqKpE+i4stPtGmggDg3KriORqcsnlZR9uKg+ds+g75AxuetpX/dfr +eYteIAbTdgtsApWjluTLdlHRKJ2hGvxEok3MenaoDT2/F08iiFD9rrbskFBKW5+VQarKD7JK/oCZ +TqNGFav4c0JqwmZ2sQomFd2TkuzbqV9UIlKRcF0T6kjsbgNs2d1s/OsNA/+mgxKb8amTD8UmTDGy +Y5lhcucqZJnSuOl14nypqZoaqsNW2xCaPINStnuWt6yHd6i58mcLlEOzrz5z+kI2sSXFCjEmN1Zn +uqMLfdb3ic1nobc6HmZP9qBVFCVMLDMNpkGMvQQxahByCp0OLna9XvNRiYuoP1Vzv9s6xiQFlpJI +qkuNKgPlV5EQ9GooFW5Hd4RcUXSfGenmHmMWOeMRFeNYGkS9y8RsZteEBt8w9DeiQyJ50hBs37vm +ExH8nYQKE3vwO9D8owrXieqWfo1IhR5kX9tUoqzVegJ5a9KK8GfaZXINFHDk6Y54jzJ0fFfy1tb0 +Nokb+Clsi7n2l9GkLqq+CxnCRelwXQIDAJ3Zo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB +/wQEAwIBBjAdBgNVHQ4EFgQU587GT/wWZ5b6SqMHwQSny2re2kcwHwYDVR0jBBgwFoAU587GT/wW +Z5b6SqMHwQSny2re2kcwDQYJKoZIhvcNAQEFBQADggIBAJuYml2+8ygjdsZs93/mQJ7ANtyVDR2t +FcU22NU57/IeIl6zgrRdu0waypIN30ckHrMk2pGI6YNw3ZPX6bqz3xZaPt7gyPvT/Wwp+BVGoGgm +zJNSroIBk5DKd8pNSe/iWtkqvTDOTLKBtjDOWU/aWR1qeqRFsIImgYZ29fUQALjuswnoT4cCB64k +XPBfrAowzIpAoHMEwfuJJPaaHFy3PApnNgUIMbOv2AFoKuB4j3TeuFGkjGwgPaL7s9QJ/XvCgKqT +bCmYIai7FvOpEl90tYeY8pUm3zTvilORiF0alKM/fCL414i6poyWqD1SNGKfAB5UVUJnxk1Gj7sU +RT0KlhaOEKGXmdXTMIXM3rRyt7yKPBgpaP3ccQfuJDlq+u2lrDgv+R4QDgZxGhBM/nV+/x5XOULK +1+EVoVZVWRvRo68R2E7DpSvvkL/A7IITW43WciyTTo9qKd+FPNMN4KIYEsxVL0e3p5sC/kH2iExt +2qkBR4NkJ2IQgtYSe14DHzSpyZH+r11thie3I6p1GMog57AP14kOpmciY/SDQSsGS7tY1dHXt7kQ +Y9iJSrSq3RZj9W6+YKH47ejWkE8axsWgKdOnIaj1Wjz3x0miIZpKlVIglnKaZsv30oZDfCK+lvm9 +AahH3eU7QPl1K5srRmSGjR70j/sHd9DqSaIcjVIUpgqT +-----END CERTIFICATE----- + +certSIGN ROOT CA +================ +-----BEGIN CERTIFICATE----- +MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD +VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa +Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE +CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I +JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH +rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2 +ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD +0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943 +AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B +Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB +AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8 +SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0 +x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt +vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz +TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD +-----END CERTIFICATE----- + +CNNIC ROOT +========== +-----BEGIN CERTIFICATE----- +MIIDVTCCAj2gAwIBAgIESTMAATANBgkqhkiG9w0BAQUFADAyMQswCQYDVQQGEwJDTjEOMAwGA1UE +ChMFQ05OSUMxEzARBgNVBAMTCkNOTklDIFJPT1QwHhcNMDcwNDE2MDcwOTE0WhcNMjcwNDE2MDcw +OTE0WjAyMQswCQYDVQQGEwJDTjEOMAwGA1UEChMFQ05OSUMxEzARBgNVBAMTCkNOTklDIFJPT1Qw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDTNfc/c3et6FtzF8LRb+1VvG7q6KR5smzD +o+/hn7E7SIX1mlwhIhAsxYLO2uOabjfhhyzcuQxauohV3/2q2x8x6gHx3zkBwRP9SFIhxFXf2tiz +VHa6dLG3fdfA6PZZxU3Iva0fFNrfWEQlMhkqx35+jq44sDB7R3IJMfAw28Mbdim7aXZOV/kbZKKT +VrdvmW7bCgScEeOAH8tjlBAKqeFkgjH5jCftppkA9nCTGPihNIaj3XrCGHn2emU1z5DrvTOTn1Or +czvmmzQgLx3vqR1jGqCA2wMv+SYahtKNu6m+UjqHZ0gNv7Sg2Ca+I19zN38m5pIEo3/PIKe38zrK +y5nLAgMBAAGjczBxMBEGCWCGSAGG+EIBAQQEAwIABzAfBgNVHSMEGDAWgBRl8jGtKvf33VKWCscC +wQ7vptU7ETAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIB/jAdBgNVHQ4EFgQUZfIxrSr3991S +lgrHAsEO76bVOxEwDQYJKoZIhvcNAQEFBQADggEBAEs17szkrr/Dbq2flTtLP1se31cpolnKOOK5 +Gv+e5m4y3R6u6jW39ZORTtpC4cMXYFDy0VwmuYK36m3knITnA3kXr5g9lNvHugDnuL8BV8F3RTIM +O/G0HAiw/VGgod2aHRM2mm23xzy54cXZF/qD1T0VoDy7HgviyJA/qIYM/PmLXoXLT1tLYhFHxUV8 +BS9BsZ4QaRuZluBVeftOhpm4lNqGOGqTo+fLbuXf6iFViZx9fX+Y9QCJ7uOEwFyWtcVG6kbghVW2 +G8kS1sHNzYDzAgE8yGnLRUhj2JTQ7IUOO04RZfSCjKY9ri4ilAnIXOo8gV0WKgOXFlUJ24pBgp5m +mxE= +-----END CERTIFICATE----- + +ApplicationCA - Japanese Government +=================================== +-----BEGIN CERTIFICATE----- +MIIDoDCCAoigAwIBAgIBMTANBgkqhkiG9w0BAQUFADBDMQswCQYDVQQGEwJKUDEcMBoGA1UEChMT +SmFwYW5lc2UgR292ZXJubWVudDEWMBQGA1UECxMNQXBwbGljYXRpb25DQTAeFw0wNzEyMTIxNTAw +MDBaFw0xNzEyMTIxNTAwMDBaMEMxCzAJBgNVBAYTAkpQMRwwGgYDVQQKExNKYXBhbmVzZSBHb3Zl +cm5tZW50MRYwFAYDVQQLEw1BcHBsaWNhdGlvbkNBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEAp23gdE6Hj6UG3mii24aZS2QNcfAKBZuOquHMLtJqO8F6tJdhjYq+xpqcBrSGUeQ3DnR4 +fl+Kf5Sk10cI/VBaVuRorChzoHvpfxiSQE8tnfWuREhzNgaeZCw7NCPbXCbkcXmP1G55IrmTwcrN +wVbtiGrXoDkhBFcsovW8R0FPXjQilbUfKW1eSvNNcr5BViCH/OlQR9cwFO5cjFW6WY2H/CPek9AE +jP3vbb3QesmlOmpyM8ZKDQUXKi17safY1vC+9D/qDihtQWEjdnjDuGWk81quzMKq2edY3rZ+nYVu +nyoKb58DKTCXKB28t89UKU5RMfkntigm/qJj5kEW8DOYRwIDAQABo4GeMIGbMB0GA1UdDgQWBBRU +WssmP3HMlEYNllPqa0jQk/5CdTAOBgNVHQ8BAf8EBAMCAQYwWQYDVR0RBFIwUKROMEwxCzAJBgNV +BAYTAkpQMRgwFgYDVQQKDA/ml6XmnKzlm73mlL/lupwxIzAhBgNVBAsMGuOCouODl+ODquOCseOD +vOOCt+ODp+ODs0NBMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADlqRHZ3ODrs +o2dGD/mLBqj7apAxzn7s2tGJfHrrLgy9mTLnsCTWw//1sogJhyzjVOGjprIIC8CFqMjSnHH2HZ9g +/DgzE+Ge3Atf2hZQKXsvcJEPmbo0NI2VdMV+eKlmXb3KIXdCEKxmJj3ekav9FfBv7WxfEPjzFvYD +io+nEhEMy/0/ecGc/WLuo89UDNErXxc+4z6/wCs+CZv+iKZ+tJIX/COUgb1up8WMwusRRdv4QcmW +dupwX3kSa+SjB1oF7ydJzyGfikwJcGapJsErEU4z0g781mzSDjJkaP+tBXhfAx2o45CsJOAPQKdL +rosot4LKGAfmt1t06SAZf7IbiVQ= +-----END CERTIFICATE----- + +GeoTrust Primary Certification Authority - G3 +============================================= +-----BEGIN CERTIFICATE----- +MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE +BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0 +IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz +NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo +YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT +LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j +K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE +c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C +IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu +dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr +2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9 +cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE +Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD +AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s +t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt +-----END CERTIFICATE----- + +thawte Primary Root CA - G2 +=========================== +-----BEGIN CERTIFICATE----- +MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC +VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu +IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg +Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV +MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG +b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt +IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS +LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5 +8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU +mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN +G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K +rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg== +-----END CERTIFICATE----- + +thawte Primary Root CA - G3 +=========================== +-----BEGIN CERTIFICATE----- +MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE +BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2 +aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w +ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh +d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD +VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG +A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At +P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC ++BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY +7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW +vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E +BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ +KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK +A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu +t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC +8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm +er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A= +-----END CERTIFICATE----- + +GeoTrust Primary Certification Authority - G2 +============================================= +-----BEGIN CERTIFICATE----- +MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu +Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1 +OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg +MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl +b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG +BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc +KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD +VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+ +EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m +ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2 +npaqBA+K +-----END CERTIFICATE----- + +VeriSign Universal Root Certification Authority +=============================================== +-----BEGIN CERTIFICATE----- +MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk +IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u +IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj +1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP +MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72 +9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I +AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR +tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G +CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O +a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud +DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3 +Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx +Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx +P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P +wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4 +mJO37M2CYfE45k+XmCpajQ== +-----END CERTIFICATE----- + +VeriSign Class 3 Public Primary Certification Authority - G4 +============================================================ +-----BEGIN CERTIFICATE----- +MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC +VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3 +b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz +ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL +MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU +cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo +b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8 +Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz +rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB +/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw +HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u +Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD +A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx +AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA== +-----END CERTIFICATE----- + +NetLock Arany (Class Gold) FÅ‘tanúsítvány +============================================ +-----BEGIN CERTIFICATE----- +MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G +A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610 +dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB +cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx +MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO +ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv +biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6 +c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu +0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw +/HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk +H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw +fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1 +neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB +BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW +qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta +YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC +bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna +NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu +dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E= +-----END CERTIFICATE----- + +Staat der Nederlanden Root CA - G2 +================================== +-----BEGIN CERTIFICATE----- +MIIFyjCCA7KgAwIBAgIEAJiWjDANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE +CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g +Um9vdCBDQSAtIEcyMB4XDTA4MDMyNjExMTgxN1oXDTIwMDMyNTExMDMxMFowWjELMAkGA1UEBhMC +TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l +ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMVZ +5291qj5LnLW4rJ4L5PnZyqtdj7U5EILXr1HgO+EASGrP2uEGQxGZqhQlEq0i6ABtQ8SpuOUfiUtn +vWFI7/3S4GCI5bkYYCjDdyutsDeqN95kWSpGV+RLufg3fNU254DBtvPUZ5uW6M7XxgpT0GtJlvOj +CwV3SPcl5XCsMBQgJeN/dVrlSPhOewMHBPqCYYdu8DvEpMfQ9XQ+pV0aCPKbJdL2rAQmPlU6Yiil +e7Iwr/g3wtG61jj99O9JMDeZJiFIhQGp5Rbn3JBV3w/oOM2ZNyFPXfUib2rFEhZgF1XyZWampzCR +OME4HYYEhLoaJXhena/MUGDWE4dS7WMfbWV9whUYdMrhfmQpjHLYFhN9C0lK8SgbIHRrxT3dsKpI +CT0ugpTNGmXZK4iambwYfp/ufWZ8Pr2UuIHOzZgweMFvZ9C+X+Bo7d7iscksWXiSqt8rYGPy5V65 +48r6f1CGPqI0GAwJaCgRHOThuVw+R7oyPxjMW4T182t0xHJ04eOLoEq9jWYv6q012iDTiIJh8BIi +trzQ1aTsr1SIJSQ8p22xcik/Plemf1WvbibG/ufMQFxRRIEKeN5KzlW/HdXZt1bv8Hb/C3m1r737 +qWmRRpdogBQ2HbN/uymYNqUg+oJgYjOk7Na6B6duxc8UpufWkjTYgfX8HV2qXB72o007uPc5AgMB +AAGjgZcwgZQwDwYDVR0TAQH/BAUwAwEB/zBSBgNVHSAESzBJMEcGBFUdIAAwPzA9BggrBgEFBQcC +ARYxaHR0cDovL3d3dy5wa2lvdmVyaGVpZC5ubC9wb2xpY2llcy9yb290LXBvbGljeS1HMjAOBgNV +HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJFoMocVHYnitfGsNig0jQt8YojrMA0GCSqGSIb3DQEBCwUA +A4ICAQCoQUpnKpKBglBu4dfYszk78wIVCVBR7y29JHuIhjv5tLySCZa59sCrI2AGeYwRTlHSeYAz ++51IvuxBQ4EffkdAHOV6CMqqi3WtFMTC6GY8ggen5ieCWxjmD27ZUD6KQhgpxrRW/FYQoAUXvQwj +f/ST7ZwaUb7dRUG/kSS0H4zpX897IZmflZ85OkYcbPnNe5yQzSipx6lVu6xiNGI1E0sUOlWDuYaN +kqbG9AclVMwWVxJKgnjIFNkXgiYtXSAfea7+1HAWFpWD2DU5/1JddRwWxRNVz0fMdWVSSt7wsKfk +CpYL+63C4iWEst3kvX5ZbJvw8NjnyvLplzh+ib7M+zkXYT9y2zqR2GUBGR2tUKRXCnxLvJxxcypF +URmFzI79R6d0lR2o0a9OF7FpJsKqeFdbxU2n5Z4FF5TKsl+gSRiNNOkmbEgeqmiSBeGCc1qb3Adb +CG19ndeNIdn8FCCqwkXfP+cAslHkwvgFuXkajDTznlvkN1trSt8sV4pAWja63XVECDdCcAz+3F4h +oKOKwJCcaNpQ5kUQR3i2TtJlycM33+FCY7BXN0Ute4qcvwXqZVUz9zkQxSgqIXobisQk+T8VyJoV +IPVVYpbtbZNQvOSqeK3Zywplh6ZmwcSBo3c6WB4L7oOLnR7SUqTMHW+wmG2UMbX4cQrcufx9MmDm +66+KAQ== +-----END CERTIFICATE----- + +CA Disig +======== +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIBATANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQGEwJTSzETMBEGA1UEBxMK +QnJhdGlzbGF2YTETMBEGA1UEChMKRGlzaWcgYS5zLjERMA8GA1UEAxMIQ0EgRGlzaWcwHhcNMDYw +MzIyMDEzOTM0WhcNMTYwMzIyMDEzOTM0WjBKMQswCQYDVQQGEwJTSzETMBEGA1UEBxMKQnJhdGlz +bGF2YTETMBEGA1UEChMKRGlzaWcgYS5zLjERMA8GA1UEAxMIQ0EgRGlzaWcwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCS9jHBfYj9mQGp2HvycXXxMcbzdWb6UShGhJd4NLxs/LxFWYgm +GErENx+hSkS943EE9UQX4j/8SFhvXJ56CbpRNyIjZkMhsDxkovhqFQ4/61HhVKndBpnXmjxUizkD +Pw/Fzsbrg3ICqB9x8y34dQjbYkzo+s7552oftms1grrijxaSfQUMbEYDXcDtab86wYqg6I7ZuUUo +hwjstMoVvoLdtUSLLa2GDGhibYVW8qwUYzrG0ZmsNHhWS8+2rT+MitcE5eN4TPWGqvWP+j1scaMt +ymfraHtuM6kMgiioTGohQBUgDCZbg8KpFhXAJIJdKxatymP2dACw30PEEGBWZ2NFAgMBAAGjgf8w +gfwwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUjbJJaJ1yCCW5wCf1UJNWSEZx+Y8wDgYDVR0P +AQH/BAQDAgEGMDYGA1UdEQQvMC2BE2Nhb3BlcmF0b3JAZGlzaWcuc2uGFmh0dHA6Ly93d3cuZGlz +aWcuc2svY2EwZgYDVR0fBF8wXTAtoCugKYYnaHR0cDovL3d3dy5kaXNpZy5zay9jYS9jcmwvY2Ff +ZGlzaWcuY3JsMCygKqAohiZodHRwOi8vY2EuZGlzaWcuc2svY2EvY3JsL2NhX2Rpc2lnLmNybDAa +BgNVHSAEEzARMA8GDSuBHpGT5goAAAABAQEwDQYJKoZIhvcNAQEFBQADggEBAF00dGFMrzvY/59t +WDYcPQuBDRIrRhCA/ec8J9B6yKm2fnQwM6M6int0wHl5QpNt/7EpFIKrIYwvF/k/Ji/1WcbvgAa3 +mkkp7M5+cTxqEEHA9tOasnxakZzArFvITV734VP/Q3f8nktnbNfzg9Gg4H8l37iYC5oyOGwwoPP/ +CBUz91BKez6jPiCp3C9WgArtQVCwyfTssuMmRAAOb54GvCKWU3BlxFAKRmukLyeBEicTXxChds6K +ezfqwzlhA5WYOudsiCUI/HloDYd9Yvi0X/vF2Ey9WLw/Q1vUHgFNPGO+I++MzVpQuGhU+QqZMxEA +4Z7CRneC9VkGjCFMhwnN5ag= +-----END CERTIFICATE----- + +Juur-SK +======= +-----BEGIN CERTIFICATE----- +MIIE5jCCA86gAwIBAgIEO45L/DANBgkqhkiG9w0BAQUFADBdMRgwFgYJKoZIhvcNAQkBFglwa2lA +c2suZWUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKExlBUyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMRAw +DgYDVQQDEwdKdXVyLVNLMB4XDTAxMDgzMDE0MjMwMVoXDTE2MDgyNjE0MjMwMVowXTEYMBYGCSqG +SIb3DQEJARYJcGtpQHNrLmVlMQswCQYDVQQGEwJFRTEiMCAGA1UEChMZQVMgU2VydGlmaXRzZWVy +aW1pc2tlc2t1czEQMA4GA1UEAxMHSnV1ci1TSzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAIFxNj4zB9bjMI0TfncyRsvPGbJgMUaXhvSYRqTCZUXP00B841oiqBB4M8yIsdOBSvZiF3tf +TQou0M+LI+5PAk676w7KvRhj6IAcjeEcjT3g/1tf6mTll+g/mX8MCgkzABpTpyHhOEvWgxutr2TC ++Rx6jGZITWYfGAriPrsfB2WThbkasLnE+w0R9vXW+RvHLCu3GFH+4Hv2qEivbDtPL+/40UceJlfw +UR0zlv/vWT3aTdEVNMfqPxZIe5EcgEMPPbgFPtGzlc3Yyg/CQ2fbt5PgIoIuvvVoKIO5wTtpeyDa +Tpxt4brNj3pssAki14sL2xzVWiZbDcDq5WDQn/413z8CAwEAAaOCAawwggGoMA8GA1UdEwEB/wQF +MAMBAf8wggEWBgNVHSAEggENMIIBCTCCAQUGCisGAQQBzh8BAQEwgfYwgdAGCCsGAQUFBwICMIHD +HoHAAFMAZQBlACAAcwBlAHIAdABpAGYAaQBrAGEAYQB0ACAAbwBuACAAdgDkAGwAagBhAHMAdABh +AHQAdQBkACAAQQBTAC0AaQBzACAAUwBlAHIAdABpAGYAaQB0AHMAZQBlAHIAaQBtAGkAcwBrAGUA +cwBrAHUAcwAgAGEAbABhAG0ALQBTAEsAIABzAGUAcgB0AGkAZgBpAGsAYQBhAHQAaQBkAGUAIABr +AGkAbgBuAGkAdABhAG0AaQBzAGUAawBzMCEGCCsGAQUFBwIBFhVodHRwOi8vd3d3LnNrLmVlL2Nw +cy8wKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL3d3dy5zay5lZS9qdXVyL2NybC8wHQYDVR0OBBYE +FASqekej5ImvGs8KQKcYP2/v6X2+MB8GA1UdIwQYMBaAFASqekej5ImvGs8KQKcYP2/v6X2+MA4G +A1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQUFAAOCAQEAe8EYlFOiCfP+JmeaUOTDBS8rNXiRTHyo +ERF5TElZrMj3hWVcRrs7EKACr81Ptcw2Kuxd/u+gkcm2k298gFTsxwhwDY77guwqYHhpNjbRxZyL +abVAyJRld/JXIWY7zoVAtjNjGr95HvxcHdMdkxuLDF2FvZkwMhgJkVLpfKG6/2SSmuz+Ne6ML678 +IIbsSt4beDI3poHSna9aEhbKmVv8b20OxaAehsmR0FyYgl9jDIpaq9iVpszLita/ZEuOyoqysOkh +Mp6qqIWYNIE5ITuoOlIyPfZrN4YGWhWY3PARZv40ILcD9EEQfTmEeZZyY7aWAuVrua0ZTbvGRNs2 +yyqcjg== +-----END CERTIFICATE----- + +Hongkong Post Root CA 1 +======================= +-----BEGIN CERTIFICATE----- +MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT +DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx +NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n +IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1 +ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr +auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh +qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY +V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV +HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i +h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio +l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei +IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps +T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT +c4afU9hDDl3WY4JxHYB0yvbiAmvZWg== +-----END CERTIFICATE----- + +SecureSign RootCA11 +=================== +-----BEGIN CERTIFICATE----- +MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi +SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS +b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw +KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1 +cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL +TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO +wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq +g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP +O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA +bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX +t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh +OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r +bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ +Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01 +y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061 +lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I= +-----END CERTIFICATE----- + +ACEDICOM Root +============= +-----BEGIN CERTIFICATE----- +MIIFtTCCA52gAwIBAgIIYY3HhjsBggUwDQYJKoZIhvcNAQEFBQAwRDEWMBQGA1UEAwwNQUNFRElD +T00gUm9vdDEMMAoGA1UECwwDUEtJMQ8wDQYDVQQKDAZFRElDT00xCzAJBgNVBAYTAkVTMB4XDTA4 +MDQxODE2MjQyMloXDTI4MDQxMzE2MjQyMlowRDEWMBQGA1UEAwwNQUNFRElDT00gUm9vdDEMMAoG +A1UECwwDUEtJMQ8wDQYDVQQKDAZFRElDT00xCzAJBgNVBAYTAkVTMIICIjANBgkqhkiG9w0BAQEF +AAOCAg8AMIICCgKCAgEA/5KV4WgGdrQsyFhIyv2AVClVYyT/kGWbEHV7w2rbYgIB8hiGtXxaOLHk +WLn709gtn70yN78sFW2+tfQh0hOR2QetAQXW8713zl9CgQr5auODAKgrLlUTY4HKRxx7XBZXehuD +YAQ6PmXDzQHe3qTWDLqO3tkE7hdWIpuPY/1NFgu3e3eM+SW10W2ZEi5PGrjm6gSSrj0RuVFCPYew +MYWveVqc/udOXpJPQ/yrOq2lEiZmueIM15jO1FillUAKt0SdE3QrwqXrIhWYENiLxQSfHY9g5QYb +m8+5eaA9oiM/Qj9r+hwDezCNzmzAv+YbX79nuIQZ1RXve8uQNjFiybwCq0Zfm/4aaJQ0PZCOrfbk +HQl/Sog4P75n/TSW9R28MHTLOO7VbKvU/PQAtwBbhTIWdjPp2KOZnQUAqhbm84F9b32qhm2tFXTT +xKJxqvQUfecyuB+81fFOvW8XAjnXDpVCOscAPukmYxHqC9FK/xidstd7LzrZlvvoHpKuE1XI2Sf2 +3EgbsCTBheN3nZqk8wwRHQ3ItBTutYJXCb8gWH8vIiPYcMt5bMlL8qkqyPyHK9caUPgn6C9D4zq9 +2Fdx/c6mUlv53U3t5fZvie27k5x2IXXwkkwp9y+cAS7+UEaeZAwUswdbxcJzbPEHXEUkFDWug/Fq +TYl6+rPYLWbwNof1K1MCAwEAAaOBqjCBpzAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKaz +4SsrSbbXc6GqlPUB53NlTKxQMA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUprPhKytJttdzoaqU +9QHnc2VMrFAwRAYDVR0gBD0wOzA5BgRVHSAAMDEwLwYIKwYBBQUHAgEWI2h0dHA6Ly9hY2VkaWNv +bS5lZGljb21ncm91cC5jb20vZG9jMA0GCSqGSIb3DQEBBQUAA4ICAQDOLAtSUWImfQwng4/F9tqg +aHtPkl7qpHMyEVNEskTLnewPeUKzEKbHDZ3Ltvo/Onzqv4hTGzz3gvoFNTPhNahXwOf9jU8/kzJP +eGYDdwdY6ZXIfj7QeQCM8htRM5u8lOk6e25SLTKeI6RF+7YuE7CLGLHdztUdp0J/Vb77W7tH1Pwk +zQSulgUV1qzOMPPKC8W64iLgpq0i5ALudBF/TP94HTXa5gI06xgSYXcGCRZj6hitoocf8seACQl1 +ThCojz2GuHURwCRiipZ7SkXp7FnFvmuD5uHorLUwHv4FB4D54SMNUI8FmP8sX+g7tq3PgbUhh8oI +KiMnMCArz+2UW6yyetLHKKGKC5tNSixthT8Jcjxn4tncB7rrZXtaAWPWkFtPF2Y9fwsZo5NjEFIq +nxQWWOLcpfShFosOkYuByptZ+thrkQdlVV9SH686+5DdaaVbnG0OLLb6zqylfDJKZ0DcMDQj3dcE +I2bw/FWAp/tmGYI1Z2JwOV5vx+qQQEQIHriy1tvuWacNGHk0vFQYXlPKNFHtRQrmjseCNj6nOGOp +MCwXEGCSn1WHElkQwg9naRHMTh5+Spqtr0CodaxWkHS4oJyleW/c6RrIaQXpuvoDs3zk4E7Czp3o +tkYNbn5XOmeUwssfnHdKZ05phkOTOPu220+DkdRgfks+KzgHVZhepA== +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority +======================================================= +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx +FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow +XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz +IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 +f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol +hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky +CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX +bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/ +D/xwzoiQ +-----END CERTIFICATE----- + +Microsec e-Szigno Root CA 2009 +============================== +-----BEGIN CERTIFICATE----- +MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER +MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv +c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o +dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE +BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt +U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA +fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG +0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA +pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm +1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC +AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf +QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE +FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o +lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX +I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775 +tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02 +yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi +LXpUq3DDfSJlgnCW +-----END CERTIFICATE----- + +E-Guven Kok Elektronik Sertifika Hizmet Saglayicisi +=================================================== +-----BEGIN CERTIFICATE----- +MIIDtjCCAp6gAwIBAgIQRJmNPMADJ72cdpW56tustTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQG +EwJUUjEoMCYGA1UEChMfRWxla3Ryb25payBCaWxnaSBHdXZlbmxpZ2kgQS5TLjE8MDoGA1UEAxMz +ZS1HdXZlbiBLb2sgRWxla3Ryb25payBTZXJ0aWZpa2EgSGl6bWV0IFNhZ2xheWljaXNpMB4XDTA3 +MDEwNDExMzI0OFoXDTE3MDEwNDExMzI0OFowdTELMAkGA1UEBhMCVFIxKDAmBgNVBAoTH0VsZWt0 +cm9uaWsgQmlsZ2kgR3V2ZW5saWdpIEEuUy4xPDA6BgNVBAMTM2UtR3V2ZW4gS29rIEVsZWt0cm9u +aWsgU2VydGlmaWthIEhpem1ldCBTYWdsYXlpY2lzaTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAMMSIJ6wXgBljU5Gu4Bc6SwGl9XzcslwuedLZYDBS75+PNdUMZTe1RK6UxYC6lhj71vY +8+0qGqpxSKPcEC1fX+tcS5yWCEIlKBHMilpiAVDV6wlTL/jDj/6z/P2douNffb7tC+Bg62nsM+3Y +jfsSSYMAyYuXjDtzKjKzEve5TfL0TW3H5tYmNwjy2f1rXKPlSFxYvEK+A1qBuhw1DADT9SN+cTAI +JjjcJRFHLfO6IxClv7wC90Nex/6wN1CZew+TzuZDLMN+DfIcQ2Zgy2ExR4ejT669VmxMvLz4Bcpk +9Ok0oSy1c+HCPujIyTQlCFzz7abHlJ+tiEMl1+E5YP6sOVkCAwEAAaNCMEAwDgYDVR0PAQH/BAQD +AgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFJ/uRLOU1fqRTy7ZVZoEVtstxNulMA0GCSqG +SIb3DQEBBQUAA4IBAQB/X7lTW2M9dTLn+sR0GstG30ZpHFLPqk/CaOv/gKlR6D1id4k9CnU58W5d +F4dvaAXBlGzZXd/aslnLpRCKysw5zZ/rTt5S/wzw9JKp8mxTq5vSR6AfdPebmvEvFZ96ZDAYBzwq +D2fK/A+JYZ1lpTzlvBNbCNvj/+27BrtqBrF6T2XGgv0enIu1De5Iu7i9qgi0+6N8y5/NkHZchpZ4 +Vwpm+Vganf2XKWDeEaaQHBkc7gGWIjQ0LpH5t8Qn0Xvmv/uARFoW5evg1Ao4vOSR49XrXMGs3xtq +fJ7lddK2l4fbzIcrQzqECK+rPNv3PGYxhrCdU3nt+CPeQuMtgvEP5fqX +-----END CERTIFICATE----- + +GlobalSign Root CA - R3 +======================= +-----BEGIN CERTIFICATE----- +MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv +YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh +bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT +aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln +bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt +iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ +0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3 +rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl +OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2 +xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7 +lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8 +EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E +bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18 +YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r +kpeDMdmztcpHWD9f +-----END CERTIFICATE----- + +TC TrustCenter Universal CA III +=============================== +-----BEGIN CERTIFICATE----- +MIID4TCCAsmgAwIBAgIOYyUAAQACFI0zFQLkbPQwDQYJKoZIhvcNAQEFBQAwezELMAkGA1UEBhMC +REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxJDAiBgNVBAsTG1RDIFRydXN0Q2VudGVy +IFVuaXZlcnNhbCBDQTEoMCYGA1UEAxMfVEMgVHJ1c3RDZW50ZXIgVW5pdmVyc2FsIENBIElJSTAe +Fw0wOTA5MDkwODE1MjdaFw0yOTEyMzEyMzU5NTlaMHsxCzAJBgNVBAYTAkRFMRwwGgYDVQQKExNU +QyBUcnVzdENlbnRlciBHbWJIMSQwIgYDVQQLExtUQyBUcnVzdENlbnRlciBVbml2ZXJzYWwgQ0Ex +KDAmBgNVBAMTH1RDIFRydXN0Q2VudGVyIFVuaXZlcnNhbCBDQSBJSUkwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDC2pxisLlxErALyBpXsq6DFJmzNEubkKLF5+cvAqBNLaT6hdqbJYUt +QCggbergvbFIgyIpRJ9Og+41URNzdNW88jBmlFPAQDYvDIRlzg9uwliT6CwLOunBjvvya8o84pxO +juT5fdMnnxvVZ3iHLX8LR7PH6MlIfK8vzArZQe+f/prhsq75U7Xl6UafYOPfjdN/+5Z+s7Vy+Eut +CHnNaYlAJ/Uqwa1D7KRTyGG299J5KmcYdkhtWyUB0SbFt1dpIxVbYYqt8Bst2a9c8SaQaanVDED1 +M4BDj5yjdipFtK+/fz6HP3bFzSreIMUWWMv5G/UPyw0RUmS40nZid4PxWJ//AgMBAAGjYzBhMB8G +A1UdIwQYMBaAFFbn4VslQ4Dg9ozhcbyO5YAvxEjiMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/ +BAQDAgEGMB0GA1UdDgQWBBRW5+FbJUOA4PaM4XG8juWAL8RI4jANBgkqhkiG9w0BAQUFAAOCAQEA +g8ev6n9NCjw5sWi+e22JLumzCecYV42FmhfzdkJQEw/HkG8zrcVJYCtsSVgZ1OK+t7+rSbyUyKu+ +KGwWaODIl0YgoGhnYIg5IFHYaAERzqf2EQf27OysGh+yZm5WZ2B6dF7AbZc2rrUNXWZzwCUyRdhK +BgePxLcHsU0GDeGl6/R1yrqc0L2z0zIkTO5+4nYES0lT2PLpVDP85XEfPRRclkvxOvIAu2y0+pZV +CIgJwcyRGSmwIC3/yzikQOEXvnlhgP8HA4ZMTnsGnxGGjYnuJ8Tb4rwZjgvDwxPHLQNjO9Po5KIq +woIIlBZU8O8fJ5AluA0OKBtHd0e9HKgl8ZS0Zg== +-----END CERTIFICATE----- + +Autoridad de Certificacion Firmaprofesional CIF A62634068 +========================================================= +-----BEGIN CERTIFICATE----- +MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA +BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 +MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw +QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB +NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD +Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P +B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY +7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH +ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI +plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX +MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX +LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK +bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU +vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud +EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH +DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp +cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA +bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx +ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx +51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk +R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP +T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f +Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl +osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR +crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR +saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD +KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi +6Et8Vcad+qMUu2WFbm5PEn4KPJ2V +-----END CERTIFICATE----- + +Izenpe.com +========== +-----BEGIN CERTIFICATE----- +MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG +EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz +MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu +QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ +03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK +ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU ++zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC +PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT +OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK +F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK +0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+ +0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB +leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID +AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+ +SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG +NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx +MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O +BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l +Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga +kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q +hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs +g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5 +aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5 +nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC +ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo +Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z +WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw== +-----END CERTIFICATE----- + +Chambers of Commerce Root - 2008 +================================ +-----BEGIN CERTIFICATE----- +MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD +MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv +bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu +QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy +Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl +ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF +EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl +cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC +AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA +XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj +h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/ +ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk +NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g +D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331 +lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ +0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj +ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2 +EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI +G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ +BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh +bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh +bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC +CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH +AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1 +wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH +3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU +RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6 +M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1 +YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF +9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK +zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG +nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg +OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ +-----END CERTIFICATE----- + +Global Chambersign Root - 2008 +============================== +-----BEGIN CERTIFICATE----- +MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD +MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv +bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu +QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx +NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg +Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ +QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD +aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf +VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf +XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0 +ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB +/gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA +TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M +H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe +Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF +HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh +wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB +AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT +BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE +BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm +aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm +aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp +1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0 +dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG +/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6 +ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s +dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg +9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH +foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du +qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr +P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq +c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z +09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B +-----END CERTIFICATE----- + +Go Daddy Root Certificate Authority - G2 +======================================== +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu +MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5 +MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6 +b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G +A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq +9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD ++qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd +fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl +NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9 +BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac +vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r +5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV +N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO +LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1 +-----END CERTIFICATE----- + +Starfield Root Certificate Authority - G2 +========================================= +-----BEGIN CERTIFICATE----- +MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s +b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0 +eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw +DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg +VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB +dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv +W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs +bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk +N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf +ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU +JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol +TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx +4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw +F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K +pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ +c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0 +-----END CERTIFICATE----- + +Starfield Services Root Certificate Authority - G2 +================================================== +-----BEGIN CERTIFICATE----- +MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s +b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl +IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV +BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT +dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg +Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2 +h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa +hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP +LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB +rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw +AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG +SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP +E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy +xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd +iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza +YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6 +-----END CERTIFICATE----- + +AffirmTrust Commercial +====================== +-----BEGIN CERTIFICATE----- +MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS +BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw +MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly +bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb +DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV +C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6 +BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww +MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV +HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG +hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi +qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv +0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh +sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8= +-----END CERTIFICATE----- + +AffirmTrust Networking +====================== +-----BEGIN CERTIFICATE----- +MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS +BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw +MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly +bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE +Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI +dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24 +/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb +h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV +HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu +UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6 +12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23 +WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9 +/ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s= +-----END CERTIFICATE----- + +AffirmTrust Premium +=================== +-----BEGIN CERTIFICATE----- +MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS +BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy +OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy +dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A +MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn +BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV +5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs ++7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd +GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R +p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI +S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04 +6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5 +/bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo ++Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB +/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv +MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg +Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC +6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S +L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK ++4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV +BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg +IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60 +g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb +zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw== +-----END CERTIFICATE----- + +AffirmTrust Premium ECC +======================= +-----BEGIN CERTIFICATE----- +MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV +BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx +MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U +cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA +IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ +N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW +BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK +BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X +57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM +eQ== +-----END CERTIFICATE----- + +Certum Trusted Network CA +========================= +-----BEGIN CERTIFICATE----- +MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK +ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy +MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU +ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC +l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J +J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4 +fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0 +cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB +Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw +DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj +jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1 +mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj +Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI +03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw= +-----END CERTIFICATE----- + +Certinomis - Autorité Racine +============================= +-----BEGIN CERTIFICATE----- +MIIFnDCCA4SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJGUjETMBEGA1UEChMK +Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxJjAkBgNVBAMMHUNlcnRpbm9taXMg +LSBBdXRvcml0w6kgUmFjaW5lMB4XDTA4MDkxNzA4Mjg1OVoXDTI4MDkxNzA4Mjg1OVowYzELMAkG +A1UEBhMCRlIxEzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMSYw +JAYDVQQDDB1DZXJ0aW5vbWlzIC0gQXV0b3JpdMOpIFJhY2luZTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAJ2Fn4bT46/HsmtuM+Cet0I0VZ35gb5j2CN2DpdUzZlMGvE5x4jYF1AMnmHa +wE5V3udauHpOd4cN5bjr+p5eex7Ezyh0x5P1FMYiKAT5kcOrJ3NqDi5N8y4oH3DfVS9O7cdxbwly +Lu3VMpfQ8Vh30WC8Tl7bmoT2R2FFK/ZQpn9qcSdIhDWerP5pqZ56XjUl+rSnSTV3lqc2W+HN3yNw +2F1MpQiD8aYkOBOo7C+ooWfHpi2GR+6K/OybDnT0K0kCe5B1jPyZOQE51kqJ5Z52qz6WKDgmi92N +jMD2AR5vpTESOH2VwnHu7XSu5DaiQ3XV8QCb4uTXzEIDS3h65X27uK4uIJPT5GHfceF2Z5c/tt9q +c1pkIuVC28+BA5PY9OMQ4HL2AHCs8MF6DwV/zzRpRbWT5BnbUhYjBYkOjUjkJW+zeL9i9Qf6lSTC +lrLooyPCXQP8w9PlfMl1I9f09bze5N/NgL+RiH2nE7Q5uiy6vdFrzPOlKO1Enn1So2+WLhl+HPNb +xxaOu2B9d2ZHVIIAEWBsMsGoOBvrbpgT1u449fCfDu/+MYHB0iSVL1N6aaLwD4ZFjliCK0wi1F6g +530mJ0jfJUaNSih8hp75mxpZuWW/Bd22Ql095gBIgl4g9xGC3srYn+Y3RyYe63j3YcNBZFgCQfna +4NH4+ej9Uji29YnfAgMBAAGjWzBZMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G +A1UdDgQWBBQNjLZh2kS40RR9w759XkjwzspqsDAXBgNVHSAEEDAOMAwGCiqBegFWAgIAAQEwDQYJ +KoZIhvcNAQEFBQADggIBACQ+YAZ+He86PtvqrxyaLAEL9MW12Ukx9F1BjYkMTv9sov3/4gbIOZ/x +WqndIlgVqIrTseYyCYIDbNc/CMf4uboAbbnW/FIyXaR/pDGUu7ZMOH8oMDX/nyNTt7buFHAAQCva +R6s0fl6nVjBhK4tDrP22iCj1a7Y+YEq6QpA0Z43q619FVDsXrIvkxmUP7tCMXWY5zjKn2BCXwH40 +nJ+U8/aGH88bc62UeYdocMMzpXDn2NU4lG9jeeu/Cg4I58UvD0KgKxRA/yHgBcUn4YQRE7rWhh1B +CxMjidPJC+iKunqjo3M3NYB9Ergzd0A4wPpeMNLytqOx1qKVl4GbUu1pTP+A5FPbVFsDbVRfsbjv +JL1vnxHDx2TCDyhihWZeGnuyt++uNckZM6i4J9szVb9o4XVIRFb7zdNIu0eJOqxp9YDG5ERQL1TE +qkPFMTFYvZbF6nVsmnWxTfj3l/+WFvKXTej28xH5On2KOG4Ey+HTRRWqpdEdnV1j6CTmNhTih60b +WfVEm/vXd3wfAXBioSAaosUaKPQhA+4u2cGA6rnZgtZbdsLLO7XSAPCjDuGtbkD326C00EauFddE +wk01+dIL8hf2rGbVJLJP0RyZwG71fet0BLj5TXcJ17TPBzAJ8bgAVtkXFhYKK4bfjwEZGuW7gmP/ +vgt2Fl43N+bYdJeimUV5 +-----END CERTIFICATE----- + +Root CA Generalitat Valenciana +============================== +-----BEGIN CERTIFICATE----- +MIIGizCCBXOgAwIBAgIEO0XlaDANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJFUzEfMB0GA1UE +ChMWR2VuZXJhbGl0YXQgVmFsZW5jaWFuYTEPMA0GA1UECxMGUEtJR1ZBMScwJQYDVQQDEx5Sb290 +IENBIEdlbmVyYWxpdGF0IFZhbGVuY2lhbmEwHhcNMDEwNzA2MTYyMjQ3WhcNMjEwNzAxMTUyMjQ3 +WjBoMQswCQYDVQQGEwJFUzEfMB0GA1UEChMWR2VuZXJhbGl0YXQgVmFsZW5jaWFuYTEPMA0GA1UE +CxMGUEtJR1ZBMScwJQYDVQQDEx5Sb290IENBIEdlbmVyYWxpdGF0IFZhbGVuY2lhbmEwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGKqtXETcvIorKA3Qdyu0togu8M1JAJke+WmmmO3I2 +F0zo37i7L3bhQEZ0ZQKQUgi0/6iMweDHiVYQOTPvaLRfX9ptI6GJXiKjSgbwJ/BXufjpTjJ3Cj9B +ZPPrZe52/lSqfR0grvPXdMIKX/UIKFIIzFVd0g/bmoGlu6GzwZTNVOAydTGRGmKy3nXiz0+J2ZGQ +D0EbtFpKd71ng+CT516nDOeB0/RSrFOyA8dEJvt55cs0YFAQexvba9dHq198aMpunUEDEO5rmXte +JajCq+TA81yc477OMUxkHl6AovWDfgzWyoxVjr7gvkkHD6MkQXpYHYTqWBLI4bft75PelAgxAgMB +AAGjggM7MIIDNzAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9vY3NwLnBraS5n +dmEuZXMwEgYDVR0TAQH/BAgwBgEB/wIBAjCCAjQGA1UdIASCAiswggInMIICIwYKKwYBBAG/VQIB +ADCCAhMwggHoBggrBgEFBQcCAjCCAdoeggHWAEEAdQB0AG8AcgBpAGQAYQBkACAAZABlACAAQwBl +AHIAdABpAGYAaQBjAGEAYwBpAPMAbgAgAFIAYQDtAHoAIABkAGUAIABsAGEAIABHAGUAbgBlAHIA +YQBsAGkAdABhAHQAIABWAGEAbABlAG4AYwBpAGEAbgBhAC4ADQAKAEwAYQAgAEQAZQBjAGwAYQBy +AGEAYwBpAPMAbgAgAGQAZQAgAFAAcgDhAGMAdABpAGMAYQBzACAAZABlACAAQwBlAHIAdABpAGYA +aQBjAGEAYwBpAPMAbgAgAHEAdQBlACAAcgBpAGcAZQAgAGUAbAAgAGYAdQBuAGMAaQBvAG4AYQBt +AGkAZQBuAHQAbwAgAGQAZQAgAGwAYQAgAHAAcgBlAHMAZQBuAHQAZQAgAEEAdQB0AG8AcgBpAGQA +YQBkACAAZABlACAAQwBlAHIAdABpAGYAaQBjAGEAYwBpAPMAbgAgAHMAZQAgAGUAbgBjAHUAZQBu +AHQAcgBhACAAZQBuACAAbABhACAAZABpAHIAZQBjAGMAaQDzAG4AIAB3AGUAYgAgAGgAdAB0AHAA +OgAvAC8AdwB3AHcALgBwAGsAaQAuAGcAdgBhAC4AZQBzAC8AYwBwAHMwJQYIKwYBBQUHAgEWGWh0 +dHA6Ly93d3cucGtpLmd2YS5lcy9jcHMwHQYDVR0OBBYEFHs100DSHHgZZu90ECjcPk+yeAT8MIGV +BgNVHSMEgY0wgYqAFHs100DSHHgZZu90ECjcPk+yeAT8oWykajBoMQswCQYDVQQGEwJFUzEfMB0G +A1UEChMWR2VuZXJhbGl0YXQgVmFsZW5jaWFuYTEPMA0GA1UECxMGUEtJR1ZBMScwJQYDVQQDEx5S +b290IENBIEdlbmVyYWxpdGF0IFZhbGVuY2lhbmGCBDtF5WgwDQYJKoZIhvcNAQEFBQADggEBACRh +TvW1yEICKrNcda3FbcrnlD+laJWIwVTAEGmiEi8YPyVQqHxK6sYJ2fR1xkDar1CdPaUWu20xxsdz +Ckj+IHLtb8zog2EWRpABlUt9jppSCS/2bxzkoXHPjCpaF3ODR00PNvsETUlR4hTJZGH71BTg9J63 +NI8KJr2XXPR5OkowGcytT6CYirQxlyric21+eLj4iIlPsSKRZEv1UN4D2+XFducTZnV+ZfsBn5OH +iJ35Rld8TWCvmHMTI6QgkYH60GFmuH3Rr9ZvHmw96RH9qfmCIoaZM3Fa6hlXPZHNqcCjbgcTpsnt ++GijnsNacgmHKNHEc8RzGF9QdRYxn7fofMM= +-----END CERTIFICATE----- + +A-Trust-nQual-03 +================ +-----BEGIN CERTIFICATE----- +MIIDzzCCAregAwIBAgIDAWweMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJBVDFIMEYGA1UE +Cgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy +a2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5RdWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5R +dWFsLTAzMB4XDTA1MDgxNzIyMDAwMFoXDTE1MDgxNzIyMDAwMFowgY0xCzAJBgNVBAYTAkFUMUgw +RgYDVQQKDD9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0 +ZW52ZXJrZWhyIEdtYkgxGTAXBgNVBAsMEEEtVHJ1c3QtblF1YWwtMDMxGTAXBgNVBAMMEEEtVHJ1 +c3QtblF1YWwtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtPWFuA/OQO8BBC4SA +zewqo51ru27CQoT3URThoKgtUaNR8t4j8DRE/5TrzAUjlUC5B3ilJfYKvUWG6Nm9wASOhURh73+n +yfrBJcyFLGM/BWBzSQXgYHiVEEvc+RFZznF/QJuKqiTfC0Li21a8StKlDJu3Qz7dg9MmEALP6iPE +SU7l0+m0iKsMrmKS1GWH2WrX9IWf5DMiJaXlyDO6w8dB3F/GaswADm0yqLaHNgBid5seHzTLkDx4 +iHQF63n1k3Flyp3HaxgtPVxO59X4PzF9j4fsCiIvI+n+u33J4PTs63zEsMMtYrWacdaxaujs2e3V +cuy+VwHOBVWf3tFgiBCzAgMBAAGjNjA0MA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0OBAoECERqlWdV +eRFPMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAVdRU0VlIXLOThaq/Yy/kgM40 +ozRiPvbY7meIMQQDbwvUB/tOdQ/TLtPAF8fGKOwGDREkDg6lXb+MshOWcdzUzg4NCmgybLlBMRmr +sQd7TZjTXLDR8KdCoLXEjq/+8T/0709GAHbrAvv5ndJAlseIOrifEXnzgGWovR/TeIGgUUw3tKZd +JXDRZslo+S4RFGjxVJgIrCaSD96JntT6s3kr0qN51OyLrIdTaEJMUVF0HhsnLuP1Hyl0Te2v9+GS +mYHovjrHF1D2t8b8m7CKa9aIA5GPBnc6hQLdmNVDeD/GMBWsm2vLV7eJUYs66MmEDNuxUCAKGkq6 +ahq97BvIxYSazQ== +-----END CERTIFICATE----- + +TWCA Root Certification Authority +================================= +-----BEGIN CERTIFICATE----- +MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ +VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG +EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB +IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK +AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx +QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC +oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP +4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r +y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB +BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG +9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC +mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW +QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY +T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny +Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw== +-----END CERTIFICATE----- + +Security Communication RootCA2 +============================== +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc +U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh +dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC +SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy +aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++ ++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R +3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV +spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K +EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8 +QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB +CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj +u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk +3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q +tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29 +mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 +-----END CERTIFICATE----- + +EC-ACC +====== +-----BEGIN CERTIFICATE----- +MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE +BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w +ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD +VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE +CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT +BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7 +MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt +SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl +Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh +cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK +w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT +ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4 +HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a +E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw +0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E +BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD +VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0 +Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l +dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ +lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa +Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe +l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2 +E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D +5EI= +-----END CERTIFICATE----- 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 452eadc656..4bb6376393 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -23,7 +23,10 @@ * * Contributor(s): * - * Chris Rienzo + * Christopher M. Rienzo + * Darren Schreiber + * + * Maintainer: Christopher M. Rienzo * * mod_http_cache.c -- HTTP GET with caching * -- designed for downloading audio files from a webserver for playback @@ -96,12 +99,12 @@ struct http_get_data { }; typedef struct http_get_data http_get_data_t; -static switch_status_t http_get(cached_url_t *url, switch_core_session_t *session); +static switch_status_t http_get(url_cache_t *cache, cached_url_t *url, switch_core_session_t *session); static size_t get_file_callback(void *ptr, size_t size, size_t nmemb, void *get); static size_t get_header_callback(void *ptr, size_t size, size_t nmemb, void *url); static void process_cache_control_header(cached_url_t *url, char *data); -static switch_status_t http_put(switch_core_session_t *session, const char *url, const char *filename); +static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename); /** * Queue used for clock cache replacement algorithm. This @@ -159,6 +162,12 @@ struct url_cache { int shutdown; /** Synchronizes shutdown of cache */ switch_thread_rwlock_t *shutdown_lock; + /** SSL cert filename */ + char *ssl_cacert; + /** Verify certificate */ + int ssl_verifypeer; + /** Verify that hostname matches certificate */ + int ssl_verifyhost; }; static url_cache_t gcache; @@ -173,20 +182,38 @@ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session); /** * Put a file to the URL + * @param cache the cache * @param session the (optional) session uploading the file * @param url The URL * @param filename The file to upload * @return SWITCH_STATUS_SUCCESS if successful */ -static switch_status_t http_put(switch_core_session_t *session, const char *url, const char *filename) +static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename) { switch_status_t status = SWITCH_STATUS_SUCCESS; + + switch_curl_slist_t *headers = NULL; /* optional linked-list of HTTP headers */ + char *ext; /* file extension, used for MIME type identification */ + const char *mime_type = "application/octet-stream"; + char *buf; + CURL *curl_handle = NULL; long httpRes = 0; struct stat file_info = {0}; FILE *file_to_put = NULL; int fd; - + + /* guess what type of mime content this is going to be */ + if ((ext = strrchr(filename, '.'))) { + ext++; + if (!(mime_type = switch_core_mime_ext2type(ext))) { + mime_type = "application/octet-stream"; + } + } + + buf = switch_mprintf("Content-Type: %s", mime_type); + headers = switch_curl_slist_append(headers, buf); + /* open file and get the file size */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "opening %s for upload to %s\n", filename, url); fd = open(filename, O_RDONLY); @@ -217,12 +244,25 @@ static switch_status_t http_put(switch_core_session_t *session, const char *url, switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); + switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url); switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put); switch_curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10); switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0"); + if (!cache->ssl_verifypeer) { + switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); + } else { + /* this is the file with all the trusted certificate authorities */ + if (!zstr(cache->ssl_cacert)) { + switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, cache->ssl_cacert); + } + /* verify that the host name matches the cert */ + if (!cache->ssl_verifyhost) { + switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); + } + } switch_curl_easy_perform(curl_handle); switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes); switch_curl_easy_cleanup(curl_handle); @@ -239,6 +279,12 @@ done: fclose(file_to_put); } + if (headers) { + switch_curl_slist_free_all(headers); + } + + switch_safe_free(buf); + return status; } @@ -276,6 +322,7 @@ static size_t get_file_callback(void *ptr, size_t size, size_t nmemb, void *get) static char *trim(char *str) { size_t len; + int i; if (zstr(str)) { return str; @@ -283,7 +330,7 @@ static char *trim(char *str) len = strlen(str); /* strip whitespace from front */ - for (int i = 0; i < len; i++) { + for (i = 0; i < len; i++) { if (!isspace(str[i])) { str = &str[i]; len -= i; @@ -295,7 +342,7 @@ static char *trim(char *str) } /* strip whitespace from end */ - for (int i = len - 1; i >= 0; i--) { + for (i = len - 1; i >= 0; i--) { if (!isspace(str[i])) { break; } @@ -313,6 +360,7 @@ static void process_cache_control_header(cached_url_t *url, char *data) { char *max_age_str; switch_time_t max_age; + int i; /* trim whitespace and check if empty */ data = trim(data); @@ -331,7 +379,7 @@ static void process_cache_control_header(cached_url_t *url, char *data) if (zstr(max_age_str)) { return; } - for (int i = 0; i < strlen(max_age_str); i++) { + for (i = 0; i < strlen(max_age_str); i++) { if (!isdigit(max_age_str[i])) { max_age_str[i] = '\0'; break; @@ -346,7 +394,7 @@ static void process_cache_control_header(cached_url_t *url, char *data) return; } - url->max_age = switch_time_now() + (max_age * 1000 * 1000); + url->max_age = max_age * 1000 * 1000; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting max age to %u seconds from now\n", (int)max_age); } @@ -412,10 +460,12 @@ static void url_cache_unlock(url_cache_t *cache, switch_core_session_t *session) */ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session) { + int i; + url_cache_lock(cache, session); // remove each cached URL from the hash and the queue - for (int i = 0; i < cache->queue.max_size; i++) { + for (i = 0; i < cache->queue.max_size; i++) { cached_url_t *url = cache->queue.data[i]; if (url) { switch_core_hash_delete(cache->map, url->url); @@ -485,7 +535,7 @@ static char *url_cache_get(url_cache_t *cache, switch_core_session_t *session, c /* download the file */ url_cache_unlock(cache, session); - if (http_get(u, session) == SWITCH_STATUS_SUCCESS) { + if (http_get(cache, u, session) == SWITCH_STATUS_SUCCESS) { /* Got the file, let the waiters know it is available */ url_cache_lock(cache, session); u->status = CACHED_URL_AVAILABLE; @@ -648,6 +698,7 @@ static cached_url_t *cached_url_create(url_cache_t *cache, const char *url) char *dirname = NULL; cached_url_t *u = NULL; const char *file_extension = ""; + const char *ext = NULL; if (zstr(url)) { return NULL; @@ -666,7 +717,7 @@ static cached_url_t *cached_url_create(url_cache_t *cache, const char *url) switch_dir_make_recursive(dirname, SWITCH_DEFAULT_DIR_PERMS, cache->pool); /* find extension on the end of URL */ - for(const char *ext = &url[strlen(url) - 1]; ext != url; ext--) { + for (ext = &url[strlen(url) - 1]; ext != url; ext--) { if (*ext == '/' || *ext == '\\') { break; } @@ -708,11 +759,12 @@ static void cached_url_destroy(cached_url_t *url, switch_memory_pool_t *pool) /** * Fetch a file via HTTP + * @param cache the cache * @param url The cached URL entry * @param session the (optional) session * @return SWITCH_STATUS_SUCCESS if successful */ -static switch_status_t http_get(cached_url_t *url, switch_core_session_t *session) +static switch_status_t http_get(url_cache_t *cache, cached_url_t *url, switch_core_session_t *session) { switch_status_t status = SWITCH_STATUS_SUCCESS; switch_CURL *curl_handle = NULL; @@ -734,7 +786,19 @@ static switch_status_t http_get(cached_url_t *url, switch_core_session_t *sessio switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &get_data); switch_curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, get_header_callback); switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void *) url); - switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0"); + switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0"); + if (!cache->ssl_verifypeer) { + switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); + } else { + /* this is the file with all the trusted certificate authorities */ + if (!zstr(cache->ssl_cacert)) { + switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, cache->ssl_cacert); + } + /* verify that the host name matches the cert */ + if (!cache->ssl_verifyhost) { + switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); + } + } switch_curl_easy_perform(curl_handle); switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes); switch_curl_easy_cleanup(curl_handle); @@ -766,10 +830,12 @@ static switch_status_t http_get(cached_url_t *url, switch_core_session_t *sessio */ static void setup_dir(url_cache_t *cache) { + int i; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting up %s\n", cache->location); switch_dir_make_recursive(cache->location, SWITCH_DEFAULT_DIR_PERMS, cache->pool); - for (int i = 0x00; i <= 0xff; i++) { + for (i = 0x00; i <= 0xff; i++) { switch_dir_t *dir = NULL; char *dirname = switch_mprintf("%s%s%02x", cache->location, SWITCH_PATH_SEPARATOR, i); if (switch_dir_open(&dir, dirname, cache->pool) == SWITCH_STATUS_SUCCESS) { @@ -791,7 +857,7 @@ static void setup_dir(url_cache_t *cache) static int isUrl(const char *filename) { - return !zstr(filename) && !strncmp("http://", filename, strlen("http://")); + return !zstr(filename) && (!strncmp("http://", filename, strlen("http://")) || !strncmp("https://", filename, strlen("https://"))); } #define HTTP_PREFETCH_SYNTAX "" @@ -868,7 +934,7 @@ SWITCH_STANDARD_API(http_cache_tryget) switch_memory_pool_t *pool = NULL; char *filename; - if (zstr(cmd) || strncmp("http://", cmd, strlen("http://"))) { + if (!isUrl(cmd)) { stream->write_function(stream, "USAGE: %s\n", HTTP_GET_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -910,7 +976,7 @@ SWITCH_STANDARD_API(http_cache_put) char *argv[10] = { 0 }; int argc = 0; - if (zstr(cmd) || strncmp("http://", cmd, strlen("http://"))) { + if (zstr(cmd) || (strncmp("http://", cmd, strlen("http://")) && strncmp("https://", cmd, strlen("https://")))) { stream->write_function(stream, "USAGE: %s\n", HTTP_PUT_SYNTAX); status = SWITCH_STATUS_SUCCESS; goto done; @@ -924,7 +990,7 @@ SWITCH_STANDARD_API(http_cache_put) goto done; } - status = http_put(session, argv[0], argv[1]); + status = http_put(&gcache, session, argv[0], argv[1]); if (status == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK\n"); } else { @@ -1013,6 +1079,9 @@ static switch_status_t do_config(url_cache_t *cache) cache->location = SWITCH_PREFIX_DIR "/http_cache"; cache->prefetch_queue_size = 100; cache->prefetch_thread_count = 8; + cache->ssl_cacert = SWITCH_PREFIX_DIR "/conf/cacert.pem"; + cache->ssl_verifyhost = 1; + cache->ssl_verifypeer = 1; /* get params */ settings = switch_xml_child(cfg, "settings"); @@ -1035,6 +1104,15 @@ static switch_status_t do_config(url_cache_t *cache) } else if (!strcasecmp(var, "prefetch-thread-count")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting prefetch-thread-count to %s\n", val); cache->prefetch_thread_count = atoi(val); + } else if (!strcasecmp(var, "ssl-cacert")) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting ssl-cacert to %s\n", val); + cache->ssl_cacert = switch_core_strdup(cache->pool, val); + } else if (!strcasecmp(var, "ssl-verifyhost")) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting ssl-verifyhost to %s\n", val); + cache->ssl_verifyhost = !switch_false(val); /* only disable if explicitly set to false */ + } else if (!strcasecmp(var, "ssl-verifypeer")) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting ssl-verifypeer to %s\n", val); + cache->ssl_verifypeer = !switch_false(val); /* only disable if explicitly set to false */ } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var); } @@ -1082,6 +1160,8 @@ done: SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load) { switch_api_interface_t *api; + int i; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_API(api, "http_get", "HTTP GET", http_cache_get, HTTP_GET_SYNTAX); @@ -1111,7 +1191,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load) /* Start the prefetch threads */ switch_queue_create(&gcache.prefetch_queue, gcache.prefetch_queue_size, gcache.pool); - for (int i = 0; i < gcache.prefetch_thread_count; i++) { + for (i = 0; i < gcache.prefetch_thread_count; i++) { int started = 0; switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; diff --git a/src/mod/applications/mod_mongo/Makefile b/src/mod/applications/mod_mongo/Makefile index 26687b5ac6..cdab0466be 100644 --- a/src/mod/applications/mod_mongo/Makefile +++ b/src/mod/applications/mod_mongo/Makefile @@ -24,6 +24,9 @@ $(MONGO_CXX_DRIVER_SRC): $(LIBMONGOCLIENT_A): $(MONGO_CXX_DRIVER_SRC) - cd $(MONGO_CXX_DRIVER_SRC) && scons + (cd $(MONGO_CXX_DRIVER_SRC) && \ + sed -i SConstruct -e "s/Environment()/Environment(ENV = {'PATH' : os.environ['PATH'],'CFLAGS' : os.environ['CFLAGS'],'CXXFLAGS' : os.environ['CXXFLAGS']})/" && \ + echo "env.Append(PATH=os.environ['PATH'])" >> SConstruct && \ + scons) $(TOUCH_TARGET) diff --git a/src/mod/applications/mod_mongo/mod_mongo.cpp b/src/mod/applications/mod_mongo/mod_mongo.cpp index 85bbd0ee4a..27723af13d 100644 --- a/src/mod/applications/mod_mongo/mod_mongo.cpp +++ b/src/mod/applications/mod_mongo/mod_mongo.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_mongo/mod_mongo.h b/src/mod/applications/mod_mongo/mod_mongo.h index a1c8322bd7..b336443225 100644 --- a/src/mod/applications/mod_mongo/mod_mongo.h +++ b/src/mod/applications/mod_mongo/mod_mongo.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_mongo/mongo_conn.cpp b/src/mod/applications/mod_mongo/mongo_conn.cpp index 075b8f85d6..673e1be768 100644 --- a/src/mod/applications/mod_mongo/mongo_conn.cpp +++ b/src/mod/applications/mod_mongo/mongo_conn.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_mp4/mod_mp4.cpp b/src/mod/applications/mod_mp4/mod_mp4.cpp index 0d9eac113f..56cbf53877 100644 --- a/src/mod/applications/mod_mp4/mod_mp4.cpp +++ b/src/mod/applications/mod_mp4/mod_mp4.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_nibblebill/mod_nibblebill.c b/src/mod/applications/mod_nibblebill/mod_nibblebill.c index 44cbc29abc..c1a788454a 100755 --- a/src/mod/applications/mod_nibblebill/mod_nibblebill.c +++ b/src/mod/applications/mod_nibblebill/mod_nibblebill.c @@ -287,7 +287,7 @@ static void transfer_call(switch_core_session_t *session, char *destination) switch_separate_string(mydup, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); /* Find the uuid of our B leg. If it exists, transfer it first */ - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if ((uuid = switch_channel_get_partner_uuid(channel))) { switch_core_session_t *b_session; /* Get info on the B leg */ diff --git a/src/mod/applications/mod_osp/docs/mod_osp.txt b/src/mod/applications/mod_osp/docs/mod_osp.txt new file mode 100644 index 0000000000..a5686a4a03 --- /dev/null +++ b/src/mod/applications/mod_osp/docs/mod_osp.txt @@ -0,0 +1,84 @@ +FreeSWITCH Open Settlement Protocol (OSP) module + +This module provides OSP based call authentication, authorization, routing lookup and call detail record (CDR) collection services using standard FreeSWITCH application and dailplan interfaces. + +The OSP module can be configured by the following parameters in osp.conf.xml: + +Global parameters: + + + + + +Global parameter names and values can be: + +debug-info: Flag to show OSP module debug information. The default is "disabled". +log-level: At which log level to show OSP module debug information. The default is "info". +crypto-hardware: If to use hardware for OpenSSL. The default is "disabled". +sip: Used SIP module and profile. The default is "sofia" and "external". +h323: Used H.323 module and profile. The default is "h323" and "external". This option has not been implemented. +iax: Used IAX2 module and profile. The default is "iax" and "external". This option has not been implemented. +skype: Used Skype module and profile. The default is "skypopen" and "external". This option has not been implemented. +default-protocol: The VoIP protocol for destinations with unknown/undefined protocol. The default is "sip". + +OSP provider parameters: + + + + + + + +OSP provider parameter names ane values cab be: + +profile: OSP provider profile name. +service-point-url: OSP service point URL. This parameter must be defined. Up to 8 URLs are allowed. +device-ip: FreeSWITCH IP for OSP module. This parameter must be defined. +ssl-lifetime: SSL lifetime. The default is 300 in seconds. +http-max-connections: HTTP max connections. The default is 20. +http-persistence: HTTP persistence. The default is 60 in seconds. +http-retry-delay: HTTP retry delay. The default is 0 in seconds. +http-retry-limit: HTTP retry times. The default is 2. +http-timeout: HTTP timeout. The default is 10000 in ms. +work-mode: OSP module work mode (direct and indirect). The default is "direct". +service-type: OSP service type (voice and npquery). The default is "voice". +max-destinations: Max destinations OSP server will return. It is up to 12. The default is 12. + +The OSP application is called in dial plan like this: + + + +The OSP dialplan is called in dial plan like this: + + + +For both OSP application and dialplan, the is an OSP service provider name configured in osp.conf.xml. If it is empty, profile "default" is used. + +Both OSP application and dialplan accept a set of inbound channel variables that are used to pass additional call information to OSP module. These channel variables include: + +osp_source_device: Actual source device IP address channel variable. It is only for FreeSWITH OSP module running in indirect mode. +osp_source_nid: Source device network ID channel variable. +osp_custom_info_N: Up to 8 custom info channel variables. N is the index starting from 1. +osp_networkid_userparam: The URI user parameter name that is used to present destination network ID. +osp_networkid_uriparam: The URI parameter name that is used to present destination network ID. +osp_user_phone: Flag to add "user=phone" URI parameter. The default is "disabled". +osp_outbound_proxy: Outbound proxy IP address channel variable. + +Both OSP application and dialplan also export a set of channel variables for outbound channels and FreeSWITCH dial plan logic (for OSP dialplan, some exported channel variables are not visible for dial plan). These channel variables include: + +osp_profile: Used OSP profile name. Used by outbound channels. +osp_transaction_id: OSP transaction ID. Used by outbound channels. +osp_calling: Original inbound calling number. Used by outbound channels. +osp_called: Original inbound called number. Used by outbound channels. +osp_start_time: Inbound call start time. Used by outbound channels. +osp_source_device: Actual source device. Used by outbound channels. It is only for FreeSWITH OSP module running in indirect mode. +osp_source_nid: Source network ID. Used by outbound channels. +osp_destination_total: Total number of destinations from OSP servers. Used by outbound channels. +osp_destination_count: Destination index. Used by outbound channels. +osp_destination_ip: Destination IP. Used by outbound channels. +osp_destination_nid: Destination network ID. Used by outbound channels. +osp_authreq_status: Authorization request result status. +osp_route_count: Number of supported destinations. +osp_route_N: Destination route string. N is the index starting from 1. +osp_auto_route: Bridge route string. + diff --git a/src/mod/applications/mod_osp/mod_osp.c b/src/mod/applications/mod_osp/mod_osp.c index 1775421560..6f312386f4 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, 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 new file mode 100644 index 0000000000..08f1a8723e --- /dev/null +++ b/src/mod/applications/mod_random/mod_random.c @@ -0,0 +1,234 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2012, Anthony Minessale II + * + * 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 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): + * + * Anthony Minessale II + * Neal Horman + * + * + * mod_random.c -- entropy source module + * + */ +#include + +/* Prototypes */ +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_random_shutdown); +SWITCH_MODULE_RUNTIME_FUNCTION(mod_random_runtime); +SWITCH_MODULE_LOAD_FUNCTION(mod_random_load); + +SWITCH_MODULE_DEFINITION(mod_random, mod_random_load, mod_random_shutdown, mod_random_runtime); + +static int RUNNING = 0; +static const char *random_device_files[] = { "/dev/hwrandom", "/dev/random", NULL }; +const char *random_device_file = NULL; + +static void event_handler(switch_event_t *event); + + +SWITCH_MODULE_LOAD_FUNCTION(mod_random_load) +{ + +#ifdef WIN32 + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s missing window support\n", modname); + return SWITCH_STATUS_NOTIMPL; +#endif + + int i = 0; + + + for(i = 0 ;random_device_files[i]; i++) { + if (switch_file_exists(random_device_files[i], pool) == SWITCH_STATUS_SUCCESS) { + random_device_file = random_device_files[i]; + break; + } + } + + + if (!random_device_file) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s can't locate a random device file\n", modname); + return SWITCH_STATUS_FALSE; + } + + + if ((switch_event_bind(modname, SWITCH_EVENT_ALL, NULL, event_handler, NULL) != SWITCH_STATUS_SUCCESS)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); + return SWITCH_STATUS_TERM; + } + + /* connect my internal structure to the blank pointer passed to me */ + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + + RUNNING = 1; + + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_random_shutdown) +{ + + switch_event_unbind_callback(event_handler); + + RUNNING = 0; + + return SWITCH_STATUS_SUCCESS; +} + +#if WIN32 +SWITCH_MODULE_RUNTIME_FUNCTION(mod_random_runtime) +{ + RUNNING = 0; + return SWITCH_STATUS_TERM; +} +#else + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +typedef struct { + int count; + int size; + unsigned char *data; +} entropy_t; + + +static int random_add_entropy(int fd, void *buf, size_t size) +{ + entropy_t e = { 0 }; + int r = 0; + + e.count = size * 8; + e.size = size; + e.data = (unsigned char *) buf; + + if (ioctl(fd, RNDADDENTROPY, &e) != 0) { + r = 1; + } + + return r; +} + +static int rng_read(int fd, void *buf, size_t size) +{ + size_t off = 0; + ssize_t r; + unsigned char *bp = (unsigned char *) buf; + + while (size > 0) { + do { + r = read(fd, bp + off, size); + } while ((r == -1) && (errno == EINTR)); + + if (r <= 0) { + break; + } + + off += r; + size -= r; + } + + return size; +} + +static int rfd = 0; + +static void event_handler(switch_event_t *event) +{ + char *buf; + + if (switch_event_serialize(event, &buf, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { + random_add_entropy(rfd, buf, strlen(buf)); + free(buf); + } + +} + +SWITCH_MODULE_RUNTIME_FUNCTION(mod_random_runtime) +{ + + unsigned char data[1024] = {0}; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread starting using random_device_file %s\n", modname, random_device_file); + + if ((rfd = open(random_device_file, O_RDWR)) < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Error opening random_device_file %s\n", modname, random_device_file); + RUNNING = 0; + } + + rng_read(rfd, data, 4); + + while(RUNNING) { + int16_t data[64]; + int i = 0; + int len = sizeof(data) / 2; + + switch_generate_sln_silence(data, len, 1); + random_add_entropy(rfd, data, len); + + while(i < len && !data[i]) i++; + + if (i < len) { + switch_yield(abs(data[i]) * 1000); + } + + } + + if (rfd > -1) { + close(rfd); + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread ending\n", modname); + + return SWITCH_STATUS_TERM; +} + +#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 + */ diff --git a/src/mod/applications/mod_redis/credis.c b/src/mod/applications/mod_redis/credis.c index bb71904005..d25756fc3a 100644 --- a/src/mod/applications/mod_redis/credis.c +++ b/src/mod/applications/mod_redis/credis.c @@ -32,6 +32,11 @@ #include #include #include +#ifdef _MSC_VER +#include +#include +#define snprintf _snprintf +#else #include #include #include @@ -39,6 +44,7 @@ #include #include #include +#endif #include #include #include @@ -550,6 +556,7 @@ REDIS credis_connect(const char *host, int port, int timeout) int fd, yes = 1; struct sockaddr_in sa; REDIS rhnd; + int valid = 0; if ((rhnd = cr_new()) == NULL) return NULL; @@ -566,7 +573,16 @@ REDIS credis_connect(const char *host, int port, int timeout) sa.sin_family = AF_INET; sa.sin_port = htons(port); - if (inet_aton(host, &sa.sin_addr) == 0) { +#ifdef WIN32 + sa.sin_addr.S_un.S_addr = inet_addr(host); + if (sa.sin_addr.S_un.S_addr != 0) { + valid = 1; + } +#else + valid = inet_aton(host, &sa.sin_addr); +#endif + + if (valid == 0) { struct hostent *he = gethostbyname(host); if (he == NULL) goto error; diff --git a/src/mod/applications/mod_fax/mod_fax.2008.vcproj b/src/mod/applications/mod_redis/mod_redis.2008.vcproj similarity index 75% rename from src/mod/applications/mod_fax/mod_fax.2008.vcproj rename to src/mod/applications/mod_redis/mod_redis.2008.vcproj index dd10ca8a93..5afc296984 100644 --- a/src/mod/applications/mod_fax/mod_fax.2008.vcproj +++ b/src/mod/applications/mod_redis/mod_redis.2008.vcproj @@ -2,9 +2,9 @@ @@ -23,7 +23,7 @@ Name="Debug|Win32" ConfigurationType="2" InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops" - CharacterSet="0" + CharacterSet="2" > @@ -84,9 +82,11 @@ @@ -213,9 +209,11 @@ diff --git a/src/mod/applications/mod_redis/mod_redis.2010.vcxproj b/src/mod/applications/mod_redis/mod_redis.2010.vcxproj new file mode 100644 index 0000000000..d5cef0ccbb --- /dev/null +++ b/src/mod/applications/mod_redis/mod_redis.2010.vcxproj @@ -0,0 +1,123 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + mod_redis + {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6} + mod_redis + Win32Proj + + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + + false + + + + + + + X64 + + + + false + + + MachineX64 + + + + + + false + + + + + + + X64 + + + + false + + + MachineX64 + + + + + + + + + {202d7a4e-760d-4d0e-afa1-d7459ced30ff} + false + + + + + + + + + \ No newline at end of file diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index f70282f8c6..8b747cb015 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -42,7 +42,17 @@ SWITCH_MODULE_DEFINITION(mod_sms, mod_sms_load, mod_sms_shutdown, NULL); static void event_handler(switch_event_t *event) { const char *dest_proto = switch_event_get_header(event, "dest_proto"); + const char *check_failure = switch_event_get_header(event, "Delivery-Failure"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "skip_global_process", "true"); + + if (switch_true(check_failure)) { + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Delivery Failure\n"); + DUMP_EVENT(event); + + return; + } + switch_core_chat_send(dest_proto, event); } @@ -252,7 +262,7 @@ static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_ if (xinline) { switch_core_execute_chat_app(event, application, app_data); } else { - switch_event_add_header_string(*extension, SWITCH_STACK_BOTTOM, application, zstr(data) ? "__undef" : data); + switch_event_add_header_string(*extension, SWITCH_STACK_BOTTOM, application, zstr(app_data) ? "__undef" : app_data); } } switch_safe_free(substituted); diff --git a/src/mod/applications/mod_soundtouch/Makefile b/src/mod/applications/mod_soundtouch/Makefile index facfe4c0a8..2b3ff9b1ce 100644 --- a/src/mod/applications/mod_soundtouch/Makefile +++ b/src/mod/applications/mod_soundtouch/Makefile @@ -13,7 +13,7 @@ $(SNDT_SRC): $(GETLIB) $(VERSION).tar.gz $(SNDT_BUILD)/Makefile: $(SNDT_SRC) - mkdir -p $(SNDT_BUILD) + mkdir -p $(SNDT_BUILD)/config/m4 rm -rf $(SNDT_BUILD)/config/m4/* rm -rf $(SNDT_SRC)/config/m4/* cd $(SNDT_SRC) && AUTOMAKE="automake --add-missing --foreign --copy" autoreconf -fisv diff --git a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp index 37f88baf99..e991728d1a 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_spandsp/Makefile.am b/src/mod/applications/mod_spandsp/Makefile.am index 2a63c42316..023903f4ad 100644 --- a/src/mod/applications/mod_spandsp/Makefile.am +++ b/src/mod/applications/mod_spandsp/Makefile.am @@ -1,8 +1,8 @@ include $(top_srcdir)/build/modmake.rulesam MODNAME=mod_spandsp -TIFF_DIR=$(switch_srcdir)/libs/tiff-3.8.2 -TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-3.8.2 +TIFF_DIR=$(switch_srcdir)/libs/tiff-4.0.2 +TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-4.0.2 TIFF_LA=$(TIFF_BUILDDIR)/libtiff/libtiff.la BUILD_CFLAGS= SPANDSP_DIR=$(switch_srcdir)/libs/spandsp diff --git a/src/mod/applications/mod_spandsp/conf/autoload_configs/spandsp.conf.xml b/src/mod/applications/mod_spandsp/conf/autoload_configs/spandsp.conf.xml index 6f062cc731..24ef4ed26d 100644 --- a/src/mod/applications/mod_spandsp/conf/autoload_configs/spandsp.conf.xml +++ b/src/mod/applications/mod_spandsp/conf/autoload_configs/spandsp.conf.xml @@ -34,7 +34,7 @@ - + @@ -42,20 +42,25 @@ - + + + + - - + + + - - + + + diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.2008.vcproj b/src/mod/applications/mod_spandsp/mod_spandsp.2008.vcproj index 80b2a6a511..7611d79f15 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.2008.vcproj +++ b/src/mod/applications/mod_spandsp/mod_spandsp.2008.vcproj @@ -42,7 +42,7 @@ /> - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) @@ -82,7 +82,7 @@ X64 - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) @@ -96,7 +96,7 @@ - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) @@ -112,7 +112,7 @@ X64 - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index c210e02c0e..6ee395770f 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -1,4 +1,4 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * Copyright (C) 2005-2012, Anthony Minessale II * @@ -29,11 +29,13 @@ * Brian West * Steve Underwood * Antonio Gallo - * Christopher M. Rienzo + * Christopher M. Rienzo * mod_spandsp.c -- Module implementing spandsp fax, dsp, and codec functionality * */ + + #include "mod_spandsp.h" #include #include "mod_spandsp_modem.h" @@ -51,7 +53,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown); SWITCH_MODULE_DEFINITION(mod_spandsp, mod_spandsp_init, mod_spandsp_shutdown, NULL); -static switch_event_node_t *NODE = NULL; SWITCH_STANDARD_APP(spanfax_tx_function) { @@ -74,19 +75,60 @@ SWITCH_STANDARD_APP(stop_dtmf_session_function) } +SWITCH_STANDARD_APP(tdd_encode_function) +{ + char *text = (char *) data; + + if (!zstr(text)) { + spandsp_tdd_encode_session(session, text); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing text data\n"); + } +} + +SWITCH_STANDARD_APP(tdd_send_function) +{ + char *text = (char *) data; + + if (!zstr(text)) { + spandsp_tdd_send_session(session, text); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing text data\n"); + } +} + +SWITCH_STANDARD_APP(stop_tdd_encode_function) +{ + spandsp_stop_tdd_encode_session(session); +} + + + + +SWITCH_STANDARD_APP(tdd_decode_function) +{ + spandsp_tdd_decode_session(session); +} + +SWITCH_STANDARD_APP(stop_tdd_decode_function) +{ + spandsp_stop_tdd_decode_session(session); +} + + SWITCH_STANDARD_APP(spandsp_fax_detect_session_function) { - int argc = 0; + int argc = 0; char *argv[4] = { 0 }; - char *dupdata; - const char *app = NULL, *arg = NULL; - int timeout = 0; + char *dupdata; + const char *app = NULL, *arg = NULL; + int timeout = 0; int tone_type = MODEM_CONNECT_TONES_FAX_CNG; - if (!zstr(data) && (dupdata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (dupdata = switch_core_session_strdup(session, data))) { if ((argc = switch_split(dupdata, ' ', argv)) >= 2) { - app = argv[0]; - arg = argv[1]; + app = argv[0]; + arg = argv[1]; if (argc > 2) { timeout = atoi(argv[2]); if (timeout < 0) { @@ -100,71 +142,101 @@ SWITCH_STANDARD_APP(spandsp_fax_detect_session_function) tone_type = MODEM_CONNECT_TONES_FAX_CNG; } } - } - } - - if (app) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Enabling fax detection '%s' '%s'\n", argv[0], argv[1]); + } + } + + if (app) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Enabling fax detection '%s' '%s'\n", argv[0], argv[1]); spandsp_fax_detect_session(session, "rw", timeout, tone_type, 1, app, arg, NULL); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Enable fax detection '%s' '%s'\n", argv[0], argv[1]); - } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Enable fax detection '%s' '%s'\n", argv[0], argv[1]); + } } SWITCH_STANDARD_APP(spandsp_stop_fax_detect_session_function) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Disabling fax detection\n"); - spandsp_fax_stop_detect_session(session); + spandsp_fax_stop_detect_session(session); +} + +static void tdd_event_handler(switch_event_t *event) +{ + const char *uuid = switch_event_get_header(event, "tdd-uuid"); + const char *message = switch_event_get_body(event); + switch_core_session_t *session; + + if (zstr(message)) { + message = switch_event_get_header(event, "tdd-message"); + } + + if (zstr(message)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No message for tdd handler\n"); + return; + } + + if (zstr(uuid)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No uuid for tdd handler\n"); + return; + } + + if ((session = switch_core_session_locate(uuid))) { + + spandsp_tdd_encode_session(session, message); + + switch_core_session_rwunlock(session); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No session for supplied uuid.\n"); + } } static void event_handler(switch_event_t *event) { - load_configuration(1); + load_configuration(1); } SWITCH_STANDARD_APP(t38_gateway_function) { - switch_channel_t *channel = switch_core_session_get_channel(session); - time_t timeout = switch_epoch_time_now(NULL) + 20; - const char *var; - int argc = 0; - char *argv[2] = { 0 }; - char *dupdata; - const char *direction = NULL, *flags = NULL; - - if (!zstr(data) && (dupdata = switch_core_session_strdup(session, data))) { - if ((argc = switch_split(dupdata, ' ', argv))) { - if (argc > 0) { - direction = argv[0]; - } - - if (argc > 1) { - flags = argv[1]; - } - } - } + switch_channel_t *channel = switch_core_session_get_channel(session); + time_t timeout = switch_epoch_time_now(NULL) + 20; + const char *var; + int argc = 0; + char *argv[2] = { 0 }; + char *dupdata; + const char *direction = NULL, *flags = NULL; - if (zstr(direction) || strcasecmp(direction, "self")) { - direction = "peer"; - } - - switch_channel_set_variable(channel, "t38_leg", direction); + if (!zstr(data) && (dupdata = switch_core_session_strdup(session, data))) { + if ((argc = switch_split(dupdata, ' ', argv))) { + if (argc > 0) { + direction = argv[0]; + } - if (!zstr(flags) && !strcasecmp(flags, "nocng")) { - t38_gateway_start(session, direction, NULL); - } else { - if ((var = switch_channel_get_variable(channel, "t38_gateway_detect_timeout"))) { - long to = atol(var); - if (to > -1) { - timeout = (time_t) (switch_epoch_time_now(NULL) + to); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s invalid timeout value.\n", switch_channel_get_name(channel)); - } - } + if (argc > 1) { + flags = argv[1]; + } + } + } - //switch_ivr_tone_detect_session(session, "t38", "1100.0", "rw", timeout, 1, direction, NULL, t38_gateway_start); + if (zstr(direction) || strcasecmp(direction, "self")) { + direction = "peer"; + } + + switch_channel_set_variable(channel, "t38_leg", direction); + + if (!zstr(flags) && !strcasecmp(flags, "nocng")) { + t38_gateway_start(session, direction, NULL); + } else { + if ((var = switch_channel_get_variable(channel, "t38_gateway_detect_timeout"))) { + long to = atol(var); + if (to > -1) { + timeout = (time_t) (switch_epoch_time_now(NULL) + to); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s invalid timeout value.\n", switch_channel_get_name(channel)); + } + } + + //switch_ivr_tone_detect_session(session, "t38", "1100.0", "rw", timeout, 1, direction, NULL, t38_gateway_start); spandsp_fax_detect_session(session, "rw", timeout, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, 1, direction, NULL, t38_gateway_start); - } + } } /** @@ -189,34 +261,47 @@ SWITCH_STANDARD_APP(start_tone_detect_app) } } -/** - * Start tone detector API - */ + SWITCH_STANDARD_API(start_tone_detect_api) { switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_core_session_t *psession = NULL; + switch_core_session_t *psession = NULL; + char *puuid = NULL, *descriptor = NULL; if (zstr(cmd)) { - stream->write_function(stream, "-ERR missing descriptor name\n"); + stream->write_function(stream, "-ERR missing uuid\n"); return SWITCH_STATUS_SUCCESS; } - if (!(psession = switch_core_session_locate(cmd))) { - stream->write_function(stream, "-ERR Cannot locate session\n"); - return SWITCH_STATUS_SUCCESS; - } + puuid = strdup((char *)cmd); + if ((descriptor = strchr(puuid, ' '))) { + *descriptor++ = '\0'; + } - status = callprogress_detector_start(psession, cmd); + if (zstr(descriptor)) { + stream->write_function(stream, "-ERR missing descriptor name\n"); + goto end; + } + + if (!(psession = switch_core_session_locate(puuid))) { + stream->write_function(stream, "-ERR Cannot locate session\n"); + goto end; + } + + status = callprogress_detector_start(psession, descriptor); if (status == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK started\n"); } else { stream->write_function(stream, "-ERR failed to start tone detector\n"); } - - switch_core_session_rwunlock(psession); + + switch_core_session_rwunlock(psession); + + end: + + switch_safe_free(puuid); return status; } @@ -244,57 +329,142 @@ SWITCH_STANDARD_APP(stop_tone_detect_app) SWITCH_STANDARD_API(stop_tone_detect_api) { switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_core_session_t *psession = NULL; + switch_core_session_t *psession = NULL; if (zstr(cmd)) { - stream->write_function(stream, "-ERR missing descriptor name\n"); + stream->write_function(stream, "-ERR missing session UUID\n"); return SWITCH_STATUS_SUCCESS; } - if (!(psession = switch_core_session_locate(cmd))) { - stream->write_function(stream, "-ERR Cannot locate session\n"); - return SWITCH_STATUS_SUCCESS; - } + if (!(psession = switch_core_session_locate(cmd))) { + stream->write_function(stream, "-ERR Cannot locate session\n"); + return SWITCH_STATUS_SUCCESS; + } + + callprogress_detector_stop(psession); + stream->write_function(stream, "+OK stopped\n"); + switch_core_session_rwunlock(psession); - callprogress_detector_stop(psession); - stream->write_function(stream, "+OK stopped\n"); - switch_core_session_rwunlock(psession); - return status; } + +SWITCH_STANDARD_API(start_tdd_detect_api) +{ + switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_core_session_t *psession = NULL; + + if (!(psession = switch_core_session_locate(cmd))) { + stream->write_function(stream, "-ERR Cannot locate session\n"); + return SWITCH_STATUS_SUCCESS; + } + + spandsp_tdd_decode_session(psession); + + if (status == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK started\n"); + } else { + stream->write_function(stream, "-ERR failed to start tdd detector\n"); + } + + switch_core_session_rwunlock(psession); + + return status; +} + + +SWITCH_STANDARD_API(stop_tdd_detect_api) +{ + switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_core_session_t *psession = NULL; + + + if (!(psession = switch_core_session_locate(cmd))) { + stream->write_function(stream, "-ERR Cannot locate session\n"); + return SWITCH_STATUS_SUCCESS; + } + + spandsp_stop_tdd_decode_session(psession); + + stream->write_function(stream, "+OK stopped\n"); + switch_core_session_rwunlock(psession); + + return status; +} + + +SWITCH_STANDARD_API(start_send_tdd_api) +{ + switch_core_session_t *psession = NULL; + char *puuid = NULL, *text = NULL; + + if (zstr(cmd)) { + stream->write_function(stream, "-ERR missing uuid\n"); + return SWITCH_STATUS_SUCCESS; + } + + puuid = strdup((char *)cmd); + + if ((text = strchr(puuid, ' '))) { + *text++ = '\0'; + } + + if (zstr(text)) { + stream->write_function(stream, "-ERR missing text\n"); + goto end; + } + + + if (!(psession = switch_core_session_locate(puuid))) { + stream->write_function(stream, "-ERR Cannot locate session\n"); + goto end; + } + + + spandsp_tdd_encode_session(psession, text); + + stream->write_function(stream, "+OK\n"); + switch_core_session_rwunlock(psession); + + end: + + switch_safe_free(puuid); + + return SWITCH_STATUS_SUCCESS; +} + void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on) { - switch_core_session_t *target_session = NULL; - int locked = 0; + switch_core_session_t *target_session = NULL; + int locked = 0; - if (self) { - target_session = session; - } else { - if (switch_core_session_get_partner(session, &target_session) == SWITCH_STATUS_SUCCESS) { - locked = 1; - } else { - target_session = NULL; - } - } + if (self) { + target_session = session; + } else { + if (switch_core_session_get_partner(session, &target_session) == SWITCH_STATUS_SUCCESS) { + locked = 1; + } else { + target_session = NULL; + } + } - if (target_session) { - switch_core_session_message_t *msg; - - msg = switch_core_session_alloc(target_session, sizeof(*msg)); - MESSAGE_STAMP_FFL(msg); - msg->message_id = SWITCH_MESSAGE_INDICATE_AUDIO_DATA; - msg->from = __FILE__; - msg->numeric_arg = on; - - switch_core_session_queue_message(target_session, msg); + if (target_session) { + switch_core_session_message_t *msg; - if (locked) { - switch_core_session_rwunlock(target_session); - locked = 0; - } - } + msg = switch_core_session_alloc(target_session, sizeof(*msg)); + MESSAGE_STAMP_FFL(msg); + msg->message_id = SWITCH_MESSAGE_INDICATE_AUDIO_DATA; + msg->from = __FILE__; + msg->numeric_arg = on; + + switch_core_session_queue_message(target_session, msg); + + if (locked) { + switch_core_session_rwunlock(target_session); + locked = 0; + } + } } @@ -305,48 +475,46 @@ void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t sel switch_status_t load_configuration(switch_bool_t reload) { switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL, callprogress = NULL, xdescriptor = NULL; - switch_status_t status = SWITCH_STATUS_FALSE; + switch_status_t status = SWITCH_STATUS_FALSE; - switch_mutex_lock(spandsp_globals.mutex); + switch_mutex_lock(spandsp_globals.mutex); if (spandsp_globals.tones) { - switch_core_hash_destroy(&spandsp_globals.tones); - } - - if (spandsp_globals.config_pool) { - switch_core_destroy_memory_pool(&spandsp_globals.config_pool); - } + switch_core_hash_destroy(&spandsp_globals.tones); + } - switch_core_new_memory_pool(&spandsp_globals.config_pool); + if (spandsp_globals.config_pool) { + switch_core_destroy_memory_pool(&spandsp_globals.config_pool); + } + + switch_core_new_memory_pool(&spandsp_globals.config_pool); switch_core_hash_init(&spandsp_globals.tones, spandsp_globals.config_pool); - spandsp_globals.modem_dialplan = "XML"; - spandsp_globals.modem_context = "default"; - spandsp_globals.modem_count = 0; + spandsp_globals.modem_dialplan = "XML"; + spandsp_globals.modem_context = "default"; + spandsp_globals.modem_count = 0; - spandsp_globals.enable_t38 = 1; + spandsp_globals.enable_t38 = 1; spandsp_globals.total_sessions = 0; spandsp_globals.verbose = 0; spandsp_globals.use_ecm = 1; spandsp_globals.disable_v17 = 0; spandsp_globals.prepend_string = switch_core_strdup(spandsp_globals.config_pool, "fax"); spandsp_globals.spool = switch_core_strdup(spandsp_globals.config_pool, "/tmp"); - spandsp_globals.ident = "SpanDSP Fax Ident"; - spandsp_globals.header = "SpanDSP Fax Header"; - spandsp_globals.timezone = ""; - - /* TODO make configuration param */ + spandsp_globals.ident = "SpanDSP Fax Ident"; + spandsp_globals.header = "SpanDSP Fax Header"; + spandsp_globals.timezone = ""; spandsp_globals.tonedebug = 0; if ((xml = switch_xml_open_cfg("spandsp.conf", &cfg, NULL)) || (xml = switch_xml_open_cfg("fax.conf", &cfg, NULL))) { - status = SWITCH_STATUS_SUCCESS; + status = SWITCH_STATUS_SUCCESS; if ((x_lists = switch_xml_child(cfg, "modem-settings"))) { for (x_list = switch_xml_child(x_lists, "param"); x_list; x_list = x_list->next) { const char *name = switch_xml_attr(x_list, "name"); const char *value = switch_xml_attr(x_list, "value"); - + if (zstr(name)) { continue; } @@ -355,28 +523,28 @@ switch_status_t load_configuration(switch_bool_t reload) continue; } - - if (!reload && !strcmp(name, "total-modems")) { - int tmp = atoi(value); - if (tmp > -1 && tmp < MAX_MODEMS) { - spandsp_globals.modem_count = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%d] for total-modems\n", tmp); - } + if (!reload && !strcmp(name, "total-modems")) { + int tmp = atoi(value); + + if (tmp > -1 && tmp < MAX_MODEMS) { + spandsp_globals.modem_count = tmp; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%d] for total-modems\n", tmp); + } } else if (!strcmp(name, "dialplan")) { - spandsp_globals.modem_dialplan = switch_core_strdup(spandsp_globals.config_pool, value); + spandsp_globals.modem_dialplan = switch_core_strdup(spandsp_globals.config_pool, value); } else if (!strcmp(name, "context")) { - spandsp_globals.modem_context = switch_core_strdup(spandsp_globals.config_pool, value); + spandsp_globals.modem_context = switch_core_strdup(spandsp_globals.config_pool, value); } else if (!strcmp(name, "verbose")) { - if (switch_true(value)) { - spandsp_globals.modem_verbose = 1; - } else { - spandsp_globals.modem_verbose = 0; - } - } - } - } + if (switch_true(value)) { + spandsp_globals.modem_verbose = 1; + } else { + spandsp_globals.modem_verbose = 0; + } + } + } + } if ((x_lists = switch_xml_child(cfg, "fax-settings")) || (x_lists = switch_xml_child(cfg, "settings"))) { for (x_list = switch_xml_child(x_lists, "param"); x_list; x_list = x_list->next) { @@ -409,19 +577,19 @@ switch_status_t load_configuration(switch_bool_t reload) } else if (!strcmp(name, "enable-t38")) { if (switch_true(value)) { spandsp_globals.enable_t38= 1; - } else { + } else { spandsp_globals.enable_t38 = 0; - } + } } else if (!strcmp(name, "enable-t38-request")) { if (switch_true(value)) { spandsp_globals.enable_t38_request = 1; - } else { + } else { spandsp_globals.enable_t38_request = 0; - } + } } else if (!strcmp(name, "ident")) { - spandsp_globals.ident = switch_core_strdup(spandsp_globals.config_pool, value); + spandsp_globals.ident = switch_core_strdup(spandsp_globals.config_pool, value); } else if (!strcmp(name, "header")) { - spandsp_globals.header = switch_core_strdup(spandsp_globals.config_pool, value); + spandsp_globals.header = switch_core_strdup(spandsp_globals.config_pool, value); } else if (!strcmp(name, "spool-dir")) { spandsp_globals.spool = switch_core_strdup(spandsp_globals.config_pool, value); } else if (!strcmp(name, "file-prefix")) { @@ -433,91 +601,101 @@ switch_status_t load_configuration(switch_bool_t reload) } } - /* Configure call progress detector */ - if ((callprogress = switch_xml_child(cfg, "descriptors"))) { - for (xdescriptor = switch_xml_child(callprogress, "descriptor"); xdescriptor; xdescriptor = switch_xml_next(xdescriptor)) { - const char *name = switch_xml_attr(xdescriptor, "name"); - const char *tone_name = NULL; - switch_xml_t tone = NULL, element = NULL; - tone_descriptor_t *descriptor = NULL; + /* Configure call progress detector */ + if ((callprogress = switch_xml_child(cfg, "descriptors"))) { + /* check if debugging is enabled */ + const char *debug = switch_xml_attr(callprogress, "debug-level"); + if (!zstr(debug) && switch_is_number(debug)) { + int debug_val = atoi(debug); + if (debug_val > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting tone detector debug-level to : %d\n", debug_val); + spandsp_globals.tonedebug = debug_val; + } + } - /* create descriptor */ - if (zstr(name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing name\n"); - switch_goto_status(SWITCH_STATUS_FALSE, done); - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding tone_descriptor: %s\n", name); - if (tone_descriptor_create(&descriptor, name, spandsp_globals.config_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to allocate tone_descriptor: %s\n", name); - switch_goto_status(SWITCH_STATUS_FALSE, done); - } - switch_core_hash_insert(spandsp_globals.tones, name, descriptor); + for (xdescriptor = switch_xml_child(callprogress, "descriptor"); xdescriptor; xdescriptor = switch_xml_next(xdescriptor)) { + const char *name = switch_xml_attr(xdescriptor, "name"); + const char *tone_name = NULL; + switch_xml_t tone = NULL, element = NULL; + tone_descriptor_t *descriptor = NULL; + + /* create descriptor */ + if (zstr(name)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing name\n"); + switch_goto_status(SWITCH_STATUS_FALSE, done); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Adding tone_descriptor: %s\n", name); + if (tone_descriptor_create(&descriptor, name, spandsp_globals.config_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to allocate tone_descriptor: %s\n", name); + switch_goto_status(SWITCH_STATUS_FALSE, done); + } + switch_core_hash_insert(spandsp_globals.tones, name, descriptor); + + /* add tones to descriptor */ + for (tone = switch_xml_child(xdescriptor, "tone"); tone; tone = switch_xml_next(tone)) { + int id = 0; + tone_name = switch_xml_attr(tone, "name"); + if (zstr(tone_name)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing name for %s\n", name); + switch_goto_status(SWITCH_STATUS_FALSE, done); + } + id = tone_descriptor_add_tone(descriptor, tone_name); + if (id == -1) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "Unable to add tone_descriptor: %s, tone: %s. (too many tones)\n", name, tone_name); + switch_goto_status(SWITCH_STATUS_FALSE, done); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, + "Adding tone_descriptor: %s, tone: %s(%d)\n", name, tone_name, id); + /* add elements to tone */ + for (element = switch_xml_child(tone, "element"); element; element = switch_xml_next(element)) { + const char *freq1_attr = switch_xml_attr(element, "freq1"); + const char *freq2_attr = switch_xml_attr(element, "freq2"); + const char *min_attr = switch_xml_attr(element, "min"); + const char *max_attr = switch_xml_attr(element, "max"); + int freq1, freq2, min, max; + if (zstr(freq1_attr)) { + freq1 = 0; + } else { + freq1 = atoi(freq1_attr); + } + if (zstr(freq2_attr)) { + freq2 = 0; + } else { + freq2 = atoi(freq2_attr); + } + if (zstr(min_attr)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "Missing min in of %s %s(%d)\n", name, tone_name, id); + switch_goto_status(SWITCH_STATUS_FALSE, done); + } + min = atoi(min_attr); + if (zstr(max_attr)) { + max = 0; + } else { + max = atoi(max_attr); + } + /* check params */ + if ((freq1 < 0 || freq2 < 0 || min < 0 || max < 0) || (freq1 == 0 && min == 0 && max == 0)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid element param.\n"); + switch_goto_status(SWITCH_STATUS_FALSE, done); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, + "Adding tone_descriptor: %s, tone: %s(%d), element (%d, %d, %d, %d)\n", name, tone_name, id, freq1, freq2, min, max); + tone_descriptor_add_tone_element(descriptor, id, freq1, freq2, min, max); + } + } + } + } + + done: - /* add tones to descriptor */ - for (tone = switch_xml_child(xdescriptor, "tone"); tone; tone = switch_xml_next(tone)) { - int id = 0; - tone_name = switch_xml_attr(tone, "name"); - if (zstr(tone_name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing name for %s\n", name); - switch_goto_status(SWITCH_STATUS_FALSE, done); - } - id = tone_descriptor_add_tone(descriptor, tone_name); - if (id == -1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Unable to add tone_descriptor: %s, tone: %s. (too many tones)\n", name, tone_name); - switch_goto_status(SWITCH_STATUS_FALSE, done); - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Adding tone_descriptor: %s, tone: %s(%d)\n", name, tone_name, id); - /* add elements to tone */ - for (element = switch_xml_child(tone, "element"); element; element = switch_xml_next(element)) { - const char *freq1_attr = switch_xml_attr(element, "freq1"); - const char *freq2_attr = switch_xml_attr(element, "freq2"); - const char *min_attr = switch_xml_attr(element, "min"); - const char *max_attr = switch_xml_attr(element, "max"); - int freq1, freq2, min, max; - if (zstr(freq1_attr)) { - freq1 = 0; - } else { - freq1 = atoi(freq1_attr); - } - if (zstr(freq2_attr)) { - freq2 = 0; - } else { - freq2 = atoi(freq2_attr); - } - if (zstr(min_attr)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Missing min in of %s %s(%d)\n", name, tone_name, id); - switch_goto_status(SWITCH_STATUS_FALSE, done); - } - min = atoi(min_attr); - if (zstr(max_attr)) { - max = 0; - } else { - max = atoi(max_attr); - } - /* check params */ - if ((freq1 < 0 || freq2 < 0 || min < 0 || max < 0) || (freq1 == 0 && min == 0 && max == 0)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid element param.\n"); - switch_goto_status(SWITCH_STATUS_FALSE, done); - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Adding tone_descriptor: %s, tone: %s(%d), element (%d, %d, %d, %d)\n", name, tone_name, id, freq1, freq2, min, max); - tone_descriptor_add_tone_element(descriptor, id, freq1, freq2, min, max); - } - } - } - } - - done: - switch_xml_free(xml); } - switch_mutex_unlock(spandsp_globals.mutex); + switch_mutex_unlock(spandsp_globals.mutex); - return status; + return status; } @@ -533,7 +711,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) switch_mutex_init(&spandsp_globals.mutex, SWITCH_MUTEX_NESTED, pool); SWITCH_ADD_APP(app_interface, "t38_gateway", "Convert to T38 Gateway if tones are heard", "Convert to T38 Gateway if tones are heard", - t38_gateway_function, "", SAF_MEDIA_TAP); + t38_gateway_function, "", SAF_MEDIA_TAP); SWITCH_ADD_APP(app_interface, "rxfax", "FAX Receive Application", "FAX Receive Application", spanfax_rx_function, SPANFAX_RX_USAGE, SAF_SUPPORT_NOMEDIA); @@ -543,32 +721,57 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) 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); + + SWITCH_ADD_APP(app_interface, "spandsp_stop_inject_tdd", "stop sending tdd", "", stop_tdd_encode_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "spandsp_inject_tdd", "Send TDD data", "Send TDD data", tdd_encode_function, "", SAF_MEDIA_TAP); + + SWITCH_ADD_APP(app_interface, "spandsp_stop_detect_tdd", "stop sending tdd", "", stop_tdd_decode_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "spandsp_detect_tdd", "Detect TDD data", "Detect TDD data", tdd_decode_function, "", SAF_MEDIA_TAP); + + + SWITCH_ADD_APP(app_interface, "spandsp_send_tdd", "Send TDD data", "Send TDD data", tdd_send_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "spandsp_start_fax_detect", "start fax detect", "start fax detect", spandsp_fax_detect_session_function, "[ ][ ][ ]", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_stop_fax_detect", "stop fax detect", "stop fax detect", spandsp_stop_fax_detect_session_function, "", SAF_NONE); - - load_configuration(0); + + load_configuration(0); mod_spandsp_fax_load(pool); - mod_spandsp_codecs_load(module_interface, pool); + mod_spandsp_codecs_load(module_interface, pool); + - if (mod_spandsp_dsp_load(module_interface, pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load or process spandsp.conf, not adding tone_detect applications\n"); - } else { - SWITCH_ADD_APP(app_interface, "start_tone_detect", "Start background tone detection with cadence", "", start_tone_detect_app, "[name]", SAF_NONE); - SWITCH_ADD_APP(app_interface, "stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE); - SWITCH_ADD_API(api_interface, "start_tone_detect", "Start background tone detection with cadence", start_tone_detect_api, "[name]"); - SWITCH_ADD_API(api_interface, "stop_tone_detect", "Stop background tone detection with cadence", stop_tone_detect_api, ""); + } else { + SWITCH_ADD_APP(app_interface, "start_tone_detect", "Start background tone detection with cadence", "", start_tone_detect_app, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE); + SWITCH_ADD_API(api_interface, "start_tone_detect", "Start background tone detection with cadence", start_tone_detect_api, " "); + SWITCH_ADD_API(api_interface, "stop_tone_detect", "Stop background tone detection with cadence", stop_tone_detect_api, ""); } - if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) { + + SWITCH_ADD_API(api_interface, "start_tdd_detect", "Start background tdd detection", start_tdd_detect_api, ""); + SWITCH_ADD_API(api_interface, "stop_tdd_detect", "Stop background tdd detection", stop_tdd_detect_api, ""); + + SWITCH_ADD_API(api_interface, "uuid_send_tdd", "send tdd data to a uuid", start_send_tdd_api, " "); + + switch_console_set_complete("add uuid_send_tdd ::console::list_uuid"); + + + + if ((switch_event_bind(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our reloadxml handler!\n"); /* Not such severe to prevent loading */ } + if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_TDD_SEND_MESSAGE, tdd_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); + } + + modem_global_init(module_interface, pool); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_spandsp loaded, using spandsp library version [%s]\n", SPANDSP_RELEASE_DATETIME_STRING); @@ -578,19 +781,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown) { - switch_event_unbind(&NODE); + switch_event_unbind_callback(event_handler); + switch_event_unbind_callback(tdd_event_handler); + mod_spandsp_fax_shutdown(); mod_spandsp_dsp_shutdown(); modem_global_shutdown(); - if (spandsp_globals.tones) { - switch_core_hash_destroy(&spandsp_globals.tones); - } + if (spandsp_globals.tones) { + switch_core_hash_destroy(&spandsp_globals.tones); + } - if (spandsp_globals.config_pool) { - switch_core_destroy_memory_pool(&spandsp_globals.config_pool); - } + if (spandsp_globals.config_pool) { + switch_core_destroy_memory_pool(&spandsp_globals.config_pool); + } return SWITCH_STATUS_UNLOAD; } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index 3ba14bcd14..ce9618f5e0 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -42,6 +42,9 @@ typedef HANDLE zap_socket_t; typedef int zap_socket_t; #endif +#define MY_EVENT_TDD_SEND_MESSAGE "TDD::SEND_MESSAGE" +#define MY_EVENT_TDD_RECV_MESSAGE "TDD::RECV_MESSAGE" + #define MAX_MODEMS 1024 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES #include @@ -57,9 +60,9 @@ struct spandsp_globals { short int use_ecm; short int verbose; short int disable_v17; - short int enable_t38; - short int enable_t38_request; - short int enable_t38_insist; + short int enable_t38; + short int enable_t38_request; + short int enable_t38_insist; char *ident; char *header; char *timezone; @@ -81,7 +84,7 @@ extern struct spandsp_globals spandsp_globals; typedef enum { FUNCTION_TX, FUNCTION_RX, - FUNCTION_GW + FUNCTION_GW } mod_spandsp_fax_application_mode_t; /****************************************************************************** @@ -104,7 +107,7 @@ struct tone_descriptor { /** The mapping of tone id to key */ char tone_keys[MAX_TONES][STRLEN]; - int idx; + int idx; }; typedef struct tone_descriptor tone_descriptor_t; @@ -140,3 +143,22 @@ switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session); void spanfax_log_message(void *user_data, int level, const char *msg); switch_status_t load_configuration(switch_bool_t reload); void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on); + +switch_status_t spandsp_stop_tdd_encode_session(switch_core_session_t *session); +switch_status_t spandsp_tdd_encode_session(switch_core_session_t *session, const char *text); + + +switch_status_t spandsp_stop_tdd_decode_session(switch_core_session_t *session); +switch_status_t spandsp_tdd_decode_session(switch_core_session_t *session); +switch_status_t spandsp_tdd_send_session(switch_core_session_t *session, const char *text); + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index 144d02ef8d..43b739ff39 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -1,4 +1,4 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * Copyright (C) 2005-2012, Anthony Minessale II * @@ -28,13 +28,324 @@ * Anthony Minessale II * Steve Underwood * Antonio Gallo - * Christopher M. Rienzo + * Christopher M. Rienzo * mod_spandsp_dsp.c -- dsp applications provided by SpanDSP * */ #include "mod_spandsp.h" +#define TDD_LEAD 10 + +typedef struct { + switch_core_session_t *session; + v18_state_t *tdd_state; + int head_lead; + int tail_lead; +} switch_tdd_t; + +static switch_bool_t tdd_encode_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) +{ + switch_tdd_t *pvt = (switch_tdd_t *) user_data; + switch_frame_t *frame = NULL; + switch_bool_t r = SWITCH_TRUE; + + switch (type) { + case SWITCH_ABC_TYPE_INIT: { + break; + } + case SWITCH_ABC_TYPE_CLOSE: + if (pvt->tdd_state) { + v18_free(pvt->tdd_state); + } + break; + case SWITCH_ABC_TYPE_WRITE_REPLACE: + if ((frame = switch_core_media_bug_get_write_replace_frame(bug))) { + int len; + + if (pvt->tail_lead) { + if (!--pvt->tail_lead) { + r = SWITCH_FALSE; + } + memset(frame->data, 0, frame->datalen); + + } else if (pvt->head_lead) { + pvt->head_lead--; + memset(frame->data, 0, frame->datalen); + } else { + len = v18_tx(pvt->tdd_state, frame->data, frame->samples); + + if (!len) { + pvt->tail_lead = TDD_LEAD; + } + } + + switch_core_media_bug_set_write_replace_frame(bug, frame); + } + break; + case SWITCH_ABC_TYPE_WRITE: + default: + break; + } + + return r; +} + +switch_status_t spandsp_stop_tdd_encode_session(switch_core_session_t *session) +{ + switch_media_bug_t *bug; + switch_channel_t *channel = switch_core_session_get_channel(session); + + if ((bug = switch_channel_get_private(channel, "tdd_encode"))) { + switch_channel_set_private(channel, "tdd_encode", NULL); + switch_core_media_bug_remove(session, &bug); + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + +static void put_text_msg(void *user_data, const uint8_t *msg, int len) +{ + switch_tdd_t *pvt = (switch_tdd_t *) user_data; + switch_event_t *event, *clone; + switch_channel_t *channel = switch_core_session_get_channel(pvt->session); + switch_core_session_t *other_session; + + + switch_channel_add_variable_var_check(channel, "tdd_messages", (char *)msg, SWITCH_FALSE, SWITCH_STACK_PUSH); + + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_TDD_RECV_MESSAGE) == SWITCH_STATUS_SUCCESS) { + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", "mod_spandsp"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "tdd"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "TDD MESSAGE"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "TDD-Data", (char *)msg); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(pvt->session)); + switch_event_add_body(event, "%s\n\n", (char *)msg); + + if (switch_core_session_get_partner(pvt->session, &other_session) == SWITCH_STATUS_SUCCESS) { + + if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) { + switch_core_session_receive_event(other_session, &clone); + } + + if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) { + switch_core_session_queue_event(other_session, &clone); + } + + switch_core_session_rwunlock(other_session); + } + + switch_event_fire(&event); + + + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s got TDD Message [%s]\n", switch_channel_get_name(channel), (char *)msg); + +} + +static int get_v18_mode(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + const char *var; + int r = V18_MODE_5BIT_45; + + if ((var = switch_channel_get_variable(channel, "v18_mode"))) { + if (!strcasecmp(var, "5BIT_45") || !strcasecmp(var, "baudot")) { + r = V18_MODE_5BIT_45; + } else if (!strcasecmp(var, "5BIT_50")) { + r = V18_MODE_5BIT_50; + } else if (!strcasecmp(var, "DTMF")) { + r = V18_MODE_DTMF; + } else if (!strcasecmp(var, "EDT")) { + r = V18_MODE_EDT; + } else if (!strcasecmp(var, "BELL103") || !strcasecmp(var, "ascii")) { + r = V18_MODE_BELL103; + } else if (!strcasecmp(var, "V23VIDEOTEX")) { + r = V18_MODE_V23VIDEOTEX; + } else if (!strcasecmp(var, "V21TEXTPHONE")) { + r = V18_MODE_V21TEXTPHONE; + } else if (!strcasecmp(var, "V18TEXTPHONE")) { + r = V18_MODE_V18TEXTPHONE; + } + } + + return r; +} + + +switch_status_t spandsp_tdd_send_session(switch_core_session_t *session, const char *text) +{ + v18_state_t *tdd_state; + switch_frame_t *read_frame, write_frame = { 0 }; + uint8_t write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE]; + switch_codec_implementation_t read_impl = { 0 }; + switch_codec_t write_codec = { 0 }; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_status_t status; + + switch_core_session_get_read_impl(session, &read_impl); + + if (switch_core_codec_init(&write_codec, + "L16", + NULL, + read_impl.actual_samples_per_second, + read_impl.microseconds_per_packet / 1000, + read_impl.number_of_channels, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { + write_frame.data = write_buf; + write_frame.buflen = sizeof(write_buf); + write_frame.datalen = read_impl.decoded_bytes_per_packet; + write_frame.samples = write_frame.datalen / 2; + write_frame.codec = &write_codec; + switch_core_session_set_read_codec(session, &write_codec); + } else { + return SWITCH_STATUS_FALSE; + } + + tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), put_text_msg, NULL); + + + v18_put(tdd_state, text, -1); + + while(switch_channel_ready(channel)) { + status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); + + if (!SWITCH_READ_ACCEPTABLE(status)) { + break; + } + + + if (!v18_tx(tdd_state, (void *)write_buf, write_frame.samples)) { + break; + } + + if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { + break; + } + + } + + switch_core_codec_destroy(&write_codec); + switch_core_session_set_read_codec(session, NULL); + + v18_free(tdd_state); + + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t spandsp_tdd_encode_session(switch_core_session_t *session, const char *text) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_media_bug_t *bug; + switch_status_t status; + switch_tdd_t *pvt; + //switch_codec_implementation_t read_impl = { 0 }; + + //switch_core_session_get_read_impl(session, &read_impl); + + if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) { + return SWITCH_STATUS_MEMERR; + } + + pvt->session = session; + pvt->tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), put_text_msg, NULL); + pvt->head_lead = TDD_LEAD; + + v18_put(pvt->tdd_state, text, -1); + + if ((status = switch_core_media_bug_add(session, "spandsp_tdd_encode", NULL, + tdd_encode_callback, pvt, 0, SMBF_WRITE_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) { + v18_free(pvt->tdd_state); + return status; + } + + switch_channel_set_private(channel, "tdd_encode", bug); + + return SWITCH_STATUS_SUCCESS; +} + + + +///XXX +static switch_bool_t tdd_decode_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) +{ + switch_tdd_t *pvt = (switch_tdd_t *) user_data; + switch_frame_t *frame = NULL; + switch_bool_t r = SWITCH_TRUE; + + switch (type) { + case SWITCH_ABC_TYPE_INIT: { + break; + } + case SWITCH_ABC_TYPE_CLOSE: + if (pvt->tdd_state) { + v18_free(pvt->tdd_state); + } + break; + case SWITCH_ABC_TYPE_READ_REPLACE: + if ((frame = switch_core_media_bug_get_read_replace_frame(bug))) { + + v18_rx(pvt->tdd_state, frame->data, frame->samples); + + switch_core_media_bug_set_read_replace_frame(bug, frame); + } + break; + case SWITCH_ABC_TYPE_WRITE: + default: + break; + } + + return r; +} + +switch_status_t spandsp_stop_tdd_decode_session(switch_core_session_t *session) +{ + switch_media_bug_t *bug; + switch_channel_t *channel = switch_core_session_get_channel(session); + + if ((bug = switch_channel_get_private(channel, "tdd_decode"))) { + switch_channel_set_private(channel, "tdd_decode", NULL); + switch_core_media_bug_remove(session, &bug); + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + +switch_status_t spandsp_tdd_decode_session(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_media_bug_t *bug; + switch_status_t status; + switch_tdd_t *pvt; + //switch_codec_implementation_t read_impl = { 0 }; + + //switch_core_session_get_read_impl(session, &read_impl); + + if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) { + return SWITCH_STATUS_MEMERR; + } + + pvt->session = session; + pvt->tdd_state = v18_init(NULL, FALSE, get_v18_mode(session), put_text_msg, pvt); + + if ((status = switch_core_media_bug_add(session, "spandsp_tdd_decode", NULL, + tdd_decode_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) { + v18_free(pvt->tdd_state); + return status; + } + + switch_channel_set_private(channel, "tdd_decode", bug); + + return SWITCH_STATUS_SUCCESS; +} + +///XXX + typedef struct { switch_core_session_t *session; dtmf_rx_state_t *dtmf_detect; @@ -194,7 +505,7 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session) } if ((status = switch_core_media_bug_add(session, "spandsp_dtmf_detect", NULL, - inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) { + inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) { return status; } @@ -227,10 +538,13 @@ struct tone_detector { /** The debug level */ int debug; + + /** The session that owns this detector */ + switch_core_session_t *session; }; typedef struct tone_detector tone_detector_t; -static switch_status_t tone_detector_create(tone_detector_t **detector, tone_descriptor_t *descriptor, switch_memory_pool_t *memory_pool); +static switch_status_t tone_detector_create(switch_core_session_t *session, tone_detector_t **detector, tone_descriptor_t *descriptor); static switch_bool_t tone_detector_process_buffer(tone_detector_t *detector, void *data, unsigned int len, const char **key); static void tone_detector_destroy(tone_detector_t *detector); @@ -273,9 +587,9 @@ int tone_descriptor_add_tone(tone_descriptor_t *descriptor, const char *key) } switch_set_string(descriptor->tone_keys[id], key); - if (id > descriptor->idx) { - descriptor->idx = id; - } + if (id > descriptor->idx) { + descriptor->idx = id; + } return id; } @@ -311,7 +625,7 @@ static void tone_report_callback(void *user_data, int code, int level, int delay { tone_detector_t *detector = (tone_detector_t *)user_data; if (detector->debug > 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Tone report: code = %d, level = %d, delay = %d\n", code, level, delay); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(detector->session), SWITCH_LOG_DEBUG, "Tone report: code = %d, level = %d, delay = %d\n", code, level, delay); } detector->detected_tone = code; } @@ -328,28 +642,30 @@ static void tone_segment_callback(void *user_data, int f1, int f2, int duration) { tone_detector_t *detector = (tone_detector_t *)user_data; if (detector->debug > 1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Tone segment: f1 = %d, f2 = %d, duration = %d\n", f1, f2, duration); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(detector->session), SWITCH_LOG_DEBUG, "Tone segment: f1 = %d, f2 = %d, duration = %d\n", f1, f2, duration); } } /** * Allocate the tone detector * + * @param session the session that owns the detector * @param detector the detector to create * @param descriptor the descriptor to use * @param memory_pool the pool to use * @return SWITCH_STATUS_SUCCESS if successful */ -static switch_status_t tone_detector_create(tone_detector_t **detector, tone_descriptor_t *descriptor, switch_memory_pool_t *memory_pool) +static switch_status_t tone_detector_create(switch_core_session_t *session, tone_detector_t **detector, tone_descriptor_t *descriptor) { tone_detector_t *ldetector = NULL; - ldetector = switch_core_alloc(memory_pool, sizeof(tone_detector_t)); + ldetector = switch_core_session_alloc(session, sizeof(tone_detector_t)); if (!ldetector) { return SWITCH_STATUS_FALSE; } memset(ldetector, 0, sizeof(tone_detector_t)); ldetector->descriptor = descriptor; ldetector->debug = spandsp_globals.tonedebug; + ldetector->session = session; *detector = ldetector; return SWITCH_STATUS_SUCCESS; } @@ -423,15 +739,15 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons /* find the tone descriptor with the matching name and create the detector */ descriptor = switch_core_hash_find(spandsp_globals.tones, name); if (!descriptor) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) no tone descriptor defined with name '%s'. Update configuration. \n", switch_channel_get_name(channel), name); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "no tone descriptor defined with name '%s'. Update configuration. \n", name); return SWITCH_STATUS_FALSE; } - tone_detector_create(&detector, descriptor, switch_core_session_get_pool(session)); + tone_detector_create(session, &detector, descriptor); /* start listening for tones */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Starting tone detection for '%s'\n", switch_channel_get_name(channel), name); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Starting tone detection for '%s'\n", name); switch_core_media_bug_add(session, "spandsp_tone_detect", NULL, - callprogress_detector_process_buffer, detector, 0 /* stop time */, SMBF_READ_STREAM, &bug); + callprogress_detector_process_buffer, detector, 0 /* stop time */, SMBF_READ_REPLACE, &bug); if (!bug) { return SWITCH_STATUS_FALSE; } @@ -450,35 +766,30 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons */ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) { - uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_frame_t frame = { 0 }; tone_detector_t *detector = (tone_detector_t *)user_data; - switch_core_session_t *session = switch_core_media_bug_get_session(bug); - switch_channel_t *channel = switch_core_session_get_channel(session); - - frame.data = data; - frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; + switch_core_session_t *session = detector->session; switch(type) { case SWITCH_ABC_TYPE_INIT: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) initializing tone detector\n", switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "initializing tone detector\n"); tone_detector_init(detector); break; - case SWITCH_ABC_TYPE_READ: + case SWITCH_ABC_TYPE_READ_REPLACE: { + switch_frame_t *frame; const char *detected_tone = NULL; if (!detector->spandsp_detector) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) detector is destroyed\n", switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "detector is destroyed\n"); return SWITCH_FALSE; } - if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) error reading frame\n", switch_channel_get_name(channel)); + if (!(frame = switch_core_media_bug_get_read_replace_frame(bug))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "error reading frame\n"); return SWITCH_FALSE; } - tone_detector_process_buffer(detector, frame.data, frame.samples, &detected_tone); + tone_detector_process_buffer(detector, frame->data, frame->samples, &detected_tone); if (detected_tone) { switch_event_t *event = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) DETECTED TONE: %s\n", switch_channel_get_name(channel), detected_tone); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "DETECTED TONE: %s\n", detected_tone); if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detected-Tone", detected_tone); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session)); @@ -487,20 +798,14 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu } break; } - case SWITCH_ABC_TYPE_WRITE: - break; - case SWITCH_ABC_TYPE_WRITE_REPLACE: - break; - case SWITCH_ABC_TYPE_READ_REPLACE: - break; - case SWITCH_ABC_TYPE_READ_PING: - break; case SWITCH_ABC_TYPE_CLOSE: if (detector->spandsp_detector) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) destroying tone detector\n", switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "destroying tone detector\n"); tone_detector_destroy(detector); } break; + default: + break; } return SWITCH_TRUE; } @@ -535,7 +840,7 @@ switch_status_t mod_spandsp_dsp_load(switch_loadable_module_interface_t **module */ void mod_spandsp_dsp_shutdown(void) { - return; + return; } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 975aca1fc8..c15f9afe67 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -59,14 +59,14 @@ typedef enum { T38_MODE, AUDIO_MODE, - T38_GATEWAY_MODE + T38_GATEWAY_MODE } transport_mode_t; typedef enum { - T38_MODE_UNKNOWN = 0, - T38_MODE_NEGOTIATED = 1, - T38_MODE_REQUESTED = 2, - T38_MODE_REFUSED = -1, + T38_MODE_UNKNOWN = 0, + T38_MODE_NEGOTIATED = 1, + T38_MODE_REQUESTED = 2, + T38_MODE_REFUSED = -1, } t38_mode_t; @@ -78,9 +78,9 @@ struct pvt_s { fax_state_t *fax_state; t38_terminal_state_t *t38_state; t38_gateway_state_t *t38_gateway_state; - t38_core_state_t *t38_core; + t38_core_state_t *t38_core; - udptl_state_t *udptl_state; + udptl_state_t *udptl_state; char *filename; char *ident; @@ -96,10 +96,10 @@ struct pvt_s { int tx_page_end; int done; - - t38_mode_t t38_mode; - struct pvt_s *next; + t38_mode_t t38_mode; + + struct pvt_s *next; }; typedef struct pvt_s pvt_t; @@ -107,10 +107,10 @@ typedef struct pvt_s pvt_t; static void launch_timer_thread(void); static struct { - pvt_t *head; - switch_mutex_t *mutex; - switch_thread_t *thread; - int thread_running; + pvt_t *head; + switch_mutex_t *mutex; + switch_thread_t *thread; + int thread_running; } t38_state_list; @@ -118,7 +118,7 @@ static struct { static void wake_thread(int force) { if (force) { - switch_thread_cond_signal(spandsp_globals.cond); + switch_thread_cond_signal(spandsp_globals.cond); return; } @@ -130,111 +130,111 @@ static void wake_thread(int force) static int add_pvt(pvt_t *pvt) { - int r = 0; - - if (t38_state_list.thread_running) { - switch_mutex_lock(t38_state_list.mutex); - pvt->next = t38_state_list.head; - t38_state_list.head = pvt; - switch_mutex_unlock(t38_state_list.mutex); - r = 1; - wake_thread(0); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error launching thread\n"); - } + int r = 0; - return r; + if (t38_state_list.thread_running) { + switch_mutex_lock(t38_state_list.mutex); + pvt->next = t38_state_list.head; + t38_state_list.head = pvt; + switch_mutex_unlock(t38_state_list.mutex); + r = 1; + wake_thread(0); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error launching thread\n"); + } + + return r; } static int del_pvt(pvt_t *del_pvt) { - pvt_t *p, *l = NULL; - int r = 0; + pvt_t *p, *l = NULL; + int r = 0; - switch_mutex_lock(t38_state_list.mutex); + switch_mutex_lock(t38_state_list.mutex); - for (p = t38_state_list.head; p; p = p->next) { - if (p == del_pvt) { - if (l) { - l->next = p->next; - } else { - t38_state_list.head = p->next; - } - p->next = NULL; - r = 1; - break; - } + for (p = t38_state_list.head; p; p = p->next) { + if (p == del_pvt) { + if (l) { + l->next = p->next; + } else { + t38_state_list.head = p->next; + } + p->next = NULL; + r = 1; + break; + } + + l = p; + } - l = p; - } + switch_mutex_unlock(t38_state_list.mutex); - switch_mutex_unlock(t38_state_list.mutex); + wake_thread(0); - wake_thread(0); - - return r; + return r; } static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void *obj) { - switch_timer_t timer = { 0 }; - pvt_t *pvt; - int samples = 160; - int ms = 20; + switch_timer_t timer = { 0 }; + pvt_t *pvt; + int samples = 160; + int ms = 20; - switch_mutex_lock(t38_state_list.mutex); - t38_state_list.thread_running = 1; - switch_mutex_unlock(t38_state_list.mutex); + switch_mutex_lock(t38_state_list.mutex); + t38_state_list.thread_running = 1; + switch_mutex_unlock(t38_state_list.mutex); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread started.\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread started.\n"); if (switch_core_timer_init(&timer, "soft", ms, samples, NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "timer init failed.\n"); - goto end; - } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "timer init failed.\n"); + goto end; + } - switch_mutex_lock(spandsp_globals.cond_mutex); + switch_mutex_lock(spandsp_globals.cond_mutex); - while(t38_state_list.thread_running) { + while(t38_state_list.thread_running) { - switch_mutex_lock(t38_state_list.mutex); + switch_mutex_lock(t38_state_list.mutex); - if (!t38_state_list.head) { - switch_mutex_unlock(t38_state_list.mutex); + if (!t38_state_list.head) { + switch_mutex_unlock(t38_state_list.mutex); switch_thread_cond_wait(spandsp_globals.cond, spandsp_globals.cond_mutex); - switch_core_timer_sync(&timer); - continue; - } + switch_core_timer_sync(&timer); + continue; + } - for (pvt = t38_state_list.head; pvt; pvt = pvt->next) { - if (pvt->udptl_state && pvt->session && switch_channel_ready(switch_core_session_get_channel(pvt->session))) { - t38_terminal_send_timeout(pvt->t38_state, samples); - } - } + for (pvt = t38_state_list.head; pvt; pvt = pvt->next) { + if (pvt->udptl_state && pvt->session && switch_channel_ready(switch_core_session_get_channel(pvt->session))) { + t38_terminal_send_timeout(pvt->t38_state, samples); + } + } - switch_mutex_unlock(t38_state_list.mutex); + switch_mutex_unlock(t38_state_list.mutex); - switch_core_timer_next(&timer); - } + switch_core_timer_next(&timer); + } + + switch_mutex_unlock(spandsp_globals.cond_mutex); - switch_mutex_unlock(spandsp_globals.cond_mutex); - end: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread ended.\n"); - - switch_mutex_lock(t38_state_list.mutex); - t38_state_list.thread_running = 0; - switch_mutex_unlock(t38_state_list.mutex); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread ended.\n"); - if (timer.timer_interface) { - switch_core_timer_destroy(&timer); - } - - return NULL; + switch_mutex_lock(t38_state_list.mutex); + t38_state_list.thread_running = 0; + switch_mutex_unlock(t38_state_list.mutex); + + if (timer.timer_interface) { + switch_core_timer_destroy(&timer); + } + + return NULL; } static void launch_timer_thread(void) @@ -472,8 +472,8 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) char *fax_transfer_rate = NULL; char *fax_result_code = NULL; switch_event_t *event; - const char *var; - char *expanded; + const char *var; + char *expanded; pvt = (pvt_t *) user_data; switch_assert(pvt); @@ -590,80 +590,79 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) switch_event_fire(&event); } - if ((var = switch_channel_get_variable(channel, "system_on_fax_result"))) { - expanded = switch_channel_expand_variables(channel, var); - switch_system(expanded, SWITCH_FALSE); - if (expanded != var) { - free(expanded); - } - } + if ((var = switch_channel_get_variable(channel, "system_on_fax_result"))) { + expanded = switch_channel_expand_variables(channel, var); + switch_system(expanded, SWITCH_FALSE); + if (expanded != var) { + free(expanded); + } + } - switch_channel_execute_on(channel, "execute_on_fax_result"); + switch_channel_execute_on(channel, "execute_on_fax_result"); - if (result == T30_ERR_OK) { - if ((var = switch_channel_get_variable(channel, "system_on_fax_success"))) { - expanded = switch_channel_expand_variables(channel, var); - switch_system(expanded, SWITCH_FALSE); - if (expanded != var) { - free(expanded); - } - } - switch_channel_execute_on(channel, "execute_on_fax_success"); - } else { - if ((var = switch_channel_get_variable(channel, "system_on_fax_failure"))) { - expanded = switch_channel_expand_variables(channel, var); - switch_system(expanded, SWITCH_FALSE); - if (expanded != var) { - free(expanded); - } - } - switch_channel_execute_on(channel, "execute_on_fax_failure"); - } - + if (result == T30_ERR_OK) { + if ((var = switch_channel_get_variable(channel, "system_on_fax_success"))) { + expanded = switch_channel_expand_variables(channel, var); + switch_system(expanded, SWITCH_FALSE); + if (expanded != var) { + free(expanded); + } + } + switch_channel_execute_on(channel, "execute_on_fax_success"); + } else { + if ((var = switch_channel_get_variable(channel, "system_on_fax_failure"))) { + expanded = switch_channel_expand_variables(channel, var); + switch_system(expanded, SWITCH_FALSE); + if (expanded != var) { + free(expanded); + } + } + switch_channel_execute_on(channel, "execute_on_fax_failure"); + } } static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count) { - switch_frame_t out_frame = { 0 }; - switch_core_session_t *session; - pvt_t *pvt; - uint8_t pkt[LOCAL_FAX_MAX_DATAGRAM]; - int x; - int r = 0; + switch_frame_t out_frame = { 0 }; + switch_core_session_t *session; + pvt_t *pvt; + uint8_t pkt[LOCAL_FAX_MAX_DATAGRAM]; + int x; + int r = 0; - pvt = (pvt_t *) user_data; - session = pvt->session; + pvt = (pvt_t *) user_data; + session = pvt->session; - /* we need to build a real packet here and make write_frame.packet and write_frame.packetlen point to it */ - out_frame.flags = SFF_UDPTL_PACKET | SFF_PROXY_PACKET; - out_frame.packet = pkt; - if ((r = udptl_build_packet(pvt->udptl_state, pkt, buf, len)) > 0) { - out_frame.packetlen = r; - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "WRITE %d udptl bytes\n", out_frame.packetlen); + /* we need to build a real packet here and make write_frame.packet and write_frame.packetlen point to it */ + out_frame.flags = SFF_UDPTL_PACKET | SFF_PROXY_PACKET; + out_frame.packet = pkt; + if ((r = udptl_build_packet(pvt->udptl_state, pkt, buf, len)) > 0) { + out_frame.packetlen = r; + //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "WRITE %d udptl bytes\n", out_frame.packetlen); - for (x = 0; x < count; x++) { - if (switch_core_session_write_frame(session, &out_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID WRITE: %d:%d\n", out_frame.packetlen, count); - r = -1; - break; - } - } - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID PACKETLEN: %d PASSED: %d:%d\n", r, len, count); - } - - if (r < 0) { - t30_state_t *t30; + for (x = 0; x < count; x++) { + if (switch_core_session_write_frame(session, &out_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID WRITE: %d:%d\n", out_frame.packetlen, count); + r = -1; + break; + } + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID PACKETLEN: %d PASSED: %d:%d\n", r, len, count); + } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "TERMINATING T30 STATE\n"); + if (r < 0) { + t30_state_t *t30; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "TERMINATING T30 STATE\n"); + + if (pvt->t38_state && (t30 = t38_terminal_get_t30_state(pvt->t38_state))) { + t30_terminate(t30); + } + switch_yield(10000); + } - if (pvt->t38_state && (t30 = t38_terminal_get_t30_state(pvt->t38_state))) { - t30_terminate(t30); - } - switch_yield(10000); - } - - return r < 0 ? r : 0; + return r < 0 ? r : 0; } static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) @@ -675,6 +674,7 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) t38_terminal_state_t *t38; t30_state_t *t30; const char *tmp; + const char *tz; int fec_entries = DEFAULT_FEC_ENTRIES; int fec_span = DEFAULT_FEC_SPAN; @@ -686,11 +686,11 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) switch_assert(channel); if ((tmp = switch_channel_get_variable(channel, "t38_gateway_redundancy"))) { - int tmp_value; - tmp_value = atoi(tmp); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX changing redundancy from %d:%d to %d:%d\n", fec_span, fec_entries, tmp_value, tmp_value ); - fec_entries = tmp_value; - fec_span = tmp_value; + int tmp_value; + tmp_value = atoi(tmp); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX changing redundancy from %d:%d to %d:%d\n", fec_span, fec_entries, tmp_value, tmp_value ); + fec_entries = tmp_value; + fec_span = tmp_value; } switch (trans_mode) { @@ -722,131 +722,135 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) } break; case T38_MODE: - { - switch_core_session_message_t msg = { 0 }; + { + switch_core_session_message_t msg = { 0 }; - if (pvt->t38_state == NULL) { - pvt->t38_state = (t38_terminal_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_terminal_state_t)); - } - if (pvt->t38_state == NULL) { - return SWITCH_STATUS_FALSE; - } - if (pvt->udptl_state == NULL) { - pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t)); - } - if (pvt->udptl_state == NULL) { - t38_terminal_free(pvt->t38_state); - pvt->t38_state = NULL; - return SWITCH_STATUS_FALSE; - } + if (pvt->t38_state == NULL) { + pvt->t38_state = (t38_terminal_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_terminal_state_t)); + } + if (pvt->t38_state == NULL) { + return SWITCH_STATUS_FALSE; + } + if (pvt->udptl_state == NULL) { + pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t)); + } + if (pvt->udptl_state == NULL) { + t38_terminal_free(pvt->t38_state); + pvt->t38_state = NULL; + return SWITCH_STATUS_FALSE; + } - t38 = pvt->t38_state; - t30 = t38_terminal_get_t30_state(t38); + t38 = pvt->t38_state; + t30 = t38_terminal_get_t30_state(t38); - memset(t38, 0, sizeof(t38_terminal_state_t)); + memset(t38, 0, sizeof(t38_terminal_state_t)); - if (t38_terminal_init(t38, pvt->caller, t38_tx_packet_handler, pvt) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); - return SWITCH_STATUS_FALSE; - } + if (t38_terminal_init(t38, pvt->caller, t38_tx_packet_handler, pvt) == NULL) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); + return SWITCH_STATUS_FALSE; + } - pvt->t38_core = t38_terminal_get_t38_core_state(pvt->t38_state); + pvt->t38_core = t38_terminal_get_t38_core_state(pvt->t38_state); - if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, - (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); - return SWITCH_STATUS_FALSE; - } - - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; - switch_core_session_receive_message(pvt->session, &msg); - - /* add to timer thread processing */ - if (!add_pvt(pvt)) { - if (channel) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - } - } - - span_log_set_message_handler(&t38->logging, spanfax_log_message, NULL); - span_log_set_message_handler(&t30->logging, spanfax_log_message, NULL); - - if (pvt->verbose) { - span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - } - } - break; - case T38_GATEWAY_MODE: - if (pvt->t38_gateway_state == NULL) { - pvt->t38_gateway_state = (t38_gateway_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_gateway_state_t)); - } - - if (pvt->udptl_state == NULL) { - pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t)); - } - - if (t38_gateway_init(pvt->t38_gateway_state, t38_tx_packet_handler, pvt) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); - t38_gateway_free(pvt->t38_gateway_state); - pvt->t38_gateway_state = NULL; - - return SWITCH_STATUS_FALSE; - } - - pvt->t38_core = t38_gateway_get_t38_core_state(pvt->t38_gateway_state); - - if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, + if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); - t38_gateway_free(pvt->t38_gateway_state); - udptl_release(pvt->udptl_state); - pvt->udptl_state = NULL; - return SWITCH_STATUS_FALSE; - } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); + return SWITCH_STATUS_FALSE; + } - t38_gateway_set_transmit_on_idle(pvt->t38_gateway_state, TRUE); + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; + switch_core_session_receive_message(pvt->session, &msg); - if (switch_true(switch_channel_get_variable(channel, "fax_v17_disabled"))) { - t38_gateway_set_supported_modems(pvt->t38_gateway_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); - } else { - t38_gateway_set_supported_modems(pvt->t38_gateway_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); - } + /* add to timer thread processing */ + if (!add_pvt(pvt)) { + if (channel) { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + } + } - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, pvt->use_ecm); - switch_channel_set_variable(channel, "fax_ecm_requested", pvt->use_ecm ? "true" : "false"); - - if (switch_true(switch_channel_get_variable(channel, "FAX_DISABLE_ECM"))) { - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, FALSE); - } else { - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, TRUE); - } - + span_log_set_message_handler(&t38->logging, spanfax_log_message, NULL); + span_log_set_message_handler(&t30->logging, spanfax_log_message, NULL); - span_log_set_message_handler(&pvt->t38_gateway_state->logging, spanfax_log_message, NULL); - span_log_set_message_handler(&pvt->t38_core->logging, spanfax_log_message, NULL); + if (pvt->verbose) { + span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + } + } + break; + case T38_GATEWAY_MODE: + if (pvt->t38_gateway_state == NULL) { + pvt->t38_gateway_state = (t38_gateway_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_gateway_state_t)); + } - if (pvt->verbose) { - span_log_set_level(&pvt->t38_gateway_state->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&pvt->t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - } + if (pvt->udptl_state == NULL) { + pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t)); + } - t38_set_t38_version(pvt->t38_core, 0); - t38_gateway_set_ecm_capability(pvt->t38_gateway_state, 1); + if (t38_gateway_init(pvt->t38_gateway_state, t38_tx_packet_handler, pvt) == NULL) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n"); + t38_gateway_free(pvt->t38_gateway_state); + pvt->t38_gateway_state = NULL; + + return SWITCH_STATUS_FALSE; + } - return SWITCH_STATUS_SUCCESS; + pvt->t38_core = t38_gateway_get_t38_core_state(pvt->t38_gateway_state); + + if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, fec_span, fec_entries, + (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n"); + t38_gateway_free(pvt->t38_gateway_state); + udptl_release(pvt->udptl_state); + pvt->udptl_state = NULL; + return SWITCH_STATUS_FALSE; + } + + t38_gateway_set_transmit_on_idle(pvt->t38_gateway_state, TRUE); + + if (switch_true(switch_channel_get_variable(channel, "fax_v17_disabled"))) { + t38_gateway_set_supported_modems(pvt->t38_gateway_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); + } else { + t38_gateway_set_supported_modems(pvt->t38_gateway_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); + } + + t38_gateway_set_ecm_capability(pvt->t38_gateway_state, pvt->use_ecm); + switch_channel_set_variable(channel, "fax_ecm_requested", pvt->use_ecm ? "true" : "false"); + + if (switch_true(switch_channel_get_variable(channel, "FAX_DISABLE_ECM"))) { + t38_gateway_set_ecm_capability(pvt->t38_gateway_state, FALSE); + } else { + t38_gateway_set_ecm_capability(pvt->t38_gateway_state, TRUE); + } + + + span_log_set_message_handler(&pvt->t38_gateway_state->logging, spanfax_log_message, NULL); + span_log_set_message_handler(&pvt->t38_core->logging, spanfax_log_message, NULL); + + if (pvt->verbose) { + span_log_set_level(&pvt->t38_gateway_state->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(&pvt->t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + } + + t38_set_t38_version(pvt->t38_core, 0); + t38_gateway_set_ecm_capability(pvt->t38_gateway_state, 1); + + return SWITCH_STATUS_SUCCESS; default: assert(0); /* What? */ return SWITCH_STATUS_SUCCESS; } /* Switch trans mode */ - + /* All the things which are common to audio and T.38 FAX setup */ t30_set_tx_ident(t30, pvt->ident); t30_set_tx_page_header_info(t30, pvt->header); - if (pvt->timezone && pvt->timezone[0]) - t30_set_tx_page_header_tz(t30, pvt->timezone); + if (pvt->timezone && pvt->timezone[0]) { + if ((tz = switch_lookup_timezone(pvt->timezone))) + t30_set_tx_page_header_tz(t30, tz); + else + t30_set_tx_page_header_tz(t30, pvt->timezone); + } t30_set_phase_e_handler(t30, phase_e_handler, pvt); t30_set_phase_d_handler(t30, phase_d_handler, pvt); @@ -868,7 +872,7 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) } if (pvt->use_ecm) { - t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); + t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION | T30_SUPPORT_T85_COMPRESSION | T30_SUPPORT_T85_L0_COMPRESSION); t30_set_ecm_capability(t30, TRUE); switch_channel_set_variable(channel, "fax_ecm_requested", "1"); } else { @@ -891,7 +895,7 @@ static switch_status_t spanfax_destroy(pvt_t *pvt) int terminate; t30_state_t *t30; - if (!pvt) return SWITCH_STATUS_FALSE; + if (!pvt) return SWITCH_STATUS_FALSE; if (pvt->fax_state) { if (pvt->t38_state) { @@ -910,8 +914,8 @@ static switch_status_t spanfax_destroy(pvt_t *pvt) if (pvt->t38_state) { - /* remove from timer thread processing */ - del_pvt(pvt); + /* remove from timer thread processing */ + del_pvt(pvt); if (pvt->t38_state) { terminate = 1; @@ -928,135 +932,135 @@ static switch_status_t spanfax_destroy(pvt_t *pvt) t38_terminal_release(pvt->t38_state); } - if (pvt->t38_gateway_state) { - t38_gateway_release(pvt->t38_gateway_state); - } + if (pvt->t38_gateway_state) { + t38_gateway_release(pvt->t38_gateway_state); + } if (pvt->udptl_state) { udptl_release(pvt->udptl_state); - } + } return SWITCH_STATUS_SUCCESS; } static t38_mode_t configure_t38(pvt_t *pvt) { - switch_core_session_t *session = pvt->session; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options"); - int method = 2; + switch_core_session_t *session = pvt->session; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options"); + int method = 2; - if (!t38_options || !pvt || !pvt->t38_core) { - pvt->t38_mode = T38_MODE_REFUSED; - return pvt->t38_mode; - } + if (!t38_options || !pvt || !pvt->t38_core) { + pvt->t38_mode = T38_MODE_REFUSED; + return pvt->t38_mode; + } - t38_set_t38_version(pvt->t38_core, t38_options->T38FaxVersion); - t38_set_max_buffer_size(pvt->t38_core, t38_options->T38FaxMaxBuffer); - t38_set_fastest_image_data_rate(pvt->t38_core, t38_options->T38MaxBitRate); - t38_set_fill_bit_removal(pvt->t38_core, t38_options->T38FaxFillBitRemoval); - t38_set_mmr_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingMMR); - t38_set_jbig_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingJBIG); - t38_set_max_datagram_size(pvt->t38_core, t38_options->T38FaxMaxDatagram); + t38_set_t38_version(pvt->t38_core, t38_options->T38FaxVersion); + t38_set_max_buffer_size(pvt->t38_core, t38_options->T38FaxMaxBuffer); + t38_set_fastest_image_data_rate(pvt->t38_core, t38_options->T38MaxBitRate); + t38_set_fill_bit_removal(pvt->t38_core, t38_options->T38FaxFillBitRemoval); + t38_set_mmr_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingMMR); + t38_set_jbig_transcoding(pvt->t38_core, t38_options->T38FaxTranscodingJBIG); + t38_set_max_datagram_size(pvt->t38_core, t38_options->T38FaxMaxDatagram); - if (t38_options->T38FaxRateManagement) { - if (!strcasecmp(t38_options->T38FaxRateManagement, "transferredTCF")) { - method = 2; - } else { - method = 1; - } - } + if (t38_options->T38FaxRateManagement) { + if (!strcasecmp(t38_options->T38FaxRateManagement, "transferredTCF")) { + method = 2; + } else { + method = 1; + } + } - t38_set_data_rate_management_method(pvt->t38_core, method); + t38_set_data_rate_management_method(pvt->t38_core, method); - //t38_set_data_transport_protocol(pvt->t38_core, int data_transport_protocol); - //t38_set_redundancy_control(pvt->t38_core, int category, int setting); + //t38_set_data_transport_protocol(pvt->t38_core, int data_transport_protocol); + //t38_set_redundancy_control(pvt->t38_core, int category, int setting); - return pvt->t38_mode; + return pvt->t38_mode; } static t38_mode_t negotiate_t38(pvt_t *pvt) { - switch_core_session_t *session = pvt->session; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_core_session_message_t msg = { 0 }; - switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options"); - int enabled = 0, insist = 0; - const char *v; + switch_core_session_t *session = pvt->session; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_core_session_message_t msg = { 0 }; + switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options"); + int enabled = 0, insist = 0; + const char *v; - pvt->t38_mode = T38_MODE_REFUSED; + pvt->t38_mode = T38_MODE_REFUSED; - if (pvt->app_mode == FUNCTION_GW) { - enabled = 1; - } else if ((v = switch_channel_get_variable(channel, "fax_enable_t38"))) { - enabled = switch_true(v); - } else { - enabled = spandsp_globals.enable_t38; - } + if (pvt->app_mode == FUNCTION_GW) { + enabled = 1; + } else if ((v = switch_channel_get_variable(channel, "fax_enable_t38"))) { + enabled = switch_true(v); + } else { + enabled = spandsp_globals.enable_t38; + } - if (!(enabled && t38_options)) { - /* if there is no t38_options the endpoint will refuse the transition */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s NO T38 options detected.\n", switch_channel_get_name(channel)); - switch_channel_set_private(channel, "t38_options", NULL); - } else { - pvt->t38_mode = T38_MODE_NEGOTIATED; - switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); + if (!(enabled && t38_options)) { + /* if there is no t38_options the endpoint will refuse the transition */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s NO T38 options detected.\n", switch_channel_get_name(channel)); + switch_channel_set_private(channel, "t38_options", NULL); + } else { + pvt->t38_mode = T38_MODE_NEGOTIATED; + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38 SDP Origin = %s\n", t38_options->sdp_o_line); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxVersion = %d\n", t38_options->T38FaxVersion); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38MaxBitRate = %d\n", t38_options->T38MaxBitRate); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxFillBitRemoval = %d\n", t38_options->T38FaxFillBitRemoval); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxTranscodingMMR = %d\n", t38_options->T38FaxTranscodingMMR); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxTranscodingJBIG = %d\n", t38_options->T38FaxTranscodingJBIG); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxRateManagement = '%s'\n", t38_options->T38FaxRateManagement); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxBuffer = %d\n", t38_options->T38FaxMaxBuffer); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxDatagram = %d\n", t38_options->T38FaxMaxDatagram); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxUdpEC = '%s'\n", t38_options->T38FaxUdpEC); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38VendorInfo = '%s'\n", switch_str_nil(t38_options->T38VendorInfo)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ip = '%s'\n", - t38_options->remote_ip ? t38_options->remote_ip : "Not specified"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "port = %d\n", t38_options->remote_port); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38 SDP Origin = %s\n", t38_options->sdp_o_line); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxVersion = %d\n", t38_options->T38FaxVersion); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38MaxBitRate = %d\n", t38_options->T38MaxBitRate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxFillBitRemoval = %d\n", t38_options->T38FaxFillBitRemoval); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxTranscodingMMR = %d\n", t38_options->T38FaxTranscodingMMR); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxTranscodingJBIG = %d\n", t38_options->T38FaxTranscodingJBIG); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxRateManagement = '%s'\n", t38_options->T38FaxRateManagement); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxBuffer = %d\n", t38_options->T38FaxMaxBuffer); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxMaxDatagram = %d\n", t38_options->T38FaxMaxDatagram); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxUdpEC = '%s'\n", t38_options->T38FaxUdpEC); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38VendorInfo = '%s'\n", switch_str_nil(t38_options->T38VendorInfo)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ip = '%s'\n", + t38_options->remote_ip ? t38_options->remote_ip : "Not specified"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "port = %d\n", t38_options->remote_port); - /* Time to practice our negotiating skills, by editing the t38_options */ + /* Time to practice our negotiating skills, by editing the t38_options */ - if (t38_options->T38FaxVersion > 3) { - t38_options->T38FaxVersion = 3; - } - t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400; + if (t38_options->T38FaxVersion > 3) { + t38_options->T38FaxVersion = 3; + } + t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400; - /* cisco gets mad when we set this to one in a response where they set it to 0, are we allowed to hardcode this to 1 on responses? */ - /* - if (!zstr(t38_options->sdp_o_line) && !switch_stristr("cisco", t38_options->sdp_o_line)) { - t38_options->T38FaxFillBitRemoval = 1; - } - */ + /* cisco gets mad when we set this to one in a response where they set it to 0, are we allowed to hardcode this to 1 on responses? */ + /* + if (!zstr(t38_options->sdp_o_line) && !switch_stristr("cisco", t38_options->sdp_o_line)) { + t38_options->T38FaxFillBitRemoval = 1; + } + */ - t38_options->T38FaxTranscodingMMR = 0; - t38_options->T38FaxTranscodingJBIG = 0; - t38_options->T38FaxRateManagement = "transferredTCF"; - t38_options->T38FaxMaxBuffer = 2000; - t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM; - if (!zstr(t38_options->T38FaxUdpEC) && - (strcasecmp(t38_options->T38FaxUdpEC, "t38UDPRedundancy") == 0 || - strcasecmp(t38_options->T38FaxUdpEC, "t38UDPFEC") == 0)) { - t38_options->T38FaxUdpEC = "t38UDPRedundancy"; - } else { - t38_options->T38FaxUdpEC = NULL; - } - t38_options->T38VendorInfo = "0 0 0"; - } + t38_options->T38FaxTranscodingMMR = 0; + t38_options->T38FaxTranscodingJBIG = 0; + t38_options->T38FaxRateManagement = "transferredTCF"; + t38_options->T38FaxMaxBuffer = 2000; + t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM; + if (!zstr(t38_options->T38FaxUdpEC) && + (strcasecmp(t38_options->T38FaxUdpEC, "t38UDPRedundancy") == 0 || + strcasecmp(t38_options->T38FaxUdpEC, "t38UDPFEC") == 0)) { + t38_options->T38FaxUdpEC = "t38UDPRedundancy"; + } else { + t38_options->T38FaxUdpEC = NULL; + } + t38_options->T38VendorInfo = "0 0 0"; + } - if ((v = switch_channel_get_variable(channel, "fax_enable_t38_insist"))) { - insist = switch_true(v); - } else { - insist = spandsp_globals.enable_t38_insist; - } + if ((v = switch_channel_get_variable(channel, "fax_enable_t38_insist"))) { + insist = switch_true(v); + } else { + insist = spandsp_globals.enable_t38_insist; + } - /* This will send the options back in a response */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION; - msg.numeric_arg = insist; - switch_core_session_receive_message(session, &msg); + /* This will send the options back in a response */ + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION; + msg.numeric_arg = insist; + switch_core_session_receive_message(session, &msg); return pvt->t38_mode; } @@ -1065,68 +1069,74 @@ static t38_mode_t negotiate_t38(pvt_t *pvt) static t38_mode_t request_t38(pvt_t *pvt) { - switch_core_session_t *session = pvt->session; - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_core_session_message_t msg = { 0 }; - switch_t38_options_t *t38_options = NULL; - int enabled = 0, insist = 0; - const char *v; + switch_core_session_t *session = pvt->session; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_core_session_message_t msg = { 0 }; + switch_t38_options_t *t38_options = NULL; + int enabled = 0, insist = 0; + const char *v; - pvt->t38_mode = T38_MODE_UNKNOWN; + pvt->t38_mode = T38_MODE_UNKNOWN; - if (pvt->app_mode == FUNCTION_GW) { - enabled = 1; - } else if ((v = switch_channel_get_variable(channel, "fax_enable_t38"))) { - enabled = switch_true(v); - } else { - enabled = spandsp_globals.enable_t38; - } + if (pvt->app_mode == FUNCTION_GW) { + enabled = 1; + } else if ((v = switch_channel_get_variable(channel, "fax_enable_t38"))) { + enabled = switch_true(v); + } else { + enabled = spandsp_globals.enable_t38; + } - if (enabled) { - if ((v = switch_channel_get_variable(channel, "fax_enable_t38_request"))) { - enabled = switch_true(v); - } else { - enabled = spandsp_globals.enable_t38_request; + if (enabled) { + if ((v = switch_channel_get_variable(channel, "fax_enable_t38_request"))) { + enabled = switch_true(v); + } else { + enabled = spandsp_globals.enable_t38_request; + } + } + + + if ((v = switch_channel_get_variable(channel, "fax_enable_t38_insist"))) { + insist = switch_true(v); + } else { + insist = spandsp_globals.enable_t38_insist; + } + + if ((t38_options = switch_channel_get_private(channel, "t38_options"))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, + "%s already has T.38 data\n", switch_channel_get_name(channel)); + enabled = 0; + } + + + + if (enabled) { + + if (!(t38_options = switch_channel_get_private(channel, "_preconfigured_t38_options"))) { + t38_options = switch_core_session_alloc(session, sizeof(*t38_options)); + switch_channel_set_private(channel, "_preconfigured_t38_options", NULL); } - } + t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400; + t38_options->T38FaxVersion = 0; + t38_options->T38FaxFillBitRemoval = 1; + t38_options->T38FaxTranscodingMMR = 0; + t38_options->T38FaxTranscodingJBIG = 0; + t38_options->T38FaxRateManagement = "transferredTCF"; + t38_options->T38FaxMaxBuffer = 2000; + t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM; + t38_options->T38FaxUdpEC = "t38UDPRedundancy"; + t38_options->T38VendorInfo = "0 0 0"; - if ((v = switch_channel_get_variable(channel, "fax_enable_t38_insist"))) { - insist = switch_true(v); - } else { - insist = spandsp_globals.enable_t38_insist; - } + switch_channel_set_private(channel, "t38_options", t38_options); + pvt->t38_mode = T38_MODE_REQUESTED; + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_REQ); - if ((t38_options = switch_channel_get_private(channel, "t38_options"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "%s already has T.38 data\n", switch_channel_get_name(channel)); - enabled = 0; - } - - if (enabled) { - t38_options = switch_core_session_alloc(session, sizeof(*t38_options)); - - t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400; - t38_options->T38FaxVersion = 0; - t38_options->T38FaxFillBitRemoval = 1; - t38_options->T38FaxTranscodingMMR = 0; - t38_options->T38FaxTranscodingJBIG = 0; - t38_options->T38FaxRateManagement = "transferredTCF"; - t38_options->T38FaxMaxBuffer = 2000; - t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM; - t38_options->T38FaxUdpEC = "t38UDPRedundancy"; - t38_options->T38VendorInfo = "0 0 0"; - - switch_channel_set_private(channel, "t38_options", t38_options); - pvt->t38_mode = T38_MODE_REQUESTED; - switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_REQ); - - /* This will send a request for t.38 mode */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA; - msg.numeric_arg = insist; - switch_core_session_receive_message(session, &msg); - } + /* This will send a request for t.38 mode */ + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA; + msg.numeric_arg = insist; + switch_core_session_receive_message(session, &msg); + } return pvt->t38_mode; } @@ -1137,9 +1147,9 @@ static t38_mode_t request_t38(pvt_t *pvt) static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_application_mode_t app_mode) { - switch_channel_t *channel; - pvt_t *pvt = NULL; - const char *tmp; + switch_channel_t *channel; + pvt_t *pvt = NULL; + const char *tmp; /* Make sure we have a valid channel when starting the FAX application */ channel = switch_core_session_get_channel(session); @@ -1151,25 +1161,25 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati /* Allocate our structs */ pvt = switch_core_session_alloc(session, sizeof(pvt_t)); - pvt->session = session; + pvt->session = session; - pvt->app_mode = app_mode; + pvt->app_mode = app_mode; - pvt->tx_page_start = -1; - pvt->tx_page_end = -1; + pvt->tx_page_start = -1; + pvt->tx_page_end = -1; - switch(pvt->app_mode) { + switch(pvt->app_mode) { - case FUNCTION_TX: - pvt->caller = 1; - break; - case FUNCTION_RX: - pvt->caller = 0; - break; - case FUNCTION_GW: - break; - } + case FUNCTION_TX: + pvt->caller = 1; + break; + case FUNCTION_RX: + pvt->caller = 0; + break; + case FUNCTION_GW: + break; + } /* Retrieving our settings from the channel variables */ @@ -1200,37 +1210,37 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati } if ((tmp = switch_channel_get_variable(channel, "fax_ident"))) { - char *data = NULL; + char *data = NULL; - data = strdup(tmp); - switch_url_decode(data); + data = strdup(tmp); + switch_url_decode(data); pvt->ident = switch_core_session_strdup(session, data); - switch_safe_free(data); + switch_safe_free(data); } else { pvt->ident = switch_core_session_strdup(session, spandsp_globals.ident); } if ((tmp = switch_channel_get_variable(channel, "fax_header"))) { - char *data = NULL; + char *data = NULL; - data = strdup(tmp); - switch_url_decode(data); - pvt->header = switch_core_session_strdup(session, data); + data = strdup(tmp); + switch_url_decode(data); + pvt->header = switch_core_session_strdup(session, data); - switch_safe_free(data); + switch_safe_free(data); } else { pvt->header = switch_core_session_strdup(session, spandsp_globals.header); } if ((tmp = switch_channel_get_variable(channel, "fax_timezone"))) { - char *data = NULL; + char *data = NULL; - data = strdup(tmp); - switch_url_decode(data); - pvt->timezone = switch_core_session_strdup(session, data); + data = strdup(tmp); + switch_url_decode(data); + pvt->timezone = switch_core_session_strdup(session, data); - switch_safe_free(data); + switch_safe_free(data); } else { pvt->timezone = switch_core_session_strdup(session, spandsp_globals.timezone); } @@ -1255,9 +1265,9 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati if ((pvt->tx_page_end < pvt->tx_page_start) && (pvt->tx_page_end != -1)) { pvt->tx_page_end = pvt->tx_page_start; } - } + } - return pvt; + return pvt; } void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *data, mod_spandsp_fax_application_mode_t app_mode) @@ -1270,15 +1280,15 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat switch_frame_t write_frame = { 0 }; switch_codec_implementation_t read_impl = { 0 }; int16_t *buf = NULL; - uint32_t req_counter = 0; + uint32_t req_counter = 0; switch_core_session_get_read_impl(session, &read_impl); counter_increment(); - - pvt = pvt_init(session, app_mode); - + + pvt = pvt_init(session, app_mode); + buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); @@ -1327,7 +1337,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat return; } - /* + /* Note: Disable echocan on the channel, remember to call app "disable_ec" in the dialplan before invoking fax applications */ @@ -1381,11 +1391,11 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat switch_ivr_sleep(session, 250, SWITCH_TRUE, NULL); - if (pvt->app_mode == FUNCTION_TX) { - req_counter = 100; - } else { - req_counter = 50; - } + if (pvt->app_mode == FUNCTION_TX) { + req_counter = 100; + } else { + req_counter = 50; + } while (switch_channel_ready(channel)) { int tx = 0; @@ -1400,7 +1410,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat - call t38_terminal_send_timeout(), sleep for a while The T.38 stuff can be placed here (and the audio stuff can be skipped) - */ + */ /* read new audio frame from the channel */ status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); @@ -1410,72 +1420,72 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat goto done; } - switch (pvt->t38_mode) { - case T38_MODE_REQUESTED: - { - if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38_FAIL)) { - pvt->t38_mode = T38_MODE_REFUSED; - continue; - } else if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - switch_core_session_message_t msg = { 0 }; - pvt->t38_mode = T38_MODE_NEGOTIATED; - switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); - spanfax_init(pvt, T38_MODE); - configure_t38(pvt); - - /* This will change the rtp stack to udptl mode */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; - switch_core_session_receive_message(session, &msg); - } - continue; - } - break; - case T38_MODE_UNKNOWN: - { - if (req_counter) { - if (!--req_counter) { - /* If you have the means, I highly recommend picking one up. ...*/ - request_t38(pvt); - } - } - - if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - if (negotiate_t38(pvt) == T38_MODE_NEGOTIATED) { - /* is is safe to call this again, it was already called above in AUDIO_MODE */ - /* but this is the only way to set up the t38 stuff */ - spanfax_init(pvt, T38_MODE); - continue; - } - } - } - break; - case T38_MODE_NEGOTIATED: - { - /* do what we need to do when we are in t38 mode */ - if (switch_test_flag(read_frame, SFF_CNG)) { - /* dunno what to do, most likely you will not get too many of these since we turn off the timer in udptl mode */ - continue; - } - - if (switch_test_flag(read_frame, SFF_UDPTL_PACKET)) { - /* now we know we can cast frame->packet to a udptl structure */ - //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "READ %d udptl bytes\n", read_frame->packetlen); - - udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); - } - } - continue; - default: - break; - } + switch (pvt->t38_mode) { + case T38_MODE_REQUESTED: + { + if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38_FAIL)) { + pvt->t38_mode = T38_MODE_REFUSED; + continue; + } else if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + switch_core_session_message_t msg = { 0 }; + pvt->t38_mode = T38_MODE_NEGOTIATED; + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); + spanfax_init(pvt, T38_MODE); + configure_t38(pvt); + + /* This will change the rtp stack to udptl mode */ + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; + switch_core_session_receive_message(session, &msg); + } + continue; + } + break; + case T38_MODE_UNKNOWN: + { + if (req_counter) { + if (!--req_counter) { + /* If you have the means, I highly recommend picking one up. ...*/ + request_t38(pvt); + } + } + + if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + if (negotiate_t38(pvt) == T38_MODE_NEGOTIATED) { + /* is is safe to call this again, it was already called above in AUDIO_MODE */ + /* but this is the only way to set up the t38 stuff */ + spanfax_init(pvt, T38_MODE); + continue; + } + } + } + break; + case T38_MODE_NEGOTIATED: + { + /* do what we need to do when we are in t38 mode */ + if (switch_test_flag(read_frame, SFF_CNG)) { + /* dunno what to do, most likely you will not get too many of these since we turn off the timer in udptl mode */ + continue; + } + + if (switch_test_flag(read_frame, SFF_UDPTL_PACKET)) { + /* now we know we can cast frame->packet to a udptl structure */ + //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "READ %d udptl bytes\n", read_frame->packetlen); + + udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); + } + } + continue; + default: + break; + } if (switch_test_flag(read_frame, SFF_CNG)) { /* We have no real signal data for the FAX software, but we have a space in time if we have a CNG indication. Do a fill-in operation in the FAX machine, to keep things rolling along. */ if (fax_rx_fillin(pvt->fax_state, read_impl.samples_per_packet)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx_fillin reported an error\n"); - continue; + continue; } } else { /* Pass the new incoming audio frame to the fax_rx function */ @@ -1524,30 +1534,30 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat void mod_spandsp_fax_load(switch_memory_pool_t *pool) { - uint32_t sanity = 200; + uint32_t sanity = 200; - memset(&t38_state_list, 0, sizeof(t38_state_list)); + memset(&t38_state_list, 0, sizeof(t38_state_list)); switch_mutex_init(&spandsp_globals.mutex, SWITCH_MUTEX_NESTED, spandsp_globals.pool); switch_mutex_init(&t38_state_list.mutex, SWITCH_MUTEX_NESTED, spandsp_globals.pool); switch_mutex_init(&spandsp_globals.cond_mutex, SWITCH_MUTEX_NESTED, spandsp_globals.pool); switch_thread_cond_create(&spandsp_globals.cond, spandsp_globals.pool); - - launch_timer_thread(); - while(--sanity && !t38_state_list.thread_running) { - switch_yield(20000); - } + launch_timer_thread(); + + while(--sanity && !t38_state_list.thread_running) { + switch_yield(20000); + } } void mod_spandsp_fax_shutdown(void) { - switch_status_t tstatus = SWITCH_STATUS_SUCCESS; + switch_status_t tstatus = SWITCH_STATUS_SUCCESS; - t38_state_list.thread_running = 0; - wake_thread(1); - switch_thread_join(&tstatus, t38_state_list.thread); + t38_state_list.thread_running = 0; + wake_thread(1); + switch_thread_join(&tstatus, t38_state_list.thread); memset(&spandsp_globals, 0, sizeof(spandsp_globals)); } @@ -1555,83 +1565,83 @@ static const switch_state_handler_table_t t38_gateway_state_handlers; static switch_status_t t38_gateway_on_soft_execute(switch_core_session_t *session) { - switch_core_session_t *other_session; + switch_core_session_t *other_session; - switch_channel_t *other_channel, *channel = switch_core_session_get_channel(session); - pvt_t *pvt; - const char *peer_uuid = switch_channel_get_variable(channel, "t38_peer"); - switch_core_session_message_t msg = { 0 }; - switch_status_t status; - switch_frame_t *read_frame = { 0 }; + switch_channel_t *other_channel, *channel = switch_core_session_get_channel(session); + pvt_t *pvt; + const char *peer_uuid = switch_channel_get_variable(channel, "t38_peer"); + switch_core_session_message_t msg = { 0 }; + switch_status_t status; + switch_frame_t *read_frame = { 0 }; - if (!(other_session = switch_core_session_locate(peer_uuid))) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot locate channel with uuid %s", - switch_channel_get_name(channel), peer_uuid); - goto end; - } + if (!(other_session = switch_core_session_locate(peer_uuid))) { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot locate channel with uuid %s", + switch_channel_get_name(channel), peer_uuid); + goto end; + } - other_channel = switch_core_session_get_channel(other_session); + other_channel = switch_core_session_get_channel(other_session); - pvt = pvt_init(session, FUNCTION_GW); - request_t38(pvt); + pvt = pvt_init(session, FUNCTION_GW); + request_t38(pvt); - msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); + msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; + msg.from = __FILE__; + msg.string_arg = peer_uuid; + switch_core_session_receive_message(session, &msg); - while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) { /* Our duty is over */ - goto end_unlock; + goto end_unlock; } - if (switch_test_flag(read_frame, SFF_CNG)) { - continue; - } + if (switch_test_flag(read_frame, SFF_CNG)) { + continue; + } - if (switch_core_session_write_frame(other_session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - goto end_unlock; - } - } + if (switch_core_session_write_frame(other_session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { + goto end_unlock; + } + } if (!(switch_channel_ready(channel) && switch_channel_up(other_channel))) { - goto end_unlock; - } + goto end_unlock; + } - if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel)); - goto end_unlock; - } + if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel)); + goto end_unlock; + } - if (pvt->t38_mode == T38_MODE_REQUESTED) { - spanfax_init(pvt, T38_GATEWAY_MODE); - configure_t38(pvt); - pvt->t38_mode = T38_MODE_NEGOTIATED; - switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); - } else { - if (negotiate_t38(pvt) != T38_MODE_NEGOTIATED) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end_unlock; - } - switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); - spanfax_init(pvt, T38_GATEWAY_MODE); - } + if (pvt->t38_mode == T38_MODE_REQUESTED) { + spanfax_init(pvt, T38_GATEWAY_MODE); + configure_t38(pvt); + pvt->t38_mode = T38_MODE_NEGOTIATED; + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); + } else { + if (negotiate_t38(pvt) != T38_MODE_NEGOTIATED) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel)); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + goto end_unlock; + } + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED); + spanfax_init(pvt, T38_GATEWAY_MODE); + } - /* This will change the rtp stack to udptl mode */ - msg.from = __FILE__; - msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; - switch_core_session_receive_message(session, &msg); + /* This will change the rtp stack to udptl mode */ + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; + switch_core_session_receive_message(session, &msg); - /* wake up the audio side */ - switch_channel_set_private(channel, "_t38_pvt", pvt); - switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38); + /* wake up the audio side */ + switch_channel_set_private(channel, "_t38_pvt", pvt); + switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38); while (switch_channel_ready(channel) && switch_channel_up(other_channel)) { @@ -1642,111 +1652,111 @@ static switch_status_t t38_gateway_on_soft_execute(switch_core_session_t *sessio /* Our duty is over */ goto end_unlock; } - - if (switch_test_flag(read_frame, SFF_CNG)) { - continue; - } - - if (switch_test_flag(read_frame, SFF_UDPTL_PACKET)) { - udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); - } - } + + if (switch_test_flag(read_frame, SFF_CNG)) { + continue; + } + + if (switch_test_flag(read_frame, SFF_UDPTL_PACKET)) { + udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen); + } + } end_unlock: - msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); + msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE; + msg.from = __FILE__; + msg.string_arg = peer_uuid; + switch_core_session_receive_message(session, &msg); - switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING); - switch_core_session_rwunlock(other_session); + switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING); + switch_core_session_rwunlock(other_session); end: - switch_channel_clear_state_handler(channel, &t38_gateway_state_handlers); - switch_channel_set_variable(channel, "t38_peer", NULL); + switch_channel_clear_state_handler(channel, &t38_gateway_state_handlers); + switch_channel_set_variable(channel, "t38_peer", NULL); - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - return SWITCH_STATUS_SUCCESS; + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + return SWITCH_STATUS_SUCCESS; } static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *session) { - switch_core_session_t *other_session; - switch_channel_t *other_channel, *channel = switch_core_session_get_channel(session); - const char *peer_uuid = switch_channel_get_variable(channel, "t38_peer"); - pvt_t *pvt = NULL; - switch_codec_t read_codec = { 0 }; + switch_core_session_t *other_session; + switch_channel_t *other_channel, *channel = switch_core_session_get_channel(session); + const char *peer_uuid = switch_channel_get_variable(channel, "t38_peer"); + pvt_t *pvt = NULL; + switch_codec_t read_codec = { 0 }; switch_codec_t write_codec = { 0 }; switch_frame_t *read_frame = { 0 }; switch_frame_t write_frame = { 0 }; switch_codec_implementation_t read_impl = { 0 }; int16_t *buf = NULL; - switch_status_t status; - int tx; - const char *t38_trace = switch_channel_get_variable(channel, "t38_trace"); - char *trace_read, *trace_write; - zap_socket_t read_fd = FAX_INVALID_SOCKET, write_fd = FAX_INVALID_SOCKET; - switch_core_session_message_t msg = { 0 }; - switch_event_t *event; + switch_status_t status; + int tx; + const char *t38_trace = switch_channel_get_variable(channel, "t38_trace"); + char *trace_read, *trace_write; + zap_socket_t read_fd = FAX_INVALID_SOCKET, write_fd = FAX_INVALID_SOCKET; + switch_core_session_message_t msg = { 0 }; + switch_event_t *event; switch_core_session_get_read_impl(session, &read_impl); - - buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); - if (!(other_session = switch_core_session_locate(peer_uuid))) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end; - } + buf = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE); - other_channel = switch_core_session_get_channel(other_session); - - msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); + if (!(other_session = switch_core_session_locate(peer_uuid))) { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + goto end; + } + + other_channel = switch_core_session_get_channel(other_session); + + msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; + msg.from = __FILE__; + msg.string_arg = peer_uuid; + switch_core_session_receive_message(session, &msg); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session)); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid); switch_channel_event_set_data(channel, event); switch_event_fire(&event); } - while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - + if (!SWITCH_READ_ACCEPTABLE(status)) { /* Our duty is over */ goto end_unlock; } - if (switch_test_flag(read_frame, SFF_CNG)) { - continue; - } + if (switch_test_flag(read_frame, SFF_CNG)) { + continue; + } - if (switch_core_session_write_frame(other_session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { - goto end_unlock; - } - } + if (switch_core_session_write_frame(other_session, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { + goto end_unlock; + } + } if (!(switch_channel_ready(channel) && switch_channel_up(other_channel))) { - goto end_unlock; - } + goto end_unlock; + } - if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end_unlock; - } - - if (!(pvt = switch_channel_get_private(other_channel, "_t38_pvt"))) { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - goto end_unlock; - } - - if (switch_core_codec_init(&read_codec, + if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + goto end_unlock; + } + + if (!(pvt = switch_channel_get_private(other_channel, "_t38_pvt"))) { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + goto end_unlock; + } + + if (switch_core_codec_init(&read_codec, "L16", NULL, read_impl.samples_per_second, @@ -1781,27 +1791,27 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL); - if (switch_true(t38_trace)) { - trace_read = switch_core_session_sprintf(session, "%s%s%s_read.raw", SWITCH_GLOBAL_dirs.temp_dir, - SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); + if (switch_true(t38_trace)) { + trace_read = switch_core_session_sprintf(session, "%s%s%s_read.raw", SWITCH_GLOBAL_dirs.temp_dir, + SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing inbound audio to %s\n", trace_read); - switch_channel_set_variable(channel, "t38_trace_read", trace_read); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing inbound audio to %s\n", trace_read); + switch_channel_set_variable(channel, "t38_trace_read", trace_read); - trace_write = switch_core_session_sprintf(session, "%s%s%s_write.raw", SWITCH_GLOBAL_dirs.temp_dir, - SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing outbound audio to %s\n", trace_write); - switch_channel_set_variable(channel, "t38_trace_read", trace_write); - + trace_write = switch_core_session_sprintf(session, "%s%s%s_write.raw", SWITCH_GLOBAL_dirs.temp_dir, + SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session)); - if ((write_fd = open(trace_read, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) != FAX_INVALID_SOCKET) { - if ((read_fd = open(trace_write, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) == FAX_INVALID_SOCKET) { - close(write_fd); - write_fd = FAX_INVALID_SOCKET; - } - } - } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Tracing outbound audio to %s\n", trace_write); + switch_channel_set_variable(channel, "t38_trace_read", trace_write); + + + if ((write_fd = open(trace_read, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) != FAX_INVALID_SOCKET) { + if ((read_fd = open(trace_write, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) == FAX_INVALID_SOCKET) { + close(write_fd); + write_fd = FAX_INVALID_SOCKET; + } + } + } while (switch_channel_ready(channel) && switch_channel_up(other_channel)) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); @@ -1811,16 +1821,16 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi goto end_unlock; } - if (switch_test_flag(read_frame, SFF_CNG)) { + if (switch_test_flag(read_frame, SFF_CNG)) { /* We have no real signal data for the FAX software, but we have a space in time if we have a CNG indication. Do a fill-in operation in the FAX machine, to keep things rolling along. */ - t38_gateway_rx_fillin(pvt->t38_gateway_state, read_impl.samples_per_packet); - } else { - if (read_fd != FAX_INVALID_SOCKET) { - switch_ssize_t rv; - do { rv = write(read_fd, read_frame->data, read_frame->datalen); } while (rv == -1 && errno == EINTR); - } - if (t38_gateway_rx(pvt->t38_gateway_state, (int16_t *) read_frame->data, read_frame->samples)) { + t38_gateway_rx_fillin(pvt->t38_gateway_state, read_impl.samples_per_packet); + } else { + if (read_fd != FAX_INVALID_SOCKET) { + switch_ssize_t rv; + do { rv = write(read_fd, read_frame->data, read_frame->datalen); } while (rv == -1 && errno == EINTR); + } + if (t38_gateway_rx(pvt->t38_gateway_state, (int16_t *) read_frame->data, read_frame->samples)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx reported an error\n"); goto end_unlock; } @@ -1840,22 +1850,22 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi write_frame.samples = tx; } - if (write_fd != FAX_INVALID_SOCKET) { - switch_ssize_t rv; - do { rv = write(write_fd, write_frame.data, write_frame.datalen); } while (rv == -1 && errno == EINTR); - } + if (write_fd != FAX_INVALID_SOCKET) { + switch_ssize_t rv; + do { rv = write(write_fd, write_frame.data, write_frame.datalen); } while (rv == -1 && errno == EINTR); + } if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { goto end_unlock; } - } + } end_unlock: - msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE; - msg.from = __FILE__; - msg.string_arg = peer_uuid; - switch_core_session_receive_message(session, &msg); + msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE; + msg.from = __FILE__; + msg.string_arg = peer_uuid; + switch_core_session_receive_message(session, &msg); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) { @@ -1863,19 +1873,19 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi switch_event_fire(&event); } - if (read_fd != FAX_INVALID_SOCKET) { - close(read_fd); - read_fd = FAX_INVALID_SOCKET; - } + if (read_fd != FAX_INVALID_SOCKET) { + close(read_fd); + read_fd = FAX_INVALID_SOCKET; + } - if (write_fd != FAX_INVALID_SOCKET) { - close(write_fd); - write_fd = FAX_INVALID_SOCKET; - } + if (write_fd != FAX_INVALID_SOCKET) { + close(write_fd); + write_fd = FAX_INVALID_SOCKET; + } - switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING); - switch_core_session_rwunlock(other_session); + switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING); + switch_core_session_rwunlock(other_session); switch_core_session_set_read_codec(session, NULL); @@ -1890,29 +1900,29 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi end: - switch_channel_clear_state_handler(channel, &t38_gateway_state_handlers); - switch_channel_set_variable(channel, "t38_peer", NULL); - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - - return SWITCH_STATUS_SUCCESS; + switch_channel_clear_state_handler(channel, &t38_gateway_state_handlers); + switch_channel_set_variable(channel, "t38_peer", NULL); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + + return SWITCH_STATUS_SUCCESS; } static switch_status_t t38_gateway_on_reset(switch_core_session_t *session) { - switch_channel_t *channel = switch_core_session_get_channel(session); + switch_channel_t *channel = switch_core_session_get_channel(session); - switch_channel_set_variable(channel, "rtp_autoflush_during_bridge", "false"); - - switch_channel_clear_flag(channel, CF_REDIRECT); + switch_channel_set_variable(channel, "rtp_autoflush_during_bridge", "false"); - if (switch_channel_test_app_flag_key("T38", channel, CF_APP_TAGGED)) { - switch_channel_clear_app_flag_key("T38", channel, CF_APP_TAGGED); - switch_channel_set_state(channel, CS_CONSUME_MEDIA); - } else { - switch_channel_set_state(channel, CS_SOFT_EXECUTE); - } + switch_channel_clear_flag(channel, CF_REDIRECT); - return SWITCH_STATUS_SUCCESS; + if (switch_channel_test_app_flag_key("T38", channel, CF_APP_TAGGED)) { + switch_channel_clear_app_flag_key("T38", channel, CF_APP_TAGGED); + switch_channel_set_state(channel, CS_CONSUME_MEDIA); + } else { + switch_channel_set_state(channel, CS_SOFT_EXECUTE); + } + + return SWITCH_STATUS_SUCCESS; } static const switch_state_handler_table_t t38_gateway_state_handlers = { @@ -1925,53 +1935,53 @@ static const switch_state_handler_table_t t38_gateway_state_handlers = { /*.on_consume_media */ t38_gateway_on_consume_media, /*.on_hibernate */ NULL, /*.on_reset */ t38_gateway_on_reset, - /*.on_park */ NULL, - /*.on_reporting */ NULL, - /*.on_destroy */ NULL, - SSH_FLAG_STICKY + /*.on_park */ NULL, + /*.on_reporting */ NULL, + /*.on_destroy */ NULL, + SSH_FLAG_STICKY }; switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app, const char *data) { - switch_channel_t *other_channel = NULL, *channel = switch_core_session_get_channel(session); - switch_core_session_t *other_session = NULL; - int peer = app && !strcasecmp(app, "peer"); - - if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { - other_channel = switch_core_session_get_channel(other_session); + switch_channel_t *other_channel = NULL, *channel = switch_core_session_get_channel(session); + switch_core_session_t *other_session = NULL; + int peer = app && !strcasecmp(app, "peer"); - switch_channel_set_variable(channel, "t38_peer", switch_core_session_get_uuid(other_session)); - switch_channel_set_variable(other_channel, "t38_peer", switch_core_session_get_uuid(session)); + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { + other_channel = switch_core_session_get_channel(other_session); - switch_channel_set_variable(peer ? other_channel : channel, "t38_gateway_format", "udptl"); - switch_channel_set_variable(peer ? channel : other_channel, "t38_gateway_format", "audio"); + switch_channel_set_variable(channel, "t38_peer", switch_core_session_get_uuid(other_session)); + switch_channel_set_variable(other_channel, "t38_peer", switch_core_session_get_uuid(session)); + + switch_channel_set_variable(peer ? other_channel : channel, "t38_gateway_format", "udptl"); + switch_channel_set_variable(peer ? channel : other_channel, "t38_gateway_format", "audio"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s starting gateway mode to %s\n", - switch_channel_get_name(peer ? channel : other_channel), - switch_channel_get_name(peer ? other_channel : channel)); - - - switch_channel_clear_state_handler(channel, NULL); - switch_channel_clear_state_handler(other_channel, NULL); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s starting gateway mode to %s\n", + switch_channel_get_name(peer ? channel : other_channel), + switch_channel_get_name(peer ? other_channel : channel)); - switch_channel_add_state_handler(channel, &t38_gateway_state_handlers); - switch_channel_add_state_handler(other_channel, &t38_gateway_state_handlers); - switch_channel_set_app_flag_key("T38", peer ? channel : other_channel, CF_APP_TAGGED); - switch_channel_clear_app_flag_key("T38", peer ? other_channel : channel, CF_APP_TAGGED); - - switch_channel_set_flag(channel, CF_REDIRECT); - switch_channel_set_state(channel, CS_RESET); + switch_channel_clear_state_handler(channel, NULL); + switch_channel_clear_state_handler(other_channel, NULL); - switch_channel_set_flag(other_channel, CF_REDIRECT); - switch_channel_set_state(other_channel, CS_RESET); - - switch_core_session_rwunlock(other_session); + switch_channel_add_state_handler(channel, &t38_gateway_state_handlers); + switch_channel_add_state_handler(other_channel, &t38_gateway_state_handlers); - } - - return SWITCH_FALSE; + switch_channel_set_app_flag_key("T38", peer ? channel : other_channel, CF_APP_TAGGED); + switch_channel_clear_app_flag_key("T38", peer ? other_channel : channel, CF_APP_TAGGED); + + switch_channel_set_flag(channel, CF_REDIRECT); + switch_channel_set_state(channel, CS_RESET); + + switch_channel_set_flag(other_channel, CF_REDIRECT); + switch_channel_set_state(other_channel, CS_RESET); + + switch_core_session_rwunlock(other_session); + + } + + return SWITCH_FALSE; } typedef struct { diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c index e3f8afa89f..eb54c217aa 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c @@ -72,33 +72,33 @@ static modem_t *acquire_modem(int index); static int t31_at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len) -{ +{ modem_t *modem = user_data; #ifndef WIN32 switch_size_t wrote; wrote = write(modem->master, buf, len); #else - DWORD wrote; - OVERLAPPED o; - o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + DWORD wrote; + OVERLAPPED o; + o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - /* Initialize the rest of the OVERLAPPED structure to zero. */ - o.Internal = 0; - o.InternalHigh = 0; - o.Offset = 0; - o.OffsetHigh = 0; - assert(o.hEvent); - if (!WriteFile(modem->master, buf, (DWORD)len, &wrote, &o)) { - GetOverlappedResult(modem->master, &o, &wrote, TRUE); - } - CloseHandle (o.hEvent); + /* Initialize the rest of the OVERLAPPED structure to zero. */ + o.Internal = 0; + o.InternalHigh = 0; + o.Offset = 0; + o.OffsetHigh = 0; + assert(o.hEvent); + if (!WriteFile(modem->master, buf, (DWORD)len, &wrote, &o)) { + GetOverlappedResult(modem->master, &o, &wrote, TRUE); + } + CloseHandle (o.hEvent); #endif - if (wrote != len) { + if (wrote != len) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to pass the full buffer onto the device file. " "%"SWITCH_SSIZE_T_FMT " bytes of " "%"SWITCH_SIZE_T_FMT " written: %s\n", wrote, len, strerror(errno)); - + if (wrote == -1) wrote = 0; #ifndef WIN32 @@ -110,8 +110,8 @@ static int t31_at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully flushed pty buffer\n"); } #endif - } - return wrote; + } + return wrote; } @@ -126,7 +126,7 @@ static int t31_call_control_handler(t31_state_t *s, void *user_data, int op, con switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DOH! NO CONTROL HANDLER INSTALLED\n"); } - return ret; + return ret; } @@ -193,7 +193,7 @@ int modem_close(modem_t *modem) } - if (modem->t31_state) { + if (modem->t31_state) { t31_free(modem->t31_state); modem->t31_state = NULL; } @@ -228,27 +228,28 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl */ #if USE_OPENPTY - if (openpty(&modem->master, &modem->slave, NULL, NULL, NULL)) { + if (openpty(&modem->master, &modem->slave, NULL, NULL, NULL)) { - if (modem->master < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to initialize pty\n"); - status = SWITCH_STATUS_FALSE; - goto end; - } + if (modem->master < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to initialize pty\n"); + status = SWITCH_STATUS_FALSE; + goto end; + } - modem->stty = ttyname(modem->slave); + modem->stty = ttyname(modem->slave); + } #else #if WIN32 modem->slot = 4+globals.NEXT_ID++; /* need work here we start at COM4 for now*/ snprintf(modem->devlink, sizeof(modem->devlink), "COM%d", modem->slot); modem->master = CreateFile(modem->devlink, - GENERIC_READ | GENERIC_WRITE, - 0, - 0, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - 0); + GENERIC_READ | GENERIC_WRITE, + 0, + 0, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, + 0); if(modem->master==INVALID_HANDLE_VALUE) { status = SWITCH_STATUS_FALSE; if(GetLastError()==ERROR_FILE_NOT_FOUND) { @@ -259,44 +260,44 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl goto end; } #elif !defined(HAVE_POSIX_OPENPT) - modem->master = open("/dev/ptmx", O_RDWR); + modem->master = open("/dev/ptmx", O_RDWR); #else - modem->master = posix_openpt(O_RDWR | O_NOCTTY); + modem->master = posix_openpt(O_RDWR | O_NOCTTY); #endif #ifndef WIN32 - if (modem->master < 0) { + if (modem->master < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to initialize UNIX98 master pty\n"); - } + } - if (grantpt(modem->master) < 0) { + if (grantpt(modem->master) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to grant access to slave pty\n"); - } + } - if (unlockpt(modem->master) < 0) { + if (unlockpt(modem->master) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to unlock slave pty\n"); - } + } - modem->stty = ptsname(modem->master); + modem->stty = ptsname(modem->master); - if (modem->stty == NULL) { + if (modem->stty == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to obtain slave pty filename\n"); - } + } - modem->slave = open(modem->stty, O_RDWR); + modem->slave = open(modem->stty, O_RDWR); - if (modem->slave < 0) { + if (modem->slave < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to open slave pty %s\n", modem->stty); - } + } #endif #ifdef SOLARIS - ioctl(modem->slave, I_PUSH, "ptem"); /* push ptem */ - ioctl(modem->slave, I_PUSH, "ldterm"); /* push ldterm*/ + ioctl(modem->slave, I_PUSH, "ptem"); /* push ptem */ + ioctl(modem->slave, I_PUSH, "ldterm"); /* push ldterm*/ #endif #endif @@ -304,21 +305,21 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl modem->slot = globals.NEXT_ID++; snprintf(modem->devlink, sizeof(modem->devlink), "/dev/FS%d", modem->slot); - unlink(modem->devlink); + unlink(modem->devlink); - if (symlink(modem->stty, modem->devlink)) { + if (symlink(modem->stty, modem->devlink)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fatal error: failed to create %s symbolic link\n", modem->devlink); modem_close(modem); status = SWITCH_STATUS_FALSE; goto end; - } + } - if (fcntl(modem->master, F_SETFL, fcntl(modem->master, F_GETFL, 0) | O_NONBLOCK)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot set up non-blocking read on %s\n", ttyname(modem->master)); - modem_close(modem); - status = SWITCH_STATUS_FALSE; - goto end; - } + if (fcntl(modem->master, F_SETFL, fcntl(modem->master, F_GETFL, 0) | O_NONBLOCK)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot set up non-blocking read on %s\n", ttyname(modem->master)); + modem_close(modem); + status = SWITCH_STATUS_FALSE; + goto end; + } #else timeouts.ReadIntervalTimeout=50; timeouts.ReadTotalTimeoutConstant=50; @@ -1031,14 +1032,14 @@ static int control_handler(modem_t *modem, const char *num, int op) 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); - switch (op) { + switch (op) { - case AT_MODEM_CONTROL_ANSWER: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + case AT_MODEM_CONTROL_ANSWER: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - Answering\n", modem->devlink, modem_state2name(modem_get_state(modem))); modem_set_state(modem, MODEM_STATE_ANSWERED); - break; - case AT_MODEM_CONTROL_CALL: + break; + case AT_MODEM_CONTROL_CALL: { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - Dialing '%s'\n", modem->devlink, modem_state2name(modem_get_state(modem)), num); @@ -1055,13 +1056,13 @@ static int control_handler(modem_t *modem, const char *num, int op) } } break; - case AT_MODEM_CONTROL_OFFHOOK: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + case AT_MODEM_CONTROL_OFFHOOK: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - Going off hook\n", modem->devlink, modem_state2name(modem_get_state(modem))); modem_set_state(modem, MODEM_STATE_OFFHOOK); break; - case AT_MODEM_CONTROL_ONHOOK: - case AT_MODEM_CONTROL_HANGUP: + case AT_MODEM_CONTROL_ONHOOK: + case AT_MODEM_CONTROL_HANGUP: { if (modem_get_state(modem) != MODEM_STATE_RINGING) { int set_state = 1; @@ -1095,16 +1096,16 @@ static int control_handler(modem_t *modem, const char *num, int op) } } } - break; - case AT_MODEM_CONTROL_DTR: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + break; + case AT_MODEM_CONTROL_DTR: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - DTR %d\n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num); - break; - case AT_MODEM_CONTROL_RTS: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + break; + case AT_MODEM_CONTROL_RTS: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - RTS %d\n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num); - break; - case AT_MODEM_CONTROL_CTS: + break; + case AT_MODEM_CONTROL_CTS: { u_char x[1]; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, @@ -1121,26 +1122,26 @@ static int control_handler(modem_t *modem, const char *num, int op) switch_set_flag(modem, MODEM_FLAG_XOFF); } } - break; - case AT_MODEM_CONTROL_CAR: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + break; + case AT_MODEM_CONTROL_CAR: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - CAR %d\n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num); - break; - case AT_MODEM_CONTROL_RNG: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + break; + case AT_MODEM_CONTROL_RNG: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - RNG %d\n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num); - break; - case AT_MODEM_CONTROL_DSR: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + break; + case AT_MODEM_CONTROL_DSR: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - DSR %d\n", modem->devlink, modem_state2name(modem_get_state(modem)), (int) (intptr_t) num); - break; - default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + break; + default: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Modem %s [%s] - operation %d\n", modem->devlink, modem_state2name(modem_get_state(modem)), op); - break; - } - /*endswitch*/ - return 0; + break; + } + /*endswitch*/ + return 0; } typedef enum { @@ -1278,7 +1279,7 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj) modem->last_event = switch_time_now(); } - avail = sizeof(buf) - modem->t31_state->tx.in_bytes + modem->t31_state->tx.out_bytes - 1; + avail = t31_at_rx_free_space(modem->t31_state); if (avail == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Buffer Full, retrying....\n"); @@ -1369,14 +1370,14 @@ static void activate_modems(void) static void deactivate_modems(void) { int max = globals.SOFT_MAX_MODEMS; - int x; + int x; switch_mutex_lock(globals.mutex); - for(x = 0; x < max; x++) { + for(x = 0; x < max; x++) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopping Modem SLOT %d\n", x); modem_close(&globals.MODEM_POOL[x]); - } + } switch_mutex_unlock(globals.mutex); @@ -1389,39 +1390,39 @@ static void deactivate_modems(void) static modem_t *acquire_modem(int index) { - modem_t *modem = NULL; + modem_t *modem = NULL; switch_time_t now = switch_time_now(); int64_t idle_debounce = 2000000; - switch_mutex_lock(globals.mutex); - if (index > -1 && index < globals.SOFT_MAX_MODEMS) { - modem = &globals.MODEM_POOL[index]; - } else { - int x; + switch_mutex_lock(globals.mutex); + if (index > -1 && index < globals.SOFT_MAX_MODEMS) { + modem = &globals.MODEM_POOL[index]; + } else { + int x; - for(x = 0; x < globals.SOFT_MAX_MODEMS; x++) { - if (globals.MODEM_POOL[x].state == MODEM_STATE_ONHOOK && (now - globals.MODEM_POOL[x].last_event) > idle_debounce) { - modem = &globals.MODEM_POOL[x]; - break; - } - } - } + for(x = 0; x < globals.SOFT_MAX_MODEMS; x++) { + if (globals.MODEM_POOL[x].state == MODEM_STATE_ONHOOK && (now - globals.MODEM_POOL[x].last_event) > idle_debounce) { + modem = &globals.MODEM_POOL[x]; + break; + } + } + } - if (modem && (modem->state != MODEM_STATE_ONHOOK || (now - modem->last_event) < idle_debounce)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Modem %s In Use!\n", modem->devlink); - modem = NULL; - } + if (modem && (modem->state != MODEM_STATE_ONHOOK || (now - modem->last_event) < idle_debounce)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Modem %s In Use!\n", modem->devlink); + modem = NULL; + } - if (modem) { - modem_set_state(modem, MODEM_STATE_ACQUIRED); + if (modem) { + modem_set_state(modem, MODEM_STATE_ACQUIRED); modem->last_event = switch_time_now(); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Modems Available!\n"); - } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Modems Available!\n"); + } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(globals.mutex); - return modem; + return modem; } switch_status_t modem_global_init(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) @@ -1462,3 +1463,14 @@ void modem_global_shutdown(void) } #endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.h b/src/mod/applications/mod_spandsp/mod_spandsp_modem.h index ae9d64e71b..d02a5fdc8f 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -155,3 +155,14 @@ switch_status_t modem_global_init(switch_loadable_module_interface_t **module_in void modem_global_shutdown(void); #endif //_MOD_SPANDSP_MODEM_H + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ diff --git a/src/mod/applications/mod_stress/mod_stress.cpp b/src/mod/applications/mod_stress/mod_stress.cpp index d96739da0a..4fae808c40 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 9b70e5b317..773fdbabeb 100644 --- a/src/mod/applications/mod_valet_parking/mod_valet_parking.c +++ b/src/mod/applications/mod_valet_parking/mod_valet_parking.c @@ -618,7 +618,7 @@ SWITCH_STANDARD_APP(valet_parking_function) char tmp[512] = ""; switch_snprintf(tmp, sizeof(tmp), "%s:%s", lot_name, ext); - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if ((uuid = switch_channel_get_partner_uuid(channel))) { switch_core_session_t *b_session; if ((b_session = switch_core_session_locate(uuid))) { diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 44bafb3ea2..51677c5b3f 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1815,6 +1815,7 @@ static void update_mwi(vm_profile_t *profile, const char *id, const char *domain int total_new_urgent_messages = 0; int total_saved_urgent_messages = 0; switch_event_t *event; + switch_event_t *message_event; message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages, &total_new_urgent_messages, &total_saved_urgent_messages); @@ -1831,6 +1832,18 @@ static void update_mwi(vm_profile_t *profile, const char *id, const char *domain switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages); switch_event_fire(&event); + + + switch_event_create_subclass(&message_event, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT); + switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Action", "mwi-update"); + switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-User", id); + switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Domain", domain_name); + switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Total-New", "%d", total_new_messages); + switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Total-Saved", "%d", total_saved_messages); + switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Total-New-Urgent", "%d", total_new_urgent_messages); + switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Total-Saved-Urgent", "%d", total_saved_urgent_messages); + + switch_event_fire(&message_event); } @@ -2197,8 +2210,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p if (fail) { /* add feedback for user - let him/her know that the password they tried to change to is not allowed */ - /* change the following macro to VM_CHANGE_PASS_FAIL_MACRO when new prompts have been recorded */ - switch_ivr_phrase_macro(session, VM_FAIL_AUTH_MACRO, NULL, NULL, NULL); + switch_ivr_phrase_macro(session, VM_CHANGE_PASS_FAIL_MACRO, NULL, NULL, NULL); } else { sql = switch_mprintf("update voicemail_prefs set password='%s' where username='%s' and domain='%s'", buf, myid, domain_name); vm_execute_sql(profile, sql, profile->mutex); @@ -2536,7 +2548,10 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p if (authed) { switch_channel_set_variable(channel, "user_pin_authenticated", "true"); switch_channel_set_variable(channel, "user_pin_authenticated_user", myid); - if (!zstr(myid)) switch_ivr_set_user(session, myid); + if (!zstr(myid) && !zstr(domain_name)) { + char *account = switch_core_session_sprintf(session, "%s@%s", myid, domain_name); + switch_ivr_set_user(session, account); + } } else { switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE); } @@ -3490,7 +3505,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p switch_safe_free(file_path); - if (switch_channel_ready(channel)) { + if (switch_channel_ready(channel) && vm_enabled) { status = switch_ivr_phrase_macro(session, VM_GOODBYE_MACRO, NULL, NULL, NULL); } @@ -3523,12 +3538,12 @@ SWITCH_STANDARD_APP(voicemail_function) if (argv[x] && !strcasecmp(argv[x], "check")) { check++; x++; - } else if (argv[x] && !strcasecmp(argv[x], "auth")) { - auth++; - x++; } else if (argv[x] && !strcasecmp(argv[x], "auth_only")) { auth = 2; x++; + } else if (argv[x] && !strcasecmp(argv[x], "auth")) { + auth++; + x++; } else { break; } @@ -3572,7 +3587,7 @@ SWITCH_STANDARD_APP(voicemail_function) return; } - if (check) { + if (check || auth == 2) { if (argv[x]) { uuid = argv[x++]; } @@ -3793,6 +3808,9 @@ static void actual_message_query_handler(switch_event_t *event) if (globals.message_query_exact_match) { if ((profile = (vm_profile_t *) switch_core_hash_find(globals.profile_hash, domain))) { parse_profile(); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "Cound not find a profile for domain: [%s] Returning 0 messages\nWhen message-query-exact-match is enabled you must have a dedicated vm profile per distinct domain name you wish to use.\n", domain); } } else { for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { @@ -4896,6 +4914,8 @@ SWITCH_STANDARD_API(vm_fsdb_pref_greeting_set_function) profile->name, SWITCH_PATH_SEPARATOR, domain, SWITCH_PATH_SEPARATOR, id); char *final_file_path = switch_core_sprintf(pool, "%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, slot, profile->file_ext); + switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool); + if (file_path) { if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR Filename doesn't exist\n"); @@ -4990,6 +5010,8 @@ SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function) profile->name, SWITCH_PATH_SEPARATOR, domain, SWITCH_PATH_SEPARATOR, id); char *final_file_path = switch_core_sprintf(pool, "%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext); + switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool); + if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR Filename doesn't exist\n"); profile_rwunlock(profile); @@ -4997,6 +5019,7 @@ SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function) } switch_file_rename(file_path, final_file_path, pool); + if (atoi(res) == 0) { sql = switch_mprintf("INSERT INTO voicemail_prefs (username, domain, name_path) VALUES('%q', '%q', '%q')", id, domain, final_file_path); } else { diff --git a/src/mod/applications/mod_voicemail_ivr/config.h b/src/mod/applications/mod_voicemail_ivr/config.h index f94fdb6f54..9d3b63d584 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 a277140985..31f95732b5 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/applications/mod_voicemail_ivr/menu.h b/src/mod/applications/mod_voicemail_ivr/menu.h index 6a49dedcba..1f91b658f6 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, 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 a20dfe806d..c8e9ca0868 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/asr_tts/mod_pocketsphinx/Makefile b/src/mod/asr_tts/mod_pocketsphinx/Makefile index ca72c6b0a4..e3d795fb60 100644 --- a/src/mod/asr_tts/mod_pocketsphinx/Makefile +++ b/src/mod/asr_tts/mod_pocketsphinx/Makefile @@ -12,35 +12,43 @@ POCKETSPHINX_LA=$(POCKETSPHINX_BUILDDIR)/src/libpocketsphinx/libpocketsphinx.la SPHINXMODEL=communicator_semi_6000_20080321 LOCAL_CFLAGS=-I$(SPHINXBASE_DIR)/include -I$(POCKETSPHINX_DIR)/include -LOCAL_LIBADD=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2) +LOCAL_LIBADD=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2) BASE=../../../.. include $(BASE)/build/modmake.rules +mod_pocketsphinx.lo: $(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2) + $(SPHINXBASE_DIR): $(GETLIB) $(SPHINXBASE).tar.gz -$(SPHINXBASE_BUILDDIR)/buildstamp: $(SPHINXBASE_DIR) +$(SPHINXBASE_BUILDDIR)/Makefile: $(SPHINXBASE_DIR) mkdir -p $(SPHINXBASE_BUILDDIR) - test -f $(SPHINXBASE_BUILDDIR)/Makefile || (cd $(SPHINXBASE_BUILDDIR) && $(DEFAULT_VARS) $(SPHINXBASE_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(SPHINXBASE_DIR) --without-python CFLAGS=) - test -f $(SPHINXBASE_BUILDDIR)/buildstamp || (touch $(SPHINXBASE_BUILDDIR)/buildstamp) + (cd $(SPHINXBASE_BUILDDIR) && $(DEFAULT_VARS) $(SPHINXBASE_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(SPHINXBASE_DIR) --without-python CFLAGS=) + $(TOUCH_TARGET) + +$(SPHINXBASE_BUILDDIR)/buildstamp: $(SPHINXBASE_BUILDDIR)/Makefile + (cd $(SPHINXBASE_BUILDDIR) && $(MAKE)) + touch $@ $(SPHINXBASE_LA): $(SPHINXBASE_BUILDDIR)/buildstamp - cd $(SPHINXBASE_BUILDDIR) && $(MAKE) + $(TOUCH_TARGET) + +$(SPHINXBASE_LA2): $(SPHINXBASE_BUILDDIR)/buildstamp $(TOUCH_TARGET) $(POCKETSPHINX_DIR): $(GETLIB) $(POCKETSPHINX).tar.gz -$(POCKETSPHINX_BUILDDIR)/Makefile: $(POCKETSPHINX_DIR) $(SPHINXBASE_LA) +$(POCKETSPHINX_BUILDDIR)/Makefile: $(POCKETSPHINX_DIR) $(SPHINXBASE_LA) $(SPHINXBASE_LA2) mkdir -p $(POCKETSPHINX_BUILDDIR) - cd $(POCKETSPHINX_BUILDDIR) && $(DEFAULT_VARS) $(POCKETSPHINX_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(POCKETSPHINX_DIR) --without-python --with-sphinxbase=$(SPHINXBASE_DIR) --with-sphinxbase-build=$(SPHINXBASE_BUILDDIR) CFLAGS= + (cd $(POCKETSPHINX_BUILDDIR) && $(DEFAULT_VARS) $(POCKETSPHINX_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(POCKETSPHINX_DIR) --without-python --with-sphinxbase=$(SPHINXBASE_DIR) --with-sphinxbase-build=$(SPHINXBASE_BUILDDIR) CFLAGS=) $(TOUCH_TARGET) $(POCKETSPHINX_BUILDDIR)/buildstamp: $(POCKETSPHINX_BUILDDIR)/Makefile - test -f $(POCKETSPHINX_BUILDDIR)/buildstamp || touch $(POCKETSPHINX_BUILDDIR)/buildstamp + (cd $(POCKETSPHINX_BUILDDIR) && $(MAKE)) + touch $@ -$(POCKETSPHINX_LA): $(POCKETSPHINX_BUILDDIR)/Makefile - cd $(POCKETSPHINX_BUILDDIR) && $(MAKE) +$(POCKETSPHINX_LA): $(POCKETSPHINX_BUILDDIR)/buildstamp $(TOUCH_TARGET) $(DESTDIR)$(grammardir)/model: @@ -52,6 +60,7 @@ $(DESTDIR)$(grammardir)/model/communicator: cp -rp $(switch_srcdir)/libs/Communicator_semi_40.cd_semi_6000/* $(DESTDIR)$(grammardir)/model/communicator dictionary: - @cp -f $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic + @install -m0644 $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic local_install: $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary + diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index a4dde5189d..aaf8f8764a 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2009-2010, Anthony Minessale II + * Copyright (C) 2009-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -17,7 +17,7 @@ * The Original Code is FreeSWITCH mod_unimrcp * * The Initial Developer of the Original Code is - * Christopher M. Rienzo + * Christopher M. Rienzo * * Portions created by the Initial Developer are Copyright (C) * the Initial Developer. All Rights Reserved. @@ -25,9 +25,11 @@ * Contributor(s): * * Brian West - * Christopher M. Rienzo + * Christopher M. Rienzo * Luke Dashjr (OpenMethods, LLC) * + * Maintainer: Christopher M. Rienzo + * * mod_unimrcp.c -- UniMRCP module (MRCP client) * */ diff --git a/src/mod/codecs/mod_h26x/mod_h26x.c b/src/mod/codecs/mod_h26x/mod_h26x.c index 368edb98f2..083dc064c9 100644 --- a/src/mod/codecs/mod_h26x/mod_h26x.c +++ b/src/mod/codecs/mod_h26x/mod_h26x.c @@ -84,7 +84,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_CODEC(codec_interface, "H.264 Video (passthru)"); switch_core_codec_add_implementation(pool, codec_interface, - SWITCH_CODEC_TYPE_VIDEO, 99, "H264", NULL, 90000, 90000, 0, + SWITCH_CODEC_TYPE_VIDEO, 97, "H264", NULL, 90000, 90000, 0, 0, 0, 0, 0, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy); SWITCH_ADD_CODEC(codec_interface, "H.263 Video (passthru)"); switch_core_codec_add_implementation(pool, codec_interface, diff --git a/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c b/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c index 2be9533936..4cc3c2de79 100644 --- a/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c +++ b/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c @@ -578,8 +578,10 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec if (sess->encoder.rtp_queue[sess->encoder.queue_rindex].datalen) { /* if there is something where we want to write, we're dropping it */ sess->encoder.rxdiscarded++; +#if 0 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding encoded frame of %d bytes from RTP session %lu, windex = %d, rindex = %d\n", sess->encoder.rtp_queue[sess->encoder.queue_rindex].datalen, sess->sessid, sess->encoder.queue_windex, sess->encoder.queue_rindex); +#endif SAFE_INDEX_INC(sess->encoder.rtp_queue, sess->encoder.queue_rindex); sess->encoder.queue_size--; } @@ -766,8 +768,10 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses if (sess->decoder.rtp_queue[sess->decoder.queue_rindex].datalen) { /* if there is something where we want to write, we're dropping it */ sess->decoder.rxdiscarded++; +#if 0 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding decoded frame of %d bytes from RTP session %lu, windex = %d, rindex = %d\n", sess->decoder.rtp_queue[sess->decoder.queue_rindex].datalen, sess->sessid, sess->decoder.queue_windex, sess->decoder.queue_rindex); +#endif SAFE_INDEX_INC(sess->decoder.rtp_queue, sess->decoder.queue_rindex); sess->decoder.queue_size--; } diff --git a/src/mod/codecs/mod_silk/mod_silk.c b/src/mod/codecs/mod_silk/mod_silk.c index 6a090bef0d..5c32b72969 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * 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 new file mode 100644 index 0000000000..220229037a --- /dev/null +++ b/src/mod/codecs/mod_speex/conf/autoload_configs/speex.conf.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/codecs/mod_speex/mod_speex.c b/src/mod/codecs/mod_speex/mod_speex.c index ab9a044b53..8416686373 100644 --- a/src/mod/codecs/mod_speex/mod_speex.c +++ b/src/mod/codecs/mod_speex/mod_speex.c @@ -24,7 +24,7 @@ * Contributor(s): * * Anthony Minessale II - * Chris Rienzo + * Christopher M. Rienzo * * * mod_speex.c -- Speex Codec Module diff --git a/src/mod/codecs/mod_voipcodecs/Makefile b/src/mod/codecs/mod_voipcodecs/Makefile index 5b81d25f66..113d5ab77b 100644 --- a/src/mod/codecs/mod_voipcodecs/Makefile +++ b/src/mod/codecs/mod_voipcodecs/Makefile @@ -1,7 +1,7 @@ BASE=../../../.. -TIFF_DIR=$(switch_srcdir)/libs/tiff-3.8.2 -TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-3.8.2 +TIFF_DIR=$(switch_srcdir)/libs/tiff-4.0.2 +TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-4.0.2 TIFF_LA=$(TIFF_BUILDDIR)/libtiff/libtiff.la SPANDSP_DIR=$(switch_srcdir)/libs/spandsp diff --git a/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.2008.vcproj b/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.2008.vcproj index 779c3647b7..94dab696eb 100644 --- a/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.2008.vcproj +++ b/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.2008.vcproj @@ -42,7 +42,7 @@ /> + * + * 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 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): + * + * Anthony Minessale II + * Seven Du + * + * mod_vp8.c -- VP8 Video Codec + * + */ + +#include + +SWITCH_MODULE_LOAD_FUNCTION(mod_vp8_load); +SWITCH_MODULE_DEFINITION(mod_vp8, mod_vp8_load, NULL, NULL); + +static switch_status_t switch_vp8_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) +{ + int encoding, decoding; + + encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); + decoding = (flags & SWITCH_CODEC_FLAG_DECODE); + + if (!(encoding || decoding)) { + return SWITCH_STATUS_FALSE; + } else { + if (codec->fmtp_in) { + codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in); + } + return SWITCH_STATUS_SUCCESS; + } +} + +static switch_status_t switch_vp8_encode(switch_codec_t *codec, + switch_codec_t *other_codec, + void *decoded_data, + uint32_t decoded_data_len, + uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, + unsigned int *flag) +{ + return SWITCH_STATUS_FALSE; +} + +static switch_status_t switch_vp8_decode(switch_codec_t *codec, + switch_codec_t *other_codec, + void *encoded_data, + uint32_t encoded_data_len, + uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, + unsigned int *flag) +{ + return SWITCH_STATUS_FALSE; +} + +static switch_status_t switch_vp8_destroy(switch_codec_t *codec) +{ + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_MODULE_LOAD_FUNCTION(mod_vp8_load) +{ + switch_codec_interface_t *codec_interface; + /* 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); + /* indicate that the module should continue to be loaded */ + 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: + */ diff --git a/src/mod/endpoints/mod_dingaling/Makefile b/src/mod/endpoints/mod_dingaling/Makefile index f2ac13bb7a..c56dc228cb 100644 --- a/src/mod/endpoints/mod_dingaling/Makefile +++ b/src/mod/endpoints/mod_dingaling/Makefile @@ -9,7 +9,7 @@ IKS_LA=$(IKS_DIR)/src/libiksemel.la DING_DIR=$(BASE)/libs/libdingaling LOCAL_CFLAGS += -I$(DING_DIR)/src -I$(BASE)/libs/iksemel/include LOCAL_OBJS=$(DING_DIR)/src/libdingaling.o $(DING_DIR)/src/sha1.o $(IKS_LA) -LOCAL_SOURCES=$(DING_DIR)/src/libdingaling.c $(DING_DIR)/src/sha1.c +LOCAL_SOURCES=$(DING_DIR)/src/libdingaling.c $(DING_DIR)/src/sha1.c $(DING_DIR)/src/libdingaling.h LOCAL_LDFLAGS=$(LIBGNUTLS_LIBS) include $(BASE)/build/modmake.rules diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 735a68efc7..e6c2864617 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -33,8 +33,11 @@ #include #include +#define MDL_RTCP_DUR 5000 #define DL_CAND_WAIT 10000000 #define DL_CAND_INITIAL_WAIT 2000000 +//#define DL_CAND_WAIT 2000000 +//#define DL_CAND_INITIAL_WAIT 5000000 #define DL_EVENT_LOGIN_SUCCESS "dingaling::login_success" #define DL_EVENT_LOGIN_FAILURE "dingaling::login_failure" @@ -79,7 +82,8 @@ typedef enum { TFLAG_TERM = (1 << 21), TFLAG_TRANSPORT_ACCEPT = (1 << 22), TFLAG_READY = (1 << 23), - TFLAG_NAT_MAP = (1 << 24) + TFLAG_NAT_MAP = (1 << 24), + TFLAG_SECURE = (1 << 25) } TFLAGS; typedef enum { @@ -144,47 +148,103 @@ struct mdl_profile { }; typedef struct mdl_profile mdl_profile_t; -struct private_object { - unsigned int flags; +/*! \brief The required components to setup a jingle transport */ +typedef struct mdl_transport { + char *remote_ip; + switch_port_t remote_port; + + switch_port_t local_port; /*!< The real local port */ + switch_port_t adv_local_port; + unsigned int ssrc; + + char local_user[17]; + char local_pass[17]; + char *remote_user; + char *remote_pass; + int ptime; + int payload_count; + int restart_rtp; + switch_codec_t read_codec; switch_codec_t write_codec; + switch_frame_t read_frame; + + uint32_t codec_rate; + char *codec_name; + + switch_payload_t codec_num; + switch_payload_t r_codec_num; + + char *stun_ip; + uint16_t stun_port; + + switch_rtp_t *rtp_session; + ldl_transport_type_t type; + + int total; + int accepted; + + int ready; + + int codec_index; + + int vid_width; + int vid_height; + int vid_rate; + + switch_byte_t has_crypto; + int crypto_tag; + unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN]; + unsigned char remote_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN]; + switch_rtp_crypto_key_type_t crypto_send_type; + switch_rtp_crypto_key_type_t crypto_recv_type; + switch_rtp_crypto_key_type_t crypto_type; + + char *local_crypto_key; + char *remote_crypto_key; + + ldl_crypto_data_t *local_crypto_data; + +} mdl_transport_t; + + +struct private_object { + unsigned int flags; mdl_profile_t *profile; switch_core_session_t *session; + switch_channel_t *channel; + switch_caller_profile_t *caller_profile; unsigned short samprate; switch_mutex_t *mutex; const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS]; unsigned int num_codecs; - int codec_index; - switch_rtp_t *rtp_session; + + mdl_transport_t transports[LDL_TPORT_MAX+1]; + ldl_session_t *dlsession; - char *remote_ip; - switch_port_t local_port; - switch_port_t adv_local_port; - switch_port_t remote_port; - char local_user[17]; - char local_pass[17]; - char *remote_user; + char *us; char *them; unsigned int cand_id; unsigned int desc_id; unsigned int dc; + uint32_t timestamp_send; int32_t timestamp_recv; uint32_t last_read; - char *codec_name; - switch_payload_t codec_num; - switch_payload_t r_codec_num; - uint32_t codec_rate; + switch_time_t next_desc; switch_time_t next_cand; - char *stun_ip; + char *recip; char *dnis; - uint16_t stun_port; switch_mutex_t *flag_mutex; + + int read_count; + + }; struct rfc2833_digit { @@ -744,8 +804,12 @@ static void terminate_session(switch_core_session_t **session, int line, switch_ tech_pvt = switch_core_session_get_private(*session); - if (tech_pvt && tech_pvt->profile && tech_pvt->profile->ip && tech_pvt->local_port) { - switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->local_port); + if (tech_pvt && tech_pvt->profile && tech_pvt->profile->ip && tech_pvt->transports[LDL_TPORT_RTP].local_port) { + switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->transports[LDL_TPORT_RTP].local_port); + } + + if (tech_pvt && tech_pvt->profile && tech_pvt->profile->ip && tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port) { + switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port); } if (!switch_core_session_running(*session) && (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY))) { @@ -811,16 +875,35 @@ static void dl_logger(char *file, const char *func, int line, int level, char *f static int get_codecs(struct private_object *tech_pvt) { + char *codec_string = NULL; + const char *var; + char *codec_order[SWITCH_MAX_CODECS]; + int codec_order_last; + char **codec_order_p = NULL; + + switch_assert(tech_pvt != NULL); switch_assert(tech_pvt->session != NULL); if (!tech_pvt->num_codecs) { - if (globals.codec_string) { + + if ((var = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { + codec_string = (char *)var; + codec_order_last = switch_separate_string(codec_string, ',', codec_order, SWITCH_MAX_CODECS); + codec_order_p = codec_order; + } else { + codec_string = globals.codec_string; + codec_order_last = globals.codec_order_last; + codec_order_p = globals.codec_order; + } + + if (codec_string) { if ((tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs, - SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last)) <= 0) { + SWITCH_MAX_CODECS, codec_order_p, codec_order_last)) <= 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n"); return 0; } + } else if (((tech_pvt->num_codecs = switch_loadable_module_get_codecs(tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n"); return 0; @@ -864,76 +947,251 @@ static void handle_thread_launch(ldl_handle_t *handle) } -static int activate_rtp(struct private_object *tech_pvt) +switch_status_t mdl_build_crypto(struct private_object *tech_pvt, ldl_transport_type_t ttype, + int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction) +{ + unsigned char b64_key[512] = ""; + const char *type_str; + unsigned char *key; + char *p; + + + if (!switch_test_flag(tech_pvt, TFLAG_SECURE)) { + return SWITCH_STATUS_SUCCESS; + } + + + if (type == AES_CM_128_HMAC_SHA1_80) { + type_str = SWITCH_RTP_CRYPTO_KEY_80; + } else { + type_str = SWITCH_RTP_CRYPTO_KEY_32; + } + + if (direction == SWITCH_RTP_CRYPTO_SEND) { + key = tech_pvt->transports[ttype].local_raw_key; + } else { + key = tech_pvt->transports[ttype].remote_raw_key; + + } + + switch_rtp_get_random(key, SWITCH_RTP_KEY_LEN); + switch_b64_encode(key, SWITCH_RTP_KEY_LEN, b64_key, sizeof(b64_key)); + p = strrchr((char *) b64_key, '='); + + while (p && *p && *p == '=') { + *p-- = '\0'; + } + + tech_pvt->transports[ttype].local_crypto_key = switch_core_session_sprintf(tech_pvt->session, "%d %s inline:%s", index, type_str, b64_key); + tech_pvt->transports[ttype].local_crypto_data = switch_core_session_alloc(tech_pvt->session, sizeof(ldl_crypto_data_t)); + tech_pvt->transports[ttype].local_crypto_data->tag = switch_core_session_sprintf(tech_pvt->session, "%d", index); + tech_pvt->transports[ttype].local_crypto_data->suite = switch_core_session_strdup(tech_pvt->session, type_str); + tech_pvt->transports[ttype].local_crypto_data->key = switch_core_session_sprintf(tech_pvt->session, "inline:%s", (char *)b64_key); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Local Key [%s]\n", tech_pvt->transports[ttype].local_crypto_key); + + tech_pvt->transports[ttype].crypto_type = AES_CM_128_NULL_AUTH; + + + return SWITCH_STATUS_SUCCESS; +} + + +static switch_status_t mdl_add_crypto(struct private_object *tech_pvt, + ldl_transport_type_t ttype, const char *key_str, switch_rtp_crypto_direction_t direction) +{ + unsigned char key[SWITCH_RTP_MAX_CRYPTO_LEN]; + switch_rtp_crypto_key_type_t type; + char *p; + + + p = strchr(key_str, ' '); + + if (p && *p && *(p + 1)) { + p++; + if (!strncasecmp(p, SWITCH_RTP_CRYPTO_KEY_32, strlen(SWITCH_RTP_CRYPTO_KEY_32))) { + type = AES_CM_128_HMAC_SHA1_32; + } else if (!strncasecmp(p, SWITCH_RTP_CRYPTO_KEY_80, strlen(SWITCH_RTP_CRYPTO_KEY_80))) { + type = AES_CM_128_HMAC_SHA1_80; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Parse Error near [%s]\n", p); + goto bad; + } + + p = strchr(p, ' '); + if (p && *p && *(p + 1)) { + p++; + if (strncasecmp(p, "inline:", 7)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Parse Error near [%s]\n", p); + goto bad; + } + + p += 7; + switch_b64_decode(p, (char *) key, sizeof(key)); + + if (direction == SWITCH_RTP_CRYPTO_SEND) { + tech_pvt->transports[ttype].crypto_send_type = type; + memcpy(tech_pvt->transports[ttype].local_raw_key, key, SWITCH_RTP_KEY_LEN); + } else { + tech_pvt->transports[ttype].crypto_recv_type = type; + memcpy(tech_pvt->transports[ttype].remote_raw_key, key, SWITCH_RTP_KEY_LEN); + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE, + "%s Setting %s crypto key\n", ldl_transport_type_str(ttype), switch_core_session_get_name(tech_pvt->session)); + tech_pvt->transports[ttype].has_crypto++; + + + return SWITCH_STATUS_SUCCESS; + } + + } + + bad: + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Error!\n"); + return SWITCH_STATUS_FALSE; + +} + +static void try_secure(struct private_object *tech_pvt, ldl_transport_type_t ttype) +{ + + if (!switch_test_flag(tech_pvt, TFLAG_SECURE)) { + return; + } + + + if (tech_pvt->transports[ttype].crypto_recv_type) { + tech_pvt->transports[ttype].crypto_type = tech_pvt->transports[ttype].crypto_recv_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); + + + switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session, + SWITCH_RTP_CRYPTO_RECV, tech_pvt->transports[ttype].crypto_tag, + tech_pvt->transports[ttype].crypto_type, + tech_pvt->transports[ttype].remote_raw_key, SWITCH_RTP_KEY_LEN); + + switch_channel_set_variable(tech_pvt->channel, "jingle_secure_audio_confirmed", "true"); + + 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)); + + //} + +} + + + +static int activate_audio_rtp(struct private_object *tech_pvt) { switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session); const char *err; - int ms = 0; + int ms = tech_pvt->transports[LDL_TPORT_RTP].ptime; switch_rtp_flag_t flags; + int locked = 0; + int r = 1; - if (switch_rtp_ready(tech_pvt->rtp_session)) { + + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { return 1; } - if (!(tech_pvt->remote_ip && tech_pvt->remote_port)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "No valid candidates received!\n"); + if (!(tech_pvt->transports[LDL_TPORT_RTP].remote_ip && tech_pvt->transports[LDL_TPORT_RTP].remote_port)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "No valid rtp candidates received!\n"); return 0; } - if (switch_core_codec_init(&tech_pvt->read_codec, - tech_pvt->codec_name, - NULL, - tech_pvt->codec_rate, - ms, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Can't load codec?\n"); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return 0; + if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_RTP].read_codec)) { + locked = 1; + switch_mutex_lock(tech_pvt->transports[LDL_TPORT_RTP].read_codec.mutex); + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { + switch_rtp_kill_socket(tech_pvt->transports[LDL_TPORT_RTP].rtp_session); + switch_rtp_destroy(&tech_pvt->transports[LDL_TPORT_RTP].rtp_session); + } + + + } else { + if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_RTP].read_codec, + tech_pvt->transports[LDL_TPORT_RTP].codec_name, + NULL, + tech_pvt->transports[LDL_TPORT_RTP].codec_rate, + ms, + 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Can't load codec?\n"); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + r = 0; + goto end; + } + tech_pvt->transports[LDL_TPORT_RTP].read_frame.rate = tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_second; + tech_pvt->transports[LDL_TPORT_RTP].read_frame.codec = &tech_pvt->transports[LDL_TPORT_RTP].read_codec; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n", + tech_pvt->transports[LDL_TPORT_RTP].codec_name, (int) tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_second); + + if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_RTP].write_codec, + tech_pvt->transports[LDL_TPORT_RTP].codec_name, + NULL, + tech_pvt->transports[LDL_TPORT_RTP].codec_rate, + ms, + 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Can't load codec?\n"); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + r = 0; + goto end; + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n", + tech_pvt->transports[LDL_TPORT_RTP].codec_name, (int) tech_pvt->transports[LDL_TPORT_RTP].write_codec.implementation->samples_per_second); + + switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->transports[LDL_TPORT_RTP].read_codec); + switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->transports[LDL_TPORT_RTP].write_codec); } - tech_pvt->read_frame.rate = tech_pvt->read_codec.implementation->samples_per_second; - tech_pvt->read_frame.codec = &tech_pvt->read_codec; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n", - tech_pvt->codec_name, (int) tech_pvt->read_codec.implementation->samples_per_second); - - if (switch_core_codec_init(&tech_pvt->write_codec, - tech_pvt->codec_name, - NULL, - tech_pvt->codec_rate, - ms, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Can't load codec?\n"); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return 0; - } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n", - tech_pvt->codec_name, (int) tech_pvt->write_codec.implementation->samples_per_second); - - switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec); - switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec); - - if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) { + if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->transports[LDL_TPORT_RTP].remote_ip, tech_pvt->profile->local_network)) { switch_port_t external_port = 0; - switch_nat_add_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE); + switch_nat_add_mapping((switch_port_t) tech_pvt->transports[LDL_TPORT_RTP].local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE); if (external_port) { - tech_pvt->adv_local_port = external_port; + tech_pvt->transports[LDL_TPORT_RTP].adv_local_port = external_port; switch_set_flag(tech_pvt, TFLAG_NAT_MAP); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "NAT mapping returned 0. Run freeswitch with -nonat since it's not working right.\n"); } } - if (tech_pvt->adv_local_port != tech_pvt->local_port) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d(%d) -> %s:%d\n", tech_pvt->profile->ip, - tech_pvt->local_port, tech_pvt->adv_local_port, tech_pvt->remote_ip, tech_pvt->remote_port); + if (tech_pvt->transports[LDL_TPORT_RTP].adv_local_port != tech_pvt->transports[LDL_TPORT_RTP].local_port) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP AUDIO RTP %s:%d(%d) -> %s:%d codec: %s(%d) %dh %di\n", + tech_pvt->profile->ip, + tech_pvt->transports[LDL_TPORT_RTP].local_port, + tech_pvt->transports[LDL_TPORT_RTP].adv_local_port, + tech_pvt->transports[LDL_TPORT_RTP].remote_ip, + tech_pvt->transports[LDL_TPORT_RTP].remote_port, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->iananame, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->ianacode, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->microseconds_per_packet + + ); } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip, - tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP AUDIO RTP %s:%d -> %s:%d codec: %s(%d) %dh %di\n", + tech_pvt->profile->ip, + tech_pvt->transports[LDL_TPORT_RTP].local_port, + tech_pvt->transports[LDL_TPORT_RTP].remote_ip, + tech_pvt->transports[LDL_TPORT_RTP].remote_port, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->iananame, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->ianacode, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->microseconds_per_packet + ); } flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG; @@ -947,128 +1205,390 @@ static int activate_rtp(struct private_object *tech_pvt) flags &= ~SWITCH_RTP_FLAG_AUTOADJ; } - if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip, - tech_pvt->local_port, - tech_pvt->remote_ip, - tech_pvt->remote_port, - tech_pvt->codec_num, - tech_pvt->read_codec.implementation->samples_per_packet, - tech_pvt->read_codec.implementation->microseconds_per_packet, - flags, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) { + if (!(tech_pvt->transports[LDL_TPORT_RTP].rtp_session = switch_rtp_new(tech_pvt->profile->ip, + tech_pvt->transports[LDL_TPORT_RTP].local_port, + tech_pvt->transports[LDL_TPORT_RTP].remote_ip, + tech_pvt->transports[LDL_TPORT_RTP].remote_port, + tech_pvt->transports[LDL_TPORT_RTP].codec_num, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet, + tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->microseconds_per_packet, + flags, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return 0; + r = 0; + goto end; } else { uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0; uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0; uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1; - switch_rtp_activate_ice(tech_pvt->rtp_session, tech_pvt->remote_user, tech_pvt->local_user); + + switch_rtp_set_ssrc(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_RTP].ssrc); + + if (tech_pvt->transports[LDL_TPORT_RTCP].remote_port) { + switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, MDL_RTCP_DUR, + tech_pvt->transports[LDL_TPORT_RTCP].remote_port); + + } + + try_secure(tech_pvt, LDL_TPORT_RTP); + + switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, + tech_pvt->transports[LDL_TPORT_RTP].remote_user, + tech_pvt->transports[LDL_TPORT_RTP].local_user, + tech_pvt->transports[LDL_TPORT_RTP].remote_pass); + if ((vad_in && inb) || (vad_out && !inb)) { - if (switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING) != SWITCH_STATUS_SUCCESS) { + if (switch_rtp_enable_vad(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, tech_pvt->session, &tech_pvt->transports[LDL_TPORT_RTP].read_codec, SWITCH_VAD_FLAG_TALKING) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VAD ERROR %s\n", err); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return 0; + r = 0; + goto end; } switch_set_flag_locked(tech_pvt, TFLAG_VAD); } - switch_rtp_set_cng_pt(tech_pvt->rtp_session, 13); - switch_rtp_set_telephony_event(tech_pvt->rtp_session, 101); + //switch_rtp_set_cng_pt(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, 13); + switch_rtp_set_telephony_event(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, 101); + + if (tech_pvt->transports[LDL_TPORT_RTCP].remote_port) { + switch_rtp_activate_rtcp_ice(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, + tech_pvt->transports[LDL_TPORT_RTCP].remote_user, + tech_pvt->transports[LDL_TPORT_RTCP].local_user, + tech_pvt->transports[LDL_TPORT_RTCP].remote_pass); + + } + + + } - return 1; + end: + + if (locked) { + switch_mutex_unlock(tech_pvt->transports[LDL_TPORT_RTP].read_codec.mutex); + } + + return r; +} + + +static int activate_video_rtp(struct private_object *tech_pvt) +{ + switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session); + const char *err; + int ms = 0; + switch_rtp_flag_t flags; + int r = 1, locked = 0; + + + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session)) { + r = 1; goto end; + } + + if (!(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip && tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_port)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "No valid video_rtp candidates received!\n"); + r = 0; goto end; + } + + if (zstr(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "No valid video_rtp codecs received!\n"); + r = 0; goto end; + } + + if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec)) { + locked = 1; + switch_mutex_lock(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.mutex); + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session)) { + switch_rtp_kill_socket(tech_pvt->transports[LDL_TPORT_RTP].rtp_session); + switch_rtp_destroy(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session); + } + + + + + + } else { + if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name, + NULL, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_rate, + ms, + 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Can't load codec?\n"); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + r = 0; goto end; + } + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.rate = tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->samples_per_second; + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.codec = &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n", + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name, (int) tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->samples_per_second); + + if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].write_codec, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name, + NULL, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_rate, + ms, + 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Can't load codec?\n"); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + r = 0; goto end; + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n", + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name, (int) tech_pvt->transports[LDL_TPORT_VIDEO_RTP].write_codec.implementation->samples_per_second); + + switch_core_session_set_video_read_codec(tech_pvt->session, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec); + switch_core_session_set_video_write_codec(tech_pvt->session, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].write_codec); + } + + if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip, tech_pvt->profile->local_network)) { + switch_port_t external_port = 0; + switch_nat_add_mapping((switch_port_t) tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE); + + if (external_port) { + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port = external_port; + switch_set_flag(tech_pvt, TFLAG_NAT_MAP); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "NAT mapping returned 0. Run freeswitch with -nonat since it's not working right.\n"); + } + } + + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port != tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP VIDEO RTP %s:%d(%d) -> %s:%d codec: %s(%d) %dh %di\n", + tech_pvt->profile->ip, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->iananame, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->ianacode, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->samples_per_packet, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->microseconds_per_packet + + ); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP VIDEO RTP %s:%d -> %s:%d codec: %s(%d) %dh %di\n", + tech_pvt->profile->ip, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->iananame, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->ianacode, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->samples_per_packet, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->microseconds_per_packet + ); + } + + + flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_VIDEO; + + + if (switch_true(switch_channel_get_variable(channel, "disable_rtp_auto_adjust"))) { + flags &= ~SWITCH_RTP_FLAG_AUTOADJ; + } + + if (!(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session = switch_rtp_new(tech_pvt->profile->ip, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_port, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_num, + 1, + 90000, + flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session)))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + r = 0; goto end; + } else { + switch_rtp_set_ssrc(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ssrc); + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_port) { + switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, MDL_RTCP_DUR, + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_port); + } + try_secure(tech_pvt, LDL_TPORT_VIDEO_RTP); + + + switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_user, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_user, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_pass); + switch_channel_set_flag(channel, CF_VIDEO); + //switch_rtp_set_default_payload(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].r_codec_num); + + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_port) { + + switch_rtp_activate_rtcp_ice(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_user, + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].local_user, + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_pass); + } + + + + } + + end: + if (locked) { + switch_mutex_unlock(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.mutex); + } + + return r; } -static int do_candidates(struct private_object *tech_pvt, int force) +static int activate_rtp(struct private_object *tech_pvt) +{ + int r = 0; + + if (tech_pvt->transports[LDL_TPORT_RTP].ready) { + r += activate_audio_rtp(tech_pvt); + } + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ready) { + r += activate_video_rtp(tech_pvt); + } + + return r; +} + + +static int do_tport_candidates(struct private_object *tech_pvt, ldl_transport_type_t ttype, ldl_candidate_t *cand, int force) { switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session); + char *advip = tech_pvt->profile->extip ? tech_pvt->profile->extip : tech_pvt->profile->ip; + char *err = NULL, *address = NULL; + + if (!force && tech_pvt->transports[ttype].ready) { + return 0; + } + + if (switch_test_flag(tech_pvt, TFLAG_LANADDR)) { + advip = tech_pvt->profile->ip; + } + address = advip; + + if(address && !strncasecmp(address, "host:", 5)) { + address = address + 5; + } + + memset(cand, 0, sizeof(*cand)); + switch_stun_random_string(tech_pvt->transports[ttype].local_user, 16, NULL); + switch_stun_random_string(tech_pvt->transports[ttype].local_pass, 16, NULL); + + cand->port = tech_pvt->transports[ttype].adv_local_port; + cand->address = address; + + if (!strncasecmp(advip, "stun:", 5)) { + char *stun_ip = advip + 5; + + if (tech_pvt->transports[ttype].stun_ip) { + cand->address = tech_pvt->transports[ttype].stun_ip; + cand->port = tech_pvt->transports[ttype].stun_port; + } else { + if (!stun_ip) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER!\n"); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return 0; + } + + cand->address = tech_pvt->profile->ip; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand->address, + cand->port); + if (switch_stun_lookup + (&cand->address, &cand->port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &err, + switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, + SWITCH_STUN_DEFAULT_PORT, err); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return 0; + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand->address, cand->port); + } + cand->type = "stun"; + tech_pvt->transports[ttype].stun_ip = switch_core_session_strdup(tech_pvt->session, cand->address); + tech_pvt->transports[ttype].stun_port = cand->port; + } else { + cand->type = "local"; + } + + cand->name = (char *)ldl_transport_type_str(ttype); + cand->username = tech_pvt->transports[ttype].local_user; + cand->password = tech_pvt->transports[ttype].local_pass; + cand->pref = 1; + cand->protocol = "udp"; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, + "Send %s Candidate %s:%d [%s]\n", ldl_transport_type_str(ttype), cand->address, cand->port, + cand->username); + + + + tech_pvt->transports[ttype].ready = 1; + + return 1; +} + + +static int do_candidates(struct private_object *tech_pvt, int force) +{ + ldl_candidate_t cand[4] = {{0}}; + int idx = 0; if (switch_test_flag(tech_pvt, TFLAG_DO_CAND)) { return 1; } tech_pvt->next_cand += DL_CAND_WAIT; - if (switch_test_flag(tech_pvt, TFLAG_BYE)) { + if (switch_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->dlsession) { return 0; } switch_set_flag_locked(tech_pvt, TFLAG_DO_CAND); - if (force || !switch_test_flag(tech_pvt, TFLAG_RTP_READY)) { - ldl_candidate_t cand[1]; - char *advip = tech_pvt->profile->extip ? tech_pvt->profile->extip : tech_pvt->profile->ip; - char *err = NULL, *address = NULL; - - memset(cand, 0, sizeof(cand)); - switch_stun_random_string(tech_pvt->local_user, 16, NULL); - switch_stun_random_string(tech_pvt->local_pass, 16, NULL); - - if (switch_test_flag(tech_pvt, TFLAG_LANADDR)) { - advip = tech_pvt->profile->ip; - } - address = advip; - - if(address && !strncasecmp(address, "host:", 5)) { - address = address + 5; - } - - cand[0].port = tech_pvt->adv_local_port; - cand[0].address = address; - - if (!strncasecmp(advip, "stun:", 5)) { - char *stun_ip = advip + 5; - - if (tech_pvt->stun_ip) { - cand[0].address = tech_pvt->stun_ip; - cand[0].port = tech_pvt->stun_port; - } else { - if (!stun_ip) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER!\n"); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return 0; - } - - cand[0].address = tech_pvt->profile->ip; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address, - cand[0].port); - if (switch_stun_lookup - (&cand[0].address, &cand[0].port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &err, - switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, - SWITCH_STUN_DEFAULT_PORT, err); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return 0; - } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address, cand[0].port); - } - cand[0].type = "stun"; - tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, cand[0].address); - tech_pvt->stun_port = cand[0].port; - } else { - cand[0].type = "local"; - } - - cand[0].name = "rtp"; - cand[0].username = tech_pvt->local_user; - cand[0].password = tech_pvt->local_pass; - cand[0].pref = 1; - cand[0].protocol = "udp"; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, - cand[0].username); + idx += do_tport_candidates(tech_pvt, LDL_TPORT_RTP, &cand[idx], force); + idx += do_tport_candidates(tech_pvt, LDL_TPORT_RTCP, &cand[idx], force); + idx += do_tport_candidates(tech_pvt, LDL_TPORT_VIDEO_RTP, &cand[idx], force); + idx += do_tport_candidates(tech_pvt, LDL_TPORT_VIDEO_RTCP, &cand[idx], force); + if (idx && cand[0].name) { if (ldl_session_gateway(tech_pvt->dlsession) && switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { - tech_pvt->cand_id = ldl_session_transport(tech_pvt->dlsession, cand, 1); + tech_pvt->cand_id = ldl_session_transport(tech_pvt->dlsession, cand, idx); } else { - tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1); + tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, idx); } + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u rtp candidates.\n", + tech_pvt->transports[LDL_TPORT_RTP].accepted, tech_pvt->transports[LDL_TPORT_RTP].total); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u rtcp candidates.\n", + tech_pvt->transports[LDL_TPORT_RTCP].accepted, tech_pvt->transports[LDL_TPORT_RTCP].total); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u video_rtp candidates\n", + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].accepted, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].total); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u video_rctp candidates\n", + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].accepted, tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].total); + + + + if ((tech_pvt->transports[LDL_TPORT_RTP].ready && tech_pvt->transports[LDL_TPORT_RTCP].ready)) { switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT); switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY); } + + switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND); return 1; + } + + + static char *lame(char *in) { if (!strncasecmp(in, "ilbc", 4)) { @@ -1078,25 +1598,124 @@ 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; + int dft_audio = -1, dft_video = -1; + + memset(payloads, 0, sizeof(payloads)); + + for (idx = 0; idx < tech_pvt->num_codecs && (dft_audio == -1 || dft_video == -1); idx++) { + if (dft_audio < 0 && tech_pvt->codecs[idx]->codec_type == SWITCH_CODEC_TYPE_AUDIO) { + dft_audio = idx; + } + if (dft_video < 0 && tech_pvt->codecs[idx]->codec_type == SWITCH_CODEC_TYPE_VIDEO) { + dft_video = idx; + } + } + + if (dft_audio == -1 && dft_video == -1) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Cannot find a codec.\n"); + return; + } + + idx = 0; + + payloads[0].type = LDL_TPORT_RTP; + if (tech_pvt->transports[LDL_TPORT_RTP].codec_index < 0) { + if (dft_audio > -1) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Don't have my audio codec yet here's one\n"); + tech_pvt->transports[LDL_TPORT_RTP].codec_name = lame(tech_pvt->codecs[dft_audio]->iananame); + tech_pvt->transports[LDL_TPORT_RTP].codec_num = tech_pvt->codecs[dft_audio]->ianacode; + tech_pvt->transports[LDL_TPORT_RTP].codec_rate = tech_pvt->codecs[dft_audio]->samples_per_second; + tech_pvt->transports[LDL_TPORT_RTP].r_codec_num = tech_pvt->codecs[dft_audio]->ianacode; + tech_pvt->transports[LDL_TPORT_RTP].codec_index = dft_audio; + + payloads[0].name = lame(tech_pvt->codecs[dft_audio]->iananame); + payloads[0].id = tech_pvt->codecs[dft_audio]->ianacode; + payloads[0].rate = tech_pvt->codecs[dft_audio]->samples_per_second; + payloads[0].bps = tech_pvt->codecs[dft_audio]->bits_per_second; + payloads[0].ptime = tech_pvt->codecs[dft_audio]->microseconds_per_packet / 1000; + idx++; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Don't have an audio codec.\n"); + } + } else { + payloads[0].name = lame(tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_RTP].codec_index]->iananame); + payloads[0].id = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_RTP].codec_index]->ianacode; + payloads[0].rate = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_RTP].codec_index]->samples_per_second; + payloads[0].bps = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_RTP].codec_index]->bits_per_second; + payloads[0].ptime = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_RTP].codec_index]->microseconds_per_packet / 1000; + idx++; + } + + + payloads[1].type = LDL_TPORT_VIDEO_RTP; + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index < 0) { + if (dft_video > -1) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Don't have my video codec yet here's one\n"); + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name = lame(tech_pvt->codecs[dft_video]->iananame); + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_num = tech_pvt->codecs[dft_video]->ianacode; + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_rate = tech_pvt->codecs[dft_video]->samples_per_second; + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].r_codec_num = tech_pvt->codecs[dft_video]->ianacode; + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index = dft_video; + + payloads[1].name = lame(tech_pvt->codecs[dft_video]->iananame); + payloads[1].id = tech_pvt->codecs[dft_video]->ianacode; + payloads[1].rate = tech_pvt->codecs[dft_video]->samples_per_second; + payloads[1].bps = tech_pvt->codecs[dft_video]->bits_per_second; + payloads[1].width = 600; + payloads[1].height = 400; + payloads[1].framerate = 30; + + idx++; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Don't have video codec.\n"); + } + } else { + payloads[1].name = lame(tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index]->iananame); + payloads[1].id = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index]->ianacode; + payloads[1].rate = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index]->samples_per_second; + payloads[1].bps = tech_pvt->codecs[tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index]->bits_per_second; + idx++; + } + + for(i = 0; i < idx; i++) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[i].name, payloads[i].rate); + } + + + if (!payloads[1].id && tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port) { + switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port); + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port = 0; + } + + + tech_pvt->desc_id = ldl_session_describe(tech_pvt->dlsession, payloads, idx, + switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT, + &tech_pvt->transports[LDL_TPORT_RTP].ssrc, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ssrc, + tech_pvt->transports[LDL_TPORT_RTP].local_crypto_data, + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_crypto_data); + + +} + static int do_describe(struct private_object *tech_pvt, int force) { - ldl_payload_t payloads[5]; if (!tech_pvt->session) { return 0; } - if (switch_test_flag(tech_pvt, TFLAG_DO_DESC)) { - return 1; - } - tech_pvt->next_desc += DL_CAND_WAIT; if (switch_test_flag(tech_pvt, TFLAG_BYE)) { return 0; } - memset(payloads, 0, sizeof(payloads)); + switch_set_flag_locked(tech_pvt, TFLAG_DO_CAND); if (!get_codecs(tech_pvt)) { terminate_session(&tech_pvt->session, __LINE__, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); @@ -1107,31 +1726,7 @@ static int do_describe(struct private_object *tech_pvt, int force) if (force || !switch_test_flag(tech_pvt, TFLAG_CODEC_READY)) { - if (tech_pvt->codec_index < 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Don't have my codec yet here's one\n"); - tech_pvt->codec_name = lame(tech_pvt->codecs[0]->iananame); - tech_pvt->codec_num = tech_pvt->codecs[0]->ianacode; - tech_pvt->codec_rate = tech_pvt->codecs[0]->samples_per_second; - tech_pvt->r_codec_num = tech_pvt->codecs[0]->ianacode; - tech_pvt->codec_index = 0; - - payloads[0].name = lame(tech_pvt->codecs[0]->iananame); - payloads[0].id = tech_pvt->codecs[0]->ianacode; - payloads[0].rate = tech_pvt->codecs[0]->samples_per_second; - payloads[0].bps = tech_pvt->codecs[0]->bits_per_second; - - } else { - payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame); - payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode; - payloads[0].rate = tech_pvt->codecs[tech_pvt->codec_index]->samples_per_second; - payloads[0].bps = tech_pvt->codecs[tech_pvt->codec_index]->bits_per_second; - } - - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[0].name, payloads[0].rate); - tech_pvt->desc_id = - ldl_session_describe(tech_pvt->dlsession, payloads, 1, - switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT); + setup_codecs(tech_pvt); switch_set_flag_locked(tech_pvt, TFLAG_CODEC_READY); } switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND); @@ -1167,8 +1762,8 @@ static switch_status_t negotiate_media(switch_core_session_t *session) while (!(switch_test_flag(tech_pvt, TFLAG_CODEC_READY) && switch_test_flag(tech_pvt, TFLAG_RTP_READY) && - switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && - tech_pvt->remote_ip && tech_pvt->remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) { + switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && //tech_pvt->read_count && + tech_pvt->transports[LDL_TPORT_RTP].remote_ip && tech_pvt->transports[LDL_TPORT_RTP].remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) { now = switch_micro_time_now(); elapsed = (unsigned int) ((now - started) / 1000); @@ -1195,10 +1790,20 @@ static switch_status_t negotiate_media(switch_core_session_t *session) switch_clear_flag_locked(tech_pvt, TFLAG_IO); goto done; } + if (switch_test_flag(tech_pvt, TFLAG_BYE) || !switch_test_flag(tech_pvt, TFLAG_IO)) { goto done; } - switch_cond_next(); + + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { + switch_rtp_ping(tech_pvt->transports[LDL_TPORT_RTP].rtp_session); + } + + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session)) { + switch_rtp_ping(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session); + } + + switch_yield(20000); } if (switch_channel_down(channel) || switch_test_flag(tech_pvt, TFLAG_BYE)) { @@ -1219,6 +1824,9 @@ static switch_status_t negotiate_media(switch_core_session_t *session) } ret = SWITCH_STATUS_SUCCESS; + switch_channel_audio_sync(channel); + + goto done; out: @@ -1241,7 +1849,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); switch_assert(tech_pvt != NULL); - tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN; + tech_pvt->transports[LDL_TPORT_RTP].read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN; switch_set_flag(tech_pvt, TFLAG_READY); @@ -1295,35 +1903,51 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); if (tech_pvt) { - if (tech_pvt->rtp_session) { - switch_rtp_destroy(&tech_pvt->rtp_session); + if (tech_pvt->transports[LDL_TPORT_RTP].rtp_session) { + switch_rtp_destroy(&tech_pvt->transports[LDL_TPORT_RTP].rtp_session); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NUKE RTP\n"); - tech_pvt->rtp_session = NULL; + tech_pvt->transports[LDL_TPORT_RTP].rtp_session = NULL; + } + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session) { + switch_rtp_destroy(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NUKE RTP\n"); + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session = NULL; } if (switch_test_flag(tech_pvt, TFLAG_NAT_MAP)) { - switch_nat_del_mapping((switch_port_t) tech_pvt->adv_local_port, SWITCH_NAT_UDP); + switch_nat_del_mapping((switch_port_t) tech_pvt->transports[LDL_TPORT_RTP].adv_local_port, SWITCH_NAT_UDP); switch_clear_flag(tech_pvt, TFLAG_NAT_MAP); } - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); + if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_RTP].read_codec)) { + switch_core_codec_destroy(&tech_pvt->transports[LDL_TPORT_RTP].read_codec); } - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); + if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_RTP].write_codec)) { + switch_core_codec_destroy(&tech_pvt->transports[LDL_TPORT_RTP].write_codec); + } + + if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec)) { + switch_core_codec_destroy(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec); + } + + if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_RTP].write_codec)) { + switch_core_codec_destroy(&tech_pvt->transports[LDL_TPORT_RTP].write_codec); } if (tech_pvt->dlsession) { ldl_session_destroy(&tech_pvt->dlsession); } - switch_thread_rwlock_unlock(tech_pvt->profile->rwlock); - - if (tech_pvt->profile->purge) { - mdl_profile_t *profile = tech_pvt->profile; - if (switch_core_hash_delete(globals.profile_hash, profile->name) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile %s deleted successfully\n", profile->name); + if (tech_pvt->profile) { + switch_thread_rwlock_unlock(tech_pvt->profile->rwlock); + + if (tech_pvt->profile->purge) { + mdl_profile_t *profile = tech_pvt->profile; + if (switch_core_hash_delete(globals.profile_hash, profile->name) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile %s deleted successfully\n", profile->name); + } } } } @@ -1340,8 +1964,12 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); switch_assert(tech_pvt != NULL); - if (tech_pvt->profile->ip && tech_pvt->local_port) { - switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->local_port); + if (tech_pvt->profile->ip && tech_pvt->transports[LDL_TPORT_RTP].local_port) { + switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->transports[LDL_TPORT_RTP].local_port); + } + + if (tech_pvt->profile->ip && tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port) { + switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port); } switch_clear_flag_locked(tech_pvt, TFLAG_IO); @@ -1382,13 +2010,13 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); switch_set_flag_locked(tech_pvt, TFLAG_BYE); - if (switch_rtp_ready(tech_pvt->rtp_session)) { - switch_rtp_kill_socket(tech_pvt->rtp_session); + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { + switch_rtp_kill_socket(tech_pvt->transports[LDL_TPORT_RTP].rtp_session); } break; case SWITCH_SIG_BREAK: - if (switch_rtp_ready(tech_pvt->rtp_session)) { - switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK); + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { + switch_rtp_set_flag(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, SWITCH_RTP_FLAG_BREAK); } break; } @@ -1421,7 +2049,7 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "DTMF [%c]\n", dtmf->digit); - return switch_rtp_queue_rfc2833(tech_pvt->rtp_session, dtmf); + return switch_rtp_queue_rfc2833(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, dtmf); } @@ -1434,7 +2062,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch tech_pvt = (struct private_object *) switch_core_session_get_private(session); switch_assert(tech_pvt != NULL); - while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) { + while (!(tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation && switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session))) { if (switch_channel_ready(channel)) { switch_yield(10000); } else { @@ -1443,7 +2071,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch } - tech_pvt->read_frame.datalen = 0; + tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen = 0; switch_set_flag_locked(tech_pvt, TFLAG_READING); #if 0 @@ -1457,23 +2085,25 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch if (switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_status_t status; - - switch_assert(tech_pvt->rtp_session != NULL); - tech_pvt->read_frame.datalen = 0; + //switch_status_t status; + + switch_assert(tech_pvt->transports[LDL_TPORT_RTP].rtp_session != NULL); + tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen = 0; - while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) { - tech_pvt->read_frame.flags = SFF_NONE; + while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen == 0) { + tech_pvt->transports[LDL_TPORT_RTP].read_frame.flags = SFF_NONE; - status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags); - if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { - return SWITCH_STATUS_FALSE; + switch_rtp_zerocopy_read_frame(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, &tech_pvt->transports[LDL_TPORT_RTP].read_frame, flags); + + tech_pvt->read_count++; +#if 0 + if (tech_pvt->read_count == 1 && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { + setup_codecs(tech_pvt); } +#endif - - - //payload = tech_pvt->read_frame.payload; + //payload = tech_pvt->transports[LDL_TPORT_RTP].read_frame.payload; #if 0 elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000); @@ -1489,22 +2119,22 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch return SWITCH_STATUS_BREAK; } #endif - if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) { + if (switch_rtp_has_dtmf(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { switch_dtmf_t dtmf = { 0 }; - switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf); + switch_rtp_dequeue_dtmf(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, &dtmf); switch_channel_queue_dtmf(channel, &dtmf); } - if (tech_pvt->read_frame.datalen > 0) { + if (tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen > 0) { size_t bytes = 0; int frames = 1; - if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) { - if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet)) { - frames = (tech_pvt->read_frame.datalen / bytes); + 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); } - tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_packet); + tech_pvt->transports[LDL_TPORT_RTP].read_frame.samples = (int) (frames * tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet); } break; } @@ -1513,12 +2143,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch switch_clear_flag_locked(tech_pvt, TFLAG_READING); - if (tech_pvt->read_frame.datalen == 0) { - *frame = NULL; - return SWITCH_STATUS_GENERR; + if (tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen == 0) { + switch_set_flag((&tech_pvt->transports[LDL_TPORT_RTP].read_frame), SFF_CNG); + tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen = 2; } - *frame = &tech_pvt->read_frame; + *frame = &tech_pvt->transports[LDL_TPORT_RTP].read_frame; return SWITCH_STATUS_SUCCESS; } @@ -1533,7 +2163,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc tech_pvt = (struct private_object *) switch_core_session_get_private(session); switch_assert(tech_pvt != NULL); - while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) { + while (!(tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation && switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session))) { if (switch_channel_ready(channel)) { switch_yield(10000); } else { @@ -1541,7 +2171,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc } } - if (!switch_core_codec_ready(&tech_pvt->read_codec) || !tech_pvt->read_codec.implementation) { + if (!switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_RTP].read_codec) || !tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation) { return SWITCH_STATUS_GENERR; } @@ -1552,13 +2182,13 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc switch_set_flag_locked(tech_pvt, TFLAG_WRITING); if (!switch_test_flag(frame, SFF_CNG)) { - if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) { - bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet; + if (tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->encoded_bytes_per_packet) { + bytes = tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->encoded_bytes_per_packet; frames = ((int) frame->datalen / bytes); } else frames = 1; - samples = frames * tech_pvt->read_codec.implementation->samples_per_packet; + samples = frames * tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet; } #if 0 printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n", @@ -1567,8 +2197,8 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc #endif tech_pvt->timestamp_send += samples; - //switch_rtp_write_frame(tech_pvt->rtp_session, frame, tech_pvt->timestamp_send); - if (switch_rtp_write_frame(tech_pvt->rtp_session, frame) < 0) { + //switch_rtp_write_frame(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, frame, tech_pvt->timestamp_send); + if (switch_rtp_write_frame(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, frame) < 0) { status = SWITCH_STATUS_GENERR; } @@ -1576,6 +2206,74 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc return status; } + +static switch_status_t channel_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) +{ + struct private_object *tech_pvt = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); + //int payload = 0; + //switch_status_t status; + + tech_pvt = (struct private_object *) switch_core_session_get_private(session); + switch_assert(tech_pvt != NULL); + + if (!switch_test_flag(tech_pvt, TFLAG_IO)) { + return SWITCH_STATUS_GENERR; + } + + while (!(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation && switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session))) { + if (switch_channel_ready(channel)) { + switch_yield(10000); + } else { + return SWITCH_STATUS_GENERR; + } + } + + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.datalen = 0; + + while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.datalen == 0) { + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.flags = SFF_NONE; + switch_rtp_zerocopy_read_frame(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame, flags); + } + + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.datalen == 0) { + switch_set_flag((&tech_pvt->transports[LDL_TPORT_RTP].read_frame), SFF_CNG); + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.datalen = 2; + } + + *frame = &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame; + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t channel_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) +{ + struct private_object *tech_pvt = (struct private_object *)switch_core_session_get_private(session); + switch_channel_t *channel = switch_core_session_get_channel(session); + int wrote = 0; + + switch_assert(tech_pvt != NULL); + + while (!(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation && switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session))) { + if (switch_channel_ready(channel)) { + switch_yield(10000); + } else { + return SWITCH_STATUS_GENERR; + } + } + + if (!switch_test_flag(tech_pvt, TFLAG_IO)) { + return SWITCH_STATUS_SUCCESS; + } + + if (!switch_test_flag(frame, SFF_CNG)) { + wrote = switch_rtp_write_frame(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, frame); + } + + return wrote > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR; +} + static switch_status_t channel_answer_channel(switch_core_session_t *session) { struct private_object *tech_pvt; @@ -1603,10 +2301,13 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s channel_answer_channel(session); break; case SWITCH_MESSAGE_INDICATE_BRIDGE: - rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_STICK); + rtp_flush_read_buffer(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, SWITCH_RTP_FLUSH_STICK); break; case SWITCH_MESSAGE_INDICATE_UNBRIDGE: - rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK); + rtp_flush_read_buffer(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, SWITCH_RTP_FLUSH_UNSTICK); + break; + case SWITCH_MESSAGE_INDICATE_STUN_ERROR: + //switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_NORMAL_CLEARING); break; default: break; @@ -1654,12 +2355,15 @@ switch_state_handler_table_t dingaling_event_handlers = { switch_io_routines_t dingaling_io_routines = { /*.outgoing_channel */ channel_outgoing_channel, - /*.read_frame */ channel_read_frame, + /*.transports[LDL_TPORT_RTP].read_frame */ channel_read_frame, /*.write_frame */ channel_write_frame, /*.kill_channel */ channel_kill_channel, /*.send_dtmf */ channel_send_dtmf, /*.receive_message */ channel_receive_message, - /*.receive_event */ channel_receive_event + /*.receive_event */ channel_receive_event, + /*.state_change */ NULL, + /*.read_video_frame */ channel_read_video_frame, + /*.write_video_frame */ channel_write_video_frame }; @@ -1688,6 +2392,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi char *p, *u, ubuf[512] = "", *user = NULL, *f_cid_msg = NULL; const char *cid_msg = NULL; ldl_user_flag_t flags = LDL_FLAG_OUTBOUND; + const char *var; switch_copy_string(workspace, outbound_profile->destination_number, sizeof(workspace)); profile_name = workspace; @@ -1752,6 +2457,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi return SWITCH_CAUSE_NORMAL_UNSPECIFIED; } + + + if (!ldl_handle_ready(mdl_profile->handle)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG, "Doh! we are not logged in yet!\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); @@ -1775,19 +2483,40 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_core_session_add_stream(*new_session, NULL); if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) { memset(tech_pvt, 0, sizeof(*tech_pvt)); + tech_pvt->profile = mdl_profile; switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session)); tech_pvt->flags |= globals.flags; tech_pvt->flags |= mdl_profile->flags; channel = switch_core_session_get_channel(*new_session); switch_core_session_set_private(*new_session, tech_pvt); tech_pvt->session = *new_session; - tech_pvt->codec_index = -1; - if (!(tech_pvt->local_port = switch_rtp_request_port(mdl_profile->ip))) { + tech_pvt->channel = switch_core_session_get_channel(tech_pvt->session); + tech_pvt->transports[LDL_TPORT_RTP].codec_index = -1; + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index = -1; + + switch_set_flag(tech_pvt, TFLAG_SECURE); + mdl_build_crypto(tech_pvt, LDL_TPORT_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); + mdl_build_crypto(tech_pvt, LDL_TPORT_VIDEO_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); + + + + if (!(tech_pvt->transports[LDL_TPORT_RTP].local_port = switch_rtp_request_port(mdl_profile->ip))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "No RTP port available!\n"); terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } - tech_pvt->adv_local_port = tech_pvt->local_port; + tech_pvt->transports[LDL_TPORT_RTP].adv_local_port = tech_pvt->transports[LDL_TPORT_RTP].local_port; + tech_pvt->transports[LDL_TPORT_RTCP].adv_local_port = tech_pvt->transports[LDL_TPORT_RTP].local_port + 1; + if (!(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port = switch_rtp_request_port(mdl_profile->ip))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "No RTP port available!\n"); + terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + } + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port = tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port; + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].adv_local_port = tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port + 1; + + + tech_pvt->recip = switch_core_session_strdup(*new_session, full_id); if (dnis) { tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis); @@ -1848,12 +2577,17 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi } switch_safe_free(f_cid_msg); - tech_pvt->profile = mdl_profile; + ldl_session_set_private(dlsession, *new_session); ldl_session_set_value(dlsession, "dnis", dnis); ldl_session_set_value(dlsession, "caller_id_name", outbound_profile->caller_id_name); ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number); tech_pvt->dlsession = dlsession; + + if ((var = switch_event_get_header(var_event, "absolute_codec_string"))) { + switch_channel_set_variable(channel, "absolute_codec_string", var); + } + if (!get_codecs(tech_pvt)) { terminate_session(new_session, __LINE__, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL); return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL; @@ -2117,6 +2851,8 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val) } else if (val && !strcasecmp(val, "md5")) { profile->user_flags |= LDL_FLAG_SASL_MD5; } + } else if (!strcasecmp(var, "use-jingle") && switch_true(val)) { + profile->user_flags |= LDL_FLAG_JINGLE; } else if (!strcasecmp(var, "exten") && !zstr(val)) { profile->exten = switch_core_strdup(module_pool, val); } else if (!strcasecmp(var, "context") && !zstr(val)) { @@ -2757,6 +3493,308 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id) switch_safe_free(xmlstr); } +static switch_status_t parse_candidates(ldl_session_t *dlsession, switch_core_session_t *session, ldl_transport_type_t ttype, const char *subject) +{ + + ldl_candidate_t *candidates; + unsigned int len = 0; + unsigned int x, choice = 0, ok = 0; + uint8_t lanaddr = 0; + struct private_object *tech_pvt = NULL; + switch_status_t status = LDL_STATUS_SUCCESS; + + if (!(tech_pvt = switch_core_session_get_private(session))) { + return SWITCH_STATUS_FALSE; + } + + if (ldl_session_get_candidates(dlsession, ttype, &candidates, &len) != LDL_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Candidate Error!\n"); + switch_set_flag(tech_pvt, TFLAG_BYE); + switch_clear_flag(tech_pvt, TFLAG_IO); + status = LDL_STATUS_FALSE; + goto end; + } + + + tech_pvt->transports[ttype].total = len; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%u %s candidates\n", len, ldl_transport_type_str(ttype)); + + if (tech_pvt->profile->acl_count) { + for (x = 0; x < len; x++) { + uint32_t y = 0; + + if (strcasecmp(candidates[x].protocol, "udp")) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d has an unsupported protocol!\n", + candidates[x].address, candidates[x].port); + continue; + } + + for (y = 0; y < tech_pvt->profile->acl_count; y++) { + + if (switch_check_network_list_ip(candidates[x].address, tech_pvt->profile->acl[y])) { + choice = x; + ok = 1; + } + + if (ok) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n", + candidates[x].address, candidates[x].port, tech_pvt->profile->acl[y]); + goto end_candidates; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d FAIL ACL %s\n", + candidates[x].address, candidates[x].port, tech_pvt->profile->acl[y]); + } + } + } + } else { + for (x = 0; x < len; x++) { + + + if (tech_pvt->profile->lanaddr) { + lanaddr = strncasecmp(candidates[x].address, tech_pvt->profile->lanaddr, strlen(tech_pvt->profile->lanaddr)) ? 0 : 1; + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s candidates %s:%d\n", + ldl_transport_type_str(ttype), candidates[x].address, + candidates[x].port); + + + // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them? + if (!strcasecmp(candidates[x].protocol, "udp") && + (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun") || !strcasecmp(candidates[x].type, "relay")) && + ((tech_pvt->profile->lanaddr && + lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && + strncasecmp(candidates[x].address, "192.168.", 8) && + strncasecmp(candidates[x].address, "127.", 4) && + strncasecmp(candidates[x].address, "255.", 4) && + strncasecmp(candidates[x].address, "0.", 2) && + strncasecmp(candidates[x].address, "1.", 2) && + strncasecmp(candidates[x].address, "2.", 2) && + strncasecmp(candidates[x].address, "172.16.", 7) && + strncasecmp(candidates[x].address, "172.17.", 7) && + strncasecmp(candidates[x].address, "172.18.", 7) && + strncasecmp(candidates[x].address, "172.19.", 7) && + strncasecmp(candidates[x].address, "172.2", 5) && + strncasecmp(candidates[x].address, "172.30.", 7) && + strncasecmp(candidates[x].address, "172.31.", 7) && + strncasecmp(candidates[x].address, "192.0.2.", 8) && strncasecmp(candidates[x].address, "169.254.", 8) + ))) { + choice = x; + ok = 1; + } + } + } + + + end_candidates: + + if (ok) { + ldl_payload_t payloads[5]; + char *key; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "Acceptable %s Candidate %s:%d\n", ldl_transport_type_str(ttype), candidates[choice].address, candidates[choice].port); + + + if (tech_pvt->transports[ttype].accepted) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Already Accepted [%s:%d]\n", + tech_pvt->transports[ttype].remote_ip, tech_pvt->transports[ttype].remote_port); + goto end; + } + + + if (tech_pvt->transports[ttype].remote_ip) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->transports[ttype].remote_ip); + goto end; + } + + + memset(payloads, 0, sizeof(payloads)); + + tech_pvt->transports[ttype].accepted++; + + if (ttype == LDL_TPORT_VIDEO_RTP) { + if ((key = ldl_session_get_value(dlsession, "video:crypto:1"))) { + mdl_add_crypto(tech_pvt, ttype, key, SWITCH_RTP_CRYPTO_RECV); + } else { + tech_pvt->transports[ttype].crypto_type = 0; + } + } else if (ttype == LDL_TPORT_RTP) { + if ((key = ldl_session_get_value(dlsession, "audio:crypto:1"))) { + mdl_add_crypto(tech_pvt, ttype, key, SWITCH_RTP_CRYPTO_RECV); + } else { + tech_pvt->transports[ttype].crypto_type = 0; + } + } + + if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { + switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); + //ldl_session_accept_candidate(dlsession, &candidates[choice]); + } + + if (!strcasecmp(subject, "candidates")) { + //switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); + switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); + } + + if (lanaddr) { + switch_set_flag_locked(tech_pvt, TFLAG_LANADDR); + } + + if (!get_codecs(tech_pvt)) { + terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + status = LDL_STATUS_FALSE; + goto end; + } + + + tech_pvt->transports[ttype].remote_ip = switch_core_session_strdup(session, candidates[choice].address); + ldl_session_set_ip(dlsession, tech_pvt->transports[ttype].remote_ip); + tech_pvt->transports[ttype].remote_port = candidates[choice].port; + tech_pvt->transports[ttype].remote_user = switch_core_session_strdup(session, candidates[choice].username); + tech_pvt->transports[ttype].remote_pass = switch_core_session_strdup(session, candidates[choice].password); + + if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { + if (!do_candidates(tech_pvt, 0)) { + terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + status = LDL_STATUS_FALSE; + + goto end; + } + } + + if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && (ttype == LDL_TPORT_VIDEO_RTP || ttype == LDL_TPORT_VIDEO_RTP) && + tech_pvt->transports[ttype].accepted == 1 && (1||switch_test_flag(tech_pvt, TFLAG_RTP_READY))) { + + if (ttype == LDL_TPORT_VIDEO_RTP) { + activate_video_rtp(tech_pvt); + } + + if (ttype == LDL_TPORT_VIDEO_RTP) { + activate_audio_rtp(tech_pvt); + } + + tech_pvt->transports[ttype].restart_rtp++; + } + + + status = LDL_STATUS_SUCCESS; + } + + end: + + return status; + +} + + +static ldl_status parse_payloads_type(ldl_session_t *dlsession, switch_core_session_t *session, + ldl_transport_type_t ttype, ldl_payload_t *payloads, unsigned int len) +{ + struct private_object *tech_pvt = NULL; + switch_status_t status = LDL_STATUS_SUCCESS; + unsigned int x, y; + int match = 0; + + tech_pvt = switch_core_session_get_private(session); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%u payloads\n", len); + for (x = 0; x < len; x++) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, + payloads[x].id); + for (y = 0; y < tech_pvt->num_codecs; y++) { + char *name = tech_pvt->codecs[y]->iananame; + + if ((ttype == LDL_TPORT_VIDEO_RTP && tech_pvt->codecs[y]->codec_type != SWITCH_CODEC_TYPE_VIDEO) || + (ttype == LDL_TPORT_RTP && tech_pvt->codecs[y]->codec_type != SWITCH_CODEC_TYPE_AUDIO)) { + continue; + } + + if (!strncasecmp(name, "ilbc", 4)) { + name = "ilbc"; + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "compare %s %d/%d to %s %d/%d\n", + payloads[x].name, payloads[x].id, payloads[x].rate, + name, tech_pvt->codecs[y]->ianacode, tech_pvt->codecs[y]->samples_per_second); + + if (tech_pvt->codecs[y]->ianacode > 95) { + match = strcasecmp(name, payloads[x].name) ? 0 : 1; + } else { + match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0; + } + + if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) { + tech_pvt->transports[ttype].codec_index = y; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Choosing %s Payload index %u %s %u\n", + ldl_transport_type_str(ttype), + y, + payloads[x].name, payloads[x].id); + tech_pvt->transports[ttype].codec_name = tech_pvt->codecs[y]->iananame; + tech_pvt->transports[ttype].codec_num = tech_pvt->codecs[y]->ianacode; + tech_pvt->transports[ttype].r_codec_num = (switch_payload_t) (payloads[x].id); + tech_pvt->transports[ttype].codec_rate = payloads[x].rate; + tech_pvt->transports[ttype].ptime = payloads[x].ptime; + tech_pvt->transports[ttype].payload_count++; + + if (ttype == LDL_TPORT_VIDEO_RTP) { + tech_pvt->transports[ttype].vid_width = payloads[x].width; + tech_pvt->transports[ttype].vid_height = payloads[x].height; + tech_pvt->transports[ttype].vid_rate = payloads[x].framerate; + } + + if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { + + + if (!do_describe(tech_pvt, 0)) { + terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + status = LDL_STATUS_FALSE; + goto done; + } + } + status = LDL_STATUS_SUCCESS; + goto done; + } + } + } + + done: + + return status; + +} + +static ldl_status parse_payloads(ldl_session_t *dlsession, switch_core_session_t *session, ldl_payload_t *payloads, unsigned int len) +{ + int match = 0; + struct private_object *tech_pvt = NULL; + ldl_status status; + + tech_pvt = switch_core_session_get_private(session); + + + if ((status = parse_payloads_type(dlsession, session, LDL_TPORT_RTP, payloads, len)) == LDL_STATUS_SUCCESS) { + match++; + } + + if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ready) { + if ((status = parse_payloads_type(dlsession, session, LDL_TPORT_VIDEO_RTP, payloads, len)) == LDL_STATUS_SUCCESS) { + match++; + } + } + + if (!match && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { + if (!do_describe(tech_pvt, 0)) { + terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + status = LDL_STATUS_FALSE; + } + } + + + return status; + +} + + static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg) { @@ -3060,15 +4098,36 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi tech_pvt->dlsession = dlsession; tech_pvt->session = session; - tech_pvt->codec_index = -1; + tech_pvt->channel = switch_core_session_get_channel(session); + tech_pvt->transports[LDL_TPORT_RTP].codec_index = -1; + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index = -1; tech_pvt->profile = profile; - if (!(tech_pvt->local_port = switch_rtp_request_port(profile->ip))) { + + switch_set_flag(tech_pvt, TFLAG_SECURE); + mdl_build_crypto(tech_pvt, LDL_TPORT_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); + mdl_build_crypto(tech_pvt, LDL_TPORT_VIDEO_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); + + + if (!(tech_pvt->transports[LDL_TPORT_RTP].local_port = switch_rtp_request_port(profile->ip))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "No RTP port available!\n"); terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); status = LDL_STATUS_FALSE; goto done; } - tech_pvt->adv_local_port = tech_pvt->local_port; + tech_pvt->transports[LDL_TPORT_RTP].adv_local_port = tech_pvt->transports[LDL_TPORT_RTP].local_port; + tech_pvt->transports[LDL_TPORT_RTCP].adv_local_port = tech_pvt->transports[LDL_TPORT_RTP].local_port + 1; + + if (!(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port = switch_rtp_request_port(profile->ip))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "No RTP port available!\n"); + terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + status = LDL_STATUS_FALSE; + goto done; + } + tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port = tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port; + tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].adv_local_port = tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port + 1; + + + switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); tech_pvt->recip = switch_core_session_strdup(session, from); if (!(exten = ldl_session_get_value(dlsession, "dnis"))) { @@ -3205,8 +4264,8 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi p++; } switch_set_flag_locked(tech_pvt, TFLAG_DTMF); - if (switch_rtp_ready(tech_pvt->rtp_session)) { - switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK); + if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_RTP].rtp_session)) { + switch_rtp_set_flag(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, SWITCH_RTP_FLAG_BREAK); } } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SESSION MSG [%s]\n", msg); @@ -3252,10 +4311,9 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi if (dl_signal) { ldl_payload_t *payloads; unsigned int len = 0; - int match = 0; - + if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { - if (!strcasecmp(msg, "accept")) { + if (msg && !strcasecmp(msg, "accept")) { switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); if (!do_candidates(tech_pvt, 0)) { @@ -3266,7 +4324,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi } } - if (tech_pvt->codec_index > -1) { + if (tech_pvt->transports[LDL_TPORT_RTP].codec_index > -1) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Already decided on a codec\n"); break; } @@ -3278,55 +4336,9 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi goto done; } - if (ldl_session_get_payloads(dlsession, &payloads, &len) == LDL_STATUS_SUCCESS) { - unsigned int x, y; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%u payloads\n", len); - for (x = 0; x < len; x++) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, - payloads[x].id); - for (y = 0; y < tech_pvt->num_codecs; y++) { - char *name = tech_pvt->codecs[y]->iananame; - - if (!strncasecmp(name, "ilbc", 4)) { - name = "ilbc"; - } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "compare %s %d/%d to %s %d/%d\n", - payloads[x].name, payloads[x].id, payloads[x].rate, - name, tech_pvt->codecs[y]->ianacode, tech_pvt->codecs[y]->samples_per_second); - if (tech_pvt->codecs[y]->ianacode > 95) { - match = strcasecmp(name, payloads[x].name) ? 0 : 1; - } else { - match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0; - } - - if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) { - tech_pvt->codec_index = y; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, - payloads[x].name, payloads[x].id); - tech_pvt->codec_name = tech_pvt->codecs[y]->iananame; - tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode; - tech_pvt->r_codec_num = (switch_payload_t) (payloads[x].id); - tech_pvt->codec_rate = payloads[x].rate; - if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { - if (!do_describe(tech_pvt, 0)) { - terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - status = LDL_STATUS_FALSE; - goto done; - } - } - status = LDL_STATUS_SUCCESS; - goto done; - } - } - } - if (!match && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { - if (!do_describe(tech_pvt, 0)) { - terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - status = LDL_STATUS_FALSE; - goto done; - } - } + status = parse_payloads(dlsession, session, payloads, len); + goto done; } } @@ -3334,141 +4346,14 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi break; case LDL_SIGNAL_CANDIDATES: if (dl_signal) { - ldl_candidate_t *candidates; - unsigned int len = 0; - unsigned int x, choice = 0, ok = 0; - uint8_t lanaddr = 0; - - if (ldl_session_get_candidates(dlsession, &candidates, &len) != LDL_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Candidate Error!\n"); - switch_set_flag(tech_pvt, TFLAG_BYE); - switch_clear_flag(tech_pvt, TFLAG_IO); - status = LDL_STATUS_FALSE; - goto done; - } - - - if (tech_pvt->remote_ip) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip); - break; - } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%u candidates\n", len); - - if (profile->acl_count) { - for (x = 0; x < len; x++) { - uint32_t y = 0; - - if (strcasecmp(candidates[x].protocol, "udp")) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d has an unsupported protocol!\n", - candidates[x].address, candidates[x].port); - continue; - } - - for (y = 0; y < profile->acl_count; y++) { - - if (switch_check_network_list_ip(candidates[x].address, profile->acl[y])) { - choice = x; - ok = 1; - } - - if (ok) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n", - candidates[x].address, candidates[x].port, profile->acl[y]); - goto end_candidates; - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d FAIL ACL %s\n", - candidates[x].address, candidates[x].port, profile->acl[y]); - } - } - } - } else { - for (x = 0; x < len; x++) { - - if (profile->lanaddr) { - lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1; - } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, - candidates[x].port); - - // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them? - if (!strcasecmp(candidates[x].protocol, "udp") && - (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && - ((profile->lanaddr && - lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && - strncasecmp(candidates[x].address, "192.168.", 8) && - strncasecmp(candidates[x].address, "127.", 4) && - strncasecmp(candidates[x].address, "255.", 4) && - strncasecmp(candidates[x].address, "0.", 2) && - strncasecmp(candidates[x].address, "1.", 2) && - strncasecmp(candidates[x].address, "2.", 2) && - strncasecmp(candidates[x].address, "172.16.", 7) && - strncasecmp(candidates[x].address, "172.17.", 7) && - strncasecmp(candidates[x].address, "172.18.", 7) && - strncasecmp(candidates[x].address, "172.19.", 7) && - strncasecmp(candidates[x].address, "172.2", 5) && - strncasecmp(candidates[x].address, "172.30.", 7) && - strncasecmp(candidates[x].address, "172.31.", 7) && - strncasecmp(candidates[x].address, "192.0.2.", 8) && strncasecmp(candidates[x].address, "169.254.", 8) - ))) { - choice = x; - ok = 1; - } - } - } - - end_candidates: - - if (ok) { - ldl_payload_t payloads[5]; - - memset(payloads, 0, sizeof(payloads)); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "Acceptable Candidate %s:%d\n", candidates[choice].address, candidates[choice].port); - - if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { - switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); - //ldl_session_accept_candidate(dlsession, &candidates[choice]); - } - - if (!strcasecmp(subject, "candidates")) { - //switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT); - switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); - } - - if (lanaddr) { - switch_set_flag_locked(tech_pvt, TFLAG_LANADDR); - } - - if (!get_codecs(tech_pvt)) { - terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - status = LDL_STATUS_FALSE; - goto done; - } - - - tech_pvt->remote_ip = switch_core_session_strdup(session, candidates[choice].address); - ldl_session_set_ip(dlsession, tech_pvt->remote_ip); - tech_pvt->remote_port = candidates[choice].port; - tech_pvt->remote_user = switch_core_session_strdup(session, candidates[choice].username); - - - if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { - if (!do_candidates(tech_pvt, 0)) { - terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - status = LDL_STATUS_FALSE; - goto done; - } - } - - status = LDL_STATUS_SUCCESS; - } - - goto done; + status = SWITCH_STATUS_SUCCESS; + status = parse_candidates(dlsession, session, LDL_TPORT_RTP, subject); + status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTP, subject); + status = parse_candidates(dlsession, session, LDL_TPORT_RTCP, subject); + status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTCP, subject); } + break; case LDL_SIGNAL_REJECT: if (channel) { diff --git a/src/mod/endpoints/mod_gsmopen/.gitignore b/src/mod/endpoints/mod_gsmopen/.gitignore index e2769c8969..9fdeeb1412 100644 --- a/src/mod/endpoints/mod_gsmopen/.gitignore +++ b/src/mod/endpoints/mod_gsmopen/.gitignore @@ -1,3 +1,2 @@ !/gsmlib/gsmlib-*/aclocal.m4 !/gsmlib/gsmlib-*/configure -!/gsmlib/gsmlib_1.10.orig.tar.gz diff --git a/src/mod/endpoints/mod_gsmopen/Makefile b/src/mod/endpoints/mod_gsmopen/Makefile index 18823eb4ca..18943c8956 100644 --- a/src/mod/endpoints/mod_gsmopen/Makefile +++ b/src/mod/endpoints/mod_gsmopen/Makefile @@ -1,5 +1,5 @@ MODNAME=mod_gsmopen -LOCAL_CFLAGS += -I../../../../libs/spandsp/src -I../../../..//libs/tiff-3.8.2/libtiff -DGSMOPEN_C_VER=\"`git log -1 --format="%h" gsmopen_protocol.cpp`\" -DMODGSMOPEN_C_VER=\"`git log -1 --format="%h" mod_gsmopen.cpp`\" +LOCAL_CFLAGS += -I../../../../libs/spandsp/src -I../../../..//libs/tiff-4.0.2/libtiff -DGSMOPEN_C_VER=\"`git log -1 --format="%h" gsmopen_protocol.cpp`\" -DMODGSMOPEN_C_VER=\"`git log -1 --format="%h" mod_gsmopen.cpp`\" LOCAL_LDFLAGS=-L../../../../libs/spandsp/src -lspandsp -lctb-0.16 -lgsmme LOCAL_OBJS=gsmopen_protocol.o include ../../../../build/modmake.rules diff --git a/src/mod/endpoints/mod_gsmopen/Makefile.am b/src/mod/endpoints/mod_gsmopen/Makefile.am index 749d04896c..0ce65353a7 100644 --- a/src/mod/endpoints/mod_gsmopen/Makefile.am +++ b/src/mod/endpoints/mod_gsmopen/Makefile.am @@ -1,8 +1,8 @@ include $(top_srcdir)/build/modmake.rulesam MODNAME=mod_gsmopen -TIFF_DIR=$(switch_srcdir)/libs/tiff-3.8.2 -TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-3.8.2 +TIFF_DIR=$(switch_srcdir)/libs/tiff-4.0.2 +TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-4.0.2 TIFF_LA=$(TIFF_BUILDDIR)/libtiff/libtiff.la SPANDSP_DIR=$(switch_srcdir)/libs/spandsp diff --git a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/Makefile b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/Makefile index d67bdbbabf..15e3388bd2 100644 --- a/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/Makefile +++ b/src/mod/endpoints/mod_gsmopen/alsa_nogsmlib_nocplusplus/mod_gsmopen/Makefile @@ -1,7 +1,7 @@ MODNAME=mod_gsmopen SVNDEF := -D'GSMOPEN_SVN_VERSION="$(shell svnversion -n .)"' -#LOCAL_CFLAGS += $(SVNDEF) -Wno-error=address -DNO_GSMLIB -I../../../../../../libs/spandsp/src -I../../../../../..//libs/tiff-3.8.2/libtiff -LOCAL_CFLAGS += $(SVNDEF) -DNO_GSMLIB -I../../../../../../libs/spandsp/src -I../../../../../..//libs/tiff-3.8.2/libtiff +#LOCAL_CFLAGS += $(SVNDEF) -Wno-error=address -DNO_GSMLIB -I../../../../../../libs/spandsp/src -I../../../../../..//libs/tiff-4.0.2/libtiff +LOCAL_CFLAGS += $(SVNDEF) -DNO_GSMLIB -I../../../../../../libs/spandsp/src -I../../../../../..//libs/tiff-4.0.2/libtiff LOCAL_LDFLAGS=-lasound -L../../../../../../libs/spandsp/src -lspandsp LOCAL_OBJS=gsmopen_protocol.o include ../../../../../../build/modmake.rules 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 37eb15741c..01388575b0 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 @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2011, Anthony Minessale II + * Copyright (C) 2005/2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -132,7 +132,7 @@ //#define SAMPLES_PER_FRAME SAMPLERATE_GSMOPEN/50 #ifndef GSMOPEN_SVN_VERSION -#define GSMOPEN_SVN_VERSION SWITCH_VERSION_REVISION +#define GSMOPEN_SVN_VERSION SWITCH_VERSION_FULL #endif /* GSMOPEN_SVN_VERSION */ typedef enum { diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/README b/src/mod/endpoints/mod_gsmopen/gsmlib/README index 709f78f2ca..9dbb65daa8 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmlib/README +++ b/src/mod/endpoints/mod_gsmopen/gsmlib/README @@ -1,8 +1,8 @@ For Linux distros without gsmlib (eg: CentOS): -Here are the original (ancient) sources for gsmlib, and the patch made by Ubuntu for modern compilers. +In the directory gsmlib-1.10-patched-13ubuntu is the source for gsmlib +as patched by Ubuntu for modern compilers: -In the directory gsmlib-1.10-patched-13ubuntu are the patched sources, ready for (no need to patch them again): ./configure make make install diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2010.vcxproj b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2010.vcxproj new file mode 100644 index 0000000000..78bc811ea1 --- /dev/null +++ b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.2010.vcxproj @@ -0,0 +1,263 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + gsmlib + {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} + + + + StaticLibrary + false + MultiByte + + + StaticLibrary + false + MultiByte + + + StaticLibrary + false + MultiByte + + + StaticLibrary + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + .\Release\ + .\Release\ + .\Debug\ + .\Debug\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + MaxSpeed + OnlyExplicitInline + ../vcproject;..;.;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + true + .\Release/gsmlib.pch + .\Release/ + .\Release/ + .\Release/ + true + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + .\Release\gsmlib.lib + true + + + true + .\Release/gsmlib.bsc + + + + + Disabled + ..;.;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + true + .\Debug/gsmlib.pch + .\Debug/ + .\Debug/ + .\Debug/ + Level3 + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + .\Debug\gsmlib.lib + true + false + %(IgnoreSpecificDefaultLibraries) + + + true + .\Debug/gsmlib.bsc + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + ../vcproject;..;.;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + true + .\Release/gsmlib.pch + .\Release/ + .\Release/ + .\Release/ + true + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + .\Release\gsmlib.lib + true + + + true + .\Release/gsmlib.bsc + + + + + X64 + + + Disabled + ..;.;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + true + .\Debug/gsmlib.pch + .\Debug/ + .\Debug/ + .\Debug/ + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + .\Debug\gsmlib.lib + true + false + %(IgnoreSpecificDefaultLibraries) + + + true + .\Debug/gsmlib.bsc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.vcproj b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.vcproj index a102fe5773..16d4ae1bc0 100755 --- a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.vcproj +++ b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-13ubuntu/win32/gsmlib.vcproj @@ -1,7 +1,7 @@ + @@ -169,6 +172,163 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib_1.10-13.diff b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib_1.10-13.diff deleted file mode 100644 index ddea9c6d8f..0000000000 --- a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib_1.10-13.diff +++ /dev/null @@ -1,64915 +0,0 @@ ---- gsmlib-1.10.orig/g41.patch -+++ gsmlib-1.10/g41.patch -@@ -0,0 +1,29 @@ -+--- ./gsmlib/gsm_me_ta.h~ 2006-03-09 19:15:59.000000000 +0000 -++++ ./gsmlib/gsm_me_ta.h 2006-03-09 19:16:31.000000000 +0000 -+@@ -291,8 +291,8 @@ -+ // 3 disable phone receive RF circuits only -+ // 4 disable phone both transmit and receive RF circuits -+ // 5...127 implementation-defined -+- int MeTa::getFunctionalityLevel() throw(GsmException); -+- void MeTa::setFunctionalityLevel(int level) throw(GsmException); -++ int getFunctionalityLevel() throw(GsmException); -++ void setFunctionalityLevel(int level) throw(GsmException); -+ -+ // return battery charge status (+CBC): -+ // 0 ME is powered by the battery -+@@ -386,13 +386,13 @@ -+ void setCallWaitingLockStatus(FacilityClass cl, -+ bool lock)throw(GsmException); -+ -+- void MeTa::setCLIRPresentation(bool enable) throw(GsmException); -++ void setCLIRPresentation(bool enable) throw(GsmException); -+ //(+CLIR) -+ -+ // 0:according to the subscription of the CLIR service -+ // 1:CLIR invocation -+ // 2:CLIR suppression -+- int MeTa::getCLIRPresentation() throw(GsmException); -++ int getCLIRPresentation() throw(GsmException); -+ -+ friend class Phonebook; -+ friend class SMSStore; ---- gsmlib-1.10.orig/Makefile.in -+++ gsmlib-1.10/Makefile.in -@@ -1,8 +1,6 @@ --# Makefile.in generated by automake 1.6.3 from Makefile.am. --# @configure_input@ -+# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am - --# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 --# Free Software Foundation, Inc. -+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. - # This Makefile.in is free software; the Free Software Foundation - # gives unlimited permission to copy and/or distribute it, - # with or without modifications, as long as this notice is preserved. -@@ -12,8 +10,6 @@ - # even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. - --@SET_MAKE@ -- - # ************************************************************************* - # * GSM TA/ME library - # * -@@ -25,6 +21,8 @@ - # * - # * Created: 21.5.1999 - # ************************************************************************* -+ -+ - SHELL = @SHELL@ - - srcdir = @srcdir@ -@@ -45,9 +43,13 @@ - mandir = @mandir@ - includedir = @includedir@ - oldincludedir = /usr/include -+ -+DESTDIR = -+ - pkgdatadir = $(datadir)/@PACKAGE@ - pkglibdir = $(libdir)/@PACKAGE@ - pkgincludedir = $(includedir)/@PACKAGE@ -+ - top_builddir = . - - ACLOCAL = @ACLOCAL@ -@@ -55,16 +57,12 @@ - AUTOMAKE = @AUTOMAKE@ - AUTOHEADER = @AUTOHEADER@ - --am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd - INSTALL = @INSTALL@ --INSTALL_PROGRAM = @INSTALL_PROGRAM@ -+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) - INSTALL_DATA = @INSTALL_DATA@ --install_sh_DATA = $(install_sh) -c -m 644 --install_sh_PROGRAM = $(install_sh) -c --install_sh_SCRIPT = $(install_sh) -c - INSTALL_SCRIPT = @INSTALL_SCRIPT@ --INSTALL_HEADER = $(INSTALL_DATA) - transform = @program_transform_name@ -+ - NORMAL_INSTALL = : - PRE_INSTALL = : - POST_INSTALL = : -@@ -73,33 +71,38 @@ - POST_UNINSTALL = : - host_alias = @host_alias@ - host_triplet = @host@ -- --EXEEXT = @EXEEXT@ --OBJEXT = @OBJEXT@ --PATH_SEPARATOR = @PATH_SEPARATOR@ --AMTAR = @AMTAR@ -+AR = @AR@ - AS = @AS@ --AWK = @AWK@ - BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ - CATOBJEXT = @CATOBJEXT@ - CC = @CC@ - CPP = @CPP@ - CXX = @CXX@ -+CXXCPP = @CXXCPP@ - DATADIRNAME = @DATADIRNAME@ --DEPDIR = @DEPDIR@ - DLLTOOL = @DLLTOOL@ - ECHO = @ECHO@ -+EGREP = @EGREP@ -+EXEEXT = @EXEEXT@ -+F77 = @F77@ -+GCJ = @GCJ@ -+GCJFLAGS = @GCJFLAGS@ - GENCAT = @GENCAT@ -+GLIBC2 = @GLIBC2@ - GLIBC21 = @GLIBC21@ - GMSGFMT = @GMSGFMT@ - GSM_VERSION = @GSM_VERSION@ -+HAVE_ASPRINTF = @HAVE_ASPRINTF@ - HAVE_LIB = @HAVE_LIB@ --INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -+HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -+HAVE_SNPRINTF = @HAVE_SNPRINTF@ -+HAVE_WPRINTF = @HAVE_WPRINTF@ - INSTOBJEXT = @INSTOBJEXT@ - INTLBISON = @INTLBISON@ - INTLLIBS = @INTLLIBS@ - INTLOBJS = @INTLOBJS@ - INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ - LIB = @LIB@ - LIBICONV = @LIBICONV@ - LIBINTL = @LIBINTL@ -@@ -108,89 +111,83 @@ - LTLIB = @LTLIB@ - LTLIBICONV = @LTLIBICONV@ - LTLIBINTL = @LTLIBINTL@ -+MAKEINFO = @MAKEINFO@ - MKINSTALLDIRS = @MKINSTALLDIRS@ - OBJDUMP = @OBJDUMP@ -+OBJEXT = @OBJEXT@ - PACKAGE = @PACKAGE@ - POSUB = @POSUB@ - RANLIB = @RANLIB@ -+RC = @RC@ - STRIP = @STRIP@ - USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ - USE_NLS = @USE_NLS@ - VERSION = @VERSION@ --am__include = @am__include@ --am__quote = @am__quote@ --install_sh = @install_sh@ - - SUBDIRS_ = po gsmlib apps tests doc scripts win32 ext - - EXTRA_DIST = gsmlib.spec -- - @COMPILE_INTL_TRUE@SUBDIRS = intl $(SUBDIRS_) # po - make automake happy - @COMPILE_INTL_FALSE@SUBDIRS = $(SUBDIRS_) # po intl - make automake happy --subdir = . - ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs - CONFIG_HEADER = gsm_config.h --CONFIG_CLEAN_FILES = intl/Makefile --DIST_SOURCES = -+CONFIG_CLEAN_FILES = -+DIST_COMMON = README ./stamp-h.in ABOUT-NLS AUTHORS COPYING ChangeLog \ -+INSTALL Makefile.am Makefile.in NEWS TODO acconfig.h acinclude.m4 \ -+aclocal.m4 configure configure.in gsm_config.h.in - --RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ -- uninstall-info-recursive all-recursive install-data-recursive \ -- install-exec-recursive installdirs-recursive install-recursive \ -- uninstall-recursive check-recursive installcheck-recursive --DIST_COMMON = README ABOUT-NLS AUTHORS COPYING ChangeLog INSTALL \ -- Makefile.am Makefile.in NEWS TODO acconfig.h acinclude.m4 \ -- aclocal.m4 configure configure.in gsm_config.h.in --DIST_SUBDIRS = po gsmlib apps tests doc scripts win32 ext intl --all: gsm_config.h -- $(MAKE) $(AM_MAKEFLAGS) all-recursive - -+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -+ -+TAR = tar -+GZIP_ENV = --best -+DIST_SUBDIRS = intl po gsmlib apps tests doc scripts win32 ext po \ -+gsmlib apps tests doc scripts win32 ext -+all: all-redirect - .SUFFIXES: -+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) -+ cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile - --am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ -- configure.lineno --$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) -- cd $(top_srcdir) && \ -- $(AUTOMAKE) --gnu Makefile --Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status -- cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe) -+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) -+ cd $(top_builddir) \ -+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status - --$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) -+$(ACLOCAL_M4): configure.in acinclude.m4 -+ cd $(srcdir) && $(ACLOCAL) -+ -+config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck --$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) -+$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) - cd $(srcdir) && $(AUTOCONF) - --$(ACLOCAL_M4): configure.in acinclude.m4 -- cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -- --gsm_config.h: stamp-h1 -+gsm_config.h: stamp-h - @if test ! -f $@; then \ -- rm -f stamp-h1; \ -- $(MAKE) stamp-h1; \ -+ rm -f stamp-h; \ -+ $(MAKE) stamp-h; \ - else :; fi -- --stamp-h1: $(srcdir)/gsm_config.h.in $(top_builddir)/config.status -- @rm -f stamp-h1 -- cd $(top_builddir) && $(SHELL) ./config.status gsm_config.h -- --$(srcdir)/gsm_config.h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/acconfig.h -+stamp-h: $(srcdir)/gsm_config.h.in $(top_builddir)/config.status -+ cd $(top_builddir) \ -+ && CONFIG_FILES= CONFIG_HEADERS=gsm_config.h \ -+ $(SHELL) ./config.status -+ @echo timestamp > stamp-h 2> /dev/null -+$(srcdir)/gsm_config.h.in: $(srcdir)/stamp-h.in -+ @if test ! -f $@; then \ -+ rm -f $(srcdir)/stamp-h.in; \ -+ $(MAKE) $(srcdir)/stamp-h.in; \ -+ else :; fi -+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h - cd $(top_srcdir) && $(AUTOHEADER) -- touch $(srcdir)/gsm_config.h.in -+ @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null - --distclean-hdr: -- -rm -f gsm_config.h stamp-h1 --intl/Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in -- cd $(top_builddir) && $(SHELL) ./config.status $@ -+mostlyclean-hdr: - --mostlyclean-libtool: -- -rm -f *.lo -+clean-hdr: - --clean-libtool: -- -rm -rf .libs _libs -+distclean-hdr: -+ -rm -f gsm_config.h - --distclean-libtool: -- -rm -f libtool --uninstall-info-am: -+maintainer-clean-hdr: - - # This directory's subdirectories are mostly independent; you can cd - # into them and run `make' without going through this Makefile. -@@ -198,8 +195,13 @@ - # (1) if the variable is set in `config.status', edit `config.status' - # (which will cause the Makefiles to be regenerated when you run `make'); - # (2) otherwise, pass the desired values on the `make' command line. --$(RECURSIVE_TARGETS): -- @set fnord $$MAKEFLAGS; amf=$$2; \ -+ -+@SET_MAKE@ -+ -+all-recursive install-data-recursive install-exec-recursive \ -+installdirs-recursive install-recursive uninstall-recursive \ -+check-recursive installcheck-recursive info-recursive dvi-recursive: -+ @set fnord $(MAKEFLAGS); amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ -@@ -219,18 +221,13 @@ - - mostlyclean-recursive clean-recursive distclean-recursive \ - maintainer-clean-recursive: -- @set fnord $$MAKEFLAGS; amf=$$2; \ -+ @set fnord $(MAKEFLAGS); amf=$$2; \ - dot_seen=no; \ -- case "$@" in \ -- distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ -- *) list='$(SUBDIRS)' ;; \ -- esac; \ -- rev=''; for subdir in $$list; do \ -- if test "$$subdir" = "."; then :; else \ -- rev="$$subdir $$rev"; \ -- fi; \ -+ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ -+ rev="$$subdir $$rev"; \ -+ test "$$subdir" != "." || dot_seen=yes; \ - done; \ -- rev="$$rev ."; \ -+ test "$$dot_seen" = "no" && rev=". $$rev"; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ -@@ -247,237 +244,180 @@ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done - --ETAGS = etags --ETAGSFLAGS = -- - tags: TAGS - --ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) -- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ -- unique=`for i in $$list; do \ -- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ -- done | \ -- $(AWK) ' { files[$$0] = 1; } \ -+ID: $(HEADERS) $(SOURCES) $(LISP) -+ list='$(SOURCES) $(HEADERS)'; \ -+ unique=`for i in $$list; do echo $$i; done | \ -+ awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ -- mkid -fID $$unique -+ here=`pwd` && cd $(srcdir) \ -+ && mkid -f$$here/ID $$unique $(LISP) - --TAGS: tags-recursive $(HEADERS) $(SOURCES) gsm_config.h.in $(TAGS_DEPENDENCIES) \ -- $(TAGS_FILES) $(LISP) -+TAGS: tags-recursive $(HEADERS) $(SOURCES) gsm_config.h.in $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ -- if test "$$subdir" = .; then :; else \ -+ if test "$$subdir" = .; then :; else \ - test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ -- fi; \ -+ fi; \ - done; \ -- list='$(SOURCES) $(HEADERS) gsm_config.h.in $(LISP) $(TAGS_FILES)'; \ -- unique=`for i in $$list; do \ -- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ -- done | \ -- $(AWK) ' { files[$$0] = 1; } \ -+ list='$(SOURCES) $(HEADERS)'; \ -+ unique=`for i in $$list; do echo $$i; done | \ -+ awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ -- test -z "$(ETAGS_ARGS)$$tags$$unique" \ -- || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ -- $$tags $$unique -- --GTAGS: -- here=`$(am__cd) $(top_builddir) && pwd` \ -- && cd $(top_srcdir) \ -- && gtags -i $(GTAGS_ARGS) $$here -+ test -z "$(ETAGS_ARGS)gsm_config.h.in$$unique$(LISP)$$tags" \ -+ || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags gsm_config.h.in $$unique $(LISP)) - --distclean-tags: -- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH --DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -+mostlyclean-tags: - --top_distdir = . --distdir = $(PACKAGE)-$(VERSION) -+clean-tags: - --am__remove_distdir = \ -- { test ! -d $(distdir) \ -- || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ -- && rm -fr $(distdir); }; } -+distclean-tags: -+ -rm -f TAGS ID - --GZIP_ENV = --best --distcleancheck_listfiles = find . -type f -print -+maintainer-clean-tags: - -+distdir = $(PACKAGE)-$(VERSION) -+top_distdir = $(distdir) -+ -+# This target untars the dist file and tries a VPATH configuration. Then -+# it guarantees that the distribution is self-contained by making another -+# tarfile. -+distcheck: dist -+ -rm -rf $(distdir) -+ GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz -+ mkdir $(distdir)/=build -+ mkdir $(distdir)/=inst -+ dc_install_base=`cd $(distdir)/=inst && pwd`; \ -+ cd $(distdir)/=build \ -+ && ../configure --with-included-gettext --srcdir=.. --prefix=$$dc_install_base \ -+ && $(MAKE) $(AM_MAKEFLAGS) \ -+ && $(MAKE) $(AM_MAKEFLAGS) dvi \ -+ && $(MAKE) $(AM_MAKEFLAGS) check \ -+ && $(MAKE) $(AM_MAKEFLAGS) install \ -+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ -+ && $(MAKE) $(AM_MAKEFLAGS) dist -+ -rm -rf $(distdir) -+ @banner="$(distdir).tar.gz is ready for distribution"; \ -+ dashes=`echo "$$banner" | sed s/./=/g`; \ -+ echo "$$dashes"; \ -+ echo "$$banner"; \ -+ echo "$$dashes" -+dist: distdir -+ -chmod -R a+r $(distdir) -+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -+ -rm -rf $(distdir) -+dist-all: distdir -+ -chmod -R a+r $(distdir) -+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -+ -rm -rf $(distdir) - distdir: $(DISTFILES) -- $(am__remove_distdir) -+ -rm -rf $(distdir) - mkdir $(distdir) -- $(mkinstalldirs) $(distdir)/intl $(distdir)/po -- @list='$(DISTFILES)'; for file in $$list; do \ -- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ -- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ -- if test "$$dir" != "$$file" && test "$$dir" != "."; then \ -- dir="/$$dir"; \ -- $(mkinstalldirs) "$(distdir)$$dir"; \ -- else \ -- dir=''; \ -- fi; \ -+ -chmod 777 $(distdir) -+ here=`cd $(top_builddir) && pwd`; \ -+ top_distdir=`cd $(distdir) && pwd`; \ -+ distdir=`cd $(distdir) && pwd`; \ -+ cd $(top_srcdir) \ -+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile -+ @for file in $(DISTFILES); do \ -+ d=$(srcdir); \ - if test -d $$d/$$file; then \ -- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ -- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ -- fi; \ -- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ -+ cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ -- || cp -p $$d/$$file $(distdir)/$$file \ -- || exit 1; \ -+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ -+ || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done -- list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ -+ for subdir in $(DIST_SUBDIRS); do \ - if test "$$subdir" = .; then :; else \ - test -d $(distdir)/$$subdir \ - || mkdir $(distdir)/$$subdir \ - || exit 1; \ -- (cd $$subdir && \ -- $(MAKE) $(AM_MAKEFLAGS) \ -- top_distdir="$(top_distdir)" \ -- distdir=../$(distdir)/$$subdir \ -- distdir) \ -+ chmod 777 $(distdir)/$$subdir; \ -+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ - || exit 1; \ - fi; \ - done -- -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ -- ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ -- ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ -- ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ -- || chmod -R a+r $(distdir) --dist-gzip: distdir -- $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz -- $(am__remove_distdir) -- --dist dist-all: distdir -- $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz -- $(am__remove_distdir) -- --# This target untars the dist file and tries a VPATH configuration. Then --# it guarantees that the distribution is self-contained by making another --# tarfile. --distcheck: dist -- $(am__remove_distdir) -- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - -- chmod -R a-w $(distdir); chmod a+w $(distdir) -- mkdir $(distdir)/=build -- mkdir $(distdir)/=inst -- chmod a-w $(distdir) -- dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \ -- && cd $(distdir)/=build \ -- && ../configure --srcdir=.. --prefix=$$dc_install_base \ -- --with-included-gettext \ -- $(DISTCHECK_CONFIGURE_FLAGS) \ -- && $(MAKE) $(AM_MAKEFLAGS) \ -- && $(MAKE) $(AM_MAKEFLAGS) dvi \ -- && $(MAKE) $(AM_MAKEFLAGS) check \ -- && $(MAKE) $(AM_MAKEFLAGS) install \ -- && $(MAKE) $(AM_MAKEFLAGS) installcheck \ -- && $(MAKE) $(AM_MAKEFLAGS) uninstall \ -- && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ -- || { echo "ERROR: files left after uninstall:" ; \ -- find $$dc_install_base -type f -print ; \ -- exit 1; } >&2 ) \ -- && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ -- && rm -f $(distdir).tar.gz \ -- && $(MAKE) $(AM_MAKEFLAGS) distcleancheck -- $(am__remove_distdir) -- @echo "$(distdir).tar.gz is ready for distribution" | \ -- sed 'h;s/./=/g;p;x;p;x' --distcleancheck: distclean -- if test '$(srcdir)' = . ; then \ -- echo "ERROR: distcleancheck can only run from a VPATH build" ; \ -- exit 1 ; \ -- fi -- test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ -- || { echo "ERROR: files left after distclean:" ; \ -- $(distcleancheck_listfiles) ; \ -- exit 1; } >&2 -+info-am: -+info: info-recursive -+dvi-am: -+dvi: dvi-recursive - check-am: all-am - check: check-recursive --all-am: Makefile gsm_config.h --installdirs: installdirs-recursive --installdirs-am: -+installcheck-am: -+installcheck: installcheck-recursive -+all-recursive-am: gsm_config.h -+ $(MAKE) $(AM_MAKEFLAGS) all-recursive - --install: install-recursive -+install-exec-am: - install-exec: install-exec-recursive -+ -+install-data-am: - install-data: install-data-recursive --uninstall: uninstall-recursive - - install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -- --installcheck: installcheck-recursive -+install: install-recursive -+uninstall-am: -+uninstall: uninstall-recursive -+all-am: Makefile gsm_config.h -+all-redirect: all-recursive-am - install-strip: -- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ -- INSTALL_STRIP_FLAG=-s \ -- `test -z '$(STRIP)' || \ -- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -+installdirs: installdirs-recursive -+installdirs-am: -+ -+ - mostlyclean-generic: - - clean-generic: - - distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) -+ -rm -f config.cache config.log stamp-h stamp-h[0-9]* - - maintainer-clean-generic: -- @echo "This command is intended for maintainers to use" -- @echo "it deletes files that may require special tools to rebuild." --clean: clean-recursive -- --clean-am: clean-generic clean-libtool mostlyclean-am -- --distclean: distclean-recursive -- -rm -f $(am__CONFIG_DISTCLEAN_FILES) --distclean-am: clean-am distclean-generic distclean-hdr distclean-libtool \ -- distclean-tags -+mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic - --dvi: dvi-recursive -- --dvi-am: -- --info: info-recursive -- --info-am: -+mostlyclean: mostlyclean-recursive - --install-data-am: -+clean-am: clean-hdr clean-tags clean-generic mostlyclean-am - --install-exec-am: -+clean: clean-recursive - --install-info: install-info-recursive -+distclean-am: distclean-hdr distclean-tags distclean-generic clean-am -+ -rm -f libtool - --install-man: -+distclean: distclean-recursive -+ -rm -f config.status - --installcheck-am: -+maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ -+ maintainer-clean-generic distclean-am -+ @echo "This command is intended for maintainers to use;" -+ @echo "it deletes files that may require special tools to rebuild." - - maintainer-clean: maintainer-clean-recursive -- -rm -f $(am__CONFIG_DISTCLEAN_FILES) -- -rm -rf autom4te.cache --maintainer-clean-am: distclean-am maintainer-clean-generic -- --mostlyclean: mostlyclean-recursive -- --mostlyclean-am: mostlyclean-generic mostlyclean-libtool -+ -rm -f config.status - --uninstall-am: uninstall-info-am -- --uninstall-info: uninstall-info-recursive -- --.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ -- clean-generic clean-libtool clean-recursive dist dist-all \ -- dist-gzip distcheck distclean distclean-generic distclean-hdr \ -- distclean-libtool distclean-recursive distclean-tags \ -- distcleancheck distdir dvi dvi-am dvi-recursive info info-am \ -- info-recursive install install-am install-data install-data-am \ -- install-data-recursive install-exec install-exec-am \ -- install-exec-recursive install-info install-info-am \ -- install-info-recursive install-man install-recursive \ -- install-strip installcheck installcheck-am installdirs \ -- installdirs-am installdirs-recursive maintainer-clean \ -- maintainer-clean-generic maintainer-clean-recursive mostlyclean \ -- mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ -- tags tags-recursive uninstall uninstall-am uninstall-info-am \ -- uninstall-info-recursive uninstall-recursive -+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ -+install-data-recursive uninstall-data-recursive install-exec-recursive \ -+uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ -+all-recursive check-recursive installcheck-recursive info-recursive \ -+dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ -+maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ -+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ -+dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ -+install-exec-am install-exec install-data-am install-data install-am \ -+install uninstall-am uninstall all-redirect all-am all installdirs-am \ -+installdirs mostlyclean-generic distclean-generic clean-generic \ -+maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - - all: -+ - # Tell versions [3.59,3.63) of GNU make to not export all variables. - # Otherwise a system limit (for SysV at least) may be exceeded. - .NOEXPORT: ---- gsmlib-1.10.orig/gsm_config.h.in -+++ gsmlib-1.10/gsm_config.h.in -@@ -55,25 +55,50 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_ARGZ_H - -+/* Define to 1 if you have the `asprintf' function. */ -+#undef HAVE_ASPRINTF -+ -+/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the -+ CoreFoundation framework. */ -+#undef HAVE_CFLOCALECOPYCURRENT -+ -+/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in -+ the CoreFoundation framework. */ -+#undef HAVE_CFPREFERENCESCOPYAPPVALUE -+ - /* Define if the GNU dcgettext() function is already present or preinstalled. - */ - #undef HAVE_DCGETTEXT - -+/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you -+ don't. */ -+#undef HAVE_DECL_FEOF_UNLOCKED -+ -+/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if -+ you don't. */ -+#undef HAVE_DECL_FGETS_UNLOCKED -+ -+/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you -+ don't. */ -+#undef HAVE_DECL_GETC_UNLOCKED -+ -+/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you -+ don't. */ -+#undef HAVE_DECL__SNPRINTF -+ -+/* Define to 1 if you have the declaration of `_snwprintf', and to 0 if you -+ don't. */ -+#undef HAVE_DECL__SNWPRINTF -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_DLFCN_H - --/* Define to 1 if you have the `feof_unlocked' function. */ --#undef HAVE_FEOF_UNLOCKED -- --/* Define to 1 if you have the `fgets_unlocked' function. */ --#undef HAVE_FGETS_UNLOCKED -+/* Define to 1 if you have the `fwprintf' function. */ -+#undef HAVE_FWPRINTF - - /* Define to 1 if you have the `getcwd' function. */ - #undef HAVE_GETCWD - --/* Define to 1 if you have the `getc_unlocked' function. */ --#undef HAVE_GETC_UNLOCKED -- - /* Define to 1 if you have the `getegid' function. */ - #undef HAVE_GETEGID - -@@ -95,6 +120,9 @@ - /* Define if you have the iconv() function. */ - #undef HAVE_ICONV - -+/* Define if you have the 'intmax_t' type in or . */ -+#undef HAVE_INTMAX_T -+ - /* Define if exists and doesn't clash with . */ - #undef HAVE_INTTYPES_H - -@@ -120,6 +148,12 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_LOCALE_H - -+/* Define if you have the 'long double' type. */ -+#undef HAVE_LONG_DOUBLE -+ -+/* Define if you have the 'long long' type. */ -+#undef HAVE_LONG_LONG -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_MALLOC_H - -@@ -141,6 +175,9 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_NL_TYPES_H - -+/* Define if your printf() function supports format strings with positions. */ -+#undef HAVE_POSIX_PRINTF -+ - /* Define to 1 if you have the `putenv' function. */ - #undef HAVE_PUTENV - -@@ -150,6 +187,9 @@ - /* Define to 1 if you have the `setlocale' function. */ - #undef HAVE_SETLOCALE - -+/* Define to 1 if you have the `snprintf' function. */ -+#undef HAVE_SNPRINTF -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_STDDEF_H - -@@ -193,12 +233,24 @@ - /* Define to 1 if you have the `tsearch' function. */ - #undef HAVE_TSEARCH - -+/* Define if you have the 'uintmax_t' type in or . */ -+#undef HAVE_UINTMAX_T -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_UNISTD_H - --/* Define if you have the unsigned long long type. */ -+/* Define if you have the 'unsigned long long' type. */ - #undef HAVE_UNSIGNED_LONG_LONG - -+/* Define if you have the 'wchar_t' type. */ -+#undef HAVE_WCHAR_T -+ -+/* Define to 1 if you have the `wcslen' function. */ -+#undef HAVE_WCSLEN -+ -+/* Define if you have the 'wint_t' type. */ -+#undef HAVE_WINT_T -+ - /* Define to 1 if you have the `__argz_count' function. */ - #undef HAVE___ARGZ_COUNT - -@@ -208,6 +260,9 @@ - /* Define to 1 if you have the `__argz_stringify' function. */ - #undef HAVE___ARGZ_STRINGIFY - -+/* Define to 1 if you have the `__fsetlocking' function. */ -+#undef HAVE___FSETLOCKING -+ - /* Define as const if the declaration of iconv() needs const. */ - #undef ICONV_CONST - -@@ -244,12 +299,16 @@ - /* The size of a `unsigned short int', as computed by sizeof. */ - #undef SIZEOF_UNSIGNED_SHORT_INT - -+/* Define as the maximum value of type 'size_t', if the system doesn't define -+ it. */ -+#undef SIZE_MAX -+ - /* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. -- STACK_DIRECTION > 0 => grows toward higher addresses -- STACK_DIRECTION < 0 => grows toward lower addresses -- STACK_DIRECTION = 0 => direction of growth unknown */ -+ STACK_DIRECTION > 0 => grows toward higher addresses -+ STACK_DIRECTION < 0 => grows toward lower addresses -+ STACK_DIRECTION = 0 => direction of growth unknown */ - #undef STACK_DIRECTION - - /* Define to 1 if you have the ANSI C header files. */ -@@ -261,16 +320,25 @@ - /* Define to empty if `const' does not conform to ANSI C. */ - #undef const - --/* Define as `__inline' if that's what the C compiler calls it, or to nothing -- if it is not supported. */ -+/* Define to `__inline__' or `__inline' if that's what the C compiler -+ calls it, or to nothing if 'inline' is not supported under any name. */ -+#ifndef __cplusplus - #undef inline -+#endif - - /* Define to `long' if does not define. */ - #undef off_t - -+/* Define as the type of the result of subtracting two pointers, if the system -+ doesn't define it. */ -+#undef ptrdiff_t -+ -+/* Define to empty if the C compiler doesn't support this keyword. */ -+#undef signed -+ - /* Define to `unsigned' if does not define. */ - #undef size_t - --/* Define to unsigned long or unsigned long long if and -- don't define. */ -+/* Define to unsigned long or unsigned long long if and -+ don't define. */ - #undef uintmax_t ---- gsmlib-1.10.orig/aclocal.m4 -+++ gsmlib-1.10/aclocal.m4 -@@ -1,7 +1,7 @@ --# aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*- -+# generated automatically by aclocal 1.9.6 -*- Autoconf -*- - --# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 --# Free Software Foundation, Inc. -+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -+# 2005 Free Software Foundation, Inc. - # This file is free software; the Free Software Foundation - # gives unlimited permission to copy and/or distribute it, - # with or without modifications, as long as this notice is preserved. -@@ -11,5211 +11,1221 @@ - # even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. - -+# codeset.m4 serial AM1 (gettext-0.10.40) -+dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- -- --# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. -+dnl From Bruno Haible. - --# 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. -+AC_DEFUN([AM_LANGINFO_CODESET], -+[ -+ AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, -+ [AC_TRY_LINK([#include ], -+ [char* cs = nl_langinfo(CODESET);], -+ am_cv_langinfo_codeset=yes, -+ am_cv_langinfo_codeset=no) -+ ]) -+ if test $am_cv_langinfo_codeset = yes; then -+ AC_DEFINE(HAVE_LANGINFO_CODESET, 1, -+ [Define if you have and nl_langinfo(CODESET).]) -+ fi -+]) - --# 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. -+# gettext.m4 serial 37 (gettext-0.14.4) -+dnl Copyright (C) 1995-2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+dnl -+dnl This file can can be used in projects which are not available under -+dnl the GNU General Public License or the GNU Library General Public -+dnl License but which still want to provide support for the GNU gettext -+dnl functionality. -+dnl Please note that the actual code of the GNU gettext library is covered -+dnl by the GNU Library General Public License, and the rest of the GNU -+dnl gettext package package is covered by the GNU General Public License. -+dnl They are *not* in the public domain. - --# 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. -+dnl Authors: -+dnl Ulrich Drepper , 1995-2000. -+dnl Bruno Haible , 2000-2003. - --AC_PREREQ([2.52]) -+dnl Macro to add for using GNU gettext. - --# serial 6 -+dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). -+dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The -+dnl default (if it is not specified or empty) is 'no-libtool'. -+dnl INTLSYMBOL should be 'external' for packages with no intl directory, -+dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. -+dnl If INTLSYMBOL is 'use-libtool', then a libtool library -+dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, -+dnl depending on --{enable,disable}-{shared,static} and on the presence of -+dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library -+dnl $(top_builddir)/intl/libintl.a will be created. -+dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext -+dnl implementations (in libc or libintl) without the ngettext() function -+dnl will be ignored. If NEEDSYMBOL is specified and is -+dnl 'need-formatstring-macros', then GNU gettext implementations that don't -+dnl support the ISO C 99 formatstring macros will be ignored. -+dnl INTLDIR is used to find the intl libraries. If empty, -+dnl the value `$(top_builddir)/intl/' is used. -+dnl -+dnl The result of the configuration is one of three cases: -+dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled -+dnl and used. -+dnl Catalog format: GNU --> install in $(datadir) -+dnl Catalog extension: .mo after installation, .gmo in source tree -+dnl 2) GNU gettext has been found in the system's C library. -+dnl Catalog format: GNU --> install in $(datadir) -+dnl Catalog extension: .mo after installation, .gmo in source tree -+dnl 3) No internationalization, always use English msgid. -+dnl Catalog format: none -+dnl Catalog extension: none -+dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. -+dnl The use of .gmo is historical (it was needed to avoid overwriting the -+dnl GNU format catalogs when building on a platform with an X/Open gettext), -+dnl but we keep it in order not to force irrelevant filename changes on the -+dnl maintainers. -+dnl -+AC_DEFUN([AM_GNU_GETTEXT], -+[ -+ dnl Argument checking. -+ ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , -+ [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT -+])])])])]) -+ ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , -+ [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT -+])])])]) -+ define([gt_included_intl], ifelse([$1], [external], [no], [yes])) -+ define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) - --# When config.status generates a header, we must update the stamp-h file. --# This file resides in the same directory as the config header --# that is generated. We must strip everything past the first ":", --# and everything past the last "/". -+ AC_REQUIRE([AM_PO_SUBDIRS])dnl -+ ifelse(gt_included_intl, yes, [ -+ AC_REQUIRE([AM_INTL_SUBDIR])dnl -+ ]) - --# _AM_DIRNAME(PATH) --# ----------------- --# Like AS_DIRNAME, only do it during macro expansion --AC_DEFUN([_AM_DIRNAME], -- [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, -- m4_if(regexp([$1], [^//\([^/]\|$\)]), -1, -- m4_if(regexp([$1], [^/.*]), -1, -- [.], -- patsubst([$1], [^\(/\).*], [\1])), -- patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), -- patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl --])# _AM_DIRNAME -- -- --# The stamp files are numbered to have different names. --# We could number them on a directory basis, but that's additional --# complications, let's have a unique counter. --m4_define([_AM_STAMP_Count], [0]) -+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. -+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -+ AC_REQUIRE([AC_LIB_RPATH]) - -+ dnl Sometimes libintl requires libiconv, so first search for libiconv. -+ dnl Ideally we would do this search only after the -+ dnl if test "$USE_NLS" = "yes"; then -+ dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then -+ dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT -+ dnl the configure script would need to contain the same shell code -+ dnl again, outside any 'if'. There are two solutions: -+ dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. -+ dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. -+ dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not -+ dnl documented, we avoid it. -+ ifelse(gt_included_intl, yes, , [ -+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) -+ ]) - --# _AM_STAMP(HEADER) --# ----------------- --# The name of the stamp file for HEADER. --AC_DEFUN([_AM_STAMP], --[m4_define([_AM_STAMP_Count], m4_incr(_AM_STAMP_Count))dnl --AS_ESCAPE(_AM_DIRNAME(patsubst([$1], -- [:.*])))/stamp-h[]_AM_STAMP_Count]) -+ dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. -+ gt_INTL_MACOSX - -+ dnl Set USE_NLS. -+ AM_NLS - --# _AM_CONFIG_HEADER(HEADER[:SOURCES], COMMANDS, INIT-COMMANDS) --# ------------------------------------------------------------ --# We used to try to get a real timestamp in stamp-h. But the fear is that --# that will cause unnecessary cvs conflicts. --AC_DEFUN([_AM_CONFIG_HEADER], --[# Add the stamp file to the list of files AC keeps track of, --# along with our hook. --AC_CONFIG_HEADERS([$1], -- [# update the timestamp --echo 'timestamp for $1' >"_AM_STAMP([$1])" --$2], -- [$3]) --])# _AM_CONFIG_HEADER -- -- --# AM_CONFIG_HEADER(HEADER[:SOURCES]..., COMMANDS, INIT-COMMANDS) --# -------------------------------------------------------------- --AC_DEFUN([AM_CONFIG_HEADER], --[AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])]) --])# AM_CONFIG_HEADER -+ ifelse(gt_included_intl, yes, [ -+ BUILD_INCLUDED_LIBINTL=no -+ USE_INCLUDED_LIBINTL=no -+ ]) -+ LIBINTL= -+ LTLIBINTL= -+ POSUB= - --# Do all the work for Automake. -*- Autoconf -*- -+ dnl If we use NLS figure out what method -+ if test "$USE_NLS" = "yes"; then -+ gt_use_preinstalled_gnugettext=no -+ ifelse(gt_included_intl, yes, [ -+ AC_MSG_CHECKING([whether included gettext is requested]) -+ AC_ARG_WITH(included-gettext, -+ [ --with-included-gettext use the GNU gettext library included here], -+ nls_cv_force_use_gnu_gettext=$withval, -+ nls_cv_force_use_gnu_gettext=no) -+ AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) - --# This macro actually does too much some checks are only needed if --# your package does certain things. But this isn't really a big deal. -+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" -+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then -+ ]) -+ dnl User does not insist on using GNU NLS library. Figure out what -+ dnl to use. If GNU gettext is available we use this. Else we have -+ dnl to fall back to GNU NLS library. - --# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 --# Free Software Foundation, Inc. -+ dnl Add a version number to the cache macros. -+ define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1))) -+ define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc]) -+ define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl]) - --# 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. -+ AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc, -+ [AC_TRY_LINK([#include -+]ifelse([$2], [need-formatstring-macros], -+[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -+#endif -+changequote(,)dnl -+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -+changequote([,])dnl -+], [])[extern int _nl_msg_cat_cntr; -+extern int *_nl_domain_bindings;], -+ [bindtextdomain ("", ""); -+return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings], -+ gt_cv_func_gnugettext_libc=yes, -+ gt_cv_func_gnugettext_libc=no)]) - --# 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. -+ if test "$gt_cv_func_gnugettext_libc" != "yes"; then -+ dnl Sometimes libintl requires libiconv, so first search for libiconv. -+ ifelse(gt_included_intl, yes, , [ -+ AM_ICONV_LINK -+ ]) -+ dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL -+ dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) -+ dnl because that would add "-liconv" to LIBINTL and LTLIBINTL -+ dnl even if libiconv doesn't exist. -+ AC_LIB_LINKFLAGS_BODY([intl]) -+ AC_CACHE_CHECK([for GNU gettext in libintl], -+ gt_cv_func_gnugettext_libintl, -+ [gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS $INCINTL" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS $LIBINTL" -+ dnl Now see whether libintl exists and does not depend on libiconv. -+ AC_TRY_LINK([#include -+]ifelse([$2], [need-formatstring-macros], -+[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -+#endif -+changequote(,)dnl -+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -+changequote([,])dnl -+], [])[extern int _nl_msg_cat_cntr; -+extern -+#ifdef __cplusplus -+"C" -+#endif -+const char *_nl_expand_alias (const char *);], -+ [bindtextdomain ("", ""); -+return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")], -+ gt_cv_func_gnugettext_libintl=yes, -+ gt_cv_func_gnugettext_libintl=no) -+ dnl Now see whether libintl exists and depends on libiconv. -+ if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then -+ LIBS="$LIBS $LIBICONV" -+ AC_TRY_LINK([#include -+]ifelse([$2], [need-formatstring-macros], -+[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -+#endif -+changequote(,)dnl -+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -+changequote([,])dnl -+], [])[extern int _nl_msg_cat_cntr; -+extern -+#ifdef __cplusplus -+"C" -+#endif -+const char *_nl_expand_alias (const char *);], -+ [bindtextdomain ("", ""); -+return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")], -+ [LIBINTL="$LIBINTL $LIBICONV" -+ LTLIBINTL="$LTLIBINTL $LTLIBICONV" -+ gt_cv_func_gnugettext_libintl=yes -+ ]) -+ fi -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS"]) -+ fi - --# 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. -+ dnl If an already present or preinstalled GNU gettext() is found, -+ dnl use it. But if this macro is used in GNU gettext, and GNU -+ dnl gettext is already preinstalled in libintl, we update this -+ dnl libintl. (Cf. the install rule in intl/Makefile.in.) -+ if test "$gt_cv_func_gnugettext_libc" = "yes" \ -+ || { test "$gt_cv_func_gnugettext_libintl" = "yes" \ -+ && test "$PACKAGE" != gettext-runtime \ -+ && test "$PACKAGE" != gettext-tools; }; then -+ gt_use_preinstalled_gnugettext=yes -+ else -+ dnl Reset the values set by searching for libintl. -+ LIBINTL= -+ LTLIBINTL= -+ INCINTL= -+ fi - --# serial 8 -+ ifelse(gt_included_intl, yes, [ -+ if test "$gt_use_preinstalled_gnugettext" != "yes"; then -+ dnl GNU gettext is not found in the C library. -+ dnl Fall back on included GNU gettext library. -+ nls_cv_use_gnu_gettext=yes -+ fi -+ fi - --# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be --# written in clear, in which case automake, when reading aclocal.m4, --# will think it sees a *use*, and therefore will trigger all it's --# C support machinery. Also note that it means that autoscan, seeing --# CC etc. in the Makefile, will ask for an AC_PROG_CC use... -+ if test "$nls_cv_use_gnu_gettext" = "yes"; then -+ dnl Mark actions used to generate GNU NLS library. -+ BUILD_INCLUDED_LIBINTL=yes -+ USE_INCLUDED_LIBINTL=yes -+ LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV" -+ LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV" -+ LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` -+ fi - -+ CATOBJEXT= -+ if test "$gt_use_preinstalled_gnugettext" = "yes" \ -+ || test "$nls_cv_use_gnu_gettext" = "yes"; then -+ dnl Mark actions to use GNU gettext tools. -+ CATOBJEXT=.gmo -+ fi -+ ]) - --AC_PREREQ([2.52]) -+ if test -n "$INTL_MACOSX_LIBS"; then -+ if test "$gt_use_preinstalled_gnugettext" = "yes" \ -+ || test "$nls_cv_use_gnu_gettext" = "yes"; then -+ dnl Some extra flags are needed during linking. -+ LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" -+ LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" -+ fi -+ fi - --# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow --# the ones we care about. --m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -+ if test "$gt_use_preinstalled_gnugettext" = "yes" \ -+ || test "$nls_cv_use_gnu_gettext" = "yes"; then -+ AC_DEFINE(ENABLE_NLS, 1, -+ [Define to 1 if translation of program messages to the user's native language -+ is requested.]) -+ else -+ USE_NLS=no -+ fi -+ fi - --# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) --# AM_INIT_AUTOMAKE([OPTIONS]) --# ----------------------------------------------- --# The call with PACKAGE and VERSION arguments is the old style --# call (pre autoconf-2.50), which is being phased out. PACKAGE --# and VERSION should now be passed to AC_INIT and removed from --# the call to AM_INIT_AUTOMAKE. --# We support both call styles for the transition. After --# the next Automake release, Autoconf can make the AC_INIT --# arguments mandatory, and then we can depend on a new Autoconf --# release and drop the old call support. --AC_DEFUN([AM_INIT_AUTOMAKE], --[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -- AC_REQUIRE([AC_PROG_INSTALL])dnl --# test to see if srcdir already configured --if test "`cd $srcdir && pwd`" != "`pwd`" && -- test -f $srcdir/config.status; then -- AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) --fi -+ AC_MSG_CHECKING([whether to use NLS]) -+ AC_MSG_RESULT([$USE_NLS]) -+ if test "$USE_NLS" = "yes"; then -+ AC_MSG_CHECKING([where the gettext function comes from]) -+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then -+ if test "$gt_cv_func_gnugettext_libintl" = "yes"; then -+ gt_source="external libintl" -+ else -+ gt_source="libc" -+ fi -+ else -+ gt_source="included intl directory" -+ fi -+ AC_MSG_RESULT([$gt_source]) -+ fi - --# Define the identity of the package. --dnl Distinguish between old-style and new-style calls. --m4_ifval([$2], --[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl -- AC_SUBST([PACKAGE], [$1])dnl -- AC_SUBST([VERSION], [$2])], --[_AM_SET_OPTIONS([$1])dnl -- AC_SUBST([PACKAGE], [AC_PACKAGE_TARNAME])dnl -- AC_SUBST([VERSION], [AC_PACKAGE_VERSION])])dnl -+ if test "$USE_NLS" = "yes"; then - --_AM_IF_OPTION([no-define],, --[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) -- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl -+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then -+ if test "$gt_cv_func_gnugettext_libintl" = "yes"; then -+ AC_MSG_CHECKING([how to link with libintl]) -+ AC_MSG_RESULT([$LIBINTL]) -+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) -+ fi - --# Some tools Automake needs. --AC_REQUIRE([AM_SANITY_CHECK])dnl --AC_REQUIRE([AC_ARG_PROGRAM])dnl --AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) --AM_MISSING_PROG(AUTOCONF, autoconf) --AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) --AM_MISSING_PROG(AUTOHEADER, autoheader) --AM_MISSING_PROG(MAKEINFO, makeinfo) --AM_MISSING_PROG(AMTAR, tar) --AM_PROG_INSTALL_SH --AM_PROG_INSTALL_STRIP --# We need awk for the "check" target. The system "awk" is bad on --# some platforms. --AC_REQUIRE([AC_PROG_AWK])dnl --AC_REQUIRE([AC_PROG_MAKE_SET])dnl -+ dnl For backward compatibility. Some packages may be using this. -+ AC_DEFINE(HAVE_GETTEXT, 1, -+ [Define if the GNU gettext() function is already present or preinstalled.]) -+ AC_DEFINE(HAVE_DCGETTEXT, 1, -+ [Define if the GNU dcgettext() function is already present or preinstalled.]) -+ fi - --_AM_IF_OPTION([no-dependencies],, --[AC_PROVIDE_IFELSE([AC_PROG_][CC], -- [_AM_DEPENDENCIES(CC)], -- [define([AC_PROG_][CC], -- defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl --AC_PROVIDE_IFELSE([AC_PROG_][CXX], -- [_AM_DEPENDENCIES(CXX)], -- [define([AC_PROG_][CXX], -- defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl --]) --]) -+ dnl We need to process the po/ directory. -+ POSUB=po -+ fi - --# Copyright 2002 Free Software Foundation, Inc. -+ ifelse(gt_included_intl, yes, [ -+ dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL -+ dnl to 'yes' because some of the testsuite requires it. -+ if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then -+ BUILD_INCLUDED_LIBINTL=yes -+ fi - --# 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. -+ dnl Make all variables we use known to autoconf. -+ AC_SUBST(BUILD_INCLUDED_LIBINTL) -+ AC_SUBST(USE_INCLUDED_LIBINTL) -+ AC_SUBST(CATOBJEXT) - --# 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. -+ dnl For backward compatibility. Some configure.ins may be using this. -+ nls_cv_header_intl= -+ nls_cv_header_libgt= - --# 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 -+ dnl For backward compatibility. Some Makefiles may be using this. -+ DATADIRNAME=share -+ AC_SUBST(DATADIRNAME) - --# AM_AUTOMAKE_VERSION(VERSION) --# ---------------------------- --# Automake X.Y traces this macro to ensure aclocal.m4 has been --# generated from the m4 files accompanying Automake X.Y. --AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.6"]) -+ dnl For backward compatibility. Some Makefiles may be using this. -+ INSTOBJEXT=.mo -+ AC_SUBST(INSTOBJEXT) - --# AM_SET_CURRENT_AUTOMAKE_VERSION --# ------------------------------- --# Call AM_AUTOMAKE_VERSION so it can be traced. --# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. --AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -- [AM_AUTOMAKE_VERSION([1.6.3])]) -+ dnl For backward compatibility. Some Makefiles may be using this. -+ GENCAT=gencat -+ AC_SUBST(GENCAT) - --# Helper functions for option handling. -*- Autoconf -*- -+ dnl For backward compatibility. Some Makefiles may be using this. -+ INTLOBJS= -+ if test "$USE_INCLUDED_LIBINTL" = yes; then -+ INTLOBJS="\$(GETTOBJS)" -+ fi -+ AC_SUBST(INTLOBJS) - --# Copyright 2001, 2002 Free Software Foundation, Inc. -+ dnl Enable libtool support if the surrounding package wishes it. -+ INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix -+ AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) -+ ]) - --# 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. -+ dnl For backward compatibility. Some Makefiles may be using this. -+ INTLLIBS="$LIBINTL" -+ AC_SUBST(INTLLIBS) - --# 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. -+ dnl Make all documented variables known to autoconf. -+ AC_SUBST(LIBINTL) -+ AC_SUBST(LTLIBINTL) -+ AC_SUBST(POSUB) -+]) - --# 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. - --# serial 2 -+dnl Checks for all prerequisites of the intl subdirectory, -+dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, -+dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. -+AC_DEFUN([AM_INTL_SUBDIR], -+[ -+ AC_REQUIRE([AC_PROG_INSTALL])dnl -+ AC_REQUIRE([AM_MKINSTALLDIRS])dnl -+ AC_REQUIRE([AC_PROG_CC])dnl -+ AC_REQUIRE([AC_CANONICAL_HOST])dnl -+ AC_REQUIRE([gt_GLIBC2])dnl -+ AC_REQUIRE([AC_PROG_RANLIB])dnl -+ AC_REQUIRE([AC_ISC_POSIX])dnl -+ AC_REQUIRE([AC_HEADER_STDC])dnl -+ AC_REQUIRE([AC_C_CONST])dnl -+ AC_REQUIRE([bh_C_SIGNED])dnl -+ AC_REQUIRE([AC_C_INLINE])dnl -+ AC_REQUIRE([AC_TYPE_OFF_T])dnl -+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl -+ AC_REQUIRE([gl_AC_TYPE_LONG_LONG])dnl -+ AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl -+ AC_REQUIRE([gt_TYPE_WCHAR_T])dnl -+ AC_REQUIRE([gt_TYPE_WINT_T])dnl -+ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) -+ AC_REQUIRE([gl_AC_HEADER_STDINT_H]) -+ AC_REQUIRE([gt_TYPE_INTMAX_T]) -+ AC_REQUIRE([gt_PRINTF_POSIX]) -+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl -+ AC_REQUIRE([AC_FUNC_MMAP])dnl -+ AC_REQUIRE([gl_GLIBC21])dnl -+ AC_REQUIRE([gt_INTDIV0])dnl -+ AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl -+ AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl -+ AC_REQUIRE([gt_INTTYPES_PRI])dnl -+ AC_REQUIRE([gl_XSIZE])dnl -+ AC_REQUIRE([gt_INTL_MACOSX])dnl - --# _AM_MANGLE_OPTION(NAME) --# ----------------------- --AC_DEFUN([_AM_MANGLE_OPTION], --[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) -+ AC_CHECK_TYPE([ptrdiff_t], , -+ [AC_DEFINE([ptrdiff_t], [long], -+ [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) -+ ]) -+ AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ -+stdlib.h string.h unistd.h sys/param.h]) -+ AC_CHECK_FUNCS([asprintf fwprintf getcwd getegid geteuid getgid getuid \ -+mempcpy munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup \ -+strtoul tsearch wcslen __argz_count __argz_stringify __argz_next \ -+__fsetlocking]) -+ -+ dnl Use the _snprintf function only if it is declared (because on NetBSD it -+ dnl is defined as a weak alias of snprintf; we prefer to use the latter). -+ gt_CHECK_DECL(_snprintf, [#include ]) -+ gt_CHECK_DECL(_snwprintf, [#include ]) -+ -+ dnl Use the *_unlocked functions only if they are declared. -+ dnl (because some of them were defined without being declared in Solaris -+ dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built -+ dnl on Solaris 2.5.1 to run on Solaris 2.6). -+ dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. -+ gt_CHECK_DECL(feof_unlocked, [#include ]) -+ gt_CHECK_DECL(fgets_unlocked, [#include ]) -+ gt_CHECK_DECL(getc_unlocked, [#include ]) -+ -+ case $gt_cv_func_printf_posix in -+ *yes) HAVE_POSIX_PRINTF=1 ;; -+ *) HAVE_POSIX_PRINTF=0 ;; -+ esac -+ AC_SUBST([HAVE_POSIX_PRINTF]) -+ if test "$ac_cv_func_asprintf" = yes; then -+ HAVE_ASPRINTF=1 -+ else -+ HAVE_ASPRINTF=0 -+ fi -+ AC_SUBST([HAVE_ASPRINTF]) -+ if test "$ac_cv_func_snprintf" = yes; then -+ HAVE_SNPRINTF=1 -+ else -+ HAVE_SNPRINTF=0 -+ fi -+ AC_SUBST([HAVE_SNPRINTF]) -+ if test "$ac_cv_func_wprintf" = yes; then -+ HAVE_WPRINTF=1 -+ else -+ HAVE_WPRINTF=0 -+ fi -+ AC_SUBST([HAVE_WPRINTF]) - --# _AM_SET_OPTION(NAME) --# ------------------------------ --# Set option NAME. Presently that only means defining a flag for this option. --AC_DEFUN([_AM_SET_OPTION], --[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) -+ AM_ICONV -+ AM_LANGINFO_CODESET -+ if test $ac_cv_header_locale_h = yes; then -+ gt_LC_MESSAGES -+ fi - --# _AM_SET_OPTIONS(OPTIONS) --# ---------------------------------- --# OPTIONS is a space-separated list of Automake options. --AC_DEFUN([_AM_SET_OPTIONS], --[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) -+ if test -n "$INTL_MACOSX_LIBS"; then -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ fi - --# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) --# ------------------------------------------- --# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. --AC_DEFUN([_AM_IF_OPTION], --[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -+ dnl intl/plural.c is generated from intl/plural.y. It requires bison, -+ dnl because plural.y uses bison specific features. It requires at least -+ dnl bison-1.26 because earlier versions generate a plural.c that doesn't -+ dnl compile. -+ dnl bison is only needed for the maintainer (who touches plural.y). But in -+ dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put -+ dnl the rule in general Makefile. Now, some people carelessly touch the -+ dnl files or have a broken "make" program, hence the plural.c rule will -+ dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not -+ dnl present or too old. -+ AC_CHECK_PROGS([INTLBISON], [bison]) -+ if test -z "$INTLBISON"; then -+ ac_verc_fail=yes -+ else -+ dnl Found it, now check the version. -+ AC_MSG_CHECKING([version of bison]) -+changequote(<<,>>)dnl -+ ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` -+ case $ac_prog_version in -+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; -+ 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) -+changequote([,])dnl -+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; -+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; -+ esac -+ AC_MSG_RESULT([$ac_prog_version]) -+ fi -+ if test $ac_verc_fail = yes; then -+ INTLBISON=: -+ fi -+]) - --# --# Check to make sure that the build environment is sane. --# - --# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. -+dnl Checks for special options needed on MacOS X. -+dnl Defines INTL_MACOSX_LIBS. -+AC_DEFUN([gt_INTL_MACOSX], -+[ -+ dnl Check for API introduced in MacOS X 10.2. -+ AC_CACHE_CHECK([for CFPreferencesCopyAppValue], -+ gt_cv_func_CFPreferencesCopyAppValue, -+ [gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS -framework CoreFoundation" -+ AC_TRY_LINK([#include ], -+ [CFPreferencesCopyAppValue(NULL, NULL)], -+ [gt_cv_func_CFPreferencesCopyAppValue=yes], -+ [gt_cv_func_CFPreferencesCopyAppValue=no]) -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS"]) -+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then -+ AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, -+ [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) -+ fi -+ dnl Check for API introduced in MacOS X 10.3. -+ AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, -+ [gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS -framework CoreFoundation" -+ AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], -+ [gt_cv_func_CFLocaleCopyCurrent=yes], -+ [gt_cv_func_CFLocaleCopyCurrent=no]) -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS"]) -+ if test $gt_cv_func_CFLocaleCopyCurrent = yes; then -+ AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, -+ [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) -+ fi -+ INTL_MACOSX_LIBS= -+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then -+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" -+ fi -+ AC_SUBST([INTL_MACOSX_LIBS]) -+]) - --# 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. -+dnl gt_CHECK_DECL(FUNC, INCLUDES) -+dnl Check whether a function is declared. -+AC_DEFUN([gt_CHECK_DECL], -+[ -+ AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, -+ [AC_TRY_COMPILE([$2], [ -+#ifndef $1 -+ char *p = (char *) $1; -+#endif -+], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) -+ if test $ac_cv_have_decl_$1 = yes; then -+ gt_value=1 -+ else -+ gt_value=0 -+ fi -+ AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], -+ [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) -+]) - --# 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. - --# serial 3 -+dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) -+AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) - --# AM_SANITY_CHECK --# --------------- --AC_DEFUN([AM_SANITY_CHECK], --[AC_MSG_CHECKING([whether build environment is sane]) --# Just in case --sleep 1 --echo timestamp > conftest.file --# Do `set' in a subshell so we don't clobber the current shell's --# arguments. Must try -L first in case configure is actually a --# symlink; some systems play weird games with the mod time of symlinks --# (eg FreeBSD returns the mod time of the symlink's containing --# directory). --if ( -- set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` -- if test "$[*]" = "X"; then -- # -L didn't work. -- set X `ls -t $srcdir/configure conftest.file` -- fi -- rm -f conftest.file -- if test "$[*]" != "X $srcdir/configure conftest.file" \ -- && test "$[*]" != "X conftest.file $srcdir/configure"; then -- -- # If neither matched, then we have a broken ls. This can happen -- # if, for instance, CONFIG_SHELL is bash and it inherits a -- # broken ls alias from the environment. This has actually -- # happened. Such a system could not be considered "sane". -- AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken --alias in your environment]) -- fi -- -- test "$[2]" = conftest.file -- ) --then -- # Ok. -- : --else -- AC_MSG_ERROR([newly created file is older than distributed files! --Check your system clock]) --fi --AC_MSG_RESULT(yes)]) -- --# -*- Autoconf -*- -+# glibc2.m4 serial 1 -+dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - -+# Test for the GNU C Library, version 2.0 or newer. -+# From Bruno Haible. - --# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc. -+AC_DEFUN([gt_GLIBC2], -+ [ -+ AC_CACHE_CHECK(whether we are using the GNU C Library 2 or newer, -+ ac_cv_gnu_library_2, -+ [AC_EGREP_CPP([Lucky GNU user], -+ [ -+#include -+#ifdef __GNU_LIBRARY__ -+ #if (__GLIBC__ >= 2) -+ Lucky GNU user -+ #endif -+#endif -+ ], -+ ac_cv_gnu_library_2=yes, -+ ac_cv_gnu_library_2=no) -+ ] -+ ) -+ AC_SUBST(GLIBC2) -+ GLIBC2="$ac_cv_gnu_library_2" -+ ] -+) - --# 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. -+# glibc21.m4 serial 3 -+dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# 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. -+# Test for the GNU C Library, version 2.1 or newer. -+# From Bruno Haible. - --# 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. -+AC_DEFUN([gl_GLIBC21], -+ [ -+ AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, -+ ac_cv_gnu_library_2_1, -+ [AC_EGREP_CPP([Lucky GNU user], -+ [ -+#include -+#ifdef __GNU_LIBRARY__ -+ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) -+ Lucky GNU user -+ #endif -+#endif -+ ], -+ ac_cv_gnu_library_2_1=yes, -+ ac_cv_gnu_library_2_1=no) -+ ] -+ ) -+ AC_SUBST(GLIBC21) -+ GLIBC21="$ac_cv_gnu_library_2_1" -+ ] -+) - --# serial 3 -+# iconv.m4 serial AM4 (gettext-0.11.3) -+dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# AM_MISSING_PROG(NAME, PROGRAM) --# ------------------------------ --AC_DEFUN([AM_MISSING_PROG], --[AC_REQUIRE([AM_MISSING_HAS_RUN]) --$1=${$1-"${am_missing_run}$2"} --AC_SUBST($1)]) -+dnl From Bruno Haible. - -+AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], -+[ -+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. -+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -+ AC_REQUIRE([AC_LIB_RPATH]) - --# AM_MISSING_HAS_RUN --# ------------------ --# Define MISSING if not defined so far and test if it supports --run. --# If it does, set am_missing_run to use it, otherwise, to nothing. --AC_DEFUN([AM_MISSING_HAS_RUN], --[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl --test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" --# Use eval to expand $SHELL --if eval "$MISSING --run true"; then -- am_missing_run="$MISSING --run " --else -- am_missing_run= -- AC_MSG_WARN([`missing' script is too old or missing]) --fi -+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV -+ dnl accordingly. -+ AC_LIB_LINKFLAGS_BODY([iconv]) - ]) - --# AM_AUX_DIR_EXPAND -- --# Copyright 2001 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., 59 Temple Place - Suite 330, Boston, MA --# 02111-1307, USA. -+AC_DEFUN([AM_ICONV_LINK], -+[ -+ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and -+ dnl those with the standalone portable GNU libiconv installed). - --# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets --# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to --# `$srcdir', `$srcdir/..', or `$srcdir/../..'. --# --# Of course, Automake must honor this variable whenever it calls a --# tool from the auxiliary directory. The problem is that $srcdir (and --# therefore $ac_aux_dir as well) can be either absolute or relative, --# depending on how configure is run. This is pretty annoying, since --# it makes $ac_aux_dir quite unusable in subdirectories: in the top --# source directory, any form will work fine, but in subdirectories a --# relative path needs to be adjusted first. --# --# $ac_aux_dir/missing --# fails when called from a subdirectory if $ac_aux_dir is relative --# $top_srcdir/$ac_aux_dir/missing --# fails if $ac_aux_dir is absolute, --# fails when called from a subdirectory in a VPATH build with --# a relative $ac_aux_dir --# --# The reason of the latter failure is that $top_srcdir and $ac_aux_dir --# are both prefixed by $srcdir. In an in-source build this is usually --# harmless because $srcdir is `.', but things will broke when you --# start a VPATH build or use an absolute $srcdir. --# --# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, --# iff we strip the leading $srcdir from $ac_aux_dir. That would be: --# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` --# and then we would define $MISSING as --# MISSING="\${SHELL} $am_aux_dir/missing" --# This will work as long as MISSING is not called from configure, because --# unfortunately $(top_srcdir) has no meaning in configure. --# However there are other variables, like CC, which are often used in --# configure, and could therefore not use this "fixed" $ac_aux_dir. --# --# Another solution, used here, is to always expand $ac_aux_dir to an --# absolute PATH. The drawback is that using absolute paths prevent a --# configured tree to be moved without reconfiguration. -+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV -+ dnl accordingly. -+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - --# Rely on autoconf to set up CDPATH properly. --AC_PREREQ([2.50]) -+ dnl Add $INCICONV to CPPFLAGS before performing the following checks, -+ dnl because if the user has installed libiconv and not disabled its use -+ dnl via --without-libiconv-prefix, he wants to use it. The first -+ dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. -+ am_save_CPPFLAGS="$CPPFLAGS" -+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - --AC_DEFUN([AM_AUX_DIR_EXPAND], [ --# expand $ac_aux_dir to an absolute path --am_aux_dir=`cd $ac_aux_dir && pwd` -+ AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ -+ am_cv_func_iconv="no, consider installing GNU libiconv" -+ am_cv_lib_iconv=no -+ AC_TRY_LINK([#include -+#include ], -+ [iconv_t cd = iconv_open("",""); -+ iconv(cd,NULL,NULL,NULL,NULL); -+ iconv_close(cd);], -+ am_cv_func_iconv=yes) -+ if test "$am_cv_func_iconv" != yes; then -+ am_save_LIBS="$LIBS" -+ LIBS="$LIBS $LIBICONV" -+ AC_TRY_LINK([#include -+#include ], -+ [iconv_t cd = iconv_open("",""); -+ iconv(cd,NULL,NULL,NULL,NULL); -+ iconv_close(cd);], -+ am_cv_lib_iconv=yes -+ am_cv_func_iconv=yes) -+ LIBS="$am_save_LIBS" -+ fi -+ ]) -+ if test "$am_cv_func_iconv" = yes; then -+ AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) -+ fi -+ if test "$am_cv_lib_iconv" = yes; then -+ AC_MSG_CHECKING([how to link with libiconv]) -+ AC_MSG_RESULT([$LIBICONV]) -+ else -+ dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV -+ dnl either. -+ CPPFLAGS="$am_save_CPPFLAGS" -+ LIBICONV= -+ LTLIBICONV= -+ fi -+ AC_SUBST(LIBICONV) -+ AC_SUBST(LTLIBICONV) - ]) - --# AM_PROG_INSTALL_SH --# ------------------ --# Define $install_sh. -+AC_DEFUN([AM_ICONV], -+[ -+ AM_ICONV_LINK -+ if test "$am_cv_func_iconv" = yes; then -+ AC_MSG_CHECKING([for iconv declaration]) -+ AC_CACHE_VAL(am_cv_proto_iconv, [ -+ AC_TRY_COMPILE([ -+#include -+#include -+extern -+#ifdef __cplusplus -+"C" -+#endif -+#if defined(__STDC__) || defined(__cplusplus) -+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -+#else -+size_t iconv(); -+#endif -+], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") -+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) -+ am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` -+ AC_MSG_RESULT([$]{ac_t:- -+ }[$]am_cv_proto_iconv) -+ AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, -+ [Define as const if the declaration of iconv() needs const.]) -+ fi -+]) - --# Copyright 2001 Free Software Foundation, Inc. -+# intdiv0.m4 serial 1 (gettext-0.11.3) -+dnl Copyright (C) 2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# 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. -+dnl From Bruno Haible. - --# 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. -+AC_DEFUN([gt_INTDIV0], -+[ -+ AC_REQUIRE([AC_PROG_CC])dnl -+ AC_REQUIRE([AC_CANONICAL_HOST])dnl - --# 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. -+ AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], -+ gt_cv_int_divbyzero_sigfpe, -+ [ -+ AC_TRY_RUN([ -+#include -+#include - --AC_DEFUN([AM_PROG_INSTALL_SH], --[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl --install_sh=${install_sh-"$am_aux_dir/install-sh"} --AC_SUBST(install_sh)]) -+static void -+#ifdef __cplusplus -+sigfpe_handler (int sig) -+#else -+sigfpe_handler (sig) int sig; -+#endif -+{ -+ /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ -+ exit (sig != SIGFPE); -+} - --# AM_PROG_INSTALL_STRIP -- --# Copyright 2001 Free Software Foundation, Inc. -+int x = 1; -+int y = 0; -+int z; -+int nan; - --# 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. -+int main () -+{ -+ signal (SIGFPE, sigfpe_handler); -+/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ -+#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) -+ signal (SIGTRAP, sigfpe_handler); -+#endif -+/* Linux/SPARC yields signal SIGILL. */ -+#if defined (__sparc__) && defined (__linux__) -+ signal (SIGILL, sigfpe_handler); -+#endif - --# 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. -+ z = x / y; -+ nan = y / y; -+ exit (1); -+} -+], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, -+ [ -+ # Guess based on the CPU. -+ case "$host_cpu" in -+ alpha* | i[34567]86 | m68k | s390*) -+ gt_cv_int_divbyzero_sigfpe="guessing yes";; -+ *) -+ gt_cv_int_divbyzero_sigfpe="guessing no";; -+ esac -+ ]) -+ ]) -+ case "$gt_cv_int_divbyzero_sigfpe" in -+ *yes) value=1;; -+ *) value=0;; -+ esac -+ AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, -+ [Define if integer division by zero raises signal SIGFPE.]) -+]) - --# 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. -+# intmax.m4 serial 2 (gettext-0.14.2) -+dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# One issue with vendor `install' (even GNU) is that you can't --# specify the program used to strip binaries. This is especially --# annoying in cross-compiling environments, where the build's strip --# is unlikely to handle the host's binaries. --# Fortunately install-sh will honor a STRIPPROG variable, so we --# always use install-sh in `make install-strip', and initialize --# STRIPPROG with the value of the STRIP variable (set by the user). --AC_DEFUN([AM_PROG_INSTALL_STRIP], --[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl --# Installed binaries are usually stripped using `strip' when the user --# run `make install-strip'. However `strip' might not be the right --# tool to use in cross-compilation environments, therefore Automake --# will honor the `STRIP' environment variable to overrule this program. --dnl Don't test for $cross_compiling = yes, because it might be `maybe'. --if test "$cross_compiling" != no; then -- AC_CHECK_TOOL([STRIP], [strip], :) --fi --INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" --AC_SUBST([INSTALL_STRIP_PROGRAM])]) -+dnl From Bruno Haible. -+dnl Test whether the system has the 'intmax_t' type, but don't attempt to -+dnl find a replacement if it is lacking. - --# serial 4 -*- Autoconf -*- -+AC_DEFUN([gt_TYPE_INTMAX_T], -+[ -+ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) -+ AC_REQUIRE([gl_AC_HEADER_STDINT_H]) -+ AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, -+ [AC_TRY_COMPILE([ -+#include -+#include -+#if HAVE_STDINT_H_WITH_UINTMAX -+#include -+#endif -+#if HAVE_INTTYPES_H_WITH_UINTMAX -+#include -+#endif -+], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) -+ if test $gt_cv_c_intmax_t = yes; then -+ AC_DEFINE(HAVE_INTMAX_T, 1, -+ [Define if you have the 'intmax_t' type in or .]) -+ fi -+]) - --# Copyright 1999, 2000, 2001 Free Software Foundation, Inc. -+# inttypes-pri.m4 serial 1 (gettext-0.11.4) -+dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# 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. -+dnl From Bruno Haible. - --# 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. -+# Define PRI_MACROS_BROKEN if exists and defines the PRI* -+# macros to non-string values. This is the case on AIX 4.3.3. - --# 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. -+AC_DEFUN([gt_INTTYPES_PRI], -+[ -+ AC_REQUIRE([gt_HEADER_INTTYPES_H]) -+ if test $gt_cv_header_inttypes_h = yes; then -+ AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], -+ gt_cv_inttypes_pri_broken, -+ [ -+ AC_TRY_COMPILE([#include -+#ifdef PRId32 -+char *p = PRId32; -+#endif -+], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) -+ ]) -+ fi -+ if test "$gt_cv_inttypes_pri_broken" = yes; then -+ AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, -+ [Define if exists and defines unusable PRI* macros.]) -+ fi -+]) - -+# inttypes.m4 serial 1 (gettext-0.11.4) -+dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be --# written in clear, in which case automake, when reading aclocal.m4, --# will think it sees a *use*, and therefore will trigger all it's --# C support machinery. Also note that it means that autoscan, seeing --# CC etc. in the Makefile, will ask for an AC_PROG_CC use... -+dnl From Paul Eggert. - -+# Define HAVE_INTTYPES_H if exists and doesn't clash with -+# . - -+AC_DEFUN([gt_HEADER_INTTYPES_H], -+[ -+ AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, -+ [ -+ AC_TRY_COMPILE( -+ [#include -+#include ], -+ [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) -+ ]) -+ if test $gt_cv_header_inttypes_h = yes; then -+ AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, -+ [Define if exists and doesn't clash with .]) -+ fi -+]) - --# _AM_DEPENDENCIES(NAME) --# ---------------------- --# See how the compiler implements dependency checking. --# NAME is "CC", "CXX", "GCJ", or "OBJC". --# We try a few techniques and use that to set a single cache variable. --# --# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was --# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular --# dependency, and given that the user is not expected to run this macro, --# just rely on AC_PROG_CC. --AC_DEFUN([_AM_DEPENDENCIES], --[AC_REQUIRE([AM_SET_DEPDIR])dnl --AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl --AC_REQUIRE([AM_MAKE_INCLUDE])dnl --AC_REQUIRE([AM_DEP_TRACK])dnl -+# inttypes_h.m4 serial 6 -+dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --ifelse([$1], CC, [depcc="$CC" am_compiler_list=], -- [$1], CXX, [depcc="$CXX" am_compiler_list=], -- [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], -- [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], -- [depcc="$$1" am_compiler_list=]) -+dnl From Paul Eggert. - --AC_CACHE_CHECK([dependency style of $depcc], -- [am_cv_$1_dependencies_compiler_type], --[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then -- # We make a subdir and do the tests there. Otherwise we can end up -- # making bogus files that we don't know about and never remove. For -- # instance it was reported that on HP-UX the gcc test will end up -- # making a dummy file named `D' -- because `-MD' means `put the output -- # in D'. -- mkdir conftest.dir -- # Copy depcomp to subdir because otherwise we won't find it if we're -- # using a relative directory. -- cp "$am_depcomp" conftest.dir -- cd conftest.dir -+# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, -+# doesn't clash with , and declares uintmax_t. - -- am_cv_$1_dependencies_compiler_type=none -- if test "$am_compiler_list" = ""; then -- am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` -+AC_DEFUN([gl_AC_HEADER_INTTYPES_H], -+[ -+ AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, -+ [AC_TRY_COMPILE( -+ [#include -+#include ], -+ [uintmax_t i = (uintmax_t) -1;], -+ gl_cv_header_inttypes_h=yes, -+ gl_cv_header_inttypes_h=no)]) -+ if test $gl_cv_header_inttypes_h = yes; then -+ AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, -+ [Define if exists, doesn't clash with , -+ and declares uintmax_t. ]) - fi -- for depmode in $am_compiler_list; do -- # We need to recreate these files for each test, as the compiler may -- # overwrite some of them when testing with obscure command lines. -- # This happens at least with the AIX C compiler. -- echo '#include "conftest.h"' > conftest.c -- echo 'int i;' > conftest.h -- echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf -- -- case $depmode in -- nosideeffect) -- # after this tag, mechanisms are not by side-effect, so they'll -- # only be used when explicitly requested -- if test "x$enable_dependency_tracking" = xyes; then -- continue -- else -- break -- fi -- ;; -- none) break ;; -- esac -- # We check with `-c' and `-o' for the sake of the "dashmstdout" -- # mode. It turns out that the SunPro C++ compiler does not properly -- # handle `-M -o', and we need to detect this. -- if depmode=$depmode \ -- source=conftest.c object=conftest.o \ -- depfile=conftest.Po tmpdepfile=conftest.TPo \ -- $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && -- grep conftest.h conftest.Po > /dev/null 2>&1 && -- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then -- am_cv_$1_dependencies_compiler_type=$depmode -- break -- fi -- done -- -- cd .. -- rm -rf conftest.dir --else -- am_cv_$1_dependencies_compiler_type=none --fi --]) --AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) - ]) - -+# lcmessage.m4 serial 4 (gettext-0.14.2) -+dnl Copyright (C) 1995-2002, 2004-2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+dnl -+dnl This file can can be used in projects which are not available under -+dnl the GNU General Public License or the GNU Library General Public -+dnl License but which still want to provide support for the GNU gettext -+dnl functionality. -+dnl Please note that the actual code of the GNU gettext library is covered -+dnl by the GNU Library General Public License, and the rest of the GNU -+dnl gettext package package is covered by the GNU General Public License. -+dnl They are *not* in the public domain. - --# AM_SET_DEPDIR --# ------------- --# Choose a directory name for dependency files. --# This macro is AC_REQUIREd in _AM_DEPENDENCIES --AC_DEFUN([AM_SET_DEPDIR], --[rm -f .deps 2>/dev/null --mkdir .deps 2>/dev/null --if test -d .deps; then -- DEPDIR=.deps --else -- # MS-DOS does not allow filenames that begin with a dot. -- DEPDIR=_deps --fi --rmdir .deps 2>/dev/null --AC_SUBST([DEPDIR]) --]) -+dnl Authors: -+dnl Ulrich Drepper , 1995. - -+# Check whether LC_MESSAGES is available in . - --# AM_DEP_TRACK --# ------------ --AC_DEFUN([AM_DEP_TRACK], --[AC_ARG_ENABLE(dependency-tracking, --[ --disable-dependency-tracking Speeds up one-time builds -- --enable-dependency-tracking Do not reject slow dependency extractors]) --if test "x$enable_dependency_tracking" != xno; then -- am_depcomp="$ac_aux_dir/depcomp" -- AMDEPBACKSLASH='\' --fi --AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) --AC_SUBST([AMDEPBACKSLASH]) -+AC_DEFUN([gt_LC_MESSAGES], -+[ -+ AC_CACHE_CHECK([for LC_MESSAGES], gt_cv_val_LC_MESSAGES, -+ [AC_TRY_LINK([#include ], [return LC_MESSAGES], -+ gt_cv_val_LC_MESSAGES=yes, gt_cv_val_LC_MESSAGES=no)]) -+ if test $gt_cv_val_LC_MESSAGES = yes; then -+ AC_DEFINE(HAVE_LC_MESSAGES, 1, -+ [Define if your file defines LC_MESSAGES.]) -+ fi - ]) - --# Generate code to set up dependency tracking. -*- Autoconf -*- -- --# Copyright 1999, 2000, 2001, 2002 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. -+# lib-ld.m4 serial 3 (gettext-0.13) -+dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# 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. -+dnl Subroutines of libtool.m4, -+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision -+dnl with libtool.m4. - --#serial 2 -+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. -+AC_DEFUN([AC_LIB_PROG_LD_GNU], -+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, -+[# I'd rather use --version here, but apparently some GNU ld's only accept -v. -+case `$LD -v 2>&1 /dev/null 2>&1; then -- dirpart=`AS_DIRNAME("$mf")` -+dnl From libtool-1.4. Sets the variable LD. -+AC_DEFUN([AC_LIB_PROG_LD], -+[AC_ARG_WITH(gnu-ld, -+[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], -+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) -+AC_REQUIRE([AC_PROG_CC])dnl -+AC_REQUIRE([AC_CANONICAL_HOST])dnl -+# Prepare PATH_SEPARATOR. -+# The user is always right. -+if test "${PATH_SEPARATOR+set}" != set; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then -+ PATH_SEPARATOR=';' - else -- continue -+ PATH_SEPARATOR=: - fi -- grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue -- # Extract the definition of DEP_FILES from the Makefile without -- # running `make'. -- DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` -- test -z "$DEPDIR" && continue -- # When using ansi2knr, U may be empty or an underscore; expand it -- U=`sed -n -e '/^U = / s///p' < "$mf"` -- test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" -- # We invoke sed twice because it is the simplest approach to -- # changing $(DEPDIR) to its actual value in the expansion. -- for file in `sed -n -e ' -- /^DEP_FILES = .*\\\\$/ { -- s/^DEP_FILES = // -- :loop -- s/\\\\$// -- p -- n -- /\\\\$/ b loop -- p -- } -- /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ -- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do -- # Make sure the directory exists. -- test -f "$dirpart/$file" && continue -- fdir=`AS_DIRNAME(["$file"])` -- AS_MKDIR_P([$dirpart/$fdir]) -- # echo "creating $dirpart/$file" -- echo '# dummy' > "$dirpart/$file" -- done --done --])# _AM_OUTPUT_DEPENDENCY_COMMANDS -- -- --# AM_OUTPUT_DEPENDENCY_COMMANDS --# ----------------------------- --# This macro should only be invoked once -- use via AC_REQUIRE. --# --# This code is only required when automatic dependency tracking --# is enabled. FIXME. This creates each `.P' file that we will --# need in order to bootstrap the dependency handling code. --AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], --[AC_CONFIG_COMMANDS([depfiles], -- [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], -- [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) --]) -- --# Copyright 2001 Free Software Foundation, Inc. -*- Autoconf -*- -- --# 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., 59 Temple Place - Suite 330, Boston, MA --# 02111-1307, USA. -- --# serial 2 -- --# AM_MAKE_INCLUDE() --# ----------------- --# Check to see how make treats includes. --AC_DEFUN([AM_MAKE_INCLUDE], --[am_make=${MAKE-make} --cat > confinc << 'END' --doit: -- @echo done --END --# If we don't find an include directive, just comment out the code. --AC_MSG_CHECKING([for style of include used by $am_make]) --am__include="#" --am__quote= --_am_result=none --# First try GNU make style include. --echo "include confinc" > confmf --# We grep out `Entering directory' and `Leaving directory' --# messages which can occur if `w' ends up in MAKEFLAGS. --# In particular we don't look at `^make:' because GNU make might --# be invoked under some other name (usually "gmake"), in which --# case it prints its new name instead of `make'. --if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then -- am__include=include -- am__quote= -- _am_result=GNU -+ rm -f conf$$.sh - fi --# Now try BSD make style include. --if test "$am__include" = "#"; then -- echo '.include "confinc"' > confmf -- if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then -- am__include=.include -- am__quote="\"" -- _am_result=BSD -- fi -+ac_prog=ld -+if test "$GCC" = yes; then -+ # Check if gcc -print-prog-name=ld gives a path. -+ AC_MSG_CHECKING([for ld used by GCC]) -+ case $host in -+ *-*-mingw*) -+ # gcc leaves a trailing carriage return which upsets mingw -+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; -+ *) -+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; -+ esac -+ case $ac_prog in -+ # Accept absolute paths. -+ [[\\/]* | [A-Za-z]:[\\/]*)] -+ [re_direlt='/[^/][^/]*/\.\./'] -+ # Canonicalize the path of ld -+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` -+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` -+ done -+ test -z "$LD" && LD="$ac_prog" -+ ;; -+ "") -+ # If it fails, then pretend we aren't using GCC. -+ ac_prog=ld -+ ;; -+ *) -+ # If it is relative, then search for the first ld in PATH. -+ with_gnu_ld=unknown -+ ;; -+ esac -+elif test "$with_gnu_ld" = yes; then -+ AC_MSG_CHECKING([for GNU ld]) -+else -+ AC_MSG_CHECKING([for non-GNU ld]) - fi --AC_SUBST(am__include) --AC_SUBST(am__quote) --AC_MSG_RESULT($_am_result) --rm -f confinc confmf -+AC_CACHE_VAL(acl_cv_path_LD, -+[if test -z "$LD"; then -+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" -+ for ac_dir in $PATH; do -+ test -z "$ac_dir" && ac_dir=. -+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then -+ acl_cv_path_LD="$ac_dir/$ac_prog" -+ # Check to see if the program is GNU ld. I'd rather use --version, -+ # but apparently some GNU ld's only accept -v. -+ # Break only if it was the GNU/non-GNU ld that we prefer. -+ case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in -+ *GNU* | *'with BFD'*) -+ test "$with_gnu_ld" != no && break ;; -+ *) -+ test "$with_gnu_ld" != yes && break ;; -+ esac -+ fi -+ done -+ IFS="$ac_save_ifs" -+else -+ acl_cv_path_LD="$LD" # Let the user override the test with a path. -+fi]) -+LD="$acl_cv_path_LD" -+if test -n "$LD"; then -+ AC_MSG_RESULT($LD) -+else -+ AC_MSG_RESULT(no) -+fi -+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) -+AC_LIB_PROG_LD_GNU - ]) - --# AM_CONDITIONAL -*- Autoconf -*- -- --# Copyright 1997, 2000, 2001 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. -+# lib-link.m4 serial 6 (gettext-0.14.3) -+dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --# 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. -+dnl From Bruno Haible. - --# 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. -+AC_PREREQ(2.50) - --# serial 5 -+dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and -+dnl the libraries corresponding to explicit and implicit dependencies. -+dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and -+dnl augments the CPPFLAGS variable. -+AC_DEFUN([AC_LIB_LINKFLAGS], -+[ -+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -+ AC_REQUIRE([AC_LIB_RPATH]) -+ define([Name],[translit([$1],[./-], [___])]) -+ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], -+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) -+ AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ -+ AC_LIB_LINKFLAGS_BODY([$1], [$2]) -+ ac_cv_lib[]Name[]_libs="$LIB[]NAME" -+ ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" -+ ac_cv_lib[]Name[]_cppflags="$INC[]NAME" -+ ]) -+ LIB[]NAME="$ac_cv_lib[]Name[]_libs" -+ LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" -+ INC[]NAME="$ac_cv_lib[]Name[]_cppflags" -+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) -+ AC_SUBST([LIB]NAME) -+ AC_SUBST([LTLIB]NAME) -+ dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the -+ dnl results of this search when this library appears as a dependency. -+ HAVE_LIB[]NAME=yes -+ undefine([Name]) -+ undefine([NAME]) -+]) - --AC_PREREQ(2.52) -+dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) -+dnl searches for libname and the libraries corresponding to explicit and -+dnl implicit dependencies, together with the specified include files and -+dnl the ability to compile and link the specified testcode. If found, it -+dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and -+dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and -+dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs -+dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. -+AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], -+[ -+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -+ AC_REQUIRE([AC_LIB_RPATH]) -+ define([Name],[translit([$1],[./-], [___])]) -+ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], -+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - --# AM_CONDITIONAL(NAME, SHELL-CONDITION) --# ------------------------------------- --# Define a conditional. --AC_DEFUN([AM_CONDITIONAL], --[ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], -- [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl --AC_SUBST([$1_TRUE]) --AC_SUBST([$1_FALSE]) --if $2; then -- $1_TRUE= -- $1_FALSE='#' --else -- $1_TRUE='#' -- $1_FALSE= --fi --AC_CONFIG_COMMANDS_PRE( --[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then -- AC_MSG_ERROR([conditional \"$1\" was never defined. --Usually this means the macro was only invoked conditionally.]) --fi])]) -+ dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME -+ dnl accordingly. -+ AC_LIB_LINKFLAGS_BODY([$1], [$2]) - --# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- -+ dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, -+ dnl because if the user has installed lib[]Name and not disabled its use -+ dnl via --without-lib[]Name-prefix, he wants to use it. -+ ac_save_CPPFLAGS="$CPPFLAGS" -+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - --# serial 46 AC_PROG_LIBTOOL -+ AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ -+ ac_save_LIBS="$LIBS" -+ LIBS="$LIBS $LIB[]NAME" -+ AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) -+ LIBS="$ac_save_LIBS" -+ ]) -+ if test "$ac_cv_lib[]Name" = yes; then -+ HAVE_LIB[]NAME=yes -+ AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) -+ AC_MSG_CHECKING([how to link with lib[]$1]) -+ AC_MSG_RESULT([$LIB[]NAME]) -+ else -+ HAVE_LIB[]NAME=no -+ dnl If $LIB[]NAME didn't lead to a usable library, we don't need -+ dnl $INC[]NAME either. -+ CPPFLAGS="$ac_save_CPPFLAGS" -+ LIB[]NAME= -+ LTLIB[]NAME= -+ fi -+ AC_SUBST([HAVE_LIB]NAME) -+ AC_SUBST([LIB]NAME) -+ AC_SUBST([LTLIB]NAME) -+ undefine([Name]) -+ undefine([NAME]) -+]) - --AC_DEFUN([AC_PROG_LIBTOOL], --[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -- --# This can be used to rebuild libtool when needed --LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" -- --# Always use our own libtool. --LIBTOOL='$(SHELL) $(top_builddir)/libtool' --AC_SUBST(LIBTOOL)dnl -- --# Prevent multiple expansion --define([AC_PROG_LIBTOOL], []) --]) -- --AC_DEFUN([AC_LIBTOOL_SETUP], --[AC_PREREQ(2.13)dnl --AC_REQUIRE([AC_ENABLE_SHARED])dnl --AC_REQUIRE([AC_ENABLE_STATIC])dnl --AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl --AC_REQUIRE([AC_CANONICAL_HOST])dnl --AC_REQUIRE([AC_CANONICAL_BUILD])dnl --AC_REQUIRE([AC_PROG_CC])dnl --AC_REQUIRE([AC_PROG_LD])dnl --AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl --AC_REQUIRE([AC_PROG_NM])dnl --AC_REQUIRE([AC_PROG_LN_S])dnl --AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl --AC_REQUIRE([AC_OBJEXT])dnl --AC_REQUIRE([AC_EXEEXT])dnl --dnl -- --_LT_AC_PROG_ECHO_BACKSLASH --# Only perform the check for file, if the check method requires it --case $deplibs_check_method in --file_magic*) -- if test "$file_magic_cmd" = '$MAGIC_CMD'; then -- AC_PATH_MAGIC -- fi -- ;; --esac -- --AC_CHECK_TOOL(RANLIB, ranlib, :) --AC_CHECK_TOOL(STRIP, strip, :) -- --ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) --ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], --enable_win32_dll=yes, enable_win32_dll=no) -- --AC_ARG_ENABLE(libtool-lock, -- [ --disable-libtool-lock avoid locking (might break parallel builds)]) --test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes -- --# Some flags need to be propagated to the compiler or linker for good --# libtool support. --case $host in --*-*-irix6*) -- # Find out which ABI we are using. -- echo '[#]line __oline__ "configure"' > conftest.$ac_ext -- if AC_TRY_EVAL(ac_compile); then -- case `/usr/bin/file conftest.$ac_objext` in -- *32-bit*) -- LD="${LD-ld} -32" -- ;; -- *N32*) -- LD="${LD-ld} -n32" -- ;; -- *64-bit*) -- LD="${LD-ld} -64" -- ;; -- esac -- fi -- rm -rf conftest* -- ;; -- --*-*-sco3.2v5*) -- # On SCO OpenServer 5, we need -belf to get full-featured binaries. -- SAVE_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -belf" -- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, -- [AC_LANG_SAVE -- AC_LANG_C -- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) -- AC_LANG_RESTORE]) -- if test x"$lt_cv_cc_needs_belf" != x"yes"; then -- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf -- CFLAGS="$SAVE_CFLAGS" -- fi -- ;; -- --ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], --[*-*-cygwin* | *-*-mingw* | *-*-pw32*) -- AC_CHECK_TOOL(DLLTOOL, dlltool, false) -- AC_CHECK_TOOL(AS, as, false) -- AC_CHECK_TOOL(OBJDUMP, objdump, false) -- -- # recent cygwin and mingw systems supply a stub DllMain which the user -- # can override, but on older systems we have to supply one -- AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, -- [AC_TRY_LINK([], -- [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); -- DllMain (0, 0, 0);], -- [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])]) -- -- case $host/$CC in -- *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) -- # old mingw systems require "-dll" to link a DLL, while more recent ones -- # require "-mdll" -- SAVE_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -mdll" -- AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, -- [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])]) -- CFLAGS="$SAVE_CFLAGS" ;; -- *-*-cygwin* | *-*-pw32*) -- # cygwin systems need to pass --dll to the linker, and not link -- # crt.o which will require a WinMain@16 definition. -- lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; -- esac -- ;; -+dnl Determine the platform dependent parameters needed to use rpath: -+dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, -+dnl hardcode_direct, hardcode_minus_L. -+AC_DEFUN([AC_LIB_RPATH], -+[ -+ dnl Tell automake >= 1.10 to complain if config.rpath is missing. -+ m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) -+ AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS -+ AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host -+ AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir -+ AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ -+ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ -+ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh -+ . ./conftest.sh -+ rm -f ./conftest.sh -+ acl_cv_rpath=done - ]) --esac -- --_LT_AC_LTCONFIG_HACK -- -+ wl="$acl_cv_wl" -+ libext="$acl_cv_libext" -+ shlibext="$acl_cv_shlibext" -+ hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" -+ hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" -+ hardcode_direct="$acl_cv_hardcode_direct" -+ hardcode_minus_L="$acl_cv_hardcode_minus_L" -+ dnl Determine whether the user wants rpath handling at all. -+ AC_ARG_ENABLE(rpath, -+ [ --disable-rpath do not hardcode runtime library paths], -+ :, enable_rpath=yes) - ]) - --# AC_LIBTOOL_HEADER_ASSERT --# ------------------------ --AC_DEFUN([AC_LIBTOOL_HEADER_ASSERT], --[AC_CACHE_CHECK([whether $CC supports assert without backlinking], -- [lt_cv_func_assert_works], -- [case $host in -- *-*-solaris*) -- if test "$GCC" = yes && test "$with_gnu_ld" != yes; then -- case `$CC --version 2>/dev/null` in -- [[12]].*) lt_cv_func_assert_works=no ;; -- *) lt_cv_func_assert_works=yes ;; -- esac -- fi -- ;; -- esac]) -- --if test "x$lt_cv_func_assert_works" = xyes; then -- AC_CHECK_HEADERS(assert.h) --fi --])# AC_LIBTOOL_HEADER_ASSERT -- --# _LT_AC_CHECK_DLFCN --# -------------------- --AC_DEFUN([_LT_AC_CHECK_DLFCN], --[AC_CHECK_HEADERS(dlfcn.h) --])# _LT_AC_CHECK_DLFCN -- --# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE --# --------------------------------- --AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], --[AC_REQUIRE([AC_CANONICAL_HOST]) --AC_REQUIRE([AC_PROG_NM]) --AC_REQUIRE([AC_OBJEXT]) --# Check for command to grab the raw symbol name followed by C symbol from nm. --AC_MSG_CHECKING([command to parse $NM output]) --AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl -- --# These are sane defaults that work on at least a few old systems. --# [They come from Ultrix. What could be older than Ultrix?!! ;)] -- --# Character class describing NM global symbol codes. --symcode='[[BCDEGRST]]' -- --# Regexp to match symbols that can be accessed directly from C. --sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' -- --# Transform the above into a raw symbol and a C symbol. --symxfrm='\1 \2\3 \3' -- --# Transform an extracted symbol line into a proper C declaration --lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" -- --# Transform an extracted symbol line into symbol name and symbol address --lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -- --# Define system-specific variables. --case $host_os in --aix*) -- symcode='[[BCDT]]' -- ;; --cygwin* | mingw* | pw32*) -- symcode='[[ABCDGISTW]]' -- ;; --hpux*) # Its linker distinguishes data from code symbols -- lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" -- lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -- ;; --irix*) -- symcode='[[BCDEGRST]]' -- ;; --solaris* | sysv5*) -- symcode='[[BDT]]' -- ;; --sysv4) -- symcode='[[DFNSTU]]' -- ;; --esac -- --# Handle CRLF in mingw tool chain --opt_cr= --case $host_os in --mingw*) -- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp -- ;; --esac -- --# If we're using GNU nm, then use its standard symbol codes. --if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then -- symcode='[[ABCDGISTW]]' --fi -- --# Try without a prefix undercore, then with it. --for ac_symprfx in "" "_"; do -- -- # Write the raw and C identifiers. --lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" -- -- # Check to see that the pipe works correctly. -- pipe_works=no -- rm -f conftest* -- cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then -- # Try sorting and uniquifying the output. -- if sort "$nlist" | uniq > "$nlist"T; then -- mv -f "$nlist"T "$nlist" -+dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -+dnl the libraries corresponding to explicit and implicit dependencies. -+dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -+AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -+[ -+ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], -+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) -+ dnl By default, look in $includedir and $libdir. -+ use_additional=yes -+ AC_LIB_WITH_FINAL_PREFIX([ -+ eval additional_includedir=\"$includedir\" -+ eval additional_libdir=\"$libdir\" -+ ]) -+ AC_LIB_ARG_WITH([lib$1-prefix], -+[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib -+ --without-lib$1-prefix don't search for lib$1 in includedir and libdir], -+[ -+ if test "X$withval" = "Xno"; then -+ use_additional=no -+ else -+ if test "X$withval" = "X"; then -+ AC_LIB_WITH_FINAL_PREFIX([ -+ eval additional_includedir=\"$includedir\" -+ eval additional_libdir=\"$libdir\" -+ ]) - else -- rm -f "$nlist"T -- fi -- -- # Make sure that we snagged all the symbols we need. -- if egrep ' nm_test_var$' "$nlist" >/dev/null; then -- if egrep ' nm_test_func$' "$nlist" >/dev/null; then -- cat < conftest.$ac_ext --#ifdef __cplusplus --extern "C" { --#endif -- --EOF -- # Now generate the symbol file. -- eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' -- -- cat <> conftest.$ac_ext --#if defined (__STDC__) && __STDC__ --# define lt_ptr void * --#else --# define lt_ptr char * --# define const --#endif -- --/* The mapping between symbol names and symbols. */ --const struct { -- const char *name; -- lt_ptr address; --} --lt_preloaded_symbols[[]] = --{ --EOF -- sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext -- cat <<\EOF >> conftest.$ac_ext -- {0, (lt_ptr) 0} --}; -- --#ifdef __cplusplus --} --#endif --EOF -- # Now try linking the two files. -- mv conftest.$ac_objext conftstm.$ac_objext -- save_LIBS="$LIBS" -- save_CFLAGS="$CFLAGS" -- LIBS="conftstm.$ac_objext" -- CFLAGS="$CFLAGS$no_builtin_flag" -- if AC_TRY_EVAL(ac_link) && test -s conftest; then -- pipe_works=yes -- fi -- LIBS="$save_LIBS" -- CFLAGS="$save_CFLAGS" -- else -- echo "cannot find nm_test_func in $nlist" >&AC_FD_CC -- fi -- else -- echo "cannot find nm_test_var in $nlist" >&AC_FD_CC -- fi -- else -- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC -- fi -- else -- echo "$progname: failed program was:" >&AC_FD_CC -- cat conftest.$ac_ext >&5 -- fi -- rm -f conftest* conftst* -- -- # Do not use the global_symbol_pipe unless it works. -- if test "$pipe_works" = yes; then -- break -- else -- lt_cv_sys_global_symbol_pipe= -- fi --done --]) --global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" --if test -z "$lt_cv_sys_global_symbol_pipe"; then -- global_symbol_to_cdecl= -- global_symbol_to_c_name_address= --else -- global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" -- global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" --fi --if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; --then -- AC_MSG_RESULT(failed) --else -- AC_MSG_RESULT(ok) --fi --]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -- --# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR --# --------------------------------- --AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR], --[# Find the correct PATH separator. Usually this is `:', but --# DJGPP uses `;' like DOS. --if test "X${PATH_SEPARATOR+set}" != Xset; then -- UNAME=${UNAME-`uname 2>/dev/null`} -- case X$UNAME in -- *-DOS) lt_cv_sys_path_separator=';' ;; -- *) lt_cv_sys_path_separator=':' ;; -- esac -- PATH_SEPARATOR=$lt_cv_sys_path_separator --fi --])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR -- --# _LT_AC_PROG_ECHO_BACKSLASH --# -------------------------- --# Add some code to the start of the generated configure script which --# will find an echo command which doesn't interpret backslashes. --AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], --[ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], -- [AC_DIVERT_PUSH(NOTICE)]) --_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR -- --# Check that we are running under the correct shell. --SHELL=${CONFIG_SHELL-/bin/sh} -- --case X$ECHO in --X*--fallback-echo) -- # Remove one level of quotation (which was required for Make). -- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` -- ;; --esac -- --echo=${ECHO-echo} --if test "X[$]1" = X--no-reexec; then -- # Discard the --no-reexec flag, and continue. -- shift --elif test "X[$]1" = X--fallback-echo; then -- # Avoid inline document here, it may be left over -- : --elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then -- # Yippee, $echo works! -- : --else -- # Restart under the correct shell. -- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} --fi -- --if test "X[$]1" = X--fallback-echo; then -- # used as fallback echo -- shift -- cat </dev/null && -- echo_test_string="`eval $cmd`" && -- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null -- then -- break -- fi -- done --fi -- --if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- : --else -- # The Solaris, AIX, and Digital Unix default echo programs unquote -- # backslashes. This makes it impossible to quote backslashes using -- # echo "$something" | sed 's/\\/\\\\/g' -- # -- # So, first we look for a working echo in the user's PATH. -- -- IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR -- for dir in $PATH /usr/ucb; do -- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && -- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- echo="$dir/echo" -- break -- fi -- done -- IFS="$save_ifs" -- -- if test "X$echo" = Xecho; then -- # We didn't find a better echo, so look for alternatives. -- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- # This shell has a builtin print -r that does the trick. -- echo='print -r' -- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && -- test "X$CONFIG_SHELL" != X/bin/ksh; then -- # If we have ksh, try running configure again with it. -- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -- export ORIGINAL_CONFIG_SHELL -- CONFIG_SHELL=/bin/ksh -- export CONFIG_SHELL -- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} -- else -- # Try using printf. -- echo='printf %s\n' -- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- # Cool, printf works -- : -- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && -- test "X$echo_testing_string" = 'X\t' && -- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL -- export CONFIG_SHELL -- SHELL="$CONFIG_SHELL" -- export SHELL -- echo="$CONFIG_SHELL [$]0 --fallback-echo" -- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && -- test "X$echo_testing_string" = 'X\t' && -- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- echo="$CONFIG_SHELL [$]0 --fallback-echo" -- else -- # maybe with a smaller string... -- prev=: -- -- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do -- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null -- then -- break -- fi -- prev="$cmd" -- done -- -- if test "$prev" != 'sed 50q "[$]0"'; then -- echo_test_string=`eval $prev` -- export echo_test_string -- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} -- else -- # Oops. We lost completely, so just stick with echo. -- echo=echo -- fi -- fi -- fi -- fi --fi --fi -- --# Copy echo and quote the copy suitably for passing to libtool from --# the Makefile, instead of quoting the original, which is used later. --ECHO=$echo --if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then -- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" --fi -- --AC_SUBST(ECHO) --AC_DIVERT_POP --])# _LT_AC_PROG_ECHO_BACKSLASH -- --# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, --# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) --# ------------------------------------------------------------------ --AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], --[if test "$cross_compiling" = yes; then : -- [$4] --else -- AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -- lt_status=$lt_dlunknown -- cat > conftest.$ac_ext < --#endif -- --#include -- --#ifdef RTLD_GLOBAL --# define LT_DLGLOBAL RTLD_GLOBAL --#else --# ifdef DL_GLOBAL --# define LT_DLGLOBAL DL_GLOBAL --# else --# define LT_DLGLOBAL 0 --# endif --#endif -- --/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -- find out it does not work in some platform. */ --#ifndef LT_DLLAZY_OR_NOW --# ifdef RTLD_LAZY --# define LT_DLLAZY_OR_NOW RTLD_LAZY --# else --# ifdef DL_LAZY --# define LT_DLLAZY_OR_NOW DL_LAZY --# else --# ifdef RTLD_NOW --# define LT_DLLAZY_OR_NOW RTLD_NOW --# else --# ifdef DL_NOW --# define LT_DLLAZY_OR_NOW DL_NOW --# else --# define LT_DLLAZY_OR_NOW 0 --# endif --# endif --# endif --# endif --#endif -- --#ifdef __cplusplus --extern "C" void exit (int); --#endif -- --void fnord() { int i=42;} --int main () --{ -- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -- int status = $lt_dlunknown; -- -- if (self) -- { -- if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -- /* dlclose (self); */ -- } -- -- exit (status); --}] --EOF -- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then -- (./conftest; exit; ) 2>/dev/null -- lt_status=$? -- case x$lt_status in -- x$lt_dlno_uscore) $1 ;; -- x$lt_dlneed_uscore) $2 ;; -- x$lt_unknown|x*) $3 ;; -- esac -- else : -- # compilation failed -- $3 -- fi --fi --rm -fr conftest* --])# _LT_AC_TRY_DLOPEN_SELF -- --# AC_LIBTOOL_DLOPEN_SELF --# ------------------- --AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], --[if test "x$enable_dlopen" != xyes; then -- enable_dlopen=unknown -- enable_dlopen_self=unknown -- enable_dlopen_self_static=unknown --else -- lt_cv_dlopen=no -- lt_cv_dlopen_libs= -- -- case $host_os in -- beos*) -- lt_cv_dlopen="load_add_on" -- lt_cv_dlopen_libs= -- lt_cv_dlopen_self=yes -- ;; -- -- cygwin* | mingw* | pw32*) -- lt_cv_dlopen="LoadLibrary" -- lt_cv_dlopen_libs= -- ;; -- -- *) -- AC_CHECK_FUNC([shl_load], -- [lt_cv_dlopen="shl_load"], -- [AC_CHECK_LIB([dld], [shl_load], -- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], -- [AC_CHECK_FUNC([dlopen], -- [lt_cv_dlopen="dlopen"], -- [AC_CHECK_LIB([dl], [dlopen], -- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], -- [AC_CHECK_LIB([svld], [dlopen], -- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], -- [AC_CHECK_LIB([dld], [dld_link], -- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) -- ]) -- ]) -- ]) -- ]) -- ]) -- ;; -- esac -- -- if test "x$lt_cv_dlopen" != xno; then -- enable_dlopen=yes -- else -- enable_dlopen=no -- fi -- -- case $lt_cv_dlopen in -- dlopen) -- save_CPPFLAGS="$CPPFLAGS" -- AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -- -- save_LDFLAGS="$LDFLAGS" -- eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -- -- save_LIBS="$LIBS" -- LIBS="$lt_cv_dlopen_libs $LIBS" -- -- AC_CACHE_CHECK([whether a program can dlopen itself], -- lt_cv_dlopen_self, [dnl -- _LT_AC_TRY_DLOPEN_SELF( -- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, -- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) -- ]) -- -- if test "x$lt_cv_dlopen_self" = xyes; then -- LDFLAGS="$LDFLAGS $link_static_flag" -- AC_CACHE_CHECK([whether a statically linked program can dlopen itself], -- lt_cv_dlopen_self_static, [dnl -- _LT_AC_TRY_DLOPEN_SELF( -- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, -- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) -- ]) -- fi -- -- CPPFLAGS="$save_CPPFLAGS" -- LDFLAGS="$save_LDFLAGS" -- LIBS="$save_LIBS" -- ;; -- esac -- -- case $lt_cv_dlopen_self in -- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -- *) enable_dlopen_self=unknown ;; -- esac -- -- case $lt_cv_dlopen_self_static in -- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -- *) enable_dlopen_self_static=unknown ;; -- esac --fi --])# AC_LIBTOOL_DLOPEN_SELF -- --AC_DEFUN([_LT_AC_LTCONFIG_HACK], --[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl --# Sed substitution that helps us do robust quoting. It backslashifies --# metacharacters that are still active within double-quoted strings. --Xsed='sed -e s/^X//' --sed_quote_subst='s/\([[\\"\\`$\\\\]]\)/\\\1/g' -- --# Same as above, but do not quote variable references. --double_quote_subst='s/\([[\\"\\`\\\\]]\)/\\\1/g' -- --# Sed substitution to delay expansion of an escaped shell variable in a --# double_quote_subst'ed string. --delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' -- --# Constants: --rm="rm -f" -- --# Global variables: --default_ofile=libtool --can_build_shared=yes -- --# All known linkers require a `.a' archive for static linking (except M$VC, --# which needs '.lib'). --libext=a --ltmain="$ac_aux_dir/ltmain.sh" --ofile="$default_ofile" --with_gnu_ld="$lt_cv_prog_gnu_ld" --need_locks="$enable_libtool_lock" -- --old_CC="$CC" --old_CFLAGS="$CFLAGS" -- --# Set sane defaults for various variables --test -z "$AR" && AR=ar --test -z "$AR_FLAGS" && AR_FLAGS=cru --test -z "$AS" && AS=as --test -z "$CC" && CC=cc --test -z "$DLLTOOL" && DLLTOOL=dlltool --test -z "$LD" && LD=ld --test -z "$LN_S" && LN_S="ln -s" --test -z "$MAGIC_CMD" && MAGIC_CMD=file --test -z "$NM" && NM=nm --test -z "$OBJDUMP" && OBJDUMP=objdump --test -z "$RANLIB" && RANLIB=: --test -z "$STRIP" && STRIP=: --test -z "$ac_objext" && ac_objext=o -- --if test x"$host" != x"$build"; then -- ac_tool_prefix=${host_alias}- --else -- ac_tool_prefix= --fi -- --# Transform linux* to *-*-linux-gnu*, to support old configure scripts. --case $host_os in --linux-gnu*) ;; --linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` --esac -- --case $host_os in --aix3*) -- # AIX sometimes has problems with the GCC collect2 program. For some -- # reason, if we set the COLLECT_NAMES environment variable, the problems -- # vanish in a puff of smoke. -- if test "X${COLLECT_NAMES+set}" != Xset; then -- COLLECT_NAMES= -- export COLLECT_NAMES -- fi -- ;; --esac -- --# Determine commands to create old-style static archives. --old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' --old_postinstall_cmds='chmod 644 $oldlib' --old_postuninstall_cmds= -- --if test -n "$RANLIB"; then -- case $host_os in -- openbsd*) -- old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" -- ;; -- *) -- old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" -- ;; -- esac -- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" --fi -- --# Allow CC to be a program name with arguments. --set dummy $CC --compiler="[$]2" -- --AC_MSG_CHECKING([for objdir]) --rm -f .libs 2>/dev/null --mkdir .libs 2>/dev/null --if test -d .libs; then -- objdir=.libs --else -- # MS-DOS does not allow filenames that begin with a dot. -- objdir=_libs --fi --rmdir .libs 2>/dev/null --AC_MSG_RESULT($objdir) -- -- --AC_ARG_WITH(pic, --[ --with-pic try to use only PIC/non-PIC objects [default=use both]], --pic_mode="$withval", pic_mode=default) --test -z "$pic_mode" && pic_mode=default -- --# We assume here that the value for lt_cv_prog_cc_pic will not be cached --# in isolation, and that seeing it set (from the cache) indicates that --# the associated values are set (in the cache) correctly too. --AC_MSG_CHECKING([for $compiler option to produce PIC]) --AC_CACHE_VAL(lt_cv_prog_cc_pic, --[ lt_cv_prog_cc_pic= -- lt_cv_prog_cc_shlib= -- lt_cv_prog_cc_wl= -- lt_cv_prog_cc_static= -- lt_cv_prog_cc_no_builtin= -- lt_cv_prog_cc_can_build_shared=$can_build_shared -- -- if test "$GCC" = yes; then -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static='-static' -- -- case $host_os in -- aix*) -- # Below there is a dirty hack to force normal static linking with -ldl -- # The problem is because libdl dynamically linked with both libc and -- # libC (AIX C++ library), which obviously doesn't included in libraries -- # list by gcc. This cause undefined symbols with -static flags. -- # This hack allows C programs to be linked with "-static -ldl", but -- # not sure about C++ programs. -- lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" -- ;; -- amigaos*) -- # FIXME: we need at least 68020 code to build shared libraries, but -- # adding the `-m68020' flag to GCC prevents building anything better, -- # like `-m68040'. -- lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' -- ;; -- beos* | irix5* | irix6* | osf3* | osf4* | osf5*) -- # PIC is the default for these OSes. -- ;; -- darwin* | rhapsody*) -- # PIC is the default on this platform -- # Common symbols not allowed in MH_DYLIB files -- lt_cv_prog_cc_pic='-fno-common' -- ;; -- cygwin* | mingw* | pw32* | os2*) -- # This hack is so that the source file can tell whether it is being -- # built for inclusion in a dll (and should export symbols for example). -- lt_cv_prog_cc_pic='-DDLL_EXPORT' -- ;; -- sysv4*MP*) -- if test -d /usr/nec; then -- lt_cv_prog_cc_pic=-Kconform_pic -- fi -- ;; -- *) -- lt_cv_prog_cc_pic='-fPIC' -- ;; -- esac -- else -- # PORTME Check for PIC flags for the system compiler. -- case $host_os in -- aix3* | aix4* | aix5*) -- lt_cv_prog_cc_wl='-Wl,' -- # All AIX code is PIC. -- if test "$host_cpu" = ia64; then -- # AIX 5 now supports IA64 processor -- lt_cv_prog_cc_static='-Bstatic' -- else -- lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' -- fi -- ;; -- -- hpux9* | hpux10* | hpux11*) -- # Is there a better lt_cv_prog_cc_static that works with the bundled CC? -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" -- lt_cv_prog_cc_pic='+Z' -- ;; -- -- irix5* | irix6*) -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static='-non_shared' -- # PIC (with -KPIC) is the default. -- ;; -- -- cygwin* | mingw* | pw32* | os2*) -- # This hack is so that the source file can tell whether it is being -- # built for inclusion in a dll (and should export symbols for example). -- lt_cv_prog_cc_pic='-DDLL_EXPORT' -- ;; -- -- newsos6) -- lt_cv_prog_cc_pic='-KPIC' -- lt_cv_prog_cc_static='-Bstatic' -- ;; -- -- osf3* | osf4* | osf5*) -- # All OSF/1 code is PIC. -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static='-non_shared' -- ;; -- -- sco3.2v5*) -- lt_cv_prog_cc_pic='-Kpic' -- lt_cv_prog_cc_static='-dn' -- lt_cv_prog_cc_shlib='-belf' -- ;; -- -- solaris*) -- lt_cv_prog_cc_pic='-KPIC' -- lt_cv_prog_cc_static='-Bstatic' -- lt_cv_prog_cc_wl='-Wl,' -- ;; -- -- sunos4*) -- lt_cv_prog_cc_pic='-PIC' -- lt_cv_prog_cc_static='-Bstatic' -- lt_cv_prog_cc_wl='-Qoption ld ' -- ;; -- -- sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -- lt_cv_prog_cc_pic='-KPIC' -- lt_cv_prog_cc_static='-Bstatic' -- if test "x$host_vendor" = xsni; then -- lt_cv_prog_cc_wl='-LD' -- else -- lt_cv_prog_cc_wl='-Wl,' -- fi -- ;; -- -- uts4*) -- lt_cv_prog_cc_pic='-pic' -- lt_cv_prog_cc_static='-Bstatic' -- ;; -- -- sysv4*MP*) -- if test -d /usr/nec ;then -- lt_cv_prog_cc_pic='-Kconform_pic' -- lt_cv_prog_cc_static='-Bstatic' -- fi -- ;; -- -- *) -- lt_cv_prog_cc_can_build_shared=no -- ;; -- esac -- fi --]) --if test -z "$lt_cv_prog_cc_pic"; then -- AC_MSG_RESULT([none]) --else -- AC_MSG_RESULT([$lt_cv_prog_cc_pic]) -- -- # Check to make sure the pic_flag actually works. -- AC_MSG_CHECKING([if $compiler PIC flag $lt_cv_prog_cc_pic works]) -- AC_CACHE_VAL(lt_cv_prog_cc_pic_works, [dnl -- save_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" -- AC_TRY_COMPILE([], [], [dnl -- case $host_os in -- hpux9* | hpux10* | hpux11*) -- # On HP-UX, both CC and GCC only warn that PIC is supported... then -- # they create non-PIC objects. So, if there were any warnings, we -- # assume that PIC is not supported. -- if test -s conftest.err; then -- lt_cv_prog_cc_pic_works=no -- else -- lt_cv_prog_cc_pic_works=yes -- fi -- ;; -- *) -- lt_cv_prog_cc_pic_works=yes -- ;; -- esac -- ], [dnl -- lt_cv_prog_cc_pic_works=no -- ]) -- CFLAGS="$save_CFLAGS" -- ]) -- -- if test "X$lt_cv_prog_cc_pic_works" = Xno; then -- lt_cv_prog_cc_pic= -- lt_cv_prog_cc_can_build_shared=no -- else -- lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" -- fi -- -- AC_MSG_RESULT([$lt_cv_prog_cc_pic_works]) --fi -- --# Check for any special shared library compilation flags. --if test -n "$lt_cv_prog_cc_shlib"; then -- AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries]) -- if echo "$old_CC $old_CFLAGS " | egrep -e "[[ ]]$lt_cv_prog_cc_shlib[[ ]]" >/dev/null; then : -- else -- AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure]) -- lt_cv_prog_cc_can_build_shared=no -- fi --fi -- --AC_MSG_CHECKING([if $compiler static flag $lt_cv_prog_cc_static works]) --AC_CACHE_VAL([lt_cv_prog_cc_static_works], [dnl -- lt_cv_prog_cc_static_works=no -- save_LDFLAGS="$LDFLAGS" -- LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" -- AC_TRY_LINK([], [], [lt_cv_prog_cc_static_works=yes]) -- LDFLAGS="$save_LDFLAGS" --]) -- --# Belt *and* braces to stop my trousers falling down: --test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= --AC_MSG_RESULT([$lt_cv_prog_cc_static_works]) -- --pic_flag="$lt_cv_prog_cc_pic" --special_shlib_compile_flags="$lt_cv_prog_cc_shlib" --wl="$lt_cv_prog_cc_wl" --link_static_flag="$lt_cv_prog_cc_static" --no_builtin_flag="$lt_cv_prog_cc_no_builtin" --can_build_shared="$lt_cv_prog_cc_can_build_shared" -- -- --# Check to see if options -o and -c are simultaneously supported by compiler --AC_MSG_CHECKING([if $compiler supports -c -o file.$ac_objext]) --AC_CACHE_VAL([lt_cv_compiler_c_o], [ --$rm -r conftest 2>/dev/null --mkdir conftest --cd conftest --echo "int some_variable = 0;" > conftest.$ac_ext --mkdir out --# According to Tom Tromey, Ian Lance Taylor reported there are C compilers --# that will create temporary files in the current directory regardless of --# the output directory. Thus, making CWD read-only will cause this test --# to fail, enabling locking or at least warning the user not to do parallel --# builds. --chmod -w . --save_CFLAGS="$CFLAGS" --CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" --compiler_c_o=no --if { (eval echo configure:__oline__: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then -- # The compiler can only warn and ignore the option if not recognized -- # So say no if there are warnings -- if test -s out/conftest.err; then -- lt_cv_compiler_c_o=no -- else -- lt_cv_compiler_c_o=yes -- fi --else -- # Append any errors to the config.log. -- cat out/conftest.err 1>&AC_FD_CC -- lt_cv_compiler_c_o=no --fi --CFLAGS="$save_CFLAGS" --chmod u+w . --$rm conftest* out/* --rmdir out --cd .. --rmdir conftest --$rm -r conftest 2>/dev/null --]) --compiler_c_o=$lt_cv_compiler_c_o --AC_MSG_RESULT([$compiler_c_o]) -- --if test x"$compiler_c_o" = x"yes"; then -- # Check to see if we can write to a .lo -- AC_MSG_CHECKING([if $compiler supports -c -o file.lo]) -- AC_CACHE_VAL([lt_cv_compiler_o_lo], [ -- lt_cv_compiler_o_lo=no -- save_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -c -o conftest.lo" -- save_objext="$ac_objext" -- ac_objext=lo -- AC_TRY_COMPILE([], [int some_variable = 0;], [dnl -- # The compiler can only warn and ignore the option if not recognized -- # So say no if there are warnings -- if test -s conftest.err; then -- lt_cv_compiler_o_lo=no -- else -- lt_cv_compiler_o_lo=yes -- fi -- ]) -- ac_objext="$save_objext" -- CFLAGS="$save_CFLAGS" -- ]) -- compiler_o_lo=$lt_cv_compiler_o_lo -- AC_MSG_RESULT([$compiler_o_lo]) --else -- compiler_o_lo=no --fi -- --# Check to see if we can do hard links to lock some files if needed --hard_links="nottested" --if test "$compiler_c_o" = no && test "$need_locks" != no; then -- # do not overwrite the value of need_locks provided by the user -- AC_MSG_CHECKING([if we can lock with hard links]) -- hard_links=yes -- $rm conftest* -- ln conftest.a conftest.b 2>/dev/null && hard_links=no -- touch conftest.a -- ln conftest.a conftest.b 2>&5 || hard_links=no -- ln conftest.a conftest.b 2>/dev/null && hard_links=no -- AC_MSG_RESULT([$hard_links]) -- if test "$hard_links" = no; then -- AC_MSG_WARN([\`$CC' does not support \`-c -o', so \`make -j' may be unsafe]) -- need_locks=warn -- fi --else -- need_locks=no --fi -- --if test "$GCC" = yes; then -- # Check to see if options -fno-rtti -fno-exceptions are supported by compiler -- AC_MSG_CHECKING([if $compiler supports -fno-rtti -fno-exceptions]) -- echo "int some_variable = 0;" > conftest.$ac_ext -- save_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" -- compiler_rtti_exceptions=no -- AC_TRY_COMPILE([], [int some_variable = 0;], [dnl -- # The compiler can only warn and ignore the option if not recognized -- # So say no if there are warnings -- if test -s conftest.err; then -- compiler_rtti_exceptions=no -- else -- compiler_rtti_exceptions=yes -- fi -- ]) -- CFLAGS="$save_CFLAGS" -- AC_MSG_RESULT([$compiler_rtti_exceptions]) -- -- if test "$compiler_rtti_exceptions" = "yes"; then -- no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' -- else -- no_builtin_flag=' -fno-builtin' -- fi --fi -- --# See if the linker supports building shared libraries. --AC_MSG_CHECKING([whether the linker ($LD) supports shared libraries]) -- --allow_undefined_flag= --no_undefined_flag= --need_lib_prefix=unknown --need_version=unknown --# when you set need_version to no, make sure it does not cause -set_version --# flags to be left without arguments --archive_cmds= --archive_expsym_cmds= --old_archive_from_new_cmds= --old_archive_from_expsyms_cmds= --export_dynamic_flag_spec= --whole_archive_flag_spec= --thread_safe_flag_spec= --hardcode_into_libs=no --hardcode_libdir_flag_spec= --hardcode_libdir_separator= --hardcode_direct=no --hardcode_minus_L=no --hardcode_shlibpath_var=unsupported --runpath_var= --link_all_deplibs=unknown --always_export_symbols=no --export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' --# include_expsyms should be a list of space-separated symbols to be *always* --# included in the symbol list --include_expsyms= --# exclude_expsyms can be an egrep regular expression of symbols to exclude --# it will be wrapped by ` (' and `)$', so one must not match beginning or --# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', --# as well as any symbol that contains `d'. --exclude_expsyms="_GLOBAL_OFFSET_TABLE_" --# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out --# platforms (ab)use it in PIC code, but their linkers get confused if --# the symbol is explicitly referenced. Since portable code cannot --# rely on this symbol name, it's probably fine to never include it in --# preloaded symbol tables. --extract_expsyms_cmds= -- --case $host_os in --cygwin* | mingw* | pw32*) -- # FIXME: the MSVC++ port hasn't been tested in a loooong time -- # When not using gcc, we currently assume that we are using -- # Microsoft Visual C++. -- if test "$GCC" != yes; then -- with_gnu_ld=no -- fi -- ;; --openbsd*) -- with_gnu_ld=no -- ;; --esac -- --ld_shlibs=yes --if test "$with_gnu_ld" = yes; then -- # If archive_cmds runs LD, not CC, wlarc should be empty -- wlarc='${wl}' -- -- # See if GNU ld supports shared libraries. -- case $host_os in -- aix3* | aix4* | aix5*) -- # On AIX, the GNU linker is very broken -- # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. -- ld_shlibs=no -- cat <&2 -- --*** Warning: the GNU linker, at least up to release 2.9.1, is reported --*** to be unable to reliably create shared libraries on AIX. --*** Therefore, libtool is disabling shared libraries support. If you --*** really care for shared libraries, you may want to modify your PATH --*** so that a non-GNU linker is found, and then restart. -- --EOF -- ;; -- -- amigaos*) -- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_minus_L=yes -- -- # Samuel A. Falvo II reports -- # that the semantics of dynamic libraries on AmigaOS, at least up -- # to version 4, is to share data among multiple programs linked -- # with the same dynamic library. Since this doesn't match the -- # behavior of shared libraries on other platforms, we can use -- # them. -- ld_shlibs=no -- ;; -- -- beos*) -- if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- allow_undefined_flag=unsupported -- # Joseph Beckenbach says some releases of gcc -- # support --undefined. This deserves some investigation. FIXME -- archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- else -- ld_shlibs=no -- fi -- ;; -- -- cygwin* | mingw* | pw32*) -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec='-L$libdir' -- allow_undefined_flag=unsupported -- always_export_symbols=yes -- -- extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ -- sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ -- test -f $output_objdir/impgen.exe || (cd $output_objdir && \ -- if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ -- else $CC -o impgen impgen.c ; fi)~ -- $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' -- -- old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' -- -- # cygwin and mingw dlls have different entry points and sets of symbols -- # to exclude. -- # FIXME: what about values for MSVC? -- dll_entry=__cygwin_dll_entry@12 -- dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ -- case $host_os in -- mingw*) -- # mingw values -- dll_entry=_DllMainCRTStartup@12 -- dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ -- ;; -- esac -- -- # mingw and cygwin differ, and it's simplest to just exclude the union -- # of the two symbol sets. -- dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 -- -- # recent cygwin and mingw systems supply a stub DllMain which the user -- # can override, but on older systems we have to supply one (in ltdll.c) -- if test "x$lt_cv_need_dllmain" = "xyes"; then -- ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " -- ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ -- test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' -- else -- ltdll_obj= -- ltdll_cmds= -- fi -- -- # Extract the symbol export list from an `--export-all' def file, -- # then regenerate the def file from the symbol export list, so that -- # the compiled dll only exports the symbol export list. -- # Be careful not to strip the DATA tag left be newer dlltools. -- export_symbols_cmds="$ltdll_cmds"' -- $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ -- sed -e "1,/EXPORTS/d" -e "s/ @ [[0-9]]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' -- -- # If the export-symbols file already is a .def file (1st line -- # is EXPORTS), use it as is. -- # If DATA tags from a recent dlltool are present, honour them! -- archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then -- cp $export_symbols $output_objdir/$soname-def; -- else -- echo EXPORTS > $output_objdir/$soname-def; -- _lt_hint=1; -- cat $export_symbols | while read symbol; do -- set dummy \$symbol; -- case \[$]# in -- 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; -- *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; -- esac; -- _lt_hint=`expr 1 + \$_lt_hint`; -- done; -- fi~ -- '"$ltdll_cmds"' -- $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ -- $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ -- $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' -- ;; -- -- netbsd*) -- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -- archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' -- wlarc= -- else -- archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -- fi -- ;; -- -- solaris* | sysv5*) -- if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then -- ld_shlibs=no -- cat <&2 -- --*** Warning: The releases 2.8.* of the GNU linker cannot reliably --*** create shared libraries on Solaris systems. Therefore, libtool --*** is disabling shared libraries support. We urge you to upgrade GNU --*** binutils to release 2.9.1 or newer. Another option is to modify --*** your PATH or compiler configuration so that the native linker is --*** used, and then restart. -- --EOF -- elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -- else -- ld_shlibs=no -- fi -- ;; -- -- sunos4*) -- archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' -- wlarc= -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -- -- *) -- if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -- else -- ld_shlibs=no -- fi -- ;; -- esac -- -- if test "$ld_shlibs" = yes; then -- runpath_var=LD_RUN_PATH -- hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' -- export_dynamic_flag_spec='${wl}--export-dynamic' -- case $host_os in -- cygwin* | mingw* | pw32*) -- # dlltool doesn't understand --whole-archive et. al. -- whole_archive_flag_spec= -- ;; -- *) -- # ancient GNU ld didn't support --whole-archive et. al. -- if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then -- whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -- else -- whole_archive_flag_spec= -- fi -- ;; -- esac -- fi --else -- # PORTME fill in a description of your system's linker (not GNU ld) -- case $host_os in -- aix3*) -- allow_undefined_flag=unsupported -- always_export_symbols=yes -- archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' -- # Note: this linker hardcodes the directories in LIBPATH if there -- # are no directories specified by -L. -- hardcode_minus_L=yes -- if test "$GCC" = yes && test -z "$link_static_flag"; then -- # Neither direct hardcoding nor static linking is supported with a -- # broken collect2. -- hardcode_direct=unsupported -- fi -- ;; -- -- aix4* | aix5*) -- if test "$host_cpu" = ia64; then -- # On IA64, the linker does run time linking by default, so we don't -- # have to do anything special. -- aix_use_runtimelinking=no -- exp_sym_flag='-Bexport' -- no_entry_flag="" -- else -- aix_use_runtimelinking=no -- -- # Test if we are trying to use run time linking or normal -- # AIX style linking. If -brtl is somewhere in LDFLAGS, we -- # need to do runtime linking. -- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) -- for ld_flag in $LDFLAGS; do -- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then -- aix_use_runtimelinking=yes -- break -- fi -- done -- esac -- -- exp_sym_flag='-bexport' -- no_entry_flag='-bnoentry' -- fi -- -- # When large executables or shared objects are built, AIX ld can -- # have problems creating the table of contents. If linking a library -- # or program results in "error TOC overflow" add -mminimal-toc to -- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -- -- hardcode_direct=yes -- archive_cmds='' -- hardcode_libdir_separator=':' -- if test "$GCC" = yes; then -- case $host_os in aix4.[[012]]|aix4.[[012]].*) -- collect2name=`${CC} -print-prog-name=collect2` -- if test -f "$collect2name" && \ -- strings "$collect2name" | grep resolve_lib_name >/dev/null -- then -- # We have reworked collect2 -- hardcode_direct=yes -- else -- # We have old collect2 -- hardcode_direct=unsupported -- # It fails to find uninstalled libraries when the uninstalled -- # path is not listed in the libpath. Setting hardcode_minus_L -- # to unsupported forces relinking -- hardcode_minus_L=yes -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_libdir_separator= -- fi -- esac -- -- shared_flag='-shared' -- else -- # not using gcc -- if test "$host_cpu" = ia64; then -- shared_flag='${wl}-G' -- else -- if test "$aix_use_runtimelinking" = yes; then -- shared_flag='${wl}-G' -- else -- shared_flag='${wl}-bM:SRE' -- fi -- fi -- fi -- -- # It seems that -bexpall can do strange things, so it is better to -- # generate a list of symbols to export. -- always_export_symbols=yes -- if test "$aix_use_runtimelinking" = yes; then -- # Warning - without using the other runtime loading flags (-brtl), -- # -berok will link without error, but may produce a broken library. -- allow_undefined_flag='-berok' -- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' -- archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -- else -- if test "$host_cpu" = ia64; then -- hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' -- allow_undefined_flag="-z nodefs" -- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -- else -- hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' -- # Warning - without using the other run time loading flags, -- # -berok will link without error, but may produce a broken library. -- allow_undefined_flag='${wl}-berok' -- # This is a bit strange, but is similar to how AIX traditionally builds -- # it's shared libraries. -- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' -- fi -- fi -- ;; -- -- amigaos*) -- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_minus_L=yes -- # see comment about different semantics on the GNU ld section -- ld_shlibs=no -- ;; -- -- cygwin* | mingw* | pw32*) -- # When not using gcc, we currently assume that we are using -- # Microsoft Visual C++. -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec=' ' -- allow_undefined_flag=unsupported -- # Tell ltmain to make .lib files, not .a files. -- libext=lib -- # FIXME: Setting linknames here is a bad hack. -- archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' -- # The linker will automatically build a .lib file if we build a DLL. -- old_archive_from_new_cmds='true' -- # FIXME: Should let the user specify the lib program. -- old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' -- fix_srcfile_path='`cygpath -w "$srcfile"`' -- ;; -- -- darwin* | rhapsody*) -- case "$host_os" in -- rhapsody* | darwin1.[[012]]) -- allow_undefined_flag='-undefined suppress' -- ;; -- *) # Darwin 1.3 on -- allow_undefined_flag='-flat_namespace -undefined suppress' -- ;; -- esac -- # FIXME: Relying on posixy $() will cause problems for -- # cross-compilation, but unfortunately the echo tests do not -- # yet detect zsh echo's removal of \ escapes. -- archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' -- # We need to add '_' to the symbols in $export_symbols first -- #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- whole_archive_flag_spec='-all_load $convenience' -- ;; -- -- freebsd1*) -- ld_shlibs=no -- ;; -- -- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -- # support. Future versions do this automatically, but an explicit c++rt0.o -- # does not break anything, and helps significantly (at the cost of a little -- # extra space). -- freebsd2.2*) -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -- -- # Unfortunately, older versions of FreeBSD 2 do not have this feature. -- freebsd2*) -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes -- hardcode_minus_L=yes -- hardcode_shlibpath_var=no -- ;; -- -- # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -- freebsd*) -- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -- -- hpux9* | hpux10* | hpux11*) -- case $host_os in -- hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; -- *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; -- esac -- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -- hardcode_libdir_separator=: -- hardcode_direct=yes -- hardcode_minus_L=yes # Not in the search PATH, but as the default -- # location of the library. -- export_dynamic_flag_spec='${wl}-E' -- ;; -- -- irix5* | irix6*) -- if test "$GCC" = yes; then -- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -- else -- archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -- fi -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- hardcode_libdir_separator=: -- link_all_deplibs=yes -- ;; -- -- netbsd*) -- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out -- else -- archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF -- fi -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -- -- newsos6) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- hardcode_libdir_separator=: -- hardcode_shlibpath_var=no -- ;; -- -- openbsd*) -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='${wl}-rpath,$libdir' -- export_dynamic_flag_spec='${wl}-E' -- else -- case "$host_os" in -- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='-R$libdir' -- ;; -- *) -- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='${wl}-rpath,$libdir' -- ;; -- esac -- fi -- ;; -- -- os2*) -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_minus_L=yes -- allow_undefined_flag=unsupported -- archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' -- old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' -- ;; -- -- osf3*) -- if test "$GCC" = yes; then -- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -- else -- allow_undefined_flag=' -expect_unresolved \*' -- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -- fi -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- hardcode_libdir_separator=: -- ;; -- -- osf4* | osf5*) # as osf3* with the addition of -msym flag -- if test "$GCC" = yes; then -- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- else -- allow_undefined_flag=' -expect_unresolved \*' -- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -- archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ -- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' -- -- #Both c and cxx compiler support -rpath directly -- hardcode_libdir_flag_spec='-rpath $libdir' -- fi -- hardcode_libdir_separator=: -- ;; -- -- sco3.2v5*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_shlibpath_var=no -- runpath_var=LD_RUN_PATH -- hardcode_runpath_var=yes -- export_dynamic_flag_spec='${wl}-Bexport' -- ;; -- -- solaris*) -- # gcc --version < 3.0 without binutils cannot create self contained -- # shared libraries reliably, requiring libgcc.a to resolve some of -- # the object symbols generated in some cases. Libraries that use -- # assert need libgcc.a to resolve __eprintf, for example. Linking -- # a copy of libgcc.a into every shared library to guarantee resolving -- # such symbols causes other problems: According to Tim Van Holder -- # , C++ libraries end up with a separate -- # (to the application) exception stack for one thing. -- no_undefined_flag=' -z defs' -- if test "$GCC" = yes; then -- case `$CC --version 2>/dev/null` in -- [[12]].*) -- cat <&2 -- --*** Warning: Releases of GCC earlier than version 3.0 cannot reliably --*** create self contained shared libraries on Solaris systems, without --*** introducing a dependency on libgcc.a. Therefore, libtool is disabling --*** -no-undefined support, which will at least allow you to build shared --*** libraries. However, you may find that when you link such libraries --*** into an application without using GCC, you have to manually add --*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to --*** upgrade to a newer version of GCC. Another option is to rebuild your --*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. -- --EOF -- no_undefined_flag= -- ;; -- esac -- fi -- # $CC -shared without GNU ld will not create a library from C++ -- # object files and a static libstdc++, better avoid it by now -- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_shlibpath_var=no -- case $host_os in -- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; -- *) # Supported since Solaris 2.6 (maybe 2.5.1?) -- whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; -- esac -- link_all_deplibs=yes -- ;; -- -- sunos4*) -- if test "x$host_vendor" = xsequent; then -- # Use $CC to link under sequent, because it throws in some extra .o -- # files that make .init and .fini sections work. -- archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' -- else -- archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' -- fi -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_direct=yes -- hardcode_minus_L=yes -- hardcode_shlibpath_var=no -- ;; -- -- sysv4) -- if test "x$host_vendor" = xsno; then -- archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes # is this really true??? -- else -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=no #Motorola manual says yes, but my tests say they lie -- fi -- runpath_var='LD_RUN_PATH' -- hardcode_shlibpath_var=no -- ;; -- -- sysv4.3*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_shlibpath_var=no -- export_dynamic_flag_spec='-Bexport' -- ;; -- -- sysv5*) -- no_undefined_flag=' -z text' -- # $CC -shared without GNU ld will not create a library from C++ -- # object files and a static libstdc++, better avoid it by now -- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -- hardcode_libdir_flag_spec= -- hardcode_shlibpath_var=no -- runpath_var='LD_RUN_PATH' -- ;; -- -- uts4*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_shlibpath_var=no -- ;; -- -- dgux*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_shlibpath_var=no -- ;; -- -- sysv4*MP*) -- if test -d /usr/nec; then -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_shlibpath_var=no -- runpath_var=LD_RUN_PATH -- hardcode_runpath_var=yes -- ld_shlibs=yes -- fi -- ;; -- -- sysv4.2uw2*) -- archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes -- hardcode_minus_L=no -- hardcode_shlibpath_var=no -- hardcode_runpath_var=yes -- runpath_var=LD_RUN_PATH -- ;; -- -- sysv5uw7* | unixware7*) -- no_undefined_flag='${wl}-z ${wl}text' -- if test "$GCC" = yes; then -- archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -- else -- archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -- fi -- runpath_var='LD_RUN_PATH' -- hardcode_shlibpath_var=no -- ;; -- -- *) -- ld_shlibs=no -- ;; -- esac --fi --AC_MSG_RESULT([$ld_shlibs]) --test "$ld_shlibs" = no && can_build_shared=no -- --# Check hardcoding attributes. --AC_MSG_CHECKING([how to hardcode library paths into programs]) --hardcode_action= --if test -n "$hardcode_libdir_flag_spec" || \ -- test -n "$runpath_var"; then -- -- # We can hardcode non-existant directories. -- if test "$hardcode_direct" != no && -- # If the only mechanism to avoid hardcoding is shlibpath_var, we -- # have to relink, otherwise we might link with an installed library -- # when we should be linking with a yet-to-be-installed one -- ## test "$hardcode_shlibpath_var" != no && -- test "$hardcode_minus_L" != no; then -- # Linking always hardcodes the temporary library directory. -- hardcode_action=relink -- else -- # We can link without hardcoding, and we can hardcode nonexisting dirs. -- hardcode_action=immediate -- fi --else -- # We cannot hardcode anything, or else we can only hardcode existing -- # directories. -- hardcode_action=unsupported --fi --AC_MSG_RESULT([$hardcode_action]) -- --striplib= --old_striplib= --AC_MSG_CHECKING([whether stripping libraries is possible]) --if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -- test -z "$striplib" && striplib="$STRIP --strip-unneeded" -- AC_MSG_RESULT([yes]) --else -- AC_MSG_RESULT([no]) --fi -- --reload_cmds='$LD$reload_flag -o $output$reload_objs' --test -z "$deplibs_check_method" && deplibs_check_method=unknown -- --# PORTME Fill in your ld.so characteristics --AC_MSG_CHECKING([dynamic linker characteristics]) --library_names_spec= --libname_spec='lib$name' --soname_spec= --postinstall_cmds= --postuninstall_cmds= --finish_cmds= --finish_eval= --shlibpath_var= --shlibpath_overrides_runpath=unknown --version_type=none --dynamic_linker="$host_os ld.so" --sys_lib_dlsearch_path_spec="/lib /usr/lib" --sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -- --case $host_os in --aix3*) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix $libname.a' -- shlibpath_var=LIBPATH -- -- # AIX has no versioning support, so we append a major version to the name. -- soname_spec='${libname}${release}.so$major' -- ;; -- --aix4* | aix5*) -- version_type=linux -- if test "$host_cpu" = ia64; then -- # AIX 5 supports IA64 -- library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- else -- # With GCC up to 2.95.x, collect2 would create an import file -- # for dependence libraries. The import file would start with -- # the line `#! .'. This would cause the generated library to -- # depend on `.', always an invalid library. This was fixed in -- # development snapshots of GCC prior to 3.0. -- case $host_os in -- aix4 | aix4.[[01]] | aix4.[[01]].*) -- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -- echo ' yes ' -- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -- : -- else -- can_build_shared=no -- fi -- ;; -- esac -- # AIX (on Power*) has no versioning support, so currently we can -- # not hardcode correct soname into executable. Probably we can -- # add versioning support to collect2, so additional links can -- # be useful in future. -- if test "$aix_use_runtimelinking" = yes; then -- # If using run time linking (on AIX 4.2 or later) use lib.so -- # instead of lib.a to let people know that these are not -- # typical AIX shared libraries. -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- else -- # We preserve .a as extension for shared libraries through AIX4.2 -- # and later when we are not doing run time linking. -- library_names_spec='${libname}${release}.a $libname.a' -- soname_spec='${libname}${release}.so$major' -- fi -- shlibpath_var=LIBPATH -- fi -- ;; -- --amigaos*) -- library_names_spec='$libname.ixlibrary $libname.a' -- # Create ${libname}_ixlibrary.a entries in /sys/libs. -- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' -- ;; -- --beos*) -- library_names_spec='${libname}.so' -- dynamic_linker="$host_os ld.so" -- shlibpath_var=LIBRARY_PATH -- ;; -- --bsdi4*) -- version_type=linux -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -- export_dynamic_flag_spec=-rdynamic -- # the default ld.so.conf also contains /usr/contrib/lib and -- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -- # libtool to hard-code these into programs -- ;; -- --cygwin* | mingw* | pw32*) -- version_type=windows -- need_version=no -- need_lib_prefix=no -- case $GCC,$host_os in -- yes,cygwin*) -- library_names_spec='$libname.dll.a' -- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' -- postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ -- dldir=$destdir/`dirname \$dlpath`~ -- test -d \$dldir || mkdir -p \$dldir~ -- $install_prog .libs/$dlname \$dldir/$dlname' -- postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ -- dlpath=$dir/\$dldll~ -- $rm \$dlpath' -- ;; -- yes,mingw*) -- library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' -- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` -- ;; -- yes,pw32*) -- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' -- ;; -- *) -- library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll $libname.lib' -- ;; -- esac -- dynamic_linker='Win32 ld.exe' -- # FIXME: first we should search . and the directory the executable is in -- shlibpath_var=PATH -- ;; -- --darwin* | rhapsody*) -- dynamic_linker="$host_os dyld" -- version_type=darwin -- need_lib_prefix=no -- need_version=no -- # FIXME: Relying on posixy $() will cause problems for -- # cross-compilation, but unfortunately the echo tests do not -- # yet detect zsh echo's removal of \ escapes. -- library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' -- soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' -- shlibpath_overrides_runpath=yes -- shlibpath_var=DYLD_LIBRARY_PATH -- ;; -- --freebsd1*) -- dynamic_linker=no -- ;; -- --freebsd*) -- objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` -- version_type=freebsd-$objformat -- case $version_type in -- freebsd-elf*) -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' -- need_version=no -- need_lib_prefix=no -- ;; -- freebsd-*) -- library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' -- need_version=yes -- ;; -- esac -- shlibpath_var=LD_LIBRARY_PATH -- case $host_os in -- freebsd2*) -- shlibpath_overrides_runpath=yes -- ;; -- *) -- shlibpath_overrides_runpath=no -- hardcode_into_libs=yes -- ;; -- esac -- ;; -- --gnu*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- hardcode_into_libs=yes -- ;; -- --hpux9* | hpux10* | hpux11*) -- # Give a soname corresponding to the major version so that dld.sl refuses to -- # link against other versions. -- dynamic_linker="$host_os dld.sl" -- version_type=sunos -- need_lib_prefix=no -- need_version=no -- shlibpath_var=SHLIB_PATH -- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -- library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' -- soname_spec='${libname}${release}.sl$major' -- # HP-UX runs *really* slowly unless shared libraries are mode 555. -- postinstall_cmds='chmod 555 $lib' -- ;; -- --irix5* | irix6*) -- version_type=irix -- need_lib_prefix=no -- need_version=no -- soname_spec='${libname}${release}.so$major' -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' -- case $host_os in -- irix5*) -- libsuff= shlibsuff= -- ;; -- *) -- case $LD in # libtool.m4 will add one of these switches to LD -- *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; -- *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; -- *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; -- *) libsuff= shlibsuff= libmagic=never-match;; -- esac -- ;; -- esac -- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -- shlibpath_overrides_runpath=no -- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -- ;; -- --# No shared lib support for Linux oldld, aout, or coff. --linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) -- dynamic_linker=no -- ;; -- --# This must be Linux ELF. --linux-gnu*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=no -- # This implies no fast_install, which is unacceptable. -- # Some rework will be needed to allow for fast_install -- # before this can be enabled. -- hardcode_into_libs=yes -- -- # We used to test for /lib/ld.so.1 and disable shared libraries on -- # powerpc, because MkLinux only supported shared libraries with the -- # GNU dynamic linker. Since this was broken with cross compilers, -- # most powerpc-linux boxes support dynamic linking these days and -- # people can always --disable-shared, the test was removed, and we -- # assume the GNU/Linux dynamic linker is in use. -- dynamic_linker='GNU/Linux ld.so' -- ;; -- --netbsd*) -- version_type=sunos -- need_lib_prefix=no -- need_version=no -- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -- dynamic_linker='NetBSD (a.out) ld.so' -- else -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' -- soname_spec='${libname}${release}.so$major' -- dynamic_linker='NetBSD ld.elf_so' -- fi -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- hardcode_into_libs=yes -- ;; -- --newsos6) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- ;; -- --openbsd*) -- version_type=sunos -- need_lib_prefix=no -- need_version=no -- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -- case "$host_os" in -- openbsd2.[[89]] | openbsd2.[[89]].*) -- shlibpath_overrides_runpath=no -- ;; -- *) -- shlibpath_overrides_runpath=yes -- ;; -- esac -- else -- shlibpath_overrides_runpath=yes -- fi -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- ;; -- --os2*) -- libname_spec='$name' -- need_lib_prefix=no -- library_names_spec='$libname.dll $libname.a' -- dynamic_linker='OS/2 ld.exe' -- shlibpath_var=LIBPATH -- ;; -- --osf3* | osf4* | osf5*) -- version_type=osf -- need_version=no -- soname_spec='${libname}${release}.so' -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -- ;; -- --sco3.2v5*) -- version_type=osf -- soname_spec='${libname}${release}.so$major' -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- ;; -- --solaris*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- hardcode_into_libs=yes -- # ldd complains unless libraries are executable -- postinstall_cmds='chmod +x $lib' -- ;; -- --sunos4*) -- version_type=sunos -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- if test "$with_gnu_ld" = yes; then -- need_lib_prefix=no -- fi -- need_version=yes -- ;; -- --sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- case $host_vendor in -- sni) -- shlibpath_overrides_runpath=no -- ;; -- motorola) -- need_lib_prefix=no -- need_version=no -- shlibpath_overrides_runpath=no -- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -- ;; -- esac -- ;; -- --uts4*) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- ;; -- --dgux*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- ;; -- --sysv4*MP*) -- if test -d /usr/nec ;then -- version_type=linux -- library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' -- soname_spec='$libname.so.$major' -- shlibpath_var=LD_LIBRARY_PATH -- fi -- ;; -- --*) -- dynamic_linker=no -- ;; --esac --AC_MSG_RESULT([$dynamic_linker]) --test "$dynamic_linker" = no && can_build_shared=no -- --# Report the final consequences. --AC_MSG_CHECKING([if libtool supports shared libraries]) --AC_MSG_RESULT([$can_build_shared]) -- --AC_MSG_CHECKING([whether to build shared libraries]) --test "$can_build_shared" = "no" && enable_shared=no -- --# On AIX, shared libraries and static libraries use the same namespace, and --# are all built from PIC. --case "$host_os" in --aix3*) -- test "$enable_shared" = yes && enable_static=no -- if test -n "$RANLIB"; then -- archive_cmds="$archive_cmds~\$RANLIB \$lib" -- postinstall_cmds='$RANLIB $lib' -- fi -- ;; -- --aix4*) -- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then -- test "$enable_shared" = yes && enable_static=no -- fi -- ;; --esac --AC_MSG_RESULT([$enable_shared]) -- --AC_MSG_CHECKING([whether to build static libraries]) --# Make sure either enable_shared or enable_static is yes. --test "$enable_shared" = yes || enable_static=yes --AC_MSG_RESULT([$enable_static]) -- --if test "$hardcode_action" = relink; then -- # Fast installation is not supported -- enable_fast_install=no --elif test "$shlibpath_overrides_runpath" = yes || -- test "$enable_shared" = no; then -- # Fast installation is not necessary -- enable_fast_install=needless --fi -- --variables_saved_for_relink="PATH $shlibpath_var $runpath_var" --if test "$GCC" = yes; then -- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" --fi -- --AC_LIBTOOL_DLOPEN_SELF -- --if test "$enable_shared" = yes && test "$GCC" = yes; then -- case $archive_cmds in -- *'~'*) -- # FIXME: we may have to deal with multi-command sequences. -- ;; -- '$CC '*) -- # Test whether the compiler implicitly links with -lc since on some -- # systems, -lgcc has to come before -lc. If gcc already passes -lc -- # to ld, don't add -lc before -lgcc. -- AC_MSG_CHECKING([whether -lc should be explicitly linked in]) -- AC_CACHE_VAL([lt_cv_archive_cmds_need_lc], -- [$rm conftest* -- echo 'static int dummy;' > conftest.$ac_ext -- -- if AC_TRY_EVAL(ac_compile); then -- soname=conftest -- lib=conftest -- libobjs=conftest.$ac_objext -- deplibs= -- wl=$lt_cv_prog_cc_wl -- compiler_flags=-v -- linker_flags=-v -- verstring= -- output_objdir=. -- libname=conftest -- save_allow_undefined_flag=$allow_undefined_flag -- allow_undefined_flag= -- if AC_TRY_EVAL(archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) -- then -- lt_cv_archive_cmds_need_lc=no -- else -- lt_cv_archive_cmds_need_lc=yes -- fi -- allow_undefined_flag=$save_allow_undefined_flag -- else -- cat conftest.err 1>&5 -- fi]) -- AC_MSG_RESULT([$lt_cv_archive_cmds_need_lc]) -- ;; -- esac --fi --need_lc=${lt_cv_archive_cmds_need_lc-yes} -- --# The second clause should only fire when bootstrapping the --# libtool distribution, otherwise you forgot to ship ltmain.sh --# with your package, and you will get complaints that there are --# no rules to generate ltmain.sh. --if test -f "$ltmain"; then -- : --else -- # If there is no Makefile yet, we rely on a make rule to execute -- # `config.status --recheck' to rerun these tests and create the -- # libtool script then. -- test -f Makefile && make "$ltmain" --fi -- --if test -f "$ltmain"; then -- trap "$rm \"${ofile}T\"; exit 1" 1 2 15 -- $rm -f "${ofile}T" -- -- echo creating $ofile -- -- # Now quote all the things that may contain metacharacters while being -- # careful not to overquote the AC_SUBSTed values. We take copies of the -- # variables and quote the copies for generation of the libtool script. -- for var in echo old_CC old_CFLAGS \ -- AR AR_FLAGS CC LD LN_S NM SHELL \ -- reload_flag reload_cmds wl \ -- pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ -- thread_safe_flag_spec whole_archive_flag_spec libname_spec \ -- library_names_spec soname_spec \ -- RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ -- old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ -- postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ -- old_striplib striplib file_magic_cmd export_symbols_cmds \ -- deplibs_check_method allow_undefined_flag no_undefined_flag \ -- finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ -- global_symbol_to_c_name_address \ -- hardcode_libdir_flag_spec hardcode_libdir_separator \ -- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -- compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do -- -- case $var in -- reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ -- old_postinstall_cmds | old_postuninstall_cmds | \ -- export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ -- extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ -- postinstall_cmds | postuninstall_cmds | \ -- finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -- # Double-quote double-evaled strings. -- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -- ;; -- *) -- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -- ;; -- esac -- done -- -- cat <<__EOF__ > "${ofile}T" --#! $SHELL -- --# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. --# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) --# NOTE: Changes made to this file will be lost: look at ltmain.sh. --# --# Copyright (C) 1996-2000 Free Software Foundation, Inc. --# Originally by Gordon Matzigkeit , 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 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. --# --# 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. -- --# Sed that helps us avoid accidentally triggering echo(1) options like -n. --Xsed="sed -e s/^X//" -- --# The HP-UX ksh and POSIX shell print the target directory to stdout --# if CDPATH is set. --if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi -- --# ### BEGIN LIBTOOL CONFIG -- --# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -- --# Shell to use when invoking shell scripts. --SHELL=$lt_SHELL -- --# Whether or not to build shared libraries. --build_libtool_libs=$enable_shared -- --# Whether or not to build static libraries. --build_old_libs=$enable_static -- --# Whether or not to add -lc for building shared libraries. --build_libtool_need_lc=$need_lc -- --# Whether or not to optimize for fast installation. --fast_install=$enable_fast_install -- --# The host system. --host_alias=$host_alias --host=$host -- --# An echo program that does not interpret backslashes. --echo=$lt_echo -- --# The archiver. --AR=$lt_AR --AR_FLAGS=$lt_AR_FLAGS -- --# The default C compiler. --CC=$lt_CC -- --# Is the compiler the GNU C compiler? --with_gcc=$GCC -- --# The linker used to build libraries. --LD=$lt_LD -- --# Whether we need hard or soft links. --LN_S=$lt_LN_S -- --# A BSD-compatible nm program. --NM=$lt_NM -- --# A symbol stripping program --STRIP=$STRIP -- --# Used to examine libraries when file_magic_cmd begins "file" --MAGIC_CMD=$MAGIC_CMD -- --# Used on cygwin: DLL creation program. --DLLTOOL="$DLLTOOL" -- --# Used on cygwin: object dumper. --OBJDUMP="$OBJDUMP" -- --# Used on cygwin: assembler. --AS="$AS" -- --# The name of the directory that contains temporary libtool files. --objdir=$objdir -- --# How to create reloadable object files. --reload_flag=$lt_reload_flag --reload_cmds=$lt_reload_cmds -- --# How to pass a linker flag through the compiler. --wl=$lt_wl -- --# Object file suffix (normally "o"). --objext="$ac_objext" -- --# Old archive suffix (normally "a"). --libext="$libext" -- --# Executable file suffix (normally ""). --exeext="$exeext" -- --# Additional compiler flags for building library objects. --pic_flag=$lt_pic_flag --pic_mode=$pic_mode -- --# Does compiler simultaneously support -c and -o options? --compiler_c_o=$lt_compiler_c_o -- --# Can we write directly to a .lo ? --compiler_o_lo=$lt_compiler_o_lo -- --# Must we lock files when doing compilation ? --need_locks=$lt_need_locks -- --# Do we need the lib prefix for modules? --need_lib_prefix=$need_lib_prefix -- --# Do we need a version for libraries? --need_version=$need_version -- --# Whether dlopen is supported. --dlopen_support=$enable_dlopen -- --# Whether dlopen of programs is supported. --dlopen_self=$enable_dlopen_self -- --# Whether dlopen of statically linked programs is supported. --dlopen_self_static=$enable_dlopen_self_static -- --# Compiler flag to prevent dynamic linking. --link_static_flag=$lt_link_static_flag -- --# Compiler flag to turn off builtin functions. --no_builtin_flag=$lt_no_builtin_flag -- --# Compiler flag to allow reflexive dlopens. --export_dynamic_flag_spec=$lt_export_dynamic_flag_spec -- --# Compiler flag to generate shared objects directly from archives. --whole_archive_flag_spec=$lt_whole_archive_flag_spec -- --# Compiler flag to generate thread-safe objects. --thread_safe_flag_spec=$lt_thread_safe_flag_spec -- --# Library versioning type. --version_type=$version_type -- --# Format of library name prefix. --libname_spec=$lt_libname_spec -- --# List of archive names. First name is the real one, the rest are links. --# The last name is the one that the linker finds with -lNAME. --library_names_spec=$lt_library_names_spec -- --# The coded name of the library, if different from the real name. --soname_spec=$lt_soname_spec -- --# Commands used to build and install an old-style archive. --RANLIB=$lt_RANLIB --old_archive_cmds=$lt_old_archive_cmds --old_postinstall_cmds=$lt_old_postinstall_cmds --old_postuninstall_cmds=$lt_old_postuninstall_cmds -- --# Create an old-style archive from a shared archive. --old_archive_from_new_cmds=$lt_old_archive_from_new_cmds -- --# Create a temporary old-style archive to link instead of a shared archive. --old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds -- --# Commands used to build and install a shared archive. --archive_cmds=$lt_archive_cmds --archive_expsym_cmds=$lt_archive_expsym_cmds --postinstall_cmds=$lt_postinstall_cmds --postuninstall_cmds=$lt_postuninstall_cmds -- --# Commands to strip libraries. --old_striplib=$lt_old_striplib --striplib=$lt_striplib -- --# Method to check whether dependent libraries are shared objects. --deplibs_check_method=$lt_deplibs_check_method -- --# Command to use when deplibs_check_method == file_magic. --file_magic_cmd=$lt_file_magic_cmd -- --# Flag that allows shared libraries with undefined symbols to be built. --allow_undefined_flag=$lt_allow_undefined_flag -- --# Flag that forces no undefined symbols. --no_undefined_flag=$lt_no_undefined_flag -- --# Commands used to finish a libtool library installation in a directory. --finish_cmds=$lt_finish_cmds -- --# Same as above, but a single script fragment to be evaled but not shown. --finish_eval=$lt_finish_eval -- --# Take the output of nm and produce a listing of raw symbols and C names. --global_symbol_pipe=$lt_global_symbol_pipe -- --# Transform the output of nm in a proper C declaration --global_symbol_to_cdecl=$lt_global_symbol_to_cdecl -- --# Transform the output of nm in a C name address pair --global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address -- --# This is the shared library runtime path variable. --runpath_var=$runpath_var -- --# This is the shared library path variable. --shlibpath_var=$shlibpath_var -- --# Is shlibpath searched before the hard-coded library search path? --shlibpath_overrides_runpath=$shlibpath_overrides_runpath -- --# How to hardcode a shared library path into an executable. --hardcode_action=$hardcode_action -- --# Whether we should hardcode library paths into libraries. --hardcode_into_libs=$hardcode_into_libs -- --# Flag to hardcode \$libdir into a binary during linking. --# This must work even if \$libdir does not exist. --hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec -- --# Whether we need a single -rpath flag with a separated argument. --hardcode_libdir_separator=$lt_hardcode_libdir_separator -- --# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the --# resulting binary. --hardcode_direct=$hardcode_direct -- --# Set to yes if using the -LDIR flag during linking hardcodes DIR into the --# resulting binary. --hardcode_minus_L=$hardcode_minus_L -- --# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into --# the resulting binary. --hardcode_shlibpath_var=$hardcode_shlibpath_var -- --# Variables whose values should be saved in libtool wrapper scripts and --# restored at relink time. --variables_saved_for_relink="$variables_saved_for_relink" -- --# Whether libtool must link a program against all its dependency libraries. --link_all_deplibs=$link_all_deplibs -- --# Compile-time system search path for libraries --sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -- --# Run-time system search path for libraries --sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -- --# Fix the shell variable \$srcfile for the compiler. --fix_srcfile_path="$fix_srcfile_path" -- --# Set to yes if exported symbols are required. --always_export_symbols=$always_export_symbols -- --# The commands to list exported symbols. --export_symbols_cmds=$lt_export_symbols_cmds -- --# The commands to extract the exported symbol list from a shared archive. --extract_expsyms_cmds=$lt_extract_expsyms_cmds -- --# Symbols that should not be listed in the preloaded symbols. --exclude_expsyms=$lt_exclude_expsyms -- --# Symbols that must always be exported. --include_expsyms=$lt_include_expsyms -- --# ### END LIBTOOL CONFIG -- --__EOF__ -- -- case $host_os in -- aix3*) -- cat <<\EOF >> "${ofile}T" -- --# AIX sometimes has problems with the GCC collect2 program. For some --# reason, if we set the COLLECT_NAMES environment variable, the problems --# vanish in a puff of smoke. --if test "X${COLLECT_NAMES+set}" != Xset; then -- COLLECT_NAMES= -- export COLLECT_NAMES --fi --EOF -- ;; -- esac -- -- case $host_os in -- cygwin* | mingw* | pw32* | os2*) -- cat <<'EOF' >> "${ofile}T" -- # This is a source program that is used to create dlls on Windows -- # Don't remove nor modify the starting and closing comments --# /* ltdll.c starts here */ --# #define WIN32_LEAN_AND_MEAN --# #include --# #undef WIN32_LEAN_AND_MEAN --# #include --# --# #ifndef __CYGWIN__ --# # ifdef __CYGWIN32__ --# # define __CYGWIN__ __CYGWIN32__ --# # endif --# #endif --# --# #ifdef __cplusplus --# extern "C" { --# #endif --# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); --# #ifdef __cplusplus --# } --# #endif --# --# #ifdef __CYGWIN__ --# #include --# DECLARE_CYGWIN_DLL( DllMain ); --# #endif --# HINSTANCE __hDllInstance_base; --# --# BOOL APIENTRY --# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) --# { --# __hDllInstance_base = hInst; --# return TRUE; --# } --# /* ltdll.c ends here */ -- # This is a source program that is used to create import libraries -- # on Windows for dlls which lack them. Don't remove nor modify the -- # starting and closing comments --# /* impgen.c starts here */ --# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. --# --# This file is part of GNU libtool. --# --# 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 /* for printf() */ --# #include /* for open(), lseek(), read() */ --# #include /* for O_RDONLY, O_BINARY */ --# #include /* for strdup() */ --# --# /* O_BINARY isn't required (or even defined sometimes) under Unix */ --# #ifndef O_BINARY --# #define O_BINARY 0 --# #endif --# --# static unsigned int --# pe_get16 (fd, offset) --# int fd; --# int offset; --# { --# unsigned char b[2]; --# lseek (fd, offset, SEEK_SET); --# read (fd, b, 2); --# return b[0] + (b[1]<<8); --# } --# --# static unsigned int --# pe_get32 (fd, offset) --# int fd; --# int offset; --# { --# unsigned char b[4]; --# lseek (fd, offset, SEEK_SET); --# read (fd, b, 4); --# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); --# } --# --# static unsigned int --# pe_as32 (ptr) --# void *ptr; --# { --# unsigned char *b = ptr; --# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); --# } --# --# int --# main (argc, argv) --# int argc; --# char *argv[]; --# { --# int dll; --# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; --# unsigned long export_rva, export_size, nsections, secptr, expptr; --# unsigned long name_rvas, nexp; --# unsigned char *expdata, *erva; --# char *filename, *dll_name; --# --# filename = argv[1]; --# --# dll = open(filename, O_RDONLY|O_BINARY); --# if (dll < 1) --# return 1; --# --# dll_name = filename; --# --# for (i=0; filename[i]; i++) --# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') --# dll_name = filename + i +1; --# --# pe_header_offset = pe_get32 (dll, 0x3c); --# opthdr_ofs = pe_header_offset + 4 + 20; --# num_entries = pe_get32 (dll, opthdr_ofs + 92); --# --# if (num_entries < 1) /* no exports */ --# return 1; --# --# export_rva = pe_get32 (dll, opthdr_ofs + 96); --# export_size = pe_get32 (dll, opthdr_ofs + 100); --# nsections = pe_get16 (dll, pe_header_offset + 4 +2); --# secptr = (pe_header_offset + 4 + 20 + --# pe_get16 (dll, pe_header_offset + 4 + 16)); --# --# expptr = 0; --# for (i = 0; i < nsections; i++) --# { --# char sname[8]; --# unsigned long secptr1 = secptr + 40 * i; --# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); --# unsigned long vsize = pe_get32 (dll, secptr1 + 16); --# unsigned long fptr = pe_get32 (dll, secptr1 + 20); --# lseek(dll, secptr1, SEEK_SET); --# read(dll, sname, 8); --# if (vaddr <= export_rva && vaddr+vsize > export_rva) --# { --# expptr = fptr + (export_rva - vaddr); --# if (export_rva + export_size > vaddr + vsize) --# export_size = vsize - (export_rva - vaddr); --# break; --# } --# } --# --# expdata = (unsigned char*)malloc(export_size); --# lseek (dll, expptr, SEEK_SET); --# read (dll, expdata, export_size); --# erva = expdata - export_rva; --# --# nexp = pe_as32 (expdata+24); --# name_rvas = pe_as32 (expdata+32); --# --# printf ("EXPORTS\n"); --# for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) -- -- mv -f "${ofile}T" "$ofile" || \ -- (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") -- chmod +x "$ofile" --fi -- --])# _LT_AC_LTCONFIG_HACK -- --# AC_LIBTOOL_DLOPEN - enable checks for dlopen support --AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) -- --# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's --AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) -- --# AC_ENABLE_SHARED - implement the --enable-shared flag --# Usage: AC_ENABLE_SHARED[(DEFAULT)] --# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to --# `yes'. --AC_DEFUN([AC_ENABLE_SHARED], --[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl --AC_ARG_ENABLE(shared, --changequote(<<, >>)dnl --<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], --changequote([, ])dnl --[p=${PACKAGE-default} --case $enableval in --yes) enable_shared=yes ;; --no) enable_shared=no ;; --*) -- enable_shared=no -- # Look at the argument we got. We use all the common list separators. -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," -- for pkg in $enableval; do -- if test "X$pkg" = "X$p"; then -- enable_shared=yes -- fi -- done -- IFS="$ac_save_ifs" -- ;; --esac], --enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl --]) -- --# AC_DISABLE_SHARED - set the default shared flag to --disable-shared --AC_DEFUN([AC_DISABLE_SHARED], --[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl --AC_ENABLE_SHARED(no)]) -- --# AC_ENABLE_STATIC - implement the --enable-static flag --# Usage: AC_ENABLE_STATIC[(DEFAULT)] --# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to --# `yes'. --AC_DEFUN([AC_ENABLE_STATIC], --[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl --AC_ARG_ENABLE(static, --changequote(<<, >>)dnl --<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], --changequote([, ])dnl --[p=${PACKAGE-default} --case $enableval in --yes) enable_static=yes ;; --no) enable_static=no ;; --*) -- enable_static=no -- # Look at the argument we got. We use all the common list separators. -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," -- for pkg in $enableval; do -- if test "X$pkg" = "X$p"; then -- enable_static=yes -- fi -- done -- IFS="$ac_save_ifs" -- ;; --esac], --enable_static=AC_ENABLE_STATIC_DEFAULT)dnl --]) -- --# AC_DISABLE_STATIC - set the default static flag to --disable-static --AC_DEFUN([AC_DISABLE_STATIC], --[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl --AC_ENABLE_STATIC(no)]) -- -- --# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag --# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] --# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to --# `yes'. --AC_DEFUN([AC_ENABLE_FAST_INSTALL], --[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl --AC_ARG_ENABLE(fast-install, --changequote(<<, >>)dnl --<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], --changequote([, ])dnl --[p=${PACKAGE-default} --case $enableval in --yes) enable_fast_install=yes ;; --no) enable_fast_install=no ;; --*) -- enable_fast_install=no -- # Look at the argument we got. We use all the common list separators. -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," -- for pkg in $enableval; do -- if test "X$pkg" = "X$p"; then -- enable_fast_install=yes -- fi -- done -- IFS="$ac_save_ifs" -- ;; --esac], --enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl --]) -- --# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install --AC_DEFUN([AC_DISABLE_FAST_INSTALL], --[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl --AC_ENABLE_FAST_INSTALL(no)]) -- --# AC_LIBTOOL_PICMODE - implement the --with-pic flag --# Usage: AC_LIBTOOL_PICMODE[(MODE)] --# Where MODE is either `yes' or `no'. If omitted, it defaults to --# `both'. --AC_DEFUN([AC_LIBTOOL_PICMODE], --[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl --pic_mode=ifelse($#,1,$1,default)]) -- -- --# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library --AC_DEFUN([AC_PATH_TOOL_PREFIX], --[AC_MSG_CHECKING([for $1]) --AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, --[case $MAGIC_CMD in -- /*) -- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. -- ;; -- ?:/*) -- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. -- ;; -- *) -- ac_save_MAGIC_CMD="$MAGIC_CMD" -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" --dnl $ac_dummy forces splitting on constant user-supplied paths. --dnl POSIX.2 word splitting is done only on the output of word expansions, --dnl not every word. This closes a longstanding sh security hole. -- ac_dummy="ifelse([$2], , $PATH, [$2])" -- for ac_dir in $ac_dummy; do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/$1; then -- lt_cv_path_MAGIC_CMD="$ac_dir/$1" -- if test -n "$file_magic_test_file"; then -- case $deplibs_check_method in -- "file_magic "*) -- file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" -- MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -- egrep "$file_magic_regex" > /dev/null; then -- : -- else -- cat <&2 -- --*** Warning: the command libtool uses to detect shared libraries, --*** $file_magic_cmd, produces output that libtool cannot recognize. --*** The result is that libtool may fail to recognize shared libraries --*** as such. This will affect the creation of libtool libraries that --*** depend on shared libraries, but programs linked with such libtool --*** libraries will work regardless of this problem. Nevertheless, you --*** may want to report the problem to your system manager and/or to --*** bug-libtool@gnu.org -- --EOF -- fi ;; -- esac -- fi -- break -- fi -- done -- IFS="$ac_save_ifs" -- MAGIC_CMD="$ac_save_MAGIC_CMD" -- ;; --esac]) --MAGIC_CMD="$lt_cv_path_MAGIC_CMD" --if test -n "$MAGIC_CMD"; then -- AC_MSG_RESULT($MAGIC_CMD) --else -- AC_MSG_RESULT(no) --fi --]) -- -- --# AC_PATH_MAGIC - find a file program which can recognise a shared library --AC_DEFUN([AC_PATH_MAGIC], --[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl --AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH) --if test -z "$lt_cv_path_MAGIC_CMD"; then -- if test -n "$ac_tool_prefix"; then -- AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH) -- else -- MAGIC_CMD=: -- fi --fi --]) -- -- --# AC_PROG_LD - find the path to the GNU or non-GNU linker --AC_DEFUN([AC_PROG_LD], --[AC_ARG_WITH(gnu-ld, --[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], --test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) --AC_REQUIRE([AC_PROG_CC])dnl --AC_REQUIRE([AC_CANONICAL_HOST])dnl --AC_REQUIRE([AC_CANONICAL_BUILD])dnl --AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl --ac_prog=ld --if test "$GCC" = yes; then -- # Check if gcc -print-prog-name=ld gives a path. -- AC_MSG_CHECKING([for ld used by GCC]) -- case $host in -- *-*-mingw*) -- # gcc leaves a trailing carriage return which upsets mingw -- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; -- *) -- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; -- esac -- case $ac_prog in -- # Accept absolute paths. -- [[\\/]]* | [[A-Za-z]]:[[\\/]]*) -- re_direlt='/[[^/]][[^/]]*/\.\./' -- # Canonicalize the path of ld -- ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` -- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -- ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` -- done -- test -z "$LD" && LD="$ac_prog" -- ;; -- "") -- # If it fails, then pretend we aren't using GCC. -- ac_prog=ld -- ;; -- *) -- # If it is relative, then search for the first ld in PATH. -- with_gnu_ld=unknown -- ;; -- esac --elif test "$with_gnu_ld" = yes; then -- AC_MSG_CHECKING([for GNU ld]) --else -- AC_MSG_CHECKING([for non-GNU ld]) --fi --AC_CACHE_VAL(lt_cv_path_LD, --[if test -z "$LD"; then -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -- for ac_dir in $PATH; do -- test -z "$ac_dir" && ac_dir=. -- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then -- lt_cv_path_LD="$ac_dir/$ac_prog" -- # Check to see if the program is GNU ld. I'd rather use --version, -- # but apparently some GNU ld's only accept -v. -- # Break only if it was the GNU/non-GNU ld that we prefer. -- if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then -- test "$with_gnu_ld" != no && break -- else -- test "$with_gnu_ld" != yes && break -- fi -- fi -- done -- IFS="$ac_save_ifs" --else -- lt_cv_path_LD="$LD" # Let the user override the test with a path. --fi]) --LD="$lt_cv_path_LD" --if test -n "$LD"; then -- AC_MSG_RESULT($LD) --else -- AC_MSG_RESULT(no) --fi --test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) --AC_PROG_LD_GNU --]) -- --# AC_PROG_LD_GNU - --AC_DEFUN([AC_PROG_LD_GNU], --[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, --[# I'd rather use --version here, but apparently some GNU ld's only accept -v. --if $LD -v 2>&1 &5; then -- lt_cv_prog_gnu_ld=yes --else -- lt_cv_prog_gnu_ld=no --fi]) --with_gnu_ld=$lt_cv_prog_gnu_ld --]) -- --# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker --# -- PORTME Some linkers may need a different reload flag. --AC_DEFUN([AC_PROG_LD_RELOAD_FLAG], --[AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag, --[lt_cv_ld_reload_flag='-r']) --reload_flag=$lt_cv_ld_reload_flag --test -n "$reload_flag" && reload_flag=" $reload_flag" --]) -- --# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies --# -- PORTME fill in with the dynamic library characteristics --AC_DEFUN([AC_DEPLIBS_CHECK_METHOD], --[AC_CACHE_CHECK([how to recognise dependant libraries], --lt_cv_deplibs_check_method, --[lt_cv_file_magic_cmd='$MAGIC_CMD' --lt_cv_file_magic_test_file= --lt_cv_deplibs_check_method='unknown' --# Need to set the preceding variable on all platforms that support --# interlibrary dependencies. --# 'none' -- dependencies not supported. --# `unknown' -- same as none, but documents that we really don't know. --# 'pass_all' -- all dependencies passed with no checks. --# 'test_compile' -- check by making test program. --# 'file_magic [[regex]]' -- check by looking for files in library path --# which responds to the $file_magic_cmd with a given egrep regex. --# If you have `file' or equivalent on your system and you're not sure --# whether `pass_all' will *always* work, you probably want this one. -- --case $host_os in --aix4* | aix5*) -- lt_cv_deplibs_check_method=pass_all -- ;; -- --beos*) -- lt_cv_deplibs_check_method=pass_all -- ;; -- --bsdi4*) -- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' -- lt_cv_file_magic_cmd='/usr/bin/file -L' -- lt_cv_file_magic_test_file=/shlib/libc.so -- ;; -- --cygwin* | mingw* | pw32*) -- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' -- lt_cv_file_magic_cmd='$OBJDUMP -f' -- ;; -- --darwin* | rhapsody*) -- lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' -- lt_cv_file_magic_cmd='/usr/bin/file -L' -- case "$host_os" in -- rhapsody* | darwin1.[[012]]) -- lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` -- ;; -- *) # Darwin 1.3 on -- lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' -- ;; -- esac -- ;; -- --freebsd*) -- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then -- case $host_cpu in -- i*86 ) -- # Not sure whether the presence of OpenBSD here was a mistake. -- # Let's accept both of them until this is cleared up. -- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' -- lt_cv_file_magic_cmd=/usr/bin/file -- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` -- ;; -- esac -- else -- lt_cv_deplibs_check_method=pass_all -- fi -- ;; -- --gnu*) -- lt_cv_deplibs_check_method=pass_all -- ;; -- --hpux10.20*|hpux11*) -- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' -- lt_cv_file_magic_cmd=/usr/bin/file -- lt_cv_file_magic_test_file=/usr/lib/libc.sl -- ;; -- --irix5* | irix6*) -- case $host_os in -- irix5*) -- # this will be overridden with pass_all, but let us keep it just in case -- lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" -- ;; -- *) -- case $LD in -- *-32|*"-32 ") libmagic=32-bit;; -- *-n32|*"-n32 ") libmagic=N32;; -- *-64|*"-64 ") libmagic=64-bit;; -- *) libmagic=never-match;; -- esac -- # this will be overridden with pass_all, but let us keep it just in case -- lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[[1234]] dynamic lib MIPS - version 1" -- ;; -- esac -- lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` -- lt_cv_deplibs_check_method=pass_all -- ;; -- --# This must be Linux ELF. --linux-gnu*) -- case $host_cpu in -- alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* | s390* ) -- lt_cv_deplibs_check_method=pass_all ;; -- *) -- # glibc up to 2.1.1 does not perform some relocations on ARM -- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; -- esac -- lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` -- ;; -- --netbsd*) -- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then -- lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$' -- else -- lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$' -- fi -- ;; -- --newos6*) -- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' -- lt_cv_file_magic_cmd=/usr/bin/file -- lt_cv_file_magic_test_file=/usr/lib/libnls.so -- ;; -- --openbsd*) -- lt_cv_file_magic_cmd=/usr/bin/file -- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` -- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' -- else -- lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' -- fi -- ;; -- --osf3* | osf4* | osf5*) -- # this will be overridden with pass_all, but let us keep it just in case -- lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' -- lt_cv_file_magic_test_file=/shlib/libc.so -- lt_cv_deplibs_check_method=pass_all -- ;; -- --sco3.2v5*) -- lt_cv_deplibs_check_method=pass_all -- ;; -- --solaris*) -- lt_cv_deplibs_check_method=pass_all -- lt_cv_file_magic_test_file=/lib/libc.so -- ;; -- --sysv5uw[[78]]* | sysv4*uw2*) -- lt_cv_deplibs_check_method=pass_all -- ;; -- --sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -- case $host_vendor in -- motorola) -- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' -- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` -- ;; -- ncr) -- lt_cv_deplibs_check_method=pass_all -- ;; -- sequent) -- lt_cv_file_magic_cmd='/bin/file' -- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' -- ;; -- sni) -- lt_cv_file_magic_cmd='/bin/file' -- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" -- lt_cv_file_magic_test_file=/lib/libc.so -- ;; -- esac -- ;; --esac --]) --file_magic_cmd=$lt_cv_file_magic_cmd --deplibs_check_method=$lt_cv_deplibs_check_method --]) -- -- --# AC_PROG_NM - find the path to a BSD-compatible name lister --AC_DEFUN([AC_PROG_NM], --[AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl --AC_MSG_CHECKING([for BSD-compatible nm]) --AC_CACHE_VAL(lt_cv_path_NM, --[if test -n "$NM"; then -- # Let the user override the test. -- lt_cv_path_NM="$NM" --else -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -- for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do -- test -z "$ac_dir" && ac_dir=. -- tmp_nm=$ac_dir/${ac_tool_prefix}nm -- if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then -- # Check to see if the nm accepts a BSD-compat flag. -- # Adding the `sed 1q' prevents false positives on HP-UX, which says: -- # nm: unknown option "B" ignored -- # Tru64's nm complains that /dev/null is an invalid object file -- if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then -- lt_cv_path_NM="$tmp_nm -B" -- break -- elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then -- lt_cv_path_NM="$tmp_nm -p" -- break -- else -- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but -- continue # so that we can try to find one that supports BSD flags -- fi -- fi -- done -- IFS="$ac_save_ifs" -- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm --fi]) --NM="$lt_cv_path_NM" --AC_MSG_RESULT([$NM]) --]) -- --# AC_CHECK_LIBM - check for math library --AC_DEFUN([AC_CHECK_LIBM], --[AC_REQUIRE([AC_CANONICAL_HOST])dnl --LIBM= --case $host in --*-*-beos* | *-*-cygwin* | *-*-pw32*) -- # These system don't have libm -- ;; --*-ncr-sysv4.3*) -- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") -- AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") -- ;; --*) -- AC_CHECK_LIB(m, main, LIBM="-lm") -- ;; --esac --]) -- --# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for --# the libltdl convenience library and INCLTDL to the include flags for --# the libltdl header and adds --enable-ltdl-convenience to the --# configure arguments. Note that LIBLTDL and INCLTDL are not --# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not --# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed --# with '${top_builddir}/' and INCLTDL will be prefixed with --# '${top_srcdir}/' (note the single quotes!). If your package is not --# flat and you're not using automake, define top_builddir and --# top_srcdir appropriately in the Makefiles. --AC_DEFUN([AC_LIBLTDL_CONVENIENCE], --[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -- case $enable_ltdl_convenience in -- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; -- "") enable_ltdl_convenience=yes -- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; -- esac -- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la -- INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) --]) -- --# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for --# the libltdl installable library and INCLTDL to the include flags for --# the libltdl header and adds --enable-ltdl-install to the configure --# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is --# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed --# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will --# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed --# with '${top_srcdir}/' (note the single quotes!). If your package is --# not flat and you're not using automake, define top_builddir and --# top_srcdir appropriately in the Makefiles. --# In the future, this macro may have to be called after AC_PROG_LIBTOOL. --AC_DEFUN([AC_LIBLTDL_INSTALLABLE], --[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -- AC_CHECK_LIB(ltdl, main, -- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], -- [if test x"$enable_ltdl_install" = xno; then -- AC_MSG_WARN([libltdl not installed, but installation disabled]) -- else -- enable_ltdl_install=yes -- fi -- ]) -- if test x"$enable_ltdl_install" = x"yes"; then -- ac_configure_args="$ac_configure_args --enable-ltdl-install" -- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la -- INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) -- else -- ac_configure_args="$ac_configure_args --enable-ltdl-install=no" -- LIBLTDL="-lltdl" -- INCLTDL= -- fi --]) -- --# old names --AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) --AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) --AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) --AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) --AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) --AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) --AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) -- --# This is just to silence aclocal about the macro not being used --ifelse([AC_DISABLE_FAST_INSTALL]) -- --# gettext.m4 serial 16 (gettext-0.11.4) --dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. --dnl --dnl This file can can be used in projects which are not available under --dnl the GNU General Public License or the GNU Library General Public --dnl License but which still want to provide support for the GNU gettext --dnl functionality. --dnl Please note that the actual code of the GNU gettext library is covered --dnl by the GNU Library General Public License, and the rest of the GNU --dnl gettext package package is covered by the GNU General Public License. --dnl They are *not* in the public domain. -- --dnl Authors: --dnl Ulrich Drepper , 1995-2000. --dnl Bruno Haible , 2000-2002. -- --dnl Macro to add for using GNU gettext. -- --dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). --dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The --dnl default (if it is not specified or empty) is 'no-libtool'. --dnl INTLSYMBOL should be 'external' for packages with no intl directory, --dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. --dnl If INTLSYMBOL is 'use-libtool', then a libtool library --dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, --dnl depending on --{enable,disable}-{shared,static} and on the presence of --dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library --dnl $(top_builddir)/intl/libintl.a will be created. --dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext --dnl implementations (in libc or libintl) without the ngettext() function --dnl will be ignored. If NEEDSYMBOL is specified and is --dnl 'need-formatstring-macros', then GNU gettext implementations that don't --dnl support the ISO C 99 formatstring macros will be ignored. --dnl INTLDIR is used to find the intl libraries. If empty, --dnl the value `$(top_builddir)/intl/' is used. --dnl --dnl The result of the configuration is one of three cases: --dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled --dnl and used. --dnl Catalog format: GNU --> install in $(datadir) --dnl Catalog extension: .mo after installation, .gmo in source tree --dnl 2) GNU gettext has been found in the system's C library. --dnl Catalog format: GNU --> install in $(datadir) --dnl Catalog extension: .mo after installation, .gmo in source tree --dnl 3) No internationalization, always use English msgid. --dnl Catalog format: none --dnl Catalog extension: none --dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. --dnl The use of .gmo is historical (it was needed to avoid overwriting the --dnl GNU format catalogs when building on a platform with an X/Open gettext), --dnl but we keep it in order not to force irrelevant filename changes on the --dnl maintainers. --dnl --AC_DEFUN([AM_GNU_GETTEXT], --[ -- dnl Argument checking. -- ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , -- [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT --])])])])]) -- ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , -- [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT --])])])]) -- define(gt_included_intl, ifelse([$1], [external], [no], [yes])) -- define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], [])) -- -- AC_REQUIRE([AM_PO_SUBDIRS])dnl -- ifelse(gt_included_intl, yes, [ -- AC_REQUIRE([AM_INTL_SUBDIR])dnl -- ]) -- -- dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. -- AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -- AC_REQUIRE([AC_LIB_RPATH]) -- -- dnl Sometimes libintl requires libiconv, so first search for libiconv. -- dnl Ideally we would do this search only after the -- dnl if test "$USE_NLS" = "yes"; then -- dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then -- dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT -- dnl the configure script would need to contain the same shell code -- dnl again, outside any 'if'. There are two solutions: -- dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. -- dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. -- dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not -- dnl documented, we avoid it. -- ifelse(gt_included_intl, yes, , [ -- AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) -- ]) -- -- AC_MSG_CHECKING([whether NLS is requested]) -- dnl Default is enabled NLS -- AC_ARG_ENABLE(nls, -- [ --disable-nls do not use Native Language Support], -- USE_NLS=$enableval, USE_NLS=yes) -- AC_MSG_RESULT($USE_NLS) -- AC_SUBST(USE_NLS) -- -- ifelse(gt_included_intl, yes, [ -- BUILD_INCLUDED_LIBINTL=no -- USE_INCLUDED_LIBINTL=no -- ]) -- LIBINTL= -- LTLIBINTL= -- POSUB= -- -- dnl If we use NLS figure out what method -- if test "$USE_NLS" = "yes"; then -- gt_use_preinstalled_gnugettext=no -- ifelse(gt_included_intl, yes, [ -- AC_MSG_CHECKING([whether included gettext is requested]) -- AC_ARG_WITH(included-gettext, -- [ --with-included-gettext use the GNU gettext library included here], -- nls_cv_force_use_gnu_gettext=$withval, -- nls_cv_force_use_gnu_gettext=no) -- AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) -- -- nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" -- if test "$nls_cv_force_use_gnu_gettext" != "yes"; then -- ]) -- dnl User does not insist on using GNU NLS library. Figure out what -- dnl to use. If GNU gettext is available we use this. Else we have -- dnl to fall back to GNU NLS library. -- -- dnl Add a version number to the cache macros. -- define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1))) -- define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc]) -- define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl]) -- -- AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc, -- [AC_TRY_LINK([#include --]ifelse([$2], [need-formatstring-macros], --[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION --#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) --#endif --changequote(,)dnl --typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; --changequote([,])dnl --], [])[extern int _nl_msg_cat_cntr; --extern int *_nl_domain_bindings;], -- [bindtextdomain ("", ""); --return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings], -- gt_cv_func_gnugettext_libc=yes, -- gt_cv_func_gnugettext_libc=no)]) -- -- if test "$gt_cv_func_gnugettext_libc" != "yes"; then -- dnl Sometimes libintl requires libiconv, so first search for libiconv. -- ifelse(gt_included_intl, yes, , [ -- AM_ICONV_LINK -- ]) -- dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL -- dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) -- dnl because that would add "-liconv" to LIBINTL and LTLIBINTL -- dnl even if libiconv doesn't exist. -- AC_LIB_LINKFLAGS_BODY([intl]) -- AC_CACHE_CHECK([for GNU gettext in libintl], -- gt_cv_func_gnugettext_libintl, -- [gt_save_CPPFLAGS="$CPPFLAGS" -- CPPFLAGS="$CPPFLAGS $INCINTL" -- gt_save_LIBS="$LIBS" -- LIBS="$LIBS $LIBINTL" -- dnl Now see whether libintl exists and does not depend on libiconv. -- AC_TRY_LINK([#include --]ifelse([$2], [need-formatstring-macros], --[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION --#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) --#endif --changequote(,)dnl --typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; --changequote([,])dnl --], [])[extern int _nl_msg_cat_cntr; --extern --#ifdef __cplusplus --"C" --#endif --const char *_nl_expand_alias ();], -- [bindtextdomain ("", ""); --return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], -- gt_cv_func_gnugettext_libintl=yes, -- gt_cv_func_gnugettext_libintl=no) -- dnl Now see whether libintl exists and depends on libiconv. -- if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then -- LIBS="$LIBS $LIBICONV" -- AC_TRY_LINK([#include --]ifelse([$2], [need-formatstring-macros], --[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION --#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) --#endif --changequote(,)dnl --typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; --changequote([,])dnl --], [])[extern int _nl_msg_cat_cntr; --extern --#ifdef __cplusplus --"C" --#endif --const char *_nl_expand_alias ();], -- [bindtextdomain ("", ""); --return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], -- [LIBINTL="$LIBINTL $LIBICONV" -- LTLIBINTL="$LTLIBINTL $LTLIBICONV" -- gt_cv_func_gnugettext_libintl=yes -- ]) -- fi -- CPPFLAGS="$gt_save_CPPFLAGS" -- LIBS="$gt_save_LIBS"]) -- fi -- -- dnl If an already present or preinstalled GNU gettext() is found, -- dnl use it. But if this macro is used in GNU gettext, and GNU -- dnl gettext is already preinstalled in libintl, we update this -- dnl libintl. (Cf. the install rule in intl/Makefile.in.) -- if test "$gt_cv_func_gnugettext_libc" = "yes" \ -- || { test "$gt_cv_func_gnugettext_libintl" = "yes" \ -- && test "$PACKAGE" != gettext; }; then -- gt_use_preinstalled_gnugettext=yes -- else -- dnl Reset the values set by searching for libintl. -- LIBINTL= -- LTLIBINTL= -- INCINTL= -- fi -- -- ifelse(gt_included_intl, yes, [ -- if test "$gt_use_preinstalled_gnugettext" != "yes"; then -- dnl GNU gettext is not found in the C library. -- dnl Fall back on included GNU gettext library. -- nls_cv_use_gnu_gettext=yes -- fi -- fi -- -- if test "$nls_cv_use_gnu_gettext" = "yes"; then -- dnl Mark actions used to generate GNU NLS library. -- INTLOBJS="\$(GETTOBJS)" -- BUILD_INCLUDED_LIBINTL=yes -- USE_INCLUDED_LIBINTL=yes -- LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV" -- LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV" -- LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` -- fi -- -- if test "$gt_use_preinstalled_gnugettext" = "yes" \ -- || test "$nls_cv_use_gnu_gettext" = "yes"; then -- dnl Mark actions to use GNU gettext tools. -- CATOBJEXT=.gmo -- fi -- ]) -- -- if test "$gt_use_preinstalled_gnugettext" = "yes" \ -- || test "$nls_cv_use_gnu_gettext" = "yes"; then -- AC_DEFINE(ENABLE_NLS, 1, -- [Define to 1 if translation of program messages to the user's native language -- is requested.]) -- else -- USE_NLS=no -- fi -- fi -- -- if test "$USE_NLS" = "yes"; then -- -- if test "$gt_use_preinstalled_gnugettext" = "yes"; then -- if test "$gt_cv_func_gnugettext_libintl" = "yes"; then -- AC_MSG_CHECKING([how to link with libintl]) -- AC_MSG_RESULT([$LIBINTL]) -- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) -- fi -- -- dnl For backward compatibility. Some packages may be using this. -- AC_DEFINE(HAVE_GETTEXT, 1, -- [Define if the GNU gettext() function is already present or preinstalled.]) -- AC_DEFINE(HAVE_DCGETTEXT, 1, -- [Define if the GNU dcgettext() function is already present or preinstalled.]) -- fi -- -- dnl We need to process the po/ directory. -- POSUB=po -- fi -- -- ifelse(gt_included_intl, yes, [ -- dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL -- dnl to 'yes' because some of the testsuite requires it. -- if test "$PACKAGE" = gettext; then -- BUILD_INCLUDED_LIBINTL=yes -- fi -- -- dnl Make all variables we use known to autoconf. -- AC_SUBST(BUILD_INCLUDED_LIBINTL) -- AC_SUBST(USE_INCLUDED_LIBINTL) -- AC_SUBST(CATOBJEXT) -- AC_SUBST(INTLOBJS) -- -- dnl For backward compatibility. Some configure.ins may be using this. -- nls_cv_header_intl= -- nls_cv_header_libgt= -- -- dnl For backward compatibility. Some Makefiles may be using this. -- DATADIRNAME=share -- AC_SUBST(DATADIRNAME) -- -- dnl For backward compatibility. Some Makefiles may be using this. -- INSTOBJEXT=.mo -- AC_SUBST(INSTOBJEXT) -- -- dnl For backward compatibility. Some Makefiles may be using this. -- GENCAT=gencat -- AC_SUBST(GENCAT) -- -- dnl Enable libtool support if the surrounding package wishes it. -- INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix -- AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) -- ]) -- -- dnl For backward compatibility. Some Makefiles may be using this. -- INTLLIBS="$LIBINTL" -- AC_SUBST(INTLLIBS) -- -- dnl Make all documented variables known to autoconf. -- AC_SUBST(LIBINTL) -- AC_SUBST(LTLIBINTL) -- AC_SUBST(POSUB) --]) -- -- --dnl Checks for all prerequisites of the po subdirectory, --dnl except for USE_NLS. --AC_DEFUN([AM_PO_SUBDIRS], --[ -- AC_REQUIRE([AC_PROG_MAKE_SET])dnl -- AC_REQUIRE([AC_PROG_INSTALL])dnl -- AC_REQUIRE([AM_MKINSTALLDIRS])dnl -- -- dnl Perform the following tests also if --disable-nls has been given, -- dnl because they are needed for "make dist" to work. -- -- dnl Search for GNU msgfmt in the PATH. -- dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. -- dnl The second test excludes FreeBSD msgfmt. -- AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, -- [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && -- (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], -- :) -- AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) -- -- dnl Search for GNU xgettext 0.11 or newer in the PATH. -- dnl The first test excludes Solaris xgettext and early GNU xgettext versions. -- dnl The second test excludes FreeBSD xgettext. -- AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, -- [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 && -- (if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], -- :) -- dnl Remove leftover from FreeBSD xgettext call. -- rm -f messages.po -- -- dnl Search for GNU msgmerge 0.11 or newer in the PATH. -- AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, -- [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :) -- -- dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. -- dnl Test whether we really found GNU msgfmt. -- if test "$GMSGFMT" != ":"; then -- dnl If it is no GNU msgfmt we define it as : so that the -- dnl Makefiles still can work. -- if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && -- (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -- : ; -- else -- GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` -- AC_MSG_RESULT( -- [found $GMSGFMT program is not GNU msgfmt; ignore it]) -- GMSGFMT=":" -- fi -- fi -- -- dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. -- dnl Test whether we really found GNU xgettext. -- if test "$XGETTEXT" != ":"; then -- dnl If it is no GNU xgettext we define it as : so that the -- dnl Makefiles still can work. -- if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 && -- (if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -- : ; -- else -- AC_MSG_RESULT( -- [found xgettext program is not GNU xgettext; ignore it]) -- XGETTEXT=":" -- fi -- dnl Remove leftover from FreeBSD xgettext call. -- rm -f messages.po -- fi -- -- AC_OUTPUT_COMMANDS([ -- for ac_file in $CONFIG_FILES; do -- # Support "outfile[:infile[:infile...]]" -- case "$ac_file" in -- *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; -- esac -- # PO directories have a Makefile.in generated from Makefile.in.in. -- case "$ac_file" in */Makefile.in) -- # Adjust a relative srcdir. -- ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` -- ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" -- ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` -- # In autoconf-2.13 it is called $ac_given_srcdir. -- # In autoconf-2.50 it is called $srcdir. -- test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" -- case "$ac_given_srcdir" in -- .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; -- /*) top_srcdir="$ac_given_srcdir" ;; -- *) top_srcdir="$ac_dots$ac_given_srcdir" ;; -- esac -- if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then -- rm -f "$ac_dir/POTFILES" -- test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" -- cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" -- # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend -- # on $ac_dir but don't depend on user-specified configuration -- # parameters. -- if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then -- # The LINGUAS file contains the set of available languages. -- if test -n "$ALL_LINGUAS"; then -- test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" -- fi -- ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` -- # Hide the ALL_LINGUAS assigment from automake. -- eval 'ALL_LINGUAS''=$ALL_LINGUAS_' -- fi -- case "$ac_given_srcdir" in -- .) srcdirpre= ;; -- *) srcdirpre='$(srcdir)/' ;; -- esac -- POFILES= -- GMOFILES= -- UPDATEPOFILES= -- DUMMYPOFILES= -- for lang in $ALL_LINGUAS; do -- POFILES="$POFILES $srcdirpre$lang.po" -- GMOFILES="$GMOFILES $srcdirpre$lang.gmo" -- UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" -- DUMMYPOFILES="$DUMMYPOFILES $lang.nop" -- done -- # CATALOGS depends on both $ac_dir and the user's LINGUAS -- # environment variable. -- INST_LINGUAS= -- if test -n "$ALL_LINGUAS"; then -- for presentlang in $ALL_LINGUAS; do -- useit=no -- if test "%UNSET%" != "$LINGUAS"; then -- desiredlanguages="$LINGUAS" -- else -- desiredlanguages="$ALL_LINGUAS" -- fi -- for desiredlang in $desiredlanguages; do -- # Use the presentlang catalog if desiredlang is -- # a. equal to presentlang, or -- # b. a variant of presentlang (because in this case, -- # presentlang can be used as a fallback for messages -- # which are not translated in the desiredlang catalog). -- case "$desiredlang" in -- "$presentlang"*) useit=yes;; -- esac -- done -- if test $useit = yes; then -- INST_LINGUAS="$INST_LINGUAS $presentlang" -- fi -- done -- fi -- CATALOGS= -- if test -n "$INST_LINGUAS"; then -- for lang in $INST_LINGUAS; do -- CATALOGS="$CATALOGS $lang.gmo" -- done -- fi -- test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" -- sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" -- for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do -- if test -f "$f"; then -- case "$f" in -- *.orig | *.bak | *~) ;; -- *) cat "$f" >> "$ac_dir/Makefile" ;; -- esac -- fi -- done -- fi -- ;; -- esac -- done], -- [# Capture the value of obsolete $ALL_LINGUAS because we need it to compute -- # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it -- # from automake. -- eval 'ALL_LINGUAS''="$ALL_LINGUAS"' -- # Capture the value of LINGUAS because we need it to compute CATALOGS. -- LINGUAS="${LINGUAS-%UNSET%}" -- ]) --]) -- -- --dnl Checks for all prerequisites of the intl subdirectory, --dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, --dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. --AC_DEFUN([AM_INTL_SUBDIR], --[ -- AC_REQUIRE([AC_PROG_INSTALL])dnl -- AC_REQUIRE([AM_MKINSTALLDIRS])dnl -- AC_REQUIRE([AC_PROG_CC])dnl -- AC_REQUIRE([AC_CANONICAL_HOST])dnl -- AC_REQUIRE([AC_PROG_RANLIB])dnl -- AC_REQUIRE([AC_ISC_POSIX])dnl -- AC_REQUIRE([AC_HEADER_STDC])dnl -- AC_REQUIRE([AC_C_CONST])dnl -- AC_REQUIRE([AC_C_INLINE])dnl -- AC_REQUIRE([AC_TYPE_OFF_T])dnl -- AC_REQUIRE([AC_TYPE_SIZE_T])dnl -- AC_REQUIRE([AC_FUNC_ALLOCA])dnl -- AC_REQUIRE([AC_FUNC_MMAP])dnl -- AC_REQUIRE([jm_GLIBC21])dnl -- AC_REQUIRE([gt_INTDIV0])dnl -- AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl -- AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl -- AC_REQUIRE([gt_INTTYPES_PRI])dnl -- -- AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ --stdlib.h string.h unistd.h sys/param.h]) -- AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \ --geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \ --strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next]) -- -- AM_ICONV -- AM_LANGINFO_CODESET -- if test $ac_cv_header_locale_h = yes; then -- AM_LC_MESSAGES -- fi -- -- dnl intl/plural.c is generated from intl/plural.y. It requires bison, -- dnl because plural.y uses bison specific features. It requires at least -- dnl bison-1.26 because earlier versions generate a plural.c that doesn't -- dnl compile. -- dnl bison is only needed for the maintainer (who touches plural.y). But in -- dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put -- dnl the rule in general Makefile. Now, some people carelessly touch the -- dnl files or have a broken "make" program, hence the plural.c rule will -- dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not -- dnl present or too old. -- AC_CHECK_PROGS([INTLBISON], [bison]) -- if test -z "$INTLBISON"; then -- ac_verc_fail=yes -- else -- dnl Found it, now check the version. -- AC_MSG_CHECKING([version of bison]) --changequote(<<,>>)dnl -- ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` -- case $ac_prog_version in -- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; -- 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) --changequote([,])dnl -- ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; -- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; -- esac -- AC_MSG_RESULT([$ac_prog_version]) -- fi -- if test $ac_verc_fail = yes; then -- INTLBISON=: -- fi --]) -- -- --AC_DEFUN([AM_MKINSTALLDIRS], --[ -- dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly -- dnl find the mkinstalldirs script in another subdir but $(top_srcdir). -- dnl Try to locate is. -- MKINSTALLDIRS= -- if test -n "$ac_aux_dir"; then -- MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" -- fi -- if test -z "$MKINSTALLDIRS"; then -- MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" -- fi -- AC_SUBST(MKINSTALLDIRS) --]) -- -- --dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) --AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) -- --# lib-prefix.m4 serial 1 (gettext-0.11) --dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -- --dnl From Bruno Haible. -- --dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed --dnl to access previously installed libraries. The basic assumption is that --dnl a user will want packages to use other packages he previously installed --dnl with the same --prefix option. --dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate --dnl libraries, but is otherwise very convenient. --AC_DEFUN([AC_LIB_PREFIX], --[ -- AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) -- AC_REQUIRE([AC_PROG_CC]) -- AC_REQUIRE([AC_CANONICAL_HOST]) -- AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -- dnl By default, look in $includedir and $libdir. -- use_additional=yes -- AC_LIB_WITH_FINAL_PREFIX([ -- eval additional_includedir=\"$includedir\" -- eval additional_libdir=\"$libdir\" -- ]) -- AC_ARG_WITH([lib-prefix], --[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib -- --without-lib-prefix don't search for libraries in includedir and libdir], --[ -- if test "X$withval" = "Xno"; then -- use_additional=no -- else -- if test "X$withval" = "X"; then -- AC_LIB_WITH_FINAL_PREFIX([ -- eval additional_includedir=\"$includedir\" -- eval additional_libdir=\"$libdir\" -- ]) -- else -- additional_includedir="$withval/include" -- additional_libdir="$withval/lib" -- fi -- fi --]) -- if test $use_additional = yes; then -- dnl Potentially add $additional_includedir to $CPPFLAGS. -- dnl But don't add it -- dnl 1. if it's the standard /usr/include, -- dnl 2. if it's already present in $CPPFLAGS, -- dnl 3. if it's /usr/local/include and we are using GCC on Linux, -- dnl 4. if it doesn't exist as a directory. -- if test "X$additional_includedir" != "X/usr/include"; then -- haveit= -- for x in $CPPFLAGS; do -- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) -- if test "X$x" = "X-I$additional_includedir"; then -- haveit=yes -- break -- fi -- done -- if test -z "$haveit"; then -- if test "X$additional_includedir" = "X/usr/local/include"; then -- if test -n "$GCC"; then -- case $host_os in -- linux*) haveit=yes;; -- esac -- fi -- fi -- if test -z "$haveit"; then -- if test -d "$additional_includedir"; then -- dnl Really add $additional_includedir to $CPPFLAGS. -- CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" -- fi -- fi -- fi -- fi -- dnl Potentially add $additional_libdir to $LDFLAGS. -- dnl But don't add it -- dnl 1. if it's the standard /usr/lib, -- dnl 2. if it's already present in $LDFLAGS, -- dnl 3. if it's /usr/local/lib and we are using GCC on Linux, -- dnl 4. if it doesn't exist as a directory. -- if test "X$additional_libdir" != "X/usr/lib"; then -- haveit= -- for x in $LDFLAGS; do -- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) -- if test "X$x" = "X-L$additional_libdir"; then -- haveit=yes -- break -- fi -- done -- if test -z "$haveit"; then -- if test "X$additional_libdir" = "X/usr/local/lib"; then -- if test -n "$GCC"; then -- case $host_os in -- linux*) haveit=yes;; -- esac -- fi -- fi -- if test -z "$haveit"; then -- if test -d "$additional_libdir"; then -- dnl Really add $additional_libdir to $LDFLAGS. -- LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" -- fi -- fi -- fi -- fi -- fi --]) -- --dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, --dnl acl_final_exec_prefix, containing the values to which $prefix and --dnl $exec_prefix will expand at the end of the configure script. --AC_DEFUN([AC_LIB_PREPARE_PREFIX], --[ -- dnl Unfortunately, prefix and exec_prefix get only finally determined -- dnl at the end of configure. -- if test "X$prefix" = "XNONE"; then -- acl_final_prefix="$ac_default_prefix" -- else -- acl_final_prefix="$prefix" -- fi -- if test "X$exec_prefix" = "XNONE"; then -- acl_final_exec_prefix='${prefix}' -- else -- acl_final_exec_prefix="$exec_prefix" -- fi -- acl_save_prefix="$prefix" -- prefix="$acl_final_prefix" -- eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" -- prefix="$acl_save_prefix" --]) -- --dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the --dnl variables prefix and exec_prefix bound to the values they will have --dnl at the end of the configure script. --AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], --[ -- acl_save_prefix="$prefix" -- prefix="$acl_final_prefix" -- acl_save_exec_prefix="$exec_prefix" -- exec_prefix="$acl_final_exec_prefix" -- $1 -- exec_prefix="$acl_save_exec_prefix" -- prefix="$acl_save_prefix" --]) -- --# lib-link.m4 serial 3 (gettext-0.11.3) --dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -- --dnl From Bruno Haible. -- --dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and --dnl the libraries corresponding to explicit and implicit dependencies. --dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and --dnl augments the CPPFLAGS variable. --AC_DEFUN([AC_LIB_LINKFLAGS], --[ -- AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -- AC_REQUIRE([AC_LIB_RPATH]) -- define([Name],[translit([$1],[./-], [___])]) -- define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], -- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) -- AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ -- AC_LIB_LINKFLAGS_BODY([$1], [$2]) -- ac_cv_lib[]Name[]_libs="$LIB[]NAME" -- ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" -- ac_cv_lib[]Name[]_cppflags="$INC[]NAME" -- ]) -- LIB[]NAME="$ac_cv_lib[]Name[]_libs" -- LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" -- INC[]NAME="$ac_cv_lib[]Name[]_cppflags" -- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) -- AC_SUBST([LIB]NAME) -- AC_SUBST([LTLIB]NAME) -- dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the -- dnl results of this search when this library appears as a dependency. -- HAVE_LIB[]NAME=yes -- undefine([Name]) -- undefine([NAME]) --]) -- --dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) --dnl searches for libname and the libraries corresponding to explicit and --dnl implicit dependencies, together with the specified include files and --dnl the ability to compile and link the specified testcode. If found, it --dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and --dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and --dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs --dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. --AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], --[ -- AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -- AC_REQUIRE([AC_LIB_RPATH]) -- define([Name],[translit([$1],[./-], [___])]) -- define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], -- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) -- -- dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME -- dnl accordingly. -- AC_LIB_LINKFLAGS_BODY([$1], [$2]) -- -- dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, -- dnl because if the user has installed lib[]Name and not disabled its use -- dnl via --without-lib[]Name-prefix, he wants to use it. -- ac_save_CPPFLAGS="$CPPFLAGS" -- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) -- -- AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ -- ac_save_LIBS="$LIBS" -- LIBS="$LIBS $LIB[]NAME" -- AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) -- LIBS="$ac_save_LIBS" -- ]) -- if test "$ac_cv_lib[]Name" = yes; then -- HAVE_LIB[]NAME=yes -- AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) -- AC_MSG_CHECKING([how to link with lib[]$1]) -- AC_MSG_RESULT([$LIB[]NAME]) -- else -- HAVE_LIB[]NAME=no -- dnl If $LIB[]NAME didn't lead to a usable library, we don't need -- dnl $INC[]NAME either. -- CPPFLAGS="$ac_save_CPPFLAGS" -- LIB[]NAME= -- LTLIB[]NAME= -- fi -- AC_SUBST([HAVE_LIB]NAME) -- AC_SUBST([LIB]NAME) -- AC_SUBST([LTLIB]NAME) -- undefine([Name]) -- undefine([NAME]) --]) -- --dnl Determine the platform dependent parameters needed to use rpath: --dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, --dnl hardcode_direct, hardcode_minus_L, --dnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec. --AC_DEFUN([AC_LIB_RPATH], --[ -- AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS -- AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld -- AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host -- AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir -- AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ -- CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ -- ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh -- . ./conftest.sh -- rm -f ./conftest.sh -- acl_cv_rpath=done -- ]) -- wl="$acl_cv_wl" -- libext="$acl_cv_libext" -- shlibext="$acl_cv_shlibext" -- hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" -- hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" -- hardcode_direct="$acl_cv_hardcode_direct" -- hardcode_minus_L="$acl_cv_hardcode_minus_L" -- sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec" -- sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec" -- dnl Determine whether the user wants rpath handling at all. -- AC_ARG_ENABLE(rpath, -- [ --disable-rpath do not hardcode runtime library paths], -- :, enable_rpath=yes) --]) -- --dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and --dnl the libraries corresponding to explicit and implicit dependencies. --dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. --AC_DEFUN([AC_LIB_LINKFLAGS_BODY], --[ -- define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], -- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) -- dnl By default, look in $includedir and $libdir. -- use_additional=yes -- AC_LIB_WITH_FINAL_PREFIX([ -- eval additional_includedir=\"$includedir\" -- eval additional_libdir=\"$libdir\" -- ]) -- AC_ARG_WITH([lib$1-prefix], --[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib -- --without-lib$1-prefix don't search for lib$1 in includedir and libdir], --[ -- if test "X$withval" = "Xno"; then -- use_additional=no -- else -- if test "X$withval" = "X"; then -- AC_LIB_WITH_FINAL_PREFIX([ -- eval additional_includedir=\"$includedir\" -- eval additional_libdir=\"$libdir\" -- ]) -- else -- additional_includedir="$withval/include" -- additional_libdir="$withval/lib" -+ additional_includedir="$withval/include" -+ additional_libdir="$withval/lib" - fi - fi - ]) -@@ -5419,7 +1429,7 @@ - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in -- linux*) haveit=yes;; -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi -@@ -5468,7 +1478,7 @@ - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in -- linux*) haveit=yes;; -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi -@@ -5552,695 +1562,8143 @@ - done - fi - else -- dnl Didn't find the library; assume it is in the system directories -- dnl known to the linker and runtime loader. (All the system -- dnl directories known to the linker should also be known to the -- dnl runtime loader, otherwise the system is severely misconfigured.) -- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" -- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" -+ dnl Didn't find the library; assume it is in the system directories -+ dnl known to the linker and runtime loader. (All the system -+ dnl directories known to the linker should also be known to the -+ dnl runtime loader, otherwise the system is severely misconfigured.) -+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" -+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" -+ fi -+ fi -+ fi -+ done -+ done -+ if test "X$rpathdirs" != "X"; then -+ if test -n "$hardcode_libdir_separator"; then -+ dnl Weird platform: only the last -rpath option counts, the user must -+ dnl pass all path elements in one option. We can arrange that for a -+ dnl single library, but not when more than one $LIBNAMEs are used. -+ alldirs= -+ for found_dir in $rpathdirs; do -+ alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" -+ done -+ dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. -+ acl_save_libdir="$libdir" -+ libdir="$alldirs" -+ eval flag=\"$hardcode_libdir_flag_spec\" -+ libdir="$acl_save_libdir" -+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" -+ else -+ dnl The -rpath options are cumulative. -+ for found_dir in $rpathdirs; do -+ acl_save_libdir="$libdir" -+ libdir="$found_dir" -+ eval flag=\"$hardcode_libdir_flag_spec\" -+ libdir="$acl_save_libdir" -+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" -+ done -+ fi -+ fi -+ if test "X$ltrpathdirs" != "X"; then -+ dnl When using libtool, the option that works for both libraries and -+ dnl executables is -R. The -R options are cumulative. -+ for found_dir in $ltrpathdirs; do -+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" -+ done -+ fi -+]) -+ -+dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -+dnl unless already present in VAR. -+dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -+dnl contains two or three consecutive elements that belong together. -+AC_DEFUN([AC_LIB_APPENDTOVAR], -+[ -+ for element in [$2]; do -+ haveit= -+ for x in $[$1]; do -+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) -+ if test "X$x" = "X$element"; then -+ haveit=yes -+ break -+ fi -+ done -+ if test -z "$haveit"; then -+ [$1]="${[$1]}${[$1]:+ }$element" -+ fi -+ done -+]) -+ -+# lib-prefix.m4 serial 4 (gettext-0.14.2) -+dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Bruno Haible. -+ -+dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -+dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -+dnl require excessive bracketing. -+ifdef([AC_HELP_STRING], -+[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -+[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) -+ -+dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -+dnl to access previously installed libraries. The basic assumption is that -+dnl a user will want packages to use other packages he previously installed -+dnl with the same --prefix option. -+dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -+dnl libraries, but is otherwise very convenient. -+AC_DEFUN([AC_LIB_PREFIX], -+[ -+ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) -+ AC_REQUIRE([AC_PROG_CC]) -+ AC_REQUIRE([AC_CANONICAL_HOST]) -+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -+ dnl By default, look in $includedir and $libdir. -+ use_additional=yes -+ AC_LIB_WITH_FINAL_PREFIX([ -+ eval additional_includedir=\"$includedir\" -+ eval additional_libdir=\"$libdir\" -+ ]) -+ AC_LIB_ARG_WITH([lib-prefix], -+[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib -+ --without-lib-prefix don't search for libraries in includedir and libdir], -+[ -+ if test "X$withval" = "Xno"; then -+ use_additional=no -+ else -+ if test "X$withval" = "X"; then -+ AC_LIB_WITH_FINAL_PREFIX([ -+ eval additional_includedir=\"$includedir\" -+ eval additional_libdir=\"$libdir\" -+ ]) -+ else -+ additional_includedir="$withval/include" -+ additional_libdir="$withval/lib" -+ fi -+ fi -+]) -+ if test $use_additional = yes; then -+ dnl Potentially add $additional_includedir to $CPPFLAGS. -+ dnl But don't add it -+ dnl 1. if it's the standard /usr/include, -+ dnl 2. if it's already present in $CPPFLAGS, -+ dnl 3. if it's /usr/local/include and we are using GCC on Linux, -+ dnl 4. if it doesn't exist as a directory. -+ if test "X$additional_includedir" != "X/usr/include"; then -+ haveit= -+ for x in $CPPFLAGS; do -+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) -+ if test "X$x" = "X-I$additional_includedir"; then -+ haveit=yes -+ break -+ fi -+ done -+ if test -z "$haveit"; then -+ if test "X$additional_includedir" = "X/usr/local/include"; then -+ if test -n "$GCC"; then -+ case $host_os in -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; -+ esac -+ fi -+ fi -+ if test -z "$haveit"; then -+ if test -d "$additional_includedir"; then -+ dnl Really add $additional_includedir to $CPPFLAGS. -+ CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" -+ fi -+ fi -+ fi -+ fi -+ dnl Potentially add $additional_libdir to $LDFLAGS. -+ dnl But don't add it -+ dnl 1. if it's the standard /usr/lib, -+ dnl 2. if it's already present in $LDFLAGS, -+ dnl 3. if it's /usr/local/lib and we are using GCC on Linux, -+ dnl 4. if it doesn't exist as a directory. -+ if test "X$additional_libdir" != "X/usr/lib"; then -+ haveit= -+ for x in $LDFLAGS; do -+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) -+ if test "X$x" = "X-L$additional_libdir"; then -+ haveit=yes -+ break -+ fi -+ done -+ if test -z "$haveit"; then -+ if test "X$additional_libdir" = "X/usr/local/lib"; then -+ if test -n "$GCC"; then -+ case $host_os in -+ linux*) haveit=yes;; -+ esac -+ fi -+ fi -+ if test -z "$haveit"; then -+ if test -d "$additional_libdir"; then -+ dnl Really add $additional_libdir to $LDFLAGS. -+ LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" -+ fi -+ fi -+ fi -+ fi -+ fi -+]) -+ -+dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -+dnl acl_final_exec_prefix, containing the values to which $prefix and -+dnl $exec_prefix will expand at the end of the configure script. -+AC_DEFUN([AC_LIB_PREPARE_PREFIX], -+[ -+ dnl Unfortunately, prefix and exec_prefix get only finally determined -+ dnl at the end of configure. -+ if test "X$prefix" = "XNONE"; then -+ acl_final_prefix="$ac_default_prefix" -+ else -+ acl_final_prefix="$prefix" -+ fi -+ if test "X$exec_prefix" = "XNONE"; then -+ acl_final_exec_prefix='${prefix}' -+ else -+ acl_final_exec_prefix="$exec_prefix" -+ fi -+ acl_save_prefix="$prefix" -+ prefix="$acl_final_prefix" -+ eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" -+ prefix="$acl_save_prefix" -+]) -+ -+dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -+dnl variables prefix and exec_prefix bound to the values they will have -+dnl at the end of the configure script. -+AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -+[ -+ acl_save_prefix="$prefix" -+ prefix="$acl_final_prefix" -+ acl_save_exec_prefix="$exec_prefix" -+ exec_prefix="$acl_final_exec_prefix" -+ $1 -+ exec_prefix="$acl_save_exec_prefix" -+ prefix="$acl_save_prefix" -+]) -+ -+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -+ -+# serial 47 Debian 1.5.20-2 AC_PROG_LIBTOOL -+ -+ -+# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) -+# ----------------------------------------------------------- -+# If this macro is not defined by Autoconf, define it here. -+m4_ifdef([AC_PROVIDE_IFELSE], -+ [], -+ [m4_define([AC_PROVIDE_IFELSE], -+ [m4_ifdef([AC_PROVIDE_$1], -+ [$2], [$3])])]) -+ -+ -+# AC_PROG_LIBTOOL -+# --------------- -+AC_DEFUN([AC_PROG_LIBTOOL], -+[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl -+dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX -+dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. -+ AC_PROVIDE_IFELSE([AC_PROG_CXX], -+ [AC_LIBTOOL_CXX], -+ [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX -+ ])]) -+dnl And a similar setup for Fortran 77 support -+ AC_PROVIDE_IFELSE([AC_PROG_F77], -+ [AC_LIBTOOL_F77], -+ [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 -+])]) -+ -+dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. -+dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run -+dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. -+ AC_PROVIDE_IFELSE([AC_PROG_GCJ], -+ [AC_LIBTOOL_GCJ], -+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], -+ [AC_LIBTOOL_GCJ], -+ [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], -+ [AC_LIBTOOL_GCJ], -+ [ifdef([AC_PROG_GCJ], -+ [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) -+ ifdef([A][M_PROG_GCJ], -+ [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) -+ ifdef([LT_AC_PROG_GCJ], -+ [define([LT_AC_PROG_GCJ], -+ defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) -+])])# AC_PROG_LIBTOOL -+ -+ -+# _AC_PROG_LIBTOOL -+# ---------------- -+AC_DEFUN([_AC_PROG_LIBTOOL], -+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -+AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl -+AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl -+AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl -+ -+# This can be used to rebuild libtool when needed -+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" -+ -+# Always use our own libtool. -+LIBTOOL='$(SHELL) $(top_builddir)/libtool' -+AC_SUBST(LIBTOOL)dnl -+ -+# Prevent multiple expansion -+define([AC_PROG_LIBTOOL], []) -+])# _AC_PROG_LIBTOOL -+ -+ -+# AC_LIBTOOL_SETUP -+# ---------------- -+AC_DEFUN([AC_LIBTOOL_SETUP], -+[AC_PREREQ(2.50)dnl -+AC_REQUIRE([AC_ENABLE_SHARED])dnl -+AC_REQUIRE([AC_ENABLE_STATIC])dnl -+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -+AC_REQUIRE([AC_CANONICAL_HOST])dnl -+AC_REQUIRE([AC_CANONICAL_BUILD])dnl -+AC_REQUIRE([AC_PROG_CC])dnl -+AC_REQUIRE([AC_PROG_LD])dnl -+AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -+AC_REQUIRE([AC_PROG_NM])dnl -+ -+AC_REQUIRE([AC_PROG_LN_S])dnl -+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! -+AC_REQUIRE([AC_OBJEXT])dnl -+AC_REQUIRE([AC_EXEEXT])dnl -+dnl -+ -+AC_LIBTOOL_SYS_MAX_CMD_LEN -+AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -+AC_LIBTOOL_OBJDIR -+ -+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -+_LT_AC_PROG_ECHO_BACKSLASH -+ -+case $host_os in -+aix3*) -+ # AIX sometimes has problems with the GCC collect2 program. For some -+ # reason, if we set the COLLECT_NAMES environment variable, the problems -+ # vanish in a puff of smoke. -+ if test "X${COLLECT_NAMES+set}" != Xset; then -+ COLLECT_NAMES= -+ export COLLECT_NAMES -+ fi -+ ;; -+esac -+ -+# Sed substitution that helps us do robust quoting. It backslashifies -+# metacharacters that are still active within double-quoted strings. -+Xsed='sed -e 1s/^X//' -+[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] -+ -+# Same as above, but do not quote variable references. -+[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] -+ -+# Sed substitution to delay expansion of an escaped shell variable in a -+# double_quote_subst'ed string. -+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' -+ -+# Sed substitution to avoid accidental globbing in evaled expressions -+no_glob_subst='s/\*/\\\*/g' -+ -+# Constants: -+rm="rm -f" -+ -+# Global variables: -+default_ofile=libtool -+can_build_shared=yes -+ -+# All known linkers require a `.a' archive for static linking (except MSVC, -+# which needs '.lib'). -+libext=a -+ltmain="$ac_aux_dir/ltmain.sh" -+ofile="$default_ofile" -+with_gnu_ld="$lt_cv_prog_gnu_ld" -+ -+AC_CHECK_TOOL(AR, ar, false) -+AC_CHECK_TOOL(RANLIB, ranlib, :) -+AC_CHECK_TOOL(STRIP, strip, :) -+ -+old_CC="$CC" -+old_CFLAGS="$CFLAGS" -+ -+# Set sane defaults for various variables -+test -z "$AR" && AR=ar -+test -z "$AR_FLAGS" && AR_FLAGS=cru -+test -z "$AS" && AS=as -+test -z "$CC" && CC=cc -+test -z "$LTCC" && LTCC=$CC -+test -z "$DLLTOOL" && DLLTOOL=dlltool -+test -z "$LD" && LD=ld -+test -z "$LN_S" && LN_S="ln -s" -+test -z "$MAGIC_CMD" && MAGIC_CMD=file -+test -z "$NM" && NM=nm -+test -z "$SED" && SED=sed -+test -z "$OBJDUMP" && OBJDUMP=objdump -+test -z "$RANLIB" && RANLIB=: -+test -z "$STRIP" && STRIP=: -+test -z "$ac_objext" && ac_objext=o -+ -+# Determine commands to create old-style static archives. -+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -+old_postinstall_cmds='chmod 644 $oldlib' -+old_postuninstall_cmds= -+ -+if test -n "$RANLIB"; then -+ case $host_os in -+ openbsd*) -+ old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" -+ ;; -+ *) -+ old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" -+ ;; -+ esac -+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -+fi -+ -+_LT_CC_BASENAME([$compiler]) -+ -+# Only perform the check for file, if the check method requires it -+case $deplibs_check_method in -+file_magic*) -+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then -+ AC_PATH_MAGIC -+ fi -+ ;; -+esac -+ -+AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -+enable_win32_dll=yes, enable_win32_dll=no) -+ -+AC_ARG_ENABLE([libtool-lock], -+ [AC_HELP_STRING([--disable-libtool-lock], -+ [avoid locking (might break parallel builds)])]) -+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes -+ -+AC_ARG_WITH([pic], -+ [AC_HELP_STRING([--with-pic], -+ [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], -+ [pic_mode="$withval"], -+ [pic_mode=default]) -+test -z "$pic_mode" && pic_mode=default -+ -+# Use C for the default configuration in the libtool script -+tagname= -+AC_LIBTOOL_LANG_C_CONFIG -+_LT_AC_TAGCONFIG -+])# AC_LIBTOOL_SETUP -+ -+ -+# _LT_AC_SYS_COMPILER -+# ------------------- -+AC_DEFUN([_LT_AC_SYS_COMPILER], -+[AC_REQUIRE([AC_PROG_CC])dnl -+ -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} -+ -+# Allow CC to be a program name with arguments. -+compiler=$CC -+])# _LT_AC_SYS_COMPILER -+ -+ -+# _LT_CC_BASENAME(CC) -+# ------------------- -+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -+AC_DEFUN([_LT_CC_BASENAME], -+[for cc_temp in $1""; do -+ case $cc_temp in -+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; -+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+]) -+ -+ -+# _LT_COMPILER_BOILERPLATE -+# ------------------------ -+# Check for compiler boilerplate output or warnings with -+# the simple compiler test code. -+AC_DEFUN([_LT_COMPILER_BOILERPLATE], -+[ac_outfile=conftest.$ac_objext -+printf "$lt_simple_compile_test_code" >conftest.$ac_ext -+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_compiler_boilerplate=`cat conftest.err` -+$rm conftest* -+])# _LT_COMPILER_BOILERPLATE -+ -+ -+# _LT_LINKER_BOILERPLATE -+# ---------------------- -+# Check for linker boilerplate output or warnings with -+# the simple link test code. -+AC_DEFUN([_LT_LINKER_BOILERPLATE], -+[ac_outfile=conftest.$ac_objext -+printf "$lt_simple_link_test_code" >conftest.$ac_ext -+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_linker_boilerplate=`cat conftest.err` -+$rm conftest* -+])# _LT_LINKER_BOILERPLATE -+ -+ -+# _LT_AC_SYS_LIBPATH_AIX -+# ---------------------- -+# Links a minimal program and checks the executable -+# for the system default hardcoded library path. In most cases, -+# this is /usr/lib:/lib, but when the MPI compilers are used -+# the location of the communication and MPI libs are included too. -+# If we don't find anything, use the default library path according -+# to the aix ld manual. -+AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], -+[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi],[]) -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+])# _LT_AC_SYS_LIBPATH_AIX -+ -+ -+# _LT_AC_SHELL_INIT(ARG) -+# ---------------------- -+AC_DEFUN([_LT_AC_SHELL_INIT], -+[ifdef([AC_DIVERSION_NOTICE], -+ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], -+ [AC_DIVERT_PUSH(NOTICE)]) -+$1 -+AC_DIVERT_POP -+])# _LT_AC_SHELL_INIT -+ -+ -+# _LT_AC_PROG_ECHO_BACKSLASH -+# -------------------------- -+# Add some code to the start of the generated configure script which -+# will find an echo command which doesn't interpret backslashes. -+AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -+[_LT_AC_SHELL_INIT([ -+# Check that we are running under the correct shell. -+SHELL=${CONFIG_SHELL-/bin/sh} -+ -+case X$ECHO in -+X*--fallback-echo) -+ # Remove one level of quotation (which was required for Make). -+ ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` -+ ;; -+esac -+ -+echo=${ECHO-echo} -+if test "X[$]1" = X--no-reexec; then -+ # Discard the --no-reexec flag, and continue. -+ shift -+elif test "X[$]1" = X--fallback-echo; then -+ # Avoid inline document here, it may be left over -+ : -+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then -+ # Yippee, $echo works! -+ : -+else -+ # Restart under the correct shell. -+ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -+fi -+ -+if test "X[$]1" = X--fallback-echo; then -+ # used as fallback echo -+ shift -+ cat </dev/null 2>&1 && unset CDPATH -+ -+if test -z "$ECHO"; then -+if test "X${echo_test_string+set}" != Xset; then -+# find a string as large as possible, as long as the shell can cope with it -+ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do -+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... -+ if (echo_test_string=`eval $cmd`) 2>/dev/null && -+ echo_test_string=`eval $cmd` && -+ (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null -+ then -+ break -+ fi -+ done -+fi -+ -+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ : -+else -+ # The Solaris, AIX, and Digital Unix default echo programs unquote -+ # backslashes. This makes it impossible to quote backslashes using -+ # echo "$something" | sed 's/\\/\\\\/g' -+ # -+ # So, first we look for a working echo in the user's PATH. -+ -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ for dir in $PATH /usr/ucb; do -+ IFS="$lt_save_ifs" -+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && -+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ echo="$dir/echo" -+ break -+ fi -+ done -+ IFS="$lt_save_ifs" -+ -+ if test "X$echo" = Xecho; then -+ # We didn't find a better echo, so look for alternatives. -+ if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ # This shell has a builtin print -r that does the trick. -+ echo='print -r' -+ elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && -+ test "X$CONFIG_SHELL" != X/bin/ksh; then -+ # If we have ksh, try running configure again with it. -+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -+ export ORIGINAL_CONFIG_SHELL -+ CONFIG_SHELL=/bin/ksh -+ export CONFIG_SHELL -+ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} -+ else -+ # Try using printf. -+ echo='printf %s\n' -+ if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ # Cool, printf works -+ : -+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && -+ test "X$echo_testing_string" = 'X\t' && -+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL -+ export CONFIG_SHELL -+ SHELL="$CONFIG_SHELL" -+ export SHELL -+ echo="$CONFIG_SHELL [$]0 --fallback-echo" -+ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && -+ test "X$echo_testing_string" = 'X\t' && -+ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ echo="$CONFIG_SHELL [$]0 --fallback-echo" -+ else -+ # maybe with a smaller string... -+ prev=: -+ -+ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do -+ if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null -+ then -+ break -+ fi -+ prev="$cmd" -+ done -+ -+ if test "$prev" != 'sed 50q "[$]0"'; then -+ echo_test_string=`eval $prev` -+ export echo_test_string -+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} -+ else -+ # Oops. We lost completely, so just stick with echo. -+ echo=echo -+ fi -+ fi -+ fi -+ fi -+fi -+fi -+ -+# Copy echo and quote the copy suitably for passing to libtool from -+# the Makefile, instead of quoting the original, which is used later. -+ECHO=$echo -+if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then -+ ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -+fi -+ -+AC_SUBST(ECHO) -+])])# _LT_AC_PROG_ECHO_BACKSLASH -+ -+ -+# _LT_AC_LOCK -+# ----------- -+AC_DEFUN([_LT_AC_LOCK], -+[AC_ARG_ENABLE([libtool-lock], -+ [AC_HELP_STRING([--disable-libtool-lock], -+ [avoid locking (might break parallel builds)])]) -+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes -+ -+# Some flags need to be propagated to the compiler or linker for good -+# libtool support. -+case $host in -+ia64-*-hpux*) -+ # Find out which ABI we are using. -+ echo 'int i;' > conftest.$ac_ext -+ if AC_TRY_EVAL(ac_compile); then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *ELF-32*) -+ HPUX_IA64_MODE="32" -+ ;; -+ *ELF-64*) -+ HPUX_IA64_MODE="64" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+*-*-irix6*) -+ # Find out which ABI we are using. -+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext -+ if AC_TRY_EVAL(ac_compile); then -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *32-bit*) -+ LD="${LD-ld} -melf32bsmip" -+ ;; -+ *N32*) -+ LD="${LD-ld} -melf32bmipn32" -+ ;; -+ *64-bit*) -+ LD="${LD-ld} -melf64bmip" -+ ;; -+ esac -+ else -+ case `/usr/bin/file conftest.$ac_objext` in -+ *32-bit*) -+ LD="${LD-ld} -32" -+ ;; -+ *N32*) -+ LD="${LD-ld} -n32" -+ ;; -+ *64-bit*) -+ LD="${LD-ld} -64" -+ ;; -+ esac -+ fi -+ fi -+ rm -rf conftest* -+ ;; -+ -+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) -+ # Find out which ABI we are using. -+ echo 'int i;' > conftest.$ac_ext -+ if AC_TRY_EVAL(ac_compile); then -+ case `/usr/bin/file conftest.o` in -+ *32-bit*) -+ case $host in -+ x86_64-*linux*) -+ LD="${LD-ld} -m elf_i386" -+ ;; -+ ppc64-*linux*|powerpc64-*linux*) -+ LD="${LD-ld} -m elf32ppclinux" -+ ;; -+ s390x-*linux*) -+ LD="${LD-ld} -m elf_s390" -+ ;; -+ sparc64-*linux*) -+ LD="${LD-ld} -m elf32_sparc" -+ ;; -+ esac -+ ;; -+ *64-bit*) -+ case $host in -+ x86_64-*linux*) -+ LD="${LD-ld} -m elf_x86_64" -+ ;; -+ ppc*-*linux*|powerpc*-*linux*) -+ LD="${LD-ld} -m elf64ppc" -+ ;; -+ s390*-*linux*) -+ LD="${LD-ld} -m elf64_s390" -+ ;; -+ sparc*-*linux*) -+ LD="${LD-ld} -m elf64_sparc" -+ ;; -+ esac -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ -+*-*-sco3.2v5*) -+ # On SCO OpenServer 5, we need -belf to get full-featured binaries. -+ SAVE_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS -belf" -+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, -+ [AC_LANG_PUSH(C) -+ AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) -+ AC_LANG_POP]) -+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then -+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf -+ CFLAGS="$SAVE_CFLAGS" -+ fi -+ ;; -+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -+[*-*-cygwin* | *-*-mingw* | *-*-pw32*) -+ AC_CHECK_TOOL(DLLTOOL, dlltool, false) -+ AC_CHECK_TOOL(AS, as, false) -+ AC_CHECK_TOOL(OBJDUMP, objdump, false) -+ ;; -+ ]) -+esac -+ -+need_locks="$enable_libtool_lock" -+ -+])# _LT_AC_LOCK -+ -+ -+# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -+# ---------------------------------------------------------------- -+# Check whether the given compiler option works -+AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], -+[AC_REQUIRE([LT_AC_PROG_SED]) -+AC_CACHE_CHECK([$1], [$2], -+ [$2=no -+ ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="$3" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&AS_MESSAGE_LOG_FD -+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ $2=yes -+ fi -+ fi -+ $rm conftest* -+]) -+ -+if test x"[$]$2" = xyes; then -+ ifelse([$5], , :, [$5]) -+else -+ ifelse([$6], , :, [$6]) -+fi -+])# AC_LIBTOOL_COMPILER_OPTION -+ -+ -+# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -+# [ACTION-SUCCESS], [ACTION-FAILURE]) -+# ------------------------------------------------------------ -+# Check whether the given compiler option works -+AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], -+[AC_CACHE_CHECK([$1], [$2], -+ [$2=no -+ save_LDFLAGS="$LDFLAGS" -+ LDFLAGS="$LDFLAGS $3" -+ printf "$lt_simple_link_test_code" > conftest.$ac_ext -+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then -+ # The linker can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ if test -s conftest.err; then -+ # Append any errors to the config.log. -+ cat conftest.err 1>&AS_MESSAGE_LOG_FD -+ $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if diff conftest.exp conftest.er2 >/dev/null; then -+ $2=yes -+ fi -+ else -+ $2=yes -+ fi -+ fi -+ $rm conftest* -+ LDFLAGS="$save_LDFLAGS" -+]) -+ -+if test x"[$]$2" = xyes; then -+ ifelse([$4], , :, [$4]) -+else -+ ifelse([$5], , :, [$5]) -+fi -+])# AC_LIBTOOL_LINKER_OPTION -+ -+ -+# AC_LIBTOOL_SYS_MAX_CMD_LEN -+# -------------------------- -+AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], -+[# find the maximum length of command line arguments -+AC_MSG_CHECKING([the maximum length of command line arguments]) -+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl -+ i=0 -+ teststring="ABCD" -+ -+ case $build_os in -+ msdosdjgpp*) -+ # On DJGPP, this test can blow up pretty badly due to problems in libc -+ # (any single argument exceeding 2000 bytes causes a buffer overrun -+ # during glob expansion). Even if it were fixed, the result of this -+ # check would be larger than it should be. -+ lt_cv_sys_max_cmd_len=12288; # 12K is about right -+ ;; -+ -+ gnu*) -+ # Under GNU Hurd, this test is not required because there is -+ # no limit to the length of command line arguments. -+ # Libtool will interpret -1 as no limit whatsoever -+ lt_cv_sys_max_cmd_len=-1; -+ ;; -+ -+ cygwin* | mingw*) -+ # On Win9x/ME, this test blows up -- it succeeds, but takes -+ # about 5 minutes as the teststring grows exponentially. -+ # Worse, since 9x/ME are not pre-emptively multitasking, -+ # you end up with a "frozen" computer, even though with patience -+ # the test eventually succeeds (with a max line length of 256k). -+ # Instead, let's just punt: use the minimum linelength reported by -+ # all of the supported platforms: 8192 (on NT/2K/XP). -+ lt_cv_sys_max_cmd_len=8192; -+ ;; -+ -+ amigaos*) -+ # On AmigaOS with pdksh, this test takes hours, literally. -+ # So we just punt and use a minimum line length of 8192. -+ lt_cv_sys_max_cmd_len=8192; -+ ;; -+ -+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) -+ # This has been around since 386BSD, at least. Likely further. -+ if test -x /sbin/sysctl; then -+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` -+ elif test -x /usr/sbin/sysctl; then -+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` -+ else -+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs -+ fi -+ # And add a safety zone -+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` -+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` -+ ;; -+ osf*) -+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure -+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not -+ # nice to cause kernel panics so lets avoid the loop below. -+ # First set a reasonable default. -+ lt_cv_sys_max_cmd_len=16384 -+ # -+ if test -x /sbin/sysconfig; then -+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in -+ *1*) lt_cv_sys_max_cmd_len=-1 ;; -+ esac -+ fi -+ ;; -+ *) -+ # If test is not a shell built-in, we'll probably end up computing a -+ # maximum length that is only half of the actual maximum length, but -+ # we can't tell. -+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} -+ while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ -+ = "XX$teststring") >/dev/null 2>&1 && -+ new_result=`expr "X$teststring" : ".*" 2>&1` && -+ lt_cv_sys_max_cmd_len=$new_result && -+ test $i != 17 # 1/2 MB should be enough -+ do -+ i=`expr $i + 1` -+ teststring=$teststring$teststring -+ done -+ teststring= -+ # Add a significant safety factor because C++ compilers can tack on massive -+ # amounts of additional arguments before passing them to the linker. -+ # It appears as though 1/2 is a usable value. -+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` -+ ;; -+ esac -+]) -+if test -n $lt_cv_sys_max_cmd_len ; then -+ AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -+else -+ AC_MSG_RESULT(none) -+fi -+])# AC_LIBTOOL_SYS_MAX_CMD_LEN -+ -+ -+# _LT_AC_CHECK_DLFCN -+# -------------------- -+AC_DEFUN([_LT_AC_CHECK_DLFCN], -+[AC_CHECK_HEADERS(dlfcn.h)dnl -+])# _LT_AC_CHECK_DLFCN -+ -+ -+# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -+# ------------------------------------------------------------------ -+AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -+if test "$cross_compiling" = yes; then : -+ [$4] -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+}] -+EOF -+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) $1 ;; -+ x$lt_dlneed_uscore) $2 ;; -+ x$lt_unknown|x*) $3 ;; -+ esac -+ else : -+ # compilation failed -+ $3 -+ fi -+fi -+rm -fr conftest* -+])# _LT_AC_TRY_DLOPEN_SELF -+ -+ -+# AC_LIBTOOL_DLOPEN_SELF -+# ------------------- -+AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -+if test "x$enable_dlopen" != xyes; then -+ enable_dlopen=unknown -+ enable_dlopen_self=unknown -+ enable_dlopen_self_static=unknown -+else -+ lt_cv_dlopen=no -+ lt_cv_dlopen_libs= -+ -+ case $host_os in -+ beos*) -+ lt_cv_dlopen="load_add_on" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ ;; -+ -+ mingw* | pw32*) -+ lt_cv_dlopen="LoadLibrary" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ cygwin*) -+ lt_cv_dlopen="dlopen" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ darwin*) -+ # if libdl is installed we need to link against it -+ AC_CHECK_LIB([dl], [dlopen], -+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ -+ lt_cv_dlopen="dyld" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ ]) -+ ;; -+ -+ *) -+ AC_CHECK_FUNC([shl_load], -+ [lt_cv_dlopen="shl_load"], -+ [AC_CHECK_LIB([dld], [shl_load], -+ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], -+ [AC_CHECK_FUNC([dlopen], -+ [lt_cv_dlopen="dlopen"], -+ [AC_CHECK_LIB([dl], [dlopen], -+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], -+ [AC_CHECK_LIB([svld], [dlopen], -+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], -+ [AC_CHECK_LIB([dld], [dld_link], -+ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) -+ ]) -+ ]) -+ ]) -+ ]) -+ ]) -+ ;; -+ esac -+ -+ if test "x$lt_cv_dlopen" != xno; then -+ enable_dlopen=yes -+ else -+ enable_dlopen=no -+ fi -+ -+ case $lt_cv_dlopen in -+ dlopen) -+ save_CPPFLAGS="$CPPFLAGS" -+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -+ -+ save_LDFLAGS="$LDFLAGS" -+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -+ -+ save_LIBS="$LIBS" -+ LIBS="$lt_cv_dlopen_libs $LIBS" -+ -+ AC_CACHE_CHECK([whether a program can dlopen itself], -+ lt_cv_dlopen_self, [dnl -+ _LT_AC_TRY_DLOPEN_SELF( -+ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, -+ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) -+ ]) -+ -+ if test "x$lt_cv_dlopen_self" = xyes; then -+ LDFLAGS="$LDFLAGS $link_static_flag" -+ AC_CACHE_CHECK([whether a statically linked program can dlopen itself], -+ lt_cv_dlopen_self_static, [dnl -+ _LT_AC_TRY_DLOPEN_SELF( -+ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, -+ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) -+ ]) -+ fi -+ -+ CPPFLAGS="$save_CPPFLAGS" -+ LDFLAGS="$save_LDFLAGS" -+ LIBS="$save_LIBS" -+ ;; -+ esac -+ -+ case $lt_cv_dlopen_self in -+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -+ *) enable_dlopen_self=unknown ;; -+ esac -+ -+ case $lt_cv_dlopen_self_static in -+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -+ *) enable_dlopen_self_static=unknown ;; -+ esac -+fi -+])# AC_LIBTOOL_DLOPEN_SELF -+ -+ -+# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) -+# --------------------------------- -+# Check to see if options -c and -o are simultaneously supported by compiler -+AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], -+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], -+ [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], -+ [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no -+ $rm -r conftest 2>/dev/null -+ mkdir conftest -+ cd conftest -+ mkdir out -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ lt_compiler_flag="-o out/conftest2.$ac_objext" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) -+ (eval "$lt_compile" 2>out/conftest.err) -+ ac_status=$? -+ cat out/conftest.err >&AS_MESSAGE_LOG_FD -+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD -+ if (exit $ac_status) && test -s out/conftest2.$ac_objext -+ then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp -+ $SED '/^$/d' out/conftest.err >out/conftest.er2 -+ if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then -+ _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes -+ fi -+ fi -+ chmod u+w . 2>&AS_MESSAGE_LOG_FD -+ $rm conftest* -+ # SGI C++ compiler will create directory out/ii_files/ for -+ # template instantiation -+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files -+ $rm out/* && rmdir out -+ cd .. -+ rmdir conftest -+ $rm conftest* -+]) -+])# AC_LIBTOOL_PROG_CC_C_O -+ -+ -+# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) -+# ----------------------------------------- -+# Check to see if we can do hard links to lock some files if needed -+AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], -+[AC_REQUIRE([_LT_AC_LOCK])dnl -+ -+hard_links="nottested" -+if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then -+ # do not overwrite the value of need_locks provided by the user -+ AC_MSG_CHECKING([if we can lock with hard links]) -+ hard_links=yes -+ $rm conftest* -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ touch conftest.a -+ ln conftest.a conftest.b 2>&5 || hard_links=no -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ AC_MSG_RESULT([$hard_links]) -+ if test "$hard_links" = no; then -+ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) -+ need_locks=warn -+ fi -+else -+ need_locks=no -+fi -+])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS -+ -+ -+# AC_LIBTOOL_OBJDIR -+# ----------------- -+AC_DEFUN([AC_LIBTOOL_OBJDIR], -+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -+[rm -f .libs 2>/dev/null -+mkdir .libs 2>/dev/null -+if test -d .libs; then -+ lt_cv_objdir=.libs -+else -+ # MS-DOS does not allow filenames that begin with a dot. -+ lt_cv_objdir=_libs -+fi -+rmdir .libs 2>/dev/null]) -+objdir=$lt_cv_objdir -+])# AC_LIBTOOL_OBJDIR -+ -+ -+# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) -+# ---------------------------------------------- -+# Check hardcoding attributes. -+AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], -+[AC_MSG_CHECKING([how to hardcode library paths into programs]) -+_LT_AC_TAGVAR(hardcode_action, $1)= -+if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ -+ test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ -+ test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then -+ -+ # We can hardcode non-existant directories. -+ if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && -+ # If the only mechanism to avoid hardcoding is shlibpath_var, we -+ # have to relink, otherwise we might link with an installed library -+ # when we should be linking with a yet-to-be-installed one -+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && -+ test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then -+ # Linking always hardcodes the temporary library directory. -+ _LT_AC_TAGVAR(hardcode_action, $1)=relink -+ else -+ # We can link without hardcoding, and we can hardcode nonexisting dirs. -+ _LT_AC_TAGVAR(hardcode_action, $1)=immediate -+ fi -+else -+ # We cannot hardcode anything, or else we can only hardcode existing -+ # directories. -+ _LT_AC_TAGVAR(hardcode_action, $1)=unsupported -+fi -+AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) -+ -+if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then -+ # Fast installation is not supported -+ enable_fast_install=no -+elif test "$shlibpath_overrides_runpath" = yes || -+ test "$enable_shared" = no; then -+ # Fast installation is not necessary -+ enable_fast_install=needless -+fi -+])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH -+ -+ -+# AC_LIBTOOL_SYS_LIB_STRIP -+# ------------------------ -+AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], -+[striplib= -+old_striplib= -+AC_MSG_CHECKING([whether stripping libraries is possible]) -+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -+ test -z "$striplib" && striplib="$STRIP --strip-unneeded" -+ AC_MSG_RESULT([yes]) -+else -+# FIXME - insert some real tests, host_os isn't really good enough -+ case $host_os in -+ darwin*) -+ if test -n "$STRIP" ; then -+ striplib="$STRIP -x" -+ AC_MSG_RESULT([yes]) -+ else -+ AC_MSG_RESULT([no]) -+fi -+ ;; -+ *) -+ AC_MSG_RESULT([no]) -+ ;; -+ esac -+fi -+])# AC_LIBTOOL_SYS_LIB_STRIP -+ -+ -+# AC_LIBTOOL_SYS_DYNAMIC_LINKER -+# ----------------------------- -+# PORTME Fill in your ld.so characteristics -+AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], -+[AC_MSG_CHECKING([dynamic linker characteristics]) -+library_names_spec= -+libname_spec='lib$name' -+soname_spec= -+shrext_cmds=".so" -+postinstall_cmds= -+postuninstall_cmds= -+finish_cmds= -+finish_eval= -+shlibpath_var= -+shlibpath_overrides_runpath=unknown -+version_type=none -+dynamic_linker="$host_os ld.so" -+sys_lib_dlsearch_path_spec="/lib /usr/lib" -+if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then -+ # if the path contains ";" then we assume it to be the separator -+ # otherwise default to the standard path separator (i.e. ":") - it is -+ # assumed that no part of a normal pathname contains ";" but that should -+ # okay in the real world where ";" in dirpaths is itself problematic. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+else -+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -+fi -+need_lib_prefix=unknown -+hardcode_into_libs=no -+ -+# when you set need_version to no, make sure it does not cause -set_version -+# flags to be left without arguments -+need_version=unknown -+ -+case $host_os in -+aix3*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' -+ shlibpath_var=LIBPATH -+ -+ # AIX 3 has no versioning support, so we append a major version to the name. -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ -+aix4* | aix5*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ hardcode_into_libs=yes -+ if test "$host_cpu" = ia64; then -+ # AIX 5 supports IA64 -+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ else -+ # With GCC up to 2.95.x, collect2 would create an import file -+ # for dependence libraries. The import file would start with -+ # the line `#! .'. This would cause the generated library to -+ # depend on `.', always an invalid library. This was fixed in -+ # development snapshots of GCC prior to 3.0. -+ case $host_os in -+ aix4 | aix4.[[01]] | aix4.[[01]].*) -+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -+ echo ' yes ' -+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -+ : -+ else -+ can_build_shared=no -+ fi -+ ;; -+ esac -+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct -+ # soname into executable. Probably we can add versioning support to -+ # collect2, so additional links can be useful in future. -+ if test "$aix_use_runtimelinking" = yes; then -+ # If using run time linking (on AIX 4.2 or later) use lib.so -+ # instead of lib.a to let people know that these are not -+ # typical AIX shared libraries. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ else -+ # We preserve .a as extension for shared libraries through AIX4.2 -+ # and later when we are not doing run time linking. -+ library_names_spec='${libname}${release}.a $libname.a' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ fi -+ shlibpath_var=LIBPATH -+ fi -+ ;; -+ -+amigaos*) -+ library_names_spec='$libname.ixlibrary $libname.a' -+ # Create ${libname}_ixlibrary.a entries in /sys/libs. -+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' -+ ;; -+ -+beos*) -+ library_names_spec='${libname}${shared_ext}' -+ dynamic_linker="$host_os ld.so" -+ shlibpath_var=LIBRARY_PATH -+ ;; -+ -+bsdi[[45]]*) -+ version_type=linux -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -+ # the default ld.so.conf also contains /usr/contrib/lib and -+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -+ # libtool to hard-code these into programs -+ ;; -+ -+cygwin* | mingw* | pw32*) -+ version_type=windows -+ shrext_cmds=".dll" -+ need_version=no -+ need_lib_prefix=no -+ -+ case $GCC,$host_os in -+ yes,cygwin* | yes,mingw* | yes,pw32*) -+ library_names_spec='$libname.dll.a' -+ # DLL is installed to $(libdir)/../bin by postinstall_cmds -+ postinstall_cmds='base_file=`basename \${file}`~ -+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ -+ dldir=$destdir/`dirname \$dlpath`~ -+ test -d \$dldir || mkdir -p \$dldir~ -+ $install_prog $dir/$dlname \$dldir/$dlname~ -+ chmod a+x \$dldir/$dlname' -+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ -+ dlpath=$dir/\$dldll~ -+ $rm \$dlpath' -+ shlibpath_overrides_runpath=yes -+ -+ case $host_os in -+ cygwin*) -+ # Cygwin DLLs use 'cyg' prefix rather than 'lib' -+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" -+ ;; -+ mingw*) -+ # MinGW DLLs use traditional 'lib' prefix -+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then -+ # It is most probably a Windows format PATH printed by -+ # mingw gcc, but we are running on Cygwin. Gcc prints its search -+ # path with ; separators, and with drive letters. We can handle the -+ # drive letters (cygwin fileutils understands them), so leave them, -+ # especially as we might pass files found there to a mingw objdump, -+ # which wouldn't understand a cygwinified path. Ahh. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+ ;; -+ pw32*) -+ # pw32 DLLs use 'pw' prefix rather than 'lib' -+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' -+ ;; -+ esac -+ ;; -+ -+ *) -+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' -+ ;; -+ esac -+ dynamic_linker='Win32 ld.exe' -+ # FIXME: first we should search . and the directory the executable is in -+ shlibpath_var=PATH -+ ;; -+ -+darwin* | rhapsody*) -+ dynamic_linker="$host_os dyld" -+ version_type=darwin -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' -+ soname_spec='${libname}${release}${major}$shared_ext' -+ shlibpath_overrides_runpath=yes -+ shlibpath_var=DYLD_LIBRARY_PATH -+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. -+ if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` -+ else -+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' -+ fi -+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' -+ ;; -+ -+dgux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+freebsd1*) -+ dynamic_linker=no -+ ;; -+ -+kfreebsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+freebsd* | dragonfly*) -+ # DragonFly does not have aout. When/if they implement a new -+ # versioning mechanism, adjust this. -+ if test -x /usr/bin/objformat; then -+ objformat=`/usr/bin/objformat` -+ else -+ case $host_os in -+ freebsd[[123]]*) objformat=aout ;; -+ *) objformat=elf ;; -+ esac -+ fi -+ version_type=freebsd-$objformat -+ case $version_type in -+ freebsd-elf*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' -+ need_version=no -+ need_lib_prefix=no -+ ;; -+ freebsd-*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' -+ need_version=yes -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_os in -+ freebsd2*) -+ shlibpath_overrides_runpath=yes -+ ;; -+ freebsd3.[[01]]* | freebsdelf3.[[01]]*) -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ *) # from 3.2 on -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ ;; -+ esac -+ ;; -+ -+gnu*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ hardcode_into_libs=yes -+ ;; -+ -+hpux9* | hpux10* | hpux11*) -+ # Give a soname corresponding to the major version so that dld.sl refuses to -+ # link against other versions. -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ case $host_cpu in -+ ia64*) -+ shrext_cmds='.so' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.so" -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ if test "X$HPUX_IA64_MODE" = X32; then -+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" -+ else -+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" -+ fi -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ hppa*64*) -+ shrext_cmds='.sl' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ *) -+ shrext_cmds='.sl' -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=SHLIB_PATH -+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ esac -+ # HP-UX runs *really* slowly unless shared libraries are mode 555. -+ postinstall_cmds='chmod 555 $lib' -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $host_os in -+ nonstopux*) version_type=nonstopux ;; -+ *) -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ version_type=linux -+ else -+ version_type=irix -+ fi ;; -+ esac -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' -+ case $host_os in -+ irix5* | nonstopux*) -+ libsuff= shlibsuff= -+ ;; -+ *) -+ case $LD in # libtool.m4 will add one of these switches to LD -+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") -+ libsuff= shlibsuff= libmagic=32-bit;; -+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") -+ libsuff=32 shlibsuff=N32 libmagic=N32;; -+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") -+ libsuff=64 shlibsuff=64 libmagic=64-bit;; -+ *) libsuff= shlibsuff= libmagic=never-match;; -+ esac -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -+ hardcode_into_libs=yes -+ ;; -+ -+# No shared lib support for Linux oldld, aout, or coff. -+linux*oldld* | linux*aout* | linux*coff*) -+ dynamic_linker=no -+ ;; -+ -+# This must be Linux ELF. -+linux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ # This implies no fast_install, which is unacceptable. -+ # Some rework will be needed to allow for fast_install -+ # before this can be enabled. -+ hardcode_into_libs=yes -+ -+ # Append ld.so.conf contents to the search path -+ if test -f /etc/ld.so.conf; then -+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` -+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" -+ fi -+ -+ # We used to test for /lib/ld.so.1 and disable shared libraries on -+ # powerpc, because MkLinux only supported shared libraries with the -+ # GNU dynamic linker. Since this was broken with cross compilers, -+ # most powerpc-linux boxes support dynamic linking these days and -+ # people can always --disable-shared, the test was removed, and we -+ # assume the GNU/Linux dynamic linker is in use. -+ dynamic_linker='GNU/Linux ld.so' -+ ;; -+ -+netbsdelf*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='NetBSD ld.elf_so' -+ ;; -+ -+knetbsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+netbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ dynamic_linker='NetBSD (a.out) ld.so' -+ else -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ dynamic_linker='NetBSD ld.elf_so' -+ fi -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ -+newsos6) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+nto-qnx*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+openbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. -+ case $host_os in -+ openbsd3.3 | openbsd3.3.*) need_version=yes ;; -+ *) need_version=no ;; -+ esac -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ case $host_os in -+ openbsd2.[[89]] | openbsd2.[[89]].*) -+ shlibpath_overrides_runpath=no -+ ;; -+ *) -+ shlibpath_overrides_runpath=yes -+ ;; -+ esac -+ else -+ shlibpath_overrides_runpath=yes -+ fi -+ ;; -+ -+os2*) -+ libname_spec='$name' -+ shrext_cmds=".dll" -+ need_lib_prefix=no -+ library_names_spec='$libname${shared_ext} $libname.a' -+ dynamic_linker='OS/2 ld.exe' -+ shlibpath_var=LIBPATH -+ ;; -+ -+osf3* | osf4* | osf5*) -+ version_type=osf -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -+ ;; -+ -+sco3.2v5*) -+ version_type=osf -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+solaris*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ # ldd complains unless libraries are executable -+ postinstall_cmds='chmod +x $lib' -+ ;; -+ -+sunos4*) -+ version_type=sunos -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ fi -+ need_version=yes -+ ;; -+ -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_vendor in -+ sni) -+ shlibpath_overrides_runpath=no -+ need_lib_prefix=no -+ export_dynamic_flag_spec='${wl}-Blargedynsym' -+ runpath_var=LD_RUN_PATH -+ ;; -+ siemens) -+ need_lib_prefix=no -+ ;; -+ motorola) -+ need_lib_prefix=no -+ need_version=no -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -+ ;; -+ esac -+ ;; -+ -+sysv4*MP*) -+ if test -d /usr/nec ;then -+ version_type=linux -+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' -+ soname_spec='$libname${shared_ext}.$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ fi -+ ;; -+ -+uts4*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+*) -+ dynamic_linker=no -+ ;; -+esac -+AC_MSG_RESULT([$dynamic_linker]) -+test "$dynamic_linker" = no && can_build_shared=no -+])# AC_LIBTOOL_SYS_DYNAMIC_LINKER -+ -+ -+# _LT_AC_TAGCONFIG -+# ---------------- -+AC_DEFUN([_LT_AC_TAGCONFIG], -+[AC_ARG_WITH([tags], -+ [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], -+ [include additional configurations @<:@automatic@:>@])], -+ [tagnames="$withval"]) -+ -+if test -f "$ltmain" && test -n "$tagnames"; then -+ if test ! -f "${ofile}"; then -+ AC_MSG_WARN([output file `$ofile' does not exist]) -+ fi -+ -+ if test -z "$LTCC"; then -+ eval "`$SHELL ${ofile} --config | grep '^LTCC='`" -+ if test -z "$LTCC"; then -+ AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) -+ else -+ AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) -+ fi -+ fi -+ -+ # Extract list of available tagged configurations in $ofile. -+ # Note that this assumes the entire list is on one line. -+ available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` -+ -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for tagname in $tagnames; do -+ IFS="$lt_save_ifs" -+ # Check whether tagname contains only valid characters -+ case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in -+ "") ;; -+ *) AC_MSG_ERROR([invalid tag name: $tagname]) -+ ;; -+ esac -+ -+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null -+ then -+ AC_MSG_ERROR([tag name \"$tagname\" already exists]) -+ fi -+ -+ # Update the list of available tags. -+ if test -n "$tagname"; then -+ echo appending configuration tag \"$tagname\" to $ofile -+ -+ case $tagname in -+ CXX) -+ if test -n "$CXX" && ( test "X$CXX" != "Xno" && -+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || -+ (test "X$CXX" != "Xg++"))) ; then -+ AC_LIBTOOL_LANG_CXX_CONFIG -+ else -+ tagname="" -+ fi -+ ;; -+ -+ F77) -+ if test -n "$F77" && test "X$F77" != "Xno"; then -+ AC_LIBTOOL_LANG_F77_CONFIG -+ else -+ tagname="" -+ fi -+ ;; -+ -+ GCJ) -+ if test -n "$GCJ" && test "X$GCJ" != "Xno"; then -+ AC_LIBTOOL_LANG_GCJ_CONFIG -+ else -+ tagname="" -+ fi -+ ;; -+ -+ RC) -+ AC_LIBTOOL_LANG_RC_CONFIG -+ ;; -+ -+ *) -+ AC_MSG_ERROR([Unsupported tag name: $tagname]) -+ ;; -+ esac -+ -+ # Append the new tag name to the list of available tags. -+ if test -n "$tagname" ; then -+ available_tags="$available_tags $tagname" -+ fi -+ fi -+ done -+ IFS="$lt_save_ifs" -+ -+ # Now substitute the updated list of available tags. -+ if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then -+ mv "${ofile}T" "$ofile" -+ chmod +x "$ofile" -+ else -+ rm -f "${ofile}T" -+ AC_MSG_ERROR([unable to update list of available tagged configurations.]) -+ fi -+fi -+])# _LT_AC_TAGCONFIG -+ -+ -+# AC_LIBTOOL_DLOPEN -+# ----------------- -+# enable checks for dlopen support -+AC_DEFUN([AC_LIBTOOL_DLOPEN], -+ [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) -+])# AC_LIBTOOL_DLOPEN -+ -+ -+# AC_LIBTOOL_WIN32_DLL -+# -------------------- -+# declare package support for building win32 DLLs -+AC_DEFUN([AC_LIBTOOL_WIN32_DLL], -+[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) -+])# AC_LIBTOOL_WIN32_DLL -+ -+ -+# AC_ENABLE_SHARED([DEFAULT]) -+# --------------------------- -+# implement the --enable-shared flag -+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -+AC_DEFUN([AC_ENABLE_SHARED], -+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl -+AC_ARG_ENABLE([shared], -+ [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], -+ [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], -+ [p=${PACKAGE-default} -+ case $enableval in -+ yes) enable_shared=yes ;; -+ no) enable_shared=no ;; -+ *) -+ enable_shared=no -+ # Look at the argument we got. We use all the common list separators. -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for pkg in $enableval; do -+ IFS="$lt_save_ifs" -+ if test "X$pkg" = "X$p"; then -+ enable_shared=yes -+ fi -+ done -+ IFS="$lt_save_ifs" -+ ;; -+ esac], -+ [enable_shared=]AC_ENABLE_SHARED_DEFAULT) -+])# AC_ENABLE_SHARED -+ -+ -+# AC_DISABLE_SHARED -+# ----------------- -+#- set the default shared flag to --disable-shared -+AC_DEFUN([AC_DISABLE_SHARED], -+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -+AC_ENABLE_SHARED(no) -+])# AC_DISABLE_SHARED -+ -+ -+# AC_ENABLE_STATIC([DEFAULT]) -+# --------------------------- -+# implement the --enable-static flag -+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -+AC_DEFUN([AC_ENABLE_STATIC], -+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl -+AC_ARG_ENABLE([static], -+ [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], -+ [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], -+ [p=${PACKAGE-default} -+ case $enableval in -+ yes) enable_static=yes ;; -+ no) enable_static=no ;; -+ *) -+ enable_static=no -+ # Look at the argument we got. We use all the common list separators. -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for pkg in $enableval; do -+ IFS="$lt_save_ifs" -+ if test "X$pkg" = "X$p"; then -+ enable_static=yes -+ fi -+ done -+ IFS="$lt_save_ifs" -+ ;; -+ esac], -+ [enable_static=]AC_ENABLE_STATIC_DEFAULT) -+])# AC_ENABLE_STATIC -+ -+ -+# AC_DISABLE_STATIC -+# ----------------- -+# set the default static flag to --disable-static -+AC_DEFUN([AC_DISABLE_STATIC], -+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -+AC_ENABLE_STATIC(no) -+])# AC_DISABLE_STATIC -+ -+ -+# AC_ENABLE_FAST_INSTALL([DEFAULT]) -+# --------------------------------- -+# implement the --enable-fast-install flag -+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -+AC_DEFUN([AC_ENABLE_FAST_INSTALL], -+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl -+AC_ARG_ENABLE([fast-install], -+ [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], -+ [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], -+ [p=${PACKAGE-default} -+ case $enableval in -+ yes) enable_fast_install=yes ;; -+ no) enable_fast_install=no ;; -+ *) -+ enable_fast_install=no -+ # Look at the argument we got. We use all the common list separators. -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for pkg in $enableval; do -+ IFS="$lt_save_ifs" -+ if test "X$pkg" = "X$p"; then -+ enable_fast_install=yes -+ fi -+ done -+ IFS="$lt_save_ifs" -+ ;; -+ esac], -+ [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) -+])# AC_ENABLE_FAST_INSTALL -+ -+ -+# AC_DISABLE_FAST_INSTALL -+# ----------------------- -+# set the default to --disable-fast-install -+AC_DEFUN([AC_DISABLE_FAST_INSTALL], -+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -+AC_ENABLE_FAST_INSTALL(no) -+])# AC_DISABLE_FAST_INSTALL -+ -+ -+# AC_LIBTOOL_PICMODE([MODE]) -+# -------------------------- -+# implement the --with-pic flag -+# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -+AC_DEFUN([AC_LIBTOOL_PICMODE], -+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -+pic_mode=ifelse($#,1,$1,default) -+])# AC_LIBTOOL_PICMODE -+ -+ -+# AC_PROG_EGREP -+# ------------- -+# This is predefined starting with Autoconf 2.54, so this conditional -+# definition can be removed once we require Autoconf 2.54 or later. -+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], -+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], -+ [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 -+ then ac_cv_prog_egrep='grep -E' -+ else ac_cv_prog_egrep='egrep' -+ fi]) -+ EGREP=$ac_cv_prog_egrep -+ AC_SUBST([EGREP]) -+])]) -+ -+ -+# AC_PATH_TOOL_PREFIX -+# ------------------- -+# find a file program which can recognise shared library -+AC_DEFUN([AC_PATH_TOOL_PREFIX], -+[AC_REQUIRE([AC_PROG_EGREP])dnl -+AC_MSG_CHECKING([for $1]) -+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -+[case $MAGIC_CMD in -+[[\\/*] | ?:[\\/]*]) -+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. -+ ;; -+*) -+ lt_save_MAGIC_CMD="$MAGIC_CMD" -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+dnl $ac_dummy forces splitting on constant user-supplied paths. -+dnl POSIX.2 word splitting is done only on the output of word expansions, -+dnl not every word. This closes a longstanding sh security hole. -+ ac_dummy="ifelse([$2], , $PATH, [$2])" -+ for ac_dir in $ac_dummy; do -+ IFS="$lt_save_ifs" -+ test -z "$ac_dir" && ac_dir=. -+ if test -f $ac_dir/$1; then -+ lt_cv_path_MAGIC_CMD="$ac_dir/$1" -+ if test -n "$file_magic_test_file"; then -+ case $deplibs_check_method in -+ "file_magic "*) -+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` -+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -+ $EGREP "$file_magic_regex" > /dev/null; then -+ : -+ else -+ cat <&2 -+ -+*** Warning: the command libtool uses to detect shared libraries, -+*** $file_magic_cmd, produces output that libtool cannot recognize. -+*** The result is that libtool may fail to recognize shared libraries -+*** as such. This will affect the creation of libtool libraries that -+*** depend on shared libraries, but programs linked with such libtool -+*** libraries will work regardless of this problem. Nevertheless, you -+*** may want to report the problem to your system manager and/or to -+*** bug-libtool@gnu.org -+ -+EOF -+ fi ;; -+ esac -+ fi -+ break -+ fi -+ done -+ IFS="$lt_save_ifs" -+ MAGIC_CMD="$lt_save_MAGIC_CMD" -+ ;; -+esac]) -+MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -+if test -n "$MAGIC_CMD"; then -+ AC_MSG_RESULT($MAGIC_CMD) -+else -+ AC_MSG_RESULT(no) -+fi -+])# AC_PATH_TOOL_PREFIX -+ -+ -+# AC_PATH_MAGIC -+# ------------- -+# find a file program which can recognise a shared library -+AC_DEFUN([AC_PATH_MAGIC], -+[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -+if test -z "$lt_cv_path_MAGIC_CMD"; then -+ if test -n "$ac_tool_prefix"; then -+ AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) -+ else -+ MAGIC_CMD=: -+ fi -+fi -+])# AC_PATH_MAGIC -+ -+ -+# AC_PROG_LD -+# ---------- -+# find the pathname to the GNU or non-GNU linker -+AC_DEFUN([AC_PROG_LD], -+[AC_ARG_WITH([gnu-ld], -+ [AC_HELP_STRING([--with-gnu-ld], -+ [assume the C compiler uses GNU ld @<:@default=no@:>@])], -+ [test "$withval" = no || with_gnu_ld=yes], -+ [with_gnu_ld=no]) -+AC_REQUIRE([LT_AC_PROG_SED])dnl -+AC_REQUIRE([AC_PROG_CC])dnl -+AC_REQUIRE([AC_CANONICAL_HOST])dnl -+AC_REQUIRE([AC_CANONICAL_BUILD])dnl -+ac_prog=ld -+if test "$GCC" = yes; then -+ # Check if gcc -print-prog-name=ld gives a path. -+ AC_MSG_CHECKING([for ld used by $CC]) -+ case $host in -+ *-*-mingw*) -+ # gcc leaves a trailing carriage return which upsets mingw -+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; -+ *) -+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; -+ esac -+ case $ac_prog in -+ # Accept absolute paths. -+ [[\\/]]* | ?:[[\\/]]*) -+ re_direlt='/[[^/]][[^/]]*/\.\./' -+ # Canonicalize the pathname of ld -+ ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` -+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -+ ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` -+ done -+ test -z "$LD" && LD="$ac_prog" -+ ;; -+ "") -+ # If it fails, then pretend we aren't using GCC. -+ ac_prog=ld -+ ;; -+ *) -+ # If it is relative, then search for the first ld in PATH. -+ with_gnu_ld=unknown -+ ;; -+ esac -+elif test "$with_gnu_ld" = yes; then -+ AC_MSG_CHECKING([for GNU ld]) -+else -+ AC_MSG_CHECKING([for non-GNU ld]) -+fi -+AC_CACHE_VAL(lt_cv_path_LD, -+[if test -z "$LD"; then -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in $PATH; do -+ IFS="$lt_save_ifs" -+ test -z "$ac_dir" && ac_dir=. -+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then -+ lt_cv_path_LD="$ac_dir/$ac_prog" -+ # Check to see if the program is GNU ld. I'd rather use --version, -+ # but apparently some variants of GNU ld only accept -v. -+ # Break only if it was the GNU/non-GNU ld that we prefer. -+ case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then -+ case $host_cpu in -+ i*86 ) -+ # Not sure whether the presence of OpenBSD here was a mistake. -+ # Let's accept both of them until this is cleared up. -+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' -+ lt_cv_file_magic_cmd=/usr/bin/file -+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` -+ ;; -+ esac -+ else -+ lt_cv_deplibs_check_method=pass_all -+ fi -+ ;; -+ -+gnu*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ -+hpux10.20* | hpux11*) -+ lt_cv_file_magic_cmd=/usr/bin/file -+ case $host_cpu in -+ ia64*) -+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' -+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so -+ ;; -+ hppa*64*) -+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] -+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl -+ ;; -+ *) -+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' -+ lt_cv_file_magic_test_file=/usr/lib/libc.sl -+ ;; -+ esac -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $LD in -+ *-32|*"-32 ") libmagic=32-bit;; -+ *-n32|*"-n32 ") libmagic=N32;; -+ *-64|*"-64 ") libmagic=64-bit;; -+ *) libmagic=never-match;; -+ esac -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ -+# This must be Linux ELF. -+linux*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ -+netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then -+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' -+ else -+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' -+ fi -+ ;; -+ -+newos6*) -+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' -+ lt_cv_file_magic_cmd=/usr/bin/file -+ lt_cv_file_magic_test_file=/usr/lib/libnls.so -+ ;; -+ -+nto-qnx*) -+ lt_cv_deplibs_check_method=unknown -+ ;; -+ -+openbsd*) -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' -+ else -+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' -+ fi -+ ;; -+ -+osf3* | osf4* | osf5*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ -+sco3.2v5*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ -+solaris*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ case $host_vendor in -+ motorola) -+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' -+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` -+ ;; -+ ncr) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ sequent) -+ lt_cv_file_magic_cmd='/bin/file' -+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' -+ ;; -+ sni) -+ lt_cv_file_magic_cmd='/bin/file' -+ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" -+ lt_cv_file_magic_test_file=/lib/libc.so -+ ;; -+ siemens) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ esac -+ ;; -+ -+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+esac -+]) -+file_magic_cmd=$lt_cv_file_magic_cmd -+deplibs_check_method=$lt_cv_deplibs_check_method -+test -z "$deplibs_check_method" && deplibs_check_method=unknown -+])# AC_DEPLIBS_CHECK_METHOD -+ -+ -+# AC_PROG_NM -+# ---------- -+# find the pathname to a BSD-compatible name lister -+AC_DEFUN([AC_PROG_NM], -+[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, -+[if test -n "$NM"; then -+ # Let the user override the test. -+ lt_cv_path_NM="$NM" -+else -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do -+ IFS="$lt_save_ifs" -+ test -z "$ac_dir" && ac_dir=. -+ tmp_nm="$ac_dir/${ac_tool_prefix}nm" -+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then -+ # Check to see if the nm accepts a BSD-compat flag. -+ # Adding the `sed 1q' prevents false positives on HP-UX, which says: -+ # nm: unknown option "B" ignored -+ # Tru64's nm complains that /dev/null is an invalid object file -+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in -+ */dev/null* | *'Invalid file or object type'*) -+ lt_cv_path_NM="$tmp_nm -B" -+ break -+ ;; -+ *) -+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in -+ */dev/null*) -+ lt_cv_path_NM="$tmp_nm -p" -+ break -+ ;; -+ *) -+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but -+ continue # so that we can try to find one that supports BSD flags -+ ;; -+ esac -+ esac -+ fi -+ done -+ IFS="$lt_save_ifs" -+ test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -+fi]) -+NM="$lt_cv_path_NM" -+])# AC_PROG_NM -+ -+ -+# AC_CHECK_LIBM -+# ------------- -+# check for math library -+AC_DEFUN([AC_CHECK_LIBM], -+[AC_REQUIRE([AC_CANONICAL_HOST])dnl -+LIBM= -+case $host in -+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) -+ # These system don't have libm, or don't need it -+ ;; -+*-ncr-sysv4.3*) -+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") -+ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") -+ ;; -+*) -+ AC_CHECK_LIB(m, cos, LIBM="-lm") -+ ;; -+esac -+])# AC_CHECK_LIBM -+ -+ -+# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) -+# ----------------------------------- -+# sets LIBLTDL to the link flags for the libltdl convenience library and -+# LTDLINCL to the include flags for the libltdl header and adds -+# --enable-ltdl-convenience to the configure arguments. Note that -+# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, -+# it is assumed to be `libltdl'. LIBLTDL will be prefixed with -+# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' -+# (note the single quotes!). If your package is not flat and you're not -+# using automake, define top_builddir and top_srcdir appropriately in -+# the Makefiles. -+AC_DEFUN([AC_LIBLTDL_CONVENIENCE], -+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -+ case $enable_ltdl_convenience in -+ no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; -+ "") enable_ltdl_convenience=yes -+ ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; -+ esac -+ LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la -+ LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) -+ # For backwards non-gettext consistent compatibility... -+ INCLTDL="$LTDLINCL" -+])# AC_LIBLTDL_CONVENIENCE -+ -+ -+# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) -+# ----------------------------------- -+# sets LIBLTDL to the link flags for the libltdl installable library and -+# LTDLINCL to the include flags for the libltdl header and adds -+# --enable-ltdl-install to the configure arguments. Note that -+# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, -+# and an installed libltdl is not found, it is assumed to be `libltdl'. -+# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with -+# '${top_srcdir}/' (note the single quotes!). If your package is not -+# flat and you're not using automake, define top_builddir and top_srcdir -+# appropriately in the Makefiles. -+# In the future, this macro may have to be called after AC_PROG_LIBTOOL. -+AC_DEFUN([AC_LIBLTDL_INSTALLABLE], -+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -+ AC_CHECK_LIB(ltdl, lt_dlinit, -+ [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], -+ [if test x"$enable_ltdl_install" = xno; then -+ AC_MSG_WARN([libltdl not installed, but installation disabled]) -+ else -+ enable_ltdl_install=yes -+ fi -+ ]) -+ if test x"$enable_ltdl_install" = x"yes"; then -+ ac_configure_args="$ac_configure_args --enable-ltdl-install" -+ LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la -+ LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) -+ else -+ ac_configure_args="$ac_configure_args --enable-ltdl-install=no" -+ LIBLTDL="-lltdl" -+ LTDLINCL= -+ fi -+ # For backwards non-gettext consistent compatibility... -+ INCLTDL="$LTDLINCL" -+])# AC_LIBLTDL_INSTALLABLE -+ -+ -+# AC_LIBTOOL_CXX -+# -------------- -+# enable support for C++ libraries -+AC_DEFUN([AC_LIBTOOL_CXX], -+[AC_REQUIRE([_LT_AC_LANG_CXX]) -+])# AC_LIBTOOL_CXX -+ -+ -+# _LT_AC_LANG_CXX -+# --------------- -+AC_DEFUN([_LT_AC_LANG_CXX], -+[AC_REQUIRE([AC_PROG_CXX]) -+AC_REQUIRE([_LT_AC_PROG_CXXCPP]) -+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) -+])# _LT_AC_LANG_CXX -+ -+# _LT_AC_PROG_CXXCPP -+# --------------- -+AC_DEFUN([_LT_AC_PROG_CXXCPP], -+[ -+AC_REQUIRE([AC_PROG_CXX]) -+if test -n "$CXX" && ( test "X$CXX" != "Xno" && -+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || -+ (test "X$CXX" != "Xg++"))) ; then -+ AC_PROG_CXXCPP -+fi -+])# _LT_AC_PROG_CXXCPP -+ -+# AC_LIBTOOL_F77 -+# -------------- -+# enable support for Fortran 77 libraries -+AC_DEFUN([AC_LIBTOOL_F77], -+[AC_REQUIRE([_LT_AC_LANG_F77]) -+])# AC_LIBTOOL_F77 -+ -+ -+# _LT_AC_LANG_F77 -+# --------------- -+AC_DEFUN([_LT_AC_LANG_F77], -+[AC_REQUIRE([AC_PROG_F77]) -+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) -+])# _LT_AC_LANG_F77 -+ -+ -+# AC_LIBTOOL_GCJ -+# -------------- -+# enable support for GCJ libraries -+AC_DEFUN([AC_LIBTOOL_GCJ], -+[AC_REQUIRE([_LT_AC_LANG_GCJ]) -+])# AC_LIBTOOL_GCJ -+ -+ -+# _LT_AC_LANG_GCJ -+# --------------- -+AC_DEFUN([_LT_AC_LANG_GCJ], -+[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], -+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], -+ [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], -+ [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], -+ [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], -+ [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) -+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) -+])# _LT_AC_LANG_GCJ -+ -+ -+# AC_LIBTOOL_RC -+# -------------- -+# enable support for Windows resource files -+AC_DEFUN([AC_LIBTOOL_RC], -+[AC_REQUIRE([LT_AC_PROG_RC]) -+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) -+])# AC_LIBTOOL_RC -+ -+ -+# AC_LIBTOOL_LANG_C_CONFIG -+# ------------------------ -+# Ensure that the configuration vars for the C compiler are -+# suitably defined. Those variables are subsequently used by -+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -+AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) -+AC_DEFUN([_LT_AC_LANG_C_CONFIG], -+[lt_save_CC="$CC" -+AC_LANG_PUSH(C) -+ -+# Source file extension for C test sources. -+ac_ext=c -+ -+# Object file extension for compiled C test sources. -+objext=o -+_LT_AC_TAGVAR(objext, $1)=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code="int some_variable = 0;\n" -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code='int main(){return(0);}\n' -+ -+_LT_AC_SYS_COMPILER -+ -+# save warnings/boilerplate of simple test code -+_LT_COMPILER_BOILERPLATE -+_LT_LINKER_BOILERPLATE -+ -+# -+# Check for any special shared library compilation flags. -+# -+_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)= -+if test "$GCC" = no; then -+ case $host_os in -+ sco3.2v5*) -+ _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf' -+ ;; -+ esac -+fi -+if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then -+ AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries]) -+ if echo "$old_CC $old_CFLAGS " | grep "[[ ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ ]]" >/dev/null; then : -+ else -+ AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure]) -+ _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no -+ fi -+fi -+ -+ -+# -+# Check to make sure the static flag actually works. -+# -+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works], -+ _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), -+ $_LT_AC_TAGVAR(lt_prog_compiler_static, $1), -+ [], -+ [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) -+ -+ -+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) -+AC_LIBTOOL_PROG_COMPILER_PIC($1) -+AC_LIBTOOL_PROG_CC_C_O($1) -+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -+AC_LIBTOOL_PROG_LD_SHLIBS($1) -+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) -+AC_LIBTOOL_SYS_LIB_STRIP -+AC_LIBTOOL_DLOPEN_SELF($1) -+ -+# Report which librarie types wil actually be built -+AC_MSG_CHECKING([if libtool supports shared libraries]) -+AC_MSG_RESULT([$can_build_shared]) -+ -+AC_MSG_CHECKING([whether to build shared libraries]) -+test "$can_build_shared" = "no" && enable_shared=no -+ -+# On AIX, shared libraries and static libraries use the same namespace, and -+# are all built from PIC. -+case $host_os in -+aix3*) -+ test "$enable_shared" = yes && enable_static=no -+ if test -n "$RANLIB"; then -+ archive_cmds="$archive_cmds~\$RANLIB \$lib" -+ postinstall_cmds='$RANLIB $lib' -+ fi -+ ;; -+ -+aix4* | aix5*) -+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then -+ test "$enable_shared" = yes && enable_static=no -+ fi -+ ;; -+esac -+AC_MSG_RESULT([$enable_shared]) -+ -+AC_MSG_CHECKING([whether to build static libraries]) -+# Make sure either enable_shared or enable_static is yes. -+test "$enable_shared" = yes || enable_static=yes -+AC_MSG_RESULT([$enable_static]) -+ -+AC_LIBTOOL_CONFIG($1) -+ -+AC_LANG_POP -+CC="$lt_save_CC" -+])# AC_LIBTOOL_LANG_C_CONFIG -+ -+ -+# AC_LIBTOOL_LANG_CXX_CONFIG -+# -------------------------- -+# Ensure that the configuration vars for the C compiler are -+# suitably defined. Those variables are subsequently used by -+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -+AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) -+AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], -+[AC_LANG_PUSH(C++) -+AC_REQUIRE([AC_PROG_CXX]) -+AC_REQUIRE([_LT_AC_PROG_CXXCPP]) -+ -+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+_LT_AC_TAGVAR(allow_undefined_flag, $1)= -+_LT_AC_TAGVAR(always_export_symbols, $1)=no -+_LT_AC_TAGVAR(archive_expsym_cmds, $1)= -+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= -+_LT_AC_TAGVAR(hardcode_direct, $1)=no -+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no -+_LT_AC_TAGVAR(hardcode_automatic, $1)=no -+_LT_AC_TAGVAR(module_cmds, $1)= -+_LT_AC_TAGVAR(module_expsym_cmds, $1)= -+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown -+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -+_LT_AC_TAGVAR(no_undefined_flag, $1)= -+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no -+ -+# Dependencies to place before and after the object being linked: -+_LT_AC_TAGVAR(predep_objects, $1)= -+_LT_AC_TAGVAR(postdep_objects, $1)= -+_LT_AC_TAGVAR(predeps, $1)= -+_LT_AC_TAGVAR(postdeps, $1)= -+_LT_AC_TAGVAR(compiler_lib_search_path, $1)= -+ -+# Source file extension for C++ test sources. -+ac_ext=cpp -+ -+# Object file extension for compiled C++ test sources. -+objext=o -+_LT_AC_TAGVAR(objext, $1)=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code="int some_variable = 0;\n" -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' -+ -+# ltmain only uses $CC for tagged configurations so make sure $CC is set. -+_LT_AC_SYS_COMPILER -+ -+# save warnings/boilerplate of simple test code -+_LT_COMPILER_BOILERPLATE -+_LT_LINKER_BOILERPLATE -+ -+# Allow CC to be a program name with arguments. -+lt_save_CC=$CC -+lt_save_LD=$LD -+lt_save_GCC=$GCC -+GCC=$GXX -+lt_save_with_gnu_ld=$with_gnu_ld -+lt_save_path_LD=$lt_cv_path_LD -+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then -+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx -+else -+ unset lt_cv_prog_gnu_ld -+fi -+if test -n "${lt_cv_path_LDCXX+set}"; then -+ lt_cv_path_LD=$lt_cv_path_LDCXX -+else -+ unset lt_cv_path_LD -+fi -+test -z "${LDCXX+set}" || LD=$LDCXX -+CC=${CXX-"c++"} -+compiler=$CC -+_LT_AC_TAGVAR(compiler, $1)=$CC -+_LT_CC_BASENAME([$compiler]) -+ -+# We don't want -fno-exception wen compiling C++ code, so set the -+# no_builtin_flag separately -+if test "$GXX" = yes; then -+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' -+else -+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= -+fi -+ -+if test "$GXX" = yes; then -+ # Set up default GNU C++ configuration -+ -+ AC_PROG_LD -+ -+ # Check if GNU C++ uses GNU ld as the underlying linker, since the -+ # archiving commands below assume that GNU ld is being used. -+ if test "$with_gnu_ld" = yes; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' -+ -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to -+ # investigate it a little bit more. (MM) -+ wlarc='${wl}' -+ -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ -+ grep 'no-whole-archive' > /dev/null; then -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -+ fi -+ else -+ with_gnu_ld=no -+ wlarc= -+ -+ # A generic and very simple default shared library creation -+ # command for GNU C++ for the case where it uses the native -+ # linker, instead of GNU ld. If possible, this setting should -+ # overridden to take advantage of the native linker features on -+ # the platform it is being used on. -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' -+ fi -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' -+ -+else -+ GXX=no -+ with_gnu_ld=no -+ wlarc= -+fi -+ -+# PORTME: fill in a description of your system's C++ link characteristics -+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -+_LT_AC_TAGVAR(ld_shlibs, $1)=yes -+case $host_os in -+ aix3*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ aix4* | aix5*) -+ if test "$host_cpu" = ia64; then -+ # On IA64, the linker does run time linking by default, so we don't -+ # have to do anything special. -+ aix_use_runtimelinking=no -+ exp_sym_flag='-Bexport' -+ no_entry_flag="" -+ else -+ aix_use_runtimelinking=no -+ -+ # Test if we are trying to use run time linking or normal -+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we -+ # need to do runtime linking. -+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) -+ for ld_flag in $LDFLAGS; do -+ case $ld_flag in -+ *-brtl*) -+ aix_use_runtimelinking=yes -+ break -+ ;; -+ esac -+ done -+ esac -+ -+ exp_sym_flag='-bexport' -+ no_entry_flag='-bnoentry' -+ fi -+ -+ # When large executables or shared objects are built, AIX ld can -+ # have problems creating the table of contents. If linking a library -+ # or program results in "error TOC overflow" add -mminimal-toc to -+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -+ -+ _LT_AC_TAGVAR(archive_cmds, $1)='' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ -+ if test "$GXX" = yes; then -+ case $host_os in aix4.[[012]]|aix4.[[012]].*) -+ # We only want to do this on AIX 4.2 and lower, the check -+ # below for broken collect2 doesn't work under 4.3+ -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ else -+ # We have old collect2 -+ _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -+ fi -+ esac -+ shared_flag='-shared' -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag="$shared_flag "'${wl}-G' -+ fi -+ else -+ # not using gcc -+ if test "$host_cpu" = ia64; then -+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release -+ # chokes on -Wl,-G. The following line is correct: -+ shared_flag='-G' -+ else -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag='${wl}-G' -+ else -+ shared_flag='${wl}-bM:SRE' -+ fi -+ fi -+ fi -+ -+ # It seems that -bexpall does not export symbols beginning with -+ # underscore (_), so it is better to generate a list of symbols to export. -+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes -+ if test "$aix_use_runtimelinking" = yes; then -+ # Warning - without using the other runtime loading flags (-brtl), -+ # -berok will link without error, but may produce a broken library. -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' -+ # Determine the default libpath from the value encoded in an empty executable. -+ _LT_AC_SYS_LIBPATH_AIX -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" -+ -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -+ else -+ if test "$host_cpu" = ia64; then -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -+ else -+ # Determine the default libpath from the value encoded in an empty executable. -+ _LT_AC_SYS_LIBPATH_AIX -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" -+ # Warning - without using the other run time loading flags, -+ # -berok will link without error, but may produce a broken library. -+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' -+ # -bexpall does not export symbols beginning with underscore (_) -+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes -+ # Exported symbols can be pulled into shared objects from archives -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes -+ # This is similar to how AIX traditionally builds its shared libraries. -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' -+ fi -+ fi -+ ;; -+ chorus*) -+ case $cc_basename in -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ ;; -+ -+ -+ cygwin* | mingw* | pw32*) -+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, -+ # as there is no search path for DLLs. -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported -+ _LT_AC_TAGVAR(always_export_symbols, $1)=no -+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes -+ -+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ # If the export-symbols file already is a .def file (1st line -+ # is EXPORTS), use it as is; otherwise, prepend... -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then -+ cp $export_symbols $output_objdir/$soname.def; -+ else -+ echo EXPORTS > $output_objdir/$soname.def; -+ cat $export_symbols >> $output_objdir/$soname.def; -+ fi~ -+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ else -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ darwin* | rhapsody*) -+ case $host_os in -+ rhapsody* | darwin1.[[012]]) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' -+ ;; -+ *) # Darwin 1.3 on -+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ else -+ case ${MACOSX_DEPLOYMENT_TARGET} in -+ 10.[[012]]) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ ;; -+ 10.*) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' -+ ;; -+ esac -+ fi -+ ;; -+ esac -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_automatic, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ -+ if test "$GXX" = yes ; then -+ lt_int_apple_cc_single_mod=no -+ output_verbose_link_cmd='echo' -+ if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then -+ lt_int_apple_cc_single_mod=yes -+ fi -+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ fi -+ _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ fi -+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ case $cc_basename in -+ xlc*) -+ output_verbose_link_cmd='echo' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' -+ _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ ;; -+ *) -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ fi -+ ;; -+ -+ dgux*) -+ case $cc_basename in -+ ec++*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ ghcx*) -+ # Green Hills C++ Compiler -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ ;; -+ freebsd[[12]]*) -+ # C++ shared libraries reported to be fairly broken before switch to ELF -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ freebsd-elf*) -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ ;; -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF -+ # conventions -+ _LT_AC_TAGVAR(ld_shlibs, $1)=yes -+ ;; -+ gnu*) -+ ;; -+ hpux9*) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, -+ # but as the default -+ # location of the library. -+ -+ case $cc_basename in -+ CC*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ aCC*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ else -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ esac -+ ;; -+ hpux10*|hpux11*) -+ if test $with_gnu_ld = no; then -+ case $host_cpu in -+ hppa*64*) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ ;; -+ ia64*) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ ;; -+ *) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' -+ ;; -+ esac -+ fi -+ case $host_cpu in -+ hppa*64*) -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ ia64*) -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, -+ # but as the default -+ # location of the library. -+ ;; -+ *) -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, -+ # but as the default -+ # location of the library. -+ ;; -+ esac -+ -+ case $cc_basename in -+ CC*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ aCC*) -+ case $host_cpu in -+ hppa*64*|ia64*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' -+ ;; -+ *) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' -+ ;; -+ esac -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes; then -+ if test $with_gnu_ld = no; then -+ case $host_cpu in -+ ia64*|hppa*64*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' -+ ;; -+ *) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' -+ ;; -+ esac -+ fi -+ else -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ esac -+ ;; -+ irix5* | irix6*) -+ case $cc_basename in -+ CC*) -+ # SGI C++ -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ -+ # Archives containing C++ object files must be created using -+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is -+ # necessary to make sure instantiated templates are included -+ # in the archive. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' -+ ;; -+ *) -+ if test "$GXX" = yes; then -+ if test "$with_gnu_ld" = no; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' -+ fi -+ fi -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ ;; -+ esac -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ ;; -+ linux*) -+ case $cc_basename in -+ KCC*) -+ # Kuck and Associates, Inc. (KAI) C++ Compiler -+ -+ # KCC will only create a shared library if the output file -+ # ends with ".so" (or ".sl" for HP-UX), so rename the library -+ # to its proper name (with version) after linking. -+ _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' -+ -+ # Archives containing C++ object files must be created using -+ # "CC -Bstatic", where "CC" is the KAI C++ compiler. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' -+ ;; -+ icpc*) -+ # Intel C++ -+ with_gnu_ld=yes -+ # version 8.0 and above of icpc choke on multiply defined symbols -+ # if we add $predep_objects and $postdep_objects, however 7.1 and -+ # earlier do not add the objects themselves. -+ case `$CC -V 2>&1` in -+ *"Version 7."*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ ;; -+ *) # Version 8.0 or newer -+ tmp_idyn= -+ case $host_cpu in -+ ia64*) tmp_idyn=' -i_dynamic';; -+ esac -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ ;; -+ esac -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' -+ ;; -+ pgCC*) -+ # Portland Group C++ compiler -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ ;; -+ cxx*) -+ # Compaq C++ -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' -+ -+ runpath_var=LD_RUN_PATH -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ esac -+ ;; -+ lynxos*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ m88k*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ mvs*) -+ case $cc_basename in -+ cxx*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ ;; -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' -+ wlarc= -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ fi -+ # Workaround some broken pre-1.5 toolchains -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' -+ ;; -+ openbsd2*) -+ # C++ shared libraries are fairly broken -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ openbsd*) -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ fi -+ output_verbose_link_cmd='echo' -+ ;; -+ osf3*) -+ case $cc_basename in -+ KCC*) -+ # Kuck and Associates, Inc. (KAI) C++ Compiler -+ -+ # KCC will only create a shared library if the output file -+ # ends with ".so" (or ".sl" for HP-UX), so rename the library -+ # to its proper name (with version) after linking. -+ _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Archives containing C++ object files must be created using -+ # "CC -Bstatic", where "CC" is the KAI C++ compiler. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' -+ -+ ;; -+ RCC*) -+ # Rational C++ 2.4.1 -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ cxx*) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' -+ -+ else -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ esac -+ ;; -+ osf4* | osf5*) -+ case $cc_basename in -+ KCC*) -+ # Kuck and Associates, Inc. (KAI) C++ Compiler -+ -+ # KCC will only create a shared library if the output file -+ # ends with ".so" (or ".sl" for HP-UX), so rename the library -+ # to its proper name (with version) after linking. -+ _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Archives containing C++ object files must be created using -+ # the KAI C++ compiler. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' -+ ;; -+ RCC*) -+ # Rational C++ 2.4.1 -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ cxx*) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ -+ echo "-hidden">> $lib.exp~ -+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ -+ $rm $lib.exp' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' -+ -+ else -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ esac -+ ;; -+ psos*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ sco*) -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ case $cc_basename in -+ CC*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ ;; -+ sunos4*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.x -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ lcc*) -+ # Lucid -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ ;; -+ solaris*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.2, 5.x and Centerline C++ -+ _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes -+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ case $host_os in -+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; -+ *) -+ # The C++ compiler is used as linker so we must use $wl -+ # flag to pass the commands to the underlying system -+ # linker. We must also pass each convience library through -+ # to the system linker between allextract/defaultextract. -+ # The C++ compiler will combine linker options so we -+ # cannot just pass the convience library names through -+ # without $wl. -+ # Supported since Solaris 2.6 (maybe 2.5.1?) -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' -+ ;; -+ esac -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ -+ output_verbose_link_cmd='echo' -+ -+ # Archives containing C++ object files must be created using -+ # "CC -xar", where "CC" is the Sun C++ compiler. This is -+ # necessary to make sure instantiated templates are included -+ # in the archive. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' -+ ;; -+ gcx*) -+ # Green Hills C++ Compiler -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' -+ -+ # The C++ compiler must be used to create the archive. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' -+ ;; -+ *) -+ # GNU C++ compiler with Solaris linker -+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then -+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' -+ if $CC --version | grep -v '^2\.7' > /dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" -+ else -+ # g++ 2.7 appears to require `-G' NOT `-shared' on this -+ # platform. -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" -+ fi -+ -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' -+ fi -+ ;; -+ esac -+ ;; -+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ ;; -+ tandem*) -+ case $cc_basename in -+ NCC*) -+ # NonStop-UX NCC 3.20 -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ ;; -+ vxworks*) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+esac -+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no -+ -+_LT_AC_TAGVAR(GCC, $1)="$GXX" -+_LT_AC_TAGVAR(LD, $1)="$LD" -+ -+AC_LIBTOOL_POSTDEP_PREDEP($1) -+AC_LIBTOOL_PROG_COMPILER_PIC($1) -+AC_LIBTOOL_PROG_CC_C_O($1) -+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -+AC_LIBTOOL_PROG_LD_SHLIBS($1) -+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) -+AC_LIBTOOL_SYS_LIB_STRIP -+AC_LIBTOOL_DLOPEN_SELF($1) -+ -+AC_LIBTOOL_CONFIG($1) -+ -+AC_LANG_POP -+CC=$lt_save_CC -+LDCXX=$LD -+LD=$lt_save_LD -+GCC=$lt_save_GCC -+with_gnu_ldcxx=$with_gnu_ld -+with_gnu_ld=$lt_save_with_gnu_ld -+lt_cv_path_LDCXX=$lt_cv_path_LD -+lt_cv_path_LD=$lt_save_path_LD -+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld -+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -+])# AC_LIBTOOL_LANG_CXX_CONFIG -+ -+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) -+# ------------------------ -+# Figure out "hidden" library dependencies from verbose -+# compiler output when linking a shared library. -+# Parse the compiler output and extract the necessary -+# objects, libraries and library flags. -+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ -+dnl we can't use the lt_simple_compile_test_code here, -+dnl because it contains code intended for an executable, -+dnl not a library. It's possible we should let each -+dnl tag define a new lt_????_link_test_code variable, -+dnl but it's only used here... -+ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" -+ifelse([$1], [], -+[#! $SHELL -+ -+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -+# NOTE: Changes made to this file will be lost: look at ltmain.sh. -+# -+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -+# Free Software Foundation, Inc. -+# -+# This file is part of GNU Libtool: -+# Originally by Gordon Matzigkeit , 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 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+# -+# 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. -+ -+# A sed program that does not truncate output. -+SED=$lt_SED -+ -+# Sed that helps us avoid accidentally triggering echo(1) options like -n. -+Xsed="$SED -e 1s/^X//" -+ -+# The HP-UX ksh and POSIX shell print the target directory to stdout -+# if CDPATH is set. -+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH -+ -+# The names of the tagged configurations supported by this script. -+available_tags= -+ -+# ### BEGIN LIBTOOL CONFIG], -+[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) -+ -+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+ -+# Shell to use when invoking shell scripts. -+SHELL=$lt_SHELL -+ -+# Whether or not to build shared libraries. -+build_libtool_libs=$enable_shared -+ -+# Whether or not to build static libraries. -+build_old_libs=$enable_static -+ -+# Whether or not to add -lc for building shared libraries. -+build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) -+ -+# Whether or not to disallow shared libs when runtime libs are static -+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) -+ -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ -+# The host system. -+host_alias=$host_alias -+host=$host -+host_os=$host_os -+ -+# The build system. -+build_alias=$build_alias -+build=$build -+build_os=$build_os -+ -+# An echo program that does not interpret backslashes. -+echo=$lt_echo -+ -+# The archiver. -+AR=$lt_AR -+AR_FLAGS=$lt_AR_FLAGS -+ -+# A C compiler. -+LTCC=$lt_LTCC -+ -+# A language-specific compiler. -+CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) -+ -+# Is the compiler the GNU C compiler? -+with_gcc=$_LT_AC_TAGVAR(GCC, $1) -+ -+# An ERE matcher. -+EGREP=$lt_EGREP -+ -+# The linker used to build libraries. -+LD=$lt_[]_LT_AC_TAGVAR(LD, $1) -+ -+# Whether we need hard or soft links. -+LN_S=$lt_LN_S -+ -+# A BSD-compatible nm program. -+NM=$lt_NM -+ -+# A symbol stripping program -+STRIP=$lt_STRIP -+ -+# Used to examine libraries when file_magic_cmd begins "file" -+MAGIC_CMD=$MAGIC_CMD -+ -+# Used on cygwin: DLL creation program. -+DLLTOOL="$DLLTOOL" -+ -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. -+AS="$AS" -+ -+# The name of the directory that contains temporary libtool files. -+objdir=$objdir -+ -+# How to create reloadable object files. -+reload_flag=$lt_reload_flag -+reload_cmds=$lt_reload_cmds -+ -+# How to pass a linker flag through the compiler. -+wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) -+ -+# Object file suffix (normally "o"). -+objext="$ac_objext" -+ -+# Old archive suffix (normally "a"). -+libext="$libext" -+ -+# Shared library suffix (normally ".so"). -+shrext_cmds='$shrext_cmds' -+ -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ -+# Additional compiler flags for building library objects. -+pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) -+pic_mode=$pic_mode -+ -+# What is the maximum length of a command? -+max_cmd_len=$lt_cv_sys_max_cmd_len -+ -+# Does compiler simultaneously support -c and -o options? -+compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) -+ -+# Must we lock files when doing compilation? -+need_locks=$lt_need_locks -+ -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen_support=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ -+# Compiler flag to prevent dynamic linking. -+link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) -+ -+# Compiler flag to turn off builtin functions. -+no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -+ -+# Compiler flag to allow reflexive dlopens. -+export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) -+ -+# Compiler flag to generate shared objects directly from archives. -+whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) -+ -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) -+ -+# Library versioning type. -+version_type=$version_type -+ -+# Format of library name prefix. -+libname_spec=$lt_libname_spec -+ -+# List of archive names. First name is the real one, the rest are links. -+# The last name is the one that the linker finds with -lNAME. -+library_names_spec=$lt_library_names_spec -+ -+# The coded name of the library, if different from the real name. -+soname_spec=$lt_soname_spec -+ -+# Commands used to build and install an old-style archive. -+RANLIB=$lt_RANLIB -+old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) -+old_postinstall_cmds=$lt_old_postinstall_cmds -+old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ -+# Create an old-style archive from a shared archive. -+old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) -+ -+# Create a temporary old-style archive to link instead of a shared archive. -+old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) -+ -+# Commands used to build and install a shared archive. -+archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) -+archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) -+postinstall_cmds=$lt_postinstall_cmds -+postuninstall_cmds=$lt_postuninstall_cmds -+ -+# Commands used to build a loadable module (assumed same as above if empty) -+module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) -+module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) -+ -+# Commands to strip libraries. -+old_striplib=$lt_old_striplib -+striplib=$lt_striplib -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) -+ -+# The library search path used internally by the compiler when linking -+# a shared library. -+compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) -+ -+# Method to check whether dependent libraries are shared objects. -+deplibs_check_method=$lt_deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$lt_file_magic_cmd -+ -+# Flag that allows shared libraries with undefined symbols to be built. -+allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) -+ -+# Flag that forces no undefined symbols. -+no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) -+ -+# Commands used to finish a libtool library installation in a directory. -+finish_cmds=$lt_finish_cmds -+ -+# Same as above, but a single script fragment to be evaled but not shown. -+finish_eval=$lt_finish_eval -+ -+# Take the output of nm and produce a listing of raw symbols and C names. -+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe -+ -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl -+ -+# Transform the output of nm in a C name address pair -+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address -+ -+# This is the shared library runtime path variable. -+runpath_var=$runpath_var -+ -+# This is the shared library path variable. -+shlibpath_var=$shlibpath_var -+ -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+ -+# How to hardcode a shared library path into an executable. -+hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) -+ -+# Whether we should hardcode library paths into libraries. -+hardcode_into_libs=$hardcode_into_libs -+ -+# Flag to hardcode \$libdir into a binary during linking. -+# This must work even if \$libdir does not exist. -+hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) -+ -+# If ld is used when linking, flag to hardcode \$libdir into -+# a binary during linking. This must work even if \$libdir does -+# not exist. -+hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) -+ -+# Whether we need a single -rpath flag with a separated argument. -+hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) -+ -+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -+# resulting binary. -+hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) -+ -+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -+# resulting binary. -+hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) -+ -+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -+# the resulting binary. -+hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) -+ -+# Set to yes if building a shared library automatically hardcodes DIR into the library -+# and all subsequent libraries and executables linked against it. -+hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) -+ -+# Variables whose values should be saved in libtool wrapper scripts and -+# restored at relink time. -+variables_saved_for_relink="$variables_saved_for_relink" -+ -+# Whether libtool must link a program against all its dependency libraries. -+link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) -+ -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ -+# Fix the shell variable \$srcfile for the compiler. -+fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) -+ -+# The commands to extract the exported symbol list from a shared archive. -+extract_expsyms_cmds=$lt_extract_expsyms_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) -+ -+# Symbols that must always be exported. -+include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) -+ -+ifelse([$1],[], -+[# ### END LIBTOOL CONFIG], -+[# ### END LIBTOOL TAG CONFIG: $tagname]) -+ -+__EOF__ -+ -+ifelse([$1],[], [ -+ case $host_os in -+ aix3*) -+ cat <<\EOF >> "$cfgfile" -+ -+# AIX sometimes has problems with the GCC collect2 program. For some -+# reason, if we set the COLLECT_NAMES environment variable, the problems -+# vanish in a puff of smoke. -+if test "X${COLLECT_NAMES+set}" != Xset; then -+ COLLECT_NAMES= -+ export COLLECT_NAMES -+fi -+EOF -+ ;; -+ esac -+ -+ # We use sed instead of cat because bash on DJGPP gets confused if -+ # if finds mixed CR/LF and LF-only lines. Since sed operates in -+ # text mode, it properly converts lines to CR/LF. This bash problem -+ # is reportedly fixed, but why not run on old versions too? -+ sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) -+ -+ mv -f "$cfgfile" "$ofile" || \ -+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") -+ chmod +x "$ofile" -+]) -+else -+ # If there is no Makefile yet, we rely on a make rule to execute -+ # `config.status --recheck' to rerun these tests and create the -+ # libtool script then. -+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` -+ if test -f "$ltmain_in"; then -+ test -f Makefile && make "$ltmain" -+ fi -+fi -+])# AC_LIBTOOL_CONFIG -+ -+ -+# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) -+# ------------------------------------------- -+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], -+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -+ -+_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= -+ -+if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' -+ -+ AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], -+ lt_cv_prog_compiler_rtti_exceptions, -+ [-fno-rtti -fno-exceptions], [], -+ [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -+fi -+])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI -+ -+ -+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -+# --------------------------------- -+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], -+[AC_REQUIRE([AC_CANONICAL_HOST]) -+AC_REQUIRE([AC_PROG_NM]) -+AC_REQUIRE([AC_OBJEXT]) -+# Check for command to grab the raw symbol name followed by C symbol from nm. -+AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -+[ -+# These are sane defaults that work on at least a few old systems. -+# [They come from Ultrix. What could be older than Ultrix?!! ;)] -+ -+# Character class describing NM global symbol codes. -+symcode='[[BCDEGRST]]' -+ -+# Regexp to match symbols that can be accessed directly from C. -+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' -+ -+# Transform an extracted symbol line into a proper C declaration -+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" -+ -+# Transform an extracted symbol line into symbol name and symbol address -+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -+ -+# Define system-specific variables. -+case $host_os in -+aix*) -+ symcode='[[BCDT]]' -+ ;; -+cygwin* | mingw* | pw32*) -+ symcode='[[ABCDGISTW]]' -+ ;; -+hpux*) # Its linker distinguishes data from code symbols -+ if test "$host_cpu" = ia64; then -+ symcode='[[ABCDEGRST]]' -+ fi -+ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" -+ lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -+ ;; -+linux*) -+ if test "$host_cpu" = ia64; then -+ symcode='[[ABCDGIRSTW]]' -+ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" -+ lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -+ fi -+ ;; -+irix* | nonstopux*) -+ symcode='[[BCDEGRST]]' -+ ;; -+osf*) -+ symcode='[[BCDEGQRST]]' -+ ;; -+solaris* | sysv5*) -+ symcode='[[BDRT]]' -+ ;; -+sysv4) -+ symcode='[[DFNSTU]]' -+ ;; -+esac -+ -+# Handle CRLF in mingw tool chain -+opt_cr= -+case $build_os in -+mingw*) -+ opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp -+ ;; -+esac -+ -+# If we're using GNU nm, then use its standard symbol codes. -+case `$NM -V 2>&1` in -+*GNU* | *'with BFD'*) -+ symcode='[[ABCDGIRSTW]]' ;; -+esac -+ -+# Try without a prefix undercore, then with it. -+for ac_symprfx in "" "_"; do -+ -+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. -+ symxfrm="\\1 $ac_symprfx\\2 \\2" -+ -+ # Write the raw and C identifiers. -+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" -+ -+ # Check to see that the pipe works correctly. -+ pipe_works=no -+ -+ rm -f conftest* -+ cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then -+ # Try sorting and uniquifying the output. -+ if sort "$nlist" | uniq > "$nlist"T; then -+ mv -f "$nlist"T "$nlist" -+ else -+ rm -f "$nlist"T -+ fi -+ -+ # Make sure that we snagged all the symbols we need. -+ if grep ' nm_test_var$' "$nlist" >/dev/null; then -+ if grep ' nm_test_func$' "$nlist" >/dev/null; then -+ cat < conftest.$ac_ext -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+EOF -+ # Now generate the symbol file. -+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' -+ -+ cat <> conftest.$ac_ext -+#if defined (__STDC__) && __STDC__ -+# define lt_ptr_t void * -+#else -+# define lt_ptr_t char * -+# define const -+#endif -+ -+/* The mapping between symbol names and symbols. */ -+const struct { -+ const char *name; -+ lt_ptr_t address; -+} -+lt_preloaded_symbols[[]] = -+{ -+EOF -+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext -+ cat <<\EOF >> conftest.$ac_ext -+ {0, (lt_ptr_t) 0} -+}; -+ -+#ifdef __cplusplus -+} -+#endif -+EOF -+ # Now try linking the two files. -+ mv conftest.$ac_objext conftstm.$ac_objext -+ lt_save_LIBS="$LIBS" -+ lt_save_CFLAGS="$CFLAGS" -+ LIBS="conftstm.$ac_objext" -+ CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" -+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then -+ pipe_works=yes -+ fi -+ LIBS="$lt_save_LIBS" -+ CFLAGS="$lt_save_CFLAGS" -+ else -+ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD -+ fi -+ else -+ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD -+ fi -+ else -+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD -+ fi -+ else -+ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD -+ cat conftest.$ac_ext >&5 -+ fi -+ rm -f conftest* conftst* -+ -+ # Do not use the global_symbol_pipe unless it works. -+ if test "$pipe_works" = yes; then -+ break -+ else -+ lt_cv_sys_global_symbol_pipe= -+ fi -+done -+]) -+if test -z "$lt_cv_sys_global_symbol_pipe"; then -+ lt_cv_sys_global_symbol_to_cdecl= -+fi -+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then -+ AC_MSG_RESULT(failed) -+else -+ AC_MSG_RESULT(ok) -+fi -+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -+ -+ -+# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) -+# --------------------------------------- -+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], -+[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= -+_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -+_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= -+ -+AC_MSG_CHECKING([for $compiler option to produce PIC]) -+ ifelse([$1],[CXX],[ -+ # C++ specific cases for pic, static, wl, etc. -+ if test "$GXX" = yes; then -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' -+ -+ case $host_os in -+ aix*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ fi -+ ;; -+ amigaos*) -+ # FIXME: we need at least 68020 code to build shared libraries, but -+ # adding the `-m68020' flag to GCC prevents building anything better, -+ # like `-m68040'. -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' -+ ;; -+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) -+ # PIC is the default for these OSes. -+ ;; -+ mingw* | os2* | pw32*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' -+ ;; -+ darwin* | rhapsody*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' -+ ;; -+ *djgpp*) -+ # DJGPP does not support shared libraries at all -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -+ ;; -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic -+ fi -+ ;; -+ hpux*) -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' -+ ;; -+ esac -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' -+ ;; -+ esac -+ else -+ case $host_os in -+ aix4* | aix5*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ else -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' -+ fi -+ ;; -+ chorus*) -+ case $cc_basename in -+ cxch68*) -+ # Green Hills C++ Compiler -+ # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" -+ ;; -+ esac -+ ;; -+ darwin*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ case $cc_basename in -+ xlc*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ ;; -+ esac -+ ;; -+ dgux*) -+ case $cc_basename in -+ ec++*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ ;; -+ ghcx*) -+ # Green Hills C++ Compiler -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ # FreeBSD uses GNU C++ -+ ;; -+ hpux9* | hpux10* | hpux11*) -+ case $cc_basename in -+ CC*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" -+ if test "$host_cpu" != ia64; then -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' -+ fi -+ ;; -+ aCC*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' -+ ;; -+ esac -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ irix5* | irix6* | nonstopux*) -+ case $cc_basename in -+ CC*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' -+ # CC pic flag -KPIC is the default. -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ linux*) -+ case $cc_basename in -+ KCC*) -+ # KAI C++ Compiler -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' -+ ;; -+ icpc* | ecpc*) -+ # Intel C++ -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' -+ ;; -+ pgCC*) -+ # Portland Group C++ compiler. -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ cxx*) -+ # Compaq C++ -+ # Make sure the PIC flag is empty. It appears that all Alpha -+ # Linux and Compaq Tru64 Unix objects are PIC. -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ lynxos*) -+ ;; -+ m88k*) -+ ;; -+ mvs*) -+ case $cc_basename in -+ cxx*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ ;; -+ osf3* | osf4* | osf5*) -+ case $cc_basename in -+ KCC*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' -+ ;; -+ RCC*) -+ # Rational C++ 2.4.1 -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' -+ ;; -+ cxx*) -+ # Digital/Compaq C++ -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ # Make sure the PIC flag is empty. It appears that all Alpha -+ # Linux and Compaq Tru64 Unix objects are PIC. -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ psos*) -+ ;; -+ sco*) -+ case $cc_basename in -+ CC*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ solaris*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.2, 5.x and Centerline C++ -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' -+ ;; -+ gcx*) -+ # Green Hills C++ Compiler -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ sunos4*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.x -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ lcc*) -+ # Lucid -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ tandem*) -+ case $cc_basename in -+ NCC*) -+ # NonStop-UX NCC 3.20 -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ unixware*) -+ ;; -+ vxworks*) -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no -+ ;; -+ esac -+ fi -+], -+[ -+ if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' -+ -+ case $host_os in -+ aix*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ fi -+ ;; -+ -+ amigaos*) -+ # FIXME: we need at least 68020 code to build shared libraries, but -+ # adding the `-m68020' flag to GCC prevents building anything better, -+ # like `-m68040'. -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' -+ ;; -+ -+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) -+ # PIC is the default for these OSes. -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' -+ ;; -+ -+ darwin* | rhapsody*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' -+ ;; -+ -+ msdosdjgpp*) -+ # Just because we use GCC doesn't mean we suddenly get shared libraries -+ # on systems that don't support them. -+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no -+ enable_shared=no -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic -+ fi -+ ;; -+ -+ hpux*) -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' -+ ;; -+ esac -+ ;; -+ -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' -+ ;; -+ esac -+ else -+ # PORTME Check for flag to pass linker flags through the system compiler. -+ case $host_os in -+ aix*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ else -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' -+ fi -+ ;; -+ darwin*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ case $cc_basename in -+ xlc*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ ;; -+ esac -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' -+ ;; -+ -+ hpux9* | hpux10* | hpux11*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' -+ ;; -+ esac -+ # Is there a better lt_prog_compiler_static that works with the bundled CC? -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ # PIC (with -KPIC) is the default. -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' -+ ;; -+ -+ newsos6) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ -+ linux*) -+ case $cc_basename in -+ icc* | ecc*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' -+ ;; -+ pgcc* | pgf77* | pgf90* | pgf95*) -+ # Portland Group compilers (*not* the Pentium gcc compiler, -+ # which looks to be a dead project) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ ccc*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ # All Alpha code is PIC. -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' -+ ;; -+ esac -+ ;; -+ -+ osf3* | osf4* | osf5*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ # All OSF/1 code is PIC. -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' -+ ;; -+ -+ sco3.2v5*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn' -+ ;; -+ -+ solaris*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ case $cc_basename in -+ f77* | f90* | f95*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; -+ esac -+ ;; -+ -+ sunos4*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ -+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec ;then -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ fi -+ ;; -+ -+ unicos*) -+ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' -+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no -+ ;; -+ -+ uts4*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' -+ _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' -+ ;; -+ -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no -+ ;; -+ esac -+ fi -+]) -+AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) -+ -+# -+# Check to make sure the PIC flag actually works. -+# -+if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then -+ AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], -+ _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), -+ [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], -+ [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in -+ "" | " "*) ;; -+ *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; -+ esac], -+ [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -+ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -+fi -+case $host_os in -+ # For platforms which do not support PIC, -DPIC is meaningless: -+ *djgpp*) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -+ ;; -+ *) -+ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" -+ ;; -+esac -+]) -+ -+ -+# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) -+# ------------------------------------ -+# See if the linker supports building shared libraries. -+AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], -+[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -+ifelse([$1],[CXX],[ -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ case $host_os in -+ aix4* | aix5*) -+ # If we're using GNU nm, then we don't want the "-C" option. -+ # -C means demangle to AIX nm, but means don't demangle with GNU nm -+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' -+ else -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' -+ fi -+ ;; -+ pw32*) -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" -+ ;; -+ cygwin* | mingw*) -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' -+ ;; -+ linux*) -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=no -+ ;; -+ *) -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ ;; -+ esac -+],[ -+ runpath_var= -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)= -+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no -+ _LT_AC_TAGVAR(archive_cmds, $1)= -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)= -+ _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= -+ _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -+ _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=no -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown -+ _LT_AC_TAGVAR(hardcode_automatic, $1)=no -+ _LT_AC_TAGVAR(module_cmds, $1)= -+ _LT_AC_TAGVAR(module_expsym_cmds, $1)= -+ _LT_AC_TAGVAR(always_export_symbols, $1)=no -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ # include_expsyms should be a list of space-separated symbols to be *always* -+ # included in the symbol list -+ _LT_AC_TAGVAR(include_expsyms, $1)= -+ # exclude_expsyms can be an extended regexp of symbols to exclude -+ # it will be wrapped by ` (' and `)$', so one must not match beginning or -+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -+ # as well as any symbol that contains `d'. -+ _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" -+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -+ # platforms (ab)use it in PIC code, but their linkers get confused if -+ # the symbol is explicitly referenced. Since portable code cannot -+ # rely on this symbol name, it's probably fine to never include it in -+ # preloaded symbol tables. -+ extract_expsyms_cmds= -+ # Just being paranoid about ensuring that cc_basename is set. -+ _LT_CC_BASENAME([$compiler]) -+ case $host_os in -+ cygwin* | mingw* | pw32*) -+ # FIXME: the MSVC++ port hasn't been tested in a loooong time -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ if test "$GCC" != yes; then -+ with_gnu_ld=no -+ fi -+ ;; -+ openbsd*) -+ with_gnu_ld=no -+ ;; -+ esac -+ -+ _LT_AC_TAGVAR(ld_shlibs, $1)=yes -+ if test "$with_gnu_ld" = yes; then -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ wlarc='${wl}' -+ -+ # Set some defaults for GNU ld with shared library support. These -+ # are reset later if shared libraries are not supported. Putting them -+ # here allows them to be overridden if necessary. -+ runpath_var=LD_RUN_PATH -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -+ fi -+ supports_anon_versioning=no -+ case `$LD -v 2>/dev/null` in -+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 -+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... -+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... -+ *\ 2.11.*) ;; # other 2.11 versions -+ *) supports_anon_versioning=yes ;; -+ esac -+ -+ # See if GNU ld supports shared libraries. -+ case $host_os in -+ aix3* | aix4* | aix5*) -+ # On AIX/PPC, the GNU linker is very broken -+ if test "$host_cpu" != ia64; then -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ cat <&2 -+ -+*** Warning: the GNU linker, at least up to release 2.9.1, is reported -+*** to be unable to reliably create shared libraries on AIX. -+*** Therefore, libtool is disabling shared libraries support. If you -+*** really care for shared libraries, you may want to modify your PATH -+*** so that a non-GNU linker is found, and then restart. -+ -+EOF -+ fi -+ ;; -+ -+ amigaos*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ -+ # Samuel A. Falvo II reports -+ # that the semantics of dynamic libraries on AmigaOS, at least up -+ # to version 4, is to share data among multiple programs linked -+ # with the same dynamic library. Since this doesn't match the -+ # behavior of shared libraries on other platforms, we can't use -+ # them. -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ -+ beos*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported -+ # Joseph Beckenbach says some releases of gcc -+ # support --undefined. This deserves some investigation. FIXME -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ else -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, -+ # as there is no search path for DLLs. -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported -+ _LT_AC_TAGVAR(always_export_symbols, $1)=no -+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' -+ -+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ # If the export-symbols file already is a .def file (1st line -+ # is EXPORTS), use it as is; otherwise, prepend... -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then -+ cp $export_symbols $output_objdir/$soname.def; -+ else -+ echo EXPORTS > $output_objdir/$soname.def; -+ cat $export_symbols >> $output_objdir/$soname.def; -+ fi~ -+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ else -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ -+ linux*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ tmp_addflag= -+ case $cc_basename,$host_cpu in -+ pgcc*) # Portland Group C compiler -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag' -+ ;; -+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag -Mnomain' ;; -+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 -+ tmp_addflag=' -i_dynamic' ;; -+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 -+ tmp_addflag=' -i_dynamic -nofor_main' ;; -+ ifc* | ifort*) # Intel Fortran compiler -+ tmp_addflag=' -nofor_main' ;; -+ esac -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ -+ if test $supports_anon_versioning = yes; then -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ -+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ -+ $echo "local: *; };" >> $output_objdir/$libname.ver~ -+ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' -+ fi -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=no -+ else -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' -+ wlarc= -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ fi -+ ;; -+ -+ solaris* | sysv5*) -+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ cat <&2 -+ -+*** Warning: The releases 2.8.* of the GNU linker cannot reliably -+*** create shared libraries on Solaris systems. Therefore, libtool -+*** is disabling shared libraries support. We urge you to upgrade GNU -+*** binutils to release 2.9.1 or newer. Another option is to modify -+*** your PATH or compiler configuration so that the native linker is -+*** used, and then restart. -+ -+EOF -+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ -+ sunos4*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ wlarc= -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ *) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ fi -+ ;; -+ esac -+ -+ if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then -+ runpath_var= -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -+ fi -+ else -+ # PORTME fill in a description of your system's linker (not GNU ld) -+ case $host_os in -+ aix3*) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported -+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' -+ # Note: this linker hardcodes the directories in LIBPATH if there -+ # are no directories specified by -L. -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ if test "$GCC" = yes && test -z "$link_static_flag"; then -+ # Neither direct hardcoding nor static linking is supported with a -+ # broken collect2. -+ _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported -+ fi -+ ;; -+ -+ aix4* | aix5*) -+ if test "$host_cpu" = ia64; then -+ # On IA64, the linker does run time linking by default, so we don't -+ # have to do anything special. -+ aix_use_runtimelinking=no -+ exp_sym_flag='-Bexport' -+ no_entry_flag="" -+ else -+ # If we're using GNU nm, then we don't want the "-C" option. -+ # -C means demangle to AIX nm, but means don't demangle with GNU nm -+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' -+ else -+ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' -+ fi -+ aix_use_runtimelinking=no -+ -+ # Test if we are trying to use run time linking or normal -+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we -+ # need to do runtime linking. -+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) -+ for ld_flag in $LDFLAGS; do -+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then -+ aix_use_runtimelinking=yes -+ break -+ fi -+ done -+ esac -+ -+ exp_sym_flag='-bexport' -+ no_entry_flag='-bnoentry' -+ fi -+ -+ # When large executables or shared objects are built, AIX ld can -+ # have problems creating the table of contents. If linking a library -+ # or program results in "error TOC overflow" add -mminimal-toc to -+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -+ -+ _LT_AC_TAGVAR(archive_cmds, $1)='' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ -+ if test "$GCC" = yes; then -+ case $host_os in aix4.[[012]]|aix4.[[012]].*) -+ # We only want to do this on AIX 4.2 and lower, the check -+ # below for broken collect2 doesn't work under 4.3+ -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ else -+ # We have old collect2 -+ _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -+ fi -+ esac -+ shared_flag='-shared' -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag="$shared_flag "'${wl}-G' -+ fi -+ else -+ # not using gcc -+ if test "$host_cpu" = ia64; then -+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release -+ # chokes on -Wl,-G. The following line is correct: -+ shared_flag='-G' -+ else -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag='${wl}-G' -+ else -+ shared_flag='${wl}-bM:SRE' -+ fi -+ fi -+ fi -+ -+ # It seems that -bexpall does not export symbols beginning with -+ # underscore (_), so it is better to generate a list of symbols to export. -+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes -+ if test "$aix_use_runtimelinking" = yes; then -+ # Warning - without using the other runtime loading flags (-brtl), -+ # -berok will link without error, but may produce a broken library. -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' -+ # Determine the default libpath from the value encoded in an empty executable. -+ _LT_AC_SYS_LIBPATH_AIX -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -+ else -+ if test "$host_cpu" = ia64; then -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -+ else -+ # Determine the default libpath from the value encoded in an empty executable. -+ _LT_AC_SYS_LIBPATH_AIX -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" -+ # Warning - without using the other run time loading flags, -+ # -berok will link without error, but may produce a broken library. -+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' -+ # -bexpall does not export symbols beginning with underscore (_) -+ _LT_AC_TAGVAR(always_export_symbols, $1)=yes -+ # Exported symbols can be pulled into shared objects from archives -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes -+ # This is similar to how AIX traditionally builds its shared libraries. -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' -+ fi -+ fi -+ ;; -+ -+ amigaos*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ # see comment about different semantics on the GNU ld section -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ -+ bsdi[[45]]*) -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ # hardcode_libdir_flag_spec is actually meaningless, as there is -+ # no search path for DLLs. -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported -+ # Tell ltmain to make .lib files, not .a files. -+ libext=lib -+ # Tell ltmain to make .dll files, not .so files. -+ shrext_cmds=".dll" -+ # FIXME: Setting linknames here is a bad hack. -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' -+ # The linker will automatically build a .lib file if we build a DLL. -+ _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' -+ # FIXME: Should let the user specify the lib program. -+ _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' -+ _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' -+ _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes -+ ;; -+ -+ darwin* | rhapsody*) -+ case $host_os in -+ rhapsody* | darwin1.[[012]]) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' -+ ;; -+ *) # Darwin 1.3 on -+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ else -+ case ${MACOSX_DEPLOYMENT_TARGET} in -+ 10.[[012]]) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ ;; -+ 10.*) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' -+ ;; -+ esac -+ fi -+ ;; -+ esac -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_automatic, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ if test "$GCC" = yes ; then -+ output_verbose_link_cmd='echo' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ case $cc_basename in -+ xlc*) -+ output_verbose_link_cmd='echo' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' -+ _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ ;; -+ *) -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ fi -+ ;; -+ -+ dgux*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ freebsd1*) -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ -+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -+ # support. Future versions do this automatically, but an explicit c++rt0.o -+ # does not break anything, and helps significantly (at the cost of a little -+ # extra space). -+ freebsd2.2*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ # Unfortunately, older versions of FreeBSD 2 do not have this feature. -+ freebsd2*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ hpux9*) -+ if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' -+ ;; -+ -+ hpux10* | hpux11*) -+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*|ia64*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ *) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ esac -+ else -+ case $host_cpu in -+ hppa*64*|ia64*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ *) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ esac -+ fi -+ if test "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ ia64*) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ ;; -+ *) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ ;; -+ esac -+ fi -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ newsos6) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ openbsd*) -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' -+ else -+ case $host_os in -+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ ;; -+ *) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' -+ ;; -+ esac -+ fi -+ ;; -+ -+ os2*) -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported -+ _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' -+ _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' -+ ;; -+ -+ osf3*) -+ if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ ;; -+ -+ osf4* | osf5*) # as osf3* with the addition of -msym flag -+ if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' -+ else -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ -+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' -+ -+ # Both c and cxx compiler support -rpath directly -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: -+ ;; -+ -+ sco3.2v5*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ;; -+ -+ solaris*) -+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' -+ if test "$GCC" = yes; then -+ wlarc='${wl}' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' -+ else -+ wlarc='' -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ case $host_os in -+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; -+ *) -+ # The compiler driver will combine linker options so we -+ # cannot just pass the convience library names through -+ # without $wl, iff we do not link with $LD. -+ # Luckily, gcc supports the same syntax we need for Sun Studio. -+ # Supported since Solaris 2.6 (maybe 2.5.1?) -+ case $wlarc in -+ '') -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; -+ *) -+ _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; -+ esac ;; -+ esac -+ _LT_AC_TAGVAR(link_all_deplibs, $1)=yes -+ ;; -+ -+ sunos4*) -+ if test "x$host_vendor" = xsequent; then -+ # Use $CC to link under sequent, because it throws in some extra .o -+ # files that make .init and .fini sections work. -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' -+ fi -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ sysv4) -+ case $host_vendor in -+ sni) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? -+ ;; -+ siemens) -+ ## LD is ld it makes a PLAMLIB -+ ## CC just makes a GrossModule. -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no -+ ;; -+ motorola) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie -+ ;; -+ esac -+ runpath_var='LD_RUN_PATH' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ sysv4.3*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ _LT_AC_TAGVAR(ld_shlibs, $1)=yes -+ fi -+ ;; -+ -+ sysv4.2uw2*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_direct, $1)=yes -+ _LT_AC_TAGVAR(hardcode_minus_L, $1)=no -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ hardcode_runpath_var=yes -+ runpath_var=LD_RUN_PATH -+ ;; -+ -+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) -+ _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text' -+ if test "$GCC" = yes; then -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ fi -+ runpath_var='LD_RUN_PATH' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ sysv5*) -+ _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' -+ # $CC -shared without GNU ld will not create a library from C++ -+ # object files and a static libstdc++, better avoid it by now -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ runpath_var='LD_RUN_PATH' -+ ;; -+ -+ uts4*) -+ _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' -+ _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no -+ ;; -+ -+ *) -+ _LT_AC_TAGVAR(ld_shlibs, $1)=no -+ ;; -+ esac -+ fi -+]) -+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no -+ -+variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -+if test "$GCC" = yes; then -+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -+fi -+ -+# -+# Do we need to explicitly link libc? -+# -+case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in -+x|xyes) -+ # Assume -lc should be added -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes -+ -+ if test "$enable_shared" = yes && test "$GCC" = yes; then -+ case $_LT_AC_TAGVAR(archive_cmds, $1) in -+ *'~'*) -+ # FIXME: we may have to deal with multi-command sequences. -+ ;; -+ '$CC '*) -+ # Test whether the compiler implicitly links with -lc since on some -+ # systems, -lgcc has to come before -lc. If gcc already passes -lc -+ # to ld, don't add -lc before -lgcc. -+ AC_MSG_CHECKING([whether -lc should be explicitly linked in]) -+ $rm conftest* -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then -+ soname=conftest -+ lib=conftest -+ libobjs=conftest.$ac_objext -+ deplibs= -+ wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) -+ compiler_flags=-v -+ linker_flags=-v -+ verstring= -+ output_objdir=. -+ libname=conftest -+ lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)= -+ if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) -+ then -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -+ else -+ _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes -+ fi -+ _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag -+ else -+ cat conftest.err 1>&5 -+ fi -+ $rm conftest* -+ AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) -+ ;; -+ esac -+ fi -+ ;; -+esac -+])# AC_LIBTOOL_PROG_LD_SHLIBS -+ -+ -+# _LT_AC_FILE_LTDLL_C -+# ------------------- -+# Be careful that the start marker always follows a newline. -+AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ -+# /* ltdll.c starts here */ -+# #define WIN32_LEAN_AND_MEAN -+# #include -+# #undef WIN32_LEAN_AND_MEAN -+# #include -+# -+# #ifndef __CYGWIN__ -+# # ifdef __CYGWIN32__ -+# # define __CYGWIN__ __CYGWIN32__ -+# # endif -+# #endif -+# -+# #ifdef __cplusplus -+# extern "C" { -+# #endif -+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -+# #ifdef __cplusplus -+# } -+# #endif -+# -+# #ifdef __CYGWIN__ -+# #include -+# DECLARE_CYGWIN_DLL( DllMain ); -+# #endif -+# HINSTANCE __hDllInstance_base; -+# -+# BOOL APIENTRY -+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -+# { -+# __hDllInstance_base = hInst; -+# return TRUE; -+# } -+# /* ltdll.c ends here */ -+])# _LT_AC_FILE_LTDLL_C -+ -+ -+# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) -+# --------------------------------- -+AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) -+ -+ -+# old names -+AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) -+AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -+AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -+AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) -+AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) -+AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) -+AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) -+ -+# This is just to silence aclocal about the macro not being used -+ifelse([AC_DISABLE_FAST_INSTALL]) -+ -+AC_DEFUN([LT_AC_PROG_GCJ], -+[AC_CHECK_TOOL(GCJ, gcj, no) -+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" -+ AC_SUBST(GCJFLAGS) -+]) -+ -+AC_DEFUN([LT_AC_PROG_RC], -+[AC_CHECK_TOOL(RC, windres, no) -+]) -+ -+# NOTE: This macro has been submitted for inclusion into # -+# GNU Autoconf as AC_PROG_SED. When it is available in # -+# a released version of Autoconf we should remove this # -+# macro and use it instead. # -+# LT_AC_PROG_SED -+# -------------- -+# Check for a fully-functional sed program, that truncates -+# as few characters as possible. Prefer GNU sed if found. -+AC_DEFUN([LT_AC_PROG_SED], -+[AC_MSG_CHECKING([for a sed that does not truncate output]) -+AC_CACHE_VAL(lt_cv_path_SED, -+[# Loop through the user's path and test for sed and gsed. -+# Then use that list of sed's as ones to test for truncation. -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for lt_ac_prog in sed gsed; do -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then -+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" -+ fi -+ done -+ done -+done -+lt_ac_max=0 -+lt_ac_count=0 -+# Add /usr/xpg4/bin/sed as it is typically found on Solaris -+# along with /bin/sed that truncates output. -+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do -+ test ! -f $lt_ac_sed && continue -+ cat /dev/null > conftest.in -+ lt_ac_count=0 -+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in -+ # Check for GNU sed and select it if it is found. -+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then -+ lt_cv_path_SED=$lt_ac_sed -+ break -+ fi -+ while true; do -+ cat conftest.in conftest.in >conftest.tmp -+ mv conftest.tmp conftest.in -+ cp conftest.in conftest.nl -+ echo >>conftest.nl -+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break -+ cmp -s conftest.out conftest.nl || break -+ # 10000 chars as input seems more than enough -+ test $lt_ac_count -gt 10 && break -+ lt_ac_count=`expr $lt_ac_count + 1` -+ if test $lt_ac_count -gt $lt_ac_max; then -+ lt_ac_max=$lt_ac_count -+ lt_cv_path_SED=$lt_ac_sed -+ fi -+ done -+done -+]) -+SED=$lt_cv_path_SED -+AC_MSG_RESULT([$SED]) -+]) -+ -+# longdouble.m4 serial 1 (gettext-0.12) -+dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Bruno Haible. -+dnl Test whether the compiler supports the 'long double' type. -+dnl Prerequisite: AC_PROG_CC -+ -+AC_DEFUN([gt_TYPE_LONGDOUBLE], -+[ -+ AC_CACHE_CHECK([for long double], gt_cv_c_long_double, -+ [if test "$GCC" = yes; then -+ gt_cv_c_long_double=yes -+ else -+ AC_TRY_COMPILE([ -+ /* The Stardent Vistra knows sizeof(long double), but does not support it. */ -+ long double foo = 0.0; -+ /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ -+ int array [2*(sizeof(long double) >= sizeof(double)) - 1]; -+ ], , -+ gt_cv_c_long_double=yes, gt_cv_c_long_double=no) -+ fi]) -+ if test $gt_cv_c_long_double = yes; then -+ AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' type.]) -+ fi -+]) -+ -+# longlong.m4 serial 5 -+dnl Copyright (C) 1999-2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Paul Eggert. -+ -+# Define HAVE_LONG_LONG if 'long long' works. -+ -+AC_DEFUN([gl_AC_TYPE_LONG_LONG], -+[ -+ AC_CACHE_CHECK([for long long], ac_cv_type_long_long, -+ [AC_TRY_LINK([long long ll = 1LL; int i = 63;], -+ [long long llmax = (long long) -1; -+ return ll << i | ll >> i | llmax / ll | llmax % ll;], -+ ac_cv_type_long_long=yes, -+ ac_cv_type_long_long=no)]) -+ if test $ac_cv_type_long_long = yes; then -+ AC_DEFINE(HAVE_LONG_LONG, 1, -+ [Define if you have the 'long long' type.]) -+ fi -+]) -+ -+# nls.m4 serial 2 (gettext-0.14.3) -+dnl Copyright (C) 1995-2003, 2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+dnl -+dnl This file can can be used in projects which are not available under -+dnl the GNU General Public License or the GNU Library General Public -+dnl License but which still want to provide support for the GNU gettext -+dnl functionality. -+dnl Please note that the actual code of the GNU gettext library is covered -+dnl by the GNU Library General Public License, and the rest of the GNU -+dnl gettext package package is covered by the GNU General Public License. -+dnl They are *not* in the public domain. -+ -+dnl Authors: -+dnl Ulrich Drepper , 1995-2000. -+dnl Bruno Haible , 2000-2003. -+ -+AC_PREREQ(2.50) -+ -+AC_DEFUN([AM_NLS], -+[ -+ AC_MSG_CHECKING([whether NLS is requested]) -+ dnl Default is enabled NLS -+ AC_ARG_ENABLE(nls, -+ [ --disable-nls do not use Native Language Support], -+ USE_NLS=$enableval, USE_NLS=yes) -+ AC_MSG_RESULT($USE_NLS) -+ AC_SUBST(USE_NLS) -+]) -+ -+AC_DEFUN([AM_MKINSTALLDIRS], -+[ -+ dnl Tell automake >= 1.10 to complain if mkinstalldirs is missing. -+ m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([mkinstalldirs])]) -+ dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly -+ dnl find the mkinstalldirs script in another subdir but $(top_srcdir). -+ dnl Try to locate it. -+ MKINSTALLDIRS= -+ if test -n "$ac_aux_dir"; then -+ case "$ac_aux_dir" in -+ /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; -+ *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; -+ esac -+ fi -+ if test -z "$MKINSTALLDIRS"; then -+ MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" -+ fi -+ AC_SUBST(MKINSTALLDIRS) -+]) -+ -+# po.m4 serial 7 (gettext-0.14.3) -+dnl Copyright (C) 1995-2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+dnl -+dnl This file can can be used in projects which are not available under -+dnl the GNU General Public License or the GNU Library General Public -+dnl License but which still want to provide support for the GNU gettext -+dnl functionality. -+dnl Please note that the actual code of the GNU gettext library is covered -+dnl by the GNU Library General Public License, and the rest of the GNU -+dnl gettext package package is covered by the GNU General Public License. -+dnl They are *not* in the public domain. -+ -+dnl Authors: -+dnl Ulrich Drepper , 1995-2000. -+dnl Bruno Haible , 2000-2003. -+ -+AC_PREREQ(2.50) -+ -+dnl Checks for all prerequisites of the po subdirectory. -+AC_DEFUN([AM_PO_SUBDIRS], -+[ -+ AC_REQUIRE([AC_PROG_MAKE_SET])dnl -+ AC_REQUIRE([AC_PROG_INSTALL])dnl -+ AC_REQUIRE([AM_MKINSTALLDIRS])dnl -+ AC_REQUIRE([AM_NLS])dnl -+ -+ dnl Perform the following tests also if --disable-nls has been given, -+ dnl because they are needed for "make dist" to work. -+ -+ dnl Search for GNU msgfmt in the PATH. -+ dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. -+ dnl The second test excludes FreeBSD msgfmt. -+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, -+ [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && -+ (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], -+ :) -+ AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) -+ -+ dnl Search for GNU xgettext 0.12 or newer in the PATH. -+ dnl The first test excludes Solaris xgettext and early GNU xgettext versions. -+ dnl The second test excludes FreeBSD xgettext. -+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, -+ [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && -+ (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], -+ :) -+ dnl Remove leftover from FreeBSD xgettext call. -+ rm -f messages.po -+ -+ dnl Search for GNU msgmerge 0.11 or newer in the PATH. -+ AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, -+ [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) -+ -+ dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. -+ dnl Test whether we really found GNU msgfmt. -+ if test "$GMSGFMT" != ":"; then -+ dnl If it is no GNU msgfmt we define it as : so that the -+ dnl Makefiles still can work. -+ if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && -+ (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -+ : ; -+ else -+ GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` -+ AC_MSG_RESULT( -+ [found $GMSGFMT program is not GNU msgfmt; ignore it]) -+ GMSGFMT=":" -+ fi -+ fi -+ -+ dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. -+ dnl Test whether we really found GNU xgettext. -+ if test "$XGETTEXT" != ":"; then -+ dnl If it is no GNU xgettext we define it as : so that the -+ dnl Makefiles still can work. -+ if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && -+ (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -+ : ; -+ else -+ AC_MSG_RESULT( -+ [found xgettext program is not GNU xgettext; ignore it]) -+ XGETTEXT=":" -+ fi -+ dnl Remove leftover from FreeBSD xgettext call. -+ rm -f messages.po -+ fi -+ -+ AC_OUTPUT_COMMANDS([ -+ for ac_file in $CONFIG_FILES; do -+ # Support "outfile[:infile[:infile...]]" -+ case "$ac_file" in -+ *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; -+ esac -+ # PO directories have a Makefile.in generated from Makefile.in.in. -+ case "$ac_file" in */Makefile.in) -+ # Adjust a relative srcdir. -+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` -+ ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" -+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` -+ # In autoconf-2.13 it is called $ac_given_srcdir. -+ # In autoconf-2.50 it is called $srcdir. -+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" -+ case "$ac_given_srcdir" in -+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; -+ /*) top_srcdir="$ac_given_srcdir" ;; -+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;; -+ esac -+ # Treat a directory as a PO directory if and only if it has a -+ # POTFILES.in file. This allows packages to have multiple PO -+ # directories under different names or in different locations. -+ if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then -+ rm -f "$ac_dir/POTFILES" -+ test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" -+ cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" -+ POMAKEFILEDEPS="POTFILES.in" -+ # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend -+ # on $ac_dir but don't depend on user-specified configuration -+ # parameters. -+ if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then -+ # The LINGUAS file contains the set of available languages. -+ if test -n "$OBSOLETE_ALL_LINGUAS"; then -+ test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" -+ fi -+ ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` -+ # Hide the ALL_LINGUAS assigment from automake. -+ eval 'ALL_LINGUAS''=$ALL_LINGUAS_' -+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" -+ else -+ # The set of available languages was given in configure.in. -+ eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' -+ fi -+ # Compute POFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) -+ # Compute UPDATEPOFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) -+ # Compute DUMMYPOFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) -+ # Compute GMOFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) -+ case "$ac_given_srcdir" in -+ .) srcdirpre= ;; -+ *) srcdirpre='$(srcdir)/' ;; -+ esac -+ POFILES= -+ UPDATEPOFILES= -+ DUMMYPOFILES= -+ GMOFILES= -+ for lang in $ALL_LINGUAS; do -+ POFILES="$POFILES $srcdirpre$lang.po" -+ UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" -+ DUMMYPOFILES="$DUMMYPOFILES $lang.nop" -+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo" -+ done -+ # CATALOGS depends on both $ac_dir and the user's LINGUAS -+ # environment variable. -+ INST_LINGUAS= -+ if test -n "$ALL_LINGUAS"; then -+ for presentlang in $ALL_LINGUAS; do -+ useit=no -+ if test "%UNSET%" != "$LINGUAS"; then -+ desiredlanguages="$LINGUAS" -+ else -+ desiredlanguages="$ALL_LINGUAS" -+ fi -+ for desiredlang in $desiredlanguages; do -+ # Use the presentlang catalog if desiredlang is -+ # a. equal to presentlang, or -+ # b. a variant of presentlang (because in this case, -+ # presentlang can be used as a fallback for messages -+ # which are not translated in the desiredlang catalog). -+ case "$desiredlang" in -+ "$presentlang"*) useit=yes;; -+ esac -+ done -+ if test $useit = yes; then -+ INST_LINGUAS="$INST_LINGUAS $presentlang" -+ fi -+ done -+ fi -+ CATALOGS= -+ if test -n "$INST_LINGUAS"; then -+ for lang in $INST_LINGUAS; do -+ CATALOGS="$CATALOGS $lang.gmo" -+ done - fi -+ test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" -+ sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" -+ for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do -+ if test -f "$f"; then -+ case "$f" in -+ *.orig | *.bak | *~) ;; -+ *) cat "$f" >> "$ac_dir/Makefile" ;; -+ esac -+ fi -+ done - fi -- fi -- done -+ ;; -+ esac -+ done], -+ [# Capture the value of obsolete ALL_LINGUAS because we need it to compute -+ # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it -+ # from automake. -+ eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' -+ # Capture the value of LINGUAS because we need it to compute CATALOGS. -+ LINGUAS="${LINGUAS-%UNSET%}" -+ ]) -+]) -+ -+dnl Postprocesses a Makefile in a directory containing PO files. -+AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], -+[ -+ # When this code is run, in config.status, two variables have already been -+ # set: -+ # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, -+ # - LINGUAS is the value of the environment variable LINGUAS at configure -+ # time. -+ -+changequote(,)dnl -+ # Adjust a relative srcdir. -+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` -+ ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" -+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` -+ # In autoconf-2.13 it is called $ac_given_srcdir. -+ # In autoconf-2.50 it is called $srcdir. -+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" -+ case "$ac_given_srcdir" in -+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; -+ /*) top_srcdir="$ac_given_srcdir" ;; -+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;; -+ esac -+ -+ # Find a way to echo strings without interpreting backslash. -+ if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then -+ gt_echo='echo' -+ else -+ if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then -+ gt_echo='printf %s\n' -+ else -+ echo_func () { -+ cat < "$ac_file.tmp" -+ if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then -+ # Add dependencies that cannot be formulated as a simple suffix rule. -+ for lang in $ALL_LINGUAS; do -+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` -+ cat >> "$ac_file.tmp" < /dev/null; then -+ # Add dependencies that cannot be formulated as a simple suffix rule. -+ for lang in $ALL_LINGUAS; do -+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` -+ cat >> "$ac_file.tmp" <> "$ac_file.tmp" < -+#include -+/* The string "%2$d %1$d", with dollar characters protected from the shell's -+ dollar expansion (possibly an autoconf bug). */ -+static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; -+static char buf[100]; -+int main () -+{ -+ sprintf (buf, format, 33, 55); -+ return (strcmp (buf, "55 33") != 0); -+}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, -+ [ -+ AC_EGREP_CPP(notposix, [ -+#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ -+ notposix -+#endif -+ ], gt_cv_func_printf_posix="guessing no", -+ gt_cv_func_printf_posix="guessing yes") -+ ]) -+ ]) -+ case $gt_cv_func_printf_posix in -+ *yes) -+ AC_DEFINE(HAVE_POSIX_PRINTF, 1, -+ [Define if your printf() function supports format strings with positions.]) -+ ;; -+ esac -+]) -+ -+# progtest.m4 serial 4 (gettext-0.14.2) -+dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+dnl -+dnl This file can can be used in projects which are not available under -+dnl the GNU General Public License or the GNU Library General Public -+dnl License but which still want to provide support for the GNU gettext -+dnl functionality. -+dnl Please note that the actual code of the GNU gettext library is covered -+dnl by the GNU Library General Public License, and the rest of the GNU -+dnl gettext package package is covered by the GNU General Public License. -+dnl They are *not* in the public domain. -+ -+dnl Authors: -+dnl Ulrich Drepper , 1996. -+ -+AC_PREREQ(2.50) -+ -+# Search path for a program which passes the given test. -+ -+dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, -+dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) -+AC_DEFUN([AM_PATH_PROG_WITH_TEST], -+[ -+# Prepare PATH_SEPARATOR. -+# The user is always right. -+if test "${PATH_SEPARATOR+set}" != set; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then -+ PATH_SEPARATOR=';' -+ else -+ PATH_SEPARATOR=: -+ fi -+ rm -f conf$$.sh -+fi -+ -+# Find out how to test for executable files. Don't use a zero-byte file, -+# as systems may use methods other than mode bits to determine executability. -+cat >conf$$.file <<_ASEOF -+#! /bin/sh -+exit 0 -+_ASEOF -+chmod +x conf$$.file -+if test -x conf$$.file >/dev/null 2>&1; then -+ ac_executable_p="test -x" -+else -+ ac_executable_p="test -f" -+fi -+rm -f conf$$.file -+ -+# Extract the first word of "$2", so it can be a program name with args. -+set dummy $2; ac_word=[$]2 -+AC_MSG_CHECKING([for $ac_word]) -+AC_CACHE_VAL(ac_cv_path_$1, -+[case "[$]$1" in -+ [[\\/]]* | ?:[[\\/]]*) -+ ac_cv_path_$1="[$]$1" # Let the user override the test with a path. -+ ;; -+ *) -+ ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in ifelse([$5], , $PATH, [$5]); do -+ IFS="$ac_save_IFS" -+ test -z "$ac_dir" && ac_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then -+ echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD -+ if [$3]; then -+ ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" -+ break 2 -+ fi -+ fi - done -- fi -- fi -- if test "X$ltrpathdirs" != "X"; then -- dnl When using libtool, the option that works for both libraries and -- dnl executables is -R. The -R options are cumulative. -- for found_dir in $ltrpathdirs; do -- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done -+ IFS="$ac_save_IFS" -+dnl If no 4th arg is given, leave the cache variable unset, -+dnl so AC_PATH_PROGS will keep looking. -+ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" -+])dnl -+ ;; -+esac])dnl -+$1="$ac_cv_path_$1" -+if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then -+ AC_MSG_RESULT([$]$1) -+else -+ AC_MSG_RESULT(no) -+fi -+AC_SUBST($1)dnl -+]) -+ -+# signed.m4 serial 1 (gettext-0.10.40) -+dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Bruno Haible. -+ -+AC_DEFUN([bh_C_SIGNED], -+[ -+ AC_CACHE_CHECK([for signed], bh_cv_c_signed, -+ [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)]) -+ if test $bh_cv_c_signed = no; then -+ AC_DEFINE(signed, , -+ [Define to empty if the C compiler doesn't support this keyword.]) - fi - ]) - --dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, --dnl unless already present in VAR. --dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes --dnl contains two or three consecutive elements that belong together. --AC_DEFUN([AC_LIB_APPENDTOVAR], -+# size_max.m4 serial 2 -+dnl Copyright (C) 2003 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Bruno Haible. -+ -+AC_DEFUN([gl_SIZE_MAX], - [ -- for element in [$2]; do -- haveit= -- for x in $[$1]; do -- AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) -- if test "X$x" = "X$element"; then -- haveit=yes -- break -+ AC_CHECK_HEADERS(stdint.h) -+ dnl First test whether the system already has SIZE_MAX. -+ AC_MSG_CHECKING([for SIZE_MAX]) -+ result= -+ AC_EGREP_CPP([Found it], [ -+#include -+#if HAVE_STDINT_H -+#include -+#endif -+#ifdef SIZE_MAX -+Found it -+#endif -+], result=yes) -+ if test -z "$result"; then -+ dnl Define it ourselves. Here we assume that the type 'size_t' is not wider -+ dnl than the type 'unsigned long'. -+ dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr', -+ dnl which is guaranteed to work from LONG_MIN to LONG_MAX. -+ _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi, -+ [#include ], result=?) -+ _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo, -+ [#include ], result=?) -+ _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint, -+ [#include ], result=?) -+ if test "$fits_in_uint" = 1; then -+ dnl Even though SIZE_MAX fits in an unsigned int, it must be of type -+ dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. -+ AC_TRY_COMPILE([#include -+ extern size_t foo; -+ extern unsigned long foo; -+ ], [], fits_in_uint=0) -+ fi -+ if test -z "$result"; then -+ if test "$fits_in_uint" = 1; then -+ result="$res_hi$res_lo"U -+ else -+ result="$res_hi$res_lo"UL - fi -- done -- if test -z "$haveit"; then -- [$1]="${[$1]}${[$1]:+ }$element" -+ else -+ dnl Shouldn't happen, but who knows... -+ result='~(size_t)0' - fi -- done -+ fi -+ AC_MSG_RESULT([$result]) -+ if test "$result" != yes; then -+ AC_DEFINE_UNQUOTED([SIZE_MAX], [$result], -+ [Define as the maximum value of type 'size_t', if the system doesn't define it.]) -+ fi - ]) - --# lib-ld.m4 serial 1 (gettext-0.11) --dnl Copyright (C) 1996-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# stdint_h.m4 serial 5 -+dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. - --dnl Subroutines of libtool.m4, --dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision --dnl with libtool.m4. -+dnl From Paul Eggert. - --dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. --AC_DEFUN([AC_LIB_PROG_LD_GNU], --[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, --[# I'd rather use --version here, but apparently some GNU ld's only accept -v. --if $LD -v 2>&1 &5; then -- acl_cv_prog_gnu_ld=yes --else -- acl_cv_prog_gnu_ld=no --fi]) --with_gnu_ld=$acl_cv_prog_gnu_ld -+# Define HAVE_STDINT_H_WITH_UINTMAX if exists, -+# doesn't clash with , and declares uintmax_t. -+ -+AC_DEFUN([gl_AC_HEADER_STDINT_H], -+[ -+ AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, -+ [AC_TRY_COMPILE( -+ [#include -+#include ], -+ [uintmax_t i = (uintmax_t) -1;], -+ gl_cv_header_stdint_h=yes, -+ gl_cv_header_stdint_h=no)]) -+ if test $gl_cv_header_stdint_h = yes; then -+ AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, -+ [Define if exists, doesn't clash with , -+ and declares uintmax_t. ]) -+ fi -+]) -+ -+# uintmax_t.m4 serial 9 -+dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Paul Eggert. -+ -+AC_PREREQ(2.13) -+ -+# Define uintmax_t to 'unsigned long' or 'unsigned long long' -+# if it is not already defined in or . -+ -+AC_DEFUN([gl_AC_TYPE_UINTMAX_T], -+[ -+ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) -+ AC_REQUIRE([gl_AC_HEADER_STDINT_H]) -+ if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then -+ AC_REQUIRE([gl_AC_TYPE_UNSIGNED_LONG_LONG]) -+ test $ac_cv_type_unsigned_long_long = yes \ -+ && ac_type='unsigned long long' \ -+ || ac_type='unsigned long' -+ AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, -+ [Define to unsigned long or unsigned long long -+ if and don't define.]) -+ else -+ AC_DEFINE(HAVE_UINTMAX_T, 1, -+ [Define if you have the 'uintmax_t' type in or .]) -+ fi -+]) -+ -+# ulonglong.m4 serial 4 -+dnl Copyright (C) 1999-2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Paul Eggert. -+ -+# Define HAVE_UNSIGNED_LONG_LONG if 'unsigned long long' works. -+ -+AC_DEFUN([gl_AC_TYPE_UNSIGNED_LONG_LONG], -+[ -+ AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, -+ [AC_TRY_LINK([unsigned long long ull = 1ULL; int i = 63;], -+ [unsigned long long ullmax = (unsigned long long) -1; -+ return ull << i | ull >> i | ullmax / ull | ullmax % ull;], -+ ac_cv_type_unsigned_long_long=yes, -+ ac_cv_type_unsigned_long_long=no)]) -+ if test $ac_cv_type_unsigned_long_long = yes; then -+ AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, -+ [Define if you have the 'unsigned long long' type.]) -+ fi -+]) -+ -+# wchar_t.m4 serial 1 (gettext-0.12) -+dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Bruno Haible. -+dnl Test whether has the 'wchar_t' type. -+dnl Prerequisite: AC_PROG_CC -+ -+AC_DEFUN([gt_TYPE_WCHAR_T], -+[ -+ AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, -+ [AC_TRY_COMPILE([#include -+ wchar_t foo = (wchar_t)'\0';], , -+ gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) -+ if test $gt_cv_c_wchar_t = yes; then -+ AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) -+ fi -+]) -+ -+# wint_t.m4 serial 1 (gettext-0.12) -+dnl Copyright (C) 2003 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Bruno Haible. -+dnl Test whether has the 'wint_t' type. -+dnl Prerequisite: AC_PROG_CC -+ -+AC_DEFUN([gt_TYPE_WINT_T], -+[ -+ AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t, -+ [AC_TRY_COMPILE([#include -+ wint_t foo = (wchar_t)'\0';], , -+ gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)]) -+ if test $gt_cv_c_wint_t = yes; then -+ AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.]) -+ fi -+]) -+ -+# xsize.m4 serial 3 -+dnl Copyright (C) 2003-2004 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+AC_DEFUN([gl_XSIZE], -+[ -+ dnl Prerequisites of lib/xsize.h. -+ AC_REQUIRE([gl_SIZE_MAX]) -+ AC_REQUIRE([AC_C_INLINE]) -+ AC_CHECK_HEADERS(stdint.h) -+]) -+ -+# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# AM_AUTOMAKE_VERSION(VERSION) -+# ---------------------------- -+# Automake X.Y traces this macro to ensure aclocal.m4 has been -+# generated from the m4 files accompanying Automake X.Y. -+AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) -+ -+# AM_SET_CURRENT_AUTOMAKE_VERSION -+# ------------------------------- -+# Call AM_AUTOMAKE_VERSION so it can be traced. -+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. -+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -+ [AM_AUTOMAKE_VERSION([1.9.6])]) -+ -+# AM_AUX_DIR_EXPAND -*- Autoconf -*- -+ -+# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -+# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -+# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -+# -+# Of course, Automake must honor this variable whenever it calls a -+# tool from the auxiliary directory. The problem is that $srcdir (and -+# therefore $ac_aux_dir as well) can be either absolute or relative, -+# depending on how configure is run. This is pretty annoying, since -+# it makes $ac_aux_dir quite unusable in subdirectories: in the top -+# source directory, any form will work fine, but in subdirectories a -+# relative path needs to be adjusted first. -+# -+# $ac_aux_dir/missing -+# fails when called from a subdirectory if $ac_aux_dir is relative -+# $top_srcdir/$ac_aux_dir/missing -+# fails if $ac_aux_dir is absolute, -+# fails when called from a subdirectory in a VPATH build with -+# a relative $ac_aux_dir -+# -+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -+# are both prefixed by $srcdir. In an in-source build this is usually -+# harmless because $srcdir is `.', but things will broke when you -+# start a VPATH build or use an absolute $srcdir. -+# -+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -+# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -+# and then we would define $MISSING as -+# MISSING="\${SHELL} $am_aux_dir/missing" -+# This will work as long as MISSING is not called from configure, because -+# unfortunately $(top_srcdir) has no meaning in configure. -+# However there are other variables, like CC, which are often used in -+# configure, and could therefore not use this "fixed" $ac_aux_dir. -+# -+# Another solution, used here, is to always expand $ac_aux_dir to an -+# absolute PATH. The drawback is that using absolute paths prevent a -+# configured tree to be moved without reconfiguration. -+ -+AC_DEFUN([AM_AUX_DIR_EXPAND], -+[dnl Rely on autoconf to set up CDPATH properly. -+AC_PREREQ([2.50])dnl -+# expand $ac_aux_dir to an absolute path -+am_aux_dir=`cd $ac_aux_dir && pwd` - ]) - --dnl From libtool-1.4. Sets the variable LD. --AC_DEFUN([AC_LIB_PROG_LD], --[AC_ARG_WITH(gnu-ld, --[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], --test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) --AC_REQUIRE([AC_PROG_CC])dnl --AC_REQUIRE([AC_CANONICAL_HOST])dnl --ac_prog=ld --if test "$GCC" = yes; then -- # Check if gcc -print-prog-name=ld gives a path. -- AC_MSG_CHECKING([for ld used by GCC]) -- case $host in -- *-*-mingw*) -- # gcc leaves a trailing carriage return which upsets mingw -- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; -- *) -- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; -- esac -- case $ac_prog in -- # Accept absolute paths. -- [[\\/]* | [A-Za-z]:[\\/]*)] -- [re_direlt='/[^/][^/]*/\.\./'] -- # Canonicalize the path of ld -- ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` -- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -- ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` -- done -- test -z "$LD" && LD="$ac_prog" -- ;; -- "") -- # If it fails, then pretend we aren't using GCC. -- ac_prog=ld -- ;; -- *) -- # If it is relative, then search for the first ld in PATH. -- with_gnu_ld=unknown -- ;; -- esac --elif test "$with_gnu_ld" = yes; then -- AC_MSG_CHECKING([for GNU ld]) --else -- AC_MSG_CHECKING([for non-GNU ld]) --fi --AC_CACHE_VAL(acl_cv_path_LD, --[if test -z "$LD"; then -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" -- for ac_dir in $PATH; do -- test -z "$ac_dir" && ac_dir=. -- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then -- acl_cv_path_LD="$ac_dir/$ac_prog" -- # Check to see if the program is GNU ld. I'd rather use --version, -- # but apparently some GNU ld's only accept -v. -- # Break only if it was the GNU/non-GNU ld that we prefer. -- if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then -- test "$with_gnu_ld" != no && break -+# AM_CONDITIONAL -*- Autoconf -*- -+ -+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# serial 7 -+ -+# AM_CONDITIONAL(NAME, SHELL-CONDITION) -+# ------------------------------------- -+# Define a conditional. -+AC_DEFUN([AM_CONDITIONAL], -+[AC_PREREQ(2.52)dnl -+ ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], -+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -+AC_SUBST([$1_TRUE]) -+AC_SUBST([$1_FALSE]) -+if $2; then -+ $1_TRUE= -+ $1_FALSE='#' -+else -+ $1_TRUE='#' -+ $1_FALSE= -+fi -+AC_CONFIG_COMMANDS_PRE( -+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then -+ AC_MSG_ERROR([[conditional "$1" was never defined. -+Usually this means the macro was only invoked conditionally.]]) -+fi])]) -+ -+ -+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# serial 8 -+ -+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -+# written in clear, in which case automake, when reading aclocal.m4, -+# will think it sees a *use*, and therefore will trigger all it's -+# C support machinery. Also note that it means that autoscan, seeing -+# CC etc. in the Makefile, will ask for an AC_PROG_CC use... -+ -+ -+# _AM_DEPENDENCIES(NAME) -+# ---------------------- -+# See how the compiler implements dependency checking. -+# NAME is "CC", "CXX", "GCJ", or "OBJC". -+# We try a few techniques and use that to set a single cache variable. -+# -+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -+# dependency, and given that the user is not expected to run this macro, -+# just rely on AC_PROG_CC. -+AC_DEFUN([_AM_DEPENDENCIES], -+[AC_REQUIRE([AM_SET_DEPDIR])dnl -+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -+AC_REQUIRE([AM_MAKE_INCLUDE])dnl -+AC_REQUIRE([AM_DEP_TRACK])dnl -+ -+ifelse([$1], CC, [depcc="$CC" am_compiler_list=], -+ [$1], CXX, [depcc="$CXX" am_compiler_list=], -+ [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], -+ [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], -+ [depcc="$$1" am_compiler_list=]) -+ -+AC_CACHE_CHECK([dependency style of $depcc], -+ [am_cv_$1_dependencies_compiler_type], -+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then -+ # We make a subdir and do the tests there. Otherwise we can end up -+ # making bogus files that we don't know about and never remove. For -+ # instance it was reported that on HP-UX the gcc test will end up -+ # making a dummy file named `D' -- because `-MD' means `put the output -+ # in D'. -+ mkdir conftest.dir -+ # Copy depcomp to subdir because otherwise we won't find it if we're -+ # using a relative directory. -+ cp "$am_depcomp" conftest.dir -+ cd conftest.dir -+ # We will build objects and dependencies in a subdirectory because -+ # it helps to detect inapplicable dependency modes. For instance -+ # both Tru64's cc and ICC support -MD to output dependencies as a -+ # side effect of compilation, but ICC will put the dependencies in -+ # the current directory while Tru64 will put them in the object -+ # directory. -+ mkdir sub -+ -+ am_cv_$1_dependencies_compiler_type=none -+ if test "$am_compiler_list" = ""; then -+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` -+ fi -+ for depmode in $am_compiler_list; do -+ # Setup a source with many dependencies, because some compilers -+ # like to wrap large dependency lists on column 80 (with \), and -+ # we should not choose a depcomp mode which is confused by this. -+ # -+ # We need to recreate these files for each test, as the compiler may -+ # overwrite some of them when testing with obscure command lines. -+ # This happens at least with the AIX C compiler. -+ : > sub/conftest.c -+ for i in 1 2 3 4 5 6; do -+ echo '#include "conftst'$i'.h"' >> sub/conftest.c -+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with -+ # Solaris 8's {/usr,}/bin/sh. -+ touch sub/conftst$i.h -+ done -+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf -+ -+ case $depmode in -+ nosideeffect) -+ # after this tag, mechanisms are not by side-effect, so they'll -+ # only be used when explicitly requested -+ if test "x$enable_dependency_tracking" = xyes; then -+ continue - else -- test "$with_gnu_ld" != yes && break -+ break -+ fi -+ ;; -+ none) break ;; -+ esac -+ # We check with `-c' and `-o' for the sake of the "dashmstdout" -+ # mode. It turns out that the SunPro C++ compiler does not properly -+ # handle `-M -o', and we need to detect this. -+ if depmode=$depmode \ -+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ -+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ -+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ -+ >/dev/null 2>conftest.err && -+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && -+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && -+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then -+ # icc doesn't choke on unknown options, it will just issue warnings -+ # or remarks (even with -Werror). So we grep stderr for any message -+ # that says an option was ignored or not supported. -+ # When given -MP, icc 7.0 and 7.1 complain thusly: -+ # icc: Command line warning: ignoring option '-M'; no argument required -+ # The diagnosis changed in icc 8.0: -+ # icc: Command line remark: option '-MP' not supported -+ if (grep 'ignoring option' conftest.err || -+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else -+ am_cv_$1_dependencies_compiler_type=$depmode -+ break - fi - fi - done -- IFS="$ac_save_ifs" --else -- acl_cv_path_LD="$LD" # Let the user override the test with a path. --fi]) --LD="$acl_cv_path_LD" --if test -n "$LD"; then -- AC_MSG_RESULT($LD) -+ -+ cd .. -+ rm -rf conftest.dir - else -- AC_MSG_RESULT(no) -+ am_cv_$1_dependencies_compiler_type=none - fi --test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) --AC_LIB_PROG_LD_GNU -+]) -+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -+AM_CONDITIONAL([am__fastdep$1], [ -+ test "x$enable_dependency_tracking" != xno \ -+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) - ]) - --# iconv.m4 serial AM4 (gettext-0.11.3) --dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. - --dnl From Bruno Haible. -+# AM_SET_DEPDIR -+# ------------- -+# Choose a directory name for dependency files. -+# This macro is AC_REQUIREd in _AM_DEPENDENCIES -+AC_DEFUN([AM_SET_DEPDIR], -+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -+]) - --AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], --[ -- dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. -- AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) -- AC_REQUIRE([AC_LIB_RPATH]) - -- dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV -- dnl accordingly. -- AC_LIB_LINKFLAGS_BODY([iconv]) -+# AM_DEP_TRACK -+# ------------ -+AC_DEFUN([AM_DEP_TRACK], -+[AC_ARG_ENABLE(dependency-tracking, -+[ --disable-dependency-tracking speeds up one-time build -+ --enable-dependency-tracking do not reject slow dependency extractors]) -+if test "x$enable_dependency_tracking" != xno; then -+ am_depcomp="$ac_aux_dir/depcomp" -+ AMDEPBACKSLASH='\' -+fi -+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -+AC_SUBST([AMDEPBACKSLASH]) - ]) - --AC_DEFUN([AM_ICONV_LINK], --[ -- dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and -- dnl those with the standalone portable GNU libiconv installed). -+# Generate code to set up dependency tracking. -*- Autoconf -*- - -- dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV -- dnl accordingly. -- AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) -+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - -- dnl Add $INCICONV to CPPFLAGS before performing the following checks, -- dnl because if the user has installed libiconv and not disabled its use -- dnl via --without-libiconv-prefix, he wants to use it. The first -- dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. -- am_save_CPPFLAGS="$CPPFLAGS" -- AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) -+#serial 3 - -- AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ -- am_cv_func_iconv="no, consider installing GNU libiconv" -- am_cv_lib_iconv=no -- AC_TRY_LINK([#include --#include ], -- [iconv_t cd = iconv_open("",""); -- iconv(cd,NULL,NULL,NULL,NULL); -- iconv_close(cd);], -- am_cv_func_iconv=yes) -- if test "$am_cv_func_iconv" != yes; then -- am_save_LIBS="$LIBS" -- LIBS="$LIBS $LIBICONV" -- AC_TRY_LINK([#include --#include ], -- [iconv_t cd = iconv_open("",""); -- iconv(cd,NULL,NULL,NULL,NULL); -- iconv_close(cd);], -- am_cv_lib_iconv=yes -- am_cv_func_iconv=yes) -- LIBS="$am_save_LIBS" -- fi -- ]) -- if test "$am_cv_func_iconv" = yes; then -- AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) -- fi -- if test "$am_cv_lib_iconv" = yes; then -- AC_MSG_CHECKING([how to link with libiconv]) -- AC_MSG_RESULT([$LIBICONV]) -+# _AM_OUTPUT_DEPENDENCY_COMMANDS -+# ------------------------------ -+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -+[for mf in $CONFIG_FILES; do -+ # Strip MF so we end up with the name of the file. -+ mf=`echo "$mf" | sed -e 's/:.*$//'` -+ # Check whether this is an Automake generated Makefile or not. -+ # We used to match only the files named `Makefile.in', but -+ # some people rename them; so instead we look at the file content. -+ # Grep'ing the first line is not enough: some people post-process -+ # each Makefile.in and add a new line on top of each file to say so. -+ # So let's grep whole file. -+ if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then -+ dirpart=`AS_DIRNAME("$mf")` - else -- dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV -- dnl either. -- CPPFLAGS="$am_save_CPPFLAGS" -- LIBICONV= -- LTLIBICONV= -+ continue - fi -- AC_SUBST(LIBICONV) -- AC_SUBST(LTLIBICONV) --]) -+ # Extract the definition of DEPDIR, am__include, and am__quote -+ # from the Makefile without running `make'. -+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` -+ test -z "$DEPDIR" && continue -+ am__include=`sed -n 's/^am__include = //p' < "$mf"` -+ test -z "am__include" && continue -+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"` -+ # When using ansi2knr, U may be empty or an underscore; expand it -+ U=`sed -n 's/^U = //p' < "$mf"` -+ # Find all dependency output files, they are included files with -+ # $(DEPDIR) in their names. We invoke sed twice because it is the -+ # simplest approach to changing $(DEPDIR) to its actual value in the -+ # expansion. -+ for file in `sed -n " -+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ -+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do -+ # Make sure the directory exists. -+ test -f "$dirpart/$file" && continue -+ fdir=`AS_DIRNAME(["$file"])` -+ AS_MKDIR_P([$dirpart/$fdir]) -+ # echo "creating $dirpart/$file" -+ echo '# dummy' > "$dirpart/$file" -+ done -+done -+])# _AM_OUTPUT_DEPENDENCY_COMMANDS - --AC_DEFUN([AM_ICONV], --[ -- AM_ICONV_LINK -- if test "$am_cv_func_iconv" = yes; then -- AC_MSG_CHECKING([for iconv declaration]) -- AC_CACHE_VAL(am_cv_proto_iconv, [ -- AC_TRY_COMPILE([ --#include --#include --extern --#ifdef __cplusplus --"C" --#endif --#if defined(__STDC__) || defined(__cplusplus) --size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); --#else --size_t iconv(); --#endif --], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") -- am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) -- am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` -- AC_MSG_RESULT([$]{ac_t:- -- }[$]am_cv_proto_iconv) -- AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, -- [Define as const if the declaration of iconv() needs const.]) -- fi -+ -+# AM_OUTPUT_DEPENDENCY_COMMANDS -+# ----------------------------- -+# This macro should only be invoked once -- use via AC_REQUIRE. -+# -+# This code is only required when automatic dependency tracking -+# is enabled. FIXME. This creates each `.P' file that we will -+# need in order to bootstrap the dependency handling code. -+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -+[AC_CONFIG_COMMANDS([depfiles], -+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], -+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) - ]) - --# progtest.m4 serial 2 (gettext-0.10.40) --dnl Copyright (C) 1996-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. --dnl --dnl This file can can be used in projects which are not available under --dnl the GNU General Public License or the GNU Library General Public --dnl License but which still want to provide support for the GNU gettext --dnl functionality. --dnl Please note that the actual code of the GNU gettext library is covered --dnl by the GNU Library General Public License, and the rest of the GNU --dnl gettext package package is covered by the GNU General Public License. --dnl They are *not* in the public domain. -+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# serial 8 - --dnl Authors: --dnl Ulrich Drepper , 1996. -+# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. -+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) - --# Search path for a program which passes the given test. -+# Do all the work for Automake. -*- Autoconf -*- - --dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, --dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) --AC_DEFUN([AM_PATH_PROG_WITH_TEST], --[# Extract the first word of "$2", so it can be a program name with args. --set dummy $2; ac_word=[$]2 --AC_MSG_CHECKING([for $ac_word]) --AC_CACHE_VAL(ac_cv_path_$1, --[case "[$]$1" in -- /*) -- ac_cv_path_$1="[$]$1" # Let the user override the test with a path. -- ;; -- *) -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" -- for ac_dir in ifelse([$5], , $PATH, [$5]); do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/$ac_word; then -- if [$3]; then -- ac_cv_path_$1="$ac_dir/$ac_word" -- break -- fi -- fi -- done -- IFS="$ac_save_ifs" --dnl If no 4th arg is given, leave the cache variable unset, --dnl so AC_PATH_PROGS will keep looking. --ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" --])dnl -- ;; --esac])dnl --$1="$ac_cv_path_$1" --if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then -- AC_MSG_RESULT([$]$1) --else -- AC_MSG_RESULT(no) --fi --AC_SUBST($1)dnl --]) -+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --# isc-posix.m4 serial 2 (gettext-0.11.2) --dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -- --# This file is not needed with autoconf-2.53 and newer. Remove it in 2005. -- --# This test replaces the one in autoconf. --# Currently this macro should have the same name as the autoconf macro --# because gettext's gettext.m4 (distributed in the automake package) --# still uses it. Otherwise, the use in gettext.m4 makes autoheader --# give these diagnostics: --# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX --# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX -+# serial 12 - --undefine([AC_ISC_POSIX]) -+# This macro actually does too much. Some checks are only needed if -+# your package does certain things. But this isn't really a big deal. - --AC_DEFUN([AC_ISC_POSIX], -- [ -- dnl This test replaces the obsolescent AC_ISC_POSIX kludge. -- AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) -- ] --) -+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -+# AM_INIT_AUTOMAKE([OPTIONS]) -+# ----------------------------------------------- -+# The call with PACKAGE and VERSION arguments is the old style -+# call (pre autoconf-2.50), which is being phased out. PACKAGE -+# and VERSION should now be passed to AC_INIT and removed from -+# the call to AM_INIT_AUTOMAKE. -+# We support both call styles for the transition. After -+# the next Automake release, Autoconf can make the AC_INIT -+# arguments mandatory, and then we can depend on a new Autoconf -+# release and drop the old call support. -+AC_DEFUN([AM_INIT_AUTOMAKE], -+[AC_PREREQ([2.58])dnl -+dnl Autoconf wants to disallow AM_ names. We explicitly allow -+dnl the ones we care about. -+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -+AC_REQUIRE([AC_PROG_INSTALL])dnl -+# test to see if srcdir already configured -+if test "`cd $srcdir && pwd`" != "`pwd`" && -+ test -f $srcdir/config.status; then -+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) -+fi - --# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40) --dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# test whether we have cygpath -+if test -z "$CYGPATH_W"; then -+ if (cygpath --version) >/dev/null 2>/dev/null; then -+ CYGPATH_W='cygpath -w' -+ else -+ CYGPATH_W=echo -+ fi -+fi -+AC_SUBST([CYGPATH_W]) - --# Test for the GNU C Library, version 2.1 or newer. --# From Bruno Haible. -+# Define the identity of the package. -+dnl Distinguish between old-style and new-style calls. -+m4_ifval([$2], -+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl -+ AC_SUBST([PACKAGE], [$1])dnl -+ AC_SUBST([VERSION], [$2])], -+[_AM_SET_OPTIONS([$1])dnl -+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl -+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - --AC_DEFUN([jm_GLIBC21], -- [ -- AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, -- ac_cv_gnu_library_2_1, -- [AC_EGREP_CPP([Lucky GNU user], -- [ --#include --#ifdef __GNU_LIBRARY__ -- #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) -- Lucky GNU user -- #endif --#endif -- ], -- ac_cv_gnu_library_2_1=yes, -- ac_cv_gnu_library_2_1=no) -- ] -- ) -- AC_SUBST(GLIBC21) -- GLIBC21="$ac_cv_gnu_library_2_1" -- ] --) -+_AM_IF_OPTION([no-define],, -+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) -+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl - --# intdiv0.m4 serial 1 (gettext-0.11.3) --dnl Copyright (C) 2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# Some tools Automake needs. -+AC_REQUIRE([AM_SANITY_CHECK])dnl -+AC_REQUIRE([AC_ARG_PROGRAM])dnl -+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -+AM_MISSING_PROG(AUTOCONF, autoconf) -+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -+AM_MISSING_PROG(AUTOHEADER, autoheader) -+AM_MISSING_PROG(MAKEINFO, makeinfo) -+AM_PROG_INSTALL_SH -+AM_PROG_INSTALL_STRIP -+AC_REQUIRE([AM_PROG_MKDIR_P])dnl -+# We need awk for the "check" target. The system "awk" is bad on -+# some platforms. -+AC_REQUIRE([AC_PROG_AWK])dnl -+AC_REQUIRE([AC_PROG_MAKE_SET])dnl -+AC_REQUIRE([AM_SET_LEADING_DOT])dnl -+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], -+ [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], -+ [_AM_PROG_TAR([v7])])]) -+_AM_IF_OPTION([no-dependencies],, -+[AC_PROVIDE_IFELSE([AC_PROG_CC], -+ [_AM_DEPENDENCIES(CC)], -+ [define([AC_PROG_CC], -+ defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -+AC_PROVIDE_IFELSE([AC_PROG_CXX], -+ [_AM_DEPENDENCIES(CXX)], -+ [define([AC_PROG_CXX], -+ defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -+]) -+]) - --dnl From Bruno Haible. - --AC_DEFUN([gt_INTDIV0], --[ -- AC_REQUIRE([AC_PROG_CC])dnl -- AC_REQUIRE([AC_CANONICAL_HOST])dnl -+# When config.status generates a header, we must update the stamp-h file. -+# This file resides in the same directory as the config header -+# that is generated. The stamp files are numbered to have different names. - -- AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], -- gt_cv_int_divbyzero_sigfpe, -- [ -- AC_TRY_RUN([ --#include --#include -+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -+# loop where config.status creates the headers, so we can generate -+# our stamp files there. -+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -+[# Compute $1's index in $config_headers. -+_am_stamp_count=1 -+for _am_header in $config_headers :; do -+ case $_am_header in -+ $1 | $1:* ) -+ break ;; -+ * ) -+ _am_stamp_count=`expr $_am_stamp_count + 1` ;; -+ esac -+done -+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) - --static void --#ifdef __cplusplus --sigfpe_handler (int sig) --#else --sigfpe_handler (sig) int sig; --#endif --{ -- /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ -- exit (sig != SIGFPE); --} -+# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --int x = 1; --int y = 0; --int z; --int nan; -+# AM_PROG_INSTALL_SH -+# ------------------ -+# Define $install_sh. -+AC_DEFUN([AM_PROG_INSTALL_SH], -+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -+install_sh=${install_sh-"$am_aux_dir/install-sh"} -+AC_SUBST(install_sh)]) - --int main () --{ -- signal (SIGFPE, sigfpe_handler); --/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ --#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) -- signal (SIGTRAP, sigfpe_handler); --#endif --/* Linux/SPARC yields signal SIGILL. */ --#if defined (__sparc__) && defined (__linux__) -- signal (SIGILL, sigfpe_handler); --#endif -+# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - -- z = x / y; -- nan = y / y; -- exit (1); --} --], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, -- [ -- # Guess based on the CPU. -- case "$host_cpu" in -- alpha* | i[34567]86 | m68k | s390*) -- gt_cv_int_divbyzero_sigfpe="guessing yes";; -- *) -- gt_cv_int_divbyzero_sigfpe="guessing no";; -- esac -- ]) -- ]) -- case "$gt_cv_int_divbyzero_sigfpe" in -- *yes) value=1;; -- *) value=0;; -- esac -- AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, -- [Define if integer division by zero raises signal SIGFPE.]) --]) -+# serial 2 - --# uintmax_t.m4 serial 6 (gettext-0.11) --dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# Check whether the underlying file-system supports filenames -+# with a leading dot. For instance MS-DOS doesn't. -+AC_DEFUN([AM_SET_LEADING_DOT], -+[rm -rf .tst 2>/dev/null -+mkdir .tst 2>/dev/null -+if test -d .tst; then -+ am__leading_dot=. -+else -+ am__leading_dot=_ -+fi -+rmdir .tst 2>/dev/null -+AC_SUBST([am__leading_dot])]) - --dnl From Paul Eggert. -+# Check to see how 'make' treats includes. -*- Autoconf -*- - --AC_PREREQ(2.13) -+# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --# Define uintmax_t to `unsigned long' or `unsigned long long' --# if does not exist. -+# serial 3 - --AC_DEFUN([jm_AC_TYPE_UINTMAX_T], --[ -- AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) -- AC_REQUIRE([jm_AC_HEADER_STDINT_H]) -- if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then -- AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) -- test $ac_cv_type_unsigned_long_long = yes \ -- && ac_type='unsigned long long' \ -- || ac_type='unsigned long' -- AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, -- [Define to unsigned long or unsigned long long -- if and don't define.]) -- fi -+# AM_MAKE_INCLUDE() -+# ----------------- -+# Check to see how make treats includes. -+AC_DEFUN([AM_MAKE_INCLUDE], -+[am_make=${MAKE-make} -+cat > confinc << 'END' -+am__doit: -+ @echo done -+.PHONY: am__doit -+END -+# If we don't find an include directive, just comment out the code. -+AC_MSG_CHECKING([for style of include used by $am_make]) -+am__include="#" -+am__quote= -+_am_result=none -+# First try GNU make style include. -+echo "include confinc" > confmf -+# We grep out `Entering directory' and `Leaving directory' -+# messages which can occur if `w' ends up in MAKEFLAGS. -+# In particular we don't look at `^make:' because GNU make might -+# be invoked under some other name (usually "gmake"), in which -+# case it prints its new name instead of `make'. -+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then -+ am__include=include -+ am__quote= -+ _am_result=GNU -+fi -+# Now try BSD make style include. -+if test "$am__include" = "#"; then -+ echo '.include "confinc"' > confmf -+ if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then -+ am__include=.include -+ am__quote="\"" -+ _am_result=BSD -+ fi -+fi -+AC_SUBST([am__include]) -+AC_SUBST([am__quote]) -+AC_MSG_RESULT([$_am_result]) -+rm -f confinc confmf - ]) - --# inttypes_h.m4 serial 4 (gettext-0.11.4) --dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -+ -+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# serial 4 - --dnl From Paul Eggert. -+# AM_MISSING_PROG(NAME, PROGRAM) -+# ------------------------------ -+AC_DEFUN([AM_MISSING_PROG], -+[AC_REQUIRE([AM_MISSING_HAS_RUN]) -+$1=${$1-"${am_missing_run}$2"} -+AC_SUBST($1)]) - --# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, --# doesn't clash with , and declares uintmax_t. - --AC_DEFUN([jm_AC_HEADER_INTTYPES_H], --[ -- AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, -- [AC_TRY_COMPILE( -- [#include --#include ], -- [uintmax_t i = (uintmax_t) -1;], -- jm_ac_cv_header_inttypes_h=yes, -- jm_ac_cv_header_inttypes_h=no)]) -- if test $jm_ac_cv_header_inttypes_h = yes; then -- AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, --[Define if exists, doesn't clash with , -- and declares uintmax_t. ]) -- fi -+# AM_MISSING_HAS_RUN -+# ------------------ -+# Define MISSING if not defined so far and test if it supports --run. -+# If it does, set am_missing_run to use it, otherwise, to nothing. -+AC_DEFUN([AM_MISSING_HAS_RUN], -+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -+# Use eval to expand $SHELL -+if eval "$MISSING --run true"; then -+ am_missing_run="$MISSING --run " -+else -+ am_missing_run= -+ AC_MSG_WARN([`missing' script is too old or missing]) -+fi - ]) - --# stdint_h.m4 serial 2 (gettext-0.11.4) --dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --dnl From Paul Eggert. -+# AM_PROG_MKDIR_P -+# --------------- -+# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. -+# -+# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories -+# created by `make install' are always world readable, even if the -+# installer happens to have an overly restrictive umask (e.g. 077). -+# This was a mistake. There are at least two reasons why we must not -+# use `-m 0755': -+# - it causes special bits like SGID to be ignored, -+# - it may be too restrictive (some setups expect 775 directories). -+# -+# Do not use -m 0755 and let people choose whatever they expect by -+# setting umask. -+# -+# We cannot accept any implementation of `mkdir' that recognizes `-p'. -+# Some implementations (such as Solaris 8's) are not thread-safe: if a -+# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' -+# concurrently, both version can detect that a/ is missing, but only -+# one can create it and the other will error out. Consequently we -+# restrict ourselves to GNU make (using the --version option ensures -+# this.) -+AC_DEFUN([AM_PROG_MKDIR_P], -+[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then -+ # We used to keeping the `.' as first argument, in order to -+ # allow $(mkdir_p) to be used without argument. As in -+ # $(mkdir_p) $(somedir) -+ # where $(somedir) is conditionally defined. However this is wrong -+ # for two reasons: -+ # 1. if the package is installed by a user who cannot write `.' -+ # make install will fail, -+ # 2. the above comment should most certainly read -+ # $(mkdir_p) $(DESTDIR)$(somedir) -+ # so it does not work when $(somedir) is undefined and -+ # $(DESTDIR) is not. -+ # To support the latter case, we have to write -+ # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), -+ # so the `.' trick is pointless. -+ mkdir_p='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. -+ for d in ./-p ./--version; -+ do -+ test -d $d && rmdir $d -+ done -+ # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. -+ if test -f "$ac_aux_dir/mkinstalldirs"; then -+ mkdir_p='$(mkinstalldirs)' -+ else -+ mkdir_p='$(install_sh) -d' -+ fi -+fi -+AC_SUBST([mkdir_p])]) - --# Define HAVE_STDINT_H_WITH_UINTMAX if exists, --# doesn't clash with , and declares uintmax_t. -+# Helper functions for option handling. -*- Autoconf -*- - --AC_DEFUN([jm_AC_HEADER_STDINT_H], --[ -- AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h, -- [AC_TRY_COMPILE( -- [#include --#include ], -- [uintmax_t i = (uintmax_t) -1;], -- jm_ac_cv_header_stdint_h=yes, -- jm_ac_cv_header_stdint_h=no)]) -- if test $jm_ac_cv_header_stdint_h = yes; then -- AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, --[Define if exists, doesn't clash with , -- and declares uintmax_t. ]) -- fi --]) -+# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --# ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40) --dnl Copyright (C) 1999-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# serial 3 - --dnl From Paul Eggert. -+# _AM_MANGLE_OPTION(NAME) -+# ----------------------- -+AC_DEFUN([_AM_MANGLE_OPTION], -+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - --AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG], --[ -- AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, -- [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;], -- [unsigned long long ullmax = (unsigned long long) -1; -- return ull << i | ull >> i | ullmax / ull | ullmax % ull;], -- ac_cv_type_unsigned_long_long=yes, -- ac_cv_type_unsigned_long_long=no)]) -- if test $ac_cv_type_unsigned_long_long = yes; then -- AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, -- [Define if you have the unsigned long long type.]) -- fi --]) -+# _AM_SET_OPTION(NAME) -+# ------------------------------ -+# Set option NAME. Presently that only means defining a flag for this option. -+AC_DEFUN([_AM_SET_OPTION], -+[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) - --# inttypes.m4 serial 1 (gettext-0.11.4) --dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# _AM_SET_OPTIONS(OPTIONS) -+# ---------------------------------- -+# OPTIONS is a space-separated list of Automake options. -+AC_DEFUN([_AM_SET_OPTIONS], -+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - --dnl From Paul Eggert. -+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -+# ------------------------------------------- -+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -+AC_DEFUN([_AM_IF_OPTION], -+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - --# Define HAVE_INTTYPES_H if exists and doesn't clash with --# . -+# Check to make sure that the build environment is sane. -*- Autoconf -*- - --AC_DEFUN([gt_HEADER_INTTYPES_H], --[ -- AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, -- [ -- AC_TRY_COMPILE( -- [#include --#include ], -- [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) -- ]) -- if test $gt_cv_header_inttypes_h = yes; then -- AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, -- [Define if exists and doesn't clash with .]) -- fi --]) -+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -+# Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --# inttypes-pri.m4 serial 1 (gettext-0.11.4) --dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# serial 4 - --dnl From Bruno Haible. -+# AM_SANITY_CHECK -+# --------------- -+AC_DEFUN([AM_SANITY_CHECK], -+[AC_MSG_CHECKING([whether build environment is sane]) -+# Just in case -+sleep 1 -+echo timestamp > conftest.file -+# Do `set' in a subshell so we don't clobber the current shell's -+# arguments. Must try -L first in case configure is actually a -+# symlink; some systems play weird games with the mod time of symlinks -+# (eg FreeBSD returns the mod time of the symlink's containing -+# directory). -+if ( -+ set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` -+ if test "$[*]" = "X"; then -+ # -L didn't work. -+ set X `ls -t $srcdir/configure conftest.file` -+ fi -+ rm -f conftest.file -+ if test "$[*]" != "X $srcdir/configure conftest.file" \ -+ && test "$[*]" != "X conftest.file $srcdir/configure"; then - --# Define PRI_MACROS_BROKEN if exists and defines the PRI* --# macros to non-string values. This is the case on AIX 4.3.3. -+ # If neither matched, then we have a broken ls. This can happen -+ # if, for instance, CONFIG_SHELL is bash and it inherits a -+ # broken ls alias from the environment. This has actually -+ # happened. Such a system could not be considered "sane". -+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -+alias in your environment]) -+ fi - --AC_DEFUN([gt_INTTYPES_PRI], --[ -- AC_REQUIRE([gt_HEADER_INTTYPES_H]) -- if test $gt_cv_header_inttypes_h = yes; then -- AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], -- gt_cv_inttypes_pri_broken, -- [ -- AC_TRY_COMPILE([#include --#ifdef PRId32 --char *p = PRId32; --#endif --], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) -- ]) -- fi -- if test "$gt_cv_inttypes_pri_broken" = yes; then -- AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, -- [Define if exists and defines unusable PRI* macros.]) -- fi --]) -+ test "$[2]" = conftest.file -+ ) -+then -+ # Ok. -+ : -+else -+ AC_MSG_ERROR([newly created file is older than distributed files! -+Check your system clock]) -+fi -+AC_MSG_RESULT(yes)]) - --# codeset.m4 serial AM1 (gettext-0.10.40) --dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. -+# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --dnl From Bruno Haible. -+# AM_PROG_INSTALL_STRIP -+# --------------------- -+# One issue with vendor `install' (even GNU) is that you can't -+# specify the program used to strip binaries. This is especially -+# annoying in cross-compiling environments, where the build's strip -+# is unlikely to handle the host's binaries. -+# Fortunately install-sh will honor a STRIPPROG variable, so we -+# always use install-sh in `make install-strip', and initialize -+# STRIPPROG with the value of the STRIP variable (set by the user). -+AC_DEFUN([AM_PROG_INSTALL_STRIP], -+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -+# Installed binaries are usually stripped using `strip' when the user -+# run `make install-strip'. However `strip' might not be the right -+# tool to use in cross-compilation environments, therefore Automake -+# will honor the `STRIP' environment variable to overrule this program. -+dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -+if test "$cross_compiling" != no; then -+ AC_CHECK_TOOL([STRIP], [strip], :) -+fi -+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" -+AC_SUBST([INSTALL_STRIP_PROGRAM])]) - --AC_DEFUN([AM_LANGINFO_CODESET], --[ -- AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, -- [AC_TRY_LINK([#include ], -- [char* cs = nl_langinfo(CODESET);], -- am_cv_langinfo_codeset=yes, -- am_cv_langinfo_codeset=no) -- ]) -- if test $am_cv_langinfo_codeset = yes; then -- AC_DEFINE(HAVE_LANGINFO_CODESET, 1, -- [Define if you have and nl_langinfo(CODESET).]) -- fi --]) -+# Check how to create a tarball. -*- Autoconf -*- - --# lcmessage.m4 serial 3 (gettext-0.11.3) --dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. --dnl This file is free software, distributed under the terms of the GNU --dnl General Public License. As a special exception to the GNU General --dnl Public License, this file may be distributed as part of a program --dnl that contains a configuration script generated by Autoconf, under --dnl the same distribution terms as the rest of that program. --dnl --dnl This file can can be used in projects which are not available under --dnl the GNU General Public License or the GNU Library General Public --dnl License but which still want to provide support for the GNU gettext --dnl functionality. --dnl Please note that the actual code of the GNU gettext library is covered --dnl by the GNU Library General Public License, and the rest of the GNU --dnl gettext package package is covered by the GNU General Public License. --dnl They are *not* in the public domain. -+# Copyright (C) 2004, 2005 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. - --dnl Authors: --dnl Ulrich Drepper , 1995. -+# serial 2 - --# Check whether LC_MESSAGES is available in . -+# _AM_PROG_TAR(FORMAT) -+# -------------------- -+# Check how to create a tarball in format FORMAT. -+# FORMAT should be one of `v7', `ustar', or `pax'. -+# -+# Substitute a variable $(am__tar) that is a command -+# writing to stdout a FORMAT-tarball containing the directory -+# $tardir. -+# tardir=directory && $(am__tar) > result.tar -+# -+# Substitute a variable $(am__untar) that extract such -+# a tarball read from stdin. -+# $(am__untar) < result.tar -+AC_DEFUN([_AM_PROG_TAR], -+[# Always define AMTAR for backward compatibility. -+AM_MISSING_PROG([AMTAR], [tar]) -+m4_if([$1], [v7], -+ [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], -+ [m4_case([$1], [ustar],, [pax],, -+ [m4_fatal([Unknown tar format])]) -+AC_MSG_CHECKING([how to create a $1 tar archive]) -+# Loop over all known methods to create a tar archive until one works. -+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -+_am_tools=${am_cv_prog_tar_$1-$_am_tools} -+# Do not fold the above two line into one, because Tru64 sh and -+# Solaris sh will not grok spaces in the rhs of `-'. -+for _am_tool in $_am_tools -+do -+ case $_am_tool in -+ gnutar) -+ for _am_tar in tar gnutar gtar; -+ do -+ AM_RUN_LOG([$_am_tar --version]) && break -+ done -+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' -+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' -+ am__untar="$_am_tar -xf -" -+ ;; -+ plaintar) -+ # Must skip GNU tar: if it does not support --format= it doesn't create -+ # ustar tarball either. -+ (tar --version) >/dev/null 2>&1 && continue -+ am__tar='tar chf - "$$tardir"' -+ am__tar_='tar chf - "$tardir"' -+ am__untar='tar xf -' -+ ;; -+ pax) -+ am__tar='pax -L -x $1 -w "$$tardir"' -+ am__tar_='pax -L -x $1 -w "$tardir"' -+ am__untar='pax -r' -+ ;; -+ cpio) -+ am__tar='find "$$tardir" -print | cpio -o -H $1 -L' -+ am__tar_='find "$tardir" -print | cpio -o -H $1 -L' -+ am__untar='cpio -i -H $1 -d' -+ ;; -+ none) -+ am__tar=false -+ am__tar_=false -+ am__untar=false -+ ;; -+ esac - --AC_DEFUN([AM_LC_MESSAGES], --[ -- AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, -- [AC_TRY_LINK([#include ], [return LC_MESSAGES], -- am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) -- if test $am_cv_val_LC_MESSAGES = yes; then -- AC_DEFINE(HAVE_LC_MESSAGES, 1, -- [Define if your file defines LC_MESSAGES.]) -+ # If the value was cached, stop now. We just wanted to have am__tar -+ # and am__untar set. -+ test -n "${am_cv_prog_tar_$1}" && break -+ -+ # tar/untar a dummy directory, and stop if the command works -+ rm -rf conftest.dir -+ mkdir conftest.dir -+ echo GrepMe > conftest.dir/file -+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) -+ rm -rf conftest.dir -+ if test -s conftest.tar; then -+ AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi --]) -+done -+rm -rf conftest.dir -+ -+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -+AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -+AC_SUBST([am__tar]) -+AC_SUBST([am__untar]) -+]) # _AM_PROG_TAR - -+m4_include([acinclude.m4]) ---- gsmlib-1.10.orig/configure -+++ gsmlib-1.10/configure -@@ -1,178 +1,10 @@ - #! /bin/sh - # Guess values for system-dependent variables and create Makefiles. --# Generated by GNU Autoconf 2.53. -+# Generated by GNU Autoconf 2.59. - # --# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 --# Free Software Foundation, Inc. -+# Copyright (C) 2003 Free Software Foundation, Inc. - # This configure script is free software; the Free Software Foundation - # gives unlimited permission to copy, distribute and modify it. -- --# Find the correct PATH separator. Usually this is `:', but --# DJGPP uses `;' like DOS. --if test "X${PATH_SEPARATOR+set}" != Xset; then -- UNAME=${UNAME-`uname 2>/dev/null`} -- case X$UNAME in -- *-DOS) lt_cv_sys_path_separator=';' ;; -- *) lt_cv_sys_path_separator=':' ;; -- esac -- PATH_SEPARATOR=$lt_cv_sys_path_separator --fi -- -- --# Check that we are running under the correct shell. --SHELL=${CONFIG_SHELL-/bin/sh} -- --case X$ECHO in --X*--fallback-echo) -- # Remove one level of quotation (which was required for Make). -- ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` -- ;; --esac -- --echo=${ECHO-echo} --if test "X$1" = X--no-reexec; then -- # Discard the --no-reexec flag, and continue. -- shift --elif test "X$1" = X--fallback-echo; then -- # Avoid inline document here, it may be left over -- : --elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then -- # Yippee, $echo works! -- : --else -- # Restart under the correct shell. -- exec $SHELL "$0" --no-reexec ${1+"$@"} --fi -- --if test "X$1" = X--fallback-echo; then -- # used as fallback echo -- shift -- cat </dev/null && -- echo_test_string="`eval $cmd`" && -- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null -- then -- break -- fi -- done --fi -- --if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- : --else -- # The Solaris, AIX, and Digital Unix default echo programs unquote -- # backslashes. This makes it impossible to quote backslashes using -- # echo "$something" | sed 's/\\/\\\\/g' -- # -- # So, first we look for a working echo in the user's PATH. -- -- IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR -- for dir in $PATH /usr/ucb; do -- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && -- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- echo="$dir/echo" -- break -- fi -- done -- IFS="$save_ifs" -- -- if test "X$echo" = Xecho; then -- # We didn't find a better echo, so look for alternatives. -- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- # This shell has a builtin print -r that does the trick. -- echo='print -r' -- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && -- test "X$CONFIG_SHELL" != X/bin/ksh; then -- # If we have ksh, try running configure again with it. -- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -- export ORIGINAL_CONFIG_SHELL -- CONFIG_SHELL=/bin/ksh -- export CONFIG_SHELL -- exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} -- else -- # Try using printf. -- echo='printf %s\n' -- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- # Cool, printf works -- : -- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && -- test "X$echo_testing_string" = 'X\t' && -- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL -- export CONFIG_SHELL -- SHELL="$CONFIG_SHELL" -- export SHELL -- echo="$CONFIG_SHELL $0 --fallback-echo" -- elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && -- test "X$echo_testing_string" = 'X\t' && -- echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && -- test "X$echo_testing_string" = "X$echo_test_string"; then -- echo="$CONFIG_SHELL $0 --fallback-echo" -- else -- # maybe with a smaller string... -- prev=: -- -- for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do -- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null -- then -- break -- fi -- prev="$cmd" -- done -- -- if test "$prev" != 'sed 50q "$0"'; then -- echo_test_string=`eval $prev` -- export echo_test_string -- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} -- else -- # Oops. We lost completely, so just stick with echo. -- echo=echo -- fi -- fi -- fi -- fi --fi --fi -- --# Copy echo and quote the copy suitably for passing to libtool from --# the Makefile, instead of quoting the original, which is used later. --ECHO=$echo --if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then -- ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" --fi -- -- -- --if expr a : '\(a\)' >/dev/null 2>&1; then -- as_expr=expr --else -- as_expr=false --fi -- -- - ## --------------------- ## - ## M4sh Initialization. ## - ## --------------------- ## -@@ -181,46 +13,57 @@ - if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: -+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which -+ # is contrary to our usage. Disable this feature. -+ alias -g '${1+"$@"}'='"$@"' - elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix - fi -+DUALCASE=1; export DUALCASE # for MKS sh - --# NLS nuisances. - # Support unset when possible. --if (FOO=FOO; unset FOO) >/dev/null 2>&1; then -+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset - else - as_unset=false - fi - --(set +x; test -n "`(LANG=C; export LANG) 2>&1`") && -- { $as_unset LANG || test "${LANG+set}" != set; } || -- { LANG=C; export LANG; } --(set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && -- { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || -- { LC_ALL=C; export LC_ALL; } --(set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && -- { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || -- { LC_TIME=C; export LC_TIME; } --(set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && -- { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || -- { LC_CTYPE=C; export LC_CTYPE; } --(set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && -- { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || -- { LANGUAGE=C; export LANGUAGE; } --(set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && -- { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || -- { LC_COLLATE=C; export LC_COLLATE; } --(set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && -- { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || -- { LC_NUMERIC=C; export LC_NUMERIC; } --(set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && -- { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || -- { LC_MESSAGES=C; export LC_MESSAGES; } -+ -+# Work around bugs in pre-3.0 UWIN ksh. -+$as_unset ENV MAIL MAILPATH -+PS1='$ ' -+PS2='> ' -+PS4='+ ' -+ -+# NLS nuisances. -+for as_var in \ -+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ -+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ -+ LC_TELEPHONE LC_TIME -+do -+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then -+ eval $as_var=C; export $as_var -+ else -+ $as_unset $as_var -+ fi -+done -+ -+# Required to use basename. -+if expr a : '\(a\)' >/dev/null 2>&1; then -+ as_expr=expr -+else -+ as_expr=false -+fi -+ -+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then -+ as_basename=basename -+else -+ as_basename=false -+fi - - - # Name of the executable. --as_me=`(basename "$0") 2>/dev/null || -+as_me=`$as_basename "$0" || - $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ -@@ -231,6 +74,7 @@ - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - -+ - # PATH needs CR, and LINENO needs CR and PATH. - # Avoid depending upon Character Ranges. - as_cr_letters='abcdefghijklmnopqrstuvwxyz' -@@ -241,15 +85,15 @@ - - # The user is always right. - if test "${PATH_SEPARATOR+set}" != set; then -- echo "#! /bin/sh" >conftest.sh -- echo "exit 0" >>conftest.sh -- chmod +x conftest.sh -- if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi -- rm -f conftest.sh -+ rm -f conf$$.sh - fi - - -@@ -297,6 +141,8 @@ - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then -+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } -+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} -@@ -369,13 +215,20 @@ - fi - rm -f conf$$ conf$$.exe conf$$.file - -+if mkdir -p . 2>/dev/null; then -+ as_mkdir_p=: -+else -+ test -d ./-p && rmdir ./-p -+ as_mkdir_p=false -+fi -+ - as_executable_p="test -f" - - # Sed expression to map a string onto a valid CPP name. --as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" -+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - - # Sed expression to map a string onto a valid variable name. --as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" -+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - # IFS -@@ -385,76 +238,233 @@ - IFS=" $as_nl" - - # CDPATH. --$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } -- -+$as_unset CDPATH - --# Name of the host. --# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, --# so uname gets run too. --ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - --exec 6>&1 - --# --# Initializations. --# --ac_default_prefix=/usr/local --cross_compiling=no --subdirs= --MFLAGS= --MAKEFLAGS= -+# Check that we are running under the correct shell. - SHELL=${CONFIG_SHELL-/bin/sh} - --# Maximum number of lines to put in a shell here document. --# This variable seems obsolete. It should probably be removed, and --# only ac_max_sed_lines should be used. --: ${ac_max_here_lines=38} -+case X$ECHO in -+X*--fallback-echo) -+ # Remove one level of quotation (which was required for Make). -+ ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` -+ ;; -+esac - --# Identity of this package. --PACKAGE_NAME= --PACKAGE_TARNAME= --PACKAGE_VERSION= --PACKAGE_STRING= --PACKAGE_BUGREPORT= -+echo=${ECHO-echo} -+if test "X$1" = X--no-reexec; then -+ # Discard the --no-reexec flag, and continue. -+ shift -+elif test "X$1" = X--fallback-echo; then -+ # Avoid inline document here, it may be left over -+ : -+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then -+ # Yippee, $echo works! -+ : -+else -+ # Restart under the correct shell. -+ exec $SHELL "$0" --no-reexec ${1+"$@"} -+fi - --ac_unique_file="gsmlib/gsm_error.h" --# Factoring default headers for most tests. --ac_includes_default="\ --#include --#if HAVE_SYS_TYPES_H --# include --#endif --#if HAVE_SYS_STAT_H --# include --#endif --#if STDC_HEADERS --# include --# include --#else --# if HAVE_STDLIB_H --# include --# endif --#endif --#if HAVE_STRING_H --# if !STDC_HEADERS && HAVE_MEMORY_H --# include --# endif --# include --#endif --#if HAVE_STRINGS_H --# include --#endif --#if HAVE_INTTYPES_H --# include --#else --# if HAVE_STDINT_H --# include --# endif --#endif --#if HAVE_UNISTD_H --# include --#endif" -+if test "X$1" = X--fallback-echo; then -+ # used as fallback echo -+ shift -+ cat </dev/null 2>&1 && unset CDPATH -+ -+if test -z "$ECHO"; then -+if test "X${echo_test_string+set}" != Xset; then -+# find a string as large as possible, as long as the shell can cope with it -+ for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do -+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... -+ if (echo_test_string=`eval $cmd`) 2>/dev/null && -+ echo_test_string=`eval $cmd` && -+ (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null -+ then -+ break -+ fi -+ done -+fi -+ -+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ : -+else -+ # The Solaris, AIX, and Digital Unix default echo programs unquote -+ # backslashes. This makes it impossible to quote backslashes using -+ # echo "$something" | sed 's/\\/\\\\/g' -+ # -+ # So, first we look for a working echo in the user's PATH. -+ -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ for dir in $PATH /usr/ucb; do -+ IFS="$lt_save_ifs" -+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && -+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ echo="$dir/echo" -+ break -+ fi -+ done -+ IFS="$lt_save_ifs" -+ -+ if test "X$echo" = Xecho; then -+ # We didn't find a better echo, so look for alternatives. -+ if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ # This shell has a builtin print -r that does the trick. -+ echo='print -r' -+ elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && -+ test "X$CONFIG_SHELL" != X/bin/ksh; then -+ # If we have ksh, try running configure again with it. -+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -+ export ORIGINAL_CONFIG_SHELL -+ CONFIG_SHELL=/bin/ksh -+ export CONFIG_SHELL -+ exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} -+ else -+ # Try using printf. -+ echo='printf %s\n' -+ if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -+ echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ # Cool, printf works -+ : -+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && -+ test "X$echo_testing_string" = 'X\t' && -+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL -+ export CONFIG_SHELL -+ SHELL="$CONFIG_SHELL" -+ export SHELL -+ echo="$CONFIG_SHELL $0 --fallback-echo" -+ elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && -+ test "X$echo_testing_string" = 'X\t' && -+ echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && -+ test "X$echo_testing_string" = "X$echo_test_string"; then -+ echo="$CONFIG_SHELL $0 --fallback-echo" -+ else -+ # maybe with a smaller string... -+ prev=: -+ -+ for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do -+ if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null -+ then -+ break -+ fi -+ prev="$cmd" -+ done -+ -+ if test "$prev" != 'sed 50q "$0"'; then -+ echo_test_string=`eval $prev` -+ export echo_test_string -+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} -+ else -+ # Oops. We lost completely, so just stick with echo. -+ echo=echo -+ fi -+ fi -+ fi -+ fi -+fi -+fi -+ -+# Copy echo and quote the copy suitably for passing to libtool from -+# the Makefile, instead of quoting the original, which is used later. -+ECHO=$echo -+if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then -+ ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -+fi -+ -+ -+ -+ -+tagnames=${tagnames+${tagnames},}CXX -+ -+tagnames=${tagnames+${tagnames},}F77 -+ -+# Name of the host. -+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -+# so uname gets run too. -+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` -+ -+exec 6>&1 -+ -+# -+# Initializations. -+# -+ac_default_prefix=/usr/local -+ac_config_libobj_dir=. -+cross_compiling=no -+subdirs= -+MFLAGS= -+MAKEFLAGS= -+SHELL=${CONFIG_SHELL-/bin/sh} -+ -+# Maximum number of lines to put in a shell here document. -+# This variable seems obsolete. It should probably be removed, and -+# only ac_max_sed_lines should be used. -+: ${ac_max_here_lines=38} -+ -+# Identity of this package. -+PACKAGE_NAME= -+PACKAGE_TARNAME= -+PACKAGE_VERSION= -+PACKAGE_STRING= -+PACKAGE_BUGREPORT= -+ -+ac_unique_file="gsmlib/gsm_error.h" -+# Factoring default headers for most tests. -+ac_includes_default="\ -+#include -+#if HAVE_SYS_TYPES_H -+# include -+#endif -+#if HAVE_SYS_STAT_H -+# include -+#endif -+#if STDC_HEADERS -+# include -+# include -+#else -+# if HAVE_STDLIB_H -+# include -+# endif -+#endif -+#if HAVE_STRING_H -+# if !STDC_HEADERS && HAVE_MEMORY_H -+# include -+# endif -+# include -+#endif -+#if HAVE_STRINGS_H -+# include -+#endif -+#if HAVE_INTTYPES_H -+# include -+#else -+# if HAVE_STDINT_H -+# include -+# endif -+#endif -+#if HAVE_UNISTD_H -+# include -+#endif" - -+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL ALLOCA GSM_VERSION MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE GLIBC2 GLIBC21 INTL_MACOSX_LIBS HAVE_POSIX_PRINTF HAVE_ASPRINTF HAVE_SNPRINTF HAVE_WPRINTF LIBICONV LTLIBICONV INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX INTLLIBS LIBINTL LTLIBINTL POSUB COMPILE_INTL_TRUE COMPILE_INTL_FALSE LIBOBJS LTLIBOBJS' -+ac_subst_files='' - - # Initialize some variables set by options. - ac_init_help= -@@ -812,7 +822,7 @@ - - # Be sure to have absolute paths. - for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ -- localstatedir libdir includedir oldincludedir infodir mandir -+ localstatedir libdir includedir oldincludedir infodir mandir - do - eval ac_val=$`echo $ac_var` - case $ac_val in -@@ -852,10 +862,10 @@ - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || - $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -- X"$0" : 'X\(//\)[^/]' \| \ -- X"$0" : 'X\(//\)$' \| \ -- X"$0" : 'X\(/\)' \| \ -- . : '\(.\)' 2>/dev/null || -+ X"$0" : 'X\(//\)[^/]' \| \ -+ X"$0" : 'X\(//\)$' \| \ -+ X"$0" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || - echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } -@@ -878,6 +888,9 @@ - { (exit 1); exit 1; }; } - fi - fi -+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || -+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 -+ { (exit 1); exit 1; }; } - srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` - ac_env_build_alias_set=${build_alias+set} - ac_env_build_alias_value=$build_alias -@@ -919,6 +932,18 @@ - ac_env_CXXFLAGS_value=$CXXFLAGS - ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} - ac_cv_env_CXXFLAGS_value=$CXXFLAGS -+ac_env_CXXCPP_set=${CXXCPP+set} -+ac_env_CXXCPP_value=$CXXCPP -+ac_cv_env_CXXCPP_set=${CXXCPP+set} -+ac_cv_env_CXXCPP_value=$CXXCPP -+ac_env_F77_set=${F77+set} -+ac_env_F77_value=$F77 -+ac_cv_env_F77_set=${F77+set} -+ac_cv_env_F77_value=$F77 -+ac_env_FFLAGS_set=${FFLAGS+set} -+ac_env_FFLAGS_value=$FFLAGS -+ac_cv_env_FFLAGS_set=${FFLAGS+set} -+ac_cv_env_FFLAGS_value=$FFLAGS - - # - # Report the --help message. -@@ -952,9 +977,9 @@ - cat <<_ACEOF - Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX -- [$ac_default_prefix] -+ [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX -- [PREFIX] -+ [PREFIX] - - By default, \`make install' will install all the files in - \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -@@ -998,24 +1023,31 @@ - Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] -- --disable-dependency-tracking Speeds up one-time builds -- --enable-dependency-tracking Do not reject slow dependency extractors -- --enable-shared=PKGS build shared libraries default=yes -- --enable-static=PKGS build static libraries default=yes -- --enable-fast-install=PKGS optimize for fast installation default=yes -+ --disable-dependency-tracking speeds up one-time build -+ --enable-dependency-tracking do not reject slow dependency extractors -+ --enable-shared[=PKGS] -+ build shared libraries [default=yes] -+ --enable-static[=PKGS] -+ build static libraries [default=yes] -+ --enable-fast-install[=PKGS] -+ optimize for fast installation [default=yes] - --disable-libtool-lock avoid locking (might break parallel builds) -- --disable-rpath do not hardcode runtime library paths - --disable-nls do not use Native Language Support -+ --disable-rpath do not hardcode runtime library paths - - Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) -+ --with-gnu-ld assume the C compiler uses GNU ld [default=no] -+ --with-pic try to use only PIC/non-PIC objects [default=use -+ both] -+ --with-tags[=TAGS] -+ include additional configurations [automatic] - --with-gnu-ld assume the C compiler uses GNU ld default=no -- --with-pic try to use only PIC/non-PIC objects default=use both -- --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib -+ --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib - --without-libiconv-prefix don't search for libiconv in includedir and libdir - --with-included-gettext use the GNU gettext library included here -- --with-libintl-prefix=DIR search for libintl in DIR/include and DIR/lib -+ --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib - --without-libintl-prefix don't search for libintl in includedir and libdir - - Some influential environment variables: -@@ -1028,6 +1060,9 @@ - CPP C preprocessor - CXX C++ compiler command - CXXFLAGS C++ compiler flags -+ CXXCPP C++ preprocessor -+ F77 Fortran 77 compiler command -+ FFLAGS Fortran 77 compiler flags - - Use these variables to override the choices made by `configure' or to help - it to find libraries and programs with nonstandard names/locations. -@@ -1065,12 +1100,45 @@ - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; - esac --# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be --# absolute. --ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` --ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` --ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` --ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` -+ -+# Do not use `cd foo && pwd` to compute absolute paths, because -+# the directories may not exist. -+case `pwd` in -+.) ac_abs_builddir="$ac_dir";; -+*) -+ case "$ac_dir" in -+ .) ac_abs_builddir=`pwd`;; -+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; -+ *) ac_abs_builddir=`pwd`/"$ac_dir";; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_top_builddir=${ac_top_builddir}.;; -+*) -+ case ${ac_top_builddir}. in -+ .) ac_abs_top_builddir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; -+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_srcdir=$ac_srcdir;; -+*) -+ case $ac_srcdir in -+ .) ac_abs_srcdir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; -+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_top_srcdir=$ac_top_srcdir;; -+*) -+ case $ac_top_srcdir in -+ .) ac_abs_top_srcdir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; -+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; -+ esac;; -+esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. -@@ -1081,13 +1149,13 @@ - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || -- test -f $ac_srcdir/configure.in; then -+ test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi -- cd $ac_popdir -+ cd "$ac_popdir" - done - fi - -@@ -1095,8 +1163,7 @@ - if $ac_init_version; then - cat <<\_ACEOF - --Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 --Free Software Foundation, Inc. -+Copyright (C) 2003 Free Software Foundation, Inc. - This configure script is free software; the Free Software Foundation - gives unlimited permission to copy, distribute and modify it. - _ACEOF -@@ -1108,7 +1175,7 @@ - running configure, to aid debugging if configure makes a mistake. - - It was created by $as_me, which was --generated by GNU Autoconf 2.53. Invocation command line was -+generated by GNU Autoconf 2.59. Invocation command line was - - $ $0 $@ - -@@ -1160,27 +1227,54 @@ - - # Keep a trace of the command line. - # Strip out --no-create and --no-recursion so they do not pile up. -+# Strip out --silent because we don't want to record it for future runs. - # Also quote any args containing shell meta-characters. -+# Make two passes to allow for proper duplicate-argument suppression. - ac_configure_args= -+ac_configure_args0= -+ac_configure_args1= - ac_sep= --for ac_arg -+ac_must_keep_next=false -+for ac_pass in 1 2 - do -- case $ac_arg in -- -no-create | --no-create | --no-creat | --no-crea | --no-cre \ -- | --no-cr | --no-c | -n ) continue ;; -- -no-recursion | --no-recursion | --no-recursio | --no-recursi \ -- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) -- continue ;; -- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) -- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; -- esac -- case " $ac_configure_args " in -- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. -- *) ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" -- ac_sep=" " ;; -- esac -- # Get rid of the leading space. -+ for ac_arg -+ do -+ case $ac_arg in -+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ -+ | -silent | --silent | --silen | --sile | --sil) -+ continue ;; -+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) -+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; -+ esac -+ case $ac_pass in -+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; -+ 2) -+ ac_configure_args1="$ac_configure_args1 '$ac_arg'" -+ if test $ac_must_keep_next = true; then -+ ac_must_keep_next=false # Got value, back to normal. -+ else -+ case $ac_arg in -+ *=* | --config-cache | -C | -disable-* | --disable-* \ -+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ -+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ -+ | -with-* | --with-* | -without-* | --without-* | --x) -+ case "$ac_configure_args0 " in -+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; -+ esac -+ ;; -+ -* ) ac_must_keep_next=true ;; -+ esac -+ fi -+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" -+ # Get rid of the leading space. -+ ac_sep=" " -+ ;; -+ esac -+ done - done -+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - - # When interrupted or exit'd, cleanup temporary files, and complete - # config.log. We remove comments because anyway the quotes in there -@@ -1191,6 +1285,7 @@ - # Save into config.log some information that might help in debugging. - { - echo -+ - cat <<\_ASBOX - ## ---------------- ## - ## Cache variables. ## -@@ -1203,16 +1298,45 @@ - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) - sed -n \ -- "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; -- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" -+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; -+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; - *) - sed -n \ -- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" -+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; - } - echo -+ -+ cat <<\_ASBOX -+## ----------------- ## -+## Output variables. ## -+## ----------------- ## -+_ASBOX -+ echo -+ for ac_var in $ac_subst_vars -+ do -+ eval ac_val=$`echo $ac_var` -+ echo "$ac_var='"'"'$ac_val'"'"'" -+ done | sort -+ echo -+ -+ if test -n "$ac_subst_files"; then -+ cat <<\_ASBOX -+## ------------- ## -+## Output files. ## -+## ------------- ## -+_ASBOX -+ echo -+ for ac_var in $ac_subst_files -+ do -+ eval ac_val=$`echo $ac_var` -+ echo "$ac_var='"'"'$ac_val'"'"'" -+ done | sort -+ echo -+ fi -+ - if test -s confdefs.h; then - cat <<\_ASBOX - ## ----------- ## -@@ -1220,14 +1344,14 @@ - ## ----------- ## - _ASBOX - echo -- sed "/^$/d" confdefs.h -+ sed "/^$/d" confdefs.h | sort - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 -- rm -f core core.* *.core && -+ rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status - ' 0 -@@ -1307,7 +1431,7 @@ - # value. - ac_cache_corrupted=false - for ac_var in `(set) 2>&1 | -- sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do -+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" -@@ -1324,13 +1448,13 @@ - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then -- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 - echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} -- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 - echo "$as_me: former value: $ac_old_val" >&2;} -- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 - echo "$as_me: current value: $ac_new_val" >&2;} -- ac_cache_corrupted=: -+ ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. -@@ -1378,6 +1502,7 @@ - - - -+ - ac_aux_dir= - for ac_dir in scripts $srcdir/scripts; do - if test -f $ac_dir/install-sh; then -@@ -1414,6 +1539,7 @@ - # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag - # AFS /usr/afsws/bin/install, which mishandles nonexistent args - # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -+# OS/2's system install, which has a completely different semantic - # ./install, which can be erroneously created by make from ./install.sh. - echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 - echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 -@@ -1430,6 +1556,7 @@ - case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ -+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. -@@ -1437,20 +1564,20 @@ - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then -- if test $ac_prog = install && -- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then -- # AIX install. It has an incompatible calling convention. -- : -- elif test $ac_prog = install && -- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then -- # program-specific install script used by HP pwplus--don't use. -- : -- else -- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" -- break 3 -- fi -- fi -+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then -+ if test $ac_prog = install && -+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then -+ # AIX install. It has an incompatible calling convention. -+ : -+ elif test $ac_prog = install && -+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then -+ # program-specific install script used by HP pwplus--don't use. -+ : -+ else -+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" -+ break 3 -+ fi -+ fi - done - done - ;; -@@ -1685,9 +1812,7 @@ - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift -- set dummy "$as_dir/$ac_word" ${1+"$@"} -- shift -- ac_cv_prog_CC="$@" -+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi - fi - fi -@@ -1792,8 +1917,10 @@ - fi - - --test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH" >&5 --echo "$as_me: error: no acceptable C compiler found in \$PATH" >&2;} -+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -+See \`config.log' for more details." >&5 -+echo "$as_me: error: no acceptable C compiler found in \$PATH -+See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - - # Provide some information about the compiler. -@@ -1817,15 +1944,12 @@ - (exit $ac_status); } - - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -1835,12 +1959,12 @@ - } - _ACEOF - ac_clean_files_save=$ac_clean_files --ac_clean_files="$ac_clean_files a.out a.exe" -+ac_clean_files="$ac_clean_files a.out a.exe b.out" - # Try to create an executable without -o first, disregard a.out. - # It will help us diagnose broken compilers, and finding out an intuition - # of exeext. --echo "$as_me:$LINENO: checking for C compiler default output" >&5 --echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 -+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 - ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 -@@ -1854,26 +1978,39 @@ - # Be careful to initialize this variable, since it used to be cached. - # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. - ac_cv_exeext= --for ac_file in `ls a_out.exe a.exe conftest.exe 2>/dev/null; -- ls a.out conftest 2>/dev/null; -- ls a.* conftest.* 2>/dev/null`; do -+# b.out is created by i960 compilers. -+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -+do -+ test -f "$ac_file" || continue - case $ac_file in -- *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb | *.xSYM ) ;; -- a.out ) # We found the default executable, but exeext='' is most -- # certainly right. -- break;; -- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` -- # FIXME: I believe we export ac_cv_exeext for Libtool --akim. -- export ac_cv_exeext -- break;; -- * ) break;; -+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) -+ ;; -+ conftest.$ac_ext ) -+ # This is the source file. -+ ;; -+ [ab].out ) -+ # We found the default executable, but exeext='' is most -+ # certainly right. -+ break;; -+ *.* ) -+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` -+ # FIXME: I believe we export ac_cv_exeext for Libtool, -+ # but it would be cool to find out if it's true. Does anybody -+ # maintain Libtool? --akim. -+ export ac_cv_exeext -+ break;; -+ * ) -+ break;; - esac - done - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --{ { echo "$as_me:$LINENO: error: C compiler cannot create executables" >&5 --echo "$as_me: error: C compiler cannot create executables" >&2;} -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -+See \`config.log' for more details." >&5 -+echo "$as_me: error: C compiler cannot create executables -+See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - fi - -@@ -1900,9 +2037,11 @@ - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. --If you meant to cross compile, use \`--host'." >&5 -+If you meant to cross compile, use \`--host'. -+See \`config.log' for more details." >&5 - echo "$as_me: error: cannot run C compiled programs. --If you meant to cross compile, use \`--host'." >&2;} -+If you meant to cross compile, use \`--host'. -+See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -@@ -1910,7 +2049,7 @@ - echo "$as_me:$LINENO: result: yes" >&5 - echo "${ECHO_T}yes" >&6 - --rm -f a.out a.exe conftest$ac_cv_exeext -+rm -f a.out a.exe conftest$ac_cv_exeext b.out - ac_clean_files=$ac_clean_files_save - # Check the compiler produces executables we can run. If not, either - # the compiler is broken, or we cross compile. -@@ -1930,18 +2069,21 @@ - # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will - # work properly (i.e., refer to `conftest.exe'), while it won't with - # `rm'. --for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do -+for ac_file in conftest.exe conftest conftest.*; do -+ test -f "$ac_file" || continue - case $ac_file in -- *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; -+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` -- export ac_cv_exeext -- break;; -+ export ac_cv_exeext -+ break;; - * ) break;; - esac - done - else -- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link" >&5 --echo "$as_me: error: cannot compute suffix of executables: cannot compile and link" >&2;} -+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -+See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - -@@ -1958,15 +2100,12 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -1983,16 +2122,19 @@ - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in -- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; -+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac - done - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile" >&5 --echo "$as_me: error: cannot compute suffix of object files: cannot compile" >&2;} -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute suffix of object files: cannot compile -+See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - -@@ -2008,15 +2150,12 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -2030,11 +2169,20 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2043,10 +2191,11 @@ - ac_compiler_gnu=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ac_compiler_gnu=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cv_c_compiler_gnu=$ac_compiler_gnu - - fi -@@ -2062,15 +2211,12 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -2081,11 +2227,20 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2094,10 +2249,11 @@ - ac_cv_prog_cc_g=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ac_cv_prog_cc_g=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 - echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 -@@ -2116,6 +2272,120 @@ - CFLAGS= - fi - fi -+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -+if test "${ac_cv_prog_cc_stdc+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_cv_prog_cc_stdc=no -+ac_save_CC=$CC -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+#include -+#include -+#include -+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -+struct buf { int x; }; -+FILE * (*rcsopen) (struct buf *, struct stat *, int); -+static char *e (p, i) -+ char **p; -+ int i; -+{ -+ return p[i]; -+} -+static char *f (char * (*g) (char **, int), char **p, ...) -+{ -+ char *s; -+ va_list v; -+ va_start (v,p); -+ s = g (p, va_arg (v,int)); -+ va_end (v); -+ return s; -+} -+ -+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has -+ function prototypes and stuff, but not '\xHH' hex character constants. -+ These don't provoke an error unfortunately, instead are silently treated -+ as 'x'. The following induces an error, until -std1 is added to get -+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an -+ array size at least. It's necessary to write '\x00'==0 to get something -+ that's true only with -std1. */ -+int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -+ -+int test (int i, double x); -+struct s1 {int (*f) (int a);}; -+struct s2 {int (*f) (double a);}; -+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -+int argc; -+char **argv; -+int -+main () -+{ -+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; -+ ; -+ return 0; -+} -+_ACEOF -+# Don't try gcc -ansi; that turns off useful extensions and -+# breaks some systems' header files. -+# AIX -qlanglvl=ansi -+# Ultrix and OSF/1 -std1 -+# HP-UX 10.20 and later -Ae -+# HP-UX older versions -Aa -D_HPUX_SOURCE -+# SVR4 -Xc -D__EXTENSIONS__ -+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -+do -+ CC="$ac_save_CC $ac_arg" -+ rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_prog_cc_stdc=$ac_arg -+break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext -+done -+rm -f conftest.$ac_ext conftest.$ac_objext -+CC=$ac_save_CC -+ -+fi -+ -+case "x$ac_cv_prog_cc_stdc" in -+ x|xno) -+ echo "$as_me:$LINENO: result: none needed" >&5 -+echo "${ECHO_T}none needed" >&6 ;; -+ *) -+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 -+ CC="$CC $ac_cv_prog_cc_stdc" ;; -+esac -+ - # Some people use a C++ compiler to compile C. Since we use `exit', - # in C++ we need to declare it. In case someone uses the same compiler - # for both compiling C and C++ we need to have the C++ compiler decide -@@ -2127,19 +2397,27 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ -- ''\ -- '#include ' \ -+ '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ -@@ -2147,16 +2425,13 @@ - 'void exit (int);' - do - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_declaration --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+#include - int - main () - { -@@ -2167,11 +2442,20 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2180,20 +2464,18 @@ - : - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - continue - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_declaration --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -2204,11 +2486,20 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2217,9 +2508,10 @@ - break - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done - rm -f conftest* - if test -n "$ac_declaration"; then -@@ -2230,9 +2522,10 @@ - - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - ac_ext=c - ac_cpp='$CPP $CPPFLAGS' - ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -@@ -2249,8 +2542,11 @@ - ac_check_lib_save_LIBS=$LIBS - LIBS="-lintl $LIBS" - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - - /* Override any gcc2 internal prototype to avoid an error. */ - #ifdef __cplusplus -@@ -2259,12 +2555,6 @@ - /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ - char textdomain (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -2275,11 +2565,20 @@ - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2288,10 +2587,12 @@ - ac_cv_lib_intl_textdomain=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ac_cv_lib_intl_textdomain=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - LIBS=$ac_check_lib_save_LIBS - fi - echo "$as_me:$LINENO: result: $ac_cv_lib_intl_textdomain" >&5 -@@ -2306,14 +2607,10 @@ - fi - - --# Add the stamp file to the list of files AC keeps track of, --# along with our hook. --ac_config_headers="$ac_config_headers gsm_config.h" -+ ac_config_headers="$ac_config_headers gsm_config.h" - - -- -- --am__api_version="1.6" -+am__api_version="1.9" - echo "$as_me:$LINENO: checking whether build environment is sane" >&5 - echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 - # Just in case -@@ -2372,7 +2669,6 @@ - program_transform_name=`echo $program_transform_name | sed -f conftest.sed` - rm conftest.sed - -- - # expand $ac_aux_dir to an absolute path - am_aux_dir=`cd $ac_aux_dir && pwd` - -@@ -2386,6 +2682,39 @@ - echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} - fi - -+if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then -+ # We used to keeping the `.' as first argument, in order to -+ # allow $(mkdir_p) to be used without argument. As in -+ # $(mkdir_p) $(somedir) -+ # where $(somedir) is conditionally defined. However this is wrong -+ # for two reasons: -+ # 1. if the package is installed by a user who cannot write `.' -+ # make install will fail, -+ # 2. the above comment should most certainly read -+ # $(mkdir_p) $(DESTDIR)$(somedir) -+ # so it does not work when $(somedir) is undefined and -+ # $(DESTDIR) is not. -+ # To support the latter case, we have to write -+ # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), -+ # so the `.' trick is pointless. -+ mkdir_p='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. -+ for d in ./-p ./--version; -+ do -+ test -d $d && rmdir $d -+ done -+ # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. -+ if test -f "$ac_aux_dir/mkinstalldirs"; then -+ mkdir_p='$(mkinstalldirs)' -+ else -+ mkdir_p='$(install_sh) -d' -+ fi -+fi -+ - for ac_prog in gawk mawk nawk awk - do - # Extract the first word of "$ac_prog", so it can be a program name with args. -@@ -2426,15 +2755,15 @@ - test -n "$AWK" && break - done - --echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \${MAKE}" >&5 --echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 --set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` -+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` - if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.make <<\_ACEOF - all: -- @echo 'ac_maketemp="${MAKE}"' -+ @echo 'ac_maketemp="$(MAKE)"' - _ACEOF - # GNU make sometimes prints "make[1]: Entering...", which would confuse us. - eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -@@ -2455,24 +2784,25 @@ - SET_MAKE="MAKE=${MAKE-make}" - fi - --rm -f .deps 2>/dev/null --mkdir .deps 2>/dev/null --if test -d .deps; then -- DEPDIR=.deps -+rm -rf .tst 2>/dev/null -+mkdir .tst 2>/dev/null -+if test -d .tst; then -+ am__leading_dot=. - else -- # MS-DOS does not allow filenames that begin with a dot. -- DEPDIR=_deps -+ am__leading_dot=_ - fi --rmdir .deps 2>/dev/null -+rmdir .tst 2>/dev/null - -+DEPDIR="${am__leading_dot}deps" - --ac_config_commands="$ac_config_commands depfiles" -+ ac_config_commands="$ac_config_commands depfiles" - - - am_make=${MAKE-make} - cat > confinc << 'END' --doit: -+am__doit: - @echo done -+.PHONY: am__doit - END - # If we don't find an include directive, just comment out the code. - echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 -@@ -2487,7 +2817,7 @@ - # In particular we don't look at `^make:' because GNU make might - # be invoked under some other name (usually "gmake"), in which - # case it prints its new name instead of `make'. --if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then -+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -@@ -2528,7 +2858,7 @@ - - - -- # test to see if srcdir already configured -+# test to see if srcdir already configured - if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -@@ -2536,6 +2866,16 @@ - { (exit 1); exit 1; }; } - fi - -+# test whether we have cygpath -+if test -z "$CYGPATH_W"; then -+ if (cygpath --version) >/dev/null 2>/dev/null; then -+ CYGPATH_W='cygpath -w' -+ else -+ CYGPATH_W=echo -+ fi -+fi -+ -+ - # Define the identity of the package. - PACKAGE=gsmlib - VERSION=1.10 -@@ -2566,9 +2906,6 @@ - - MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -- --AMTAR=${AMTAR-"${am_missing_run}tar"} -- - install_sh=${install_sh-"$am_aux_dir/install-sh"} - - # Installed binaries are usually stripped using `strip' when the user -@@ -2661,6 +2998,13 @@ - - # We need awk for the "check" target. The system "awk" is bad on - # some platforms. -+# Always define AMTAR for backward compatibility. -+ -+AMTAR=${AMTAR-"${am_missing_run}tar"} -+ -+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' -+ -+ - - - depcc="$CC" am_compiler_list= -@@ -2681,18 +3025,34 @@ - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir -+ # We will build objects and dependencies in a subdirectory because -+ # it helps to detect inapplicable dependency modes. For instance -+ # both Tru64's cc and ICC support -MD to output dependencies as a -+ # side effect of compilation, but ICC will put the dependencies in -+ # the current directory while Tru64 will put them in the object -+ # directory. -+ mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - for depmode in $am_compiler_list; do -+ # Setup a source with many dependencies, because some compilers -+ # like to wrap large dependency lists on column 80 (with \), and -+ # we should not choose a depcomp mode which is confused by this. -+ # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. -- echo '#include "conftest.h"' > conftest.c -- echo 'int i;' > conftest.h -- echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf -+ : > sub/conftest.c -+ for i in 1 2 3 4 5 6; do -+ echo '#include "conftst'$i'.h"' >> sub/conftest.c -+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with -+ # Solaris 8's {/usr,}/bin/sh. -+ touch sub/conftst$i.h -+ done -+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) -@@ -2710,13 +3070,25 @@ - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ -- source=conftest.c object=conftest.o \ -- depfile=conftest.Po tmpdepfile=conftest.TPo \ -- $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && -- grep conftest.h conftest.Po > /dev/null 2>&1 && -+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ -+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ -+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ -+ >/dev/null 2>conftest.err && -+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && -+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then -- am_cv_CC_dependencies_compiler_type=$depmode -- break -+ # icc doesn't choke on unknown options, it will just issue warnings -+ # or remarks (even with -Werror). So we grep stderr for any message -+ # that says an option was ignored or not supported. -+ # When given -MP, icc 7.0 and 7.1 complain thusly: -+ # icc: Command line warning: ignoring option '-M'; no argument required -+ # The diagnosis changed in icc 8.0: -+ # icc: Command line remark: option '-MP' not supported -+ if (grep 'ignoring option' conftest.err || -+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else -+ am_cv_CC_dependencies_compiler_type=$depmode -+ break -+ fi - fi - done - -@@ -2733,30 +3105,44 @@ - - - -+if -+ test "x$enable_dependency_tracking" != xno \ -+ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then -+ am__fastdepCC_TRUE= -+ am__fastdepCC_FALSE='#' -+else -+ am__fastdepCC_TRUE='#' -+ am__fastdepCC_FALSE= -+fi -+ -+ -+ - - # Check whether --enable-shared or --disable-shared was given. - if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - p=${PACKAGE-default} --case $enableval in --yes) enable_shared=yes ;; --no) enable_shared=no ;; --*) -- enable_shared=no -- # Look at the argument we got. We use all the common list separators. -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," -- for pkg in $enableval; do -- if test "X$pkg" = "X$p"; then -- enable_shared=yes -- fi -- done -- IFS="$ac_save_ifs" -- ;; --esac -+ case $enableval in -+ yes) enable_shared=yes ;; -+ no) enable_shared=no ;; -+ *) -+ enable_shared=no -+ # Look at the argument we got. We use all the common list separators. -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for pkg in $enableval; do -+ IFS="$lt_save_ifs" -+ if test "X$pkg" = "X$p"; then -+ enable_shared=yes -+ fi -+ done -+ IFS="$lt_save_ifs" -+ ;; -+ esac - else - enable_shared=yes - fi; - -+ - if test "$CXXFLAGS" = ""; then - CXXFLAGS="-O2" - fi -@@ -2774,46 +3160,50 @@ - if test "${enable_static+set}" = set; then - enableval="$enable_static" - p=${PACKAGE-default} --case $enableval in --yes) enable_static=yes ;; --no) enable_static=no ;; --*) -- enable_static=no -- # Look at the argument we got. We use all the common list separators. -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," -- for pkg in $enableval; do -- if test "X$pkg" = "X$p"; then -- enable_static=yes -- fi -- done -- IFS="$ac_save_ifs" -- ;; --esac -+ case $enableval in -+ yes) enable_static=yes ;; -+ no) enable_static=no ;; -+ *) -+ enable_static=no -+ # Look at the argument we got. We use all the common list separators. -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for pkg in $enableval; do -+ IFS="$lt_save_ifs" -+ if test "X$pkg" = "X$p"; then -+ enable_static=yes -+ fi -+ done -+ IFS="$lt_save_ifs" -+ ;; -+ esac - else - enable_static=yes - fi; -+ - # Check whether --enable-fast-install or --disable-fast-install was given. - if test "${enable_fast_install+set}" = set; then - enableval="$enable_fast_install" - p=${PACKAGE-default} --case $enableval in --yes) enable_fast_install=yes ;; --no) enable_fast_install=no ;; --*) -- enable_fast_install=no -- # Look at the argument we got. We use all the common list separators. -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," -- for pkg in $enableval; do -- if test "X$pkg" = "X$p"; then -- enable_fast_install=yes -- fi -- done -- IFS="$ac_save_ifs" -- ;; --esac -+ case $enableval in -+ yes) enable_fast_install=yes ;; -+ no) enable_fast_install=no ;; -+ *) -+ enable_fast_install=no -+ # Look at the argument we got. We use all the common list separators. -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for pkg in $enableval; do -+ IFS="$lt_save_ifs" -+ if test "X$pkg" = "X$p"; then -+ enable_fast_install=yes -+ fi -+ done -+ IFS="$lt_save_ifs" -+ ;; -+ esac - else - enable_fast_install=yes - fi; -+ - # Make sure we can run config.sub. - $ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -@@ -2868,16 +3258,77 @@ - host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - --# Find the correct PATH separator. Usually this is `:', but --# DJGPP uses `;' like DOS. --if test "X${PATH_SEPARATOR+set}" != Xset; then -- UNAME=${UNAME-`uname 2>/dev/null`} -- case X$UNAME in -- *-DOS) lt_cv_sys_path_separator=';' ;; -- *) lt_cv_sys_path_separator=':' ;; -- esac -- PATH_SEPARATOR=$lt_cv_sys_path_separator -+echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 -+echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 -+if test "${lt_cv_path_SED+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ # Loop through the user's path and test for sed and gsed. -+# Then use that list of sed's as ones to test for truncation. -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for lt_ac_prog in sed gsed; do -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then -+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" -+ fi -+ done -+ done -+done -+lt_ac_max=0 -+lt_ac_count=0 -+# Add /usr/xpg4/bin/sed as it is typically found on Solaris -+# along with /bin/sed that truncates output. -+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do -+ test ! -f $lt_ac_sed && continue -+ cat /dev/null > conftest.in -+ lt_ac_count=0 -+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in -+ # Check for GNU sed and select it if it is found. -+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then -+ lt_cv_path_SED=$lt_ac_sed -+ break -+ fi -+ while true; do -+ cat conftest.in conftest.in >conftest.tmp -+ mv conftest.tmp conftest.in -+ cp conftest.in conftest.nl -+ echo >>conftest.nl -+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break -+ cmp -s conftest.out conftest.nl || break -+ # 10000 chars as input seems more than enough -+ test $lt_ac_count -gt 10 && break -+ lt_ac_count=`expr $lt_ac_count + 1` -+ if test $lt_ac_count -gt $lt_ac_max; then -+ lt_ac_max=$lt_ac_count -+ lt_cv_path_SED=$lt_ac_sed -+ fi -+ done -+done -+ -+fi -+ -+SED=$lt_cv_path_SED -+echo "$as_me:$LINENO: result: $SED" >&5 -+echo "${ECHO_T}$SED" >&6 -+ -+echo "$as_me:$LINENO: checking for egrep" >&5 -+echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -+if test "${ac_cv_prog_egrep+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1 -+ then ac_cv_prog_egrep='grep -E' -+ else ac_cv_prog_egrep='egrep' -+ fi - fi -+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -+echo "${ECHO_T}$ac_cv_prog_egrep" >&6 -+ EGREP=$ac_cv_prog_egrep -+ - - - # Check whether --with-gnu-ld or --without-gnu-ld was given. -@@ -2890,8 +3341,8 @@ - ac_prog=ld - if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. -- echo "$as_me:$LINENO: checking for ld used by GCC" >&5 --echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 -+ echo "$as_me:$LINENO: checking for ld used by $CC" >&5 -+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw -@@ -2901,12 +3352,12 @@ - esac - case $ac_prog in - # Accept absolute paths. -- [\\/]* | [A-Za-z]:[\\/]*) -+ [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' -- # Canonicalize the path of ld -- ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` -+ # Canonicalize the pathname of ld -+ ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -- ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` -+ ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; -@@ -2930,22 +3381,26 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - if test -z "$LD"; then -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do -+ IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, -- # but apparently some GNU ld's only accept -v. -+ # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. -- if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then -+ case `"$lt_cv_path_LD" -v 2>&1 &6 - else -- # I'd rather use --version here, but apparently some GNU ld's only accept -v. --if $LD -v 2>&1 &5; then -+ # I'd rather use --version here, but apparently some GNU lds only accept -v. -+case `$LD -v 2>&1 &5 - echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 -@@ -2989,7 +3447,20 @@ - echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 - echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 - reload_flag=$lt_cv_ld_reload_flag --test -n "$reload_flag" && reload_flag=" $reload_flag" -+case $reload_flag in -+"" | " "*) ;; -+*) reload_flag=" $reload_flag" ;; -+esac -+reload_cmds='$LD$reload_flag -o $output$reload_objs' -+case $host_os in -+ darwin*) -+ if test "$GCC" = yes; then -+ reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs' -+ else -+ reload_cmds='$LD$reload_flag -o $output$reload_objs' -+ fi -+ ;; -+esac - - echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 - echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 -@@ -3000,35 +3471,42 @@ - # Let the user override the test. - lt_cv_path_NM="$NM" - else -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do -+ IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. -- tmp_nm=$ac_dir/${ac_tool_prefix}nm -- if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then -+ tmp_nm="$ac_dir/${ac_tool_prefix}nm" -+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file -- if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then -+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in -+ */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break -- elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then -- lt_cv_path_NM="$tmp_nm -p" -- break -- else -- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but -- continue # so that we can try to find one that supports BSD flags -- fi -+ ;; -+ *) -+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in -+ */dev/null*) -+ lt_cv_path_NM="$tmp_nm -p" -+ break -+ ;; -+ *) -+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but -+ continue # so that we can try to find one that supports BSD flags -+ ;; -+ esac -+ esac - fi - done -- IFS="$ac_save_ifs" -+ IFS="$lt_save_ifs" - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm - fi - fi -- -+echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 -+echo "${ECHO_T}$lt_cv_path_NM" >&6 - NM="$lt_cv_path_NM" --echo "$as_me:$LINENO: result: $NM" >&5 --echo "${ECHO_T}$NM" >&6 - - echo "$as_me:$LINENO: checking whether ln -s works" >&5 - echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 -@@ -3041,8 +3519,8 @@ - echo "${ECHO_T}no, using $LN_S" >&6 - fi - --echo "$as_me:$LINENO: checking how to recognise dependant libraries" >&5 --echo $ECHO_N "checking how to recognise dependant libraries... $ECHO_C" >&6 -+echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 -+echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 - if test "${lt_cv_deplibs_check_method+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -@@ -3056,7 +3534,7 @@ - # 'pass_all' -- all dependencies passed with no checks. - # 'test_compile' -- check by making test program. - # 'file_magic [[regex]]' -- check by looking for files in library path --# which responds to the $file_magic_cmd with a given egrep regex. -+# which responds to the $file_magic_cmd with a given extended regex. - # If you have `file' or equivalent on your system and you're not sure - # whether `pass_all' will *always* work, you probably want this one. - -@@ -3069,37 +3547,36 @@ - lt_cv_deplibs_check_method=pass_all - ;; - --bsdi4*) -+bsdi[45]*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - --cygwin* | mingw* | pw32*) -+cygwin*) -+ # func_win32_libid is a shell function defined in ltmain.sh -+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' -+ lt_cv_file_magic_cmd='func_win32_libid' -+ ;; -+ -+mingw* | pw32*) -+ # Base MSYS/MinGW do not provide the 'file' command needed by -+ # func_win32_libid shell function, so use a weaker test based on 'objdump'. - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - - darwin* | rhapsody*) -- lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' -- lt_cv_file_magic_cmd='/usr/bin/file -L' -- case "$host_os" in -- rhapsody* | darwin1.[012]) -- lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` -- ;; -- *) # Darwin 1.3 on -- lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' -- ;; -- esac -+ lt_cv_deplibs_check_method=pass_all - ;; - --freebsd*) -+freebsd* | kfreebsd*-gnu | dragonfly*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. -- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' -+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; -@@ -3113,50 +3590,44 @@ - lt_cv_deplibs_check_method=pass_all - ;; - --hpux10.20*|hpux11*) -- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' -+hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file -- lt_cv_file_magic_test_file=/usr/lib/libc.sl -- ;; -- --irix5* | irix6*) -- case $host_os in -- irix5*) -- # this will be overridden with pass_all, but let us keep it just in case -- lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" -+ case $host_cpu in -+ ia64*) -+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' -+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so -+ ;; -+ hppa*64*) -+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' -+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) -- case $LD in -- *-32|*"-32 ") libmagic=32-bit;; -- *-n32|*"-n32 ") libmagic=N32;; -- *-64|*"-64 ") libmagic=64-bit;; -- *) libmagic=never-match;; -- esac -- # this will be overridden with pass_all, but let us keep it just in case -- lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" -+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' -+ lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac -- lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $LD in -+ *-32|*"-32 ") libmagic=32-bit;; -+ *-n32|*"-n32 ") libmagic=N32;; -+ *-64|*"-64 ") libmagic=64-bit;; -+ *) libmagic=never-match;; -+ esac - lt_cv_deplibs_check_method=pass_all - ;; - - # This must be Linux ELF. --linux-gnu*) -- case $host_cpu in -- alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* | s390* ) -- lt_cv_deplibs_check_method=pass_all ;; -- *) -- # glibc up to 2.1.1 does not perform some relocations on ARM -- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; -- esac -- lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` -+linux*) -+ lt_cv_deplibs_check_method=pass_all - ;; - --netbsd*) -+netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then -- lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$' -+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - else -- lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$' -+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' - fi - ;; - -@@ -3166,20 +3637,19 @@ - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -+nto-qnx*) -+ lt_cv_deplibs_check_method=unknown -+ ;; -+ - openbsd*) -- lt_cv_file_magic_cmd=/usr/bin/file -- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' -+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' - else -- lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' -+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - fi - ;; - - osf3* | osf4* | osf5*) -- # this will be overridden with pass_all, but let us keep it just in case -- lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' -- lt_cv_file_magic_test_file=/shlib/libc.so - lt_cv_deplibs_check_method=pass_all - ;; - -@@ -3189,11 +3659,6 @@ - - solaris*) - lt_cv_deplibs_check_method=pass_all -- lt_cv_file_magic_test_file=/lib/libc.so -- ;; -- --sysv5uw[78]* | sysv4*uw2*) -- lt_cv_deplibs_check_method=pass_all - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -@@ -3214,8 +3679,15 @@ - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; -+ siemens) -+ lt_cv_deplibs_check_method=pass_all -+ ;; - esac - ;; -+ -+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; - esac - - fi -@@ -3223,207 +3695,208 @@ - echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 - file_magic_cmd=$lt_cv_file_magic_cmd - deplibs_check_method=$lt_cv_deplibs_check_method -+test -z "$deplibs_check_method" && deplibs_check_method=unknown - - - - -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} - -+# Allow CC to be a program name with arguments. -+compiler=$CC - -+# Check whether --enable-libtool-lock or --disable-libtool-lock was given. -+if test "${enable_libtool_lock+set}" = set; then -+ enableval="$enable_libtool_lock" - --# Check for command to grab the raw symbol name followed by C symbol from nm. --echo "$as_me:$LINENO: checking command to parse $NM output" >&5 --echo $ECHO_N "checking command to parse $NM output... $ECHO_C" >&6 --if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- --# These are sane defaults that work on at least a few old systems. --# [They come from Ultrix. What could be older than Ultrix?!! ;)] -- --# Character class describing NM global symbol codes. --symcode='[BCDEGRST]' -- --# Regexp to match symbols that can be accessed directly from C. --sympat='\([_A-Za-z][_A-Za-z0-9]*\)' -- --# Transform the above into a raw symbol and a C symbol. --symxfrm='\1 \2\3 \3' -- --# Transform an extracted symbol line into a proper C declaration --lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" -- --# Transform an extracted symbol line into symbol name and symbol address --lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -- --# Define system-specific variables. --case $host_os in --aix*) -- symcode='[BCDT]' -- ;; --cygwin* | mingw* | pw32*) -- symcode='[ABCDGISTW]' -- ;; --hpux*) # Its linker distinguishes data from code symbols -- lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" -- lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -- ;; --irix*) -- symcode='[BCDEGRST]' -- ;; --solaris* | sysv5*) -- symcode='[BDT]' -- ;; --sysv4) -- symcode='[DFNSTU]' -- ;; --esac -- --# Handle CRLF in mingw tool chain --opt_cr= --case $host_os in --mingw*) -- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp -- ;; --esac -- --# If we're using GNU nm, then use its standard symbol codes. --if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then -- symcode='[ABCDGISTW]' --fi -- --# Try without a prefix undercore, then with it. --for ac_symprfx in "" "_"; do -- -- # Write the raw and C identifiers. --lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" -- -- # Check to see that the pipe works correctly. -- pipe_works=no -- rm -f conftest* -- cat > conftest.$ac_ext < conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then -- # Now try to grab the symbols. -- nlist=conftest.nm -- if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 -- (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 -+ case `/usr/bin/file conftest.$ac_objext` in -+ *ELF-32*) -+ HPUX_IA64_MODE="32" -+ ;; -+ *ELF-64*) -+ HPUX_IA64_MODE="64" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+*-*-irix6*) -+ # Find out which ABI we are using. -+ echo '#line 3740 "configure"' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && test -s "$nlist"; then -- # Try sorting and uniquifying the output. -- if sort "$nlist" | uniq > "$nlist"T; then -- mv -f "$nlist"T "$nlist" -- else -- rm -f "$nlist"T -- fi -+ (exit $ac_status); }; then -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *32-bit*) -+ LD="${LD-ld} -melf32bsmip" -+ ;; -+ *N32*) -+ LD="${LD-ld} -melf32bmipn32" -+ ;; -+ *64-bit*) -+ LD="${LD-ld} -melf64bmip" -+ ;; -+ esac -+ else -+ case `/usr/bin/file conftest.$ac_objext` in -+ *32-bit*) -+ LD="${LD-ld} -32" -+ ;; -+ *N32*) -+ LD="${LD-ld} -n32" -+ ;; -+ *64-bit*) -+ LD="${LD-ld} -64" -+ ;; -+ esac -+ fi -+ fi -+ rm -rf conftest* -+ ;; - -- # Make sure that we snagged all the symbols we need. -- if egrep ' nm_test_var$' "$nlist" >/dev/null; then -- if egrep ' nm_test_func$' "$nlist" >/dev/null; then -- cat < conftest.$ac_ext --#ifdef __cplusplus --extern "C" { --#endif -+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) -+ # Find out which ABI we are using. -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.o` in -+ *32-bit*) -+ case $host in -+ x86_64-*linux*) -+ LD="${LD-ld} -m elf_i386" -+ ;; -+ ppc64-*linux*|powerpc64-*linux*) -+ LD="${LD-ld} -m elf32ppclinux" -+ ;; -+ s390x-*linux*) -+ LD="${LD-ld} -m elf_s390" -+ ;; -+ sparc64-*linux*) -+ LD="${LD-ld} -m elf32_sparc" -+ ;; -+ esac -+ ;; -+ *64-bit*) -+ case $host in -+ x86_64-*linux*) -+ LD="${LD-ld} -m elf_x86_64" -+ ;; -+ ppc*-*linux*|powerpc*-*linux*) -+ LD="${LD-ld} -m elf64ppc" -+ ;; -+ s390*-*linux*) -+ LD="${LD-ld} -m elf64_s390" -+ ;; -+ sparc*-*linux*) -+ LD="${LD-ld} -m elf64_sparc" -+ ;; -+ esac -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; - --EOF -- # Now generate the symbol file. -- eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' -+*-*-sco3.2v5*) -+ # On SCO OpenServer 5, we need -belf to get full-featured binaries. -+ SAVE_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS -belf" -+ echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 -+echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 -+if test "${lt_cv_cc_needs_belf+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu - -- cat <> conftest.$ac_ext --#if defined (__STDC__) && __STDC__ --# define lt_ptr void * --#else --# define lt_ptr char * --# define const --#endif -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --/* The mapping between symbol names and symbols. */ --const struct { -- const char *name; -- lt_ptr address; --} --lt_preloaded_symbols[] = -+int -+main () - { --EOF -- sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext -- cat <<\EOF >> conftest.$ac_ext -- {0, (lt_ptr) 0} --}; - --#ifdef __cplusplus -+ ; -+ return 0; - } --#endif --EOF -- # Now try linking the two files. -- mv conftest.$ac_objext conftstm.$ac_objext -- save_LIBS="$LIBS" -- save_CFLAGS="$CFLAGS" -- LIBS="conftstm.$ac_objext" -- CFLAGS="$CFLAGS$no_builtin_flag" -- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && test -s conftest; then -- pipe_works=yes -- fi -- LIBS="$save_LIBS" -- CFLAGS="$save_CFLAGS" -- else -- echo "cannot find nm_test_func in $nlist" >&5 -- fi -- else -- echo "cannot find nm_test_var in $nlist" >&5 -- fi -- else -- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 -- fi -- else -- echo "$progname: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- fi -- rm -f conftest* conftst* -- -- # Do not use the global_symbol_pipe unless it works. -- if test "$pipe_works" = yes; then -- break -- else -- lt_cv_sys_global_symbol_pipe= -- fi --done -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ lt_cv_cc_needs_belf=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+lt_cv_cc_needs_belf=no - fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu - --global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" --if test -z "$lt_cv_sys_global_symbol_pipe"; then -- global_symbol_to_cdecl= -- global_symbol_to_c_name_address= --else -- global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" -- global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" --fi --if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; --then -- echo "$as_me:$LINENO: result: failed" >&5 --echo "${ECHO_T}failed" >&6 --else -- echo "$as_me:$LINENO: result: ok" >&5 --echo "${ECHO_T}ok" >&6 - fi -+echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 -+echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 -+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then -+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf -+ CFLAGS="$SAVE_CFLAGS" -+ fi -+ ;; -+ -+esac -+ -+need_locks="$enable_libtool_lock" -+ - - ac_ext=c - ac_cpp='$CPP $CPPFLAGS' -@@ -3448,24 +3921,34 @@ - do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -- Syntax error -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ Syntax error - _ACEOF - if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -@@ -3476,7 +3959,8 @@ - : - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - # Broken: fails on valid input. - continue - fi -@@ -3485,20 +3969,24 @@ - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - _ACEOF - if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -@@ -3510,7 +3998,8 @@ - continue - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - # Passes both tests. - ac_preproc_ok=: - break -@@ -3539,24 +4028,34 @@ - do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -- Syntax error -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ Syntax error - _ACEOF - if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -@@ -3567,7 +4066,8 @@ - : - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - # Broken: fails on valid input. - continue - fi -@@ -3576,20 +4076,24 @@ - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - _ACEOF - if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -@@ -3601,7 +4105,8 @@ - continue - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - # Passes both tests. - ac_preproc_ok=: - break -@@ -3614,8 +4119,10 @@ - if $ac_preproc_ok; then - : - else -- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check" >&5 --echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} -+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -+See \`config.log' for more details." >&5 -+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -+See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - -@@ -3632,49 +4139,67 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - #include - #include - #include - -+int -+main () -+{ -+ -+ ; -+ return 0; -+} - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then - ac_cv_header_stdc=yes - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- ac_cv_header_stdc=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_header_stdc=no - fi --rm -f conftest.err conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - - if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- egrep "memchr" >/dev/null 2>&1; then -+ $EGREP "memchr" >/dev/null 2>&1; then - : - else - ac_cv_header_stdc=no -@@ -3686,13 +4211,16 @@ - if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- egrep "free" >/dev/null 2>&1; then -+ $EGREP "free" >/dev/null 2>&1; then - : - else - ac_cv_header_stdc=no -@@ -3707,16 +4235,20 @@ - : - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - #if ((' ' & 0x0FF) == 0x020) - # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') - # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) - #else --# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ -- || ('j' <= (c) && (c) <= 'r') \ -- || ('s' <= (c) && (c) <= 'z')) -+# define ISLOWER(c) \ -+ (('a' <= (c) && (c) <= 'i') \ -+ || ('j' <= (c) && (c) <= 'r') \ -+ || ('s' <= (c) && (c) <= 'z')) - # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) - #endif - -@@ -3727,7 +4259,7 @@ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) -- || toupper (i) != TOUPPER (i)) -+ || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); - } -@@ -3747,11 +4279,12 @@ - else - echo "$as_me: program exited with status $ac_status" >&5 - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ( exit $ac_status ) - ac_cv_header_stdc=no - fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext - fi - fi - fi -@@ -3776,7 +4309,7 @@ - - - for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ -- inttypes.h stdint.h unistd.h -+ inttypes.h stdint.h unistd.h - do - as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` - echo "$as_me:$LINENO: checking for $ac_header" >&5 -@@ -3785,19 +4318,31 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default - - #include <$ac_header> - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3806,10 +4351,11 @@ - eval "$as_ac_Header=yes" - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - eval "$as_ac_Header=no" - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi - echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 - echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -@@ -3840,18 +4386,30 @@ - echo "$as_me:$LINENO: checking $ac_header usability" >&5 - echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default - #include <$ac_header> - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3860,10 +4418,11 @@ - ac_header_compiler=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ac_header_compiler=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 - echo "${ECHO_T}$ac_header_compiler" >&6 - -@@ -3871,20 +4430,24 @@ - echo "$as_me:$LINENO: checking $ac_header presence" >&5 - echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include <$ac_header> - _ACEOF - if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -@@ -3895,7 +4458,8 @@ - ac_header_preproc=yes - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ac_header_preproc=no - fi - rm -f conftest.err conftest.$ac_ext -@@ -3903,26 +4467,43 @@ - echo "${ECHO_T}$ac_header_preproc" >&6 - - # So? What about this header? --case $ac_header_compiler:$ac_header_preproc in -- yes:no ) -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 - echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -- no:yes ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 - echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; - esac - echo "$as_me:$LINENO: checking for $ac_header" >&5 - echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 - if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- eval "$as_ac_Header=$ac_header_preproc" -+ eval "$as_ac_Header=\$ac_header_preproc" - fi - echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 - echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -@@ -3937,159 +4518,65 @@ - - done - -- -- -- -- --# Only perform the check for file, if the check method requires it --case $deplibs_check_method in --file_magic*) -- if test "$file_magic_cmd" = '$MAGIC_CMD'; then -- echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 --echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 --if test "${lt_cv_path_MAGIC_CMD+set}" = set; then -+ac_ext=cc -+ac_cpp='$CXXCPP $CPPFLAGS' -+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -+if test -n "$ac_tool_prefix"; then -+ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -+ do -+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -+set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- case $MAGIC_CMD in -- /*) -- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. -- ;; -- ?:/*) -- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. -- ;; -- *) -- ac_save_MAGIC_CMD="$MAGIC_CMD" -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" -- ac_dummy="/usr/bin:$PATH" -- for ac_dir in $ac_dummy; do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/${ac_tool_prefix}file; then -- lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" -- if test -n "$file_magic_test_file"; then -- case $deplibs_check_method in -- "file_magic "*) -- file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" -- MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -- egrep "$file_magic_regex" > /dev/null; then -- : -- else -- cat <&2 -- --*** Warning: the command libtool uses to detect shared libraries, --*** $file_magic_cmd, produces output that libtool cannot recognize. --*** The result is that libtool may fail to recognize shared libraries --*** as such. This will affect the creation of libtool libraries that --*** depend on shared libraries, but programs linked with such libtool --*** libraries will work regardless of this problem. Nevertheless, you --*** may want to report the problem to your system manager and/or to --*** bug-libtool@gnu.org -+ if test -n "$CXX"; then -+ ac_cv_prog_CXX="$CXX" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done - --EOF -- fi ;; -- esac -- fi -- break -- fi -- done -- IFS="$ac_save_ifs" -- MAGIC_CMD="$ac_save_MAGIC_CMD" -- ;; --esac - fi -- --MAGIC_CMD="$lt_cv_path_MAGIC_CMD" --if test -n "$MAGIC_CMD"; then -- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 --echo "${ECHO_T}$MAGIC_CMD" >&6 -+fi -+CXX=$ac_cv_prog_CXX -+if test -n "$CXX"; then -+ echo "$as_me:$LINENO: result: $CXX" >&5 -+echo "${ECHO_T}$CXX" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 - echo "${ECHO_T}no" >&6 - fi - --if test -z "$lt_cv_path_MAGIC_CMD"; then -- if test -n "$ac_tool_prefix"; then -- echo "$as_me:$LINENO: checking for file" >&5 --echo $ECHO_N "checking for file... $ECHO_C" >&6 --if test "${lt_cv_path_MAGIC_CMD+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- case $MAGIC_CMD in -- /*) -- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. -- ;; -- ?:/*) -- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. -- ;; -- *) -- ac_save_MAGIC_CMD="$MAGIC_CMD" -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" -- ac_dummy="/usr/bin:$PATH" -- for ac_dir in $ac_dummy; do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/file; then -- lt_cv_path_MAGIC_CMD="$ac_dir/file" -- if test -n "$file_magic_test_file"; then -- case $deplibs_check_method in -- "file_magic "*) -- file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" -- MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -- egrep "$file_magic_regex" > /dev/null; then -- : -- else -- cat <&2 -- --*** Warning: the command libtool uses to detect shared libraries, --*** $file_magic_cmd, produces output that libtool cannot recognize. --*** The result is that libtool may fail to recognize shared libraries --*** as such. This will affect the creation of libtool libraries that --*** depend on shared libraries, but programs linked with such libtool --*** libraries will work regardless of this problem. Nevertheless, you --*** may want to report the problem to your system manager and/or to --*** bug-libtool@gnu.org -- --EOF -- fi ;; -- esac -- fi -- break -- fi -+ test -n "$CXX" && break - done -- IFS="$ac_save_ifs" -- MAGIC_CMD="$ac_save_MAGIC_CMD" -- ;; --esac --fi -- --MAGIC_CMD="$lt_cv_path_MAGIC_CMD" --if test -n "$MAGIC_CMD"; then -- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 --echo "${ECHO_T}$MAGIC_CMD" >&6 --else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -- -- else -- MAGIC_CMD=: -- fi - fi -- -- fi -- ;; --esac -- --if test -n "$ac_tool_prefix"; then -- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. --set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -+if test -z "$CXX"; then -+ ac_ct_CXX=$CXX -+ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -+do -+ # Extract the first word of "$ac_prog", so it can be a program name with args. -+set dummy $ac_prog; ac_word=$2 - echo "$as_me:$LINENO: checking for $ac_word" >&5 - echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_RANLIB+set}" = set; then -+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test -n "$RANLIB"; then -- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -+ if test -n "$ac_ct_CXX"; then -+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. - else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR - for as_dir in $PATH -@@ -4098,7 +4585,7 @@ - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" -+ ac_cv_prog_ac_ct_CXX="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -@@ -4107,4958 +4594,18846 @@ - - fi - fi --RANLIB=$ac_cv_prog_RANLIB --if test -n "$RANLIB"; then -- echo "$as_me:$LINENO: result: $RANLIB" >&5 --echo "${ECHO_T}$RANLIB" >&6 -+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -+if test -n "$ac_ct_CXX"; then -+ echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -+echo "${ECHO_T}$ac_ct_CXX" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 - echo "${ECHO_T}no" >&6 - fi - --fi --if test -z "$ac_cv_prog_RANLIB"; then -- ac_ct_RANLIB=$RANLIB -- # Extract the first word of "ranlib", so it can be a program name with args. --set dummy ranlib; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- if test -n "$ac_ct_RANLIB"; then -- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. --else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_ac_ct_RANLIB="ranlib" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done -+ test -n "$ac_ct_CXX" && break - done -+test -n "$ac_ct_CXX" || ac_ct_CXX="g++" - -- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" --fi --fi --ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB --if test -n "$ac_ct_RANLIB"; then -- echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 --echo "${ECHO_T}$ac_ct_RANLIB" >&6 --else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+ CXX=$ac_ct_CXX - fi - -- RANLIB=$ac_ct_RANLIB --else -- RANLIB="$ac_cv_prog_RANLIB" --fi - --if test -n "$ac_tool_prefix"; then -- # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. --set dummy ${ac_tool_prefix}strip; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_STRIP+set}" = set; then -+# Provide some information about the compiler. -+echo "$as_me:$LINENO:" \ -+ "checking for C++ compiler version" >&5 -+ac_compiler=`set X $ac_compile; echo $2` -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 -+ (eval $ac_compiler --version &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 -+ (eval $ac_compiler -v &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 -+ (eval $ac_compiler -V &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+ -+echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 -+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test -n "$STRIP"; then -- ac_cv_prog_STRIP="$STRIP" # Let the user override the test. --else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_STRIP="${ac_tool_prefix}strip" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --fi --fi --STRIP=$ac_cv_prog_STRIP --if test -n "$STRIP"; then -- echo "$as_me:$LINENO: result: $STRIP" >&5 --echo "${ECHO_T}$STRIP" >&6 -+int -+main () -+{ -+#ifndef __GNUC__ -+ choke me -+#endif -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_compiler_gnu=yes - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_compiler_gnu=no - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - - fi --if test -z "$ac_cv_prog_STRIP"; then -- ac_ct_STRIP=$STRIP -- # Extract the first word of "strip", so it can be a program name with args. --set dummy strip; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then -+echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 -+GXX=`test $ac_compiler_gnu = yes && echo yes` -+ac_test_CXXFLAGS=${CXXFLAGS+set} -+ac_save_CXXFLAGS=$CXXFLAGS -+CXXFLAGS="-g" -+echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 -+if test "${ac_cv_prog_cxx_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test -n "$ac_ct_STRIP"; then -- ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. --else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_ac_ct_STRIP="strip" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - -- test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" --fi --fi --ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP --if test -n "$ac_ct_STRIP"; then -- echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 --echo "${ECHO_T}$ac_ct_STRIP" >&6 --else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -+int -+main () -+{ - -- STRIP=$ac_ct_STRIP --else -- STRIP="$ac_cv_prog_STRIP" --fi -- -- --enable_dlopen=no --enable_win32_dll=no -- --# Check whether --enable-libtool-lock or --disable-libtool-lock was given. --if test "${enable_libtool_lock+set}" = set; then -- enableval="$enable_libtool_lock" -- --fi; --test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes -- --# Some flags need to be propagated to the compiler or linker for good --# libtool support. --case $host in --*-*-irix6*) -- # Find out which ABI we are using. -- echo '#line 4259 "configure"' > conftest.$ac_ext -- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; then -- case `/usr/bin/file conftest.$ac_objext` in -- *32-bit*) -- LD="${LD-ld} -32" -- ;; -- *N32*) -- LD="${LD-ld} -n32" -- ;; -- *64-bit*) -- LD="${LD-ld} -64" -- ;; -- esac -- fi -- rm -rf conftest* -- ;; -- --*-*-sco3.2v5*) -- # On SCO OpenServer 5, we need -belf to get full-featured binaries. -- SAVE_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -belf" -- echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 --echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 --if test "${lt_cv_cc_needs_belf+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_prog_cxx_g=yes - else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- -- ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu -- -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ac_cv_prog_cxx_g=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 -+if test "$ac_test_CXXFLAGS" = set; then -+ CXXFLAGS=$ac_save_CXXFLAGS -+elif test $ac_cv_prog_cxx_g = yes; then -+ if test "$GXX" = yes; then -+ CXXFLAGS="-g -O2" -+ else -+ CXXFLAGS="-g" -+ fi -+else -+ if test "$GXX" = yes; then -+ CXXFLAGS="-O2" -+ else -+ CXXFLAGS= -+ fi -+fi -+for ac_declaration in \ -+ '' \ -+ 'extern "C" void std::exit (int) throw (); using std::exit;' \ -+ 'extern "C" void std::exit (int); using std::exit;' \ -+ 'extern "C" void exit (int) throw ();' \ -+ 'extern "C" void exit (int);' \ -+ 'void exit (int);' -+do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_declaration -+#include - int - main () - { -- -+exit (42); - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- lt_cv_cc_needs_belf=yes -+ : - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --lt_cv_cc_needs_belf=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+continue - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -- ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_declaration -+int -+main () -+{ -+exit (42); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - - fi --echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 --echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 -- if test x"$lt_cv_cc_needs_belf" != x"yes"; then -- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf -- CFLAGS="$SAVE_CFLAGS" -- fi -- ;; -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+rm -f conftest* -+if test -n "$ac_declaration"; then -+ echo '#ifdef __cplusplus' >>confdefs.h -+ echo $ac_declaration >>confdefs.h -+ echo '#endif' >>confdefs.h -+fi - -+ac_ext=cc -+ac_cpp='$CXXCPP $CPPFLAGS' -+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - --esac -+depcc="$CXX" am_compiler_list= - --# Sed substitution that helps us do robust quoting. It backslashifies --# metacharacters that are still active within double-quoted strings. --Xsed='sed -e s/^X//' --sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' -+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 -+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then -+ # We make a subdir and do the tests there. Otherwise we can end up -+ # making bogus files that we don't know about and never remove. For -+ # instance it was reported that on HP-UX the gcc test will end up -+ # making a dummy file named `D' -- because `-MD' means `put the output -+ # in D'. -+ mkdir conftest.dir -+ # Copy depcomp to subdir because otherwise we won't find it if we're -+ # using a relative directory. -+ cp "$am_depcomp" conftest.dir -+ cd conftest.dir -+ # We will build objects and dependencies in a subdirectory because -+ # it helps to detect inapplicable dependency modes. For instance -+ # both Tru64's cc and ICC support -MD to output dependencies as a -+ # side effect of compilation, but ICC will put the dependencies in -+ # the current directory while Tru64 will put them in the object -+ # directory. -+ mkdir sub - --# Same as above, but do not quote variable references. --double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' -+ am_cv_CXX_dependencies_compiler_type=none -+ if test "$am_compiler_list" = ""; then -+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` -+ fi -+ for depmode in $am_compiler_list; do -+ # Setup a source with many dependencies, because some compilers -+ # like to wrap large dependency lists on column 80 (with \), and -+ # we should not choose a depcomp mode which is confused by this. -+ # -+ # We need to recreate these files for each test, as the compiler may -+ # overwrite some of them when testing with obscure command lines. -+ # This happens at least with the AIX C compiler. -+ : > sub/conftest.c -+ for i in 1 2 3 4 5 6; do -+ echo '#include "conftst'$i'.h"' >> sub/conftest.c -+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with -+ # Solaris 8's {/usr,}/bin/sh. -+ touch sub/conftst$i.h -+ done -+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - --# Sed substitution to delay expansion of an escaped shell variable in a --# double_quote_subst'ed string. --delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' -+ case $depmode in -+ nosideeffect) -+ # after this tag, mechanisms are not by side-effect, so they'll -+ # only be used when explicitly requested -+ if test "x$enable_dependency_tracking" = xyes; then -+ continue -+ else -+ break -+ fi -+ ;; -+ none) break ;; -+ esac -+ # We check with `-c' and `-o' for the sake of the "dashmstdout" -+ # mode. It turns out that the SunPro C++ compiler does not properly -+ # handle `-M -o', and we need to detect this. -+ if depmode=$depmode \ -+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ -+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ -+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ -+ >/dev/null 2>conftest.err && -+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && -+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && -+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then -+ # icc doesn't choke on unknown options, it will just issue warnings -+ # or remarks (even with -Werror). So we grep stderr for any message -+ # that says an option was ignored or not supported. -+ # When given -MP, icc 7.0 and 7.1 complain thusly: -+ # icc: Command line warning: ignoring option '-M'; no argument required -+ # The diagnosis changed in icc 8.0: -+ # icc: Command line remark: option '-MP' not supported -+ if (grep 'ignoring option' conftest.err || -+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else -+ am_cv_CXX_dependencies_compiler_type=$depmode -+ break -+ fi -+ fi -+ done - --# Constants: --rm="rm -f" -+ cd .. -+ rm -rf conftest.dir -+else -+ am_cv_CXX_dependencies_compiler_type=none -+fi - --# Global variables: --default_ofile=libtool --can_build_shared=yes -+fi -+echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 -+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 -+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - --# All known linkers require a `.a' archive for static linking (except M$VC, --# which needs '.lib'). --libext=a --ltmain="$ac_aux_dir/ltmain.sh" --ofile="$default_ofile" --with_gnu_ld="$lt_cv_prog_gnu_ld" --need_locks="$enable_libtool_lock" - --old_CC="$CC" --old_CFLAGS="$CFLAGS" -- --# Set sane defaults for various variables --test -z "$AR" && AR=ar --test -z "$AR_FLAGS" && AR_FLAGS=cru --test -z "$AS" && AS=as --test -z "$CC" && CC=cc --test -z "$DLLTOOL" && DLLTOOL=dlltool --test -z "$LD" && LD=ld --test -z "$LN_S" && LN_S="ln -s" --test -z "$MAGIC_CMD" && MAGIC_CMD=file --test -z "$NM" && NM=nm --test -z "$OBJDUMP" && OBJDUMP=objdump --test -z "$RANLIB" && RANLIB=: --test -z "$STRIP" && STRIP=: --test -z "$ac_objext" && ac_objext=o -- --if test x"$host" != x"$build"; then -- ac_tool_prefix=${host_alias}- --else -- ac_tool_prefix= --fi -- --# Transform linux* to *-*-linux-gnu*, to support old configure scripts. --case $host_os in --linux-gnu*) ;; --linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` --esac -- --case $host_os in --aix3*) -- # AIX sometimes has problems with the GCC collect2 program. For some -- # reason, if we set the COLLECT_NAMES environment variable, the problems -- # vanish in a puff of smoke. -- if test "X${COLLECT_NAMES+set}" != Xset; then -- COLLECT_NAMES= -- export COLLECT_NAMES -- fi -- ;; --esac -- --# Determine commands to create old-style static archives. --old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' --old_postinstall_cmds='chmod 644 $oldlib' --old_postuninstall_cmds= -- --if test -n "$RANLIB"; then -- case $host_os in -- openbsd*) -- old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" -- ;; -- *) -- old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" -- ;; -- esac -- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" --fi - --# Allow CC to be a program name with arguments. --set dummy $CC --compiler="$2" -- --echo "$as_me:$LINENO: checking for objdir" >&5 --echo $ECHO_N "checking for objdir... $ECHO_C" >&6 --rm -f .libs 2>/dev/null --mkdir .libs 2>/dev/null --if test -d .libs; then -- objdir=.libs -+if -+ test "x$enable_dependency_tracking" != xno \ -+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then -+ am__fastdepCXX_TRUE= -+ am__fastdepCXX_FALSE='#' - else -- # MS-DOS does not allow filenames that begin with a dot. -- objdir=_libs -+ am__fastdepCXX_TRUE='#' -+ am__fastdepCXX_FALSE= - fi --rmdir .libs 2>/dev/null --echo "$as_me:$LINENO: result: $objdir" >&5 --echo "${ECHO_T}$objdir" >&6 - - - --# Check whether --with-pic or --without-pic was given. --if test "${with_pic+set}" = set; then -- withval="$with_pic" -- pic_mode="$withval" --else -- pic_mode=default --fi; --test -z "$pic_mode" && pic_mode=default - --# We assume here that the value for lt_cv_prog_cc_pic will not be cached --# in isolation, and that seeing it set (from the cache) indicates that --# the associated values are set (in the cache) correctly too. --echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 --echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 --if test "${lt_cv_prog_cc_pic+set}" = set; then -+if test -n "$CXX" && ( test "X$CXX" != "Xno" && -+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || -+ (test "X$CXX" != "Xg++"))) ; then -+ ac_ext=cc -+ac_cpp='$CXXCPP $CPPFLAGS' -+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -+echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 -+echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 -+if test -z "$CXXCPP"; then -+ if test "${ac_cv_prog_CXXCPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- lt_cv_prog_cc_pic= -- lt_cv_prog_cc_shlib= -- lt_cv_prog_cc_wl= -- lt_cv_prog_cc_static= -- lt_cv_prog_cc_no_builtin= -- lt_cv_prog_cc_can_build_shared=$can_build_shared -- -- if test "$GCC" = yes; then -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static='-static' -- -- case $host_os in -- aix*) -- # Below there is a dirty hack to force normal static linking with -ldl -- # The problem is because libdl dynamically linked with both libc and -- # libC (AIX C++ library), which obviously doesn't included in libraries -- # list by gcc. This cause undefined symbols with -static flags. -- # This hack allows C programs to be linked with "-static -ldl", but -- # not sure about C++ programs. -- lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" -- ;; -- amigaos*) -- # FIXME: we need at least 68020 code to build shared libraries, but -- # adding the `-m68020' flag to GCC prevents building anything better, -- # like `-m68040'. -- lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' -- ;; -- beos* | irix5* | irix6* | osf3* | osf4* | osf5*) -- # PIC is the default for these OSes. -- ;; -- darwin* | rhapsody*) -- # PIC is the default on this platform -- # Common symbols not allowed in MH_DYLIB files -- lt_cv_prog_cc_pic='-fno-common' -- ;; -- cygwin* | mingw* | pw32* | os2*) -- # This hack is so that the source file can tell whether it is being -- # built for inclusion in a dll (and should export symbols for example). -- lt_cv_prog_cc_pic='-DDLL_EXPORT' -- ;; -- sysv4*MP*) -- if test -d /usr/nec; then -- lt_cv_prog_cc_pic=-Kconform_pic -- fi -- ;; -- *) -- lt_cv_prog_cc_pic='-fPIC' -- ;; -- esac -+ # Double quotes because CXXCPP needs to be expanded -+ for CXXCPP in "$CXX -E" "/lib/cpp" -+ do -+ ac_preproc_ok=false -+for ac_cxx_preproc_warn_flag in '' yes -+do -+ # Use a header file that comes with gcc, so configuring glibc -+ # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. -+ # On the NeXT, cc -E runs the code through the compiler's parser, -+ # not just through cpp. "Syntax error" is here to catch this case. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ Syntax error -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_cxx_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else -- # PORTME Check for PIC flags for the system compiler. -- case $host_os in -- aix3* | aix4* | aix5*) -- lt_cv_prog_cc_wl='-Wl,' -- # All AIX code is PIC. -- if test "$host_cpu" = ia64; then -- # AIX 5 now supports IA64 processor -- lt_cv_prog_cc_static='-Bstatic' -- else -- lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' -- fi -- ;; -- -- hpux9* | hpux10* | hpux11*) -- # Is there a better lt_cv_prog_cc_static that works with the bundled CC? -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" -- lt_cv_prog_cc_pic='+Z' -- ;; -- -- irix5* | irix6*) -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static='-non_shared' -- # PIC (with -KPIC) is the default. -- ;; -- -- cygwin* | mingw* | pw32* | os2*) -- # This hack is so that the source file can tell whether it is being -- # built for inclusion in a dll (and should export symbols for example). -- lt_cv_prog_cc_pic='-DDLL_EXPORT' -- ;; -- -- newsos6) -- lt_cv_prog_cc_pic='-KPIC' -- lt_cv_prog_cc_static='-Bstatic' -- ;; -- -- osf3* | osf4* | osf5*) -- # All OSF/1 code is PIC. -- lt_cv_prog_cc_wl='-Wl,' -- lt_cv_prog_cc_static='-non_shared' -- ;; -- -- sco3.2v5*) -- lt_cv_prog_cc_pic='-Kpic' -- lt_cv_prog_cc_static='-dn' -- lt_cv_prog_cc_shlib='-belf' -- ;; -- -- solaris*) -- lt_cv_prog_cc_pic='-KPIC' -- lt_cv_prog_cc_static='-Bstatic' -- lt_cv_prog_cc_wl='-Wl,' -- ;; -- -- sunos4*) -- lt_cv_prog_cc_pic='-PIC' -- lt_cv_prog_cc_static='-Bstatic' -- lt_cv_prog_cc_wl='-Qoption ld ' -- ;; -- -- sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -- lt_cv_prog_cc_pic='-KPIC' -- lt_cv_prog_cc_static='-Bstatic' -- if test "x$host_vendor" = xsni; then -- lt_cv_prog_cc_wl='-LD' -- else -- lt_cv_prog_cc_wl='-Wl,' -- fi -- ;; -- -- uts4*) -- lt_cv_prog_cc_pic='-pic' -- lt_cv_prog_cc_static='-Bstatic' -- ;; -- -- sysv4*MP*) -- if test -d /usr/nec ;then -- lt_cv_prog_cc_pic='-Kconform_pic' -- lt_cv_prog_cc_static='-Bstatic' -- fi -- ;; -- -- *) -- lt_cv_prog_cc_can_build_shared=no -- ;; -- esac -+ ac_cpp_err= - fi -- --fi -- --if test -z "$lt_cv_prog_cc_pic"; then -- echo "$as_me:$LINENO: result: none" >&5 --echo "${ECHO_T}none" >&6 - else -- echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic" >&5 --echo "${ECHO_T}$lt_cv_prog_cc_pic" >&6 -- -- # Check to make sure the pic_flag actually works. -- echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 --echo $ECHO_N "checking if $compiler PIC flag $lt_cv_prog_cc_pic works... $ECHO_C" >&6 -- if test "${lt_cv_prog_cc_pic_works+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ : - else -- save_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ -+ # Broken: fails on valid input. -+continue -+fi -+rm -f conftest.err conftest.$ac_ext - -- ; -- return 0; --} -+ # OK, works on sane cases. Now check whether non-existent headers -+ # can be detected and how. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- case $host_os in -- hpux9* | hpux10* | hpux11*) -- # On HP-UX, both CC and GCC only warn that PIC is supported... then -- # they create non-PIC objects. So, if there were any warnings, we -- # assume that PIC is not supported. -- if test -s conftest.err; then -- lt_cv_prog_cc_pic_works=no -- else -- lt_cv_prog_cc_pic_works=yes -- fi -- ;; -- *) -- lt_cv_prog_cc_pic_works=yes -- ;; -- esac -- -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_cxx_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ # Broken: success on invalid input. -+continue - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -- lt_cv_prog_cc_pic_works=no -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ # Passes both tests. -+ac_preproc_ok=: -+break - fi --rm -f conftest.$ac_objext conftest.$ac_ext -- CFLAGS="$save_CFLAGS" -+rm -f conftest.err conftest.$ac_ext - -+done -+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -+rm -f conftest.err conftest.$ac_ext -+if $ac_preproc_ok; then -+ break - fi - -+ done -+ ac_cv_prog_CXXCPP=$CXXCPP - -- if test "X$lt_cv_prog_cc_pic_works" = Xno; then -- lt_cv_prog_cc_pic= -- lt_cv_prog_cc_can_build_shared=no -- else -- lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" -- fi -- -- echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic_works" >&5 --echo "${ECHO_T}$lt_cv_prog_cc_pic_works" >&6 - fi -- --# Check for any special shared library compilation flags. --if test -n "$lt_cv_prog_cc_shlib"; then -- { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&5 --echo "$as_me: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&2;} -- if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]" >/dev/null; then : -- else -- { echo "$as_me:$LINENO: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 --echo "$as_me: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} -- lt_cv_prog_cc_can_build_shared=no -- fi --fi -- --echo "$as_me:$LINENO: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 --echo $ECHO_N "checking if $compiler static flag $lt_cv_prog_cc_static works... $ECHO_C" >&6 --if test "${lt_cv_prog_cc_static_works+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ CXXCPP=$ac_cv_prog_CXXCPP - else -- lt_cv_prog_cc_static_works=no -- save_LDFLAGS="$LDFLAGS" -- LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" -+ ac_cv_prog_CXXCPP=$CXXCPP -+fi -+echo "$as_me:$LINENO: result: $CXXCPP" >&5 -+echo "${ECHO_T}$CXXCPP" >&6 -+ac_preproc_ok=false -+for ac_cxx_preproc_warn_flag in '' yes -+do -+ # Use a header file that comes with gcc, so configuring glibc -+ # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. -+ # On the NeXT, cc -E runs the code through the compiler's parser, -+ # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include - #endif --int --main () --{ -- -- ; -- return 0; --} -+ Syntax error - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_cxx_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ : -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ # Broken: fails on valid input. -+continue -+fi -+rm -f conftest.err conftest.$ac_ext -+ -+ # OK, works on sane cases. Now check whether non-existent headers -+ # can be detected and how. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- lt_cv_prog_cc_static_works=yes -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_cxx_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ # Broken: success on invalid input. -+continue - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ # Passes both tests. -+ac_preproc_ok=: -+break - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -- LDFLAGS="$save_LDFLAGS" -+rm -f conftest.err conftest.$ac_ext - -+done -+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -+rm -f conftest.err conftest.$ac_ext -+if $ac_preproc_ok; then -+ : -+else -+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check -+See \`config.log' for more details." >&5 -+echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } - fi - -+ac_ext=cc -+ac_cpp='$CXXCPP $CPPFLAGS' -+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -+ -+fi - --# Belt *and* braces to stop my trousers falling down: --test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= --echo "$as_me:$LINENO: result: $lt_cv_prog_cc_static_works" >&5 --echo "${ECHO_T}$lt_cv_prog_cc_static_works" >&6 - --pic_flag="$lt_cv_prog_cc_pic" --special_shlib_compile_flags="$lt_cv_prog_cc_shlib" --wl="$lt_cv_prog_cc_wl" --link_static_flag="$lt_cv_prog_cc_static" --no_builtin_flag="$lt_cv_prog_cc_no_builtin" --can_build_shared="$lt_cv_prog_cc_can_build_shared" -+ac_ext=f -+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' -+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_f77_compiler_gnu -+if test -n "$ac_tool_prefix"; then -+ for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran -+ do -+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -+set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_F77+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$F77"; then -+ ac_cv_prog_F77="$F77" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_F77="$ac_tool_prefix$ac_prog" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done - -+fi -+fi -+F77=$ac_cv_prog_F77 -+if test -n "$F77"; then -+ echo "$as_me:$LINENO: result: $F77" >&5 -+echo "${ECHO_T}$F77" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi - --# Check to see if options -o and -c are simultaneously supported by compiler --echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 --echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 --if test "${lt_cv_compiler_c_o+set}" = set; then -+ test -n "$F77" && break -+ done -+fi -+if test -z "$F77"; then -+ ac_ct_F77=$F77 -+ for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran -+do -+ # Extract the first word of "$ac_prog", so it can be a program name with args. -+set dummy $ac_prog; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_ac_ct_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -+ if test -n "$ac_ct_F77"; then -+ ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_F77="$ac_prog" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+fi -+fi -+ac_ct_F77=$ac_cv_prog_ac_ct_F77 -+if test -n "$ac_ct_F77"; then -+ echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 -+echo "${ECHO_T}$ac_ct_F77" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi - --$rm -r conftest 2>/dev/null --mkdir conftest --cd conftest --echo "int some_variable = 0;" > conftest.$ac_ext --mkdir out --# According to Tom Tromey, Ian Lance Taylor reported there are C compilers --# that will create temporary files in the current directory regardless of --# the output directory. Thus, making CWD read-only will cause this test --# to fail, enabling locking or at least warning the user not to do parallel --# builds. --chmod -w . --save_CFLAGS="$CFLAGS" --CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" --compiler_c_o=no --if { (eval echo configure:4795: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then -- # The compiler can only warn and ignore the option if not recognized -- # So say no if there are warnings -- if test -s out/conftest.err; then -- lt_cv_compiler_c_o=no -- else -- lt_cv_compiler_c_o=yes -- fi --else -- # Append any errors to the config.log. -- cat out/conftest.err 1>&5 -- lt_cv_compiler_c_o=no --fi --CFLAGS="$save_CFLAGS" --chmod u+w . --$rm conftest* out/* --rmdir out --cd .. --rmdir conftest --$rm -r conftest 2>/dev/null -+ test -n "$ac_ct_F77" && break -+done - -+ F77=$ac_ct_F77 - fi - --compiler_c_o=$lt_cv_compiler_c_o --echo "$as_me:$LINENO: result: $compiler_c_o" >&5 --echo "${ECHO_T}$compiler_c_o" >&6 -- --if test x"$compiler_c_o" = x"yes"; then -- # Check to see if we can write to a .lo -- echo "$as_me:$LINENO: checking if $compiler supports -c -o file.lo" >&5 --echo $ECHO_N "checking if $compiler supports -c -o file.lo... $ECHO_C" >&6 -- if test "${lt_cv_compiler_o_lo+set}" = set; then -+ -+# Provide some information about the compiler. -+echo "$as_me:5311:" \ -+ "checking for Fortran 77 compiler version" >&5 -+ac_compiler=`set X $ac_compile; echo $2` -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 -+ (eval $ac_compiler --version &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 -+ (eval $ac_compiler -v &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 -+ (eval $ac_compiler -V &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+rm -f a.out -+ -+# If we don't use `.F' as extension, the preprocessor is not run on the -+# input file. (Note that this only needs to work for GNU compilers.) -+ac_save_ext=$ac_ext -+ac_ext=F -+echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 -+echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 -+if test "${ac_cv_f77_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- -- lt_cv_compiler_o_lo=no -- save_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -c -o conftest.lo" -- save_objext="$ac_objext" -- ac_objext=lo - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+ program main -+#ifndef __GNUC__ -+ choke me - #endif --int --main () --{ --int some_variable = 0; -- ; -- return 0; --} -+ -+ end - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- # The compiler can only warn and ignore the option if not recognized -- # So say no if there are warnings -- if test -s conftest.err; then -- lt_cv_compiler_o_lo=no -- else -- lt_cv_compiler_o_lo=yes -- fi -- -+ ac_compiler_gnu=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- ac_objext="$save_objext" -- CFLAGS="$save_CFLAGS" -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_compiler_gnu=no - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ac_cv_f77_compiler_gnu=$ac_compiler_gnu - -- compiler_o_lo=$lt_cv_compiler_o_lo -- echo "$as_me:$LINENO: result: $compiler_o_lo" >&5 --echo "${ECHO_T}$compiler_o_lo" >&6 --else -- compiler_o_lo=no - fi -- --# Check to see if we can do hard links to lock some files if needed --hard_links="nottested" --if test "$compiler_c_o" = no && test "$need_locks" != no; then -- # do not overwrite the value of need_locks provided by the user -- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 --echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 -- hard_links=yes -- $rm conftest* -- ln conftest.a conftest.b 2>/dev/null && hard_links=no -- touch conftest.a -- ln conftest.a conftest.b 2>&5 || hard_links=no -- ln conftest.a conftest.b 2>/dev/null && hard_links=no -- echo "$as_me:$LINENO: result: $hard_links" >&5 --echo "${ECHO_T}$hard_links" >&6 -- if test "$hard_links" = no; then -- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 --echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} -- need_locks=warn -- fi -+echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 -+echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 -+ac_ext=$ac_save_ext -+ac_test_FFLAGS=${FFLAGS+set} -+ac_save_FFLAGS=$FFLAGS -+FFLAGS= -+echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 -+echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 -+if test "${ac_cv_prog_f77_g+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- need_locks=no --fi -- --if test "$GCC" = yes; then -- # Check to see if options -fno-rtti -fno-exceptions are supported by compiler -- echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 --echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -- echo "int some_variable = 0;" > conftest.$ac_ext -- save_CFLAGS="$CFLAGS" -- CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" -- compiler_rtti_exceptions=no -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ FFLAGS=-g -+cat >conftest.$ac_ext <<_ACEOF -+ program main - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --int some_variable = 0; -- ; -- return 0; --} -+ end - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- # The compiler can only warn and ignore the option if not recognized -- # So say no if there are warnings -- if test -s conftest.err; then -- compiler_rtti_exceptions=no -- else -- compiler_rtti_exceptions=yes -- fi -- -+ ac_cv_prog_f77_g=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_prog_f77_g=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -- CFLAGS="$save_CFLAGS" -- echo "$as_me:$LINENO: result: $compiler_rtti_exceptions" >&5 --echo "${ECHO_T}$compiler_rtti_exceptions" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -- if test "$compiler_rtti_exceptions" = "yes"; then -- no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' -+fi -+echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 -+echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 -+if test "$ac_test_FFLAGS" = set; then -+ FFLAGS=$ac_save_FFLAGS -+elif test $ac_cv_prog_f77_g = yes; then -+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then -+ FFLAGS="-g -O2" -+ else -+ FFLAGS="-g" -+ fi -+else -+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then -+ FFLAGS="-O2" - else -- no_builtin_flag=' -fno-builtin' -+ FFLAGS= - fi - fi - --# See if the linker supports building shared libraries. --echo "$as_me:$LINENO: checking whether the linker ($LD) supports shared libraries" >&5 --echo $ECHO_N "checking whether the linker ($LD) supports shared libraries... $ECHO_C" >&6 -+G77=`test $ac_compiler_gnu = yes && echo yes` -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu - --allow_undefined_flag= --no_undefined_flag= --need_lib_prefix=unknown --need_version=unknown --# when you set need_version to no, make sure it does not cause -set_version --# flags to be left without arguments --archive_cmds= --archive_expsym_cmds= --old_archive_from_new_cmds= --old_archive_from_expsyms_cmds= --export_dynamic_flag_spec= --whole_archive_flag_spec= --thread_safe_flag_spec= --hardcode_into_libs=no --hardcode_libdir_flag_spec= --hardcode_libdir_separator= --hardcode_direct=no --hardcode_minus_L=no --hardcode_shlibpath_var=unsupported --runpath_var= --link_all_deplibs=unknown --always_export_symbols=no --export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' --# include_expsyms should be a list of space-separated symbols to be *always* --# included in the symbol list --include_expsyms= --# exclude_expsyms can be an egrep regular expression of symbols to exclude --# it will be wrapped by ` (' and `)$', so one must not match beginning or --# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', --# as well as any symbol that contains `d'. --exclude_expsyms="_GLOBAL_OFFSET_TABLE_" --# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out --# platforms (ab)use it in PIC code, but their linkers get confused if --# the symbol is explicitly referenced. Since portable code cannot --# rely on this symbol name, it's probably fine to never include it in --# preloaded symbol tables. --extract_expsyms_cmds= - --case $host_os in --cygwin* | mingw* | pw32*) -- # FIXME: the MSVC++ port hasn't been tested in a loooong time -- # When not using gcc, we currently assume that we are using -- # Microsoft Visual C++. -- if test "$GCC" != yes; then -- with_gnu_ld=no -- fi -- ;; --openbsd*) -- with_gnu_ld=no -- ;; --esac -- --ld_shlibs=yes --if test "$with_gnu_ld" = yes; then -- # If archive_cmds runs LD, not CC, wlarc should be empty -- wlarc='${wl}' - -- # See if GNU ld supports shared libraries. -- case $host_os in -- aix3* | aix4* | aix5*) -- # On AIX, the GNU linker is very broken -- # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. -- ld_shlibs=no -- cat <&2 -- --*** Warning: the GNU linker, at least up to release 2.9.1, is reported --*** to be unable to reliably create shared libraries on AIX. --*** Therefore, libtool is disabling shared libraries support. If you --*** really care for shared libraries, you may want to modify your PATH --*** so that a non-GNU linker is found, and then restart. -+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! - --EOF -+# find the maximum length of command line arguments -+echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 -+echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 -+if test "${lt_cv_sys_max_cmd_len+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ i=0 -+ teststring="ABCD" -+ -+ case $build_os in -+ msdosdjgpp*) -+ # On DJGPP, this test can blow up pretty badly due to problems in libc -+ # (any single argument exceeding 2000 bytes causes a buffer overrun -+ # during glob expansion). Even if it were fixed, the result of this -+ # check would be larger than it should be. -+ lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - -- amigaos*) -- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_minus_L=yes -- -- # Samuel A. Falvo II reports -- # that the semantics of dynamic libraries on AmigaOS, at least up -- # to version 4, is to share data among multiple programs linked -- # with the same dynamic library. Since this doesn't match the -- # behavior of shared libraries on other platforms, we can use -- # them. -- ld_shlibs=no -+ gnu*) -+ # Under GNU Hurd, this test is not required because there is -+ # no limit to the length of command line arguments. -+ # Libtool will interpret -1 as no limit whatsoever -+ lt_cv_sys_max_cmd_len=-1; - ;; - -- beos*) -- if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- allow_undefined_flag=unsupported -- # Joseph Beckenbach says some releases of gcc -- # support --undefined. This deserves some investigation. FIXME -- archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- else -- ld_shlibs=no -- fi -+ cygwin* | mingw*) -+ # On Win9x/ME, this test blows up -- it succeeds, but takes -+ # about 5 minutes as the teststring grows exponentially. -+ # Worse, since 9x/ME are not pre-emptively multitasking, -+ # you end up with a "frozen" computer, even though with patience -+ # the test eventually succeeds (with a max line length of 256k). -+ # Instead, let's just punt: use the minimum linelength reported by -+ # all of the supported platforms: 8192 (on NT/2K/XP). -+ lt_cv_sys_max_cmd_len=8192; - ;; - -- cygwin* | mingw* | pw32*) -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec='-L$libdir' -- allow_undefined_flag=unsupported -- always_export_symbols=yes -- -- extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ -- sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ -- test -f $output_objdir/impgen.exe || (cd $output_objdir && \ -- if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ -- else $CC -o impgen impgen.c ; fi)~ -- $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' -- -- old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' -- -- # cygwin and mingw dlls have different entry points and sets of symbols -- # to exclude. -- # FIXME: what about values for MSVC? -- dll_entry=__cygwin_dll_entry@12 -- dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ -- case $host_os in -- mingw*) -- # mingw values -- dll_entry=_DllMainCRTStartup@12 -- dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ -- ;; -- esac -- -- # mingw and cygwin differ, and it's simplest to just exclude the union -- # of the two symbol sets. -- dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 -- -- # recent cygwin and mingw systems supply a stub DllMain which the user -- # can override, but on older systems we have to supply one (in ltdll.c) -- if test "x$lt_cv_need_dllmain" = "xyes"; then -- ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " -- ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ -- test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' -- else -- ltdll_obj= -- ltdll_cmds= -- fi -- -- # Extract the symbol export list from an `--export-all' def file, -- # then regenerate the def file from the symbol export list, so that -- # the compiled dll only exports the symbol export list. -- # Be careful not to strip the DATA tag left be newer dlltools. -- export_symbols_cmds="$ltdll_cmds"' -- $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ -- sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' -- -- # If the export-symbols file already is a .def file (1st line -- # is EXPORTS), use it as is. -- # If DATA tags from a recent dlltool are present, honour them! -- archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then -- cp $export_symbols $output_objdir/$soname-def; -- else -- echo EXPORTS > $output_objdir/$soname-def; -- _lt_hint=1; -- cat $export_symbols | while read symbol; do -- set dummy \$symbol; -- case \$# in -- 2) echo " \$2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; -- *) echo " \$2 @ \$_lt_hint \$3 ; " >> $output_objdir/$soname-def;; -- esac; -- _lt_hint=`expr 1 + \$_lt_hint`; -- done; -- fi~ -- '"$ltdll_cmds"' -- $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ -- $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ -- $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' -+ amigaos*) -+ # On AmigaOS with pdksh, this test takes hours, literally. -+ # So we just punt and use a minimum line length of 8192. -+ lt_cv_sys_max_cmd_len=8192; - ;; - -- netbsd*) -- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -- archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' -- wlarc= -+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) -+ # This has been around since 386BSD, at least. Likely further. -+ if test -x /sbin/sysctl; then -+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` -+ elif test -x /usr/sbin/sysctl; then -+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else -- archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi -+ # And add a safety zone -+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` -+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; -- -- solaris* | sysv5*) -- if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then -- ld_shlibs=no -- cat <&2 -- --*** Warning: The releases 2.8.* of the GNU linker cannot reliably --*** create shared libraries on Solaris systems. Therefore, libtool --*** is disabling shared libraries support. We urge you to upgrade GNU --*** binutils to release 2.9.1 or newer. Another option is to modify --*** your PATH or compiler configuration so that the native linker is --*** used, and then restart. -- --EOF -- elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -- else -- ld_shlibs=no -+ osf*) -+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure -+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not -+ # nice to cause kernel panics so lets avoid the loop below. -+ # First set a reasonable default. -+ lt_cv_sys_max_cmd_len=16384 -+ # -+ if test -x /sbin/sysconfig; then -+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in -+ *1*) lt_cv_sys_max_cmd_len=-1 ;; -+ esac - fi - ;; -- -- sunos4*) -- archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' -- wlarc= -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -- - *) -- if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -- else -- ld_shlibs=no -- fi -+ # If test is not a shell built-in, we'll probably end up computing a -+ # maximum length that is only half of the actual maximum length, but -+ # we can't tell. -+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} -+ while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ -+ = "XX$teststring") >/dev/null 2>&1 && -+ new_result=`expr "X$teststring" : ".*" 2>&1` && -+ lt_cv_sys_max_cmd_len=$new_result && -+ test $i != 17 # 1/2 MB should be enough -+ do -+ i=`expr $i + 1` -+ teststring=$teststring$teststring -+ done -+ teststring= -+ # Add a significant safety factor because C++ compilers can tack on massive -+ # amounts of additional arguments before passing them to the linker. -+ # It appears as though 1/2 is a usable value. -+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - ;; - esac - -- if test "$ld_shlibs" = yes; then -- runpath_var=LD_RUN_PATH -- hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' -- export_dynamic_flag_spec='${wl}--export-dynamic' -- case $host_os in -- cygwin* | mingw* | pw32*) -- # dlltool doesn't understand --whole-archive et. al. -- whole_archive_flag_spec= -- ;; -- *) -- # ancient GNU ld didn't support --whole-archive et. al. -- if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then -- whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -- else -- whole_archive_flag_spec= -- fi -- ;; -- esac -- fi --else -- # PORTME fill in a description of your system's linker (not GNU ld) -- case $host_os in -- aix3*) -- allow_undefined_flag=unsupported -- always_export_symbols=yes -- archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' -- # Note: this linker hardcodes the directories in LIBPATH if there -- # are no directories specified by -L. -- hardcode_minus_L=yes -- if test "$GCC" = yes && test -z "$link_static_flag"; then -- # Neither direct hardcoding nor static linking is supported with a -- # broken collect2. -- hardcode_direct=unsupported -- fi -- ;; -- -- aix4* | aix5*) -- if test "$host_cpu" = ia64; then -- # On IA64, the linker does run time linking by default, so we don't -- # have to do anything special. -- aix_use_runtimelinking=no -- exp_sym_flag='-Bexport' -- no_entry_flag="" -- else -- aix_use_runtimelinking=no -- -- # Test if we are trying to use run time linking or normal -- # AIX style linking. If -brtl is somewhere in LDFLAGS, we -- # need to do runtime linking. -- case $host_os in aix4.[23]|aix4.[23].*|aix5*) -- for ld_flag in $LDFLAGS; do -- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then -- aix_use_runtimelinking=yes -- break -- fi -- done -- esac -+fi - -- exp_sym_flag='-bexport' -- no_entry_flag='-bnoentry' -- fi -+if test -n $lt_cv_sys_max_cmd_len ; then -+ echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 -+echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 -+else -+ echo "$as_me:$LINENO: result: none" >&5 -+echo "${ECHO_T}none" >&6 -+fi - -- # When large executables or shared objects are built, AIX ld can -- # have problems creating the table of contents. If linking a library -- # or program results in "error TOC overflow" add -mminimal-toc to -- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - -- hardcode_direct=yes -- archive_cmds='' -- hardcode_libdir_separator=':' -- if test "$GCC" = yes; then -- case $host_os in aix4.[012]|aix4.[012].*) -- collect2name=`${CC} -print-prog-name=collect2` -- if test -f "$collect2name" && \ -- strings "$collect2name" | grep resolve_lib_name >/dev/null -- then -- # We have reworked collect2 -- hardcode_direct=yes -- else -- # We have old collect2 -- hardcode_direct=unsupported -- # It fails to find uninstalled libraries when the uninstalled -- # path is not listed in the libpath. Setting hardcode_minus_L -- # to unsupported forces relinking -- hardcode_minus_L=yes -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_libdir_separator= -- fi -- esac - -- shared_flag='-shared' -- else -- # not using gcc -- if test "$host_cpu" = ia64; then -- shared_flag='${wl}-G' -- else -- if test "$aix_use_runtimelinking" = yes; then -- shared_flag='${wl}-G' -- else -- shared_flag='${wl}-bM:SRE' -- fi -- fi -- fi - -- # It seems that -bexpall can do strange things, so it is better to -- # generate a list of symbols to export. -- always_export_symbols=yes -- if test "$aix_use_runtimelinking" = yes; then -- # Warning - without using the other runtime loading flags (-brtl), -- # -berok will link without error, but may produce a broken library. -- allow_undefined_flag='-berok' -- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' -- archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -- else -- if test "$host_cpu" = ia64; then -- hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' -- allow_undefined_flag="-z nodefs" -- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -- else -- hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' -- # Warning - without using the other run time loading flags, -- # -berok will link without error, but may produce a broken library. -- allow_undefined_flag='${wl}-berok' -- # This is a bit strange, but is similar to how AIX traditionally builds -- # it's shared libraries. -- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' -- fi -- fi -- ;; -+# Check for command to grab the raw symbol name followed by C symbol from nm. -+echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 -+echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 -+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else - -- amigaos*) -- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_minus_L=yes -- # see comment about different semantics on the GNU ld section -- ld_shlibs=no -- ;; -+# These are sane defaults that work on at least a few old systems. -+# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -- cygwin* | mingw* | pw32*) -- # When not using gcc, we currently assume that we are using -- # Microsoft Visual C++. -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec=' ' -- allow_undefined_flag=unsupported -- # Tell ltmain to make .lib files, not .a files. -- libext=lib -- # FIXME: Setting linknames here is a bad hack. -- archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' -- # The linker will automatically build a .lib file if we build a DLL. -- old_archive_from_new_cmds='true' -- # FIXME: Should let the user specify the lib program. -- old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' -- fix_srcfile_path='`cygpath -w "$srcfile"`' -- ;; -- -- darwin* | rhapsody*) -- case "$host_os" in -- rhapsody* | darwin1.[012]) -- allow_undefined_flag='-undefined suppress' -- ;; -- *) # Darwin 1.3 on -- allow_undefined_flag='-flat_namespace -undefined suppress' -- ;; -- esac -- # FIXME: Relying on posixy $() will cause problems for -- # cross-compilation, but unfortunately the echo tests do not -- # yet detect zsh echo's removal of \ escapes. -- archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' -- # We need to add '_' to the symbols in $export_symbols first -- #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- whole_archive_flag_spec='-all_load $convenience' -- ;; -- -- freebsd1*) -- ld_shlibs=no -- ;; -- -- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -- # support. Future versions do this automatically, but an explicit c++rt0.o -- # does not break anything, and helps significantly (at the cost of a little -- # extra space). -- freebsd2.2*) -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -+# Character class describing NM global symbol codes. -+symcode='[BCDEGRST]' - -- # Unfortunately, older versions of FreeBSD 2 do not have this feature. -- freebsd2*) -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes -- hardcode_minus_L=yes -- hardcode_shlibpath_var=no -- ;; -+# Regexp to match symbols that can be accessed directly from C. -+sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -- # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -- freebsd*) -- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -+# Transform an extracted symbol line into a proper C declaration -+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" - -- hpux9* | hpux10* | hpux11*) -- case $host_os in -- hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; -- *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; -- esac -- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -- hardcode_libdir_separator=: -- hardcode_direct=yes -- hardcode_minus_L=yes # Not in the search PATH, but as the default -- # location of the library. -- export_dynamic_flag_spec='${wl}-E' -- ;; -+# Transform an extracted symbol line into symbol name and symbol address -+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -- irix5* | irix6*) -- if test "$GCC" = yes; then -- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -- else -- archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -- fi -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- hardcode_libdir_separator=: -- link_all_deplibs=yes -- ;; -+# Define system-specific variables. -+case $host_os in -+aix*) -+ symcode='[BCDT]' -+ ;; -+cygwin* | mingw* | pw32*) -+ symcode='[ABCDGISTW]' -+ ;; -+hpux*) # Its linker distinguishes data from code symbols -+ if test "$host_cpu" = ia64; then -+ symcode='[ABCDEGRST]' -+ fi -+ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" -+ lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -+ ;; -+linux*) -+ if test "$host_cpu" = ia64; then -+ symcode='[ABCDGIRSTW]' -+ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" -+ lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" -+ fi -+ ;; -+irix* | nonstopux*) -+ symcode='[BCDEGRST]' -+ ;; -+osf*) -+ symcode='[BCDEGQRST]' -+ ;; -+solaris* | sysv5*) -+ symcode='[BDRT]' -+ ;; -+sysv4) -+ symcode='[DFNSTU]' -+ ;; -+esac - -- netbsd*) -- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out -- else -- archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF -- fi -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- ;; -+# Handle CRLF in mingw tool chain -+opt_cr= -+case $build_os in -+mingw*) -+ opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp -+ ;; -+esac - -- newsos6) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- hardcode_libdir_separator=: -- hardcode_shlibpath_var=no -- ;; -+# If we're using GNU nm, then use its standard symbol codes. -+case `$NM -V 2>&1` in -+*GNU* | *'with BFD'*) -+ symcode='[ABCDGIRSTW]' ;; -+esac - -- openbsd*) -- hardcode_direct=yes -- hardcode_shlibpath_var=no -- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='${wl}-rpath,$libdir' -- export_dynamic_flag_spec='${wl}-E' -- else -- case "$host_os" in -- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) -- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='-R$libdir' -- ;; -- *) -- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='${wl}-rpath,$libdir' -- ;; -- esac -- fi -- ;; -+# Try without a prefix undercore, then with it. -+for ac_symprfx in "" "_"; do - -- os2*) -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_minus_L=yes -- allow_undefined_flag=unsupported -- archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' -- old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' -- ;; -+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. -+ symxfrm="\\1 $ac_symprfx\\2 \\2" - -- osf3*) -- if test "$GCC" = yes; then -- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -- else -- allow_undefined_flag=' -expect_unresolved \*' -- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -- fi -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- hardcode_libdir_separator=: -- ;; -+ # Write the raw and C identifiers. -+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - -- osf4* | osf5*) # as osf3* with the addition of -msym flag -- if test "$GCC" = yes; then -- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -- else -- allow_undefined_flag=' -expect_unresolved \*' -- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -- archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ -- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' -+ # Check to see that the pipe works correctly. -+ pipe_works=no - -- #Both c and cxx compiler support -rpath directly -- hardcode_libdir_flag_spec='-rpath $libdir' -- fi -- hardcode_libdir_separator=: -- ;; -+ rm -f conftest* -+ cat > conftest.$ac_ext <, C++ libraries end up with a separate -- # (to the application) exception stack for one thing. -- no_undefined_flag=' -z defs' -- if test "$GCC" = yes; then -- case `$CC --version 2>/dev/null` in -- [12].*) -- cat <&2 -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ # Now try to grab the symbols. -+ nlist=conftest.nm -+ if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 -+ (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s "$nlist"; then -+ # Try sorting and uniquifying the output. -+ if sort "$nlist" | uniq > "$nlist"T; then -+ mv -f "$nlist"T "$nlist" -+ else -+ rm -f "$nlist"T -+ fi - --*** Warning: Releases of GCC earlier than version 3.0 cannot reliably --*** create self contained shared libraries on Solaris systems, without --*** introducing a dependency on libgcc.a. Therefore, libtool is disabling --*** -no-undefined support, which will at least allow you to build shared --*** libraries. However, you may find that when you link such libraries --*** into an application without using GCC, you have to manually add --*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to --*** upgrade to a newer version of GCC. Another option is to rebuild your --*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. -+ # Make sure that we snagged all the symbols we need. -+ if grep ' nm_test_var$' "$nlist" >/dev/null; then -+ if grep ' nm_test_func$' "$nlist" >/dev/null; then -+ cat < conftest.$ac_ext -+#ifdef __cplusplus -+extern "C" { -+#endif - - EOF -- no_undefined_flag= -- ;; -- esac -- fi -- # $CC -shared without GNU ld will not create a library from C++ -- # object files and a static libstdc++, better avoid it by now -- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -- hardcode_libdir_flag_spec='-R$libdir' -- hardcode_shlibpath_var=no -- case $host_os in -- solaris2.[0-5] | solaris2.[0-5].*) ;; -- *) # Supported since Solaris 2.6 (maybe 2.5.1?) -- whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; -- esac -- link_all_deplibs=yes -- ;; -- -- sunos4*) -- if test "x$host_vendor" = xsequent; then -- # Use $CC to link under sequent, because it throws in some extra .o -- # files that make .init and .fini sections work. -- archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' -- else -- archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' -- fi -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_direct=yes -- hardcode_minus_L=yes -- hardcode_shlibpath_var=no -- ;; -- -- sysv4) -- if test "x$host_vendor" = xsno; then -- archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes # is this really true??? -- else -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=no #Motorola manual says yes, but my tests say they lie -- fi -- runpath_var='LD_RUN_PATH' -- hardcode_shlibpath_var=no -- ;; -- -- sysv4.3*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_shlibpath_var=no -- export_dynamic_flag_spec='-Bexport' -- ;; -- -- sysv5*) -- no_undefined_flag=' -z text' -- # $CC -shared without GNU ld will not create a library from C++ -- # object files and a static libstdc++, better avoid it by now -- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -- hardcode_libdir_flag_spec= -- hardcode_shlibpath_var=no -- runpath_var='LD_RUN_PATH' -- ;; -- -- uts4*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_shlibpath_var=no -- ;; -- -- dgux*) -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_libdir_flag_spec='-L$libdir' -- hardcode_shlibpath_var=no -- ;; -+ # Now generate the symbol file. -+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' - -- sysv4*MP*) -- if test -d /usr/nec; then -- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -- hardcode_shlibpath_var=no -- runpath_var=LD_RUN_PATH -- hardcode_runpath_var=yes -- ld_shlibs=yes -- fi -- ;; -+ cat <> conftest.$ac_ext -+#if defined (__STDC__) && __STDC__ -+# define lt_ptr_t void * -+#else -+# define lt_ptr_t char * -+# define const -+#endif - -- sysv4.2uw2*) -- archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' -- hardcode_direct=yes -- hardcode_minus_L=no -- hardcode_shlibpath_var=no -- hardcode_runpath_var=yes -- runpath_var=LD_RUN_PATH -- ;; -+/* The mapping between symbol names and symbols. */ -+const struct { -+ const char *name; -+ lt_ptr_t address; -+} -+lt_preloaded_symbols[] = -+{ -+EOF -+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext -+ cat <<\EOF >> conftest.$ac_ext -+ {0, (lt_ptr_t) 0} -+}; - -- sysv5uw7* | unixware7*) -- no_undefined_flag='${wl}-z ${wl}text' -- if test "$GCC" = yes; then -- archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+#ifdef __cplusplus -+} -+#endif -+EOF -+ # Now try linking the two files. -+ mv conftest.$ac_objext conftstm.$ac_objext -+ lt_save_LIBS="$LIBS" -+ lt_save_CFLAGS="$CFLAGS" -+ LIBS="conftstm.$ac_objext" -+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext}; then -+ pipe_works=yes -+ fi -+ LIBS="$lt_save_LIBS" -+ CFLAGS="$lt_save_CFLAGS" -+ else -+ echo "cannot find nm_test_func in $nlist" >&5 -+ fi -+ else -+ echo "cannot find nm_test_var in $nlist" >&5 -+ fi - else -- archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi -- runpath_var='LD_RUN_PATH' -- hardcode_shlibpath_var=no -- ;; -- -- *) -- ld_shlibs=no -- ;; -- esac --fi --echo "$as_me:$LINENO: result: $ld_shlibs" >&5 --echo "${ECHO_T}$ld_shlibs" >&6 --test "$ld_shlibs" = no && can_build_shared=no -- --# Check hardcoding attributes. --echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 --echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 --hardcode_action= --if test -n "$hardcode_libdir_flag_spec" || \ -- test -n "$runpath_var"; then -+ else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ fi -+ rm -f conftest* conftst* - -- # We can hardcode non-existant directories. -- if test "$hardcode_direct" != no && -- # If the only mechanism to avoid hardcoding is shlibpath_var, we -- # have to relink, otherwise we might link with an installed library -- # when we should be linking with a yet-to-be-installed one -- ## test "$hardcode_shlibpath_var" != no && -- test "$hardcode_minus_L" != no; then -- # Linking always hardcodes the temporary library directory. -- hardcode_action=relink -+ # Do not use the global_symbol_pipe unless it works. -+ if test "$pipe_works" = yes; then -+ break - else -- # We can link without hardcoding, and we can hardcode nonexisting dirs. -- hardcode_action=immediate -+ lt_cv_sys_global_symbol_pipe= - fi -+done -+ -+fi -+ -+if test -z "$lt_cv_sys_global_symbol_pipe"; then -+ lt_cv_sys_global_symbol_to_cdecl= -+fi -+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then -+ echo "$as_me:$LINENO: result: failed" >&5 -+echo "${ECHO_T}failed" >&6 - else -- # We cannot hardcode anything, or else we can only hardcode existing -- # directories. -- hardcode_action=unsupported -+ echo "$as_me:$LINENO: result: ok" >&5 -+echo "${ECHO_T}ok" >&6 - fi --echo "$as_me:$LINENO: result: $hardcode_action" >&5 --echo "${ECHO_T}$hardcode_action" >&6 - --striplib= --old_striplib= --echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 --echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 --if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -- test -z "$striplib" && striplib="$STRIP --strip-unneeded" -- echo "$as_me:$LINENO: result: yes" >&5 --echo "${ECHO_T}yes" >&6 -+echo "$as_me:$LINENO: checking for objdir" >&5 -+echo $ECHO_N "checking for objdir... $ECHO_C" >&6 -+if test "${lt_cv_objdir+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+ rm -f .libs 2>/dev/null -+mkdir .libs 2>/dev/null -+if test -d .libs; then -+ lt_cv_objdir=.libs -+else -+ # MS-DOS does not allow filenames that begin with a dot. -+ lt_cv_objdir=_libs - fi -+rmdir .libs 2>/dev/null -+fi -+echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 -+echo "${ECHO_T}$lt_cv_objdir" >&6 -+objdir=$lt_cv_objdir - --reload_cmds='$LD$reload_flag -o $output$reload_objs' --test -z "$deplibs_check_method" && deplibs_check_method=unknown - --# PORTME Fill in your ld.so characteristics --echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 --echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 --library_names_spec= --libname_spec='lib$name' --soname_spec= --postinstall_cmds= --postuninstall_cmds= --finish_cmds= --finish_eval= --shlibpath_var= --shlibpath_overrides_runpath=unknown --version_type=none --dynamic_linker="$host_os ld.so" --sys_lib_dlsearch_path_spec="/lib /usr/lib" --sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" - --case $host_os in --aix3*) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix $libname.a' -- shlibpath_var=LIBPATH - -- # AIX has no versioning support, so we append a major version to the name. -- soname_spec='${libname}${release}.so$major' -- ;; - --aix4* | aix5*) -- version_type=linux -- if test "$host_cpu" = ia64; then -- # AIX 5 supports IA64 -- library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- else -- # With GCC up to 2.95.x, collect2 would create an import file -- # for dependence libraries. The import file would start with -- # the line `#! .'. This would cause the generated library to -- # depend on `.', always an invalid library. This was fixed in -- # development snapshots of GCC prior to 3.0. -- case $host_os in -- aix4 | aix4.[01] | aix4.[01].*) -- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -- echo ' yes ' -- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -- : -- else -- can_build_shared=no -- fi -- ;; -- esac -- # AIX (on Power*) has no versioning support, so currently we can -- # not hardcode correct soname into executable. Probably we can -- # add versioning support to collect2, so additional links can -- # be useful in future. -- if test "$aix_use_runtimelinking" = yes; then -- # If using run time linking (on AIX 4.2 or later) use lib.so -- # instead of lib.a to let people know that these are not -- # typical AIX shared libraries. -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- else -- # We preserve .a as extension for shared libraries through AIX4.2 -- # and later when we are not doing run time linking. -- library_names_spec='${libname}${release}.a $libname.a' -- soname_spec='${libname}${release}.so$major' -- fi -- shlibpath_var=LIBPATH -+case $host_os in -+aix3*) -+ # AIX sometimes has problems with the GCC collect2 program. For some -+ # reason, if we set the COLLECT_NAMES environment variable, the problems -+ # vanish in a puff of smoke. -+ if test "X${COLLECT_NAMES+set}" != Xset; then -+ COLLECT_NAMES= -+ export COLLECT_NAMES - fi - ;; -+esac - --amigaos*) -- library_names_spec='$libname.ixlibrary $libname.a' -- # Create ${libname}_ixlibrary.a entries in /sys/libs. -- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' -- ;; -+# Sed substitution that helps us do robust quoting. It backslashifies -+# metacharacters that are still active within double-quoted strings. -+Xsed='sed -e 1s/^X//' -+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' - --beos*) -- library_names_spec='${libname}.so' -- dynamic_linker="$host_os ld.so" -- shlibpath_var=LIBRARY_PATH -- ;; -+# Same as above, but do not quote variable references. -+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' - --bsdi4*) -- version_type=linux -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -- export_dynamic_flag_spec=-rdynamic -- # the default ld.so.conf also contains /usr/contrib/lib and -- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -- # libtool to hard-code these into programs -- ;; -+# Sed substitution to delay expansion of an escaped shell variable in a -+# double_quote_subst'ed string. -+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - --cygwin* | mingw* | pw32*) -- version_type=windows -- need_version=no -- need_lib_prefix=no -- case $GCC,$host_os in -- yes,cygwin*) -- library_names_spec='$libname.dll.a' -- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' -- postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ -- dldir=$destdir/`dirname \$dlpath`~ -- test -d \$dldir || mkdir -p \$dldir~ -- $install_prog .libs/$dlname \$dldir/$dlname' -- postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ -- dlpath=$dir/\$dldll~ -- $rm \$dlpath' -- ;; -- yes,mingw*) -- library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' -- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` -+# Sed substitution to avoid accidental globbing in evaled expressions -+no_glob_subst='s/\*/\\\*/g' -+ -+# Constants: -+rm="rm -f" -+ -+# Global variables: -+default_ofile=libtool -+can_build_shared=yes -+ -+# All known linkers require a `.a' archive for static linking (except MSVC, -+# which needs '.lib'). -+libext=a -+ltmain="$ac_aux_dir/ltmain.sh" -+ofile="$default_ofile" -+with_gnu_ld="$lt_cv_prog_gnu_ld" -+ -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -+set dummy ${ac_tool_prefix}ar; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_AR+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$AR"; then -+ ac_cv_prog_AR="$AR" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_AR="${ac_tool_prefix}ar" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+fi -+fi -+AR=$ac_cv_prog_AR -+if test -n "$AR"; then -+ echo "$as_me:$LINENO: result: $AR" >&5 -+echo "${ECHO_T}$AR" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+fi -+if test -z "$ac_cv_prog_AR"; then -+ ac_ct_AR=$AR -+ # Extract the first word of "ar", so it can be a program name with args. -+set dummy ar; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$ac_ct_AR"; then -+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_AR="ar" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+ test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" -+fi -+fi -+ac_ct_AR=$ac_cv_prog_ac_ct_AR -+if test -n "$ac_ct_AR"; then -+ echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 -+echo "${ECHO_T}$ac_ct_AR" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+ AR=$ac_ct_AR -+else -+ AR="$ac_cv_prog_AR" -+fi -+ -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -+set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_RANLIB+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$RANLIB"; then -+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+fi -+fi -+RANLIB=$ac_cv_prog_RANLIB -+if test -n "$RANLIB"; then -+ echo "$as_me:$LINENO: result: $RANLIB" >&5 -+echo "${ECHO_T}$RANLIB" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+fi -+if test -z "$ac_cv_prog_RANLIB"; then -+ ac_ct_RANLIB=$RANLIB -+ # Extract the first word of "ranlib", so it can be a program name with args. -+set dummy ranlib; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$ac_ct_RANLIB"; then -+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_RANLIB="ranlib" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+ test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" -+fi -+fi -+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -+if test -n "$ac_ct_RANLIB"; then -+ echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -+echo "${ECHO_T}$ac_ct_RANLIB" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+ RANLIB=$ac_ct_RANLIB -+else -+ RANLIB="$ac_cv_prog_RANLIB" -+fi -+ -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -+set dummy ${ac_tool_prefix}strip; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_STRIP+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$STRIP"; then -+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_STRIP="${ac_tool_prefix}strip" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+fi -+fi -+STRIP=$ac_cv_prog_STRIP -+if test -n "$STRIP"; then -+ echo "$as_me:$LINENO: result: $STRIP" >&5 -+echo "${ECHO_T}$STRIP" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+fi -+if test -z "$ac_cv_prog_STRIP"; then -+ ac_ct_STRIP=$STRIP -+ # Extract the first word of "strip", so it can be a program name with args. -+set dummy strip; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -n "$ac_ct_STRIP"; then -+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_STRIP="strip" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ -+ test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" -+fi -+fi -+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -+if test -n "$ac_ct_STRIP"; then -+ echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -+echo "${ECHO_T}$ac_ct_STRIP" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+ STRIP=$ac_ct_STRIP -+else -+ STRIP="$ac_cv_prog_STRIP" -+fi -+ -+ -+old_CC="$CC" -+old_CFLAGS="$CFLAGS" -+ -+# Set sane defaults for various variables -+test -z "$AR" && AR=ar -+test -z "$AR_FLAGS" && AR_FLAGS=cru -+test -z "$AS" && AS=as -+test -z "$CC" && CC=cc -+test -z "$LTCC" && LTCC=$CC -+test -z "$DLLTOOL" && DLLTOOL=dlltool -+test -z "$LD" && LD=ld -+test -z "$LN_S" && LN_S="ln -s" -+test -z "$MAGIC_CMD" && MAGIC_CMD=file -+test -z "$NM" && NM=nm -+test -z "$SED" && SED=sed -+test -z "$OBJDUMP" && OBJDUMP=objdump -+test -z "$RANLIB" && RANLIB=: -+test -z "$STRIP" && STRIP=: -+test -z "$ac_objext" && ac_objext=o -+ -+# Determine commands to create old-style static archives. -+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -+old_postinstall_cmds='chmod 644 $oldlib' -+old_postuninstall_cmds= -+ -+if test -n "$RANLIB"; then -+ case $host_os in -+ openbsd*) -+ old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" -+ ;; -+ *) -+ old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" -+ ;; -+ esac -+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -+fi -+ -+for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ -+# Only perform the check for file, if the check method requires it -+case $deplibs_check_method in -+file_magic*) -+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then -+ echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 -+echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 -+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ case $MAGIC_CMD in -+[\\/*] | ?:[\\/]*) -+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. -+ ;; -+*) -+ lt_save_MAGIC_CMD="$MAGIC_CMD" -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" -+ for ac_dir in $ac_dummy; do -+ IFS="$lt_save_ifs" -+ test -z "$ac_dir" && ac_dir=. -+ if test -f $ac_dir/${ac_tool_prefix}file; then -+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" -+ if test -n "$file_magic_test_file"; then -+ case $deplibs_check_method in -+ "file_magic "*) -+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` -+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -+ $EGREP "$file_magic_regex" > /dev/null; then -+ : -+ else -+ cat <&2 -+ -+*** Warning: the command libtool uses to detect shared libraries, -+*** $file_magic_cmd, produces output that libtool cannot recognize. -+*** The result is that libtool may fail to recognize shared libraries -+*** as such. This will affect the creation of libtool libraries that -+*** depend on shared libraries, but programs linked with such libtool -+*** libraries will work regardless of this problem. Nevertheless, you -+*** may want to report the problem to your system manager and/or to -+*** bug-libtool@gnu.org -+ -+EOF -+ fi ;; -+ esac -+ fi -+ break -+ fi -+ done -+ IFS="$lt_save_ifs" -+ MAGIC_CMD="$lt_save_MAGIC_CMD" -+ ;; -+esac -+fi -+ -+MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -+if test -n "$MAGIC_CMD"; then -+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 -+echo "${ECHO_T}$MAGIC_CMD" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+if test -z "$lt_cv_path_MAGIC_CMD"; then -+ if test -n "$ac_tool_prefix"; then -+ echo "$as_me:$LINENO: checking for file" >&5 -+echo $ECHO_N "checking for file... $ECHO_C" >&6 -+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ case $MAGIC_CMD in -+[\\/*] | ?:[\\/]*) -+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. -+ ;; -+*) -+ lt_save_MAGIC_CMD="$MAGIC_CMD" -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" -+ for ac_dir in $ac_dummy; do -+ IFS="$lt_save_ifs" -+ test -z "$ac_dir" && ac_dir=. -+ if test -f $ac_dir/file; then -+ lt_cv_path_MAGIC_CMD="$ac_dir/file" -+ if test -n "$file_magic_test_file"; then -+ case $deplibs_check_method in -+ "file_magic "*) -+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` -+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -+ $EGREP "$file_magic_regex" > /dev/null; then -+ : -+ else -+ cat <&2 -+ -+*** Warning: the command libtool uses to detect shared libraries, -+*** $file_magic_cmd, produces output that libtool cannot recognize. -+*** The result is that libtool may fail to recognize shared libraries -+*** as such. This will affect the creation of libtool libraries that -+*** depend on shared libraries, but programs linked with such libtool -+*** libraries will work regardless of this problem. Nevertheless, you -+*** may want to report the problem to your system manager and/or to -+*** bug-libtool@gnu.org -+ -+EOF -+ fi ;; -+ esac -+ fi -+ break -+ fi -+ done -+ IFS="$lt_save_ifs" -+ MAGIC_CMD="$lt_save_MAGIC_CMD" -+ ;; -+esac -+fi -+ -+MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -+if test -n "$MAGIC_CMD"; then -+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 -+echo "${ECHO_T}$MAGIC_CMD" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+ else -+ MAGIC_CMD=: -+ fi -+fi -+ -+ fi -+ ;; -+esac -+ -+enable_dlopen=no -+enable_win32_dll=no -+ -+# Check whether --enable-libtool-lock or --disable-libtool-lock was given. -+if test "${enable_libtool_lock+set}" = set; then -+ enableval="$enable_libtool_lock" -+ -+fi; -+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes -+ -+ -+# Check whether --with-pic or --without-pic was given. -+if test "${with_pic+set}" = set; then -+ withval="$with_pic" -+ pic_mode="$withval" -+else -+ pic_mode=default -+fi; -+test -z "$pic_mode" && pic_mode=default -+ -+# Use C for the default configuration in the libtool script -+tagname= -+lt_save_CC="$CC" -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+ -+# Source file extension for C test sources. -+ac_ext=c -+ -+# Object file extension for compiled C test sources. -+objext=o -+objext=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code="int some_variable = 0;\n" -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code='int main(){return(0);}\n' -+ -+ -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} -+ -+# Allow CC to be a program name with arguments. -+compiler=$CC -+ -+ -+# save warnings/boilerplate of simple test code -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_compile_test_code" >conftest.$ac_ext -+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_compiler_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_link_test_code" >conftest.$ac_ext -+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_linker_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ -+# -+# Check for any special shared library compilation flags. -+# -+lt_prog_cc_shlib= -+if test "$GCC" = no; then -+ case $host_os in -+ sco3.2v5*) -+ lt_prog_cc_shlib='-belf' -+ ;; -+ esac -+fi -+if test -n "$lt_prog_cc_shlib"; then -+ { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5 -+echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;} -+ if echo "$old_CC $old_CFLAGS " | grep "[ ]$lt_prog_cc_shlib[ ]" >/dev/null; then : -+ else -+ { echo "$as_me:$LINENO: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 -+echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} -+ lt_cv_prog_cc_can_build_shared=no -+ fi -+fi -+ -+ -+# -+# Check to make sure the static flag actually works. -+# -+echo "$as_me:$LINENO: checking if $compiler static flag $lt_prog_compiler_static works" >&5 -+echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6 -+if test "${lt_prog_compiler_static_works+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_prog_compiler_static_works=no -+ save_LDFLAGS="$LDFLAGS" -+ LDFLAGS="$LDFLAGS $lt_prog_compiler_static" -+ printf "$lt_simple_link_test_code" > conftest.$ac_ext -+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then -+ # The linker can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ if test -s conftest.err; then -+ # Append any errors to the config.log. -+ cat conftest.err 1>&5 -+ $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if diff conftest.exp conftest.er2 >/dev/null; then -+ lt_prog_compiler_static_works=yes -+ fi -+ else -+ lt_prog_compiler_static_works=yes -+ fi -+ fi -+ $rm conftest* -+ LDFLAGS="$save_LDFLAGS" -+ -+fi -+echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 -+echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 -+ -+if test x"$lt_prog_compiler_static_works" = xyes; then -+ : -+else -+ lt_prog_compiler_static= -+fi -+ -+ -+ -+ -+lt_prog_compiler_no_builtin_flag= -+ -+if test "$GCC" = yes; then -+ lt_prog_compiler_no_builtin_flag=' -fno-builtin' -+ -+ -+echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_cv_prog_compiler_rtti_exceptions=no -+ ac_outfile=conftest.$ac_objext -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="-fno-rtti -fno-exceptions" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:6407: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&5 -+ echo "$as_me:6411: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ lt_cv_prog_compiler_rtti_exceptions=yes -+ fi -+ fi -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 -+ -+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then -+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -+else -+ : -+fi -+ -+fi -+ -+lt_prog_compiler_wl= -+lt_prog_compiler_pic= -+lt_prog_compiler_static= -+ -+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 -+ -+ if test "$GCC" = yes; then -+ lt_prog_compiler_wl='-Wl,' -+ lt_prog_compiler_static='-static' -+ -+ case $host_os in -+ aix*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static='-Bstatic' -+ fi -+ ;; -+ -+ amigaos*) -+ # FIXME: we need at least 68020 code to build shared libraries, but -+ # adding the `-m68020' flag to GCC prevents building anything better, -+ # like `-m68040'. -+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' -+ ;; -+ -+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) -+ # PIC is the default for these OSes. -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic='-DDLL_EXPORT' -+ ;; -+ -+ darwin* | rhapsody*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ lt_prog_compiler_pic='-fno-common' -+ ;; -+ -+ msdosdjgpp*) -+ # Just because we use GCC doesn't mean we suddenly get shared libraries -+ # on systems that don't support them. -+ lt_prog_compiler_can_build_shared=no -+ enable_shared=no -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ lt_prog_compiler_pic=-Kconform_pic -+ fi -+ ;; -+ -+ hpux*) -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic='-fPIC' -+ ;; -+ esac -+ ;; -+ -+ *) -+ lt_prog_compiler_pic='-fPIC' -+ ;; -+ esac -+ else -+ # PORTME Check for flag to pass linker flags through the system compiler. -+ case $host_os in -+ aix*) -+ lt_prog_compiler_wl='-Wl,' -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static='-Bstatic' -+ else -+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' -+ fi -+ ;; -+ darwin*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ case $cc_basename in -+ xlc*) -+ lt_prog_compiler_pic='-qnocommon' -+ lt_prog_compiler_wl='-Wl,' -+ ;; -+ esac -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic='-DDLL_EXPORT' -+ ;; -+ -+ hpux9* | hpux10* | hpux11*) -+ lt_prog_compiler_wl='-Wl,' -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic='+Z' -+ ;; -+ esac -+ # Is there a better lt_prog_compiler_static that works with the bundled CC? -+ lt_prog_compiler_static='${wl}-a ${wl}archive' -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ lt_prog_compiler_wl='-Wl,' -+ # PIC (with -KPIC) is the default. -+ lt_prog_compiler_static='-non_shared' -+ ;; -+ -+ newsos6) -+ lt_prog_compiler_pic='-KPIC' -+ lt_prog_compiler_static='-Bstatic' -+ ;; -+ -+ linux*) -+ case $cc_basename in -+ icc* | ecc*) -+ lt_prog_compiler_wl='-Wl,' -+ lt_prog_compiler_pic='-KPIC' -+ lt_prog_compiler_static='-static' -+ ;; -+ pgcc* | pgf77* | pgf90* | pgf95*) -+ # Portland Group compilers (*not* the Pentium gcc compiler, -+ # which looks to be a dead project) -+ lt_prog_compiler_wl='-Wl,' -+ lt_prog_compiler_pic='-fpic' -+ lt_prog_compiler_static='-Bstatic' -+ ;; -+ ccc*) -+ lt_prog_compiler_wl='-Wl,' -+ # All Alpha code is PIC. -+ lt_prog_compiler_static='-non_shared' -+ ;; -+ esac -+ ;; -+ -+ osf3* | osf4* | osf5*) -+ lt_prog_compiler_wl='-Wl,' -+ # All OSF/1 code is PIC. -+ lt_prog_compiler_static='-non_shared' -+ ;; -+ -+ sco3.2v5*) -+ lt_prog_compiler_pic='-Kpic' -+ lt_prog_compiler_static='-dn' -+ ;; -+ -+ solaris*) -+ lt_prog_compiler_pic='-KPIC' -+ lt_prog_compiler_static='-Bstatic' -+ case $cc_basename in -+ f77* | f90* | f95*) -+ lt_prog_compiler_wl='-Qoption ld ';; -+ *) -+ lt_prog_compiler_wl='-Wl,';; -+ esac -+ ;; -+ -+ sunos4*) -+ lt_prog_compiler_wl='-Qoption ld ' -+ lt_prog_compiler_pic='-PIC' -+ lt_prog_compiler_static='-Bstatic' -+ ;; -+ -+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ lt_prog_compiler_wl='-Wl,' -+ lt_prog_compiler_pic='-KPIC' -+ lt_prog_compiler_static='-Bstatic' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec ;then -+ lt_prog_compiler_pic='-Kconform_pic' -+ lt_prog_compiler_static='-Bstatic' -+ fi -+ ;; -+ -+ unicos*) -+ lt_prog_compiler_wl='-Wl,' -+ lt_prog_compiler_can_build_shared=no -+ ;; -+ -+ uts4*) -+ lt_prog_compiler_pic='-pic' -+ lt_prog_compiler_static='-Bstatic' -+ ;; -+ -+ *) -+ lt_prog_compiler_can_build_shared=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic" >&6 -+ -+# -+# Check to make sure the PIC flag actually works. -+# -+if test -n "$lt_prog_compiler_pic"; then -+ -+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 -+if test "${lt_prog_compiler_pic_works+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_prog_compiler_pic_works=no -+ ac_outfile=conftest.$ac_objext -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:6669: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&5 -+ echo "$as_me:6673: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ lt_prog_compiler_pic_works=yes -+ fi -+ fi -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 -+ -+if test x"$lt_prog_compiler_pic_works" = xyes; then -+ case $lt_prog_compiler_pic in -+ "" | " "*) ;; -+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; -+ esac -+else -+ lt_prog_compiler_pic= -+ lt_prog_compiler_can_build_shared=no -+fi -+ -+fi -+case $host_os in -+ # For platforms which do not support PIC, -DPIC is meaningless: -+ *djgpp*) -+ lt_prog_compiler_pic= -+ ;; -+ *) -+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -+if test "${lt_cv_prog_compiler_c_o+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_cv_prog_compiler_c_o=no -+ $rm -r conftest 2>/dev/null -+ mkdir conftest -+ cd conftest -+ mkdir out -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ lt_compiler_flag="-o out/conftest2.$ac_objext" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:6731: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>out/conftest.err) -+ ac_status=$? -+ cat out/conftest.err >&5 -+ echo "$as_me:6735: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s out/conftest2.$ac_objext -+ then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp -+ $SED '/^$/d' out/conftest.err >out/conftest.er2 -+ if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then -+ lt_cv_prog_compiler_c_o=yes -+ fi -+ fi -+ chmod u+w . 2>&5 -+ $rm conftest* -+ # SGI C++ compiler will create directory out/ii_files/ for -+ # template instantiation -+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files -+ $rm out/* && rmdir out -+ cd .. -+ rmdir conftest -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 -+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 -+ -+ -+hard_links="nottested" -+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then -+ # do not overwrite the value of need_locks provided by the user -+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 -+ hard_links=yes -+ $rm conftest* -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ touch conftest.a -+ ln conftest.a conftest.b 2>&5 || hard_links=no -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ echo "$as_me:$LINENO: result: $hard_links" >&5 -+echo "${ECHO_T}$hard_links" >&6 -+ if test "$hard_links" = no; then -+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} -+ need_locks=warn -+ fi -+else -+ need_locks=no -+fi -+ -+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -+ -+ runpath_var= -+ allow_undefined_flag= -+ enable_shared_with_static_runtimes=no -+ archive_cmds= -+ archive_expsym_cmds= -+ old_archive_From_new_cmds= -+ old_archive_from_expsyms_cmds= -+ export_dynamic_flag_spec= -+ whole_archive_flag_spec= -+ thread_safe_flag_spec= -+ hardcode_libdir_flag_spec= -+ hardcode_libdir_flag_spec_ld= -+ hardcode_libdir_separator= -+ hardcode_direct=no -+ hardcode_minus_L=no -+ hardcode_shlibpath_var=unsupported -+ link_all_deplibs=unknown -+ hardcode_automatic=no -+ module_cmds= -+ module_expsym_cmds= -+ always_export_symbols=no -+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ # include_expsyms should be a list of space-separated symbols to be *always* -+ # included in the symbol list -+ include_expsyms= -+ # exclude_expsyms can be an extended regexp of symbols to exclude -+ # it will be wrapped by ` (' and `)$', so one must not match beginning or -+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -+ # as well as any symbol that contains `d'. -+ exclude_expsyms="_GLOBAL_OFFSET_TABLE_" -+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -+ # platforms (ab)use it in PIC code, but their linkers get confused if -+ # the symbol is explicitly referenced. Since portable code cannot -+ # rely on this symbol name, it's probably fine to never include it in -+ # preloaded symbol tables. -+ extract_expsyms_cmds= -+ # Just being paranoid about ensuring that cc_basename is set. -+ for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ case $host_os in -+ cygwin* | mingw* | pw32*) -+ # FIXME: the MSVC++ port hasn't been tested in a loooong time -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ if test "$GCC" != yes; then -+ with_gnu_ld=no -+ fi -+ ;; -+ openbsd*) -+ with_gnu_ld=no -+ ;; -+ esac -+ -+ ld_shlibs=yes -+ if test "$with_gnu_ld" = yes; then -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ wlarc='${wl}' -+ -+ # Set some defaults for GNU ld with shared library support. These -+ # are reset later if shared libraries are not supported. Putting them -+ # here allows them to be overridden if necessary. -+ runpath_var=LD_RUN_PATH -+ hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' -+ export_dynamic_flag_spec='${wl}--export-dynamic' -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then -+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ whole_archive_flag_spec= -+ fi -+ supports_anon_versioning=no -+ case `$LD -v 2>/dev/null` in -+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 -+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... -+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... -+ *\ 2.11.*) ;; # other 2.11 versions -+ *) supports_anon_versioning=yes ;; -+ esac -+ -+ # See if GNU ld supports shared libraries. -+ case $host_os in -+ aix3* | aix4* | aix5*) -+ # On AIX/PPC, the GNU linker is very broken -+ if test "$host_cpu" != ia64; then -+ ld_shlibs=no -+ cat <&2 -+ -+*** Warning: the GNU linker, at least up to release 2.9.1, is reported -+*** to be unable to reliably create shared libraries on AIX. -+*** Therefore, libtool is disabling shared libraries support. If you -+*** really care for shared libraries, you may want to modify your PATH -+*** so that a non-GNU linker is found, and then restart. -+ -+EOF -+ fi -+ ;; -+ -+ amigaos*) -+ archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_minus_L=yes -+ -+ # Samuel A. Falvo II reports -+ # that the semantics of dynamic libraries on AmigaOS, at least up -+ # to version 4, is to share data among multiple programs linked -+ # with the same dynamic library. Since this doesn't match the -+ # behavior of shared libraries on other platforms, we can't use -+ # them. -+ ld_shlibs=no -+ ;; -+ -+ beos*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ allow_undefined_flag=unsupported -+ # Joseph Beckenbach says some releases of gcc -+ # support --undefined. This deserves some investigation. FIXME -+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ else -+ ld_shlibs=no -+ fi -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, -+ # as there is no search path for DLLs. -+ hardcode_libdir_flag_spec='-L$libdir' -+ allow_undefined_flag=unsupported -+ always_export_symbols=no -+ enable_shared_with_static_runtimes=yes -+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' -+ -+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then -+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ # If the export-symbols file already is a .def file (1st line -+ # is EXPORTS), use it as is; otherwise, prepend... -+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then -+ cp $export_symbols $output_objdir/$soname.def; -+ else -+ echo EXPORTS > $output_objdir/$soname.def; -+ cat $export_symbols >> $output_objdir/$soname.def; -+ fi~ -+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ else -+ ld_shlibs=no -+ fi -+ ;; -+ -+ linux*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ tmp_addflag= -+ case $cc_basename,$host_cpu in -+ pgcc*) # Portland Group C compiler -+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag' -+ ;; -+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers -+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag -Mnomain' ;; -+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 -+ tmp_addflag=' -i_dynamic' ;; -+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 -+ tmp_addflag=' -i_dynamic -nofor_main' ;; -+ ifc* | ifort*) # Intel Fortran compiler -+ tmp_addflag=' -nofor_main' ;; -+ esac -+ archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ -+ if test $supports_anon_versioning = yes; then -+ archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ -+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ -+ $echo "local: *; };" >> $output_objdir/$libname.ver~ -+ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' -+ fi -+ link_all_deplibs=no -+ else -+ ld_shlibs=no -+ fi -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' -+ wlarc= -+ else -+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ fi -+ ;; -+ -+ solaris* | sysv5*) -+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then -+ ld_shlibs=no -+ cat <&2 -+ -+*** Warning: The releases 2.8.* of the GNU linker cannot reliably -+*** create shared libraries on Solaris systems. Therefore, libtool -+*** is disabling shared libraries support. We urge you to upgrade GNU -+*** binutils to release 2.9.1 or newer. Another option is to modify -+*** your PATH or compiler configuration so that the native linker is -+*** used, and then restart. -+ -+EOF -+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs=no -+ fi -+ ;; -+ -+ sunos4*) -+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ wlarc= -+ hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ *) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs=no -+ fi -+ ;; -+ esac -+ -+ if test "$ld_shlibs" = no; then -+ runpath_var= -+ hardcode_libdir_flag_spec= -+ export_dynamic_flag_spec= -+ whole_archive_flag_spec= -+ fi -+ else -+ # PORTME fill in a description of your system's linker (not GNU ld) -+ case $host_os in -+ aix3*) -+ allow_undefined_flag=unsupported -+ always_export_symbols=yes -+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' -+ # Note: this linker hardcodes the directories in LIBPATH if there -+ # are no directories specified by -L. -+ hardcode_minus_L=yes -+ if test "$GCC" = yes && test -z "$link_static_flag"; then -+ # Neither direct hardcoding nor static linking is supported with a -+ # broken collect2. -+ hardcode_direct=unsupported -+ fi -+ ;; -+ -+ aix4* | aix5*) -+ if test "$host_cpu" = ia64; then -+ # On IA64, the linker does run time linking by default, so we don't -+ # have to do anything special. -+ aix_use_runtimelinking=no -+ exp_sym_flag='-Bexport' -+ no_entry_flag="" -+ else -+ # If we're using GNU nm, then we don't want the "-C" option. -+ # -C means demangle to AIX nm, but means don't demangle with GNU nm -+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then -+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ else -+ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ fi -+ aix_use_runtimelinking=no -+ -+ # Test if we are trying to use run time linking or normal -+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we -+ # need to do runtime linking. -+ case $host_os in aix4.[23]|aix4.[23].*|aix5*) -+ for ld_flag in $LDFLAGS; do -+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then -+ aix_use_runtimelinking=yes -+ break -+ fi -+ done -+ esac -+ -+ exp_sym_flag='-bexport' -+ no_entry_flag='-bnoentry' -+ fi -+ -+ # When large executables or shared objects are built, AIX ld can -+ # have problems creating the table of contents. If linking a library -+ # or program results in "error TOC overflow" add -mminimal-toc to -+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -+ -+ archive_cmds='' -+ hardcode_direct=yes -+ hardcode_libdir_separator=':' -+ link_all_deplibs=yes -+ -+ if test "$GCC" = yes; then -+ case $host_os in aix4.[012]|aix4.[012].*) -+ # We only want to do this on AIX 4.2 and lower, the check -+ # below for broken collect2 doesn't work under 4.3+ -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ hardcode_direct=yes -+ else -+ # We have old collect2 -+ hardcode_direct=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ hardcode_minus_L=yes -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_libdir_separator= -+ fi -+ esac -+ shared_flag='-shared' -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag="$shared_flag "'${wl}-G' -+ fi -+ else -+ # not using gcc -+ if test "$host_cpu" = ia64; then -+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release -+ # chokes on -Wl,-G. The following line is correct: -+ shared_flag='-G' -+ else -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag='${wl}-G' -+ else -+ shared_flag='${wl}-bM:SRE' -+ fi -+ fi -+ fi -+ -+ # It seems that -bexpall does not export symbols beginning with -+ # underscore (_), so it is better to generate a list of symbols to export. -+ always_export_symbols=yes -+ if test "$aix_use_runtimelinking" = yes; then -+ # Warning - without using the other runtime loading flags (-brtl), -+ # -berok will link without error, but may produce a broken library. -+ allow_undefined_flag='-berok' -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" -+ archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -+ else -+ if test "$host_cpu" = ia64; then -+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' -+ allow_undefined_flag="-z nodefs" -+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -+ else -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" -+ # Warning - without using the other run time loading flags, -+ # -berok will link without error, but may produce a broken library. -+ no_undefined_flag=' ${wl}-bernotok' -+ allow_undefined_flag=' ${wl}-berok' -+ # -bexpall does not export symbols beginning with underscore (_) -+ always_export_symbols=yes -+ # Exported symbols can be pulled into shared objects from archives -+ whole_archive_flag_spec=' ' -+ archive_cmds_need_lc=yes -+ # This is similar to how AIX traditionally builds its shared libraries. -+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' -+ fi -+ fi -+ ;; -+ -+ amigaos*) -+ archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_minus_L=yes -+ # see comment about different semantics on the GNU ld section -+ ld_shlibs=no -+ ;; -+ -+ bsdi[45]*) -+ export_dynamic_flag_spec=-rdynamic -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ # hardcode_libdir_flag_spec is actually meaningless, as there is -+ # no search path for DLLs. -+ hardcode_libdir_flag_spec=' ' -+ allow_undefined_flag=unsupported -+ # Tell ltmain to make .lib files, not .a files. -+ libext=lib -+ # Tell ltmain to make .dll files, not .so files. -+ shrext_cmds=".dll" -+ # FIXME: Setting linknames here is a bad hack. -+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' -+ # The linker will automatically build a .lib file if we build a DLL. -+ old_archive_From_new_cmds='true' -+ # FIXME: Should let the user specify the lib program. -+ old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' -+ fix_srcfile_path='`cygpath -w "$srcfile"`' -+ enable_shared_with_static_runtimes=yes -+ ;; -+ -+ darwin* | rhapsody*) -+ case $host_os in -+ rhapsody* | darwin1.[012]) -+ allow_undefined_flag='${wl}-undefined ${wl}suppress' -+ ;; -+ *) # Darwin 1.3 on -+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then -+ allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ else -+ case ${MACOSX_DEPLOYMENT_TARGET} in -+ 10.[012]) -+ allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ ;; -+ 10.*) -+ allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup' -+ ;; -+ esac -+ fi -+ ;; -+ esac -+ archive_cmds_need_lc=no -+ hardcode_direct=no -+ hardcode_automatic=yes -+ hardcode_shlibpath_var=unsupported -+ whole_archive_flag_spec='' -+ link_all_deplibs=yes -+ if test "$GCC" = yes ; then -+ output_verbose_link_cmd='echo' -+ archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ case $cc_basename in -+ xlc*) -+ output_verbose_link_cmd='echo' -+ archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' -+ module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ ;; -+ *) -+ ld_shlibs=no -+ ;; -+ esac -+ fi -+ ;; -+ -+ dgux*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_shlibpath_var=no -+ ;; -+ -+ freebsd1*) -+ ld_shlibs=no -+ ;; -+ -+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -+ # support. Future versions do this automatically, but an explicit c++rt0.o -+ # does not break anything, and helps significantly (at the cost of a little -+ # extra space). -+ freebsd2.2*) -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' -+ hardcode_libdir_flag_spec='-R$libdir' -+ hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ # Unfortunately, older versions of FreeBSD 2 do not have this feature. -+ freebsd2*) -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct=yes -+ hardcode_minus_L=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' -+ hardcode_libdir_flag_spec='-R$libdir' -+ hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ hpux9*) -+ if test "$GCC" = yes; then -+ archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ else -+ archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ fi -+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator=: -+ hardcode_direct=yes -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L=yes -+ export_dynamic_flag_spec='${wl}-E' -+ ;; -+ -+ hpux10* | hpux11*) -+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ *) -+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ esac -+ else -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ *) -+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ esac -+ fi -+ if test "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*) -+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -+ hardcode_libdir_flag_spec_ld='+b $libdir' -+ hardcode_libdir_separator=: -+ hardcode_direct=no -+ hardcode_shlibpath_var=no -+ ;; -+ ia64*) -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_direct=no -+ hardcode_shlibpath_var=no -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L=yes -+ ;; -+ *) -+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator=: -+ hardcode_direct=yes -+ export_dynamic_flag_spec='${wl}-E' -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L=yes -+ ;; -+ esac -+ fi -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ if test "$GCC" = yes; then -+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ hardcode_libdir_flag_spec_ld='-rpath $libdir' -+ fi -+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator=: -+ link_all_deplibs=yes -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out -+ else -+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF -+ fi -+ hardcode_libdir_flag_spec='-R$libdir' -+ hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ newsos6) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct=yes -+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator=: -+ hardcode_shlibpath_var=no -+ ;; -+ -+ openbsd*) -+ hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' -+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir' -+ export_dynamic_flag_spec='${wl}-E' -+ else -+ case $host_os in -+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec='-R$libdir' -+ ;; -+ *) -+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir' -+ ;; -+ esac -+ fi -+ ;; -+ -+ os2*) -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_minus_L=yes -+ allow_undefined_flag=unsupported -+ archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' -+ old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' -+ ;; -+ -+ osf3*) -+ if test "$GCC" = yes; then -+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ allow_undefined_flag=' -expect_unresolved \*' -+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ fi -+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator=: -+ ;; -+ -+ osf4* | osf5*) # as osf3* with the addition of -msym flag -+ if test "$GCC" = yes; then -+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -+ else -+ allow_undefined_flag=' -expect_unresolved \*' -+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ -+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' -+ -+ # Both c and cxx compiler support -rpath directly -+ hardcode_libdir_flag_spec='-rpath $libdir' -+ fi -+ hardcode_libdir_separator=: -+ ;; -+ -+ sco3.2v5*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var=no -+ export_dynamic_flag_spec='${wl}-Bexport' -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ;; -+ -+ solaris*) -+ no_undefined_flag=' -z text' -+ if test "$GCC" = yes; then -+ wlarc='${wl}' -+ archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' -+ else -+ wlarc='' -+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ fi -+ hardcode_libdir_flag_spec='-R$libdir' -+ hardcode_shlibpath_var=no -+ case $host_os in -+ solaris2.[0-5] | solaris2.[0-5].*) ;; -+ *) -+ # The compiler driver will combine linker options so we -+ # cannot just pass the convience library names through -+ # without $wl, iff we do not link with $LD. -+ # Luckily, gcc supports the same syntax we need for Sun Studio. -+ # Supported since Solaris 2.6 (maybe 2.5.1?) -+ case $wlarc in -+ '') -+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; -+ *) -+ whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; -+ esac ;; -+ esac -+ link_all_deplibs=yes -+ ;; -+ -+ sunos4*) -+ if test "x$host_vendor" = xsequent; then -+ # Use $CC to link under sequent, because it throws in some extra .o -+ # files that make .init and .fini sections work. -+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' -+ fi -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_direct=yes -+ hardcode_minus_L=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ sysv4) -+ case $host_vendor in -+ sni) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct=yes # is this really true??? -+ ;; -+ siemens) -+ ## LD is ld it makes a PLAMLIB -+ ## CC just makes a GrossModule. -+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ reload_cmds='$CC -r -o $output$reload_objs' -+ hardcode_direct=no -+ ;; -+ motorola) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie -+ ;; -+ esac -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var=no -+ ;; -+ -+ sysv4.3*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var=no -+ export_dynamic_flag_spec='-Bexport' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var=no -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ld_shlibs=yes -+ fi -+ ;; -+ -+ sysv4.2uw2*) -+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct=yes -+ hardcode_minus_L=no -+ hardcode_shlibpath_var=no -+ hardcode_runpath_var=yes -+ runpath_var=LD_RUN_PATH -+ ;; -+ -+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) -+ no_undefined_flag='${wl}-z ${wl}text' -+ if test "$GCC" = yes; then -+ archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ fi -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var=no -+ ;; -+ -+ sysv5*) -+ no_undefined_flag=' -z text' -+ # $CC -shared without GNU ld will not create a library from C++ -+ # object files and a static libstdc++, better avoid it by now -+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ hardcode_libdir_flag_spec= -+ hardcode_shlibpath_var=no -+ runpath_var='LD_RUN_PATH' -+ ;; -+ -+ uts4*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_shlibpath_var=no -+ ;; -+ -+ *) -+ ld_shlibs=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $ld_shlibs" >&5 -+echo "${ECHO_T}$ld_shlibs" >&6 -+test "$ld_shlibs" = no && can_build_shared=no -+ -+variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -+if test "$GCC" = yes; then -+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -+fi -+ -+# -+# Do we need to explicitly link libc? -+# -+case "x$archive_cmds_need_lc" in -+x|xyes) -+ # Assume -lc should be added -+ archive_cmds_need_lc=yes -+ -+ if test "$enable_shared" = yes && test "$GCC" = yes; then -+ case $archive_cmds in -+ *'~'*) -+ # FIXME: we may have to deal with multi-command sequences. -+ ;; -+ '$CC '*) -+ # Test whether the compiler implicitly links with -lc since on some -+ # systems, -lgcc has to come before -lc. If gcc already passes -lc -+ # to ld, don't add -lc before -lgcc. -+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 -+ $rm conftest* -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } 2>conftest.err; then -+ soname=conftest -+ lib=conftest -+ libobjs=conftest.$ac_objext -+ deplibs= -+ wl=$lt_prog_compiler_wl -+ compiler_flags=-v -+ linker_flags=-v -+ verstring= -+ output_objdir=. -+ libname=conftest -+ lt_save_allow_undefined_flag=$allow_undefined_flag -+ allow_undefined_flag= -+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 -+ (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+ then -+ archive_cmds_need_lc=no -+ else -+ archive_cmds_need_lc=yes -+ fi -+ allow_undefined_flag=$lt_save_allow_undefined_flag -+ else -+ cat conftest.err 1>&5 -+ fi -+ $rm conftest* -+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 -+echo "${ECHO_T}$archive_cmds_need_lc" >&6 -+ ;; -+ esac -+ fi -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -+library_names_spec= -+libname_spec='lib$name' -+soname_spec= -+shrext_cmds=".so" -+postinstall_cmds= -+postuninstall_cmds= -+finish_cmds= -+finish_eval= -+shlibpath_var= -+shlibpath_overrides_runpath=unknown -+version_type=none -+dynamic_linker="$host_os ld.so" -+sys_lib_dlsearch_path_spec="/lib /usr/lib" -+if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then -+ # if the path contains ";" then we assume it to be the separator -+ # otherwise default to the standard path separator (i.e. ":") - it is -+ # assumed that no part of a normal pathname contains ";" but that should -+ # okay in the real world where ";" in dirpaths is itself problematic. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+else -+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -+fi -+need_lib_prefix=unknown -+hardcode_into_libs=no -+ -+# when you set need_version to no, make sure it does not cause -set_version -+# flags to be left without arguments -+need_version=unknown -+ -+case $host_os in -+aix3*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' -+ shlibpath_var=LIBPATH -+ -+ # AIX 3 has no versioning support, so we append a major version to the name. -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ -+aix4* | aix5*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ hardcode_into_libs=yes -+ if test "$host_cpu" = ia64; then -+ # AIX 5 supports IA64 -+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ else -+ # With GCC up to 2.95.x, collect2 would create an import file -+ # for dependence libraries. The import file would start with -+ # the line `#! .'. This would cause the generated library to -+ # depend on `.', always an invalid library. This was fixed in -+ # development snapshots of GCC prior to 3.0. -+ case $host_os in -+ aix4 | aix4.[01] | aix4.[01].*) -+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -+ echo ' yes ' -+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -+ : -+ else -+ can_build_shared=no -+ fi -+ ;; -+ esac -+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct -+ # soname into executable. Probably we can add versioning support to -+ # collect2, so additional links can be useful in future. -+ if test "$aix_use_runtimelinking" = yes; then -+ # If using run time linking (on AIX 4.2 or later) use lib.so -+ # instead of lib.a to let people know that these are not -+ # typical AIX shared libraries. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ else -+ # We preserve .a as extension for shared libraries through AIX4.2 -+ # and later when we are not doing run time linking. -+ library_names_spec='${libname}${release}.a $libname.a' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ fi -+ shlibpath_var=LIBPATH -+ fi -+ ;; -+ -+amigaos*) -+ library_names_spec='$libname.ixlibrary $libname.a' -+ # Create ${libname}_ixlibrary.a entries in /sys/libs. -+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' -+ ;; -+ -+beos*) -+ library_names_spec='${libname}${shared_ext}' -+ dynamic_linker="$host_os ld.so" -+ shlibpath_var=LIBRARY_PATH -+ ;; -+ -+bsdi[45]*) -+ version_type=linux -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -+ # the default ld.so.conf also contains /usr/contrib/lib and -+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -+ # libtool to hard-code these into programs -+ ;; -+ -+cygwin* | mingw* | pw32*) -+ version_type=windows -+ shrext_cmds=".dll" -+ need_version=no -+ need_lib_prefix=no -+ -+ case $GCC,$host_os in -+ yes,cygwin* | yes,mingw* | yes,pw32*) -+ library_names_spec='$libname.dll.a' -+ # DLL is installed to $(libdir)/../bin by postinstall_cmds -+ postinstall_cmds='base_file=`basename \${file}`~ -+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ -+ dldir=$destdir/`dirname \$dlpath`~ -+ test -d \$dldir || mkdir -p \$dldir~ -+ $install_prog $dir/$dlname \$dldir/$dlname~ -+ chmod a+x \$dldir/$dlname' -+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ -+ dlpath=$dir/\$dldll~ -+ $rm \$dlpath' -+ shlibpath_overrides_runpath=yes -+ -+ case $host_os in -+ cygwin*) -+ # Cygwin DLLs use 'cyg' prefix rather than 'lib' -+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" -+ ;; -+ mingw*) -+ # MinGW DLLs use traditional 'lib' prefix -+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then -+ # It is most probably a Windows format PATH printed by -+ # mingw gcc, but we are running on Cygwin. Gcc prints its search -+ # path with ; separators, and with drive letters. We can handle the -+ # drive letters (cygwin fileutils understands them), so leave them, -+ # especially as we might pass files found there to a mingw objdump, -+ # which wouldn't understand a cygwinified path. Ahh. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+ ;; -+ pw32*) -+ # pw32 DLLs use 'pw' prefix rather than 'lib' -+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ ;; -+ esac -+ ;; -+ -+ *) -+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' -+ ;; -+ esac -+ dynamic_linker='Win32 ld.exe' -+ # FIXME: first we should search . and the directory the executable is in -+ shlibpath_var=PATH -+ ;; -+ -+darwin* | rhapsody*) -+ dynamic_linker="$host_os dyld" -+ version_type=darwin -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' -+ soname_spec='${libname}${release}${major}$shared_ext' -+ shlibpath_overrides_runpath=yes -+ shlibpath_var=DYLD_LIBRARY_PATH -+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. -+ if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` -+ else -+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' -+ fi -+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' -+ ;; -+ -+dgux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+freebsd1*) -+ dynamic_linker=no -+ ;; -+ -+kfreebsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+freebsd* | dragonfly*) -+ # DragonFly does not have aout. When/if they implement a new -+ # versioning mechanism, adjust this. -+ if test -x /usr/bin/objformat; then -+ objformat=`/usr/bin/objformat` -+ else -+ case $host_os in -+ freebsd[123]*) objformat=aout ;; -+ *) objformat=elf ;; -+ esac -+ fi -+ version_type=freebsd-$objformat -+ case $version_type in -+ freebsd-elf*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' -+ need_version=no -+ need_lib_prefix=no -+ ;; -+ freebsd-*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' -+ need_version=yes -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_os in -+ freebsd2*) -+ shlibpath_overrides_runpath=yes -+ ;; -+ freebsd3.[01]* | freebsdelf3.[01]*) -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ *) # from 3.2 on -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ ;; -+ esac -+ ;; -+ -+gnu*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ hardcode_into_libs=yes -+ ;; -+ -+hpux9* | hpux10* | hpux11*) -+ # Give a soname corresponding to the major version so that dld.sl refuses to -+ # link against other versions. -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ case $host_cpu in -+ ia64*) -+ shrext_cmds='.so' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.so" -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ if test "X$HPUX_IA64_MODE" = X32; then -+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" -+ else -+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" -+ fi -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ hppa*64*) -+ shrext_cmds='.sl' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ *) -+ shrext_cmds='.sl' -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=SHLIB_PATH -+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ esac -+ # HP-UX runs *really* slowly unless shared libraries are mode 555. -+ postinstall_cmds='chmod 555 $lib' -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $host_os in -+ nonstopux*) version_type=nonstopux ;; -+ *) -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ version_type=linux -+ else -+ version_type=irix -+ fi ;; -+ esac -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' -+ case $host_os in -+ irix5* | nonstopux*) -+ libsuff= shlibsuff= -+ ;; -+ *) -+ case $LD in # libtool.m4 will add one of these switches to LD -+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") -+ libsuff= shlibsuff= libmagic=32-bit;; -+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") -+ libsuff=32 shlibsuff=N32 libmagic=N32;; -+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") -+ libsuff=64 shlibsuff=64 libmagic=64-bit;; -+ *) libsuff= shlibsuff= libmagic=never-match;; -+ esac -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -+ hardcode_into_libs=yes -+ ;; -+ -+# No shared lib support for Linux oldld, aout, or coff. -+linux*oldld* | linux*aout* | linux*coff*) -+ dynamic_linker=no -+ ;; -+ -+# This must be Linux ELF. -+linux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ # This implies no fast_install, which is unacceptable. -+ # Some rework will be needed to allow for fast_install -+ # before this can be enabled. -+ hardcode_into_libs=yes -+ -+ # Append ld.so.conf contents to the search path -+ if test -f /etc/ld.so.conf; then -+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` -+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" -+ fi -+ -+ # We used to test for /lib/ld.so.1 and disable shared libraries on -+ # powerpc, because MkLinux only supported shared libraries with the -+ # GNU dynamic linker. Since this was broken with cross compilers, -+ # most powerpc-linux boxes support dynamic linking these days and -+ # people can always --disable-shared, the test was removed, and we -+ # assume the GNU/Linux dynamic linker is in use. -+ dynamic_linker='GNU/Linux ld.so' -+ ;; -+ -+netbsdelf*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='NetBSD ld.elf_so' -+ ;; -+ -+knetbsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+netbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ dynamic_linker='NetBSD (a.out) ld.so' -+ else -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ dynamic_linker='NetBSD ld.elf_so' -+ fi -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ -+newsos6) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+nto-qnx*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+openbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. -+ case $host_os in -+ openbsd3.3 | openbsd3.3.*) need_version=yes ;; -+ *) need_version=no ;; -+ esac -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ case $host_os in -+ openbsd2.[89] | openbsd2.[89].*) -+ shlibpath_overrides_runpath=no -+ ;; -+ *) -+ shlibpath_overrides_runpath=yes -+ ;; -+ esac -+ else -+ shlibpath_overrides_runpath=yes -+ fi -+ ;; -+ -+os2*) -+ libname_spec='$name' -+ shrext_cmds=".dll" -+ need_lib_prefix=no -+ library_names_spec='$libname${shared_ext} $libname.a' -+ dynamic_linker='OS/2 ld.exe' -+ shlibpath_var=LIBPATH -+ ;; -+ -+osf3* | osf4* | osf5*) -+ version_type=osf -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -+ ;; -+ -+sco3.2v5*) -+ version_type=osf -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+solaris*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ # ldd complains unless libraries are executable -+ postinstall_cmds='chmod +x $lib' -+ ;; -+ -+sunos4*) -+ version_type=sunos -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ fi -+ need_version=yes -+ ;; -+ -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_vendor in -+ sni) -+ shlibpath_overrides_runpath=no -+ need_lib_prefix=no -+ export_dynamic_flag_spec='${wl}-Blargedynsym' -+ runpath_var=LD_RUN_PATH -+ ;; -+ siemens) -+ need_lib_prefix=no -+ ;; -+ motorola) -+ need_lib_prefix=no -+ need_version=no -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -+ ;; -+ esac -+ ;; -+ -+sysv4*MP*) -+ if test -d /usr/nec ;then -+ version_type=linux -+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' -+ soname_spec='$libname${shared_ext}.$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ fi -+ ;; -+ -+uts4*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+*) -+ dynamic_linker=no -+ ;; -+esac -+echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -+echo "${ECHO_T}$dynamic_linker" >&6 -+test "$dynamic_linker" = no && can_build_shared=no -+ -+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -+hardcode_action= -+if test -n "$hardcode_libdir_flag_spec" || \ -+ test -n "$runpath_var" || \ -+ test "X$hardcode_automatic" = "Xyes" ; then -+ -+ # We can hardcode non-existant directories. -+ if test "$hardcode_direct" != no && -+ # If the only mechanism to avoid hardcoding is shlibpath_var, we -+ # have to relink, otherwise we might link with an installed library -+ # when we should be linking with a yet-to-be-installed one -+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && -+ test "$hardcode_minus_L" != no; then -+ # Linking always hardcodes the temporary library directory. -+ hardcode_action=relink -+ else -+ # We can link without hardcoding, and we can hardcode nonexisting dirs. -+ hardcode_action=immediate -+ fi -+else -+ # We cannot hardcode anything, or else we can only hardcode existing -+ # directories. -+ hardcode_action=unsupported -+fi -+echo "$as_me:$LINENO: result: $hardcode_action" >&5 -+echo "${ECHO_T}$hardcode_action" >&6 -+ -+if test "$hardcode_action" = relink; then -+ # Fast installation is not supported -+ enable_fast_install=no -+elif test "$shlibpath_overrides_runpath" = yes || -+ test "$enable_shared" = no; then -+ # Fast installation is not necessary -+ enable_fast_install=needless -+fi -+ -+striplib= -+old_striplib= -+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -+ test -z "$striplib" && striplib="$STRIP --strip-unneeded" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+else -+# FIXME - insert some real tests, host_os isn't really good enough -+ case $host_os in -+ darwin*) -+ if test -n "$STRIP" ; then -+ striplib="$STRIP -x" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+ else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ ;; -+ *) -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+ ;; -+ esac -+fi -+ -+if test "x$enable_dlopen" != xyes; then -+ enable_dlopen=unknown -+ enable_dlopen_self=unknown -+ enable_dlopen_self_static=unknown -+else -+ lt_cv_dlopen=no -+ lt_cv_dlopen_libs= -+ -+ case $host_os in -+ beos*) -+ lt_cv_dlopen="load_add_on" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ ;; -+ -+ mingw* | pw32*) -+ lt_cv_dlopen="LoadLibrary" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ cygwin*) -+ lt_cv_dlopen="dlopen" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ darwin*) -+ # if libdl is installed we need to link against it -+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -+if test "${ac_cv_lib_dl_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldl $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dl_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dl_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -+if test $ac_cv_lib_dl_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ -+ lt_cv_dlopen="dyld" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ -+fi -+ -+ ;; -+ -+ *) -+ echo "$as_me:$LINENO: checking for shl_load" >&5 -+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -+if test "${ac_cv_func_shl_load+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define shl_load to an innocuous variant, in case declares shl_load. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define shl_load innocuous_shl_load -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char shl_load (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef shl_load -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char shl_load (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_shl_load) || defined (__stub___shl_load) -+choke me -+#else -+char (*f) () = shl_load; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != shl_load; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_shl_load=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_func_shl_load=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -+echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -+if test $ac_cv_func_shl_load = yes; then -+ lt_cv_dlopen="shl_load" -+else -+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -+if test "${ac_cv_lib_dld_shl_load+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char shl_load (); -+int -+main () -+{ -+shl_load (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dld_shl_load=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dld_shl_load=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -+if test $ac_cv_lib_dld_shl_load = yes; then -+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -+else -+ echo "$as_me:$LINENO: checking for dlopen" >&5 -+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -+if test "${ac_cv_func_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define dlopen to an innocuous variant, in case declares dlopen. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define dlopen innocuous_dlopen -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char dlopen (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef dlopen -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_dlopen) || defined (__stub___dlopen) -+choke me -+#else -+char (*f) () = dlopen; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != dlopen; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_func_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -+if test $ac_cv_func_dlopen = yes; then -+ lt_cv_dlopen="dlopen" -+else -+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -+if test "${ac_cv_lib_dl_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldl $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dl_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dl_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -+if test $ac_cv_lib_dl_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -+if test "${ac_cv_lib_svld_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lsvld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_svld_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_svld_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -+if test $ac_cv_lib_svld_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -+else -+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -+if test "${ac_cv_lib_dld_dld_link+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dld_link (); -+int -+main () -+{ -+dld_link (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dld_dld_link=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dld_dld_link=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -+if test $ac_cv_lib_dld_dld_link = yes; then -+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ ;; -+ esac -+ -+ if test "x$lt_cv_dlopen" != xno; then -+ enable_dlopen=yes -+ else -+ enable_dlopen=no -+ fi -+ -+ case $lt_cv_dlopen in -+ dlopen) -+ save_CPPFLAGS="$CPPFLAGS" -+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -+ -+ save_LDFLAGS="$LDFLAGS" -+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -+ -+ save_LIBS="$LIBS" -+ LIBS="$lt_cv_dlopen_libs $LIBS" -+ -+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -+if test "${lt_cv_dlopen_self+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ lt_cv_dlopen_self=cross -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+} -+EOF -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&5 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; -+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; -+ x$lt_unknown|x*) lt_cv_dlopen_self=no ;; -+ esac -+ else : -+ # compilation failed -+ lt_cv_dlopen_self=no -+ fi -+fi -+rm -fr conftest* -+ -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -+echo "${ECHO_T}$lt_cv_dlopen_self" >&6 -+ -+ if test "x$lt_cv_dlopen_self" = xyes; then -+ LDFLAGS="$LDFLAGS $link_static_flag" -+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -+if test "${lt_cv_dlopen_self_static+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ lt_cv_dlopen_self_static=cross -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+} -+EOF -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&5 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; -+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; -+ x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; -+ esac -+ else : -+ # compilation failed -+ lt_cv_dlopen_self_static=no -+ fi -+fi -+rm -fr conftest* -+ -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 -+ fi -+ -+ CPPFLAGS="$save_CPPFLAGS" -+ LDFLAGS="$save_LDFLAGS" -+ LIBS="$save_LIBS" -+ ;; -+ esac -+ -+ case $lt_cv_dlopen_self in -+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -+ *) enable_dlopen_self=unknown ;; -+ esac -+ -+ case $lt_cv_dlopen_self_static in -+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -+ *) enable_dlopen_self_static=unknown ;; -+ esac -+fi -+ -+ -+# Report which librarie types wil actually be built -+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 -+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -+echo "$as_me:$LINENO: result: $can_build_shared" >&5 -+echo "${ECHO_T}$can_build_shared" >&6 -+ -+echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 -+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 -+test "$can_build_shared" = "no" && enable_shared=no -+ -+# On AIX, shared libraries and static libraries use the same namespace, and -+# are all built from PIC. -+case $host_os in -+aix3*) -+ test "$enable_shared" = yes && enable_static=no -+ if test -n "$RANLIB"; then -+ archive_cmds="$archive_cmds~\$RANLIB \$lib" -+ postinstall_cmds='$RANLIB $lib' -+ fi -+ ;; -+ -+aix4* | aix5*) -+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then -+ test "$enable_shared" = yes && enable_static=no -+ fi -+ ;; -+esac -+echo "$as_me:$LINENO: result: $enable_shared" >&5 -+echo "${ECHO_T}$enable_shared" >&6 -+ -+echo "$as_me:$LINENO: checking whether to build static libraries" >&5 -+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 -+# Make sure either enable_shared or enable_static is yes. -+test "$enable_shared" = yes || enable_static=yes -+echo "$as_me:$LINENO: result: $enable_static" >&5 -+echo "${ECHO_T}$enable_static" >&6 -+ -+# The else clause should only fire when bootstrapping the -+# libtool distribution, otherwise you forgot to ship ltmain.sh -+# with your package, and you will get complaints that there are -+# no rules to generate ltmain.sh. -+if test -f "$ltmain"; then -+ # See if we are running on zsh, and set the options which allow our commands through -+ # without removal of \ escapes. -+ if test -n "${ZSH_VERSION+set}" ; then -+ setopt NO_GLOB_SUBST -+ fi -+ # Now quote all the things that may contain metacharacters while being -+ # careful not to overquote the AC_SUBSTed values. We take copies of the -+ # variables and quote the copies for generation of the libtool script. -+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ -+ SED SHELL STRIP \ -+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ -+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ -+ deplibs_check_method reload_flag reload_cmds need_locks \ -+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ -+ lt_cv_sys_global_symbol_to_c_name_address \ -+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -+ old_postinstall_cmds old_postuninstall_cmds \ -+ compiler \ -+ CC \ -+ LD \ -+ lt_prog_compiler_wl \ -+ lt_prog_compiler_pic \ -+ lt_prog_compiler_static \ -+ lt_prog_compiler_no_builtin_flag \ -+ export_dynamic_flag_spec \ -+ thread_safe_flag_spec \ -+ whole_archive_flag_spec \ -+ enable_shared_with_static_runtimes \ -+ old_archive_cmds \ -+ old_archive_from_new_cmds \ -+ predep_objects \ -+ postdep_objects \ -+ predeps \ -+ postdeps \ -+ compiler_lib_search_path \ -+ archive_cmds \ -+ archive_expsym_cmds \ -+ postinstall_cmds \ -+ postuninstall_cmds \ -+ old_archive_from_expsyms_cmds \ -+ allow_undefined_flag \ -+ no_undefined_flag \ -+ export_symbols_cmds \ -+ hardcode_libdir_flag_spec \ -+ hardcode_libdir_flag_spec_ld \ -+ hardcode_libdir_separator \ -+ hardcode_automatic \ -+ module_cmds \ -+ module_expsym_cmds \ -+ lt_cv_prog_compiler_c_o \ -+ exclude_expsyms \ -+ include_expsyms; do -+ -+ case $var in -+ old_archive_cmds | \ -+ old_archive_from_new_cmds | \ -+ archive_cmds | \ -+ archive_expsym_cmds | \ -+ module_cmds | \ -+ module_expsym_cmds | \ -+ old_archive_from_expsyms_cmds | \ -+ export_symbols_cmds | \ -+ extract_expsyms_cmds | reload_cmds | finish_cmds | \ -+ postinstall_cmds | postuninstall_cmds | \ -+ old_postinstall_cmds | old_postuninstall_cmds | \ -+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -+ # Double-quote double-evaled strings. -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -+ ;; -+ *) -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -+ ;; -+ esac -+ done -+ -+ case $lt_echo in -+ *'\$0 --fallback-echo"') -+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` -+ ;; -+ esac -+ -+cfgfile="${ofile}T" -+ trap "$rm \"$cfgfile\"; exit 1" 1 2 15 -+ $rm -f "$cfgfile" -+ { echo "$as_me:$LINENO: creating $ofile" >&5 -+echo "$as_me: creating $ofile" >&6;} -+ -+ cat <<__EOF__ >> "$cfgfile" -+#! $SHELL -+ -+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -+# NOTE: Changes made to this file will be lost: look at ltmain.sh. -+# -+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -+# Free Software Foundation, Inc. -+# -+# This file is part of GNU Libtool: -+# Originally by Gordon Matzigkeit , 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 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+# -+# 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. -+ -+# A sed program that does not truncate output. -+SED=$lt_SED -+ -+# Sed that helps us avoid accidentally triggering echo(1) options like -n. -+Xsed="$SED -e 1s/^X//" -+ -+# The HP-UX ksh and POSIX shell print the target directory to stdout -+# if CDPATH is set. -+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH -+ -+# The names of the tagged configurations supported by this script. -+available_tags= -+ -+# ### BEGIN LIBTOOL CONFIG -+ -+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+ -+# Shell to use when invoking shell scripts. -+SHELL=$lt_SHELL -+ -+# Whether or not to build shared libraries. -+build_libtool_libs=$enable_shared -+ -+# Whether or not to build static libraries. -+build_old_libs=$enable_static -+ -+# Whether or not to add -lc for building shared libraries. -+build_libtool_need_lc=$archive_cmds_need_lc -+ -+# Whether or not to disallow shared libs when runtime libs are static -+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes -+ -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ -+# The host system. -+host_alias=$host_alias -+host=$host -+host_os=$host_os -+ -+# The build system. -+build_alias=$build_alias -+build=$build -+build_os=$build_os -+ -+# An echo program that does not interpret backslashes. -+echo=$lt_echo -+ -+# The archiver. -+AR=$lt_AR -+AR_FLAGS=$lt_AR_FLAGS -+ -+# A C compiler. -+LTCC=$lt_LTCC -+ -+# A language-specific compiler. -+CC=$lt_compiler -+ -+# Is the compiler the GNU C compiler? -+with_gcc=$GCC -+ -+# An ERE matcher. -+EGREP=$lt_EGREP -+ -+# The linker used to build libraries. -+LD=$lt_LD -+ -+# Whether we need hard or soft links. -+LN_S=$lt_LN_S -+ -+# A BSD-compatible nm program. -+NM=$lt_NM -+ -+# A symbol stripping program -+STRIP=$lt_STRIP -+ -+# Used to examine libraries when file_magic_cmd begins "file" -+MAGIC_CMD=$MAGIC_CMD -+ -+# Used on cygwin: DLL creation program. -+DLLTOOL="$DLLTOOL" -+ -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. -+AS="$AS" -+ -+# The name of the directory that contains temporary libtool files. -+objdir=$objdir -+ -+# How to create reloadable object files. -+reload_flag=$lt_reload_flag -+reload_cmds=$lt_reload_cmds -+ -+# How to pass a linker flag through the compiler. -+wl=$lt_lt_prog_compiler_wl -+ -+# Object file suffix (normally "o"). -+objext="$ac_objext" -+ -+# Old archive suffix (normally "a"). -+libext="$libext" -+ -+# Shared library suffix (normally ".so"). -+shrext_cmds='$shrext_cmds' -+ -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ -+# Additional compiler flags for building library objects. -+pic_flag=$lt_lt_prog_compiler_pic -+pic_mode=$pic_mode -+ -+# What is the maximum length of a command? -+max_cmd_len=$lt_cv_sys_max_cmd_len -+ -+# Does compiler simultaneously support -c and -o options? -+compiler_c_o=$lt_lt_cv_prog_compiler_c_o -+ -+# Must we lock files when doing compilation? -+need_locks=$lt_need_locks -+ -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen_support=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ -+# Compiler flag to prevent dynamic linking. -+link_static_flag=$lt_lt_prog_compiler_static -+ -+# Compiler flag to turn off builtin functions. -+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag -+ -+# Compiler flag to allow reflexive dlopens. -+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec -+ -+# Compiler flag to generate shared objects directly from archives. -+whole_archive_flag_spec=$lt_whole_archive_flag_spec -+ -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$lt_thread_safe_flag_spec -+ -+# Library versioning type. -+version_type=$version_type -+ -+# Format of library name prefix. -+libname_spec=$lt_libname_spec -+ -+# List of archive names. First name is the real one, the rest are links. -+# The last name is the one that the linker finds with -lNAME. -+library_names_spec=$lt_library_names_spec -+ -+# The coded name of the library, if different from the real name. -+soname_spec=$lt_soname_spec -+ -+# Commands used to build and install an old-style archive. -+RANLIB=$lt_RANLIB -+old_archive_cmds=$lt_old_archive_cmds -+old_postinstall_cmds=$lt_old_postinstall_cmds -+old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ -+# Create an old-style archive from a shared archive. -+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds -+ -+# Create a temporary old-style archive to link instead of a shared archive. -+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds -+ -+# Commands used to build and install a shared archive. -+archive_cmds=$lt_archive_cmds -+archive_expsym_cmds=$lt_archive_expsym_cmds -+postinstall_cmds=$lt_postinstall_cmds -+postuninstall_cmds=$lt_postuninstall_cmds -+ -+# Commands used to build a loadable module (assumed same as above if empty) -+module_cmds=$lt_module_cmds -+module_expsym_cmds=$lt_module_expsym_cmds -+ -+# Commands to strip libraries. -+old_striplib=$lt_old_striplib -+striplib=$lt_striplib -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predep_objects=$lt_predep_objects -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdep_objects=$lt_postdep_objects -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predeps=$lt_predeps -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdeps=$lt_postdeps -+ -+# The library search path used internally by the compiler when linking -+# a shared library. -+compiler_lib_search_path=$lt_compiler_lib_search_path -+ -+# Method to check whether dependent libraries are shared objects. -+deplibs_check_method=$lt_deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$lt_file_magic_cmd -+ -+# Flag that allows shared libraries with undefined symbols to be built. -+allow_undefined_flag=$lt_allow_undefined_flag -+ -+# Flag that forces no undefined symbols. -+no_undefined_flag=$lt_no_undefined_flag -+ -+# Commands used to finish a libtool library installation in a directory. -+finish_cmds=$lt_finish_cmds -+ -+# Same as above, but a single script fragment to be evaled but not shown. -+finish_eval=$lt_finish_eval -+ -+# Take the output of nm and produce a listing of raw symbols and C names. -+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe -+ -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl -+ -+# Transform the output of nm in a C name address pair -+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address -+ -+# This is the shared library runtime path variable. -+runpath_var=$runpath_var -+ -+# This is the shared library path variable. -+shlibpath_var=$shlibpath_var -+ -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+ -+# How to hardcode a shared library path into an executable. -+hardcode_action=$hardcode_action -+ -+# Whether we should hardcode library paths into libraries. -+hardcode_into_libs=$hardcode_into_libs -+ -+# Flag to hardcode \$libdir into a binary during linking. -+# This must work even if \$libdir does not exist. -+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec -+ -+# If ld is used when linking, flag to hardcode \$libdir into -+# a binary during linking. This must work even if \$libdir does -+# not exist. -+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld -+ -+# Whether we need a single -rpath flag with a separated argument. -+hardcode_libdir_separator=$lt_hardcode_libdir_separator -+ -+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -+# resulting binary. -+hardcode_direct=$hardcode_direct -+ -+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -+# resulting binary. -+hardcode_minus_L=$hardcode_minus_L -+ -+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -+# the resulting binary. -+hardcode_shlibpath_var=$hardcode_shlibpath_var -+ -+# Set to yes if building a shared library automatically hardcodes DIR into the library -+# and all subsequent libraries and executables linked against it. -+hardcode_automatic=$hardcode_automatic -+ -+# Variables whose values should be saved in libtool wrapper scripts and -+# restored at relink time. -+variables_saved_for_relink="$variables_saved_for_relink" -+ -+# Whether libtool must link a program against all its dependency libraries. -+link_all_deplibs=$link_all_deplibs -+ -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ -+# Fix the shell variable \$srcfile for the compiler. -+fix_srcfile_path="$fix_srcfile_path" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$always_export_symbols -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$lt_export_symbols_cmds -+ -+# The commands to extract the exported symbol list from a shared archive. -+extract_expsyms_cmds=$lt_extract_expsyms_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$lt_exclude_expsyms -+ -+# Symbols that must always be exported. -+include_expsyms=$lt_include_expsyms -+ -+# ### END LIBTOOL CONFIG -+ -+__EOF__ -+ -+ -+ case $host_os in -+ aix3*) -+ cat <<\EOF >> "$cfgfile" -+ -+# AIX sometimes has problems with the GCC collect2 program. For some -+# reason, if we set the COLLECT_NAMES environment variable, the problems -+# vanish in a puff of smoke. -+if test "X${COLLECT_NAMES+set}" != Xset; then -+ COLLECT_NAMES= -+ export COLLECT_NAMES -+fi -+EOF -+ ;; -+ esac -+ -+ # We use sed instead of cat because bash on DJGPP gets confused if -+ # if finds mixed CR/LF and LF-only lines. Since sed operates in -+ # text mode, it properly converts lines to CR/LF. This bash problem -+ # is reportedly fixed, but why not run on old versions too? -+ sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) -+ -+ mv -f "$cfgfile" "$ofile" || \ -+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") -+ chmod +x "$ofile" -+ -+else -+ # If there is no Makefile yet, we rely on a make rule to execute -+ # `config.status --recheck' to rerun these tests and create the -+ # libtool script then. -+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` -+ if test -f "$ltmain_in"; then -+ test -f Makefile && make "$ltmain" -+ fi -+fi -+ -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+CC="$lt_save_CC" -+ -+ -+# Check whether --with-tags or --without-tags was given. -+if test "${with_tags+set}" = set; then -+ withval="$with_tags" -+ tagnames="$withval" -+fi; -+ -+if test -f "$ltmain" && test -n "$tagnames"; then -+ if test ! -f "${ofile}"; then -+ { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 -+echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} -+ fi -+ -+ if test -z "$LTCC"; then -+ eval "`$SHELL ${ofile} --config | grep '^LTCC='`" -+ if test -z "$LTCC"; then -+ { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 -+echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} -+ else -+ { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 -+echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} -+ fi -+ fi -+ -+ # Extract list of available tagged configurations in $ofile. -+ # Note that this assumes the entire list is on one line. -+ available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` -+ -+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," -+ for tagname in $tagnames; do -+ IFS="$lt_save_ifs" -+ # Check whether tagname contains only valid characters -+ case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in -+ "") ;; -+ *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 -+echo "$as_me: error: invalid tag name: $tagname" >&2;} -+ { (exit 1); exit 1; }; } -+ ;; -+ esac -+ -+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null -+ then -+ { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 -+echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} -+ { (exit 1); exit 1; }; } -+ fi -+ -+ # Update the list of available tags. -+ if test -n "$tagname"; then -+ echo appending configuration tag \"$tagname\" to $ofile -+ -+ case $tagname in -+ CXX) -+ if test -n "$CXX" && ( test "X$CXX" != "Xno" && -+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || -+ (test "X$CXX" != "Xg++"))) ; then -+ ac_ext=cc -+ac_cpp='$CXXCPP $CPPFLAGS' -+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -+ -+ -+ -+ -+archive_cmds_need_lc_CXX=no -+allow_undefined_flag_CXX= -+always_export_symbols_CXX=no -+archive_expsym_cmds_CXX= -+export_dynamic_flag_spec_CXX= -+hardcode_direct_CXX=no -+hardcode_libdir_flag_spec_CXX= -+hardcode_libdir_flag_spec_ld_CXX= -+hardcode_libdir_separator_CXX= -+hardcode_minus_L_CXX=no -+hardcode_automatic_CXX=no -+module_cmds_CXX= -+module_expsym_cmds_CXX= -+link_all_deplibs_CXX=unknown -+old_archive_cmds_CXX=$old_archive_cmds -+no_undefined_flag_CXX= -+whole_archive_flag_spec_CXX= -+enable_shared_with_static_runtimes_CXX=no -+ -+# Dependencies to place before and after the object being linked: -+predep_objects_CXX= -+postdep_objects_CXX= -+predeps_CXX= -+postdeps_CXX= -+compiler_lib_search_path_CXX= -+ -+# Source file extension for C++ test sources. -+ac_ext=cpp -+ -+# Object file extension for compiled C++ test sources. -+objext=o -+objext_CXX=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code="int some_variable = 0;\n" -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code='int main(int, char *) { return(0); }\n' -+ -+# ltmain only uses $CC for tagged configurations so make sure $CC is set. -+ -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} -+ -+# Allow CC to be a program name with arguments. -+compiler=$CC -+ -+ -+# save warnings/boilerplate of simple test code -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_compile_test_code" >conftest.$ac_ext -+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_compiler_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_link_test_code" >conftest.$ac_ext -+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_linker_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ -+# Allow CC to be a program name with arguments. -+lt_save_CC=$CC -+lt_save_LD=$LD -+lt_save_GCC=$GCC -+GCC=$GXX -+lt_save_with_gnu_ld=$with_gnu_ld -+lt_save_path_LD=$lt_cv_path_LD -+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then -+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx -+else -+ unset lt_cv_prog_gnu_ld -+fi -+if test -n "${lt_cv_path_LDCXX+set}"; then -+ lt_cv_path_LD=$lt_cv_path_LDCXX -+else -+ unset lt_cv_path_LD -+fi -+test -z "${LDCXX+set}" || LD=$LDCXX -+CC=${CXX-"c++"} -+compiler=$CC -+compiler_CXX=$CC -+for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ -+# We don't want -fno-exception wen compiling C++ code, so set the -+# no_builtin_flag separately -+if test "$GXX" = yes; then -+ lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' -+else -+ lt_prog_compiler_no_builtin_flag_CXX= -+fi -+ -+if test "$GXX" = yes; then -+ # Set up default GNU C++ configuration -+ -+ -+# Check whether --with-gnu-ld or --without-gnu-ld was given. -+if test "${with_gnu_ld+set}" = set; then -+ withval="$with_gnu_ld" -+ test "$withval" = no || with_gnu_ld=yes -+else -+ with_gnu_ld=no -+fi; -+ac_prog=ld -+if test "$GCC" = yes; then -+ # Check if gcc -print-prog-name=ld gives a path. -+ echo "$as_me:$LINENO: checking for ld used by $CC" >&5 -+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 -+ case $host in -+ *-*-mingw*) -+ # gcc leaves a trailing carriage return which upsets mingw -+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; -+ *) -+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; -+ esac -+ case $ac_prog in -+ # Accept absolute paths. -+ [\\/]* | ?:[\\/]*) -+ re_direlt='/[^/][^/]*/\.\./' -+ # Canonicalize the pathname of ld -+ ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` -+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -+ ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` -+ done -+ test -z "$LD" && LD="$ac_prog" -+ ;; -+ "") -+ # If it fails, then pretend we aren't using GCC. -+ ac_prog=ld -+ ;; -+ *) -+ # If it is relative, then search for the first ld in PATH. -+ with_gnu_ld=unknown -+ ;; -+ esac -+elif test "$with_gnu_ld" = yes; then -+ echo "$as_me:$LINENO: checking for GNU ld" >&5 -+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 -+else -+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5 -+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 -+fi -+if test "${lt_cv_path_LD+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -z "$LD"; then -+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in $PATH; do -+ IFS="$lt_save_ifs" -+ test -z "$ac_dir" && ac_dir=. -+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then -+ lt_cv_path_LD="$ac_dir/$ac_prog" -+ # Check to see if the program is GNU ld. I'd rather use --version, -+ # but apparently some variants of GNU ld only accept -v. -+ # Break only if it was the GNU/non-GNU ld that we prefer. -+ case `"$lt_cv_path_LD" -v 2>&1 &5 -+echo "${ECHO_T}$LD" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 -+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} -+ { (exit 1); exit 1; }; } -+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 -+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 -+if test "${lt_cv_prog_gnu_ld+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ # I'd rather use --version here, but apparently some GNU lds only accept -v. -+case `$LD -v 2>&1 &5 -+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 -+with_gnu_ld=$lt_cv_prog_gnu_ld -+ -+ -+ -+ # Check if GNU C++ uses GNU ld as the underlying linker, since the -+ # archiving commands below assume that GNU ld is being used. -+ if test "$with_gnu_ld" = yes; then -+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' -+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic' -+ -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to -+ # investigate it a little bit more. (MM) -+ wlarc='${wl}' -+ -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ -+ grep 'no-whole-archive' > /dev/null; then -+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ whole_archive_flag_spec_CXX= -+ fi -+ else -+ with_gnu_ld=no -+ wlarc= -+ -+ # A generic and very simple default shared library creation -+ # command for GNU C++ for the case where it uses the native -+ # linker, instead of GNU ld. If possible, this setting should -+ # overridden to take advantage of the native linker features on -+ # the platform it is being used on. -+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' -+ fi -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' -+ -+else -+ GXX=no -+ with_gnu_ld=no -+ wlarc= -+fi -+ -+# PORTME: fill in a description of your system's C++ link characteristics -+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -+ld_shlibs_CXX=yes -+case $host_os in -+ aix3*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ aix4* | aix5*) -+ if test "$host_cpu" = ia64; then -+ # On IA64, the linker does run time linking by default, so we don't -+ # have to do anything special. -+ aix_use_runtimelinking=no -+ exp_sym_flag='-Bexport' -+ no_entry_flag="" -+ else -+ aix_use_runtimelinking=no -+ -+ # Test if we are trying to use run time linking or normal -+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we -+ # need to do runtime linking. -+ case $host_os in aix4.[23]|aix4.[23].*|aix5*) -+ for ld_flag in $LDFLAGS; do -+ case $ld_flag in -+ *-brtl*) -+ aix_use_runtimelinking=yes -+ break -+ ;; -+ esac -+ done -+ esac -+ -+ exp_sym_flag='-bexport' -+ no_entry_flag='-bnoentry' -+ fi -+ -+ # When large executables or shared objects are built, AIX ld can -+ # have problems creating the table of contents. If linking a library -+ # or program results in "error TOC overflow" add -mminimal-toc to -+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -+ -+ archive_cmds_CXX='' -+ hardcode_direct_CXX=yes -+ hardcode_libdir_separator_CXX=':' -+ link_all_deplibs_CXX=yes -+ -+ if test "$GXX" = yes; then -+ case $host_os in aix4.[012]|aix4.[012].*) -+ # We only want to do this on AIX 4.2 and lower, the check -+ # below for broken collect2 doesn't work under 4.3+ -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ hardcode_direct_CXX=yes -+ else -+ # We have old collect2 -+ hardcode_direct_CXX=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ hardcode_minus_L_CXX=yes -+ hardcode_libdir_flag_spec_CXX='-L$libdir' -+ hardcode_libdir_separator_CXX= -+ fi -+ esac -+ shared_flag='-shared' -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag="$shared_flag "'${wl}-G' -+ fi -+ else -+ # not using gcc -+ if test "$host_cpu" = ia64; then -+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release -+ # chokes on -Wl,-G. The following line is correct: -+ shared_flag='-G' -+ else -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag='${wl}-G' -+ else -+ shared_flag='${wl}-bM:SRE' -+ fi -+ fi -+ fi -+ -+ # It seems that -bexpall does not export symbols beginning with -+ # underscore (_), so it is better to generate a list of symbols to export. -+ always_export_symbols_CXX=yes -+ if test "$aix_use_runtimelinking" = yes; then -+ # Warning - without using the other runtime loading flags (-brtl), -+ # -berok will link without error, but may produce a broken library. -+ allow_undefined_flag_CXX='-berok' -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" -+ -+ archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -+ else -+ if test "$host_cpu" = ia64; then -+ hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' -+ allow_undefined_flag_CXX="-z nodefs" -+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -+ else -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" -+ # Warning - without using the other run time loading flags, -+ # -berok will link without error, but may produce a broken library. -+ no_undefined_flag_CXX=' ${wl}-bernotok' -+ allow_undefined_flag_CXX=' ${wl}-berok' -+ # -bexpall does not export symbols beginning with underscore (_) -+ always_export_symbols_CXX=yes -+ # Exported symbols can be pulled into shared objects from archives -+ whole_archive_flag_spec_CXX=' ' -+ archive_cmds_need_lc_CXX=yes -+ # This is similar to how AIX traditionally builds its shared libraries. -+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' -+ fi -+ fi -+ ;; -+ chorus*) -+ case $cc_basename in -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ ;; -+ -+ -+ cygwin* | mingw* | pw32*) -+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, -+ # as there is no search path for DLLs. -+ hardcode_libdir_flag_spec_CXX='-L$libdir' -+ allow_undefined_flag_CXX=unsupported -+ always_export_symbols_CXX=no -+ enable_shared_with_static_runtimes_CXX=yes -+ -+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then -+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ # If the export-symbols file already is a .def file (1st line -+ # is EXPORTS), use it as is; otherwise, prepend... -+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then -+ cp $export_symbols $output_objdir/$soname.def; -+ else -+ echo EXPORTS > $output_objdir/$soname.def; -+ cat $export_symbols >> $output_objdir/$soname.def; -+ fi~ -+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ else -+ ld_shlibs_CXX=no -+ fi -+ ;; -+ darwin* | rhapsody*) -+ case $host_os in -+ rhapsody* | darwin1.[012]) -+ allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress' -+ ;; -+ *) # Darwin 1.3 on -+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then -+ allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ else -+ case ${MACOSX_DEPLOYMENT_TARGET} in -+ 10.[012]) -+ allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ ;; -+ 10.*) -+ allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup' -+ ;; -+ esac -+ fi -+ ;; -+ esac -+ archive_cmds_need_lc_CXX=no -+ hardcode_direct_CXX=no -+ hardcode_automatic_CXX=yes -+ hardcode_shlibpath_var_CXX=unsupported -+ whole_archive_flag_spec_CXX='' -+ link_all_deplibs_CXX=yes -+ -+ if test "$GXX" = yes ; then -+ lt_int_apple_cc_single_mod=no -+ output_verbose_link_cmd='echo' -+ if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then -+ lt_int_apple_cc_single_mod=yes -+ fi -+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then -+ archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ else -+ archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ fi -+ module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ if test "X$lt_int_apple_cc_single_mod" = Xyes ; then -+ archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ fi -+ module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ case $cc_basename in -+ xlc*) -+ output_verbose_link_cmd='echo' -+ archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' -+ module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ ;; -+ *) -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ fi -+ ;; -+ -+ dgux*) -+ case $cc_basename in -+ ec++*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ ghcx*) -+ # Green Hills C++ Compiler -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ ;; -+ freebsd[12]*) -+ # C++ shared libraries reported to be fairly broken before switch to ELF -+ ld_shlibs_CXX=no -+ ;; -+ freebsd-elf*) -+ archive_cmds_need_lc_CXX=no -+ ;; -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF -+ # conventions -+ ld_shlibs_CXX=yes -+ ;; -+ gnu*) -+ ;; -+ hpux9*) -+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator_CXX=: -+ export_dynamic_flag_spec_CXX='${wl}-E' -+ hardcode_direct_CXX=yes -+ hardcode_minus_L_CXX=yes # Not in the search PATH, -+ # but as the default -+ # location of the library. -+ -+ case $cc_basename in -+ CC*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ aCC*) -+ archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes; then -+ archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ else -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ fi -+ ;; -+ esac -+ ;; -+ hpux10*|hpux11*) -+ if test $with_gnu_ld = no; then -+ case $host_cpu in -+ hppa*64*) -+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' -+ hardcode_libdir_flag_spec_ld_CXX='+b $libdir' -+ hardcode_libdir_separator_CXX=: -+ ;; -+ ia64*) -+ hardcode_libdir_flag_spec_CXX='-L$libdir' -+ ;; -+ *) -+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator_CXX=: -+ export_dynamic_flag_spec_CXX='${wl}-E' -+ ;; -+ esac -+ fi -+ case $host_cpu in -+ hppa*64*) -+ hardcode_direct_CXX=no -+ hardcode_shlibpath_var_CXX=no -+ ;; -+ ia64*) -+ hardcode_direct_CXX=no -+ hardcode_shlibpath_var_CXX=no -+ hardcode_minus_L_CXX=yes # Not in the search PATH, -+ # but as the default -+ # location of the library. -+ ;; -+ *) -+ hardcode_direct_CXX=yes -+ hardcode_minus_L_CXX=yes # Not in the search PATH, -+ # but as the default -+ # location of the library. -+ ;; -+ esac -+ -+ case $cc_basename in -+ CC*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ aCC*) -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' -+ ;; -+ *) -+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' -+ ;; -+ esac -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes; then -+ if test $with_gnu_ld = no; then -+ case $host_cpu in -+ ia64*|hppa*64*) -+ archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' -+ ;; -+ *) -+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' -+ ;; -+ esac -+ fi -+ else -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ fi -+ ;; -+ esac -+ ;; -+ irix5* | irix6*) -+ case $cc_basename in -+ CC*) -+ # SGI C++ -+ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ -+ # Archives containing C++ object files must be created using -+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is -+ # necessary to make sure instantiated templates are included -+ # in the archive. -+ old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' -+ ;; -+ *) -+ if test "$GXX" = yes; then -+ if test "$with_gnu_ld" = no; then -+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' -+ fi -+ fi -+ link_all_deplibs_CXX=yes -+ ;; -+ esac -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_CXX=: -+ ;; -+ linux*) -+ case $cc_basename in -+ KCC*) -+ # Kuck and Associates, Inc. (KAI) C++ Compiler -+ -+ # KCC will only create a shared library if the output file -+ # ends with ".so" (or ".sl" for HP-UX), so rename the library -+ # to its proper name (with version) after linking. -+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' -+ archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' -+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic' -+ -+ # Archives containing C++ object files must be created using -+ # "CC -Bstatic", where "CC" is the KAI C++ compiler. -+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' -+ ;; -+ icpc*) -+ # Intel C++ -+ with_gnu_ld=yes -+ # version 8.0 and above of icpc choke on multiply defined symbols -+ # if we add $predep_objects and $postdep_objects, however 7.1 and -+ # earlier do not add the objects themselves. -+ case `$CC -V 2>&1` in -+ *"Version 7."*) -+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ ;; -+ *) # Version 8.0 or newer -+ tmp_idyn= -+ case $host_cpu in -+ ia64*) tmp_idyn=' -i_dynamic';; -+ esac -+ archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ ;; -+ esac -+ archive_cmds_need_lc_CXX=no -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' -+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic' -+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' -+ ;; -+ pgCC*) -+ # Portland Group C++ compiler -+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' -+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' -+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic' -+ whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ ;; -+ cxx*) -+ # Compaq C++ -+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' -+ -+ runpath_var=LD_RUN_PATH -+ hardcode_libdir_flag_spec_CXX='-rpath $libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ esac -+ ;; -+ lynxos*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ m88k*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ mvs*) -+ case $cc_basename in -+ cxx*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ ;; -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' -+ wlarc= -+ hardcode_libdir_flag_spec_CXX='-R$libdir' -+ hardcode_direct_CXX=yes -+ hardcode_shlibpath_var_CXX=no -+ fi -+ # Workaround some broken pre-1.5 toolchains -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' -+ ;; -+ openbsd2*) -+ # C++ shared libraries are fairly broken -+ ld_shlibs_CXX=no -+ ;; -+ openbsd*) -+ hardcode_direct_CXX=yes -+ hardcode_shlibpath_var_CXX=no -+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' -+ export_dynamic_flag_spec_CXX='${wl}-E' -+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ fi -+ output_verbose_link_cmd='echo' -+ ;; -+ osf3*) -+ case $cc_basename in -+ KCC*) -+ # Kuck and Associates, Inc. (KAI) C++ Compiler -+ -+ # KCC will only create a shared library if the output file -+ # ends with ".so" (or ".sl" for HP-UX), so rename the library -+ # to its proper name (with version) after linking. -+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Archives containing C++ object files must be created using -+ # "CC -Bstatic", where "CC" is the KAI C++ compiler. -+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' -+ -+ ;; -+ RCC*) -+ # Rational C++ 2.4.1 -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ cxx*) -+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then -+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' -+ -+ else -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ fi -+ ;; -+ esac -+ ;; -+ osf4* | osf5*) -+ case $cc_basename in -+ KCC*) -+ # Kuck and Associates, Inc. (KAI) C++ Compiler -+ -+ # KCC will only create a shared library if the output file -+ # ends with ".so" (or ".sl" for HP-UX), so rename the library -+ # to its proper name (with version) after linking. -+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Archives containing C++ object files must be created using -+ # the KAI C++ compiler. -+ old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' -+ ;; -+ RCC*) -+ # Rational C++ 2.4.1 -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ cxx*) -+ allow_undefined_flag_CXX=' -expect_unresolved \*' -+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ -+ echo "-hidden">> $lib.exp~ -+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ -+ $rm $lib.exp' -+ -+ hardcode_libdir_flag_spec_CXX='-rpath $libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ # -+ # There doesn't appear to be a way to prevent this compiler from -+ # explicitly linking system object files so we need to strip them -+ # from the output so that they don't get included in the library -+ # dependencies. -+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' -+ ;; -+ *) -+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then -+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_CXX=: -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' -+ -+ else -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ fi -+ ;; -+ esac -+ ;; -+ psos*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ sco*) -+ archive_cmds_need_lc_CXX=no -+ case $cc_basename in -+ CC*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ ;; -+ sunos4*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.x -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ lcc*) -+ # Lucid -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ ;; -+ solaris*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.2, 5.x and Centerline C++ -+ archive_cmds_need_lc_CXX=yes -+ no_undefined_flag_CXX=' -zdefs' -+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' -+ archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' -+ -+ hardcode_libdir_flag_spec_CXX='-R$libdir' -+ hardcode_shlibpath_var_CXX=no -+ case $host_os in -+ solaris2.[0-5] | solaris2.[0-5].*) ;; -+ *) -+ # The C++ compiler is used as linker so we must use $wl -+ # flag to pass the commands to the underlying system -+ # linker. We must also pass each convience library through -+ # to the system linker between allextract/defaultextract. -+ # The C++ compiler will combine linker options so we -+ # cannot just pass the convience library names through -+ # without $wl. -+ # Supported since Solaris 2.6 (maybe 2.5.1?) -+ whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' -+ ;; -+ esac -+ link_all_deplibs_CXX=yes -+ -+ output_verbose_link_cmd='echo' -+ -+ # Archives containing C++ object files must be created using -+ # "CC -xar", where "CC" is the Sun C++ compiler. This is -+ # necessary to make sure instantiated templates are included -+ # in the archive. -+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' -+ ;; -+ gcx*) -+ # Green Hills C++ Compiler -+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' -+ -+ # The C++ compiler must be used to create the archive. -+ old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' -+ ;; -+ *) -+ # GNU C++ compiler with Solaris linker -+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then -+ no_undefined_flag_CXX=' ${wl}-z ${wl}defs' -+ if $CC --version | grep -v '^2\.7' > /dev/null; then -+ archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' -+ archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" -+ else -+ # g++ 2.7 appears to require `-G' NOT `-shared' on this -+ # platform. -+ archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' -+ archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' -+ -+ # Commands to make compiler produce verbose output that lists -+ # what "hidden" libraries, object files and flags are used when -+ # linking a shared library. -+ output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" -+ fi -+ -+ hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' -+ fi -+ ;; -+ esac -+ ;; -+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) -+ archive_cmds_need_lc_CXX=no -+ ;; -+ tandem*) -+ case $cc_basename in -+ NCC*) -+ # NonStop-UX NCC 3.20 -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ esac -+ ;; -+ vxworks*) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+ *) -+ # FIXME: insert proper C++ library support -+ ld_shlibs_CXX=no -+ ;; -+esac -+echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 -+echo "${ECHO_T}$ld_shlibs_CXX" >&6 -+test "$ld_shlibs_CXX" = no && can_build_shared=no -+ -+GCC_CXX="$GXX" -+LD_CXX="$LD" -+ -+ -+cat > conftest.$ac_ext <&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ # Parse the compiler output and extract the necessary -+ # objects, libraries and library flags. -+ -+ # Sentinel used to keep track of whether or not we are before -+ # the conftest object file. -+ pre_test_object_deps_done=no -+ -+ # The `*' in the case matches for architectures that use `case' in -+ # $output_verbose_cmd can trigger glob expansion during the loop -+ # eval without this substitution. -+ output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` -+ -+ for p in `eval $output_verbose_link_cmd`; do -+ case $p in -+ -+ -L* | -R* | -l*) -+ # Some compilers place space between "-{L,R}" and the path. -+ # Remove the space. -+ if test $p = "-L" \ -+ || test $p = "-R"; then -+ prev=$p -+ continue -+ else -+ prev= -+ fi -+ -+ if test "$pre_test_object_deps_done" = no; then -+ case $p in -+ -L* | -R*) -+ # Internal compiler library paths should come after those -+ # provided the user. The postdeps already come after the -+ # user supplied libs so there is no need to process them. -+ if test -z "$compiler_lib_search_path_CXX"; then -+ compiler_lib_search_path_CXX="${prev}${p}" -+ else -+ compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" -+ fi -+ ;; -+ # The "-l" case would never come before the object being -+ # linked, so don't bother handling this case. -+ esac -+ else -+ if test -z "$postdeps_CXX"; then -+ postdeps_CXX="${prev}${p}" -+ else -+ postdeps_CXX="${postdeps_CXX} ${prev}${p}" -+ fi -+ fi -+ ;; -+ -+ *.$objext) -+ # This assumes that the test object file only shows up -+ # once in the compiler output. -+ if test "$p" = "conftest.$objext"; then -+ pre_test_object_deps_done=yes -+ continue -+ fi -+ -+ if test "$pre_test_object_deps_done" = no; then -+ if test -z "$predep_objects_CXX"; then -+ predep_objects_CXX="$p" -+ else -+ predep_objects_CXX="$predep_objects_CXX $p" -+ fi -+ else -+ if test -z "$postdep_objects_CXX"; then -+ postdep_objects_CXX="$p" -+ else -+ postdep_objects_CXX="$postdep_objects_CXX $p" -+ fi -+ fi -+ ;; -+ -+ *) ;; # Ignore the rest. -+ -+ esac -+ done -+ -+ # Clean up. -+ rm -f a.out a.exe -+else -+ echo "libtool.m4: error: problem compiling CXX test program" -+fi -+ -+$rm -f confest.$objext -+ -+# PORTME: override above test on systems where it is broken -+case $host_os in -+solaris*) -+ case $cc_basename in -+ CC*) -+ # Adding this requires a known-good setup of shared libraries for -+ # Sun compiler versions before 5.6, else PIC objects from an old -+ # archive will be linked into the output, leading to subtle bugs. -+ postdeps_CXX='-lCstd -lCrun' -+ ;; -+ esac -+esac -+ -+ -+case " $postdeps_CXX " in -+*" -lc "*) archive_cmds_need_lc_CXX=no ;; -+esac -+ -+lt_prog_compiler_wl_CXX= -+lt_prog_compiler_pic_CXX= -+lt_prog_compiler_static_CXX= -+ -+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 -+ -+ # C++ specific cases for pic, static, wl, etc. -+ if test "$GXX" = yes; then -+ lt_prog_compiler_wl_CXX='-Wl,' -+ lt_prog_compiler_static_CXX='-static' -+ -+ case $host_os in -+ aix*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static_CXX='-Bstatic' -+ fi -+ ;; -+ amigaos*) -+ # FIXME: we need at least 68020 code to build shared libraries, but -+ # adding the `-m68020' flag to GCC prevents building anything better, -+ # like `-m68040'. -+ lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' -+ ;; -+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) -+ # PIC is the default for these OSes. -+ ;; -+ mingw* | os2* | pw32*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT' -+ ;; -+ darwin* | rhapsody*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ lt_prog_compiler_pic_CXX='-fno-common' -+ ;; -+ *djgpp*) -+ # DJGPP does not support shared libraries at all -+ lt_prog_compiler_pic_CXX= -+ ;; -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ lt_prog_compiler_pic_CXX=-Kconform_pic -+ fi -+ ;; -+ hpux*) -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ ;; -+ *) -+ lt_prog_compiler_pic_CXX='-fPIC' -+ ;; -+ esac -+ ;; -+ *) -+ lt_prog_compiler_pic_CXX='-fPIC' -+ ;; -+ esac -+ else -+ case $host_os in -+ aix4* | aix5*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static_CXX='-Bstatic' -+ else -+ lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' -+ fi -+ ;; -+ chorus*) -+ case $cc_basename in -+ cxch68*) -+ # Green Hills C++ Compiler -+ # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" -+ ;; -+ esac -+ ;; -+ darwin*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ case $cc_basename in -+ xlc*) -+ lt_prog_compiler_pic_CXX='-qnocommon' -+ lt_prog_compiler_wl_CXX='-Wl,' -+ ;; -+ esac -+ ;; -+ dgux*) -+ case $cc_basename in -+ ec++*) -+ lt_prog_compiler_pic_CXX='-KPIC' -+ ;; -+ ghcx*) -+ # Green Hills C++ Compiler -+ lt_prog_compiler_pic_CXX='-pic' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ # FreeBSD uses GNU C++ -+ ;; -+ hpux9* | hpux10* | hpux11*) -+ case $cc_basename in -+ CC*) -+ lt_prog_compiler_wl_CXX='-Wl,' -+ lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" -+ if test "$host_cpu" != ia64; then -+ lt_prog_compiler_pic_CXX='+Z' -+ fi -+ ;; -+ aCC*) -+ lt_prog_compiler_wl_CXX='-Wl,' -+ lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic_CXX='+Z' -+ ;; -+ esac -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ irix5* | irix6* | nonstopux*) -+ case $cc_basename in -+ CC*) -+ lt_prog_compiler_wl_CXX='-Wl,' -+ lt_prog_compiler_static_CXX='-non_shared' -+ # CC pic flag -KPIC is the default. -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ linux*) -+ case $cc_basename in -+ KCC*) -+ # KAI C++ Compiler -+ lt_prog_compiler_wl_CXX='--backend -Wl,' -+ lt_prog_compiler_pic_CXX='-fPIC' -+ ;; -+ icpc* | ecpc*) -+ # Intel C++ -+ lt_prog_compiler_wl_CXX='-Wl,' -+ lt_prog_compiler_pic_CXX='-KPIC' -+ lt_prog_compiler_static_CXX='-static' -+ ;; -+ pgCC*) -+ # Portland Group C++ compiler. -+ lt_prog_compiler_wl_CXX='-Wl,' -+ lt_prog_compiler_pic_CXX='-fpic' -+ lt_prog_compiler_static_CXX='-Bstatic' -+ ;; -+ cxx*) -+ # Compaq C++ -+ # Make sure the PIC flag is empty. It appears that all Alpha -+ # Linux and Compaq Tru64 Unix objects are PIC. -+ lt_prog_compiler_pic_CXX= -+ lt_prog_compiler_static_CXX='-non_shared' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ lynxos*) -+ ;; -+ m88k*) -+ ;; -+ mvs*) -+ case $cc_basename in -+ cxx*) -+ lt_prog_compiler_pic_CXX='-W c,exportall' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ ;; -+ osf3* | osf4* | osf5*) -+ case $cc_basename in -+ KCC*) -+ lt_prog_compiler_wl_CXX='--backend -Wl,' -+ ;; -+ RCC*) -+ # Rational C++ 2.4.1 -+ lt_prog_compiler_pic_CXX='-pic' -+ ;; -+ cxx*) -+ # Digital/Compaq C++ -+ lt_prog_compiler_wl_CXX='-Wl,' -+ # Make sure the PIC flag is empty. It appears that all Alpha -+ # Linux and Compaq Tru64 Unix objects are PIC. -+ lt_prog_compiler_pic_CXX= -+ lt_prog_compiler_static_CXX='-non_shared' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ psos*) -+ ;; -+ sco*) -+ case $cc_basename in -+ CC*) -+ lt_prog_compiler_pic_CXX='-fPIC' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ solaris*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.2, 5.x and Centerline C++ -+ lt_prog_compiler_pic_CXX='-KPIC' -+ lt_prog_compiler_static_CXX='-Bstatic' -+ lt_prog_compiler_wl_CXX='-Qoption ld ' -+ ;; -+ gcx*) -+ # Green Hills C++ Compiler -+ lt_prog_compiler_pic_CXX='-PIC' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ sunos4*) -+ case $cc_basename in -+ CC*) -+ # Sun C++ 4.x -+ lt_prog_compiler_pic_CXX='-pic' -+ lt_prog_compiler_static_CXX='-Bstatic' -+ ;; -+ lcc*) -+ # Lucid -+ lt_prog_compiler_pic_CXX='-pic' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ tandem*) -+ case $cc_basename in -+ NCC*) -+ # NonStop-UX NCC 3.20 -+ lt_prog_compiler_pic_CXX='-KPIC' -+ ;; -+ *) -+ ;; -+ esac -+ ;; -+ unixware*) -+ ;; -+ vxworks*) -+ ;; -+ *) -+ lt_prog_compiler_can_build_shared_CXX=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 -+ -+# -+# Check to make sure the PIC flag actually works. -+# -+if test -n "$lt_prog_compiler_pic_CXX"; then -+ -+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 -+if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_prog_compiler_pic_works_CXX=no -+ ac_outfile=conftest.$ac_objext -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:11334: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&5 -+ echo "$as_me:11338: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ lt_prog_compiler_pic_works_CXX=yes -+ fi -+ fi -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 -+ -+if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then -+ case $lt_prog_compiler_pic_CXX in -+ "" | " "*) ;; -+ *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; -+ esac -+else -+ lt_prog_compiler_pic_CXX= -+ lt_prog_compiler_can_build_shared_CXX=no -+fi -+ -+fi -+case $host_os in -+ # For platforms which do not support PIC, -DPIC is meaningless: -+ *djgpp*) -+ lt_prog_compiler_pic_CXX= -+ ;; -+ *) -+ lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -+if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_cv_prog_compiler_c_o_CXX=no -+ $rm -r conftest 2>/dev/null -+ mkdir conftest -+ cd conftest -+ mkdir out -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ lt_compiler_flag="-o out/conftest2.$ac_objext" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:11396: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>out/conftest.err) -+ ac_status=$? -+ cat out/conftest.err >&5 -+ echo "$as_me:11400: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s out/conftest2.$ac_objext -+ then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp -+ $SED '/^$/d' out/conftest.err >out/conftest.er2 -+ if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then -+ lt_cv_prog_compiler_c_o_CXX=yes -+ fi -+ fi -+ chmod u+w . 2>&5 -+ $rm conftest* -+ # SGI C++ compiler will create directory out/ii_files/ for -+ # template instantiation -+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files -+ $rm out/* && rmdir out -+ cd .. -+ rmdir conftest -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 -+ -+ -+hard_links="nottested" -+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then -+ # do not overwrite the value of need_locks provided by the user -+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 -+ hard_links=yes -+ $rm conftest* -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ touch conftest.a -+ ln conftest.a conftest.b 2>&5 || hard_links=no -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ echo "$as_me:$LINENO: result: $hard_links" >&5 -+echo "${ECHO_T}$hard_links" >&6 -+ if test "$hard_links" = no; then -+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} -+ need_locks=warn -+ fi -+else -+ need_locks=no -+fi -+ -+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -+ -+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ case $host_os in -+ aix4* | aix5*) -+ # If we're using GNU nm, then we don't want the "-C" option. -+ # -C means demangle to AIX nm, but means don't demangle with GNU nm -+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then -+ export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ else -+ export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ fi -+ ;; -+ pw32*) -+ export_symbols_cmds_CXX="$ltdll_cmds" -+ ;; -+ cygwin* | mingw*) -+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' -+ ;; -+ linux*) -+ link_all_deplibs_CXX=no -+ ;; -+ *) -+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ ;; -+ esac -+ -+echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 -+echo "${ECHO_T}$ld_shlibs_CXX" >&6 -+test "$ld_shlibs_CXX" = no && can_build_shared=no -+ -+variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -+if test "$GCC" = yes; then -+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -+fi -+ -+# -+# Do we need to explicitly link libc? -+# -+case "x$archive_cmds_need_lc_CXX" in -+x|xyes) -+ # Assume -lc should be added -+ archive_cmds_need_lc_CXX=yes -+ -+ if test "$enable_shared" = yes && test "$GCC" = yes; then -+ case $archive_cmds_CXX in -+ *'~'*) -+ # FIXME: we may have to deal with multi-command sequences. -+ ;; -+ '$CC '*) -+ # Test whether the compiler implicitly links with -lc since on some -+ # systems, -lgcc has to come before -lc. If gcc already passes -lc -+ # to ld, don't add -lc before -lgcc. -+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 -+ $rm conftest* -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } 2>conftest.err; then -+ soname=conftest -+ lib=conftest -+ libobjs=conftest.$ac_objext -+ deplibs= -+ wl=$lt_prog_compiler_wl_CXX -+ compiler_flags=-v -+ linker_flags=-v -+ verstring= -+ output_objdir=. -+ libname=conftest -+ lt_save_allow_undefined_flag=$allow_undefined_flag_CXX -+ allow_undefined_flag_CXX= -+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 -+ (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+ then -+ archive_cmds_need_lc_CXX=no -+ else -+ archive_cmds_need_lc_CXX=yes -+ fi -+ allow_undefined_flag_CXX=$lt_save_allow_undefined_flag -+ else -+ cat conftest.err 1>&5 -+ fi -+ $rm conftest* -+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 -+echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 -+ ;; -+ esac -+ fi -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -+library_names_spec= -+libname_spec='lib$name' -+soname_spec= -+shrext_cmds=".so" -+postinstall_cmds= -+postuninstall_cmds= -+finish_cmds= -+finish_eval= -+shlibpath_var= -+shlibpath_overrides_runpath=unknown -+version_type=none -+dynamic_linker="$host_os ld.so" -+sys_lib_dlsearch_path_spec="/lib /usr/lib" -+if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then -+ # if the path contains ";" then we assume it to be the separator -+ # otherwise default to the standard path separator (i.e. ":") - it is -+ # assumed that no part of a normal pathname contains ";" but that should -+ # okay in the real world where ";" in dirpaths is itself problematic. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+else -+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -+fi -+need_lib_prefix=unknown -+hardcode_into_libs=no -+ -+# when you set need_version to no, make sure it does not cause -set_version -+# flags to be left without arguments -+need_version=unknown -+ -+case $host_os in -+aix3*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' -+ shlibpath_var=LIBPATH -+ -+ # AIX 3 has no versioning support, so we append a major version to the name. -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ -+aix4* | aix5*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ hardcode_into_libs=yes -+ if test "$host_cpu" = ia64; then -+ # AIX 5 supports IA64 -+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ else -+ # With GCC up to 2.95.x, collect2 would create an import file -+ # for dependence libraries. The import file would start with -+ # the line `#! .'. This would cause the generated library to -+ # depend on `.', always an invalid library. This was fixed in -+ # development snapshots of GCC prior to 3.0. -+ case $host_os in -+ aix4 | aix4.[01] | aix4.[01].*) -+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -+ echo ' yes ' -+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -+ : -+ else -+ can_build_shared=no -+ fi -+ ;; -+ esac -+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct -+ # soname into executable. Probably we can add versioning support to -+ # collect2, so additional links can be useful in future. -+ if test "$aix_use_runtimelinking" = yes; then -+ # If using run time linking (on AIX 4.2 or later) use lib.so -+ # instead of lib.a to let people know that these are not -+ # typical AIX shared libraries. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ else -+ # We preserve .a as extension for shared libraries through AIX4.2 -+ # and later when we are not doing run time linking. -+ library_names_spec='${libname}${release}.a $libname.a' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ fi -+ shlibpath_var=LIBPATH -+ fi -+ ;; -+ -+amigaos*) -+ library_names_spec='$libname.ixlibrary $libname.a' -+ # Create ${libname}_ixlibrary.a entries in /sys/libs. -+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' -+ ;; -+ -+beos*) -+ library_names_spec='${libname}${shared_ext}' -+ dynamic_linker="$host_os ld.so" -+ shlibpath_var=LIBRARY_PATH -+ ;; -+ -+bsdi[45]*) -+ version_type=linux -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -+ # the default ld.so.conf also contains /usr/contrib/lib and -+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -+ # libtool to hard-code these into programs -+ ;; -+ -+cygwin* | mingw* | pw32*) -+ version_type=windows -+ shrext_cmds=".dll" -+ need_version=no -+ need_lib_prefix=no -+ -+ case $GCC,$host_os in -+ yes,cygwin* | yes,mingw* | yes,pw32*) -+ library_names_spec='$libname.dll.a' -+ # DLL is installed to $(libdir)/../bin by postinstall_cmds -+ postinstall_cmds='base_file=`basename \${file}`~ -+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ -+ dldir=$destdir/`dirname \$dlpath`~ -+ test -d \$dldir || mkdir -p \$dldir~ -+ $install_prog $dir/$dlname \$dldir/$dlname~ -+ chmod a+x \$dldir/$dlname' -+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ -+ dlpath=$dir/\$dldll~ -+ $rm \$dlpath' -+ shlibpath_overrides_runpath=yes -+ -+ case $host_os in -+ cygwin*) -+ # Cygwin DLLs use 'cyg' prefix rather than 'lib' -+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" -+ ;; -+ mingw*) -+ # MinGW DLLs use traditional 'lib' prefix -+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then -+ # It is most probably a Windows format PATH printed by -+ # mingw gcc, but we are running on Cygwin. Gcc prints its search -+ # path with ; separators, and with drive letters. We can handle the -+ # drive letters (cygwin fileutils understands them), so leave them, -+ # especially as we might pass files found there to a mingw objdump, -+ # which wouldn't understand a cygwinified path. Ahh. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+ ;; -+ pw32*) -+ # pw32 DLLs use 'pw' prefix rather than 'lib' -+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ ;; -+ esac -+ ;; -+ -+ *) -+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' -+ ;; -+ esac -+ dynamic_linker='Win32 ld.exe' -+ # FIXME: first we should search . and the directory the executable is in -+ shlibpath_var=PATH -+ ;; -+ -+darwin* | rhapsody*) -+ dynamic_linker="$host_os dyld" -+ version_type=darwin -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' -+ soname_spec='${libname}${release}${major}$shared_ext' -+ shlibpath_overrides_runpath=yes -+ shlibpath_var=DYLD_LIBRARY_PATH -+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. -+ if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` -+ else -+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' -+ fi -+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' -+ ;; -+ -+dgux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+freebsd1*) -+ dynamic_linker=no -+ ;; -+ -+kfreebsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+freebsd* | dragonfly*) -+ # DragonFly does not have aout. When/if they implement a new -+ # versioning mechanism, adjust this. -+ if test -x /usr/bin/objformat; then -+ objformat=`/usr/bin/objformat` -+ else -+ case $host_os in -+ freebsd[123]*) objformat=aout ;; -+ *) objformat=elf ;; -+ esac -+ fi -+ version_type=freebsd-$objformat -+ case $version_type in -+ freebsd-elf*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' -+ need_version=no -+ need_lib_prefix=no -+ ;; -+ freebsd-*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' -+ need_version=yes -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_os in -+ freebsd2*) -+ shlibpath_overrides_runpath=yes -+ ;; -+ freebsd3.[01]* | freebsdelf3.[01]*) -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ *) # from 3.2 on -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ ;; -+ esac -+ ;; -+ -+gnu*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ hardcode_into_libs=yes -+ ;; -+ -+hpux9* | hpux10* | hpux11*) -+ # Give a soname corresponding to the major version so that dld.sl refuses to -+ # link against other versions. -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ case $host_cpu in -+ ia64*) -+ shrext_cmds='.so' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.so" -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ if test "X$HPUX_IA64_MODE" = X32; then -+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" -+ else -+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" -+ fi -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ hppa*64*) -+ shrext_cmds='.sl' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ *) -+ shrext_cmds='.sl' -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=SHLIB_PATH -+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ esac -+ # HP-UX runs *really* slowly unless shared libraries are mode 555. -+ postinstall_cmds='chmod 555 $lib' -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $host_os in -+ nonstopux*) version_type=nonstopux ;; -+ *) -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ version_type=linux -+ else -+ version_type=irix -+ fi ;; -+ esac -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' -+ case $host_os in -+ irix5* | nonstopux*) -+ libsuff= shlibsuff= -+ ;; -+ *) -+ case $LD in # libtool.m4 will add one of these switches to LD -+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") -+ libsuff= shlibsuff= libmagic=32-bit;; -+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") -+ libsuff=32 shlibsuff=N32 libmagic=N32;; -+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") -+ libsuff=64 shlibsuff=64 libmagic=64-bit;; -+ *) libsuff= shlibsuff= libmagic=never-match;; -+ esac -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -+ hardcode_into_libs=yes -+ ;; -+ -+# No shared lib support for Linux oldld, aout, or coff. -+linux*oldld* | linux*aout* | linux*coff*) -+ dynamic_linker=no -+ ;; -+ -+# This must be Linux ELF. -+linux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ # This implies no fast_install, which is unacceptable. -+ # Some rework will be needed to allow for fast_install -+ # before this can be enabled. -+ hardcode_into_libs=yes -+ -+ # Append ld.so.conf contents to the search path -+ if test -f /etc/ld.so.conf; then -+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` -+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" -+ fi -+ -+ # We used to test for /lib/ld.so.1 and disable shared libraries on -+ # powerpc, because MkLinux only supported shared libraries with the -+ # GNU dynamic linker. Since this was broken with cross compilers, -+ # most powerpc-linux boxes support dynamic linking these days and -+ # people can always --disable-shared, the test was removed, and we -+ # assume the GNU/Linux dynamic linker is in use. -+ dynamic_linker='GNU/Linux ld.so' -+ ;; -+ -+netbsdelf*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='NetBSD ld.elf_so' -+ ;; -+ -+knetbsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+netbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ dynamic_linker='NetBSD (a.out) ld.so' -+ else -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ dynamic_linker='NetBSD ld.elf_so' -+ fi -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ -+newsos6) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+nto-qnx*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+openbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. -+ case $host_os in -+ openbsd3.3 | openbsd3.3.*) need_version=yes ;; -+ *) need_version=no ;; -+ esac -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ case $host_os in -+ openbsd2.[89] | openbsd2.[89].*) -+ shlibpath_overrides_runpath=no -+ ;; -+ *) -+ shlibpath_overrides_runpath=yes -+ ;; -+ esac -+ else -+ shlibpath_overrides_runpath=yes -+ fi -+ ;; -+ -+os2*) -+ libname_spec='$name' -+ shrext_cmds=".dll" -+ need_lib_prefix=no -+ library_names_spec='$libname${shared_ext} $libname.a' -+ dynamic_linker='OS/2 ld.exe' -+ shlibpath_var=LIBPATH -+ ;; -+ -+osf3* | osf4* | osf5*) -+ version_type=osf -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -+ ;; -+ -+sco3.2v5*) -+ version_type=osf -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+solaris*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ # ldd complains unless libraries are executable -+ postinstall_cmds='chmod +x $lib' -+ ;; -+ -+sunos4*) -+ version_type=sunos -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ fi -+ need_version=yes -+ ;; -+ -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_vendor in -+ sni) -+ shlibpath_overrides_runpath=no -+ need_lib_prefix=no -+ export_dynamic_flag_spec='${wl}-Blargedynsym' -+ runpath_var=LD_RUN_PATH -+ ;; -+ siemens) -+ need_lib_prefix=no -+ ;; -+ motorola) -+ need_lib_prefix=no -+ need_version=no -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -+ ;; -+ esac -+ ;; -+ -+sysv4*MP*) -+ if test -d /usr/nec ;then -+ version_type=linux -+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' -+ soname_spec='$libname${shared_ext}.$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ fi -+ ;; -+ -+uts4*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+*) -+ dynamic_linker=no -+ ;; -+esac -+echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -+echo "${ECHO_T}$dynamic_linker" >&6 -+test "$dynamic_linker" = no && can_build_shared=no -+ -+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -+hardcode_action_CXX= -+if test -n "$hardcode_libdir_flag_spec_CXX" || \ -+ test -n "$runpath_var_CXX" || \ -+ test "X$hardcode_automatic_CXX" = "Xyes" ; then -+ -+ # We can hardcode non-existant directories. -+ if test "$hardcode_direct_CXX" != no && -+ # If the only mechanism to avoid hardcoding is shlibpath_var, we -+ # have to relink, otherwise we might link with an installed library -+ # when we should be linking with a yet-to-be-installed one -+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && -+ test "$hardcode_minus_L_CXX" != no; then -+ # Linking always hardcodes the temporary library directory. -+ hardcode_action_CXX=relink -+ else -+ # We can link without hardcoding, and we can hardcode nonexisting dirs. -+ hardcode_action_CXX=immediate -+ fi -+else -+ # We cannot hardcode anything, or else we can only hardcode existing -+ # directories. -+ hardcode_action_CXX=unsupported -+fi -+echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 -+echo "${ECHO_T}$hardcode_action_CXX" >&6 -+ -+if test "$hardcode_action_CXX" = relink; then -+ # Fast installation is not supported -+ enable_fast_install=no -+elif test "$shlibpath_overrides_runpath" = yes || -+ test "$enable_shared" = no; then -+ # Fast installation is not necessary -+ enable_fast_install=needless -+fi -+ -+striplib= -+old_striplib= -+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -+ test -z "$striplib" && striplib="$STRIP --strip-unneeded" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+else -+# FIXME - insert some real tests, host_os isn't really good enough -+ case $host_os in -+ darwin*) -+ if test -n "$STRIP" ; then -+ striplib="$STRIP -x" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+ else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ ;; -+ *) -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+ ;; -+ esac -+fi -+ -+if test "x$enable_dlopen" != xyes; then -+ enable_dlopen=unknown -+ enable_dlopen_self=unknown -+ enable_dlopen_self_static=unknown -+else -+ lt_cv_dlopen=no -+ lt_cv_dlopen_libs= -+ -+ case $host_os in -+ beos*) -+ lt_cv_dlopen="load_add_on" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ ;; -+ -+ mingw* | pw32*) -+ lt_cv_dlopen="LoadLibrary" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ cygwin*) -+ lt_cv_dlopen="dlopen" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ darwin*) -+ # if libdl is installed we need to link against it -+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -+if test "${ac_cv_lib_dl_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldl $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dl_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dl_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -+if test $ac_cv_lib_dl_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ -+ lt_cv_dlopen="dyld" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ -+fi -+ -+ ;; -+ -+ *) -+ echo "$as_me:$LINENO: checking for shl_load" >&5 -+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -+if test "${ac_cv_func_shl_load+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define shl_load to an innocuous variant, in case declares shl_load. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define shl_load innocuous_shl_load -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char shl_load (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef shl_load -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char shl_load (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_shl_load) || defined (__stub___shl_load) -+choke me -+#else -+char (*f) () = shl_load; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != shl_load; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_shl_load=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_func_shl_load=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -+echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -+if test $ac_cv_func_shl_load = yes; then -+ lt_cv_dlopen="shl_load" -+else -+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -+if test "${ac_cv_lib_dld_shl_load+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char shl_load (); -+int -+main () -+{ -+shl_load (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dld_shl_load=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dld_shl_load=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -+if test $ac_cv_lib_dld_shl_load = yes; then -+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -+else -+ echo "$as_me:$LINENO: checking for dlopen" >&5 -+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -+if test "${ac_cv_func_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define dlopen to an innocuous variant, in case declares dlopen. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define dlopen innocuous_dlopen -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char dlopen (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef dlopen -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_dlopen) || defined (__stub___dlopen) -+choke me -+#else -+char (*f) () = dlopen; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != dlopen; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_func_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -+if test $ac_cv_func_dlopen = yes; then -+ lt_cv_dlopen="dlopen" -+else -+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -+if test "${ac_cv_lib_dl_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldl $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dl_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dl_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -+if test $ac_cv_lib_dl_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -+if test "${ac_cv_lib_svld_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lsvld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_svld_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_svld_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -+if test $ac_cv_lib_svld_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -+else -+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -+if test "${ac_cv_lib_dld_dld_link+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dld_link (); -+int -+main () -+{ -+dld_link (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dld_dld_link=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dld_dld_link=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -+if test $ac_cv_lib_dld_dld_link = yes; then -+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ ;; -+ esac -+ -+ if test "x$lt_cv_dlopen" != xno; then -+ enable_dlopen=yes -+ else -+ enable_dlopen=no -+ fi -+ -+ case $lt_cv_dlopen in -+ dlopen) -+ save_CPPFLAGS="$CPPFLAGS" -+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -+ -+ save_LDFLAGS="$LDFLAGS" -+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -+ -+ save_LIBS="$LIBS" -+ LIBS="$lt_cv_dlopen_libs $LIBS" -+ -+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -+if test "${lt_cv_dlopen_self+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ lt_cv_dlopen_self=cross -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+} -+EOF -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&5 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; -+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; -+ x$lt_unknown|x*) lt_cv_dlopen_self=no ;; -+ esac -+ else : -+ # compilation failed -+ lt_cv_dlopen_self=no -+ fi -+fi -+rm -fr conftest* -+ -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -+echo "${ECHO_T}$lt_cv_dlopen_self" >&6 -+ -+ if test "x$lt_cv_dlopen_self" = xyes; then -+ LDFLAGS="$LDFLAGS $link_static_flag" -+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -+if test "${lt_cv_dlopen_self_static+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ lt_cv_dlopen_self_static=cross -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+} -+EOF -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&5 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; -+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; -+ x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; -+ esac -+ else : -+ # compilation failed -+ lt_cv_dlopen_self_static=no -+ fi -+fi -+rm -fr conftest* -+ -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 -+ fi -+ -+ CPPFLAGS="$save_CPPFLAGS" -+ LDFLAGS="$save_LDFLAGS" -+ LIBS="$save_LIBS" -+ ;; -+ esac -+ -+ case $lt_cv_dlopen_self in -+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -+ *) enable_dlopen_self=unknown ;; -+ esac -+ -+ case $lt_cv_dlopen_self_static in -+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -+ *) enable_dlopen_self_static=unknown ;; -+ esac -+fi -+ -+ -+# The else clause should only fire when bootstrapping the -+# libtool distribution, otherwise you forgot to ship ltmain.sh -+# with your package, and you will get complaints that there are -+# no rules to generate ltmain.sh. -+if test -f "$ltmain"; then -+ # See if we are running on zsh, and set the options which allow our commands through -+ # without removal of \ escapes. -+ if test -n "${ZSH_VERSION+set}" ; then -+ setopt NO_GLOB_SUBST -+ fi -+ # Now quote all the things that may contain metacharacters while being -+ # careful not to overquote the AC_SUBSTed values. We take copies of the -+ # variables and quote the copies for generation of the libtool script. -+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ -+ SED SHELL STRIP \ -+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ -+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ -+ deplibs_check_method reload_flag reload_cmds need_locks \ -+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ -+ lt_cv_sys_global_symbol_to_c_name_address \ -+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -+ old_postinstall_cmds old_postuninstall_cmds \ -+ compiler_CXX \ -+ CC_CXX \ -+ LD_CXX \ -+ lt_prog_compiler_wl_CXX \ -+ lt_prog_compiler_pic_CXX \ -+ lt_prog_compiler_static_CXX \ -+ lt_prog_compiler_no_builtin_flag_CXX \ -+ export_dynamic_flag_spec_CXX \ -+ thread_safe_flag_spec_CXX \ -+ whole_archive_flag_spec_CXX \ -+ enable_shared_with_static_runtimes_CXX \ -+ old_archive_cmds_CXX \ -+ old_archive_from_new_cmds_CXX \ -+ predep_objects_CXX \ -+ postdep_objects_CXX \ -+ predeps_CXX \ -+ postdeps_CXX \ -+ compiler_lib_search_path_CXX \ -+ archive_cmds_CXX \ -+ archive_expsym_cmds_CXX \ -+ postinstall_cmds_CXX \ -+ postuninstall_cmds_CXX \ -+ old_archive_from_expsyms_cmds_CXX \ -+ allow_undefined_flag_CXX \ -+ no_undefined_flag_CXX \ -+ export_symbols_cmds_CXX \ -+ hardcode_libdir_flag_spec_CXX \ -+ hardcode_libdir_flag_spec_ld_CXX \ -+ hardcode_libdir_separator_CXX \ -+ hardcode_automatic_CXX \ -+ module_cmds_CXX \ -+ module_expsym_cmds_CXX \ -+ lt_cv_prog_compiler_c_o_CXX \ -+ exclude_expsyms_CXX \ -+ include_expsyms_CXX; do -+ -+ case $var in -+ old_archive_cmds_CXX | \ -+ old_archive_from_new_cmds_CXX | \ -+ archive_cmds_CXX | \ -+ archive_expsym_cmds_CXX | \ -+ module_cmds_CXX | \ -+ module_expsym_cmds_CXX | \ -+ old_archive_from_expsyms_cmds_CXX | \ -+ export_symbols_cmds_CXX | \ -+ extract_expsyms_cmds | reload_cmds | finish_cmds | \ -+ postinstall_cmds | postuninstall_cmds | \ -+ old_postinstall_cmds | old_postuninstall_cmds | \ -+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -+ # Double-quote double-evaled strings. -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -+ ;; -+ *) -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -+ ;; -+ esac -+ done -+ -+ case $lt_echo in -+ *'\$0 --fallback-echo"') -+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` -+ ;; -+ esac -+ -+cfgfile="$ofile" -+ -+ cat <<__EOF__ >> "$cfgfile" -+# ### BEGIN LIBTOOL TAG CONFIG: $tagname -+ -+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+ -+# Shell to use when invoking shell scripts. -+SHELL=$lt_SHELL -+ -+# Whether or not to build shared libraries. -+build_libtool_libs=$enable_shared -+ -+# Whether or not to build static libraries. -+build_old_libs=$enable_static -+ -+# Whether or not to add -lc for building shared libraries. -+build_libtool_need_lc=$archive_cmds_need_lc_CXX -+ -+# Whether or not to disallow shared libs when runtime libs are static -+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX -+ -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ -+# The host system. -+host_alias=$host_alias -+host=$host -+host_os=$host_os -+ -+# The build system. -+build_alias=$build_alias -+build=$build -+build_os=$build_os -+ -+# An echo program that does not interpret backslashes. -+echo=$lt_echo -+ -+# The archiver. -+AR=$lt_AR -+AR_FLAGS=$lt_AR_FLAGS -+ -+# A C compiler. -+LTCC=$lt_LTCC -+ -+# A language-specific compiler. -+CC=$lt_compiler_CXX -+ -+# Is the compiler the GNU C compiler? -+with_gcc=$GCC_CXX -+ -+# An ERE matcher. -+EGREP=$lt_EGREP -+ -+# The linker used to build libraries. -+LD=$lt_LD_CXX -+ -+# Whether we need hard or soft links. -+LN_S=$lt_LN_S -+ -+# A BSD-compatible nm program. -+NM=$lt_NM -+ -+# A symbol stripping program -+STRIP=$lt_STRIP -+ -+# Used to examine libraries when file_magic_cmd begins "file" -+MAGIC_CMD=$MAGIC_CMD -+ -+# Used on cygwin: DLL creation program. -+DLLTOOL="$DLLTOOL" -+ -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. -+AS="$AS" -+ -+# The name of the directory that contains temporary libtool files. -+objdir=$objdir -+ -+# How to create reloadable object files. -+reload_flag=$lt_reload_flag -+reload_cmds=$lt_reload_cmds -+ -+# How to pass a linker flag through the compiler. -+wl=$lt_lt_prog_compiler_wl_CXX -+ -+# Object file suffix (normally "o"). -+objext="$ac_objext" -+ -+# Old archive suffix (normally "a"). -+libext="$libext" -+ -+# Shared library suffix (normally ".so"). -+shrext_cmds='$shrext_cmds' -+ -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ -+# Additional compiler flags for building library objects. -+pic_flag=$lt_lt_prog_compiler_pic_CXX -+pic_mode=$pic_mode -+ -+# What is the maximum length of a command? -+max_cmd_len=$lt_cv_sys_max_cmd_len -+ -+# Does compiler simultaneously support -c and -o options? -+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX -+ -+# Must we lock files when doing compilation? -+need_locks=$lt_need_locks -+ -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen_support=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ -+# Compiler flag to prevent dynamic linking. -+link_static_flag=$lt_lt_prog_compiler_static_CXX -+ -+# Compiler flag to turn off builtin functions. -+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX -+ -+# Compiler flag to allow reflexive dlopens. -+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX -+ -+# Compiler flag to generate shared objects directly from archives. -+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX -+ -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX -+ -+# Library versioning type. -+version_type=$version_type -+ -+# Format of library name prefix. -+libname_spec=$lt_libname_spec -+ -+# List of archive names. First name is the real one, the rest are links. -+# The last name is the one that the linker finds with -lNAME. -+library_names_spec=$lt_library_names_spec -+ -+# The coded name of the library, if different from the real name. -+soname_spec=$lt_soname_spec -+ -+# Commands used to build and install an old-style archive. -+RANLIB=$lt_RANLIB -+old_archive_cmds=$lt_old_archive_cmds_CXX -+old_postinstall_cmds=$lt_old_postinstall_cmds -+old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ -+# Create an old-style archive from a shared archive. -+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX -+ -+# Create a temporary old-style archive to link instead of a shared archive. -+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX -+ -+# Commands used to build and install a shared archive. -+archive_cmds=$lt_archive_cmds_CXX -+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX -+postinstall_cmds=$lt_postinstall_cmds -+postuninstall_cmds=$lt_postuninstall_cmds -+ -+# Commands used to build a loadable module (assumed same as above if empty) -+module_cmds=$lt_module_cmds_CXX -+module_expsym_cmds=$lt_module_expsym_cmds_CXX -+ -+# Commands to strip libraries. -+old_striplib=$lt_old_striplib -+striplib=$lt_striplib -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predep_objects=$lt_predep_objects_CXX -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdep_objects=$lt_postdep_objects_CXX -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predeps=$lt_predeps_CXX -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdeps=$lt_postdeps_CXX -+ -+# The library search path used internally by the compiler when linking -+# a shared library. -+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX -+ -+# Method to check whether dependent libraries are shared objects. -+deplibs_check_method=$lt_deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$lt_file_magic_cmd -+ -+# Flag that allows shared libraries with undefined symbols to be built. -+allow_undefined_flag=$lt_allow_undefined_flag_CXX -+ -+# Flag that forces no undefined symbols. -+no_undefined_flag=$lt_no_undefined_flag_CXX -+ -+# Commands used to finish a libtool library installation in a directory. -+finish_cmds=$lt_finish_cmds -+ -+# Same as above, but a single script fragment to be evaled but not shown. -+finish_eval=$lt_finish_eval -+ -+# Take the output of nm and produce a listing of raw symbols and C names. -+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe -+ -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl -+ -+# Transform the output of nm in a C name address pair -+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address -+ -+# This is the shared library runtime path variable. -+runpath_var=$runpath_var -+ -+# This is the shared library path variable. -+shlibpath_var=$shlibpath_var -+ -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+ -+# How to hardcode a shared library path into an executable. -+hardcode_action=$hardcode_action_CXX -+ -+# Whether we should hardcode library paths into libraries. -+hardcode_into_libs=$hardcode_into_libs -+ -+# Flag to hardcode \$libdir into a binary during linking. -+# This must work even if \$libdir does not exist. -+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX -+ -+# If ld is used when linking, flag to hardcode \$libdir into -+# a binary during linking. This must work even if \$libdir does -+# not exist. -+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX -+ -+# Whether we need a single -rpath flag with a separated argument. -+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX -+ -+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -+# resulting binary. -+hardcode_direct=$hardcode_direct_CXX -+ -+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -+# resulting binary. -+hardcode_minus_L=$hardcode_minus_L_CXX -+ -+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -+# the resulting binary. -+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX -+ -+# Set to yes if building a shared library automatically hardcodes DIR into the library -+# and all subsequent libraries and executables linked against it. -+hardcode_automatic=$hardcode_automatic_CXX -+ -+# Variables whose values should be saved in libtool wrapper scripts and -+# restored at relink time. -+variables_saved_for_relink="$variables_saved_for_relink" -+ -+# Whether libtool must link a program against all its dependency libraries. -+link_all_deplibs=$link_all_deplibs_CXX -+ -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ -+# Fix the shell variable \$srcfile for the compiler. -+fix_srcfile_path="$fix_srcfile_path_CXX" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$always_export_symbols_CXX -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$lt_export_symbols_cmds_CXX -+ -+# The commands to extract the exported symbol list from a shared archive. -+extract_expsyms_cmds=$lt_extract_expsyms_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$lt_exclude_expsyms_CXX -+ -+# Symbols that must always be exported. -+include_expsyms=$lt_include_expsyms_CXX -+ -+# ### END LIBTOOL TAG CONFIG: $tagname -+ -+__EOF__ -+ -+ -+else -+ # If there is no Makefile yet, we rely on a make rule to execute -+ # `config.status --recheck' to rerun these tests and create the -+ # libtool script then. -+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` -+ if test -f "$ltmain_in"; then -+ test -f Makefile && make "$ltmain" -+ fi -+fi -+ -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+CC=$lt_save_CC -+LDCXX=$LD -+LD=$lt_save_LD -+GCC=$lt_save_GCC -+with_gnu_ldcxx=$with_gnu_ld -+with_gnu_ld=$lt_save_with_gnu_ld -+lt_cv_path_LDCXX=$lt_cv_path_LD -+lt_cv_path_LD=$lt_save_path_LD -+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld -+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -+ -+ else -+ tagname="" -+ fi -+ ;; -+ -+ F77) -+ if test -n "$F77" && test "X$F77" != "Xno"; then -+ -+ac_ext=f -+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' -+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_f77_compiler_gnu -+ -+ -+archive_cmds_need_lc_F77=no -+allow_undefined_flag_F77= -+always_export_symbols_F77=no -+archive_expsym_cmds_F77= -+export_dynamic_flag_spec_F77= -+hardcode_direct_F77=no -+hardcode_libdir_flag_spec_F77= -+hardcode_libdir_flag_spec_ld_F77= -+hardcode_libdir_separator_F77= -+hardcode_minus_L_F77=no -+hardcode_automatic_F77=no -+module_cmds_F77= -+module_expsym_cmds_F77= -+link_all_deplibs_F77=unknown -+old_archive_cmds_F77=$old_archive_cmds -+no_undefined_flag_F77= -+whole_archive_flag_spec_F77= -+enable_shared_with_static_runtimes_F77=no -+ -+# Source file extension for f77 test sources. -+ac_ext=f -+ -+# Object file extension for compiled f77 test sources. -+objext=o -+objext_F77=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code=" subroutine t\n return\n end\n" -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code=" program t\n end\n" -+ -+# ltmain only uses $CC for tagged configurations so make sure $CC is set. -+ -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} -+ -+# Allow CC to be a program name with arguments. -+compiler=$CC -+ -+ -+# save warnings/boilerplate of simple test code -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_compile_test_code" >conftest.$ac_ext -+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_compiler_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_link_test_code" >conftest.$ac_ext -+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_linker_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ -+# Allow CC to be a program name with arguments. -+lt_save_CC="$CC" -+CC=${F77-"f77"} -+compiler=$CC -+compiler_F77=$CC -+for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ -+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 -+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -+echo "$as_me:$LINENO: result: $can_build_shared" >&5 -+echo "${ECHO_T}$can_build_shared" >&6 -+ -+echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 -+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 -+test "$can_build_shared" = "no" && enable_shared=no -+ -+# On AIX, shared libraries and static libraries use the same namespace, and -+# are all built from PIC. -+case $host_os in -+aix3*) -+ test "$enable_shared" = yes && enable_static=no -+ if test -n "$RANLIB"; then -+ archive_cmds="$archive_cmds~\$RANLIB \$lib" -+ postinstall_cmds='$RANLIB $lib' -+ fi -+ ;; -+aix4* | aix5*) -+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then -+ test "$enable_shared" = yes && enable_static=no -+ fi -+ ;; -+esac -+echo "$as_me:$LINENO: result: $enable_shared" >&5 -+echo "${ECHO_T}$enable_shared" >&6 -+ -+echo "$as_me:$LINENO: checking whether to build static libraries" >&5 -+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 -+# Make sure either enable_shared or enable_static is yes. -+test "$enable_shared" = yes || enable_static=yes -+echo "$as_me:$LINENO: result: $enable_static" >&5 -+echo "${ECHO_T}$enable_static" >&6 -+ -+test "$ld_shlibs_F77" = no && can_build_shared=no -+ -+GCC_F77="$G77" -+LD_F77="$LD" -+ -+lt_prog_compiler_wl_F77= -+lt_prog_compiler_pic_F77= -+lt_prog_compiler_static_F77= -+ -+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 -+ -+ if test "$GCC" = yes; then -+ lt_prog_compiler_wl_F77='-Wl,' -+ lt_prog_compiler_static_F77='-static' -+ -+ case $host_os in -+ aix*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static_F77='-Bstatic' -+ fi -+ ;; -+ -+ amigaos*) -+ # FIXME: we need at least 68020 code to build shared libraries, but -+ # adding the `-m68020' flag to GCC prevents building anything better, -+ # like `-m68040'. -+ lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' -+ ;; -+ -+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) -+ # PIC is the default for these OSes. -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic_F77='-DDLL_EXPORT' -+ ;; -+ -+ darwin* | rhapsody*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ lt_prog_compiler_pic_F77='-fno-common' -+ ;; -+ -+ msdosdjgpp*) -+ # Just because we use GCC doesn't mean we suddenly get shared libraries -+ # on systems that don't support them. -+ lt_prog_compiler_can_build_shared_F77=no -+ enable_shared=no -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ lt_prog_compiler_pic_F77=-Kconform_pic -+ fi -+ ;; -+ -+ hpux*) -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic_F77='-fPIC' -+ ;; -+ esac -+ ;; -+ -+ *) -+ lt_prog_compiler_pic_F77='-fPIC' -+ ;; -+ esac -+ else -+ # PORTME Check for flag to pass linker flags through the system compiler. -+ case $host_os in -+ aix*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static_F77='-Bstatic' -+ else -+ lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' -+ fi -+ ;; -+ darwin*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ case $cc_basename in -+ xlc*) -+ lt_prog_compiler_pic_F77='-qnocommon' -+ lt_prog_compiler_wl_F77='-Wl,' -+ ;; -+ esac -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic_F77='-DDLL_EXPORT' -+ ;; -+ -+ hpux9* | hpux10* | hpux11*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic_F77='+Z' -+ ;; -+ esac -+ # Is there a better lt_prog_compiler_static that works with the bundled CC? -+ lt_prog_compiler_static_F77='${wl}-a ${wl}archive' -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ # PIC (with -KPIC) is the default. -+ lt_prog_compiler_static_F77='-non_shared' -+ ;; -+ -+ newsos6) -+ lt_prog_compiler_pic_F77='-KPIC' -+ lt_prog_compiler_static_F77='-Bstatic' -+ ;; -+ -+ linux*) -+ case $cc_basename in -+ icc* | ecc*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ lt_prog_compiler_pic_F77='-KPIC' -+ lt_prog_compiler_static_F77='-static' -+ ;; -+ pgcc* | pgf77* | pgf90* | pgf95*) -+ # Portland Group compilers (*not* the Pentium gcc compiler, -+ # which looks to be a dead project) -+ lt_prog_compiler_wl_F77='-Wl,' -+ lt_prog_compiler_pic_F77='-fpic' -+ lt_prog_compiler_static_F77='-Bstatic' -+ ;; -+ ccc*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ # All Alpha code is PIC. -+ lt_prog_compiler_static_F77='-non_shared' -+ ;; -+ esac -+ ;; -+ -+ osf3* | osf4* | osf5*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ # All OSF/1 code is PIC. -+ lt_prog_compiler_static_F77='-non_shared' -+ ;; -+ -+ sco3.2v5*) -+ lt_prog_compiler_pic_F77='-Kpic' -+ lt_prog_compiler_static_F77='-dn' -+ ;; -+ -+ solaris*) -+ lt_prog_compiler_pic_F77='-KPIC' -+ lt_prog_compiler_static_F77='-Bstatic' -+ case $cc_basename in -+ f77* | f90* | f95*) -+ lt_prog_compiler_wl_F77='-Qoption ld ';; -+ *) -+ lt_prog_compiler_wl_F77='-Wl,';; -+ esac -+ ;; -+ -+ sunos4*) -+ lt_prog_compiler_wl_F77='-Qoption ld ' -+ lt_prog_compiler_pic_F77='-PIC' -+ lt_prog_compiler_static_F77='-Bstatic' -+ ;; -+ -+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ lt_prog_compiler_pic_F77='-KPIC' -+ lt_prog_compiler_static_F77='-Bstatic' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec ;then -+ lt_prog_compiler_pic_F77='-Kconform_pic' -+ lt_prog_compiler_static_F77='-Bstatic' -+ fi -+ ;; -+ -+ unicos*) -+ lt_prog_compiler_wl_F77='-Wl,' -+ lt_prog_compiler_can_build_shared_F77=no -+ ;; -+ -+ uts4*) -+ lt_prog_compiler_pic_F77='-pic' -+ lt_prog_compiler_static_F77='-Bstatic' -+ ;; -+ -+ *) -+ lt_prog_compiler_can_build_shared_F77=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 -+ -+# -+# Check to make sure the PIC flag actually works. -+# -+if test -n "$lt_prog_compiler_pic_F77"; then -+ -+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 -+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 -+if test "${lt_prog_compiler_pic_works_F77+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_prog_compiler_pic_works_F77=no -+ ac_outfile=conftest.$ac_objext -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="$lt_prog_compiler_pic_F77" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:13764: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&5 -+ echo "$as_me:13768: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ lt_prog_compiler_pic_works_F77=yes -+ fi -+ fi -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 -+ -+if test x"$lt_prog_compiler_pic_works_F77" = xyes; then -+ case $lt_prog_compiler_pic_F77 in -+ "" | " "*) ;; -+ *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; -+ esac -+else -+ lt_prog_compiler_pic_F77= -+ lt_prog_compiler_can_build_shared_F77=no -+fi -+ -+fi -+case $host_os in -+ # For platforms which do not support PIC, -DPIC is meaningless: -+ *djgpp*) -+ lt_prog_compiler_pic_F77= -+ ;; -+ *) -+ lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_cv_prog_compiler_c_o_F77=no -+ $rm -r conftest 2>/dev/null -+ mkdir conftest -+ cd conftest -+ mkdir out -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ lt_compiler_flag="-o out/conftest2.$ac_objext" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:13826: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>out/conftest.err) -+ ac_status=$? -+ cat out/conftest.err >&5 -+ echo "$as_me:13830: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s out/conftest2.$ac_objext -+ then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp -+ $SED '/^$/d' out/conftest.err >out/conftest.er2 -+ if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then -+ lt_cv_prog_compiler_c_o_F77=yes -+ fi -+ fi -+ chmod u+w . 2>&5 -+ $rm conftest* -+ # SGI C++ compiler will create directory out/ii_files/ for -+ # template instantiation -+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files -+ $rm out/* && rmdir out -+ cd .. -+ rmdir conftest -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 -+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 -+ -+ -+hard_links="nottested" -+if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then -+ # do not overwrite the value of need_locks provided by the user -+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 -+ hard_links=yes -+ $rm conftest* -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ touch conftest.a -+ ln conftest.a conftest.b 2>&5 || hard_links=no -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ echo "$as_me:$LINENO: result: $hard_links" >&5 -+echo "${ECHO_T}$hard_links" >&6 -+ if test "$hard_links" = no; then -+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} -+ need_locks=warn -+ fi -+else -+ need_locks=no -+fi -+ -+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -+ -+ runpath_var= -+ allow_undefined_flag_F77= -+ enable_shared_with_static_runtimes_F77=no -+ archive_cmds_F77= -+ archive_expsym_cmds_F77= -+ old_archive_From_new_cmds_F77= -+ old_archive_from_expsyms_cmds_F77= -+ export_dynamic_flag_spec_F77= -+ whole_archive_flag_spec_F77= -+ thread_safe_flag_spec_F77= -+ hardcode_libdir_flag_spec_F77= -+ hardcode_libdir_flag_spec_ld_F77= -+ hardcode_libdir_separator_F77= -+ hardcode_direct_F77=no -+ hardcode_minus_L_F77=no -+ hardcode_shlibpath_var_F77=unsupported -+ link_all_deplibs_F77=unknown -+ hardcode_automatic_F77=no -+ module_cmds_F77= -+ module_expsym_cmds_F77= -+ always_export_symbols_F77=no -+ export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ # include_expsyms should be a list of space-separated symbols to be *always* -+ # included in the symbol list -+ include_expsyms_F77= -+ # exclude_expsyms can be an extended regexp of symbols to exclude -+ # it will be wrapped by ` (' and `)$', so one must not match beginning or -+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -+ # as well as any symbol that contains `d'. -+ exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" -+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -+ # platforms (ab)use it in PIC code, but their linkers get confused if -+ # the symbol is explicitly referenced. Since portable code cannot -+ # rely on this symbol name, it's probably fine to never include it in -+ # preloaded symbol tables. -+ extract_expsyms_cmds= -+ # Just being paranoid about ensuring that cc_basename is set. -+ for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ case $host_os in -+ cygwin* | mingw* | pw32*) -+ # FIXME: the MSVC++ port hasn't been tested in a loooong time -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ if test "$GCC" != yes; then -+ with_gnu_ld=no -+ fi -+ ;; -+ openbsd*) -+ with_gnu_ld=no -+ ;; -+ esac -+ -+ ld_shlibs_F77=yes -+ if test "$with_gnu_ld" = yes; then -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ wlarc='${wl}' -+ -+ # Set some defaults for GNU ld with shared library support. These -+ # are reset later if shared libraries are not supported. Putting them -+ # here allows them to be overridden if necessary. -+ runpath_var=LD_RUN_PATH -+ hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' -+ export_dynamic_flag_spec_F77='${wl}--export-dynamic' -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then -+ whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ whole_archive_flag_spec_F77= -+ fi -+ supports_anon_versioning=no -+ case `$LD -v 2>/dev/null` in -+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 -+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... -+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... -+ *\ 2.11.*) ;; # other 2.11 versions -+ *) supports_anon_versioning=yes ;; -+ esac -+ -+ # See if GNU ld supports shared libraries. -+ case $host_os in -+ aix3* | aix4* | aix5*) -+ # On AIX/PPC, the GNU linker is very broken -+ if test "$host_cpu" != ia64; then -+ ld_shlibs_F77=no -+ cat <&2 -+ -+*** Warning: the GNU linker, at least up to release 2.9.1, is reported -+*** to be unable to reliably create shared libraries on AIX. -+*** Therefore, libtool is disabling shared libraries support. If you -+*** really care for shared libraries, you may want to modify your PATH -+*** so that a non-GNU linker is found, and then restart. -+ -+EOF -+ fi -+ ;; -+ -+ amigaos*) -+ archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_minus_L_F77=yes -+ -+ # Samuel A. Falvo II reports -+ # that the semantics of dynamic libraries on AmigaOS, at least up -+ # to version 4, is to share data among multiple programs linked -+ # with the same dynamic library. Since this doesn't match the -+ # behavior of shared libraries on other platforms, we can't use -+ # them. -+ ld_shlibs_F77=no -+ ;; -+ -+ beos*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ allow_undefined_flag_F77=unsupported -+ # Joseph Beckenbach says some releases of gcc -+ # support --undefined. This deserves some investigation. FIXME -+ archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ else -+ ld_shlibs_F77=no -+ fi -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, -+ # as there is no search path for DLLs. -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ allow_undefined_flag_F77=unsupported -+ always_export_symbols_F77=no -+ enable_shared_with_static_runtimes_F77=yes -+ export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' -+ -+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then -+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ # If the export-symbols file already is a .def file (1st line -+ # is EXPORTS), use it as is; otherwise, prepend... -+ archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then -+ cp $export_symbols $output_objdir/$soname.def; -+ else -+ echo EXPORTS > $output_objdir/$soname.def; -+ cat $export_symbols >> $output_objdir/$soname.def; -+ fi~ -+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ else -+ ld_shlibs_F77=no -+ fi -+ ;; -+ -+ linux*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ tmp_addflag= -+ case $cc_basename,$host_cpu in -+ pgcc*) # Portland Group C compiler -+ whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag' -+ ;; -+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers -+ whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag -Mnomain' ;; -+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 -+ tmp_addflag=' -i_dynamic' ;; -+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 -+ tmp_addflag=' -i_dynamic -nofor_main' ;; -+ ifc* | ifort*) # Intel Fortran compiler -+ tmp_addflag=' -nofor_main' ;; -+ esac -+ archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ -+ if test $supports_anon_versioning = yes; then -+ archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ -+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ -+ $echo "local: *; };" >> $output_objdir/$libname.ver~ -+ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' -+ fi -+ link_all_deplibs_F77=no -+ else -+ ld_shlibs_F77=no -+ fi -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' -+ wlarc= -+ else -+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ fi -+ ;; -+ -+ solaris* | sysv5*) -+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then -+ ld_shlibs_F77=no -+ cat <&2 -+ -+*** Warning: The releases 2.8.* of the GNU linker cannot reliably -+*** create shared libraries on Solaris systems. Therefore, libtool -+*** is disabling shared libraries support. We urge you to upgrade GNU -+*** binutils to release 2.9.1 or newer. Another option is to modify -+*** your PATH or compiler configuration so that the native linker is -+*** used, and then restart. -+ -+EOF -+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs_F77=no -+ fi -+ ;; -+ -+ sunos4*) -+ archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ wlarc= -+ hardcode_direct_F77=yes -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ *) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs_F77=no -+ fi -+ ;; -+ esac -+ -+ if test "$ld_shlibs_F77" = no; then -+ runpath_var= -+ hardcode_libdir_flag_spec_F77= -+ export_dynamic_flag_spec_F77= -+ whole_archive_flag_spec_F77= -+ fi -+ else -+ # PORTME fill in a description of your system's linker (not GNU ld) -+ case $host_os in -+ aix3*) -+ allow_undefined_flag_F77=unsupported -+ always_export_symbols_F77=yes -+ archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' -+ # Note: this linker hardcodes the directories in LIBPATH if there -+ # are no directories specified by -L. -+ hardcode_minus_L_F77=yes -+ if test "$GCC" = yes && test -z "$link_static_flag"; then -+ # Neither direct hardcoding nor static linking is supported with a -+ # broken collect2. -+ hardcode_direct_F77=unsupported -+ fi -+ ;; -+ -+ aix4* | aix5*) -+ if test "$host_cpu" = ia64; then -+ # On IA64, the linker does run time linking by default, so we don't -+ # have to do anything special. -+ aix_use_runtimelinking=no -+ exp_sym_flag='-Bexport' -+ no_entry_flag="" -+ else -+ # If we're using GNU nm, then we don't want the "-C" option. -+ # -C means demangle to AIX nm, but means don't demangle with GNU nm -+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then -+ export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ else -+ export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ fi -+ aix_use_runtimelinking=no -+ -+ # Test if we are trying to use run time linking or normal -+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we -+ # need to do runtime linking. -+ case $host_os in aix4.[23]|aix4.[23].*|aix5*) -+ for ld_flag in $LDFLAGS; do -+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then -+ aix_use_runtimelinking=yes -+ break -+ fi -+ done -+ esac -+ -+ exp_sym_flag='-bexport' -+ no_entry_flag='-bnoentry' -+ fi -+ -+ # When large executables or shared objects are built, AIX ld can -+ # have problems creating the table of contents. If linking a library -+ # or program results in "error TOC overflow" add -mminimal-toc to -+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -+ -+ archive_cmds_F77='' -+ hardcode_direct_F77=yes -+ hardcode_libdir_separator_F77=':' -+ link_all_deplibs_F77=yes -+ -+ if test "$GCC" = yes; then -+ case $host_os in aix4.[012]|aix4.[012].*) -+ # We only want to do this on AIX 4.2 and lower, the check -+ # below for broken collect2 doesn't work under 4.3+ -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ hardcode_direct_F77=yes -+ else -+ # We have old collect2 -+ hardcode_direct_F77=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ hardcode_minus_L_F77=yes -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_libdir_separator_F77= -+ fi -+ esac -+ shared_flag='-shared' -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag="$shared_flag "'${wl}-G' -+ fi -+ else -+ # not using gcc -+ if test "$host_cpu" = ia64; then -+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release -+ # chokes on -Wl,-G. The following line is correct: -+ shared_flag='-G' -+ else -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag='${wl}-G' -+ else -+ shared_flag='${wl}-bM:SRE' -+ fi -+ fi -+ fi -+ -+ # It seems that -bexpall does not export symbols beginning with -+ # underscore (_), so it is better to generate a list of symbols to export. -+ always_export_symbols_F77=yes -+ if test "$aix_use_runtimelinking" = yes; then -+ # Warning - without using the other runtime loading flags (-brtl), -+ # -berok will link without error, but may produce a broken library. -+ allow_undefined_flag_F77='-berok' -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+ program main -+ -+ end -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" -+ archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -+ else -+ if test "$host_cpu" = ia64; then -+ hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' -+ allow_undefined_flag_F77="-z nodefs" -+ archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -+ else -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+ program main -+ -+ end -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" -+ # Warning - without using the other run time loading flags, -+ # -berok will link without error, but may produce a broken library. -+ no_undefined_flag_F77=' ${wl}-bernotok' -+ allow_undefined_flag_F77=' ${wl}-berok' -+ # -bexpall does not export symbols beginning with underscore (_) -+ always_export_symbols_F77=yes -+ # Exported symbols can be pulled into shared objects from archives -+ whole_archive_flag_spec_F77=' ' -+ archive_cmds_need_lc_F77=yes -+ # This is similar to how AIX traditionally builds its shared libraries. -+ archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' -+ fi -+ fi -+ ;; -+ -+ amigaos*) -+ archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_minus_L_F77=yes -+ # see comment about different semantics on the GNU ld section -+ ld_shlibs_F77=no -+ ;; -+ -+ bsdi[45]*) -+ export_dynamic_flag_spec_F77=-rdynamic -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ # hardcode_libdir_flag_spec is actually meaningless, as there is -+ # no search path for DLLs. -+ hardcode_libdir_flag_spec_F77=' ' -+ allow_undefined_flag_F77=unsupported -+ # Tell ltmain to make .lib files, not .a files. -+ libext=lib -+ # Tell ltmain to make .dll files, not .so files. -+ shrext_cmds=".dll" -+ # FIXME: Setting linknames here is a bad hack. -+ archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' -+ # The linker will automatically build a .lib file if we build a DLL. -+ old_archive_From_new_cmds_F77='true' -+ # FIXME: Should let the user specify the lib program. -+ old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' -+ fix_srcfile_path_F77='`cygpath -w "$srcfile"`' -+ enable_shared_with_static_runtimes_F77=yes -+ ;; -+ -+ darwin* | rhapsody*) -+ case $host_os in -+ rhapsody* | darwin1.[012]) -+ allow_undefined_flag_F77='${wl}-undefined ${wl}suppress' -+ ;; -+ *) # Darwin 1.3 on -+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then -+ allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ else -+ case ${MACOSX_DEPLOYMENT_TARGET} in -+ 10.[012]) -+ allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ ;; -+ 10.*) -+ allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup' -+ ;; -+ esac -+ fi -+ ;; -+ esac -+ archive_cmds_need_lc_F77=no -+ hardcode_direct_F77=no -+ hardcode_automatic_F77=yes -+ hardcode_shlibpath_var_F77=unsupported -+ whole_archive_flag_spec_F77='' -+ link_all_deplibs_F77=yes -+ if test "$GCC" = yes ; then -+ output_verbose_link_cmd='echo' -+ archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ case $cc_basename in -+ xlc*) -+ output_verbose_link_cmd='echo' -+ archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' -+ module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ ;; -+ *) -+ ld_shlibs_F77=no -+ ;; -+ esac -+ fi -+ ;; -+ -+ dgux*) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ freebsd1*) -+ ld_shlibs_F77=no -+ ;; -+ -+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -+ # support. Future versions do this automatically, but an explicit c++rt0.o -+ # does not break anything, and helps significantly (at the cost of a little -+ # extra space). -+ freebsd2.2*) -+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' -+ hardcode_libdir_flag_spec_F77='-R$libdir' -+ hardcode_direct_F77=yes -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ # Unfortunately, older versions of FreeBSD 2 do not have this feature. -+ freebsd2*) -+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_F77=yes -+ hardcode_minus_L_F77=yes -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' -+ hardcode_libdir_flag_spec_F77='-R$libdir' -+ hardcode_direct_F77=yes -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ hpux9*) -+ if test "$GCC" = yes; then -+ archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ else -+ archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ fi -+ hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator_F77=: -+ hardcode_direct_F77=yes -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L_F77=yes -+ export_dynamic_flag_spec_F77='${wl}-E' -+ ;; -+ -+ hpux10* | hpux11*) -+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ *) -+ archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ esac -+ else -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ *) -+ archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ esac -+ fi -+ if test "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*) -+ hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' -+ hardcode_libdir_flag_spec_ld_F77='+b $libdir' -+ hardcode_libdir_separator_F77=: -+ hardcode_direct_F77=no -+ hardcode_shlibpath_var_F77=no -+ ;; -+ ia64*) -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_direct_F77=no -+ hardcode_shlibpath_var_F77=no -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L_F77=yes -+ ;; -+ *) -+ hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator_F77=: -+ hardcode_direct_F77=yes -+ export_dynamic_flag_spec_F77='${wl}-E' -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L_F77=yes -+ ;; -+ esac -+ fi -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ if test "$GCC" = yes; then -+ archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' -+ fi -+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_F77=: -+ link_all_deplibs_F77=yes -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out -+ else -+ archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF -+ fi -+ hardcode_libdir_flag_spec_F77='-R$libdir' -+ hardcode_direct_F77=yes -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ newsos6) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_F77=yes -+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_F77=: -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ openbsd*) -+ hardcode_direct_F77=yes -+ hardcode_shlibpath_var_F77=no -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' -+ hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' -+ export_dynamic_flag_spec_F77='${wl}-E' -+ else -+ case $host_os in -+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) -+ archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec_F77='-R$libdir' -+ ;; -+ *) -+ archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' -+ ;; -+ esac -+ fi -+ ;; -+ -+ os2*) -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_minus_L_F77=yes -+ allow_undefined_flag_F77=unsupported -+ archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' -+ old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' -+ ;; -+ -+ osf3*) -+ if test "$GCC" = yes; then -+ allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ allow_undefined_flag_F77=' -expect_unresolved \*' -+ archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ fi -+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_F77=: -+ ;; -+ -+ osf4* | osf5*) # as osf3* with the addition of -msym flag -+ if test "$GCC" = yes; then -+ allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' -+ else -+ allow_undefined_flag_F77=' -expect_unresolved \*' -+ archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ -+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' -+ -+ # Both c and cxx compiler support -rpath directly -+ hardcode_libdir_flag_spec_F77='-rpath $libdir' -+ fi -+ hardcode_libdir_separator_F77=: -+ ;; -+ -+ sco3.2v5*) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var_F77=no -+ export_dynamic_flag_spec_F77='${wl}-Bexport' -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ;; -+ -+ solaris*) -+ no_undefined_flag_F77=' -z text' -+ if test "$GCC" = yes; then -+ wlarc='${wl}' -+ archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' -+ else -+ wlarc='' -+ archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ fi -+ hardcode_libdir_flag_spec_F77='-R$libdir' -+ hardcode_shlibpath_var_F77=no -+ case $host_os in -+ solaris2.[0-5] | solaris2.[0-5].*) ;; -+ *) -+ # The compiler driver will combine linker options so we -+ # cannot just pass the convience library names through -+ # without $wl, iff we do not link with $LD. -+ # Luckily, gcc supports the same syntax we need for Sun Studio. -+ # Supported since Solaris 2.6 (maybe 2.5.1?) -+ case $wlarc in -+ '') -+ whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; -+ *) -+ whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; -+ esac ;; -+ esac -+ link_all_deplibs_F77=yes -+ ;; -+ -+ sunos4*) -+ if test "x$host_vendor" = xsequent; then -+ # Use $CC to link under sequent, because it throws in some extra .o -+ # files that make .init and .fini sections work. -+ archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' -+ fi -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_direct_F77=yes -+ hardcode_minus_L_F77=yes -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ sysv4) -+ case $host_vendor in -+ sni) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_F77=yes # is this really true??? -+ ;; -+ siemens) -+ ## LD is ld it makes a PLAMLIB -+ ## CC just makes a GrossModule. -+ archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ reload_cmds_F77='$CC -r -o $output$reload_objs' -+ hardcode_direct_F77=no -+ ;; -+ motorola) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie -+ ;; -+ esac -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ sysv4.3*) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var_F77=no -+ export_dynamic_flag_spec_F77='-Bexport' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var_F77=no -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ld_shlibs_F77=yes -+ fi -+ ;; -+ -+ sysv4.2uw2*) -+ archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_F77=yes -+ hardcode_minus_L_F77=no -+ hardcode_shlibpath_var_F77=no -+ hardcode_runpath_var=yes -+ runpath_var=LD_RUN_PATH -+ ;; -+ -+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) -+ no_undefined_flag_F77='${wl}-z ${wl}text' -+ if test "$GCC" = yes; then -+ archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ archive_cmds_F77='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ fi -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ sysv5*) -+ no_undefined_flag_F77=' -z text' -+ # $CC -shared without GNU ld will not create a library from C++ -+ # object files and a static libstdc++, better avoid it by now -+ archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ hardcode_libdir_flag_spec_F77= -+ hardcode_shlibpath_var_F77=no -+ runpath_var='LD_RUN_PATH' -+ ;; -+ -+ uts4*) -+ archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec_F77='-L$libdir' -+ hardcode_shlibpath_var_F77=no -+ ;; -+ -+ *) -+ ld_shlibs_F77=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 -+echo "${ECHO_T}$ld_shlibs_F77" >&6 -+test "$ld_shlibs_F77" = no && can_build_shared=no -+ -+variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -+if test "$GCC" = yes; then -+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -+fi -+ -+# -+# Do we need to explicitly link libc? -+# -+case "x$archive_cmds_need_lc_F77" in -+x|xyes) -+ # Assume -lc should be added -+ archive_cmds_need_lc_F77=yes -+ -+ if test "$enable_shared" = yes && test "$GCC" = yes; then -+ case $archive_cmds_F77 in -+ *'~'*) -+ # FIXME: we may have to deal with multi-command sequences. -+ ;; -+ '$CC '*) -+ # Test whether the compiler implicitly links with -lc since on some -+ # systems, -lgcc has to come before -lc. If gcc already passes -lc -+ # to ld, don't add -lc before -lgcc. -+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 -+ $rm conftest* -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } 2>conftest.err; then -+ soname=conftest -+ lib=conftest -+ libobjs=conftest.$ac_objext -+ deplibs= -+ wl=$lt_prog_compiler_wl_F77 -+ compiler_flags=-v -+ linker_flags=-v -+ verstring= -+ output_objdir=. -+ libname=conftest -+ lt_save_allow_undefined_flag=$allow_undefined_flag_F77 -+ allow_undefined_flag_F77= -+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 -+ (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+ then -+ archive_cmds_need_lc_F77=no -+ else -+ archive_cmds_need_lc_F77=yes -+ fi -+ allow_undefined_flag_F77=$lt_save_allow_undefined_flag -+ else -+ cat conftest.err 1>&5 -+ fi -+ $rm conftest* -+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 -+echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 -+ ;; -+ esac -+ fi -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -+library_names_spec= -+libname_spec='lib$name' -+soname_spec= -+shrext_cmds=".so" -+postinstall_cmds= -+postuninstall_cmds= -+finish_cmds= -+finish_eval= -+shlibpath_var= -+shlibpath_overrides_runpath=unknown -+version_type=none -+dynamic_linker="$host_os ld.so" -+sys_lib_dlsearch_path_spec="/lib /usr/lib" -+if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then -+ # if the path contains ";" then we assume it to be the separator -+ # otherwise default to the standard path separator (i.e. ":") - it is -+ # assumed that no part of a normal pathname contains ";" but that should -+ # okay in the real world where ";" in dirpaths is itself problematic. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+else -+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -+fi -+need_lib_prefix=unknown -+hardcode_into_libs=no -+ -+# when you set need_version to no, make sure it does not cause -set_version -+# flags to be left without arguments -+need_version=unknown -+ -+case $host_os in -+aix3*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' -+ shlibpath_var=LIBPATH -+ -+ # AIX 3 has no versioning support, so we append a major version to the name. -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ -+aix4* | aix5*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ hardcode_into_libs=yes -+ if test "$host_cpu" = ia64; then -+ # AIX 5 supports IA64 -+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ else -+ # With GCC up to 2.95.x, collect2 would create an import file -+ # for dependence libraries. The import file would start with -+ # the line `#! .'. This would cause the generated library to -+ # depend on `.', always an invalid library. This was fixed in -+ # development snapshots of GCC prior to 3.0. -+ case $host_os in -+ aix4 | aix4.[01] | aix4.[01].*) -+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -+ echo ' yes ' -+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -+ : -+ else -+ can_build_shared=no -+ fi -+ ;; -+ esac -+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct -+ # soname into executable. Probably we can add versioning support to -+ # collect2, so additional links can be useful in future. -+ if test "$aix_use_runtimelinking" = yes; then -+ # If using run time linking (on AIX 4.2 or later) use lib.so -+ # instead of lib.a to let people know that these are not -+ # typical AIX shared libraries. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ else -+ # We preserve .a as extension for shared libraries through AIX4.2 -+ # and later when we are not doing run time linking. -+ library_names_spec='${libname}${release}.a $libname.a' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ fi -+ shlibpath_var=LIBPATH -+ fi -+ ;; -+ -+amigaos*) -+ library_names_spec='$libname.ixlibrary $libname.a' -+ # Create ${libname}_ixlibrary.a entries in /sys/libs. -+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' -+ ;; -+ -+beos*) -+ library_names_spec='${libname}${shared_ext}' -+ dynamic_linker="$host_os ld.so" -+ shlibpath_var=LIBRARY_PATH -+ ;; -+ -+bsdi[45]*) -+ version_type=linux -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -+ # the default ld.so.conf also contains /usr/contrib/lib and -+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -+ # libtool to hard-code these into programs -+ ;; -+ -+cygwin* | mingw* | pw32*) -+ version_type=windows -+ shrext_cmds=".dll" -+ need_version=no -+ need_lib_prefix=no -+ -+ case $GCC,$host_os in -+ yes,cygwin* | yes,mingw* | yes,pw32*) -+ library_names_spec='$libname.dll.a' -+ # DLL is installed to $(libdir)/../bin by postinstall_cmds -+ postinstall_cmds='base_file=`basename \${file}`~ -+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ -+ dldir=$destdir/`dirname \$dlpath`~ -+ test -d \$dldir || mkdir -p \$dldir~ -+ $install_prog $dir/$dlname \$dldir/$dlname~ -+ chmod a+x \$dldir/$dlname' -+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ -+ dlpath=$dir/\$dldll~ -+ $rm \$dlpath' -+ shlibpath_overrides_runpath=yes -+ -+ case $host_os in -+ cygwin*) -+ # Cygwin DLLs use 'cyg' prefix rather than 'lib' -+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" -+ ;; -+ mingw*) -+ # MinGW DLLs use traditional 'lib' prefix -+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then -+ # It is most probably a Windows format PATH printed by -+ # mingw gcc, but we are running on Cygwin. Gcc prints its search -+ # path with ; separators, and with drive letters. We can handle the -+ # drive letters (cygwin fileutils understands them), so leave them, -+ # especially as we might pass files found there to a mingw objdump, -+ # which wouldn't understand a cygwinified path. Ahh. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+ ;; -+ pw32*) -+ # pw32 DLLs use 'pw' prefix rather than 'lib' -+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ ;; -+ esac -+ ;; -+ -+ *) -+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' -+ ;; -+ esac -+ dynamic_linker='Win32 ld.exe' -+ # FIXME: first we should search . and the directory the executable is in -+ shlibpath_var=PATH -+ ;; -+ -+darwin* | rhapsody*) -+ dynamic_linker="$host_os dyld" -+ version_type=darwin -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' -+ soname_spec='${libname}${release}${major}$shared_ext' -+ shlibpath_overrides_runpath=yes -+ shlibpath_var=DYLD_LIBRARY_PATH -+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. -+ if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` -+ else -+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' -+ fi -+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' -+ ;; -+ -+dgux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+freebsd1*) -+ dynamic_linker=no -+ ;; -+ -+kfreebsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+freebsd* | dragonfly*) -+ # DragonFly does not have aout. When/if they implement a new -+ # versioning mechanism, adjust this. -+ if test -x /usr/bin/objformat; then -+ objformat=`/usr/bin/objformat` -+ else -+ case $host_os in -+ freebsd[123]*) objformat=aout ;; -+ *) objformat=elf ;; -+ esac -+ fi -+ version_type=freebsd-$objformat -+ case $version_type in -+ freebsd-elf*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' -+ need_version=no -+ need_lib_prefix=no -+ ;; -+ freebsd-*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' -+ need_version=yes -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_os in -+ freebsd2*) -+ shlibpath_overrides_runpath=yes -+ ;; -+ freebsd3.[01]* | freebsdelf3.[01]*) -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ *) # from 3.2 on -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ ;; -+ esac -+ ;; -+ -+gnu*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ hardcode_into_libs=yes -+ ;; -+ -+hpux9* | hpux10* | hpux11*) -+ # Give a soname corresponding to the major version so that dld.sl refuses to -+ # link against other versions. -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ case $host_cpu in -+ ia64*) -+ shrext_cmds='.so' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.so" -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ if test "X$HPUX_IA64_MODE" = X32; then -+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" -+ else -+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" -+ fi -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ hppa*64*) -+ shrext_cmds='.sl' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ *) -+ shrext_cmds='.sl' -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=SHLIB_PATH -+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ esac -+ # HP-UX runs *really* slowly unless shared libraries are mode 555. -+ postinstall_cmds='chmod 555 $lib' -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $host_os in -+ nonstopux*) version_type=nonstopux ;; -+ *) -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ version_type=linux -+ else -+ version_type=irix -+ fi ;; -+ esac -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' -+ case $host_os in -+ irix5* | nonstopux*) -+ libsuff= shlibsuff= -+ ;; -+ *) -+ case $LD in # libtool.m4 will add one of these switches to LD -+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") -+ libsuff= shlibsuff= libmagic=32-bit;; -+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") -+ libsuff=32 shlibsuff=N32 libmagic=N32;; -+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") -+ libsuff=64 shlibsuff=64 libmagic=64-bit;; -+ *) libsuff= shlibsuff= libmagic=never-match;; -+ esac -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -+ hardcode_into_libs=yes -+ ;; -+ -+# No shared lib support for Linux oldld, aout, or coff. -+linux*oldld* | linux*aout* | linux*coff*) -+ dynamic_linker=no -+ ;; -+ -+# This must be Linux ELF. -+linux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ # This implies no fast_install, which is unacceptable. -+ # Some rework will be needed to allow for fast_install -+ # before this can be enabled. -+ hardcode_into_libs=yes -+ -+ # Append ld.so.conf contents to the search path -+ if test -f /etc/ld.so.conf; then -+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` -+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" -+ fi -+ -+ # We used to test for /lib/ld.so.1 and disable shared libraries on -+ # powerpc, because MkLinux only supported shared libraries with the -+ # GNU dynamic linker. Since this was broken with cross compilers, -+ # most powerpc-linux boxes support dynamic linking these days and -+ # people can always --disable-shared, the test was removed, and we -+ # assume the GNU/Linux dynamic linker is in use. -+ dynamic_linker='GNU/Linux ld.so' -+ ;; -+ -+netbsdelf*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='NetBSD ld.elf_so' -+ ;; -+ -+knetbsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+netbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ dynamic_linker='NetBSD (a.out) ld.so' -+ else -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ dynamic_linker='NetBSD ld.elf_so' -+ fi -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ -+newsos6) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+nto-qnx*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+openbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. -+ case $host_os in -+ openbsd3.3 | openbsd3.3.*) need_version=yes ;; -+ *) need_version=no ;; -+ esac -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ case $host_os in -+ openbsd2.[89] | openbsd2.[89].*) -+ shlibpath_overrides_runpath=no -+ ;; -+ *) -+ shlibpath_overrides_runpath=yes -+ ;; -+ esac -+ else -+ shlibpath_overrides_runpath=yes -+ fi -+ ;; -+ -+os2*) -+ libname_spec='$name' -+ shrext_cmds=".dll" -+ need_lib_prefix=no -+ library_names_spec='$libname${shared_ext} $libname.a' -+ dynamic_linker='OS/2 ld.exe' -+ shlibpath_var=LIBPATH -+ ;; -+ -+osf3* | osf4* | osf5*) -+ version_type=osf -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -+ ;; -+ -+sco3.2v5*) -+ version_type=osf -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+solaris*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ # ldd complains unless libraries are executable -+ postinstall_cmds='chmod +x $lib' -+ ;; -+ -+sunos4*) -+ version_type=sunos -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ fi -+ need_version=yes -+ ;; -+ -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_vendor in -+ sni) -+ shlibpath_overrides_runpath=no -+ need_lib_prefix=no -+ export_dynamic_flag_spec='${wl}-Blargedynsym' -+ runpath_var=LD_RUN_PATH -+ ;; -+ siemens) -+ need_lib_prefix=no -+ ;; -+ motorola) -+ need_lib_prefix=no -+ need_version=no -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -+ ;; -+ esac -+ ;; -+ -+sysv4*MP*) -+ if test -d /usr/nec ;then -+ version_type=linux -+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' -+ soname_spec='$libname${shared_ext}.$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ fi -+ ;; -+ -+uts4*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+*) -+ dynamic_linker=no -+ ;; -+esac -+echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -+echo "${ECHO_T}$dynamic_linker" >&6 -+test "$dynamic_linker" = no && can_build_shared=no -+ -+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -+hardcode_action_F77= -+if test -n "$hardcode_libdir_flag_spec_F77" || \ -+ test -n "$runpath_var_F77" || \ -+ test "X$hardcode_automatic_F77" = "Xyes" ; then -+ -+ # We can hardcode non-existant directories. -+ if test "$hardcode_direct_F77" != no && -+ # If the only mechanism to avoid hardcoding is shlibpath_var, we -+ # have to relink, otherwise we might link with an installed library -+ # when we should be linking with a yet-to-be-installed one -+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && -+ test "$hardcode_minus_L_F77" != no; then -+ # Linking always hardcodes the temporary library directory. -+ hardcode_action_F77=relink -+ else -+ # We can link without hardcoding, and we can hardcode nonexisting dirs. -+ hardcode_action_F77=immediate -+ fi -+else -+ # We cannot hardcode anything, or else we can only hardcode existing -+ # directories. -+ hardcode_action_F77=unsupported -+fi -+echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 -+echo "${ECHO_T}$hardcode_action_F77" >&6 -+ -+if test "$hardcode_action_F77" = relink; then -+ # Fast installation is not supported -+ enable_fast_install=no -+elif test "$shlibpath_overrides_runpath" = yes || -+ test "$enable_shared" = no; then -+ # Fast installation is not necessary -+ enable_fast_install=needless -+fi -+ -+striplib= -+old_striplib= -+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -+ test -z "$striplib" && striplib="$STRIP --strip-unneeded" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+else -+# FIXME - insert some real tests, host_os isn't really good enough -+ case $host_os in -+ darwin*) -+ if test -n "$STRIP" ; then -+ striplib="$STRIP -x" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+ else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ ;; -+ *) -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+ ;; -+ esac -+fi -+ -+ -+ -+# The else clause should only fire when bootstrapping the -+# libtool distribution, otherwise you forgot to ship ltmain.sh -+# with your package, and you will get complaints that there are -+# no rules to generate ltmain.sh. -+if test -f "$ltmain"; then -+ # See if we are running on zsh, and set the options which allow our commands through -+ # without removal of \ escapes. -+ if test -n "${ZSH_VERSION+set}" ; then -+ setopt NO_GLOB_SUBST -+ fi -+ # Now quote all the things that may contain metacharacters while being -+ # careful not to overquote the AC_SUBSTed values. We take copies of the -+ # variables and quote the copies for generation of the libtool script. -+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ -+ SED SHELL STRIP \ -+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ -+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ -+ deplibs_check_method reload_flag reload_cmds need_locks \ -+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ -+ lt_cv_sys_global_symbol_to_c_name_address \ -+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -+ old_postinstall_cmds old_postuninstall_cmds \ -+ compiler_F77 \ -+ CC_F77 \ -+ LD_F77 \ -+ lt_prog_compiler_wl_F77 \ -+ lt_prog_compiler_pic_F77 \ -+ lt_prog_compiler_static_F77 \ -+ lt_prog_compiler_no_builtin_flag_F77 \ -+ export_dynamic_flag_spec_F77 \ -+ thread_safe_flag_spec_F77 \ -+ whole_archive_flag_spec_F77 \ -+ enable_shared_with_static_runtimes_F77 \ -+ old_archive_cmds_F77 \ -+ old_archive_from_new_cmds_F77 \ -+ predep_objects_F77 \ -+ postdep_objects_F77 \ -+ predeps_F77 \ -+ postdeps_F77 \ -+ compiler_lib_search_path_F77 \ -+ archive_cmds_F77 \ -+ archive_expsym_cmds_F77 \ -+ postinstall_cmds_F77 \ -+ postuninstall_cmds_F77 \ -+ old_archive_from_expsyms_cmds_F77 \ -+ allow_undefined_flag_F77 \ -+ no_undefined_flag_F77 \ -+ export_symbols_cmds_F77 \ -+ hardcode_libdir_flag_spec_F77 \ -+ hardcode_libdir_flag_spec_ld_F77 \ -+ hardcode_libdir_separator_F77 \ -+ hardcode_automatic_F77 \ -+ module_cmds_F77 \ -+ module_expsym_cmds_F77 \ -+ lt_cv_prog_compiler_c_o_F77 \ -+ exclude_expsyms_F77 \ -+ include_expsyms_F77; do -+ -+ case $var in -+ old_archive_cmds_F77 | \ -+ old_archive_from_new_cmds_F77 | \ -+ archive_cmds_F77 | \ -+ archive_expsym_cmds_F77 | \ -+ module_cmds_F77 | \ -+ module_expsym_cmds_F77 | \ -+ old_archive_from_expsyms_cmds_F77 | \ -+ export_symbols_cmds_F77 | \ -+ extract_expsyms_cmds | reload_cmds | finish_cmds | \ -+ postinstall_cmds | postuninstall_cmds | \ -+ old_postinstall_cmds | old_postuninstall_cmds | \ -+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -+ # Double-quote double-evaled strings. -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -+ ;; -+ *) -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -+ ;; -+ esac -+ done -+ -+ case $lt_echo in -+ *'\$0 --fallback-echo"') -+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` -+ ;; -+ esac -+ -+cfgfile="$ofile" -+ -+ cat <<__EOF__ >> "$cfgfile" -+# ### BEGIN LIBTOOL TAG CONFIG: $tagname -+ -+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+ -+# Shell to use when invoking shell scripts. -+SHELL=$lt_SHELL -+ -+# Whether or not to build shared libraries. -+build_libtool_libs=$enable_shared -+ -+# Whether or not to build static libraries. -+build_old_libs=$enable_static -+ -+# Whether or not to add -lc for building shared libraries. -+build_libtool_need_lc=$archive_cmds_need_lc_F77 -+ -+# Whether or not to disallow shared libs when runtime libs are static -+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 -+ -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ -+# The host system. -+host_alias=$host_alias -+host=$host -+host_os=$host_os -+ -+# The build system. -+build_alias=$build_alias -+build=$build -+build_os=$build_os -+ -+# An echo program that does not interpret backslashes. -+echo=$lt_echo -+ -+# The archiver. -+AR=$lt_AR -+AR_FLAGS=$lt_AR_FLAGS -+ -+# A C compiler. -+LTCC=$lt_LTCC -+ -+# A language-specific compiler. -+CC=$lt_compiler_F77 -+ -+# Is the compiler the GNU C compiler? -+with_gcc=$GCC_F77 -+ -+# An ERE matcher. -+EGREP=$lt_EGREP -+ -+# The linker used to build libraries. -+LD=$lt_LD_F77 -+ -+# Whether we need hard or soft links. -+LN_S=$lt_LN_S -+ -+# A BSD-compatible nm program. -+NM=$lt_NM -+ -+# A symbol stripping program -+STRIP=$lt_STRIP -+ -+# Used to examine libraries when file_magic_cmd begins "file" -+MAGIC_CMD=$MAGIC_CMD -+ -+# Used on cygwin: DLL creation program. -+DLLTOOL="$DLLTOOL" -+ -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. -+AS="$AS" -+ -+# The name of the directory that contains temporary libtool files. -+objdir=$objdir -+ -+# How to create reloadable object files. -+reload_flag=$lt_reload_flag -+reload_cmds=$lt_reload_cmds -+ -+# How to pass a linker flag through the compiler. -+wl=$lt_lt_prog_compiler_wl_F77 -+ -+# Object file suffix (normally "o"). -+objext="$ac_objext" -+ -+# Old archive suffix (normally "a"). -+libext="$libext" -+ -+# Shared library suffix (normally ".so"). -+shrext_cmds='$shrext_cmds' -+ -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ -+# Additional compiler flags for building library objects. -+pic_flag=$lt_lt_prog_compiler_pic_F77 -+pic_mode=$pic_mode -+ -+# What is the maximum length of a command? -+max_cmd_len=$lt_cv_sys_max_cmd_len -+ -+# Does compiler simultaneously support -c and -o options? -+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 -+ -+# Must we lock files when doing compilation? -+need_locks=$lt_need_locks -+ -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen_support=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ -+# Compiler flag to prevent dynamic linking. -+link_static_flag=$lt_lt_prog_compiler_static_F77 -+ -+# Compiler flag to turn off builtin functions. -+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 -+ -+# Compiler flag to allow reflexive dlopens. -+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 -+ -+# Compiler flag to generate shared objects directly from archives. -+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 -+ -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 -+ -+# Library versioning type. -+version_type=$version_type -+ -+# Format of library name prefix. -+libname_spec=$lt_libname_spec -+ -+# List of archive names. First name is the real one, the rest are links. -+# The last name is the one that the linker finds with -lNAME. -+library_names_spec=$lt_library_names_spec -+ -+# The coded name of the library, if different from the real name. -+soname_spec=$lt_soname_spec -+ -+# Commands used to build and install an old-style archive. -+RANLIB=$lt_RANLIB -+old_archive_cmds=$lt_old_archive_cmds_F77 -+old_postinstall_cmds=$lt_old_postinstall_cmds -+old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ -+# Create an old-style archive from a shared archive. -+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 -+ -+# Create a temporary old-style archive to link instead of a shared archive. -+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 -+ -+# Commands used to build and install a shared archive. -+archive_cmds=$lt_archive_cmds_F77 -+archive_expsym_cmds=$lt_archive_expsym_cmds_F77 -+postinstall_cmds=$lt_postinstall_cmds -+postuninstall_cmds=$lt_postuninstall_cmds -+ -+# Commands used to build a loadable module (assumed same as above if empty) -+module_cmds=$lt_module_cmds_F77 -+module_expsym_cmds=$lt_module_expsym_cmds_F77 -+ -+# Commands to strip libraries. -+old_striplib=$lt_old_striplib -+striplib=$lt_striplib -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predep_objects=$lt_predep_objects_F77 -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdep_objects=$lt_postdep_objects_F77 -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predeps=$lt_predeps_F77 -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdeps=$lt_postdeps_F77 -+ -+# The library search path used internally by the compiler when linking -+# a shared library. -+compiler_lib_search_path=$lt_compiler_lib_search_path_F77 -+ -+# Method to check whether dependent libraries are shared objects. -+deplibs_check_method=$lt_deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$lt_file_magic_cmd -+ -+# Flag that allows shared libraries with undefined symbols to be built. -+allow_undefined_flag=$lt_allow_undefined_flag_F77 -+ -+# Flag that forces no undefined symbols. -+no_undefined_flag=$lt_no_undefined_flag_F77 -+ -+# Commands used to finish a libtool library installation in a directory. -+finish_cmds=$lt_finish_cmds -+ -+# Same as above, but a single script fragment to be evaled but not shown. -+finish_eval=$lt_finish_eval -+ -+# Take the output of nm and produce a listing of raw symbols and C names. -+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe -+ -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl -+ -+# Transform the output of nm in a C name address pair -+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address -+ -+# This is the shared library runtime path variable. -+runpath_var=$runpath_var -+ -+# This is the shared library path variable. -+shlibpath_var=$shlibpath_var -+ -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+ -+# How to hardcode a shared library path into an executable. -+hardcode_action=$hardcode_action_F77 -+ -+# Whether we should hardcode library paths into libraries. -+hardcode_into_libs=$hardcode_into_libs -+ -+# Flag to hardcode \$libdir into a binary during linking. -+# This must work even if \$libdir does not exist. -+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 -+ -+# If ld is used when linking, flag to hardcode \$libdir into -+# a binary during linking. This must work even if \$libdir does -+# not exist. -+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 -+ -+# Whether we need a single -rpath flag with a separated argument. -+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 -+ -+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -+# resulting binary. -+hardcode_direct=$hardcode_direct_F77 -+ -+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -+# resulting binary. -+hardcode_minus_L=$hardcode_minus_L_F77 -+ -+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -+# the resulting binary. -+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 -+ -+# Set to yes if building a shared library automatically hardcodes DIR into the library -+# and all subsequent libraries and executables linked against it. -+hardcode_automatic=$hardcode_automatic_F77 -+ -+# Variables whose values should be saved in libtool wrapper scripts and -+# restored at relink time. -+variables_saved_for_relink="$variables_saved_for_relink" -+ -+# Whether libtool must link a program against all its dependency libraries. -+link_all_deplibs=$link_all_deplibs_F77 -+ -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ -+# Fix the shell variable \$srcfile for the compiler. -+fix_srcfile_path="$fix_srcfile_path_F77" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$always_export_symbols_F77 -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$lt_export_symbols_cmds_F77 -+ -+# The commands to extract the exported symbol list from a shared archive. -+extract_expsyms_cmds=$lt_extract_expsyms_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$lt_exclude_expsyms_F77 -+ -+# Symbols that must always be exported. -+include_expsyms=$lt_include_expsyms_F77 -+ -+# ### END LIBTOOL TAG CONFIG: $tagname -+ -+__EOF__ -+ -+ -+else -+ # If there is no Makefile yet, we rely on a make rule to execute -+ # `config.status --recheck' to rerun these tests and create the -+ # libtool script then. -+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` -+ if test -f "$ltmain_in"; then -+ test -f Makefile && make "$ltmain" -+ fi -+fi -+ -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+CC="$lt_save_CC" -+ -+ else -+ tagname="" -+ fi -+ ;; -+ -+ GCJ) -+ if test -n "$GCJ" && test "X$GCJ" != "Xno"; then -+ -+ -+ -+# Source file extension for Java test sources. -+ac_ext=java -+ -+# Object file extension for compiled Java test sources. -+objext=o -+objext_GCJ=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code="class foo {}\n" -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n' -+ -+# ltmain only uses $CC for tagged configurations so make sure $CC is set. -+ -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} -+ -+# Allow CC to be a program name with arguments. -+compiler=$CC -+ -+ -+# save warnings/boilerplate of simple test code -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_compile_test_code" >conftest.$ac_ext -+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_compiler_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_link_test_code" >conftest.$ac_ext -+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_linker_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ -+# Allow CC to be a program name with arguments. -+lt_save_CC="$CC" -+CC=${GCJ-"gcj"} -+compiler=$CC -+compiler_GCJ=$CC -+for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ -+# GCJ did not exist at the time GCC didn't implicitly link libc in. -+archive_cmds_need_lc_GCJ=no -+ -+old_archive_cmds_GCJ=$old_archive_cmds -+ -+ -+lt_prog_compiler_no_builtin_flag_GCJ= -+ -+if test "$GCC" = yes; then -+ lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' -+ -+ -+echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_cv_prog_compiler_rtti_exceptions=no -+ ac_outfile=conftest.$ac_objext -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="-fno-rtti -fno-exceptions" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:15967: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&5 -+ echo "$as_me:15971: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ lt_cv_prog_compiler_rtti_exceptions=yes -+ fi -+ fi -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 -+ -+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then -+ lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" -+else -+ : -+fi -+ -+fi -+ -+lt_prog_compiler_wl_GCJ= -+lt_prog_compiler_pic_GCJ= -+lt_prog_compiler_static_GCJ= -+ -+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 -+ -+ if test "$GCC" = yes; then -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ lt_prog_compiler_static_GCJ='-static' -+ -+ case $host_os in -+ aix*) -+ # All AIX code is PIC. -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ fi -+ ;; -+ -+ amigaos*) -+ # FIXME: we need at least 68020 code to build shared libraries, but -+ # adding the `-m68020' flag to GCC prevents building anything better, -+ # like `-m68040'. -+ lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' -+ ;; -+ -+ beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) -+ # PIC is the default for these OSes. -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' -+ ;; -+ -+ darwin* | rhapsody*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ lt_prog_compiler_pic_GCJ='-fno-common' -+ ;; -+ -+ msdosdjgpp*) -+ # Just because we use GCC doesn't mean we suddenly get shared libraries -+ # on systems that don't support them. -+ lt_prog_compiler_can_build_shared_GCJ=no -+ enable_shared=no -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ lt_prog_compiler_pic_GCJ=-Kconform_pic -+ fi -+ ;; -+ -+ hpux*) -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic_GCJ='-fPIC' -+ ;; -+ esac -+ ;; -+ -+ *) -+ lt_prog_compiler_pic_GCJ='-fPIC' -+ ;; -+ esac -+ else -+ # PORTME Check for flag to pass linker flags through the system compiler. -+ case $host_os in -+ aix*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ if test "$host_cpu" = ia64; then -+ # AIX 5 now supports IA64 processor -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ else -+ lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' -+ fi -+ ;; -+ darwin*) -+ # PIC is the default on this platform -+ # Common symbols not allowed in MH_DYLIB files -+ case $cc_basename in -+ xlc*) -+ lt_prog_compiler_pic_GCJ='-qnocommon' -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ ;; -+ esac -+ ;; -+ -+ mingw* | pw32* | os2*) -+ # This hack is so that the source file can tell whether it is being -+ # built for inclusion in a dll (and should export symbols for example). -+ lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' -+ ;; -+ -+ hpux9* | hpux10* | hpux11*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but -+ # not for PA HP-UX. -+ case $host_cpu in -+ hppa*64*|ia64*) -+ # +Z the default -+ ;; -+ *) -+ lt_prog_compiler_pic_GCJ='+Z' -+ ;; -+ esac -+ # Is there a better lt_prog_compiler_static that works with the bundled CC? -+ lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ # PIC (with -KPIC) is the default. -+ lt_prog_compiler_static_GCJ='-non_shared' -+ ;; -+ -+ newsos6) -+ lt_prog_compiler_pic_GCJ='-KPIC' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ ;; -+ -+ linux*) -+ case $cc_basename in -+ icc* | ecc*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ lt_prog_compiler_pic_GCJ='-KPIC' -+ lt_prog_compiler_static_GCJ='-static' -+ ;; -+ pgcc* | pgf77* | pgf90* | pgf95*) -+ # Portland Group compilers (*not* the Pentium gcc compiler, -+ # which looks to be a dead project) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ lt_prog_compiler_pic_GCJ='-fpic' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ ;; -+ ccc*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ # All Alpha code is PIC. -+ lt_prog_compiler_static_GCJ='-non_shared' -+ ;; -+ esac -+ ;; -+ -+ osf3* | osf4* | osf5*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ # All OSF/1 code is PIC. -+ lt_prog_compiler_static_GCJ='-non_shared' -+ ;; -+ -+ sco3.2v5*) -+ lt_prog_compiler_pic_GCJ='-Kpic' -+ lt_prog_compiler_static_GCJ='-dn' -+ ;; -+ -+ solaris*) -+ lt_prog_compiler_pic_GCJ='-KPIC' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ case $cc_basename in -+ f77* | f90* | f95*) -+ lt_prog_compiler_wl_GCJ='-Qoption ld ';; -+ *) -+ lt_prog_compiler_wl_GCJ='-Wl,';; -+ esac -+ ;; -+ -+ sunos4*) -+ lt_prog_compiler_wl_GCJ='-Qoption ld ' -+ lt_prog_compiler_pic_GCJ='-PIC' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ ;; -+ -+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ lt_prog_compiler_pic_GCJ='-KPIC' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec ;then -+ lt_prog_compiler_pic_GCJ='-Kconform_pic' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ fi -+ ;; -+ -+ unicos*) -+ lt_prog_compiler_wl_GCJ='-Wl,' -+ lt_prog_compiler_can_build_shared_GCJ=no -+ ;; -+ -+ uts4*) -+ lt_prog_compiler_pic_GCJ='-pic' -+ lt_prog_compiler_static_GCJ='-Bstatic' -+ ;; -+ -+ *) -+ lt_prog_compiler_can_build_shared_GCJ=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 -+ -+# -+# Check to make sure the PIC flag actually works. -+# -+if test -n "$lt_prog_compiler_pic_GCJ"; then -+ -+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 -+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 -+if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_prog_compiler_pic_works_GCJ=no -+ ac_outfile=conftest.$ac_objext -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ lt_compiler_flag="$lt_prog_compiler_pic_GCJ" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ # The option is referenced via a variable to avoid confusing sed. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:16229: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>conftest.err) -+ ac_status=$? -+ cat conftest.err >&5 -+ echo "$as_me:16233: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s "$ac_outfile"; then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings other than the usual output. -+ $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp -+ $SED '/^$/d' conftest.err >conftest.er2 -+ if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then -+ lt_prog_compiler_pic_works_GCJ=yes -+ fi -+ fi -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 -+echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 -+ -+if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then -+ case $lt_prog_compiler_pic_GCJ in -+ "" | " "*) ;; -+ *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; -+ esac -+else -+ lt_prog_compiler_pic_GCJ= -+ lt_prog_compiler_can_build_shared_GCJ=no -+fi -+ -+fi -+case $host_os in -+ # For platforms which do not support PIC, -DPIC is meaningless: -+ *djgpp*) -+ lt_prog_compiler_pic_GCJ= -+ ;; -+ *) -+ lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -+if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ lt_cv_prog_compiler_c_o_GCJ=no -+ $rm -r conftest 2>/dev/null -+ mkdir conftest -+ cd conftest -+ mkdir out -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ lt_compiler_flag="-o out/conftest2.$ac_objext" -+ # Insert the option either (1) after the last *FLAGS variable, or -+ # (2) before a word containing "conftest.", or (3) at the end. -+ # Note that $ac_compile itself does not contain backslashes and begins -+ # with a dollar sign (not a hyphen), so the echo should work correctly. -+ lt_compile=`echo "$ac_compile" | $SED \ -+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -+ -e 's:$: $lt_compiler_flag:'` -+ (eval echo "\"\$as_me:16291: $lt_compile\"" >&5) -+ (eval "$lt_compile" 2>out/conftest.err) -+ ac_status=$? -+ cat out/conftest.err >&5 -+ echo "$as_me:16295: \$? = $ac_status" >&5 -+ if (exit $ac_status) && test -s out/conftest2.$ac_objext -+ then -+ # The compiler can only warn and ignore the option if not recognized -+ # So say no if there are warnings -+ $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp -+ $SED '/^$/d' out/conftest.err >out/conftest.er2 -+ if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then -+ lt_cv_prog_compiler_c_o_GCJ=yes -+ fi -+ fi -+ chmod u+w . 2>&5 -+ $rm conftest* -+ # SGI C++ compiler will create directory out/ii_files/ for -+ # template instantiation -+ test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files -+ $rm out/* && rmdir out -+ cd .. -+ rmdir conftest -+ $rm conftest* -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 -+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 -+ -+ -+hard_links="nottested" -+if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then -+ # do not overwrite the value of need_locks provided by the user -+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 -+ hard_links=yes -+ $rm conftest* -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ touch conftest.a -+ ln conftest.a conftest.b 2>&5 || hard_links=no -+ ln conftest.a conftest.b 2>/dev/null && hard_links=no -+ echo "$as_me:$LINENO: result: $hard_links" >&5 -+echo "${ECHO_T}$hard_links" >&6 -+ if test "$hard_links" = no; then -+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} -+ need_locks=warn -+ fi -+else -+ need_locks=no -+fi -+ -+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -+ -+ runpath_var= -+ allow_undefined_flag_GCJ= -+ enable_shared_with_static_runtimes_GCJ=no -+ archive_cmds_GCJ= -+ archive_expsym_cmds_GCJ= -+ old_archive_From_new_cmds_GCJ= -+ old_archive_from_expsyms_cmds_GCJ= -+ export_dynamic_flag_spec_GCJ= -+ whole_archive_flag_spec_GCJ= -+ thread_safe_flag_spec_GCJ= -+ hardcode_libdir_flag_spec_GCJ= -+ hardcode_libdir_flag_spec_ld_GCJ= -+ hardcode_libdir_separator_GCJ= -+ hardcode_direct_GCJ=no -+ hardcode_minus_L_GCJ=no -+ hardcode_shlibpath_var_GCJ=unsupported -+ link_all_deplibs_GCJ=unknown -+ hardcode_automatic_GCJ=no -+ module_cmds_GCJ= -+ module_expsym_cmds_GCJ= -+ always_export_symbols_GCJ=no -+ export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' -+ # include_expsyms should be a list of space-separated symbols to be *always* -+ # included in the symbol list -+ include_expsyms_GCJ= -+ # exclude_expsyms can be an extended regexp of symbols to exclude -+ # it will be wrapped by ` (' and `)$', so one must not match beginning or -+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -+ # as well as any symbol that contains `d'. -+ exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" -+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -+ # platforms (ab)use it in PIC code, but their linkers get confused if -+ # the symbol is explicitly referenced. Since portable code cannot -+ # rely on this symbol name, it's probably fine to never include it in -+ # preloaded symbol tables. -+ extract_expsyms_cmds= -+ # Just being paranoid about ensuring that cc_basename is set. -+ for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+ case $host_os in -+ cygwin* | mingw* | pw32*) -+ # FIXME: the MSVC++ port hasn't been tested in a loooong time -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ if test "$GCC" != yes; then -+ with_gnu_ld=no -+ fi -+ ;; -+ openbsd*) -+ with_gnu_ld=no -+ ;; -+ esac -+ -+ ld_shlibs_GCJ=yes -+ if test "$with_gnu_ld" = yes; then -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ wlarc='${wl}' -+ -+ # Set some defaults for GNU ld with shared library support. These -+ # are reset later if shared libraries are not supported. Putting them -+ # here allows them to be overridden if necessary. -+ runpath_var=LD_RUN_PATH -+ hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' -+ export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then -+ whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ whole_archive_flag_spec_GCJ= -+ fi -+ supports_anon_versioning=no -+ case `$LD -v 2>/dev/null` in -+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 -+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... -+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... -+ *\ 2.11.*) ;; # other 2.11 versions -+ *) supports_anon_versioning=yes ;; -+ esac -+ -+ # See if GNU ld supports shared libraries. -+ case $host_os in -+ aix3* | aix4* | aix5*) -+ # On AIX/PPC, the GNU linker is very broken -+ if test "$host_cpu" != ia64; then -+ ld_shlibs_GCJ=no -+ cat <&2 -+ -+*** Warning: the GNU linker, at least up to release 2.9.1, is reported -+*** to be unable to reliably create shared libraries on AIX. -+*** Therefore, libtool is disabling shared libraries support. If you -+*** really care for shared libraries, you may want to modify your PATH -+*** so that a non-GNU linker is found, and then restart. -+ -+EOF -+ fi -+ ;; -+ -+ amigaos*) -+ archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_minus_L_GCJ=yes -+ -+ # Samuel A. Falvo II reports -+ # that the semantics of dynamic libraries on AmigaOS, at least up -+ # to version 4, is to share data among multiple programs linked -+ # with the same dynamic library. Since this doesn't match the -+ # behavior of shared libraries on other platforms, we can't use -+ # them. -+ ld_shlibs_GCJ=no -+ ;; -+ -+ beos*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ allow_undefined_flag_GCJ=unsupported -+ # Joseph Beckenbach says some releases of gcc -+ # support --undefined. This deserves some investigation. FIXME -+ archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ else -+ ld_shlibs_GCJ=no -+ fi -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, -+ # as there is no search path for DLLs. -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ allow_undefined_flag_GCJ=unsupported -+ always_export_symbols_GCJ=no -+ enable_shared_with_static_runtimes_GCJ=yes -+ export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' -+ -+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then -+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ # If the export-symbols file already is a .def file (1st line -+ # is EXPORTS), use it as is; otherwise, prepend... -+ archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then -+ cp $export_symbols $output_objdir/$soname.def; -+ else -+ echo EXPORTS > $output_objdir/$soname.def; -+ cat $export_symbols >> $output_objdir/$soname.def; -+ fi~ -+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' -+ else -+ ld_shlibs_GCJ=no -+ fi -+ ;; -+ -+ linux*) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ tmp_addflag= -+ case $cc_basename,$host_cpu in -+ pgcc*) # Portland Group C compiler -+ whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag' -+ ;; -+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers -+ whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' -+ tmp_addflag=' $pic_flag -Mnomain' ;; -+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 -+ tmp_addflag=' -i_dynamic' ;; -+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 -+ tmp_addflag=' -i_dynamic -nofor_main' ;; -+ ifc* | ifort*) # Intel Fortran compiler -+ tmp_addflag=' -nofor_main' ;; -+ esac -+ archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ -+ if test $supports_anon_versioning = yes; then -+ archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ -+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ -+ $echo "local: *; };" >> $output_objdir/$libname.ver~ -+ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' -+ fi -+ link_all_deplibs_GCJ=no -+ else -+ ld_shlibs_GCJ=no -+ fi -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' -+ wlarc= -+ else -+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ fi -+ ;; -+ -+ solaris* | sysv5*) -+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then -+ ld_shlibs_GCJ=no -+ cat <&2 -+ -+*** Warning: The releases 2.8.* of the GNU linker cannot reliably -+*** create shared libraries on Solaris systems. Therefore, libtool -+*** is disabling shared libraries support. We urge you to upgrade GNU -+*** binutils to release 2.9.1 or newer. Another option is to modify -+*** your PATH or compiler configuration so that the native linker is -+*** used, and then restart. -+ -+EOF -+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs_GCJ=no -+ fi -+ ;; -+ -+ sunos4*) -+ archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ wlarc= -+ hardcode_direct_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ *) -+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs_GCJ=no -+ fi -+ ;; -+ esac -+ -+ if test "$ld_shlibs_GCJ" = no; then -+ runpath_var= -+ hardcode_libdir_flag_spec_GCJ= -+ export_dynamic_flag_spec_GCJ= -+ whole_archive_flag_spec_GCJ= -+ fi -+ else -+ # PORTME fill in a description of your system's linker (not GNU ld) -+ case $host_os in -+ aix3*) -+ allow_undefined_flag_GCJ=unsupported -+ always_export_symbols_GCJ=yes -+ archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' -+ # Note: this linker hardcodes the directories in LIBPATH if there -+ # are no directories specified by -L. -+ hardcode_minus_L_GCJ=yes -+ if test "$GCC" = yes && test -z "$link_static_flag"; then -+ # Neither direct hardcoding nor static linking is supported with a -+ # broken collect2. -+ hardcode_direct_GCJ=unsupported -+ fi -+ ;; -+ -+ aix4* | aix5*) -+ if test "$host_cpu" = ia64; then -+ # On IA64, the linker does run time linking by default, so we don't -+ # have to do anything special. -+ aix_use_runtimelinking=no -+ exp_sym_flag='-Bexport' -+ no_entry_flag="" -+ else -+ # If we're using GNU nm, then we don't want the "-C" option. -+ # -C means demangle to AIX nm, but means don't demangle with GNU nm -+ if $NM -V 2>&1 | grep 'GNU' > /dev/null; then -+ export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ else -+ export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' -+ fi -+ aix_use_runtimelinking=no -+ -+ # Test if we are trying to use run time linking or normal -+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we -+ # need to do runtime linking. -+ case $host_os in aix4.[23]|aix4.[23].*|aix5*) -+ for ld_flag in $LDFLAGS; do -+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then -+ aix_use_runtimelinking=yes -+ break -+ fi -+ done -+ esac -+ -+ exp_sym_flag='-bexport' -+ no_entry_flag='-bnoentry' -+ fi -+ -+ # When large executables or shared objects are built, AIX ld can -+ # have problems creating the table of contents. If linking a library -+ # or program results in "error TOC overflow" add -mminimal-toc to -+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not -+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. -+ -+ archive_cmds_GCJ='' -+ hardcode_direct_GCJ=yes -+ hardcode_libdir_separator_GCJ=':' -+ link_all_deplibs_GCJ=yes -+ -+ if test "$GCC" = yes; then -+ case $host_os in aix4.[012]|aix4.[012].*) -+ # We only want to do this on AIX 4.2 and lower, the check -+ # below for broken collect2 doesn't work under 4.3+ -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ hardcode_direct_GCJ=yes -+ else -+ # We have old collect2 -+ hardcode_direct_GCJ=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ hardcode_minus_L_GCJ=yes -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_libdir_separator_GCJ= -+ fi -+ esac -+ shared_flag='-shared' -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag="$shared_flag "'${wl}-G' -+ fi -+ else -+ # not using gcc -+ if test "$host_cpu" = ia64; then -+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release -+ # chokes on -Wl,-G. The following line is correct: -+ shared_flag='-G' -+ else -+ if test "$aix_use_runtimelinking" = yes; then -+ shared_flag='${wl}-G' -+ else -+ shared_flag='${wl}-bM:SRE' -+ fi -+ fi -+ fi -+ -+ # It seems that -bexpall does not export symbols beginning with -+ # underscore (_), so it is better to generate a list of symbols to export. -+ always_export_symbols_GCJ=yes -+ if test "$aix_use_runtimelinking" = yes; then -+ # Warning - without using the other runtime loading flags (-brtl), -+ # -berok will link without error, but may produce a broken library. -+ allow_undefined_flag_GCJ='-berok' -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" -+ archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" -+ else -+ if test "$host_cpu" = ia64; then -+ hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' -+ allow_undefined_flag_GCJ="-z nodefs" -+ archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" -+ else -+ # Determine the default libpath from the value encoded in an empty executable. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ -+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'` -+# Check for a 64-bit object if we didn't find anything. -+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -+}'`; fi -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -+ -+ hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" -+ # Warning - without using the other run time loading flags, -+ # -berok will link without error, but may produce a broken library. -+ no_undefined_flag_GCJ=' ${wl}-bernotok' -+ allow_undefined_flag_GCJ=' ${wl}-berok' -+ # -bexpall does not export symbols beginning with underscore (_) -+ always_export_symbols_GCJ=yes -+ # Exported symbols can be pulled into shared objects from archives -+ whole_archive_flag_spec_GCJ=' ' -+ archive_cmds_need_lc_GCJ=yes -+ # This is similar to how AIX traditionally builds its shared libraries. -+ archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' -+ fi -+ fi -+ ;; -+ -+ amigaos*) -+ archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_minus_L_GCJ=yes -+ # see comment about different semantics on the GNU ld section -+ ld_shlibs_GCJ=no -+ ;; -+ -+ bsdi[45]*) -+ export_dynamic_flag_spec_GCJ=-rdynamic -+ ;; -+ -+ cygwin* | mingw* | pw32*) -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ # hardcode_libdir_flag_spec is actually meaningless, as there is -+ # no search path for DLLs. -+ hardcode_libdir_flag_spec_GCJ=' ' -+ allow_undefined_flag_GCJ=unsupported -+ # Tell ltmain to make .lib files, not .a files. -+ libext=lib -+ # Tell ltmain to make .dll files, not .so files. -+ shrext_cmds=".dll" -+ # FIXME: Setting linknames here is a bad hack. -+ archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' -+ # The linker will automatically build a .lib file if we build a DLL. -+ old_archive_From_new_cmds_GCJ='true' -+ # FIXME: Should let the user specify the lib program. -+ old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' -+ fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`' -+ enable_shared_with_static_runtimes_GCJ=yes -+ ;; -+ -+ darwin* | rhapsody*) -+ case $host_os in -+ rhapsody* | darwin1.[012]) -+ allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress' -+ ;; -+ *) # Darwin 1.3 on -+ if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then -+ allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ else -+ case ${MACOSX_DEPLOYMENT_TARGET} in -+ 10.[012]) -+ allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -+ ;; -+ 10.*) -+ allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup' -+ ;; -+ esac -+ fi -+ ;; -+ esac -+ archive_cmds_need_lc_GCJ=no -+ hardcode_direct_GCJ=no -+ hardcode_automatic_GCJ=yes -+ hardcode_shlibpath_var_GCJ=unsupported -+ whole_archive_flag_spec_GCJ='' -+ link_all_deplibs_GCJ=yes -+ if test "$GCC" = yes ; then -+ output_verbose_link_cmd='echo' -+ archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' -+ module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ else -+ case $cc_basename in -+ xlc*) -+ output_verbose_link_cmd='echo' -+ archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' -+ module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' -+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds -+ archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' -+ ;; -+ *) -+ ld_shlibs_GCJ=no -+ ;; -+ esac -+ fi -+ ;; -+ -+ dgux*) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ freebsd1*) -+ ld_shlibs_GCJ=no -+ ;; -+ -+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -+ # support. Future versions do this automatically, but an explicit c++rt0.o -+ # does not break anything, and helps significantly (at the cost of a little -+ # extra space). -+ freebsd2.2*) -+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' -+ hardcode_libdir_flag_spec_GCJ='-R$libdir' -+ hardcode_direct_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ # Unfortunately, older versions of FreeBSD 2 do not have this feature. -+ freebsd2*) -+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_GCJ=yes -+ hardcode_minus_L_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -+ freebsd* | kfreebsd*-gnu | dragonfly*) -+ archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' -+ hardcode_libdir_flag_spec_GCJ='-R$libdir' -+ hardcode_direct_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ hpux9*) -+ if test "$GCC" = yes; then -+ archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ else -+ archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' -+ fi -+ hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator_GCJ=: -+ hardcode_direct_GCJ=yes -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L_GCJ=yes -+ export_dynamic_flag_spec_GCJ='${wl}-E' -+ ;; -+ -+ hpux10* | hpux11*) -+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ *) -+ archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -+ ;; -+ esac -+ else -+ case $host_cpu in -+ hppa*64*|ia64*) -+ archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ *) -+ archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -+ ;; -+ esac -+ fi -+ if test "$with_gnu_ld" = no; then -+ case $host_cpu in -+ hppa*64*) -+ hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' -+ hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' -+ hardcode_libdir_separator_GCJ=: -+ hardcode_direct_GCJ=no -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ ia64*) -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_direct_GCJ=no -+ hardcode_shlibpath_var_GCJ=no -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L_GCJ=yes -+ ;; -+ *) -+ hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator_GCJ=: -+ hardcode_direct_GCJ=yes -+ export_dynamic_flag_spec_GCJ='${wl}-E' -+ -+ # hardcode_minus_L: Not really in the search PATH, -+ # but as the default location of the library. -+ hardcode_minus_L_GCJ=yes -+ ;; -+ esac -+ fi -+ ;; -+ -+ irix5* | irix6* | nonstopux*) -+ if test "$GCC" = yes; then -+ archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' -+ fi -+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_GCJ=: -+ link_all_deplibs_GCJ=yes -+ ;; -+ -+ netbsd* | netbsdelf*-gnu | knetbsd*-gnu) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out -+ else -+ archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF -+ fi -+ hardcode_libdir_flag_spec_GCJ='-R$libdir' -+ hardcode_direct_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ newsos6) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_GCJ=yes -+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_GCJ=: -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ openbsd*) -+ hardcode_direct_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' -+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' -+ export_dynamic_flag_spec_GCJ='${wl}-E' -+ else -+ case $host_os in -+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) -+ archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec_GCJ='-R$libdir' -+ ;; -+ *) -+ archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' -+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' -+ ;; -+ esac -+ fi -+ ;; -+ -+ os2*) -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_minus_L_GCJ=yes -+ allow_undefined_flag_GCJ=unsupported -+ archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' -+ old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' -+ ;; -+ -+ osf3*) -+ if test "$GCC" = yes; then -+ allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ else -+ allow_undefined_flag_GCJ=' -expect_unresolved \*' -+ archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ fi -+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator_GCJ=: -+ ;; -+ -+ osf4* | osf5*) # as osf3* with the addition of -msym flag -+ if test "$GCC" = yes; then -+ allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' -+ hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' -+ else -+ allow_undefined_flag_GCJ=' -expect_unresolved \*' -+ archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' -+ archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ -+ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' -+ -+ # Both c and cxx compiler support -rpath directly -+ hardcode_libdir_flag_spec_GCJ='-rpath $libdir' -+ fi -+ hardcode_libdir_separator_GCJ=: -+ ;; -+ -+ sco3.2v5*) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var_GCJ=no -+ export_dynamic_flag_spec_GCJ='${wl}-Bexport' -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ;; -+ -+ solaris*) -+ no_undefined_flag_GCJ=' -z text' -+ if test "$GCC" = yes; then -+ wlarc='${wl}' -+ archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' -+ else -+ wlarc='' -+ archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ fi -+ hardcode_libdir_flag_spec_GCJ='-R$libdir' -+ hardcode_shlibpath_var_GCJ=no -+ case $host_os in -+ solaris2.[0-5] | solaris2.[0-5].*) ;; -+ *) -+ # The compiler driver will combine linker options so we -+ # cannot just pass the convience library names through -+ # without $wl, iff we do not link with $LD. -+ # Luckily, gcc supports the same syntax we need for Sun Studio. -+ # Supported since Solaris 2.6 (maybe 2.5.1?) -+ case $wlarc in -+ '') -+ whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; -+ *) -+ whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; -+ esac ;; -+ esac -+ link_all_deplibs_GCJ=yes -+ ;; -+ -+ sunos4*) -+ if test "x$host_vendor" = xsequent; then -+ # Use $CC to link under sequent, because it throws in some extra .o -+ # files that make .init and .fini sections work. -+ archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' -+ fi -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_direct_GCJ=yes -+ hardcode_minus_L_GCJ=yes -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ sysv4) -+ case $host_vendor in -+ sni) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_GCJ=yes # is this really true??? -+ ;; -+ siemens) -+ ## LD is ld it makes a PLAMLIB -+ ## CC just makes a GrossModule. -+ archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ reload_cmds_GCJ='$CC -r -o $output$reload_objs' -+ hardcode_direct_GCJ=no -+ ;; -+ motorola) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie -+ ;; -+ esac -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ sysv4.3*) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var_GCJ=no -+ export_dynamic_flag_spec_GCJ='-Bexport' -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_shlibpath_var_GCJ=no -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ld_shlibs_GCJ=yes -+ fi -+ ;; -+ -+ sysv4.2uw2*) -+ archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_direct_GCJ=yes -+ hardcode_minus_L_GCJ=no -+ hardcode_shlibpath_var_GCJ=no -+ hardcode_runpath_var=yes -+ runpath_var=LD_RUN_PATH -+ ;; -+ -+ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) -+ no_undefined_flag_GCJ='${wl}-z ${wl}text' -+ if test "$GCC" = yes; then -+ archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ else -+ archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' -+ fi -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ sysv5*) -+ no_undefined_flag_GCJ=' -z text' -+ # $CC -shared without GNU ld will not create a library from C++ -+ # object files and a static libstdc++, better avoid it by now -+ archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' -+ hardcode_libdir_flag_spec_GCJ= -+ hardcode_shlibpath_var_GCJ=no -+ runpath_var='LD_RUN_PATH' -+ ;; -+ -+ uts4*) -+ archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' -+ hardcode_libdir_flag_spec_GCJ='-L$libdir' -+ hardcode_shlibpath_var_GCJ=no -+ ;; -+ -+ *) -+ ld_shlibs_GCJ=no -+ ;; -+ esac -+ fi -+ -+echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 -+echo "${ECHO_T}$ld_shlibs_GCJ" >&6 -+test "$ld_shlibs_GCJ" = no && can_build_shared=no -+ -+variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -+if test "$GCC" = yes; then -+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -+fi -+ -+# -+# Do we need to explicitly link libc? -+# -+case "x$archive_cmds_need_lc_GCJ" in -+x|xyes) -+ # Assume -lc should be added -+ archive_cmds_need_lc_GCJ=yes -+ -+ if test "$enable_shared" = yes && test "$GCC" = yes; then -+ case $archive_cmds_GCJ in -+ *'~'*) -+ # FIXME: we may have to deal with multi-command sequences. -+ ;; -+ '$CC '*) -+ # Test whether the compiler implicitly links with -lc since on some -+ # systems, -lgcc has to come before -lc. If gcc already passes -lc -+ # to ld, don't add -lc before -lgcc. -+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 -+ $rm conftest* -+ printf "$lt_simple_compile_test_code" > conftest.$ac_ext -+ -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } 2>conftest.err; then -+ soname=conftest -+ lib=conftest -+ libobjs=conftest.$ac_objext -+ deplibs= -+ wl=$lt_prog_compiler_wl_GCJ -+ compiler_flags=-v -+ linker_flags=-v -+ verstring= -+ output_objdir=. -+ libname=conftest -+ lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ -+ allow_undefined_flag_GCJ= -+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 -+ (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+ then -+ archive_cmds_need_lc_GCJ=no -+ else -+ archive_cmds_need_lc_GCJ=yes -+ fi -+ allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag -+ else -+ cat conftest.err 1>&5 -+ fi -+ $rm conftest* -+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 -+echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 -+ ;; -+ esac -+ fi -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -+library_names_spec= -+libname_spec='lib$name' -+soname_spec= -+shrext_cmds=".so" -+postinstall_cmds= -+postuninstall_cmds= -+finish_cmds= -+finish_eval= -+shlibpath_var= -+shlibpath_overrides_runpath=unknown -+version_type=none -+dynamic_linker="$host_os ld.so" -+sys_lib_dlsearch_path_spec="/lib /usr/lib" -+if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then -+ # if the path contains ";" then we assume it to be the separator -+ # otherwise default to the standard path separator (i.e. ":") - it is -+ # assumed that no part of a normal pathname contains ";" but that should -+ # okay in the real world where ";" in dirpaths is itself problematic. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+else -+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -+fi -+need_lib_prefix=unknown -+hardcode_into_libs=no -+ -+# when you set need_version to no, make sure it does not cause -set_version -+# flags to be left without arguments -+need_version=unknown -+ -+case $host_os in -+aix3*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' -+ shlibpath_var=LIBPATH -+ -+ # AIX 3 has no versioning support, so we append a major version to the name. -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ -+aix4* | aix5*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ hardcode_into_libs=yes -+ if test "$host_cpu" = ia64; then -+ # AIX 5 supports IA64 -+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ else -+ # With GCC up to 2.95.x, collect2 would create an import file -+ # for dependence libraries. The import file would start with -+ # the line `#! .'. This would cause the generated library to -+ # depend on `.', always an invalid library. This was fixed in -+ # development snapshots of GCC prior to 3.0. -+ case $host_os in -+ aix4 | aix4.[01] | aix4.[01].*) -+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' -+ echo ' yes ' -+ echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then -+ : -+ else -+ can_build_shared=no -+ fi -+ ;; -+ esac -+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct -+ # soname into executable. Probably we can add versioning support to -+ # collect2, so additional links can be useful in future. -+ if test "$aix_use_runtimelinking" = yes; then -+ # If using run time linking (on AIX 4.2 or later) use lib.so -+ # instead of lib.a to let people know that these are not -+ # typical AIX shared libraries. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ else -+ # We preserve .a as extension for shared libraries through AIX4.2 -+ # and later when we are not doing run time linking. -+ library_names_spec='${libname}${release}.a $libname.a' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ fi -+ shlibpath_var=LIBPATH -+ fi -+ ;; -+ -+amigaos*) -+ library_names_spec='$libname.ixlibrary $libname.a' -+ # Create ${libname}_ixlibrary.a entries in /sys/libs. -+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' -+ ;; -+ -+beos*) -+ library_names_spec='${libname}${shared_ext}' -+ dynamic_linker="$host_os ld.so" -+ shlibpath_var=LIBRARY_PATH -+ ;; -+ -+bsdi[45]*) -+ version_type=linux -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -+ # the default ld.so.conf also contains /usr/contrib/lib and -+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -+ # libtool to hard-code these into programs -+ ;; -+ -+cygwin* | mingw* | pw32*) -+ version_type=windows -+ shrext_cmds=".dll" -+ need_version=no -+ need_lib_prefix=no -+ -+ case $GCC,$host_os in -+ yes,cygwin* | yes,mingw* | yes,pw32*) -+ library_names_spec='$libname.dll.a' -+ # DLL is installed to $(libdir)/../bin by postinstall_cmds -+ postinstall_cmds='base_file=`basename \${file}`~ -+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ -+ dldir=$destdir/`dirname \$dlpath`~ -+ test -d \$dldir || mkdir -p \$dldir~ -+ $install_prog $dir/$dlname \$dldir/$dlname~ -+ chmod a+x \$dldir/$dlname' -+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ -+ dlpath=$dir/\$dldll~ -+ $rm \$dlpath' -+ shlibpath_overrides_runpath=yes -+ -+ case $host_os in -+ cygwin*) -+ # Cygwin DLLs use 'cyg' prefix rather than 'lib' -+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" -+ ;; -+ mingw*) -+ # MinGW DLLs use traditional 'lib' prefix -+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` -+ if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then -+ # It is most probably a Windows format PATH printed by -+ # mingw gcc, but we are running on Cygwin. Gcc prints its search -+ # path with ; separators, and with drive letters. We can handle the -+ # drive letters (cygwin fileutils understands them), so leave them, -+ # especially as we might pass files found there to a mingw objdump, -+ # which wouldn't understand a cygwinified path. Ahh. -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` -+ else -+ sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` -+ fi -+ ;; -+ pw32*) -+ # pw32 DLLs use 'pw' prefix rather than 'lib' -+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' -+ ;; -+ esac -+ ;; -+ -+ *) -+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' -+ ;; -+ esac -+ dynamic_linker='Win32 ld.exe' -+ # FIXME: first we should search . and the directory the executable is in -+ shlibpath_var=PATH -+ ;; -+ -+darwin* | rhapsody*) -+ dynamic_linker="$host_os dyld" -+ version_type=darwin -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' -+ soname_spec='${libname}${release}${major}$shared_ext' -+ shlibpath_overrides_runpath=yes -+ shlibpath_var=DYLD_LIBRARY_PATH -+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -+ # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. -+ if test "$GCC" = yes; then -+ sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` -+ else -+ sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' -+ fi -+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' -+ ;; -+ -+dgux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+freebsd1*) -+ dynamic_linker=no -+ ;; -+ -+kfreebsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+freebsd* | dragonfly*) -+ # DragonFly does not have aout. When/if they implement a new -+ # versioning mechanism, adjust this. -+ if test -x /usr/bin/objformat; then -+ objformat=`/usr/bin/objformat` -+ else -+ case $host_os in -+ freebsd[123]*) objformat=aout ;; -+ *) objformat=elf ;; -+ esac -+ fi -+ version_type=freebsd-$objformat -+ case $version_type in -+ freebsd-elf*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' -+ need_version=no -+ need_lib_prefix=no -+ ;; -+ freebsd-*) -+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' -+ need_version=yes -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_os in -+ freebsd2*) -+ shlibpath_overrides_runpath=yes -+ ;; -+ freebsd3.[01]* | freebsdelf3.[01]*) -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ *) # from 3.2 on -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ ;; -+ esac -+ ;; -+ -+gnu*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ hardcode_into_libs=yes -+ ;; -+ -+hpux9* | hpux10* | hpux11*) -+ # Give a soname corresponding to the major version so that dld.sl refuses to -+ # link against other versions. -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ case $host_cpu in -+ ia64*) -+ shrext_cmds='.so' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.so" -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ if test "X$HPUX_IA64_MODE" = X32; then -+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" -+ else -+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" -+ fi -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ hppa*64*) -+ shrext_cmds='.sl' -+ hardcode_into_libs=yes -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH -+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" -+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec -+ ;; -+ *) -+ shrext_cmds='.sl' -+ dynamic_linker="$host_os dld.sl" -+ shlibpath_var=SHLIB_PATH -+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ ;; -+ esac -+ # HP-UX runs *really* slowly unless shared libraries are mode 555. -+ postinstall_cmds='chmod 555 $lib' -+ ;; -+ -+irix5* | irix6* | nonstopux*) -+ case $host_os in -+ nonstopux*) version_type=nonstopux ;; -+ *) -+ if test "$lt_cv_prog_gnu_ld" = yes; then -+ version_type=linux -+ else -+ version_type=irix -+ fi ;; -+ esac -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' -+ case $host_os in -+ irix5* | nonstopux*) -+ libsuff= shlibsuff= -+ ;; -+ *) -+ case $LD in # libtool.m4 will add one of these switches to LD -+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") -+ libsuff= shlibsuff= libmagic=32-bit;; -+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") -+ libsuff=32 shlibsuff=N32 libmagic=N32;; -+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") -+ libsuff=64 shlibsuff=64 libmagic=64-bit;; -+ *) libsuff= shlibsuff= libmagic=never-match;; -+ esac -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -+ hardcode_into_libs=yes -+ ;; -+ -+# No shared lib support for Linux oldld, aout, or coff. -+linux*oldld* | linux*aout* | linux*coff*) -+ dynamic_linker=no -+ ;; -+ -+# This must be Linux ELF. -+linux*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ # This implies no fast_install, which is unacceptable. -+ # Some rework will be needed to allow for fast_install -+ # before this can be enabled. -+ hardcode_into_libs=yes -+ -+ # Append ld.so.conf contents to the search path -+ if test -f /etc/ld.so.conf; then -+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` -+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" -+ fi -+ -+ # We used to test for /lib/ld.so.1 and disable shared libraries on -+ # powerpc, because MkLinux only supported shared libraries with the -+ # GNU dynamic linker. Since this was broken with cross compilers, -+ # most powerpc-linux boxes support dynamic linking these days and -+ # people can always --disable-shared, the test was removed, and we -+ # assume the GNU/Linux dynamic linker is in use. -+ dynamic_linker='GNU/Linux ld.so' -+ ;; -+ -+netbsdelf*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='NetBSD ld.elf_so' -+ ;; -+ -+knetbsd*-gnu) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ dynamic_linker='GNU ld.so' -+ ;; -+ -+netbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ need_version=no -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ dynamic_linker='NetBSD (a.out) ld.so' -+ else -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ dynamic_linker='NetBSD ld.elf_so' -+ fi -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ ;; -+ -+newsos6) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+nto-qnx*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ ;; -+ -+openbsd*) -+ version_type=sunos -+ need_lib_prefix=no -+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. -+ case $host_os in -+ openbsd3.3 | openbsd3.3.*) need_version=yes ;; -+ *) need_version=no ;; -+ esac -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -+ case $host_os in -+ openbsd2.[89] | openbsd2.[89].*) -+ shlibpath_overrides_runpath=no -+ ;; -+ *) -+ shlibpath_overrides_runpath=yes -+ ;; -+ esac -+ else -+ shlibpath_overrides_runpath=yes -+ fi -+ ;; -+ -+os2*) -+ libname_spec='$name' -+ shrext_cmds=".dll" -+ need_lib_prefix=no -+ library_names_spec='$libname${shared_ext} $libname.a' -+ dynamic_linker='OS/2 ld.exe' -+ shlibpath_var=LIBPATH -+ ;; -+ -+osf3* | osf4* | osf5*) -+ version_type=osf -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -+ ;; -+ -+sco3.2v5*) -+ version_type=osf -+ soname_spec='${libname}${release}${shared_ext}$major' -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+solaris*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ hardcode_into_libs=yes -+ # ldd complains unless libraries are executable -+ postinstall_cmds='chmod +x $lib' -+ ;; -+ -+sunos4*) -+ version_type=sunos -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' -+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ fi -+ need_version=yes -+ ;; -+ -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ case $host_vendor in -+ sni) -+ shlibpath_overrides_runpath=no -+ need_lib_prefix=no -+ export_dynamic_flag_spec='${wl}-Blargedynsym' -+ runpath_var=LD_RUN_PATH -+ ;; -+ siemens) -+ need_lib_prefix=no -+ ;; -+ motorola) -+ need_lib_prefix=no -+ need_version=no -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -+ ;; -+ esac -+ ;; -+ -+sysv4*MP*) -+ if test -d /usr/nec ;then -+ version_type=linux -+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' -+ soname_spec='$libname${shared_ext}.$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ fi -+ ;; -+ -+uts4*) -+ version_type=linux -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+*) -+ dynamic_linker=no -+ ;; -+esac -+echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -+echo "${ECHO_T}$dynamic_linker" >&6 -+test "$dynamic_linker" = no && can_build_shared=no -+ -+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -+hardcode_action_GCJ= -+if test -n "$hardcode_libdir_flag_spec_GCJ" || \ -+ test -n "$runpath_var_GCJ" || \ -+ test "X$hardcode_automatic_GCJ" = "Xyes" ; then -+ -+ # We can hardcode non-existant directories. -+ if test "$hardcode_direct_GCJ" != no && -+ # If the only mechanism to avoid hardcoding is shlibpath_var, we -+ # have to relink, otherwise we might link with an installed library -+ # when we should be linking with a yet-to-be-installed one -+ ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && -+ test "$hardcode_minus_L_GCJ" != no; then -+ # Linking always hardcodes the temporary library directory. -+ hardcode_action_GCJ=relink -+ else -+ # We can link without hardcoding, and we can hardcode nonexisting dirs. -+ hardcode_action_GCJ=immediate -+ fi -+else -+ # We cannot hardcode anything, or else we can only hardcode existing -+ # directories. -+ hardcode_action_GCJ=unsupported -+fi -+echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 -+echo "${ECHO_T}$hardcode_action_GCJ" >&6 -+ -+if test "$hardcode_action_GCJ" = relink; then -+ # Fast installation is not supported -+ enable_fast_install=no -+elif test "$shlibpath_overrides_runpath" = yes || -+ test "$enable_shared" = no; then -+ # Fast installation is not necessary -+ enable_fast_install=needless -+fi -+ -+striplib= -+old_striplib= -+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then -+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" -+ test -z "$striplib" && striplib="$STRIP --strip-unneeded" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+else -+# FIXME - insert some real tests, host_os isn't really good enough -+ case $host_os in -+ darwin*) -+ if test -n "$STRIP" ; then -+ striplib="$STRIP -x" -+ echo "$as_me:$LINENO: result: yes" >&5 -+echo "${ECHO_T}yes" >&6 -+ else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ ;; -+ *) -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+ ;; -+ esac -+fi -+ -+if test "x$enable_dlopen" != xyes; then -+ enable_dlopen=unknown -+ enable_dlopen_self=unknown -+ enable_dlopen_self_static=unknown -+else -+ lt_cv_dlopen=no -+ lt_cv_dlopen_libs= -+ -+ case $host_os in -+ beos*) -+ lt_cv_dlopen="load_add_on" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ ;; -+ -+ mingw* | pw32*) -+ lt_cv_dlopen="LoadLibrary" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ cygwin*) -+ lt_cv_dlopen="dlopen" -+ lt_cv_dlopen_libs= -+ ;; -+ -+ darwin*) -+ # if libdl is installed we need to link against it -+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -+if test "${ac_cv_lib_dl_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldl $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dl_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dl_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -+if test $ac_cv_lib_dl_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ -+ lt_cv_dlopen="dyld" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ -+fi -+ -+ ;; -+ -+ *) -+ echo "$as_me:$LINENO: checking for shl_load" >&5 -+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -+if test "${ac_cv_func_shl_load+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define shl_load to an innocuous variant, in case declares shl_load. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define shl_load innocuous_shl_load -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char shl_load (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef shl_load -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char shl_load (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_shl_load) || defined (__stub___shl_load) -+choke me -+#else -+char (*f) () = shl_load; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != shl_load; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_shl_load=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_func_shl_load=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -+echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -+if test $ac_cv_func_shl_load = yes; then -+ lt_cv_dlopen="shl_load" -+else -+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -+if test "${ac_cv_lib_dld_shl_load+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char shl_load (); -+int -+main () -+{ -+shl_load (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dld_shl_load=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dld_shl_load=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -+if test $ac_cv_lib_dld_shl_load = yes; then -+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -+else -+ echo "$as_me:$LINENO: checking for dlopen" >&5 -+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -+if test "${ac_cv_func_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define dlopen to an innocuous variant, in case declares dlopen. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define dlopen innocuous_dlopen -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char dlopen (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef dlopen -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_dlopen) || defined (__stub___dlopen) -+choke me -+#else -+char (*f) () = dlopen; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != dlopen; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_func_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -+if test $ac_cv_func_dlopen = yes; then -+ lt_cv_dlopen="dlopen" -+else -+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -+if test "${ac_cv_lib_dl_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldl $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dl_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dl_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -+if test $ac_cv_lib_dl_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -+if test "${ac_cv_lib_svld_dlopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lsvld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dlopen (); -+int -+main () -+{ -+dlopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_svld_dlopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_svld_dlopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -+if test $ac_cv_lib_svld_dlopen = yes; then -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -+else -+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -+if test "${ac_cv_lib_dld_dld_link+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ldld $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char dld_link (); -+int -+main () -+{ -+dld_link (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_dld_dld_link=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_dld_dld_link=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -+if test $ac_cv_lib_dld_dld_link = yes; then -+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ ;; -+ esac -+ -+ if test "x$lt_cv_dlopen" != xno; then -+ enable_dlopen=yes -+ else -+ enable_dlopen=no -+ fi -+ -+ case $lt_cv_dlopen in -+ dlopen) -+ save_CPPFLAGS="$CPPFLAGS" -+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -+ -+ save_LDFLAGS="$LDFLAGS" -+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -+ -+ save_LIBS="$LIBS" -+ LIBS="$lt_cv_dlopen_libs $LIBS" -+ -+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -+if test "${lt_cv_dlopen_self+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ lt_cv_dlopen_self=cross -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+} -+EOF -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&5 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; -+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; -+ x$lt_unknown|x*) lt_cv_dlopen_self=no ;; -+ esac -+ else : -+ # compilation failed -+ lt_cv_dlopen_self=no -+ fi -+fi -+rm -fr conftest* -+ -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -+echo "${ECHO_T}$lt_cv_dlopen_self" >&6 -+ -+ if test "x$lt_cv_dlopen_self" = xyes; then -+ LDFLAGS="$LDFLAGS $link_static_flag" -+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -+if test "${lt_cv_dlopen_self_static+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ lt_cv_dlopen_self_static=cross -+else -+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -+ lt_status=$lt_dlunknown -+ cat > conftest.$ac_ext < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LT_DLGLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LT_DLGLOBAL DL_GLOBAL -+# else -+# define LT_DLGLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LT_DLLAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LT_DLLAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LT_DLLAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LT_DLLAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LT_DLLAZY_OR_NOW DL_NOW -+# else -+# define LT_DLLAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+#ifdef __cplusplus -+extern "C" void exit (int); -+#endif -+ -+void fnord() { int i=42;} -+int main () -+{ -+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -+ int status = $lt_dlunknown; -+ -+ if (self) -+ { -+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -+ /* dlclose (self); */ -+ } -+ -+ exit (status); -+} -+EOF -+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -+ (./conftest; exit; ) >&5 2>/dev/null -+ lt_status=$? -+ case x$lt_status in -+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; -+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; -+ x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; -+ esac -+ else : -+ # compilation failed -+ lt_cv_dlopen_self_static=no -+ fi -+fi -+rm -fr conftest* -+ -+ -+fi -+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 -+ fi -+ -+ CPPFLAGS="$save_CPPFLAGS" -+ LDFLAGS="$save_LDFLAGS" -+ LIBS="$save_LIBS" - ;; -- yes,pw32*) -- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/./-/g'`${versuffix}.dll' -+ esac -+ -+ case $lt_cv_dlopen_self in -+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -+ *) enable_dlopen_self=unknown ;; -+ esac -+ -+ case $lt_cv_dlopen_self_static in -+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -+ *) enable_dlopen_self_static=unknown ;; -+ esac -+fi -+ -+ -+# The else clause should only fire when bootstrapping the -+# libtool distribution, otherwise you forgot to ship ltmain.sh -+# with your package, and you will get complaints that there are -+# no rules to generate ltmain.sh. -+if test -f "$ltmain"; then -+ # See if we are running on zsh, and set the options which allow our commands through -+ # without removal of \ escapes. -+ if test -n "${ZSH_VERSION+set}" ; then -+ setopt NO_GLOB_SUBST -+ fi -+ # Now quote all the things that may contain metacharacters while being -+ # careful not to overquote the AC_SUBSTed values. We take copies of the -+ # variables and quote the copies for generation of the libtool script. -+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ -+ SED SHELL STRIP \ -+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ -+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ -+ deplibs_check_method reload_flag reload_cmds need_locks \ -+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ -+ lt_cv_sys_global_symbol_to_c_name_address \ -+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -+ old_postinstall_cmds old_postuninstall_cmds \ -+ compiler_GCJ \ -+ CC_GCJ \ -+ LD_GCJ \ -+ lt_prog_compiler_wl_GCJ \ -+ lt_prog_compiler_pic_GCJ \ -+ lt_prog_compiler_static_GCJ \ -+ lt_prog_compiler_no_builtin_flag_GCJ \ -+ export_dynamic_flag_spec_GCJ \ -+ thread_safe_flag_spec_GCJ \ -+ whole_archive_flag_spec_GCJ \ -+ enable_shared_with_static_runtimes_GCJ \ -+ old_archive_cmds_GCJ \ -+ old_archive_from_new_cmds_GCJ \ -+ predep_objects_GCJ \ -+ postdep_objects_GCJ \ -+ predeps_GCJ \ -+ postdeps_GCJ \ -+ compiler_lib_search_path_GCJ \ -+ archive_cmds_GCJ \ -+ archive_expsym_cmds_GCJ \ -+ postinstall_cmds_GCJ \ -+ postuninstall_cmds_GCJ \ -+ old_archive_from_expsyms_cmds_GCJ \ -+ allow_undefined_flag_GCJ \ -+ no_undefined_flag_GCJ \ -+ export_symbols_cmds_GCJ \ -+ hardcode_libdir_flag_spec_GCJ \ -+ hardcode_libdir_flag_spec_ld_GCJ \ -+ hardcode_libdir_separator_GCJ \ -+ hardcode_automatic_GCJ \ -+ module_cmds_GCJ \ -+ module_expsym_cmds_GCJ \ -+ lt_cv_prog_compiler_c_o_GCJ \ -+ exclude_expsyms_GCJ \ -+ include_expsyms_GCJ; do -+ -+ case $var in -+ old_archive_cmds_GCJ | \ -+ old_archive_from_new_cmds_GCJ | \ -+ archive_cmds_GCJ | \ -+ archive_expsym_cmds_GCJ | \ -+ module_cmds_GCJ | \ -+ module_expsym_cmds_GCJ | \ -+ old_archive_from_expsyms_cmds_GCJ | \ -+ export_symbols_cmds_GCJ | \ -+ extract_expsyms_cmds | reload_cmds | finish_cmds | \ -+ postinstall_cmds | postuninstall_cmds | \ -+ old_postinstall_cmds | old_postuninstall_cmds | \ -+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -+ # Double-quote double-evaled strings. -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -+ ;; -+ *) -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -+ ;; -+ esac -+ done -+ -+ case $lt_echo in -+ *'\$0 --fallback-echo"') -+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; -- *) -- library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' -+ esac -+ -+cfgfile="$ofile" -+ -+ cat <<__EOF__ >> "$cfgfile" -+# ### BEGIN LIBTOOL TAG CONFIG: $tagname -+ -+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+ -+# Shell to use when invoking shell scripts. -+SHELL=$lt_SHELL -+ -+# Whether or not to build shared libraries. -+build_libtool_libs=$enable_shared -+ -+# Whether or not to build static libraries. -+build_old_libs=$enable_static -+ -+# Whether or not to add -lc for building shared libraries. -+build_libtool_need_lc=$archive_cmds_need_lc_GCJ -+ -+# Whether or not to disallow shared libs when runtime libs are static -+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ -+ -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ -+# The host system. -+host_alias=$host_alias -+host=$host -+host_os=$host_os -+ -+# The build system. -+build_alias=$build_alias -+build=$build -+build_os=$build_os -+ -+# An echo program that does not interpret backslashes. -+echo=$lt_echo -+ -+# The archiver. -+AR=$lt_AR -+AR_FLAGS=$lt_AR_FLAGS -+ -+# A C compiler. -+LTCC=$lt_LTCC -+ -+# A language-specific compiler. -+CC=$lt_compiler_GCJ -+ -+# Is the compiler the GNU C compiler? -+with_gcc=$GCC_GCJ -+ -+# An ERE matcher. -+EGREP=$lt_EGREP -+ -+# The linker used to build libraries. -+LD=$lt_LD_GCJ -+ -+# Whether we need hard or soft links. -+LN_S=$lt_LN_S -+ -+# A BSD-compatible nm program. -+NM=$lt_NM -+ -+# A symbol stripping program -+STRIP=$lt_STRIP -+ -+# Used to examine libraries when file_magic_cmd begins "file" -+MAGIC_CMD=$MAGIC_CMD -+ -+# Used on cygwin: DLL creation program. -+DLLTOOL="$DLLTOOL" -+ -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. -+AS="$AS" -+ -+# The name of the directory that contains temporary libtool files. -+objdir=$objdir -+ -+# How to create reloadable object files. -+reload_flag=$lt_reload_flag -+reload_cmds=$lt_reload_cmds -+ -+# How to pass a linker flag through the compiler. -+wl=$lt_lt_prog_compiler_wl_GCJ -+ -+# Object file suffix (normally "o"). -+objext="$ac_objext" -+ -+# Old archive suffix (normally "a"). -+libext="$libext" -+ -+# Shared library suffix (normally ".so"). -+shrext_cmds='$shrext_cmds' -+ -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ -+# Additional compiler flags for building library objects. -+pic_flag=$lt_lt_prog_compiler_pic_GCJ -+pic_mode=$pic_mode -+ -+# What is the maximum length of a command? -+max_cmd_len=$lt_cv_sys_max_cmd_len -+ -+# Does compiler simultaneously support -c and -o options? -+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ -+ -+# Must we lock files when doing compilation? -+need_locks=$lt_need_locks -+ -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen_support=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ -+# Compiler flag to prevent dynamic linking. -+link_static_flag=$lt_lt_prog_compiler_static_GCJ -+ -+# Compiler flag to turn off builtin functions. -+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ -+ -+# Compiler flag to allow reflexive dlopens. -+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ -+ -+# Compiler flag to generate shared objects directly from archives. -+whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ -+ -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ -+ -+# Library versioning type. -+version_type=$version_type -+ -+# Format of library name prefix. -+libname_spec=$lt_libname_spec -+ -+# List of archive names. First name is the real one, the rest are links. -+# The last name is the one that the linker finds with -lNAME. -+library_names_spec=$lt_library_names_spec -+ -+# The coded name of the library, if different from the real name. -+soname_spec=$lt_soname_spec -+ -+# Commands used to build and install an old-style archive. -+RANLIB=$lt_RANLIB -+old_archive_cmds=$lt_old_archive_cmds_GCJ -+old_postinstall_cmds=$lt_old_postinstall_cmds -+old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ -+# Create an old-style archive from a shared archive. -+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ -+ -+# Create a temporary old-style archive to link instead of a shared archive. -+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ -+ -+# Commands used to build and install a shared archive. -+archive_cmds=$lt_archive_cmds_GCJ -+archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ -+postinstall_cmds=$lt_postinstall_cmds -+postuninstall_cmds=$lt_postuninstall_cmds -+ -+# Commands used to build a loadable module (assumed same as above if empty) -+module_cmds=$lt_module_cmds_GCJ -+module_expsym_cmds=$lt_module_expsym_cmds_GCJ -+ -+# Commands to strip libraries. -+old_striplib=$lt_old_striplib -+striplib=$lt_striplib -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predep_objects=$lt_predep_objects_GCJ -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdep_objects=$lt_postdep_objects_GCJ -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predeps=$lt_predeps_GCJ -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdeps=$lt_postdeps_GCJ -+ -+# The library search path used internally by the compiler when linking -+# a shared library. -+compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ -+ -+# Method to check whether dependent libraries are shared objects. -+deplibs_check_method=$lt_deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$lt_file_magic_cmd -+ -+# Flag that allows shared libraries with undefined symbols to be built. -+allow_undefined_flag=$lt_allow_undefined_flag_GCJ -+ -+# Flag that forces no undefined symbols. -+no_undefined_flag=$lt_no_undefined_flag_GCJ -+ -+# Commands used to finish a libtool library installation in a directory. -+finish_cmds=$lt_finish_cmds -+ -+# Same as above, but a single script fragment to be evaled but not shown. -+finish_eval=$lt_finish_eval -+ -+# Take the output of nm and produce a listing of raw symbols and C names. -+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe -+ -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl -+ -+# Transform the output of nm in a C name address pair -+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address -+ -+# This is the shared library runtime path variable. -+runpath_var=$runpath_var -+ -+# This is the shared library path variable. -+shlibpath_var=$shlibpath_var -+ -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+ -+# How to hardcode a shared library path into an executable. -+hardcode_action=$hardcode_action_GCJ -+ -+# Whether we should hardcode library paths into libraries. -+hardcode_into_libs=$hardcode_into_libs -+ -+# Flag to hardcode \$libdir into a binary during linking. -+# This must work even if \$libdir does not exist. -+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ -+ -+# If ld is used when linking, flag to hardcode \$libdir into -+# a binary during linking. This must work even if \$libdir does -+# not exist. -+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ -+ -+# Whether we need a single -rpath flag with a separated argument. -+hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ -+ -+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -+# resulting binary. -+hardcode_direct=$hardcode_direct_GCJ -+ -+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -+# resulting binary. -+hardcode_minus_L=$hardcode_minus_L_GCJ -+ -+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -+# the resulting binary. -+hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ -+ -+# Set to yes if building a shared library automatically hardcodes DIR into the library -+# and all subsequent libraries and executables linked against it. -+hardcode_automatic=$hardcode_automatic_GCJ -+ -+# Variables whose values should be saved in libtool wrapper scripts and -+# restored at relink time. -+variables_saved_for_relink="$variables_saved_for_relink" -+ -+# Whether libtool must link a program against all its dependency libraries. -+link_all_deplibs=$link_all_deplibs_GCJ -+ -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ -+# Fix the shell variable \$srcfile for the compiler. -+fix_srcfile_path="$fix_srcfile_path_GCJ" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$always_export_symbols_GCJ -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$lt_export_symbols_cmds_GCJ -+ -+# The commands to extract the exported symbol list from a shared archive. -+extract_expsyms_cmds=$lt_extract_expsyms_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$lt_exclude_expsyms_GCJ -+ -+# Symbols that must always be exported. -+include_expsyms=$lt_include_expsyms_GCJ -+ -+# ### END LIBTOOL TAG CONFIG: $tagname -+ -+__EOF__ -+ -+ -+else -+ # If there is no Makefile yet, we rely on a make rule to execute -+ # `config.status --recheck' to rerun these tests and create the -+ # libtool script then. -+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` -+ if test -f "$ltmain_in"; then -+ test -f Makefile && make "$ltmain" -+ fi -+fi -+ -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+CC="$lt_save_CC" -+ -+ else -+ tagname="" -+ fi -+ ;; -+ -+ RC) -+ -+ -+ -+# Source file extension for RC test sources. -+ac_ext=rc -+ -+# Object file extension for compiled RC test sources. -+objext=o -+objext_RC=$objext -+ -+# Code to be used in simple compile tests -+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' -+ -+# Code to be used in simple link tests -+lt_simple_link_test_code="$lt_simple_compile_test_code" -+ -+# ltmain only uses $CC for tagged configurations so make sure $CC is set. -+ -+# If no C compiler was specified, use CC. -+LTCC=${LTCC-"$CC"} -+ -+# Allow CC to be a program name with arguments. -+compiler=$CC -+ -+ -+# save warnings/boilerplate of simple test code -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_compile_test_code" >conftest.$ac_ext -+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_compiler_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ac_outfile=conftest.$ac_objext -+printf "$lt_simple_link_test_code" >conftest.$ac_ext -+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err -+_lt_linker_boilerplate=`cat conftest.err` -+$rm conftest* -+ -+ -+# Allow CC to be a program name with arguments. -+lt_save_CC="$CC" -+CC=${RC-"windres"} -+compiler=$CC -+compiler_RC=$CC -+for cc_temp in $compiler""; do -+ case $cc_temp in -+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; -+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; -+ \-*) ;; -+ *) break;; -+ esac -+done -+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -+ -+lt_cv_prog_compiler_c_o_RC=yes -+ -+# The else clause should only fire when bootstrapping the -+# libtool distribution, otherwise you forgot to ship ltmain.sh -+# with your package, and you will get complaints that there are -+# no rules to generate ltmain.sh. -+if test -f "$ltmain"; then -+ # See if we are running on zsh, and set the options which allow our commands through -+ # without removal of \ escapes. -+ if test -n "${ZSH_VERSION+set}" ; then -+ setopt NO_GLOB_SUBST -+ fi -+ # Now quote all the things that may contain metacharacters while being -+ # careful not to overquote the AC_SUBSTed values. We take copies of the -+ # variables and quote the copies for generation of the libtool script. -+ for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ -+ SED SHELL STRIP \ -+ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ -+ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ -+ deplibs_check_method reload_flag reload_cmds need_locks \ -+ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ -+ lt_cv_sys_global_symbol_to_c_name_address \ -+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -+ old_postinstall_cmds old_postuninstall_cmds \ -+ compiler_RC \ -+ CC_RC \ -+ LD_RC \ -+ lt_prog_compiler_wl_RC \ -+ lt_prog_compiler_pic_RC \ -+ lt_prog_compiler_static_RC \ -+ lt_prog_compiler_no_builtin_flag_RC \ -+ export_dynamic_flag_spec_RC \ -+ thread_safe_flag_spec_RC \ -+ whole_archive_flag_spec_RC \ -+ enable_shared_with_static_runtimes_RC \ -+ old_archive_cmds_RC \ -+ old_archive_from_new_cmds_RC \ -+ predep_objects_RC \ -+ postdep_objects_RC \ -+ predeps_RC \ -+ postdeps_RC \ -+ compiler_lib_search_path_RC \ -+ archive_cmds_RC \ -+ archive_expsym_cmds_RC \ -+ postinstall_cmds_RC \ -+ postuninstall_cmds_RC \ -+ old_archive_from_expsyms_cmds_RC \ -+ allow_undefined_flag_RC \ -+ no_undefined_flag_RC \ -+ export_symbols_cmds_RC \ -+ hardcode_libdir_flag_spec_RC \ -+ hardcode_libdir_flag_spec_ld_RC \ -+ hardcode_libdir_separator_RC \ -+ hardcode_automatic_RC \ -+ module_cmds_RC \ -+ module_expsym_cmds_RC \ -+ lt_cv_prog_compiler_c_o_RC \ -+ exclude_expsyms_RC \ -+ include_expsyms_RC; do -+ -+ case $var in -+ old_archive_cmds_RC | \ -+ old_archive_from_new_cmds_RC | \ -+ archive_cmds_RC | \ -+ archive_expsym_cmds_RC | \ -+ module_cmds_RC | \ -+ module_expsym_cmds_RC | \ -+ old_archive_from_expsyms_cmds_RC | \ -+ export_symbols_cmds_RC | \ -+ extract_expsyms_cmds | reload_cmds | finish_cmds | \ -+ postinstall_cmds | postuninstall_cmds | \ -+ old_postinstall_cmds | old_postuninstall_cmds | \ -+ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -+ # Double-quote double-evaled strings. -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -+ ;; -+ *) -+ eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -+ ;; -+ esac -+ done -+ -+ case $lt_echo in -+ *'\$0 --fallback-echo"') -+ lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac -- dynamic_linker='Win32 ld.exe' -- # FIXME: first we should search . and the directory the executable is in -- shlibpath_var=PATH -- ;; - --darwin* | rhapsody*) -- dynamic_linker="$host_os dyld" -- version_type=darwin -- need_lib_prefix=no -- need_version=no -- # FIXME: Relying on posixy $() will cause problems for -- # cross-compilation, but unfortunately the echo tests do not -- # yet detect zsh echo's removal of \ escapes. -- library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' -- soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' -- shlibpath_overrides_runpath=yes -- shlibpath_var=DYLD_LIBRARY_PATH -- ;; -+cfgfile="$ofile" -+ -+ cat <<__EOF__ >> "$cfgfile" -+# ### BEGIN LIBTOOL TAG CONFIG: $tagname -+ -+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+ -+# Shell to use when invoking shell scripts. -+SHELL=$lt_SHELL -+ -+# Whether or not to build shared libraries. -+build_libtool_libs=$enable_shared -+ -+# Whether or not to build static libraries. -+build_old_libs=$enable_static -+ -+# Whether or not to add -lc for building shared libraries. -+build_libtool_need_lc=$archive_cmds_need_lc_RC -+ -+# Whether or not to disallow shared libs when runtime libs are static -+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC -+ -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ -+# The host system. -+host_alias=$host_alias -+host=$host -+host_os=$host_os -+ -+# The build system. -+build_alias=$build_alias -+build=$build -+build_os=$build_os -+ -+# An echo program that does not interpret backslashes. -+echo=$lt_echo -+ -+# The archiver. -+AR=$lt_AR -+AR_FLAGS=$lt_AR_FLAGS -+ -+# A C compiler. -+LTCC=$lt_LTCC -+ -+# A language-specific compiler. -+CC=$lt_compiler_RC -+ -+# Is the compiler the GNU C compiler? -+with_gcc=$GCC_RC -+ -+# An ERE matcher. -+EGREP=$lt_EGREP -+ -+# The linker used to build libraries. -+LD=$lt_LD_RC -+ -+# Whether we need hard or soft links. -+LN_S=$lt_LN_S -+ -+# A BSD-compatible nm program. -+NM=$lt_NM -+ -+# A symbol stripping program -+STRIP=$lt_STRIP -+ -+# Used to examine libraries when file_magic_cmd begins "file" -+MAGIC_CMD=$MAGIC_CMD -+ -+# Used on cygwin: DLL creation program. -+DLLTOOL="$DLLTOOL" -+ -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. -+AS="$AS" -+ -+# The name of the directory that contains temporary libtool files. -+objdir=$objdir -+ -+# How to create reloadable object files. -+reload_flag=$lt_reload_flag -+reload_cmds=$lt_reload_cmds -+ -+# How to pass a linker flag through the compiler. -+wl=$lt_lt_prog_compiler_wl_RC -+ -+# Object file suffix (normally "o"). -+objext="$ac_objext" -+ -+# Old archive suffix (normally "a"). -+libext="$libext" -+ -+# Shared library suffix (normally ".so"). -+shrext_cmds='$shrext_cmds' -+ -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ -+# Additional compiler flags for building library objects. -+pic_flag=$lt_lt_prog_compiler_pic_RC -+pic_mode=$pic_mode -+ -+# What is the maximum length of a command? -+max_cmd_len=$lt_cv_sys_max_cmd_len -+ -+# Does compiler simultaneously support -c and -o options? -+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC -+ -+# Must we lock files when doing compilation? -+need_locks=$lt_need_locks -+ -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen_support=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ -+# Compiler flag to prevent dynamic linking. -+link_static_flag=$lt_lt_prog_compiler_static_RC -+ -+# Compiler flag to turn off builtin functions. -+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC -+ -+# Compiler flag to allow reflexive dlopens. -+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC -+ -+# Compiler flag to generate shared objects directly from archives. -+whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC -+ -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC -+ -+# Library versioning type. -+version_type=$version_type -+ -+# Format of library name prefix. -+libname_spec=$lt_libname_spec -+ -+# List of archive names. First name is the real one, the rest are links. -+# The last name is the one that the linker finds with -lNAME. -+library_names_spec=$lt_library_names_spec -+ -+# The coded name of the library, if different from the real name. -+soname_spec=$lt_soname_spec -+ -+# Commands used to build and install an old-style archive. -+RANLIB=$lt_RANLIB -+old_archive_cmds=$lt_old_archive_cmds_RC -+old_postinstall_cmds=$lt_old_postinstall_cmds -+old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ -+# Create an old-style archive from a shared archive. -+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC -+ -+# Create a temporary old-style archive to link instead of a shared archive. -+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC -+ -+# Commands used to build and install a shared archive. -+archive_cmds=$lt_archive_cmds_RC -+archive_expsym_cmds=$lt_archive_expsym_cmds_RC -+postinstall_cmds=$lt_postinstall_cmds -+postuninstall_cmds=$lt_postuninstall_cmds -+ -+# Commands used to build a loadable module (assumed same as above if empty) -+module_cmds=$lt_module_cmds_RC -+module_expsym_cmds=$lt_module_expsym_cmds_RC -+ -+# Commands to strip libraries. -+old_striplib=$lt_old_striplib -+striplib=$lt_striplib -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predep_objects=$lt_predep_objects_RC -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdep_objects=$lt_postdep_objects_RC -+ -+# Dependencies to place before the objects being linked to create a -+# shared library. -+predeps=$lt_predeps_RC -+ -+# Dependencies to place after the objects being linked to create a -+# shared library. -+postdeps=$lt_postdeps_RC -+ -+# The library search path used internally by the compiler when linking -+# a shared library. -+compiler_lib_search_path=$lt_compiler_lib_search_path_RC -+ -+# Method to check whether dependent libraries are shared objects. -+deplibs_check_method=$lt_deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$lt_file_magic_cmd -+ -+# Flag that allows shared libraries with undefined symbols to be built. -+allow_undefined_flag=$lt_allow_undefined_flag_RC -+ -+# Flag that forces no undefined symbols. -+no_undefined_flag=$lt_no_undefined_flag_RC -+ -+# Commands used to finish a libtool library installation in a directory. -+finish_cmds=$lt_finish_cmds -+ -+# Same as above, but a single script fragment to be evaled but not shown. -+finish_eval=$lt_finish_eval -+ -+# Take the output of nm and produce a listing of raw symbols and C names. -+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe -+ -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl -+ -+# Transform the output of nm in a C name address pair -+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - --freebsd1*) -- dynamic_linker=no -- ;; -+# This is the shared library runtime path variable. -+runpath_var=$runpath_var - --freebsd*) -- objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` -- version_type=freebsd-$objformat -- case $version_type in -- freebsd-elf*) -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' -- need_version=no -- need_lib_prefix=no -- ;; -- freebsd-*) -- library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' -- need_version=yes -- ;; -- esac -- shlibpath_var=LD_LIBRARY_PATH -- case $host_os in -- freebsd2*) -- shlibpath_overrides_runpath=yes -- ;; -- *) -- shlibpath_overrides_runpath=no -- hardcode_into_libs=yes -- ;; -- esac -- ;; -+# This is the shared library path variable. -+shlibpath_var=$shlibpath_var - --gnu*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- hardcode_into_libs=yes -- ;; -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath - --hpux9* | hpux10* | hpux11*) -- # Give a soname corresponding to the major version so that dld.sl refuses to -- # link against other versions. -- dynamic_linker="$host_os dld.sl" -- version_type=sunos -- need_lib_prefix=no -- need_version=no -- shlibpath_var=SHLIB_PATH -- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH -- library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' -- soname_spec='${libname}${release}.sl$major' -- # HP-UX runs *really* slowly unless shared libraries are mode 555. -- postinstall_cmds='chmod 555 $lib' -- ;; -+# How to hardcode a shared library path into an executable. -+hardcode_action=$hardcode_action_RC - --irix5* | irix6*) -- version_type=irix -- need_lib_prefix=no -- need_version=no -- soname_spec='${libname}${release}.so$major' -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' -- case $host_os in -- irix5*) -- libsuff= shlibsuff= -- ;; -- *) -- case $LD in # libtool.m4 will add one of these switches to LD -- *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; -- *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; -- *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; -- *) libsuff= shlibsuff= libmagic=never-match;; -- esac -- ;; -- esac -- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -- shlibpath_overrides_runpath=no -- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -- ;; -+# Whether we should hardcode library paths into libraries. -+hardcode_into_libs=$hardcode_into_libs - --# No shared lib support for Linux oldld, aout, or coff. --linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) -- dynamic_linker=no -- ;; -+# Flag to hardcode \$libdir into a binary during linking. -+# This must work even if \$libdir does not exist. -+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC - --# This must be Linux ELF. --linux-gnu*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=no -- # This implies no fast_install, which is unacceptable. -- # Some rework will be needed to allow for fast_install -- # before this can be enabled. -- hardcode_into_libs=yes -+# If ld is used when linking, flag to hardcode \$libdir into -+# a binary during linking. This must work even if \$libdir does -+# not exist. -+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC - -- # We used to test for /lib/ld.so.1 and disable shared libraries on -- # powerpc, because MkLinux only supported shared libraries with the -- # GNU dynamic linker. Since this was broken with cross compilers, -- # most powerpc-linux boxes support dynamic linking these days and -- # people can always --disable-shared, the test was removed, and we -- # assume the GNU/Linux dynamic linker is in use. -- dynamic_linker='GNU/Linux ld.so' -- ;; -+# Whether we need a single -rpath flag with a separated argument. -+hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC - --netbsd*) -- version_type=sunos -- need_lib_prefix=no -- need_version=no -- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -- dynamic_linker='NetBSD (a.out) ld.so' -- else -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' -- soname_spec='${libname}${release}.so$major' -- dynamic_linker='NetBSD ld.elf_so' -+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -+# resulting binary. -+hardcode_direct=$hardcode_direct_RC -+ -+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -+# resulting binary. -+hardcode_minus_L=$hardcode_minus_L_RC -+ -+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -+# the resulting binary. -+hardcode_shlibpath_var=$hardcode_shlibpath_var_RC -+ -+# Set to yes if building a shared library automatically hardcodes DIR into the library -+# and all subsequent libraries and executables linked against it. -+hardcode_automatic=$hardcode_automatic_RC -+ -+# Variables whose values should be saved in libtool wrapper scripts and -+# restored at relink time. -+variables_saved_for_relink="$variables_saved_for_relink" -+ -+# Whether libtool must link a program against all its dependency libraries. -+link_all_deplibs=$link_all_deplibs_RC -+ -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ -+# Fix the shell variable \$srcfile for the compiler. -+fix_srcfile_path="$fix_srcfile_path_RC" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$always_export_symbols_RC -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$lt_export_symbols_cmds_RC -+ -+# The commands to extract the exported symbol list from a shared archive. -+extract_expsyms_cmds=$lt_extract_expsyms_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$lt_exclude_expsyms_RC -+ -+# Symbols that must always be exported. -+include_expsyms=$lt_include_expsyms_RC -+ -+# ### END LIBTOOL TAG CONFIG: $tagname -+ -+__EOF__ -+ -+ -+else -+ # If there is no Makefile yet, we rely on a make rule to execute -+ # `config.status --recheck' to rerun these tests and create the -+ # libtool script then. -+ ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` -+ if test -f "$ltmain_in"; then -+ test -f Makefile && make "$ltmain" - fi -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- hardcode_into_libs=yes -- ;; -+fi - --newsos6) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- ;; - --openbsd*) -- version_type=sunos -- need_lib_prefix=no -- need_version=no -- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then -- case "$host_os" in -- openbsd2.[89] | openbsd2.[89].*) -- shlibpath_overrides_runpath=no -- ;; -- *) -- shlibpath_overrides_runpath=yes -- ;; -- esac -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+CC="$lt_save_CC" -+ -+ ;; -+ -+ *) -+ { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 -+echo "$as_me: error: Unsupported tag name: $tagname" >&2;} -+ { (exit 1); exit 1; }; } -+ ;; -+ esac -+ -+ # Append the new tag name to the list of available tags. -+ if test -n "$tagname" ; then -+ available_tags="$available_tags $tagname" -+ fi -+ fi -+ done -+ IFS="$lt_save_ifs" -+ -+ # Now substitute the updated list of available tags. -+ if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then -+ mv "${ofile}T" "$ofile" -+ chmod +x "$ofile" - else -- shlibpath_overrides_runpath=yes -+ rm -f "${ofile}T" -+ { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 -+echo "$as_me: error: unable to update list of available tagged configurations." >&2;} -+ { (exit 1); exit 1; }; } - fi -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- ;; -+fi -+ -+ -+ -+# This can be used to rebuild libtool when needed -+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" -+ -+# Always use our own libtool. -+LIBTOOL='$(SHELL) $(top_builddir)/libtool' -+ -+# Prevent multiple expansion - --os2*) -- libname_spec='$name' -- need_lib_prefix=no -- library_names_spec='$libname.dll $libname.a' -- dynamic_linker='OS/2 ld.exe' -- shlibpath_var=LIBPATH -- ;; - --osf3* | osf4* | osf5*) -- version_type=osf -- need_version=no -- soname_spec='${libname}${release}.so' -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -- ;; - --sco3.2v5*) -- version_type=osf -- soname_spec='${libname}${release}.so$major' -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- ;; - --solaris*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- hardcode_into_libs=yes -- # ldd complains unless libraries are executable -- postinstall_cmds='chmod +x $lib' -- ;; - --sunos4*) -- version_type=sunos -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' -- shlibpath_var=LD_LIBRARY_PATH -- shlibpath_overrides_runpath=yes -- if test "$with_gnu_ld" = yes; then -- need_lib_prefix=no -- fi -- need_version=yes -- ;; - --sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- case $host_vendor in -- sni) -- shlibpath_overrides_runpath=no -- ;; -- motorola) -- need_lib_prefix=no -- need_version=no -- shlibpath_overrides_runpath=no -- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -- ;; -- esac -- ;; - --uts4*) -- version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- ;; - --dgux*) -- version_type=linux -- need_lib_prefix=no -- need_version=no -- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -- soname_spec='${libname}${release}.so$major' -- shlibpath_var=LD_LIBRARY_PATH -- ;; - --sysv4*MP*) -- if test -d /usr/nec ;then -- version_type=linux -- library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' -- soname_spec='$libname.so.$major' -- shlibpath_var=LD_LIBRARY_PATH -- fi -- ;; - --*) -- dynamic_linker=no -- ;; --esac --echo "$as_me:$LINENO: result: $dynamic_linker" >&5 --echo "${ECHO_T}$dynamic_linker" >&6 --test "$dynamic_linker" = no && can_build_shared=no - --# Report the final consequences. --echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 --echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 --echo "$as_me:$LINENO: result: $can_build_shared" >&5 --echo "${ECHO_T}$can_build_shared" >&6 - --echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 --echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 --test "$can_build_shared" = "no" && enable_shared=no - --# On AIX, shared libraries and static libraries use the same namespace, and --# are all built from PIC. --case "$host_os" in --aix3*) -- test "$enable_shared" = yes && enable_static=no -- if test -n "$RANLIB"; then -- archive_cmds="$archive_cmds~\$RANLIB \$lib" -- postinstall_cmds='$RANLIB $lib' -- fi -- ;; - --aix4*) -- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then -- test "$enable_shared" = yes && enable_static=no -- fi -- ;; --esac --echo "$as_me:$LINENO: result: $enable_shared" >&5 --echo "${ECHO_T}$enable_shared" >&6 - --echo "$as_me:$LINENO: checking whether to build static libraries" >&5 --echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 --# Make sure either enable_shared or enable_static is yes. --test "$enable_shared" = yes || enable_static=yes --echo "$as_me:$LINENO: result: $enable_static" >&5 --echo "${ECHO_T}$enable_static" >&6 - --if test "$hardcode_action" = relink; then -- # Fast installation is not supported -- enable_fast_install=no --elif test "$shlibpath_overrides_runpath" = yes || -- test "$enable_shared" = no; then -- # Fast installation is not necessary -- enable_fast_install=needless --fi - --variables_saved_for_relink="PATH $shlibpath_var $runpath_var" --if test "$GCC" = yes; then -- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" --fi - --if test "x$enable_dlopen" != xyes; then -- enable_dlopen=unknown -- enable_dlopen_self=unknown -- enable_dlopen_self_static=unknown --else -- lt_cv_dlopen=no -- lt_cv_dlopen_libs= - -- case $host_os in -- beos*) -- lt_cv_dlopen="load_add_on" -- lt_cv_dlopen_libs= -- lt_cv_dlopen_self=yes -- ;; - -- cygwin* | mingw* | pw32*) -- lt_cv_dlopen="LoadLibrary" -- lt_cv_dlopen_libs= -- ;; - -- *) -- echo "$as_me:$LINENO: checking for shl_load" >&5 --echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 --if test "${ac_cv_func_shl_load+set}" = set; then -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 -+# On Suns, sometimes $CPP names a directory. -+if test -n "$CPP" && test -d "$CPP"; then -+ CPP= -+fi -+if test -z "$CPP"; then -+ if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -+ # Double quotes because CPP needs to be expanded -+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" -+ do -+ ac_preproc_ok=false -+for ac_c_preproc_warn_flag in '' yes -+do -+ # Use a header file that comes with gcc, so configuring glibc -+ # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. -+ # On the NeXT, cc -E runs the code through the compiler's parser, -+ # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --/* System header to define __stub macros and hopefully few prototypes, -- which can conflict with char shl_load (); below. */ --#include --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char shl_load (); --char (*f) (); -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --/* The GNU C library defines this for functions which it implements -- to always fail with ENOSYS. Some functions are actually named -- something starting with __ and the normal name is an alias. */ --#if defined (__stub_shl_load) || defined (__stub___shl_load) --choke me -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include - #else --f = shl_load; -+# include - #endif -- -- ; -- return 0; --} -+ Syntax error - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_func_shl_load=yes -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_func_shl_load=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+ ac_cpp_err=yes - fi --echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 --echo "${ECHO_T}$ac_cv_func_shl_load" >&6 --if test $ac_cv_func_shl_load = yes; then -- lt_cv_dlopen="shl_load" --else -- echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 --echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 --if test "${ac_cv_lib_dld_shl_load+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-ldld $LIBS" --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char shl_load (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --shl_load (); -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_lib_dld_shl_load=yes -+if test -z "$ac_cpp_err"; then -+ : - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_dld_shl_load=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS --fi --echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 --echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 --if test $ac_cv_lib_dld_shl_load = yes; then -- lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" --else -- echo "$as_me:$LINENO: checking for dlopen" >&5 --echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 --if test "${ac_cv_func_dlopen+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --/* System header to define __stub macros and hopefully few prototypes, -- which can conflict with char dlopen (); below. */ --#include --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char dlopen (); --char (*f) (); -+sed 's/^/| /' conftest.$ac_ext >&5 - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --/* The GNU C library defines this for functions which it implements -- to always fail with ENOSYS. Some functions are actually named -- something starting with __ and the normal name is an alias. */ --#if defined (__stub_dlopen) || defined (__stub___dlopen) --choke me --#else --f = dlopen; --#endif -+ # Broken: fails on valid input. -+continue -+fi -+rm -f conftest.err conftest.$ac_ext - -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+ # OK, works on sane cases. Now check whether non-existent headers -+ # can be detected and how. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_func_dlopen=yes -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ # Broken: success on invalid input. -+continue - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_func_dlopen=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ # Passes both tests. -+ac_preproc_ok=: -+break -+fi -+rm -f conftest.err conftest.$ac_ext -+ -+done -+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -+rm -f conftest.err conftest.$ac_ext -+if $ac_preproc_ok; then -+ break - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+ -+ done -+ ac_cv_prog_CPP=$CPP -+ - fi --echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 --echo "${ECHO_T}$ac_cv_func_dlopen" >&6 --if test $ac_cv_func_dlopen = yes; then -- lt_cv_dlopen="dlopen" --else -- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 --echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 --if test "${ac_cv_lib_dl_dlopen+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ CPP=$ac_cv_prog_CPP - else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-ldl $LIBS" --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char dlopen (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+ ac_cv_prog_CPP=$CPP -+fi -+echo "$as_me:$LINENO: result: $CPP" >&5 -+echo "${ECHO_T}$CPP" >&6 -+ac_preproc_ok=false -+for ac_c_preproc_warn_flag in '' yes -+do -+ # Use a header file that comes with gcc, so configuring glibc -+ # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. -+ # On the NeXT, cc -E runs the code through the compiler's parser, -+ # not just through cpp. "Syntax error" is here to catch this case. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include - #endif --int --main () --{ --dlopen (); -- ; -- return 0; --} -+ Syntax error - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_lib_dl_dlopen=yes -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_dl_dlopen=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS -+ ac_cpp_err=yes - fi --echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 --echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 --if test $ac_cv_lib_dl_dlopen = yes; then -- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" --else -- echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 --echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 --if test "${ac_cv_lib_svld_dlopen+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+if test -z "$ac_cpp_err"; then -+ : - else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-lsvld $LIBS" --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char dlopen (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --dlopen (); -- ; -- return 0; --} -+ # Broken: fails on valid input. -+continue -+fi -+rm -f conftest.err conftest.$ac_ext -+ -+ # OK, works on sane cases. Now check whether non-existent headers -+ # can be detected and how. -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_lib_svld_dlopen=yes -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_svld_dlopen=no -+ ac_cpp_err=yes - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS -+if test -z "$ac_cpp_err"; then -+ # Broken: success on invalid input. -+continue -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ # Passes both tests. -+ac_preproc_ok=: -+break - fi --echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 --echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 --if test $ac_cv_lib_svld_dlopen = yes; then -- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -+rm -f conftest.err conftest.$ac_ext -+ -+done -+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -+rm -f conftest.err conftest.$ac_ext -+if $ac_preproc_ok; then -+ : - else -- echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 --echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 --if test "${ac_cv_lib_dld_dld_link+set}" = set; then -+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -+See \`config.log' for more details." >&5 -+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } -+fi -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+ac_ext=cc -+ac_cpp='$CXXCPP $CPPFLAGS' -+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -+if test -n "$ac_tool_prefix"; then -+ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -+ do -+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -+set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-ldld $LIBS" --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char dld_link (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --dld_link (); -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_lib_dld_dld_link=yes -+ if test -n "$CXX"; then -+ ac_cv_prog_CXX="$CXX" # Let the user override the test. - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_dld_dld_link=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS --fi --echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 --echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 --if test $ac_cv_lib_dld_dld_link = yes; then -- lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" --fi -- -- --fi -- -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done - - fi -- -- - fi -- -- -+CXX=$ac_cv_prog_CXX -+if test -n "$CXX"; then -+ echo "$as_me:$LINENO: result: $CXX" >&5 -+echo "${ECHO_T}$CXX" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 - fi - -- -+ test -n "$CXX" && break -+ done - fi -- -- ;; -- esac -- -- if test "x$lt_cv_dlopen" != xno; then -- enable_dlopen=yes -- else -- enable_dlopen=no -- fi -- -- case $lt_cv_dlopen in -- dlopen) -- save_CPPFLAGS="$CPPFLAGS" -- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -- -- save_LDFLAGS="$LDFLAGS" -- eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -- -- save_LIBS="$LIBS" -- LIBS="$lt_cv_dlopen_libs $LIBS" -- -- echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 --echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 --if test "${lt_cv_dlopen_self+set}" = set; then -+if test -z "$CXX"; then -+ ac_ct_CXX=$CXX -+ for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -+do -+ # Extract the first word of "$ac_prog", so it can be a program name with args. -+set dummy $ac_prog; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test "$cross_compiling" = yes; then : -- lt_cv_dlopen_self=cross -+ if test -n "$ac_ct_CXX"; then -+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. - else -- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -- lt_status=$lt_dlunknown -- cat > conftest.$ac_ext < --#endif -- --#include -- --#ifdef RTLD_GLOBAL --# define LT_DLGLOBAL RTLD_GLOBAL --#else --# ifdef DL_GLOBAL --# define LT_DLGLOBAL DL_GLOBAL --# else --# define LT_DLGLOBAL 0 --# endif --#endif -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_CXX="$ac_prog" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done - --/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -- find out it does not work in some platform. */ --#ifndef LT_DLLAZY_OR_NOW --# ifdef RTLD_LAZY --# define LT_DLLAZY_OR_NOW RTLD_LAZY --# else --# ifdef DL_LAZY --# define LT_DLLAZY_OR_NOW DL_LAZY --# else --# ifdef RTLD_NOW --# define LT_DLLAZY_OR_NOW RTLD_NOW --# else --# ifdef DL_NOW --# define LT_DLLAZY_OR_NOW DL_NOW --# else --# define LT_DLLAZY_OR_NOW 0 --# endif --# endif --# endif --# endif --#endif -+fi -+fi -+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -+if test -n "$ac_ct_CXX"; then -+ echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -+echo "${ECHO_T}$ac_ct_CXX" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi - --#ifdef __cplusplus --extern "C" void exit (int); --#endif -+ test -n "$ac_ct_CXX" && break -+done -+test -n "$ac_ct_CXX" || ac_ct_CXX="g++" - --void fnord() { int i=42;} --int main () --{ -- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -- int status = $lt_dlunknown; -+ CXX=$ac_ct_CXX -+fi - -- if (self) -- { -- if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -- /* dlclose (self); */ -- } - -- exit (status); --} --EOF -- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+# Provide some information about the compiler. -+echo "$as_me:$LINENO:" \ -+ "checking for C++ compiler version" >&5 -+ac_compiler=`set X $ac_compile; echo $2` -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 -+ (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -- (./conftest; exit; ) 2>/dev/null -- lt_status=$? -- case x$lt_status in -- x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; -- x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; -- x$lt_unknown|x*) lt_cv_dlopen_self=no ;; -- esac -- else : -- # compilation failed -- lt_cv_dlopen_self=no -- fi --fi --rm -fr conftest* -- -- --fi --echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 --echo "${ECHO_T}$lt_cv_dlopen_self" >&6 -+ (exit $ac_status); } -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 -+ (eval $ac_compiler -v &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } -+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 -+ (eval $ac_compiler -V &5) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } - -- if test "x$lt_cv_dlopen_self" = xyes; then -- LDFLAGS="$LDFLAGS $link_static_flag" -- echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 --echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 --if test "${lt_cv_dlopen_self_static+set}" = set; then -+echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 -+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test "$cross_compiling" = yes; then : -- lt_cv_dlopen_self_static=cross --else -- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 -- lt_status=$lt_dlunknown -- cat > conftest.$ac_ext < --#endif -- --#include -- --#ifdef RTLD_GLOBAL --# define LT_DLGLOBAL RTLD_GLOBAL --#else --# ifdef DL_GLOBAL --# define LT_DLGLOBAL DL_GLOBAL --# else --# define LT_DLGLOBAL 0 --# endif --#endif -- --/* We may have to define LT_DLLAZY_OR_NOW in the command line if we -- find out it does not work in some platform. */ --#ifndef LT_DLLAZY_OR_NOW --# ifdef RTLD_LAZY --# define LT_DLLAZY_OR_NOW RTLD_LAZY --# else --# ifdef DL_LAZY --# define LT_DLLAZY_OR_NOW DL_LAZY --# else --# ifdef RTLD_NOW --# define LT_DLLAZY_OR_NOW RTLD_NOW --# else --# ifdef DL_NOW --# define LT_DLLAZY_OR_NOW DL_NOW --# else --# define LT_DLLAZY_OR_NOW 0 --# endif --# endif --# endif --# endif --#endif -- --#ifdef __cplusplus --extern "C" void exit (int); --#endif -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --void fnord() { int i=42;} --int main () -+int -+main () - { -- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); -- int status = $lt_dlunknown; -- -- if (self) -- { -- if (dlsym (self,"fnord")) status = $lt_dlno_uscore; -- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; -- /* dlclose (self); */ -- } -+#ifndef __GNUC__ -+ choke me -+#endif - -- exit (status); -+ ; -+ return 0; - } --EOF -- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then -- (./conftest; exit; ) 2>/dev/null -- lt_status=$? -- case x$lt_status in -- x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; -- x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; -- x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; -- esac -- else : -- # compilation failed -- lt_cv_dlopen_self_static=no -- fi --fi --rm -fr conftest* -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_compiler_gnu=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_compiler_gnu=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - - fi --echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 --echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 -- fi -+echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 -+GXX=`test $ac_compiler_gnu = yes && echo yes` -+ac_test_CXXFLAGS=${CXXFLAGS+set} -+ac_save_CXXFLAGS=$CXXFLAGS -+CXXFLAGS="-g" -+echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 -+if test "${ac_cv_prog_cxx_g+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - -- CPPFLAGS="$save_CPPFLAGS" -- LDFLAGS="$save_LDFLAGS" -- LIBS="$save_LIBS" -- ;; -- esac -+int -+main () -+{ - -- case $lt_cv_dlopen_self in -- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -- *) enable_dlopen_self=unknown ;; -- esac -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_prog_cxx_g=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- case $lt_cv_dlopen_self_static in -- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -- *) enable_dlopen_self_static=unknown ;; -- esac -+ac_cv_prog_cxx_g=no - fi -- -- --if test "$enable_shared" = yes && test "$GCC" = yes; then -- case $archive_cmds in -- *'~'*) -- # FIXME: we may have to deal with multi-command sequences. -- ;; -- '$CC '*) -- # Test whether the compiler implicitly links with -lc since on some -- # systems, -lgcc has to come before -lc. If gcc already passes -lc -- # to ld, don't add -lc before -lgcc. -- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 --echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 -- if test "${lt_cv_archive_cmds_need_lc+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 -+if test "$ac_test_CXXFLAGS" = set; then -+ CXXFLAGS=$ac_save_CXXFLAGS -+elif test $ac_cv_prog_cxx_g = yes; then -+ if test "$GXX" = yes; then -+ CXXFLAGS="-g -O2" -+ else -+ CXXFLAGS="-g" -+ fi - else -- $rm conftest* -- echo 'static int dummy;' > conftest.$ac_ext -+ if test "$GXX" = yes; then -+ CXXFLAGS="-O2" -+ else -+ CXXFLAGS= -+ fi -+fi -+for ac_declaration in \ -+ '' \ -+ 'extern "C" void std::exit (int) throw (); using std::exit;' \ -+ 'extern "C" void std::exit (int); using std::exit;' \ -+ 'extern "C" void exit (int) throw ();' \ -+ 'extern "C" void exit (int);' \ -+ 'void exit (int);' -+do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_declaration -+#include -+int -+main () -+{ -+exit (42); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ : -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+continue -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_declaration -+int -+main () -+{ -+exit (42); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; then -- soname=conftest -- lib=conftest -- libobjs=conftest.$ac_objext -- deplibs= -- wl=$lt_cv_prog_cc_wl -- compiler_flags=-v -- linker_flags=-v -- verstring= -- output_objdir=. -- libname=conftest -- save_allow_undefined_flag=$allow_undefined_flag -- allow_undefined_flag= -- if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 -- (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } -- then -- lt_cv_archive_cmds_need_lc=no -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+rm -f conftest* -+if test -n "$ac_declaration"; then -+ echo '#ifdef __cplusplus' >>confdefs.h -+ echo $ac_declaration >>confdefs.h -+ echo '#endif' >>confdefs.h -+fi -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+depcc="$CXX" am_compiler_list= -+ -+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 -+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then -+ # We make a subdir and do the tests there. Otherwise we can end up -+ # making bogus files that we don't know about and never remove. For -+ # instance it was reported that on HP-UX the gcc test will end up -+ # making a dummy file named `D' -- because `-MD' means `put the output -+ # in D'. -+ mkdir conftest.dir -+ # Copy depcomp to subdir because otherwise we won't find it if we're -+ # using a relative directory. -+ cp "$am_depcomp" conftest.dir -+ cd conftest.dir -+ # We will build objects and dependencies in a subdirectory because -+ # it helps to detect inapplicable dependency modes. For instance -+ # both Tru64's cc and ICC support -MD to output dependencies as a -+ # side effect of compilation, but ICC will put the dependencies in -+ # the current directory while Tru64 will put them in the object -+ # directory. -+ mkdir sub -+ -+ am_cv_CXX_dependencies_compiler_type=none -+ if test "$am_compiler_list" = ""; then -+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` -+ fi -+ for depmode in $am_compiler_list; do -+ # Setup a source with many dependencies, because some compilers -+ # like to wrap large dependency lists on column 80 (with \), and -+ # we should not choose a depcomp mode which is confused by this. -+ # -+ # We need to recreate these files for each test, as the compiler may -+ # overwrite some of them when testing with obscure command lines. -+ # This happens at least with the AIX C compiler. -+ : > sub/conftest.c -+ for i in 1 2 3 4 5 6; do -+ echo '#include "conftst'$i'.h"' >> sub/conftest.c -+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with -+ # Solaris 8's {/usr,}/bin/sh. -+ touch sub/conftst$i.h -+ done -+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf -+ -+ case $depmode in -+ nosideeffect) -+ # after this tag, mechanisms are not by side-effect, so they'll -+ # only be used when explicitly requested -+ if test "x$enable_dependency_tracking" = xyes; then -+ continue - else -- lt_cv_archive_cmds_need_lc=yes -+ break -+ fi -+ ;; -+ none) break ;; -+ esac -+ # We check with `-c' and `-o' for the sake of the "dashmstdout" -+ # mode. It turns out that the SunPro C++ compiler does not properly -+ # handle `-M -o', and we need to detect this. -+ if depmode=$depmode \ -+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ -+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ -+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ -+ >/dev/null 2>conftest.err && -+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && -+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && -+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then -+ # icc doesn't choke on unknown options, it will just issue warnings -+ # or remarks (even with -Werror). So we grep stderr for any message -+ # that says an option was ignored or not supported. -+ # When given -MP, icc 7.0 and 7.1 complain thusly: -+ # icc: Command line warning: ignoring option '-M'; no argument required -+ # The diagnosis changed in icc 8.0: -+ # icc: Command line remark: option '-MP' not supported -+ if (grep 'ignoring option' conftest.err || -+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else -+ am_cv_CXX_dependencies_compiler_type=$depmode -+ break - fi -- allow_undefined_flag=$save_allow_undefined_flag -- else -- cat conftest.err 1>&5 - fi --fi -- -- echo "$as_me:$LINENO: result: $lt_cv_archive_cmds_need_lc" >&5 --echo "${ECHO_T}$lt_cv_archive_cmds_need_lc" >&6 -- ;; -- esac --fi --need_lc=${lt_cv_archive_cmds_need_lc-yes} -+ done - --# The second clause should only fire when bootstrapping the --# libtool distribution, otherwise you forgot to ship ltmain.sh --# with your package, and you will get complaints that there are --# no rules to generate ltmain.sh. --if test -f "$ltmain"; then -- : -+ cd .. -+ rm -rf conftest.dir - else -- # If there is no Makefile yet, we rely on a make rule to execute -- # `config.status --recheck' to rerun these tests and create the -- # libtool script then. -- test -f Makefile && make "$ltmain" -+ am_cv_CXX_dependencies_compiler_type=none - fi - --if test -f "$ltmain"; then -- trap "$rm \"${ofile}T\"; exit 1" 1 2 15 -- $rm -f "${ofile}T" -- -- echo creating $ofile -- -- # Now quote all the things that may contain metacharacters while being -- # careful not to overquote the AC_SUBSTed values. We take copies of the -- # variables and quote the copies for generation of the libtool script. -- for var in echo old_CC old_CFLAGS \ -- AR AR_FLAGS CC LD LN_S NM SHELL \ -- reload_flag reload_cmds wl \ -- pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ -- thread_safe_flag_spec whole_archive_flag_spec libname_spec \ -- library_names_spec soname_spec \ -- RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ -- old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ -- postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ -- old_striplib striplib file_magic_cmd export_symbols_cmds \ -- deplibs_check_method allow_undefined_flag no_undefined_flag \ -- finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ -- global_symbol_to_c_name_address \ -- hardcode_libdir_flag_spec hardcode_libdir_separator \ -- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -- compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do -- -- case $var in -- reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ -- old_postinstall_cmds | old_postuninstall_cmds | \ -- export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ -- extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ -- postinstall_cmds | postuninstall_cmds | \ -- finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) -- # Double-quote double-evaled strings. -- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" -- ;; -- *) -- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -- ;; -- esac -- done -+fi -+echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 -+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 -+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - -- cat <<__EOF__ > "${ofile}T" --#! $SHELL - --# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. --# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) --# NOTE: Changes made to this file will be lost: look at ltmain.sh. --# --# Copyright (C) 1996-2000 Free Software Foundation, Inc. --# Originally by Gordon Matzigkeit , 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 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. --# --# 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. - --# Sed that helps us avoid accidentally triggering echo(1) options like -n. --Xsed="sed -e s/^X//" -+if -+ test "x$enable_dependency_tracking" != xno \ -+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then -+ am__fastdepCXX_TRUE= -+ am__fastdepCXX_FALSE='#' -+else -+ am__fastdepCXX_TRUE='#' -+ am__fastdepCXX_FALSE= -+fi - --# The HP-UX ksh and POSIX shell print the target directory to stdout --# if CDPATH is set. --if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - --# ### BEGIN LIBTOOL CONFIG - --# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -+if test "$cross_compiling" = yes; then -+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot run test program while cross compiling -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --# Shell to use when invoking shell scripts. --SHELL=$lt_SHELL -+#include -+main() -+{ -+#if defined(__GNUC__) && \ -+ ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) -+ return 1; -+#endif -+ return 0; -+} - --# Whether or not to build shared libraries. --build_libtool_libs=$enable_shared -+_ACEOF -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ : -+else -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Whether or not to build static libraries. --build_old_libs=$enable_static -+( exit $ac_status ) -+echo "need at least gcc 2.95 to compile correctly" -+exit 1 -+fi -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi - --# Whether or not to add -lc for building shared libraries. --build_libtool_need_lc=$need_lc -+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -+# for constant arguments. Useless! -+echo "$as_me:$LINENO: checking for working alloca.h" >&5 -+echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 -+if test "${ac_cv_working_alloca_h+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+char *p = (char *) alloca (2 * sizeof (int)); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_working_alloca_h=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Whether or not to optimize for fast installation. --fast_install=$enable_fast_install -+ac_cv_working_alloca_h=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 -+echo "${ECHO_T}$ac_cv_working_alloca_h" >&6 -+if test $ac_cv_working_alloca_h = yes; then - --# The host system. --host_alias=$host_alias --host=$host -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_ALLOCA_H 1 -+_ACEOF - --# An echo program that does not interpret backslashes. --echo=$lt_echo -+fi - --# The archiver. --AR=$lt_AR --AR_FLAGS=$lt_AR_FLAGS -+echo "$as_me:$LINENO: checking for alloca" >&5 -+echo $ECHO_N "checking for alloca... $ECHO_C" >&6 -+if test "${ac_cv_func_alloca_works+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifdef __GNUC__ -+# define alloca __builtin_alloca -+#else -+# ifdef _MSC_VER -+# include -+# define alloca _alloca -+# else -+# if HAVE_ALLOCA_H -+# include -+# else -+# ifdef _AIX -+ #pragma alloca -+# else -+# ifndef alloca /* predefined by HP cc +Olibcalls */ -+char *alloca (); -+# endif -+# endif -+# endif -+# endif -+#endif - --# The default C compiler. --CC=$lt_CC -+int -+main () -+{ -+char *p = (char *) alloca (1); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_func_alloca_works=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Is the compiler the GNU C compiler? --with_gcc=$GCC -+ac_cv_func_alloca_works=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 -+echo "${ECHO_T}$ac_cv_func_alloca_works" >&6 - --# The linker used to build libraries. --LD=$lt_LD -+if test $ac_cv_func_alloca_works = yes; then - --# Whether we need hard or soft links. --LN_S=$lt_LN_S -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_ALLOCA 1 -+_ACEOF - --# A BSD-compatible nm program. --NM=$lt_NM -+else -+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions -+# that cause trouble. Some versions do not even contain alloca or -+# contain a buggy version. If you still want to use their alloca, -+# use ar to extract alloca.o from them instead of compiling alloca.c. - --# A symbol stripping program --STRIP=$STRIP -+ALLOCA=alloca.$ac_objext - --# Used to examine libraries when file_magic_cmd begins "file" --MAGIC_CMD=$MAGIC_CMD -+cat >>confdefs.h <<\_ACEOF -+#define C_ALLOCA 1 -+_ACEOF - --# Used on cygwin: DLL creation program. --DLLTOOL="$DLLTOOL" - --# Used on cygwin: object dumper. --OBJDUMP="$OBJDUMP" -+echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 -+echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6 -+if test "${ac_cv_os_cray+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#if defined(CRAY) && ! defined(CRAY2) -+webecray -+#else -+wenotbecray -+#endif - --# Used on cygwin: assembler. --AS="$AS" -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "webecray" >/dev/null 2>&1; then -+ ac_cv_os_cray=yes -+else -+ ac_cv_os_cray=no -+fi -+rm -f conftest* - --# The name of the directory that contains temporary libtool files. --objdir=$objdir -+fi -+echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 -+echo "${ECHO_T}$ac_cv_os_cray" >&6 -+if test $ac_cv_os_cray = yes; then -+ for ac_func in _getb67 GETB67 getb67; do -+ as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -+echo "$as_me:$LINENO: checking for $ac_func" >&5 -+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_var+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define $ac_func to an innocuous variant, in case declares $ac_func. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define $ac_func innocuous_$ac_func - --# How to create reloadable object files. --reload_flag=$lt_reload_flag --reload_cmds=$lt_reload_cmds -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char $ac_func (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ - --# How to pass a linker flag through the compiler. --wl=$lt_wl -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif - --# Object file suffix (normally "o"). --objext="$ac_objext" -+#undef $ac_func - --# Old archive suffix (normally "a"). --libext="$libext" -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char $ac_func (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -+choke me -+#else -+char (*f) () = $ac_func; -+#endif -+#ifdef __cplusplus -+} -+#endif - --# Executable file suffix (normally ""). --exeext="$exeext" -+int -+main () -+{ -+return f != $ac_func; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ eval "$as_ac_var=yes" -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Additional compiler flags for building library objects. --pic_flag=$lt_pic_flag --pic_mode=$pic_mode -+eval "$as_ac_var=no" -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -+if test `eval echo '${'$as_ac_var'}'` = yes; then - --# Does compiler simultaneously support -c and -o options? --compiler_c_o=$lt_compiler_c_o -+cat >>confdefs.h <<_ACEOF -+#define CRAY_STACKSEG_END $ac_func -+_ACEOF - --# Can we write directly to a .lo ? --compiler_o_lo=$lt_compiler_o_lo -+ break -+fi - --# Must we lock files when doing compilation ? --need_locks=$lt_need_locks -+ done -+fi - --# Do we need the lib prefix for modules? --need_lib_prefix=$need_lib_prefix -+echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 -+echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 -+if test "${ac_cv_c_stack_direction+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$cross_compiling" = yes; then -+ ac_cv_c_stack_direction=0 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+int -+find_stack_direction () -+{ -+ static char *addr = 0; -+ auto char dummy; -+ if (addr == 0) -+ { -+ addr = &dummy; -+ return find_stack_direction (); -+ } -+ else -+ return (&dummy > addr) ? 1 : -1; -+} - --# Do we need a version for libraries? --need_version=$need_version -+int -+main () -+{ -+ exit (find_stack_direction () < 0); -+} -+_ACEOF -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_c_stack_direction=1 -+else -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Whether dlopen is supported. --dlopen_support=$enable_dlopen -+( exit $ac_status ) -+ac_cv_c_stack_direction=-1 -+fi -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+fi -+echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 -+echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 - --# Whether dlopen of programs is supported. --dlopen_self=$enable_dlopen_self -+cat >>confdefs.h <<_ACEOF -+#define STACK_DIRECTION $ac_cv_c_stack_direction -+_ACEOF - --# Whether dlopen of statically linked programs is supported. --dlopen_self_static=$enable_dlopen_self_static - --# Compiler flag to prevent dynamic linking. --link_static_flag=$lt_link_static_flag -+fi - --# Compiler flag to turn off builtin functions. --no_builtin_flag=$lt_no_builtin_flag - --# Compiler flag to allow reflexive dlopens. --export_dynamic_flag_spec=$lt_export_dynamic_flag_spec -+echo "$as_me:$LINENO: checking for getopt_long in -lc" >&5 -+echo $ECHO_N "checking for getopt_long in -lc... $ECHO_C" >&6 -+if test "${ac_cv_lib_c_getopt_long+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lc $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --# Compiler flag to generate shared objects directly from archives. --whole_archive_flag_spec=$lt_whole_archive_flag_spec -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char getopt_long (); -+int -+main () -+{ -+getopt_long (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_c_getopt_long=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Compiler flag to generate thread-safe objects. --thread_safe_flag_spec=$lt_thread_safe_flag_spec -+ac_cv_lib_c_getopt_long=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_c_getopt_long" >&5 -+echo "${ECHO_T}$ac_cv_lib_c_getopt_long" >&6 -+if test $ac_cv_lib_c_getopt_long = yes; then -+ cat >>confdefs.h <<\_ACEOF -+#define HAVE_GETOPT_LONG 1 -+_ACEOF - --# Library versioning type. --version_type=$version_type -+fi - --# Format of library name prefix. --libname_spec=$lt_libname_spec - --# List of archive names. First name is the real one, the rest are links. --# The last name is the one that the linker finds with -lNAME. --library_names_spec=$lt_library_names_spec -+echo "$as_me:$LINENO: checking for alarm in -lc" >&5 -+echo $ECHO_N "checking for alarm in -lc... $ECHO_C" >&6 -+if test "${ac_cv_lib_c_alarm+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lc $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --# The coded name of the library, if different from the real name. --soname_spec=$lt_soname_spec -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char alarm (); -+int -+main () -+{ -+alarm (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_c_alarm=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Commands used to build and install an old-style archive. --RANLIB=$lt_RANLIB --old_archive_cmds=$lt_old_archive_cmds --old_postinstall_cmds=$lt_old_postinstall_cmds --old_postuninstall_cmds=$lt_old_postuninstall_cmds -+ac_cv_lib_c_alarm=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_c_alarm" >&5 -+echo "${ECHO_T}$ac_cv_lib_c_alarm" >&6 -+if test $ac_cv_lib_c_alarm = yes; then -+ cat >>confdefs.h <<\_ACEOF -+#define HAVE_ALARM 1 -+_ACEOF - --# Create an old-style archive from a shared archive. --old_archive_from_new_cmds=$lt_old_archive_from_new_cmds -+fi - --# Create a temporary old-style archive to link instead of a shared archive. --old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - --# Commands used to build and install a shared archive. --archive_cmds=$lt_archive_cmds --archive_expsym_cmds=$lt_archive_expsym_cmds --postinstall_cmds=$lt_postinstall_cmds --postuninstall_cmds=$lt_postuninstall_cmds - --# Commands to strip libraries. --old_striplib=$lt_old_striplib --striplib=$lt_striplib -+for ac_header in netinet/in.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+else -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Method to check whether dependent libraries are shared objects. --deplibs_check_method=$lt_deplibs_check_method -+ac_header_compiler=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 - --# Command to use when deplibs_check_method == file_magic. --file_magic_cmd=$lt_file_magic_cmd -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Flag that allows shared libraries with undefined symbols to be built. --allow_undefined_flag=$lt_allow_undefined_flag -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 - --# Flag that forces no undefined symbols. --no_undefined_flag=$lt_no_undefined_flag -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - --# Commands used to finish a libtool library installation in a directory. --finish_cmds=$lt_finish_cmds -+fi -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF - --# Same as above, but a single script fragment to be evaled but not shown. --finish_eval=$lt_finish_eval -+fi - --# Take the output of nm and produce a listing of raw symbols and C names. --global_symbol_pipe=$lt_global_symbol_pipe -+done - --# Transform the output of nm in a proper C declaration --global_symbol_to_cdecl=$lt_global_symbol_to_cdecl - --# Transform the output of nm in a C name address pair --global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address - --# This is the shared library runtime path variable. --runpath_var=$runpath_var -+for ac_header in string.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+else -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# This is the shared library path variable. --shlibpath_var=$shlibpath_var -+ac_header_compiler=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 - --# Is shlibpath searched before the hard-coded library search path? --shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# How to hardcode a shared library path into an executable. --hardcode_action=$hardcode_action -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 - --# Whether we should hardcode library paths into libraries. --hardcode_into_libs=$hardcode_into_libs -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - --# Flag to hardcode \$libdir into a binary during linking. --# This must work even if \$libdir does not exist. --hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec -+fi -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF - --# Whether we need a single -rpath flag with a separated argument. --hardcode_libdir_separator=$lt_hardcode_libdir_separator -+fi - --# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the --# resulting binary. --hardcode_direct=$hardcode_direct -+done - --# Set to yes if using the -LDIR flag during linking hardcodes DIR into the --# resulting binary. --hardcode_minus_L=$hardcode_minus_L - --# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into --# the resulting binary. --hardcode_shlibpath_var=$hardcode_shlibpath_var - --# Variables whose values should be saved in libtool wrapper scripts and --# restored at relink time. --variables_saved_for_relink="$variables_saved_for_relink" -+for ac_header in libintl.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+else -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Whether libtool must link a program against all its dependency libraries. --link_all_deplibs=$link_all_deplibs -+ac_header_compiler=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 - --# Compile-time system search path for libraries --sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Run-time system search path for libraries --sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 - --# Fix the shell variable \$srcfile for the compiler. --fix_srcfile_path="$fix_srcfile_path" -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - --# Set to yes if exported symbols are required. --always_export_symbols=$always_export_symbols -+fi -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF - --# The commands to list exported symbols. --export_symbols_cmds=$lt_export_symbols_cmds -+fi - --# The commands to extract the exported symbol list from a shared archive. --extract_expsyms_cmds=$lt_extract_expsyms_cmds -+done - --# Symbols that should not be listed in the preloaded symbols. --exclude_expsyms=$lt_exclude_expsyms - --# Symbols that must always be exported. --include_expsyms=$lt_include_expsyms -+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 -+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 -+if test "${ac_cv_c_const+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --# ### END LIBTOOL CONFIG -+int -+main () -+{ -+/* FIXME: Include the comments suggested by Paul. */ -+#ifndef __cplusplus -+ /* Ultrix mips cc rejects this. */ -+ typedef int charset[2]; -+ const charset x; -+ /* SunOS 4.1.1 cc rejects this. */ -+ char const *const *ccp; -+ char **p; -+ /* NEC SVR4.0.2 mips cc rejects this. */ -+ struct point {int x, y;}; -+ static struct point const zero = {0,0}; -+ /* AIX XL C 1.02.0.0 rejects this. -+ It does not let you subtract one const X* pointer from another in -+ an arm of an if-expression whose if-part is not a constant -+ expression */ -+ const char *g = "string"; -+ ccp = &g + (g ? g-g : 0); -+ /* HPUX 7.0 cc rejects these. */ -+ ++ccp; -+ p = (char**) ccp; -+ ccp = (char const *const *) p; -+ { /* SCO 3.2v4 cc rejects this. */ -+ char *t; -+ char const *s = 0 ? (char *) 0 : (char const *) 0; - --__EOF__ -+ *t++ = 0; -+ } -+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ -+ int x[] = {25, 17}; -+ const int *foo = &x[0]; -+ ++foo; -+ } -+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ -+ typedef const int *iptr; -+ iptr p = 0; -+ ++p; -+ } -+ { /* AIX XL C 1.02.0.0 rejects this saying -+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ -+ struct s { int j; const int *ap[3]; }; -+ struct s *b; b->j = 5; -+ } -+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ -+ const int foo = 10; -+ } -+#endif - -- case $host_os in -- aix3*) -- cat <<\EOF >> "${ofile}T" -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_c_const=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# AIX sometimes has problems with the GCC collect2 program. For some --# reason, if we set the COLLECT_NAMES environment variable, the problems --# vanish in a puff of smoke. --if test "X${COLLECT_NAMES+set}" != Xset; then -- COLLECT_NAMES= -- export COLLECT_NAMES -+ac_cv_c_const=no - fi --EOF -- ;; -- esac -- -- case $host_os in -- cygwin* | mingw* | pw32* | os2*) -- cat <<'EOF' >> "${ofile}T" -- # This is a source program that is used to create dlls on Windows -- # Don't remove nor modify the starting and closing comments --# /* ltdll.c starts here */ --# #define WIN32_LEAN_AND_MEAN --# #include --# #undef WIN32_LEAN_AND_MEAN --# #include --# --# #ifndef __CYGWIN__ --# # ifdef __CYGWIN32__ --# # define __CYGWIN__ __CYGWIN32__ --# # endif --# #endif --# --# #ifdef __cplusplus --# extern "C" { --# #endif --# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); --# #ifdef __cplusplus --# } --# #endif --# --# #ifdef __CYGWIN__ --# #include --# DECLARE_CYGWIN_DLL( DllMain ); --# #endif --# HINSTANCE __hDllInstance_base; --# --# BOOL APIENTRY --# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) --# { --# __hDllInstance_base = hInst; --# return TRUE; --# } --# /* ltdll.c ends here */ -- # This is a source program that is used to create import libraries -- # on Windows for dlls which lack them. Don't remove nor modify the -- # starting and closing comments --# /* impgen.c starts here */ --# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. --# --# This file is part of GNU libtool. --# --# 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 /* for printf() */ --# #include /* for open(), lseek(), read() */ --# #include /* for O_RDONLY, O_BINARY */ --# #include /* for strdup() */ --# --# /* O_BINARY isn't required (or even defined sometimes) under Unix */ --# #ifndef O_BINARY --# #define O_BINARY 0 --# #endif --# --# static unsigned int --# pe_get16 (fd, offset) --# int fd; --# int offset; --# { --# unsigned char b[2]; --# lseek (fd, offset, SEEK_SET); --# read (fd, b, 2); --# return b[0] + (b[1]<<8); --# } --# --# static unsigned int --# pe_get32 (fd, offset) --# int fd; --# int offset; --# { --# unsigned char b[4]; --# lseek (fd, offset, SEEK_SET); --# read (fd, b, 4); --# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); --# } --# --# static unsigned int --# pe_as32 (ptr) --# void *ptr; --# { --# unsigned char *b = ptr; --# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); --# } --# --# int --# main (argc, argv) --# int argc; --# char *argv[]; --# { --# int dll; --# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; --# unsigned long export_rva, export_size, nsections, secptr, expptr; --# unsigned long name_rvas, nexp; --# unsigned char *expdata, *erva; --# char *filename, *dll_name; --# --# filename = argv[1]; --# --# dll = open(filename, O_RDONLY|O_BINARY); --# if (dll < 1) --# return 1; --# --# dll_name = filename; --# --# for (i=0; filename[i]; i++) --# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') --# dll_name = filename + i +1; --# --# pe_header_offset = pe_get32 (dll, 0x3c); --# opthdr_ofs = pe_header_offset + 4 + 20; --# num_entries = pe_get32 (dll, opthdr_ofs + 92); --# --# if (num_entries < 1) /* no exports */ --# return 1; --# --# export_rva = pe_get32 (dll, opthdr_ofs + 96); --# export_size = pe_get32 (dll, opthdr_ofs + 100); --# nsections = pe_get16 (dll, pe_header_offset + 4 +2); --# secptr = (pe_header_offset + 4 + 20 + --# pe_get16 (dll, pe_header_offset + 4 + 16)); --# --# expptr = 0; --# for (i = 0; i < nsections; i++) --# { --# char sname[8]; --# unsigned long secptr1 = secptr + 40 * i; --# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); --# unsigned long vsize = pe_get32 (dll, secptr1 + 16); --# unsigned long fptr = pe_get32 (dll, secptr1 + 20); --# lseek(dll, secptr1, SEEK_SET); --# read(dll, sname, 8); --# if (vaddr <= export_rva && vaddr+vsize > export_rva) --# { --# expptr = fptr + (export_rva - vaddr); --# if (export_rva + export_size > vaddr + vsize) --# export_size = vsize - (export_rva - vaddr); --# break; --# } --# } --# --# expdata = (unsigned char*)malloc(export_size); --# lseek (dll, expptr, SEEK_SET); --# read (dll, expdata, export_size); --# erva = expdata - export_rva; --# --# nexp = pe_as32 (expdata+24); --# name_rvas = pe_as32 (expdata+32); --# --# printf ("EXPORTS\n"); --# for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) -- -- mv -f "${ofile}T" "$ofile" || \ -- (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") -- chmod +x "$ofile" -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi -+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 -+echo "${ECHO_T}$ac_cv_c_const" >&6 -+if test $ac_cv_c_const = no; then - -+cat >>confdefs.h <<\_ACEOF -+#define const -+_ACEOF - -+fi - - -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - --# This can be used to rebuild libtool when needed --LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" -- --# Always use our own libtool. --LIBTOOL='$(SHELL) $(top_builddir)/libtool' -- --# Prevent multiple expansion -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "vsnprintf" >/dev/null 2>&1; then -+ cat >>confdefs.h <<\_ACEOF -+#define HAVE_VSNPRINTF 1 -+_ACEOF - -+fi -+rm -f conftest* - - --ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu --echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 --echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 --# On Suns, sometimes $CPP names a directory. --if test -n "$CPP" && test -d "$CPP"; then -- CPP= --fi --if test -z "$CPP"; then -- if test "${ac_cv_prog_CPP+set}" = set; then -+echo "$as_me:$LINENO: checking for unsigned short int" >&5 -+echo $ECHO_N "checking for unsigned short int... $ECHO_C" >&6 -+if test "${ac_cv_type_unsigned_short_int+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- # Double quotes because CPP needs to be expanded -- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" -- do -- ac_preproc_ok=false --for ac_c_preproc_warn_flag in '' yes --do -- # Use a header file that comes with gcc, so configuring glibc -- # with a fresh cross-compiler works. -- # On the NeXT, cc -E runs the code through the compiler's parser, -- # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -- Syntax error -+/* confdefs.h. */ - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+if ((unsigned short int *) 0) -+ return 0; -+if (sizeof (unsigned short int)) -+ return 0; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- : -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_type_unsigned_short_int=yes - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- # Broken: fails on valid input. --continue -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_unsigned_short_int=no - fi --rm -f conftest.err conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_short_int" >&5 -+echo "${ECHO_T}$ac_cv_type_unsigned_short_int" >&6 - -- # OK, works on sane cases. Now check whether non-existent headers -- # can be detected and how. -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -+echo "$as_me:$LINENO: checking size of unsigned short int" >&5 -+echo $ECHO_N "checking size of unsigned short int... $ECHO_C" >&6 -+if test "${ac_cv_sizeof_unsigned_short_int+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ if test "$ac_cv_type_unsigned_short_int" = yes; then -+ # The cast to unsigned long works around a bug in the HP C Compiler -+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -+ # This bug is HP SR number 8606223364. -+ if test "$cross_compiling" = yes; then -+ # Depending upon the size, compute the lo and hi bounds. -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) >= 0)]; -+test_array [0] = 0 -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- # Broken: success on invalid input. --continue -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=0 ac_mid=0 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) <= $ac_mid)]; -+test_array [0] = 0 -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- # Passes both tests. --ac_preproc_ok=: --break --fi --rm -f conftest.err conftest.$ac_ext -+sed 's/^/| /' conftest.$ac_ext >&5 - --done --# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. --rm -f conftest.err conftest.$ac_ext --if $ac_preproc_ok; then -- break -+ac_lo=`expr $ac_mid + 1` -+ if test $ac_lo -le $ac_mid; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid + 1` - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- done -- ac_cv_prog_CPP=$CPP -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) < 0)]; -+test_array [0] = 0 - --fi -- CPP=$ac_cv_prog_CPP --else -- ac_cv_prog_CPP=$CPP --fi --echo "$as_me:$LINENO: result: $CPP" >&5 --echo "${ECHO_T}$CPP" >&6 --ac_preproc_ok=false --for ac_c_preproc_warn_flag in '' yes --do -- # Use a header file that comes with gcc, so configuring glibc -- # with a fresh cross-compiler works. -- # On the NeXT, cc -E runs the code through the compiler's parser, -- # not just through cpp. "Syntax error" is here to catch this case. -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -- Syntax error -+ ; -+ return 0; -+} - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- : --else -- echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- # Broken: fails on valid input. --continue --fi --rm -f conftest.err conftest.$ac_ext -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=-1 ac_mid=-1 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) >= $ac_mid)]; -+test_array [0] = 0 - -- # OK, works on sane cases. Now check whether non-existent headers -- # can be detected and how. -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -+ ; -+ return 0; -+} - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- # Broken: success on invalid input. --continue -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- # Passes both tests. --ac_preproc_ok=: --break --fi --rm -f conftest.err conftest.$ac_ext -- --done --# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. --rm -f conftest.err conftest.$ac_ext --if $ac_preproc_ok; then -- : --else -- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check" >&5 --echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} -- { (exit 1); exit 1; }; } --fi -- --ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu -- --ac_ext=cc --ac_cpp='$CXXCPP $CPPFLAGS' --ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_cxx_compiler_gnu --if test -n "$ac_tool_prefix"; then -- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -- do -- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. --set dummy $ac_tool_prefix$ac_prog; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_CXX+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- if test -n "$CXX"; then -- ac_cv_prog_CXX="$CXX" # Let the user override the test. --else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_hi=`expr '(' $ac_mid ')' - 1` -+ if test $ac_mid -le $ac_hi; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid` - fi --fi --CXX=$ac_cv_prog_CXX --if test -n "$CXX"; then -- echo "$as_me:$LINENO: result: $CXX" >&5 --echo "${ECHO_T}$CXX" >&6 --else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -- -- test -n "$CXX" && break -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done --fi --if test -z "$CXX"; then -- ac_ct_CXX=$CXX -- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC --do -- # Extract the first word of "$ac_prog", so it can be a program name with args. --set dummy $ac_prog; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- if test -n "$ac_ct_CXX"; then -- ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. - else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_ac_ct_CXX="$ac_prog" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo= ac_hi= - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --ac_ct_CXX=$ac_cv_prog_ac_ct_CXX --if test -n "$ac_ct_CXX"; then -- echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 --echo "${ECHO_T}$ac_ct_CXX" >&6 --else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -- -- test -n "$ac_ct_CXX" && break --done --test -n "$ac_ct_CXX" || ac_ct_CXX="g++" -- -- CXX=$ac_ct_CXX --fi -- -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+# Binary search between lo and hi bounds. -+while test "x$ac_lo" != "x$ac_hi"; do -+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) <= $ac_mid)]; -+test_array [0] = 0 - --# Provide some information about the compiler. --echo "$as_me:$LINENO:" \ -- "checking for C++ compiler version" >&5 --ac_compiler=`set X $ac_compile; echo $2` --{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 -- (eval $ac_compiler --version &5) 2>&5 -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } --{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 -- (eval $ac_compiler -v &5) 2>&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } --{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 -- (eval $ac_compiler -V &5) 2>&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } -+ (exit $ac_status); }; }; then -+ ac_hi=$ac_mid -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 --echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 --if test "${ac_cv_cxx_compiler_gnu+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ac_lo=`expr '(' $ac_mid ')' + 1` -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+case $ac_lo in -+?*) ac_cv_sizeof_unsigned_short_int=$ac_lo;; -+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned short int), 77 -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute sizeof (unsigned short int), 77 -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } ;; -+esac -+else -+ if test "$cross_compiling" = yes; then -+ { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -+echo "$as_me: error: internal error: not reached in cross-compile" >&2;} -+ { (exit 1); exit 1; }; } - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+long longval () { return (long) (sizeof (unsigned short int)); } -+unsigned long ulongval () { return (long) (sizeof (unsigned short int)); } -+#include -+#include - int - main () - { --#ifndef __GNUC__ -- choke me --#endif -+ -+ FILE *f = fopen ("conftest.val", "w"); -+ if (! f) -+ exit (1); -+ if (((long) (sizeof (unsigned short int))) < 0) -+ { -+ long i = longval (); -+ if (i != ((long) (sizeof (unsigned short int)))) -+ exit (1); -+ fprintf (f, "%ld\n", i); -+ } -+ else -+ { -+ unsigned long i = ulongval (); -+ if (i != ((long) (sizeof (unsigned short int)))) -+ exit (1); -+ fprintf (f, "%lu\n", i); -+ } -+ exit (ferror (f) || fclose (f) != 0); - - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_compiler_gnu=yes -+ ac_cv_sizeof_unsigned_short_int=`cat conftest.val` - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_compiler_gnu=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext --ac_cv_cxx_compiler_gnu=$ac_compiler_gnu -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+( exit $ac_status ) -+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned short int), 77 -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute sizeof (unsigned short int), 77 -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } - fi --echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 --echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 --GXX=`test $ac_compiler_gnu = yes && echo yes` --ac_test_CXXFLAGS=${CXXFLAGS+set} --ac_save_CXXFLAGS=$CXXFLAGS --CXXFLAGS="-g" --echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 --echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 --if test "${ac_cv_prog_cxx_g+set}" = set; then -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+fi -+rm -f conftest.val -+else -+ ac_cv_sizeof_unsigned_short_int=0 -+fi -+fi -+echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned_short_int" >&5 -+echo "${ECHO_T}$ac_cv_sizeof_unsigned_short_int" >&6 -+cat >>confdefs.h <<_ACEOF -+#define SIZEOF_UNSIGNED_SHORT_INT $ac_cv_sizeof_unsigned_short_int -+_ACEOF -+ -+ -+echo "$as_me:$LINENO: checking for unsigned long int" >&5 -+echo $ECHO_N "checking for unsigned long int... $ECHO_C" >&6 -+if test "${ac_cv_type_unsigned_long_int+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { -- -+if ((unsigned long int *) 0) -+ return 0; -+if (sizeof (unsigned long int)) -+ return 0; - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_prog_cxx_g=yes -+ ac_cv_type_unsigned_long_int=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_prog_cxx_g=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_unsigned_long_int=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 --echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 --if test "$ac_test_CXXFLAGS" = set; then -- CXXFLAGS=$ac_save_CXXFLAGS --elif test $ac_cv_prog_cxx_g = yes; then -- if test "$GXX" = yes; then -- CXXFLAGS="-g -O2" -- else -- CXXFLAGS="-g" -- fi -+echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_long_int" >&5 -+echo "${ECHO_T}$ac_cv_type_unsigned_long_int" >&6 -+ -+echo "$as_me:$LINENO: checking size of unsigned long int" >&5 -+echo $ECHO_N "checking size of unsigned long int... $ECHO_C" >&6 -+if test "${ac_cv_sizeof_unsigned_long_int+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test "$GXX" = yes; then -- CXXFLAGS="-O2" -- else -- CXXFLAGS= -- fi --fi --for ac_declaration in \ -- ''\ -- '#include ' \ -- 'extern "C" void std::exit (int) throw (); using std::exit;' \ -- 'extern "C" void std::exit (int); using std::exit;' \ -- 'extern "C" void exit (int) throw ();' \ -- 'extern "C" void exit (int);' \ -- 'void exit (int);' --do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --$ac_declaration --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ if test "$ac_cv_type_unsigned_long_int" = yes; then -+ # The cast to unsigned long works around a bug in the HP C Compiler -+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -+ # This bug is HP SR number 8606223364. -+ if test "$cross_compiling" = yes; then -+ # Depending upon the size, compute the lo and hi bounds. -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --exit (42); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) >= 0)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- : --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --continue --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_declaration --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ ac_lo=0 ac_mid=0 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --exit (42); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) <= $ac_mid)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- break -+ ac_hi=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --fi --rm -f conftest.$ac_objext conftest.$ac_ext --done --rm -f conftest* --if test -n "$ac_declaration"; then -- echo '#ifdef __cplusplus' >>confdefs.h -- echo $ac_declaration >>confdefs.h -- echo '#endif' >>confdefs.h --fi -- --ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu -- --depcc="$CXX" am_compiler_list= -- --echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 --echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 --if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then -- # We make a subdir and do the tests there. Otherwise we can end up -- # making bogus files that we don't know about and never remove. For -- # instance it was reported that on HP-UX the gcc test will end up -- # making a dummy file named `D' -- because `-MD' means `put the output -- # in D'. -- mkdir conftest.dir -- # Copy depcomp to subdir because otherwise we won't find it if we're -- # using a relative directory. -- cp "$am_depcomp" conftest.dir -- cd conftest.dir -- -- am_cv_CXX_dependencies_compiler_type=none -- if test "$am_compiler_list" = ""; then -- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` -- fi -- for depmode in $am_compiler_list; do -- # We need to recreate these files for each test, as the compiler may -- # overwrite some of them when testing with obscure command lines. -- # This happens at least with the AIX C compiler. -- echo '#include "conftest.h"' > conftest.c -- echo 'int i;' > conftest.h -- echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf -- -- case $depmode in -- nosideeffect) -- # after this tag, mechanisms are not by side-effect, so they'll -- # only be used when explicitly requested -- if test "x$enable_dependency_tracking" = xyes; then -- continue -- else -- break -- fi -- ;; -- none) break ;; -- esac -- # We check with `-c' and `-o' for the sake of the "dashmstdout" -- # mode. It turns out that the SunPro C++ compiler does not properly -- # handle `-M -o', and we need to detect this. -- if depmode=$depmode \ -- source=conftest.c object=conftest.o \ -- depfile=conftest.Po tmpdepfile=conftest.TPo \ -- $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && -- grep conftest.h conftest.Po > /dev/null 2>&1 && -- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then -- am_cv_CXX_dependencies_compiler_type=$depmode -- break -- fi -- done -- -- cd .. -- rm -rf conftest.dir --else -- am_cv_CXX_dependencies_compiler_type=none --fi -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo=`expr $ac_mid + 1` -+ if test $ac_lo -le $ac_mid; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid + 1` - fi --echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 --echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 --CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type -- -- -- --if test "$cross_compiling" = yes; then -- { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 --echo "$as_me: error: cannot run test program while cross compiling" >&2;} -- { (exit 1); exit 1; }; } -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --#include --main() --{ --#if defined(__GNUC__) && \ -- ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) -- return 1; --#endif -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) < 0)]; -+test_array [0] = 0 -+ -+ ; - return 0; - } -- - _ACEOF --rm -f conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- : --else -- echo "$as_me: program exited with status $ac_status" >&5 --echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --( exit $ac_status ) --echo "need at least gcc 2.95 to compile correctly" --exit 1 --fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext --fi -- --# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works --# for constant arguments. Useless! --echo "$as_me:$LINENO: checking for working alloca.h" >&5 --echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 --if test "${ac_cv_working_alloca_h+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ ac_hi=-1 ac_mid=-1 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --char *p = (char *) alloca (2 * sizeof (int)); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) >= $ac_mid)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_working_alloca_h=yes -+ ac_lo=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_working_alloca_h=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --fi --echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 --echo "${ECHO_T}$ac_cv_working_alloca_h" >&6 --if test $ac_cv_working_alloca_h = yes; then -- --cat >>confdefs.h <<\_ACEOF --#define HAVE_ALLOCA_H 1 --_ACEOF -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_hi=`expr '(' $ac_mid ')' - 1` -+ if test $ac_mid -le $ac_hi; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid` - fi -- --echo "$as_me:$LINENO: checking for alloca" >&5 --echo $ECHO_N "checking for alloca... $ECHO_C" >&6 --if test "${ac_cv_func_alloca_works+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#ifdef __GNUC__ --# define alloca __builtin_alloca --#else --# ifdef _MSC_VER --# include --# define alloca _alloca --# else --# if HAVE_ALLOCA_H --# include --# else --# ifdef _AIX -- #pragma alloca --# else --# ifndef alloca /* predefined by HP cc +Olibcalls */ --char *alloca (); --# endif --# endif --# endif --# endif --#endif -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ac_lo= ac_hi= -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+# Binary search between lo and hi bounds. -+while test "x$ac_lo" != "x$ac_hi"; do -+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --char *p = (char *) alloca (1); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) <= $ac_mid)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_func_alloca_works=yes -+ ac_hi=$ac_mid - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_func_alloca_works=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --fi --echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 --echo "${ECHO_T}$ac_cv_func_alloca_works" >&6 -- --if test $ac_cv_func_alloca_works = yes; then -- --cat >>confdefs.h <<\_ACEOF --#define HAVE_ALLOCA 1 --_ACEOF -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo=`expr '(' $ac_mid ')' + 1` -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+case $ac_lo in -+?*) ac_cv_sizeof_unsigned_long_int=$ac_lo;; -+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned long int), 77 -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute sizeof (unsigned long int), 77 -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } ;; -+esac - else -- # The SVR3 libPW and SVR4 libucb both contain incompatible functions --# that cause trouble. Some versions do not even contain alloca or --# contain a buggy version. If you still want to use their alloca, --# use ar to extract alloca.o from them instead of compiling alloca.c. -- --ALLOCA=alloca.$ac_objext -- --cat >>confdefs.h <<\_ACEOF --#define C_ALLOCA 1 --_ACEOF -- -- --echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 --echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6 --if test "${ac_cv_os_cray+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ if test "$cross_compiling" = yes; then -+ { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -+echo "$as_me: error: internal error: not reached in cross-compile" >&2;} -+ { (exit 1); exit 1; }; } - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#if defined(CRAY) && ! defined(CRAY2) --webecray --#else --wenotbecray --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+long longval () { return (long) (sizeof (unsigned long int)); } -+unsigned long ulongval () { return (long) (sizeof (unsigned long int)); } -+#include -+#include -+int -+main () -+{ -+ -+ FILE *f = fopen ("conftest.val", "w"); -+ if (! f) -+ exit (1); -+ if (((long) (sizeof (unsigned long int))) < 0) -+ { -+ long i = longval (); -+ if (i != ((long) (sizeof (unsigned long int)))) -+ exit (1); -+ fprintf (f, "%ld\n", i); -+ } -+ else -+ { -+ unsigned long i = ulongval (); -+ if (i != ((long) (sizeof (unsigned long int)))) -+ exit (1); -+ fprintf (f, "%lu\n", i); -+ } -+ exit (ferror (f) || fclose (f) != 0); - -+ ; -+ return 0; -+} - _ACEOF --if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- egrep "webecray" >/dev/null 2>&1; then -- ac_cv_os_cray=yes -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_sizeof_unsigned_long_int=`cat conftest.val` - else -- ac_cv_os_cray=no --fi --rm -f conftest* -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+( exit $ac_status ) -+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned long int), 77 -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute sizeof (unsigned long int), 77 -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } - fi --echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 --echo "${ECHO_T}$ac_cv_os_cray" >&6 --if test $ac_cv_os_cray = yes; then -- for ac_func in _getb67 GETB67 getb67; do -- as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` --echo "$as_me:$LINENO: checking for $ac_func" >&5 --echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 --if eval "test \"\${$as_ac_var+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+fi -+rm -f conftest.val - else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --/* System header to define __stub macros and hopefully few prototypes, -- which can conflict with char $ac_func (); below. */ --#include --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char $ac_func (); --char (*f) (); -+ ac_cv_sizeof_unsigned_long_int=0 -+fi -+fi -+echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned_long_int" >&5 -+echo "${ECHO_T}$ac_cv_sizeof_unsigned_long_int" >&6 -+cat >>confdefs.h <<_ACEOF -+#define SIZEOF_UNSIGNED_LONG_INT $ac_cv_sizeof_unsigned_long_int -+_ACEOF - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ -+echo "$as_me:$LINENO: checking for unsigned int" >&5 -+echo $ECHO_N "checking for unsigned int... $ECHO_C" >&6 -+if test "${ac_cv_type_unsigned_int+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --/* The GNU C library defines this for functions which it implements -- to always fail with ENOSYS. Some functions are actually named -- something starting with __ and the normal name is an alias. */ --#if defined (__stub_$ac_func) || defined (__stub___$ac_func) --choke me --#else --f = $ac_func; --#endif -- -+if ((unsigned int *) 0) -+ return 0; -+if (sizeof (unsigned int)) -+ return 0; - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- eval "$as_ac_var=yes" -+ ac_cv_type_unsigned_int=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --eval "$as_ac_var=no" --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 --if test `eval echo '${'$as_ac_var'}'` = yes; then -- --cat >>confdefs.h <<_ACEOF --#define CRAY_STACKSEG_END $ac_func --_ACEOF -+sed 's/^/| /' conftest.$ac_ext >&5 - -- break -+ac_cv_type_unsigned_int=no - fi -- -- done -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi -+echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_int" >&5 -+echo "${ECHO_T}$ac_cv_type_unsigned_int" >&6 - --echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 --echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 --if test "${ac_cv_c_stack_direction+set}" = set; then -+echo "$as_me:$LINENO: checking size of unsigned int" >&5 -+echo $ECHO_N "checking size of unsigned int... $ECHO_C" >&6 -+if test "${ac_cv_sizeof_unsigned_int+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -+ if test "$ac_cv_type_unsigned_int" = yes; then -+ # The cast to unsigned long works around a bug in the HP C Compiler -+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -+ # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then -- ac_cv_c_stack_direction=0 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ # Depending upon the size, compute the lo and hi bounds. -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int --find_stack_direction () -+main () - { -- static char *addr = 0; -- auto char dummy; -- if (addr == 0) -- { -- addr = &dummy; -- return find_stack_direction (); -- } -- else -- return (&dummy > addr) ? 1 : -1; --} -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) >= 0)]; -+test_array [0] = 0 - -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=0 ac_mid=0 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { -- exit (find_stack_direction () < 0); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) <= $ac_mid)]; -+test_array [0] = 0 -+ -+ ; -+ return 0; - } - _ACEOF --rm -f conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_c_stack_direction=1 -+ ac_hi=$ac_mid; break - else -- echo "$as_me: program exited with status $ac_status" >&5 --echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --( exit $ac_status ) --ac_cv_c_stack_direction=-1 --fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext --fi --fi --echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 --echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 -- --cat >>confdefs.h <<_ACEOF --#define STACK_DIRECTION $ac_cv_c_stack_direction --_ACEOF -- -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo=`expr $ac_mid + 1` -+ if test $ac_lo -le $ac_mid; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid + 1` - fi -- -- --echo "$as_me:$LINENO: checking for getopt_long in -lc" >&5 --echo $ECHO_N "checking for getopt_long in -lc... $ECHO_C" >&6 --if test "${ac_cv_lib_c_getopt_long+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-lc $LIBS" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) < 0)]; -+test_array [0] = 0 - --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char getopt_long (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=-1 ac_mid=-1 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --getopt_long (); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) >= $ac_mid)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_lib_c_getopt_long=yes -+ ac_lo=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_c_getopt_long=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS --fi --echo "$as_me:$LINENO: result: $ac_cv_lib_c_getopt_long" >&5 --echo "${ECHO_T}$ac_cv_lib_c_getopt_long" >&6 --if test $ac_cv_lib_c_getopt_long = yes; then -- cat >>confdefs.h <<\_ACEOF --#define HAVE_GETOPT_LONG 1 --_ACEOF -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_hi=`expr '(' $ac_mid ')' - 1` -+ if test $ac_mid -le $ac_hi; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid` - fi -- -- --echo "$as_me:$LINENO: checking for alarm in -lc" >&5 --echo $ECHO_N "checking for alarm in -lc... $ECHO_C" >&6 --if test "${ac_cv_lib_c_alarm+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-lc $LIBS" --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char alarm (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ac_lo= ac_hi= -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+# Binary search between lo and hi bounds. -+while test "x$ac_lo" != "x$ac_hi"; do -+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default - int - main () - { --alarm (); -+static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) <= $ac_mid)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_lib_c_alarm=yes -+ ac_hi=$ac_mid - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_c_alarm=no --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS --fi --echo "$as_me:$LINENO: result: $ac_cv_lib_c_alarm" >&5 --echo "${ECHO_T}$ac_cv_lib_c_alarm" >&6 --if test $ac_cv_lib_c_alarm = yes; then -- cat >>confdefs.h <<\_ACEOF --#define HAVE_ALARM 1 --_ACEOF -- --fi -+sed 's/^/| /' conftest.$ac_ext >&5 - -- -- --for ac_header in netinet/in.h --do --as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ac_lo=`expr '(' $ac_mid ')' + 1` - fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+case $ac_lo in -+?*) ac_cv_sizeof_unsigned_int=$ac_lo;; -+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned int), 77 -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute sizeof (unsigned int), 77 -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } ;; -+esac - else -- # Is the header compilable? --echo "$as_me:$LINENO: checking $ac_header usability" >&5 --echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ if test "$cross_compiling" = yes; then -+ { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -+echo "$as_me: error: internal error: not reached in cross-compile" >&2;} -+ { (exit 1); exit 1; }; } -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default --#include <$ac_header> -+long longval () { return (long) (sizeof (unsigned int)); } -+unsigned long ulongval () { return (long) (sizeof (unsigned int)); } -+#include -+#include -+int -+main () -+{ -+ -+ FILE *f = fopen ("conftest.val", "w"); -+ if (! f) -+ exit (1); -+ if (((long) (sizeof (unsigned int))) < 0) -+ { -+ long i = longval (); -+ if (i != ((long) (sizeof (unsigned int)))) -+ exit (1); -+ fprintf (f, "%ld\n", i); -+ } -+ else -+ { -+ unsigned long i = ulongval (); -+ if (i != ((long) (sizeof (unsigned int)))) -+ exit (1); -+ fprintf (f, "%lu\n", i); -+ } -+ exit (ferror (f) || fclose (f) != 0); -+ -+ ; -+ return 0; -+} - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_header_compiler=yes -+ ac_cv_sizeof_unsigned_int=`cat conftest.val` - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_header_compiler=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 --echo "${ECHO_T}$ac_header_compiler" >&6 -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# Is the header present? --echo "$as_me:$LINENO: checking $ac_header presence" >&5 --echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include <$ac_header> -+( exit $ac_status ) -+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned int), 77 -+See \`config.log' for more details." >&5 -+echo "$as_me: error: cannot compute sizeof (unsigned int), 77 -+See \`config.log' for more details." >&2;} -+ { (exit 1); exit 1; }; } -+fi -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+fi -+rm -f conftest.val -+else -+ ac_cv_sizeof_unsigned_int=0 -+fi -+fi -+echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned_int" >&5 -+echo "${ECHO_T}$ac_cv_sizeof_unsigned_int" >&6 -+cat >>confdefs.h <<_ACEOF -+#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -- ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -+ -+ -+ -+GSM_VERSION="1:4:0" -+ -+ -+LINGUAS="de" -+ALL_LINGUAS=$LINGUAS -+ -+ -+ MKINSTALLDIRS= -+ if test -n "$ac_aux_dir"; then -+ case "$ac_aux_dir" in -+ /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; -+ *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; -+ esac - fi -+ if test -z "$MKINSTALLDIRS"; then -+ MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" -+ fi -+ -+ -+ -+ echo "$as_me:$LINENO: checking whether NLS is requested" >&5 -+echo $ECHO_N "checking whether NLS is requested... $ECHO_C" >&6 -+ # Check whether --enable-nls or --disable-nls was given. -+if test "${enable_nls+set}" = set; then -+ enableval="$enable_nls" -+ USE_NLS=$enableval - else -- ac_cpp_err=yes -+ USE_NLS=yes -+fi; -+ echo "$as_me:$LINENO: result: $USE_NLS" >&5 -+echo "${ECHO_T}$USE_NLS" >&6 -+ -+ -+ -+ -+ -+ -+# Prepare PATH_SEPARATOR. -+# The user is always right. -+if test "${PATH_SEPARATOR+set}" != set; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then -+ PATH_SEPARATOR=';' -+ else -+ PATH_SEPARATOR=: -+ fi -+ rm -f conf$$.sh - fi --if test -z "$ac_cpp_err"; then -- ac_header_preproc=yes -+ -+# Find out how to test for executable files. Don't use a zero-byte file, -+# as systems may use methods other than mode bits to determine executability. -+cat >conf$$.file <<_ASEOF -+#! /bin/sh -+exit 0 -+_ASEOF -+chmod +x conf$$.file -+if test -x conf$$.file >/dev/null 2>&1; then -+ ac_executable_p="test -x" - else -- echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- ac_header_preproc=no -+ ac_executable_p="test -f" - fi --rm -f conftest.err conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 --echo "${ECHO_T}$ac_header_preproc" >&6 -+rm -f conf$$.file - --# So? What about this header? --case $ac_header_compiler:$ac_header_preproc in -- yes:no ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 --echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -- no:yes ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 --echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; --esac --echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -+# Extract the first word of "msgfmt", so it can be a program name with args. -+set dummy msgfmt; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_path_MSGFMT+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- eval "$as_ac_Header=$ac_header_preproc" -+ case "$MSGFMT" in -+ [\\/]* | ?:[\\/]*) -+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. -+ ;; -+ *) -+ ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in $PATH; do -+ IFS="$ac_save_IFS" -+ test -z "$ac_dir" && ac_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then -+ echo "$as_me: trying $ac_dir/$ac_word..." >&5 -+ if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && -+ (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -+ ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" -+ break 2 -+ fi -+ fi -+ done -+ done -+ IFS="$ac_save_IFS" -+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" -+ ;; -+esac - fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+MSGFMT="$ac_cv_path_MSGFMT" -+if test "$MSGFMT" != ":"; then -+ echo "$as_me:$LINENO: result: $MSGFMT" >&5 -+echo "${ECHO_T}$MSGFMT" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+ # Extract the first word of "gmsgfmt", so it can be a program name with args. -+set dummy gmsgfmt; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_path_GMSGFMT+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ case $GMSGFMT in -+ [\\/]* | ?:[\\/]*) -+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. -+ ;; -+ *) -+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done - -+ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" -+ ;; -+esac - fi --if test `eval echo '${'$as_ac_Header'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 --_ACEOF -+GMSGFMT=$ac_cv_path_GMSGFMT - -+if test -n "$GMSGFMT"; then -+ echo "$as_me:$LINENO: result: $GMSGFMT" >&5 -+echo "${ECHO_T}$GMSGFMT" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 - fi - --done - - -+# Prepare PATH_SEPARATOR. -+# The user is always right. -+if test "${PATH_SEPARATOR+set}" != set; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then -+ PATH_SEPARATOR=';' -+ else -+ PATH_SEPARATOR=: -+ fi -+ rm -f conf$$.sh -+fi - --for ac_header in string.h --do --as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+# Find out how to test for executable files. Don't use a zero-byte file, -+# as systems may use methods other than mode bits to determine executability. -+cat >conf$$.file <<_ASEOF -+#! /bin/sh -+exit 0 -+_ASEOF -+chmod +x conf$$.file -+if test -x conf$$.file >/dev/null 2>&1; then -+ ac_executable_p="test -x" -+else -+ ac_executable_p="test -f" - fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+rm -f conf$$.file -+ -+# Extract the first word of "xgettext", so it can be a program name with args. -+set dummy xgettext; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_path_XGETTEXT+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- # Is the header compilable? --echo "$as_me:$LINENO: checking $ac_header usability" >&5 --echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#include <$ac_header> --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_header_compiler=yes -+ case "$XGETTEXT" in -+ [\\/]* | ?:[\\/]*) -+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. -+ ;; -+ *) -+ ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in $PATH; do -+ IFS="$ac_save_IFS" -+ test -z "$ac_dir" && ac_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then -+ echo "$as_me: trying $ac_dir/$ac_word..." >&5 -+ if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && -+ (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" -+ break 2 -+ fi -+ fi -+ done -+ done -+ IFS="$ac_save_IFS" -+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" -+ ;; -+esac -+fi -+XGETTEXT="$ac_cv_path_XGETTEXT" -+if test "$XGETTEXT" != ":"; then -+ echo "$as_me:$LINENO: result: $XGETTEXT" >&5 -+echo "${ECHO_T}$XGETTEXT" >&6 - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_header_compiler=no -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 - fi --rm -f conftest.$ac_objext conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 --echo "${ECHO_T}$ac_header_compiler" >&6 - --# Is the header present? --echo "$as_me:$LINENO: checking $ac_header presence" >&5 --echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include <$ac_header> --_ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -- ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -+ rm -f messages.po -+ -+ -+# Prepare PATH_SEPARATOR. -+# The user is always right. -+if test "${PATH_SEPARATOR+set}" != set; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then -+ PATH_SEPARATOR=';' - else -- ac_cpp_err= -+ PATH_SEPARATOR=: - fi --else -- ac_cpp_err=yes -+ rm -f conf$$.sh - fi --if test -z "$ac_cpp_err"; then -- ac_header_preproc=yes -+ -+# Find out how to test for executable files. Don't use a zero-byte file, -+# as systems may use methods other than mode bits to determine executability. -+cat >conf$$.file <<_ASEOF -+#! /bin/sh -+exit 0 -+_ASEOF -+chmod +x conf$$.file -+if test -x conf$$.file >/dev/null 2>&1; then -+ ac_executable_p="test -x" - else -- echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- ac_header_preproc=no -+ ac_executable_p="test -f" - fi --rm -f conftest.err conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 --echo "${ECHO_T}$ac_header_preproc" >&6 -+rm -f conf$$.file - --# So? What about this header? --case $ac_header_compiler:$ac_header_preproc in -- yes:no ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 --echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -- no:yes ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 --echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; --esac --echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -+# Extract the first word of "msgmerge", so it can be a program name with args. -+set dummy msgmerge; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_path_MSGMERGE+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- eval "$as_ac_Header=$ac_header_preproc" -+ case "$MSGMERGE" in -+ [\\/]* | ?:[\\/]*) -+ ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. -+ ;; -+ *) -+ ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR -+ for ac_dir in $PATH; do -+ IFS="$ac_save_IFS" -+ test -z "$ac_dir" && ac_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then -+ echo "$as_me: trying $ac_dir/$ac_word..." >&5 -+ if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then -+ ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" -+ break 2 -+ fi -+ fi -+ done -+ done -+ IFS="$ac_save_IFS" -+ test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" -+ ;; -+esac - fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -- -+MSGMERGE="$ac_cv_path_MSGMERGE" -+if test "$MSGMERGE" != ":"; then -+ echo "$as_me:$LINENO: result: $MSGMERGE" >&5 -+echo "${ECHO_T}$MSGMERGE" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 - fi --if test `eval echo '${'$as_ac_Header'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 --_ACEOF - --fi - --done -+ if test "$GMSGFMT" != ":"; then -+ if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && -+ (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -+ : ; -+ else -+ GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` -+ echo "$as_me:$LINENO: result: found $GMSGFMT program is not GNU msgfmt; ignore it" >&5 -+echo "${ECHO_T}found $GMSGFMT program is not GNU msgfmt; ignore it" >&6 -+ GMSGFMT=":" -+ fi -+ fi -+ -+ if test "$XGETTEXT" != ":"; then -+ if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && -+ (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -+ : ; -+ else -+ echo "$as_me:$LINENO: result: found xgettext program is not GNU xgettext; ignore it" >&5 -+echo "${ECHO_T}found xgettext program is not GNU xgettext; ignore it" >&6 -+ XGETTEXT=":" -+ fi -+ rm -f messages.po -+ fi - -+ ac_config_commands="$ac_config_commands default-1" - - --for ac_header in libintl.h --do --as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ -+ echo "$as_me:$LINENO: checking whether we are using the GNU C Library 2 or newer" >&5 -+echo $ECHO_N "checking whether we are using the GNU C Library 2 or newer... $ECHO_C" >&6 -+if test "${ac_cv_gnu_library_2+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - else -- # Is the header compilable? --echo "$as_me:$LINENO: checking $ac_header usability" >&5 --echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#include <$ac_header> -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_header_compiler=yes -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+#include -+#ifdef __GNU_LIBRARY__ -+ #if (__GLIBC__ >= 2) -+ Lucky GNU user -+ #endif -+#endif -+ -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "Lucky GNU user" >/dev/null 2>&1; then -+ ac_cv_gnu_library_2=yes - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_header_compiler=no -+ ac_cv_gnu_library_2=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 --echo "${ECHO_T}$ac_header_compiler" >&6 -+rm -f conftest* - --# Is the header present? --echo "$as_me:$LINENO: checking $ac_header presence" >&5 --echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include <$ac_header> --_ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -- ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi -+ -+ -+fi -+echo "$as_me:$LINENO: result: $ac_cv_gnu_library_2" >&5 -+echo "${ECHO_T}$ac_cv_gnu_library_2" >&6 -+ -+ GLIBC2="$ac_cv_gnu_library_2" -+ -+ -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -+set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_RANLIB+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- ac_cpp_err=yes -+ if test -n "$RANLIB"; then -+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done -+ - fi --if test -z "$ac_cpp_err"; then -- ac_header_preproc=yes -+fi -+RANLIB=$ac_cv_prog_RANLIB -+if test -n "$RANLIB"; then -+ echo "$as_me:$LINENO: result: $RANLIB" >&5 -+echo "${ECHO_T}$RANLIB" >&6 - else -- echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- ac_header_preproc=no -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 - fi --rm -f conftest.err conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 --echo "${ECHO_T}$ac_header_preproc" >&6 - --# So? What about this header? --case $ac_header_compiler:$ac_header_preproc in -- yes:no ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 --echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -- no:yes ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 --echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; --esac --echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -+fi -+if test -z "$ac_cv_prog_RANLIB"; then -+ ac_ct_RANLIB=$RANLIB -+ # Extract the first word of "ranlib", so it can be a program name with args. -+set dummy ranlib; ac_word=$2 -+echo "$as_me:$LINENO: checking for $ac_word" >&5 -+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- eval "$as_ac_Header=$ac_header_preproc" --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+ if test -n "$ac_ct_RANLIB"; then -+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_RANLIB="ranlib" -+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+done - -+ test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" - fi --if test `eval echo '${'$as_ac_Header'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 --_ACEOF -- -+fi -+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -+if test -n "$ac_ct_RANLIB"; then -+ echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -+echo "${ECHO_T}$ac_ct_RANLIB" >&6 -+else -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 - fi - --done -- -+ RANLIB=$ac_ct_RANLIB -+else -+ RANLIB="$ac_cv_prog_RANLIB" -+fi - --echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 --echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 --if test "${ac_cv_prog_cc_stdc+set}" = set; then -+echo "$as_me:$LINENO: checking for library containing strerror" >&5 -+echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6 -+if test "${ac_cv_search_strerror+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- ac_cv_prog_cc_stdc=no --ac_save_CC=$CC -+ ac_func_search_save_LIBS=$LIBS -+ac_cv_search_strerror=no - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --#include --#include --#include --/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ --struct buf { int x; }; --FILE * (*rcsopen) (struct buf *, struct stat *, int); --static char *e (p, i) -- char **p; -- int i; --{ -- return p[i]; --} --static char *f (char * (*g) (char **, int), char **p, ...) --{ -- char *s; -- va_list v; -- va_start (v,p); -- s = g (p, va_arg (v,int)); -- va_end (v); -- return s; --} --int test (int i, double x); --struct s1 {int (*f) (int a);}; --struct s2 {int (*f) (double a);}; --int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); --int argc; --char **argv; --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" - #endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char strerror (); - int - main () - { --return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; -+strerror (); - ; - return 0; - } - _ACEOF --# Don't try gcc -ansi; that turns off useful extensions and --# breaks some systems' header files. --# AIX -qlanglvl=ansi --# Ultrix and OSF/1 -std1 --# HP-UX 10.20 and later -Ae --# HP-UX older versions -Aa -D_HPUX_SOURCE --# SVR4 -Xc -D__EXTENSIONS__ --for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" --do -- CC="$ac_save_CC $ac_arg" -- rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_prog_cc_stdc=$ac_arg --break -+ ac_cv_search_strerror="none required" - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --fi --rm -f conftest.$ac_objext --done --rm -f conftest.$ac_ext conftest.$ac_objext --CC=$ac_save_CC -+sed 's/^/| /' conftest.$ac_ext >&5 - - fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+if test "$ac_cv_search_strerror" = no; then -+ for ac_lib in cposix; do -+ LIBS="-l$ac_lib $ac_func_search_save_LIBS" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - --case "x$ac_cv_prog_cc_stdc" in -- x|xno) -- echo "$as_me:$LINENO: result: none needed" >&5 --echo "${ECHO_T}none needed" >&6 ;; -- *) -- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 --echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 -- CC="$CC $ac_cv_prog_cc_stdc" ;; --esac -- --echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 --echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 --if test "${ac_cv_c_const+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" - #endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char strerror (); - int - main () - { --/* FIXME: Include the comments suggested by Paul. */ --#ifndef __cplusplus -- /* Ultrix mips cc rejects this. */ -- typedef int charset[2]; -- const charset x; -- /* SunOS 4.1.1 cc rejects this. */ -- char const *const *ccp; -- char **p; -- /* NEC SVR4.0.2 mips cc rejects this. */ -- struct point {int x, y;}; -- static struct point const zero = {0,0}; -- /* AIX XL C 1.02.0.0 rejects this. -- It does not let you subtract one const X* pointer from another in -- an arm of an if-expression whose if-part is not a constant -- expression */ -- const char *g = "string"; -- ccp = &g + (g ? g-g : 0); -- /* HPUX 7.0 cc rejects these. */ -- ++ccp; -- p = (char**) ccp; -- ccp = (char const *const *) p; -- { /* SCO 3.2v4 cc rejects this. */ -- char *t; -- char const *s = 0 ? (char *) 0 : (char const *) 0; -- -- *t++ = 0; -- } -- { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ -- int x[] = {25, 17}; -- const int *foo = &x[0]; -- ++foo; -- } -- { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ -- typedef const int *iptr; -- iptr p = 0; -- ++p; -- } -- { /* AIX XL C 1.02.0.0 rejects this saying -- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ -- struct s { int j; const int *ap[3]; }; -- struct s *b; b->j = 5; -- } -- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ -- const int foo = 10; -- } --#endif -+strerror (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_search_strerror="-l$ac_lib" -+break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ done -+fi -+LIBS=$ac_func_search_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 -+echo "${ECHO_T}$ac_cv_search_strerror" >&6 -+if test "$ac_cv_search_strerror" != no; then -+ test "$ac_cv_search_strerror" = "none required" || LIBS="$ac_cv_search_strerror $LIBS" -+ -+fi -+ -+ -+ echo "$as_me:$LINENO: checking for signed" >&5 -+echo $ECHO_N "checking for signed... $ECHO_C" >&6 -+if test "${bh_cv_c_signed+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - -+int -+main () -+{ -+signed char x; - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_c_const=yes -+ bh_cv_c_signed=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_c_const=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+bh_cv_c_signed=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 --echo "${ECHO_T}$ac_cv_c_const" >&6 --if test $ac_cv_c_const = no; then -+echo "$as_me:$LINENO: result: $bh_cv_c_signed" >&5 -+echo "${ECHO_T}$bh_cv_c_signed" >&6 -+ if test $bh_cv_c_signed = no; then - - cat >>confdefs.h <<\_ACEOF --#define const -+#define signed - _ACEOF - --fi -- -- --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include -+ fi - -+echo "$as_me:$LINENO: checking for inline" >&5 -+echo $ECHO_N "checking for inline... $ECHO_C" >&6 -+if test "${ac_cv_c_inline+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_cv_c_inline=no -+for ac_kw in inline __inline__ __inline; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF --if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- egrep "vsnprintf" >/dev/null 2>&1; then -- cat >>confdefs.h <<\_ACEOF --#define HAVE_VSNPRINTF 1 -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#ifndef __cplusplus -+typedef int foo_t; -+static $ac_kw foo_t static_foo () {return 0; } -+$ac_kw foo_t foo () {return 0; } -+#endif -+ - _ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_c_inline=$ac_kw; break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - - fi --rm -f conftest* -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+ -+fi -+echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 -+echo "${ECHO_T}$ac_cv_c_inline" >&6 - - --echo "$as_me:$LINENO: checking for unsigned short int" >&5 --echo $ECHO_N "checking for unsigned short int... $ECHO_C" >&6 --if test "${ac_cv_type_unsigned_short_int+set}" = set; then -+case $ac_cv_c_inline in -+ inline | yes) ;; -+ *) -+ case $ac_cv_c_inline in -+ no) ac_val=;; -+ *) ac_val=$ac_cv_c_inline;; -+ esac -+ cat >>confdefs.h <<_ACEOF -+#ifndef __cplusplus -+#define inline $ac_val -+#endif -+_ACEOF -+ ;; -+esac -+ -+echo "$as_me:$LINENO: checking for off_t" >&5 -+echo $ECHO_N "checking for off_t... $ECHO_C" >&6 -+if test "${ac_cv_type_off_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { --if ((unsigned short int *) 0) -+if ((off_t *) 0) - return 0; --if (sizeof (unsigned short int)) -+if (sizeof (off_t)) - return 0; - ; - return 0; -@@ -9066,136 +23441,198 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_type_unsigned_short_int=yes -+ ac_cv_type_off_t=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_type_unsigned_short_int=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_off_t=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_short_int" >&5 --echo "${ECHO_T}$ac_cv_type_unsigned_short_int" >&6 -+echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 -+echo "${ECHO_T}$ac_cv_type_off_t" >&6 -+if test $ac_cv_type_off_t = yes; then -+ : -+else - --echo "$as_me:$LINENO: checking size of unsigned short int" >&5 --echo $ECHO_N "checking size of unsigned short int... $ECHO_C" >&6 --if test "${ac_cv_sizeof_unsigned_short_int+set}" = set; then -+cat >>confdefs.h <<_ACEOF -+#define off_t long -+_ACEOF -+ -+fi -+ -+echo "$as_me:$LINENO: checking for size_t" >&5 -+echo $ECHO_N "checking for size_t... $ECHO_C" >&6 -+if test "${ac_cv_type_size_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test "$ac_cv_type_unsigned_short_int" = yes; then -- # The cast to unsigned long works around a bug in the HP C Compiler -- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -- # This bug is HP SR number 8606223364. -- if test "$cross_compiling" = yes; then -- # Depending upon the size, compute the lo and hi bounds. --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) >= 0)]; --test_array [0] = 0 -- -+if ((size_t *) 0) -+ return 0; -+if (sizeof (size_t)) -+ return 0; - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_lo=0 ac_mid=0 -- while :; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ ac_cv_type_size_t=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_size_t=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 -+echo "${ECHO_T}$ac_cv_type_size_t" >&6 -+if test $ac_cv_type_size_t = yes; then -+ : -+else -+ -+cat >>confdefs.h <<_ACEOF -+#define size_t unsigned -+_ACEOF -+ -+fi -+ -+ -+ echo "$as_me:$LINENO: checking for long long" >&5 -+echo $ECHO_N "checking for long long... $ECHO_C" >&6 -+if test "${ac_cv_type_long_long+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+long long ll = 1LL; int i = 63; - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) <= $ac_mid)]; --test_array [0] = 0 -- -+long long llmax = (long long) -1; -+ return ll << i | ll >> i | llmax / ll | llmax % ll; - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=$ac_mid; break -+ ac_cv_type_long_long=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo=`expr $ac_mid + 1` -- if test $ac_lo -le $ac_mid; then -- ac_lo= ac_hi= -- break -- fi -- ac_mid=`expr 2 '*' $ac_mid + 1` -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_long_long=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -- done -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 -+echo "${ECHO_T}$ac_cv_type_long_long" >&6 -+ if test $ac_cv_type_long_long = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_LONG_LONG 1 -+_ACEOF -+ -+ fi -+ -+ -+ echo "$as_me:$LINENO: checking for long double" >&5 -+echo $ECHO_N "checking for long double... $ECHO_C" >&6 -+if test "${gt_cv_c_long_double+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ if test "$GCC" = yes; then -+ gt_cv_c_long_double=yes -+ else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+ /* The Stardent Vistra knows sizeof(long double), but does not support it. */ -+ long double foo = 0.0; -+ /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ -+ int array [2*(sizeof(long double) >= sizeof(double)) - 1]; -+ - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) < 0)]; --test_array [0] = 0 - - ; - return 0; -@@ -9203,33 +23640,62 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=-1 ac_mid=-1 -- while :; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ gt_cv_c_long_double=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_c_long_double=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ fi -+fi -+echo "$as_me:$LINENO: result: $gt_cv_c_long_double" >&5 -+echo "${ECHO_T}$gt_cv_c_long_double" >&6 -+ if test $gt_cv_c_long_double = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_LONG_DOUBLE 1 -+_ACEOF -+ -+ fi -+ -+ -+ echo "$as_me:$LINENO: checking for wchar_t" >&5 -+echo $ECHO_N "checking for wchar_t... $ECHO_C" >&6 -+if test "${gt_cv_c_wchar_t+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+ wchar_t foo = (wchar_t)'\0'; - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) >= $ac_mid)]; --test_array [0] = 0 - - ; - return 0; -@@ -9237,55 +23703,61 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_lo=$ac_mid; break --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_hi=`expr '(' $ac_mid ')' - 1` -- if test $ac_mid -le $ac_hi; then -- ac_lo= ac_hi= -- break -- fi -- ac_mid=`expr 2 '*' $ac_mid` --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- done -+ gt_cv_c_wchar_t=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo= ac_hi= -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_c_wchar_t=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --rm -f conftest.$ac_objext conftest.$ac_ext --# Binary search between lo and hi bounds. --while test "x$ac_lo" != "x$ac_hi"; do -- ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+echo "$as_me:$LINENO: result: $gt_cv_c_wchar_t" >&5 -+echo "${ECHO_T}$gt_cv_c_wchar_t" >&6 -+ if test $gt_cv_c_wchar_t = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_WCHAR_T 1 -+_ACEOF -+ -+ fi -+ -+ -+ echo "$as_me:$LINENO: checking for wint_t" >&5 -+echo $ECHO_N "checking for wint_t... $ECHO_C" >&6 -+if test "${gt_cv_c_wint_t+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+ wint_t foo = (wchar_t)'\0'; - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned short int))) <= $ac_mid)]; --test_array [0] = 0 - - ; - return 0; -@@ -9293,437 +23765,717 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=$ac_mid -+ gt_cv_c_wint_t=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo=`expr '(' $ac_mid ')' + 1` -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_c_wint_t=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext --done --case $ac_lo in --?*) ac_cv_sizeof_unsigned_short_int=$ac_lo;; --'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned short int), 77" >&5 --echo "$as_me: error: cannot compute sizeof (unsigned short int), 77" >&2;} -- { (exit 1); exit 1; }; } ;; --esac --else -- if test "$cross_compiling" = yes; then -- { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 --echo "$as_me: error: cannot run test program while cross compiling" >&2;} -- { (exit 1); exit 1; }; } -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $gt_cv_c_wint_t" >&5 -+echo "${ECHO_T}$gt_cv_c_wint_t" >&6 -+ if test $gt_cv_c_wint_t = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_WINT_T 1 -+_ACEOF -+ -+ fi -+ -+ -+ echo "$as_me:$LINENO: checking for inttypes.h" >&5 -+echo $ECHO_N "checking for inttypes.h... $ECHO_C" >&6 -+if test "${gl_cv_header_inttypes_h+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --long longval () { return (long) (sizeof (unsigned short int)); } --unsigned long ulongval () { return (long) (sizeof (unsigned short int)); } --#include --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+#include - int - main () - { -- -- FILE *f = fopen ("conftest.val", "w"); -- if (! f) -- exit (1); -- if (((long) (sizeof (unsigned short int))) < 0) -- { -- long i = longval (); -- if (i != ((long) (sizeof (unsigned short int)))) -- exit (1); -- fprintf (f, "%ld\n", i); -- } -- else -- { -- unsigned long i = ulongval (); -- if (i != ((long) (sizeof (unsigned short int)))) -- exit (1); -- fprintf (f, "%lu\n", i); -- } -- exit (ferror (f) || fclose (f) != 0); -- -+uintmax_t i = (uintmax_t) -1; - ; - return 0; - } - _ACEOF --rm -f conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_sizeof_unsigned_short_int=`cat conftest.val` --else -- echo "$as_me: program exited with status $ac_status" >&5 --echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --( exit $ac_status ) --{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned short int), 77" >&5 --echo "$as_me: error: cannot compute sizeof (unsigned short int), 77" >&2;} -- { (exit 1); exit 1; }; } --fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext --fi --fi --rm -f conftest.val -+ gl_cv_header_inttypes_h=yes - else -- ac_cv_sizeof_unsigned_short_int=0 -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gl_cv_header_inttypes_h=no - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned_short_int" >&5 --echo "${ECHO_T}$ac_cv_sizeof_unsigned_short_int" >&6 -+echo "$as_me:$LINENO: result: $gl_cv_header_inttypes_h" >&5 -+echo "${ECHO_T}$gl_cv_header_inttypes_h" >&6 -+ if test $gl_cv_header_inttypes_h = yes; then -+ - cat >>confdefs.h <<_ACEOF --#define SIZEOF_UNSIGNED_SHORT_INT $ac_cv_sizeof_unsigned_short_int -+#define HAVE_INTTYPES_H_WITH_UINTMAX 1 - _ACEOF - -+ fi - --echo "$as_me:$LINENO: checking for unsigned long int" >&5 --echo $ECHO_N "checking for unsigned long int... $ECHO_C" >&6 --if test "${ac_cv_type_unsigned_long_int+set}" = set; then -+ -+ echo "$as_me:$LINENO: checking for stdint.h" >&5 -+echo $ECHO_N "checking for stdint.h... $ECHO_C" >&6 -+if test "${gl_cv_header_stdint_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+#include - int - main () - { --if ((unsigned long int *) 0) -- return 0; --if (sizeof (unsigned long int)) -- return 0; -+uintmax_t i = (uintmax_t) -1; - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_type_unsigned_long_int=yes -+ gl_cv_header_stdint_h=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_type_unsigned_long_int=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gl_cv_header_stdint_h=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_long_int" >&5 --echo "${ECHO_T}$ac_cv_type_unsigned_long_int" >&6 -+echo "$as_me:$LINENO: result: $gl_cv_header_stdint_h" >&5 -+echo "${ECHO_T}$gl_cv_header_stdint_h" >&6 -+ if test $gl_cv_header_stdint_h = yes; then - --echo "$as_me:$LINENO: checking size of unsigned long int" >&5 --echo $ECHO_N "checking size of unsigned long int... $ECHO_C" >&6 --if test "${ac_cv_sizeof_unsigned_long_int+set}" = set; then -+cat >>confdefs.h <<_ACEOF -+#define HAVE_STDINT_H_WITH_UINTMAX 1 -+_ACEOF -+ -+ fi -+ -+ -+ -+ -+ echo "$as_me:$LINENO: checking for intmax_t" >&5 -+echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 -+if test "${gt_cv_c_intmax_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test "$ac_cv_type_unsigned_long_int" = yes; then -- # The cast to unsigned long works around a bug in the HP C Compiler -- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -- # This bug is HP SR number 8606223364. -- if test "$cross_compiling" = yes; then -- # Depending upon the size, compute the lo and hi bounds. --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+#include -+#include -+#if HAVE_STDINT_H_WITH_UINTMAX -+#include -+#endif -+#if HAVE_INTTYPES_H_WITH_UINTMAX -+#include - #endif -+ - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) >= 0)]; --test_array [0] = 0 -- -+intmax_t x = -1; - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_lo=0 ac_mid=0 -- while :; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+ gt_cv_c_intmax_t=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_c_intmax_t=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $gt_cv_c_intmax_t" >&5 -+echo "${ECHO_T}$gt_cv_c_intmax_t" >&6 -+ if test $gt_cv_c_intmax_t = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_INTMAX_T 1 -+_ACEOF -+ -+ fi -+ -+ -+ -+ echo "$as_me:$LINENO: checking whether printf() supports POSIX/XSI format strings" >&5 -+echo $ECHO_N "checking whether printf() supports POSIX/XSI format strings... $ECHO_C" >&6 -+if test "${gt_cv_func_printf_posix+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ -+ if test "$cross_compiling" = yes; then -+ -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ -+ notposix - #endif --int --main () --{ --static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) <= $ac_mid)]; --test_array [0] = 0 - -- ; -- return 0; -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "notposix" >/dev/null 2>&1; then -+ gt_cv_func_printf_posix="guessing no" -+else -+ gt_cv_func_printf_posix="guessing yes" -+fi -+rm -f conftest* -+ -+ -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+#include -+#include -+/* The string "%2$d %1$d", with dollar characters protected from the shell's -+ dollar expansion (possibly an autoconf bug). */ -+static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; -+static char buf[100]; -+int main () -+{ -+ sprintf (buf, format, 33, 55); -+ return (strcmp (buf, "55 33") != 0); - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=$ac_mid; break -+ gt_cv_func_printf_posix=yes - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo=`expr $ac_mid + 1` -- if test $ac_lo -le $ac_mid; then -- ac_lo= ac_hi= -- break -- fi -- ac_mid=`expr 2 '*' $ac_mid + 1` -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+( exit $ac_status ) -+gt_cv_func_printf_posix=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -- done -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+ -+fi -+echo "$as_me:$LINENO: result: $gt_cv_func_printf_posix" >&5 -+echo "${ECHO_T}$gt_cv_func_printf_posix" >&6 -+ case $gt_cv_func_printf_posix in -+ *yes) -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_POSIX_PRINTF 1 -+_ACEOF -+ -+ ;; -+ esac -+ -+ -+ -+for ac_header in stdlib.h unistd.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) < 0)]; --test_array [0] = 0 -- -- ; -- return 0; --} -+#include <$ac_header> - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_hi=-1 ac_mid=-1 -- while :; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) >= $ac_mid)]; --test_array [0] = 0 -- -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_lo=$ac_mid; break -+ ac_header_compiler=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_hi=`expr '(' $ac_mid ')' - 1` -- if test $ac_mid -le $ac_hi; then -- ac_lo= ac_hi= -- break -- fi -- ac_mid=`expr 2 '*' $ac_mid` -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_header_compiler=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -- done -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 -+ -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo= ac_hi= -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 -+ -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+ - fi --rm -f conftest.$ac_objext conftest.$ac_ext --# Binary search between lo and hi bounds. --while test "x$ac_lo" != "x$ac_hi"; do -- ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF -+ -+fi -+ -+done -+ -+ -+for ac_func in getpagesize -+do -+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -+echo "$as_me:$LINENO: checking for $ac_func" >&5 -+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_var+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define $ac_func to an innocuous variant, in case declares $ac_func. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define $ac_func innocuous_$ac_func -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char $ac_func (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef $ac_func -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char $ac_func (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -+choke me -+#else -+char (*f) () = $ac_func; -+#endif -+#ifdef __cplusplus -+} - #endif -+ - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned long int))) <= $ac_mid)]; --test_array [0] = 0 -- -+return f != $ac_func; - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=$ac_mid -+ eval "$as_ac_var=yes" - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo=`expr '(' $ac_mid ')' + 1` -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+eval "$as_ac_var=no" -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -+if test `eval echo '${'$as_ac_var'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -+_ACEOF -+ - fi --rm -f conftest.$ac_objext conftest.$ac_ext - done --case $ac_lo in --?*) ac_cv_sizeof_unsigned_long_int=$ac_lo;; --'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned long int), 77" >&5 --echo "$as_me: error: cannot compute sizeof (unsigned long int), 77" >&2;} -- { (exit 1); exit 1; }; } ;; --esac -+ -+echo "$as_me:$LINENO: checking for working mmap" >&5 -+echo $ECHO_N "checking for working mmap... $ECHO_C" >&6 -+if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else - if test "$cross_compiling" = yes; then -- { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 --echo "$as_me: error: cannot run test program while cross compiling" >&2;} -- { (exit 1); exit 1; }; } -+ ac_cv_func_mmap_fixed_mapped=no - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - $ac_includes_default --long longval () { return (long) (sizeof (unsigned long int)); } --unsigned long ulongval () { return (long) (sizeof (unsigned long int)); } --#include --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+/* malloc might have been renamed as rpl_malloc. */ -+#undef malloc -+ -+/* Thanks to Mike Haertel and Jim Avera for this test. -+ Here is a matrix of mmap possibilities: -+ mmap private not fixed -+ mmap private fixed at somewhere currently unmapped -+ mmap private fixed at somewhere already mapped -+ mmap shared not fixed -+ mmap shared fixed at somewhere currently unmapped -+ mmap shared fixed at somewhere already mapped -+ For private mappings, we should verify that changes cannot be read() -+ back from the file, nor mmap's back from the file at a different -+ address. (There have been systems where private was not correctly -+ implemented like the infamous i386 svr4.0, and systems where the -+ VM page cache was not coherent with the file system buffer cache -+ like early versions of FreeBSD and possibly contemporary NetBSD.) -+ For shared mappings, we should conversely verify that changes get -+ propagated back to all the places they're supposed to be. -+ -+ Grep wants private fixed already mapped. -+ The main things grep needs to know about mmap are: -+ * does it exist and is it safe to write into the mmap'd area -+ * how to use it (BSD variants) */ -+ -+#include -+#include -+ -+#if !STDC_HEADERS && !HAVE_STDLIB_H -+char *malloc (); - #endif -+ -+/* This mess was copied from the GNU getpagesize.h. */ -+#if !HAVE_GETPAGESIZE -+/* Assume that all systems that can run configure have sys/param.h. */ -+# if !HAVE_SYS_PARAM_H -+# define HAVE_SYS_PARAM_H 1 -+# endif -+ -+# ifdef _SC_PAGESIZE -+# define getpagesize() sysconf(_SC_PAGESIZE) -+# else /* no _SC_PAGESIZE */ -+# if HAVE_SYS_PARAM_H -+# include -+# ifdef EXEC_PAGESIZE -+# define getpagesize() EXEC_PAGESIZE -+# else /* no EXEC_PAGESIZE */ -+# ifdef NBPG -+# define getpagesize() NBPG * CLSIZE -+# ifndef CLSIZE -+# define CLSIZE 1 -+# endif /* no CLSIZE */ -+# else /* no NBPG */ -+# ifdef NBPC -+# define getpagesize() NBPC -+# else /* no NBPC */ -+# ifdef PAGESIZE -+# define getpagesize() PAGESIZE -+# endif /* PAGESIZE */ -+# endif /* no NBPC */ -+# endif /* no NBPG */ -+# endif /* no EXEC_PAGESIZE */ -+# else /* no HAVE_SYS_PARAM_H */ -+# define getpagesize() 8192 /* punt totally */ -+# endif /* no HAVE_SYS_PARAM_H */ -+# endif /* no _SC_PAGESIZE */ -+ -+#endif /* no HAVE_GETPAGESIZE */ -+ - int - main () - { -+ char *data, *data2, *data3; -+ int i, pagesize; -+ int fd; - -- FILE *f = fopen ("conftest.val", "w"); -- if (! f) -+ pagesize = getpagesize (); -+ -+ /* First, make a file with some known garbage in it. */ -+ data = (char *) malloc (pagesize); -+ if (!data) - exit (1); -- if (((long) (sizeof (unsigned long int))) < 0) -- { -- long i = longval (); -- if (i != ((long) (sizeof (unsigned long int)))) -- exit (1); -- fprintf (f, "%ld\n", i); -- } -- else -- { -- unsigned long i = ulongval (); -- if (i != ((long) (sizeof (unsigned long int)))) -- exit (1); -- fprintf (f, "%lu\n", i); -- } -- exit (ferror (f) || fclose (f) != 0); -+ for (i = 0; i < pagesize; ++i) -+ *(data + i) = rand (); -+ umask (0); -+ fd = creat ("conftest.mmap", 0600); -+ if (fd < 0) -+ exit (1); -+ if (write (fd, data, pagesize) != pagesize) -+ exit (1); -+ close (fd); - -- ; -- return 0; -+ /* Next, try to mmap the file at a fixed address which already has -+ something else allocated at it. If we can, also make sure that -+ we see the same garbage. */ -+ fd = open ("conftest.mmap", O_RDWR); -+ if (fd < 0) -+ exit (1); -+ data2 = (char *) malloc (2 * pagesize); -+ if (!data2) -+ exit (1); -+ data2 += (pagesize - ((long) data2 & (pagesize - 1))) & (pagesize - 1); -+ if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, -+ MAP_PRIVATE | MAP_FIXED, fd, 0L)) -+ exit (1); -+ for (i = 0; i < pagesize; ++i) -+ if (*(data + i) != *(data2 + i)) -+ exit (1); -+ -+ /* Finally, make sure that changes to the mapped area do not -+ percolate back to the file as seen by read(). (This is a bug on -+ some variants of i386 svr4.0.) */ -+ for (i = 0; i < pagesize; ++i) -+ *(data2 + i) = *(data2 + i) + 1; -+ data3 = (char *) malloc (pagesize); -+ if (!data3) -+ exit (1); -+ if (read (fd, data3, pagesize) != pagesize) -+ exit (1); -+ for (i = 0; i < pagesize; ++i) -+ if (*(data + i) != *(data3 + i)) -+ exit (1); -+ close (fd); -+ exit (0); - } - _ACEOF - rm -f conftest$ac_exeext -@@ -9737,279 +24489,268 @@ - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_sizeof_unsigned_long_int=`cat conftest.val` -+ ac_cv_func_mmap_fixed_mapped=yes - else - echo "$as_me: program exited with status $ac_status" >&5 - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ( exit $ac_status ) --{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned long int), 77" >&5 --echo "$as_me: error: cannot compute sizeof (unsigned long int), 77" >&2;} -- { (exit 1); exit 1; }; } --fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext --fi -+ac_cv_func_mmap_fixed_mapped=no - fi --rm -f conftest.val --else -- ac_cv_sizeof_unsigned_long_int=0 -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext - fi - fi --echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned_long_int" >&5 --echo "${ECHO_T}$ac_cv_sizeof_unsigned_long_int" >&6 --cat >>confdefs.h <<_ACEOF --#define SIZEOF_UNSIGNED_LONG_INT $ac_cv_sizeof_unsigned_long_int -+echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 -+echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6 -+if test $ac_cv_func_mmap_fixed_mapped = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_MMAP 1 - _ACEOF - -+fi -+rm -f conftest.mmap - --echo "$as_me:$LINENO: checking for unsigned int" >&5 --echo $ECHO_N "checking for unsigned int... $ECHO_C" >&6 --if test "${ac_cv_type_unsigned_int+set}" = set; then -+ -+ echo "$as_me:$LINENO: checking whether we are using the GNU C Library 2.1 or newer" >&5 -+echo $ECHO_N "checking whether we are using the GNU C Library 2.1 or newer... $ECHO_C" >&6 -+if test "${ac_cv_gnu_library_2_1+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+#include -+#ifdef __GNU_LIBRARY__ -+ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) -+ Lucky GNU user -+ #endif - #endif --int --main () --{ --if ((unsigned int *) 0) -- return 0; --if (sizeof (unsigned int)) -- return 0; -- ; -- return 0; --} -+ - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_type_unsigned_int=yes -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "Lucky GNU user" >/dev/null 2>&1; then -+ ac_cv_gnu_library_2_1=yes - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_type_unsigned_int=no -+ ac_cv_gnu_library_2_1=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest* -+ -+ -+ - fi --echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_int" >&5 --echo "${ECHO_T}$ac_cv_type_unsigned_int" >&6 -+echo "$as_me:$LINENO: result: $ac_cv_gnu_library_2_1" >&5 -+echo "${ECHO_T}$ac_cv_gnu_library_2_1" >&6 - --echo "$as_me:$LINENO: checking size of unsigned int" >&5 --echo $ECHO_N "checking size of unsigned int... $ECHO_C" >&6 --if test "${ac_cv_sizeof_unsigned_int+set}" = set; then -+ GLIBC21="$ac_cv_gnu_library_2_1" -+ -+ -+ -+ -+ echo "$as_me:$LINENO: checking whether integer division by zero raises SIGFPE" >&5 -+echo $ECHO_N "checking whether integer division by zero raises SIGFPE... $ECHO_C" >&6 -+if test "${gt_cv_int_divbyzero_sigfpe+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- if test "$ac_cv_type_unsigned_int" = yes; then -- # The cast to unsigned long works around a bug in the HP C Compiler -- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -- # This bug is HP SR number 8606223364. -- if test "$cross_compiling" = yes; then -- # Depending upon the size, compute the lo and hi bounds. --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) >= 0)]; --test_array [0] = 0 - -- ; -- return 0; --} -+ if test "$cross_compiling" = yes; then -+ -+ # Guess based on the CPU. -+ case "$host_cpu" in -+ alpha* | i3456786 | m68k | s390*) -+ gt_cv_int_divbyzero_sigfpe="guessing yes";; -+ *) -+ gt_cv_int_divbyzero_sigfpe="guessing no";; -+ esac -+ -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_lo=0 ac_mid=0 -- while :; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+#include -+#include -+ -+static void -+#ifdef __cplusplus -+sigfpe_handler (int sig) -+#else -+sigfpe_handler (sig) int sig; - #endif --int --main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) <= $ac_mid)]; --test_array [0] = 0 -+ /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ -+ exit (sig != SIGFPE); -+} - -- ; -- return 0; -+int x = 1; -+int y = 0; -+int z; -+int nan; -+ -+int main () -+{ -+ signal (SIGFPE, sigfpe_handler); -+/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ -+#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) -+ signal (SIGTRAP, sigfpe_handler); -+#endif -+/* Linux/SPARC yields signal SIGILL. */ -+#if defined (__sparc__) && defined (__linux__) -+ signal (SIGILL, sigfpe_handler); -+#endif -+ -+ z = x / y; -+ nan = y / y; -+ exit (1); - } -+ - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=$ac_mid; break -+ gt_cv_int_divbyzero_sigfpe=yes - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo=`expr $ac_mid + 1` -- if test $ac_lo -le $ac_mid; then -- ac_lo= ac_hi= -- break -- fi -- ac_mid=`expr 2 '*' $ac_mid + 1` -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+( exit $ac_status ) -+gt_cv_int_divbyzero_sigfpe=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -- done -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+ -+fi -+echo "$as_me:$LINENO: result: $gt_cv_int_divbyzero_sigfpe" >&5 -+echo "${ECHO_T}$gt_cv_int_divbyzero_sigfpe" >&6 -+ case "$gt_cv_int_divbyzero_sigfpe" in -+ *yes) value=1;; -+ *) value=0;; -+ esac -+ -+cat >>confdefs.h <<_ACEOF -+#define INTDIV0_RAISES_SIGFPE $value -+_ACEOF -+ -+ -+ -+ echo "$as_me:$LINENO: checking for unsigned long long" >&5 -+echo $ECHO_N "checking for unsigned long long... $ECHO_C" >&6 -+if test "${ac_cv_type_unsigned_long_long+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+unsigned long long ull = 1ULL; int i = 63; - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) < 0)]; --test_array [0] = 0 -- -+unsigned long long ullmax = (unsigned long long) -1; -+ return ull << i | ull >> i | ullmax / ull | ullmax % ull; - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_hi=-1 ac_mid=-1 -- while :; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) >= $ac_mid)]; --test_array [0] = 0 -- -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_lo=$ac_mid; break --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_hi=`expr '(' $ac_mid ')' - 1` -- if test $ac_mid -le $ac_hi; then -- ac_lo= ac_hi= -- break -- fi -- ac_mid=`expr 2 '*' $ac_mid` --fi --rm -f conftest.$ac_objext conftest.$ac_ext -- done -+ ac_cv_type_unsigned_long_long=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo= ac_hi= -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_unsigned_long_long=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - fi --rm -f conftest.$ac_objext conftest.$ac_ext --# Binary search between lo and hi bounds. --while test "x$ac_lo" != "x$ac_hi"; do -- ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_long_long" >&5 -+echo "${ECHO_T}$ac_cv_type_unsigned_long_long" >&6 -+ if test $ac_cv_type_unsigned_long_long = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_UNSIGNED_LONG_LONG 1 -+_ACEOF -+ -+ fi -+ -+ -+ -+ -+ if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then -+ -+ test $ac_cv_type_unsigned_long_long = yes \ -+ && ac_type='unsigned long long' \ -+ || ac_type='unsigned long' -+ -+cat >>confdefs.h <<_ACEOF -+#define uintmax_t $ac_type -+_ACEOF -+ -+ else -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_UINTMAX_T 1 -+_ACEOF -+ -+ fi -+ -+ -+ echo "$as_me:$LINENO: checking for inttypes.h" >&5 -+echo $ECHO_N "checking for inttypes.h... $ECHO_C" >&6 -+if test "${gt_cv_header_inttypes_h+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+#include - int - main () - { --static int test_array [1 - 2 * !(((long) (sizeof (unsigned int))) <= $ac_mid)]; --test_array [0] = 0 - - ; - return 0; -@@ -10017,1079 +24758,1229 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_hi=$ac_mid -+ gt_cv_header_inttypes_h=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_lo=`expr '(' $ac_mid ')' + 1` -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_header_inttypes_h=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext --done --case $ac_lo in --?*) ac_cv_sizeof_unsigned_int=$ac_lo;; --'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned int), 77" >&5 --echo "$as_me: error: cannot compute sizeof (unsigned int), 77" >&2;} -- { (exit 1); exit 1; }; } ;; --esac --else -- if test "$cross_compiling" = yes; then -- { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 --echo "$as_me: error: cannot run test program while cross compiling" >&2;} -- { (exit 1); exit 1; }; } -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ -+fi -+echo "$as_me:$LINENO: result: $gt_cv_header_inttypes_h" >&5 -+echo "${ECHO_T}$gt_cv_header_inttypes_h" >&6 -+ if test $gt_cv_header_inttypes_h = yes; then -+ -+cat >>confdefs.h <<_ACEOF -+#define HAVE_INTTYPES_H 1 -+_ACEOF -+ -+ fi -+ -+ -+ -+ if test $gt_cv_header_inttypes_h = yes; then -+ echo "$as_me:$LINENO: checking whether the inttypes.h PRIxNN macros are broken" >&5 -+echo $ECHO_N "checking whether the inttypes.h PRIxNN macros are broken... $ECHO_C" >&6 -+if test "${gt_cv_inttypes_pri_broken+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --long longval () { return (long) (sizeof (unsigned int)); } --unsigned long ulongval () { return (long) (sizeof (unsigned int)); } --#include --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ - -- FILE *f = fopen ("conftest.val", "w"); -- if (! f) -- exit (1); -- if (((long) (sizeof (unsigned int))) < 0) -- { -- long i = longval (); -- if (i != ((long) (sizeof (unsigned int)))) -- exit (1); -- fprintf (f, "%ld\n", i); -- } -- else -- { -- unsigned long i = ulongval (); -- if (i != ((long) (sizeof (unsigned int)))) -- exit (1); -- fprintf (f, "%lu\n", i); -- } -- exit (ferror (f) || fclose (f) != 0); -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+#ifdef PRId32 -+char *p = PRId32; -+#endif -+ -+int -+main () -+{ - - ; - return 0; - } - _ACEOF --rm -f conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_sizeof_unsigned_int=`cat conftest.val` --else -- echo "$as_me: program exited with status $ac_status" >&5 --echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --( exit $ac_status ) --{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned int), 77" >&5 --echo "$as_me: error: cannot compute sizeof (unsigned int), 77" >&2;} -- { (exit 1); exit 1; }; } --fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext --fi --fi --rm -f conftest.val -+ gt_cv_inttypes_pri_broken=no - else -- ac_cv_sizeof_unsigned_int=0 -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_inttypes_pri_broken=yes - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ - fi --echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned_int" >&5 --echo "${ECHO_T}$ac_cv_sizeof_unsigned_int" >&6 -+echo "$as_me:$LINENO: result: $gt_cv_inttypes_pri_broken" >&5 -+echo "${ECHO_T}$gt_cv_inttypes_pri_broken" >&6 -+ fi -+ if test "$gt_cv_inttypes_pri_broken" = yes; then -+ - cat >>confdefs.h <<_ACEOF --#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int -+#define PRI_MACROS_BROKEN 1 - _ACEOF - -- -- --GSM_VERSION="1:4:0" -- -- --LINGUAS="de" --ALL_LINGUAS=$LINGUAS -- -- MKINSTALLDIRS= -- if test -n "$ac_aux_dir"; then -- MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" -- fi -- if test -z "$MKINSTALLDIRS"; then -- MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" - fi - - - -- -- -- # Extract the first word of "msgfmt", so it can be a program name with args. --set dummy msgfmt; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_path_MSGFMT+set}" = set; then -+for ac_header in stdint.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- case "$MSGFMT" in -- /*) -- ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. -- ;; -- *) -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" -- for ac_dir in $PATH; do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/$ac_word; then -- if $ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && -- (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -- ac_cv_path_MSGFMT="$ac_dir/$ac_word" -- break -- fi -- fi -- done -- IFS="$ac_save_ifs" -- test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" -- ;; --esac - fi --MSGFMT="$ac_cv_path_MSGFMT" --if test "$MSGFMT" != ":"; then -- echo "$as_me:$LINENO: result: $MSGFMT" >&5 --echo "${ECHO_T}$MSGFMT" >&6 -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -- -- # Extract the first word of "gmsgfmt", so it can be a program name with args. --set dummy gmsgfmt; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_path_GMSGFMT+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes - else -- case $GMSGFMT in -- [\\/]* | ?:[\\/]*) -- ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. -- ;; -- *) -- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" -- ;; --esac -+ac_header_compiler=no - fi --GMSGFMT=$ac_cv_path_GMSGFMT -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 - --if test -n "$GMSGFMT"; then -- echo "$as_me:$LINENO: result: $GMSGFMT" >&5 --echo "${ECHO_T}$GMSGFMT" >&6 -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+ ac_cpp_err=yes - fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 - -- # Extract the first word of "xgettext", so it can be a program name with args. --set dummy xgettext; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_path_XGETTEXT+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- case "$XGETTEXT" in -- /*) -- ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. -- ;; -- *) -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" -- for ac_dir in $PATH; do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/$ac_word; then -- if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 && -- (if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -- ac_cv_path_XGETTEXT="$ac_dir/$ac_word" -- break -- fi -- fi -- done -- IFS="$ac_save_ifs" -- test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" -- ;; -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; - esac --fi --XGETTEXT="$ac_cv_path_XGETTEXT" --if test "$XGETTEXT" != ":"; then -- echo "$as_me:$LINENO: result: $XGETTEXT" >&5 --echo "${ECHO_T}$XGETTEXT" >&6 -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+ eval "$as_ac_Header=\$ac_header_preproc" - fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -- rm -f messages.po -- -- # Extract the first word of "msgmerge", so it can be a program name with args. --set dummy msgmerge; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_path_MSGMERGE+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- case "$MSGMERGE" in -- /*) -- ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. -- ;; -- *) -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" -- for ac_dir in $PATH; do -- test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/$ac_word; then -- if $ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1; then -- ac_cv_path_MSGMERGE="$ac_dir/$ac_word" -- break -- fi -- fi -- done -- IFS="$ac_save_ifs" -- test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" -- ;; --esac - fi --MSGMERGE="$ac_cv_path_MSGMERGE" --if test "$MSGMERGE" != ":"; then -- echo "$as_me:$LINENO: result: $MSGMERGE" >&5 --echo "${ECHO_T}$MSGMERGE" >&6 --else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF -+ - fi - -+done - -- if test "$GMSGFMT" != ":"; then -- if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && -- (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -- : ; -- else -- GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` -- echo "$as_me:$LINENO: result: found $GMSGFMT program is not GNU msgfmt; ignore it" >&5 --echo "${ECHO_T}found $GMSGFMT program is not GNU msgfmt; ignore it" >&6 -- GMSGFMT=":" -- fi -- fi -+ echo "$as_me:$LINENO: checking for SIZE_MAX" >&5 -+echo $ECHO_N "checking for SIZE_MAX... $ECHO_C" >&6 -+ result= -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - -- if test "$XGETTEXT" != ":"; then -- if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 && -- (if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then -- : ; -- else -- echo "$as_me:$LINENO: result: found xgettext program is not GNU xgettext; ignore it" >&5 --echo "${ECHO_T}found xgettext program is not GNU xgettext; ignore it" >&6 -- XGETTEXT=":" -- fi -- rm -f messages.po -- fi -+#include -+#if HAVE_STDINT_H -+#include -+#endif -+#ifdef SIZE_MAX -+Found it -+#endif - -- ac_config_commands="$ac_config_commands default-1" -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "Found it" >/dev/null 2>&1; then -+ result=yes -+fi -+rm -f conftest* - -+ if test -z "$result"; then -+ if test "$cross_compiling" = yes; then -+ # Depending upon the size, compute the lo and hi bounds. -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 / 10) >= 0)]; -+test_array [0] = 0 - --if test -n "$ac_tool_prefix"; then -- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. --set dummy ${ac_tool_prefix}ranlib; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_RANLIB+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- if test -n "$RANLIB"; then -- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. --else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=0 ac_mid=0 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 / 10) <= $ac_mid)]; -+test_array [0] = 0 - --fi --fi --RANLIB=$ac_cv_prog_RANLIB --if test -n "$RANLIB"; then -- echo "$as_me:$LINENO: result: $RANLIB" >&5 --echo "${ECHO_T}$RANLIB" >&6 -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=$ac_mid; break - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo=`expr $ac_mid + 1` -+ if test $ac_lo -le $ac_mid; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid + 1` - fi --if test -z "$ac_cv_prog_RANLIB"; then -- ac_ct_RANLIB=$RANLIB -- # Extract the first word of "ranlib", so it can be a program name with args. --set dummy ranlib; ac_word=$2 --echo "$as_me:$LINENO: checking for $ac_word" >&5 --echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 --if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- if test -n "$ac_ct_RANLIB"; then -- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 / 10) < 0)]; -+test_array [0] = 0 -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=-1 ac_mid=-1 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 / 10) >= $ac_mid)]; -+test_array [0] = 0 -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=$ac_mid; break - else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -- ac_cv_prog_ac_ct_RANLIB="ranlib" -- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done --done -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" --fi -+ac_hi=`expr '(' $ac_mid ')' - 1` -+ if test $ac_mid -le $ac_hi; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid` - fi --ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB --if test -n "$ac_ct_RANLIB"; then -- echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 --echo "${ECHO_T}$ac_ct_RANLIB" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 --fi -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -- RANLIB=$ac_ct_RANLIB --else -- RANLIB="$ac_cv_prog_RANLIB" -+ac_lo= ac_hi= - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+# Binary search between lo and hi bounds. -+while test "x$ac_lo" != "x$ac_hi"; do -+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 / 10) <= $ac_mid)]; -+test_array [0] = 0 - -- -- echo "$as_me:$LINENO: checking for strerror in -lcposix" >&5 --echo $ECHO_N "checking for strerror in -lcposix... $ECHO_C" >&6 --if test "${ac_cv_lib_cposix_strerror+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=$ac_mid - else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-lcposix $LIBS" --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char strerror (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ac_lo=`expr '(' $ac_mid ')' + 1` -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+case $ac_lo in -+?*) res_hi=$ac_lo;; -+'') result=? ;; -+esac -+else -+ if test "$cross_compiling" = yes; then -+ { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -+echo "$as_me: error: internal error: not reached in cross-compile" >&2;} -+ { (exit 1); exit 1; }; } -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+long longval () { return ~(size_t)0 / 10; } -+unsigned long ulongval () { return ~(size_t)0 / 10; } -+#include -+#include - int - main () - { --strerror (); -+ -+ FILE *f = fopen ("conftest.val", "w"); -+ if (! f) -+ exit (1); -+ if ((~(size_t)0 / 10) < 0) -+ { -+ long i = longval (); -+ if (i != (~(size_t)0 / 10)) -+ exit (1); -+ fprintf (f, "%ld\n", i); -+ } -+ else -+ { -+ unsigned long i = ulongval (); -+ if (i != (~(size_t)0 / 10)) -+ exit (1); -+ fprintf (f, "%lu\n", i); -+ } -+ exit (ferror (f) || fclose (f) != 0); -+ - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext -+rm -f conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_lib_cposix_strerror=yes -+ res_hi=`cat conftest.val` - else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_lib_cposix_strerror=no -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+( exit $ac_status ) -+result=? - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $ac_cv_lib_cposix_strerror" >&5 --echo "${ECHO_T}$ac_cv_lib_cposix_strerror" >&6 --if test $ac_cv_lib_cposix_strerror = yes; then -- LIBS="$LIBS -lcposix" - fi -+rm -f conftest.val -+ if test "$cross_compiling" = yes; then -+ # Depending upon the size, compute the lo and hi bounds. -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 % 10) >= 0)]; -+test_array [0] = 0 - -- -- --echo "$as_me:$LINENO: checking for inline" >&5 --echo $ECHO_N "checking for inline... $ECHO_C" >&6 --if test "${ac_cv_c_inline+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- ac_cv_c_inline=no --for ac_kw in inline __inline__ __inline; do -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#ifndef __cplusplus --static $ac_kw int static_foo () {return 0; } --$ac_kw int foo () {return 0; } --#endif -- -+ ; -+ return 0; -+} - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_c_inline=$ac_kw; break --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --fi --rm -f conftest.$ac_objext conftest.$ac_ext --done -- --fi --echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 --echo "${ECHO_T}$ac_cv_c_inline" >&6 --case $ac_cv_c_inline in -- inline | yes) ;; -- no) --cat >>confdefs.h <<\_ACEOF --#define inline --_ACEOF -- ;; -- *) cat >>confdefs.h <<_ACEOF --#define inline $ac_cv_c_inline -+ ac_lo=0 ac_mid=0 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF -- ;; --esac -- --echo "$as_me:$LINENO: checking for off_t" >&5 --echo $ECHO_N "checking for off_t... $ECHO_C" >&6 --if test "${ac_cv_type_off_t+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { --if ((off_t *) 0) -- return 0; --if (sizeof (off_t)) -- return 0; -+static int test_array [1 - 2 * !((~(size_t)0 % 10) <= $ac_mid)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_type_off_t=yes -+ ac_hi=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_type_off_t=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_lo=`expr $ac_mid + 1` -+ if test $ac_lo -le $ac_mid; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid + 1` - fi --echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 --echo "${ECHO_T}$ac_cv_type_off_t" >&6 --if test $ac_cv_type_off_t = yes; then -- : -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --cat >>confdefs.h <<_ACEOF --#define off_t long -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF -- --fi -- --echo "$as_me:$LINENO: checking for size_t" >&5 --echo $ECHO_N "checking for size_t... $ECHO_C" >&6 --if test "${ac_cv_type_size_t+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { --if ((size_t *) 0) -- return 0; --if (sizeof (size_t)) -- return 0; -+static int test_array [1 - 2 * !((~(size_t)0 % 10) < 0)]; -+test_array [0] = 0 -+ - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_type_size_t=yes --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_type_size_t=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext --fi --echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 --echo "${ECHO_T}$ac_cv_type_size_t" >&6 --if test $ac_cv_type_size_t = yes; then -- : --else -- --cat >>confdefs.h <<_ACEOF --#define size_t unsigned -+ ac_hi=-1 ac_mid=-1 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((~(size_t)0 % 10) >= $ac_mid)]; -+test_array [0] = 0 - --fi -- -- -- --for ac_header in stdlib.h unistd.h --do --as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 --else -- # Is the header compilable? --echo "$as_me:$LINENO: checking $ac_header usability" >&5 --echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#include <$ac_header> -+ ; -+ return 0; -+} - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_header_compiler=yes --else -- echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_header_compiler=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 --echo "${ECHO_T}$ac_header_compiler" >&6 -- --# Is the header present? --echo "$as_me:$LINENO: checking $ac_header presence" >&5 --echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include <$ac_header> --_ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- ac_header_preproc=yes -+ (exit $ac_status); }; }; then -+ ac_lo=$ac_mid; break - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- ac_header_preproc=no --fi --rm -f conftest.err conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 --echo "${ECHO_T}$ac_header_preproc" >&6 -+sed 's/^/| /' conftest.$ac_ext >&5 - --# So? What about this header? --case $ac_header_compiler:$ac_header_preproc in -- yes:no ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 --echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -- no:yes ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 --echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; --esac --echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- eval "$as_ac_Header=$ac_header_preproc" -+ac_hi=`expr '(' $ac_mid ')' - 1` -+ if test $ac_mid -le $ac_hi; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid` - fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo= ac_hi= - fi --if test `eval echo '${'$as_ac_Header'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 --_ACEOF -- -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi -- --done -- -- --for ac_func in getpagesize --do --as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` --echo "$as_me:$LINENO: checking for $ac_func" >&5 --echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 --if eval "test \"\${$as_ac_var+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+# Binary search between lo and hi bounds. -+while test "x$ac_lo" != "x$ac_hi"; do -+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --/* System header to define __stub macros and hopefully few prototypes, -- which can conflict with char $ac_func (); below. */ --#include --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char $ac_func (); --char (*f) (); -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { --/* The GNU C library defines this for functions which it implements -- to always fail with ENOSYS. Some functions are actually named -- something starting with __ and the normal name is an alias. */ --#if defined (__stub_$ac_func) || defined (__stub___$ac_func) --choke me --#else --f = $ac_func; --#endif -+static int test_array [1 - 2 * !((~(size_t)0 % 10) <= $ac_mid)]; -+test_array [0] = 0 - - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- eval "$as_ac_var=yes" -+ ac_hi=$ac_mid - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --eval "$as_ac_var=no" --fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 --if test `eval echo '${'$as_ac_var'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 --_ACEOF -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo=`expr '(' $ac_mid ')' + 1` - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -- --echo "$as_me:$LINENO: checking for working mmap" >&5 --echo $ECHO_N "checking for working mmap... $ECHO_C" >&6 --if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+case $ac_lo in -+?*) res_lo=$ac_lo;; -+'') result=? ;; -+esac - else - if test "$cross_compiling" = yes; then -- ac_cv_func_mmap_fixed_mapped=no -+ { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -+echo "$as_me: error: internal error: not reached in cross-compile" >&2;} -+ { (exit 1); exit 1; }; } - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --/* malloc might have been renamed as rpl_malloc. */ --#undef malloc -- --/* Thanks to Mike Haertel and Jim Avera for this test. -- Here is a matrix of mmap possibilities: -- mmap private not fixed -- mmap private fixed at somewhere currently unmapped -- mmap private fixed at somewhere already mapped -- mmap shared not fixed -- mmap shared fixed at somewhere currently unmapped -- mmap shared fixed at somewhere already mapped -- For private mappings, we should verify that changes cannot be read() -- back from the file, nor mmap's back from the file at a different -- address. (There have been systems where private was not correctly -- implemented like the infamous i386 svr4.0, and systems where the -- VM page cache was not coherent with the file system buffer cache -- like early versions of FreeBSD and possibly contemporary NetBSD.) -- For shared mappings, we should conversely verify that changes get -- propagated back to all the places they're supposed to be. -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+long longval () { return ~(size_t)0 % 10; } -+unsigned long ulongval () { return ~(size_t)0 % 10; } -+#include -+#include -+int -+main () -+{ - -- Grep wants private fixed already mapped. -- The main things grep needs to know about mmap are: -- * does it exist and is it safe to write into the mmap'd area -- * how to use it (BSD variants) */ -+ FILE *f = fopen ("conftest.val", "w"); -+ if (! f) -+ exit (1); -+ if ((~(size_t)0 % 10) < 0) -+ { -+ long i = longval (); -+ if (i != (~(size_t)0 % 10)) -+ exit (1); -+ fprintf (f, "%ld\n", i); -+ } -+ else -+ { -+ unsigned long i = ulongval (); -+ if (i != (~(size_t)0 % 10)) -+ exit (1); -+ fprintf (f, "%lu\n", i); -+ } -+ exit (ferror (f) || fclose (f) != 0); - --#include --#include -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ res_lo=`cat conftest.val` -+else -+ echo "$as_me: program exited with status $ac_status" >&5 -+echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --#if !STDC_HEADERS && !HAVE_STDLIB_H --char *malloc (); --#endif -+( exit $ac_status ) -+result=? -+fi -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+fi -+fi -+rm -f conftest.val -+ if test "$cross_compiling" = yes; then -+ # Depending upon the size, compute the lo and hi bounds. -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((sizeof (size_t) <= sizeof (unsigned int)) >= 0)]; -+test_array [0] = 0 - --/* This mess was copied from the GNU getpagesize.h. */ --#if !HAVE_GETPAGESIZE --/* Assume that all systems that can run configure have sys/param.h. */ --# if !HAVE_SYS_PARAM_H --# define HAVE_SYS_PARAM_H 1 --# endif -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=0 ac_mid=0 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((sizeof (size_t) <= sizeof (unsigned int)) <= $ac_mid)]; -+test_array [0] = 0 - --# ifdef _SC_PAGESIZE --# define getpagesize() sysconf(_SC_PAGESIZE) --# else /* no _SC_PAGESIZE */ --# if HAVE_SYS_PARAM_H --# include --# ifdef EXEC_PAGESIZE --# define getpagesize() EXEC_PAGESIZE --# else /* no EXEC_PAGESIZE */ --# ifdef NBPG --# define getpagesize() NBPG * CLSIZE --# ifndef CLSIZE --# define CLSIZE 1 --# endif /* no CLSIZE */ --# else /* no NBPG */ --# ifdef NBPC --# define getpagesize() NBPC --# else /* no NBPC */ --# ifdef PAGESIZE --# define getpagesize() PAGESIZE --# endif /* PAGESIZE */ --# endif /* no NBPC */ --# endif /* no NBPG */ --# endif /* no EXEC_PAGESIZE */ --# else /* no HAVE_SYS_PARAM_H */ --# define getpagesize() 8192 /* punt totally */ --# endif /* no HAVE_SYS_PARAM_H */ --# endif /* no _SC_PAGESIZE */ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=$ac_mid; break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --#endif /* no HAVE_GETPAGESIZE */ -+ac_lo=`expr $ac_mid + 1` -+ if test $ac_lo -le $ac_mid; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid + 1` -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { -- char *data, *data2, *data3; -- int i, pagesize; -- int fd; -- -- pagesize = getpagesize (); -- -- /* First, make a file with some known garbage in it. */ -- data = (char *) malloc (pagesize); -- if (!data) -- exit (1); -- for (i = 0; i < pagesize; ++i) -- *(data + i) = rand (); -- umask (0); -- fd = creat ("conftest.mmap", 0600); -- if (fd < 0) -- exit (1); -- if (write (fd, data, pagesize) != pagesize) -- exit (1); -- close (fd); -- -- /* Next, try to mmap the file at a fixed address which already has -- something else allocated at it. If we can, also make sure that -- we see the same garbage. */ -- fd = open ("conftest.mmap", O_RDWR); -- if (fd < 0) -- exit (1); -- data2 = (char *) malloc (2 * pagesize); -- if (!data2) -- exit (1); -- data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); -- if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, -- MAP_PRIVATE | MAP_FIXED, fd, 0L)) -- exit (1); -- for (i = 0; i < pagesize; ++i) -- if (*(data + i) != *(data2 + i)) -- exit (1); -+static int test_array [1 - 2 * !((sizeof (size_t) <= sizeof (unsigned int)) < 0)]; -+test_array [0] = 0 - -- /* Finally, make sure that changes to the mapped area do not -- percolate back to the file as seen by read(). (This is a bug on -- some variants of i386 svr4.0.) */ -- for (i = 0; i < pagesize; ++i) -- *(data2 + i) = *(data2 + i) + 1; -- data3 = (char *) malloc (pagesize); -- if (!data3) -- exit (1); -- if (read (fd, data3, pagesize) != pagesize) -- exit (1); -- for (i = 0; i < pagesize; ++i) -- if (*(data + i) != *(data3 + i)) -- exit (1); -- close (fd); -- exit (0); -+ ; -+ return 0; - } - _ACEOF --rm -f conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && { ac_try='./conftest$ac_exeext' -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_cv_func_mmap_fixed_mapped=yes --else -- echo "$as_me: program exited with status $ac_status" >&5 --echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --( exit $ac_status ) --ac_cv_func_mmap_fixed_mapped=no --fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext --fi --fi --echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 --echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6 --if test $ac_cv_func_mmap_fixed_mapped = yes; then -+ ac_hi=-1 ac_mid=-1 -+ while :; do -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((sizeof (size_t) <= sizeof (unsigned int)) >= $ac_mid)]; -+test_array [0] = 0 - --cat >>confdefs.h <<\_ACEOF --#define HAVE_MMAP 1 -+ ; -+ return 0; -+} - _ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_lo=$ac_mid; break -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_hi=`expr '(' $ac_mid ')' - 1` -+ if test $ac_mid -le $ac_hi; then -+ ac_lo= ac_hi= -+ break -+ fi -+ ac_mid=`expr 2 '*' $ac_mid` - fi --rm -f conftest.mmap -- -- -- echo "$as_me:$LINENO: checking whether we are using the GNU C Library 2.1 or newer" >&5 --echo $ECHO_N "checking whether we are using the GNU C Library 2.1 or newer... $ECHO_C" >&6 --if test "${ac_cv_gnu_library_2_1+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ done - else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - --#include --#ifdef __GNU_LIBRARY__ -- #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) -- Lucky GNU user -- #endif --#endif -+ac_lo= ac_hi= -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+# Binary search between lo and hi bounds. -+while test "x$ac_lo" != "x$ac_hi"; do -+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+static int test_array [1 - 2 * !((sizeof (size_t) <= sizeof (unsigned int)) <= $ac_mid)]; -+test_array [0] = 0 - -+ ; -+ return 0; -+} - _ACEOF --if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- egrep "Lucky GNU user" >/dev/null 2>&1; then -- ac_cv_gnu_library_2_1=yes -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_hi=$ac_mid - else -- ac_cv_gnu_library_2_1=no --fi --rm -f conftest* -- -- -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_lo=`expr '(' $ac_mid ')' + 1` - fi --echo "$as_me:$LINENO: result: $ac_cv_gnu_library_2_1" >&5 --echo "${ECHO_T}$ac_cv_gnu_library_2_1" >&6 -- -- GLIBC21="$ac_cv_gnu_library_2_1" -- -- -- -- -- echo "$as_me:$LINENO: checking whether integer division by zero raises SIGFPE" >&5 --echo $ECHO_N "checking whether integer division by zero raises SIGFPE... $ECHO_C" >&6 --if test "${gt_cv_int_divbyzero_sigfpe+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+done -+case $ac_lo in -+?*) fits_in_uint=$ac_lo;; -+'') result=? ;; -+esac - else -- -- if test "$cross_compiling" = yes; then -- -- # Guess based on the CPU. -- case "$host_cpu" in -- alpha* | i3456786 | m68k | s390*) -- gt_cv_int_divbyzero_sigfpe="guessing yes";; -- *) -- gt_cv_int_divbyzero_sigfpe="guessing no";; -- esac -- -+ if test "$cross_compiling" = yes; then -+ { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -+echo "$as_me: error: internal error: not reached in cross-compile" >&2;} -+ { (exit 1); exit 1; }; } - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -- -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+long longval () { return sizeof (size_t) <= sizeof (unsigned int); } -+unsigned long ulongval () { return sizeof (size_t) <= sizeof (unsigned int); } -+#include - #include --#include -- --static void --#ifdef __cplusplus --sigfpe_handler (int sig) --#else --sigfpe_handler (sig) int sig; --#endif -+int -+main () - { -- /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ -- exit (sig != SIGFPE); --} -- --int x = 1; --int y = 0; --int z; --int nan; - --int main () --{ -- signal (SIGFPE, sigfpe_handler); --/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ --#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) -- signal (SIGTRAP, sigfpe_handler); --#endif --/* Linux/SPARC yields signal SIGILL. */ --#if defined (__sparc__) && defined (__linux__) -- signal (SIGILL, sigfpe_handler); --#endif -+ FILE *f = fopen ("conftest.val", "w"); -+ if (! f) -+ exit (1); -+ if ((sizeof (size_t) <= sizeof (unsigned int)) < 0) -+ { -+ long i = longval (); -+ if (i != (sizeof (size_t) <= sizeof (unsigned int))) -+ exit (1); -+ fprintf (f, "%ld\n", i); -+ } -+ else -+ { -+ unsigned long i = ulongval (); -+ if (i != (sizeof (size_t) <= sizeof (unsigned int))) -+ exit (1); -+ fprintf (f, "%lu\n", i); -+ } -+ exit (ferror (f) || fclose (f) != 0); - -- z = x / y; -- nan = y / y; -- exit (1); -+ ; -+ return 0; - } -- - _ACEOF - rm -f conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -@@ -11102,329 +25993,378 @@ - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- gt_cv_int_divbyzero_sigfpe=yes -+ fits_in_uint=`cat conftest.val` - else - echo "$as_me: program exited with status $ac_status" >&5 - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - ( exit $ac_status ) --gt_cv_int_divbyzero_sigfpe=no -+result=? - fi --rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext - fi -- - fi --echo "$as_me:$LINENO: result: $gt_cv_int_divbyzero_sigfpe" >&5 --echo "${ECHO_T}$gt_cv_int_divbyzero_sigfpe" >&6 -- case "$gt_cv_int_divbyzero_sigfpe" in -- *yes) value=1;; -- *) value=0;; -- esac -- --cat >>confdefs.h <<_ACEOF --#define INTDIV0_RAISES_SIGFPE $value --_ACEOF -- -- -+rm -f conftest.val -+ if test "$fits_in_uint" = 1; then -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+ extern size_t foo; -+ extern unsigned long foo; - -- echo "$as_me:$LINENO: checking for inttypes.h" >&5 --echo $ECHO_N "checking for inttypes.h... $ECHO_C" >&6 --if test "${jm_ac_cv_header_inttypes_h+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { --uintmax_t i = (uintmax_t) -1; -+ - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- jm_ac_cv_header_inttypes_h=yes -+ fits_in_uint=0 - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --jm_ac_cv_header_inttypes_h=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - fi --echo "$as_me:$LINENO: result: $jm_ac_cv_header_inttypes_h" >&5 --echo "${ECHO_T}$jm_ac_cv_header_inttypes_h" >&6 -- if test $jm_ac_cv_header_inttypes_h = yes; then -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+ fi -+ if test -z "$result"; then -+ if test "$fits_in_uint" = 1; then -+ result="$res_hi$res_lo"U -+ else -+ result="$res_hi$res_lo"UL -+ fi -+ else -+ result='~(size_t)0' -+ fi -+ fi -+ echo "$as_me:$LINENO: result: $result" >&5 -+echo "${ECHO_T}$result" >&6 -+ if test "$result" != yes; then - - cat >>confdefs.h <<_ACEOF --#define HAVE_INTTYPES_H_WITH_UINTMAX 1 -+#define SIZE_MAX $result - _ACEOF - - fi - - -- echo "$as_me:$LINENO: checking for stdint.h" >&5 --echo $ECHO_N "checking for stdint.h... $ECHO_C" >&6 --if test "${jm_ac_cv_header_stdint_h+set}" = set; then -+ -+ -+ -+for ac_header in stdint.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --uintmax_t i = (uintmax_t) -1; -- ; -- return 0; --} -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- jm_ac_cv_header_stdint_h=yes -+ ac_header_compiler=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --jm_ac_cv_header_stdint_h=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_header_compiler=no - fi --echo "$as_me:$LINENO: result: $jm_ac_cv_header_stdint_h" >&5 --echo "${ECHO_T}$jm_ac_cv_header_stdint_h" >&6 -- if test $jm_ac_cv_header_stdint_h = yes; then -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 - --cat >>confdefs.h <<_ACEOF --#define HAVE_STDINT_H_WITH_UINTMAX 1 -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ - _ACEOF -- -- fi -- -- -- echo "$as_me:$LINENO: checking for unsigned long long" >&5 --echo $ECHO_N "checking for unsigned long long... $ECHO_C" >&6 --if test "${ac_cv_type_unsigned_long_long+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --unsigned long long ull = 1; int i = 63; --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif --int --main () --{ --unsigned long long ullmax = (unsigned long long) -1; -- return ull << i | ull >> i | ullmax / ull | ullmax % ull; -- ; -- return 0; --} -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_type_unsigned_long_long=yes -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_cv_type_unsigned_long_long=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_header_preproc=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 -+ -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" - fi --echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_long_long" >&5 --echo "${ECHO_T}$ac_cv_type_unsigned_long_long" >&6 -- if test $ac_cv_type_unsigned_long_long = yes; then -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - --cat >>confdefs.h <<\_ACEOF --#define HAVE_UNSIGNED_LONG_LONG 1 -+fi -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 - _ACEOF - -- fi -- -- -- -- -- if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then -- -- test $ac_cv_type_unsigned_long_long = yes \ -- && ac_type='unsigned long long' \ -- || ac_type='unsigned long' -+fi - --cat >>confdefs.h <<_ACEOF --#define uintmax_t $ac_type --_ACEOF -+done - -- fi - - -- echo "$as_me:$LINENO: checking for inttypes.h" >&5 --echo $ECHO_N "checking for inttypes.h... $ECHO_C" >&6 --if test "${gt_cv_header_inttypes_h+set}" = set; then -+ echo "$as_me:$LINENO: checking for CFPreferencesCopyAppValue" >&5 -+echo $ECHO_N "checking for CFPreferencesCopyAppValue... $ECHO_C" >&6 -+if test "${gt_cv_func_CFPreferencesCopyAppValue+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --#include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+ gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS -framework CoreFoundation" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { -- -+CFPreferencesCopyAppValue(NULL, NULL) - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- gt_cv_header_inttypes_h=yes -+ gt_cv_func_CFPreferencesCopyAppValue=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --gt_cv_header_inttypes_h=no --fi --rm -f conftest.$ac_objext conftest.$ac_ext -+sed 's/^/| /' conftest.$ac_ext >&5 - -+gt_cv_func_CFPreferencesCopyAppValue=no - fi --echo "$as_me:$LINENO: result: $gt_cv_header_inttypes_h" >&5 --echo "${ECHO_T}$gt_cv_header_inttypes_h" >&6 -- if test $gt_cv_header_inttypes_h = yes; then -- --cat >>confdefs.h <<_ACEOF --#define HAVE_INTTYPES_H 1 --_ACEOF -- -- fi -- -- -- -- if test $gt_cv_header_inttypes_h = yes; then -- echo "$as_me:$LINENO: checking whether the inttypes.h PRIxNN macros are broken" >&5 --echo $ECHO_N "checking whether the inttypes.h PRIxNN macros are broken... $ECHO_C" >&6 --if test "${gt_cv_inttypes_pri_broken+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- -- cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include --#ifdef PRId32 --char *p = PRId32; --#endif -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS" -+fi -+echo "$as_me:$LINENO: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 -+echo "${ECHO_T}$gt_cv_func_CFPreferencesCopyAppValue" >&6 -+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_CFPREFERENCESCOPYAPPVALUE 1 -+_ACEOF -+ -+ fi -+ echo "$as_me:$LINENO: checking for CFLocaleCopyCurrent" >&5 -+echo $ECHO_N "checking for CFLocaleCopyCurrent... $ECHO_C" >&6 -+if test "${gt_cv_func_CFLocaleCopyCurrent+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS -framework CoreFoundation" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { -- -+CFLocaleCopyCurrent(); - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- gt_cv_inttypes_pri_broken=no -+ gt_cv_func_CFLocaleCopyCurrent=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --gt_cv_inttypes_pri_broken=yes --fi --rm -f conftest.$ac_objext conftest.$ac_ext -+sed 's/^/| /' conftest.$ac_ext >&5 - -+gt_cv_func_CFLocaleCopyCurrent=no - fi --echo "$as_me:$LINENO: result: $gt_cv_inttypes_pri_broken" >&5 --echo "${ECHO_T}$gt_cv_inttypes_pri_broken" >&6 -- fi -- if test "$gt_cv_inttypes_pri_broken" = yes; then -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS" -+fi -+echo "$as_me:$LINENO: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 -+echo "${ECHO_T}$gt_cv_func_CFLocaleCopyCurrent" >&6 -+ if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - --cat >>confdefs.h <<_ACEOF --#define PRI_MACROS_BROKEN 1 -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_CFLOCALECOPYCURRENT 1 - _ACEOF - - fi -+ INTL_MACOSX_LIBS= -+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then -+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" -+ fi -+ - - - if test "X$prefix" = "XNONE"; then -@@ -11450,6 +26390,19 @@ - else - with_gnu_ld=no - fi; -+# Prepare PATH_SEPARATOR. -+# The user is always right. -+if test "${PATH_SEPARATOR+set}" != set; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then -+ PATH_SEPARATOR=';' -+ else -+ PATH_SEPARATOR=: -+ fi -+ rm -f conf$$.sh -+fi - ac_prog=ld - if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. -@@ -11501,11 +26454,12 @@ - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. -- if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then -- test "$with_gnu_ld" != no && break -- else -- test "$with_gnu_ld" != yes && break -- fi -+ case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in -+ *GNU* | *'with BFD'*) -+ test "$with_gnu_ld" != no && break ;; -+ *) -+ test "$with_gnu_ld" != yes && break ;; -+ esac - fi - done - IFS="$ac_save_ifs" -@@ -11531,11 +26485,12 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. --if $LD -v 2>&1 &5; then -- acl_cv_prog_gnu_ld=yes --else -- acl_cv_prog_gnu_ld=no --fi -+case `$LD -v 2>&1 &5 - echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6 -@@ -11543,6 +26498,7 @@ - - - -+ - echo "$as_me:$LINENO: checking for shared library run path origin" >&5 - echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6 - if test "${acl_cv_rpath+set}" = set; then -@@ -11565,8 +26521,6 @@ - hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - hardcode_direct="$acl_cv_hardcode_direct" - hardcode_minus_L="$acl_cv_hardcode_minus_L" -- sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec" -- sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec" - # Check whether --enable-rpath or --disable-rpath was given. - if test "${enable_rpath+set}" = set; then - enableval="$enable_rpath" -@@ -11790,7 +26744,7 @@ - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in -- linux*) haveit=yes;; -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi -@@ -11834,7 +26788,7 @@ - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in -- linux*) haveit=yes;; -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi -@@ -11964,223 +26918,722 @@ - - - -+ echo "$as_me:$LINENO: checking for ptrdiff_t" >&5 -+echo $ECHO_N "checking for ptrdiff_t... $ECHO_C" >&6 -+if test "${ac_cv_type_ptrdiff_t+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+int -+main () -+{ -+if ((ptrdiff_t *) 0) -+ return 0; -+if (sizeof (ptrdiff_t)) -+ return 0; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_type_ptrdiff_t=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_type_ptrdiff_t=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_type_ptrdiff_t" >&5 -+echo "${ECHO_T}$ac_cv_type_ptrdiff_t" >&6 -+if test $ac_cv_type_ptrdiff_t = yes; then -+ : -+else -+ -+cat >>confdefs.h <<\_ACEOF -+#define ptrdiff_t long -+_ACEOF -+ -+ -+fi -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+for ac_header in argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ -+stdlib.h string.h unistd.h sys/param.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+else -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_header_compiler=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 -+ -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 -+ -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+ -+fi -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF -+ -+fi -+ -+done -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+for ac_func in asprintf fwprintf getcwd getegid geteuid getgid getuid \ -+mempcpy munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup \ -+strtoul tsearch wcslen __argz_count __argz_stringify __argz_next \ -+__fsetlocking -+do -+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -+echo "$as_me:$LINENO: checking for $ac_func" >&5 -+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_var+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+/* Define $ac_func to an innocuous variant, in case declares $ac_func. -+ For example, HP-UX 11i declares gettimeofday. */ -+#define $ac_func innocuous_$ac_func -+ -+/* System header to define __stub macros and hopefully few prototypes, -+ which can conflict with char $ac_func (); below. -+ Prefer to if __STDC__ is defined, since -+ exists even on freestanding compilers. */ -+ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ -+#undef $ac_func -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+{ -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char $ac_func (); -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -+choke me -+#else -+char (*f) () = $ac_func; -+#endif -+#ifdef __cplusplus -+} -+#endif -+ -+int -+main () -+{ -+return f != $ac_func; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ eval "$as_ac_var=yes" -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+eval "$as_ac_var=no" -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -+if test `eval echo '${'$as_ac_var'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -+_ACEOF -+ -+fi -+done -+ -+ -+ -+ echo "$as_me:$LINENO: checking whether _snprintf is declared" >&5 -+echo $ECHO_N "checking whether _snprintf is declared... $ECHO_C" >&6 -+if test "${ac_cv_have_decl__snprintf+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+ -+#ifndef _snprintf -+ char *p = (char *) _snprintf; -+#endif - -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_have_decl__snprintf=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_cv_have_decl__snprintf=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_have_decl__snprintf" >&5 -+echo "${ECHO_T}$ac_cv_have_decl__snprintf" >&6 -+ if test $ac_cv_have_decl__snprintf = yes; then -+ gt_value=1 -+ else -+ gt_value=0 -+ fi - -+cat >>confdefs.h <<_ACEOF -+#define HAVE_DECL__SNPRINTF $gt_value -+_ACEOF - - - --for ac_header in argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ --stdlib.h string.h unistd.h sys/param.h --do --as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking whether _snwprintf is declared" >&5 -+echo $ECHO_N "checking whether _snwprintf is declared... $ECHO_C" >&6 -+if test "${ac_cv_have_decl__snwprintf+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - else -- # Is the header compilable? --echo "$as_me:$LINENO: checking $ac_header usability" >&5 --echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --$ac_includes_default --#include <$ac_header> -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+ -+#ifndef _snwprintf -+ char *p = (char *) _snwprintf; -+#endif -+ -+ ; -+ return 0; -+} - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- ac_header_compiler=yes -+ ac_cv_have_decl__snwprintf=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --ac_header_compiler=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_have_decl__snwprintf=no - fi --rm -f conftest.$ac_objext conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 --echo "${ECHO_T}$ac_header_compiler" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_have_decl__snwprintf" >&5 -+echo "${ECHO_T}$ac_cv_have_decl__snwprintf" >&6 -+ if test $ac_cv_have_decl__snwprintf = yes; then -+ gt_value=1 -+ else -+ gt_value=0 -+ fi - --# Is the header present? --echo "$as_me:$LINENO: checking $ac_header presence" >&5 --echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --#include <$ac_header> -+cat >>confdefs.h <<_ACEOF -+#define HAVE_DECL__SNWPRINTF $gt_value - _ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ -+ -+ -+ -+ echo "$as_me:$LINENO: checking whether feof_unlocked is declared" >&5 -+echo $ECHO_N "checking whether feof_unlocked is declared... $ECHO_C" >&6 -+if test "${ac_cv_have_decl_feof_unlocked+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+ -+#ifndef feof_unlocked -+ char *p = (char *) feof_unlocked; -+#endif -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -- egrep -v '^ *\+' conftest.er1 >conftest.err -+ grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- ac_header_preproc=yes -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_have_decl_feof_unlocked=yes - else - echo "$as_me: failed program was:" >&5 -- cat conftest.$ac_ext >&5 -- ac_header_preproc=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_have_decl_feof_unlocked=no - fi --rm -f conftest.err conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 --echo "${ECHO_T}$ac_header_preproc" >&6 -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_have_decl_feof_unlocked" >&5 -+echo "${ECHO_T}$ac_cv_have_decl_feof_unlocked" >&6 -+ if test $ac_cv_have_decl_feof_unlocked = yes; then -+ gt_value=1 -+ else -+ gt_value=0 -+ fi - --# So? What about this header? --case $ac_header_compiler:$ac_header_preproc in -- yes:no ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 --echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -- no:yes ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 --echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; --esac --echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -+cat >>confdefs.h <<_ACEOF -+#define HAVE_DECL_FEOF_UNLOCKED $gt_value -+_ACEOF -+ -+ -+ -+ echo "$as_me:$LINENO: checking whether fgets_unlocked is declared" >&5 -+echo $ECHO_N "checking whether fgets_unlocked is declared... $ECHO_C" >&6 -+if test "${ac_cv_have_decl_fgets_unlocked+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else -- eval "$as_ac_Header=$ac_header_preproc" --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ - --fi --if test `eval echo '${'$as_ac_Header'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+#ifndef fgets_unlocked -+ char *p = (char *) fgets_unlocked; -+#endif -+ -+ ; -+ return 0; -+} - _ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_have_decl_fgets_unlocked=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 - -+ac_cv_have_decl_fgets_unlocked=no - fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_have_decl_fgets_unlocked" >&5 -+echo "${ECHO_T}$ac_cv_have_decl_fgets_unlocked" >&6 -+ if test $ac_cv_have_decl_fgets_unlocked = yes; then -+ gt_value=1 -+ else -+ gt_value=0 -+ fi - --done -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -+cat >>confdefs.h <<_ACEOF -+#define HAVE_DECL_FGETS_UNLOCKED $gt_value -+_ACEOF - - - --for ac_func in feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \ --geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \ --strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next --do --as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` --echo "$as_me:$LINENO: checking for $ac_func" >&5 --echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 --if eval "test \"\${$as_ac_var+set}\" = set"; then -+ echo "$as_me:$LINENO: checking whether getc_unlocked is declared" >&5 -+echo $ECHO_N "checking whether getc_unlocked is declared... $ECHO_C" >&6 -+if test "${ac_cv_have_decl_getc_unlocked+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" --/* System header to define __stub macros and hopefully few prototypes, -- which can conflict with char $ac_func (); below. */ --#include --/* Override any gcc2 internal prototype to avoid an error. */ --#ifdef __cplusplus --extern "C" --#endif --/* We use char because int might match the return type of a gcc2 -- builtin and then its argument prototype would still apply. */ --char $ac_func (); --char (*f) (); -- --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include - int - main () - { --/* The GNU C library defines this for functions which it implements -- to always fail with ENOSYS. Some functions are actually named -- something starting with __ and the normal name is an alias. */ --#if defined (__stub_$ac_func) || defined (__stub___$ac_func) --choke me --#else --f = $ac_func; -+ -+#ifndef getc_unlocked -+ char *p = (char *) getc_unlocked; - #endif - - ; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- eval "$as_ac_var=yes" -+ ac_cv_have_decl_getc_unlocked=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --eval "$as_ac_var=no" -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_have_decl_getc_unlocked=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 --if test `eval echo '${'$as_ac_var'}'` = yes; then -- cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -+echo "$as_me:$LINENO: result: $ac_cv_have_decl_getc_unlocked" >&5 -+echo "${ECHO_T}$ac_cv_have_decl_getc_unlocked" >&6 -+ if test $ac_cv_have_decl_getc_unlocked = yes; then -+ gt_value=1 -+ else -+ gt_value=0 -+ fi -+ -+cat >>confdefs.h <<_ACEOF -+#define HAVE_DECL_GETC_UNLOCKED $gt_value - _ACEOF - --fi --done -+ -+ -+ case $gt_cv_func_printf_posix in -+ *yes) HAVE_POSIX_PRINTF=1 ;; -+ *) HAVE_POSIX_PRINTF=0 ;; -+ esac -+ -+ if test "$ac_cv_func_asprintf" = yes; then -+ HAVE_ASPRINTF=1 -+ else -+ HAVE_ASPRINTF=0 -+ fi -+ -+ if test "$ac_cv_func_snprintf" = yes; then -+ HAVE_SNPRINTF=1 -+ else -+ HAVE_SNPRINTF=0 -+ fi -+ -+ if test "$ac_cv_func_wprintf" = yes; then -+ HAVE_WPRINTF=1 -+ else -+ HAVE_WPRINTF=0 -+ fi - - - -@@ -12222,16 +27675,13 @@ - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - #include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -12244,11 +27694,20 @@ - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -12257,23 +27716,22 @@ - am_cv_func_iconv=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - #include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -12286,11 +27744,20 @@ - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -12300,9 +27767,11 @@ - am_cv_func_iconv=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - LIBS="$am_save_LIBS" - fi - -@@ -12337,8 +27806,11 @@ - else - - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - - #include - #include -@@ -12352,12 +27824,6 @@ - size_t iconv(); - #endif - --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -12368,11 +27834,20 @@ - _ACEOF - rm -f conftest.$ac_objext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>&5 -+ (eval $ac_compile) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest.$ac_objext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -12381,10 +27856,11 @@ - am_cv_proto_iconv_arg1="" - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - am_cv_proto_iconv_arg1="const" - fi --rm -f conftest.$ac_objext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" - fi - -@@ -12407,15 +27883,12 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -12426,11 +27899,20 @@ - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -12439,10 +27921,12 @@ - am_cv_langinfo_codeset=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - am_cv_langinfo_codeset=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - - fi - echo "$as_me:$LINENO: result: $am_cv_langinfo_codeset" >&5 -@@ -12459,19 +27943,16 @@ - - echo "$as_me:$LINENO: checking for LC_MESSAGES" >&5 - echo $ECHO_N "checking for LC_MESSAGES... $ECHO_C" >&6 --if test "${am_cv_val_LC_MESSAGES+set}" = set; then -+if test "${gt_cv_val_LC_MESSAGES+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { -@@ -12482,27 +27963,38 @@ - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then -- am_cv_val_LC_MESSAGES=yes -+ gt_cv_val_LC_MESSAGES=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 --am_cv_val_LC_MESSAGES=no -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_val_LC_MESSAGES=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - fi --echo "$as_me:$LINENO: result: $am_cv_val_LC_MESSAGES" >&5 --echo "${ECHO_T}$am_cv_val_LC_MESSAGES" >&6 -- if test $am_cv_val_LC_MESSAGES = yes; then -+echo "$as_me:$LINENO: result: $gt_cv_val_LC_MESSAGES" >&5 -+echo "${ECHO_T}$gt_cv_val_LC_MESSAGES" >&6 -+ if test $gt_cv_val_LC_MESSAGES = yes; then - - cat >>confdefs.h <<\_ACEOF - #define HAVE_LC_MESSAGES 1 -@@ -12512,6 +28004,10 @@ - - fi - -+ if test -n "$INTL_MACOSX_LIBS"; then -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ fi -+ - for ac_prog in bison - do - # Extract the first word of "$ac_prog", so it can be a program name with args. -@@ -12545,46 +28041,187 @@ - echo "$as_me:$LINENO: result: $INTLBISON" >&5 - echo "${ECHO_T}$INTLBISON" >&6 - else -- echo "$as_me:$LINENO: result: no" >&5 --echo "${ECHO_T}no" >&6 -+ echo "$as_me:$LINENO: result: no" >&5 -+echo "${ECHO_T}no" >&6 -+fi -+ -+ test -n "$INTLBISON" && break -+done -+ -+ if test -z "$INTLBISON"; then -+ ac_verc_fail=yes -+ else -+ echo "$as_me:$LINENO: checking version of bison" >&5 -+echo $ECHO_N "checking version of bison... $ECHO_C" >&6 -+ ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` -+ case $ac_prog_version in -+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; -+ 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) -+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; -+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; -+ esac -+ echo "$as_me:$LINENO: result: $ac_prog_version" >&5 -+echo "${ECHO_T}$ac_prog_version" >&6 -+ fi -+ if test $ac_verc_fail = yes; then -+ INTLBISON=: -+ fi -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ echo "$as_me:$LINENO: checking for CFPreferencesCopyAppValue" >&5 -+echo $ECHO_N "checking for CFPreferencesCopyAppValue... $ECHO_C" >&6 -+if test "${gt_cv_func_CFPreferencesCopyAppValue+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS -framework CoreFoundation" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+CFPreferencesCopyAppValue(NULL, NULL) -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ gt_cv_func_CFPreferencesCopyAppValue=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_func_CFPreferencesCopyAppValue=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS" -+fi -+echo "$as_me:$LINENO: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 -+echo "${ECHO_T}$gt_cv_func_CFPreferencesCopyAppValue" >&6 -+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_CFPREFERENCESCOPYAPPVALUE 1 -+_ACEOF -+ -+ fi -+ echo "$as_me:$LINENO: checking for CFLocaleCopyCurrent" >&5 -+echo $ECHO_N "checking for CFLocaleCopyCurrent... $ECHO_C" >&6 -+if test "${gt_cv_func_CFLocaleCopyCurrent+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ gt_save_CPPFLAGS="$CPPFLAGS" -+ CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers" -+ gt_save_LIBS="$LIBS" -+ LIBS="$LIBS -framework CoreFoundation" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+int -+main () -+{ -+CFLocaleCopyCurrent(); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ gt_cv_func_CFLocaleCopyCurrent=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+gt_cv_func_CFLocaleCopyCurrent=no - fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ CPPFLAGS="$gt_save_CPPFLAGS" -+ LIBS="$gt_save_LIBS" -+fi -+echo "$as_me:$LINENO: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 -+echo "${ECHO_T}$gt_cv_func_CFLocaleCopyCurrent" >&6 -+ if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - -- test -n "$INTLBISON" && break --done -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_CFLOCALECOPYCURRENT 1 -+_ACEOF - -- if test -z "$INTLBISON"; then -- ac_verc_fail=yes -- else -- echo "$as_me:$LINENO: checking version of bison" >&5 --echo $ECHO_N "checking version of bison... $ECHO_C" >&6 -- ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` -- case $ac_prog_version in -- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; -- 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) -- ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; -- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; -- esac -- echo "$as_me:$LINENO: result: $ac_prog_version" >&5 --echo "${ECHO_T}$ac_prog_version" >&6 - fi -- if test $ac_verc_fail = yes; then -- INTLBISON=: -+ INTL_MACOSX_LIBS= -+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then -+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - - - - -- -- -- -- -- -- -- -- -- -- -- - echo "$as_me:$LINENO: checking whether NLS is requested" >&5 - echo $ECHO_N "checking whether NLS is requested... $ECHO_C" >&6 - # Check whether --enable-nls or --disable-nls was given. -@@ -12599,6 +28236,7 @@ - - - -+ - BUILD_INCLUDED_LIBINTL=no - USE_INCLUDED_LIBINTL=no - -@@ -12636,33 +28274,39 @@ - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - extern int _nl_msg_cat_cntr; - extern int *_nl_domain_bindings; --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif - int - main () - { - bindtextdomain ("", ""); --return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings -+return * gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -12671,10 +28315,12 @@ - gt_cv_func_gnugettext1_libc=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - gt_cv_func_gnugettext1_libc=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - fi - echo "$as_me:$LINENO: result: $gt_cv_func_gnugettext1_libc" >&5 - echo "${ECHO_T}$gt_cv_func_gnugettext1_libc" >&6 -@@ -12892,7 +28538,7 @@ - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in -- linux*) haveit=yes;; -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi -@@ -12936,7 +28582,7 @@ - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in -- linux*) haveit=yes;; -+ linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi -@@ -13069,37 +28715,43 @@ - gt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBINTL" - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - extern int _nl_msg_cat_cntr; - extern - #ifdef __cplusplus - "C" - #endif --const char *_nl_expand_alias (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+const char *_nl_expand_alias (const char *); - int - main () - { - bindtextdomain ("", ""); --return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_expand_alias (0) -+return * gettext ("") + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -13108,44 +28760,52 @@ - gt_cv_func_gnugettext1_libintl=yes - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - gt_cv_func_gnugettext1_libintl=no - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - if test "$gt_cv_func_gnugettext1_libintl" != yes && test -n "$LIBICONV"; then - LIBS="$LIBS $LIBICONV" - cat >conftest.$ac_ext <<_ACEOF --#line $LINENO "configure" --#include "confdefs.h" -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ - #include - extern int _nl_msg_cat_cntr; - extern - #ifdef __cplusplus - "C" - #endif --const char *_nl_expand_alias (); --#ifdef F77_DUMMY_MAIN --# ifdef __cplusplus -- extern "C" --# endif -- int F77_DUMMY_MAIN() { return 1; } --#endif -+const char *_nl_expand_alias (const char *); - int - main () - { - bindtextdomain ("", ""); --return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_expand_alias (0) -+return * gettext ("") + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ; - return 0; - } - _ACEOF - rm -f conftest.$ac_objext conftest$ac_exeext - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>&5 -+ (eval $ac_link) 2>conftest.er1 - ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -s conftest$ac_exeext' -+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -13157,9 +28817,11 @@ - - else - echo "$as_me: failed program was:" >&5 --cat conftest.$ac_ext >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ - fi --rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext - fi - CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS" -@@ -13170,7 +28832,8 @@ - - if test "$gt_cv_func_gnugettext1_libc" = "yes" \ - || { test "$gt_cv_func_gnugettext1_libintl" = "yes" \ -- && test "$PACKAGE" != gettext; }; then -+ && test "$PACKAGE" != gettext-runtime \ -+ && test "$PACKAGE" != gettext-tools; }; then - gt_use_preinstalled_gnugettext=yes - else - LIBINTL= -@@ -13185,20 +28848,28 @@ - fi - - if test "$nls_cv_use_gnu_gettext" = "yes"; then -- INTLOBJS="\$(GETTOBJS)" -- BUILD_INCLUDED_LIBINTL=yes -+ BUILD_INCLUDED_LIBINTL=yes - USE_INCLUDED_LIBINTL=yes - LIBINTL="\${top_builddir}/intl/libintl.a $LIBICONV" - LTLIBINTL="\${top_builddir}/intl/libintl.a $LTLIBICONV" - LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` - fi - -+ CATOBJEXT= - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - CATOBJEXT=.gmo - fi - - -+ if test -n "$INTL_MACOSX_LIBS"; then -+ if test "$gt_use_preinstalled_gnugettext" = "yes" \ -+ || test "$nls_cv_use_gnu_gettext" = "yes"; then -+ LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" -+ LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" -+ fi -+ fi -+ - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - -@@ -13211,6 +28882,26 @@ - fi - fi - -+ echo "$as_me:$LINENO: checking whether to use NLS" >&5 -+echo $ECHO_N "checking whether to use NLS... $ECHO_C" >&6 -+ echo "$as_me:$LINENO: result: $USE_NLS" >&5 -+echo "${ECHO_T}$USE_NLS" >&6 -+ if test "$USE_NLS" = "yes"; then -+ echo "$as_me:$LINENO: checking where the gettext function comes from" >&5 -+echo $ECHO_N "checking where the gettext function comes from... $ECHO_C" >&6 -+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then -+ if test "$gt_cv_func_gnugettext1_libintl" = "yes"; then -+ gt_source="external libintl" -+ else -+ gt_source="libc" -+ fi -+ else -+ gt_source="included intl directory" -+ fi -+ echo "$as_me:$LINENO: result: $gt_source" >&5 -+echo "${ECHO_T}$gt_source" >&6 -+ fi -+ - if test "$USE_NLS" = "yes"; then - - if test "$gt_use_preinstalled_gnugettext" = "yes"; then -@@ -13260,7 +28951,7 @@ - fi - - -- if test "$PACKAGE" = gettext; then -+ if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then - BUILD_INCLUDED_LIBINTL=yes - fi - -@@ -13268,7 +28959,6 @@ - - - -- - nls_cv_header_intl= - nls_cv_header_libgt= - -@@ -13281,6 +28971,12 @@ - GENCAT=gencat - - -+ INTLOBJS= -+ if test "$USE_INCLUDED_LIBINTL" = yes; then -+ INTLOBJS="\$(GETTOBJS)" -+ fi -+ -+ - INTL_LIBTOOL_SUFFIX_PREFIX= - - -@@ -13318,8 +29014,8 @@ - fi - - --ac_config_files="$ac_config_files Makefile gsmlib/Makefile tests/Makefile apps/Makefile win32/Makefile doc/Makefile scripts/Makefile intl/Makefile po/Makefile.in ext/Makefile" --ac_config_commands="$ac_config_commands default" -+ ac_config_files="$ac_config_files Makefile gsmlib/Makefile tests/Makefile apps/Makefile win32/Makefile doc/Makefile scripts/Makefile intl/Makefile po/Makefile.in ext/Makefile" -+ ac_config_commands="$ac_config_commands default" - cat >confcache <<\_ACEOF - # This file is a shell script that caches the results of configure - # tests run on this system so they can be shared between configure -@@ -13330,7 +29026,7 @@ - # config.status only pays attention to the cache file if you give it - # the --recheck option to rerun configure. - # --# `ac_cv_env_foo' variables (set or unset) will be overriden when -+# `ac_cv_env_foo' variables (set or unset) will be overridden when - # loading this file, other *unset* `ac_cv_foo' will be assigned the - # following values. - -@@ -13348,13 +29044,13 @@ - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ -- "s/'/'\\\\''/g; -- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" -+ "s/'/'\\\\''/g; -+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ -- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" -+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; - } | -@@ -13365,7 +29061,7 @@ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache --if cmp -s $cache_file confcache; then :; else -+if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" - cat confcache >$cache_file -@@ -13384,18 +29080,33 @@ - # trailing colons and then remove the whole line if VPATH becomes empty - # (actually we leave an empty line to preserve line numbers). - if test "x$srcdir" = x.; then -- ac_vpsub='/^[ ]*VPATH[ ]*=/{ -+ ac_vpsub='/^[ ]*VPATH[ ]*=/{ - s/:*\$(srcdir):*/:/; - s/:*\${srcdir}:*/:/; - s/:*@srcdir@:*/:/; --s/^\([^=]*=[ ]*\):*/\1/; -+s/^\([^=]*=[ ]*\):*/\1/; - s/:*$//; --s/^[^=]*=[ ]*$//; -+s/^[^=]*=[ ]*$//; - }' - fi - - DEFS=-DHAVE_CONFIG_H - -+ac_libobjs= -+ac_ltlibobjs= -+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue -+ # 1. Remove the extension, and $U if already installed. -+ ac_i=`echo "$ac_i" | -+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'` -+ # 2. Add them. -+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" -+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' -+done -+LIBOBJS=$ac_libobjs -+ -+LTLIBOBJS=$ac_ltlibobjs -+ -+ - if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. - Usually this means the macro was only invoked conditionally." >&5 -@@ -13403,6 +29114,27 @@ - Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } - fi -+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then -+ { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. -+Usually this means the macro was only invoked conditionally." >&5 -+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. -+Usually this means the macro was only invoked conditionally." >&2;} -+ { (exit 1); exit 1; }; } -+fi -+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then -+ { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. -+Usually this means the macro was only invoked conditionally." >&5 -+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. -+Usually this means the macro was only invoked conditionally." >&2;} -+ { (exit 1); exit 1; }; } -+fi -+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then -+ { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. -+Usually this means the macro was only invoked conditionally." >&5 -+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. -+Usually this means the macro was only invoked conditionally." >&2;} -+ { (exit 1); exit 1; }; } -+fi - if test -z "${COMPILE_INTL_TRUE}" && test -z "${COMPILE_INTL_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"COMPILE_INTL\" was never defined. - Usually this means the macro was only invoked conditionally." >&5 -@@ -13424,11 +29156,12 @@ - # configure, is in config.log if it exists. - - debug=false -+ac_cs_recheck=false -+ac_cs_silent=false - SHELL=\${CONFIG_SHELL-$SHELL} - _ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF -- - ## --------------------- ## - ## M4sh Initialization. ## - ## --------------------- ## -@@ -13437,46 +29170,57 @@ - if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: -+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which -+ # is contrary to our usage. Disable this feature. -+ alias -g '${1+"$@"}'='"$@"' - elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix - fi -+DUALCASE=1; export DUALCASE # for MKS sh - --# NLS nuisances. - # Support unset when possible. --if (FOO=FOO; unset FOO) >/dev/null 2>&1; then -+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset - else - as_unset=false - fi - --(set +x; test -n "`(LANG=C; export LANG) 2>&1`") && -- { $as_unset LANG || test "${LANG+set}" != set; } || -- { LANG=C; export LANG; } --(set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && -- { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || -- { LC_ALL=C; export LC_ALL; } --(set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && -- { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || -- { LC_TIME=C; export LC_TIME; } --(set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && -- { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || -- { LC_CTYPE=C; export LC_CTYPE; } --(set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && -- { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || -- { LANGUAGE=C; export LANGUAGE; } --(set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && -- { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || -- { LC_COLLATE=C; export LC_COLLATE; } --(set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && -- { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || -- { LC_NUMERIC=C; export LC_NUMERIC; } --(set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && -- { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || -- { LC_MESSAGES=C; export LC_MESSAGES; } -+ -+# Work around bugs in pre-3.0 UWIN ksh. -+$as_unset ENV MAIL MAILPATH -+PS1='$ ' -+PS2='> ' -+PS4='+ ' -+ -+# NLS nuisances. -+for as_var in \ -+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ -+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ -+ LC_TELEPHONE LC_TIME -+do -+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then -+ eval $as_var=C; export $as_var -+ else -+ $as_unset $as_var -+ fi -+done -+ -+# Required to use basename. -+if expr a : '\(a\)' >/dev/null 2>&1; then -+ as_expr=expr -+else -+ as_expr=false -+fi -+ -+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then -+ as_basename=basename -+else -+ as_basename=false -+fi - - - # Name of the executable. --as_me=`(basename "$0") 2>/dev/null || -+as_me=`$as_basename "$0" || - $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ -@@ -13487,6 +29231,7 @@ - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - -+ - # PATH needs CR, and LINENO needs CR and PATH. - # Avoid depending upon Character Ranges. - as_cr_letters='abcdefghijklmnopqrstuvwxyz' -@@ -13497,15 +29242,15 @@ - - # The user is always right. - if test "${PATH_SEPARATOR+set}" != set; then -- echo "#! /bin/sh" >conftest.sh -- echo "exit 0" >>conftest.sh -- chmod +x conftest.sh -- if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then -+ echo "#! /bin/sh" >conf$$.sh -+ echo "exit 0" >>conf$$.sh -+ chmod +x conf$$.sh -+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi -- rm -f conftest.sh -+ rm -f conf$$.sh - fi - - -@@ -13554,6 +29299,8 @@ - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then -+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } -+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} -@@ -13627,13 +29374,20 @@ - fi - rm -f conf$$ conf$$.exe conf$$.file - -+if mkdir -p . 2>/dev/null; then -+ as_mkdir_p=: -+else -+ test -d ./-p && rmdir ./-p -+ as_mkdir_p=false -+fi -+ - as_executable_p="test -f" - - # Sed expression to map a string onto a valid CPP name. --as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" -+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - - # Sed expression to map a string onto a valid variable name. --as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" -+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - # IFS -@@ -13643,7 +29397,7 @@ - IFS=" $as_nl" - - # CDPATH. --$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } -+$as_unset CDPATH - - exec 6>&1 - -@@ -13660,7 +29414,7 @@ - cat >&5 <<_CSEOF - - This file was extended by $as_me, which was --generated by GNU Autoconf 2.53. Invocation command line was -+generated by GNU Autoconf 2.59. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS -@@ -13700,12 +29454,13 @@ - - -h, --help print this help, then exit - -V, --version print version number, then exit -+ -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] -- instantiate the configuration file FILE -+ instantiate the configuration file FILE - --header=FILE[:TEMPLATE] -- instantiate the configuration header FILE -+ instantiate the configuration header FILE - - Configuration files: - $config_files -@@ -13722,11 +29477,10 @@ - cat >>$CONFIG_STATUS <<_ACEOF - ac_cs_version="\\ - config.status --configured by $0, generated by GNU Autoconf 2.53, -+configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" - --Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 --Free Software Foundation, Inc. -+Copyright (C) 2003 Free Software Foundation, Inc. - This config.status script is free software; the Free Software Foundation - gives unlimited permission to copy, distribute and modify it." - srcdir=$srcdir -@@ -13743,25 +29497,25 @@ - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` -- shift -- set dummy "$ac_option" "$ac_optarg" ${1+"$@"} -- shift -+ ac_shift=: -+ ;; -+ -*) -+ ac_option=$1 -+ ac_optarg=$2 -+ ac_shift=shift - ;; -- -*);; - *) # This is not an option, so the user has probably given explicit - # arguments. -+ ac_option=$1 - ac_need_defaults=false;; - esac - -- case $1 in -+ case $ac_option in - # Handling of the options. - _ACEOF --cat >>$CONFIG_STATUS <<_ACEOF -- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) -- echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" -- exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; --_ACEOF - cat >>$CONFIG_STATUS <<\_ACEOF -+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) -+ ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) -@@ -13776,13 +29530,16 @@ - --debug | --d* | -d ) - debug=: ;; - --file | --fil | --fi | --f ) -- shift -- CONFIG_FILES="$CONFIG_FILES $1" -+ $ac_shift -+ CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) -- shift -- CONFIG_HEADERS="$CONFIG_HEADERS $1" -+ $ac_shift -+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; -+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ -+ | -silent | --silent | --silen | --sile | --sil | --si | --s) -+ ac_cs_silent=: ;; - - # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -@@ -13797,6 +29554,20 @@ - shift - done - -+ac_configure_extra_args= -+ -+if $ac_cs_silent; then -+ exec 6>/dev/null -+ ac_configure_extra_args="$ac_configure_extra_args --silent" -+fi -+ -+_ACEOF -+cat >>$CONFIG_STATUS <<_ACEOF -+if \$ac_cs_recheck; then -+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 -+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -+fi -+ - _ACEOF - - cat >>$CONFIG_STATUS <<_ACEOF -@@ -13805,10 +29576,10 @@ - # - - AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" --# Capture the value of obsolete $ALL_LINGUAS because we need it to compute -- # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it -+# Capture the value of obsolete ALL_LINGUAS because we need it to compute -+ # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it - # from automake. -- eval 'ALL_LINGUAS''="$ALL_LINGUAS"' -+ eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' - # Capture the value of LINGUAS because we need it to compute CATALOGS. - LINGUAS="${LINGUAS-%UNSET%}" - -@@ -13852,6 +29623,9 @@ - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands - fi - -+# Have a temporary directory for convenience. Make it in the build tree -+# simply because there is no reason to put it here, and in addition, -+# creating and moving files from /tmp can sometimes cause problems. - # Create a temporary directory, and hook for its removal unless debugging. - $debug || - { -@@ -13860,17 +29634,17 @@ - } - - # Create a (secure) tmp directory for tmp files. --: ${TMPDIR=/tmp} -+ - { -- tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && -+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" - } || - { -- tmp=$TMPDIR/cs$$-$RANDOM -+ tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) - } || - { -- echo "$me: cannot create a temporary directory in $TMPDIR" >&2 -+ echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } - } - -@@ -13928,6 +29702,7 @@ - s,@ac_ct_CC@,$ac_ct_CC,;t t - s,@EXEEXT@,$EXEEXT,;t t - s,@OBJEXT@,$OBJEXT,;t t -+s,@CYGPATH_W@,$CYGPATH_W,;t t - s,@PACKAGE@,$PACKAGE,;t t - s,@VERSION@,$VERSION,;t t - s,@ACLOCAL@,$ACLOCAL,;t t -@@ -13935,13 +29710,17 @@ - s,@AUTOMAKE@,$AUTOMAKE,;t t - s,@AUTOHEADER@,$AUTOHEADER,;t t - s,@MAKEINFO@,$MAKEINFO,;t t --s,@AMTAR@,$AMTAR,;t t - s,@install_sh@,$install_sh,;t t - s,@STRIP@,$STRIP,;t t - s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t - s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t -+s,@mkdir_p@,$mkdir_p,;t t - s,@AWK@,$AWK,;t t - s,@SET_MAKE@,$SET_MAKE,;t t -+s,@am__leading_dot@,$am__leading_dot,;t t -+s,@AMTAR@,$AMTAR,;t t -+s,@am__tar@,$am__tar,;t t -+s,@am__untar@,$am__untar,;t t - s,@DEPDIR@,$DEPDIR,;t t - s,@am__include@,$am__include,;t t - s,@am__quote@,$am__quote,;t t -@@ -13949,6 +29728,8 @@ - s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t - s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t - s,@CCDEPMODE@,$CCDEPMODE,;t t -+s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t -+s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t - s,@build@,$build,;t t - s,@build_cpu@,$build_cpu,;t t - s,@build_vendor@,$build_vendor,;t t -@@ -13957,35 +29738,50 @@ - s,@host_cpu@,$host_cpu,;t t - s,@host_vendor@,$host_vendor,;t t - s,@host_os@,$host_os,;t t -+s,@EGREP@,$EGREP,;t t - s,@LN_S@,$LN_S,;t t - s,@ECHO@,$ECHO,;t t -+s,@AR@,$AR,;t t -+s,@ac_ct_AR@,$ac_ct_AR,;t t - s,@RANLIB@,$RANLIB,;t t - s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t - s,@CPP@,$CPP,;t t --s,@LIBTOOL@,$LIBTOOL,;t t - s,@CXX@,$CXX,;t t - s,@CXXFLAGS@,$CXXFLAGS,;t t - s,@ac_ct_CXX@,$ac_ct_CXX,;t t - s,@CXXDEPMODE@,$CXXDEPMODE,;t t -+s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t -+s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t -+s,@CXXCPP@,$CXXCPP,;t t -+s,@F77@,$F77,;t t -+s,@FFLAGS@,$FFLAGS,;t t -+s,@ac_ct_F77@,$ac_ct_F77,;t t -+s,@LIBTOOL@,$LIBTOOL,;t t - s,@ALLOCA@,$ALLOCA,;t t - s,@GSM_VERSION@,$GSM_VERSION,;t t - s,@MKINSTALLDIRS@,$MKINSTALLDIRS,;t t -+s,@USE_NLS@,$USE_NLS,;t t - s,@MSGFMT@,$MSGFMT,;t t - s,@GMSGFMT@,$GMSGFMT,;t t - s,@XGETTEXT@,$XGETTEXT,;t t - s,@MSGMERGE@,$MSGMERGE,;t t -+s,@GLIBC2@,$GLIBC2,;t t - s,@GLIBC21@,$GLIBC21,;t t -+s,@INTL_MACOSX_LIBS@,$INTL_MACOSX_LIBS,;t t -+s,@HAVE_POSIX_PRINTF@,$HAVE_POSIX_PRINTF,;t t -+s,@HAVE_ASPRINTF@,$HAVE_ASPRINTF,;t t -+s,@HAVE_SNPRINTF@,$HAVE_SNPRINTF,;t t -+s,@HAVE_WPRINTF@,$HAVE_WPRINTF,;t t - s,@LIBICONV@,$LIBICONV,;t t - s,@LTLIBICONV@,$LTLIBICONV,;t t - s,@INTLBISON@,$INTLBISON,;t t --s,@USE_NLS@,$USE_NLS,;t t - s,@BUILD_INCLUDED_LIBINTL@,$BUILD_INCLUDED_LIBINTL,;t t - s,@USE_INCLUDED_LIBINTL@,$USE_INCLUDED_LIBINTL,;t t - s,@CATOBJEXT@,$CATOBJEXT,;t t --s,@INTLOBJS@,$INTLOBJS,;t t - s,@DATADIRNAME@,$DATADIRNAME,;t t - s,@INSTOBJEXT@,$INSTOBJEXT,;t t - s,@GENCAT@,$GENCAT,;t t -+s,@INTLOBJS@,$INTLOBJS,;t t - s,@INTL_LIBTOOL_SUFFIX_PREFIX@,$INTL_LIBTOOL_SUFFIX_PREFIX,;t t - s,@INTLLIBS@,$INTLLIBS,;t t - s,@LIBINTL@,$LIBINTL,;t t -@@ -13993,6 +29789,8 @@ - s,@POSUB@,$POSUB,;t t - s,@COMPILE_INTL_TRUE@,$COMPILE_INTL_TRUE,;t t - s,@COMPILE_INTL_FALSE@,$COMPILE_INTL_FALSE,;t t -+s,@LIBOBJS@,$LIBOBJS,;t t -+s,@LTLIBOBJS@,$LTLIBOBJS,;t t - CEOF - - _ACEOF -@@ -14022,9 +29820,9 @@ - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then -- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" -+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else -- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" -+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end -@@ -14042,46 +29840,51 @@ - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin -- cat >$tmp/stdin -- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` -- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; -+ cat >$tmp/stdin -+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` -+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` -- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; -+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || - $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -- X"$ac_file" : 'X\(//\)[^/]' \| \ -- X"$ac_file" : 'X\(//\)$' \| \ -- X"$ac_file" : 'X\(/\)' \| \ -- . : '\(.\)' 2>/dev/null || -+ X"$ac_file" : 'X\(//\)[^/]' \| \ -+ X"$ac_file" : 'X\(//\)$' \| \ -+ X"$ac_file" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || - echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` -- { case "$ac_dir" in -- [\\/]* | ?:[\\/]* ) as_incr_dir=;; -- *) as_incr_dir=.;; --esac --as_dummy="$ac_dir" --for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do -- case $as_mkdir_dir in -- # Skip DOS drivespec -- ?:) as_incr_dir=$as_mkdir_dir ;; -- *) -- as_incr_dir=$as_incr_dir/$as_mkdir_dir -- test -d "$as_incr_dir" || -- mkdir "$as_incr_dir" || -- { { echo "$as_me:$LINENO: error: cannot create \"$ac_dir\"" >&5 --echo "$as_me: error: cannot create \"$ac_dir\"" >&2;} -- { (exit 1); exit 1; }; } -- ;; -- esac --done; } -+ { if $as_mkdir_p; then -+ mkdir -p "$ac_dir" -+ else -+ as_dir="$ac_dir" -+ as_dirs= -+ while test ! -d "$as_dir"; do -+ as_dirs="$as_dir $as_dirs" -+ as_dir=`(dirname "$as_dir") 2>/dev/null || -+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -+ X"$as_dir" : 'X\(//\)[^/]' \| \ -+ X"$as_dir" : 'X\(//\)$' \| \ -+ X"$as_dir" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || -+echo X"$as_dir" | -+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } -+ /^X\(\/\/\)[^/].*/{ s//\1/; q; } -+ /^X\(\/\/\)$/{ s//\1/; q; } -+ /^X\(\/\).*/{ s//\1/; q; } -+ s/.*/./; q'` -+ done -+ test ! -n "$as_dirs" || mkdir $as_dirs -+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} -+ { (exit 1); exit 1; }; }; } - - ac_builddir=. - -@@ -14108,12 +29911,45 @@ - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; - esac --# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be --# absolute. --ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` --ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` --ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` --ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` -+ -+# Do not use `cd foo && pwd` to compute absolute paths, because -+# the directories may not exist. -+case `pwd` in -+.) ac_abs_builddir="$ac_dir";; -+*) -+ case "$ac_dir" in -+ .) ac_abs_builddir=`pwd`;; -+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; -+ *) ac_abs_builddir=`pwd`/"$ac_dir";; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_top_builddir=${ac_top_builddir}.;; -+*) -+ case ${ac_top_builddir}. in -+ .) ac_abs_top_builddir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; -+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_srcdir=$ac_srcdir;; -+*) -+ case $ac_srcdir in -+ .) ac_abs_srcdir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; -+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_top_srcdir=$ac_top_srcdir;; -+*) -+ case $ac_top_srcdir in -+ .) ac_abs_top_srcdir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; -+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; -+ esac;; -+esac - - - case $INSTALL in -@@ -14121,11 +29957,6 @@ - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; - esac - -- if test x"$ac_file" != x-; then -- { echo "$as_me:$LINENO: creating $ac_file" >&5 --echo "$as_me: creating $ac_file" >&6;} -- rm -f "$ac_file" -- fi - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ -@@ -14135,7 +29966,7 @@ - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | -- sed 's,.*/,,'` by configure." -+ sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. -@@ -14144,26 +29975,32 @@ - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) -- # Absolute (can't be DOS-style, as IFS=:) -- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -+ # Absolute (can't be DOS-style, as IFS=:) -+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 - echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } -- echo $f;; -+ echo "$f";; - *) # Relative -- if test -f "$f"; then -- # Build tree -- echo $f -- elif test -f "$srcdir/$f"; then -- # Source tree -- echo $srcdir/$f -- else -- # /dev/null tree -- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -+ if test -f "$f"; then -+ # Build tree -+ echo "$f" -+ elif test -f "$srcdir/$f"; then -+ # Source tree -+ echo "$srcdir/$f" -+ else -+ # /dev/null tree -+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 - echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } -- fi;; -+ fi;; - esac - done` || { (exit 1); exit 1; } -+ -+ if test x"$ac_file" != x-; then -+ { echo "$as_me:$LINENO: creating $ac_file" >&5 -+echo "$as_me: creating $ac_file" >&6;} -+ rm -f "$ac_file" -+ fi - _ACEOF - cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -@@ -14203,12 +30040,12 @@ - # NAME is the cpp macro being defined and VALUE is the value it is being given. - # - # ac_d sets the value in "#define NAME VALUE" lines. --ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' --ac_dB='[ ].*$,\1#\2' -+ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -+ac_dB='[ ].*$,\1#\2' - ac_dC=' ' - ac_dD=',;t' - # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". --ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -+ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' - ac_uB='$,\1#\2define\3' - ac_uC=' ' - ac_uD=',;t' -@@ -14217,11 +30054,11 @@ - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin -- cat >$tmp/stdin -- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` -- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; -+ cat >$tmp/stdin -+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` -+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` -- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; -+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - -@@ -14235,28 +30072,29 @@ - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) -- # Absolute (can't be DOS-style, as IFS=:) -- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -+ # Absolute (can't be DOS-style, as IFS=:) -+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 - echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } -- echo $f;; -+ # Do quote $f, to prevent DOS paths from being IFS'd. -+ echo "$f";; - *) # Relative -- if test -f "$f"; then -- # Build tree -- echo $f -- elif test -f "$srcdir/$f"; then -- # Source tree -- echo $srcdir/$f -- else -- # /dev/null tree -- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -+ if test -f "$f"; then -+ # Build tree -+ echo "$f" -+ elif test -f "$srcdir/$f"; then -+ # Source tree -+ echo "$srcdir/$f" -+ else -+ # /dev/null tree -+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 - echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } -- fi;; -+ fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. -- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in -+ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - - _ACEOF - -@@ -14279,9 +30117,9 @@ - s,[\\$`],\\&,g - t clear - : clear --s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp - t end --s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp - : end - _ACEOF - # If some macros were called several times there might be several times -@@ -14295,13 +30133,13 @@ - # example, in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - cat >>conftest.undefs <<\_ACEOF --s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -+s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, - _ACEOF - - # Break up conftest.defines because some shells have a limit on the size - # of here documents, and old seds have small limits too (100 cmds). - echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS --echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -+echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS - echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS - echo ' :' >>$CONFIG_STATUS - rm -f conftest.tail -@@ -14310,7 +30148,7 @@ - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. -- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS -+ echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS -@@ -14325,7 +30163,7 @@ - mv conftest.tail conftest.defines - done - rm -f conftest.defines --echo ' fi # egrep' >>$CONFIG_STATUS -+echo ' fi # grep' >>$CONFIG_STATUS - echo >>$CONFIG_STATUS - - # Break up conftest.undefs because some shells have a limit on the size -@@ -14337,7 +30175,7 @@ - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' -- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS -+ echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS -@@ -14365,41 +30203,46 @@ - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in - if test x"$ac_file" != x-; then -- if cmp -s $ac_file $tmp/config.h 2>/dev/null; then -+ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then - { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 - echo "$as_me: $ac_file is unchanged" >&6;} - else - ac_dir=`(dirname "$ac_file") 2>/dev/null || - $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -- X"$ac_file" : 'X\(//\)[^/]' \| \ -- X"$ac_file" : 'X\(//\)$' \| \ -- X"$ac_file" : 'X\(/\)' \| \ -- . : '\(.\)' 2>/dev/null || -+ X"$ac_file" : 'X\(//\)[^/]' \| \ -+ X"$ac_file" : 'X\(//\)$' \| \ -+ X"$ac_file" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || - echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` -- { case "$ac_dir" in -- [\\/]* | ?:[\\/]* ) as_incr_dir=;; -- *) as_incr_dir=.;; --esac --as_dummy="$ac_dir" --for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do -- case $as_mkdir_dir in -- # Skip DOS drivespec -- ?:) as_incr_dir=$as_mkdir_dir ;; -- *) -- as_incr_dir=$as_incr_dir/$as_mkdir_dir -- test -d "$as_incr_dir" || -- mkdir "$as_incr_dir" || -- { { echo "$as_me:$LINENO: error: cannot create \"$ac_dir\"" >&5 --echo "$as_me: error: cannot create \"$ac_dir\"" >&2;} -- { (exit 1); exit 1; }; } -- ;; -- esac --done; } -+ { if $as_mkdir_p; then -+ mkdir -p "$ac_dir" -+ else -+ as_dir="$ac_dir" -+ as_dirs= -+ while test ! -d "$as_dir"; do -+ as_dirs="$as_dir $as_dirs" -+ as_dir=`(dirname "$as_dir") 2>/dev/null || -+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -+ X"$as_dir" : 'X\(//\)[^/]' \| \ -+ X"$as_dir" : 'X\(//\)$' \| \ -+ X"$as_dir" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || -+echo X"$as_dir" | -+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } -+ /^X\(\/\/\)[^/].*/{ s//\1/; q; } -+ /^X\(\/\/\)$/{ s//\1/; q; } -+ /^X\(\/\).*/{ s//\1/; q; } -+ s/.*/./; q'` -+ done -+ test ! -n "$as_dirs" || mkdir $as_dirs -+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} -+ { (exit 1); exit 1; }; }; } - - rm -f $ac_file - mv $tmp/config.h $ac_file -@@ -14408,13 +30251,29 @@ - cat $tmp/config.h - rm -f $tmp/config.h - fi -- # Run the commands associated with the file. -- case $ac_file in -- gsm_config.h ) # update the timestamp --echo 'timestamp for gsm_config.h' >"./stamp-h1" -- ;; -+# Compute $ac_file's index in $config_headers. -+_am_stamp_count=1 -+for _am_header in $config_headers :; do -+ case $_am_header in -+ $ac_file | $ac_file:* ) -+ break ;; -+ * ) -+ _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac - done -+echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null || -+$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -+ X$ac_file : 'X\(//\)[^/]' \| \ -+ X$ac_file : 'X\(//\)$' \| \ -+ X$ac_file : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || -+echo X$ac_file | -+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } -+ /^X\(\/\/\)[^/].*/{ s//\1/; q; } -+ /^X\(\/\/\)$/{ s//\1/; q; } -+ /^X\(\/\).*/{ s//\1/; q; } -+ s/.*/./; q'`/stamp-h$_am_stamp_count -+done - _ACEOF - cat >>$CONFIG_STATUS <<\_ACEOF - -@@ -14426,16 +30285,41 @@ - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_dir=`(dirname "$ac_dest") 2>/dev/null || - $as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -- X"$ac_dest" : 'X\(//\)[^/]' \| \ -- X"$ac_dest" : 'X\(//\)$' \| \ -- X"$ac_dest" : 'X\(/\)' \| \ -- . : '\(.\)' 2>/dev/null || -+ X"$ac_dest" : 'X\(//\)[^/]' \| \ -+ X"$ac_dest" : 'X\(//\)$' \| \ -+ X"$ac_dest" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || - echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` -+ { if $as_mkdir_p; then -+ mkdir -p "$ac_dir" -+ else -+ as_dir="$ac_dir" -+ as_dirs= -+ while test ! -d "$as_dir"; do -+ as_dirs="$as_dir $as_dirs" -+ as_dir=`(dirname "$as_dir") 2>/dev/null || -+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -+ X"$as_dir" : 'X\(//\)[^/]' \| \ -+ X"$as_dir" : 'X\(//\)$' \| \ -+ X"$as_dir" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || -+echo X"$as_dir" | -+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } -+ /^X\(\/\/\)[^/].*/{ s//\1/; q; } -+ /^X\(\/\/\)$/{ s//\1/; q; } -+ /^X\(\/\).*/{ s//\1/; q; } -+ s/.*/./; q'` -+ done -+ test ! -n "$as_dirs" || mkdir $as_dirs -+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} -+ { (exit 1); exit 1; }; }; } -+ - ac_builddir=. - - if test "$ac_dir" != .; then -@@ -14461,12 +30345,45 @@ - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; - esac --# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be --# absolute. --ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` --ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` --ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` --ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` -+ -+# Do not use `cd foo && pwd` to compute absolute paths, because -+# the directories may not exist. -+case `pwd` in -+.) ac_abs_builddir="$ac_dir";; -+*) -+ case "$ac_dir" in -+ .) ac_abs_builddir=`pwd`;; -+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; -+ *) ac_abs_builddir=`pwd`/"$ac_dir";; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_top_builddir=${ac_top_builddir}.;; -+*) -+ case ${ac_top_builddir}. in -+ .) ac_abs_top_builddir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; -+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_srcdir=$ac_srcdir;; -+*) -+ case $ac_srcdir in -+ .) ac_abs_srcdir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; -+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; -+ esac;; -+esac -+case $ac_abs_builddir in -+.) ac_abs_top_srcdir=$ac_top_srcdir;; -+*) -+ case $ac_top_srcdir in -+ .) ac_abs_top_srcdir=$ac_abs_builddir;; -+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; -+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; -+ esac;; -+esac - - - { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 -@@ -14484,10 +30401,10 @@ - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`(dirname "$mf") 2>/dev/null || - $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -- X"$mf" : 'X\(//\)[^/]' \| \ -- X"$mf" : 'X\(//\)$' \| \ -- X"$mf" : 'X\(/\)' \| \ -- . : '\(.\)' 2>/dev/null || -+ X"$mf" : 'X\(//\)[^/]' \| \ -+ X"$mf" : 'X\(//\)$' \| \ -+ X"$mf" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || - echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } -@@ -14497,61 +30414,60 @@ - else - continue - fi -- grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue -- # Extract the definition of DEP_FILES from the Makefile without -- # running `make'. -- DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` -+ # Extract the definition of DEPDIR, am__include, and am__quote -+ # from the Makefile without running `make'. -+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue -+ am__include=`sed -n 's/^am__include = //p' < "$mf"` -+ test -z "am__include" && continue -+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it -- U=`sed -n -e '/^U = / s///p' < "$mf"` -- test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" -- # We invoke sed twice because it is the simplest approach to -- # changing $(DEPDIR) to its actual value in the expansion. -- for file in `sed -n -e ' -- /^DEP_FILES = .*\\\\$/ { -- s/^DEP_FILES = // -- :loop -- s/\\\\$// -- p -- n -- /\\\\$/ b loop -- p -- } -- /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ -+ U=`sed -n 's/^U = //p' < "$mf"` -+ # Find all dependency output files, they are included files with -+ # $(DEPDIR) in their names. We invoke sed twice because it is the -+ # simplest approach to changing $(DEPDIR) to its actual value in the -+ # expansion. -+ for file in `sed -n " -+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`(dirname "$file") 2>/dev/null || - $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -- X"$file" : 'X\(//\)[^/]' \| \ -- X"$file" : 'X\(//\)$' \| \ -- X"$file" : 'X\(/\)' \| \ -- . : '\(.\)' 2>/dev/null || -+ X"$file" : 'X\(//\)[^/]' \| \ -+ X"$file" : 'X\(//\)$' \| \ -+ X"$file" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || - echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` -- { case $dirpart/$fdir in -- [\\/]* | ?:[\\/]* ) as_incr_dir=;; -- *) as_incr_dir=.;; --esac --as_dummy=$dirpart/$fdir --for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do -- case $as_mkdir_dir in -- # Skip DOS drivespec -- ?:) as_incr_dir=$as_mkdir_dir ;; -- *) -- as_incr_dir=$as_incr_dir/$as_mkdir_dir -- test -d "$as_incr_dir" || -- mkdir "$as_incr_dir" || -- { { echo "$as_me:$LINENO: error: cannot create $dirpart/$fdir" >&5 --echo "$as_me: error: cannot create $dirpart/$fdir" >&2;} -- { (exit 1); exit 1; }; } -- ;; -- esac --done; } -+ { if $as_mkdir_p; then -+ mkdir -p $dirpart/$fdir -+ else -+ as_dir=$dirpart/$fdir -+ as_dirs= -+ while test ! -d "$as_dir"; do -+ as_dirs="$as_dir $as_dirs" -+ as_dir=`(dirname "$as_dir") 2>/dev/null || -+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ -+ X"$as_dir" : 'X\(//\)[^/]' \| \ -+ X"$as_dir" : 'X\(//\)$' \| \ -+ X"$as_dir" : 'X\(/\)' \| \ -+ . : '\(.\)' 2>/dev/null || -+echo X"$as_dir" | -+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } -+ /^X\(\/\/\)[^/].*/{ s//\1/; q; } -+ /^X\(\/\/\)$/{ s//\1/; q; } -+ /^X\(\/\).*/{ s//\1/; q; } -+ s/.*/./; q'` -+ done -+ test ! -n "$as_dirs" || mkdir $as_dirs -+ fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 -+echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} -+ { (exit 1); exit 1; }; }; } - - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" -@@ -14578,35 +30494,51 @@ - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac -+ # Treat a directory as a PO directory if and only if it has a -+ # POTFILES.in file. This allows packages to have multiple PO -+ # directories under different names or in different locations. - if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then - rm -f "$ac_dir/POTFILES" - test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" -- # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend -+ POMAKEFILEDEPS="POTFILES.in" -+ # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend - # on $ac_dir but don't depend on user-specified configuration - # parameters. - if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then - # The LINGUAS file contains the set of available languages. -- if test -n "$ALL_LINGUAS"; then -+ if test -n "$OBSOLETE_ALL_LINGUAS"; then - test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" - fi -- ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` -+ ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assigment from automake. - eval 'ALL_LINGUAS''=$ALL_LINGUAS_' -+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" -+ else -+ # The set of available languages was given in configure.in. -+ eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' - fi -+ # Compute POFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) -+ # Compute UPDATEPOFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) -+ # Compute DUMMYPOFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) -+ # Compute GMOFILES -+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) - case "$ac_given_srcdir" in - .) srcdirpre= ;; - *) srcdirpre='$(srcdir)/' ;; - esac - POFILES= -- GMOFILES= - UPDATEPOFILES= - DUMMYPOFILES= -+ GMOFILES= - for lang in $ALL_LINGUAS; do - POFILES="$POFILES $srcdirpre$lang.po" -- GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" - DUMMYPOFILES="$DUMMYPOFILES $lang.nop" -+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - done - # CATALOGS depends on both $ac_dir and the user's LINGUAS - # environment variable. -@@ -14641,7 +30573,7 @@ - done - fi - test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" -- sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" -+ sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" - for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do - if test -f "$f"; then - case "$f" in -@@ -14677,8 +30609,11 @@ - # need to make the FD available again. - if test "$no_create" != yes; then - ac_cs_success=: -+ ac_config_status_args= -+ test "$silent" = yes && -+ ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null -- $SHELL $CONFIG_STATUS || ac_cs_success=false -+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. ---- gsmlib-1.10.orig/stamp-h.in -+++ gsmlib-1.10/stamp-h.in -@@ -0,0 +1 @@ -+timestamp ---- gsmlib-1.10.orig/apps/gsmsmsstore.cc -+++ gsmlib-1.10/apps/gsmsmsstore.cc -@@ -292,19 +292,14 @@ - sourceStore = new SortedSMSStore(sourceMeTa->getSMSStore(storeName)); - } - -- // make sure destination file exists -+ // make sure destination file exists if specified -+ // Use isFile() for its exception-throwing properties, and discard -+ // return value cos we don't care (yet) whether it's a device or a -+ // regular file. - if (destination != "") -- { -- try -- { -- ofstream f(destination.c_str(), ios::out | ios::app | ios::binary); -- } -- catch (exception) -- { -- } -- } -+ isFile(destination); - -- // start accessing destination destination store or file -+ // start accessing destination store or file - if (operation == CopyOp || operation == BackupOp || operation == AddOp || - operation == DeleteOp) - if (destination == "-") ---- gsmlib-1.10.orig/apps/gsmsmsd.cc -+++ gsmlib-1.10/apps/gsmsmsd.cc -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - #endif - #if defined(HAVE_GETOPT_LONG) || defined(WIN32) - #include -@@ -39,6 +40,7 @@ - #include - #include - #include -+#include - - using namespace std; - using namespace gsmlib; -@@ -53,6 +55,12 @@ - {"store", required_argument, (int*)NULL, 't'}, - {"device", required_argument, (int*)NULL, 'd'}, - {"spool", required_argument, (int*)NULL, 's'}, -+ {"sent", required_argument, (int*)NULL, 'S'}, -+ {"failed", required_argument, (int*)NULL, 'F'}, -+ {"priorities", required_argument, (int*)NULL, 'P'}, -+#ifndef WIN32 -+ {"syslog", no_argument, (int*)NULL, 'L'}, -+#endif - {"sca", required_argument, (int*)NULL, 'C'}, - {"flush", no_argument, (int*)NULL, 'f'}, - {"concatenate", required_argument, (int*)NULL, 'c'}, -@@ -178,9 +186,21 @@ - - bool requestStatusReport = false; - --void sendSMS(string spoolDir, Ref at) -+void sendSMS(string spoolDirBase, string sentDirBase, string failedDirBase, -+ unsigned int priority, bool enableSyslog, Ref at) - { -- if (spoolDir != "") -+ string spoolDir = spoolDirBase; -+ string sentDir = sentDirBase; -+ string failedDir = failedDirBase; -+ if ( priority >= 1 ) -+ { -+ spoolDir = spoolDirBase + stringPrintf(_("%d"),priority); -+ sentDir = sentDirBase + stringPrintf(_("%d"),priority); -+ failedDir = failedDirBase + stringPrintf(_("%d"),priority); -+ } -+ if ( priority > 1 ) -+ sendSMS(spoolDirBase, sentDirBase, failedDirBase, priority-1, enableSyslog, at); -+ if (spoolDirBase != "") - { - // look into spoolDir for any outgoing SMS that should be sent - #ifdef WIN32 -@@ -211,6 +231,8 @@ - strcmp(entry->d_name, "..") != 0) - #endif - { -+ if ( priority > 1 ) -+ sendSMS(spoolDirBase, sentDirBase, failedDirBase, priority-1, enableSyslog, at); - // read in file - // the first line is interpreted as the phone number - // the rest is the message -@@ -221,11 +243,30 @@ - #endif - ifstream ifs(filename.c_str()); - if (! ifs) -+#ifndef WIN32 -+ if (enableSyslog) -+ { -+ syslog(LOG_WARNING, "Could not open SMS spool file %s", -+ filename.c_str()); -+ if (failedDirBase != "") { -+ string failedfilename = failedDir + "/" + entry->d_name; -+ rename(filename.c_str(),failedfilename.c_str()); -+ } -+ continue; -+ } -+ else -+#endif - throw GsmException( - stringPrintf(_("count not open SMS spool file %s"), - filename.c_str()), ParameterError); - char phoneBuf[1001]; - ifs.getline(phoneBuf, 1000); -+ for(int i=0;i<1000;i++) -+ if(phoneBuf[i]=='\t' || phoneBuf[i]==0) -+ { // ignore everything after a in the phone number -+ phoneBuf[i]=0; -+ break; -+ } - string text; - while (! ifs.eof()) - { -@@ -252,17 +293,51 @@ - submitSMS->setStatusReportRequest(requestStatusReport); - Address destAddr(phoneNumber); - submitSMS->setDestinationAddress(destAddr); -- if (concatenatedMessageId == -1) -- me->sendSMSs(submitSMS, text, true); -- else -+ try - { -- // maximum for concatenatedMessageId is 255 -- if (concatenatedMessageId > 256) -- concatenatedMessageId = 0; -- me->sendSMSs(submitSMS, text, false, concatenatedMessageId++); -+ if (concatenatedMessageId == -1) -+ me->sendSMSs(submitSMS, text, true); -+ else -+ { -+ // maximum for concatenatedMessageId is 255 -+ if (concatenatedMessageId > 256) -+ concatenatedMessageId = 0; -+ me->sendSMSs(submitSMS, text, false, concatenatedMessageId++); -+ } -+#ifndef WIN32 -+ if (enableSyslog) -+ syslog(LOG_NOTICE, "Sent SMS to %s from file %s", phoneBuf, filename.c_str()); -+#endif -+ if (sentDirBase != "") { -+#ifdef WIN32 -+ string sentfilename = sentDir + "\\" + fileInfo.name; -+#else -+ string sentfilename = sentDir + "/" + entry->d_name; -+#endif -+ rename(filename.c_str(),sentfilename.c_str()); -+ } else { -+ unlink(filename.c_str()); -+ } -+ } -+ catch (GsmException &me) -+ { -+#ifndef WIN32 -+ if (enableSyslog) -+ syslog(LOG_WARNING, "Failed sending SMS to %s from file %s: %s", phoneBuf, -+ filename.c_str(), me.what()); -+ else -+#endif -+ cerr << "Failed sending SMS to " << phoneBuf << " from " -+ << filename << ": " << me.what() << endl; -+ if (failedDirBase != "") { -+#ifdef WIN32 -+ string failedfilename = failedDir + "\\" + fileInfo.name; -+#else -+ string failedfilename = failedDir + "/" + entry->d_name; -+#endif -+ rename(filename.c_str(),failedfilename.c_str()); -+ } - } -- -- unlink(filename.c_str()); - #ifdef WIN32 - } - moreFiles = _findnext(fileHandle, &fileInfo) == 0; -@@ -276,10 +351,18 @@ - } - } - -+#ifndef WIN32 -+void syslogExit(int exitcode, int *dummy) -+{ -+ syslog(LOG_NOTICE, "exited (exit %d)",exitcode); -+} -+#endif -+ - // *** main program - - int main(int argc, char *argv[]) - { -+ bool enableSyslog = false; - try - { - string device = "/dev/mobilephone"; -@@ -291,13 +374,16 @@ - bool flushSMS = false; - bool onlyReceptionIndication = true; - string spoolDir; -+ string sentDir = ""; -+ string failedDir = ""; -+ unsigned int priorities = 0; - string initString = DEFAULT_INIT_STRING; - bool swHandshake = false; - string concatenatedMessageIdStr; - - int opt; - int dummy; -- while((opt = getopt_long(argc, argv, "c:C:I:t:fd:a:b:hvs:XDr", -+ while((opt = getopt_long(argc, argv, "c:C:I:t:fd:a:b:hvs:S:F:P:LXDr", - longOpts, &dummy)) != -1) - switch (opt) - { -@@ -328,6 +414,18 @@ - case 's': - spoolDir = optarg; - break; -+ case 'L': -+ enableSyslog = true; -+ break; -+ case 'S': -+ sentDir = optarg; -+ break; -+ case 'F': -+ failedDir = optarg; -+ break; -+ case 'P': -+ priorities = abs(atoi(optarg)); -+ break; - case 'f': - flushSMS = true; - break; -@@ -360,11 +458,21 @@ - << _(" -d, --device sets the device to connect to") << endl - << _(" -D, --direct enable direct routing of SMSs") << endl - << _(" -f, --flush flush SMS from store") << endl -+ << _(" -F, --failed directory to move failed SMS to,") << endl -+ << _(" if unset, the SMS will be deleted") << endl - << _(" -h, --help prints this message") << endl - << _(" -I, --init device AT init sequence") << endl -+#ifndef WIN32 -+ << _(" -L, --syslog log errors and information to syslog") -+ << endl -+#endif -+ << _(" -P, --priorities number of priority levels to use,") << endl -+ << _(" (default: none)") << endl - << _(" -r, --requeststat request SMS status report") << endl - << _(" -s, --spool spool directory for outgoing SMS") - << endl -+ << _(" -S, --sent directory to move sent SMS to,") << endl -+ << _(" if unset, the SMS will be deleted") << endl - << _(" -t, --store name of SMS store to use for flush\n" - " and/or temporary SMS storage") << endl - << endl -@@ -380,6 +488,14 @@ - << endl << endl - << _(" default is \"sms cb stat\"") << endl << endl - << _("If no action is given, the SMS is printed to stdout") -+ << endl << endl -+ << _("If -P is given, it activates the priority system and sets the") << endl -+ << _("number or levels to use. For every level, there must be directories") << endl -+ << _("named +.") << endl -+ << _("For example \"-P 2 -s queue -S send -F failed\" needs the following") <getAt()); -+ sendSMS(spoolDir, sentDir, failedDir, priorities, enableSyslog, me->getAt()); - } - } - catch (GsmException &ge) ---- gsmlib-1.10.orig/gsmlib/gsm_unix_serial.cc -+++ gsmlib-1.10/gsmlib/gsm_unix_serial.cc -@@ -20,12 +20,14 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - #include - #include -+#include - - using namespace std; - using namespace gsmlib; -@@ -131,7 +133,7 @@ - { - int res = read(_fd, &c, 1); - if (res != 1) -- return -1; -+ throwModemException(_("end of file when reading from TA")); - else - readDone = true; - break; -@@ -178,11 +180,15 @@ - - // switch off non-blocking mode - int fdFlags; -- if ((fdFlags = fcntl(_fd, F_GETFL)) == -1) -+ if ((fdFlags = fcntl(_fd, F_GETFL)) == -1) { -+ close(_fd); - throwModemException(_("getting file status flags failed")); -+ } - fdFlags &= ~O_NONBLOCK; -- if (fcntl(_fd, F_SETFL, fdFlags) == -1) -+ if (fcntl(_fd, F_SETFL, fdFlags) == -1) { -+ close(_fd); - throwModemException(_("switching of non-blocking mode failed")); -+ } - - long int saveTimeoutVal = _timeoutVal; - _timeoutVal = 3; -@@ -194,17 +200,22 @@ - - // toggle DTR to reset modem - int mctl = TIOCM_DTR; -- if (ioctl(_fd, TIOCMBIC, &mctl) < 0) -+ if (ioctl(_fd, TIOCMBIC, &mctl) < 0) { -+ close(_fd); - throwModemException(_("clearing DTR failed")); -+ } - // the waiting time for DTR toggling is increased with each loop - usleep(holdoff[initTries]); -- if (ioctl(_fd, TIOCMBIS, &mctl) < 0) -+ if (ioctl(_fd, TIOCMBIS, &mctl) < 0) { -+ close(_fd); - throwModemException(_("setting DTR failed")); -- -+ } - // get line modes -- if (tcgetattr(_fd, &t) < 0) -+ if (tcgetattr(_fd, &t) < 0) { -+ close(_fd); - throwModemException(stringPrintf(_("tcgetattr device '%s'"), - device.c_str())); -+ } - - // set line speed - cfsetispeed(&t, lineSpeed); -@@ -229,9 +240,11 @@ - t.c_cc[VSUSP] = 0; - - // write back -- if(tcsetattr (_fd, TCSANOW, &t) < 0) -+ if(tcsetattr (_fd, TCSANOW, &t) < 0) { -+ close(_fd); - throwModemException(stringPrintf(_("tcsetattr device '%s'"), - device.c_str())); -+ } - // the waiting time for writing to the ME/TA is increased with each loop - usleep(holdoff[initTries]); - -@@ -279,11 +292,14 @@ - catch (GsmException &e) - { - _timeoutVal = saveTimeoutVal; -- if (initTries == 0) -+ if (initTries == 0) { -+ close(_fd); - throw e; -+ } - } - } - // no response after 3 tries -+ close(_fd); - throw GsmException(stringPrintf(_("reset modem failed '%s'"), - device.c_str()), OtherError); - } ---- gsmlib-1.10.orig/gsmlib/gsm_me_ta.cc -+++ gsmlib-1.10/gsmlib/gsm_me_ta.cc -@@ -19,6 +19,8 @@ - #include - #include - -+#include -+ - using namespace std; - using namespace gsmlib; - ---- gsmlib-1.10.orig/gsmlib/gsm_sorted_phonebook.cc -+++ gsmlib-1.10/gsmlib/gsm_sorted_phonebook.cc -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - - const int MAX_LINE_SIZE = 1000; - ---- gsmlib-1.10.orig/gsmlib/gsm_sms_codec.cc -+++ gsmlib-1.10/gsmlib/gsm_sms_codec.cc -@@ -23,6 +23,7 @@ - #ifdef HAVE_STRING_H - #include - #endif -+#include - #include - using namespace std; - using namespace gsmlib; ---- gsmlib-1.10.orig/gsmlib/gsm_at.cc -+++ gsmlib-1.10/gsmlib/gsm_at.cc -@@ -106,11 +106,27 @@ - putLine("AT" + atCommand); - // and gobble up CR/LF (and possibly echoed characters if echo can't be - // switched off) -+ // Also, some mobiles (e.g., Sony Ericsson K800i) respond to commands -+ // like "at+cmgf=0" with "+CMGF: 0" on success as well as the "OK" -+ // status -- so gobble that (but not if that sort of response was expected) -+ // FIXME: this is a gross hack, should be done via capabilities or sth -+ #include -+ string::size_type loc = atCommand.find( "=", 1 ); -+ string expect; -+ if (loc != string::npos) { -+ expect = atCommand; -+ expect.replace(loc, 1, " "); -+ expect.insert(loc, ":"); -+ } else { -+ expect = ""; -+ } - do - { - s = normalize(getLine()); - } -- while (s.length() == 0 || s == "AT" + atCommand); -+ while (s.length() == 0 || s == "AT" + atCommand || -+ ((response.length() == 0 || !matchResponse(s, response)) && -+ (expect.length() > 0 && matchResponse(s, expect)))); - - // handle errors - if (matchResponse(s, "+CME ERROR:") || matchResponse(s, "+CMS ERROR:")) ---- gsmlib-1.10.orig/gsmlib/gsm_map_key.h -+++ gsmlib-1.10/gsmlib/gsm_map_key.h -@@ -27,6 +27,7 @@ - - template class MapKey - { -+ public: - SortedStore &_myStore; // my store - // different type keys - Address _addressKey; -@@ -45,6 +46,7 @@ - MapKey(SortedStore &myStore, string key) : - _myStore(myStore), _strKey(key) {} - -+/* - friend - bool operator< - #ifndef WIN32 -@@ -59,6 +61,7 @@ - #endif - (const MapKey &x, - const MapKey &y); -+*/ - }; - - // compare two keys -@@ -72,7 +75,7 @@ - // MapKey members - - template -- bool gsmlib::operator<(const MapKey &x, -+ bool operator<(const MapKey &x, - const MapKey &y) - { - assert(&x._myStore == &y._myStore); -@@ -97,7 +100,7 @@ - } - - template -- bool gsmlib::operator==(const MapKey &x, -+ bool operator==(const MapKey &x, - const MapKey &y) - { - assert(&x._myStore == &y._myStore); ---- gsmlib-1.10.orig/gsmlib/gsm_me_ta.h -+++ gsmlib-1.10/gsmlib/gsm_me_ta.h -@@ -291,8 +291,8 @@ - // 3 disable phone receive RF circuits only - // 4 disable phone both transmit and receive RF circuits - // 5...127 implementation-defined -- int MeTa::getFunctionalityLevel() throw(GsmException); -- void MeTa::setFunctionalityLevel(int level) throw(GsmException); -+ int getFunctionalityLevel() throw(GsmException); -+ void setFunctionalityLevel(int level) throw(GsmException); - - // return battery charge status (+CBC): - // 0 ME is powered by the battery -@@ -386,13 +386,13 @@ - void setCallWaitingLockStatus(FacilityClass cl, - bool lock)throw(GsmException); - -- void MeTa::setCLIRPresentation(bool enable) throw(GsmException); -+ void setCLIRPresentation(bool enable) throw(GsmException); - //(+CLIR) - - // 0:according to the subscription of the CLIR service - // 1:CLIR invocation - // 2:CLIR suppression -- int MeTa::getCLIRPresentation() throw(GsmException); -+ int getCLIRPresentation() throw(GsmException); - - friend class Phonebook; - friend class SMSStore; ---- gsmlib-1.10.orig/gsmlib/gsm_util.cc -+++ gsmlib-1.10/gsmlib/gsm_util.cc -@@ -35,6 +35,7 @@ - #define __USE_GNU - #define _GNU_SOURCE - #endif -+#include - #include - #include - ---- gsmlib-1.10.orig/intl/Makefile -+++ gsmlib-1.10/intl/Makefile -@@ -0,0 +1,214 @@ -+# Makefile for directory with message catalog handling in GNU NLS Utilities. -+# Copyright (C) 1995, 1996, 1997 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+PACKAGE = gsmlib -+VERSION = 1.10 -+ -+SHELL = /bin/sh -+ -+srcdir = . -+top_srcdir = .. -+top_builddir = .. -+ -+ -+prefix = /usr -+exec_prefix = ${prefix} -+transform = s,x,x, -+libdir = $(exec_prefix)/lib -+includedir = $(prefix)/include -+datadir = $(prefix)/share -+localedir = $(datadir)/locale -+gnulocaledir = $(prefix)/share/locale -+gettextsrcdir = ${prefix}/share/gettext/intl -+aliaspath = $(localedir):. -+subdir = intl -+ -+INSTALL = /usr/bin/install -c -+INSTALL_DATA = ${INSTALL} -m 644 -+MKINSTALLDIRS = $(top_builddir)/scripts/mkinstalldirs -+ -+l = @l@ -+ -+AR = ar -+CC = i486-linux-gnu-gcc -+LIBTOOL = $(SHELL) $(top_builddir)/libtool -+RANLIB = ranlib -+ -+DEFS = -DGNULOCALEDIR=\"$(gnulocaledir)\" \ -+-DLOCALE_ALIAS_PATH=\"$(aliaspath)\" -DHAVE_CONFIG_H -+CPPFLAGS = -+CFLAGS = -D_REENTRANT -g -O2 -+LDFLAGS = -+ -+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) -+ -+HEADERS = $(COMHDRS) libgettext.h loadinfo.h -+COMHDRS = gettext.h gettextP.h hash-string.h -+SOURCES = $(COMSRCS) intl-compat.c cat-compat.c -+COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \ -+finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \ -+explodename.c -+OBJECTS = bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \ -+finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \ -+explodename.$lo -+CATOBJS = cat-compat.$lo ../po/cat-id-tbl.$lo -+GETTOBJS = intl-compat.$lo -+DISTFILES.common = ChangeLog Makefile.in linux-msg.sed po2tbl.sed.in \ -+xopen-msg.sed $(HEADERS) $(SOURCES) -+DISTFILES.normal = VERSION -+DISTFILES.gettext = libintl.glibc intlh.inst.in -+ -+.SUFFIXES: -+.SUFFIXES: .c .o .lo -+.c.o: -+ $(COMPILE) $< -+.c.lo: -+ $(LIBTOOL) --mode=compile $(COMPILE) $< -+ -+INCLUDES = -I.. -I. -I$(top_srcdir)/intl -I$(top_srcdir)/lib -+ -+all: all-no -+ -+all-yes: libintl.$la intlh.inst -+all-no: -+ -+libintl.a: $(OBJECTS) -+ rm -f $@ -+ $(AR) cru $@ $(OBJECTS) -+ $(RANLIB) $@ -+ -+libintl.la: $(OBJECTS) -+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJECTS) \ -+ -version-info 1:0 -rpath $(libdir) -+ -+../po/cat-id-tbl.$lo: ../po/cat-id-tbl.c $(top_srcdir)/po/$(PACKAGE).pot -+ cd ../po && $(MAKE) cat-id-tbl.$lo -+ -+check: all -+ -+# This installation goal is only used in GNU gettext. Packages which -+# only use the library should use install instead. -+ -+# We must not install the libintl.h/libintl.a files if we are on a -+# system which has the gettext() function in its C library or in a -+# separate library or use the catgets interface. A special case is -+# where configure found a previously installed GNU gettext library. -+# If you want to use the one which comes with this version of the -+# package, you have to use `configure --with-included-gettext'. -+install: install-exec install-data -+install-exec: all -+ if test "$(PACKAGE)" = "gettext" \ -+ && test '' = '$(GETTOBJS)'; then \ -+ if test -r $(MKINSTALLDIRS); then \ -+ $(MKINSTALLDIRS) $(libdir) $(includedir); \ -+ else \ -+ $(top_srcdir)/mkinstalldirs $(libdir) $(includedir); \ -+ fi; \ -+ $(INSTALL_DATA) intlh.inst $(includedir)/libintl.h; \ -+ $(INSTALL_DATA) libintl.a $(libdir)/libintl.a; \ -+ else \ -+ : ; \ -+ fi -+install-data: all -+ if test "$(PACKAGE)" = "gettext"; then \ -+ if test -r $(MKINSTALLDIRS); then \ -+ $(MKINSTALLDIRS) $(gettextsrcdir); \ -+ else \ -+ $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \ -+ fi; \ -+ $(INSTALL_DATA) VERSION $(gettextsrcdir)/VERSION; \ -+ dists="$(DISTFILES.common)"; \ -+ for file in $$dists; do \ -+ $(INSTALL_DATA) $(srcdir)/$$file $(gettextsrcdir)/$$file; \ -+ done; \ -+ else \ -+ : ; \ -+ fi -+ -+# Define this as empty until I found a useful application. -+installcheck: -+ -+uninstall: -+ dists="$(DISTFILES.common)"; \ -+ for file in $$dists; do \ -+ rm -f $(gettextsrcdir)/$$file; \ -+ done -+ -+info dvi: -+ -+$(OBJECTS): ../gsm_config.h libgettext.h -+bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h -+dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h -+ -+tags: TAGS -+ -+TAGS: $(HEADERS) $(SOURCES) -+ here=`pwd`; cd $(srcdir) && etags -o $$here/TAGS $(HEADERS) $(SOURCES) -+ -+id: ID -+ -+ID: $(HEADERS) $(SOURCES) -+ here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES) -+ -+ -+mostlyclean: -+ rm -f *.a *.o *.lo core core.* -+ -+clean: mostlyclean -+ -+distclean: clean -+ rm -f Makefile ID TAGS po2msg.sed po2tbl.sed -+ -+maintainer-clean: distclean -+ @echo "This command is intended for maintainers to use;" -+ @echo "it deletes files that may require special tools to rebuild." -+ -+ -+# GNU gettext needs not contain the file `VERSION' but contains some -+# other files which should not be distributed in other packages. -+distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) -+dist distdir: Makefile $(DISTFILES) -+ if test "$(PACKAGE)" = gettext; then \ -+ additional="$(DISTFILES.gettext)"; \ -+ else \ -+ additional="$(DISTFILES.normal)"; \ -+ fi; \ -+ for file in $(DISTFILES.common) $$additional; do \ -+ ln $(srcdir)/$$file $(distdir) 2> /dev/null \ -+ || cp -p $(srcdir)/$$file $(distdir); \ -+ done -+ -+dist-libc: -+ tar zcvf intl-glibc.tar.gz $(COMSRCS) $(COMHDRS) libintl.h.glibc -+ -+Makefile: Makefile.in ../config.status -+ cd .. \ -+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status -+ -+# The dependency for intlh.inst is different in gettext and all other -+# packages. Because we cannot you GNU make features we have to solve -+# the problem while rewriting Makefile.in. -+@GT_YES@intlh.inst: intlh.inst.in ../config.status -+@GT_YES@ cd .. \ -+@GT_YES@ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ -+@GT_YES@ $(SHELL) ./config.status -+@GT_NO@.PHONY: intlh.inst -+@GT_NO@intlh.inst: -+ -+# Tell versions [3.59,3.63) of GNU make not to export all variables. -+# Otherwise a system limit (for SysV at least) may be exceeded. -+.NOEXPORT: ---- gsmlib-1.10.orig/po/cat-id-tbl.c -+++ gsmlib-1.10/po/cat-id-tbl.c -@@ -1,435 +0,0 @@ --/* Automatically generated by po2tbl.sed from gsmlib.pot. */ -- --#if HAVE_CONFIG_H --# include --#endif -- --#include "libgettext.h" -- --const struct _msg_ent _msg_tbl[] = { -- {"", 1}, -- {"could not execute '%s'", 2}, -- {"error writing to '%s'", 3}, -- {"error when calling opendir('%s')(errno: %d/%s)", 4}, -- {"count not open SMS spool file %s", 5}, -- {": version %s [compiled %s]", 6}, -- {"\ --: [-a action][-b baudrate][-C sca][-d device][-f][-h][-I init string]\n\ -- [-s spool dir][-t][-v]{sms_type}", 7}, -- {"\ -- -a, --action the action to execute when an SMS arrives\n\ -- (SMS is send to stdin of action)", 8}, -- {" -b, --baudrate baudrate to use for device (default: 38400)", 9}, -- {" -c, --concatenate start ID for concatenated SMS messages", 10}, -- {" -C, --sca SMS service centre address", 11}, -- {" -d, --device sets the device to connect to", 12}, -- {" -D, --direct enable direct routing of SMSs", 13}, -- {" -f, --flush flush SMS from store", 14}, -- {" -h, --help prints this message", 15}, -- {" -I, --init device AT init sequence", 16}, -- {" -r, --requeststat request SMS status report", 17}, -- {" -s, --spool spool directory for outgoing SMS", 18}, -- {"\ -- -t, --store name of SMS store to use for flush\n\ -- and/or temporary SMS storage", 19}, -- {" -v, --version prints version and exits", 20}, -- {" -X, --xonxoff switch on software handshake", 21}, -- {" sms_type may be any combination of", 22}, -- {" sms, no_sms controls reception of normal SMS", 23}, -- {" cb, no_cb controls reception of cell broadcast messages", 24}, -- {" stat, no_stat controls reception of status reports", 25}, -- {" default is \"sms cb stat\"", 26}, -- {"If no action is given, the SMS is printed to stdout", 27}, -- {"unknown option", 28}, -- {"error when calling sigaction() (errno: %d/%s)", 29}, -- {"store name must be given for flush option", 30}, -- {"Type of message: ", 31}, -- {"SMS message\n", 32}, -- {"submit report message\n", 33}, -- {"status report message\n", 34}, -- {"cell broadcast message\n", 35}, -- {"[ERROR]: ", 36}, -- {"(try setting sms_type, please refer to gsmsmsd manpage)", 37}, -- {"\ --: [-b baudrate][-c concatenatedID][-C sca][-d device][-h][-I init string]\n\ -- [-t][-v][-X] phonenumber [text]", 38}, -- {" -c, --concatenate ID for concatenated SMS messages", 39}, -- {" -d, --device sets the destination device to connect to", 40}, -- {"\ -- -t, --test convert text to GSM alphabet and vice\n\ -- versa, no SMS message is sent", 41}, -- {" phonenumber recipient's phone number", 42}, -- {"\ -- text optional text of the SMS message\n\ -- if omitted: read from stdin", 43}, -- {"phone number and text missing", 44}, -- {"more than two parameters given", 45}, -- {"text is larger than 160 characters", 46}, -- {"inserting '%s' tel# %s", 47}, -- {" (index #%d)", 48}, -- {"updating '%s' tel# %s to new tel# %s", 49}, -- {"updating '%s' tel# %s to new tel# %s(index %d)", 50}, -- {"deleting '%s' tel# %s", 51}, -- {"\ --: [-b baudrate][-c][-d device or file][-h][-I init string]\n\ -- [-p phonebook name][-s device or file][-t charset][-v][-V][-y][-X]", 52}, -- {" -c, --copy copy source entries to destination", 53}, -- {"\ -- -d, --destination sets the destination device to connect \n\ -- to, or the file to write", 54}, -- {" -D, --destination-backend sets the destination backend", 55}, -- {" -i, --index takes index positions into account", 56}, -- {" -p, --phonebook name of phonebook to use", 57}, -- {"\ -- -s, --source sets the source device to connect to,\n\ -- or the file to read", 58}, -- {"\ -- -t, --charset sets the character set to use for\n\ -- phonebook entries", 59}, -- {" -S, --source-backend sets the source backend", 60}, -- {" -V, --verbose print detailed progress messages", 61}, -- {"\ -- -y, --synchronize synchronize destination with source\n\ -- entries (destination is overwritten)\n\ -- (see gsmpb(1) for details)", 62}, -- {"both source and destination must be given", 63}, -- {"phonebook name must be given", 64}, -- {"\ --text '%s' is too large to fit into destination (maximum size %d characters)", 65}, -- {"\ --phone number '%s' is too large to fit into destination (maximum size %d \ --characters)", 66}, -- {"active ", 67}, -- {"inactive ", 68}, -- {"number: ", 69}, -- {" subaddr: ", 70}, -- {" time: ", 71}, -- {" Manufacturer: ", 72}, -- {" Model: ", 73}, -- {" Revision: ", 74}, -- {" Serial Number: ", 75}, -- {" Functionality Level: ", 76}, -- {"unsupported", 77}, -- {"> Status: ", 78}, -- {"unknown", 79}, -- {"current", 80}, -- {"available", 81}, -- {"forbidden", 82}, -- {" Long name: '", 83}, -- {" Short name: '", 84}, -- {" Numeric name: ", 85}, -- {" Mode: ", 86}, -- {"automatic", 87}, -- {"manual", 88}, -- {"deregister", 89}, -- {"manual/automatic", 90}, -- {" Voice", 91}, -- {" unknown", 92}, -- {" Data", 93}, -- {" Fax", 94}, -- {"on", 95}, -- {"off", 96}, -- {"UnconditionalReason", 97}, -- {"MobileBusyReason", 98}, -- {"NoReplyReason", 99}, -- {"NotReachableReason", 100}, -- {"0 ME is powered by the battery", 101}, -- {"1 ME has a battery connected, but is not powered by it", 102}, -- {"2 ME does not have a battery connected", 103}, -- {"3 Recognized power fault, calls inhibited", 104}, -- {"unknown facility class parameter '%c'", 105}, -- {"not enough parameters, minimum number of parameters is %d", 106}, -- {"too many parameters, maximum number of parameters is %d", 107}, -- {"\ --: [-b baudrate][-d device][-h][-I init string][-o operation]\n\ -- [-v][-X]{parameters}", 108}, -- {"\ -- -o, --operation operation to perform on the mobile \n\ -- phone with the specified parameters", 109}, -- {"\ -- parameters parameters to use for the operation\n\ -- (if an operation is given) or\n\ -- a specification which kind of\n\ -- information to read from the mobile phone", 110}, -- {"\ --Refer to gsmctl(1) for details on the available parameters and operations.", 111}, -- {"unknown information parameter '%s'", 112}, -- {"unknown opmode parameter '%s'", 113}, -- {"unknown forward reason parameter '%s'", 114}, -- {"unknown forward mode parameter '%s'", 115}, -- {"unknown operation '%s'", 116}, -- {"inserting entry #%d from source into destination", 117}, -- {"incompatible options '%c' and '%c'", 118}, -- {"\ --: [-a][-b baudrate][-c][-C sca][-d device or file]\n\ -- [-h][-I init string][-k][-l][-s device or file][-t SMS store name]\n\ -- [-v][-V][-x][-X]{indices}|[phonenumber text]", 119}, -- {"\ -- -a, --add add new SMS submit message\n\ -- (phonenumber and text) to destination", 120}, -- {"\ -- -c, --copy copy source entries to destination\n\ -- (if indices are given, copy only these entries)", 121}, -- {"\ -- -d, --destination sets the destination device to\n\ -- connect to, or the file to write to", 122}, -- {"\ -- -k, --backup backup new entries to destination\n\ -- (if indices are given, copy only these entries)", 123}, -- {" -l, --list list source to stdout", 124}, -- {" -t, --store name of SMS store to use", 125}, -- {" -x, --delete delete entries denoted by indices", 126}, -- {"no operation option given", 127}, -- {"both source and destination required", 128}, -- {"destination must not be given", 129}, -- {"source required", 130}, -- {"source must not be given", 131}, -- {"destination required", 132}, -- {"expected number, got '%s'", 133}, -- {"not enough parameters given", 134}, -- {"unexpected parameters", 135}, -- {"store name must be given", 136}, -- {"no index '%s' in source", 137}, -- {"index #%d", 138}, -- {"inserting new entry into destination", 139}, -- {"deleting entry #%d from destination", 140}, -- {"no index '%s' in destination", 141}, -- {"unspecified ME/TA error", 142}, -- {"ME/TA error '", 143}, -- {"(code %s)", 144}, -- {"ME/TA error '' (code not known)", 145}, -- {"unexpected response '%s' when sending 'AT%s'", 146}, -- {"unexpected character in PDU handshake", 147}, -- {"phone failure", 148}, -- {"no connection to phone", 149}, -- {"phone adaptor link reserved", 150}, -- {"operation not allowed", 151}, -- {"operation not supported", 152}, -- {"ph SIM PIN required", 153}, -- {"SIM not inserted", 154}, -- {"SIM PIN required", 155}, -- {"SIM PUK required", 156}, -- {"SIM failure", 157}, -- {"SIM busy", 158}, -- {"SIM wrong", 159}, -- {"incorrect password", 160}, -- {"SIM PIN2 required", 161}, -- {"SIM PUK2 required", 162}, -- {"memory full", 163}, -- {"invalid index", 164}, -- {"not found", 165}, -- {"memory failure", 166}, -- {"text string too long", 167}, -- {"invalid characters in text string", 168}, -- {"dial string too long", 169}, -- {"invalid characters in dial string", 170}, -- {"no network service", 171}, -- {"network timeout", 172}, -- {"invalid ME error %d", 173}, -- {"Unassigned (unallocated) number", 174}, -- {"Operator determined barring", 175}, -- {"Call barred", 176}, -- {"Network failure", 177}, -- {"Short message transfer rejected", 178}, -- {"Congestion", 179}, -- {"Destination out of service", 180}, -- {"Unidentified subscriber", 181}, -- {"Facility rejected", 182}, -- {"Unknown subscriber", 183}, -- {"Network out of order", 184}, -- {"Temporary failure", 185}, -- {"Resources unavailable, unspecified", 186}, -- {"Requested facility not subscribed", 187}, -- {"Requested facility not implemented", 188}, -- {"Invalid Transaction Identifier", 189}, -- {"Semantically incorrect message", 190}, -- {"Invalid mandatory information", 191}, -- {"Message type non-existent or not implemented", 192}, -- {"Message not compatible with short message protocol state", 193}, -- {"Information element non-existent or not implemented", 194}, -- {"Protocol error, unspecified", 195}, -- {"Interworking, unspecified", 196}, -- {"Telematic interworking not supported", 197}, -- {"Short message Type 0 not supported", 198}, -- {"Cannot replace short message", 199}, -- {"Unspecified TP-PID error", 200}, -- {"Data coding scheme (alphabet) not supported", 201}, -- {"Message class not supported", 202}, -- {"Unspecifiec TP-DCS error", 203}, -- {"Command cannot be actioned", 204}, -- {"Command unsupported", 205}, -- {"Unspecified TP-Command error", 206}, -- {"TPDU not supported", 207}, -- {"SC busy", 208}, -- {"No SC subscription", 209}, -- {"SC system failure", 210}, -- {"Invalid SME address", 211}, -- {"Destination SME barred", 212}, -- {"SM Rejected-Duplicated SM", 213}, -- {"SIM SMS storage full", 214}, -- {"No SMS storage capability in SIM", 215}, -- {"Error in MS", 216}, -- {"Memory Capacity Exceed", 217}, -- {"Unspecified error cause", 218}, -- {"ME failure", 219}, -- {"SMS service of ME reserved", 220}, -- {"invalid PDU mode parameter", 221}, -- {"invalid text mode parameter", 222}, -- {"PH-SIM PIN required", 223}, -- {"invalid memory index", 224}, -- {"SMSC address unknown", 225}, -- {"no +CNMA acknowledgement expected", 226}, -- {"unknown error", 227}, -- {"invalid SMS error %d", 228}, -- {"Short message received by the SME", 229}, -- {"\ --Short message forwarded by the SC to the SME but the SC is unable to confirm \ --delivery", 230}, -- {"Short message replaced by the SC", 231}, -- {"reserved", 232}, -- {"SME busy", 233}, -- {"No response from SME", 234}, -- {"Service rejected", 235}, -- {"Quality of service not available", 236}, -- {"Error in SME", 237}, -- {" (Temporary error, SC is not making any more transfer attempts)", 238}, -- {" (Temporary error, SC still trying to transfer SM)", 239}, -- {"Remote Procedure Error", 240}, -- {"Incompatible destination", 241}, -- {"Connection rejected by SME", 242}, -- {"Not obtainable", 243}, -- {"No interworking available", 244}, -- {"SM validity period expired", 245}, -- {"SM deleted by originating SME", 246}, -- {"SM deleted by SC administration", 247}, -- {"SM does not exit", 248}, -- {" (Permanent Error, SC is not making any more transfer attempts)", 249}, -- {"unexpected number format %d", 250}, -- {"unexpected unsolicited event '%s'", 251}, -- {"unable to set operator", 252}, -- {"call forward time must be in the range 0..30", 253}, -- {"Functionality Level commands not supported by ME", 254}, -- {"Requested Functionality Level out of range", 255}, -- {"unsupported alphabet for SMS", 256}, -- {"SMS text is larger than allowed", 257}, -- {"not more than 255 concatenated SMSs allowed", 258}, -- {"only serviceLevel 0 or 1 supported", 259}, -- {"cannot route SMS messages to TE", 260}, -- {"cannot route cell broadcast messages to TE", 261}, -- {"cannot route status reports messages to TE", 262}, -- {"cannot route status report messages to TE", 263}, -- {"expected parameter", 264}, -- {"expected '\"'", 265}, -- {"expected number", 266}, -- {"unexpected end of string '%s'", 267}, -- {" (at position %d of string '%s')", 268}, -- {"expected '%c'", 269}, -- {"expected ')' or ','", 270}, -- {"expected ')', ',' or '-'", 271}, -- {"range of the form a-b-c not allowed", 272}, -- {"range of the form a- no allowed", 273}, -- {"expected comma", 274}, -- {"expected end of line", 275}, -- {"\ --length of text '%s' exceeds maximum text length (%d characters) of phonebook \ --'%s'", 276}, -- {"\ --length of telephone number '%s' exceeds maximum telephone number length (%d \ --characters) of phonebook '%s'", 277}, -- {"phonebook full", 278}, -- {"attempt to overwrite phonebook entry", 279}, -- {"SIM card changed while accessing phonebook", 280}, -- {"unhandled SMS TPDU type", 281}, -- {"can only send SMS-SUBMIT and SMS-COMMAND TPDUs", 282}, -- {"no device given for sending SMS", 283}, -- {"Message type: SMS-DELIVER", 284}, -- {"SC address: '", 285}, -- {"More messages to send: ", 286}, -- {"Reply path: ", 287}, -- {"User data header indicator: ", 288}, -- {"Status report indication: ", 289}, -- {"Originating address: '", 290}, -- {"Protocol identifier: 0x", 291}, -- {"Data coding scheme: ", 292}, -- {"SC timestamp: ", 293}, -- {"User data length: ", 294}, -- {"User data header: 0x", 295}, -- {"User data: '", 296}, -- {"Message type: SMS-SUBMIT", 297}, -- {"Reject duplicates: ", 298}, -- {"Validity period format: ", 299}, -- {"not present", 300}, -- {"relative", 301}, -- {"absolute", 302}, -- {"Status report request: ", 303}, -- {"Message reference: ", 304}, -- {"Destination address: '", 305}, -- {"Validity period: ", 306}, -- {"Message type: SMS-STATUS-REPORT", 307}, -- {"Status report qualifier: ", 308}, -- {"Recipient address: '", 309}, -- {"Discharge time: ", 310}, -- {"Status: 0x", 311}, -- {"Message type: SMS-COMMAND", 312}, -- {"Command type: 0x", 313}, -- {"Message number: ", 314}, -- {"Command data length: ", 315}, -- {"Command data: '", 316}, -- {"Message type: SMS-DELIVER-REPORT", 317}, -- {"Protocol identifier present: ", 318}, -- {"Data coding scheme present: ", 319}, -- {"User data length present: ", 320}, -- {"Message type: SMS-SUBMIT-REPORT", 321}, -- {" minutes", 322}, -- {" days", 323}, -- {" weeks", 324}, -- {"compressed ", 325}, -- {"voicemail message waiting", 326}, -- {"fax message waiting", 327}, -- {"electronic mail message waiting", 328}, -- {"other message waiting", 329}, -- {"default alphabet", 330}, -- {"8-bit alphabet", 331}, -- {"16-bit alphabet", 332}, -- {"reserved alphabet", 333}, -- {"bad hexadecimal PDU format", 334}, -- {"premature end of PDU", 335}, -- {"unknown time period format", 336}, -- {"interrupted when reading from TA", 337}, -- {"reading from TA", 338}, -- {"timeout when reading from TA", 339}, -- {"opening device '%s'", 340}, -- {"getting file status flags failed", 341}, -- {"switching of non-blocking mode failed", 342}, -- {"clearing DTR failed", 343}, -- {"setting DTR failed", 344}, -- {"tcgetattr device '%s'", 345}, -- {"tcsetattr device '%s'", 346}, -- {"reset modem failed '%s'", 347}, -- {"interrupted when writing to TA", 348}, -- {"writing to TA", 349}, -- {"timeout when writing to TA", 350}, -- {"unknown baudrate '%s'", 351}, -- {"error when calling stat('%s') (errno: %d/%s)", 352}, -- {"file '%s' is neither file nor character device", 353}, -- {"maxmimum number of symbolic links exceeded", 354}, -- {"error renaming '%s' to '%s'", 355}, -- {"text '%s' contains illegal character '\"'", 356}, -- {"illegal character in telephone number '%s'", 357}, -- {"error reading from file '%s", 358}, -- {"entry '%s' lacks index", 359}, -- {"line '%s' has invalid format", 360}, -- {"error opening file '%s' for writing", 361}, -- {"", 362}, -- {"error writing to file '%s'", 363}, -- {"attempt to change phonebook read from ", 364}, -- {"cannot open file '%s'", 365}, -- {"", 366}, -- {"indices must be unique in phonebook", 367}, -- {"error reading from file '%s'", 368}, -- {"file '%s' has wrong version", 369}, -- {"corrupt SMS store file '%s'", 370}, -- {"attempt to change SMS store read from ", 371}, --}; -- --int _msg_tbl_length = 371; ---- gsmlib-1.10.orig/po/de.po -+++ gsmlib-1.10/po/de.po -@@ -233,7 +233,7 @@ - - #: apps/gsmsendsms.cc:171 - msgid " phonenumber recipient's phone number" --msgstr " Telefonummer die Telefonnumer des Empfängers" -+msgstr " Telefonummer die Telefonnummer des Empfängers" - - #: apps/gsmsendsms.cc:172 - msgid "" -@@ -295,7 +295,7 @@ - - #: apps/gsmpb.cc:325 - msgid " -c, --copy copy source entries to destination" --msgstr " -c, --copy kopiere Quell-Enträge zum Zielgerät/-datei" -+msgstr " -c, --copy kopiere Quell-Einträge zum Zielgerät/-datei" - - #: apps/gsmpb.cc:327 - msgid "" -@@ -626,14 +626,14 @@ - msgstr "" - ": [-a][-b Baud-Rate][-c][-C sca][-d Gerät oder Datei]\n" - " [-h][-I Init String][-k][-l][-s Gerät oder Datei][-t SMS Speichername]\n" --" [-v][-V][-x][-X]{Indices}|[Telefonnumer Text]" -+" [-v][-V][-x][-X]{Indices}|[Telefonnummer Text]" - - #: apps/gsmsmsstore.cc:191 - msgid "" - " -a, --add add new SMS submit message\n" - " (phonenumber and text) to destination" - msgstr "" --" -a, --add füge neue SMS-Submit-Nachricht (Telefonnumer und\n" -+" -a, --add füge neue SMS-Submit-Nachricht (Telefonnummer und\n" - " Text) in das Zielgerät/-datei ein" - - #: apps/gsmsmsstore.cc:197 -@@ -1437,7 +1437,7 @@ - - #: gsmlib/gsm_sms.cc:450 gsmlib/gsm_sms.cc:626 - msgid "Destination address: '" --msgstr "Zieladdresse: '" -+msgstr "Zieladresse: '" - - #: gsmlib/gsm_sms.cc:455 - msgid "Validity period: " ---- gsmlib-1.10.orig/po/gsmlib.pot -+++ gsmlib-1.10/po/gsmlib.pot -@@ -7,7 +7,8 @@ - msgid "" - msgstr "" - "Project-Id-Version: PACKAGE VERSION\n" --"POT-Creation-Date: 2002-10-22 22:48+0200\n" -+"Report-Msgid-Bugs-To: \n" -+"POT-Creation-Date: 2008-10-06 14:36+1100\n" - "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" - "Last-Translator: FULL NAME \n" - "Language-Team: LANGUAGE \n" -@@ -15,168 +16,225 @@ - "Content-Type: text/plain; charset=CHARSET\n" - "Content-Transfer-Encoding: 8bit\n" - --#: apps/gsmsmsd.cc:164 -+#: apps/gsmsmsd.cc:172 - #, c-format - msgid "could not execute '%s'" - msgstr "" - --#: apps/gsmsmsd.cc:168 -+#: apps/gsmsmsd.cc:176 - #, c-format - msgid "error writing to '%s'" - msgstr "" - --#: apps/gsmsmsd.cc:196 -+#: apps/gsmsmsd.cc:197 apps/gsmsmsd.cc:198 apps/gsmsmsd.cc:199 -+#, c-format -+msgid "%d" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:216 - #, c-format - msgid "error when calling opendir('%s')(errno: %d/%s)" - msgstr "" - --#: apps/gsmsmsd.cc:225 -+#: apps/gsmsmsd.cc:260 - #, c-format - msgid "count not open SMS spool file %s" - msgstr "" - --#: apps/gsmsmsd.cc:341 apps/gsmsendsms.cc:144 apps/gsmpb.cc:311 -+#: apps/gsmsmsd.cc:439 apps/gsmsendsms.cc:144 apps/gsmpb.cc:311 - #: apps/gsmctl.cc:380 apps/gsmsmsstore.cc:179 - #, c-format - msgid ": version %s [compiled %s]" - msgstr "" - --#: apps/gsmsmsd.cc:346 -+#: apps/gsmsmsd.cc:444 - msgid "" - ": [-a action][-b baudrate][-C sca][-d device][-f][-h][-I init string]\n" - " [-s spool dir][-t][-v]{sms_type}" - msgstr "" - --#: apps/gsmsmsd.cc:350 -+#: apps/gsmsmsd.cc:448 - msgid "" - " -a, --action the action to execute when an SMS arrives\n" - " (SMS is send to stdin of action)" - msgstr "" - --#: apps/gsmsmsd.cc:354 apps/gsmsendsms.cc:153 apps/gsmpb.cc:322 -+#: apps/gsmsmsd.cc:452 apps/gsmsendsms.cc:153 apps/gsmpb.cc:322 - #: apps/gsmctl.cc:389 apps/gsmsmsstore.cc:194 - msgid " -b, --baudrate baudrate to use for device (default: 38400)" - msgstr "" - --#: apps/gsmsmsd.cc:357 -+#: apps/gsmsmsd.cc:455 - msgid " -c, --concatenate start ID for concatenated SMS messages" - msgstr "" - --#: apps/gsmsmsd.cc:359 apps/gsmsendsms.cc:158 apps/gsmsmsstore.cc:200 -+#: apps/gsmsmsd.cc:457 apps/gsmsendsms.cc:158 apps/gsmsmsstore.cc:200 - msgid " -C, --sca SMS service centre address" - msgstr "" - --#: apps/gsmsmsd.cc:360 -+#: apps/gsmsmsd.cc:458 - msgid " -d, --device sets the device to connect to" - msgstr "" - --#: apps/gsmsmsd.cc:361 -+#: apps/gsmsmsd.cc:459 - msgid " -D, --direct enable direct routing of SMSs" - msgstr "" - --#: apps/gsmsmsd.cc:362 -+#: apps/gsmsmsd.cc:460 - msgid " -f, --flush flush SMS from store" - msgstr "" - --#: apps/gsmsmsd.cc:363 apps/gsmsendsms.cc:161 apps/gsmpb.cc:332 -+#: apps/gsmsmsd.cc:461 -+msgid " -F, --failed directory to move failed SMS to," -+msgstr "" -+ -+#: apps/gsmsmsd.cc:462 apps/gsmsmsd.cc:475 -+msgid " if unset, the SMS will be deleted" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:463 apps/gsmsendsms.cc:161 apps/gsmpb.cc:332 - #: apps/gsmctl.cc:394 apps/gsmsmsstore.cc:204 - msgid " -h, --help prints this message" - msgstr "" - --#: apps/gsmsmsd.cc:364 apps/gsmsendsms.cc:162 apps/gsmpb.cc:335 -+#: apps/gsmsmsd.cc:464 apps/gsmsendsms.cc:162 apps/gsmpb.cc:335 - #: apps/gsmctl.cc:395 apps/gsmsmsstore.cc:205 - msgid " -I, --init device AT init sequence" - msgstr "" - --#: apps/gsmsmsd.cc:365 apps/gsmsendsms.cc:163 -+#: apps/gsmsmsd.cc:466 -+msgid " -L, --syslog log errors and information to syslog" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:469 -+msgid " -P, --priorities number of priority levels to use," -+msgstr "" -+ -+#: apps/gsmsmsd.cc:470 -+msgid " (default: none)" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:471 apps/gsmsendsms.cc:163 - msgid " -r, --requeststat request SMS status report" - msgstr "" - --#: apps/gsmsmsd.cc:366 -+#: apps/gsmsmsd.cc:472 - msgid " -s, --spool spool directory for outgoing SMS" - msgstr "" - --#: apps/gsmsmsd.cc:368 -+#: apps/gsmsmsd.cc:474 -+msgid " -S, --sent directory to move sent SMS to," -+msgstr "" -+ -+#: apps/gsmsmsd.cc:476 - msgid "" - " -t, --store name of SMS store to use for flush\n" - " and/or temporary SMS storage" - msgstr "" - --#: apps/gsmsmsd.cc:371 apps/gsmsendsms.cc:167 apps/gsmpb.cc:343 -+#: apps/gsmsmsd.cc:479 apps/gsmsendsms.cc:167 apps/gsmpb.cc:343 - #: apps/gsmctl.cc:399 apps/gsmsmsstore.cc:213 - msgid " -v, --version prints version and exits" - msgstr "" - --#: apps/gsmsmsd.cc:372 apps/gsmsendsms.cc:169 apps/gsmpb.cc:346 -+#: apps/gsmsmsd.cc:480 apps/gsmsendsms.cc:169 apps/gsmpb.cc:346 - #: apps/gsmctl.cc:400 apps/gsmsmsstore.cc:218 - msgid " -X, --xonxoff switch on software handshake" - msgstr "" - --#: apps/gsmsmsd.cc:374 -+#: apps/gsmsmsd.cc:482 - msgid " sms_type may be any combination of" - msgstr "" - --#: apps/gsmsmsd.cc:375 -+#: apps/gsmsmsd.cc:483 - msgid " sms, no_sms controls reception of normal SMS" - msgstr "" - --#: apps/gsmsmsd.cc:377 -+#: apps/gsmsmsd.cc:485 - msgid " cb, no_cb controls reception of cell broadcast messages" - msgstr "" - --#: apps/gsmsmsd.cc:379 -+#: apps/gsmsmsd.cc:487 - msgid " stat, no_stat controls reception of status reports" - msgstr "" - --#: apps/gsmsmsd.cc:381 -+#: apps/gsmsmsd.cc:489 - msgid " default is \"sms cb stat\"" - msgstr "" - --#: apps/gsmsmsd.cc:382 -+#: apps/gsmsmsd.cc:490 - msgid "If no action is given, the SMS is printed to stdout" - msgstr "" - --#: apps/gsmsmsd.cc:387 apps/gsmsendsms.cc:178 apps/gsmpb.cc:354 -+#: apps/gsmsmsd.cc:492 -+msgid "If -P is given, it activates the priority system and sets the" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:493 -+msgid "number or levels to use. For every level, there must be directories" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:494 -+msgid "named +." -+msgstr "" -+ -+#: apps/gsmsmsd.cc:495 -+msgid "For example \"-P 2 -s queue -S send -F failed\" needs the following" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:496 -+msgid "directories: queue1/ queue2/ send1/ send2/ failed1/ failed2/" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:497 -+msgid "Before sending one SMS from queue2, all pending SMS from queue1" -+msgstr "" -+ -+#: apps/gsmsmsd.cc:498 -+msgid "will be sent." -+msgstr "" -+ -+#: apps/gsmsmsd.cc:503 apps/gsmsendsms.cc:178 apps/gsmpb.cc:354 - #: apps/gsmctl.cc:414 apps/gsmsmsstore.cc:223 - msgid "unknown option" - msgstr "" - --#: apps/gsmsmsd.cc:426 -+#: apps/gsmsmsd.cc:542 - #, c-format - msgid "error when calling sigaction() (errno: %d/%s)" - msgstr "" - --#: apps/gsmsmsd.cc:446 -+#: apps/gsmsmsd.cc:562 - msgid "store name must be given for flush option" - msgstr "" - - #. process the new message --#: apps/gsmsmsd.cc:454 apps/gsmsmsd.cc:522 -+#: apps/gsmsmsd.cc:570 apps/gsmsmsd.cc:638 - msgid "Type of message: " - msgstr "" - --#: apps/gsmsmsd.cc:458 apps/gsmsmsd.cc:526 -+#: apps/gsmsmsd.cc:574 apps/gsmsmsd.cc:642 - msgid "SMS message\n" - msgstr "" - --#: apps/gsmsmsd.cc:461 -+#: apps/gsmsmsd.cc:577 - msgid "submit report message\n" - msgstr "" - --#: apps/gsmsmsd.cc:464 apps/gsmsmsd.cc:532 -+#: apps/gsmsmsd.cc:580 apps/gsmsmsd.cc:648 - msgid "status report message\n" - msgstr "" - --#: apps/gsmsmsd.cc:529 -+#: apps/gsmsmsd.cc:645 - msgid "cell broadcast message\n" - msgstr "" - --#: apps/gsmsmsd.cc:585 apps/gsmsmsd.cc:587 apps/gsmsendsms.cc:253 --#: apps/gsmpb.cc:503 apps/gsmctl.cc:631 apps/gsmsmsstore.cc:435 -+#: apps/gsmsmsd.cc:701 apps/gsmsmsd.cc:703 apps/gsmsendsms.cc:253 -+#: apps/gsmpb.cc:503 apps/gsmctl.cc:631 apps/gsmsmsstore.cc:430 - msgid "[ERROR]: " - msgstr "" - --#: apps/gsmsmsd.cc:588 -+#: apps/gsmsmsd.cc:704 - msgid "(try setting sms_type, please refer to gsmsmsd manpage)" - msgstr "" - -@@ -372,7 +430,7 @@ - msgstr "" - - #: apps/gsmctl.cc:131 gsmlib/gsm_error.cc:104 gsmlib/gsm_sms.cc:441 --#: gsmlib/gsm_sms_codec.cc:204 -+#: gsmlib/gsm_sms_codec.cc:205 - msgid "unknown" - msgstr "" - -@@ -541,7 +599,7 @@ - msgid "unknown operation '%s'" - msgstr "" - --#: apps/gsmsmsstore.cc:91 apps/gsmsmsstore.cc:363 apps/gsmsmsstore.cc:380 -+#: apps/gsmsmsstore.cc:91 apps/gsmsmsstore.cc:358 apps/gsmsmsstore.cc:375 - #, c-format - msgid "inserting entry #%d from source into destination" - msgstr "" -@@ -618,7 +676,7 @@ - msgid "destination required" - msgstr "" - --#: apps/gsmsmsstore.cc:254 gsmlib/gsm_util.cc:285 -+#: apps/gsmsmsstore.cc:254 gsmlib/gsm_util.cc:286 - #, c-format - msgid "expected number, got '%s'" - msgstr "" -@@ -631,30 +689,30 @@ - msgid "unexpected parameters" - msgstr "" - --#: apps/gsmsmsstore.cc:280 apps/gsmsmsstore.cc:317 -+#: apps/gsmsmsstore.cc:280 apps/gsmsmsstore.cc:312 - msgid "store name must be given" - msgstr "" - --#: apps/gsmsmsstore.cc:344 apps/gsmsmsstore.cc:377 -+#: apps/gsmsmsstore.cc:339 apps/gsmsmsstore.cc:372 - #, c-format - msgid "no index '%s' in source" - msgstr "" - --#: apps/gsmsmsstore.cc:392 -+#: apps/gsmsmsstore.cc:387 - #, c-format - msgid "index #%d" - msgstr "" - --#: apps/gsmsmsstore.cc:406 -+#: apps/gsmsmsstore.cc:401 - msgid "inserting new entry into destination" - msgstr "" - --#: apps/gsmsmsstore.cc:421 -+#: apps/gsmsmsstore.cc:416 - #, c-format - msgid "deleting entry #%d from destination" - msgstr "" - --#: apps/gsmsmsstore.cc:426 -+#: apps/gsmsmsstore.cc:421 - #, c-format - msgid "no index '%s' in destination" - msgstr "" -@@ -1107,52 +1165,52 @@ - msgid "unexpected unsolicited event '%s'" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:536 -+#: gsmlib/gsm_me_ta.cc:538 - msgid "unable to set operator" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:663 -+#: gsmlib/gsm_me_ta.cc:665 - msgid "call forward time must be in the range 0..30" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:811 -+#: gsmlib/gsm_me_ta.cc:813 - msgid "Functionality Level commands not supported by ME" - msgstr "" - - #. If the number was just out of range, we get here. --#: gsmlib/gsm_me_ta.cc:830 -+#: gsmlib/gsm_me_ta.cc:832 - msgid "Requested Functionality Level out of range" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:941 -+#: gsmlib/gsm_me_ta.cc:943 - msgid "unsupported alphabet for SMS" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:950 -+#: gsmlib/gsm_me_ta.cc:952 - msgid "SMS text is larger than allowed" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:962 -+#: gsmlib/gsm_me_ta.cc:964 - msgid "not more than 255 concatenated SMSs allowed" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:995 -+#: gsmlib/gsm_me_ta.cc:997 - msgid "only serviceLevel 0 or 1 supported" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:1108 gsmlib/gsm_me_ta.cc:1150 -+#: gsmlib/gsm_me_ta.cc:1110 gsmlib/gsm_me_ta.cc:1152 - msgid "cannot route SMS messages to TE" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:1122 gsmlib/gsm_me_ta.cc:1164 -+#: gsmlib/gsm_me_ta.cc:1124 gsmlib/gsm_me_ta.cc:1166 - msgid "cannot route cell broadcast messages to TE" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:1134 -+#: gsmlib/gsm_me_ta.cc:1136 - msgid "cannot route status reports messages to TE" - msgstr "" - --#: gsmlib/gsm_me_ta.cc:1178 -+#: gsmlib/gsm_me_ta.cc:1180 - msgid "cannot route status report messages to TE" - msgstr "" - -@@ -1314,7 +1372,7 @@ - msgid "Validity period format: " - msgstr "" - --#: gsmlib/gsm_sms.cc:432 gsmlib/gsm_sms_codec.cc:183 -+#: gsmlib/gsm_sms.cc:432 gsmlib/gsm_sms_codec.cc:184 - msgid "not present" - msgstr "" - -@@ -1402,209 +1460,212 @@ - msgid "Message type: SMS-SUBMIT-REPORT" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:188 gsmlib/gsm_sms_codec.cc:190 -+#: gsmlib/gsm_sms_codec.cc:189 gsmlib/gsm_sms_codec.cc:191 - msgid " minutes" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:192 -+#: gsmlib/gsm_sms_codec.cc:193 - msgid " days" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:194 -+#: gsmlib/gsm_sms_codec.cc:195 - msgid " weeks" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:213 -+#: gsmlib/gsm_sms_codec.cc:214 - msgid "compressed " - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:218 -+#: gsmlib/gsm_sms_codec.cc:219 - msgid "voicemail message waiting" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:221 -+#: gsmlib/gsm_sms_codec.cc:222 - msgid "fax message waiting" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:224 -+#: gsmlib/gsm_sms_codec.cc:225 - msgid "electronic mail message waiting" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:227 -+#: gsmlib/gsm_sms_codec.cc:228 - msgid "other message waiting" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:234 -+#: gsmlib/gsm_sms_codec.cc:235 - msgid "default alphabet" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:237 -+#: gsmlib/gsm_sms_codec.cc:238 - msgid "8-bit alphabet" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:240 -+#: gsmlib/gsm_sms_codec.cc:241 - msgid "16-bit alphabet" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:243 -+#: gsmlib/gsm_sms_codec.cc:244 - msgid "reserved alphabet" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:256 -+#: gsmlib/gsm_sms_codec.cc:257 - msgid "bad hexadecimal PDU format" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:285 gsmlib/gsm_sms_codec.cc:295 --#: gsmlib/gsm_sms_codec.cc:310 gsmlib/gsm_sms_codec.cc:318 --#: gsmlib/gsm_sms_codec.cc:339 gsmlib/gsm_sms_codec.cc:347 --#: gsmlib/gsm_sms_codec.cc:368 gsmlib/gsm_sms_codec.cc:382 -+#: gsmlib/gsm_sms_codec.cc:286 gsmlib/gsm_sms_codec.cc:296 -+#: gsmlib/gsm_sms_codec.cc:311 gsmlib/gsm_sms_codec.cc:319 -+#: gsmlib/gsm_sms_codec.cc:340 gsmlib/gsm_sms_codec.cc:348 -+#: gsmlib/gsm_sms_codec.cc:369 gsmlib/gsm_sms_codec.cc:383 - msgid "premature end of PDU" - msgstr "" - --#: gsmlib/gsm_sms_codec.cc:473 -+#: gsmlib/gsm_sms_codec.cc:474 - msgid "unknown time period format" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:119 -+#: gsmlib/gsm_unix_serial.cc:121 - msgid "interrupted when reading from TA" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:144 -+#: gsmlib/gsm_unix_serial.cc:136 -+msgid "end of file when reading from TA" -+msgstr "" -+ -+#: gsmlib/gsm_unix_serial.cc:146 - msgid "reading from TA" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:149 -+#: gsmlib/gsm_unix_serial.cc:151 - msgid "timeout when reading from TA" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:176 -+#: gsmlib/gsm_unix_serial.cc:178 - #, c-format - msgid "opening device '%s'" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:182 -+#: gsmlib/gsm_unix_serial.cc:185 - msgid "getting file status flags failed" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:185 -+#: gsmlib/gsm_unix_serial.cc:190 - msgid "switching of non-blocking mode failed" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:198 -+#: gsmlib/gsm_unix_serial.cc:205 - msgid "clearing DTR failed" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:202 -+#: gsmlib/gsm_unix_serial.cc:211 - msgid "setting DTR failed" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:206 -+#: gsmlib/gsm_unix_serial.cc:216 - #, c-format - msgid "tcgetattr device '%s'" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:233 -+#: gsmlib/gsm_unix_serial.cc:245 - #, c-format - msgid "tcsetattr device '%s'" - msgstr "" - --#. no response after 3 tries --#: gsmlib/gsm_unix_serial.cc:287 -+#: gsmlib/gsm_unix_serial.cc:303 - #, c-format - msgid "reset modem failed '%s'" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:332 gsmlib/gsm_unix_serial.cc:364 -+#: gsmlib/gsm_unix_serial.cc:348 gsmlib/gsm_unix_serial.cc:380 - msgid "interrupted when writing to TA" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:347 gsmlib/gsm_unix_serial.cc:356 -+#: gsmlib/gsm_unix_serial.cc:363 gsmlib/gsm_unix_serial.cc:372 - msgid "writing to TA" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:377 -+#: gsmlib/gsm_unix_serial.cc:393 - msgid "timeout when writing to TA" - msgstr "" - --#: gsmlib/gsm_unix_serial.cc:438 -+#: gsmlib/gsm_unix_serial.cc:454 - #, c-format - msgid "unknown baudrate '%s'" - msgstr "" - --#: gsmlib/gsm_util.cc:205 -+#: gsmlib/gsm_util.cc:206 - #, c-format - msgid "error when calling stat('%s') (errno: %d/%s)" - msgstr "" - --#: gsmlib/gsm_util.cc:236 -+#: gsmlib/gsm_util.cc:237 - #, c-format - msgid "file '%s' is neither file nor character device" - msgstr "" - --#: gsmlib/gsm_util.cc:240 -+#: gsmlib/gsm_util.cc:241 - msgid "maxmimum number of symbolic links exceeded" - msgstr "" - --#: gsmlib/gsm_util.cc:250 -+#: gsmlib/gsm_util.cc:251 - #, c-format - msgid "error renaming '%s' to '%s'" - msgstr "" - --#: gsmlib/gsm_util.cc:348 -+#: gsmlib/gsm_util.cc:349 - #, c-format - msgid "text '%s' contains illegal character '\"'" - msgstr "" - --#: gsmlib/gsm_util.cc:358 -+#: gsmlib/gsm_util.cc:359 - #, c-format - msgid "illegal character in telephone number '%s'" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:95 -+#: gsmlib/gsm_sorted_phonebook.cc:96 - #, c-format - msgid "error reading from file '%s" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:109 -+#: gsmlib/gsm_sorted_phonebook.cc:110 - #, c-format - msgid "entry '%s' lacks index" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:118 gsmlib/gsm_sorted_phonebook.cc:124 -+#: gsmlib/gsm_sorted_phonebook.cc:119 gsmlib/gsm_sorted_phonebook.cc:125 - #, c-format - msgid "line '%s' has invalid format" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:173 gsmlib/gsm_sorted_sms_store.cc:159 -+#: gsmlib/gsm_sorted_phonebook.cc:174 gsmlib/gsm_sorted_sms_store.cc:159 - #, c-format - msgid "error opening file '%s' for writing" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:174 gsmlib/gsm_sorted_phonebook.cc:193 -+#: gsmlib/gsm_sorted_phonebook.cc:175 gsmlib/gsm_sorted_phonebook.cc:194 - #: gsmlib/gsm_sorted_sms_store.cc:67 gsmlib/gsm_sorted_sms_store.cc:160 - msgid "" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:192 gsmlib/gsm_sorted_sms_store.cc:66 -+#: gsmlib/gsm_sorted_phonebook.cc:193 gsmlib/gsm_sorted_sms_store.cc:66 - #, c-format - msgid "error writing to file '%s'" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:216 -+#: gsmlib/gsm_sorted_phonebook.cc:217 - msgid "attempt to change phonebook read from " - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:229 gsmlib/gsm_sorted_sms_store.cc:215 -+#: gsmlib/gsm_sorted_phonebook.cc:230 gsmlib/gsm_sorted_sms_store.cc:215 - #, c-format - msgid "cannot open file '%s'" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:244 gsmlib/gsm_sorted_sms_store.cc:55 -+#: gsmlib/gsm_sorted_phonebook.cc:245 gsmlib/gsm_sorted_sms_store.cc:55 - #: gsmlib/gsm_sorted_sms_store.cc:228 - msgid "" - msgstr "" - --#: gsmlib/gsm_sorted_phonebook.cc:361 -+#: gsmlib/gsm_sorted_phonebook.cc:362 - msgid "indices must be unique in phonebook" - msgstr "" - ---- gsmlib-1.10.orig/gsmlib-1.10.debmg/debian/gsm-utils.dirs -+++ gsmlib-1.10/gsmlib-1.10.debmg/debian/gsm-utils.dirs -@@ -0,0 +1,11 @@ -+var/spool/sms/queue1 -+var/spool/sms/queue2 -+var/spool/sms/queue3 -+var/spool/sms/sent1 -+var/spool/sms/sent2 -+var/spool/sms/sent3 -+var/spool/sms/failed1 -+var/spool/sms/failed2 -+var/spool/sms/failed3 -+var/spool/sms/tmp -+var/run/gsm-utils ---- gsmlib-1.10.orig/gsmlib-1.10.debmg/debian/gsm-utils.postinst -+++ gsmlib-1.10/gsmlib-1.10.debmg/debian/gsm-utils.postinst -@@ -0,0 +1,28 @@ -+#!/bin/sh -e -+ -+# create gsmsms group if necessary. -+if ! grep -q ^gsmsms: /etc/group; then -+# echo Adding system group: gsmsms. -+ addgroup gsmsms -+fi -+ -+# create gsmsms user if necessary. -+if ! grep -q ^gsmsms: /etc/passwd; then -+# echo Adding system user: gsmsms. -+ adduser --system --ingroup gsmsms \ -+ --no-create-home --home /var/spool/sms gsmsms -+fi -+ -+# allow gsmsms to use serial lines -+if ! groups gsmsms | grep -q dialout ; then -+ adduser gsmsms dialout -+fi -+ -+# echo Updating spool directory structure: /var/spool/sms -+chown -R gsmsms:gsmsms /var/spool/sms /var/run/gsm-utils -+chmod 700 /var/spool/sms/* -+chmod 750 /var/spool/sms -+chmod 730 /var/spool/sms/queue* /var/spool/sms/tmp -+ -+# Add the rest automatically.. -+#DEBHELPER# ---- gsmlib-1.10.orig/gsmlib-1.10.debmg/debian/gsm-utils.undocumented -+++ gsmlib-1.10/gsmlib-1.10.debmg/debian/gsm-utils.undocumented -@@ -0,0 +1,2 @@ -+gsmsmsspool.1 -+gsmsmsrequeue.8 ---- gsmlib-1.10.orig/gsmlib-1.10.debmg/debian/gsm-utils.prerm -+++ gsmlib-1.10/gsmlib-1.10.debmg/debian/gsm-utils.prerm -@@ -0,0 +1,7 @@ -+#!/bin/sh -e -+ -+deluser gsmsms || true -+delgroup gsmsms || true -+ -+# Add the rest automatically.. -+#DEBHELPER# ---- gsmlib-1.10.orig/scripts/config.sub -+++ gsmlib-1.10/scripts/config.sub -@@ -1,9 +1,10 @@ - #! /bin/sh - # Configuration validation subroutine script. --# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 - # Free Software Foundation, Inc. - --timestamp='2001-09-07' -+timestamp='2008-01-16' - - # This file is (in principle) common to ALL GNU software. - # The presence of a machine in this file suggests that SOME GNU software -@@ -21,15 +22,17 @@ - # - # 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. -- -+# 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. - --# Please send patches to . -+ -+# Please send patches to . Submit a context -+# diff and a properly formatted ChangeLog entry. - # - # Configuration subroutine to validate and canonicalize a configuration type. - # Supply the specified configuration type as an argument. -@@ -69,8 +72,8 @@ - version="\ - GNU config.sub ($timestamp) - --Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 --Free Software Foundation, Inc. -+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -@@ -82,11 +85,11 @@ - while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) -- echo "$timestamp" ; exit 0 ;; -+ echo "$timestamp" ; exit ;; - --version | -v ) -- echo "$version" ; exit 0 ;; -+ echo "$version" ; exit ;; - --help | --h* | -h ) -- echo "$usage"; exit 0 ;; -+ echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. -@@ -98,7 +101,7 @@ - *local*) - # First pass through any local machine types. - echo $1 -- exit 0;; -+ exit ;; - - * ) - break ;; -@@ -117,7 +120,9 @@ - # Here we must recognize all the valid KERNEL-OS combinations. - maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` - case $maybe_os in -- nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) -+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ -+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ -+ storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; -@@ -143,7 +148,7 @@ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -- -apple | -axis) -+ -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; -@@ -168,6 +173,10 @@ - -hiux*) - os=-hiuxwe2 - ;; -+ -sco6) -+ os=-sco5v6 -+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -+ ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -@@ -184,6 +193,10 @@ - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; -+ -sco5v6*) -+ # Don't forget version if it is 3.2v4 or newer. -+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -+ ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -@@ -226,32 +239,53 @@ - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ -- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ -+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ -+ | am33_2.0 \ -+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ -+ | bfin \ - | c4x | clipper \ -- | d10v | d30v | dsp16xx \ -- | fr30 \ -+ | d10v | d30v | dlx | dsp16xx \ -+ | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ -- | m32r | m68000 | m68k | m88k | mcore \ -- | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ -- | mips64vr4100 | mips64vr4100el | mips64vr4300 \ -- | mips64vr4300el | mips64vr5000 | mips64vr5000el \ -- | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ -- | mipsisa32 \ -+ | ip2k | iq2000 \ -+ | m32c | m32r | m32rle | m68000 | m68k | m88k \ -+ | maxq | mb | microblaze | mcore | mep \ -+ | mips | mipsbe | mipseb | mipsel | mipsle \ -+ | mips16 \ -+ | mips64 | mips64el \ -+ | mips64vr | mips64vrel \ -+ | mips64orion | mips64orionel \ -+ | mips64vr4100 | mips64vr4100el \ -+ | mips64vr4300 | mips64vr4300el \ -+ | mips64vr5000 | mips64vr5000el \ -+ | mips64vr5900 | mips64vr5900el \ -+ | mipsisa32 | mipsisa32el \ -+ | mipsisa32r2 | mipsisa32r2el \ -+ | mipsisa64 | mipsisa64el \ -+ | mipsisa64r2 | mipsisa64r2el \ -+ | mipsisa64sb1 | mipsisa64sb1el \ -+ | mipsisa64sr71k | mipsisa64sr71kel \ -+ | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ -+ | mt \ -+ | msp430 \ -+ | nios | nios2 \ - | ns16k | ns32k \ -- | openrisc \ -+ | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ -- | s390 | s390x \ -- | sh | sh[34] | sh[34]eb | shbe | shle \ -- | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ -- | stormy16 | strongarm \ -- | tahoe | thumb | tic80 | tron \ -- | v850 \ -+ | score \ -+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ -+ | sh64 | sh64le \ -+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ -+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ -+ | spu | strongarm \ -+ | tahoe | thumb | tic4x | tic80 | tron \ -+ | v850 | v850e \ - | we32k \ -- | x86 | xscale \ -+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; -@@ -262,6 +296,9 @@ - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; -+ ms1) -+ basic_machine=mt-unknown -+ ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and -@@ -278,41 +315,68 @@ - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ -- | alphapca5[67]-* | arc-* \ -- | arm-* | armbe-* | armle-* | armv*-* \ -- | bs2000-* \ -- | c[123]* | c30-* | [cjt]90-* | c54x-* \ -- | clipper-* | cray2-* | cydra-* \ -- | d10v-* | d30v-* \ -+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ -+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ -+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ -+ | avr-* | avr32-* \ -+ | bfin-* | bs2000-* \ -+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ -+ | clipper-* | craynv-* | cydra-* \ -+ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ -- | f30[01]-* | f700-* | fr30-* | fx80-* \ -+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ -- | m32r-* \ -- | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ -- | m88110-* | m88k-* | mcore-* \ -- | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ -- | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ -- | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ -- | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ -+ | ip2k-* | iq2000-* \ -+ | m32c-* | m32r-* | m32rle-* \ -+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ -+ | m88110-* | m88k-* | maxq-* | mcore-* \ -+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ -+ | mips16-* \ -+ | mips64-* | mips64el-* \ -+ | mips64vr-* | mips64vrel-* \ -+ | mips64orion-* | mips64orionel-* \ -+ | mips64vr4100-* | mips64vr4100el-* \ -+ | mips64vr4300-* | mips64vr4300el-* \ -+ | mips64vr5000-* | mips64vr5000el-* \ -+ | mips64vr5900-* | mips64vr5900el-* \ -+ | mipsisa32-* | mipsisa32el-* \ -+ | mipsisa32r2-* | mipsisa32r2el-* \ -+ | mipsisa64-* | mipsisa64el-* \ -+ | mipsisa64r2-* | mipsisa64r2el-* \ -+ | mipsisa64sb1-* | mipsisa64sb1el-* \ -+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ -+ | mipstx39-* | mipstx39el-* \ -+ | mmix-* \ -+ | mt-* \ -+ | msp430-* \ -+ | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ -- | s390-* | s390x-* \ -- | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ -- | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ -- | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \ -- | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ -- | v850-* | vax-* \ -+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ -+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ -+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ -+ | sparclite-* \ -+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ -+ | tahoe-* | thumb-* \ -+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ -+ | tron-* \ -+ | v850-* | v850e-* | vax-* \ - | we32k-* \ -- | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ -+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ -+ | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-*) - ;; -+ # Recognize the basic CPU types without company name, with glob match. -+ xtensa*) -+ basic_machine=$basic_machine-unknown -+ ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) -@@ -329,6 +393,9 @@ - basic_machine=a29k-amd - os=-udi - ;; -+ abacus) -+ basic_machine=abacus-unknown -+ ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout -@@ -343,6 +410,12 @@ - basic_machine=a29k-none - os=-bsd - ;; -+ amd64) -+ basic_machine=x86_64-pc -+ ;; -+ amd64-*) -+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` -+ ;; - amdahl) - basic_machine=580-amdahl - os=-sysv -@@ -374,6 +447,18 @@ - basic_machine=ns32k-sequent - os=-dynix - ;; -+ blackfin) -+ basic_machine=bfin-unknown -+ os=-linux -+ ;; -+ blackfin-*) -+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` -+ os=-linux -+ ;; -+ c90) -+ basic_machine=c90-cray -+ os=-unicos -+ ;; - convex-c1) - basic_machine=c1-convex - os=-bsd -@@ -394,30 +479,45 @@ - basic_machine=c38-convex - os=-bsd - ;; -- cray | ymp) -- basic_machine=ymp-cray -+ cray | j90) -+ basic_machine=j90-cray - os=-unicos - ;; -- cray2) -- basic_machine=cray2-cray -- os=-unicos -+ craynv) -+ basic_machine=craynv-cray -+ os=-unicosmp - ;; -- [cjt]90) -- basic_machine=${basic_machine}-cray -- os=-unicos -+ cr16) -+ basic_machine=cr16-unknown -+ os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; -+ crisv32 | crisv32-* | etraxfs*) -+ basic_machine=crisv32-axis -+ ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; -+ crx) -+ basic_machine=crx-unknown -+ os=-elf -+ ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; -+ decsystem10* | dec10*) -+ basic_machine=pdp10-dec -+ os=-tops10 -+ ;; -+ decsystem20* | dec20*) -+ basic_machine=pdp10-dec -+ os=-tops20 -+ ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola -@@ -426,6 +526,10 @@ - basic_machine=m88k-motorola - os=-sysv3 - ;; -+ djgpp) -+ basic_machine=i586-pc -+ os=-msdosdjgpp -+ ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx -@@ -576,6 +680,14 @@ - basic_machine=m68k-isi - os=-sysv - ;; -+ m68knommu) -+ basic_machine=m68k-unknown -+ os=-linux -+ ;; -+ m68knommu-*) -+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` -+ os=-linux -+ ;; - m88k-omron*) - basic_machine=m88k-omron - ;; -@@ -591,6 +703,10 @@ - basic_machine=i386-pc - os=-mingw32 - ;; -+ mingw32ce) -+ basic_machine=arm-unknown -+ os=-mingw32ce -+ ;; - miniframe) - basic_machine=m68000-convergent - ;; -@@ -598,32 +714,27 @@ - basic_machine=m68k-atari - os=-mint - ;; -- mipsel*-linux*) -- basic_machine=mipsel-unknown -- os=-linux-gnu -- ;; -- mips*-linux*) -- basic_machine=mips-unknown -- os=-linux-gnu -- ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; -- mmix*) -- basic_machine=mmix-knuth -- os=-mmixware -- ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; -+ morphos) -+ basic_machine=powerpc-unknown -+ os=-morphos -+ ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; -+ ms1-*) -+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` -+ ;; - mvs) - basic_machine=i370-ibm - os=-mvs -@@ -699,6 +810,13 @@ - basic_machine=hppa1.1-oki - os=-proelf - ;; -+ openrisc | openrisc-*) -+ basic_machine=or32-unknown -+ ;; -+ os400) -+ basic_machine=powerpc-ibm -+ os=-os400 -+ ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose -@@ -715,55 +833,75 @@ - basic_machine=i860-intel - os=-osf - ;; -+ parisc) -+ basic_machine=hppa-unknown -+ os=-linux -+ ;; -+ parisc-*) -+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` -+ os=-linux -+ ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; -- pc532 | pc532-*) -+ pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; -- pentium | p5 | k5 | k6 | nexgen) -+ pc98) -+ basic_machine=i386-pc -+ ;; -+ pc98-*) -+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` -+ ;; -+ pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; -- pentiumpro | p6 | 6x86 | athlon) -+ pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; -- pentiumii | pentium2) -+ pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; -- pentium-* | p5-* | k5-* | k6-* | nexgen-*) -+ pentium4) -+ basic_machine=i786-pc -+ ;; -+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; -- pentiumii-* | pentium2-*) -+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; -+ pentium4-*) -+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` -+ ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown -- ;; -+ ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown -- ;; -+ ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown -- ;; -+ ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown -- ;; -+ ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; -@@ -774,6 +912,10 @@ - basic_machine=i586-unknown - os=-pw32 - ;; -+ rdos) -+ basic_machine=i386-pc -+ os=-rdos -+ ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff -@@ -784,10 +926,30 @@ - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; -+ s390 | s390-*) -+ basic_machine=s390-ibm -+ ;; -+ s390x | s390x-*) -+ basic_machine=s390x-ibm -+ ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; -+ sb1) -+ basic_machine=mipsisa64sb1-unknown -+ ;; -+ sb1el) -+ basic_machine=mipsisa64sb1el-unknown -+ ;; -+ sde) -+ basic_machine=mipsisa32-sde -+ os=-elf -+ ;; -+ sei) -+ basic_machine=mips-sei -+ os=-seiux -+ ;; - sequent) - basic_machine=i386-sequent - ;; -@@ -795,7 +957,13 @@ - basic_machine=sh-hitachi - os=-hms - ;; -- sparclite-wrs) -+ sh5el) -+ basic_machine=sh5le-unknown -+ ;; -+ sh64) -+ basic_machine=sh64-unknown -+ ;; -+ sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; -@@ -862,22 +1030,46 @@ - os=-dynix - ;; - t3e) -- basic_machine=t3e-cray -+ basic_machine=alphaev5-cray -+ os=-unicos -+ ;; -+ t90) -+ basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; -+ tic55x | c55x*) -+ basic_machine=tic55x-unknown -+ os=-coff -+ ;; -+ tic6x | c6x*) -+ basic_machine=tic6x-unknown -+ os=-coff -+ ;; -+ tile*) -+ basic_machine=tile-unknown -+ os=-linux-gnu -+ ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; -+ toad1) -+ basic_machine=pdp10-xkl -+ os=-tops20 -+ ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; -+ tpf) -+ basic_machine=s390x-ibm -+ os=-tpf -+ ;; - udi29k) - basic_machine=a29k-amd - os=-udi -@@ -899,8 +1091,8 @@ - os=-vms - ;; - vpp*|vx|vx-*) -- basic_machine=f301-fujitsu -- ;; -+ basic_machine=f301-fujitsu -+ ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks -@@ -921,17 +1113,17 @@ - basic_machine=hppa1.1-winbond - os=-proelf - ;; -- windows32) -- basic_machine=i386-pc -- os=-windows32-msvcrt -- ;; -- xmp) -- basic_machine=xmp-cray -- os=-unicos -+ xbox) -+ basic_machine=i686-pc -+ os=-mingw32 - ;; -- xps | xps100) -+ xps | xps100) - basic_machine=xps100-honeywell - ;; -+ ymp) -+ basic_machine=ymp-cray -+ os=-unicos -+ ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim -@@ -952,16 +1144,12 @@ - op60c) - basic_machine=hppa1.1-oki - ;; -- mips) -- if [ x$os = x-linux-gnu ]; then -- basic_machine=mips-unknown -- else -- basic_machine=mips-mips -- fi -- ;; - romp) - basic_machine=romp-ibm - ;; -+ mmix) -+ basic_machine=mmix-knuth -+ ;; - rs6000) - basic_machine=rs6000-ibm - ;; -@@ -978,13 +1166,13 @@ - we32k) - basic_machine=we32k-att - ;; -- sh3 | sh4 | sh3eb | sh4eb) -+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; -- sparc | sparcv9 | sparcv9b) -+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; -- cydra) -+ cydra) - basic_machine=cydra-cydrome - ;; - orion) -@@ -999,10 +1187,6 @@ - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; -- c4x*) -- basic_machine=c4x-none -- os=-coff -- ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; -@@ -1058,17 +1242,23 @@ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ -- | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ -- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ -+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ -+ | -openbsd* | -solidbsd* \ -+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ -+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ -- | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ -- | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ -+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ -+ | -uxpv* | -beos* | -mpeix* | -udk* \ -+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ -- | -os2* | -vos*) -+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ -+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ -+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ -+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) -@@ -1080,16 +1270,21 @@ - ;; - esac - ;; -+ -nto-qnx*) -+ ;; - -nto*) -- os=-nto-qnx -+ os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -- | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ -+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; -+ -linux-dietlibc) -+ os=-linux-dietlibc -+ ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; -@@ -1102,6 +1297,9 @@ - -opened*) - os=-openedition - ;; -+ -os400*) -+ os=-os400 -+ ;; - -wince*) - os=-wince - ;; -@@ -1120,14 +1318,23 @@ - -acis*) - os=-aos - ;; -+ -atheos*) -+ os=-atheos -+ ;; -+ -syllable*) -+ os=-syllable -+ ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; -+ -nova*) -+ os=-rtmk-nova -+ ;; - -ns2 ) -- os=-nextstep2 -+ os=-nextstep2 - ;; - -nsk*) - os=-nsk -@@ -1139,6 +1346,9 @@ - -sinix*) - os=-sysv4 - ;; -+ -tpf*) -+ os=-tpf -+ ;; - -triton*) - os=-sysv3 - ;; -@@ -1166,8 +1376,17 @@ - -xenix) - os=-xenix - ;; -- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -- os=-mint -+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -+ os=-mint -+ ;; -+ -aros*) -+ os=-aros -+ ;; -+ -kaos*) -+ os=-kaos -+ ;; -+ -zvmoe) -+ os=-zvmoe - ;; - -none) - ;; -@@ -1191,6 +1410,12 @@ - # system, and we'll never get to this point. - - case $basic_machine in -+ score-*) -+ os=-elf -+ ;; -+ spu-*) -+ os=-elf -+ ;; - *-acorn) - os=-riscix1.2 - ;; -@@ -1200,10 +1425,14 @@ - arm*-semi) - os=-aout - ;; -+ c4x-* | tic4x-*) -+ os=-coff -+ ;; -+ # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; -- pdp11-*) -+ pdp11-*) - os=-none - ;; - *-dec | vax-*) -@@ -1224,12 +1453,18 @@ - m68*-cisco) - os=-aout - ;; -+ mep-*) -+ os=-elf -+ ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; -+ or32-*) -+ os=-coff -+ ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; -@@ -1239,9 +1474,15 @@ - *-be) - os=-beos - ;; -+ *-haiku) -+ os=-haiku -+ ;; - *-ibm) - os=-aix - ;; -+ *-knuth) -+ os=-mmixware -+ ;; - *-wec) - os=-proelf - ;; -@@ -1293,19 +1534,19 @@ - *-next) - os=-nextstep3 - ;; -- *-gould) -+ *-gould) - os=-sysv - ;; -- *-highlevel) -+ *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; -- *-sgi) -+ *-sgi) - os=-irix - ;; -- *-siemens) -+ *-siemens) - os=-sysv4 - ;; - *-masscomp) -@@ -1374,10 +1615,16 @@ - -mvs* | -opened*) - vendor=ibm - ;; -+ -os400*) -+ vendor=ibm -+ ;; - -ptx*) - vendor=sequent - ;; -- -vxsim* | -vxworks*) -+ -tpf*) -+ vendor=ibm -+ ;; -+ -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) -@@ -1401,7 +1648,7 @@ - esac - - echo $basic_machine$os --exit 0 -+exit - - # Local variables: - # eval: (add-hook 'write-file-hooks 'time-stamp) ---- gsmlib-1.10.orig/scripts/ltconfig -+++ gsmlib-1.10/scripts/ltconfig -@@ -1,8 +1,8 @@ - #! /bin/sh - - # ltconfig - Create a system-specific libtool. --# Copyright (C) 1996-1998 Free Software Foundation, Inc. --# Gordon Matzigkeit , 1996 -+# Copyright (C) 1996-1999 Free Software Foundation, Inc. -+# Originally by Gordon Matzigkeit , 1996 - # - # This file is free software; you can redistribute it and/or modify it - # under the terms of the GNU General Public License as published by -@@ -32,12 +32,8 @@ - # Discard the --no-reexec flag, and continue. - shift - elif test "X$1" = X--fallback-echo; then -- # used as fallback echo -- shift -- cat </dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -@@ -46,11 +42,30 @@ - exec "$SHELL" "$0" --no-reexec ${1+"$@"} - fi - -+if test "X$1" = X--fallback-echo; then -+ # used as fallback echo -+ shift -+ cat </dev/null`} -+ case X$UNAME in -+ *-DOS) PATH_SEPARATOR=';' ;; -+ *) PATH_SEPARATOR=':' ;; -+ esac -+fi -+ - # The HP-UX ksh and POSIX shell print the target directory to stdout - # if CDPATH is set. --if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi -+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - --if test "X${echo_test_string+set}" != "Xset"; then -+if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... -@@ -70,9 +85,9 @@ - # - # So, first we look for a working echo in the user's PATH. - -- IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" -+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" - for dir in $PATH /usr/ucb; do -- if test -f $dir/echo && -+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then - echo="$dir/echo" -@@ -87,7 +102,8 @@ - test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' -- elif test -f /bin/ksh && test "X$CONFIG_SHELL" != X/bin/ksh; then -+ elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && -+ test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running ltconfig again with it. - ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}" - export ORIGINAL_CONFIG_SHELL -@@ -96,10 +112,10 @@ - exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} - else - # Try using printf. -- echo='printf %s\n' -+ echo='printf "%s\n"' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && -- test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then -- # Cool, printf works -+ test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then -+ # Cool, printf works - : - elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && - test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then -@@ -110,9 +126,9 @@ - echo="$CONFIG_SHELL $0 --fallback-echo" - elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && - test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then -- echo="$CONFIG_SHELL $0 --fallback-echo" -+ echo="$CONFIG_SHELL $0 --fallback-echo" - else -- # maybe with a smaller string... -+ # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do -@@ -143,15 +159,20 @@ - # Same as above, but do not quote variable references. - double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' - -+# Sed substitution to delay expansion of an escaped shell variable in a -+# double_quote_subst'ed string. -+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' -+ - # The name of this program. - progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` - - # Constants: - PROGRAM=ltconfig - PACKAGE=libtool --VERSION=1.2d --ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' --ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' -+VERSION=1.3.5 -+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)" -+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' - rm="rm -f" - - help="Try \`$progname --help' for more information." -@@ -160,8 +181,12 @@ - default_ofile=libtool - can_build_shared=yes - enable_shared=yes --# All known linkers require a `.a' archive for static linking. -+# All known linkers require a `.a' archive for static linking (except M$VC, -+# which needs '.lib'). - enable_static=yes -+enable_fast_install=yes -+enable_dlopen=unknown -+enable_win32_dll=no - ltmain= - silent= - srcdir= -@@ -174,18 +199,24 @@ - with_gcc=no - with_gnu_ld=no - need_locks=yes -+ac_ext=c - objext=o - libext=a -+exeext= -+cache_file= - - old_AR="$AR" - old_CC="$CC" - old_CFLAGS="$CFLAGS" - old_CPPFLAGS="$CPPFLAGS" -+old_LDFLAGS="$LDFLAGS" - old_LD="$LD" - old_LN_S="$LN_S" -+old_LIBS="$LIBS" - old_NM="$NM" - old_RANLIB="$RANLIB" - old_DLLTOOL="$DLLTOOL" -+old_OBJDUMP="$OBJDUMP" - old_AS="$AS" - - # Parse the command line options. -@@ -214,6 +245,9 @@ - --debug enable verbose shell tracing - --disable-shared do not build shared libraries - --disable-static do not build static libraries -+ --disable-fast-install do not optimize for fast installation -+ --enable-dlopen enable dlopen support -+ --enable-win32-dll enable building dlls on win32 hosts - --help display this help and exit - --no-verify do not verify that HOST is a valid host type - -o, --output=FILE specify the output file [default=$default_ofile] -@@ -224,6 +258,7 @@ - --with-gcc assume that the GNU C compiler will be used - --with-gnu-ld assume that the C compiler uses the GNU linker - --disable-lock disable file locking -+ --cache-file=FILE configure cache file - - LTMAIN is the \`ltmain.sh' shell script fragment or \`ltmain.c' program - that provides basic libtool functionality. -@@ -242,6 +277,12 @@ - - --disable-static) enable_static=no ;; - -+ --disable-fast-install) enable_fast_install=no ;; -+ -+ --enable-dlopen) enable_dlopen=yes ;; -+ -+ --enable-win32-dll) enable_win32_dll=yes ;; -+ - --quiet | --silent) silent=yes ;; - - --srcdir) prev=srcdir ;; -@@ -252,13 +293,15 @@ - --output | -o) prev=ofile ;; - --output=*) ofile="$optarg" ;; - -- --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION"; exit 0 ;; -+ --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"; exit 0 ;; - - --with-gcc) with_gcc=yes ;; - --with-gnu-ld) with_gnu_ld=yes ;; - - --disable-lock) need_locks=no ;; - -+ --cache-file=*) cache_file="$optarg" ;; -+ - -*) - echo "$progname: unrecognized option \`$option'" 1>&2 - echo "$help" 1>&2 -@@ -326,8 +369,13 @@ - # Only set LANG and LC_ALL to C if already set. - # These must not be set unconditionally because not all systems understand - # e.g. LANG=C (notably SCO). --if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi --if test "${LANG+set}" = set; then LANG=C; export LANG; fi -+if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi -+if test "X${LANG+set}" = Xset; then LANG=C; export LANG; fi -+ -+if test -n "$cache_file" && test -r "$cache_file"; then -+ echo "loading cache $cache_file within ltconfig" -+ . $cache_file -+fi - - if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. -@@ -343,7 +391,7 @@ - - if test -z "$srcdir"; then - # Assume the source directory is the same one as the path to LTMAIN. -- srcdir=`$echo "$ltmain" | $Xsed -e 's%/[^/]*$%%'` -+ srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'` - test "$srcdir" = "$ltmain" && srcdir=. - fi - -@@ -414,7 +462,7 @@ - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. -- if test "${COLLECT_NAMES+set}" != set; then -+ if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi -@@ -429,15 +477,18 @@ - # Set a sane default for `AR'. - test -z "$AR" && AR=ar - -+# Set a sane default for `OBJDUMP'. -+test -z "$OBJDUMP" && OBJDUMP=objdump -+ - # If RANLIB is not set, then run the test. - if test "${RANLIB+set}" != "set"; then - result=no - - echo $ac_n "checking for ranlib... $ac_c" 1>&6 -- IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" -+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" - for dir in $PATH; do - test -z "$dir" && dir=. -- if test -f $dir/ranlib; then -+ if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then - RANLIB="ranlib" - result="ranlib" - break -@@ -453,8 +504,9 @@ - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" - fi - --# Set sane defaults for `DLLTOOL' and `AS', used on cygwin32. -+# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin. - test -z "$DLLTOOL" && DLLTOOL=dlltool -+test -z "$OBJDUMP" && OBJDUMP=objdump - test -z "$AS" && AS=as - - # Check to see if we are using GCC. -@@ -462,11 +514,10 @@ - # If CC is not set, then try to find GCC or a usable CC. - if test -z "$CC"; then - echo $ac_n "checking for gcc... $ac_c" 1>&6 -- IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" -+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" - for dir in $PATH; do -- IFS="$save_ifs" - test -z "$dir" && dir=. -- if test -f $dir/gcc; then -+ if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then - CC="gcc" - break - fi -@@ -483,11 +534,11 @@ - # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". - if test -z "$CC"; then - echo $ac_n "checking for cc... $ac_c" 1>&6 -- IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" -+ IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" - cc_rejected=no - for dir in $PATH; do - test -z "$dir" && dir=. -- if test -f $dir/cc; then -+ if test -f $dir/cc || test -f $dir/cc$ac_exeext; then - if test "$dir/cc" = "/usr/ucb/cc"; then - cc_rejected=yes - continue -@@ -527,7 +578,7 @@ - # Now see if the compiler is really GCC. - with_gcc=no - echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 -- echo "$progname:530: checking whether we are using GNU C" >&5 -+ echo "$progname:581: checking whether we are using GNU C" >&5 - - $rm conftest.c - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then -+ if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:589: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - with_gcc=yes - fi - $rm conftest.c -@@ -549,8 +600,8 @@ - echo $ac_n "checking for object suffix... $ac_c" 1>&6 - $rm conftest* - echo 'int i = 1;' > conftest.c --echo "$progname:552: checking for object suffix" >& 5 --if { (eval echo $progname:553: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then -+echo "$progname:603: checking for object suffix" >& 5 -+if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then - # Append any warnings to the config.log. - cat conftest.err 1>&5 - -@@ -568,6 +619,38 @@ - $rm conftest* - echo "$ac_t$objext" 1>&6 - -+echo $ac_n "checking for executable suffix... $ac_c" 1>&6 -+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ ac_cv_exeext="no" -+ $rm conftest* -+ echo 'main () { return 0; }' > conftest.c -+ echo "$progname:629: checking for executable suffix" >& 5 -+ if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then -+ # Append any warnings to the config.log. -+ cat conftest.err 1>&5 -+ -+ for ac_file in conftest.*; do -+ case $ac_file in -+ *.c | *.err | *.$objext ) ;; -+ *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;; -+ esac -+ done -+ else -+ cat conftest.err 1>&5 -+ echo "$progname: failed program was:" >&5 -+ cat conftest.c >&5 -+ fi -+ $rm conftest* -+fi -+if test "X$ac_cv_exeext" = Xno; then -+ exeext="" -+else -+ exeext="$ac_cv_exeext" -+fi -+echo "$ac_t$ac_cv_exeext" 1>&6 -+ - echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 - pic_flag= - special_shlib_compile_flags= -@@ -580,10 +663,19 @@ - link_static_flag='-static' - - case "$host_os" in -- aix3* | aix4* | irix5* | irix6* | osf3* | osf4*) -+ beos* | irix5* | irix6* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; -- cygwin32* | mingw32* | os2*) -+ aix*) -+ # Below there is a dirty hack to force normal static linking with -ldl -+ # The problem is because libdl dynamically linked with both libc and -+ # libC (AIX C++ library), which obviously doesn't included in libraries -+ # list by gcc. This cause undefined symbols with -static flags. -+ # This hack allows C programs to be linked with "-static -ldl", but -+ # we not sure about C++ programs. -+ link_static_flag="$link_static_flag ${wl}-lC" -+ ;; -+ cygwin* | mingw* | os2*) - # We can build DLLs from non-PIC. - ;; - amigaos*) -@@ -592,6 +684,11 @@ - # like `-m68040'. - pic_flag='-m68020 -resident32 -malways-restore-a4' - ;; -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ pic_flag=-Kconform_pic -+ fi -+ ;; - *) - pic_flag='-fPIC' - ;; -@@ -617,11 +714,11 @@ - # PIC (with -KPIC) is the default. - ;; - -- cygwin32* | mingw32* | os2*) -+ cygwin* | mingw* | os2*) - # We can build DLLs from non-PIC. - ;; - -- osf3* | osf4*) -+ osf3* | osf4* | osf5*) - # All OSF/1 code is PIC. - wl='-Wl,' - link_static_flag='-non_shared' -@@ -645,7 +742,7 @@ - wl='-Qoption ld ' - ;; - -- sysv4.2uw2* | sysv5*) -+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - pic_flag='-KPIC' - link_static_flag='-Bstatic' - wl='-Wl,' -@@ -655,7 +752,12 @@ - pic_flag='-pic' - link_static_flag='-Bstatic' - ;; -- -+ sysv4*MP*) -+ if test -d /usr/nec ;then -+ pic_flag='-Kconform_pic' -+ link_static_flag='-Bstatic' -+ fi -+ ;; - *) - can_build_shared=no - ;; -@@ -671,22 +773,30 @@ - echo "int some_variable = 0;" > conftest.c - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $pic_flag -DPIC" -- echo "$progname:674: checking if $compiler PIC flag $pic_flag works" >&5 -- if { (eval echo $progname:675: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then -+ echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5 -+ if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then - # Append any warnings to the config.log. - cat conftest.err 1>&5 -- -- # On HP-UX, both CC and GCC only warn that PIC is supported... then they -- # create non-PIC objects. So, if there were any warnings, we assume that -- # PIC is not supported. -- if test -s conftest.err; then -- echo "$ac_t"no 1>&6 -- can_build_shared=no -- pic_flag= -- else -+ -+ case "$host_os" in -+ hpux9* | hpux10* | hpux11*) -+ # On HP-UX, both CC and GCC only warn that PIC is supported... then they -+ # create non-PIC objects. So, if there were any warnings, we assume that -+ # PIC is not supported. -+ if test -s conftest.err; then -+ echo "$ac_t"no 1>&6 -+ can_build_shared=no -+ pic_flag= -+ else -+ echo "$ac_t"yes 1>&6 -+ pic_flag=" $pic_flag" -+ fi -+ ;; -+ *) - echo "$ac_t"yes 1>&6 - pic_flag=" $pic_flag" -- fi -+ ;; -+ esac - else - # Append any errors to the config.log. - cat conftest.err 1>&5 -@@ -702,16 +812,26 @@ - - # Check to see if options -o and -c are simultaneously supported by compiler - echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6 -+$rm -r conftest 2>/dev/null -+mkdir conftest -+cd conftest - $rm conftest* - echo "int some_variable = 0;" > conftest.c -+mkdir out -+# According to Tom Tromey, Ian Lance Taylor reported there are C compilers -+# that will create temporary files in the current directory regardless of -+# the output directory. Thus, making CWD read-only will cause this test -+# to fail, enabling locking or at least warning the user not to do parallel -+# builds. -+chmod -w . - save_CFLAGS="$CFLAGS" --CFLAGS="$CFLAGS -c -o conftest2.o" --echo "$progname:709: checking if $compiler supports -c -o file.o" >&5 --if { (eval echo $progname:710: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest2.o; then -+CFLAGS="$CFLAGS -o out/conftest2.o" -+echo "$progname:829: checking if $compiler supports -c -o file.o" >&5 -+if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then - - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings -- if test -s conftest.err; then -+ if test -s out/conftest.err; then - echo "$ac_t"no 1>&6 - compiler_c_o=no - else -@@ -720,12 +840,17 @@ - fi - else - # Append any errors to the config.log. -- cat conftest.err 1>&5 -+ cat out/conftest.err 1>&5 - compiler_c_o=no - echo "$ac_t"no 1>&6 - fi - CFLAGS="$save_CFLAGS" --$rm conftest* -+chmod u+w . -+$rm conftest* out/* -+rmdir out -+cd .. -+rmdir conftest -+$rm -r conftest 2>/dev/null - - if test x"$compiler_c_o" = x"yes"; then - # Check to see if we can write to a .lo -@@ -734,8 +859,8 @@ - echo "int some_variable = 0;" > conftest.c - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -c -o conftest.lo" -- echo "$progname:737: checking if $compiler supports -c -o file.lo" >&5 --if { (eval echo $progname:738: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then -+ echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5 -+if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then - - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings -@@ -743,8 +868,8 @@ - echo "$ac_t"no 1>&6 - compiler_o_lo=no - else -- echo "$ac_t"yes 1>&6 -- compiler_o_lo=yes -+ echo "$ac_t"yes 1>&6 -+ compiler_o_lo=yes - fi - else - # Append any errors to the config.log. -@@ -786,17 +911,17 @@ - echo "int some_variable = 0;" > conftest.c - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c" -- echo "$progname:789: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -- if { (eval echo $progname:790: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then -+ echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -+ if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then - - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then -- echo "$ac_t"no 1>&6 -- compiler_rtti_exceptions=no -+ echo "$ac_t"no 1>&6 -+ compiler_rtti_exceptions=no - else -- echo "$ac_t"yes 1>&6 -- compiler_rtti_exceptions=yes -+ echo "$ac_t"yes 1>&6 -+ compiler_rtti_exceptions=yes - fi - else - # Append any errors to the config.log. -@@ -830,8 +955,8 @@ - echo 'main(){return(0);}' > conftest.c - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $link_static_flag" --echo "$progname:833: checking if $compiler static flag $link_static_flag works" >&5 --if { (eval echo $progname:834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then -+echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5 -+if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - echo "$ac_t$link_static_flag" 1>&6 - else - echo "$ac_t"none 1>&6 -@@ -843,9 +968,9 @@ - if test -z "$LN_S"; then - # Check to see if we can use ln -s, or we need hard links. - echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 -- $rm conftestdata -- if ln -s X conftestdata 2>/dev/null; then -- $rm conftestdata -+ $rm conftest.dat -+ if ln -s X conftest.dat 2>/dev/null; then -+ $rm conftest.dat - LN_S="ln -s" - else - LN_S=ln -@@ -863,48 +988,18 @@ - if test "$with_gcc" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 -- echo "$progname:866: checking for ld used by GCC" >&5 -+ echo "$progname:991: checking for ld used by GCC" >&5 - ac_prog=`($CC -print-prog-name=ld) 2>&5` - case "$ac_prog" in - # Accept absolute paths. -- /* | [A-Za-z]:/*) -+ [\\/]* | [A-Za-z]:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' -- sub_uncdrive='s%^\([A-Za-z]\):/%//\1/%' -- # Canonicalize the path of ld -- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -- ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` -- done -- case "$host_os" in -- cygwin*) -- # Convert to a UNC path for cygwin -- test -z "$LD" && LD=`echo X$ac_prog | $Xsed -e "$sub_uncdrive"` -- ;; -- *) -- test -z "$LD" && LD="$ac_prog" -- ;; -- esac -- ;; -- ## -- ## FIXME: The code fails later on if we try to use an $LD with -- ## '\\' path separators. -- ## -- [A-Za-z]:[\\]*) -- re_direlt='\\[^\\][^\\]*\\\.\.\(\\\)' -- sub_uncdrive='s%^\([A-Za-z]\):\\%//\1/%' -- sub_uncdir='s%\\%/%g' - # Canonicalize the path of ld -+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do -- ac_prog=`echo $ac_prog| sed "s%$re_direlt%\1%"` -+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done -- case "$host_os" in -- cygwin*) -- # Convert to a UNC path for cygwin -- test -z "$LD" && LD=`echo X$ac_prog | $Xsed -e "$sub_uncdrive" -e "$sub_uncdir"` -- ;; -- *) -- test -z "$LD" && LD="$ac_prog" -- ;; -- esac -+ test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we are not using GCC. -@@ -917,17 +1012,17 @@ - esac - elif test "$with_gnu_ld" = yes; then - echo $ac_n "checking for GNU ld... $ac_c" 1>&6 -- echo "$progname:920: checking for GNU ld" >&5 -+ echo "$progname:1015: checking for GNU ld" >&5 - else - echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -- echo "$progname:923: checking for non-GNU ld" >&5 -+ echo "$progname:1018: checking for non-GNU ld" >&5 - fi - - if test -z "$LD"; then -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" -+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. -- if test -f "$ac_dir/$ac_prog"; then -+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. -@@ -969,130 +1064,208 @@ - - allow_undefined_flag= - no_undefined_flag= -+need_lib_prefix=unknown -+need_version=unknown -+# when you set need_version to no, make sure it does not cause -set_version -+# flags to be left without arguments - archive_cmds= --archive_sym_cmds= -+archive_expsym_cmds= - old_archive_from_new_cmds= - export_dynamic_flag_spec= - whole_archive_flag_spec= -+thread_safe_flag_spec= - hardcode_libdir_flag_spec= - hardcode_libdir_separator= - hardcode_direct=no - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - runpath_var= -+always_export_symbols=no -+export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' -+# include_expsyms should be a list of space-separated symbols to be *always* -+# included in the symbol list -+include_expsyms= -+# exclude_expsyms can be an egrep regular expression of symbols to exclude -+# it will be wrapped by ` (' and `)$', so one must not match beginning or -+# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -+# as well as any symbol that contains `d'. -+exclude_expsyms="_GLOBAL_OFFSET_TABLE_" -+# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -+# platforms (ab)use it in PIC code, but their linkers get confused if -+# the symbol is explicitly referenced. Since portable code cannot -+# rely on this symbol name, it's probably fine to never include it in -+# preloaded symbol tables. - - case "$host_os" in --aix3* | aix4*) -- # On AIX, the GNU linker works like the native linker. -- with_gnu_ld=no -+cygwin* | mingw*) -+ # FIXME: the MSVC++ port hasn't been tested in a loooong time -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ if test "$with_gcc" != yes; then -+ with_gnu_ld=no -+ fi - ;; -+ - esac - - ld_shlibs=yes - if test "$with_gnu_ld" = yes; then -+ # If archive_cmds runs LD, not CC, wlarc should be empty -+ wlarc='${wl}' - - # See if GNU ld supports shared libraries. - case "$host_os" in -+ aix3* | aix4*) -+ # On AIX, the GNU linker is very broken -+ ld_shlibs=no -+ cat <&2 -+ -+*** Warning: the GNU linker, at least up to release 2.9.1, is reported -+*** to be unable to reliably create shared libraries on AIX. -+*** Therefore, libtool is disabling shared libraries support. If you -+*** really care for shared libraries, you may want to modify your PATH -+*** so that a non-GNU linker is found, and then restart. -+ -+EOF -+ ;; -+ - amigaos*) -- archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib$libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' -+ archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes -- ;; - -- sunos4*) -- archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs$deplibs' -- hardcode_direct=yes -- hardcode_minus_L=yes -- hardcode_shlibpath_var=no -+ # Samuel A. Falvo II reports -+ # that the semantics of dynamic libraries on AmigaOS, at least up -+ # to version 4, is to share data among multiple programs linked -+ # with the same dynamic library. Since this doesn't match the -+ # behavior of shared libraries on other platforms, we can use -+ # them. -+ ld_shlibs=no - ;; - -- cygwin32* | mingw32*) -- if test "$with_gcc" = yes; then -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec='-L$libdir' -+ beos*) -+ if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported -- # Very, very bogus. -- echo ' --#define WIN32_LEAN_AND_MEAN --#include --#undef WIN32_LEAN_AND_MEAN --#include -+ # Joseph Beckenbach says some releases of gcc -+ # support --undefined. This deserves some investigation. FIXME -+ archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' -+ else -+ ld_shlibs=no -+ fi -+ ;; - --BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -+ cygwin* | mingw*) -+ # hardcode_libdir_flag_spec is actually meaningless, as there is -+ # no search path for DLLs. -+ hardcode_libdir_flag_spec='-L$libdir' -+ allow_undefined_flag=unsupported -+ always_export_symbols=yes - --#include --DECLARE_CYGWIN_DLL( DllMain ); --HINSTANCE __hDllInstance_base; -+ # Extract the symbol export list from an `--export-all' def file, -+ # then regenerate the def file from the symbol export list, so that -+ # the compiled dll only exports the symbol export list. -+ # Be careful not to strip the DATA tag left by newer dlltools. -+ export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ -+ test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ -+ $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ -+ sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols' -+ -+ # If DATA tags from a recent dlltool are present, honour them! -+ archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ -+ _lt_hint=1; -+ cat $export_symbols | while read symbol; do -+ set dummy \$symbol; -+ case \$# in -+ 2) echo " \$2 @ \$_lt_hint ; " >> $objdir/$soname-def;; -+ *) echo " \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;; -+ esac; -+ _lt_hint=`expr 1 + \$_lt_hint`; -+ done~ -+ test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ -+ test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ -+ $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ -+ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ -+ $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ -+ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ -+ $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts' - --BOOL APIENTRY --DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) --{ -- __hDllInstance_base = hInst; -- return TRUE; --} --' > ltdll.c -- archive_cmds='$CC -c '"`pwd`"'/ltdll.c~echo EXPORTS > $lib-def~ -- $DLLTOOL --export-all --output-def $lib-def $libobjs ltdll.$objext~ -- $CC -Wl,--base-file,$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 $libobjs ltdll.$objext~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC -Wl,--base-file,$soname-base $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $rm ltdll.$objext $soname-base $soname-exp' -- archive_sym_cmds='$CC -c '"`pwd`"'/ltdll.c~echo EXPORTS > $lib-def~ -- cat "$export_symbols" >> $lib-def~ -- $CC -Wl,--base-file,$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 $libobjs ltdll.$objext~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC -Wl,--base-file,$soname-base $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $rm ltdll.$objext $soname-base $soname-exp' -- old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $lib-def --output-lib $objdir/$libname.a~$rm $lib.exp' -- else -- # When not using gcc, we currently assume that we are using -- # Microsoft Visual C++. -- with_gnu_ld=no -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec=' ' -- allow_undefined_flag=unsupported -- # Tell ltmain to make .lib files, not .a files. -- libext=lib -- # FIXME: Setting linknames here is a bad hack. -- archive_cmds='$CC -o $lib$libobjs`echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' -- # The linker will automatically build a .lib file if we build a DLL. -- old_archive_from_new_cmds='true' -- # FIXME: Should let the user specify the lib program. -- old_archive_cmds='lib /OUT:$oldlib$oldobjs' -- fix_srcfile_path='`cygpath -w $srcfile`' -+ old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' -+ ;; -+ -+ netbsd*) -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib' -+ # can we support soname and/or expsyms with a.out? -oliva - fi - ;; - -+ solaris* | sysv5*) -+ if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then -+ ld_shlibs=no -+ cat <&2 -+ -+*** Warning: The releases 2.8.* of the GNU linker cannot reliably -+*** create shared libraries on Solaris systems. Therefore, libtool -+*** is disabling shared libraries support. We urge you to upgrade GNU -+*** binutils to release 2.9.1 or newer. Another option is to modify -+*** your PATH or compiler configuration so that the native linker is -+*** used, and then restart. -+ -+EOF -+ elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -+ archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' -+ else -+ ld_shlibs=no -+ fi -+ ;; -+ -+ sunos4*) -+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts' -+ wlarc= -+ hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ ;; -+ - *) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then -- archive_cmds='$CC -shared ${wl}-soname $wl$soname -o $lib$libobjs$deplibs' -- archive_sym_cmds='$CC -shared ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib$libobjs$deplibs' -+ archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' -+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - -- if test "$ld_shlibs" = yes && test "$with_gnu_ld" = yes; then -+ if test "$ld_shlibs" = yes; then - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' -- whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' -+ case $host_os in -+ cygwin* | mingw*) -+ # dlltool doesn't understand --whole-archive et. al. -+ whole_archive_flag_spec= -+ ;; -+ *) -+ # ancient GNU ld didn't support --whole-archive et. al. -+ if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then -+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' -+ else -+ whole_archive_flag_spec= -+ fi -+ ;; -+ esac - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case "$host_os" in - aix3*) - allow_undefined_flag=unsupported -- archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\' | sort | uniq' > $lib.exp~ -- $LD -o $objdir/$soname$libobjs$deplibs -bE:$lib.exp -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' -- archive_sym_cmds='$LD -o $objdir/$soname$libobjs$deplibs -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' -+ always_export_symbols=yes -+ archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes -@@ -1104,80 +1277,67 @@ - ;; - - aix4*) -- allow_undefined_flag=unsupported -- archive_cmds='$NM$libobjs | $global_symbol_pipe | sed '\''s/.* //'\' | sort | uniq' > $lib.exp else cat $export_symbols > $lib.exp~ -- $CC -o $objdir/$soname$libobjs$deplibs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry~$AR cru $lib $objdir/$soname' -- archive_sym_cmds='$CC -o $objdir/$soname$libobjs$deplibs ${wl}-bE:$export_symbols ${wl}-bM:SRE ${wl}-bnoentry~$AR cru $lib $objdir/$soname' -- hardcode_direct=yes -- hardcode_minus_L=yes -- ;; -+ hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib' -+ hardcode_libdir_separator=':' -+ if test "$with_gcc" = yes; then -+ collect2name=`${CC} -print-prog-name=collect2` -+ if test -f "$collect2name" && \ -+ strings "$collect2name" | grep resolve_lib_name >/dev/null -+ then -+ # We have reworked collect2 -+ hardcode_direct=yes -+ else -+ # We have old collect2 -+ hardcode_direct=unsupported -+ # It fails to find uninstalled libraries when the uninstalled -+ # path is not listed in the libpath. Setting hardcode_minus_L -+ # to unsupported forces relinking -+ hardcode_minus_L=yes -+ hardcode_libdir_flag_spec='-L$libdir' -+ hardcode_libdir_separator= -+ fi -+ shared_flag='-shared' -+ else -+ shared_flag='${wl}-bM:SRE' -+ hardcode_direct=yes -+ fi -+ allow_undefined_flag=' ${wl}-berok' -+ archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}' -+ archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}' -+ case "$host_os" in aix4.[01]|aix4.[01].*) -+ # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on -+ always_export_symbols=yes ;; -+ esac -+ ;; - - amigaos*) -- archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib$libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' -+ archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes -+ # see comment about different semantics on the GNU ld section -+ ld_shlibs=no - ;; - -- cygwin32* | mingw32*) -- if test "$with_gcc" = yes; then -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec='-L$libdir' -- allow_undefined_flag=unsupported -- # Very, very bogus. -- echo ' --#define WIN32_LEAN_AND_MEAN --#include --#undef WIN32_LEAN_AND_MEAN --#include -- --BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -- --#include --DECLARE_CYGWIN_DLL( DllMain ); --HINSTANCE __hDllInstance_base; -+ cygwin* | mingw*) -+ # When not using gcc, we currently assume that we are using -+ # Microsoft Visual C++. -+ # hardcode_libdir_flag_spec is actually meaningless, as there is -+ # no search path for DLLs. -+ hardcode_libdir_flag_spec=' ' -+ allow_undefined_flag=unsupported -+ # Tell ltmain to make .lib files, not .a files. -+ libext=lib -+ # FIXME: Setting linknames here is a bad hack. -+ archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' -+ # The linker will automatically build a .lib file if we build a DLL. -+ old_archive_from_new_cmds='true' -+ # FIXME: Should let the user specify the lib program. -+ old_archive_cmds='lib /OUT:$oldlib$oldobjs' -+ fix_srcfile_path='`cygpath -w $srcfile`' -+ ;; - --BOOL APIENTRY --DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) --{ -- __hDllInstance_base = hInst; -- return TRUE; --} --' > ltdll.c -- archive_cmds='$CC -c '"`pwd`"'/ltdll.c~echo EXPORTS > $lib-def~ -- $DLLTOOL --export-all --output-def $lib-def $libobjs ltdll.$objext~ -- $CC -Wl,--base-file,$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 $libobjs ltdll.$objext~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC -Wl,--base-file,$soname-base $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $rm ltdll.$objext $soname-base $soname-exp' -- archive_sym_cmds='$CC -c '"`pwd`"'/ltdll.c~echo EXPORTS > $lib-def~ -- cat "$export_symbols" >> $lib-def~ -- $CC -Wl,--base-file,$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 $libobjs ltdll.$objext~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC -Wl,--base-file,$soname-base $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $DLLTOOL --as=$AS --dllname $soname --exclude-symbol=_cygwin_dll_entry@12 --def $lib-def --base-file $soname-base --output-exp $soname-exp~ -- $CC $soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $libobjs ltdll.$objext$deplibs~ -- $rm ltdll.$objext $soname-base $soname-exp' -- old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $lib-def --output-lib $objdir/$libname.a~$rm $lib.exp' -- else -- # When not using gcc, we currently assume that we are using -- # Microsoft Visual C++. -- # hardcode_libdir_flag_spec is actually meaningless, as there is -- # no search path for DLLs. -- hardcode_libdir_flag_spec=' ' -- allow_undefined_flag=unsupported -- # Tell ltmain to make .lib files, not .a files. -- libext=lib -- # FIXME: Setting linknames here is a bad hack. -- archive_cmds='$CC -o $lib$libobjs`echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' -- # The linker will automatically build a .lib file if we build a DLL. -- old_archive_from_new_cmds='true' -- # FIXME: Should let the user specify the lib program. -- old_archive_cmds='lib /OUT:$oldlib$oldobjs' -- fix_srcfile_path='`cygpath -w $srcfile`' -- fi -+ freebsd1*) -+ ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor -@@ -1185,65 +1345,64 @@ - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) -- archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs /usr/lib/c++rt0.o' -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes -- hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) -- archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs' -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - -- # FreeBSD 3, at last, uses gcc -shared to do shared libraries. -- freebsd3*) -- archive_cmds='$CC -shared -o $lib$libobjs$deplibs' -+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. -+ freebsd*) -+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes -- hardcode_minus_L=no - hardcode_shlibpath_var=no - ;; - -- hpux9*) -- archive_cmds='$rm $objdir/$soname~$LD -b +s +b $install_libdir -o $objdir/$soname$libobjs$deplibs~test $objdir/$soname = $lib || mv $objdir/$soname $lib' -- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -- hardcode_direct=yes -- hardcode_minus_L=yes -- export_dynamic_flag_spec='${wl}-E' -- ;; -- -- hpux10* | hpux11*) -- archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib$libobjs$deplibs' -+ hpux9* | hpux10* | hpux11*) -+ case "$host_os" in -+ hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;; -+ *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;; -+ esac - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' -+ hardcode_libdir_separator=: - hardcode_direct=yes -- hardcode_minus_L=yes -+ hardcode_minus_L=yes # Not in the search PATH, but as the default -+ # location of the library. - export_dynamic_flag_spec='${wl}-E' - ;; - - irix5* | irix6*) - if test "$with_gcc" = yes; then -- archive_cmds='$CC -shared -o $lib ${wl}-soname ${wl}$soname ${wl}-set_version ${wl}$verstring$libobjs$deplibs' -+ archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - else -- archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs$deplibs' -+ archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator=: - ;; - - netbsd*) -- # Tested with NetBSD 1.2 ld -- archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs' -- hardcode_libdir_flag_spec='-R$libdir' -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' # a.out -+ else -+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts' # ELF -+ fi -+ hardcode_libdir_flag_spec='${wl}-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - openbsd*) -- archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs' -+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no -@@ -1253,102 +1412,169 @@ - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported -- archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp$libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib$libobjs$deplibs $objdir/$libname.def' -+ archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' - ;; - -- osf3* | osf4*) -+ osf3*) - if test "$with_gcc" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -- archive_cmds='$CC -shared${allow_undefined_flag} -o $lib ${wl}-soname ${wl}$soname ${wl}-set_version ${wl}$verstring$libobjs$deplibs' -+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' -- archive_cmds='$LD -shared${allow_undefined_flag} -o $lib -soname $soname -set_version $verstring$libobjs$deplibs' -+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - -- sco3.2v5*) -- archive_cmds='$LD -G -o $lib$libobjs$deplibs' -+ osf4* | osf5*) # As osf3* with the addition of the -msym flag -+ if test "$with_gcc" = yes; then -+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' -+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' -+ else -+ allow_undefined_flag=' -expect_unresolved \*' -+ archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' -+ fi -+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' -+ hardcode_libdir_separator=: -+ ;; -+ rhapsody*) -+ archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts' -+ hardcode_libdir_flags_spec='-L$libdir' - hardcode_direct=yes -+ hardcode_shlibpath_var=no -+ ;; -+ -+ sco3.2v5*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' -+ hardcode_shlibpath_var=no -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes - ;; - - solaris*) - no_undefined_flag=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now -- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib$libobjs$deplibs' -- archive_sym_cmds='$echo "{ global:" > $lib.exp~sed $export_symbols -e "s/.*/\1;/" >> $lib.exp~$echo "local: * }" >> $lib.exp~ -- $LD -G${allow_undefined_flag} -M $export_symbols -h $soname -o $lib$libobjs$deplibs~$rm $lib.exp' -+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' -+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no -- -- # Solaris 2 before 2.5 hardcodes -L paths. - case "$host_os" in -- solaris2.[0-4]*) -- hardcode_minus_L=yes -- ;; -+ solaris2.[0-5] | solaris2.[0-5].*) ;; -+ *) # Supported since Solaris 2.6 (maybe 2.5.1?) -+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; - esac - ;; - - sunos4*) -- # Why do we need -Bstatic? To avoid inter-library dependencies, maybe... -- if test "$with_gcc" = yes; then -- archive_cmds='$CC -shared ${wl}-Bstatic -o $lib$libobjs$deplibs' -- else -- archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs$deplibs' -- fi -+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - -+ sysv4) -+ if test "x$host_vendor" = xsequent; then -+ # Use $CC to link under sequent, because it throws in some extra .o -+ # files that make .init and .fini sections work. -+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts' -+ else -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' -+ fi -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var=no -+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie -+ ;; -+ -+ sysv4.3*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' -+ hardcode_shlibpath_var=no -+ export_dynamic_flag_spec='-Bexport' -+ ;; -+ -+ sysv5*) -+ no_undefined_flag=' -z text' -+ # $CC -shared without GNU ld will not create a library from C++ -+ # object files and a static libstdc++, better avoid it by now -+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' -+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ -+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' -+ hardcode_libdir_flag_spec= -+ hardcode_shlibpath_var=no -+ runpath_var='LD_RUN_PATH' -+ ;; -+ - uts4*) -- archive_cmds='$LD -G -h $soname -o $lib$libobjs$deplibs' -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' - hardcode_libdir_flag_spec='-L$libdir' -- hardcode_direct=no -- hardcode_minus_L=no - hardcode_shlibpath_var=no - ;; - - dgux*) -- archive_cmds='$LD -G -h $soname -o $lib$libobjs$deplibs' -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' - hardcode_libdir_flag_spec='-L$libdir' -- hardcode_direct=no -+ hardcode_shlibpath_var=no -+ ;; -+ -+ sysv4*MP*) -+ if test -d /usr/nec; then -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' -+ hardcode_shlibpath_var=no -+ runpath_var=LD_RUN_PATH -+ hardcode_runpath_var=yes -+ ld_shlibs=yes -+ fi -+ ;; -+ -+ sysv4.2uw2*) -+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts' -+ hardcode_direct=yes - hardcode_minus_L=no - hardcode_shlibpath_var=no -+ hardcode_runpath_var=yes -+ runpath_var=LD_RUN_PATH -+ ;; -+ -+ unixware7*) -+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' -+ runpath_var='LD_RUN_PATH' -+ hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no -- can_build_shared=no - ;; - esac - fi - echo "$ac_t$ld_shlibs" 1>&6 -+test "$ld_shlibs" = no && can_build_shared=no - - if test -z "$NM"; then - echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 - case "$NM" in -- /* | [A-Za-z]:[/\\]*) ;; # Let the user override the test with a path. -+ [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path. - *) -- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" -- for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do -+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" -+ for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do - test -z "$ac_dir" && ac_dir=. -- if test -f $ac_dir/nm; then -- # Check to see if the nm accepts a BSD-compat flag. -- # Adding the `sed 1q' prevents false positives on HP-UX, which says: -- # nm: unknown option "B" ignored -- if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then -- NM="$ac_dir/nm -B" -- elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then -- NM="$ac_dir/nm -p" -+ if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then -+ # Check to see if the nm accepts a BSD-compat flag. -+ # Adding the `sed 1q' prevents false positives on HP-UX, which says: -+ # nm: unknown option "B" ignored -+ if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then -+ NM="$ac_dir/nm -B" -+ break -+ elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then -+ NM="$ac_dir/nm -p" -+ break - else -- NM="$ac_dir/nm" -+ NM=${NM="$ac_dir/nm"} # keep the first match, but -+ continue # so that we can try to find one that supports BSD flags - fi -- break - fi - done - IFS="$ac_save_ifs" -@@ -1365,52 +1591,54 @@ - # [They come from Ultrix. What could be older than Ultrix?!! ;)] - - # Character class describing NM global symbol codes. --symcode='[BCDEGRSTU]' -+symcode='[BCDEGRST]' - - # Regexp to match symbols that can be accessed directly from C. - sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - - # Transform the above into a raw symbol and a C symbol. --symxfrm='\1 \1' -+symxfrm='\1 \2\3 \3' -+ -+# Transform an extracted symbol line into a proper C declaration -+global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" - - # Define system-specific variables. - case "$host_os" in - aix*) -- symcode='[BCDTU]' -+ symcode='[BCDT]' -+ ;; -+cygwin* | mingw*) -+ symcode='[ABCDGISTW]' - ;; --sunos* | cygwin32* | mingw32*) -- sympat='_\([_A-Za-z][_A-Za-z0-9]*\)' -- symxfrm='_\1 \1' -+hpux*) # Its linker distinguishes data from code symbols -+ global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'" - ;; - irix*) -- # Cannot use undefined symbols on IRIX because inlined functions mess us up. - symcode='[BCDEGRST]' - ;; - solaris*) -- symcode='[BDTU]' -+ symcode='[BDT]' -+ ;; -+sysv4) -+ symcode='[DFNSTU]' - ;; - esac - - # If we're using GNU nm, then use its standard symbol codes. - if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then -- symcode='[ABCDGISTUW]' -+ symcode='[ABCDGISTW]' - fi - --case "$host_os" in --cygwin32* | mingw32*) -- # We do not want undefined symbols on cygwin32. The user must -- # arrange to define them via -l arguments. -- symcode='[ABCDGISTW]' -- ;; --esac -+# Try without a prefix undercore, then with it. -+for ac_symprfx in "" "_"; do - --# Write the raw and C identifiers. --global_symbol_pipe="sed -n -e 's/^.* $symcode $sympat$/$symxfrm/p'" -+ # Write the raw and C identifiers. -+ global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'" - --# Check to see that the pipe works correctly. --pipe_works=no --$rm conftest* --cat > conftest.c < conftest.c <&5 --if { (eval echo $progname:1426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then -- # Now try to grab the symbols. -- nlist=conftest.nm -- if { echo "$progname:1429: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then -- -- # Try sorting and uniquifying the output. -- if sort "$nlist" | uniq > "$nlist"T; then -- mv -f "$nlist"T "$nlist" -- wcout=`wc "$nlist" 2>/dev/null` -- count=`$echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` -- (test "$count" -ge 0) 2>/dev/null || count=-1 -- else -- rm -f "$nlist"T -- count=-1 -- fi -+ echo "$progname:1653: checking if global_symbol_pipe works" >&5 -+ if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then -+ # Now try to grab the symbols. -+ nlist=conftest.nm -+ if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then -+ -+ # Try sorting and uniquifying the output. -+ if sort "$nlist" | uniq > "$nlist"T; then -+ mv -f "$nlist"T "$nlist" -+ else -+ rm -f "$nlist"T -+ fi - -- # Make sure that we snagged all the symbols we need. -- if egrep ' nm_test_var$' "$nlist" >/dev/null; then -- if egrep ' nm_test_func$' "$nlist" >/dev/null; then -- cat < conftest.c -+ # Make sure that we snagged all the symbols we need. -+ if egrep ' nm_test_var$' "$nlist" >/dev/null; then -+ if egrep ' nm_test_func$' "$nlist" >/dev/null; then -+ cat < conftest.c - #ifdef __cplusplus - extern "C" { - #endif - - EOF -- # Now generate the symbol file. -- sed 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> conftest.c -+ # Now generate the symbol file. -+ eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c' - -- cat <> conftest.c -+ cat <> conftest.c - #if defined (__STDC__) && __STDC__ --# define __ptr_t void * -+# define lt_ptr_t void * - #else --# define __ptr_t char * -+# define lt_ptr_t char * -+# define const - #endif - --/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ --int dld_preloaded_symbol_count = $count; -- - /* The mapping between symbol names and symbols. */ --struct { -- char *name; -- __ptr_t address; -+const struct { -+ const char *name; -+ lt_ptr_t address; - } --dld_preloaded_symbols[] = -+lt_preloaded_symbols[] = - { - EOF -- sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> conftest.c -- cat <<\EOF >> conftest.c -- {0, (__ptr_t) 0} -+ sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c -+ cat <<\EOF >> conftest.c -+ {0, (lt_ptr_t) 0} - }; - - #ifdef __cplusplus - } - #endif - EOF -- # Now try linking the two files. -- mv conftest.$objext conftestm.$objext -- save_LIBS="$LIBS" -- save_CFLAGS="$CFLAGS" -- LIBS="conftestm.$objext" -- CFLAGS="$CFLAGS$no_builtin_flag" -- if { (eval echo $progname:1487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then -- pipe_works=yes -- else -- echo "$progname: failed program was:" >&5 -- cat conftest.c >&5 -- fi -- LIBS="$save_LIBS" -+ # Now try linking the two files. -+ mv conftest.$objext conftstm.$objext -+ save_LIBS="$LIBS" -+ save_CFLAGS="$CFLAGS" -+ LIBS="conftstm.$objext" -+ CFLAGS="$CFLAGS$no_builtin_flag" -+ if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then -+ pipe_works=yes -+ else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.c >&5 -+ fi -+ LIBS="$save_LIBS" -+ else -+ echo "cannot find nm_test_func in $nlist" >&5 -+ fi - else -- echo "cannot find nm_test_func in $nlist" >&5 -+ echo "cannot find nm_test_var in $nlist" >&5 - fi - else -- echo "cannot find nm_test_var in $nlist" >&5 -+ echo "cannot run $global_symbol_pipe" >&5 - fi - else -- echo "cannot run $global_symbol_pipe" >&5 -+ echo "$progname: failed program was:" >&5 -+ cat conftest.c >&5 - fi -+ $rm conftest* conftst* -+ -+ # Do not use the global_symbol_pipe unless it works. -+ if test "$pipe_works" = yes; then -+ break -+ else -+ global_symbol_pipe= -+ fi -+done -+if test "$pipe_works" = yes; then -+ echo "${ac_t}ok" 1>&6 - else -- echo "$progname: failed program was:" >&5 -- cat conftest.c >&5 -+ echo "${ac_t}failed" 1>&6 - fi --$rm conftest* - --# Do not use the global_symbol_pipe unless it works. --echo "$ac_t$pipe_works" 1>&6 --test "$pipe_works" = yes || global_symbol_pipe= -+if test -z "$global_symbol_pipe"; then -+ global_symbol_to_cdecl= -+fi - - # Check hardcoding attributes. - echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 -@@ -1517,10 +1752,12 @@ - test -n "$runpath_var"; then - - # We can hardcode non-existant directories. -- if test "$hardcode_direct" != no && \ -- test "$hardcode_minus_L" != no && \ -- test "$hardcode_shlibpath_var" != no; then -- -+ if test "$hardcode_direct" != no && -+ # If the only mechanism to avoid hardcoding is shlibpath_var, we -+ # have to relink, otherwise we might link with an installed library -+ # when we should be linking with a yet-to-be-installed one -+ ## test "$hardcode_shlibpath_var" != no && -+ test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else -@@ -1552,26 +1789,27 @@ - finish_cmds= - finish_eval= - shlibpath_var= -+shlibpath_overrides_runpath=unknown - version_type=none - dynamic_linker="$host_os ld.so" --sys_lib_search_path="/lib /usr/lib /usr/local/lib" --check_shared_deplibs_method='none' -+sys_lib_dlsearch_path_spec="/lib /usr/lib" -+sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -+file_magic_cmd= -+file_magic_test_file= -+deplibs_check_method='unknown' - # Need to set the preceding variable on all platforms that support - # interlibrary dependencies. - # 'none' -- dependencies not supported. -+# `unknown' -- same as none, but documents that we really don't know. - # 'pass_all' -- all dependencies passed with no checks. - # 'test_compile' -- check by making test program. --# 'file_regex' -- check by looking for filenames that look like the shared --# library in the library path. --# 'file_magic [regex]' -- check by looking for files in library path which --# responds to the "file" command with a given regex. This is actually a --# superset of the file_regex command. If you have file on your system, you'll --# want to use this instead. --# Notes: regexes are run through expr. -- -+# 'file_magic [regex]' -- check by looking for files in library path -+# which responds to the $file_magic_cmd with a given egrep regex. -+# If you have `file' or equivalent on your system and you're not sure -+# whether `pass_all' will *always* work, you probably want this one. - echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 - case "$host_os" in --aix3* | aix4*) -+aix3*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix $libname.a' - shlibpath_var=LIBPATH -@@ -1580,44 +1818,111 @@ - soname_spec='${libname}${release}.so$major' - ;; - -+aix4*) -+ version_type=linux -+ # AIX has no versioning support, so currently we can not hardcode correct -+ # soname into executable. Probably we can add versioning support to -+ # collect2, so additional links can be useful in future. -+ # We preserve .a as extension for shared libraries though AIX4.2 -+ # and later linker supports .so -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a' -+ shlibpath_var=LIBPATH -+ deplibs_check_method=pass_all -+ ;; -+ - amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' - ;; - -+beos*) -+ library_names_spec='${libname}.so' -+ dynamic_linker="$host_os ld.so" -+ shlibpath_var=LIBRARY_PATH -+ deplibs_check_method=pass_all -+ lt_cv_dlopen="load_add_on" -+ lt_cv_dlopen_libs= -+ lt_cv_dlopen_self=yes -+ ;; -+ - bsdi4*) - version_type=linux -- library_names_spec='${libname}.so.$major ${libname}.so' -- soname_spec='${libname}.so' -- finish_cmds='PATH="$PATH:/sbin" ldconfig $libdir' -+ need_version=no -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -+ soname_spec='${libname}${release}.so$major' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH -+ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=/shlib/libc.so -+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" -+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" -+ export_dynamic_flag_spec=-rdynamic -+ # the default ld.so.conf also contains /usr/contrib/lib and -+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow -+ # libtool to hard-code these into programs - ;; - --cygwin32* | mingw32*) -+cygwin* | mingw*) - version_type=windows -+ need_version=no -+ need_lib_prefix=no - if test "$with_gcc" = yes; then - library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a' - else - library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' - fi - dynamic_linker='Win32 ld.exe' -- libname_spec='$name' -+ deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' -+ file_magic_cmd='${OBJDUMP} -f' -+ # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH -+ lt_cv_dlopen="LoadLibrary" -+ lt_cv_dlopen_libs= - ;; - --freebsd2* | freebsd3*) -+freebsd1*) -+ dynamic_linker=no -+ ;; -+ -+freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - version_type=freebsd-$objformat -- library_names_spec='${libname}${release}.so$versuffix $libname.so' -- finish_cmds='PATH="$PATH:/sbin" OBJFORMAT="$objformat" ldconfig -m $libdir' -+ case "$version_type" in -+ freebsd-elf*) -+ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=`echo /usr/lib/libc.so*` -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' -+ need_version=no -+ need_lib_prefix=no -+ ;; -+ freebsd-*) -+ deplibs_check_method=unknown -+ library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' -+ need_version=yes -+ ;; -+ esac - shlibpath_var=LD_LIBRARY_PATH -+ case "$host_os" in -+ freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*) -+ shlibpath_overrides_runpath=yes -+ ;; -+ *) # from 3.2 on -+ shlibpath_overrides_runpath=no -+ ;; -+ esac - ;; - - gnu*) - version_type=linux -- library_names_spec='${libname}${release}.so$versuffix ${libname}.so' -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' -+ soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH -+ deplibs_check_method=pass_all - ;; - - hpux9* | hpux10* | hpux11*) -@@ -1625,25 +1930,52 @@ - # link against other versions. - dynamic_linker="$host_os dld.sl" - version_type=sunos -+ need_lib_prefix=no -+ need_version=no - shlibpath_var=SHLIB_PATH -+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' - soname_spec='${libname}${release}.sl$major' - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' -+ case "$host_os" in -+ hpux10.20*) -+ # TODO: Does this work for hpux-11 too? -+ deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=/usr/lib/libc.sl -+ ;; -+ esac - ;; - --irix5*) -- version_type=osf -- soname_spec='${libname}${release}.so' -- library_names_spec='${libname}${release}.so$versuffix $libname.so' -- shlibpath_var=LD_LIBRARY_PATH -- ;; -- --irix6*) -- version_type=osf -- soname_spec='${libname}${release}.so' -- library_names_spec='${libname}${release}.so$versuffix $libname.so' -- shlibpath_var=LD_LIBRARYN32_PATH -+irix5* | irix6*) -+ version_type=irix -+ need_lib_prefix=no -+ need_version=no -+ soname_spec='${libname}${release}.so.$major' -+ library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so' -+ case "$host_os" in -+ irix5*) -+ libsuff= shlibsuff= -+ # this will be overridden with pass_all, but let us keep it just in case -+ deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" -+ ;; -+ *) -+ case "$LD" in # libtool.m4 will add one of these switches to LD -+ *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; -+ *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; -+ *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; -+ *) libsuff= shlibsuff= libmagic=never-match;; -+ esac -+ ;; -+ esac -+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" -+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=`echo /lib${libsuff}/libc.so*` -+ deplibs_check_method='pass_all' - ;; - - # No shared lib support for Linux oldld, aout, or coff. -@@ -1654,12 +1986,14 @@ - # This must be Linux ELF. - linux-gnu*) - version_type=linux -+ need_lib_prefix=no -+ need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH -- check_shared_deplibs_method='file_magic ELF 32-bit LSB shared object' -- sys_lib_search_path="/lib /usr/lib /usr/local/lib `echo $LD_LIBRARY_PATH | sed -e 's/:/ /g'`" -+ shlibpath_overrides_runpath=no -+ deplibs_check_method=pass_all - - if test -f /lib/ld.so.1; then - dynamic_linker='GNU ld.so' -@@ -1672,26 +2006,60 @@ - fi - ;; - --netbsd* | openbsd*) -+netbsd*) -+ version_type=sunos -+ if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then -+ library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' -+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' -+ dynamic_linker='NetBSD (a.out) ld.so' -+ else -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' -+ soname_spec='${libname}${release}.so$major' -+ dynamic_linker='NetBSD ld.elf_so' -+ fi -+ shlibpath_var=LD_LIBRARY_PATH -+ ;; -+ -+openbsd*) - version_type=sunos -- library_names_spec='${libname}${release}.so$versuffix' -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ need_version=no -+ fi -+ library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - ;; - - os2*) - libname_spec='$name' -+ need_lib_prefix=no - library_names_spec='$libname.dll $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - --osf3* | osf4*) -+osf3* | osf4* | osf5*) - version_type=osf -+ need_version=no - soname_spec='${libname}${release}.so' -- library_names_spec='${libname}${release}.so$versuffix $libname.so' -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' - shlibpath_var=LD_LIBRARY_PATH -- check_shared_deplibs_method='pass_all' -+ # this will be overridden with pass_all, but let us keep it just in case -+ deplibs_check_method='file_magic COFF format alpha shared library' -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=/shlib/libc.so -+ deplibs_check_method='pass_all' -+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" -+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" -+ ;; -+ -+rhapsody*) -+ version_type=sunos -+ library_names_spec='${libname}.so' -+ soname_spec='${libname}.so' -+ shlibpath_var=DYLD_LIBRARY_PATH -+ deplibs_check_method=pass_all - ;; - - sco3.2v5*) -@@ -1703,11 +2071,17 @@ - - solaris*) - version_type=linux -+ need_lib_prefix=no -+ need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' -+ deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib" -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=/lib/libc.so - ;; - - sunos4*) -@@ -1715,29 +2089,63 @@ - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=yes -+ if test "$with_gnu_ld" = yes; then -+ need_lib_prefix=no -+ fi -+ need_version=yes - ;; - --sysv4.2uw2*) -+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH -+ case "$host_vendor" in -+ sequent) -+ file_magic_cmd='/bin/file' -+ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' -+ ;; -+ ncr) -+ deplibs_check_method='pass_all' -+ ;; -+ motorola) -+ need_lib_prefix=no -+ need_version=no -+ shlibpath_overrides_runpath=no -+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' -+ deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' -+ file_magic_cmd=/usr/bin/file -+ file_magic_test_file=`echo /usr/lib/libc.so*` -+ ;; -+ esac - ;; - - uts4*) - version_type=linux -- library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major $libname.so' -- soname_spec='${libname}${release}.so.$major' -+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' -+ soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - - dgux*) - version_type=linux -+ need_lib_prefix=no -+ need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -+sysv4*MP*) -+ if test -d /usr/nec ;then -+ version_type=linux -+ library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' -+ soname_spec='$libname.so.$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ fi -+ ;; -+ - *) - dynamic_linker=no - ;; -@@ -1748,19 +2156,58 @@ - # Report the final consequences. - echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 - -+# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in -+# configure.in, otherwise build static only libraries. -+case "$host_os" in -+cygwin* | mingw* | os2*) -+ if test x$can_build_shared = xyes; then -+ test x$enable_win32_dll = xno && can_build_shared=no -+ echo "checking if package supports dlls... $can_build_shared" 1>&6 -+ fi -+;; -+esac -+ -+if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then -+ case "$deplibs_check_method" in -+ "file_magic "*) -+ file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" -+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | -+ egrep "$file_magic_regex" > /dev/null; then -+ : -+ else -+ cat <&2 -+ -+*** Warning: the command libtool uses to detect shared libraries, -+*** $file_magic_cmd, produces output that libtool cannot recognize. -+*** The result is that libtool may fail to recognize shared libraries -+*** as such. This will affect the creation of libtool libraries that -+*** depend on shared libraries, but programs linked with such libtool -+*** libraries will work regardless of this problem. Nevertheless, you -+*** may want to report the problem to your system manager and/or to -+*** bug-libtool@gnu.org -+ -+EOF -+ fi ;; -+ esac -+fi -+ - echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case "$host_os" in --aix*) -+aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; -+ -+aix4*) -+ test "$enable_shared" = yes && enable_static=no -+ ;; - esac - - echo "$ac_t$enable_shared" 1>&6 -@@ -1770,6 +2217,15 @@ - - echo "checking whether to build static libraries... $enable_static" 1>&6 - -+if test "$hardcode_action" = relink; then -+ # Fast installation is not supported -+ enable_fast_install=no -+elif test "$shlibpath_overrides_runpath" = yes || -+ test "$enable_shared" = no; then -+ # Fast installation is not necessary -+ enable_fast_install=needless -+fi -+ - echo $ac_n "checking for objdir... $ac_c" 1>&6 - rm -f .libs 2>/dev/null - mkdir .libs 2>/dev/null -@@ -1782,6 +2238,449 @@ - rmdir .libs 2>/dev/null - echo "$ac_t$objdir" 1>&6 - -+if test "x$enable_dlopen" != xyes; then -+ enable_dlopen=unknown -+ enable_dlopen_self=unknown -+ enable_dlopen_self_static=unknown -+else -+if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then -+ lt_cv_dlopen=no lt_cv_dlopen_libs= -+echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -+echo "$progname:2248: checking for dlopen in -ldl" >&5 -+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` -+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ ac_save_LIBS="$LIBS" -+LIBS="-ldl $LIBS" -+cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then -+ rm -rf conftest* -+ eval "ac_cv_lib_$ac_lib_var=yes" -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -rf conftest* -+ eval "ac_cv_lib_$ac_lib_var=no" -+fi -+rm -f conftest* -+LIBS="$ac_save_LIBS" -+ -+fi -+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then -+ echo "$ac_t""yes" 1>&6 -+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -+else -+ echo "$ac_t""no" 1>&6 -+echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -+echo "$progname:2288: checking for dlopen" >&5 -+if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ cat > conftest.$ac_ext < -+/* Override any gcc2 internal prototype to avoid an error. */ -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char dlopen(); -+ -+int main() { -+ -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_dlopen) || defined (__stub___dlopen) -+choke me -+#else -+dlopen(); -+#endif -+ -+; return 0; } -+EOF -+if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then -+ rm -rf conftest* -+ eval "ac_cv_func_dlopen=yes" -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -rf conftest* -+ eval "ac_cv_func_dlopen=no" -+fi -+rm -f conftest* -+fi -+if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then -+ echo "$ac_t""yes" 1>&6 -+ lt_cv_dlopen="dlopen" -+else -+ echo "$ac_t""no" 1>&6 -+echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 -+echo "$progname:2335: checking for dld_link in -ldld" >&5 -+ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` -+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ ac_save_LIBS="$LIBS" -+LIBS="-ldld $LIBS" -+cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then -+ rm -rf conftest* -+ eval "ac_cv_lib_$ac_lib_var=yes" -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -rf conftest* -+ eval "ac_cv_lib_$ac_lib_var=no" -+fi -+rm -f conftest* -+LIBS="$ac_save_LIBS" -+ -+fi -+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then -+ echo "$ac_t""yes" 1>&6 -+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" -+else -+ echo "$ac_t""no" 1>&6 -+echo $ac_n "checking for shl_load""... $ac_c" 1>&6 -+echo "$progname:2375: checking for shl_load" >&5 -+if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ cat > conftest.$ac_ext < -+/* Override any gcc2 internal prototype to avoid an error. */ -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char shl_load(); -+ -+int main() { -+ -+/* The GNU C library defines this for functions which it implements -+ to always fail with ENOSYS. Some functions are actually named -+ something starting with __ and the normal name is an alias. */ -+#if defined (__stub_shl_load) || defined (__stub___shl_load) -+choke me -+#else -+shl_load(); -+#endif -+ -+; return 0; } -+EOF -+if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then -+ rm -rf conftest* -+ eval "ac_cv_func_shl_load=yes" -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -rf conftest* -+ eval "ac_cv_func_shl_load=no" -+fi -+rm -f conftest* -+fi -+ -+if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then -+ echo "$ac_t""yes" 1>&6 -+ lt_cv_dlopen="shl_load" -+else -+ echo "$ac_t""no" 1>&6 -+echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 -+echo "$progname:2423: checking for shl_load in -ldld" >&5 -+ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` -+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ ac_save_LIBS="$LIBS" -+LIBS="-ldld $LIBS" -+cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then -+ rm -rf conftest* -+ eval "ac_cv_lib_$ac_lib_var=yes" -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -rf conftest* -+ eval "ac_cv_lib_$ac_lib_var=no" -+fi -+rm -f conftest* -+LIBS="$ac_save_LIBS" -+ -+fi -+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then -+ echo "$ac_t""yes" 1>&6 -+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" -+else -+ echo "$ac_t""no" 1>&6 -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+ -+fi -+ -+fi -+ -+ if test "x$lt_cv_dlopen" != xno; then -+ enable_dlopen=yes -+ fi -+ -+ case "$lt_cv_dlopen" in -+ dlopen) -+for ac_hdr in dlfcn.h; do -+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -+echo "$progname:2488: checking for $ac_hdr" >&5 -+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ cat > conftest.$ac_ext < -+int fnord = 0; -+EOF -+ac_try="$ac_compile >/dev/null 2>conftest.out" -+{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -+if test -z "$ac_err"; then -+ rm -rf conftest* -+ eval "ac_cv_header_$ac_safe=yes" -+else -+ echo "$ac_err" >&5 -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -rf conftest* -+ eval "ac_cv_header_$ac_safe=no" -+fi -+rm -f conftest* -+fi -+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then -+ echo "$ac_t""yes" 1>&6 -+else -+ echo "$ac_t""no" 1>&6 -+fi -+done -+ -+ if test "x$ac_cv_header_dlfcn_h" = xyes; then -+ CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" -+ fi -+ eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" -+ LIBS="$lt_cv_dlopen_libs $LIBS" -+ -+ echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 -+echo "$progname:2526: checking whether a program can dlopen itself" >&5 -+if test "${lt_cv_dlopen_self+set}" = set; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ if test "$cross_compiling" = yes; then -+ lt_cv_dlopen_self=cross -+ else -+ cat > conftest.c < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LTDL_GLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LTDL_GLOBAL DL_GLOBAL -+# else -+# define LTDL_GLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LTDL_LAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LTDL_LAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LTDL_LAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LTDL_LAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LTDL_LAZY_OR_NOW DL_NOW -+# else -+# define LTDL_LAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+fnord() { int i=42;} -+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); -+ if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); -+ if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } -+ -+EOF -+if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -+then -+ lt_cv_dlopen_self=yes -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -fr conftest* -+ lt_cv_dlopen_self=no -+fi -+rm -fr conftest* -+fi -+ -+fi -+ -+echo "$ac_t""$lt_cv_dlopen_self" 1>&6 -+ -+ if test "$lt_cv_dlopen_self" = yes; then -+ LDFLAGS="$LDFLAGS $link_static_flag" -+ echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 -+echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5 -+if test "${lt_cv_dlopen_self_static+set}" = set; then -+ echo $ac_n "(cached) $ac_c" 1>&6 -+else -+ if test "$cross_compiling" = yes; then -+ lt_cv_dlopen_self_static=cross -+ else -+ cat > conftest.c < -+#endif -+ -+#include -+ -+#ifdef RTLD_GLOBAL -+# define LTDL_GLOBAL RTLD_GLOBAL -+#else -+# ifdef DL_GLOBAL -+# define LTDL_GLOBAL DL_GLOBAL -+# else -+# define LTDL_GLOBAL 0 -+# endif -+#endif -+ -+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we -+ find out it does not work in some platform. */ -+#ifndef LTDL_LAZY_OR_NOW -+# ifdef RTLD_LAZY -+# define LTDL_LAZY_OR_NOW RTLD_LAZY -+# else -+# ifdef DL_LAZY -+# define LTDL_LAZY_OR_NOW DL_LAZY -+# else -+# ifdef RTLD_NOW -+# define LTDL_LAZY_OR_NOW RTLD_NOW -+# else -+# ifdef DL_NOW -+# define LTDL_LAZY_OR_NOW DL_NOW -+# else -+# define LTDL_LAZY_OR_NOW 0 -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+fnord() { int i=42;} -+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); -+ if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); -+ if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } -+ -+EOF -+if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null -+then -+ lt_cv_dlopen_self_static=yes -+else -+ echo "$progname: failed program was:" >&5 -+ cat conftest.$ac_ext >&5 -+ rm -fr conftest* -+ lt_cv_dlopen_self_static=no -+fi -+rm -fr conftest* -+fi -+ -+fi -+ -+echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 -+fi -+ ;; -+ esac -+ -+ case "$lt_cv_dlopen_self" in -+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; -+ *) enable_dlopen_self=unknown ;; -+ esac -+ -+ case "$lt_cv_dlopen_self_static" in -+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; -+ *) enable_dlopen_self_static=unknown ;; -+ esac -+fi -+ - # Copy echo and quote the copy, instead of the original, because it is - # used later. - ltecho="$echo" -@@ -1790,30 +2689,36 @@ - fi - LTSHELL="$SHELL" - -+LTCONFIG_VERSION="$VERSION" -+ - # Only quote variables if we're using ltmain.sh. - case "$ltmain" in - *.sh) - # Now quote all the things that may contain metacharacters. -- for var in ltecho old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \ -- old_LN_S old_DLLTOOL old_AS AR CC LD LN_S NM LTSHELL VERSION \ -+ for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \ -+ old_LD old_LDFLAGS old_LIBS \ -+ old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \ -+ AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ - reload_flag reload_cmds wl \ - pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ -- whole_archive_flag_spec libname_spec library_names_spec soname_spec \ -+ thread_safe_flag_spec whole_archive_flag_spec libname_spec \ -+ library_names_spec soname_spec \ - RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ -- old_postuninstall_cmds archive_cmds archive_sym_cmds postinstall_cmds postuninstall_cmds \ -- check_shared_deplibs_method allow_undefined_flag no_undefined_flag \ -- finish_cmds finish_eval global_symbol_pipe \ -- hardcode_libdir_flag_spec hardcode_libdir_separator sys_lib_search_path \ -- compiler_c_o compiler_o_lo need_locks; do -+ old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \ -+ file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \ -+ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ -+ hardcode_libdir_flag_spec hardcode_libdir_separator \ -+ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ -+ compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do - - case "$var" in - reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ -- archive_cmds | archive_sym_cmds | \ -+ export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ - postinstall_cmds | postuninstall_cmds | \ -- finish_cmds | sys_lib_search_path) -+ finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. -- eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\"\`\\\"" -+ eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" -@@ -1823,8 +2728,7 @@ - - case "$ltecho" in - *'\$0 --fallback-echo"') -- ltecho=`$echo "X$ltecho" | -- $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` -+ ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -@@ -1835,11 +2739,11 @@ - #! $SHELL - - # `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. --# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION) -+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) - # NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. - # --# Copyright (C) 1996-1998 Free Software Foundation, Inc. --# Gordon Matzigkeit , 1996 -+# Copyright (C) 1996-1999 Free Software Foundation, Inc. -+# Originally by Gordon Matzigkeit , 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 -@@ -1865,7 +2769,7 @@ - - # The HP-UX ksh and POSIX shell print the target directory to stdout - # if CDPATH is set. --if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi -+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - - ### BEGIN LIBTOOL CONFIG - EOF -@@ -1874,8 +2778,9 @@ - - *) - # Double-quote the variables that need it (for aesthetics). -- for var in old_CC old_CFLAGS old_CPPFLAGS old_LD old_NM old_RANLIB \ -- old_LN_S old_DLLTOOL old_AS; do -+ for var in old_CC old_CFLAGS old_CPPFLAGS \ -+ old_LD old_LDFLAGS old_LIBS \ -+ old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do - eval "$var=\\\"\$var\\\"" - done - -@@ -1886,7 +2791,7 @@ - $rm "$cfgfile" - cat < "$cfgfile" - # `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file. --# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION) -+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) - EOF - ;; - esac -@@ -1895,15 +2800,16 @@ - # Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - # - # CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\ --# LD=$old_LD NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ --# DLLTOOL="$old_DLLTOOL" AS="$old_AS" \\ -+# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\ -+# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ -+# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\ - # $0$ltconfig_args - # - # Compiler and other test output produced by $progname, useful for - # debugging $progname, is in ./config.log if it exists. - - # The version of $progname that generated this script. --LTCONFIG_VERSION=$VERSION -+LTCONFIG_VERSION=$LTCONFIG_VERSION - - # Shell to use when invoking shell scripts. - SHELL=$LTSHELL -@@ -1914,6 +2820,9 @@ - # Whether or not to build static libraries. - build_old_libs=$enable_static - -+# Whether or not to optimize for fast installation. -+fast_install=$enable_fast_install -+ - # The host system. - host_alias=$host_alias - host=$host -@@ -1936,10 +2845,13 @@ - # A BSD-compatible nm program. - NM=$NM - --# Used on cygwin32: DLL creation program. -+# Used on cygwin: DLL creation program. - DLLTOOL="$DLLTOOL" - --# Used on cygwin32: assembler. -+# Used on cygwin: object dumper. -+OBJDUMP="$OBJDUMP" -+ -+# Used on cygwin: assembler. - AS="$AS" - - # The name of the directory that contains temporary libtool files. -@@ -1958,10 +2870,13 @@ - # Old archive suffix (normally "a"). - libext="$libext" - -+# Executable file suffix (normally ""). -+exeext="$exeext" -+ - # Additional compiler flags for building library objects. - pic_flag=$pic_flag - --# Does compiler simultaneously support -c and -o options -+# Does compiler simultaneously support -c and -o options? - compiler_c_o=$compiler_c_o - - # Can we write directly to a .lo ? -@@ -1970,6 +2885,21 @@ - # Must we lock files when doing compilation ? - need_locks=$need_locks - -+# Do we need the lib prefix for modules? -+need_lib_prefix=$need_lib_prefix -+ -+# Do we need a version for libraries? -+need_version=$need_version -+ -+# Whether dlopen is supported. -+dlopen=$enable_dlopen -+ -+# Whether dlopen of programs is supported. -+dlopen_self=$enable_dlopen_self -+ -+# Whether dlopen of statically linked programs is supported. -+dlopen_self_static=$enable_dlopen_self_static -+ - # Compiler flag to prevent dynamic linking. - link_static_flag=$link_static_flag - -@@ -1982,6 +2912,9 @@ - # Compiler flag to generate shared objects directly from archives. - whole_archive_flag_spec=$whole_archive_flag_spec - -+# Compiler flag to generate thread-safe objects. -+thread_safe_flag_spec=$thread_safe_flag_spec -+ - # Library versioning type. - version_type=$version_type - -@@ -2006,12 +2939,15 @@ - - # Commands used to build and install a shared archive. - archive_cmds=$archive_cmds --archive_sym_cmds=$archive_sym_cmds -+archive_expsym_cmds=$archive_expsym_cmds - postinstall_cmds=$postinstall_cmds - postuninstall_cmds=$postuninstall_cmds - - # Method to check whether dependent libraries are shared objects. --check_shared_deplibs_method=$check_shared_deplibs_method -+deplibs_check_method=$deplibs_check_method -+ -+# Command to use when deplibs_check_method == file_magic. -+file_magic_cmd=$file_magic_cmd - - # Flag that allows shared libraries with undefined symbols to be built. - allow_undefined_flag=$allow_undefined_flag -@@ -2028,12 +2964,18 @@ - # Take the output of nm and produce a listing of raw symbols and C names. - global_symbol_pipe=$global_symbol_pipe - -+# Transform the output of nm in a proper C declaration -+global_symbol_to_cdecl=$global_symbol_to_cdecl -+ - # This is the shared library runtime path variable. - runpath_var=$runpath_var - - # This is the shared library path variable. - shlibpath_var=$shlibpath_var - -+# Is shlibpath searched before the hard-coded library search path? -+shlibpath_overrides_runpath=$shlibpath_overrides_runpath -+ - # How to hardcode a shared library path into an executable. - hardcode_action=$hardcode_action - -@@ -2056,11 +2998,27 @@ - # the resulting binary. - hardcode_shlibpath_var=$hardcode_shlibpath_var - --# System search path for libraries --sys_lib_search_path=$sys_lib_search_path -+# Compile-time system search path for libraries -+sys_lib_search_path_spec=$sys_lib_search_path_spec -+ -+# Run-time system search path for libraries -+sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec - - # Fix the shell variable \$srcfile for the compiler. - fix_srcfile_path="$fix_srcfile_path" -+ -+# Set to yes if exported symbols are required. -+always_export_symbols=$always_export_symbols -+ -+# The commands to list exported symbols. -+export_symbols_cmds=$export_symbols_cmds -+ -+# Symbols that should not be listed in the preloaded symbols. -+exclude_expsyms=$exclude_expsyms -+ -+# Symbols that must always be exported. -+include_expsyms=$include_expsyms -+ - EOF - - case "$ltmain" in -@@ -2074,7 +3032,7 @@ - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. --if test "${COLLECT_NAMES+set}" != set; then -+if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi -@@ -2083,7 +3041,11 @@ - esac - - # Append the ltmain.sh script. -- cat "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1) -+ sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1) -+ # We use sed instead of cat because bash on DJGPP gets confused if -+ # if finds mixed CR/LF and LF-only lines. Since sed operates in -+ # text mode, it properly converts lines to CR/LF. This bash problem -+ # is reportedly fixed, but why not run on old versions too? - - chmod +x "$ofile" - ;; -@@ -2093,6 +3055,58 @@ - echo "FIXME: would compile $ltmain" - ;; - esac -+ -+test -n "$cache_file" || exit 0 -+ -+# AC_CACHE_SAVE -+trap '' 1 2 15 -+cat > confcache <<\EOF -+# This file is a shell script that caches the results of configure -+# tests run on this system so they can be shared between configure -+# scripts and configure runs. It is not useful on other systems. -+# If it contains results you don't want to keep, you may remove or edit it. -+# -+# By default, configure uses ./config.cache as the cache file, -+# creating it if it does not exist already. You can give configure -+# the --cache-file=FILE option to use a different cache file; that is -+# what configure does when it calls configure scripts in -+# subdirectories, so they share the cache. -+# Giving --cache-file=/dev/null disables caching, for debugging configure. -+# config.status only pays attention to the cache file if you give it the -+# --recheck option to rerun configure. -+# -+EOF -+# The following way of writing the cache mishandles newlines in values, -+# but we know of no workaround that is simple, portable, and efficient. -+# So, don't put newlines in cache variables' values. -+# Ultrix sh set writes to stderr and can't be redirected directly, -+# and sets the high bit in the cache file unless we assign to the vars. -+(set) 2>&1 | -+ case `(ac_space=' '; set | grep ac_space) 2>&1` in -+ *ac_space=\ *) -+ # `set' does not quote correctly, so add quotes (double-quote substitution -+ # turns \\\\ into \\, and sed turns \\ into \). -+ sed -n \ -+ -e "s/'/'\\\\''/g" \ -+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" -+ ;; -+ *) -+ # `set' quotes correctly as required by POSIX, so do not add quotes. -+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' -+ ;; -+ esac >> confcache -+if cmp -s $cache_file confcache; then -+ : -+else -+ if test -w $cache_file; then -+ echo "updating cache $cache_file" -+ cat confcache > $cache_file -+ else -+ echo "not updating unwritable cache $cache_file" -+ fi -+fi -+rm -f confcache -+ - exit 0 - - # Local Variables: ---- gsmlib-1.10.orig/scripts/config.guess -+++ gsmlib-1.10/scripts/config.guess -@@ -1,9 +1,10 @@ - #! /bin/sh - # Attempt to guess a canonical system name. --# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 - # Free Software Foundation, Inc. - --timestamp='2001-09-04' -+timestamp='2008-01-23' - - # This file 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 +18,18 @@ - # - # 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. -+# 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. - --# Written by Per Bothner . --# Please send patches to . -+ -+# Originally written by Per Bothner . -+# Please send patches to . Submit a context -+# diff and a properly formatted ChangeLog entry. - # - # This script attempts to guess a canonical system name similar to - # config.sub. If it succeeds, it prints the system name on stdout, and -@@ -52,8 +56,8 @@ - GNU config.guess ($timestamp) - - Originally written by Per Bothner. --Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 --Free Software Foundation, Inc. -+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -@@ -65,11 +69,11 @@ - while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) -- echo "$timestamp" ; exit 0 ;; -+ echo "$timestamp" ; exit ;; - --version | -v ) -- echo "$version" ; exit 0 ;; -+ echo "$version" ; exit ;; - --help | --h* | -h ) -- echo "$usage"; exit 0 ;; -+ echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. -@@ -87,30 +91,42 @@ - exit 1 - fi - -+trap 'exit 1' 1 2 15 - --dummy=dummy-$$ --trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 -+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -+# compiler to aid in system detection is discouraged as it requires -+# temporary files to be created and, as you can see below, it is a -+# headache to deal with in a portable fashion. - --# CC_FOR_BUILD -- compiler used by this script. - # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still - # use `HOST_CC' if defined, but it is deprecated. - --set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in -- ,,) echo "int dummy(){}" > $dummy.c ; -- for c in cc gcc c89 ; do -- ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; -- if test $? = 0 ; then -+# Portable tmp directory creation inspired by the Autoconf team. -+ -+set_cc_for_build=' -+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -+: ${TMPDIR=/tmp} ; -+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || -+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || -+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || -+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -+dummy=$tmp/dummy ; -+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -+case $CC_FOR_BUILD,$HOST_CC,$CC in -+ ,,) echo "int x;" > $dummy.c ; -+ for c in cc gcc c89 c99 ; do -+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; -- rm -f $dummy.c $dummy.o $dummy.rel ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; --esac' -+esac ; set_cc_for_build= ;' - - # This is needed to find uname on a Pyramid OSx when run in the BSD universe. - # (ghazi@noc.rutgers.edu 1994-08-24) -@@ -127,29 +143,31 @@ - - case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) -- # Netbsd (nbsd) targets should (where applicable) match one or -+ # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. -- # Determine the machine/vendor (is the vendor relevant). -- case "${UNAME_MACHINE}" in -- amiga) machine=m68k-unknown ;; -- arm32) machine=arm-unknown ;; -- atari*) machine=m68k-atari ;; -- sun3*) machine=m68k-sun ;; -- mac68k) machine=m68k-apple ;; -- macppc) machine=powerpc-apple ;; -- hp3[0-9][05]) machine=m68k-hp ;; -- ibmrt|romp-ibm) machine=romp-ibm ;; -- *) machine=${UNAME_MACHINE}-unknown ;; -+ # -+ # Note: NetBSD doesn't particularly care about the vendor -+ # portion of the name. We always set it to "unknown". -+ sysctl="sysctl -n hw.machine_arch" -+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ -+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` -+ case "${UNAME_MACHINE_ARCH}" in -+ armeb) machine=armeb-unknown ;; -+ arm*) machine=arm-unknown ;; -+ sh3el) machine=shl-unknown ;; -+ sh3eb) machine=sh-unknown ;; -+ sh5el) machine=sh5le-unknown ;; -+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. -- case "${UNAME_MACHINE}" in -- i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) -+ case "${UNAME_MACHINE_ARCH}" in -+ arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null -@@ -166,120 +184,128 @@ - ;; - esac - # The OS release -- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` -+ # Debian GNU/NetBSD machines have a different userland, and -+ # thus, need a distinct triplet. However, they do not need -+ # kernel version information, so it can be replaced with a -+ # suitable tag, in the style of linux-gnu. -+ case "${UNAME_VERSION}" in -+ Debian*) -+ release='-gnu' -+ ;; -+ *) -+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` -+ ;; -+ esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" -- exit 0 ;; -+ exit ;; -+ *:OpenBSD:*:*) -+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` -+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} -+ exit ;; -+ *:ekkoBSD:*:*) -+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} -+ exit ;; -+ *:SolidBSD:*:*) -+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} -+ exit ;; -+ macppc:MirBSD:*:*) -+ echo powerpc-unknown-mirbsd${UNAME_RELEASE} -+ exit ;; -+ *:MirBSD:*:*) -+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} -+ exit ;; - alpha:OSF1:*:*) -- if test $UNAME_RELEASE = "V4.0"; then -+ case $UNAME_RELEASE in -+ *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` -- fi -+ ;; -+ *5.*) -+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` -+ ;; -+ esac -+ # According to Compaq, /usr/sbin/psrinfo has been available on -+ # OSF/1 and Tru64 systems produced since 1995. I hope that -+ # covers most systems running today. This code pipes the CPU -+ # types through head -n 1, so we only detect the type of CPU 0. -+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` -+ case "$ALPHA_CPU_TYPE" in -+ "EV4 (21064)") -+ UNAME_MACHINE="alpha" ;; -+ "EV4.5 (21064)") -+ UNAME_MACHINE="alpha" ;; -+ "LCA4 (21066/21068)") -+ UNAME_MACHINE="alpha" ;; -+ "EV5 (21164)") -+ UNAME_MACHINE="alphaev5" ;; -+ "EV5.6 (21164A)") -+ UNAME_MACHINE="alphaev56" ;; -+ "EV5.6 (21164PC)") -+ UNAME_MACHINE="alphapca56" ;; -+ "EV5.7 (21164PC)") -+ UNAME_MACHINE="alphapca57" ;; -+ "EV6 (21264)") -+ UNAME_MACHINE="alphaev6" ;; -+ "EV6.7 (21264A)") -+ UNAME_MACHINE="alphaev67" ;; -+ "EV6.8CB (21264C)") -+ UNAME_MACHINE="alphaev68" ;; -+ "EV6.8AL (21264B)") -+ UNAME_MACHINE="alphaev68" ;; -+ "EV6.8CX (21264D)") -+ UNAME_MACHINE="alphaev68" ;; -+ "EV6.9A (21264/EV69A)") -+ UNAME_MACHINE="alphaev69" ;; -+ "EV7 (21364)") -+ UNAME_MACHINE="alphaev7" ;; -+ "EV7.9 (21364A)") -+ UNAME_MACHINE="alphaev79" ;; -+ esac -+ # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. -- cat <$dummy.s -- .data --\$Lformat: -- .byte 37,100,45,37,120,10,0 # "%d-%x\n" -- -- .text -- .globl main -- .align 4 -- .ent main --main: -- .frame \$30,16,\$26,0 -- ldgp \$29,0(\$27) -- .prologue 1 -- .long 0x47e03d80 # implver \$0 -- lda \$2,-1 -- .long 0x47e20c21 # amask \$2,\$1 -- lda \$16,\$Lformat -- mov \$0,\$17 -- not \$1,\$18 -- jsr \$26,printf -- ldgp \$29,0(\$26) -- mov 0,\$16 -- jsr \$26,exit -- .end main --EOF -- eval $set_cc_for_build -- $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null -- if test "$?" = 0 ; then -- case `./$dummy` in -- 0-0) -- UNAME_MACHINE="alpha" -- ;; -- 1-0) -- UNAME_MACHINE="alphaev5" -- ;; -- 1-1) -- UNAME_MACHINE="alphaev56" -- ;; -- 1-101) -- UNAME_MACHINE="alphapca56" -- ;; -- 2-303) -- UNAME_MACHINE="alphaev6" -- ;; -- 2-307) -- UNAME_MACHINE="alphaev67" -- ;; -- 2-1307) -- UNAME_MACHINE="alphaev68" -- ;; -- esac -- fi -- rm -f $dummy.s $dummy -- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -- exit 0 ;; -+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -+ exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix -- exit 0 ;; -+ exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 -- exit 0 ;; -+ exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 -- exit 0;; -- amiga:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos -- exit 0 ;; -- arc64:OpenBSD:*:*) -- echo mips64el-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- arc:OpenBSD:*:*) -- echo mipsel-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- hkmips:OpenBSD:*:*) -- echo mips-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- pmax:OpenBSD:*:*) -- echo mipsel-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- sgi:OpenBSD:*:*) -- echo mips-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- wgrisc:OpenBSD:*:*) -- echo mipsel-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; -+ *:[Mm]orph[Oo][Ss]:*:*) -+ echo ${UNAME_MACHINE}-unknown-morphos -+ exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition -- exit 0 ;; -+ exit ;; -+ *:z/VM:*:*) -+ echo s390-ibm-zvmoe -+ exit ;; -+ *:OS400:*:*) -+ echo powerpc-ibm-os400 -+ exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} -- exit 0;; -+ exit ;; -+ arm:riscos:*:*|arm:RISCOS:*:*) -+ echo arm-unknown-riscos -+ exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp -- exit 0;; -+ exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then -@@ -287,25 +313,32 @@ - else - echo pyramid-pyramid-bsd - fi -- exit 0 ;; -+ exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 -- exit 0 ;; -+ exit ;; -+ DRS?6000:unix:4.0:6*) -+ echo sparc-icl-nx6 -+ exit ;; -+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) -+ case `/usr/bin/uname -p` in -+ sparc) echo sparc-icl-nx7; exit ;; -+ esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -- i86pc:SunOS:5.*:*) -+ exit ;; -+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) -@@ -314,12 +347,12 @@ - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` -- exit 0 ;; -+ exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - sun*:*:4.2BSD:*) -- UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` -+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) -@@ -329,16 +362,10 @@ - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac -- exit 0 ;; -+ exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} -- exit 0 ;; -- sparc*:NetBSD:*) -- echo `uname -p`-unknown-netbsd${UNAME_RELEASE} -- exit 0 ;; -- atari*:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor -@@ -349,49 +376,40 @@ - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} -- exit 0 ;; -- sun3*:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mac68k:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mvme68k:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mvme88k:OpenBSD:*:*) -- echo m88k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; -+ m68k:machten:*:*) -+ echo m68k-apple-machten${UNAME_RELEASE} -+ exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 -- exit 0 ;; -+ exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -@@ -415,27 +433,33 @@ - exit (-1); - } - EOF -- $CC_FOR_BUILD $dummy.c -o $dummy \ -- && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ -- && rm -f $dummy.c $dummy && exit 0 -- rm -f $dummy.c $dummy -+ $CC_FOR_BUILD -o $dummy $dummy.c && -+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && -+ SYSTEM_NAME=`$dummy $dummyarg` && -+ { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax -- exit 0 ;; -+ exit ;; -+ Motorola:*:4.3:PL8-*) -+ echo powerpc-harris-powermax -+ exit ;; -+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) -+ echo powerpc-harris-powermax -+ exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix -- exit 0 ;; -+ exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 -- exit 0 ;; -+ exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 -- exit 0 ;; -+ exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 -- exit 0 ;; -+ exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` -@@ -451,29 +475,29 @@ - else - echo i586-dg-dgux${UNAME_RELEASE} - fi -- exit 0 ;; -+ exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 -- exit 0 ;; -+ exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 -- exit 0 ;; -+ exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 -- exit 0 ;; -+ exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd -- exit 0 ;; -+ exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` -- exit 0 ;; -+ exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. -- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id -- exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' -+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id -+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix -- exit 0 ;; -+ exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` -@@ -481,7 +505,7 @@ - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} -- exit 0 ;; -+ exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build -@@ -496,17 +520,20 @@ - exit(0); - } - EOF -- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 -- rm -f $dummy.c $dummy -- echo rs6000-ibm-aix3.2.5 -+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` -+ then -+ echo "$SYSTEM_NAME" -+ else -+ echo rs6000-ibm-aix3.2.5 -+ fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi -- exit 0 ;; -- *:AIX:*:[45]) -- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` -+ exit ;; -+ *:AIX:*:[456]) -+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else -@@ -518,38 +545,36 @@ - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} -- exit 0 ;; -+ exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix -- exit 0 ;; -+ exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 -- exit 0 ;; -+ exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to -- exit 0 ;; # report: romp-ibm BSD 4.3 -+ exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx -- exit 0 ;; -+ exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 -- exit 0 ;; -+ exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd -- exit 0 ;; -+ exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 -- exit 0 ;; -+ exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) -- case "${HPUX_REV}" in -- 11.[0-9][0-9]) -- if [ -x /usr/bin/getconf ]; then -- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` -+ if [ -x /usr/bin/getconf ]; then -+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 -@@ -558,13 +583,13 @@ - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; -+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac -- fi ;; -- esac -- if [ "${HP_ARCH}" = "" ]; then -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ fi -+ if [ "${HP_ARCH}" = "" ]; then -+ eval $set_cc_for_build -+ sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include -@@ -597,17 +622,37 @@ - exit (0); - } - EOF -- (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` -- if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi -- rm -f $dummy.c $dummy -- fi ;; -+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` -+ test -z "$HP_ARCH" && HP_ARCH=hppa -+ fi ;; - esac -+ if [ ${HP_ARCH} = "hppa2.0w" ] -+ then -+ eval $set_cc_for_build -+ -+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating -+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler -+ # generating 64-bit code. GNU and HP use different nomenclature: -+ # -+ # $ CC_FOR_BUILD=cc ./config.guess -+ # => hppa2.0w-hp-hpux11.23 -+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess -+ # => hppa64-hp-hpux11.23 -+ -+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | -+ grep __LP64__ >/dev/null -+ then -+ HP_ARCH="hppa2.0w" -+ else -+ HP_ARCH="hppa64" -+ fi -+ fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} -- exit 0 ;; -+ exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} -- exit 0 ;; -+ exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -@@ -635,158 +680,247 @@ - exit (0); - } - EOF -- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 -- rm -f $dummy.c $dummy -+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && -+ { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 -- exit 0 ;; -+ exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd -- exit 0 ;; -+ exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd -- exit 0 ;; -+ exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix -- exit 0 ;; -+ exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf -- exit 0 ;; -+ exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf -- exit 0 ;; -+ exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi -- exit 0 ;; -+ exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites -- exit 0 ;; -- hppa*:OpenBSD:*:*) -- echo hppa-unknown-openbsd -- exit 0 ;; -+ exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd -- exit 0 ;; -+ exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi -- exit 0 ;; -+ exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd -- exit 0 ;; -+ exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd -- exit 0 ;; -+ exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd -- exit 0 ;; -- CRAY*X-MP:*:*:*) -- echo xmp-cray-unicos -- exit 0 ;; -+ exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -- CRAY*T3D:*:*:*) -- echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -- CRAY-2:*:*:*) -- echo cray2-cray-unicos -- exit 0 ;; -+ exit ;; -+ *:UNICOS/mp:*:*) -+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -+ exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -- exit 0 ;; -- hp300:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; -+ 5000:UNIX_System_V:4.*:*) -+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` -+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -+ exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:FreeBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` -- exit 0 ;; -- *:OpenBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` -- exit 0 ;; -+ case ${UNAME_MACHINE} in -+ pc98) -+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; -+ amd64) -+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; -+ *) -+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; -+ esac -+ exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin -- exit 0 ;; -- i*:MINGW*:*) -+ exit ;; -+ *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 -- exit 0 ;; -+ exit ;; -+ i*:windows32*:*) -+ # uname -m includes "-pc" on this system. -+ echo ${UNAME_MACHINE}-mingw32 -+ exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 -- exit 0 ;; -+ exit ;; -+ *:Interix*:[3456]*) -+ case ${UNAME_MACHINE} in -+ x86) -+ echo i586-pc-interix${UNAME_RELEASE} -+ exit ;; -+ EM64T | authenticamd) -+ echo x86_64-unknown-interix${UNAME_RELEASE} -+ exit ;; -+ IA64) -+ echo ia64-unknown-interix${UNAME_RELEASE} -+ exit ;; -+ esac ;; -+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) -+ echo i${UNAME_MACHINE}-pc-mks -+ exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? -- echo i386-pc-interix -- exit 0 ;; -+ echo i586-pc-interix -+ exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin -- exit 0 ;; -+ exit ;; -+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) -+ echo x86_64-unknown-cygwin -+ exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin -- exit 0 ;; -+ exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ exit ;; - *:GNU:*:*) -+ # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` -- exit 0 ;; -+ exit ;; -+ *:GNU/*:*:*) -+ # other systems with GNU libc and userland -+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu -+ exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix -- exit 0 ;; -+ exit ;; - arm*:Linux:*:*) -+ eval $set_cc_for_build -+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_EABI__ -+ then -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ else -+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi -+ fi -+ exit ;; -+ avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ exit ;; -+ cris:Linux:*:*) -+ echo cris-axis-linux-gnu -+ exit ;; -+ crisv32:Linux:*:*) -+ echo crisv32-axis-linux-gnu -+ exit ;; -+ frv:Linux:*:*) -+ echo frv-unknown-linux-gnu -+ exit ;; - ia64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux -- exit 0 ;; -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ exit ;; -+ m32r*:Linux:*:*) -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ exit ;; - mips:Linux:*:*) -- case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in -- big) echo mips-unknown-linux-gnu && exit 0 ;; -- little) echo mipsel-unknown-linux-gnu && exit 0 ;; -- esac -+ eval $set_cc_for_build -+ sed 's/^ //' << EOF >$dummy.c -+ #undef CPU -+ #undef mips -+ #undef mipsel -+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) -+ CPU=mipsel -+ #else -+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) -+ CPU=mips -+ #else -+ CPU= -+ #endif -+ #endif -+EOF -+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' -+ /^CPU/{ -+ s: ::g -+ p -+ }'`" -+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; -+ mips64:Linux:*:*) -+ eval $set_cc_for_build -+ sed 's/^ //' << EOF >$dummy.c -+ #undef CPU -+ #undef mips64 -+ #undef mips64el -+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) -+ CPU=mips64el -+ #else -+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) -+ CPU=mips64 -+ #else -+ CPU= -+ #endif -+ #endif -+EOF -+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' -+ /^CPU/{ -+ s: ::g -+ p -+ }'`" -+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } -+ ;; -+ or32:Linux:*:*) -+ echo or32-unknown-linux-gnu -+ exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu -- exit 0 ;; -+ exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu -- exit 0 ;; -+ exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; -@@ -800,7 +934,7 @@ - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} -- exit 0 ;; -+ exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in -@@ -808,27 +942,37 @@ - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac -- exit 0 ;; -+ exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu -- exit 0 ;; -+ exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux -- exit 0 ;; -+ exit ;; -+ sh64*:Linux:*:*) -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ exit ;; -+ vax:Linux:*:*) -+ echo ${UNAME_MACHINE}-dec-linux-gnu -+ exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu -- exit 0 ;; -+ exit ;; -+ xtensa*:Linux:*:*) -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. -- ld_supported_targets=`cd /; ld --help 2>&1 \ -+ # Set LC_ALL=C to ensure ld outputs messages in English. -+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// -@@ -840,52 +984,58 @@ - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" -- exit 0 ;; -+ exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" -- exit 0 ;; -+ exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" -- exit 0 ;; -+ exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build -- cat >$dummy.c < --#ifdef __cplusplus --#include /* for printf() prototype */ -- int main (int argc, char *argv[]) { --#else -- int main (argc, argv) int argc; char *argv[]; { --#endif --#ifdef __ELF__ --# ifdef __GLIBC__ --# if __GLIBC__ >= 2 -- printf ("%s-pc-linux-gnu\n", argv[1]); --# else -- printf ("%s-pc-linux-gnulibc1\n", argv[1]); --# endif --# else -- printf ("%s-pc-linux-gnulibc1\n", argv[1]); --# endif --#else -- printf ("%s-pc-linux-gnuaout\n", argv[1]); --#endif -- return 0; --} -+ sed 's/^ //' << EOF >$dummy.c -+ #include -+ #ifdef __ELF__ -+ # ifdef __GLIBC__ -+ # if __GLIBC__ >= 2 -+ LIBC=gnu -+ # else -+ LIBC=gnulibc1 -+ # endif -+ # else -+ LIBC=gnulibc1 -+ # endif -+ #else -+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) -+ LIBC=gnu -+ #else -+ LIBC=gnuaout -+ #endif -+ #endif -+ #ifdef __dietlibc__ -+ LIBC=dietlibc -+ #endif - EOF -- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 -- rm -f $dummy.c $dummy -- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 -+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' -+ /^LIBC/{ -+ s: ::g -+ p -+ }'`" -+ test x"${LIBC}" != x && { -+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}" -+ exit -+ } -+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 -- exit 0 ;; -+ exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... -@@ -893,7 +1043,27 @@ - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} -- exit 0 ;; -+ exit ;; -+ i*86:OS/2:*:*) -+ # If we were able to find `uname', then EMX Unix compatibility -+ # is probably installed. -+ echo ${UNAME_MACHINE}-pc-os2-emx -+ exit ;; -+ i*86:XTS-300:*:STOP) -+ echo ${UNAME_MACHINE}-unknown-stop -+ exit ;; -+ i*86:atheos:*:*) -+ echo ${UNAME_MACHINE}-unknown-atheos -+ exit ;; -+ i*86:syllable:*:*) -+ echo ${UNAME_MACHINE}-pc-syllable -+ exit ;; -+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) -+ echo i386-unknown-lynxos${UNAME_RELEASE} -+ exit ;; -+ i*86:*DOS:*:*) -+ echo ${UNAME_MACHINE}-pc-msdosdjgpp -+ exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then -@@ -901,99 +1071,100 @@ - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi -- exit 0 ;; -- i*86:*:5:[78]*) -+ exit ;; -+ i*86:*:5:[678]*) -+ # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} -- exit 0 ;; -+ exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then -- UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` -- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 -- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ -+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` -+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 -+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 -- (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ -+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 -- (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ -+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi -- exit 0 ;; -- i*86:*DOS:*:*) -- echo ${UNAME_MACHINE}-pc-msdosdjgpp -- exit 0 ;; -+ exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp -- exit 0 ;; -+ exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 -- exit 0 ;; -+ exit ;; - paragon:*:*:*) - echo i860-intel-osf1 -- exit 0 ;; -+ exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi -- exit 0 ;; -+ exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv -- exit 0 ;; -- M68*:*:R3V[567]*:*) -- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; -- 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) -+ exit ;; -+ mc68k:UNIX:SYSTEM5:3.51m) -+ echo m68k-convergent-sysv -+ exit ;; -+ M680?0:D-NIX:5.3:*) -+ echo m68k-diab-dnix -+ exit ;; -+ M68*:*:R3V[5678]*:*) -+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; -+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -- && echo i486-ncr-sysv4.3${OS_REL} && exit 0 -+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ -- && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; -+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -- && echo i486-ncr-sysv4 && exit 0 ;; -+ && { echo i486-ncr-sysv4; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 -- exit 0 ;; -- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) -- echo i386-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 -- exit 0 ;; -+ exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 -- exit 0 ;; -+ exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` -@@ -1001,82 +1172,107 @@ - else - echo ns32k-sni-sysv - fi -- exit 0 ;; -+ exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 -- exit 0 ;; -+ exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 -- exit 0 ;; -+ exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 -- exit 0 ;; -+ exit ;; -+ i*86:VOS:*:*) -+ # From Paul.Green@stratus.com. -+ echo ${UNAME_MACHINE}-stratus-vos -+ exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos -- exit 0 ;; -+ exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 -- exit 0 ;; -+ exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi -- exit 0 ;; -+ exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos -- exit 0 ;; -+ exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos -- exit 0 ;; -+ exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos -- exit 0 ;; -+ exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; -+ SX-6:SUPER-UX:*:*) -+ echo sx6-nec-superux${UNAME_RELEASE} -+ exit ;; -+ SX-7:SUPER-UX:*:*) -+ echo sx7-nec-superux${UNAME_RELEASE} -+ exit ;; -+ SX-8:SUPER-UX:*:*) -+ echo sx8-nec-superux${UNAME_RELEASE} -+ exit ;; -+ SX-8R:SUPER-UX:*:*) -+ echo sx8r-nec-superux${UNAME_RELEASE} -+ exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:Darwin:*:*) -- echo `uname -p`-apple-darwin${UNAME_RELEASE} -- exit 0 ;; -+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown -+ case $UNAME_PROCESSOR in -+ unknown) UNAME_PROCESSOR=powerpc ;; -+ esac -+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} -+ exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) -- if test "${UNAME_MACHINE}" = "x86pc"; then -+ UNAME_PROCESSOR=`uname -p` -+ if test "$UNAME_PROCESSOR" = "x86"; then -+ UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi -- echo `uname -p`-${UNAME_MACHINE}-nto-qnx -- exit 0 ;; -+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} -+ exit ;; - *:QNX:*:4*) - echo i386-pc-qnx -- exit 0 ;; -- NSR-[KW]:NONSTOP_KERNEL:*:*) -+ exit ;; -+ NSE-?:NONSTOP_KERNEL:*:*) -+ echo nse-tandem-nsk${UNAME_RELEASE} -+ exit ;; -+ NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux -- exit 0 ;; -+ exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv -- exit 0 ;; -+ exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 -@@ -1087,36 +1283,47 @@ - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 -- exit 0 ;; -- i*86:OS/2:*:*) -- # If we were able to find `uname', then EMX Unix compatibility -- # is probably installed. -- echo ${UNAME_MACHINE}-pc-os2-emx -- exit 0 ;; -+ exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 -- exit 0 ;; -+ exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex -- exit 0 ;; -+ exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 -- exit 0 ;; -+ exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 -- exit 0 ;; -+ exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 -- exit 0 ;; -+ exit ;; - *:ITS:*:*) - echo pdp10-unknown-its -- exit 0 ;; -- i*86:XTS-300:*:STOP) -- echo ${UNAME_MACHINE}-unknown-stop -- exit 0 ;; -- i*86:atheos:*:*) -- echo ${UNAME_MACHINE}-unknown-atheos -- exit 0 ;; -+ exit ;; -+ SEI:*:*:SEIUX) -+ echo mips-sei-seiux${UNAME_RELEASE} -+ exit ;; -+ *:DragonFly:*:*) -+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` -+ exit ;; -+ *:*VMS:*:*) -+ UNAME_MACHINE=`(uname -p) 2>/dev/null` -+ case "${UNAME_MACHINE}" in -+ A*) echo alpha-dec-vms ; exit ;; -+ I*) echo ia64-dec-vms ; exit ;; -+ V*) echo vax-dec-vms ; exit ;; -+ esac ;; -+ *:XENIX:*:SysV) -+ echo i386-pc-xenix -+ exit ;; -+ i*86:skyos:*:*) -+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' -+ exit ;; -+ i*86:rdos:*:*) -+ echo ${UNAME_MACHINE}-pc-rdos -+ exit ;; - esac - - #echo '(No uname command or uname output not recognized.)' 1>&2 -@@ -1148,7 +1355,7 @@ - #endif - - #if defined (__arm) && defined (__acorn) && defined (__unix) -- printf ("arm-acorn-riscix"); exit (0); -+ printf ("arm-acorn-riscix\n"); exit (0); - #endif - - #if defined (hp300) && !defined (hpux) -@@ -1237,12 +1444,12 @@ - } - EOF - --$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 --rm -f $dummy.c $dummy -+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && -+ { echo "$SYSTEM_NAME"; exit; } - - # Apollos put the system type in the environment. - --test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } -+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - - # Convex versions that predate uname can use getsysinfo(1) - -@@ -1251,22 +1458,22 @@ - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd -- exit 0 ;; -+ exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi -- exit 0 ;; -+ exit ;; - c34*) - echo c34-convex-bsd -- exit 0 ;; -+ exit ;; - c38*) - echo c38-convex-bsd -- exit 0 ;; -+ exit ;; - c4*) - echo c4-convex-bsd -- exit 0 ;; -+ exit ;; - esac - fi - -@@ -1277,7 +1484,9 @@ - the operating system you are using. It is advised that you - download the most up to date version of the config scripts from - -- ftp://ftp.gnu.org/pub/gnu/config/ -+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -+and -+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - - If the version you run ($0) is already up to date, please - send the following data and any information you think might be ---- gsmlib-1.10.orig/scripts/ltmain.sh -+++ gsmlib-1.10/scripts/ltmain.sh -@@ -1,7 +1,7 @@ - # ltmain.sh - Provide generalized library-building support services. - # NOTE: Changing this file will not affect anything until you rerun configure. - # --# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 - # Free Software Foundation, Inc. - # Originally by Gordon Matzigkeit , 1996 - # -@@ -17,13 +17,41 @@ - # - # 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. -+# 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. - -+basename="s,^.*/,,g" -+ -+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -+# is ksh but when the shell is invoked as "sh" and the current value of -+# the _XPG environment variable is not equal to 1 (one), the special -+# positional parameter $0, within a function call, is the name of the -+# function. -+progpath="$0" -+ -+# The name of this program: -+progname=`echo "$progpath" | $SED $basename` -+modename="$progname" -+ -+# Global variables: -+EXIT_SUCCESS=0 -+EXIT_FAILURE=1 -+ -+PROGRAM=ltmain.sh -+PACKAGE=libtool -+VERSION="1.5.20 Debian 1.5.20-2" -+TIMESTAMP=" (1.1220.2.287 2005/08/31 18:54:15)" -+ -+# See if we are running on zsh, and set the options which allow our -+# commands through without removal of \ escapes. -+if test -n "${ZSH_VERSION+set}" ; then -+ setopt NO_GLOB_SUBST -+fi -+ - # Check that we have a working $echo. - if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. -@@ -36,7 +64,7 @@ - : - else - # Restart under the correct shell, and then maybe $echo will work. -- exec $SHELL "$0" --no-reexec ${1+"$@"} -+ exec $SHELL "$progpath" --no-reexec ${1+"$@"} - fi - - if test "X$1" = X--fallback-echo; then -@@ -45,19 +73,9 @@ - cat <&2 -- echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 -- exit 1 -+ $echo "$modename: not configured to build any kind of library" 1>&2 -+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 -+ exit $EXIT_FAILURE - fi - - # Global variables. -@@ -105,8 +135,225 @@ - lo2o="s/\\.lo\$/.${objext}/" - o2lo="s/\\.${objext}\$/.lo/" - -+##################################### -+# Shell function definitions: -+# This seems to be the best place for them -+ -+# func_win32_libid arg -+# return the library type of file 'arg' -+# -+# Need a lot of goo to handle *both* DLLs and import libs -+# Has to be a shell function in order to 'eat' the argument -+# that is supplied when $file_magic_command is called. -+func_win32_libid () -+{ -+ win32_libid_type="unknown" -+ win32_fileres=`file -L $1 2>/dev/null` -+ case $win32_fileres in -+ *ar\ archive\ import\ library*) # definitely import -+ win32_libid_type="x86 archive import" -+ ;; -+ *ar\ archive*) # could be an import, or static -+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ -+ $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then -+ win32_nmres=`eval $NM -f posix -A $1 | \ -+ sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` -+ if test "X$win32_nmres" = "Ximport" ; then -+ win32_libid_type="x86 archive import" -+ else -+ win32_libid_type="x86 archive static" -+ fi -+ fi -+ ;; -+ *DLL*) -+ win32_libid_type="x86 DLL" -+ ;; -+ *executable*) # but shell scripts are "executable" too... -+ case $win32_fileres in -+ *MS\ Windows\ PE\ Intel*) -+ win32_libid_type="x86 DLL" -+ ;; -+ esac -+ ;; -+ esac -+ $echo $win32_libid_type -+} -+ -+ -+# func_infer_tag arg -+# Infer tagged configuration to use if any are available and -+# if one wasn't chosen via the "--tag" command line option. -+# Only attempt this if the compiler in the base compile -+# command doesn't match the default compiler. -+# arg is usually of the form 'gcc ...' -+func_infer_tag () -+{ -+ if test -n "$available_tags" && test -z "$tagname"; then -+ CC_quoted= -+ for arg in $CC; do -+ case $arg in -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -+ arg="\"$arg\"" -+ ;; -+ esac -+ CC_quoted="$CC_quoted $arg" -+ done -+ case $@ in -+ # Blanks in the command may have been stripped by the calling shell, -+ # but not from the CC environment variable when configure was run. -+ " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; -+ # Blanks at the start of $base_compile will cause this to fail -+ # if we don't check for them as well. -+ *) -+ for z in $available_tags; do -+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then -+ # Evaluate the configuration. -+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" -+ CC_quoted= -+ for arg in $CC; do -+ # Double-quote args containing other shell metacharacters. -+ case $arg in -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -+ arg="\"$arg\"" -+ ;; -+ esac -+ CC_quoted="$CC_quoted $arg" -+ done -+ case "$@ " in -+ " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) -+ # The compiler in the base compile command matches -+ # the one in the tagged configuration. -+ # Assume this is the tagged configuration we want. -+ tagname=$z -+ break -+ ;; -+ esac -+ fi -+ done -+ # If $tagname still isn't set, then no tagged configuration -+ # was found and let the user know that the "--tag" command -+ # line option must be used. -+ if test -z "$tagname"; then -+ $echo "$modename: unable to infer tagged configuration" -+ $echo "$modename: specify a tag with \`--tag'" 1>&2 -+ exit $EXIT_FAILURE -+# else -+# $echo "$modename: using $tagname tagged configuration" -+ fi -+ ;; -+ esac -+ fi -+} -+ -+ -+# func_extract_an_archive dir oldlib -+func_extract_an_archive () -+{ -+ f_ex_an_ar_dir="$1"; shift -+ f_ex_an_ar_oldlib="$1" -+ -+ $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" -+ $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? -+ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then -+ : -+ else -+ $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 -+ exit $EXIT_FAILURE -+ fi -+} -+ -+# func_extract_archives gentop oldlib ... -+func_extract_archives () -+{ -+ my_gentop="$1"; shift -+ my_oldlibs=${1+"$@"} -+ my_oldobjs="" -+ my_xlib="" -+ my_xabs="" -+ my_xdir="" -+ my_status="" -+ -+ $show "${rm}r $my_gentop" -+ $run ${rm}r "$my_gentop" -+ $show "$mkdir $my_gentop" -+ $run $mkdir "$my_gentop" -+ my_status=$? -+ if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then -+ exit $my_status -+ fi -+ -+ for my_xlib in $my_oldlibs; do -+ # Extract the objects. -+ case $my_xlib in -+ [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; -+ *) my_xabs=`pwd`"/$my_xlib" ;; -+ esac -+ my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` -+ my_xdir="$my_gentop/$my_xlib" -+ -+ $show "${rm}r $my_xdir" -+ $run ${rm}r "$my_xdir" -+ $show "$mkdir $my_xdir" -+ $run $mkdir "$my_xdir" -+ status=$? -+ if test "$status" -ne 0 && test ! -d "$my_xdir"; then -+ exit $status -+ fi -+ case $host in -+ *-darwin*) -+ $show "Extracting $my_xabs" -+ # Do not bother doing anything if just a dry run -+ if test -z "$run"; then -+ darwin_orig_dir=`pwd` -+ cd $my_xdir || exit $? -+ darwin_archive=$my_xabs -+ darwin_curdir=`pwd` -+ darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` -+ darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` -+ if test -n "$darwin_arches"; then -+ darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` -+ darwin_arch= -+ $show "$darwin_base_archive has multiple architectures $darwin_arches" -+ for darwin_arch in $darwin_arches ; do -+ mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" -+ lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" -+ cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" -+ func_extract_an_archive "`pwd`" "${darwin_base_archive}" -+ cd "$darwin_curdir" -+ $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" -+ done # $darwin_arches -+ ## Okay now we have a bunch of thin objects, gotta fatten them up :) -+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` -+ darwin_file= -+ darwin_files= -+ for darwin_file in $darwin_filelist; do -+ darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` -+ lipo -create -output "$darwin_file" $darwin_files -+ done # $darwin_filelist -+ ${rm}r unfat-$$ -+ cd "$darwin_orig_dir" -+ else -+ cd "$darwin_orig_dir" -+ func_extract_an_archive "$my_xdir" "$my_xabs" -+ fi # $darwin_arches -+ fi # $run -+ ;; -+ *) -+ func_extract_an_archive "$my_xdir" "$my_xabs" -+ ;; -+ esac -+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` -+ done -+ func_extract_archives_result="$my_oldobjs" -+} -+# End of Shell function definitions -+##################################### -+ -+# Darwin sucks -+eval std_shrext=\"$shrext_cmds\" -+ - # Parse our command line options once, thoroughly. --while test $# -gt 0 -+while test "$#" -gt 0 - do - arg="$1" - shift -@@ -122,6 +369,34 @@ - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; -+ tag) -+ tagname="$arg" -+ preserve_args="${preserve_args}=$arg" -+ -+ # Check whether tagname contains only valid characters -+ case $tagname in -+ *[!-_A-Za-z0-9,/]*) -+ $echo "$progname: invalid tag name: $tagname" 1>&2 -+ exit $EXIT_FAILURE -+ ;; -+ esac -+ -+ case $tagname in -+ CC) -+ # Don't test for the "default" C tag, as we know, it's there, but -+ # not specially marked. -+ ;; -+ *) -+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then -+ taglist="$taglist $tagname" -+ # Evaluate the configuration. -+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" -+ else -+ $echo "$progname: ignoring unknown tag $tagname" 1>&2 -+ fi -+ ;; -+ esac -+ ;; - *) - eval "$prev=\$arg" - ;; -@@ -139,18 +414,27 @@ - ;; - - --version) -- echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" -- exit 0 -+ $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" -+ $echo -+ $echo "Copyright (C) 2005 Free Software Foundation, Inc." -+ $echo "This is free software; see the source for copying conditions. There is NO" -+ $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -+ exit $? - ;; - - --config) -- sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 -- exit 0 -+ ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath -+ # Now print the configurations for the tags. -+ for tagname in $taglist; do -+ ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" -+ done -+ exit $? - ;; - - --debug) -- echo "$progname: enabling shell trace mode" -+ $echo "$progname: enabling shell trace mode" - set -x -+ preserve_args="$preserve_args $arg" - ;; - - --dry-run | -n) -@@ -158,18 +442,18 @@ - ;; - - --features) -- echo "host: $host" -+ $echo "host: $host" - if test "$build_libtool_libs" = yes; then -- echo "enable shared libraries" -+ $echo "enable shared libraries" - else -- echo "disable shared libraries" -+ $echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then -- echo "enable static libraries" -+ $echo "enable static libraries" - else -- echo "disable static libraries" -+ $echo "disable static libraries" - fi -- exit 0 -+ exit $? - ;; - - --finish) mode="finish" ;; -@@ -181,6 +465,15 @@ - - --quiet | --silent) - show=: -+ preserve_args="$preserve_args $arg" -+ ;; -+ -+ --tag) prevopt="--tag" prev=tag ;; -+ --tag=*) -+ set tag "$optarg" ${1+"$@"} -+ shift -+ prev=tag -+ preserve_args="$preserve_args --tag" - ;; - - -dlopen) -@@ -191,7 +484,7 @@ - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - - *) -@@ -204,7 +497,7 @@ - if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # If this variable is set in any of the actions, the command in it -@@ -216,8 +509,10 @@ - - # Infer the operation mode. - if test -z "$mode"; then -+ $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 -+ $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 - case $nonopt in -- *cc | *++ | gcc* | *-gcc*) -+ *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) - mode=link - for arg - do -@@ -258,7 +553,7 @@ - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. -@@ -272,158 +567,127 @@ - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= -- prev= -- lastarg= -- srcfile="$nonopt" -+ srcfile="$nonopt" # always keep a non-empty value in "srcfile" -+ suppress_opt=yes - suppress_output= -+ arg_mode=normal -+ libobj= -+ later= - -- user_target=no - for arg - do -- case $prev in -- "") ;; -- xcompiler) -- # Aesthetically quote the previous argument. -- prev= -- lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` -- -- case $arg in -- # Double-quote args containing other shell metacharacters. -- # Many Bourne shells cannot handle close brackets correctly -- # in scan sets, so we specify it separately. -- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -- arg="\"$arg\"" -- ;; -- esac -- -- # Add the previous argument to base_compile. -- if test -z "$base_compile"; then -- base_compile="$lastarg" -- else -- base_compile="$base_compile $lastarg" -- fi -- continue -+ case $arg_mode in -+ arg ) -+ # do not "continue". Instead, add this to base_compile -+ lastarg="$arg" -+ arg_mode=normal - ;; -- esac - -- # Accept any command-line options. -- case $arg in -- -o) -- if test "$user_target" != "no"; then -- $echo "$modename: you cannot specify \`-o' more than once" 1>&2 -- exit 1 -- fi -- user_target=next -- ;; -- -- -static) -- build_old_libs=yes -+ target ) -+ libobj="$arg" -+ arg_mode=normal - continue - ;; - -- -prefer-pic) -- pic_mode=yes -- continue -- ;; -+ normal ) -+ # Accept any command-line options. -+ case $arg in -+ -o) -+ if test -n "$libobj" ; then -+ $echo "$modename: you cannot specify \`-o' more than once" 1>&2 -+ exit $EXIT_FAILURE -+ fi -+ arg_mode=target -+ continue -+ ;; - -- -prefer-non-pic) -- pic_mode=no -- continue -- ;; -+ -static | -prefer-pic | -prefer-non-pic) -+ later="$later $arg" -+ continue -+ ;; - -- -Xcompiler) -- prev=xcompiler -- continue -- ;; -+ -no-suppress) -+ suppress_opt=no -+ continue -+ ;; - -- -Wc,*) -- args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` -- lastarg= -- save_ifs="$IFS"; IFS=',' -- for arg in $args; do -- IFS="$save_ifs" -+ -Xcompiler) -+ arg_mode=arg # the next one goes into the "base_compile" arg list -+ continue # The current "srcfile" will either be retained or -+ ;; # replaced later. I would guess that would be a bug. -+ -+ -Wc,*) -+ args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` -+ lastarg= -+ save_ifs="$IFS"; IFS=',' -+ for arg in $args; do -+ IFS="$save_ifs" - -- # Double-quote args containing other shell metacharacters. -- # Many Bourne shells cannot handle close brackets correctly -- # in scan sets, so we specify it separately. -- case $arg in -- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -- arg="\"$arg\"" -- ;; -- esac -- lastarg="$lastarg $arg" -- done -- IFS="$save_ifs" -- lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` -+ # Double-quote args containing other shell metacharacters. -+ # Many Bourne shells cannot handle close brackets correctly -+ # in scan sets, so we specify it separately. -+ case $arg in -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -+ arg="\"$arg\"" -+ ;; -+ esac -+ lastarg="$lastarg $arg" -+ done -+ IFS="$save_ifs" -+ lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - -- # Add the arguments to base_compile. -- if test -z "$base_compile"; then -- base_compile="$lastarg" -- else -+ # Add the arguments to base_compile. - base_compile="$base_compile $lastarg" -- fi -- continue -- ;; -- esac -+ continue -+ ;; - -- case $user_target in -- next) -- # The next one is the -o target name -- user_target=yes -- continue -- ;; -- yes) -- # We got the output file -- user_target=set -- libobj="$arg" -- continue -+ * ) -+ # Accept the current argument as the source file. -+ # The previous "srcfile" becomes the current argument. -+ # -+ lastarg="$srcfile" -+ srcfile="$arg" -+ ;; -+ esac # case $arg - ;; -- esac -- -- # Accept the current argument as the source file. -- lastarg="$srcfile" -- srcfile="$arg" -+ esac # case $arg_mode - - # Aesthetically quote the previous argument. -- -- # Backslashify any backslashes, double quotes, and dollar signs. -- # These are the only characters that are still specially -- # interpreted inside of double-quoted scrings. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - -+ case $lastarg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly -- # in scan sets, so we specify it separately. -- case $lastarg in -+ # in scan sets, and some SunOS ksh mistreat backslash-escaping -+ # in scan sets (worked around with variable expansion), -+ # and furthermore cannot handle '|' '&' '(' ')' in scan sets -+ # at all, so we specify them separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - -- # Add the previous argument to base_compile. -- if test -z "$base_compile"; then -- base_compile="$lastarg" -- else -- base_compile="$base_compile $lastarg" -- fi -- done -+ base_compile="$base_compile $lastarg" -+ done # for arg - -- case $user_target in -- set) -+ case $arg_mode in -+ arg) -+ $echo "$modename: you must specify an argument for -Xcompile" -+ exit $EXIT_FAILURE - ;; -- no) -- # Get the name of the library object. -- libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` -+ target) -+ $echo "$modename: you must specify a target with \`-o'" 1>&2 -+ exit $EXIT_FAILURE - ;; - *) -- $echo "$modename: you must specify a target with \`-o'" 1>&2 -- exit 1 -+ # Get the name of the library object. -+ [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo -- xform='[cCFSfmso]' -+ xform='[cCFSifmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; -@@ -431,10 +695,13 @@ - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; -+ *.ii) xform=ii ;; -+ *.class) xform=class ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; -+ *.java) xform=java ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` -@@ -443,25 +710,63 @@ - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - -+ func_infer_tag $base_compile -+ -+ for arg in $later; do -+ case $arg in -+ -static) -+ build_old_libs=yes -+ continue -+ ;; -+ -+ -prefer-pic) -+ pic_mode=yes -+ continue -+ ;; -+ -+ -prefer-non-pic) -+ pic_mode=no -+ continue -+ ;; -+ esac -+ done -+ -+ qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` -+ case $qlibobj in -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -+ qlibobj="\"$qlibobj\"" ;; -+ esac -+ test "X$libobj" != "X$qlibobj" \ -+ && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ -+ && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." -+ objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` -+ xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` -+ if test "X$xdir" = "X$obj"; then -+ xdir= -+ else -+ xdir=$xdir/ -+ fi -+ lobj=${xdir}$objdir/$objname -+ - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then -- removelist="$obj $libobj" -+ removelist="$obj $lobj $libobj ${libobj}T" - else -- removelist="$libobj" -+ removelist="$lobj $libobj ${libobj}T" - fi - - $run $rm $removelist -- trap "$run $rm $removelist; exit 1" 1 2 15 -+ trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in -@@ -480,8 +785,9 @@ - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" -- trap "$run $rm $removelist; exit 1" 1 2 15 -+ trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 - else -+ output_obj= - need_locks=no - lockfile= - fi -@@ -489,13 +795,13 @@ - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then -- until $run ln "$0" "$lockfile" 2>/dev/null; do -+ until $run ln "$progpath" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then -- echo "\ -+ $echo "\ - *** ERROR, $lockfile exists and contains: - `cat $lockfile 2>/dev/null` - -@@ -507,14 +813,33 @@ - compiler." - - $run $rm $removelist -- exit 1 -+ exit $EXIT_FAILURE - fi -- echo $srcfile > "$lockfile" -+ $echo "$srcfile" > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi -+ qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` -+ case $qsrcfile in -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -+ qsrcfile="\"$qsrcfile\"" ;; -+ esac -+ -+ $run $rm "$libobj" "${libobj}T" -+ -+ # Create a libtool object file (analogous to a ".la" file), -+ # but don't create it if we're doing a dry run. -+ test -z "$run" && cat > ${libobj}T </dev/null`" != x"$srcfile"; then -- echo "\ -+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then -+ $echo "\ - *** ERROR, $lockfile contains: - `cat $lockfile 2>/dev/null` - -@@ -583,13 +893,13 @@ - compiler." - - $run $rm $removelist -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one -- if test x"$output_obj" != x"$libobj"; then -- $show "$mv $output_obj $libobj" -- if $run $mv $output_obj $libobj; then : -+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then -+ $show "$mv $output_obj $lobj" -+ if $run $mv $output_obj $lobj; then : - else - error=$? - $run $rm $removelist -@@ -597,77 +907,50 @@ - fi - fi - -- # If we have no pic_flag, then copy the object into place and finish. -- if (test -z "$pic_flag" || test "$pic_mode" != default) && -- test "$build_old_libs" = yes; then -- # Rename the .lo from within objdir to obj -- if test -f $obj; then -- $show $rm $obj -- $run $rm $obj -- fi -+ # Append the name of the PIC object to the libtool object file. -+ test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != x"$srcfile"; then -- echo "\ -+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then -+ $echo "\ - *** ERROR, $lockfile contains: - `cat $lockfile 2>/dev/null` - -@@ -682,11 +965,11 @@ - compiler." - - $run $rm $removelist -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Just move the object if needed -- if test x"$output_obj" != x"$obj"; then -+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else -@@ -696,29 +979,31 @@ - fi - fi - -- # Create an invalid libtool object if no PIC, so that we do not -- # accidentally link it into a program. -- if test "$build_libtool_libs" != yes; then -- $show "echo timestamp > $libobj" -- $run eval "echo timestamp > \$libobj" || exit $? -- else -- # Move the .lo from within objdir -- $show "$mv $libobj $lo_libobj" -- if $run $mv $libobj $lo_libobj; then : -- else -- error=$? -- $run $rm $removelist -- exit $error -- fi -- fi -+ # Append the name of the non-PIC object the libtool object file. -+ # Only append if the libtool object file exists. -+ test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null 2>&1; then -+ pic_object= -+ non_pic_object= -+ -+ # Read the .lo file -+ # If there is no directory component, then add one. -+ case $arg in -+ */* | *\\*) . $arg ;; -+ *) . ./$arg ;; -+ esac -+ -+ if test -z "$pic_object" || \ -+ test -z "$non_pic_object" || -+ test "$pic_object" = none && \ -+ test "$non_pic_object" = none; then -+ $echo "$modename: cannot find name of object for \`$arg'" 1>&2 -+ exit $EXIT_FAILURE -+ fi -+ -+ # Extract subdirectory from the argument. -+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` -+ if test "X$xdir" = "X$arg"; then -+ xdir= -+ else -+ xdir="$xdir/" -+ fi -+ -+ if test "$pic_object" != none; then -+ # Prepend the subdirectory the object is found in. -+ pic_object="$xdir$pic_object" -+ -+ if test "$prev" = dlfiles; then -+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then -+ dlfiles="$dlfiles $pic_object" -+ prev= -+ continue -+ else -+ # If libtool objects are unsupported, then we need to preload. -+ prev=dlprefiles -+ fi -+ fi -+ -+ # CHECK ME: I think I busted this. -Ossama -+ if test "$prev" = dlprefiles; then -+ # Preload the old-style object. -+ dlprefiles="$dlprefiles $pic_object" -+ prev= -+ fi -+ -+ # A PIC object. -+ libobjs="$libobjs $pic_object" -+ arg="$pic_object" -+ fi -+ -+ # Non-PIC object. -+ if test "$non_pic_object" != none; then -+ # Prepend the subdirectory the object is found in. -+ non_pic_object="$xdir$non_pic_object" -+ -+ # A standard non-PIC object -+ non_pic_objects="$non_pic_objects $non_pic_object" -+ if test -z "$pic_object" || test "$pic_object" = none ; then -+ arg="$non_pic_object" -+ fi -+ fi -+ else -+ # Only an error if not doing a dry-run. -+ if test -z "$run"; then -+ $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 -+ exit $EXIT_FAILURE -+ else -+ # Dry-run case. -+ -+ # Extract subdirectory from the argument. -+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` -+ if test "X$xdir" = "X$arg"; then -+ xdir= -+ else -+ xdir="$xdir/" -+ fi -+ -+ pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` -+ non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` -+ libobjs="$libobjs $pic_object" -+ non_pic_objects="$non_pic_objects $non_pic_object" -+ fi -+ fi -+ done -+ else -+ $echo "$modename: link input file \`$save_arg' does not exist" -+ exit $EXIT_FAILURE -+ fi -+ arg=$save_arg -+ prev= -+ continue -+ ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - if test "$prev" = rpath; then -@@ -938,13 +1341,33 @@ - finalize_command="$finalize_command $wl$qarg" - continue - ;; -+ xcclinker) -+ linker_flags="$linker_flags $qarg" -+ compiler_flags="$compiler_flags $qarg" -+ prev= -+ compile_command="$compile_command $qarg" -+ finalize_command="$finalize_command $qarg" -+ continue -+ ;; -+ shrext) -+ shrext_cmds="$arg" -+ prev= -+ continue -+ ;; -+ darwin_framework) -+ compiler_flags="$compiler_flags $arg" -+ compile_command="$compile_command $arg" -+ finalize_command="$finalize_command $arg" -+ prev= -+ continue -+ ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac -- fi # test -n $prev -+ fi # test -n "$prev" - - prevarg="$arg" - -@@ -986,7 +1409,7 @@ - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" -- exit 1 -+ exit $EXIT_FAILURE - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms -@@ -996,6 +1419,14 @@ - continue - ;; - -+ -framework|-arch) -+ prev=darwin_framework -+ compiler_flags="$compiler_flags $arg" -+ compile_command="$compile_command $arg" -+ finalize_command="$finalize_command $arg" -+ continue -+ ;; -+ - -inst-prefix-dir) - prev=inst_prefix - continue -@@ -1005,7 +1436,7 @@ - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in -- no/*-*-irix*) -+ no/*-*-irix* | /*-*-irix*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; -@@ -1022,7 +1453,7 @@ - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - dir="$absdir" - ;; -@@ -1056,25 +1487,75 @@ - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; -- *-*-openbsd*) -+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; -- esac -- elif test "X$arg" = "X-lc_r"; then -- case $host in -- *-*-openbsd*) -- # Do not include libc_r directly, use -pthread flag. -+ *-*-rhapsody* | *-*-darwin1.[012]) -+ # Rhapsody C and math libraries are in the System framework -+ deplibs="$deplibs -framework System" - continue -- ;; - esac -+ elif test "X$arg" = "X-lc_r"; then -+ case $host in -+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) -+ # Do not include libc_r directly, use -pthread flag. -+ continue -+ ;; -+ esac - fi - deplibs="$deplibs $arg" - continue - ;; - -- -module) -- module=yes -+ # Tru64 UNIX uses -model [arg] to determine the layout of C++ -+ # classes, name mangling, and exception handling. -+ -model) -+ compile_command="$compile_command $arg" -+ compiler_flags="$compiler_flags $arg" -+ finalize_command="$finalize_command $arg" -+ prev=xcompiler -+ continue -+ ;; -+ -+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) -+ compiler_flags="$compiler_flags $arg" -+ compile_command="$compile_command $arg" -+ finalize_command="$finalize_command $arg" -+ continue -+ ;; -+ -+ -module) -+ module=yes -+ continue -+ ;; -+ -+ # -64, -mips[0-9] enable 64-bit mode on the SGI compiler -+ # -r[0-9][0-9]* specifies the processor on the SGI compiler -+ # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler -+ # +DA*, +DD* enable 64-bit mode on the HP compiler -+ # -q* pass through compiler args for the IBM compiler -+ # -m* pass through architecture-specific compiler args for GCC -+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*) -+ -+ # Unknown arguments in both finalize_command and compile_command need -+ # to be aesthetically quoted because they are evaled later. -+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` -+ case $arg in -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") -+ arg="\"$arg\"" -+ ;; -+ esac -+ compile_command="$compile_command $arg" -+ finalize_command="$finalize_command $arg" -+ if test "$with_gcc" = "yes" ; then -+ compiler_flags="$compiler_flags $arg" -+ fi -+ continue -+ ;; -+ -+ -shrext) -+ prev=shrext - continue - ;; - -@@ -1102,8 +1583,18 @@ - continue - ;; - -+ -objectlist) -+ prev=objectlist -+ continue -+ ;; -+ - -o) prev=output ;; - -+ -precious-files-regex) -+ prev=precious_regex -+ continue -+ ;; -+ - -release) - prev=release - continue -@@ -1126,7 +1617,7 @@ - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - case "$xrpath " in -@@ -1154,6 +1645,11 @@ - prev=vinfo - continue - ;; -+ -version-number) -+ prev=vinfo -+ vinfo_number=yes -+ continue -+ ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` -@@ -1202,6 +1698,11 @@ - continue - ;; - -+ -XCClinker) -+ prev=xcclinker -+ continue -+ ;; -+ - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need -@@ -1214,29 +1715,101 @@ - esac - ;; - -- *.lo | *.$objext) -- # A library or standard object. -- if test "$prev" = dlfiles; then -- # This file was specified with -dlopen. -- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then -- dlfiles="$dlfiles $arg" -- prev= -- continue -- else -- # If libtool objects are unsupported, then we need to preload. -- prev=dlprefiles -- fi -- fi -+ *.$objext) -+ # A standard object. -+ objs="$objs $arg" -+ ;; - -- if test "$prev" = dlprefiles; then -- # Preload the old-style object. -- dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` -- prev= -- else -+ *.lo) -+ # A libtool-controlled object. -+ -+ # Check to see that this really is a libtool object. -+ if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ pic_object= -+ non_pic_object= -+ -+ # Read the .lo file -+ # If there is no directory component, then add one. - case $arg in -- *.lo) libobjs="$libobjs $arg" ;; -- *) objs="$objs $arg" ;; -+ */* | *\\*) . $arg ;; -+ *) . ./$arg ;; - esac -+ -+ if test -z "$pic_object" || \ -+ test -z "$non_pic_object" || -+ test "$pic_object" = none && \ -+ test "$non_pic_object" = none; then -+ $echo "$modename: cannot find name of object for \`$arg'" 1>&2 -+ exit $EXIT_FAILURE -+ fi -+ -+ # Extract subdirectory from the argument. -+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` -+ if test "X$xdir" = "X$arg"; then -+ xdir= -+ else -+ xdir="$xdir/" -+ fi -+ -+ if test "$pic_object" != none; then -+ # Prepend the subdirectory the object is found in. -+ pic_object="$xdir$pic_object" -+ -+ if test "$prev" = dlfiles; then -+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then -+ dlfiles="$dlfiles $pic_object" -+ prev= -+ continue -+ else -+ # If libtool objects are unsupported, then we need to preload. -+ prev=dlprefiles -+ fi -+ fi -+ -+ # CHECK ME: I think I busted this. -Ossama -+ if test "$prev" = dlprefiles; then -+ # Preload the old-style object. -+ dlprefiles="$dlprefiles $pic_object" -+ prev= -+ fi -+ -+ # A PIC object. -+ libobjs="$libobjs $pic_object" -+ arg="$pic_object" -+ fi -+ -+ # Non-PIC object. -+ if test "$non_pic_object" != none; then -+ # Prepend the subdirectory the object is found in. -+ non_pic_object="$xdir$non_pic_object" -+ -+ # A standard non-PIC object -+ non_pic_objects="$non_pic_objects $non_pic_object" -+ if test -z "$pic_object" || test "$pic_object" = none ; then -+ arg="$non_pic_object" -+ fi -+ fi -+ else -+ # Only an error if not doing a dry-run. -+ if test -z "$run"; then -+ $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 -+ exit $EXIT_FAILURE -+ else -+ # Dry-run case. -+ -+ # Extract subdirectory from the argument. -+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` -+ if test "X$xdir" = "X$arg"; then -+ xdir= -+ else -+ xdir="$xdir/" -+ fi -+ -+ pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` -+ non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` -+ libobjs="$libobjs $pic_object" -+ non_pic_objects="$non_pic_objects $non_pic_object" -+ fi - fi - ;; - -@@ -1287,7 +1860,7 @@ - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then -@@ -1296,6 +1869,7 @@ - finalize_command="$finalize_command $arg" - fi - -+ oldlibs= - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" -@@ -1330,7 +1904,7 @@ - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; -@@ -1338,7 +1912,17 @@ - *) linkmode=prog ;; # Anything else should be a program. - esac - -+ case $host in -+ *cygwin* | *mingw* | *pw32*) -+ # don't eliminate duplications in $postdeps and $predeps -+ duplicate_compiler_generated_deps=yes -+ ;; -+ *) -+ duplicate_compiler_generated_deps=$duplicate_deps -+ ;; -+ esac - specialdeplibs= -+ - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) -@@ -1358,7 +1942,7 @@ - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= -- if test "X$duplicate_deps" = "Xyes" ; then -+ if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; -@@ -1383,7 +1967,7 @@ - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - done -@@ -1400,39 +1984,58 @@ - ;; - esac - for pass in $passes; do -+ if test "$linkmode,$pass" = "lib,link" || -+ test "$linkmode,$pass" = "prog,scan"; then -+ libs="$deplibs" -+ deplibs= -+ fi - if test "$linkmode" = prog; then -- # Determine which files to process - case $pass in -- dlopen) -- libs="$dlfiles" -- save_deplibs="$deplibs" # Collect dlpreopened libraries -- deplibs= -- ;; -+ dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; -- link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; -+ link) -+ libs="$deplibs %DEPLIBS%" -+ test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" -+ ;; - esac - fi -+ if test "$pass" = dlopen; then -+ # Collect dlpreopened libraries -+ save_deplibs="$deplibs" -+ deplibs= -+ fi - for deplib in $libs; do - lib= - found=no - case $deplib in -- -l*) -- if test "$linkmode" = oldlib && test "$linkmode" = obj; then -- $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 -- continue -+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) -+ if test "$linkmode,$pass" = "prog,link"; then -+ compile_deplibs="$deplib $compile_deplibs" -+ finalize_deplibs="$deplib $finalize_deplibs" -+ else -+ compiler_flags="$compiler_flags $deplib" - fi -- if test "$pass" = conv; then -- deplibs="$deplib $deplibs" -+ continue -+ ;; -+ -l*) -+ if test "$linkmode" != lib && test "$linkmode" != prog; then -+ $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do -- # Search the libtool library -- lib="$searchdir/lib${name}.la" -- if test -f "$lib"; then -- found=yes -- break -- fi -+ for search_ext in .la $std_shrext .so .a; do -+ # Search the libtool library -+ lib="$searchdir/lib${name}${search_ext}" -+ if test -f "$lib"; then -+ if test "$search_ext" = ".la"; then -+ found=yes -+ else -+ found=no -+ fi -+ break 2 -+ fi -+ done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library -@@ -1444,6 +2047,42 @@ - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue -+ else # deplib is a libtool library -+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, -+ # We need to do some special things here, and not later. -+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then -+ case " $predeps $postdeps " in -+ *" $deplib "*) -+ if (${SED} -e '2q' $lib | -+ grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ library_names= -+ old_library= -+ case $lib in -+ */* | *\\*) . $lib ;; -+ *) . ./$lib ;; -+ esac -+ for l in $old_library $library_names; do -+ ll="$l" -+ done -+ if test "X$ll" = "X$old_library" ; then # only static version available -+ found=no -+ ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` -+ test "X$ladir" = "X$lib" && ladir="." -+ lib=$ladir/$old_library -+ if test "$linkmode,$pass" = "prog,link"; then -+ compile_deplibs="$deplib $compile_deplibs" -+ finalize_deplibs="$deplib $finalize_deplibs" -+ else -+ deplibs="$deplib $deplibs" -+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" -+ fi -+ continue -+ fi -+ fi -+ ;; -+ *) ;; -+ esac -+ fi - fi - ;; # -l - -L*) -@@ -1461,14 +2100,14 @@ - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" -- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi -+ newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - *) -- $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 -+ $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 - ;; - esac # linkmode - continue -@@ -1493,16 +2132,33 @@ - fi - case $linkmode in - lib) -- if test "$deplibs_check_method" != pass_all; then -- echo -- echo "*** Warning: This library needs some functionality provided by $deplib." -- echo "*** I have the capability to make that library automatically link in when" -- echo "*** you link to this library. But I can only do this if you have a" -- echo "*** shared version of the library, which you do not appear to have." -+ valid_a_lib=no -+ case $deplibs_check_method in -+ match_pattern*) -+ set dummy $deplibs_check_method -+ match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` -+ if eval $echo \"$deplib\" 2>/dev/null \ -+ | $SED 10q \ -+ | $EGREP "$match_pattern_regex" > /dev/null; then -+ valid_a_lib=yes -+ fi -+ ;; -+ pass_all) -+ valid_a_lib=yes -+ ;; -+ esac -+ if test "$valid_a_lib" != yes; then -+ $echo -+ $echo "*** Warning: Trying to link with static lib archive $deplib." -+ $echo "*** I have the capability to make that library automatically link in when" -+ $echo "*** you link to this library. But I can only do this if you have a" -+ $echo "*** shared version of the library, which you do not appear to have" -+ $echo "*** because the file extensions .$libext of this argument makes me believe" -+ $echo "*** that it is just a static archive that I should not used here." - else -- echo -- echo "*** Warning: Linking the shared library $output against the" -- echo "*** static library $deplib is not portable!" -+ $echo -+ $echo "*** Warning: Linking the shared library $output against the" -+ $echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue -@@ -1519,14 +2175,18 @@ - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) -- if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then -- # If there is no dlopen support or we're linking statically, -- # we need to preload. -- newdlprefiles="$newdlprefiles $deplib" -- compile_deplibs="$deplib $compile_deplibs" -- finalize_deplibs="$deplib $finalize_deplibs" -- else -- newdlfiles="$newdlfiles $deplib" -+ if test "$pass" = conv; then -+ deplibs="$deplib $deplibs" -+ elif test "$linkmode" = prog; then -+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then -+ # If there is no dlopen support or we're linking statically, -+ # we need to preload. -+ newdlprefiles="$newdlprefiles $deplib" -+ compile_deplibs="$deplib $compile_deplibs" -+ finalize_deplibs="$deplib $finalize_deplibs" -+ else -+ newdlfiles="$newdlfiles $deplib" -+ fi - fi - continue - ;; -@@ -1538,14 +2198,14 @@ - if test "$found" = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Check to see that this really is a libtool archive. -- if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : -+ if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` -@@ -1558,8 +2218,11 @@ - library_names= - old_library= - # If the library was installed with an old release of libtool, -- # it will not redefine variable installed. -+ # it will not redefine variables installed, or shouldnotlink - installed=yes -+ shouldnotlink=no -+ avoidtemprpath= -+ - - # Read the .la file - case $lib in -@@ -1569,8 +2232,7 @@ - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || -- { test "$linkmode" = oldlib && test "$linkmode" = obj; }; then -- # Add dl[pre]opened files of deplib -+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi -@@ -1581,7 +2243,7 @@ - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" -@@ -1598,11 +2260,12 @@ - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - continue - fi # $pass = conv - -+ - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do -@@ -1610,19 +2273,23 @@ - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi -- if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then -+ if test -z "$dlname" || -+ test "$dlopen_support" != yes || -+ test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking -- # statically, we need to preload. -- dlprefiles="$dlprefiles $lib" -+ # statically, we need to preload. We also need to preload any -+ # dependent libraries so libltdl's deplib preloader doesn't -+ # bomb out in the load deplibs phase. -+ dlprefiles="$dlprefiles $lib $dependency_libs" - else - newdlfiles="$newdlfiles $lib" - fi -@@ -1654,11 +2321,19 @@ - dir="$libdir" - absdir="$libdir" - fi -+ test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else -- dir="$ladir/$objdir" -- absdir="$abs_ladir/$objdir" -- # Remove this search path later -- notinst_path="$notinst_path $abs_ladir" -+ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then -+ dir="$ladir" -+ absdir="$abs_ladir" -+ # Remove this search path later -+ notinst_path="$notinst_path $abs_ladir" -+ else -+ dir="$ladir/$objdir" -+ absdir="$abs_ladir/$objdir" -+ # Remove this search path later -+ notinst_path="$notinst_path $abs_ladir" -+ fi - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - -@@ -1666,7 +2341,7 @@ - if test "$pass" = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). -@@ -1688,11 +2363,12 @@ - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else -- deplibs="$lib $deplibs" -+ deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - -+ - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" -@@ -1726,13 +2402,19 @@ - continue - fi # $linkmode = prog... - -- link_static=no # Whether the deplib will be linked statically -- if test -n "$library_names" && -- { test "$prefer_static_libs" = no || test -z "$old_library"; }; then -- # Link against this shared library -+ if test "$linkmode,$pass" = "prog,link"; then -+ if test -n "$library_names" && -+ { test "$prefer_static_libs" = no || test -z "$old_library"; }; then -+ # We need to hardcode the library path -+ if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then -+ # Make sure the rpath contains only unique directories. -+ case "$temp_rpath " in -+ *" $dir "*) ;; -+ *" $absdir "*) ;; -+ *) temp_rpath="$temp_rpath $absdir" ;; -+ esac -+ fi - -- if test "$linkmode,$pass" = "prog,link" || -- { test "$linkmode" = lib && test "$hardcode_into_libs" = yes; }; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. -@@ -1754,17 +2436,6 @@ - esac - ;; - esac -- if test "$linkmode" = prog; then -- # We need to hardcode the library path -- if test -n "$shlibpath_var"; then -- # Make sure the rpath contains only unique directories. -- case "$temp_rpath " in -- *" $dir "*) ;; -- *" $absdir "*) ;; -- *) temp_rpath="$temp_rpath $dir" ;; -- esac -- fi -- fi - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && -@@ -1774,11 +2445,52 @@ - # We only need to search for static libraries - continue - fi -+ fi - -+ link_static=no # Whether the deplib will be linked statically -+ if test -n "$library_names" && -+ { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi -+ # This is a shared library -+ -+ # Warn about portability, can't link against -module's on -+ # some systems (darwin) -+ if test "$shouldnotlink" = yes && test "$pass" = link ; then -+ $echo -+ if test "$linkmode" = prog; then -+ $echo "*** Warning: Linking the executable $output against the loadable module" -+ else -+ $echo "*** Warning: Linking the shared library $output against the loadable module" -+ fi -+ $echo "*** $linklib is not portable!" -+ fi -+ if test "$linkmode" = lib && -+ test "$hardcode_into_libs" = yes; then -+ # Hardcode the library path. -+ # Skip directories that are in the system default run-time -+ # search path. -+ case " $sys_lib_dlsearch_path " in -+ *" $absdir "*) ;; -+ *) -+ case "$compile_rpath " in -+ *" $absdir "*) ;; -+ *) compile_rpath="$compile_rpath $absdir" -+ esac -+ ;; -+ esac -+ case " $sys_lib_dlsearch_path " in -+ *" $libdir "*) ;; -+ *) -+ case "$finalize_rpath " in -+ *" $libdir "*) ;; -+ *) finalize_rpath="$finalize_rpath $libdir" -+ esac -+ ;; -+ esac -+ fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname -@@ -1792,7 +2504,7 @@ - elif test -n "$soname_spec"; then - # bleh windows - case $host in -- *cygwin*) -+ *cygwin* | mingw*) - major=`expr $current - $age` - versuffix="-$major" - ;; -@@ -1804,17 +2516,18 @@ - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" -- soname=`echo $soroot | sed -e 's/^.*\///'` -- newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" -+ soname=`$echo $soroot | ${SED} -e 's/^.*\///'` -+ newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' -- eval cmds=\"$extract_expsyms_cmds\" -+ cmds=$extract_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done -@@ -1825,9 +2538,10 @@ - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' -- eval cmds=\"$old_archive_from_expsyms_cmds\" -+ cmds=$old_archive_from_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done -@@ -1847,6 +2561,22 @@ - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" -+ case $host in -+ *-*-sco3.2v5* ) add_dir="-L$dir" ;; -+ *-*-darwin* ) -+ # if the lib is a module then we can not link against -+ # it, someone is ignoring the new warnings I added -+ if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then -+ $echo "** Warning, lib $linklib is a module, not a shared library" -+ if test -z "$old_library" ; then -+ $echo -+ $echo "** And there doesn't seem to be a static archive available" -+ $echo "** The link will probably fail, sorry" -+ else -+ add="$dir/$old_library" -+ fi -+ fi -+ esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; -@@ -1865,6 +2595,14 @@ - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" -+ # Try looking first in the location we're being installed to. -+ if test -n "$inst_prefix_dir"; then -+ case $libdir in -+ [\\/]*) -+ add_dir="$add_dir -L$inst_prefix_dir$libdir" -+ ;; -+ esac -+ fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" -@@ -1878,7 +2616,7 @@ - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" -- exit 1 -+ exit $EXIT_FAILURE - fi - - if test -n "$add_shlibpath"; then -@@ -1912,16 +2650,7 @@ - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then -- # Try looking first in the location we're being installed to. -- add_dir= -- if test -n "$inst_prefix_dir"; then -- case "$libdir" in -- [\\/]*) -- add_dir="-L$inst_prefix_dir$libdir" -- ;; -- esac -- fi -- add_dir="$add_dir -L$libdir" -+ add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in -@@ -1929,18 +2658,24 @@ - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" -+ elif test "$hardcode_automatic" = yes; then -+ if test -n "$inst_prefix_dir" && -+ test -f "$inst_prefix_dir$libdir/$linklib" ; then -+ add="$inst_prefix_dir$libdir/$linklib" -+ else -+ add="$libdir/$linklib" -+ fi - else - # We cannot seem to hardcode it, guess we'll fake it. -+ add_dir="-L$libdir" - # Try looking first in the location we're being installed to. -- add_dir= - if test -n "$inst_prefix_dir"; then -- case "$libdir" in -- [\\/]*) -- add_dir="-L$inst_prefix_dir$libdir" -- ;; -+ case $libdir in -+ [\\/]*) -+ add_dir="$add_dir -L$inst_prefix_dir$libdir" -+ ;; - esac - fi -- add_dir="$add_dir -L$libdir" - add="-l$name" - fi - -@@ -1953,15 +2688,6 @@ - fi - fi - elif test "$linkmode" = prog; then -- if test "$alldeplibs" = yes && -- { test "$deplibs_check_method" = pass_all || -- { test "$build_libtool_libs" = yes && -- test -n "$library_names"; }; }; then -- # We only need to search for static libraries -- continue -- fi -- -- # Try to link the static library - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. -@@ -1981,20 +2707,21 @@ - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. -- echo -- echo "*** Warning: This library needs some functionality provided by $lib." -- echo "*** I have the capability to make that library automatically link in when" -- echo "*** you link to this library. But I can only do this if you have a" -- echo "*** shared version of the library, which you do not appear to have." -+ $echo -+ $echo "*** Warning: This system can not link to static lib archive $lib." -+ $echo "*** I have the capability to make that library automatically link in when" -+ $echo "*** you link to this library. But I can only do this if you have a" -+ $echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then -- echo "*** Therefore, libtool will create a static module, that should work " -- echo "*** as long as the dlopening application is linked with the -dlopen flag." -+ $echo "*** But as you try to build a module library, libtool will still create " -+ $echo "*** a static module, that should work as long as the dlopening application" -+ $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then -- echo -- echo "*** However, this would only work if libtool was able to extract symbol" -- echo "*** lists from a program, using \`nm' or equivalent, but libtool could" -- echo "*** not find such a program. So, this module is probably useless." -- echo "*** \`nm' from GNU binutils and a full rebuild may help." -+ $echo -+ $echo "*** However, this would only work if libtool was able to extract symbol" -+ $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" -+ $echo "*** not find such a program. So, this module is probably useless." -+ $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module -@@ -2004,8 +2731,6 @@ - fi - fi - else -- convenience="$convenience $dir/$old_library" -- old_convenience="$old_convenience $dir/$old_library" - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi -@@ -2013,7 +2738,8 @@ - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && -- { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || -+ { test "$hardcode_into_libs" != yes || -+ test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= -@@ -2065,29 +2791,75 @@ - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then -- path="-L$absdir/$objdir" -+ path="$absdir/$objdir" - else -- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` -+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi -- path="-L$absdir" -+ path="$absdir" - fi -+ depdepl= -+ case $host in -+ *-*-darwin*) -+ # we do not want to link against static libs, -+ # but need to link against shared -+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` -+ if test -n "$deplibrary_names" ; then -+ for tmp in $deplibrary_names ; do -+ depdepl=$tmp -+ done -+ if test -f "$path/$depdepl" ; then -+ depdepl="$path/$depdepl" -+ fi -+ # do not add paths which are already there -+ case " $newlib_search_path " in -+ *" $path "*) ;; -+ *) newlib_search_path="$newlib_search_path $path";; -+ esac -+ fi -+ path="" -+ ;; -+ *) -+ path="-L$path" -+ ;; -+ esac -+ ;; -+ -l*) -+ case $host in -+ *-*-darwin*) -+ # Again, we only want to link against shared libraries -+ eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` -+ for tmp in $newlib_search_path ; do -+ if test -f "$tmp/lib$tmp_libs.dylib" ; then -+ eval depdepl="$tmp/lib$tmp_libs.dylib" -+ break -+ fi -+ done -+ path="" -+ ;; -+ *) continue ;; -+ esac - ;; - *) continue ;; - esac - case " $deplibs " in - *" $path "*) ;; -- *) deplibs="$deplibs $path" ;; -+ *) deplibs="$path $deplibs" ;; -+ esac -+ case " $deplibs " in -+ *" $depdepl "*) ;; -+ *) deplibs="$depdepl $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs -+ dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do -@@ -2095,7 +2867,6 @@ - done - fi - if test "$pass" != dlopen; then -- test "$pass" != scan && dependency_libs="$newdependency_libs" - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= -@@ -2118,9 +2889,30 @@ - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do -+ # FIXME: Pedantically, this is the right thing to do, so -+ # that some nasty dependency loop isn't accidentally -+ # broken: -+ #new_libs="$deplib $new_libs" -+ # Pragmatically, this seems to cause very few problems in -+ # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; -+ -R*) ;; - *) -+ # And here is the reason: when a library appears more -+ # than once as an explicit dependence of a library, or -+ # is implicitly linked in more than once by the -+ # compiler, it is considered special, and multiple -+ # occurrences thereof are not removed. Compare this -+ # with having the same library being listed as a -+ # dependency of multiple other libraries: in this case, -+ # we know (pedantically, we assume) the library does not -+ # need to be listed more than once, so we keep only the -+ # last copy. This is not always right, but it is rare -+ # enough that we require users that really mean to play -+ # such unportable linking tricks to link the library -+ # using -Wl,-lname, so that libtool does not consider it -+ # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) -@@ -2148,11 +2940,20 @@ - eval $var=\"$tmp_libs\" - done # for var - fi -- if test "$pass" = "conv" && -- { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then -- libs="$deplibs" # reset libs -- deplibs= -- fi -+ # Last step: remove runtime libs from dependency_libs -+ # (they stay in deplibs) -+ tmp_libs= -+ for i in $dependency_libs ; do -+ case " $predeps $postdeps $compiler_lib_search_path " in -+ *" $i "*) -+ i="" -+ ;; -+ esac -+ if test -n "$i" ; then -+ tmp_libs="$tmp_libs $i" -+ fi -+ done -+ dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" -@@ -2161,6 +2962,10 @@ - - case $linkmode in - oldlib) -+ if test -n "$deplibs"; then -+ $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 -+ fi -+ - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi -@@ -2174,7 +2979,7 @@ - fi - - if test -n "$vinfo"; then -- $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 -+ $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then -@@ -2196,17 +3001,19 @@ - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` -+ eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` -+ eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` -@@ -2217,11 +3024,11 @@ - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 -- exit 1 -+ exit $EXIT_FAILURE - else -- echo -- echo "*** Warning: Linking the shared library $output against the non-libtool" -- echo "*** objects $objs is not portable!" -+ $echo -+ $echo "*** Warning: Linking the shared library $output against the non-libtool" -+ $echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi -@@ -2240,14 +3047,16 @@ - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. -- libext=al -+ # Some compilers have problems with a `.al' extension so -+ # convenience libraries should have the same extension an -+ # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then -- $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 -+ $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then -@@ -2263,45 +3072,87 @@ - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - -- current="$2" -- revision="$3" -- age="$4" -+ # convert absolute version numbers to libtool ages -+ # this retains compatibility with .la files and attempts -+ # to make the code below a bit more comprehensible -+ -+ case $vinfo_number in -+ yes) -+ number_major="$2" -+ number_minor="$3" -+ number_revision="$4" -+ # -+ # There are really only two kinds -- those that -+ # use the current revision as the major version -+ # and those that subtract age and use age as -+ # a minor version. But, then there is irix -+ # which has an extra 1 added just for fun -+ # -+ case $version_type in -+ darwin|linux|osf|windows) -+ current=`expr $number_major + $number_minor` -+ age="$number_minor" -+ revision="$number_revision" -+ ;; -+ freebsd-aout|freebsd-elf|sunos) -+ current="$number_major" -+ revision="$number_minor" -+ age="0" -+ ;; -+ irix|nonstopux) -+ current=`expr $number_major + $number_minor - 1` -+ age="$number_minor" -+ revision="$number_minor" -+ ;; -+ *) -+ $echo "$modename: unknown library version type \`$version_type'" 1>&2 -+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 -+ exit $EXIT_FAILURE -+ ;; -+ esac -+ ;; -+ no) -+ current="$2" -+ revision="$3" -+ age="$4" -+ ;; -+ esac - - # Check that each of the things are valid numbers. - case $current in -- [0-9]*) ;; -+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) -- $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 -+ $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - - case $revision in -- [0-9]*) ;; -+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) -- $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 -+ $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - - case $age in -- [0-9]*) ;; -+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) -- $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 -+ $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - - if test "$age" -gt "$current"; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Calculate the version variables. -@@ -2318,7 +3169,7 @@ - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` -- verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" -+ verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - ;; - - freebsd-aout) -@@ -2331,16 +3182,21 @@ - versuffix=".$current"; - ;; - -- irix) -+ irix | nonstopux) - major=`expr $current - $age + 1` -- verstring="sgi$major.$revision" -+ -+ case $version_type in -+ nonstopux) verstring_prefix=nonstopux ;; -+ *) verstring_prefix=sgi ;; -+ esac -+ verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` -- verstring="sgi$major.$iface:$verstring" -+ verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. -@@ -2354,7 +3210,7 @@ - ;; - - osf) -- major=`expr $current - $age` -+ major=.`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - -@@ -2384,20 +3240,19 @@ - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 -- echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 -- exit 1 -+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 -+ exit $EXIT_FAILURE - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= -- verstring="0.0" - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely -- verstring="" -+ verstring= - ;; - *) - verstring="0.0" -@@ -2431,9 +3286,30 @@ - fi - - if test "$mode" != relink; then -- # Remove our outputs. -- $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" -- $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* -+ # Remove our outputs, but don't remove object files since they -+ # may have been created when compiling PIC objects. -+ removelist= -+ tempremovelist=`$echo "$output_objdir/*"` -+ for p in $tempremovelist; do -+ case $p in -+ *.$objext) -+ ;; -+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) -+ if test "X$precious_files_regex" != "X"; then -+ if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 -+ then -+ continue -+ fi -+ fi -+ removelist="$removelist $p" -+ ;; -+ *) ;; -+ esac -+ done -+ if test -n "$removelist"; then -+ $show "${rm}r $removelist" -+ $run ${rm}r $removelist -+ fi - fi - - # Now set the variables for building old libraries. -@@ -2446,9 +3322,9 @@ - - # Eliminate all temporary directories. - for path in $notinst_path; do -- lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` -- deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` -- dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` -+ lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` -+ deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` -+ dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then -@@ -2499,10 +3375,11 @@ - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; -- *-*-openbsd*) -+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. -+ test "X$arg" = "X-lc" && continue - ;; -- *) -+ *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs="$deplibs -lc" -@@ -2531,7 +3408,7 @@ - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just -- # implementing what was already the behaviour. -+ # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) -@@ -2544,64 +3421,88 @@ - int main() { return 0; } - EOF - $rm conftest -- $CC -o conftest conftest.c $deplibs -+ $LTCC -o conftest conftest.c $deplibs - if test "$?" -eq 0 ; then - ldd_output=`ldd conftest` - for i in $deplibs; do -- name="`expr $i : '-l\(.*\)'`" -+ name=`expr $i : '-l\(.*\)'` - # If $name is empty we are operating on a -L argument. -- if test -n "$name" && test "$name" != "0"; then -- libname=`eval \\$echo \"$libname_spec\"` -- deplib_matches=`eval \\$echo \"$library_names_spec\"` -- set dummy $deplib_matches -- deplib_match=$2 -- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then -- newdeplibs="$newdeplibs $i" -- else -- droppeddeps=yes -- echo -- echo "*** Warning: This library needs some functionality provided by $i." -- echo "*** I have the capability to make that library automatically link in when" -- echo "*** you link to this library. But I can only do this if you have a" -- echo "*** shared version of the library, which you do not appear to have." -+ if test "$name" != "" && test "$name" -ne "0"; then -+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then -+ case " $predeps $postdeps " in -+ *" $i "*) -+ newdeplibs="$newdeplibs $i" -+ i="" -+ ;; -+ esac -+ fi -+ if test -n "$i" ; then -+ libname=`eval \\$echo \"$libname_spec\"` -+ deplib_matches=`eval \\$echo \"$library_names_spec\"` -+ set dummy $deplib_matches -+ deplib_match=$2 -+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then -+ newdeplibs="$newdeplibs $i" -+ else -+ droppeddeps=yes -+ $echo -+ $echo "*** Warning: dynamic linker does not accept needed library $i." -+ $echo "*** I have the capability to make that library automatically link in when" -+ $echo "*** you link to this library. But I can only do this if you have a" -+ $echo "*** shared version of the library, which I believe you do not have" -+ $echo "*** because a test_compile did reveal that the linker did not use it for" -+ $echo "*** its dynamic dependency list that programs get resolved with at runtime." -+ fi - fi - else - newdeplibs="$newdeplibs $i" - fi - done - else -- # Error occured in the first compile. Let's try to salvage the situation: -- # Compile a seperate program for each library. -+ # Error occurred in the first compile. Let's try to salvage -+ # the situation: Compile a separate program for each library. - for i in $deplibs; do -- name="`expr $i : '-l\(.*\)'`" -- # If $name is empty we are operating on a -L argument. -- if test -n "$name" && test "$name" != "0"; then -+ name=`expr $i : '-l\(.*\)'` -+ # If $name is empty we are operating on a -L argument. -+ if test "$name" != "" && test "$name" != "0"; then - $rm conftest -- $CC -o conftest conftest.c $i -+ $LTCC -o conftest conftest.c $i - # Did it work? - if test "$?" -eq 0 ; then - ldd_output=`ldd conftest` -- libname=`eval \\$echo \"$libname_spec\"` -- deplib_matches=`eval \\$echo \"$library_names_spec\"` -- set dummy $deplib_matches -- deplib_match=$2 -- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then -- newdeplibs="$newdeplibs $i" -- else -- droppeddeps=yes -- echo -- echo "*** Warning: This library needs some functionality provided by $i." -- echo "*** I have the capability to make that library automatically link in when" -- echo "*** you link to this library. But I can only do this if you have a" -- echo "*** shared version of the library, which you do not appear to have." -+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then -+ case " $predeps $postdeps " in -+ *" $i "*) -+ newdeplibs="$newdeplibs $i" -+ i="" -+ ;; -+ esac -+ fi -+ if test -n "$i" ; then -+ libname=`eval \\$echo \"$libname_spec\"` -+ deplib_matches=`eval \\$echo \"$library_names_spec\"` -+ set dummy $deplib_matches -+ deplib_match=$2 -+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then -+ newdeplibs="$newdeplibs $i" -+ else -+ droppeddeps=yes -+ $echo -+ $echo "*** Warning: dynamic linker does not accept needed library $i." -+ $echo "*** I have the capability to make that library automatically link in when" -+ $echo "*** you link to this library. But I can only do this if you have a" -+ $echo "*** shared version of the library, which you do not appear to have" -+ $echo "*** because a test_compile did reveal that the linker did not use this one" -+ $echo "*** as a dynamic dependency that programs can get resolved with at runtime." -+ fi - fi - else - droppeddeps=yes -- echo -- echo "*** Warning! Library $i is needed by this library but I was not able to" -- echo "*** make it link in! You will probably need to install it or some" -- echo "*** library that it depends on before this library will be fully" -- echo "*** functional. Installing it before continuing would be even better." -+ $echo -+ $echo "*** Warning! Library $i is needed by this library but I was not able to" -+ $echo "*** make it link in! You will probably need to install it or some" -+ $echo "*** library that it depends on before this library will be fully" -+ $echo "*** functional. Installing it before continuing would be even better." - fi - else - newdeplibs="$newdeplibs $i" -@@ -2613,13 +3514,22 @@ - set dummy $deplibs_check_method - file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do -- name="`expr $a_deplib : '-l\(.*\)'`" -+ name=`expr $a_deplib : '-l\(.*\)'` - # If $name is empty we are operating on a -L argument. -- if test -n "$name" && test "$name" != "0"; then -- libname=`eval \\$echo \"$libname_spec\"` -- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do -- potential_libs=`ls $i/$libname[.-]* 2>/dev/null` -- for potent_lib in $potential_libs; do -+ if test "$name" != "" && test "$name" != "0"; then -+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then -+ case " $predeps $postdeps " in -+ *" $a_deplib "*) -+ newdeplibs="$newdeplibs $a_deplib" -+ a_deplib="" -+ ;; -+ esac -+ fi -+ if test -n "$a_deplib" ; then -+ libname=`eval \\$echo \"$libname_spec\"` -+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do -+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null` -+ for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then -@@ -2632,28 +3542,36 @@ - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do -- potliblink=`ls -ld $potlib | sed 's/.* -> //'` -+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ -- | sed 10q \ -- | egrep "$file_magic_regex" > /dev/null; then -+ | ${SED} 10q \ -+ | $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi -- done -- done -+ done -+ done -+ fi - if test -n "$a_deplib" ; then - droppeddeps=yes -- echo -- echo "*** Warning: This library needs some functionality provided by $a_deplib." -- echo "*** I have the capability to make that library automatically link in when" -- echo "*** you link to this library. But I can only do this if you have a" -- echo "*** shared version of the library, which you do not appear to have." -+ $echo -+ $echo "*** Warning: linker path does not have real file for library $a_deplib." -+ $echo "*** I have the capability to make that library automatically link in when" -+ $echo "*** you link to this library. But I can only do this if you have a" -+ $echo "*** shared version of the library, which you do not appear to have" -+ $echo "*** because I did check the linker path looking for a file starting" -+ if test -z "$potlib" ; then -+ $echo "*** with $libname but no candidates were found. (...for file magic test)" -+ else -+ $echo "*** with $libname and none of the candidates passed a file format test" -+ $echo "*** using a file magic. Last file checked: $potlib" -+ fi - fi - else - # Add a -L argument. -@@ -2665,29 +3583,47 @@ - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do -- name="`expr $a_deplib : '-l\(.*\)'`" -+ name=`expr $a_deplib : '-l\(.*\)'` - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then -- libname=`eval \\$echo \"$libname_spec\"` -- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do -- potential_libs=`ls $i/$libname[.-]* 2>/dev/null` -- for potent_lib in $potential_libs; do -- if eval echo \"$potent_lib\" 2>/dev/null \ -- | sed 10q \ -- | egrep "$match_pattern_regex" > /dev/null; then -- newdeplibs="$newdeplibs $a_deplib" -- a_deplib="" -- break 2 -- fi -+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then -+ case " $predeps $postdeps " in -+ *" $a_deplib "*) -+ newdeplibs="$newdeplibs $a_deplib" -+ a_deplib="" -+ ;; -+ esac -+ fi -+ if test -n "$a_deplib" ; then -+ libname=`eval \\$echo \"$libname_spec\"` -+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do -+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null` -+ for potent_lib in $potential_libs; do -+ potlib="$potent_lib" # see symlink-check above in file_magic test -+ if eval $echo \"$potent_lib\" 2>/dev/null \ -+ | ${SED} 10q \ -+ | $EGREP "$match_pattern_regex" > /dev/null; then -+ newdeplibs="$newdeplibs $a_deplib" -+ a_deplib="" -+ break 2 -+ fi -+ done - done -- done -+ fi - if test -n "$a_deplib" ; then - droppeddeps=yes -- echo -- echo "*** Warning: This library needs some functionality provided by $a_deplib." -- echo "*** I have the capability to make that library automatically link in when" -- echo "*** you link to this library. But I can only do this if you have a" -- echo "*** shared version of the library, which you do not appear to have." -+ $echo -+ $echo "*** Warning: linker path does not have real file for library $a_deplib." -+ $echo "*** I have the capability to make that library automatically link in when" -+ $echo "*** you link to this library. But I can only do this if you have a" -+ $echo "*** shared version of the library, which you do not appear to have" -+ $echo "*** because I did check the linker path looking for a file starting" -+ if test -z "$potlib" ; then -+ $echo "*** with $libname but no candidates were found. (...for regex pattern test)" -+ else -+ $echo "*** with $libname and none of the candidates passed a file format test" -+ $echo "*** using a regex pattern. Last file checked: $potlib" -+ fi - fi - else - # Add a -L argument. -@@ -2697,16 +3633,23 @@ - ;; - none | unknown | *) - newdeplibs="" -- if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -- -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | -- grep . >/dev/null; then -- echo -+ tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -+ -e 's/ -[LR][^ ]*//g'` -+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then -+ for i in $predeps $postdeps ; do -+ # can't use Xsed below, because $i might contain '/' -+ tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` -+ done -+ fi -+ if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ -+ | grep . >/dev/null; then -+ $echo - if test "X$deplibs_check_method" = "Xnone"; then -- echo "*** Warning: inter-library dependencies are not supported in this platform." -+ $echo "*** Warning: inter-library dependencies are not supported in this platform." - else -- echo "*** Warning: inter-library dependencies are not known to be supported." -+ $echo "*** Warning: inter-library dependencies are not known to be supported." - fi -- echo "*** All declared inter-library dependencies are being dropped." -+ $echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; -@@ -2726,17 +3669,17 @@ - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then -- echo -- echo "*** Warning: libtool could not satisfy all declared inter-library" -- echo "*** dependencies of module $libname. Therefore, libtool will create" -- echo "*** a static module, that should work as long as the dlopening" -- echo "*** application is linked with the -dlopen flag." -+ $echo -+ $echo "*** Warning: libtool could not satisfy all declared inter-library" -+ $echo "*** dependencies of module $libname. Therefore, libtool will create" -+ $echo "*** a static module, that should work as long as the dlopening" -+ $echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then -- echo -- echo "*** However, this would only work if libtool was able to extract symbol" -- echo "*** lists from a program, using \`nm' or equivalent, but libtool could" -- echo "*** not find such a program. So, this module is probably useless." -- echo "*** \`nm' from GNU binutils and a full rebuild may help." -+ $echo -+ $echo "*** However, this would only work if libtool was able to extract symbol" -+ $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" -+ $echo "*** not find such a program. So, this module is probably useless." -+ $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" -@@ -2746,16 +3689,16 @@ - build_libtool_libs=no - fi - else -- echo "*** The inter-library dependencies that have been dropped here will be" -- echo "*** automatically added whenever a program is linked with this library" -- echo "*** or is declared to -dlopen it." -+ $echo "*** The inter-library dependencies that have been dropped here will be" -+ $echo "*** automatically added whenever a program is linked with this library" -+ $echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then -- echo -- echo "*** Since this library must not contain undefined symbols," -- echo "*** because either the platform does not support them or" -- echo "*** it was explicitly requested with -no-undefined," -- echo "*** libtool will only create a static version of it." -+ $echo -+ $echo "*** Since this library must not contain undefined symbols," -+ $echo "*** because either the platform does not support them or" -+ $echo "*** it was explicitly requested with -no-undefined," -+ $echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module -@@ -2813,7 +3756,11 @@ - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" -- eval dep_rpath=\"$hardcode_libdir_flag_spec\" -+ if test -n "$hardcode_libdir_flag_spec_ld"; then -+ eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" -+ else -+ eval dep_rpath=\"$hardcode_libdir_flag_spec\" -+ fi - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. -@@ -2833,6 +3780,7 @@ - fi - - # Get the real and link names of the library. -+ eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" -@@ -2843,7 +3791,9 @@ - else - soname="$realname" - fi -- test -z "$dlname" && dlname=$soname -+ if test -z "$dlname"; then -+ dlname=$soname -+ fi - - lib="$output_objdir/$realname" - for link -@@ -2851,23 +3801,6 @@ - linknames="$linknames $link" - done - -- # Ensure that we have .o objects for linkers which dislike .lo -- # (e.g. aix) in case we are running --disable-static -- for obj in $libobjs; do -- xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` -- if test "X$xdir" = "X$obj"; then -- xdir="." -- else -- xdir="$xdir" -- fi -- baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` -- oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` -- if test ! -f $xdir/$oldobj; then -- $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" -- $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? -- fi -- done -- - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - -@@ -2877,17 +3810,29 @@ - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols -- eval cmds=\"$export_symbols_cmds\" -+ cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -- $show "$cmd" -- $run eval "$cmd" || exit $? -+ eval cmd=\"$cmd\" -+ if len=`expr "X$cmd" : ".*"` && -+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then -+ $show "$cmd" -+ $run eval "$cmd" || exit $? -+ skipped_export=false -+ else -+ # The command line is too long to execute in one step. -+ $show "using reloadable object file for export list..." -+ skipped_export=: -+ # Break out early, otherwise skipped_export may be -+ # set to false by a later but shorter cmd. -+ break -+ fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then -- $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" -- $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' -+ $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" -+ $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi -@@ -2898,46 +3843,30 @@ - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - -+ tmp_deplibs= -+ for test_deplib in $deplibs; do -+ case " $convenience " in -+ *" $test_deplib "*) ;; -+ *) -+ tmp_deplibs="$tmp_deplibs $test_deplib" -+ ;; -+ esac -+ done -+ deplibs="$tmp_deplibs" -+ - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then -+ save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" -- $show "${rm}r $gentop" -- $run ${rm}r "$gentop" -- $show "mkdir $gentop" -- $run mkdir "$gentop" -- status=$? -- if test "$status" -ne 0 && test ! -d "$gentop"; then -- exit $status -- fi - generated="$generated $gentop" - -- for xlib in $convenience; do -- # Extract the objects. -- case $xlib in -- [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; -- *) xabs=`pwd`"/$xlib" ;; -- esac -- xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` -- xdir="$gentop/$xlib" -- -- $show "${rm}r $xdir" -- $run ${rm}r "$xdir" -- $show "mkdir $xdir" -- $run mkdir "$xdir" -- status=$? -- if test "$status" -ne 0 && test ! -d "$xdir"; then -- exit $status -- fi -- $show "(cd $xdir && $AR x $xabs)" -- $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? -- -- libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` -- done -+ func_extract_archives $gentop $convenience -+ libobjs="$libobjs $func_extract_archives_result" - fi - fi -- -+ - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" -@@ -2949,23 +3878,175 @@ - fi - - # Do each of the archive commands. -+ if test "$module" = yes && test -n "$module_cmds" ; then -+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then -+ eval test_cmds=\"$module_expsym_cmds\" -+ cmds=$module_expsym_cmds -+ else -+ eval test_cmds=\"$module_cmds\" -+ cmds=$module_cmds -+ fi -+ else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then -- eval cmds=\"$archive_expsym_cmds\" -+ eval test_cmds=\"$archive_expsym_cmds\" -+ cmds=$archive_expsym_cmds -+ else -+ eval test_cmds=\"$archive_cmds\" -+ cmds=$archive_cmds -+ fi -+ fi -+ -+ if test "X$skipped_export" != "X:" && -+ len=`expr "X$test_cmds" : ".*" 2>/dev/null` && -+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then -+ : - else -- eval cmds=\"$archive_cmds\" -+ # The command line is too long to link in one step, link piecewise. -+ $echo "creating reloadable object files..." -+ -+ # Save the value of $output and $libobjs because we want to -+ # use them later. If we have whole_archive_flag_spec, we -+ # want to use save_libobjs as it was before -+ # whole_archive_flag_spec was expanded, because we can't -+ # assume the linker understands whole_archive_flag_spec. -+ # This may have to be revisited, in case too many -+ # convenience libraries get linked in and end up exceeding -+ # the spec. -+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then -+ save_libobjs=$libobjs -+ fi -+ save_output=$output -+ output_la=`$echo "X$output" | $Xsed -e "$basename"` -+ -+ # Clear the reloadable object creation command queue and -+ # initialize k to one. -+ test_cmds= -+ concat_cmds= -+ objlist= -+ delfiles= -+ last_robj= -+ k=1 -+ output=$output_objdir/$output_la-${k}.$objext -+ # Loop over the list of objects to be linked. -+ for obj in $save_libobjs -+ do -+ eval test_cmds=\"$reload_cmds $objlist $last_robj\" -+ if test "X$objlist" = X || -+ { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && -+ test "$len" -le "$max_cmd_len"; }; then -+ objlist="$objlist $obj" -+ else -+ # The command $test_cmds is almost too long, add a -+ # command to the queue. -+ if test "$k" -eq 1 ; then -+ # The first file doesn't have a previous command to add. -+ eval concat_cmds=\"$reload_cmds $objlist $last_robj\" -+ else -+ # All subsequent reloadable object files will link in -+ # the last one created. -+ eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" -+ fi -+ last_robj=$output_objdir/$output_la-${k}.$objext -+ k=`expr $k + 1` -+ output=$output_objdir/$output_la-${k}.$objext -+ objlist=$obj -+ len=1 -+ fi -+ done -+ # Handle the remaining objects by creating one last -+ # reloadable object file. All subsequent reloadable object -+ # files will link in the last one created. -+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~ -+ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" -+ -+ if ${skipped_export-false}; then -+ $show "generating symbol list for \`$libname.la'" -+ export_symbols="$output_objdir/$libname.exp" -+ $run $rm $export_symbols -+ libobjs=$output -+ # Append the command to create the export file. -+ eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" -+ fi -+ -+ # Set up a command to remove the reloadable object files -+ # after they are used. -+ i=0 -+ while test "$i" -lt "$k" -+ do -+ i=`expr $i + 1` -+ delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" -+ done -+ -+ $echo "creating a temporary reloadable object file: $output" -+ -+ # Loop through the commands generated above and execute them. -+ save_ifs="$IFS"; IFS='~' -+ for cmd in $concat_cmds; do -+ IFS="$save_ifs" -+ $show "$cmd" -+ $run eval "$cmd" || exit $? -+ done -+ IFS="$save_ifs" -+ -+ libobjs=$output -+ # Restore the value of output. -+ output=$save_output -+ -+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then -+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\" -+ fi -+ # Expand the library linking commands again to reset the -+ # value of $libobjs for piecewise linking. -+ -+ # Do each of the archive commands. -+ if test "$module" = yes && test -n "$module_cmds" ; then -+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then -+ cmds=$module_expsym_cmds -+ else -+ cmds=$module_cmds -+ fi -+ else -+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then -+ cmds=$archive_expsym_cmds -+ else -+ cmds=$archive_cmds -+ fi -+ fi -+ -+ # Append the command to remove the reloadable object files -+ # to the just-reset $cmds. -+ eval cmds=\"\$cmds~\$rm $delfiles\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" -- $run eval "$cmd" || exit $? -+ $run eval "$cmd" || { -+ lt_exit=$? -+ -+ # Restore the uninstalled library and exit -+ if test "$mode" = relink; then -+ $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' -+ fi -+ -+ exit $lt_exit -+ } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? -- exit 0 -+ -+ if test -n "$convenience"; then -+ if test -z "$whole_archive_flag_spec"; then -+ $show "${rm}r $gentop" -+ $run ${rm}r "$gentop" -+ fi -+ fi -+ -+ exit $EXIT_SUCCESS - fi - - # Create links to the real library. -@@ -3013,7 +4094,7 @@ - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` -@@ -3042,38 +4123,10 @@ - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" -- $show "${rm}r $gentop" -- $run ${rm}r "$gentop" -- $show "mkdir $gentop" -- $run mkdir "$gentop" -- status=$? -- if test "$status" -ne 0 && test ! -d "$gentop"; then -- exit $status -- fi - generated="$generated $gentop" - -- for xlib in $convenience; do -- # Extract the objects. -- case $xlib in -- [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; -- *) xabs=`pwd`"/$xlib" ;; -- esac -- xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` -- xdir="$gentop/$xlib" -- -- $show "${rm}r $xdir" -- $run ${rm}r "$xdir" -- $show "mkdir $xdir" -- $run mkdir "$xdir" -- status=$? -- if test "$status" -ne 0 && test ! -d "$xdir"; then -- exit $status -- fi -- $show "(cd $xdir && $AR x $xabs)" -- $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? -- -- reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` -- done -+ func_extract_archives $gentop $convenience -+ reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - -@@ -3081,10 +4134,11 @@ - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" -- eval cmds=\"$reload_cmds\" -+ cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done -@@ -3097,7 +4151,7 @@ - $run ${rm}r $gentop - fi - -- exit 0 -+ exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then -@@ -3108,37 +4162,24 @@ - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. -- $show "echo timestamp > $libobj" -- $run eval "echo timestamp > $libobj" || exit $? -- exit 0 -+ # $show "echo timestamp > $libobj" -+ # $run eval "echo timestamp > $libobj" || exit $? -+ exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" -- eval cmds=\"$reload_cmds\" -+ cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" -- else -- # Just create a symlink. -- $show $rm $libobj -- $run $rm $libobj -- xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` -- if test "X$xdir" = "X$libobj"; then -- xdir="." -- else -- xdir="$xdir" -- fi -- baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` -- oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` -- $show "(cd $xdir && $LN_S $oldobj $baseobj)" -- $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? - fi - - if test -n "$gentop"; then -@@ -3146,12 +4187,12 @@ - $run ${rm}r $gentop - fi - -- exit 0 -+ exit $EXIT_SUCCESS - ;; - - prog) - case $host in -- *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; -+ *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 -@@ -3176,6 +4217,16 @@ - ;; - esac - -+ case $host in -+ *darwin*) -+ # Don't allow lazy linking, it breaks C++ global constructors -+ if test "$tagname" = CXX ; then -+ compile_command="$compile_command ${wl}-bind_at_load" -+ finalize_command="$finalize_command ${wl}-bind_at_load" -+ fi -+ ;; -+ esac -+ - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - -@@ -3326,31 +4377,31 @@ - done - - if test -n "$exclude_expsyms"; then -- $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' -+ $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then -- $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' -+ $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then -- export_symbols="$output_objdir/$output.exp" -+ export_symbols="$output_objdir/$outputname.exp" - $run $rm $export_symbols -- $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' -+ $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else -- $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' -- $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' -+ $run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' -+ $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" -- name=`echo "$arg" | sed -e 's%^.*/%%'` -- $run eval 'echo ": $name " >> "$nlist"' -+ name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` -+ $run eval '$echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - -@@ -3359,12 +4410,18 @@ - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then -- egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T -+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. -- if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then -+ if grep -v "^: " < "$nlist" | -+ if sort -k 3 /dev/null 2>&1; then -+ sort -k 3 -+ else -+ sort +2 -+ fi | -+ uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S -@@ -3373,7 +4430,7 @@ - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else -- echo '/* NONE */' >> "$output_objdir/$dlsyms" -+ $echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ -@@ -3388,7 +4445,26 @@ - #endif - - /* The mapping between symbol names and symbols. */ -+" -+ -+ case $host in -+ *cygwin* | *mingw* ) -+ $echo >> "$output_objdir/$dlsyms" "\ -+/* DATA imports from DLLs on WIN32 can't be const, because -+ runtime relocations are performed -- see ld's documentation -+ on pseudo-relocs */ -+struct { -+" -+ ;; -+ * ) -+ $echo >> "$output_objdir/$dlsyms" "\ - const struct { -+" -+ ;; -+ esac -+ -+ -+ $echo >> "$output_objdir/$dlsyms" "\ - const char *name; - lt_ptr address; - } -@@ -3425,18 +4501,18 @@ - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; -- *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; -+ *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; -- *) pic_flag_for_symtable=" $pic_flag -DPIC";; -+ *) pic_flag_for_symtable=" $pic_flag";; - esac - esac - - # Now compile the dynamic symbol file. -- $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" -- $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? -+ $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" -+ $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" -@@ -3448,7 +4524,7 @@ - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - else -@@ -3536,7 +4612,7 @@ - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? -- exit 0 -+ exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then -@@ -3591,10 +4667,10 @@ - fi - - # Quote $echo for shipping. -- if test "X$echo" = "X$SHELL $0 --fallback-echo"; then -- case $0 in -- [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; -- *) qecho="$SHELL `pwd`/$0 --fallback-echo";; -+ if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then -+ case $progpath in -+ [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; -+ *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else -@@ -3606,15 +4682,231 @@ - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in -- *.exe) output=`echo $output|sed 's,.exe$,,'` ;; -+ *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in -- *cygwin*) exeext=.exe ;; -+ *cygwin*) -+ exeext=.exe -+ outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; - *) exeext= ;; - esac -+ case $host in -+ *cygwin* | *mingw* ) -+ cwrappersource=`$echo ${objdir}/lt-${outputname}.c` -+ cwrapper=`$echo ${output}.exe` -+ $rm $cwrappersource $cwrapper -+ trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 -+ -+ cat > $cwrappersource <> $cwrappersource<<"EOF" -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#if defined(PATH_MAX) -+# define LT_PATHMAX PATH_MAX -+#elif defined(MAXPATHLEN) -+# define LT_PATHMAX MAXPATHLEN -+#else -+# define LT_PATHMAX 1024 -+#endif -+ -+#ifndef DIR_SEPARATOR -+#define DIR_SEPARATOR '/' -+#endif -+ -+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ -+ defined (__OS2__) -+#define HAVE_DOS_BASED_FILE_SYSTEM -+#ifndef DIR_SEPARATOR_2 -+#define DIR_SEPARATOR_2 '\\' -+#endif -+#endif -+ -+#ifndef DIR_SEPARATOR_2 -+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -+#else /* DIR_SEPARATOR_2 */ -+# define IS_DIR_SEPARATOR(ch) \ -+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -+#endif /* DIR_SEPARATOR_2 */ -+ -+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -+#define XFREE(stale) do { \ -+ if (stale) { free ((void *) stale); stale = 0; } \ -+} while (0) -+ -+const char *program_name = NULL; -+ -+void * xmalloc (size_t num); -+char * xstrdup (const char *string); -+char * basename (const char *name); -+char * fnqualify(const char *path); -+char * strendzap(char *str, const char *pat); -+void lt_fatal (const char *message, ...); -+ -+int -+main (int argc, char *argv[]) -+{ -+ char **newargz; -+ int i; -+ -+ program_name = (char *) xstrdup ((char *) basename (argv[0])); -+ newargz = XMALLOC(char *, argc+2); -+EOF -+ -+ cat >> $cwrappersource <> $cwrappersource <<"EOF" -+ newargz[1] = fnqualify(argv[0]); -+ /* we know the script has the same name, without the .exe */ -+ /* so make sure newargz[1] doesn't end in .exe */ -+ strendzap(newargz[1],".exe"); -+ for (i = 1; i < argc; i++) -+ newargz[i+1] = xstrdup(argv[i]); -+ newargz[argc+1] = NULL; -+EOF -+ -+ cat >> $cwrappersource <> $cwrappersource <<"EOF" -+ return 127; -+} -+ -+void * -+xmalloc (size_t num) -+{ -+ void * p = (void *) malloc (num); -+ if (!p) -+ lt_fatal ("Memory exhausted"); -+ -+ return p; -+} -+ -+char * -+xstrdup (const char *string) -+{ -+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL -+; -+} -+ -+char * -+basename (const char *name) -+{ -+ const char *base; -+ -+#if defined (HAVE_DOS_BASED_FILE_SYSTEM) -+ /* Skip over the disk name in MSDOS pathnames. */ -+ if (isalpha (name[0]) && name[1] == ':') -+ name += 2; -+#endif -+ -+ for (base = name; *name; name++) -+ if (IS_DIR_SEPARATOR (*name)) -+ base = name + 1; -+ return (char *) base; -+} -+ -+char * -+fnqualify(const char *path) -+{ -+ size_t size; -+ char *p; -+ char tmp[LT_PATHMAX + 1]; -+ -+ assert(path != NULL); -+ -+ /* Is it qualified already? */ -+#if defined (HAVE_DOS_BASED_FILE_SYSTEM) -+ if (isalpha (path[0]) && path[1] == ':') -+ return xstrdup (path); -+#endif -+ if (IS_DIR_SEPARATOR (path[0])) -+ return xstrdup (path); -+ -+ /* prepend the current directory */ -+ /* doesn't handle '~' */ -+ if (getcwd (tmp, LT_PATHMAX) == NULL) -+ lt_fatal ("getcwd failed"); -+ size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ -+ p = XMALLOC(char, size); -+ sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); -+ return p; -+} -+ -+char * -+strendzap(char *str, const char *pat) -+{ -+ size_t len, patlen; -+ -+ assert(str != NULL); -+ assert(pat != NULL); -+ -+ len = strlen(str); -+ patlen = strlen(pat); -+ -+ if (patlen <= len) -+ { -+ str += len - patlen; -+ if (strcmp(str, pat) == 0) -+ *str = '\0'; -+ } -+ return str; -+} -+ -+static void -+lt_error_core (int exit_status, const char * mode, -+ const char * message, va_list ap) -+{ -+ fprintf (stderr, "%s: %s: ", program_name, mode); -+ vfprintf (stderr, message, ap); -+ fprintf (stderr, ".\n"); -+ -+ if (exit_status >= 0) -+ exit (exit_status); -+} -+ -+void -+lt_fatal (const char *message, ...) -+{ -+ va_list ap; -+ va_start (ap, message); -+ lt_error_core (EXIT_FAILURE, "FATAL", message, ap); -+ va_end (ap); -+} -+EOF -+ # we should really use a build-platform specific compiler -+ # here, but OTOH, the wrappers (shell script and this C one) -+ # are only useful if you want to execute the "real" binary. -+ # Since the "real" binary is built for $host, then this -+ # wrapper might as well be built for $host, too. -+ $run $LTCC -s -o $cwrapper $cwrappersource -+ ;; -+ esac - $rm $output -- trap "$rm $output; exit 1" 1 2 15 -+ trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 - - $echo > $output "\ - #! $SHELL -@@ -3630,12 +4922,12 @@ - - # Sed substitution that helps us do robust quoting. It backslashifies - # metacharacters that are still active within double-quoted strings. --Xsed='sed -e 1s/^X//' -+Xsed='${SED} -e 1s/^X//' - sed_quote_subst='$sed_quote_subst' - - # The HP-UX ksh and POSIX shell print the target directory to stdout - # if CDPATH is set. --if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi -+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - relink_command=\"$relink_command\" - -@@ -3668,7 +4960,7 @@ - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. -- file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` -+ file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - -@@ -3681,7 +4973,7 @@ - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` -- file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` -+ file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. -@@ -3690,12 +4982,12 @@ - " - - if test "$fast_install" = yes; then -- echo >> $output "\ -+ $echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ -- { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ -+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" -@@ -3706,7 +4998,7 @@ - $rm \"\$progdir/\$file\" - fi" - -- echo >> $output "\ -+ $echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then -@@ -3714,7 +5006,7 @@ - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" -- exit 1 -+ exit $EXIT_FAILURE - fi - fi - -@@ -3724,13 +5016,13 @@ - $rm \"\$progdir/\$file\" - fi" - else -- echo >> $output "\ -+ $echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" - " - fi - -- echo >> $output "\ -+ $echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - -@@ -3761,47 +5053,35 @@ - # Run the actual program with our arguments. - " - case $host in -- # win32 systems need to use the prog path for dll -- # lookup to work -- *-*-cygwin* | *-*-pw32*) -- $echo >> $output "\ -- exec \$progdir/\$program \${1+\"\$@\"} --" -- ;; -- - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ -- exec \$progdir\\\\\$program \${1+\"\$@\"} -+ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} - " - ;; - - *) - $echo >> $output "\ -- # Export the path to the program. -- PATH=\"\$progdir:\$PATH\" -- export PATH -- -- exec \$program \${1+\"\$@\"} -+ exec \"\$progdir/\$program\" \${1+\"\$@\"} - " - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" -- exit 1 -+ exit $EXIT_FAILURE - fi - else - # The program doesn't exist. -- \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 -+ \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 -- echo \"See the $PACKAGE documentation for more information.\" 1>&2 -- exit 1 -+ $echo \"See the $PACKAGE documentation for more information.\" 1>&2 -+ exit $EXIT_FAILURE - fi - fi\ - " - chmod +x $output - fi -- exit 0 -+ exit $EXIT_SUCCESS - ;; - esac - -@@ -3817,74 +5097,130 @@ - oldobjs="$libobjs_save" - build_libtool_libs=no - else -- oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` -+ oldobjs="$old_deplibs $non_pic_objects" - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" -- $show "${rm}r $gentop" -- $run ${rm}r "$gentop" -- $show "mkdir $gentop" -- $run mkdir "$gentop" -- status=$? -- if test "$status" -ne 0 && test ! -d "$gentop"; then -- exit $status -- fi - generated="$generated $gentop" - -- # Add in members from convenience archives. -- for xlib in $addlibs; do -- # Extract the objects. -- case $xlib in -- [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; -- *) xabs=`pwd`"/$xlib" ;; -- esac -- xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` -- xdir="$gentop/$xlib" -- -- $show "${rm}r $xdir" -- $run ${rm}r "$xdir" -- $show "mkdir $xdir" -- $run mkdir "$xdir" -- status=$? -- if test "$status" -ne 0 && test ! -d "$xdir"; then -- exit $status -- fi -- $show "(cd $xdir && $AR x $xabs)" -- $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? -- -- oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` -- done -+ func_extract_archives $gentop $addlibs -+ oldobjs="$oldobjs $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then -- eval cmds=\"$old_archive_from_new_cmds\" -+ cmds=$old_archive_from_new_cmds - else -- # Ensure that we have .o objects in place in case we decided -- # not to build a shared library, and have fallen back to building -- # static libs even though --disable-static was passed! -- for oldobj in $oldobjs; do -- if test ! -f $oldobj; then -- xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` -- if test "X$xdir" = "X$oldobj"; then -- xdir="." -- else -- xdir="$xdir" -+ # POSIX demands no paths to be encoded in archives. We have -+ # to avoid creating archives with duplicate basenames if we -+ # might have to extract them afterwards, e.g., when creating a -+ # static archive out of a convenience library, or when linking -+ # the entirety of a libtool archive into another (currently -+ # not supported by libtool). -+ if (for obj in $oldobjs -+ do -+ $echo "X$obj" | $Xsed -e 's%^.*/%%' -+ done | sort | sort -uc >/dev/null 2>&1); then -+ : -+ else -+ $echo "copying selected object files to avoid basename conflicts..." -+ -+ if test -z "$gentop"; then -+ gentop="$output_objdir/${outputname}x" -+ generated="$generated $gentop" -+ -+ $show "${rm}r $gentop" -+ $run ${rm}r "$gentop" -+ $show "$mkdir $gentop" -+ $run $mkdir "$gentop" -+ status=$? -+ if test "$status" -ne 0 && test ! -d "$gentop"; then -+ exit $status - fi -- baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` -- obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` -- $show "(cd $xdir && ${LN_S} $obj $baseobj)" -- $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? - fi -- done -+ -+ save_oldobjs=$oldobjs -+ oldobjs= -+ counter=1 -+ for obj in $save_oldobjs -+ do -+ objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` -+ case " $oldobjs " in -+ " ") oldobjs=$obj ;; -+ *[\ /]"$objbase "*) -+ while :; do -+ # Make sure we don't pick an alternate name that also -+ # overlaps. -+ newobj=lt$counter-$objbase -+ counter=`expr $counter + 1` -+ case " $oldobjs " in -+ *[\ /]"$newobj "*) ;; -+ *) if test ! -f "$gentop/$newobj"; then break; fi ;; -+ esac -+ done -+ $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" -+ $run ln "$obj" "$gentop/$newobj" || -+ $run cp "$obj" "$gentop/$newobj" -+ oldobjs="$oldobjs $gentop/$newobj" -+ ;; -+ *) oldobjs="$oldobjs $obj" ;; -+ esac -+ done -+ fi - - eval cmds=\"$old_archive_cmds\" -+ -+ if len=`expr "X$cmds" : ".*"` && -+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then -+ cmds=$old_archive_cmds -+ else -+ # the command line is too long to link in one step, link in parts -+ $echo "using piecewise archive linking..." -+ save_RANLIB=$RANLIB -+ RANLIB=: -+ objlist= -+ concat_cmds= -+ save_oldobjs=$oldobjs -+ -+ # Is there a better way of finding the last object in the list? -+ for obj in $save_oldobjs -+ do -+ last_oldobj=$obj -+ done -+ for obj in $save_oldobjs -+ do -+ oldobjs="$objlist $obj" -+ objlist="$objlist $obj" -+ eval test_cmds=\"$old_archive_cmds\" -+ if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && -+ test "$len" -le "$max_cmd_len"; then -+ : -+ else -+ # the above command should be used before it gets too long -+ oldobjs=$objlist -+ if test "$obj" = "$last_oldobj" ; then -+ RANLIB=$save_RANLIB -+ fi -+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~ -+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" -+ objlist= -+ fi -+ done -+ RANLIB=$save_RANLIB -+ oldobjs=$objlist -+ if test "X$oldobjs" = "X" ; then -+ eval cmds=\"\$concat_cmds\" -+ else -+ eval cmds=\"\$concat_cmds~\$old_archive_cmds\" -+ fi -+ fi - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do -+ eval cmd=\"$cmd\" - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? -@@ -3916,8 +5252,12 @@ - fi - done - # Quote the link command for shipping. -- relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)" -+ relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` -+ if test "$hardcode_automatic" = yes ; then -+ relink_command= -+ fi -+ - - # Only create the output if not a dry run. - if test -z "$run"; then -@@ -3933,10 +5273,10 @@ - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` -- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` -+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; -@@ -3947,10 +5287,10 @@ - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` -- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` -+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - newdlfiles="$newdlfiles $libdir/$name" - done -@@ -3958,20 +5298,39 @@ - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` -- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` -+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" -+ else -+ newdlfiles= -+ for lib in $dlfiles; do -+ case $lib in -+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; -+ *) abs=`pwd`"/$lib" ;; -+ esac -+ newdlfiles="$newdlfiles $abs" -+ done -+ dlfiles="$newdlfiles" -+ newdlprefiles= -+ for lib in $dlprefiles; do -+ case $lib in -+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; -+ *) abs=`pwd`"/$lib" ;; -+ esac -+ newdlprefiles="$newdlprefiles $abs" -+ done -+ dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in -- *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; -+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ - # $outputname - a libtool library file -@@ -4000,6 +5359,9 @@ - # Is this an already installed library? - installed=$installed - -+# Should we warn about portability when linking against -modules? -+shouldnotlink=$module -+ - # Files to dlopen/dlpreopen - dlopen='$dlfiles' - dlpreopen='$dlprefiles' -@@ -4019,7 +5381,7 @@ - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac -- exit 0 -+ exit $EXIT_SUCCESS - ;; - - # libtool install mode -@@ -4030,11 +5392,11 @@ - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. -- $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then -+ $echo "X$nonopt" | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in -- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac -@@ -4043,14 +5405,14 @@ - shift - else - install_prog= -- arg="$nonopt" -+ arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in -- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac -@@ -4068,28 +5430,31 @@ - do - if test -n "$dest"; then - files="$files $dest" -- dest="$arg" -+ dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; -- -f) prev="-f" ;; -- -g) prev="-g" ;; -- -m) prev="-m" ;; -- -o) prev="-o" ;; -+ -f) -+ case " $install_prog " in -+ *[\\\ /]cp\ *) ;; -+ *) prev=$arg ;; -+ esac -+ ;; -+ -g | -m | -o) prev=$arg ;; - -s) - stripme=" -s" - continue - ;; -- -*) ;; -- -+ -*) -+ ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else -- dest="$arg" -+ dest=$arg - continue - fi - ;; -@@ -4098,7 +5463,7 @@ - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in -- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) -+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac -@@ -4108,13 +5473,13 @@ - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - if test -z "$files"; then -@@ -4124,7 +5489,7 @@ - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Strip any trailing slash from the destination. -@@ -4145,7 +5510,7 @@ - if test "$#" -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - fi - case $destdir in -@@ -4157,7 +5522,7 @@ - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - done -@@ -4182,11 +5547,11 @@ - - *.la) - # Check to see that this really is a libtool archive. -- if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : -+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - library_names= -@@ -4218,21 +5583,24 @@ - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. -- inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"` -+ inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. -+ # At present, this check doesn't affect windows .dll's that -+ # are installed into $libdir/../bin (currently, that works fine) -+ # but it's something to keep an eye on. - if test "$inst_prefix_dir" = "$destdir"; then - $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. -- relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` -+ relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else -- relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"` -+ relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - $echo "$modename: warning: relinking \`$file'" 1>&2 -@@ -4240,7 +5608,7 @@ - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - fi - -@@ -4264,23 +5632,36 @@ - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. -+ # Try `ln -sf' first, because the `ln' binary might depend on -+ # the symlink we replace! Solaris /bin/ln does not understand -f, -+ # so we also need to try rm && ln -s. - for linkname - do - if test "$linkname" != "$realname"; then -- $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" -- $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" -+ $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" -+ $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" -- eval cmds=\"$postinstall_cmds\" -+ cmds=$postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" -- $run eval "$cmd" || exit $? -+ $run eval "$cmd" || { -+ lt_exit=$? -+ -+ # Restore the uninstalled library and exit -+ if test "$mode" = relink; then -+ $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' -+ fi -+ -+ exit $lt_exit -+ } - done - IFS="$save_ifs" - fi -@@ -4318,7 +5699,7 @@ - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - -@@ -4336,7 +5717,7 @@ - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi -- exit 0 -+ exit $EXIT_SUCCESS - ;; - - *) -@@ -4348,21 +5729,47 @@ - destfile="$destdir/$destfile" - fi - -+ # If the file is missing, and there is a .exe on the end, strip it -+ # because it is most likely a libtool script we actually want to -+ # install -+ stripped_ext="" -+ case $file in -+ *.exe) -+ if test ! -f "$file"; then -+ file=`$echo $file|${SED} 's,.exe$,,'` -+ stripped_ext=".exe" -+ fi -+ ;; -+ esac -+ - # Do a test to see if this is really a libtool program. -- if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ case $host in -+ *cygwin*|*mingw*) -+ wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` -+ ;; -+ *) -+ wrapper=$file -+ ;; -+ esac -+ if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then - notinst_deplibs= - relink_command= - -+ # Note that it is not necessary on cygwin/mingw to append a dot to -+ # foo even if both foo and FILE.exe exist: automatic-append-.exe -+ # behavior happens only for exec(3), not for open(2)! Also, sourcing -+ # `FILE.' does not work on cygwin managed mounts. -+ # - # If there is no directory component, then add one. -- case $file in -- */* | *\\*) . $file ;; -- *) . ./$file ;; -+ case $wrapper in -+ */* | *\\*) . ${wrapper} ;; -+ *) . ./${wrapper} ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then -- $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 -- exit 1 -+ $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 -+ exit $EXIT_FAILURE - fi - - finalize=yes -@@ -4384,10 +5791,15 @@ - done - - relink_command= -+ # Note that it is not necessary on cygwin/mingw to append a dot to -+ # foo even if both foo and FILE.exe exist: automatic-append-.exe -+ # behavior happens only for exec(3), not for open(2)! Also, sourcing -+ # `FILE.' does not work on cygwin managed mounts. -+ # - # If there is no directory component, then add one. -- case $file in -- */* | *\\*) . $file ;; -- *) . ./$file ;; -+ case $wrapper in -+ */* | *\\*) . ${wrapper} ;; -+ *) . ./${wrapper} ;; - esac - - outputname= -@@ -4395,17 +5807,17 @@ - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" -- tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null` -- if test $? = 0 ; then : -- else -- tmpdir="$tmpdir/libtool-$$" -- fi -- if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : -+ tmpdir="$tmpdir/libtool-$$" -+ save_umask=`umask` -+ umask 0077 -+ if $mkdir "$tmpdir"; then -+ umask $save_umask - else -+ umask $save_umask - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi -- file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` -+ file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` -@@ -4423,14 +5835,14 @@ - fi - else - # Install the binary that we compiled earlier. -- file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` -+ file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another -- # one anyways -+ # one anyway - case $install_prog,$host in -- /usr/bin/install*,*cygwin*) -+ */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok -@@ -4439,7 +5851,7 @@ - destfile=$destfile.exe - ;; - *:*.exe) -- destfile=`echo $destfile | sed -e 's,.exe$,,'` -+ destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` - ;; - esac - ;; -@@ -4460,16 +5872,17 @@ - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - -- if test -n "$stripme" && test -n "$striplib"; then -+ if test -n "$stripme" && test -n "$old_striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. -- eval cmds=\"$old_postinstall_cmds\" -+ cmds=$old_postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done -@@ -4483,9 +5896,9 @@ - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" -- exec_cmd='$SHELL $0 --finish$current_libdirs' -+ exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else -- exit 0 -+ exit $EXIT_SUCCESS - fi - ;; - -@@ -4504,10 +5917,11 @@ - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. -- eval cmds=\"$finish_cmds\" -+ cmds=$finish_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" -@@ -4524,43 +5938,43 @@ - fi - - # Exit here if they wanted silent mode. -- test "$show" = : && exit 0 -+ test "$show" = : && exit $EXIT_SUCCESS - -- echo "----------------------------------------------------------------------" -- echo "Libraries have been installed in:" -+ $echo "----------------------------------------------------------------------" -+ $echo "Libraries have been installed in:" - for libdir in $libdirs; do -- echo " $libdir" -+ $echo " $libdir" - done -- echo -- echo "If you ever happen to want to link against installed libraries" -- echo "in a given directory, LIBDIR, you must either use libtool, and" -- echo "specify the full pathname of the library, or use the \`-LLIBDIR'" -- echo "flag during linking and do at least one of the following:" -+ $echo -+ $echo "If you ever happen to want to link against installed libraries" -+ $echo "in a given directory, LIBDIR, you must either use libtool, and" -+ $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" -+ $echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then -- echo " - add LIBDIR to the \`$shlibpath_var' environment variable" -- echo " during execution" -+ $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" -+ $echo " during execution" - fi - if test -n "$runpath_var"; then -- echo " - add LIBDIR to the \`$runpath_var' environment variable" -- echo " during linking" -+ $echo " - add LIBDIR to the \`$runpath_var' environment variable" -+ $echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - -- echo " - use the \`$flag' linker flag" -+ $echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then -- echo " - have your system administrator run these commands:$admincmds" -+ $echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then -- echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" -+ $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi -- echo -- echo "See any operating system documentation about shared libraries for" -- echo "more information, such as the ld(1) and ld.so(8) manual pages." -- echo "----------------------------------------------------------------------" -- exit 0 -+ $echo -+ $echo "See any operating system documentation about shared libraries for" -+ $echo "more information, such as the ld(1) and ld.so(8) manual pages." -+ $echo "----------------------------------------------------------------------" -+ exit $EXIT_SUCCESS - ;; - - # libtool execute mode -@@ -4572,7 +5986,7 @@ - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Handle -dlopen flags immediately. -@@ -4580,18 +5994,18 @@ - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. -- if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : -+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - # Read the libtool library. -@@ -4618,7 +6032,7 @@ - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - ;; - -@@ -4658,7 +6072,7 @@ - -*) ;; - *) - # Do a test to see if this is really a libtool program. -- if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; -@@ -4681,7 +6095,7 @@ - eval "export $shlibpath_var" - fi - -- # Restore saved enviroment variables -+ # Restore saved environment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi -@@ -4698,7 +6112,7 @@ - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" -- exit 0 -+ exit $EXIT_SUCCESS - fi - ;; - -@@ -4726,18 +6140,19 @@ - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - - rmdirs= - -+ origobjdir="$objdir" - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. -- objdir="$objdir" -+ objdir="$origobjdir" - else -- objdir="$dir/$objdir" -+ objdir="$dir/$origobjdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test "$mode" = uninstall && objdir="$dir" -@@ -4767,7 +6182,7 @@ - case $name in - *.la) - # Possibly a libtool archive, so verify it. -- if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. -@@ -4780,10 +6195,11 @@ - if test "$mode" = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. -- eval cmds=\"$postuninstall_cmds\" -+ cmds=$postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then -@@ -4795,10 +6211,11 @@ - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. -- eval cmds=\"$old_postuninstall_cmds\" -+ cmds=$old_postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" -+ eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then -@@ -4813,22 +6230,52 @@ - ;; - - *.lo) -- if test "$build_old_libs" = yes; then -- oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` -- rmfiles="$rmfiles $dir/$oldobj" -+ # Possibly a libtool object, so verify it. -+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ -+ # Read the .lo file -+ . $dir/$name -+ -+ # Add PIC object to the list of files to remove. -+ if test -n "$pic_object" \ -+ && test "$pic_object" != none; then -+ rmfiles="$rmfiles $dir/$pic_object" -+ fi -+ -+ # Add non-PIC object to the list of files to remove. -+ if test -n "$non_pic_object" \ -+ && test "$non_pic_object" != none; then -+ rmfiles="$rmfiles $dir/$non_pic_object" -+ fi - fi - ;; - - *) -- # Do a test to see if this is a libtool program. -- if test "$mode" = clean && -- (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -- relink_command= -- . $dir/$file -+ if test "$mode" = clean ; then -+ noexename=$name -+ case $file in -+ *.exe) -+ file=`$echo $file|${SED} 's,.exe$,,'` -+ noexename=`$echo $name|${SED} 's,.exe$,,'` -+ # $file with .exe has already been added to rmfiles, -+ # add $file without .exe -+ rmfiles="$rmfiles $file" -+ ;; -+ esac -+ # Do a test to see if this is a libtool program. -+ if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then -+ relink_command= -+ . $dir/$noexename - -- rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" -- if test "$fast_install" = yes && test -n "$relink_command"; then -- rmfiles="$rmfiles $objdir/lt-$name" -+ # note $name still contains .exe if it was in $file originally -+ # as does the version of $file that was added into $rmfiles -+ rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" -+ if test "$fast_install" = yes && test -n "$relink_command"; then -+ rmfiles="$rmfiles $objdir/lt-$name" -+ fi -+ if test "X$noexename" != "X$name" ; then -+ rmfiles="$rmfiles $objdir/lt-${noexename}.c" -+ fi - fi - fi - ;; -@@ -4836,6 +6283,7 @@ - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done -+ objdir="$origobjdir" - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do -@@ -4851,20 +6299,20 @@ - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - fi - fi # test -z "$show_help" - - if test -n "$exec_cmd"; then - eval exec $exec_cmd -- exit 1 -+ exit $EXIT_FAILURE - fi - - # We need to display help for each of the modes. -@@ -4883,6 +6331,7 @@ - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages -+ --tag=TAG use configuration variables from tag TAG - --version print version information - - MODE must be one of the following: -@@ -4896,8 +6345,10 @@ - uninstall remove libraries from an installed directory - - MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for --a more detailed description of MODE." -- exit 0 -+a more detailed description of MODE. -+ -+Report bugs to ." -+ exit $EXIT_SUCCESS - ;; - - clean) -@@ -5008,6 +6459,9 @@ - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -+ -objectlist FILE Use a list of object files found in FILE to specify objects -+ -precious-files-regex REGEX -+ don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -@@ -5049,14 +6503,34 @@ - *) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 -- exit 1 -+ exit $EXIT_FAILURE - ;; - esac - --echo -+$echo - $echo "Try \`$modename --help' for more information about other modes." - --exit 0 -+exit $? -+ -+# The TAGs below are defined such that we never get into a situation -+# in which we disable both kinds of libraries. Given conflicting -+# choices, we go for a static library, that is the most portable, -+# since we can't tell whether shared libraries were disabled because -+# the user asked for that or because the platform doesn't support -+# them. This is particularly important on AIX, because we don't -+# support having both static and shared libraries enabled at the same -+# time on that platform, so we default to a shared-only configuration. -+# If a disable-shared tag is given, we'll fallback to a static-only -+# configuration. But we'll never go from static-only to shared-only. -+ -+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -+build_libtool_libs=no -+build_old_libs=yes -+# ### END LIBTOOL TAG CONFIG: disable-shared -+ -+# ### BEGIN LIBTOOL TAG CONFIG: disable-static -+build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` -+# ### END LIBTOOL TAG CONFIG: disable-static - - # Local Variables: - # mode:shell-script ---- gsmlib-1.10.orig/doc/gsmsmsstore.man -+++ gsmlib-1.10/doc/gsmsmsstore.man -@@ -15,36 +15,36 @@ - gsmsmsstore \- SMS store manipulation program - .SH SYNOPSIS - .B gsmsmsstore --[ \fB-a\fP ] --[ \fB--add\fP ] --[ \fB-b\fP \fIbaudrate\fP ] --[ \fB--baudrate\fP \fIbaudrate\fP ] --[ \fB-c\fP ] --[ \fB--copy\fP ] --[ \fB-C\fP \fIservice centre address\fP ] --[ \fB--sca\fP \fIservice centre address\fP ] --[ \fB-d\fP \fIdestination device or file\fP ] --[ \fB--destination\fP \fIdestination device or file\fP ] --[ \fB-h\fP ] --[ \fB--help\fP ] --[ \fB-I\fP \fIinit string\fP ] --[ \fB--init\fP \fIinit string\fP ] --[ \fB-k\fP ] --[ \fB--backup\fP ] --[ \fB-l\fP ] --[ \fB--list\fP ] --[ \fB-s\fP \fIsource device or file\fP ] --[ \fB--source\fP \fIsource device or file\fP ] --[ \fB-t\fP \fISMS store name\fP ] --[ \fB--store\fP \fISMS store name\fP ] --[ \fB-v\fP ] --[ \fB--version\fP ] --[ \fB-V\fP ] --[ \fB--verbose\fP ] --[ \fB-x\fP ] --[ \fB--delete\fP ] --[ \fB-X\fP ] --[ \fB--xonxoff\fP ] -+[ \fB\-a\fP ] -+[ \fB\-\-add\fP ] -+[ \fB\-b\fP \fIbaudrate\fP ] -+[ \fB\-\-baudrate\fP \fIbaudrate\fP ] -+[ \fB\-c\fP ] -+[ \fB\-\-copy\fP ] -+[ \fB\-C\fP \fIservice centre address\fP ] -+[ \fB\-\-sca\fP \fIservice centre address\fP ] -+[ \fB\-d\fP \fIdestination device or file\fP ] -+[ \fB\-\-destination\fP \fIdestination device or file\fP ] -+[ \fB\-h\fP ] -+[ \fB\-\-help\fP ] -+[ \fB\-I\fP \fIinit string\fP ] -+[ \fB\-\-init\fP \fIinit string\fP ] -+[ \fB\-k\fP ] -+[ \fB\-\-backup\fP ] -+[ \fB\-l\fP ] -+[ \fB\-\-list\fP ] -+[ \fB\-s\fP \fIsource device or file\fP ] -+[ \fB\-\-source\fP \fIsource device or file\fP ] -+[ \fB\-t\fP \fISMS store name\fP ] -+[ \fB\-\-store\fP \fISMS store name\fP ] -+[ \fB\-v\fP ] -+[ \fB\-\-version\fP ] -+[ \fB\-V\fP ] -+[ \fB\-\-verbose\fP ] -+[ \fB\-x\fP ] -+[ \fB\-\-delete\fP ] -+[ \fB\-X\fP ] -+[ \fB\-\-xonxoff\fP ] - { \fIindices\fP } - [ \fIphonenumber\fP \fItext\fP ] - .PP -@@ -57,19 +57,19 @@ - \fIgsmsmsstore\fP reads entries from the source which can be a mobile - phone (if a serial device file is given) or a file (if a file name is - given). The source is never modified. \fIgsmsmsstore\fP writes SMS --messages to a destination file or device in the case of \fB--copy\fP, --\fB--backup\fP, and \fB--add\fP. -+messages to a destination file or device in the case of \fB\-\-copy\fP, -+\fB\-\-backup\fP, and \fB\-\-add\fP. - .PP --The \fB--list\fP option does not change any file but just lists the -+The \fB\-\-list\fP option does not change any file but just lists the - contents to standard output. - .PP --The \fB--backup\fP and \fB--copy\fP options require both source and --destination files or devices. The \fB--list\fP option requires a --source. The \fB--add\fP and \fB--delete\fP options require a -+The \fB\-\-backup\fP and \fB\-\-copy\fP options require both source and -+destination files or devices. The \fB\-\-list\fP option requires a -+source. The \fB\-\-add\fP and \fB\-\-delete\fP options require a - destination file or device. - .PP --If "-" is given as the parameter for the \fB--source\fP or --\fB--destination\fP options, the SMS store is read from standard input -+If "\-" is given as the parameter for the \fB\-\-source\fP or -+\fB\-\-destination\fP options, the SMS store is read from standard input - and/or written to standard output, respectively. - .PP - SMS message files are not human-readable. -@@ -79,61 +79,61 @@ - .PP - .SH OPTIONS - .TP --\fB-a\fP, \fB--add\fP -+\fB\-a\fP, \fB\-\-add\fP - Adds an SMS submit message with recipient address \fIphonenumber\fP and - text \fItext\fP to the destination. - .TP --\fB-b\fP \fIbaudrate\fP, \fB--baudrate\fP \fIbaudrate\fP -+\fB\-b\fP \fIbaudrate\fP, \fB\-\-baudrate\fP \fIbaudrate\fP - The baud rate to use. The default baudrate is 38400. - .TP --\fB-c\fP, \fB--copy\fP -+\fB\-c\fP, \fB\-\-copy\fP - This causes the contents of the source to be copied to the - destination. After this operation the destination has exactly the same - contents as the source. If \fIindices\fP are given on the command - line only those SMS messages denoted by the indices are copied to the - destination. - .TP --\fB-C\fP \fIservice centre address\fP, \fB--sca\fP \fIservice centre address\fP -+\fB\-C\fP \fIservice centre address\fP, \fB\-\-sca\fP \fIservice centre address\fP - Sets the service centre address to use for all SUBMIT SMSs (may not - work with some phones). - .TP --\fB-d\fP \fIdestination\fP, \fB--destination\fP \fIdestination\fP -+\fB\-d\fP \fIdestination\fP, \fB\-\-destination\fP \fIdestination\fP - The destination device or file. - .TP --\fB-h\fP, \fB--help\fP -+\fB\-h\fP, \fB\-\-help\fP - Prints an option summary. - .TP --\fB-I\fP \fIinit string\fP, \fB--init\fP \fIinit string\fP -+\fB\-I\fP \fIinit string\fP, \fB\-\-init\fP \fIinit string\fP - Initialization string to send to the TA (default: "E0"). Note that the - sequence "ATZ" is sent first. - .TP --\fB-k\fP, \fB--backup\fP -+\fB\-k\fP, \fB\-\-backup\fP - This causes those entries to be added from the source to the - destination that are not already present in the destination. If - \fIindices\fP are given on the command line only those SMS messages - denoted by the indices are backed up (ie. added) to the destination. - .TP --\fB-l\fP, \fB--list\fP -+\fB\-l\fP, \fB\-\-list\fP - Prints out the entire contents of the source in human-readable form. - .TP --\fB-s\fP \fIsource\fP, \fB--source\fP \fIsource\fP -+\fB\-s\fP \fIsource\fP, \fB\-\-source\fP \fIsource\fP - The source device or file. - .TP --\fB-t\fP \fISMS store name\fP, \fB--store\fP \fISMS store name\fP -+\fB\-t\fP \fISMS store name\fP, \fB\-\-store\fP \fISMS store name\fP - The name of the SMS store to read from or write to. This information is - only used for device sources and destinations. A commonly available message - store is "SM" (SIM card). - .TP --\fB-v\fP, \fB--version\fP -+\fB\-v\fP, \fB\-\-version\fP - Prints the program version. - .TP --\fB-V\fP, \fB--verbose\fP -+\fB\-V\fP, \fB\-\-verbose\fP - Prints out a detailed progress report. - .TP --\fB-x\fP, \fB--delete\fP -+\fB\-x\fP, \fB\-\-delete\fP - Delete the SMS messages as denoted by the \fIindices\fP from the destination. - .TP --\fB-X\fP, \fB--xonxoff\fP -+\fB\-X\fP, \fB\-\-xonxoff\fP - Uses software handshaking (XON/XOFF) for accessing the device. - .PP - .SH EXAMPLES -@@ -141,15 +141,15 @@ - to \fI/dev/mobilephone\fP to the standard output: - .PP - .nf --gsmsmsstore -b 19200 -s /dev/mobilephone -t SM -l -+gsmsmsstore \-b 19200 \-s /dev/mobilephone \-t SM \-l - .fi - .PP - The following adds entries 4, 7, and 10 from the device - \fI/dev/mobilephone\fP to the file \fIsmsstore\fP: - .PP - .nf --gsmsmsstore -s /dev/mobilephone -d /home/fred/smsstore -- -t SM -b 4 7 10 -+gsmsmsstore \-s /dev/mobilephone \-d /home/fred/smsstore -+ \-t SM \-b 4 7 10 - .fi - .PP - .SH AUTHOR ---- gsmlib-1.10.orig/doc/gsmsmsd.man -+++ gsmlib-1.10/doc/gsmsmsd.man -@@ -17,34 +17,34 @@ - .PP - .SH SYNOPSIS - .B gsmsmsd --[ \fB-a\fP \fIaction\fP ] --[ \fB--action\fP \fIaction\fP ] --[ \fB-b\fP \fIbaudrate\fP ] --[ \fB--baudrate\fP \fIbaudrate\fP ] --[ \fB-c\fP \fIconcatenatedID\fP ] --[ \fB--concatenate\fP \fIconcatenatedID\fP ] --[ \fB-C\fP \fIservice centre address\fP ] --[ \fB--sca\fP \fIservice centre address\fP ] --[ \fB-d\fP \fIdevice\fP ] --[ \fB--device\fP \fIdevice\fP ] --[ \fB-D\fP ] --[ \fB--direct\fP ] --[ \fB-f\fP ] --[ \fB--flush\fP ] --[ \fB-h\fP ] --[ \fB--help\fP ] --[ \fB-I\fP \fIinit string\fP ] --[ \fB--init\fP \fIinit string\fP ] --[ \fB-r\fP ] --[ \fB--requeststat\fP ] --[ \fB-s\fP \fIspool directory\fP ] --[ \fB--spool\fP \fIspool directory\fP ] --[ \fB-t\fP \fISMS store name\fP ] --[ \fB--store\fP \fISMS store name\fP ] --[ \fB-v\fP ] --[ \fB--version\fP ] --[ \fB-X\fP ] --[ \fB--xonxoff\fP ] -+[ \fB\-a\fP \fIaction\fP ] -+[ \fB\-\-action\fP \fIaction\fP ] -+[ \fB\-b\fP \fIbaudrate\fP ] -+[ \fB\-\-baudrate\fP \fIbaudrate\fP ] -+[ \fB\-c\fP \fIconcatenatedID\fP ] -+[ \fB\-\-concatenate\fP \fIconcatenatedID\fP ] -+[ \fB\-C\fP \fIservice centre address\fP ] -+[ \fB\-\-sca\fP \fIservice centre address\fP ] -+[ \fB\-d\fP \fIdevice\fP ] -+[ \fB\-\-device\fP \fIdevice\fP ] -+[ \fB\-D\fP ] -+[ \fB\-\-direct\fP ] -+[ \fB\-f\fP ] -+[ \fB\-\-flush\fP ] -+[ \fB\-h\fP ] -+[ \fB\-\-help\fP ] -+[ \fB\-I\fP \fIinit string\fP ] -+[ \fB\-\-init\fP \fIinit string\fP ] -+[ \fB\-r\fP ] -+[ \fB\-\-requeststat\fP ] -+[ \fB\-s\fP \fIspool directory\fP ] -+[ \fB\-\-spool\fP \fIspool directory\fP ] -+[ \fB\-t\fP \fISMS store name\fP ] -+[ \fB\-\-store\fP \fISMS store name\fP ] -+[ \fB\-v\fP ] -+[ \fB\-\-version\fP ] -+[ \fB\-X\fP ] -+[ \fB\-\-xonxoff\fP ] - { \fIsms_type\fP } - .PP - .SH DESCRIPTION -@@ -65,10 +65,10 @@ - \fIgsmsmsd\fP needs one empty storage slot for SMS messages in the - mobile phone, otherwise SMS reception will not work. The SMS store to - use for temporary storage of incoming SMS can be selected using the --\fB--store\fP option, otherwise the ME default store is used. -+\fB\-\-store\fP option, otherwise the ME default store is used. - .PP - To terminate \fIgsmsmsd\fP cleanly (without losing SMS messages) one --should send either SIGINT (CTRL-C on the command line) or SIGTERM to -+should send either SIGINT (CTRL\-C on the command line) or SIGTERM to - the process. - .PP - Error messages are printed to the standard error output. If the program -@@ -89,14 +89,14 @@ - .PP - .SH OPTIONS - .TP --\fB-a\fP \fIaction\fP, \fB--action\fP \fIaction\fP -+\fB\-a\fP \fIaction\fP, \fB\-\-action\fP \fIaction\fP - The action to execute for each incoming SMS message. If no action - is given the SMS is written to the standard output. - .TP --\fB-b\fP \fIbaudrate\fP, \fB--baudrate\fP \fIbaudrate\fP -+\fB\-b\fP \fIbaudrate\fP, \fB\-\-baudrate\fP \fIbaudrate\fP - The baud rate to use. - .TP --\fB-c\fP \fIconcatenatedID\fP, \fB--concatenate\fP \fIconcatenatedID\fP -+\fB\-c\fP \fIconcatenatedID\fP, \fB\-\-concatenate\fP \fIconcatenatedID\fP - If an ID is given, large SMSs are split into several, concatenated - SMSs. All SMSs have the same ID and are numbered consecutively so that - the receiving phone can assemble them in the correct order. IDs must -@@ -108,43 +108,43 @@ - carried in the user data header element at the beginning of the SMS - user data. This information may show up as garbage in such phones. - .TP --\fB-C\fP \fIservice centre address\fP, \fB--sca\fP \fIservice centre address\fP -+\fB\-C\fP \fIservice centre address\fP, \fB\-\-sca\fP \fIservice centre address\fP - Sets the service centre address to use for all SUBMIT SMSs (may not - work with some phones). - .TP --\fB-d\fP \fIdevice\fP, \fB--device\fP \fIdevice\fP -+\fB\-d\fP \fIdevice\fP, \fB\-\-device\fP \fIdevice\fP - The device to which the GSM modem is connected. The default is - \fI/dev/mobilephone\fP. - .TP --\fB-D\fP, \fB--direct\fP -+\fB\-D\fP, \fB\-\-direct\fP - Enables direct routing of incoming SMS messages to the TE. This is not - supported by many mobile phone/GSM modem combinations. Therefore, the - default is to store incoming SMS temporarily before processing them in - the indicated store. - .TP --\fB-f\fP, \fB--flush\fP -+\fB\-f\fP, \fB\-\-flush\fP - This option causes \fIgsmsmsd\fP to flush (ie. read and erase) - existing SMS messages from --the SMS store selected by the \fB--store\fP option. The action given --by the \fB--action\fP option is executed on each of the flushed -+the SMS store selected by the \fB\-\-store\fP option. The action given -+by the \fB\-\-action\fP option is executed on each of the flushed - SMS. This option should be used to ensure that enough space is - available in the SMS store for temporary storage of incoming SMS, - otherwise incoming SMS might be ignored silently by the ME. - .TP --\fB-h\fP, \fB--help\fP -+\fB\-h\fP, \fB\-\-help\fP - Prints an option summary. - .TP --\fB-I\fP \fIinit string\fP, \fB--init\fP \fIinit string\fP -+\fB\-I\fP \fIinit string\fP, \fB\-\-init\fP \fIinit string\fP - Initialization string to send to the TA (default: "E0"). Note that the - sequence "ATZ" is sent first. - .TP --\fB-r\fP, \fB--requeststat\fP -+\fB\-r\fP, \fB\-\-requeststat\fP - Request status reports for sent SMS. Note: This option only makes - sense if the phone supports routing of status reports to the - TE. Otherwise the status reports might show on the phone's display or - get lost. - .TP --\fB-s\fP \fIspool directory\fP, \fB--spool\fP \fIspool directory\fP -+\fB\-s\fP \fIspool directory\fP, \fB\-\-spool\fP \fIspool directory\fP - This option sets the spool directory where \fIgsmsmsd\fP expects SMS - messages to send. The format of SMS files is very simple: The first - line contains the phone number of the recipient. Everything else after -@@ -154,18 +154,18 @@ - \fIgsmsmsd\fP polls the spool directory every 5 seconds. Sent - SMS message files are removed. - .TP --\fB-t\fP \fISMS store name\fP, \fB--store\fP \fISMS store name\fP --The name of the SMS store to read from (for the \fB--flush\fP option) -+\fB\-t\fP \fISMS store name\fP, \fB\-\-store\fP \fISMS store name\fP -+The name of the SMS store to read from (for the \fB\-\-flush\fP option) - or write to (for temporary SMS storage). This option must --be must be used in conjunction with the \fB--flush\fP option. If this -+be must be used in conjunction with the \fB\-\-flush\fP option. If this - option is omitted the ME uses it's default SMS store for temporary - storage of incoming SMS. A commonly available message - store is "SM" (SIM card). - .TP --\fB-v\fP, \fB--version\fP -+\fB\-v\fP, \fB\-\-version\fP - Prints the program version. - .TP --\fB-X\fP, \fB--xonxoff\fP -+\fB\-X\fP, \fB\-\-xonxoff\fP - Uses software handshaking (XON/XOFF) for accessing the device. - .PP - .SH EXAMPLES -@@ -173,14 +173,14 @@ - as a mail to the user "smsadmin": - .PP - .nf --gsmsmsd -d /dev/ttyS2 -b 19200 -a "mail smsadmin" -+gsmsmsd \-d /dev/ttyS2 \-b 19200 \-a "mail smsadmin" - .fi - .PP - This is the format of SMS deliver messages as output from \fIgsmsmsd\fP: - .PP - .nf - ---------------------------------------------------------------- --Message type: SMS-DELIVER -+Message type: SMS\-DELIVER - SC address: '491710762100' - More messages to send: 1 - Reply path: 0 -@@ -202,7 +202,7 @@ - .PP - .nf - ---------------------------------------------------------------- --Message type: SMS-STATUS-REPORT -+Message type: SMS\-STATUS\-REPORT - SC address: '' - More messages to send: 0 - Status report qualifier: 0 -@@ -219,8 +219,8 @@ - directory for SMS to send: - .PP - .nf --gsmsmsd -d /dev/ttyS2 --spool /tmp/spooldir -f --store sm \\ ----action 'mail smsadmin' -+gsmsmsd \-d /dev/ttyS2 \-\-spool /tmp/spooldir \-f \-\-store sm \\ -+\-\-action 'mail smsadmin' - .fi - .PP - .SH FILES ---- gsmlib-1.10.orig/doc/gsmctl.man -+++ gsmlib-1.10/doc/gsmctl.man -@@ -1,6 +1,6 @@ - .TH GSMCTL 8 "##DATE##" "gsmctl v##VERSION##" - .SH NAME --gsmctl \- GSM mobile phone control program -+gsmctl, gsmsiectl \- GSM mobile phone control program - .SH SYNOPSIS - .B gsmctl - .RB [\| \-b -@@ -25,6 +25,30 @@ - .RB | \ \-\-operation - .IR operation \ | - .I parameters -+.PP -+.B gsmsiectl -+.RB [\| \-b -+.IR baudrate \|] -+.RB [\| \-\-baudrate -+.IR baudrate\| ] -+.RB [ \|\-d -+.IR device\| ] -+.RB [ \|\-\-device -+.IR device\fP ] -+.RB [ \|\-h\| ] -+.RB [ \|\-\-help\| ] -+.RB [ \|\-I -+.IR "init string" \|] -+.RB [ \|\-\-init -+.IR "init string" \|] -+.RB [ \|\-v\| ] -+.RB [ \|\-\-version\| ] -+.RB [ \|\-X\| ] -+.RB [ \|\-\-xonxoff\| ] -+.BI \-o \ operation -+.RB | \ \-\-operation -+.IR operation \ | -+.I parameters - .SH DESCRIPTION - .B gsmctl - can request information from or perform operations on an GSM mobile -@@ -38,7 +62,7 @@ - If no - .I device - is given, the device --.I/dev/mobilephone -+.I /dev/mobilephone - is used. If no - .I baudrate - is given, a default baud rate of 38400 is used. -@@ -61,6 +85,12 @@ - .B OPERATIONS - for more details. - .PP -+.B gsmsiectl -+is the same program with some extension for Siemens mobile phones. -+Some extra -+.B OPERATIONS -+are available in this case. -+.PP - Error messages are printed to the standard error output. If the - program terminates on error the error code 1 is returned. - .SH OPTIONS -@@ -252,14 +282,14 @@ - .I SIM PUK - ME is waiting SIM PUK to be given. - .TP --.I PH-SIM PIN --ME is waiting phone-to-SIM card password to be given. -+.I PH\-SIM PIN -+ME is waiting phone/-to/-SIM card password to be given. - .TP --.I PH-FSIM PIN --ME is waiting phone-to-very first SIM card password to be given. -+.I PH/-FSIM PIN -+ME is waiting phone/-to/-very first SIM card password to be given. - .TP --.I PH-FSIM PUK --ME is waiting phone-to-very first SIM card unblocking password to be -+.I PH/-FSIM PUK -+ME is waiting phone/-to/-very first SIM card unblocking password to be - given. - .TP - .I SIM PIN2 -@@ -268,13 +298,13 @@ - .I SIM PUK2 - ME is waiting SIM PUK2 to be given. - .TP --.I PH-NET PIN -+.I PH/-NET PIN - ME is waiting network personalisation password to be given. - .TP --.I PH-NET PUK -+.I PH/-NET PUK - ME is waiting network personalisation unblocking password to be given. - .TP --.I PH-NETSUB PIN -+.I PH/-NETSUB PIN - ME is waiting network subset personalisation password to be given. - .RE - .TP 7 -@@ -458,6 +488,33 @@ - This is the reverse operation to \fBlock\fP. See above for a - description of the parameters. - .RE -+.PP -+.B Extra operators for gsmsiectl: -+.PP -+.B cset -+.RS -+Charset info. -+.RE -+.PP -+.B pbook -+.RS -+Phone book info. -+.RE -+.PP -+.B signal -+.RS -+Signal tone info. -+.RE -+.PP -+.B ring -+.RS -+Ringing tone info. -+.RE -+.PP -+.B binary -+.RS -+Binary info. -+.RE - .SH EXAMPLES - The following invocation of - .I gsmctl -@@ -482,11 +539,11 @@ - .HP - Serial Number: 448058511817585 - .HP -- Status: available Long name: 'D1-TELEKOM' Short name: '' Numeric name: 26201 -+ Status: available Long name: 'D1/-TELEKOM' Short name: '' Numeric name: 26201 - .HP - Status: forbidden Long name: 'D2 PRIVAT' Short name: '' Numeric name: 26202 - .HP -- Long name: 'D1-TELEKOM' Short name: '' Numeric name: 26201 Mode: automatic -+ Long name: 'D1/-TELEKOM' Short name: '' Numeric name: 26201 Mode: automatic - .HP - 'CS' - .HP ---- gsmlib-1.10.orig/doc/gsmsendsms.man -+++ gsmlib-1.10/doc/gsmsendsms.man -@@ -17,26 +17,26 @@ - .PP - .SH SYNOPSIS - .B gsmsendsms --[ \fB-b\fP \fIbaudrate\fP ] --[ \fB--baudrate\fP \fIbaudrate\fP ] --[ \fB-c\fP \fIconcatenatedID\fP ] --[ \fB--concatenate\fP \fIconcatenatedID\fP ] --[ \fB-C\fP \fIservice centre address\fP ] --[ \fB--sca\fP \fIservice centre address\fP ] --[ \fB-d\fP \fIdevice\fP ] --[ \fB--device\fP \fIdevice\fP ] --[ \fB-h\fP ] --[ \fB--help\fP ] --[ \fB-I\fP \fIinit string\fP ] --[ \fB--init\fP \fIinit string\fP ] --[ \fB-r\fP ] --[ \fB--requeststat\fP ] --[ \fB-t\fP ] --[ \fB--test\fP ] --[ \fB-v\fP ] --[ \fB--version\fP ] --[ \fB-X\fP ] --[ \fB--xonxoff\fP ] -+[ \fB\-b\fP \fIbaudrate\fP ] -+[ \fB\-\-baudrate\fP \fIbaudrate\fP ] -+[ \fB\-c\fP \fIconcatenatedID\fP ] -+[ \fB\-\-concatenate\fP \fIconcatenatedID\fP ] -+[ \fB\-C\fP \fIservice centre address\fP ] -+[ \fB\-\-sca\fP \fIservice centre address\fP ] -+[ \fB\-d\fP \fIdevice\fP ] -+[ \fB\-\-device\fP \fIdevice\fP ] -+[ \fB\-h\fP ] -+[ \fB\-\-help\fP ] -+[ \fB\-I\fP \fIinit string\fP ] -+[ \fB\-\-init\fP \fIinit string\fP ] -+[ \fB\-r\fP ] -+[ \fB\-\-requeststat\fP ] -+[ \fB\-t\fP ] -+[ \fB\-\-test\fP ] -+[ \fB\-v\fP ] -+[ \fB\-\-version\fP ] -+[ \fB\-X\fP ] -+[ \fB\-\-xonxoff\fP ] - \fIphonenumber\fP - [ \fItext\fP ] - .PP -@@ -51,7 +51,7 @@ - \fIgsmsendsms\fP accepts a phone number (recipient address) and the - short message text as parameters. The text may have a maximum length - of 160 characters which is the maximum SMS message length. The GSM --default alphabet is used for encoding. ASCII and Latin-1 characters -+default alphabet is used for encoding. ASCII and Latin\-1 characters - that can not be encoded using the GSM default alphabet are converted - to the GSM delta character (GSM code 16). - .PP -@@ -60,10 +60,10 @@ - .PP - .SH OPTIONS - .TP --\fB-b\fP \fIbaudrate\fP, \fB--baudrate\fP \fIbaudrate\fP -+\fB\-b\fP \fIbaudrate\fP, \fB\-\-baudrate\fP \fIbaudrate\fP - The baud rate to use. - .TP --\fB-c\fP \fIconcatenatedID\fP, \fB--concatenate\fP \fIconcatenatedID\fP -+\fB\-c\fP \fIconcatenatedID\fP, \fB\-\-concatenate\fP \fIconcatenatedID\fP - If an ID is given, large SMSs are split into several, concatenated - SMSs. All SMSs have the same ID and are numbered consecutively so that - the receiving phone can assemble them in the correct order. IDs must -@@ -73,37 +73,37 @@ - carried in the user data header element at the beginning of the SMS - user data. This information may show up as garbage in such phones. - .TP --\fB-C\fP \fIservice centre address\fP, \fB--sca\fP \fIservice centre address\fP -+\fB\-C\fP \fIservice centre address\fP, \fB\-\-sca\fP \fIservice centre address\fP - Sets the service centre address to use for all SUBMIT SMSs (may not - work with some phones). - .TP --\fB-d\fP \fIdevice\fP, \fB--device\fP \fIdevice\fP -+\fB\-d\fP \fIdevice\fP, \fB\-\-device\fP \fIdevice\fP - The device to which the GSM modem is connected. The default is - \fI/dev/mobilephone\fP. - .TP --\fB-h\fP, \fB--help\fP -+\fB\-h\fP, \fB\-\-help\fP - Prints an option summary. - .TP --\fB-I\fP \fIinit string\fP, \fB--init\fP \fIinit string\fP -+\fB-I\fP \fIinit string\fP, \fB\-\-init\fP \fIinit string\fP - Initialization string to send to the TA (default: "E0"). Note that the - sequence "ATZ" is sent first. - .TP --\fB-r\fP, \fB--requeststat\fP -+\fB\-r\fP, \fB\-\-requeststat\fP - Request status reports for sent SMS. - .TP --\fB-t\fP, \fB--test\fP -+\fB\-t\fP, \fB\-\-test\fP - If this option is given the text is converted --to the GSM default alphabet and back to Latin-1. This option can be --used to find out how ASCII or Latin-1 texts are converted to the GSM -+to the GSM default alphabet and back to Latin\-1. This option can be -+used to find out how ASCII or Latin\-1 texts are converted to the GSM - default alphabet. Characters that can not be converted to the GSM default --alphabet are reported as ASCII code 172 (Latin-1 boolean "not") -+alphabet are reported as ASCII code 172 (Latin\-1 boolean "not") - after this double conversion. No SMS messages are sent, a connection - to a mobile phone is not established. - .TP --\fB-v\fP, \fB--version\fP -+\fB\-v\fP, \fB\-\-version\fP - Prints the program version. - .TP --\fB-X\fP, \fB--xonxoff\fP -+\fB\-X\fP, \fB\-\-xonxoff\fP - Uses software handshaking (XON/XOFF) for accessing the device. - .PP - .SH EXAMPLES -@@ -111,8 +111,8 @@ - SMS message to the number "1234": - .PP - .nf --gsmsendsms -d /dev/ttyS2 -b 19200 1234 "This is a test." --echo "This is a test." | gsmsendsms -d /dev/ttyS2 -b 19200 1234 -+gsmsendsms \-d /dev/ttyS2 \-b 19200 1234 "This is a test." -+echo "This is a test." | gsmsendsms \-d /dev/ttyS2 \-b 19200 1234 - .fi - .PP - .SH FILES ---- gsmlib-1.10.orig/doc/gsmpb.man -+++ gsmlib-1.10/doc/gsmpb.man -@@ -15,32 +15,32 @@ - gsmpb \- GSM mobile phone phonebook manipulation program - .SH SYNOPSIS - .B gsmpb --[ \fB-b\fP \fIbaudrate\fP ] --[ \fB--baudrate\fP \fIbaudrate\fP ] --[ \fB-c\fP ] --[ \fB--copy\fP ] --[ \fB-d\fP \fIdestination device or file\fP ] --[ \fB--destination\fP \fIdestination device or file\fP ] --[ \fB-h\fP ] --[ \fB--help\fP ] --[ \fB-i\fP ] --[ \fB--index\fP ] --[ \fB-I\fP \fIinit string\fP ] --[ \fB--init\fP \fIinit string\fP ] --[ \fB-p\fP \fIphonebook name\fP ] --[ \fB--phonebook\fP \fIphonebook name\fP ] --[ \fB-s\fP \fIsource device or file\fP ] --[ \fB--source\fP \fIsource device or file\fP ] --[ \fB-t\fP \fIcharacter set\fP ] --[ \fB--charset\fP \fIcharacter set\fP ] --[ \fB-v\fP ] --[ \fB--version\fP ] --[ \fB-V\fP ] --[ \fB--verbose\fP ] --[ \fB-X\fP ] --[ \fB--xonxoff\fP ] --[ \fB-y\fP ] --[ \fB--synchronize\fP ] -+[ \fB\-b\fP \fIbaudrate\fP ] -+[ \fB\-\-baudrate\fP \fIbaudrate\fP ] -+[ \fB\-c\fP ] -+[ \fB\-\-copy\fP ] -+[ \fB\-d\fP \fIdestination device or file\fP ] -+[ \fB\-\-destination\fP \fIdestination device or file\fP ] -+[ \fB\-h\fP ] -+[ \fB\-\-help\fP ] -+[ \fB\-i\fP ] -+[ \fB\-\-index\fP ] -+[ \fB\-I\fP \fIinit string\fP ] -+[ \fB\-\-init\fP \fIinit string\fP ] -+[ \fB\-p\fP \fIphonebook name\fP ] -+[ \fB\-\-phonebook\fP \fIphonebook name\fP ] -+[ \fB\-s\fP \fIsource device or file\fP ] -+[ \fB\-\-source\fP \fIsource device or file\fP ] -+[ \fB\-t\fP \fIcharacter set\fP ] -+[ \fB\-\-charset\fP \fIcharacter set\fP ] -+[ \fB\-v\fP ] -+[ \fB\-\-version\fP ] -+[ \fB\-V\fP ] -+[ \fB\-\-verbose\fP ] -+[ \fB\-X\fP ] -+[ \fB\-\-xonxoff\fP ] -+[ \fB\-y\fP ] -+[ \fB\-\-synchronize\fP ] - .PP - .SH DESCRIPTION - \fIgsmpb\fP can store or retrieve phonebook entries residing in a GSM -@@ -55,45 +55,45 @@ - destination, or the destination is synchronized with regard to the - source which is the default (details see below). - .PP --If "-" is given as the parameter for the \fB--source\fP or --\fB--destination\fP options, the phonebook is read from standard input -+If "\-" is given as the parameter for the \fB\-\-source\fP or -+\fB\-\-destination\fP options, the phonebook is read from standard input - and/or written to standard output, respectively. - .PP - Phonebook entries names are encoded using the GSM default alphabet in --the mobile phone, whereas they are stored using the Latin-1 encoding -+the mobile phone, whereas they are stored using the Latin\-1 encoding - in phonebook files. When reading phonebook entries from a mobile phone --entry names are converted from the GSM default to Latin-1. Characters --that can not be converted to Latin-1 are encoded as character code --172 (Latin-1 boolean "not"). When writing file-based phonebook entries -+entry names are converted from the GSM default to Latin\-1. Characters -+that can not be converted to Latin\-1 are encoded as character code -+172 (Latin\-1 boolean "not"). When writing file-based phonebook entries - to a mobile phone a conversion to the GSM default alphabet takes - place. Characters that can not be converted are encoded as GSM delta - (code 16). If the default character set has been changed using the --\fB--charset\fP option no conversion takes place. -+\fB\-\-charset\fP option no conversion takes place. - .PP - Error messages are printed to the standard error output. If the program - terminates on error the error code 1 is returned. - .PP - .SH OPTIONS - .TP .7i --\fB-b\fP \fIbaudrate\fP, \fB--baudrate\fP \fIbaudrate\fP -+\fB\-b\fP \fIbaudrate\fP, \fB\-\-baudrate\fP \fIbaudrate\fP - The baud rate to use. The default baudrate is 38400. - .TP .7i --\fB-c\fP, \fB--copy\fP -+\fB\-c\fP, \fB\-\-copy\fP - This causes the contents of the source to be copied to the - destination. After this operation the destination has exactly the same - contents as the source. - .TP .7i --\fB-d\fP \fIdestination\fP, \fB--destination\fP \fIdestination\fP -+\fB\-d\fP \fIdestination\fP, \fB\-\-destination\fP \fIdestination\fP - The destination device or file. - .TP .7i --\fB-h\fP, \fB--help\fP -+\fB\-h\fP, \fB\-\-help\fP - Prints an option summary. - .TP .7i --\fB-I\fP \fIinit string\fP, \fB--init\fP \fIinit string\fP -+\fB\-I\fP \fIinit string\fP, \fB\-\-init\fP \fIinit string\fP - Initialization string to send to the TA (default: "E0"). Note that the - sequence "ATZ" is sent first. - .TP .7i --\fB-i\fP, \fB--index\fP -+\fB\-i\fP, \fB\-\-index\fP - If the index position is given, \fIgsmpb\fP preserves the assignment - of entries to memory slots in the mobile phone's phonebook. This can - be used to backup phonebook entries with their position into a -@@ -104,7 +104,7 @@ - be unique, ie. it is not allowed to assign one entry twice to a - specific position in the mobile phone's phonebook. - .TP .7i --\fB-p\fP \fIphonebook\fP, \fB--phonebook\fP \fIphonebook\fP -+\fB\-p\fP \fIphonebook\fP, \fB\-\-phonebook\fP \fIphonebook\fP - The name of the phonebook to read from or write to. This is only used - for device sources and destinations. Commonly available phonebooks - are: -@@ -112,10 +112,10 @@ - .po +0.7i - .ll 5.8i - \fIFD\fP --SIM fixdialling-phonebook -+SIM fixdialling\-phonebook - .TP .3i - \fILD\fP --SIM last-dialling-phonebook -+SIM last\-dialling\-phonebook - .TP .3i - \fIME\fP - ME phonebook -@@ -131,23 +131,23 @@ - .TP .7i - .po -0.7i - .ll 6.5i --\fB-s\fP \fIsource\fP, \fB--source\fP \fIsource\fP -+\fB\-s\fP \fIsource\fP, \fB\-\-source\fP \fIsource\fP - The source device or file. - .TP --\fB-t\fP \fIcharacter set\fP, \fB--charset\fP \fIcharacter set\fP -+\fB\-t\fP \fIcharacter set\fP, \fB\-\-charset\fP \fIcharacter set\fP - Set the character set to use for phonebook operations (default is the - GSM default alphabet). - .TP --\fB-v\fP, \fB--version\fP -+\fB\-v\fP, \fB\-\-version\fP - Prints the program version. - .TP .7i --\fB-V\fP, \fB--verbose\fP -+\fB\-V\fP, \fB\-\-verbose\fP - Prints out a detailed progress report. - .TP .7i --\fB-X\fP, \fB--xonxoff\fP -+\fB\-X\fP, \fB\-\-xonxoff\fP - Uses software handshaking (XON/XOFF) for accessing the device. - .TP .7i --\fB-y\fP, \fB--synchronize\fP -+\fB\-y\fP, \fB\-\-synchronize\fP - This causes the contents of the source to be synchronized with the - destination (default). Synchronization in this context means: - .TP .2i -@@ -188,7 +188,7 @@ - \fIindex\fP - The index of the entry which must be a positive number. The index may - also be empty. Indices can be used in conjunction with the --\fB--index\fP option to store the entry into a specific position in -+\fB\-\-index\fP option to store the entry into a specific position in - the mobile phone. - .TP .7i - \fItext\fP -@@ -199,7 +199,7 @@ - encoded using the GSM default alphabet (see comments above). - .TP .7i - \fIphone number\fP --Phone numbers can only contains the digits 0-9 and the '+' sign. A '+' -+Phone numbers can only contains the digits 0\-9 and the '+' sign. A '+' - sign denotes an international number. - .PP - .SH EXAMPLES -@@ -207,8 +207,8 @@ - SIM phonebook with the file $HOME/.phonebook: - .PP - .nf --gsmpb --synchronize -b 19200 -d /dev/mobilephone \\ -- -s $HOME/.phonebook -p "SM" -+gsmpb \-\-synchronize \-b 19200 \-d /dev/mobilephone \\ -+ \-s $HOME/.phonebook \-p "SM" - .fi - .PP - .SH AUTHOR ---- gsmlib-1.10.orig/debian/compat -+++ gsmlib-1.10/debian/compat -@@ -0,0 +1 @@ -+4 ---- gsmlib-1.10.orig/debian/gsm-utils.cron.d -+++ gsmlib-1.10/debian/gsm-utils.cron.d -@@ -0,0 +1,3 @@ -+# /etc/cron.d/gsm-utils: crontab fragment for gsm-utils -+ -+*/5 * * * * root if [ -x /usr/bin/gsmsmsrequeue ]; then /usr/bin/gsmsmsrequeue; fi ---- gsmlib-1.10.orig/debian/copyright -+++ gsmlib-1.10/debian/copyright -@@ -0,0 +1,34 @@ -+This package was debianized by Mikael Hedin on -+Thu, 14 Dec 2000 01:06:40 +0100. -+ -+It was downloaded from http://www.pxh.de/fs/gsmlib/index.html -+ -+Upstream Author: Peter Hofmann -+ -+ext/gsmsiexfer.cc:// * Author: Christian W. Zuckschwerdt -+ -+Copyright: -+ -+ Copyright (C) 1999-2002 Peter Hofmann -+ -+License: -+ -+ This package 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 of the License, or (at your option) any later version. -+ -+ This package 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 package; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ -+On Debian systems, the complete text of the GNU Lesser General -+Public License can be found in `/usr/share/common-licenses/LGPL'. -+ -+The Debian packaging is (C) 2000, Mikael Hedin and -+is licensed under the GPL, see `/usr/share/common-licenses/GPL'. ---- gsmlib-1.10.orig/debian/gsm-utils.dirs -+++ gsmlib-1.10/debian/gsm-utils.dirs -@@ -0,0 +1,11 @@ -+var/spool/sms/queue1 -+var/spool/sms/queue2 -+var/spool/sms/queue3 -+var/spool/sms/sent1 -+var/spool/sms/sent2 -+var/spool/sms/sent3 -+var/spool/sms/failed1 -+var/spool/sms/failed2 -+var/spool/sms/failed3 -+var/spool/sms/tmp -+var/run/gsm-utils ---- gsmlib-1.10.orig/debian/gsm-utils.default -+++ gsmlib-1.10/debian/gsm-utils.default -@@ -0,0 +1,18 @@ -+PHONEDEV=/dev/mobilephone # or /dev/ttyS0 or /dev/ircomm0 -+BAUDRATE=9600 -+PIN="" # or 1234 -+ -+# RUNGSMSMS: If set to anything other that 'yes', the asterisk init.d script -+# will not run. The default is 'yes'. -+# You should probaly also install the crontab from /usr/share/doc/gsm-utils/examples -+RUNGSMSMS=no -+ -+SPOOLDIR=/var/spool/sms -+PRIORITIES=3 -+ -+SMSADMIN=root -+SUBJECT="SMS delivery report:" -+ -+SMSPROCESSOR="" # or /usr/bin/gsmsmsprocessor -+ -+do_accounting () { true; } # it's your turn ---- gsmlib-1.10.orig/debian/watch -+++ gsmlib-1.10/debian/watch -@@ -0,0 +1,2 @@ -+version=2 -+http://www.pxh.de/fs/gsmlib/download/content.html gsmlib-(.*)\.tar\.gz ---- gsmlib-1.10.orig/debian/gsm-utils.postinst -+++ gsmlib-1.10/debian/gsm-utils.postinst -@@ -0,0 +1,28 @@ -+#!/bin/sh -e -+ -+# create gsmsms group if necessary. -+if ! grep -q ^gsmsms: /etc/group; then -+# echo Adding system group: gsmsms. -+ addgroup --system gsmsms -+fi -+ -+# create gsmsms user if necessary. -+if ! grep -q ^gsmsms: /etc/passwd; then -+# echo Adding system user: gsmsms. -+ adduser --system --ingroup gsmsms \ -+ --no-create-home --home /var/spool/sms gsmsms -+fi -+ -+# allow gsmsms to use serial lines -+if ! groups gsmsms | grep -q dialout ; then -+ adduser gsmsms dialout -+fi -+ -+# echo Updating spool directory structure: /var/spool/sms -+chown -R gsmsms:gsmsms /var/spool/sms /var/run/gsm-utils -+chmod 700 /var/spool/sms/* -+chmod 750 /var/spool/sms -+chmod 730 /var/spool/sms/queue* /var/spool/sms/tmp -+ -+# Add the rest automatically.. -+#DEBHELPER# ---- gsmlib-1.10.orig/debian/control -+++ gsmlib-1.10/debian/control -@@ -0,0 +1,45 @@ -+Source: gsmlib -+Section: comm -+Priority: extra -+Maintainer: Mark Purcell -+Build-Depends: debhelper (>= 3.0.0), chrpath -+Standards-Version: 3.7.3 -+Homepage: http://www.pxh.de/fs/gsmlib/ -+ -+Package: libgsmme-dev -+Section: libdevel -+Architecture: any -+Depends: libgsmme1c2a (= ${binary:Version}), libc6-dev -+Description: Header files and static libraries for gsmlib -+ Headers and static libraries for use when compiling programs with -+ gsmlib. -+ . -+ gsmlib is a library for access to a GSM mobile phone using the -+ standards ETSI GSM 07.07, ETSI GSM 07.05, and others. -+ -+Package: libgsmme1c2a -+Conflicts: libgsmme1, libgsmme1c102, libgsmme1c2 -+Replaces: libgsmme1c102, libgsmme1c2 -+Section: libs -+Architecture: any -+Depends: ${shlibs:Depends} -+Description: GSM mobile phone access library -+ Library to access GSM mobile phones through GSM modems or IrDA devices. -+ Features include: -+ . -+ * modification of phone books stored in the mobile phone or on the -+ SIM card -+ * reading and writing of SMS messages stored in the mobile phone -+ * sending and reception of SMS messages -+ . -+ gsmlib uses standard ETSI GSM 07.07, ETSI GSM 07.05, and others. -+ -+Package: gsm-utils -+Section: comm -+Architecture: any -+Depends: ${shlibs:Depends}, adduser -+Description: GSM mobile phone access applications -+ Some simple command line programs to access a GSM mobile phone via -+ GSM modem or IrDA. Functions include: modification of phone books and -+ reading, writing, sending and receiving SMS messages. Uses the GSM -+ standards ETSI GSM 07.07, ETSI GSM 07.05, and others. ---- gsmlib-1.10.orig/debian/gsm-utils.postrm -+++ gsmlib-1.10/debian/gsm-utils.postrm -@@ -0,0 +1,43 @@ -+#!/bin/sh -+# postrm script for #PACKAGE# -+# -+# see: dh_installdeb(1) -+ -+set -e -+ -+# summary of how this script can be called: -+# * `remove' -+# * `purge' -+# * `upgrade' -+# * `failed-upgrade' -+# * `abort-install' -+# * `abort-install' -+# * `abort-upgrade' -+# * `disappear' -+# -+# for details, see http://www.debian.org/doc/debian-policy/ or -+# the debian-policy package -+ -+ -+case "$1" in -+ remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) -+ ;; -+ -+ purge) -+ deluser gsmsms -+ ;; -+ -+ *) -+ echo "postrm called with unknown argument \`$1'" >&2 -+ exit 1 -+ ;; -+esac -+ -+# dh_installdeb will replace this with shell code automatically -+# generated by other debhelper scripts. -+ -+#DEBHELPER# -+ -+exit 0 -+ -+ ---- gsmlib-1.10.orig/debian/gsmsiexfer.1 -+++ gsmlib-1.10/debian/gsmsiexfer.1 -@@ -0,0 +1,29 @@ -+.\" -*- eval: (nroff-mode) -*- -+.de TQ -+.br -+.ns -+.TP \\$1 -+.. -+.\" Like TP, but if specified indent is more than half -+.\" the current line-length - indent, use the default indent. -+.de Tp -+.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP -+.el .TP "\\$1" -+.. -+.TH GSMSIEXFER 1 "" "gsmsiexfer" -+.SH NAME -+gsmsiexfer \- Siemens ME file transfer program for Siemens phones S25, S35, S45, ME45, SL45 -+.SH SYNOPSIS -+.B gsmsiexfer \-\-help -+.PP -+.SH DESCRIPTION -+\fIgsmsiexer\fP comes with no man page. Try gsmsiexfer \-\-help, or -+read the source. -+.PP -+.SH "SEE ALSO" -+.BR gsminfo(7), -+.BR gsmctl(1), -+.BR gsmsendsms(1), -+.BR gsmsmsd(8), -+.BR gsmsmsstore(1). -+ ---- gsmlib-1.10.orig/debian/gsm-utils.examples -+++ gsmlib-1.10/debian/gsm-utils.examples -@@ -0,0 +1,2 @@ -+contrib/gsm-utils.cron.d -+contrib/gsm-utils.init ---- gsmlib-1.10.orig/debian/dirs -+++ gsmlib-1.10/debian/dirs -@@ -0,0 +1 @@ -+/var/run/gsm-utils ---- gsmlib-1.10.orig/debian/libgsmme-dev.docs -+++ gsmlib-1.10/debian/libgsmme-dev.docs -@@ -0,0 +1,2 @@ -+doc/README.developers -+doc/README.NLS ---- gsmlib-1.10.orig/debian/gsm-utils.init -+++ gsmlib-1.10/debian/gsm-utils.init -@@ -0,0 +1,87 @@ -+#! /bin/sh -+### BEGIN INIT INFO -+# Provides: gsm-utils -+# Required-Start: $remote_fs $syslog -+# Required-Stop: $remote_fs $syslog -+# Default-Start: 2 3 4 5 -+# Default-Stop: 0 1 6 -+# Short-Description: Start daemon at boot time -+# Description: Enable service provided by daemon. -+### END INIT INFO -+# -+# /etc/init.d/gsm-utils: Controls the GSM SMS send daemon -+# -+# written by Matthias Goebl -+ -+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -+DAEMON=/usr/bin/gsmsmsd -+NAME=gsmsmsd -+DESC="GSM SMS send daemon" -+ -+test -x $DAEMON || exit 0 -+ -+if [ "$RUNGSMSMS" != "yes" ];then -+ echo "GSM SMS deamon not yet configured. Edit /etc/default/gsm-utils first." -+ exit 0 -+fi -+ -+ -+PHONEDEV=/dev/mobilephone # or /dev/ttyS0 or /dev/ircomm0 -+BAUDRATE=9600 -+PIN="" # or 1234 -+SMSPROCESSOR="" # or /usr/bin/gsmsmsprocessor -+SPOOLDIR=/var/spool/sms -+PRIORITIES=3 -+STARTOPTS="" -+SMSUSER="gsmsms:gsmsms" -+test -r /etc/default/gsm-utils && . /etc/default/gsm-utils # for overwriting some parameters -+ -+OPTIONS="-d $PHONEDEV -b $BAUDRATE -L -P $PRIORITIES" -+OPTIONS="$OPTIONS -s $SPOOLDIR/queue -S $SPOOLDIR/sent -F $SPOOLDIR/failed" -+test -n "$SMSPROCESSOR" && OPTIONS="$OPTIONS -a $SMSPROCESSOR" -+test -n "$SMSUSER" && STARTOPTS="$STARTOPTS --chuid $SMSUSER" -+test -r /etc/default/gsm-utils && . /etc/default/gsm-utils # for overwriting OPTIONS -+ -+case "$1" in -+ start) -+ echo -n "Starting $DESC: " -+ if [ -n "$PIN" ];then -+ echo -n "entering PIN.. " -+ ( -+ # This is ugly.. But if the PIN is already entered, the ME returns -+ # "ERROR" and makes gsmctl retrying.. -+ /usr/bin/gsmctl -d $PHONEDEV -b $BAUDRATE -I "+cpin=$PIN" & -+ PID=$! -+ sleep 3 -+ kill $PID 2>/dev/null -+ ) >/dev/null 2>&1 -+ fi -+ echo -n "$NAME" -+ start-stop-daemon --start --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --make-pidfile --background $STARTOPTS --exec $DAEMON -- $OPTIONS -+ echo "." -+ ;; -+ stop) -+ echo -n "Stopping $DESC: $NAME " -+ start-stop-daemon --stop --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --exec $DAEMON -+ sleep 5 -+ echo "." -+ ;; -+ restart|force-reload) -+ echo -n "Restarting $DESC: $NAME" -+ start-stop-daemon --stop --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --make-pidfile --background --exec $DAEMON -- $OPTIONS -+ sleep 5 -+ start-stop-daemon --start --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --make-pidfile --background $STARTOPTS --exec $DAEMON -- $OPTIONS -+ echo "." -+ ;; -+ *) -+ N=/etc/init.d/gsm-utils -+ echo "Usage: $N {start|stop|restart|force-reload}" >&2 -+ exit 1 -+ ;; -+esac -+ -+exit 0 ---- gsmlib-1.10.orig/debian/changelog -+++ gsmlib-1.10/debian/changelog -@@ -0,0 +1,284 @@ -+gsmlib (1.10-13) unstable; urgency=low -+ -+ * Ack NMU, Thanks Michael, Christoph & Petter -+ * debian/control add Homepage: -+ * Update debian/copyright; gsm-lib/COPYING actually specifies LGPL: -+ - fixes lintian:copyright-without-copyright-notice -+ * Update manpages fixes lintian:hyphen-used-as-minus-sign -+ * Update debian/gsm-utils.init -+ - fixes lintian:init.d-script-missing-lsb-short-description -+ * Bug fixes from ubuntu -+ - Don't install contrib/gsm-utils.init dh_installinit debian/gsm-utils.init -+ - Create /var/run/gsm-utils -+ * Add case 'L' to apps/gsmsmsd.cc - thks to Andrew Suffield -+ - syslog support does not work (Closes: #346240) -+ * gsm-utils.init really call restart with --stop first -+ - init script calls --start twice (Closes: #377448) -+ * Explictly set /bin/bash: gsmsmsspool & gsmsmsrequeue -+ - bashism in /bin/sh script (Closes: #464981) -+ - gsmsmsrequeue contains bashism or function error (Closes: #459396) -+ * Patch apps/gsmsmsstore.cc - thks Isaac Wilcox -+ - gsmsmsstore device existence check causes problems with RFCOMM -+ devices (Closes: #340179) -+ * Only start gsmsmsd if set in /etc/default/gsm-utils. crontab -> examples -+ - gsmsmsd should be optional / start only if told so in -+ /etc/default/gsm-utils (Closes: #474093) -+ * Apply patch from Stefan Katerkamp & Jacob Nevins -+ - Gsmsendsms fails with SonyEricsson W880 (fix included) (Closes: -+ #413341) -+ -+ -- Mark Purcell Mon, 06 Oct 2008 15:01:49 +1100 -+ -+gsmlib (1.10-12.5) unstable; urgency=low -+ -+ * Non-maintainer upload. -+ * Yet another bashism that was later on reported on the old bug report, thus -+ again closes: #464981 -+ * Also found a shell related problem in debian/rules and fixed it. -+ * Bumped standard to 3.7.3. -+ -+ -- Michael Meskes Mon, 14 Apr 2008 10:48:19 +0200 -+ -+gsmlib (1.10-12.4) unstable; urgency=low -+ -+ * Non-maintainer upload. -+ * Argh, somehow I mananged to upload without fixing the bug completely, -+ sorry. Added those missing braces, closes: #464981. -+ -+ -- Michael Meskes Wed, 09 Apr 2008 14:46:08 +0200 -+ -+gsmlib (1.10-12.3) unstable; urgency=high -+ -+ * Non-maintainer upload. -+ * Removed bashism in contrib/gsmsmsrequeue (Closes: #464981). -+ -+ -- Michael Meskes Sun, 06 Apr 2008 15:37:35 +0200 -+ -+gsmlib (1.10-12.2) unstable; urgency=low -+ -+ * Non-maintainer upload. -+ * Fix FTBFS with GCC 4.3: 'strerror' was not declared in this scope, thanks -+ to Cyril Brulebois for the patch (Closes: #455402). -+ -+ -- Christoph Berg Fri, 04 Apr 2008 18:01:05 +0200 -+ -+gsmlib (1.10-12.1) unstable; urgency=low -+ -+ * Non-maintainer upload to solve release goal. -+ * Add LSB dependency header to init.d scripts (Closes: #464061). -+ -+ -- Petter Reinholdtsen Fri, 28 Mar 2008 11:39:20 +0100 -+ -+gsmlib (1.10-12) unstable; urgency=low -+ -+ * addgroup --system gsmsms works better. Thanks Jon -+ * only delete gsmsms on purge -+ - gsm-utils: deletes and recreates the gsmsms user on each upgrade -+ (Closes: #346238) -+ - gsm-utils fails installation / addgroup: The user gsmsms; does -+ not exist (Closes: #445404) -+ * lintian cleanup: debian-rules-ignores-make-clean-error substvar- -+ source-version-is-deprecated -+ * Scripts are installed +x -+ - gsm-utils: uselessly installs non-executable scripts into /usr/bin -+ (Closes: #346230) -+ * Remove bogus symlink -+ - gsm-utils: wrong symlink for manpage gsmsiectl.1 (Closes: #322382) -+ - gsm-utils: gsmsiectl.1 dangling symlink (Closes: #399582) -+ * debian/gsm-utils.init reload/restart was not calling --stop. Thanks -+ Barry -+ - init script calls --start twice (Closes: #377448) -+ -+ -- Mark Purcell Mon, 08 Oct 2007 21:44:00 +0100 -+ -+gsmlib (1.10-11) unstable; urgency=low -+ -+ * Create system group gsmsms - Thanks Emmanuel -+ - gsm-utils: creates group in non-system gid range (Closes: #353967) -+ - gsm-utils: postinst should create system grp gsmsms (Closes: -+ #390266) -+ * Upgrade to compat 4 -+ * Apply gcc-4.3 patch from Martin -+ - FTBFS with GCC 4.3: missing #includes (Closes: #417222) -+ -+ -- Mark Purcell Sat, 29 Sep 2007 18:22:56 +0100 -+ -+gsmlib (1.10-10) unstable; urgency=low -+ -+ * FTBFS with G++ 4.1: extra qualifications (Closes: #356109) -+ -+ -- Mark Purcell Sat, 20 May 2006 21:54:42 +0100 -+ -+gsmlib (1.10-9) unstable; urgency=low -+ -+ * library package needs to be renamed (libstdc++ allocator change) -+ (Closes: #339179) -+ -+ -- Mark Purcell Mon, 21 Nov 2005 21:19:51 +0000 -+ -+gsmlib (1.10-8) unstable; urgency=low -+ -+ * removal of automake1.6 (Closes: #335123) -+ * fails with dash [bashisms in scripts] (Closes: #309834) -+ * Update libtool Fixes: gsmlib(GNU/k*BSD): FTBFS: out of date libtool scripts (Closes: -+ #319688) -+ * [INTL:de] German PO file corrections (Closes: #314060) -+ * Fix: old-fsf-address-in-copyright-file -+ -+ -- Mark Purcell Thu, 3 Nov 2005 22:40:19 +0000 -+ -+gsmlib (1.10-7) unstable; urgency=low -+ -+ * C++ 4.0 transition -+ * Closes: #315864: Missing manpages -+ * gsm-utils: maintainer-script-needs-depends-on-adduser postinst -+ -+ -- Mark Purcell Sat, 23 Jul 2005 00:46:31 +1000 -+ -+gsmlib (1.10-6) unstable; urgency=low -+ -+ * Rebuild for invalid dependancies -+ * Closes: #258056: libgsmme 99% cpu usage -+ - Patch from Emard -+ * Closes: #274382: FTBFS with gcc-3.4: template-id `operator< -+ <>' for `bool gsmlib::operator<(const -+ gsmlib::MapKey<gsmlib::SortedPhonebookBase>&, const -+ gsmlib::MapKey<gsmlib::SortedPhonebookBase>&)' does not -+ match any template declaration -+ - Patch from Andreas Jochens -+ * Closes: #294251: FTBFS (amd64/gcc-4.0): explicit qualification in -+ declaration of `bool gsmlib::operator<(const -+ gsmlib::MapKey<SortedStore>&, const -+ gsmlib::MapKey<SortedStore>&)' -+ - Patch from Andreas Jochens -+ * Closes: #200189: Patch and contribution -+ + Added multi-queue-priority-system and syslog patch (Matthias Goebl) -+ + Included init, spool and requeue scripts for gsmsmsd (Matthias Goebl) -+ + gsmsmsd runs with own user and group (gsmsms:gsmsms) (Matthias Goebl) -+ -+ -- Mark Purcell Tue, 17 May 2005 11:34:45 +0100 -+ -+gsmlib (1.10-5) unstable; urgency=low -+ -+ * Change Section: libdevel -+ * gsm_unix_serial.cc patch from Daniel Schepler to fix g++-3.3 -+ compliation. Thanks. (Closes: Bug#195151) -+ -+ -- Mark Purcell Sat, 19 Jul 2003 15:57:28 +1000 -+ -+gsmlib (1.10-4) unstable; urgency=low -+ -+ * Include file descriptor leak patch from Edd Dumbill (Closes: -+ Bug#168475) -+ * lintian cleanup: description-synopsis-might-not-be-phrased-properly -+ * lintian cleanup: configure-generated-file-in-source -+ -+ -- Mark Purcell Sun, 9 Feb 2003 14:04:54 +1100 -+ -+gsmlib (1.10-3) unstable; urgency=low -+ -+ * New Maintainer (Closes: Bug#180061). Thanks Mikael for your work. -+ -+ -- Mark Purcell Sat, 8 Feb 2003 16:55:26 +1100 -+ -+gsmlib (1.10-2) unstable; urgency=low -+ -+ * Rebuild to use the new c++ ABI (GCC 3.2) -+ -+ -- Mikael Hedin Thu, 23 Jan 2003 20:57:50 +0100 -+ -+gsmlib (1.10-1) unstable; urgency=low -+ -+ * New upstrem release. -+ -+ -- Mikael Hedin Wed, 6 Nov 2002 17:44:17 +0100 -+ -+gsmlib (1.9-2) unstable; urgency=low -+ -+ * Made new rules for the config.guess/sub update thing (closes: #146865, -+ #146867). -+ -+ -- Mikael Hedin Tue, 14 May 2002 09:28:03 +0200 -+ -+gsmlib (1.9-1) unstable; urgency=low -+ -+ * New upstream version. -+ * Use chrpath to get rid of rpaths. -+ * Add mini-manpage for gsmsiexfer. -+ * Remove b-d on auto-stuff, we don't use them. -+ -+ -- Mikael Hedin Mon, 13 May 2002 22:10:28 +0200 -+ -+gsmlib (1.8-2) unstable; urgency=low -+ -+ * Removed b-d on gcc 3.0, as they are no longer nessecary. -+ -+ -- Mikael Hedin Thu, 24 Jan 2002 12:59:07 +0100 -+ -+gsmlib (1.8-1) unstable; urgency=low -+ -+ * New upstream version. -+ * Revert the arch hack, now it should compile with either g++. -+ * Include the new lib in libgsmme1. Run dh_makeshlibs -V because of this. -+ * Added info for gsmsiectl in gsmctl(1). -+ -+ -- Mikael Hedin Wed, 9 Jan 2002 22:38:45 +0100 -+ -+gsmlib (1.7-2) unstable; urgency=low -+ -+ * gsm-utils: Added shlibs:Depends (closes: #126127). -+ * Spelling correction (closes: #124705, #124972) -+ * Rm libgsmme1.postins, and let dh_makeshlibs take care of ldconfig. -+ * Made explicit arch list without sparc and arm, they cannot use g++-3.0 -+ right now. -+ -+ -- Mikael Hedin Sat, 22 Dec 2001 20:27:54 +0100 -+ -+gsmlib (1.7-1) unstable; urgency=low -+ -+ * New upstream -+ * Use gcc-3.0 and g++-3.0, 2.95 doesn't compile. -+ -+ -- Mikael Hedin Thu, 1 Nov 2001 10:24:33 +0100 -+ -+gsmlib (1.6-5) unstable; urgency=low -+ -+ * Updated manpage (closes: #110973) -+ * Corrected problem with OP status (closes: #110970) -+ -+ -- Mikael Hedin Sat, 8 Sep 2001 18:12:17 +0200 -+ -+gsmlib (1.6-4) unstable; urgency=low -+ -+ * Support DEB_BUILD_OPTIONS -+ * Changed libgsmme-dev to section devel. -+ * Reran libtoolize. -+ * Lots of small patches to compile with g++-3.0. (Closes: #104411) -+ * Removed dh_testversion. -+ -+ -- Mikael Hedin Thu, 12 Jul 2001 16:06:23 +0200 -+ -+gsmlib (1.6-3) unstable; urgency=low -+ -+ * Various minor corrections. -+ -+ -- Mikael Hedin Thu, 8 Mar 2001 16:24:07 +0100 -+ -+gsmlib (1.6-2) unstable; urgency=low -+ -+ * Dont install INSTALL. Correct indentation for libgsmme1 description. -+ -+ -- Mikael Hedin Tue, 6 Mar 2001 14:55:05 +0100 -+ -+gsmlib (1.6-1) unstable; urgency=low -+ -+ * New upstream version. -+ -+ -- Mikael Hedin Mon, 29 Jan 2001 17:57:21 +0100 -+ -+gsmlib (1.5-1) unstable; urgency=low -+ -+ * Initial Release. -+ -+ -- Mikael Hedin Thu, 14 Dec 2000 01:06:40 +0100 -+ ---- gsmlib-1.10.orig/debian/gsm-utils.docs -+++ gsmlib-1.10/debian/gsm-utils.docs -@@ -0,0 +1,4 @@ -+NEWS -+README -+TODO -+doc/FAQ ---- gsmlib-1.10.orig/debian/rules -+++ gsmlib-1.10/debian/rules -@@ -0,0 +1,129 @@ -+#!/usr/bin/make -f -+ -+# Uncomment this to turn on verbose mode. -+#export DH_VERBOSE=1 -+ -+# shared library versions, option 1 -+#version=2.0.5 -+#major=2 -+# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so -+me_version=`ls gsmlib/.libs/libgsmme*.so.* | \ -+ awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'` -+me_major=`ls gsmlib/.libs/libgsmme*.so.* | \ -+ awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'` -+ex_version=`ls ext/.libs/libgsmext*.so.* | \ -+ awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'` -+ex_major=`ls ext/.libs/libgsmext*.so.* | \ -+ awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'` -+ -+ -+export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -+export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -+ -+ -+# FOR AUTOCONF 2.13 ONLY -+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) -+ confflags += $(DEB_HOST_GNU_TYPE) -+else -+ confflags += --host $(DEB_BUILD_GNU_TYPE) --build $(DEB_HOST_GNU_TYPE) -+endif -+ -+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) -+CFLAGS += -g -+CXXFLAGS += -g -+endif -+ -+configure: configure-stamp -+configure-stamp: -+ dh_testdir -+ # Add here commands to configure the package. -+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" INSTALL_PROGRAM=$(INSTALL_PROGRAM) \ -+ ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man \ -+ --infodir=\$${prefix}/share/info -+ -+ touch configure-stamp -+ -+build: configure-stamp build-stamp -+build-stamp: -+ dh_testdir -+ -+ # Add here commands to compile the package. -+ $(MAKE) -+ -+ touch build-stamp -+ -+clean: -+ dh_testdir -+ dh_testroot -+ -+ # Add here commands to clean up after the build process. -+ [ ! -f Makefile ] || $(MAKE) distclean -+ rm -f build-stamp configure-stamp config.log config.status po/de.gmo -+ -+ -test -r /usr/share/misc/config.sub && \ -+ cp -f /usr/share/misc/config.sub scripts/config.sub -+ -test -r /usr/share/misc/config.guess && \ -+ cp -f /usr/share/misc/config.guess scripts/config.guess -+ -+ dh_clean -+ -+install: build -+ dh_testdir -+ dh_testroot -+ dh_clean -k -+ dh_installdirs -+ dh_installdirs -pgsm-utils -+ -+ # Add here commands to install the package into debian/gsmlib. -+ $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp -+ chrpath -d debian/tmp/usr/bin/* -+ cp contrib/gsmsmsspool contrib/gsmsmsrequeue debian/tmp/usr/bin -+ -+ -+# Build architecture-independent files here. -+binary-indep: build install -+# We have nothing to do by default. -+ -+# Build architecture-dependent files here. -+binary-arch: build install -+ dh_testdir -+ dh_testroot -+ # -+ # build libgsmlib${major} package by moving files from gsmlib-dev -+ # -+ dh_movefiles -plibgsmme$(me_major)c2a \ -+ usr/lib/libgsmme.so.$(me_major) \ -+ usr/lib/libgsmme.so.$(me_version) \ -+ usr/lib/libgsmext.so.$(ex_major) \ -+ usr/lib/libgsmext.so.$(ex_version) \ -+ usr/share/locale -+ -+ dh_movefiles -plibgsmme-dev \ -+ usr/include \ -+ usr/lib -+ -+ dh_movefiles -pgsm-utils \ -+ usr/bin -+ -+ -+ dh_installdocs -+ dh_installexamples -+ dh_installmenu -+ dh_installinit -+ dh_installcron -+ dh_installman -pgsm-utils debian/*.1 debian/tmp/usr/share/man/man*/* -+ dh_installinfo -+ dh_installchangelogs ChangeLog -+ dh_link -+ dh_strip -+ dh_compress -+ dh_fixperms -+ dh_makeshlibs -V -+ dh_installdeb -+ dh_shlibdeps -ldebian/libgsmme1c2a/usr/lib -+ dh_gencontrol -+ dh_md5sums -+ dh_builddeb -+ -+binary: binary-indep binary-arch -+.PHONY: build clean binary-indep binary-arch binary install configure ---- gsmlib-1.10.orig/contrib/gsmsmsrequeue -+++ gsmlib-1.10/contrib/gsmsmsrequeue -@@ -0,0 +1,48 @@ -+#! /bin/bash -+# -+# /usr/bin/gsmsmsrequeue: Re-queues failed SMS -+# -+# written by Matthias Goebl -+ -+SPOOLDIR=/var/spool/sms -+PRIORITIES=3 -+SMSADMIN=root -+SUBJECT="SMS delivery report:" -+ -+send_notify() -+{ -+ tmpfile="$SPOOLDIR/tmp/"`basename "$1"` -+ status="$2" -+ if mv "$1" "$tmpfile" 2>/dev/null; then -+ # extract the first tab-separated field after the phone number as -+ # email-address to send the notification to -+ mailto=` cat "$tmpfile" | sed -ne '1s/^[^ ]* \([^ ]*\).*/\1/p' ` -+ test -z "$mailto" && mailto="$SMSADMIN" -+ cat "$tmpfile" | mail -s "$SUBJECT $status" "$mailto" -+ rm "$tmpfile" -+ fi -+} -+do_accounting() -+{ -+ true; -+} -+ -+test -r /etc/default/gsm-utils && . /etc/default/gsm-utils -+ -+for p in `seq 1 $PRIORITIES`; do -+ ls "$SPOOLDIR/failed$p" | while read file; do -+ if expr "$file" : ".*rrrrrrrrrrrr" >/dev/null; then -+ send_notify "$SPOOLDIR/failed$p/$file" "failed" -+ else -+ # re-queue SMS -+ mv "$SPOOLDIR/failed$p/$file" "$SPOOLDIR/queue$p/${file}r" 2>/dev/null -+ fi -+ done -+done -+ -+for p in `seq 1 $PRIORITIES`; do -+ ls "$SPOOLDIR/sent$p" | while read file; do -+ do_accounting "$SPOOLDIR/sent$p/$file" "sent" -+ send_notify "$SPOOLDIR/sent$p/$file" "sent" -+ done -+done ---- gsmlib-1.10.orig/contrib/gsm-utils.cron.d -+++ gsmlib-1.10/contrib/gsm-utils.cron.d -@@ -0,0 +1,3 @@ -+# /etc/cron.d/gsm-utils: crontab fragment for gsm-utils -+ -+*/5 * * * * root if [ -x /usr/bin/gsmsmsrequeue ]; then /usr/bin/gsmsmsrequeue; fi ---- gsmlib-1.10.orig/contrib/gsm-utils.default -+++ gsmlib-1.10/contrib/gsm-utils.default -@@ -0,0 +1,13 @@ -+PHONEDEV=/dev/mobilephone # or /dev/ttyS0 or /dev/ircomm0 -+BAUDRATE=9600 -+PIN="" # or 1234 -+ -+SPOOLDIR=/var/spool/sms -+PRIORITIES=3 -+ -+SMSADMIN=root -+SUBJECT="SMS delivery report:" -+ -+SMSPROCESSOR="" # or /usr/bin/gsmsmsprocessor -+ -+do_accounting () { true; } # it's your turn ---- gsmlib-1.10.orig/contrib/gsmsmsspool -+++ gsmlib-1.10/contrib/gsmsmsspool -@@ -0,0 +1,34 @@ -+#! /bin/bash -+# -+# /usr/bin/gsmsmsspool: Queues SMS for sending -+# -+# written by Matthias Goebl -+ -+SPOOLDIR=/var/spool/sms -+PRIORITIES=3 -+test -r /etc/default/gsm-utils && . /etc/default/gsm-utils -+ -+if [ -z "$1" ]; then -+ echo "Usage: gsmsmsspool NUMBER [MESSAGE]" -+ exit 1 -+fi -+ -+priority=$PRIORITIES # default priority -+test -n "$GSMSMS_PRIORITY" && priority="$GSMSMS_PRIORITY" -+mailto=`id -un` -+test -n "$GSMSMS_NOTIFY" && mailto="$GSMSMS_NOTIFY" -+ -+tmpfile="$SPOOLDIR/tmp/`date +%s`.$$" -+umask 022 -+echo "$1 $mailto" > "$tmpfile" -+if [ -n "$2" ]; then -+ echo "$2" | head -c 160 >> "$tmpfile" -+else -+ head -c 160 >> "$tmpfile" -+fi -+ -+if [ "`id -un`" = "root" ]; then -+ chown gsmsms:gsmsms "$tmpfile" -+fi -+ -+mv "$tmpfile" "$SPOOLDIR/queue$priority/" ---- gsmlib-1.10.orig/contrib/gsm-utils.init -+++ gsmlib-1.10/contrib/gsm-utils.init -@@ -0,0 +1,81 @@ -+#! /bin/sh -+### BEGIN INIT INFO -+# Provides: gsm-utils -+# Required-Start: $remote_fs $syslog -+# Required-Stop: $remote_fs $syslog -+# Default-Start: 2 3 4 5 -+# Default-Stop: 0 1 6 -+# Short-Description: Start daemon at boot time -+# Description: Enable service provided by daemon. -+### END INIT INFO -+# -+# /etc/init.d/gsm-utils: Controls the GSM SMS send daemon -+# -+# written by Matthias Goebl -+ -+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -+DAEMON=/usr/bin/gsmsmsd -+NAME=gsmsmsd -+DESC="GSM SMS send daemon" -+ -+test -x $DAEMON || exit 0 -+ -+PHONEDEV=/dev/mobilephone # or /dev/ttyS0 or /dev/ircomm0 -+BAUDRATE=9600 -+PIN="" # or 1234 -+SMSPROCESSOR="" # or /usr/bin/gsmsmsprocessor -+SPOOLDIR=/var/spool/sms -+PRIORITIES=3 -+STARTOPTS="" -+SMSUSER="gsmsms:gsmsms" -+test -r /etc/default/gsm-utils && . /etc/default/gsm-utils # for overwriting some parameters -+ -+OPTIONS="-d $PHONEDEV -b $BAUDRATE -L -P $PRIORITIES" -+OPTIONS="$OPTIONS -s $SPOOLDIR/queue -S $SPOOLDIR/sent -F $SPOOLDIR/failed" -+test -n "$SMSPROCESSOR" && OPTIONS="$OPTIONS -a $SMSPROCESSOR" -+test -n "$SMSUSER" && STARTOPTS="$STARTOPTS --chuid $SMSUSER" -+test -r /etc/default/gsm-utils && . /etc/default/gsm-utils # for overwriting OPTIONS -+ -+case "$1" in -+ start) -+ echo -n "Starting $DESC: " -+ if [ -n "$PIN" ];then -+ echo -n "entering PIN.. " -+ ( -+ # This is ugly.. But if the PIN is already entered, the ME returns -+ # "ERROR" and makes gsmctl retrying.. -+ /usr/bin/gsmctl -d $PHONEDEV -b $BAUDRATE -I "+cpin=$PIN" & -+ PID=$! -+ sleep 3 -+ kill $PID 2>/dev/null -+ ) >/dev/null 2>&1 -+ fi -+ echo -n "$NAME" -+ start-stop-daemon --start --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --make-pidfile --background $STARTOPTS --exec $DAEMON -- $OPTIONS -+ echo "." -+ ;; -+ stop) -+ echo -n "Stopping $DESC: $NAME " -+ start-stop-daemon --stop --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --exec $DAEMON -+ sleep 5 -+ echo "." -+ ;; -+ restart|force-reload) -+ echo -n "Restarting $DESC: $NAME" -+ start-stop-daemon --stop --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --make-pidfile --background $STARTOPTS --exec $DAEMON -- $OPTIONS -+ sleep 5 -+ start-stop-daemon --start --quiet --pidfile /var/run/gsm-utils/$NAME.pid \ -+ --make-pidfile --background --exec $DAEMON -- $OPTIONS -+ echo "." -+ ;; -+ *) -+ N=/etc/init.d/gsm-utils -+ echo "Usage: $N {start|stop|restart|force-reload}" >&2 -+ exit 1 -+ ;; -+esac -+ -+exit 0 diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib_1.10.orig.tar.gz b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib_1.10.orig.tar.gz deleted file mode 100644 index c3e2c3bb74..0000000000 Binary files a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib_1.10.orig.tar.gz and /dev/null differ diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h index c2e450147f..b5404ae6a9 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2011, Anthony Minessale II + * Copyright (C) 2005-2011, Anthony Minessale II * * Version: MPL 1.1 * @@ -23,17 +23,15 @@ * * This module (mod_gsmopen) has been contributed by: * - * Giovanni Maruzzelli (gmaruzz@gmail.com) + * Giovanni Maruzzelli * + * Maintainer: Giovanni Maruzzelli * - * Further Contributors: - * - * - * - * mod_gsmopen.c -- GSM compatible Endpoint Module + * mod_gsmopen.cpp -- GSM Modem compatible Endpoint Module * */ + #define __STDC_LIMIT_MACROS #ifdef WIN32 @@ -99,9 +97,9 @@ #define PROTOCOL_FBUS2 1 #define PROTOCOL_NO_SERIAL 3 -#define AT_BUFSIZ 8192 //FIXME FIXME FIXME #define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */ #define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */ +#define AT_BUFSIZ AT_MESG_MAX_LENGTH //FIXME FIXME FIXME #define AT_MESG_MAX_LINES 256 /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */ #define AT_MESG_MAX_LINES 20 /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */ @@ -115,7 +113,7 @@ #endif #ifndef GSMOPEN_SVN_VERSION -#define GSMOPEN_SVN_VERSION SWITCH_VERSION_REVISION +#define GSMOPEN_SVN_VERSION SWITCH_VERSION_FULL #endif /* GSMOPEN_SVN_VERSION */ #include "ctb-0.16/ctb.h" diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp index e422c9570b..ffa4e3d014 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -1,7 +1,43 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2011, Anthony Minessale II + * + * 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 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. + * + * This module (mod_gsmopen) has been contributed by: + * + * Giovanni Maruzzelli + * + * Maintainer: Giovanni Maruzzelli + * + * gsmopen_protocol.cpp -- Low Level Interface for mod_gamopen + * + */ + + + + #include "gsmopen.h" #ifdef WIN32 #include "win_iconv.c" -#endif// WIN32 +#endif // WIN32 #define WANT_GSMLIB #ifdef WANT_GSMLIB @@ -17,7 +53,7 @@ using namespace std; using namespace gsmlib; -#endif// WANT_GSMLIB +#endif // WANT_GSMLIB extern int running; //FIXME @@ -154,7 +190,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt) char trash[4096]; res = tech_pvt->serialPort_serial_control->Read(trash, 4096); - if (res){ + if (res) { DEBUGA_GSMOPEN("READ %d on serialport init\n", GSMOPEN_P_LOG, res); } @@ -367,7 +403,6 @@ int gsmopen_serial_config_AT(private_t *tech_pvt) if (res) { DEBUGA_GSMOPEN("AT+CMGF? failed, continue\n", GSMOPEN_P_LOG); } -#ifndef WANT_GSMLIB res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1"); if (res) { ERRORA("Error setting SMS sending mode to TEXT on the cellphone, let's hope is TEXT by default. Continuing\n", GSMOPEN_P_LOG); @@ -403,14 +438,13 @@ int gsmopen_serial_config_AT(private_t *tech_pvt) } } -#else// WANT_GSMLIB - res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0"); if (res) { ERRORA("Error setting SMS sending mode to TEXT on the cellphone, let's hope is TEXT by default. Continuing\n", GSMOPEN_P_LOG); } tech_pvt->sms_pdu_not_supported = 0; tech_pvt->no_ucs2 = 1; +#ifdef NOTDEF //GSMLIB? XXX if (tech_pvt->no_ucs2) { res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\""); if (res) { @@ -422,11 +456,11 @@ int gsmopen_serial_config_AT(private_t *tech_pvt) WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG); } } -#endif// WANT_GSMLIB +#endif // NOTDEF //GSMLIB? XXX #ifdef NOTDEF //GSMLIB? XXX - else { + else { //res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,20"); //"flash", class 0 sms 16 bit unicode res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,8"); //unicode, 16 bit message if (res) { @@ -558,6 +592,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us struct timeval timeout; char tmp_answer[AT_BUFSIZ]; char tmp_answer2[AT_BUFSIZ]; + char tmp_answer3[AT_BUFSIZ]; char *tmp_answer_ptr; char *last_line_ptr; int i = 0; @@ -566,12 +601,12 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us int at_ack = -1; int la_read = 0; int timeout_in_msec; - int msecs_passed=0; + int msecs_passed = 0; timeout_in_msec = (timeout_sec * 1000) + (timeout_usec ? (timeout_usec / 1000) : 0); if (timeout_in_msec != 100) - ERRORA("TIMEOUT=%d\n", GSMOPEN_P_LOG, timeout_in_msec); + DEBUGA_GSMOPEN("TIMEOUT=%d\n", GSMOPEN_P_LOG, timeout_in_msec); if (!running || !tech_pvt->running) { return -1; @@ -579,32 +614,36 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us tmp_answer_ptr = tmp_answer; memset(tmp_answer, 0, sizeof(char) * AT_BUFSIZ); + memset(tmp_answer2, 0, sizeof(char) * AT_BUFSIZ); + memset(tmp_answer3, 0, sizeof(char) * AT_BUFSIZ); timeout.tv_sec = timeout_sec; timeout.tv_usec = timeout_usec; PUSHA_UNLOCKA(tech_pvt->controldev_lock); LOKKA(tech_pvt->controldev_lock); - while ((!tech_pvt->controldev_dead) && msecs_passed <= timeout_in_msec){ + while ((!tech_pvt->controldev_dead) && msecs_passed <= timeout_in_msec) { char *token_ptr; timeout.tv_sec = timeout_sec; //reset the timeout, linux modify it timeout.tv_usec = timeout_usec; //reset the timeout, linux modify it -read: + read: switch_sleep(20000); msecs_passed += 20; - if (timeout_in_msec != 100){ + if (timeout_in_msec != 100) { //ERRORA("TIMEOUT=%d, PASSED=%d\n", GSMOPEN_P_LOG, timeout_in_msec, msecs_passed); } //read_count = tech_pvt->serialPort_serial_control->Readv(tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer), (timeout_sec * 1000) + (timeout_usec ? (timeout_usec / 1000) : 0)); read_count = tech_pvt->serialPort_serial_control->Read(tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer)); + memset(tmp_answer3, 0, sizeof(char) * AT_BUFSIZ); + strcpy(tmp_answer3, tmp_answer_ptr); //cicopet read_count = read(tech_pvt->controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer)); if (read_count == 0) { - if(msecs_passed <= timeout_in_msec){ - goto read; + if (msecs_passed <= timeout_in_msec) { + goto read; } } if (read_count == -1) { @@ -628,10 +667,6 @@ read: return -1; } - if (option_debug > 90) { - //DEBUGA_GSMOPEN("1 read %d bytes, --|%s|--\n", GSMOPEN_P_LOG, read_count, tmp_answer_ptr); - //DEBUGA_GSMOPEN("2 read %d bytes, --|%s|--\n", GSMOPEN_P_LOG, read_count, tmp_answer); - } tmp_answer_ptr = tmp_answer_ptr + read_count; la_counter = 0; @@ -646,6 +681,7 @@ read: GSMOPEN_P_LOG, token_ptr, tech_pvt->line_array.result[la_counter]); } la_counter++; + while ((token_ptr = strtok(NULL, "\n\r"))) { last_line_ptr = token_ptr; strncpy(tech_pvt->line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH); @@ -655,6 +691,15 @@ read: GSMOPEN_P_LOG, token_ptr, tech_pvt->line_array.result[la_counter]); } la_counter++; + + if (la_counter == AT_MESG_MAX_LINES) { + ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n", GSMOPEN_P_LOG, + AT_MESG_MAX_LINES, la_counter, tech_pvt->reading_sms_msg); + WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n", GSMOPEN_P_LOG, read_count, tmp_answer3); + at_ack = AT_ERROR; + break; + } + } } else { last_line_ptr = tmp_answer; @@ -671,18 +716,32 @@ read: strncpy(tech_pvt->line_array.result[la_counter], last_line_ptr, AT_MESG_MAX_LENGTH); // match expected string -> accept it withtout CRLF la_counter++; - + if (la_counter == AT_MESG_MAX_LINES) { + ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n", GSMOPEN_P_LOG, + AT_MESG_MAX_LINES, la_counter, tech_pvt->reading_sms_msg); + WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n", GSMOPEN_P_LOG, read_count, tmp_answer3); + at_ack = AT_ERROR; + break; + } } /* if the last line read was not a complete line, we'll read the rest in the future */ else if (tmp_answer[strlen(tmp_answer) - 1] != '\r' && tmp_answer[strlen(tmp_answer) - 1] != '\n') la_counter--; /* let's list the complete lines read so far, without re-listing the lines that has yet been listed */ - if (option_debug > 1) { - for (i = la_read; i < la_counter; i++) - DEBUGA_GSMOPEN("Read line %d: |%s|\n", GSMOPEN_P_LOG, i, tech_pvt->line_array.result[i]); + for (i = la_read; i < la_counter; i++) { + DEBUGA_GSMOPEN("Read line %d: |%s| la_counter=%d\n", GSMOPEN_P_LOG, i, tech_pvt->line_array.result[i], la_counter); } + if (la_counter == AT_MESG_MAX_LINES) { + ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n", GSMOPEN_P_LOG, + AT_MESG_MAX_LINES, la_counter, tech_pvt->reading_sms_msg); + WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n", GSMOPEN_P_LOG, read_count, tmp_answer3); + at_ack = AT_ERROR; + break; + } + + /* let's interpret the complete lines read so far (WITHOUT looking for OK, ERROR, and EXPECTED_STRING), without re-interpreting the lines that has been yet interpreted, so we're sure we don't miss anything */ for (i = la_read; i < la_counter; i++) { @@ -804,11 +863,10 @@ read: tech_pvt->line_array.result[i], tech_pvt->callid_name, tech_pvt->callid_number); } - if ((strncmp(tech_pvt->line_array.result[i], "+CMS ERROR:", 11) == 0)) { - ERRORA("Received: \"%s\", what was this error about?\n", GSMOPEN_P_LOG); - } if ((strcmp(tech_pvt->line_array.result[i], "+CMS ERROR: 500") == 0)) { - ERRORA("Received: \"%s\", maybe this account ran OUT OF CREDIT?\n", GSMOPEN_P_LOG); + ERRORA("Received: \"%s\", generic error, maybe this account ran OUT OF CREDIT?\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); + } else if ((strncmp(tech_pvt->line_array.result[i], "+CMS ERROR:", 11) == 0)) { + ERRORA("Received: \"%s\", what was this error about?\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); } if ((strcmp(tech_pvt->line_array.result[i], "BUSY") == 0)) { tech_pvt->phone_callflow = CALLFLOW_CALL_LINEBUSY; @@ -949,28 +1007,29 @@ read: if (option_debug > 1) DEBUGA_GSMOPEN("|%s| +CREG: Display: %d, Registration=%d\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i], n, stat); if (err < 2) { - WARNINGA("|%s| is not formatted as: |+CREG: xx,yy|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); - } - if (stat == 0) { - ERRORA - ("|%s| CELLPHONE is not registered to network, consider to move it or additional antenna\n", - GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); - tech_pvt->not_registered = 1; - tech_pvt->home_network_registered = 0; - tech_pvt->roaming_registered = 0; - alarm_event(tech_pvt, ALARM_NO_NETWORK_REGISTRATION, - "CELLPHONE is not registered to network, consider to move it or additional antenna"); - } else if (stat == 1) { - DEBUGA_GSMOPEN("|%s| CELLPHONE is registered to the HOME network\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); - tech_pvt->not_registered = 0; - tech_pvt->home_network_registered = 1; - tech_pvt->roaming_registered = 0; + DEBUGA_GSMOPEN("|%s| is not formatted as: |+CREG: xx,yy|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); } else { - ERRORA("|%s| CELLPHONE is registered to a ROAMING network\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); - tech_pvt->not_registered = 0; - tech_pvt->home_network_registered = 0; - tech_pvt->roaming_registered = 1; - alarm_event(tech_pvt, ALARM_ROAMING_NETWORK_REGISTRATION, "CELLPHONE is registered to a ROAMING network"); + if (stat == 0) { + ERRORA + ("|%s| CELLPHONE is not registered to network, consider to move it or additional antenna\n", + GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); + tech_pvt->not_registered = 1; + tech_pvt->home_network_registered = 0; + tech_pvt->roaming_registered = 0; + alarm_event(tech_pvt, ALARM_NO_NETWORK_REGISTRATION, + "CELLPHONE is not registered to network, consider to move it or additional antenna"); + } else if (stat == 1) { + DEBUGA_GSMOPEN("|%s| CELLPHONE is registered to the HOME network\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); + tech_pvt->not_registered = 0; + tech_pvt->home_network_registered = 1; + tech_pvt->roaming_registered = 0; + } else { + ERRORA("|%s| CELLPHONE is registered to a ROAMING network\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); + tech_pvt->not_registered = 0; + tech_pvt->home_network_registered = 0; + tech_pvt->roaming_registered = 1; + alarm_event(tech_pvt, ALARM_ROAMING_NETWORK_REGISTRATION, "CELLPHONE is registered to a ROAMING network"); + } } } @@ -987,16 +1046,6 @@ read: } if ((strncmp(tech_pvt->line_array.result[i], "^CEND:1", 7) == 0)) { - tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE; - if (option_debug > 1) - DEBUGA_GSMOPEN("|%s| CALLFLOW_CALL_IDLE\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); - if (tech_pvt->interface_state != GSMOPEN_STATE_DOWN && tech_pvt->owner) { - DEBUGA_GSMOPEN("just received a remote HANGUP\n", GSMOPEN_P_LOG); - tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_NORMAL; - gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); - DEBUGA_GSMOPEN("just sent GSMOPEN_CONTROL_HANGUP\n", GSMOPEN_P_LOG); - } - tech_pvt->phone_callflow = CALLFLOW_CALL_NOCARRIER; if (option_debug > 1) DEBUGA_GSMOPEN("|%s| CALLFLOW_CALL_NOCARRIER\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); @@ -1014,6 +1063,15 @@ read: switch_core_session_rwunlock(session); switch_channel_hangup(channel, SWITCH_CAUSE_NONE); } + tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE; + if (option_debug > 1) + DEBUGA_GSMOPEN("|%s| CALLFLOW_CALL_IDLE\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]); + if (tech_pvt->interface_state != GSMOPEN_STATE_DOWN && tech_pvt->owner) { + DEBUGA_GSMOPEN("just received a remote HANGUP\n", GSMOPEN_P_LOG); + tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_NORMAL; + gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); + DEBUGA_GSMOPEN("just sent GSMOPEN_CONTROL_HANGUP\n", GSMOPEN_P_LOG); + } // //tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; //gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); @@ -1091,9 +1149,9 @@ read: DEBUGA_PBX("just sent GSMOPEN_CONTROL_ANSWER\n", GSMOPEN_P_LOG); } } else { + tech_pvt->interface_state = GSMOPEN_STATE_UP; + DEBUGA_PBX("just interface_state UP\n", GSMOPEN_P_LOG); } - //tech_pvt->interface_state = GSMOPEN_STATE_UP; - //DEBUGA_PBX("just interface_state UP\n", GSMOPEN_P_LOG); } if ((strcmp(tech_pvt->line_array.result[i], tech_pvt->at_call_calling) == 0)) { @@ -1158,10 +1216,12 @@ read: if (res) { ERRORA("AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command); } - res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\""); +/* + res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"CIAPALO1\""); if (res) { - ERRORA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n", GSMOPEN_P_LOG); + ERRORA("AT+CSCS=\"CIAPALO1\" (set TE messages to GSM) do not got OK from the phone\n", GSMOPEN_P_LOG); } +*/ memset(at_command, 0, sizeof(at_command)); sprintf(at_command, "AT+CMGD=%d", tech_pvt->unread_sms_msg_id); /* delete the message */ tech_pvt->unread_sms_msg_id = 0; @@ -1176,7 +1236,7 @@ read: /* we're not in a call, neither calling */ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\""); if (res) { - ERRORA("AT+CKPD=\"EEE\" (cellphone screen back to user) do not got OK from the phone\n", GSMOPEN_P_LOG); + DEBUGA_GSMOPEN("AT+CKPD=\"EEE\" (cellphone screen back to user) do not got OK from the phone\n", GSMOPEN_P_LOG); } } } //unread_msg_id @@ -1544,6 +1604,8 @@ read: strncpy(tech_pvt->imsi, tech_pvt->line_array.result[i], sizeof(tech_pvt->imsi)); } } + + /* if we are reading an sms message from memory, put the line into the sms buffer if the line is not "OK" or "ERROR" */ if (tech_pvt->reading_sms_msg > 1 && at_ack == -1) { int c; @@ -1641,55 +1703,58 @@ read: } else { -#ifdef WANT_GSMLIB - char content2[1000]; - SMSMessageRef sms; - //MessageType messagetype; - //Address servicecentreaddress; - //Timestamp servicecentretimestamp; - //Address sender_recipient_address; + try { + char content2[1000]; + SMSMessageRef sms; + //MessageType messagetype; + //Address servicecentreaddress; + //Timestamp servicecentretimestamp; + //Address sender_recipient_address; - sms = SMSMessage::decode(tech_pvt->line_array.result[i]); // dataCodingScheme = 8 , text=ciao 123 belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大 + sms = SMSMessage::decode(tech_pvt->line_array.result[i]); // dataCodingScheme = 8 , text=ciao 123 belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大 - DEBUGA_GSMOPEN("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str()); + DEBUGA_GSMOPEN("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str()); - memset(content2, '\0', sizeof(content2)); - if (sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET) { - iso_8859_1_to_utf8(tech_pvt, (char *) sms->userData().c_str(), content2, sizeof(content2)); - } else if (sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET) { - ucs2_to_utf8(tech_pvt, (char *) bufToHex((unsigned char *) sms->userData().data(), sms->userData().length()).c_str(), content2, - sizeof(content2)); - } else { - ERRORA("dataCodingScheme not supported=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet()); + memset(content2, '\0', sizeof(content2)); + if (sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET) { + iso_8859_1_to_utf8(tech_pvt, (char *) sms->userData().c_str(), content2, sizeof(content2)); + } else if (sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET) { + ucs2_to_utf8(tech_pvt, (char *) bufToHex((unsigned char *) sms->userData().data(), sms->userData().length()).c_str(), + content2, sizeof(content2)); + } else { + ERRORA("dataCodingScheme not supported=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet()); + + } + DEBUGA_GSMOPEN("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet()); + DEBUGA_GSMOPEN("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str()); + 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("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType()); + DEBUGA_GSMOPEN("userData= |||%s|||\n", GSMOPEN_P_LOG, content2); + + + memset(sms_body, '\0', sizeof(sms_body)); + strncpy(sms_body, content2, sizeof(sms_body)); + DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body); + 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_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)); + tech_pvt->sms_messagetype = sms->messageType(); + //messagetype = sms->messageType(); + //servicecentreaddress = sms->serviceCentreAddress(); + //servicecentretimestamp = sms->serviceCentreTimestamp(); + //sender_recipient_address = sms->address(); } - DEBUGA_GSMOPEN("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet()); - DEBUGA_GSMOPEN("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str()); - 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("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType()); - DEBUGA_GSMOPEN("userData= |||%s|||\n", GSMOPEN_P_LOG, content2); + catch(GsmException & ge) { + ERRORA("GsmException= |||%s|||\n", GSMOPEN_P_LOG, ge.what()); + } - memset(sms_body, '\0', sizeof(sms_body)); - strncpy(sms_body, content2, sizeof(sms_body)); - DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body); - 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_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)); - tech_pvt->sms_messagetype = sms->messageType(); - //messagetype = sms->messageType(); - //servicecentreaddress = sms->serviceCentreAddress(); - //servicecentretimestamp = sms->serviceCentreTimestamp(); - //sender_recipient_address = sms->address(); - - - -#endif// WANT_GSMLIB @@ -1706,11 +1771,14 @@ read: if (look_for_ack && at_ack > -1) break; - if (la_counter > AT_MESG_MAX_LINES) { - ERRORA("Too many lines in result (>%d). Stopping reader.\n", GSMOPEN_P_LOG, AT_MESG_MAX_LINES); + if (la_counter == AT_MESG_MAX_LINES) { + ERRORA("Too many lines in result (>%d). la_counter=%d. tech_pvt->reading_sms_msg=%d. Stop accumulating lines.\n", GSMOPEN_P_LOG, + AT_MESG_MAX_LINES, la_counter, tech_pvt->reading_sms_msg); + WARNINGA("read was %d bytes, tmp_answer3= --|%s|--\n", GSMOPEN_P_LOG, read_count, tmp_answer3); at_ack = AT_ERROR; break; } + } UNLOCKA(tech_pvt->controldev_lock); @@ -1872,23 +1940,23 @@ int gsmopen_serial_write_AT(private_t *tech_pvt, const char *data) if (res != 1) { ERRORA("Error RE-sending (carriage return): %d %d (%s)\n", GSMOPEN_P_LOG, count, res, strerror(errno)); - ERRORA - ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", - GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->controldev_dead = 1; - //cicopet close(tech_pvt->controldevfd); - ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->running = 0; - alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); - tech_pvt->active = 0; - tech_pvt->name[0] = '\0'; + ERRORA + ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", + GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->controldev_dead = 1; + //cicopet close(tech_pvt->controldevfd); + ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->running = 0; + alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); + tech_pvt->active = 0; + tech_pvt->name[0] = '\0'; - UNLOCKA(tech_pvt->controldev_lock); - if (tech_pvt->owner) { - tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; - gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); - } - switch_sleep(1000000); + UNLOCKA(tech_pvt->controldev_lock); + if (tech_pvt->owner) { + tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; + gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); + } + switch_sleep(1000000); return -1; @@ -1976,23 +2044,23 @@ int gsmopen_serial_write_AT_noack(private_t *tech_pvt, const char *data) ERRORA("Error sending data... (%s)\n", GSMOPEN_P_LOG, strerror(errno)); UNLOCKA(tech_pvt->controldev_lock); - ERRORA - ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", - GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->controldev_dead = 1; - //cicopet close(tech_pvt->controldevfd); - ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->running = 0; - alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); - tech_pvt->active = 0; - tech_pvt->name[0] = '\0'; + ERRORA + ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", + GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->controldev_dead = 1; + //cicopet close(tech_pvt->controldevfd); + ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->running = 0; + alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); + tech_pvt->active = 0; + tech_pvt->name[0] = '\0'; - UNLOCKA(tech_pvt->controldev_lock); - if (tech_pvt->owner) { - tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; - gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); - } - switch_sleep(1000000); + UNLOCKA(tech_pvt->controldev_lock); + if (tech_pvt->owner) { + tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; + gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); + } + switch_sleep(1000000); return -1; @@ -2015,23 +2083,23 @@ int gsmopen_serial_write_AT_ack(private_t *tech_pvt, const char *data) ERRORA("Error sending data... (%s) \n", GSMOPEN_P_LOG, strerror(errno)); UNLOCKA(tech_pvt->controldev_lock); - ERRORA - ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", - GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->controldev_dead = 1; - //cicopet close(tech_pvt->controldevfd); - ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->running = 0; - alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); - tech_pvt->active = 0; - tech_pvt->name[0] = '\0'; + ERRORA + ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", + GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->controldev_dead = 1; + //cicopet close(tech_pvt->controldevfd); + ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->running = 0; + alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); + tech_pvt->active = 0; + tech_pvt->name[0] = '\0'; - UNLOCKA(tech_pvt->controldev_lock); - if (tech_pvt->owner) { - tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; - gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); - } - switch_sleep(1000000); + UNLOCKA(tech_pvt->controldev_lock); + if (tech_pvt->owner) { + tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; + gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); + } + switch_sleep(1000000); return -1; @@ -2057,29 +2125,29 @@ int gsmopen_serial_write_AT_ack_nocr_longtime(private_t *tech_pvt, const char *d ERRORA("Error sending data... (%s) \n", GSMOPEN_P_LOG, strerror(errno)); UNLOCKA(tech_pvt->controldev_lock); - ERRORA - ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", - GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->controldev_dead = 1; - //cicopet close(tech_pvt->controldevfd); - ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->running = 0; - alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); - tech_pvt->active = 0; - tech_pvt->name[0] = '\0'; + ERRORA + ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", + GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->controldev_dead = 1; + //cicopet close(tech_pvt->controldevfd); + ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->running = 0; + alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); + tech_pvt->active = 0; + tech_pvt->name[0] = '\0'; - UNLOCKA(tech_pvt->controldev_lock); - if (tech_pvt->owner) { - tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; - gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); - } - switch_sleep(1000000); + UNLOCKA(tech_pvt->controldev_lock); + if (tech_pvt->owner) { + tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; + gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); + } + switch_sleep(1000000); return -1; } - at_result = gsmopen_serial_read_AT(tech_pvt, 1, 500000, 5, NULL, 1); // 5.5 sec timeout + at_result = gsmopen_serial_read_AT(tech_pvt, 1, 500000, 20, NULL, 1); // 20.5 sec timeout UNLOCKA(tech_pvt->controldev_lock); POPPA_UNLOCKA(tech_pvt->controldev_lock); @@ -2099,23 +2167,23 @@ int gsmopen_serial_write_AT_expect1(private_t *tech_pvt, const char *data, const ERRORA("Error sending data... (%s) \n", GSMOPEN_P_LOG, strerror(errno)); UNLOCKA(tech_pvt->controldev_lock); - ERRORA - ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", - GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->controldev_dead = 1; - //cicopet close(tech_pvt->controldevfd); - ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); - tech_pvt->running = 0; - alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); - tech_pvt->active = 0; - tech_pvt->name[0] = '\0'; + ERRORA + ("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n", + GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->controldev_dead = 1; + //cicopet close(tech_pvt->controldevfd); + ERRORA("gsmopen_serial_monitor failed, declaring %s dead\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name); + tech_pvt->running = 0; + alarm_event(tech_pvt, ALARM_FAILED_INTERFACE, "gsmopen_serial_monitor failed, declaring interface dead"); + tech_pvt->active = 0; + tech_pvt->name[0] = '\0'; - UNLOCKA(tech_pvt->controldev_lock); - if (tech_pvt->owner) { - tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; - gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); - } - switch_sleep(1000000); + UNLOCKA(tech_pvt->controldev_lock); + if (tech_pvt->owner) { + tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE; + gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP); + } + switch_sleep(1000000); return -1; @@ -2218,7 +2286,7 @@ int gsmopen_serial_hangup_AT(private_t *tech_pvt) res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CHUP"); if (res) { - ERRORA("at_hangup command failed, command used: 'AT+CHUP'\n", GSMOPEN_P_LOG); + DEBUGA_GSMOPEN("at_hangup command timeout, command used: 'AT+CHUP'\n", GSMOPEN_P_LOG); //return -1; } @@ -2322,10 +2390,10 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out); #ifdef WIN32 - iconv_res = iconv(iconv_format, (const char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft); -#else// WIN32 + iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft); +#else // WIN32 iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft); -#endif// WIN32 +#endif // WIN32 if (iconv_res == (size_t) -1) { DEBUGA_GSMOPEN("2 ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n", GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out); @@ -2341,6 +2409,7 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb //#endif //WIN32 return 0; } + int utf8_to_iso_8859_1(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, char *iso_8859_1_out, size_t outbytesleft) { /* cicopet */ @@ -2363,12 +2432,12 @@ int utf8_to_iso_8859_1(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, c DEBUGA_GSMOPEN("in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, iso_8859_1_out=%s\n", GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_in, iso_8859_1_out); #ifdef WIN32 - iconv_res = iconv(iconv_format, (const char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft); -#else// WIN32 + iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft); +#else // WIN32 iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft); -#endif// WIN32 +#endif // WIN32 if (iconv_res == (size_t) -1) { - ERRORA("error: %s %d\n", GSMOPEN_P_LOG, strerror(errno), errno); + DEBUGA_GSMOPEN("cannot translate in iso_8859_1 error: %s %d\n", GSMOPEN_P_LOG, strerror(errno), errno); return -1; } DEBUGA_GSMOPEN @@ -2418,10 +2487,10 @@ int iso_8859_1_to_utf8(private_t *tech_pvt, char *iso_8859_1_in, char *utf8_out, inbytesleft = strlen(iso_8859_1_in) * 2; #ifdef WIN32 - iconv_res = iconv(iconv_format, (const char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft); -#else// WIN32 + iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft); +#else // WIN32 iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft); -#endif// WIN32 +#endif // WIN32 if (iconv_res == (size_t) -1) { DEBUGA_GSMOPEN("ciao in=%s, inleft=%d, out=%s, outleft=%d, utf8_out=%s\n", GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_out); @@ -2466,10 +2535,10 @@ int utf8_to_ucs2(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, char *u DEBUGA_GSMOPEN("in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, converted=%s\n", GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_in, converted); #ifdef WIN32 - iconv_res = iconv(iconv_format, (const char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft); -#else// WIN32 + iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft); +#else // WIN32 iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft); -#endif// WIN32 +#endif // WIN32 if (iconv_res == (size_t) -1) { ERRORA("error: %s %d\n", GSMOPEN_P_LOG, strerror(errno), errno); return -1; @@ -2526,7 +2595,6 @@ int gsmopen_answer(private_t *tech_pvt) DEBUGA_PBX("call answered\n", GSMOPEN_P_LOG); res = 0; - new_inbound_channel(tech_pvt); if (tech_pvt->owner) { DEBUGA_PBX("going to send GSMOPEN_STATE_UP\n", GSMOPEN_P_LOG); ast_setstate(tech_pvt->owner, GSMOPEN_STATE_UP); @@ -2547,13 +2615,10 @@ int gsmopen_ring(private_t *tech_pvt) switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if (option_debug) { - //DEBUGA_PBX("ENTERING FUNC\n", GSMOPEN_P_LOG); - } - session = switch_core_session_locate(tech_pvt->session_uuid_str); if (session) { switch_core_session_rwunlock(session); + //DEBUGA_PBX("got session, let's exit\n", GSMOPEN_P_LOG); return 0; } @@ -2568,8 +2633,9 @@ int gsmopen_ring(private_t *tech_pvt) switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); if (channel) { switch_channel_mark_ring_ready(channel); + DEBUGA_GSMOPEN("switch_channel_mark_ring_ready(channel);\n", GSMOPEN_P_LOG); } else { - ERRORA("no session\n", GSMOPEN_P_LOG); + ERRORA("no channel\n", GSMOPEN_P_LOG); } switch_core_session_rwunlock(session); } else { @@ -2577,9 +2643,6 @@ int gsmopen_ring(private_t *tech_pvt) } - if (option_debug) { - DEBUGA_PBX("EXITING FUNC\n", GSMOPEN_P_LOG); - } return res; } @@ -2660,10 +2723,11 @@ int gsmopen_senddigit(private_t *tech_pvt, char digit) char at_command[256]; memset(at_command, '\0', 256); - sprintf(at_command, "%s=\"%c\"", tech_pvt->at_send_dtmf, digit); + sprintf(at_command, "%s=1,%c", tech_pvt->at_send_dtmf, digit); res = gsmopen_serial_write_AT_ack(tech_pvt, at_command); if (res) { - ERRORA("senddigit command failed, command used: '%s=\"%c\"', giving up\n", GSMOPEN_P_LOG, tech_pvt->at_send_dtmf, digit); + DEBUGA_GSMOPEN("XXX answer (OK) takes long to come, goes into timeout. command used: '%s=1,%c'\n", GSMOPEN_P_LOG, tech_pvt->at_send_dtmf, + digit); } } @@ -2702,124 +2766,70 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text) char pdu2[16000]; memset(pdu2, '\0', sizeof(pdu2)); int pdulenght = 0; + string pdu; PUSHA_UNLOCKA(&tech_pvt->controldev_lock); LOKKA(tech_pvt->controldev_lock); -#ifndef WANT_GSMLIB - err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1"); - if (err) { - ERRORA("AT+CMGF=1 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG); - } -#else// WANT_GSMLIB - err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0"); - if (err) { - ERRORA("AT+CMGF=0 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG); - } -#endif// WANT_GSMLIB - - if (tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0) { -#ifdef WANT_GSMLIB - SMSMessageRef smsMessage; + try { + int bad_8859 = 0; - memset(mesg_test, '\0', sizeof(mesg_test)); - sprintf(mesg_test,":) ciao belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8 - //sprintf(mesg_test,":) ciao belè èéàòìù"); - //text=mesg_test; + memset(mesg_test, '\0', sizeof(mesg_test)); + sprintf(mesg_test, ":) ciao belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8 + //sprintf(mesg_test,":) ciao belè èéàòìù"); + //text=mesg_test; - utf8_to_iso_8859_1(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand)); - smsMessage = new SMSSubmitMessage(smscommand, dest); - string pdu = smsMessage->encode(); - strncpy(pdu2, pdu.c_str(), sizeof(pdu2)-1); - memset(smscommand, '\0', sizeof(smscommand)); - pdulenght = pdu.length() / 2 - 1; - sprintf(smscommand, "AT+CMGS=%d", pdulenght); + bad_8859 = utf8_to_iso_8859_1(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand)); + if (!bad_8859) { + err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0"); + if (err) { + ERRORA("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone\n", GSMOPEN_P_LOG); + } + SMSMessageRef smsMessage; + smsMessage = new SMSSubmitMessage(smscommand, dest); + //string pdu = smsMessage->encode(); + pdu = smsMessage->encode(); + strncpy(pdu2, pdu.c_str(), sizeof(pdu2) - 1); + memset(smscommand, '\0', sizeof(smscommand)); + pdulenght = pdu.length() / 2 - 1; + sprintf(smscommand, "AT+CMGS=%d", pdulenght); + } else { + int ok; -#ifdef NOTDEF + UNLOCKA(tech_pvt->controldev_lock); + POPPA_UNLOCKA(&tech_pvt->controldev_lock); -*** 9. How to support unicode? + tech_pvt->no_ucs2 = 0; + tech_pvt->sms_pdu_not_supported = 1; + ok = gsmopen_sendsms(tech_pvt, dest, text); + tech_pvt->no_ucs2 = 1; + tech_pvt->sms_pdu_not_supported = 0; -You need 6 steps: + return ok; + } -1. set datacodingschema to DCS_SIXTEEN_BIT_ALPHABET - -2. set your locale correctly, for example, my locale, china. - setlocale(LC_ALL, "chs"); - -3. translate MBCS(multiple byte character set) string to unicode string. - wchar_t wstr[ 1000 ]; - memset(wstr, 0, 2000); - mbstowcs(wstr, data.c_str(), data.length()); - -4. get unicode string length. - int wcs_len = wcslen(wstr); - -5. change unicode string to net order. - for (int i = 0; i < wcs_len; i++) - wstr[ i ] = htons(wstr[ i ]); - -6. put unicode string into pdu. - - - char content2[1000]; - SMSMessageRef sms; - //MessageType messagetype; - //Address servicecentreaddress; - //Timestamp servicecentretimestamp; - //Address sender_recipient_address; - - sms = SMSMessage::decode(tech_pvt->line_array.result[i]); // dataCodingScheme = 8 , text=ciao 123 belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大 - - DEBUGA_GSMOPEN("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str()); - - memset(content2, '\0', sizeof(content2)); - if (sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET) { - iso_8859_1_to_utf8(tech_pvt, (char *) sms->userData().c_str(), content2, sizeof(content2)); - } else if (sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET) { - ucs2_to_utf8(tech_pvt, (char *) bufToHex((unsigned char *) sms->userData().data(), sms->userData().length()).c_str(), content2, - sizeof(content2)); - } else { - ERRORA("dataCodingScheme not supported=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet()); - - } - DEBUGA_GSMOPEN("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet()); - DEBUGA_GSMOPEN("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str()); - 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("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType()); - DEBUGA_GSMOPEN("userData= |||%s|||\n", GSMOPEN_P_LOG, content2); + } + catch(GsmException & ge) { + ERRORA("GsmException= |||%s|||\n", GSMOPEN_P_LOG, ge.what()); + } - memset(sms_body, '\0', sizeof(sms_body)); - strncpy(sms_body, content2, sizeof(sms_body)); - DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body); - 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_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)); - tech_pvt->sms_messagetype = sms->messageType(); - //messagetype = sms->messageType(); - //servicecentreaddress = sms->serviceCentreAddress(); - //servicecentretimestamp = sms->serviceCentreTimestamp(); - //sender_recipient_address = sms->address(); -#endif// NOTDEF - -#else// WANT_GSMLIB - ERRORA("tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0 && no WANT_GSMLIB\n", GSMOPEN_P_LOG); - return RESULT_FAILURE; -#endif// WANT_GSMLIB } else { char dest2[1048]; + err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1"); + if (err) { + ERRORA("AT+CMGF=1 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG); + } + +/* err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\""); if (err) { ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone\n", GSMOPEN_P_LOG); } +*/ memset(dest2, '\0', sizeof(dest2)); utf8_to_ucs2(tech_pvt, dest, strlen(dest), dest2, sizeof(dest2)); @@ -2832,7 +2842,6 @@ You need 6 steps: goto uscita; } err = gsmopen_serial_AT_expect(tech_pvt, "> ", 0, 1); // wait 1.1s for the prompt, no crlf -#if 1 if (err) { DEBUGA_GSMOPEN ("Error or timeout getting prompt '> ' for sending sms directly to the remote party. BTW, seems that we cannot do that with Motorola c350, so we'll write to cellphone memory, then send from memory\n", @@ -2857,24 +2866,23 @@ You need 6 steps: goto uscita; } } -#endif -#ifndef WANT_GSMLIB - memset(mesg_test, '\0', sizeof(mesg_test)); - sprintf(mesg_test,":) ciao belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8 - //text=mesg_test; - - memset(smscommand, '\0', sizeof(smscommand)); - if (tech_pvt->no_ucs2) { - sprintf(smscommand, "%s", text); - } else { - utf8_to_ucs2(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand)); - } -#else // WANT_GSMLIB - - memset(smscommand, '\0', sizeof(smscommand)); + if (tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0) { + memset(smscommand, '\0', sizeof(smscommand)); sprintf(smscommand, "%s", pdu2); -#endif // WANT_GSMLIB + } else { + memset(mesg_test, '\0', sizeof(mesg_test)); + sprintf(mesg_test, ":) ciao belè новоÑти לק ר×ת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8 + //text=mesg_test; + + memset(smscommand, '\0', sizeof(smscommand)); + if (tech_pvt->no_ucs2) { + sprintf(smscommand, "%s", text); + } else { + utf8_to_ucs2(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand)); + } + + } smscommand[strlen(smscommand)] = 0x1A; DEBUGA_GSMOPEN("smscommand len is: %d, text is:|||%s|||\n", GSMOPEN_P_LOG, (int) strlen(smscommand), smscommand); @@ -2927,13 +2935,6 @@ You need 6 steps: POPPA_UNLOCKA(&tech_pvt->controldev_lock); } -#ifdef NOTDEF - err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0"); - if (err) { - DEBUGA_GSMOPEN("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone, continuing\n", GSMOPEN_P_LOG); - } -#endif// NOTDEF - DEBUGA_GSMOPEN("FINISH\n", GSMOPEN_P_LOG); if (failed) return -1; diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2008.vcproj b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2008.vcproj index 6310d34e08..63c43e3d20 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2008.vcproj +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2008.vcproj @@ -1,7 +1,7 @@ + @@ -39,7 +42,7 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2010.vcxproj b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2010.vcxproj new file mode 100644 index 0000000000..b2895a73d5 --- /dev/null +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.2010.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + mod_gsmopen + {74B120FF-6935-4DFE-A142-CDB6BEA99C90} + mod_skypiax + Win32Proj + + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + false + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + 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;%(AdditionalIncludeDirectories) + NO_ALSA;%(PreprocessorDefinitions) + + + Level4 + false + + + gsmlib.lib ctbd-0.16.lib "..\..\..\..\w32\library\debug\freeswitchcore.lib" "..\..\..\..\libs\libteletone\Debug\libteletone.lib" ksuser.lib "..\..\..\..\libs\win32\apr\debug\libapr-1.lib" +rpcrt4.lib "..\..\..\..\debug\libtiff.lib" "..\..\..\..\libs\spandsp\src\debug\spandsp.lib" %(AdditionalOptions) + gsmlib\gsmlib-1.10-patched-13ubuntu\win32\Debug;libctb-0.16\lib;%(AdditionalLibraryDirectories) + 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;%(AdditionalIncludeDirectories) + + + + + rpcrt4.lib %(AdditionalOptions) + false + + + + + + + X64 + + + 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;%(AdditionalIncludeDirectories) + NO_ALSA;%(PreprocessorDefinitions) + + + Level4 + false + + + gsmlib.lib ctbd-0.16.lib "..\..\..\..\w32\library\debug\freeswitchcore.lib" "..\..\..\..\libs\libteletone\Debug\libteletone.lib" ksuser.lib "..\..\..\..\libs\win32\apr\debug\libapr-1.lib" +rpcrt4.lib "..\..\..\..\debug\libtiff.lib" "..\..\..\..\libs\spandsp\src\debug\spandsp.lib" %(AdditionalOptions) + gsmlib\gsmlib-1.10-patched-13ubuntu\win32\Debug;libctb-0.16\lib;%(AdditionalLibraryDirectories) + false + + + MachineX64 + + + + + X64 + + + 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;%(AdditionalIncludeDirectories) + + + + + rpcrt4.lib %(AdditionalOptions) + false + + + MachineX64 + + + + + + + + + + + + {26c82fce-e0cf-4d10-a00c-d8e582ffeb53} + + + + + + \ No newline at end of file diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index 8ccfeda0ae..62f5cdd20f 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2011, Anthony Minessale II + * Copyright (C) 2005-2011, Anthony Minessale II * * Version: MPL 1.1 * @@ -23,14 +23,11 @@ * * This module (mod_gsmopen) has been contributed by: * - * Giovanni Maruzzelli (gmaruzz@gmail.com) + * Giovanni Maruzzelli * + * Maintainer: Giovanni Maruzzelli * - * Further Contributors: - * - * - * - * mod_gsmopen.c -- GSM compatible Endpoint Module + * mod_gsmopen.cpp -- GSM Modem compatible Endpoint Module * */ @@ -296,7 +293,9 @@ switch_status_t gsmopen_tech_init(private_t *tech_pvt, switch_core_session_t *se switch_core_timer_sync(&tech_pvt->timer_write); + switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_HANGUP); + switch_mutex_unlock(tech_pvt->flag_mutex); DEBUGA_GSMOPEN("gsmopen_codec SUCCESS\n", GSMOPEN_P_LOG); return SWITCH_STATUS_SUCCESS; } @@ -343,7 +342,13 @@ static switch_status_t interface_exists(char *the_interface) static switch_status_t remove_interface(char *the_interface) { int x = 10; + int fd; +#ifdef WIN32 + switch_size_t howmany = 8; +#else unsigned int howmany = 8; +#endif + int interface_id = -1; private_t *tech_pvt = NULL; switch_status_t status; @@ -386,6 +391,8 @@ static switch_status_t remove_interface(char *the_interface) goto end; } + LOKKA(tech_pvt->controldev_lock); + globals.GSMOPEN_INTERFACES[interface_id].running = 0; if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread) { @@ -437,6 +444,36 @@ static switch_status_t remove_interface(char *the_interface) switch_thread_join(&status, globals.GSMOPEN_INTERFACES[interface_id].gsmopen_api_thread); } + fd = tech_pvt->controldevfd; + //DEBUGA_GSMOPEN("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd); + if (fd) { + //close(fd); + tech_pvt->controldevfd = -1; + DEBUGA_GSMOPEN("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd); + } + + serial_audio_shutdown(tech_pvt); + + int res; + res = tech_pvt->serialPort_serial_control->Close(); + DEBUGA_GSMOPEN("serial_shutdown res=%d (controldevfd is %d)\n", GSMOPEN_P_LOG, res, tech_pvt->controldevfd); + +#ifndef WIN32 + shutdown(tech_pvt->audiogsmopenpipe[0], 2); + close(tech_pvt->audiogsmopenpipe[0]); + shutdown(tech_pvt->audiogsmopenpipe[1], 2); + close(tech_pvt->audiogsmopenpipe[1]); + shutdown(tech_pvt->audiopipe[0], 2); + close(tech_pvt->audiopipe[0]); + shutdown(tech_pvt->audiopipe[1], 2); + close(tech_pvt->audiopipe[1]); + shutdown(tech_pvt->GSMopenHandles.fdesc[0], 2); + close(tech_pvt->GSMopenHandles.fdesc[0]); + shutdown(tech_pvt->GSMopenHandles.fdesc[1], 2); + close(tech_pvt->GSMopenHandles.fdesc[1]); +#endif /* WIN32 */ + + UNLOCKA(tech_pvt->controldev_lock); switch_mutex_lock(globals.mutex); if (globals.gsm_console == &globals.GSMOPEN_INTERFACES[interface_id]) { DEBUGA_GSMOPEN("interface '%s' no more console\n", GSMOPEN_P_LOG, the_interface); @@ -450,6 +487,7 @@ static switch_status_t remove_interface(char *the_interface) DEBUGA_GSMOPEN("interface '%s' deleted successfully\n", GSMOPEN_P_LOG, the_interface); globals.GSMOPEN_INTERFACES[interface_id].running = 1; + end: //running = 1; return SWITCH_STATUS_SUCCESS; @@ -474,7 +512,9 @@ static switch_status_t channel_on_init(switch_core_session_t *session) channel = switch_core_session_get_channel(session); switch_assert(channel != NULL); //ERRORA("%s CHANNEL INIT\n", GSMOPEN_P_LOG, tech_pvt->name); + switch_mutex_lock(tech_pvt->flag_mutex); switch_set_flag(tech_pvt, TFLAG_IO); + switch_mutex_unlock(tech_pvt->flag_mutex); /* Move channel's state machine to ROUTING. This means the call is trying to get from the initial start where the call because, to the point @@ -549,9 +589,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) } DEBUGA_GSMOPEN("%s CHANNEL HANGUP\n", GSMOPEN_P_LOG, tech_pvt->name); + switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_VOICE); switch_set_flag(tech_pvt, TFLAG_HANGUP); + switch_mutex_unlock(tech_pvt->flag_mutex); gsmopen_hangup(tech_pvt); @@ -621,18 +663,18 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int switch (sig) { case SWITCH_SIG_KILL: DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_SIG_KILL\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); - //switch_mutex_lock(tech_pvt->flag_mutex); + switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_VOICE); switch_set_flag(tech_pvt, TFLAG_HANGUP); - //switch_mutex_unlock(tech_pvt->flag_mutex); + switch_mutex_unlock(tech_pvt->flag_mutex); break; case SWITCH_SIG_BREAK: DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_SIG_BREAK\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); //switch_set_flag(tech_pvt, TFLAG_BREAK); - //switch_mutex_lock(tech_pvt->flag_mutex); + switch_mutex_lock(tech_pvt->flag_mutex); switch_set_flag(tech_pvt, TFLAG_BREAK); - //switch_mutex_unlock(tech_pvt->flag_mutex); + switch_mutex_unlock(tech_pvt->flag_mutex); break; default: break; @@ -728,7 +770,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch samples = 320; memcpy(tech_pvt->read_frame.data, buffer2, 320); } else { - DEBUGA_GSMOPEN("read less than 320, samples=%d\n", GSMOPEN_P_LOG, samples); + if (samples != 0) { + DEBUGA_GSMOPEN("read less than 320, samples=%d\n", GSMOPEN_P_LOG, samples); + } if (tech_pvt->buffer2_full) { memcpy(tech_pvt->read_frame.data, tech_pvt->buffer2, 320); tech_pvt->buffer2_full = 0; @@ -744,10 +788,14 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch *frame = &tech_pvt->read_frame; + switch_mutex_lock(tech_pvt->flag_mutex); switch_set_flag(tech_pvt, TFLAG_VOICE); + switch_mutex_unlock(tech_pvt->flag_mutex); if (samples != 320) { - DEBUGA_GSMOPEN("samples=%d, goto cng\n", GSMOPEN_P_LOG, samples); + if (samples != 0) { + DEBUGA_GSMOPEN("samples=%d, goto cng\n", GSMOPEN_P_LOG, samples); + } goto cng; } @@ -770,15 +818,17 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch switch_channel_queue_dtmf(channel, &dtmf); p++; } - NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", GSMOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp, - (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp)); + DEBUGA_GSMOPEN("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", GSMOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp, + (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp)); tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp; } } while (switch_test_flag(tech_pvt, TFLAG_IO)) { if (switch_test_flag(tech_pvt, TFLAG_BREAK)) { + switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_BREAK); - DEBUGA_GSMOPEN("CHANNEL READ FRAME goto CNG\n", GSMOPEN_P_LOG); + switch_mutex_unlock(tech_pvt->flag_mutex); + DEBUGA_GSMOPEN("BREAK: CHANNEL READ FRAME goto CNG\n", GSMOPEN_P_LOG); goto cng; } @@ -788,7 +838,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch } if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) { + switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_VOICE); + switch_mutex_unlock(tech_pvt->flag_mutex); if (!tech_pvt->read_frame.datalen) { DEBUGA_GSMOPEN("CHANNEL READ CONTINUE\n", GSMOPEN_P_LOG); continue; @@ -799,11 +851,10 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch switch_swap_linear((int16_t *) (*frame)->data, (int) (*frame)->datalen / 2); } #endif - //WARNINGA("HERE\n", GSMOPEN_P_LOG); + //DEBUGA_GSMOPEN("HERE\n", GSMOPEN_P_LOG); return SWITCH_STATUS_SUCCESS; } - WARNINGA("HERE\n", GSMOPEN_P_LOG); DEBUGA_GSMOPEN("CHANNEL READ no TFLAG_VOICE\n", GSMOPEN_P_LOG); return SWITCH_STATUS_FALSE; @@ -852,7 +903,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc //switch_core_timer_next(&tech_pvt->timer_write); gsmopen_sound_boost(frame->data, frame->samples, tech_pvt->playback_boost); - if(!tech_pvt->no_sound){ + if (!tech_pvt->no_sound) { sent = tech_pvt->serialPort_serial_audio->Write((char *) frame->data, (int) (frame->datalen)); if (sent && sent != frame->datalen && sent != -1) { @@ -874,20 +925,23 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session) switch_assert(tech_pvt != NULL); //ERRORA("%s CHANNEL INIT\n", GSMOPEN_P_LOG, tech_pvt->name); + switch_mutex_lock(tech_pvt->flag_mutex); switch_set_flag(tech_pvt, TFLAG_IO); + switch_mutex_unlock(tech_pvt->flag_mutex); + gsmopen_serial_answer(tech_pvt); - /* Move channel's state machine to ROUTING. This means the call is trying - to get from the initial start where the call because, to the point - where a destination has been identified. If the channel is simply - left in the initial state, nothing will happen. */ - switch_channel_set_state(channel, CS_ROUTING); switch_mutex_lock(globals.mutex); globals.calls++; switch_mutex_unlock(globals.mutex); DEBUGA_GSMOPEN("%s CHANNEL ANSWER %s\n", GSMOPEN_P_LOG, tech_pvt->name, switch_core_session_get_uuid(session)); + + if (channel) { + switch_channel_mark_answered(channel); + } + DEBUGA_GSMOPEN("ANSWERED! \n", GSMOPEN_P_LOG); return SWITCH_STATUS_SUCCESS; @@ -907,8 +961,21 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s switch (msg->message_id) { case SWITCH_MESSAGE_INDICATE_ANSWER: { - DEBUGA_GSMOPEN("MSG_ID=%d, TO BE ANSWERED!\n", GSMOPEN_P_LOG, msg->message_id); - channel_answer_channel(session); + DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); + if (tech_pvt->interface_state != GSMOPEN_STATE_UP && tech_pvt->phone_callflow != CALLFLOW_CALL_ACTIVE) { + DEBUGA_GSMOPEN("MSG_ID=%d, TO BE ANSWERED!\n", GSMOPEN_P_LOG, msg->message_id); + channel_answer_channel(session); + } + } + break; + + case SWITCH_MESSAGE_INDICATE_PROGRESS: + { + DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_MESSAGE_INDICATE_PROGRESS\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); + if (tech_pvt->interface_state != GSMOPEN_STATE_UP && tech_pvt->phone_callflow != CALLFLOW_CALL_ACTIVE) { + DEBUGA_GSMOPEN("MSG_ID=%d, TO BE ANSWERED!\n", GSMOPEN_P_LOG, msg->message_id); + channel_answer_channel(session); + } } break; case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: @@ -919,9 +986,20 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s break; + case SWITCH_MESSAGE_INDICATE_TRANSFER: + DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_MESSAGE_INDICATE_TRANSFER\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); + break; + case SWITCH_MESSAGE_INDICATE_BRIDGE: + DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_MESSAGE_INDICATE_BRIDGE\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); + break; + case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY: + DEBUGA_GSMOPEN("%s CHANNEL got SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY\n", GSMOPEN_P_LOG, switch_channel_get_name(channel)); + break; default: { - DEBUGA_GSMOPEN("MSG_ID=%d\n", GSMOPEN_P_LOG, msg->message_id); + if (msg->message_id != SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC && msg->message_id != SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE) { + DEBUGA_GSMOPEN("MSG_ID=%d\n", GSMOPEN_P_LOG, msg->message_id); + } } break; } @@ -1089,7 +1167,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi caller_profile = tech_pvt->caller_profile; caller_profile->destination_number = rdest; + switch_mutex_lock(tech_pvt->flag_mutex); switch_set_flag(tech_pvt, TFLAG_OUTBOUND); + switch_mutex_unlock(tech_pvt->flag_mutex); switch_channel_set_state(channel, CS_INIT); gsmopen_call(tech_pvt, rdest, 30); switch_mutex_unlock(globals.mutex); @@ -1119,7 +1199,7 @@ static switch_status_t load_config(int reload_type) SetConsoleOutputCP(65001); DEBUGA_GSMOPEN("Windows CODEPAGE Output =%d\n", GSMOPEN_P_LOG, GetConsoleOutputCP()); //let's hope to have unicode in console now. You need to use Lucida Console or, much better, Courier New font for the command prompt to show unicode -#endif// WIN32 +#endif // WIN32 NOTICA("GSMOPEN Charset Output Test 0 %s\n", GSMOPEN_P_LOG, "èéòàù"); NOTICA("GSMOPEN Charset Output Test 1 %s\n", GSMOPEN_P_LOG, "ç°§^£"); NOTICA("GSMOPEN Charset Output Test 2 %s\n", GSMOPEN_P_LOG, "новоÑти"); @@ -1190,7 +1270,7 @@ static switch_status_t load_config(int reload_type) const char *at_hangup_expect = "OK"; const char *at_answer = "ATA"; const char *at_answer_expect = "OK"; - const char *at_send_dtmf = "AT+VTS"; + const char *at_send_dtmf = "AT^DTMF"; const char *at_preinit_1 = ""; const char *at_preinit_1_expect = ""; const char *at_preinit_2 = ""; @@ -1751,6 +1831,9 @@ static switch_status_t chat_send(switch_event_t *message_event) if (hint == NULL || !strlen(hint)) { //FIXME FIXME FIXME hint = from; } + if (subject == NULL || !strlen(subject)) { //FIXME FIXME FIXME + subject = "SIMPLE MESSAGE"; + } if (to && (user = strdup(to))) { if ((host = strchr(user, '@'))) { *host++ = '\0'; @@ -1875,7 +1958,11 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_gsmopen_shutdown) int x; private_t *tech_pvt = NULL; switch_status_t status; +#ifdef WIN32 + switch_size_t howmany = 8; +#else unsigned int howmany = 8; +#endif int interface_id; int fd; @@ -2029,11 +2116,8 @@ int new_inbound_channel(private_t *tech_pvt) return 0; } } - if (channel) { - //switch_channel_mark_answered(channel); - } - DEBUGA_GSMOPEN("new_inbound_channel\n", GSMOPEN_P_LOG); + DEBUGA_GSMOPEN("EXITING new_inbound_channel\n", GSMOPEN_P_LOG); return 0; } @@ -2208,31 +2292,45 @@ SWITCH_STANDARD_API(gsm_function) if (!strcasecmp(argv[0], "list")) { int i; + unsigned int ib = 0; + unsigned int ib_failed = 0; + unsigned int ob = 0; + unsigned int ob_failed = 0; char next_flag_char = ' '; stream->write_function(stream, "F ID\t Name \tIB (F/T) OB (F/T)\tState\tCallFlw\t\tUUID\n"); stream->write_function(stream, "= ====\t ======== \t======= =======\t======\t============\t======\n"); for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) { - next_flag_char = i == globals.next_interface ? '*' : ' '; if (strlen(globals.GSMOPEN_INTERFACES[i].name)) { + next_flag_char = i == globals.next_interface ? '*' : ' '; + ib += globals.GSMOPEN_INTERFACES[i].ib_calls; + ib_failed += globals.GSMOPEN_INTERFACES[i].ib_failed_calls; + ob += globals.GSMOPEN_INTERFACES[i].ob_calls; + ob_failed += globals.GSMOPEN_INTERFACES[i].ob_failed_calls; + + stream->write_function(stream, - "%c %d\t[%s]\t%3ld/%ld\t%6ld/%ld\t%s\t%s\t%s\n", - next_flag_char, - i, globals.GSMOPEN_INTERFACES[i].name, - globals.GSMOPEN_INTERFACES[i].ib_failed_calls, - globals.GSMOPEN_INTERFACES[i].ib_calls, - globals.GSMOPEN_INTERFACES[i].ob_failed_calls, - globals.GSMOPEN_INTERFACES[i].ob_calls, - interface_status[globals.GSMOPEN_INTERFACES[i].interface_state], - phone_callflow[globals.GSMOPEN_INTERFACES[i].phone_callflow], globals.GSMOPEN_INTERFACES[i].session_uuid_str); + //"%c %d\t[%s]\t%3ld/%ld\t%6ld/%ld\t%s\t%s\t%s\n", + "%c %d\t[%6s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n", + next_flag_char, + i, globals.GSMOPEN_INTERFACES[i].name, + globals.GSMOPEN_INTERFACES[i].ib_failed_calls, + globals.GSMOPEN_INTERFACES[i].ib_calls, + globals.GSMOPEN_INTERFACES[i].ob_failed_calls, + globals.GSMOPEN_INTERFACES[i].ob_calls, + interface_status[globals.GSMOPEN_INTERFACES[i].interface_state], + phone_callflow[globals.GSMOPEN_INTERFACES[i].phone_callflow], globals.GSMOPEN_INTERFACES[i].session_uuid_str); } else if (argc > 1 && !strcasecmp(argv[1], "full")) { - stream->write_function(stream, "%c\t%d\n", next_flag_char, i); + stream->write_function(stream, "%c %d\n", next_flag_char, i); + //stream->write_function(stream, "%c\t%d\n", next_flag_char, i); } } - stream->write_function(stream, "\nTotal: %d\n", globals.real_interfaces - 1); + //stream->write_function(stream, "\nTotal: %d\n", globals.real_interfaces - 1); + 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); } else if (!strcasecmp(argv[0], "console")) { int i; @@ -2727,7 +2825,7 @@ void *gsmopen_do_gsmopenapi_thread_func(void *obj) //FIXME } } else if (tech_pvt->controldevprotocol != PROTOCOL_NO_SERIAL && tech_pvt->interface_state == GSMOPEN_STATE_DIALING) { - WARNINGA("WE'RE DIALING, let's take the earlymedia\n", GSMOPEN_P_LOG); + DEBUGA_GSMOPEN("WE'RE DIALING, let's take the earlymedia\n", GSMOPEN_P_LOG); tech_pvt->interface_state = CALLFLOW_STATUS_EARLYMEDIA; remote_party_is_early_media(tech_pvt); //new_inbound_channel(tech_pvt); @@ -2736,7 +2834,7 @@ void *gsmopen_do_gsmopenapi_thread_func(void *obj) //FIXME } } else if (tech_pvt->interface_state == CALLFLOW_CALL_REMOTEANSWER) { - WARNINGA("REMOTE PARTY ANSWERED\n", GSMOPEN_P_LOG); + DEBUGA_GSMOPEN("REMOTE PARTY ANSWERED\n", GSMOPEN_P_LOG); outbound_channel_answered(tech_pvt); //new_inbound_channel(tech_pvt); //FIXME if (!gsmopen_new(p, AST_STATE_RING, tech_pvt->context)) { @@ -2925,6 +3023,7 @@ int sms_incoming(private_t *tech_pvt) DEBUGA_GSMOPEN("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s|\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender, tech_pvt->sms_body); +#ifdef NOTDEF if (!zstr(tech_pvt->session_uuid_str)) { session = switch_core_session_locate(tech_pvt->session_uuid_str); } @@ -2940,6 +3039,14 @@ int sms_incoming(private_t *tech_pvt) //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", GSMOPEN_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->sms_sender); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); switch_event_add_body(event, "%s\n", tech_pvt->sms_body); if (session) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true"); @@ -2987,6 +3094,38 @@ int sms_incoming(private_t *tech_pvt) if (session) { switch_core_session_rwunlock(session); } +#endif //NOTDEF + /* mod_sms begin */ + if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", GSMOPEN_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); + //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, "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); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", GSMOPEN_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->sms_sender); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); + switch_event_add_body(event, "%s\n", tech_pvt->sms_body); + //switch_core_chat_send("GLOBAL", event); /* mod_sms */ + switch_core_chat_send("GLOBAL", event); /* mod_sms */ + } else { + + ERRORA("cannot create event on interface %s. WHY?????\n", GSMOPEN_P_LOG, tech_pvt->name); + } + /* mod_sms end */ + + //memset(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->chatmessages[which]) ); //memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message)); return 0; diff --git a/src/mod/endpoints/mod_h323/mod_h323.cpp b/src/mod/endpoints/mod_h323/mod_h323.cpp index e7199e0dee..2e7050e850 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.cpp +++ b/src/mod/endpoints/mod_h323/mod_h323.cpp @@ -1334,11 +1334,11 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode) else t38_options->T38FaxUdpEC = "t38UDPRedundancy"; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxUdpEC:%s\n",t38_options->T38FaxUdpEC); - const char *uuid = switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *uuid = switch_channel_get_partner_uuid(m_fsChannel); if (uuid != NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",uuid); - switch_core_session_t *session = switch_core_session_locate(switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE)); + switch_core_session_t *session = switch_core_session_locate(switch_channel_get_partner_uuid(m_fsChannel)); if (session) { switch_channel_t * channel = switch_core_session_get_channel(session); if (channel) { @@ -2229,7 +2229,7 @@ PBoolean FSH323_ExternalRTPChannel::Start() switch_channel_mark_pre_answered(m_fsChannel); if (m_capability->GetMainType() == H323Capability::e_Data && m_conn->m_rxChannel && m_conn->m_txChannel) { - const char *uuid = switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *uuid = switch_channel_get_partner_uuid(m_fsChannel); if (uuid != NULL){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->switch_rtp_udptl_mode\n"); switch_rtp_udptl_mode(tech_pvt->rtp_session); diff --git a/src/mod/endpoints/mod_html5/Makefile.am b/src/mod/endpoints/mod_html5/Makefile.am new file mode 100644 index 0000000000..9262333ad1 --- /dev/null +++ b/src/mod/endpoints/mod_html5/Makefile.am @@ -0,0 +1,22 @@ +include $(top_srcdir)/build/modmake.rulesam + +MODNAME=mod_html5 + +LIBWEBSOCKETS_DIR=$(switch_srcdir)/libs/libwebsockets +LIBWEBSOCKETS_BUILDDIR=$(switch_builddir)/libs/libwebsockets +LIBWEBSOCKETSLA=$(LIBWEBSOCKETS_BUILDDIR)/lib/libwebsockets.la + +mod_LTLIBRARIES = mod_html5.la +mod_html5_la_SOURCES = mod_html5.c +mod_html5_la_CFLAGS = $(AM_CFLAGS) -I. +mod_html5_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(LIBWEBSOCKETSLA) +mod_html5_la_LDFLAGS = -avoid-version -module -no-undefined -shared + +BUILT_SOURCES = $(LIBWEBSOCKETSLA) + +$(mod_html5_la_SOURCES) : $(BUILT_SOURCES) + +$(LIBWEBSOCKETSLA): $(LIBWEBSOCKETS_DIR) $(LIBWEBSOCKETS_DIR)/.update + cd $(LIBWEBSOCKETS_BUILDDIR) && $(MAKE) + $(TOUCH_TARGET) + diff --git a/src/mod/endpoints/mod_html5/mod_html5.c b/src/mod/endpoints/mod_html5/mod_html5.c new file mode 100644 index 0000000000..fd8ab0573c --- /dev/null +++ b/src/mod/endpoints/mod_html5/mod_html5.c @@ -0,0 +1,541 @@ +/* + * mod_html5 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2011-2012, Barracuda Networks Inc. + * + * 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_html5 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Barracuda Networks Inc. + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * Michael Jerris + * + * mod_html5.c -- HTML5 Endpoint Module + * + */ + +#include + +#define HTML5_EVENT_CUSTOM "html5::custom" + +struct html5_profile { + char *name; /* < Profile name */ + switch_memory_pool_t *pool; /* < Memory pool */ + switch_thread_rwlock_t *rwlock; /* < Rwlock for reference counting */ + uint32_t flags; /* < PFLAGS */ + switch_mutex_t *mutex; /* < Mutex for call count */ + int calls; /* < Active calls count */ + int clients; /* < Number of connected clients */ + switch_hash_t *session_hash; /* < Active rtmp sessions */ + switch_thread_rwlock_t *session_rwlock; /* < rwlock for session hashtable */ + const char *context; /* < Default dialplan name */ + const char *dialplan; /* < Default dialplan context */ + const char *bind_address; /* < Bind address */ + const char *io_name; /* < Name of I/O module (from config) */ + int chunksize; /* < Override default chunksize (from config) */ + int buffer_len; /* < Receive buffer length the flash clients should use */ + + switch_hash_t *reg_hash; /* < Registration hashtable */ + switch_thread_rwlock_t *reg_rwlock; /* < Registration hash rwlock */ + + switch_bool_t auth_calls; /* < Require authentiation */ +}; + +typedef struct html5_profile html5_profile_t; + +struct html5_private { + unsigned int flags; + switch_codec_t read_codec; + switch_codec_t write_codec; + + switch_frame_t read_frame; + unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; /* < Buffer for read_frame */ + + switch_caller_profile_t *caller_profile; + + switch_mutex_t *mutex; + switch_mutex_t *flag_mutex; + + switch_core_session_t *session; + switch_channel_t *channel; +}; + +typedef struct html5_private html5_private_t; + +switch_status_t html5_on_execute(switch_core_session_t *session); +switch_status_t html5_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf); +switch_status_t html5_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg); +switch_status_t html5_receive_event(switch_core_session_t *session, switch_event_t *event); +switch_status_t html5_on_init(switch_core_session_t *session); +switch_status_t html5_on_hangup(switch_core_session_t *session); +switch_status_t html5_on_destroy(switch_core_session_t *session); +switch_status_t html5_on_routing(switch_core_session_t *session); +switch_status_t html5_on_exchange_media(switch_core_session_t *session); +switch_status_t html5_on_soft_execute(switch_core_session_t *session); +switch_call_cause_t html5_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); +switch_status_t html5_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); +switch_status_t html5_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); +switch_status_t html5_kill_channel(switch_core_session_t *session, int sig); + +SWITCH_MODULE_LOAD_FUNCTION(mod_html5_load); +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_html5_shutdown); +SWITCH_MODULE_DEFINITION(mod_html5, mod_html5_load, mod_html5_shutdown, NULL); + +switch_state_handler_table_t html5_state_handlers = { + /*.on_init */ html5_on_init, + /*.on_routing */ html5_on_routing, + /*.on_execute */ html5_on_execute, + /*.on_hangup */ html5_on_hangup, + /*.on_exchange_media */ html5_on_exchange_media, + /*.on_soft_execute */ html5_on_soft_execute, + /*.on_consume_media */ NULL, + /*.on_hibernate */ NULL, + /*.on_reset */ NULL, + /*.on_park */ NULL, + /*.on_reporting */ NULL, + /*.on_destroy */ html5_on_destroy +}; + +switch_io_routines_t html5_io_routines = { + /*.outgoing_channel */ html5_outgoing_channel, + /*.read_frame */ html5_read_frame, + /*.write_frame */ html5_write_frame, + /*.kill_channel */ html5_kill_channel, + /*.send_dtmf */ html5_send_dtmf, + /*.receive_message */ html5_receive_message, + /*.receive_event */ html5_receive_event +}; + +/* + State methods they get called when the state changes to the specific state + returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next + so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it. +*/ +switch_status_t html5_on_init(switch_core_session_t *session) +{ + switch_channel_t *channel; + html5_private_t *tech_pvt = NULL; + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_on_routing(switch_core_session_t *session) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_on_execute(switch_core_session_t *session) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel)); + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_on_destroy(switch_core_session_t *session) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + + if (tech_pvt == NULL) { + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_on_hangup(switch_core_session_t *session) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_kill_channel(switch_core_session_t *session, int sig) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch (sig) { + case SWITCH_SIG_KILL: + break; + case SWITCH_SIG_BREAK: + break; + default: + break; + } + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_on_exchange_media(switch_core_session_t *session) +{ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n"); + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_on_soft_execute(switch_core_session_t *session) +{ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n"); + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) +{ + html5_private_t *tech_pvt = switch_core_session_get_private(session); + switch_assert(tech_pvt != NULL); + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + // *frame = &tech_pvt->read_frame; + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) +{ + switch_channel_t *channel = NULL; + html5_private_t *tech_pvt = NULL; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t html5_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) +{ + switch_channel_t *channel; + html5_private_t *tech_pvt; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = (html5_private_t *) switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch (msg->message_id) { + case SWITCH_MESSAGE_INDICATE_ANSWER: + switch_channel_mark_answered(channel); + break; + case SWITCH_MESSAGE_INDICATE_RINGING: + switch_channel_mark_ring_ready(channel); + break; + case SWITCH_MESSAGE_INDICATE_PROGRESS: + switch_channel_mark_pre_answered(channel); + break; + case SWITCH_MESSAGE_INDICATE_HOLD: + case SWITCH_MESSAGE_INDICATE_UNHOLD: + break; + case SWITCH_MESSAGE_INDICATE_DISPLAY: + break; + default: + break; + } + + return SWITCH_STATUS_SUCCESS; +} + +/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines + that allocate memory or you will have 1 channel with memory allocated from another channel's pool! +*/ +switch_call_cause_t html5_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **newsession, switch_memory_pool_t **inpool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause) +{ + // html5_private_t *tech_pvt; + // switch_caller_profile_t *caller_profile; + // switch_channel_t *channel; + switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + + return cause; +} + +switch_status_t html5_receive_event(switch_core_session_t *session, switch_event_t *event) +{ + html5_private_t *tech_pvt = switch_core_session_get_private(session); + switch_assert(tech_pvt != NULL); + + return SWITCH_STATUS_SUCCESS; +} + +#if 0 + +static switch_xml_config_item_t *get_instructions(html5_profile_t *profile) { + switch_xml_config_item_t *dup; + switch_xml_config_item_t instructions[] = { + /* parameter name type reloadable pointer default value options structure */ + SWITCH_CONFIG_ITEM("context", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->context, "public", &switch_config_string_strdup, + "", "The dialplan context to use for inbound calls"), + SWITCH_CONFIG_ITEM("dialplan", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->dialplan, "XML", &switch_config_string_strdup, + "", "The dialplan to use for inbound calls"), + SWITCH_CONFIG_ITEM("bind-address", SWITCH_CONFIG_STRING, 0, &profile->bind_address, "0.0.0.0:1935", &switch_config_string_strdup, + "ip:port", "IP and port to bind"), + SWITCH_CONFIG_ITEM("auth-calls", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->auth_calls, SWITCH_FALSE, NULL, "true|false", "Set to true in order to reject unauthenticated calls"), + SWITCH_CONFIG_ITEM_END() + }; + + dup = malloc(sizeof(instructions)); + memcpy(dup, instructions, sizeof(instructions)); + return dup; +} + +static switch_status_t config_profile(html5_profile_t *profile, switch_bool_t reload) +{ + switch_xml_t cfg, xml, x_profiles, x_profile, x_settings; + switch_status_t status = SWITCH_STATUS_FALSE; + switch_xml_config_item_t *instructions = (profile ? get_instructions(profile) : NULL); + switch_event_t *event = NULL; + int count; + const char *file = "html5.conf"; + + if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file); + goto done; + } + + if (!(x_profiles = switch_xml_child(cfg, "profiles"))) { + goto done; + } + + for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { + const char *name = switch_xml_attr_soft(x_profile, "name"); + if (strcmp(name, profile->name)) { + continue; + } + + if (!(x_settings = switch_xml_child(x_profile, "settings"))) { + goto done; + } + + + count = switch_event_import_xml(switch_xml_child(x_settings, "param"), "name", "value", &event); + status = switch_xml_config_parse_event(event, count, reload, instructions); + } + + +done: + if (xml) { + switch_xml_free(xml); + } + switch_safe_free(instructions); + if (event) { + switch_event_destroy(&event); + } + return status; +} +#endif + +static void html5_event_handler(switch_event_t *event) +{ + if (!event) { + return; + } +} + +#define HTML5_CONTACT_FUNCTION_SYNTAX "profile/user@domain[/[!]nickname]" +SWITCH_STANDARD_API(html5_contact_function) +{ + int argc; + char *argv[5]; + char *dup = NULL; + // char *szprofile = NULL, *user = NULL; + // const char *nickname = NULL; + + if (zstr(cmd)) { + goto usage; + } + + dup = strdup(cmd); + argc = switch_split(dup, '/', argv); + + if (argc < 2 || zstr(argv[0]) || zstr(argv[1])) { + goto usage; + } + + // szprofile = argv[0]; + + if (!strchr(argv[1], '@')) { + goto usage; + } + + // user = argv[1]; + // nickname = argv[2]; + + goto done; + +usage: + stream->write_function(stream, "Usage: html5_contact "HTML5_CONTACT_FUNCTION_SYNTAX"\n"); + +done: + switch_safe_free(dup); + return SWITCH_STATUS_SUCCESS; +} + +#define HTML5_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(html5_function) +{ + int argc; + char *argv[10]; + char *dup = NULL; + + if (zstr(cmd)) { + goto usage; + } + + dup = strdup(cmd); + argc = switch_split(dup, ' ', argv); + + if (argc < 1 || zstr(argv[0])) { + goto usage; + } + + goto done; + +usage: + stream->write_function(stream, "-ERR Usage: "HTML5_FUNCTION_SYNTAX"\n"); + +done: + switch_safe_free(dup); + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_MODULE_LOAD_FUNCTION(mod_html5_load) +{ + switch_api_interface_t *api_interface; + switch_endpoint_interface_t *html5_endpoint_interface; + + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + + html5_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + html5_endpoint_interface->interface_name = "html5"; + html5_endpoint_interface->io_routines = &html5_io_routines; + html5_endpoint_interface->state_handler = &html5_state_handlers; + + SWITCH_ADD_API(api_interface, "html5", "html5 management", html5_function, HTML5_FUNCTION_SYNTAX); + SWITCH_ADD_API(api_interface, "html5_contact", "html5 contact", html5_contact_function, HTML5_CONTACT_FUNCTION_SYNTAX); + + // switch_console_set_complete("add html5 status"); + + switch_event_bind("mod_html5", SWITCH_EVENT_CUSTOM, HTML5_EVENT_CUSTOM, html5_event_handler, NULL); + + { + switch_xml_t cfg, xml, x_profiles, x_profile; + const char *file = "html5.conf"; + + if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file); + goto done; + } + + if (!(x_profiles = switch_xml_child(cfg, "profiles"))) { + goto done; + } + + for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { + //const char *name = switch_xml_attr_soft(x_profile, "name"); + //html5_profile_start(name); + } + done: + if (xml) { + switch_xml_free(xml); + } + } + + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_html5_shutdown) +{ + switch_event_unbind_callback(html5_event_handler); + + 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: + */ diff --git a/src/mod/endpoints/mod_khomp/include/applications.h b/src/mod/endpoints/mod_khomp/include/applications.h index 21b66b2b0a..14ba1d3323 100644 --- a/src/mod/endpoints/mod_khomp/include/applications.h +++ b/src/mod/endpoints/mod_khomp/include/applications.h @@ -599,7 +599,7 @@ struct Transfer return SWITCH_STATUS_FALSE; } - switch_core_session_t *peer_session = switch_core_session_locate(switch_channel_get_variable(chan,SWITCH_SIGNAL_BOND_VARIABLE)); + switch_core_session_t *peer_session = switch_core_session_locate(switch_channel_get_partner_uuid(chan)); if(!peer_session) { @@ -662,7 +662,7 @@ struct Transfer switch_channel_t * peer = switch_core_session_get_channel(peer_session); /* put the channel in hold */ - //switch_core_session_t *session = switch_core_session_locate(switch_channel_get_variable(chan,SWITCH_SIGNAL_BOND_VARIABLE)); + //switch_core_session_t *session = switch_core_session_locate(switch_channel_get_partner_uuid(chan)); //switch_channel_t *chan_core = switch_core_session_get_channel(session); const char *stream; @@ -709,7 +709,7 @@ struct Transfer switch_core_session_rwunlock(pvt->session()); switch_core_session_rwunlock(peer_session); - //switch_ivr_unhold_uuid(switch_channel_get_variable(chan,SWITCH_SIGNAL_BOND_VARIABLE)); + //switch_ivr_unhold_uuid(switch_channel_get_partner_uuid(chan)); } catch (ScopedLockFailed & err) { diff --git a/src/mod/endpoints/mod_khomp/mod_khomp.cpp b/src/mod/endpoints/mod_khomp/mod_khomp.cpp index 5e7375b0e9..557cfb46f5 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-2009, Anthony Minessale II + * Copyright (C) 2005-2012, 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 b333cebda9..e2a2c3daab 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -122,8 +122,8 @@ static void clear_queue(private_t *tech_pvt) static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *session, switch_codec_t *codec) { const char *iananame = "L16"; - int rate = 8000; - int interval = 20; + uint32_t rate = 8000; + uint32_t interval = 20; switch_status_t status = SWITCH_STATUS_SUCCESS; switch_channel_t *channel = switch_core_session_get_channel(session); const switch_codec_implementation_t *read_impl; @@ -132,6 +132,15 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses iananame = codec->implementation->iananame; rate = codec->implementation->samples_per_second; interval = codec->implementation->microseconds_per_packet / 1000; + } else { + const char *var; + + if ((var = switch_channel_get_variable(channel, "loopback_initial_codec"))) { + char *dup = switch_core_session_strdup(session, var); + uint32_t bit; + iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit); + } + } if (switch_core_codec_ready(&tech_pvt->read_codec)) { @@ -641,6 +650,39 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch return status; } +static switch_status_t find_non_loopback_bridge(switch_core_session_t *session, switch_core_session_t **br_session, const char **br_uuid) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + const char *a_uuid; + switch_core_session_t *sp; + + *br_session = NULL; + *br_uuid = NULL; + + a_uuid = switch_channel_get_partner_uuid(channel); + + while (a_uuid && (sp = switch_core_session_locate(a_uuid))) { + if (switch_core_session_check_interface(sp, loopback_endpoint_interface)) { + private_t *tech_pvt = switch_core_session_get_private(sp); + + a_uuid = switch_channel_get_partner_uuid(tech_pvt->other_channel); + switch_core_session_rwunlock(sp); + sp = NULL; + } else { + break; + } + } + + if (sp) { + *br_session = sp; + *br_uuid = a_uuid; + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; + +} + static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) { switch_channel_t *channel = NULL; @@ -669,8 +711,8 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc switch_channel_test_flag(tech_pvt->other_channel, CF_BRIDGED) && switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) && switch_channel_test_flag(tech_pvt->other_channel, CF_ANSWERED) && --tech_pvt->bowout_frame_count <= 0) { - const char *a_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); - const char *b_uuid = switch_channel_get_variable(tech_pvt->other_channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *a_uuid = NULL; + const char *b_uuid = NULL; const char *vetoa, *vetob; @@ -681,16 +723,21 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc switch_core_session_t *br_a, *br_b; switch_channel_t *ch_a = NULL, *ch_b = NULL; int good_to_go = 0; + + find_non_loopback_bridge(session, &br_a, &a_uuid); + find_non_loopback_bridge(tech_pvt->other_session, &br_b, &b_uuid); + - if ((br_a = switch_core_session_locate(a_uuid))) { + if (br_a) { ch_a = switch_core_session_get_channel(br_a); } - if ((br_b = switch_core_session_locate(b_uuid))) { + if (br_b) { ch_b = switch_core_session_get_channel(br_b); } if (ch_a && ch_b && switch_channel_test_flag(ch_a, CF_BRIDGED) && switch_channel_test_flag(ch_b, CF_BRIDGED)) { + switch_set_flag_locked(tech_pvt, TFLAG_BOWOUT); switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_BOWOUT); @@ -872,7 +919,7 @@ static switch_status_t loopback_bowout_on_execute_state_handler(switch_core_sess /* Wait for b_channel to be fully bridged */ switch_channel_wait_for_flag(b_channel, CF_BRIDGED, SWITCH_TRUE, 5000, NULL); - uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE); + uuid = switch_channel_get_partner_uuid(b_channel); if (uuid && (other_session = switch_core_session_locate(uuid))) { switch_channel_t *other_channel = switch_core_session_get_channel(other_session); diff --git a/src/mod/endpoints/mod_opal/Makefile b/src/mod/endpoints/mod_opal/Makefile index fc0fc4873d..d80ba64e57 100644 --- a/src/mod/endpoints/mod_opal/Makefile +++ b/src/mod/endpoints/mod_opal/Makefile @@ -1,7 +1,19 @@ BASE=../../../.. -LOCAL_INSERT_CFLAGS= pkg-config opal --cflags -LOCAL_CFLAGS+=-g -ggdb -I. -LOCAL_INSERT_LDFLAGS= pkg-config opal --libs + +PKG_DIR:=/usr/local/lib/pkgconfig +ifeq ($(PKG_CONFIG_PATH),) + export PKG_CONFIG_PATH:=$(PKG_DIR) +else + ifeq ($(findstring $(PKG_DIR),$(PKG_CONFIG_PATH)),) + export PKG_CONFIG_PATH:=$(PKG_CONFIG_PATH):$(PKG_DIR) + endif +endif + +#DEBUG_SUFFIX:=--define-variable=suffix=_d + +LOCAL_INSERT_CFLAGS= pkg-config opal $(DEBUG_SUFFIX) --cflags +LOCAL_CFLAGS+=-g -ggdb +LOCAL_INSERT_LDFLAGS= pkg-config opal $(DEBUG_SUFFIX) --libs include $(BASE)/build/modmake.rules diff --git a/src/mod/endpoints/mod_opal/mod_opal.cpp b/src/mod/endpoints/mod_opal/mod_opal.cpp index 0760588019..cf160ba527 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.cpp +++ b/src/mod/endpoints/mod_opal/mod_opal.cpp @@ -1,1486 +1,1280 @@ -/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library / - * Soft-Switch Application - * - * Version: MPL 1.1 - * - * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com) - * - * 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. - * - * Contributor(s): - * Tuyan Ozipek (tuyanozipek@gmail.com) - * Lukasz Zwierko (lzwierko@gmail.com) - * Robert Jongbloed (robertj@voxlucida.com.au) - * - */ - -#include "mod_opal.h" -#include -#include -#include -#include - -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, mod_opal_globals.codec_string); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_context, mod_opal_globals.context); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, mod_opal_globals.dialplan); - - -#define CF_NEED_FLUSH (1 << 1) - -struct mod_opal_globals mod_opal_globals = { 0 }; - - -static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, - switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); - - -static FSProcess *opal_process = NULL; - - -static const char ModuleName[] = "opal"; - - -static switch_status_t on_hangup(switch_core_session_t *session); -static switch_status_t on_destroy(switch_core_session_t *session); - - -static switch_io_routines_t opalfs_io_routines = { - /*.outgoing_channel */ create_outgoing_channel, - /*.read_frame */ FSConnection::read_audio_frame, - /*.write_frame */ FSConnection::write_audio_frame, - /*.kill_channel */ FSConnection::kill_channel, - /*.send_dtmf */ FSConnection::send_dtmf, - /*.receive_message */ FSConnection::receive_message, - /*.receive_event */ FSConnection::receive_event, - /*.state_change */ FSConnection::state_change, - /*.read_video_frame */ FSConnection::read_video_frame, - /*.write_video_frame */ FSConnection::write_video_frame -}; - -static switch_state_handler_table_t opalfs_event_handlers = { - /*.on_init */ FSConnection::on_init, - /*.on_routing */ FSConnection::on_routing, - /*.on_execute */ FSConnection::on_execute, - /*.on_hangup */ on_hangup, - /*.on_exchange_media */ FSConnection::on_exchange_media, - /*.on_soft_execute */ FSConnection::on_soft_execute, - /*.on_consume_media*/ NULL, - /*.on_hibernate*/ NULL, - /*.on_reset*/ NULL, - /*.on_park*/ NULL, - /*.on_reporting*/ NULL, - /*.on_destroy*/ on_destroy -}; - - -SWITCH_BEGIN_EXTERN_C -/*******************************************************************************/ - -SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown); -SWITCH_MODULE_DEFINITION(mod_opal, mod_opal_load, mod_opal_shutdown, NULL); - -SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting loading mod_opal\n"); - - /* Prevent the loading of OPAL codecs via "plug ins", this is a directory - full of DLLs that will be loaded automatically. */ - putenv((char *)"PTLIBPLUGINDIR=/no/thanks"); - - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - if (!*module_interface) { - return SWITCH_STATUS_MEMERR; - } - - opal_process = new FSProcess(); - if (opal_process == NULL) { - return SWITCH_STATUS_MEMERR; - } - - if (opal_process->Initialise(*module_interface)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initialized and running\n"); - //unloading causes a seg in linux - return SWITCH_STATUS_NOUNLOAD; - //return SWITCH_STATUS_SUCCESS; - } - - delete opal_process; - opal_process = NULL; - return SWITCH_STATUS_FALSE; -} - - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown) { - - switch_safe_free(mod_opal_globals.context); - switch_safe_free(mod_opal_globals.dialplan); - switch_safe_free(mod_opal_globals.codec_string); - delete opal_process; - opal_process = NULL; - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_END_EXTERN_C -/*******************************************************************************/ - - - -static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session, - switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) -{ - if (opal_process == NULL) { - return SWITCH_CAUSE_CRASH; - } - - PString token; - - FSManager & manager = opal_process->GetManager(); - if (!manager.SetUpCall("local:", outbound_profile->destination_number, token, outbound_profile)) { - return SWITCH_CAUSE_INVALID_NUMBER_FORMAT; - } - - PSafePtr < OpalCall > call = manager.FindCallWithLock(token); - - if (call == NULL) { - return SWITCH_CAUSE_PROTOCOL_ERROR; - } - - PSafePtr < FSConnection > connection = call->GetConnectionAs < FSConnection > (0); - - if (connection == NULL) { - return SWITCH_CAUSE_PROTOCOL_ERROR; - } - - *new_session = connection->GetSession(); - - return SWITCH_CAUSE_SUCCESS; -} - - -/////////////////////////////////////////////////////////////////////// - -#if PTRACING - -class FSTrace : public ostream { - public: - FSTrace() - : ostream(&buffer) - { - } - - private: - class Buffer : public streambuf { - char buffer[250]; - - public: - Buffer() - { - setg(buffer, buffer, &buffer[sizeof(buffer)-2]); - setp(buffer, &buffer[sizeof(buffer)-2]); - } - - virtual int sync() - { - return overflow(EOF); - } - - virtual int underflow() - { - return EOF; - } - - virtual int overflow(int c) - { - const char *fmt = "%s"; - char *func = NULL; - - int bufSize = pptr() - pbase(); - - if (c != EOF) { - *pptr() = (char)c; - bufSize++; - } - - if (bufSize != 0) { - char *bufPtr = pbase(); - char *bufEndPtr = NULL; - setp(bufPtr, epptr()); - bufPtr[bufSize] = '\0'; - int line = 0; - char *p; - - char *file = NULL; - switch_log_level_t level; - - - switch (strtoul(bufPtr, &file, 10)) { - case 1 : - level = SWITCH_LOG_INFO; - break; - default : - level = SWITCH_LOG_DEBUG; - break; - } - - if (file) { - while (isspace(*file)) file++; - - if (file && (bufPtr = strchr(file, '(')) && (bufEndPtr = strchr(bufPtr, ')'))) { - char *e; - - for(p = bufPtr; p && *p; p++) { - if (*p == '\t') { - *p = ' '; - } - } - - *bufPtr++ = '\0'; - line = atoi(bufPtr); - while (bufEndPtr && isspace(*(++bufEndPtr))); - bufPtr = bufEndPtr; - if (bufPtr && ((e = strchr(bufPtr, ' ')) || (e = strchr(bufPtr, '\t')))) { - func = bufPtr; - bufPtr = e; - *bufPtr++ = '\0'; - } - } - } - - switch_text_channel_t tchannel = SWITCH_CHANNEL_ID_LOG; - - if (!bufPtr) { - bufPtr = pbase(); - level = SWITCH_LOG_DEBUG; - } - - if (bufPtr) { - if (end_of(bufPtr) != '\n') { - fmt = "%s\n"; - } - if (!(file && func && line)) tchannel = SWITCH_CHANNEL_ID_LOG_CLEAN; - - switch_log_printf(tchannel, file, func, line, NULL, level, fmt, bufPtr); - } - - } - - return 0; - } - } buffer; -}; - -#endif - - -/////////////////////////////////////////////////////////////////////// - -FSProcess::FSProcess() - : PLibraryProcess("Vox Lucida Pty. Ltd.", "mod_opal", 1, 0, AlphaCode, 1) - , m_manager(NULL) -{ -} - - -FSProcess::~FSProcess() -{ - delete m_manager; -} - - -bool FSProcess::Initialise(switch_loadable_module_interface_t *iface) -{ - m_manager = new FSManager(); - return m_manager != NULL && m_manager->Initialise(iface); -} - - -/////////////////////////////////////////////////////////////////////// - -FSManager::FSManager() -{ - // These are deleted by the OpalManager class, no need to have destructor - m_h323ep = new H323EndPoint(*this); - m_iaxep = new IAX2EndPoint(*this); - m_fsep = new FSEndPoint(*this); -} - - -bool FSManager::Initialise(switch_loadable_module_interface_t *iface) -{ - ReadConfig(false); - -#if PTRACING - PTrace::SetLevel(mod_opal_globals.trace_level); //just for fun and eyecandy ;) - PTrace::SetOptions(PTrace::TraceLevel); - PTrace::SetStream(new FSTrace); -#endif - - m_FreeSwitch = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(iface, SWITCH_ENDPOINT_INTERFACE); - m_FreeSwitch->interface_name = ModuleName; - m_FreeSwitch->io_routines = &opalfs_io_routines; - m_FreeSwitch->state_handler = &opalfs_event_handlers; - - silenceDetectParams.m_mode = OpalSilenceDetector::NoSilenceDetection; - - if (m_listeners.empty()) { - m_h323ep->StartListener(""); - } else { - for (std::list < FSListener >::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) { - if (!m_h323ep->StartListener(it->listenAddress)) { - PTRACE(3, "mod_opal\tCannot start listener for " << it->name); - } - } - } - - AddRouteEntry("h323:.* = local:"); // config option for direct routing - AddRouteEntry("iax2:.* = local:"); // config option for direct routing - AddRouteEntry("local:.* = h323:"); // config option for direct routing - - // Make sure all known codecs are instantiated, - // these are ones we know how to translate into H.323 capabilities - GetOpalG728(); - GetOpalG729(); - GetOpalG729A(); - GetOpalG729B(); - GetOpalG729AB(); - GetOpalG7231_6k3(); - GetOpalG7231_5k3(); - GetOpalG7231A_6k3(); - GetOpalG7231A_5k3(); - GetOpalGSM0610(); - GetOpalGSMAMR(); - GetOpaliLBC(); - - /* For compatibility with the algorithm in FSConnection::SetCodecs() we need - to set all audio media formats to be 1 frame per packet */ - OpalMediaFormatList allCodecs = OpalMediaFormat::GetAllRegisteredMediaFormats(); - for (OpalMediaFormatList::iterator it = allCodecs.begin(); it != allCodecs.end(); ++it) { - if (it->GetMediaType() == OpalMediaType::Audio()) { - it->SetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption(), 1); - it->SetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption(), 1); - } - } - - if (!m_gkAddress.IsEmpty()) { - if (m_h323ep->UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface)) - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Started gatekeeper: %s\n", - (const char *)m_h323ep->GetGatekeeper()->GetName()); - else - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Could not start gatekeeper: addr=\"%s\", id=\"%s\", if=\"%s\"\n", - (const char *)m_gkAddress, - (const char *)m_gkIdentifer, - (const char *)m_gkInterface); - } - - return TRUE; -} - - -switch_status_t FSManager::ReadConfig(int reload) -{ - const char *cf = "opal.conf"; - switch_status_t status = SWITCH_STATUS_SUCCESS; - - switch_memory_pool_t *pool = NULL; - if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); - return status; - } - - set_global_context("default"); - set_global_dialplan("XML"); - - switch_event_t *params = NULL; - switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); - switch_assert(params); - switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", switch_str_nil("")); - switch_xml_t cfg; - switch_xml_t xml = switch_xml_open_cfg(cf, &cfg, params); - if (xml == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); - return SWITCH_STATUS_FALSE; - } - - switch_xml_t xmlSettings = switch_xml_child(cfg, "settings"); - if (xmlSettings) { - for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) { - const char *var = switch_xml_attr_soft(xmlParam, "name"); - const char *val = switch_xml_attr_soft(xmlParam, "value"); - - if (!strcasecmp(var, "trace-level")) { - int level = atoi(val); - if (level > 0) { - mod_opal_globals.trace_level = level; - } - } else if (!strcasecmp(var, "context")) { - set_global_context(val); - } else if (!strcasecmp(var, "dialplan")) { - set_global_dialplan(val); - } else if (!strcasecmp(var, "codec-prefs")) { - set_global_codec_string(val); - } else if (!strcasecmp(var, "jitter-size")) { - char * next; - unsigned minJitter = strtoul(val, &next, 10); - if (minJitter >= 10) { - unsigned maxJitter = minJitter; - if (*next == ',') - maxJitter = atoi(next+1); - SetAudioJitterDelay(minJitter, maxJitter); // In milliseconds - } - } else if (!strcasecmp(var, "gk-address")) { - m_gkAddress = val; - } else if (!strcasecmp(var, "gk-identifer")) { - m_gkIdentifer = val; - } else if (!strcasecmp(var, "gk-interface")) { - m_gkInterface = val; - } - } - } - - switch_xml_t xmlListeners = switch_xml_child(cfg, "listeners"); - if (xmlListeners != NULL) { - for (switch_xml_t xmlListener = switch_xml_child(xmlListeners, "listener"); xmlListener != NULL; xmlListener = xmlListener->next) { - - m_listeners.push_back(FSListener()); - FSListener & listener = m_listeners.back(); - - listener.name = switch_xml_attr_soft(xmlListener, "name"); - if (listener.name.IsEmpty()) - listener.name = "unnamed"; - - PIPSocket::Address ip; - WORD port = 1720; - - for (switch_xml_t xmlParam = switch_xml_child(xmlListener, "param"); xmlParam != NULL; xmlParam = xmlParam->next) { - const char *var = switch_xml_attr_soft(xmlParam, "name"); - const char *val = switch_xml_attr_soft(xmlParam, "value"); - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Var - '%s' and Val - '%s' \n", var, val); - if (!strcasecmp(var, "h323-ip")) - ip = val; - else if (!strcasecmp(var, "h323-port")) - port = (WORD) atoi(val); - } - - listener.listenAddress = OpalTransportAddress(ip, port); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Listener '%s'\n", (const char *) listener.name); - } - } - - switch_event_destroy(¶ms); - - if (xml) - switch_xml_free(xml); - - return status; -} - - -OpalCall * FSManager::CreateCall(void * /*userData*/) -{ - return new FSCall(*this); -} - - -/////////////////////////////////////////////////////////////////////// - -FSEndPoint::FSEndPoint(FSManager & manager) -: OpalLocalEndPoint(manager) -{ - PTRACE(3, "mod_opal\t FSEndPoint Created!"); -} - - -bool FSEndPoint::OnIncomingCall(OpalLocalConnection & connection) -{ - return ((FSConnection &) connection).OnIncoming(); -} - - -OpalLocalConnection *FSEndPoint::CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions* stringOptions) -{ - FSManager & mgr = (FSManager &) GetManager(); - switch_core_session_t *fsSession = switch_core_session_request(mgr.GetSwitchInterface(), - (switch_caller_profile_t *)userData ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL); - if (fsSession == NULL) - return NULL; - - switch_channel_t *fsChannel = switch_core_session_get_channel(fsSession); - - if (fsChannel == NULL) { - switch_core_session_destroy(&fsSession); - return NULL; - } - - return new FSConnection(call, *this, userData, options, stringOptions, (switch_caller_profile_t *)userData, fsSession, fsChannel); -} - - -/////////////////////////////////////////////////////////////////////// - -FSCall::FSCall(OpalManager & manager) - : OpalCall(manager) -{ -} - - -PBoolean FSCall::OnSetUp(OpalConnection & connection) -{ - // Transfer FS caller_id_number & caller_id_name from the FSConnection - // to the protocol connectionm (e.g. H.323) so gets sent correctly - // in outgoing packets - PSafePtr local = GetConnectionAs(); - if (local != NULL) { - PSafePtr proto = local->GetOtherPartyConnection(); - if (proto != NULL) { - proto->SetLocalPartyName(local->GetLocalPartyName()); - proto->SetDisplayName(local->GetDisplayName()); - } - } - - return OpalCall::OnSetUp(connection); -} - - -/////////////////////////////////////////////////////////////////////// - - -FSConnection::FSConnection(OpalCall & call, FSEndPoint & endpoint, void* userData, unsigned options, OpalConnection::StringOptions* stringOptions, switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel) - : OpalLocalConnection(call, endpoint, userData, options, stringOptions) - , m_endpoint(endpoint) - , m_fsSession(fsSession) - , m_fsChannel(fsChannel) -{ - opal_private_t *tech_pvt; - - tech_pvt = (opal_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt)); - tech_pvt->me = this; - switch_core_session_set_private(m_fsSession, tech_pvt); - - if (outbound_profile != NULL) { - SetLocalPartyName(outbound_profile->caller_id_number); - SetDisplayName(outbound_profile->caller_id_name); - - switch_caller_profile_t *caller_profile = switch_caller_profile_clone(m_fsSession, outbound_profile); - switch_channel_set_caller_profile(m_fsChannel, caller_profile); - - PString name = "opal/"; - name += outbound_profile->destination_number; - switch_channel_set_name(m_fsChannel, name); - - switch_channel_set_state(m_fsChannel, CS_INIT); - } -} - - -bool FSConnection::OnIncoming() -{ - if (m_fsSession == NULL) { - PTRACE(1, "mod_opal\tSession request failed."); - return false; - } - - switch_core_session_add_stream(m_fsSession, NULL); - - switch_channel_t *channel = switch_core_session_get_channel(m_fsSession); - if (channel == NULL) { - PTRACE(1, "mod_opal\tSession does not have a channel"); - return false; - } - - PURL url = GetRemotePartyURL(); - switch_caller_profile_t *caller_profile = switch_caller_profile_new(switch_core_session_get_pool(m_fsSession), - url.GetUserName(), - /** username */ - mod_opal_globals.dialplan, - /** dial plan */ - GetRemotePartyName(), - /** caller_id_name */ - GetRemotePartyNumber(), - /** caller_id_number */ - url.GetHostName(), - /** network addr */ - NULL, - /** ANI */ - NULL, - /** ANI II */ - NULL, - /** RDNIS */ - ModuleName, - /** source */ - mod_opal_globals.context, - /** set context */ - GetCalledPartyNumber() - /** destination_number */ - ); - if (caller_profile == NULL) { - PTRACE(1, "mod_opal\tCould not create caller profile"); - return false; - } - - PTRACE(4, "mod_opal\tCreated switch caller profile:\n" - " username = " << caller_profile->username << "\n" - " dialplan = " << caller_profile->dialplan << "\n" - " caller_id_name = " << caller_profile->caller_id_name << "\n" - " caller_id_number = " << caller_profile->caller_id_number << "\n" - " network_addr = " << caller_profile->network_addr << "\n" - " source = " << caller_profile->source << "\n" - " context = " << caller_profile->context << "\n" " destination_number= " << caller_profile->destination_number); - switch_channel_set_caller_profile(channel, caller_profile); - - char name[256] = "opal/in:"; - switch_copy_string(name + 8, caller_profile->destination_number, sizeof(name)-8); - switch_channel_set_name(channel, name); - switch_channel_set_state(channel, CS_INIT); - - if (switch_core_session_thread_launch(m_fsSession) != SWITCH_STATUS_SUCCESS) { - PTRACE(1, "mod_opal\tCould not launch session thread"); - return false; - } - - return true; -} - - -void FSConnection::OnReleased() -{ - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(m_fsSession); - - /* so FS on_hangup will not try to deref a landmine */ - tech_pvt->me = NULL; - - m_rxAudioOpened.Signal(); // Just in case - m_txAudioOpened.Signal(); - H225_ReleaseCompleteReason dummy; - switch_channel_hangup(switch_core_session_get_channel(m_fsSession), - (switch_call_cause_t)H323TranslateFromCallEndReason(GetCallEndReason(), dummy)); - OpalLocalConnection::OnReleased(); -} - - -void FSConnection::OnAlerting() -{ - switch_channel_mark_ring_ready(m_fsChannel); - return OpalLocalConnection::OnAlerting(); -} - -PBoolean FSConnection::SetAlerting(const PString & calleeName, PBoolean withMedia) -{ - return OpalLocalConnection::SetAlerting(calleeName, withMedia); -} - - -void FSConnection::OnEstablished() -{ - OpalLocalConnection::OnEstablished(); -} - - -PBoolean FSConnection::SendUserInputTone(char tone, unsigned duration) -{ - switch_dtmf_t dtmf = { tone, duration }; - return switch_channel_queue_dtmf(m_fsChannel, &dtmf) == SWITCH_STATUS_SUCCESS; -} - - -PBoolean FSConnection::SendUserInputString(const PString & value) -{ - return OpalConnection::SendUserInputString(value); -} - - -OpalMediaFormatList FSConnection::GetMediaFormats() const -{ - if (m_switchMediaFormats.IsEmpty()) { - const_cast(this)->SetCodecs(); - } - - return m_switchMediaFormats; -} - - -void FSConnection::SetCodecs() -{ - int numCodecs = 0; - const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS]; - const char *codec_string = NULL, *abs, *ocodec; - char *tmp_codec_string = NULL; - char *codec_order[SWITCH_MAX_CODECS]; - int codec_order_last; - - - if ((abs = switch_channel_get_variable(m_fsChannel, "absolute_codec_string"))) { - codec_string = abs; - } else { - if ((abs = switch_channel_get_variable(m_fsChannel, "codec_string"))) { - codec_string = abs; - } - - if ((ocodec = switch_channel_get_variable(m_fsChannel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) { - codec_string = switch_core_session_sprintf(m_fsSession, "%s,%s", ocodec, codec_string); - } - } - - if (!codec_string) { - codec_string = mod_opal_globals.codec_string; - } - - if (codec_string) { - if ((tmp_codec_string = strdup(codec_string))) { - codec_order_last = switch_separate_string(tmp_codec_string, ',', codec_order, SWITCH_MAX_CODECS); - numCodecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, codec_order, codec_order_last); - - } - } else { - numCodecs = switch_loadable_module_get_codecs(codecs, sizeof(codecs) / sizeof(codecs[0])); - } - - for (int i = 0; i < numCodecs; i++) { - const switch_codec_implementation_t *codec = codecs[i]; - - // See if we have a match by PayloadType/rate/name - OpalMediaFormat switchFormat((RTP_DataFrame::PayloadTypes)codec->ianacode, - codec->samples_per_second, - codec->iananame); - if (!switchFormat.IsValid()) { - // See if we have a match by name alone - switchFormat = codec->iananame; - if (!switchFormat.IsValid()) { - PTRACE(2, "mod_opal\tCould not match FS codec " << codec->iananame << " to OPAL media format."); - continue; - } - } - - - // Did we match or create a new media format? - if (switchFormat.IsValid() && codec->codec_type == SWITCH_CODEC_TYPE_AUDIO) { - PTRACE(2, "mod_opal\tMatched FS codec " << codec->iananame << " to OPAL media format " << switchFormat); - - // Calculate frames per packet, do not use codec->codec_frames_per_packet as that field - // has slightly different semantics when used in streamed codecs such as G.711 - int fpp = codec->samples_per_packet/switchFormat.GetFrameTime(); - - /* Set the frames/packet to maximum of what is in the FS table. The OPAL negotiations will - drop the value from there. This might fail if there are "holes" in the FS table, e.g. - if for some reason G.723.1 has 30ms and 90ms but not 60ms, then the OPAL negotiations - could end up with 60ms and the codec cannot be created. The "holes" are unlikely in - all but streamed codecs such as G.711, where it is theoretically possible for OPAL to - come up with 32ms and there is only 30ms and 40ms in the FS table. We deem these - scenarios succifiently rare that we can safely ignore them ... for now. */ - - if (fpp > switchFormat.GetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption())) { - switchFormat.SetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption(), fpp); - } - - if (fpp > switchFormat.GetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption())) { - switchFormat.SetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption(), fpp); - } - } - - m_switchMediaFormats += switchFormat; - } - - switch_safe_free(tmp_codec_string); -} - - -OpalMediaStream *FSConnection::CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource) -{ - return new FSMediaStream(*this, mediaFormat, sessionID, isSource); -} - - -PBoolean FSConnection::OnOpenMediaStream(OpalMediaStream & stream) -{ - if (!OpalConnection::OnOpenMediaStream(stream)) { - return false; - } - - if (stream.GetMediaFormat().GetMediaType() != OpalMediaType::Audio()) { - return true; - } - - if (stream.IsSource()) { - m_rxAudioOpened.Signal(); - } else { - m_txAudioOpened.Signal(); - } - - if (GetMediaStream(stream.GetSessionID(), stream.IsSink()) != NULL) { - // Have open media in both directions. - if (GetPhase() == AlertingPhase) { - switch_channel_mark_pre_answered(m_fsChannel); - } else if (GetPhase() < ReleasingPhase) { - switch_channel_mark_answered(m_fsChannel); - } - } - - return true; -} - - -switch_status_t FSConnection::on_init() -{ - switch_channel_t *channel = switch_core_session_get_channel(m_fsSession); - if (channel == NULL) { - return SWITCH_STATUS_FALSE; - } - - PTRACE(3, "mod_opal\tStarted routing for connection " << *this); - switch_channel_set_state(channel, CS_ROUTING); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::on_routing() -{ - PTRACE(3, "mod_opal\tRouting connection " << *this); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::on_execute() -{ - PTRACE(3, "mod_opal\tExecuting connection " << *this); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t on_destroy(switch_core_session_t *session) -{ - //switch_channel_t *channel = switch_core_session_get_channel(session); - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); - - if (tech_pvt) { - if (tech_pvt->read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - if (tech_pvt->vid_read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->vid_read_codec); - } - - if (tech_pvt->vid_write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->vid_write_codec); - } - - if (tech_pvt->read_timer.timer_interface) { - switch_core_timer_destroy(&tech_pvt->read_timer); - } - - if (tech_pvt->vid_read_timer.timer_interface) { - switch_core_timer_destroy(&tech_pvt->vid_read_timer); - } - } - - return SWITCH_STATUS_SUCCESS; -} - -/* this function has to be called with the original session beause the FSConnection might already be destroyed and we - will can't have it be a method of a dead object - */ -static switch_status_t on_hangup(switch_core_session_t *session) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); - - /* if this is still here it was our idea to hangup not opal's */ - if (tech_pvt->me) { - Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel); - tech_pvt->me->SetQ931Cause(cause); - tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX)); - tech_pvt->me = NULL; - } - - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::on_exchange_media() -{ - PTRACE(3, "mod_opal\tLoopback on connection " << *this); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::on_soft_execute() -{ - PTRACE(3, "mod_opal\tTransmit on connection " << *this); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::kill_channel(int sig) -{ - PTRACE(3, "mod_opal\tKill " << sig << " on connection " << *this); - - switch (sig) { - case SWITCH_SIG_BREAK: - break; - case SWITCH_SIG_KILL: - m_rxAudioOpened.Signal(); - m_txAudioOpened.Signal(); - break; - default: - break; - } - - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::send_dtmf(const switch_dtmf_t *dtmf) -{ - OnUserInputTone(dtmf->digit, dtmf->duration); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::receive_message(switch_core_session_message_t *msg) -{ - switch_channel_t *channel = switch_core_session_get_channel(m_fsSession); - - - /* - SWITCH_MESSAGE_INDICATE_PROGRESS: establish early media now and return SWITCH_STATUS_FALSE if you can't - SWITCH_MESSAGE_INDICATE_ANSWER: answer and set up media now if it's not already and return SWITCH_STATUS_FALSE if you can't - - Neither message means anything on an outbound call.... - - It would only happen if someone called switch_channel_answer() instead of switch_channel_mark_answered() on an outbound call. - it should not do anything if someone does it by accident somewhere hense this in both cases: - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - return SWITCH_STATUS_FALSE; - } - - - When we get these messages the core will trust that you have triggered FSMediaStream::Open and are ready for media if we do not - have media we MUST return SWITCH_STATUS_FALSE or it will cause a CRASH. - - - - */ - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_BRIDGE: - case SWITCH_MESSAGE_INDICATE_UNBRIDGE: - case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: - switch_channel_set_private_flag(channel, CF_NEED_FLUSH); - break; - - case SWITCH_MESSAGE_INDICATE_RINGING: - case SWITCH_MESSAGE_INDICATE_PROGRESS: - case SWITCH_MESSAGE_INDICATE_ANSWER: - { - switch_caller_profile_t * profile = switch_channel_get_caller_profile(channel); - if (profile != NULL && profile->caller_extension != NULL) - { - PSafePtr other = GetOtherPartyConnection(); - if (other != NULL) { - other->SetLocalPartyName(profile->caller_extension->extension_number); - other->SetDisplayName(profile->caller_extension->extension_name); - } - SetLocalPartyName(profile->caller_extension->extension_number); - SetDisplayName(profile->caller_extension->extension_name); - } - } - break; - - default: - break; - } - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_RINGING: - SetPhase(OpalConnection::AlertingPhase); - OnAlerting(); - break; - - case SWITCH_MESSAGE_INDICATE_DEFLECT: - { - PSafePtr other = GetOtherPartyConnection(); - if (other != NULL) - other->TransferConnection(msg->string_arg); - break; - } - - case SWITCH_MESSAGE_INDICATE_PROGRESS: - case SWITCH_MESSAGE_INDICATE_ANSWER: - { - int fixed = 0; - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - return SWITCH_STATUS_FALSE; - } - - if (msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) { - if (fixed) { - /* this should send alerting + media and wait for it to be established and return SUCCESS or FAIL - depending on if media was able to be established. Need code to tell the other side we want early media here. - */ - GetCall().OpenSourceMediaStreams(*this, OpalMediaType::Audio()); - SetPhase(OpalConnection::AlertingPhase); - /* how do i say please establish early media ? */ - OnAlerting(); - } else { - /* hack to avoid getting stuck, pre_answer will imply answer */ - OnConnectedInternal(); - } - } else { - OnConnectedInternal(); - } - - // Wait for media - PTRACE(2, "mod_opal\tAwaiting media start on connection " << *this); - m_rxAudioOpened.Wait(); - m_txAudioOpened.Wait(); - - if (GetPhase() >= ReleasingPhase) { - // Call got aborted - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_fsSession), SWITCH_LOG_ERROR, "Call abandoned!\n"); - return SWITCH_STATUS_FALSE; - } - - PTRACE(4, "mod_opal\tMedia started on connection " << *this); - - if (msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) { - if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) { - switch_channel_mark_pre_answered(m_fsChannel); - } - } else { - if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) { - switch_channel_mark_answered(m_fsChannel); - } - } - - } - break; - - default: - PTRACE(3, "mod_opal\tReceived message " << msg->message_id << " on connection " << *this); - } - - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::receive_event(switch_event_t *event) -{ - PTRACE(3, "mod_opal\tReceived event " << event->event_id << " on connection " << *this); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::state_change() -{ - PTRACE(3, "mod_opal\tState changed on connection " << *this); - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSConnection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id) -{ - return read_frame(OpalMediaType::Audio(), frame, flags); -} - - -switch_status_t FSConnection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id) -{ - return write_frame(OpalMediaType::Audio(), frame, flags); -} - - -switch_status_t FSConnection::read_video_frame(switch_frame_t **frame, switch_io_flag_t flag, int stream_id) -{ - return read_frame(OpalMediaType::Video(), frame, flag); -} - - -switch_status_t FSConnection::write_video_frame(switch_frame_t *frame, switch_io_flag_t flag, int stream_id) -{ - return write_frame(OpalMediaType::Video(), frame, flag); -} - - -switch_status_t FSConnection::read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags) -{ - PSafePtr < FSMediaStream > stream = PSafePtrCast < OpalMediaStream, FSMediaStream > (GetMediaStream(mediaType, false)); - return stream != NULL ? stream->read_frame(frame, flags) : SWITCH_STATUS_FALSE; -} - - -switch_status_t FSConnection::write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags) -{ - PSafePtr < FSMediaStream > stream = PSafePtrCast < OpalMediaStream, FSMediaStream > (GetMediaStream(mediaType, true)); - return stream != NULL ? stream->write_frame(frame, flags) : SWITCH_STATUS_FALSE; -} - - -/////////////////////////////////////////////////////////////////////// - -FSMediaStream::FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, unsigned sessionID, bool isSource) - : OpalMediaStream(conn, mediaFormat, sessionID, isSource) - , m_fsSession(conn.GetSession()) - , m_readRTP(0, 512) - , m_callOnStart(true) -{ - memset(&m_readFrame, 0, sizeof(m_readFrame)); - m_readFrame.codec = m_switchCodec; - m_readFrame.flags = SFF_RAW_RTP; -} - - -PBoolean FSMediaStream::Open() -{ - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(m_fsSession); - - if (IsOpen()) { - return true; - } - - bool isAudio; - if (mediaFormat.GetMediaType() == OpalMediaType::Audio()) { - isAudio = true; - } else if (mediaFormat.GetMediaType() == OpalMediaType::Video()) { - isAudio = false; - } else { - return OpalMediaStream::Open(); - } - - m_fsChannel = switch_core_session_get_channel(m_fsSession); - - int ptime = mediaFormat.GetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption()) * mediaFormat.GetFrameTime() / mediaFormat.GetTimeUnits(); - - - if (IsSink()) { - m_switchCodec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec; - m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer; - } else { - m_switchCodec = isAudio ? &tech_pvt->write_codec : &tech_pvt->vid_write_codec; - } - - // The following is performed on two different instances of this object. - if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP - mediaFormat.GetClockRate(), ptime, 1, // Channels - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings - switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) { - // Could not select a codecs using negotiated frames/packet, so try using default. - if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP - mediaFormat.GetClockRate(), 0, 1, // Channels - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings - switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) { - PTRACE(1, "mod_opal " << switch_channel_get_name(m_fsChannel)<< " Cannot initialise " << (IsSink()? "read" : "write") << ' ' - << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); - switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); - return false; - } - PTRACE(2, "mod_opal " << switch_channel_get_name(m_fsChannel)<< " Unsupported ptime of " << ptime << " on " << (IsSink()? "read" : "write") << ' ' - << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); - } - - PTRACE(1, "mod_opal " << switch_channel_get_name(m_fsChannel)<< " initialise " << - switch_channel_get_name(m_fsChannel) << (IsSink()? "read" : "write") << ' ' - << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); - - if (IsSink()) { - m_readFrame.rate = mediaFormat.GetClockRate(); - - if (isAudio) { - switch_core_session_set_read_codec(m_fsSession, m_switchCodec); - if (switch_core_timer_init(m_switchTimer, - "soft", - m_switchCodec->implementation->microseconds_per_packet / 1000, - m_switchCodec->implementation->samples_per_packet, - switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) { - switch_core_codec_destroy(m_switchCodec); - m_switchCodec = NULL; - return false; - } - } else { - switch_core_session_set_video_read_codec(m_fsSession, m_switchCodec); - switch_channel_set_flag(m_fsChannel, CF_VIDEO); - } - } else { - if (isAudio) { - switch_core_session_set_write_codec(m_fsSession, m_switchCodec); - } else { - switch_core_session_set_video_write_codec(m_fsSession, m_switchCodec); - switch_channel_set_flag(m_fsChannel, CF_VIDEO); - } - } - - PTRACE(3, "mod_opal\tSet " << (IsSink()? "read" : "write") << ' ' - << mediaFormat.GetMediaType() << " codec to << " << mediaFormat << " for connection " << *this); - - return OpalMediaStream::Open(); -} - - -PBoolean FSMediaStream::Close() -{ - if (!IsOpen()) - return false; - - /* forget these FS will properly destroy them for us */ - - m_switchTimer = NULL; - m_switchCodec = NULL; - - return OpalMediaStream::Close(); -} - - -PBoolean FSMediaStream::IsSynchronous() const -{ - return true; -} - - -PBoolean FSMediaStream::RequiresPatchThread(OpalMediaStream *) const -{ - return false; -} - -bool FSMediaStream::CheckPatchAndLock() -{ - if (GetConnection().GetPhase() >= GetConnection().ReleasingPhase || !IsOpen()) - return false; - - if (LockReadWrite()) { - if (!GetPatch() || !IsOpen()) { - UnlockReadWrite(); - return false; - } - return true; - } else { - return false; - } -} - -switch_status_t FSMediaStream::read_frame(switch_frame_t **frame, switch_io_flag_t flags) -{ - - if (!m_switchCodec) { - return SWITCH_STATUS_FALSE; - } - - if (m_callOnStart) { - /* - There is a race here... sometimes we make it here and GetPatch() is NULL - if we wait it shows up in 1ms, maybe there is a better way to wait. - - */ - while(!GetPatch()) { - if (!m_fsChannel || !switch_channel_up(m_fsChannel)) { - return SWITCH_STATUS_FALSE; - } - switch_cond_next(); - } - if (CheckPatchAndLock()) { - GetPatch()->OnStartMediaPatch(); - m_callOnStart = false; - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - } - - m_readFrame.flags = 0; - - /* - while (switch_channel_ready(m_fsChannel)) { - if (CheckPatchAndLock()) { - if (!GetPatch()->GetSource().ReadPacket(m_readRTP)) { - UnlockReadWrite(); - return SWITCH_STATUS_FALSE; - } - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - - if ((m_readFrame.datalen = m_readRTP.GetPayloadSize()) || switch_core_timer_check(&m_switchTimer, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { - if (m_readFrame.datalen) { - } else { - m_readFrame.flags = SFF_CNG; - } - break; - } - - switch_yield(1000); - } - */ - - if (switch_channel_test_private_flag(m_fsChannel, CF_NEED_FLUSH)) { - switch_channel_clear_private_flag(m_fsChannel, CF_NEED_FLUSH); - for(;;) { - if (CheckPatchAndLock()) { - if (!GetPatch()->GetSource().ReadPacket(m_readRTP)) { - UnlockReadWrite(); - return SWITCH_STATUS_FALSE; - } - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - - if (!m_readRTP.GetPayloadSize()) { - m_readFrame.flags = SFF_CNG; - break; - } - } - } else { - - if (CheckPatchAndLock()) { - if (!m_switchTimer || !GetPatch()->GetSource().ReadPacket(m_readRTP)) { - UnlockReadWrite(); - return SWITCH_STATUS_FALSE; - } - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - - switch_core_timer_next(m_switchTimer); - - if (!(m_readFrame.datalen = m_readRTP.GetPayloadSize())) { - m_readFrame.flags = SFF_CNG; - } - } - - if (!switch_channel_ready(m_fsChannel)) { - return SWITCH_STATUS_FALSE; - } - - if (!switch_core_codec_ready(m_switchCodec)) { - return SWITCH_STATUS_FALSE; - } - - //switch_core_timer_step(&m_switchTimer); - - if (m_readFrame.payload == RTP_DataFrame::CN || m_readFrame.payload == RTP_DataFrame::Cisco_CN) { - m_readFrame.flags = SFF_CNG; - } - - if (m_readFrame.flags & SFF_CNG) { - m_readFrame.buflen = sizeof(m_buf); - m_readFrame.data = m_buf; - m_readFrame.packet = NULL; - m_readFrame.packetlen = 0; - m_readFrame.timestamp = 0; - m_readFrame.m = SWITCH_FALSE; - m_readFrame.seq = 0; - m_readFrame.ssrc = 0; - m_readFrame.codec = m_switchCodec; - } else { - m_readFrame.buflen = m_readRTP.GetSize(); - m_readFrame.data = m_readRTP.GetPayloadPtr(); - m_readFrame.packet = m_readRTP.GetPointer(); - m_readFrame.packetlen = m_readRTP.GetHeaderSize() + m_readFrame.datalen; - m_readFrame.payload = (switch_payload_t) m_readRTP.GetPayloadType(); - m_readFrame.timestamp = m_readRTP.GetTimestamp(); - m_readFrame.m = (switch_bool_t) m_readRTP.GetMarker(); - m_readFrame.seq = m_readRTP.GetSequenceNumber(); - m_readFrame.ssrc = m_readRTP.GetSyncSource(); - m_readFrame.codec = m_switchCodec; - } - - *frame = &m_readFrame; - - return SWITCH_STATUS_SUCCESS; -} - - -switch_status_t FSMediaStream::write_frame(const switch_frame_t *frame, switch_io_flag_t flags) -{ - if (!switch_channel_ready(m_fsChannel)) { - return SWITCH_STATUS_FALSE; - } - - if (m_callOnStart) { - if (CheckPatchAndLock()) { - GetPatch()->OnStartMediaPatch(); - m_callOnStart = false; - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - } - - if ((frame->flags & SFF_CNG)) { - return SWITCH_STATUS_SUCCESS; - } - - if ((frame->flags & SFF_RAW_RTP) != 0) { - RTP_DataFrame rtp((const BYTE *) frame->packet, frame->packetlen, false); - - if (CheckPatchAndLock()) { - if (GetPatch()->PushFrame(rtp)) { - UnlockReadWrite(); - return SWITCH_STATUS_SUCCESS; - } - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - } - - /* If we reach this code it means a call to an ivr or something else that does not generate timestamps - Its possible that frame->timestamp is set but not guarenteed and is best ignored for the time being. - We are probably relying on the rtp stack to generate the timestamp and ssrc for us at this point. - As a quick hack I am going to keep a sample counter and increment it by frame->samples but it would be - better if we could engage whatever it is in opal that makes it generate the timestamp. - */ - - RTP_DataFrame rtp(frame->datalen); - rtp.SetPayloadType(mediaFormat.GetPayloadType()); - - m_timeStamp += frame->samples; - rtp.SetTimestamp(m_timeStamp); - - //rtp.SetTimestamp(frame->timestamp); - //rtp.SetSyncSource(frame->ssrc); - //rtp.SetMarker(frame->m); - - memcpy(rtp.GetPayloadPtr(), frame->data, frame->datalen); - - if (CheckPatchAndLock()) { - if (GetPatch()->PushFrame(rtp)) { - UnlockReadWrite(); - return SWITCH_STATUS_SUCCESS; - } - UnlockReadWrite(); - } else { - return SWITCH_STATUS_FALSE; - } - - - return SWITCH_STATUS_FALSE; -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:nil - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4:s: - */ +/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library / + * Soft-Switch Application + * + * Version: MPL 1.1 + * + * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com) + * Copyright (c) 2008-2012 Vox Lucida Pty. Ltd. (robertj@voxlucida.com.au) + * + * 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. + * + * Contributor(s): + * Tuyan Ozipek (tuyanozipek@gmail.com) + * Lukasz Zwierko (lzwierko@gmail.com) + * Robert Jongbloed (robertj@voxlucida.com.au) + * + */ + +#include "mod_opal.h" +#include +#include +#include +#include + + +/* FreeSWITCH does not correctly handle an H.323 subtely, that is that a + MAXIMUM audio frames per packet is nototiated, and there is no + requirement for the remote to actually send that many. So, in say GSM, we + negotiate up to 3 frames or 60ms of data and the remote actually sends one + (20ms) frame per packet. Perfectly legal but blows up the media handling + in FS. + + Eventually we will get around to bundling the packets, but not yet. This + compile flag will just force one frame/packet for all audio codecs. + */ +#define IMPLEMENT_MULTI_FAME_AUDIO 0 + + +static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session, + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, + switch_memory_pool_t **pool, + switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); + + +static FSProcess *opal_process = NULL; + + +static PConstString const ModuleName("opal"); +static char const ConfigFile[] = "opal.conf"; + + +static switch_io_routines_t opalfs_io_routines = { + /*.outgoing_channel */ create_outgoing_channel, + /*.read_frame */ FSConnection::read_audio_frame, + /*.write_frame */ FSConnection::write_audio_frame, + /*.kill_channel */ FSConnection::kill_channel, + /*.send_dtmf */ FSConnection::send_dtmf, + /*.receive_message */ FSConnection::receive_message, + /*.receive_event */ FSConnection::receive_event, + /*.state_change */ FSConnection::state_change, + /*.read_video_frame */ FSConnection::read_video_frame, + /*.write_video_frame */ FSConnection::write_video_frame +}; + +static switch_state_handler_table_t opalfs_event_handlers = { + /*.on_init */ FSConnection::on_init, + /*.on_routing */ FSConnection::on_routing, + /*.on_execute */ FSConnection::on_execute, + /*.on_hangup */ FSConnection::on_hangup, + /*.on_exchange_media */ FSConnection::on_exchange_media, + /*.on_soft_execute */ FSConnection::on_soft_execute, + /*.on_consume_media*/ NULL, + /*.on_hibernate*/ NULL, + /*.on_reset*/ NULL, + /*.on_park*/ NULL, + /*.on_reporting*/ NULL, + /*.on_destroy*/ FSConnection::on_destroy +}; + + +SWITCH_BEGIN_EXTERN_C +/*******************************************************************************/ + +SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load); +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown); +SWITCH_MODULE_DEFINITION(mod_opal, mod_opal_load, mod_opal_shutdown, NULL); + +SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load) +{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting loading mod_opal\n"); + + /* Prevent the loading of OPAL codecs via "plug ins", this is a directory + full of DLLs that will be loaded automatically. */ + putenv((char *)"PTLIBPLUGINDIR=/no/thanks"); + + + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + if (!*module_interface) { + return SWITCH_STATUS_MEMERR; + } + + opal_process = new FSProcess(); + if (opal_process == NULL) { + return SWITCH_STATUS_MEMERR; + } + + if (opal_process->Initialise(*module_interface)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initialized and running\n"); + //unloading causes a seg in linux + //return SWITCH_STATUS_UNLOAD; + return SWITCH_STATUS_SUCCESS; + } + + delete opal_process; + opal_process = NULL; + return SWITCH_STATUS_FALSE; +} + + +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown) +{ + delete opal_process; + opal_process = NULL; + return SWITCH_STATUS_SUCCESS; +} + +SWITCH_END_EXTERN_C +/*******************************************************************************/ + +/////////////////////////////////////////////////////////////////////// + +#if PTRACING + +class FSTrace : public std::ostream +{ +private: + class Buffer : public std::stringbuf + { + virtual int sync() + { + std::string s = str(); + if (s.empty()) + return 0; + + //Due to explicit setting of flags we know exactly what we are getting + #define THREAD_ID_INDEX 2 + #define FILE_NAME_INDEX 3 + #define FILE_LINE_INDEX 4 +#if PTLIB_CHECK_VERSION(2,11,1) + #define CONTEXT_ID_REGEX "([0-9]+|- - - - - - -)\t" + #define LOG_PRINTF_FORMAT "{%s,%s} %s" + #define FULL_TEXT_INDEX 6 +#else + #define CONTEXT_ID_REGEX + #define LOG_PRINTF_FORMAT "{%s} %s" + #define FULL_TEXT_INDEX 5 +#endif + PStringArray fields(7); + static PRegularExpression logRE("^([0-9]+)\t *(.+)\t *([^(]+)\\(([0-9]+)\\)\t"CONTEXT_ID_REGEX"(.*)", + PRegularExpression::Extended); + if (!logRE.Execute(s.c_str(), fields)) { + fields[1] = "4"; + fields[THREAD_ID_INDEX] = "unknown"; + fields[FILE_NAME_INDEX] = __FILE__; + fields[FILE_LINE_INDEX] = __LINE__; + fields[FULL_TEXT_INDEX] = s; + } + + switch_log_level_t level; + switch (fields[1].AsUnsigned()) { + case 0 : + level = SWITCH_LOG_ALERT; + break; + case 1 : + level = SWITCH_LOG_ERROR; + break; + case 2 : + level = SWITCH_LOG_WARNING; + break; + case 3 : + level = SWITCH_LOG_INFO; + break; + default : + level = SWITCH_LOG_DEBUG; + break; + } + + fields[4].Replace("\t", " ", true); +#if PTLIB_CHECK_VERSION(2,11,1) + fields[5].Replace("- - - - - - -", "-"), +#endif + switch_log_printf(SWITCH_CHANNEL_ID_LOG, + fields[FILE_NAME_INDEX], + "PTLib-OPAL", + fields[FILE_LINE_INDEX].AsUnsigned(), + NULL, + level, + LOG_PRINTF_FORMAT, + fields[THREAD_ID_INDEX].GetPointer(), +#if PTLIB_CHECK_VERSION(2,11,1) + fields[5].GetPointer(), +#endif + fields[FULL_TEXT_INDEX].GetPointer()); + + // Reset string + str(std::string()); + return 0; + } + } buffer; + +public: + FSTrace() + : ostream(&buffer) + { + } +}; + +#endif // PTRACING + + +/////////////////////////////////////////////////////////////////////// + +FSProcess::FSProcess() + : PLibraryProcess("Vox Lucida Pty. Ltd.", MODNAME, 1, 1, BetaCode, 1) + , m_manager(NULL) +{ +} + + +FSProcess::~FSProcess() +{ + delete m_manager; +#if PTRACING + PTrace::SetStream(NULL); // This will delete the FSTrace object +#endif +} + + +bool FSProcess::Initialise(switch_loadable_module_interface_t *iface) +{ + m_manager = new FSManager(); + return m_manager != NULL && m_manager->Initialise(iface); +} + + +/////////////////////////////////////////////////////////////////////// + +FSManager::FSManager() + : m_context("default") + , m_dialplan("XML") +{ + // These are deleted by the OpalManager class, no need to have destructor + m_h323ep = new H323EndPoint(*this); + m_iaxep = new IAX2EndPoint(*this); + m_fsep = new FSEndPoint(*this); +} + + +bool FSManager::Initialise(switch_loadable_module_interface_t *iface) +{ + ReadConfig(false); + + m_FreeSwitch = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(iface, SWITCH_ENDPOINT_INTERFACE); + m_FreeSwitch->interface_name = ModuleName; + m_FreeSwitch->io_routines = &opalfs_io_routines; + m_FreeSwitch->state_handler = &opalfs_event_handlers; + + silenceDetectParams.m_mode = OpalSilenceDetector::NoSilenceDetection; + + if (m_listeners.empty()) { + m_h323ep->StartListener(""); + } else { + for (std::list < FSListener >::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) { + if (!m_h323ep->StartListener(OpalTransportAddress(it->m_address, it->m_port))) { + PTRACE(2, "mod_opal\tCannot start listener for " << it->m_name); + } + } + } + + AddRouteEntry("h323:.* = local:"); // config option for direct routing + AddRouteEntry("iax2:.* = local:"); // config option for direct routing + AddRouteEntry("local:.* = h323:"); // config option for direct routing + + // Make sure all known codecs are instantiated, + // these are ones we know how to translate into H.323 capabilities + GetOpalG728(); + GetOpalG729(); + GetOpalG729A(); + GetOpalG729B(); + GetOpalG729AB(); + GetOpalG7231_6k3(); + GetOpalG7231_5k3(); + GetOpalG7231A_6k3(); + GetOpalG7231A_5k3(); + GetOpalGSM0610(); + GetOpalGSMAMR(); + GetOpaliLBC(); + +#if !IMPLEMENT_MULTI_FAME_AUDIO + OpalMediaFormatList allCodecs = OpalMediaFormat::GetAllRegisteredMediaFormats(); + for (OpalMediaFormatList::iterator it = allCodecs.begin(); it != allCodecs.end(); ++it) { + if (it->GetMediaType() == OpalMediaType::Audio()) { + it->SetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption(), 1); + it->SetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption(), 1); + OpalMediaFormat::SetRegisteredMediaFormat(*it); + } + } +#endif // IMPLEMENT_MULTI_FAME_AUDIO + + if (!m_gkAddress.IsEmpty()) { + if (m_h323ep->UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface)) + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Started gatekeeper: %s\n", + (const char *)m_h323ep->GetGatekeeper()->GetName()); + else + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Could not start gatekeeper: addr=\"%s\", id=\"%s\", if=\"%s\"\n", + (const char *)m_gkAddress, + (const char *)m_gkIdentifer, + (const char *)m_gkInterface); + } + + return TRUE; +} + + +switch_status_t FSManager::ReadConfig(int reload) +{ + switch_event_t *request_params = NULL; + switch_event_create(&request_params, SWITCH_EVENT_REQUEST_PARAMS); + switch_assert(request_params); + switch_event_add_header_string(request_params, SWITCH_STACK_BOTTOM, "profile", switch_str_nil("")); + + switch_xml_t cfg; + switch_xml_t xml = switch_xml_open_cfg(ConfigFile, &cfg, request_params); + if (xml == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", ConfigFile); + return SWITCH_STATUS_FALSE; + } + + switch_xml_t xmlSettings = switch_xml_child(cfg, "settings"); + if (xmlSettings) { + for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) { + PConstCaselessString const var(switch_xml_attr_soft(xmlParam, "name")); + PConstString const val(switch_xml_attr_soft(xmlParam, "value")); + + if (var == "context") { + m_context = val; + } else if (var == "dialplan") { + m_dialplan = val; + } else if (var == "codec-prefs") { + m_codecPrefs = val; + } else if (var == "disable-transcoding") { + m_disableTranscoding = switch_true(val); + } else if (var == "jitter-size") { + SetAudioJitterDelay(val.AsUnsigned(), val.Mid(val.Find(',')+1).AsUnsigned()); // In milliseconds + } else if (var == "gk-address") { + m_gkAddress = val; + } else if (var == "gk-identifer") { + m_gkIdentifer = val; + } else if (var == "gk-interface") { + m_gkInterface = val; +#if PTRACING + } else if (var == "trace-level") { + unsigned level = val.AsUnsigned(); + if (level > 0) { + PTrace::SetLevel(level); + PTrace::ClearOptions(0xffffffff); // Everything off + PTrace::SetOptions( // Except these + PTrace::TraceLevel|PTrace::FileAndLine|PTrace::Thread +#if PTLIB_CHECK_VERSION(2,11,1) + |PTrace::ContextIdentifier +#endif + ); + PTrace::SetStream(new FSTrace); + } +#endif + } + } + } + + switch_xml_t xmlListeners = switch_xml_child(cfg, "listeners"); + if (xmlListeners != NULL) { + for (switch_xml_t xmlListener = switch_xml_child(xmlListeners, "listener"); xmlListener != NULL; xmlListener = xmlListener->next) { + + m_listeners.push_back(FSListener()); + FSListener & listener = m_listeners.back(); + + listener.m_name = switch_xml_attr_soft(xmlListener, "name"); + if (listener.m_name.IsEmpty()) + listener.m_name = "unnamed"; + + for (switch_xml_t xmlParam = switch_xml_child(xmlListener, "param"); xmlParam != NULL; xmlParam = xmlParam->next) { + PConstCaselessString const var(switch_xml_attr_soft(xmlParam, "name")); + PConstString const val(switch_xml_attr_soft(xmlParam, "value")); + if (var == "h323-ip") + listener.m_address = val; + else if (var == "h323-port") + listener.m_port = (uint16_t)val.AsUnsigned(); + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Listener '%s'\n", (const char *) listener.m_name); + } + } + + switch_event_destroy(&request_params); + + if (xml) + switch_xml_free(xml); + + return SWITCH_STATUS_SUCCESS; +} + + +static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session, + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, + switch_memory_pool_t **pool, + switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause) +{ + if (opal_process == NULL) + return SWITCH_CAUSE_CRASH; + + FSConnection::outgoing_params params; + params.var_event = var_event; + params.outbound_profile = outbound_profile; + params.new_session = new_session; + params.pool = pool; + params.flags = flags; + params.cancel_cause = cancel_cause; + params.fail_cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT; + + if (opal_process->GetManager().SetUpCall("local:", outbound_profile->destination_number, ¶ms) != NULL) + return SWITCH_CAUSE_SUCCESS; + + if (*new_session != NULL) + switch_core_session_destroy(new_session); + return params.fail_cause; +} + + +/////////////////////////////////////////////////////////////////////// + +FSEndPoint::FSEndPoint(FSManager & manager) + : OpalLocalEndPoint(manager) + , m_manager(manager) +{ + PTRACE(4, "mod_opal\tFSEndPoint created."); +} + + +OpalLocalConnection *FSEndPoint::CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions* stringOptions) +{ + return new FSConnection(call, *this, options, stringOptions, (FSConnection::outgoing_params *)userData); +} + + +/////////////////////////////////////////////////////////////////////// + +FSConnection::FSConnection(OpalCall & call, + FSEndPoint & endpoint, + unsigned options, + OpalConnection::StringOptions* stringOptions, + outgoing_params * params) + : OpalLocalConnection(call, endpoint, NULL, options, stringOptions) + , m_endpoint(endpoint) + , m_fsSession(NULL) + , m_fsChannel(NULL) + , m_flushAudio(false) +{ + memset(&m_read_timer, 0, sizeof(m_read_timer)); + memset(&m_read_codec, 0, sizeof(m_read_codec)); + memset(&m_write_codec, 0, sizeof(m_write_codec)); + memset(&m_vid_read_timer, 0, sizeof(m_vid_read_timer)); + memset(&m_vid_read_codec, 0, sizeof(m_vid_read_codec)); + memset(&m_vid_write_codec, 0, sizeof(m_vid_write_codec)); + + if (params != NULL) { + // If we fail, this is the cause + params->fail_cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + + if ((m_fsSession = switch_core_session_request(endpoint.GetManager().GetSwitchInterface(), + SWITCH_CALL_DIRECTION_INBOUND, params->flags, params->pool)) == NULL) { + PTRACE(1, "mod_opal\tCannot create session for outgoing call."); + return; + } + } + else { + if ((m_fsSession = switch_core_session_request(endpoint.GetManager().GetSwitchInterface(), + SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) == NULL) { + PTRACE(1, "mod_opal\tCannot create session for incoming call."); + return; + } + } + + if ((m_fsChannel = switch_core_session_get_channel(m_fsSession)) == NULL) { + switch_core_session_destroy(&m_fsSession); + return; + } + + switch_core_session_set_private(m_fsSession, this); + SafeReference(); // Make sure cannot be deleted until on_destroy() + + if (params != NULL) { + switch_caller_profile_t *caller_profile = switch_caller_profile_clone(m_fsSession, params->outbound_profile); + switch_channel_set_caller_profile(m_fsChannel, caller_profile); + SetLocalPartyName(caller_profile->caller_id_number); + SetDisplayName(caller_profile->caller_id_name); + + *params->new_session = m_fsSession; + } + + switch_channel_set_state(m_fsChannel, CS_INIT); +} + + +bool FSConnection::OnOutgoingSetUp() +{ + if (m_fsSession == NULL || m_fsChannel == NULL) { + PTRACE(1, "mod_opal\tSession request failed."); + return false; + } + + // Transfer FS caller_id_number & caller_id_name from the FSConnection + // to the protocol connection (e.g. H.323) so gets sent correctly + // in outgoing packets + PSafePtr proto = GetOtherPartyConnection(); + if (proto == NULL) { + PTRACE(1, "mod_opal\tNo protocol connection in call."); + return false; + } + + proto->SetLocalPartyName(GetLocalPartyName()); + proto->SetDisplayName(GetDisplayName()); + + switch_channel_set_name(m_fsChannel, ModuleName + '/' + GetRemotePartyURL()); + return true; +} + + +bool FSConnection::OnIncoming() +{ + if (m_fsSession == NULL || m_fsChannel == NULL) { + PTRACE(1, "mod_opal\tSession request failed."); + return false; + } + + switch_core_session_add_stream(m_fsSession, NULL); + + PURL url = GetRemotePartyURL(); + switch_caller_profile_t *caller_profile = switch_caller_profile_new( + switch_core_session_get_pool(m_fsSession), + url.GetUserName(), /** username */ + m_endpoint.GetManager().GetDialPlan(), /** dial plan */ + GetRemotePartyName(), /** caller_id_name */ + GetRemotePartyNumber(), /** caller_id_number */ + url.GetHostName(), /** network addr */ + NULL, /** ANI */ + NULL, /** ANI II */ + NULL, /** RDNIS */ + ModuleName, /** source */ + m_endpoint.GetManager().GetContext(), /** set context */ + GetCalledPartyNumber() /** destination_number */ + ); + if (caller_profile == NULL) { + PTRACE(1, "mod_opal\tCould not create caller profile"); + return false; + } + + PTRACE(4, "mod_opal\tCreated switch caller profile:\n" + " username = " << caller_profile->username << "\n" + " dialplan = " << caller_profile->dialplan << "\n" + " caller_id_name = " << caller_profile->caller_id_name << "\n" + " caller_id_number = " << caller_profile->caller_id_number << "\n" + " network_addr = " << caller_profile->network_addr << "\n" + " source = " << caller_profile->source << "\n" + " context = " << caller_profile->context << "\n" + " destination_number= " << caller_profile->destination_number); + switch_channel_set_caller_profile(m_fsChannel, caller_profile); + + switch_channel_set_name(m_fsChannel, ModuleName + '/' + url.GetScheme() + ':' + caller_profile->destination_number); + + if (switch_core_session_thread_launch(m_fsSession) != SWITCH_STATUS_SUCCESS) { + PTRACE(1, "mod_opal\tCould not launch session thread"); + switch_core_session_destroy(&m_fsSession); + m_fsChannel = NULL; + return false; + } + + return true; +} + + +void FSConnection::OnReleased() +{ + m_rxAudioOpened.Signal(); // Just in case + m_txAudioOpened.Signal(); + + if (m_fsChannel == NULL) { + PTRACE(3, "mod_opal\tHanging up FS side"); + switch_channel_hangup(m_fsChannel, (switch_call_cause_t)callEndReason.q931); + } + + OpalLocalConnection::OnReleased(); +} + + +PBoolean FSConnection::SetAlerting(const PString & calleeName, PBoolean withMedia) +{ + if (PAssertNULL(m_fsChannel) == NULL) + return false; + + switch_channel_mark_ring_ready(m_fsChannel); + return OpalLocalConnection::SetAlerting(calleeName, withMedia); +} + + +PBoolean FSConnection::SendUserInputTone(char tone, unsigned duration) +{ + if (PAssertNULL(m_fsChannel) == NULL) + return false; + + switch_dtmf_t dtmf = { tone, duration }; + return switch_channel_queue_dtmf(m_fsChannel, &dtmf) == SWITCH_STATUS_SUCCESS; +} + + +OpalMediaFormatList FSConnection::GetMediaFormats() const +{ + if (m_switchMediaFormats.IsEmpty()) { + const_cast(this)->SetCodecs(); + } + + return m_switchMediaFormats; +} + + +void FSConnection::SetCodecs() +{ + int numCodecs = 0; + const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS]; + + PString codec_string = switch_channel_get_variable(m_fsChannel, "absolute_codec_string"); + if (codec_string.IsEmpty()) { + codec_string = switch_channel_get_variable(m_fsChannel, "codec_string"); + if (codec_string.IsEmpty()) { + codec_string = m_endpoint.GetManager().GetCodecPrefs(); + if (codec_string.IsEmpty()) { + numCodecs = switch_loadable_module_get_codecs(codecs, sizeof(codecs) / sizeof(codecs[0])); + for (int i = 0; i < numCodecs; i++) { + if (i > 0) + codec_string += ','; + codec_string += codecs[i]->iananame; + } + PTRACE(4, "mod_opal\tDefault to all loaded codecs=" << codec_string); + } + else { + PTRACE(4, "mod_opal\tSettings codec-prefs=" << codec_string); + } + } + else { + PTRACE(4, "mod_opal\tChannel codec_string=" << codec_string); + } + + PString orig_codec = switch_channel_get_variable(m_fsChannel, SWITCH_ORIGINATOR_CODEC_VARIABLE); + if (!orig_codec.IsEmpty()) { + if (m_endpoint.GetManager().GetDisableTranscoding()) { + codec_string = orig_codec; + PTRACE(4, "mod_opal\tNo transcoding, forced to originator codec=" << orig_codec); + } + else { + codec_string.Splice(orig_codec+',', 0); + PTRACE(4, "mod_opal\tSetting preference to originator codec=" << orig_codec); + } + } + } + else { + PTRACE(4, "mod_opal\tChannel absolute_codec_string=" << codec_string); + } + + { + char *codec_order[SWITCH_MAX_CODECS]; + int codec_order_last = switch_separate_string((char *)codec_string.GetPointer(), ',', codec_order, SWITCH_MAX_CODECS); + numCodecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, codec_order, codec_order_last); + } + + for (int i = 0; i < numCodecs; i++) { + const switch_codec_implementation_t *codec = codecs[i]; + + // See if we have a match by PayloadType/rate/name + OpalMediaFormat switchFormat((RTP_DataFrame::PayloadTypes)codec->ianacode, + codec->samples_per_second, + codec->iananame); + if (!switchFormat.IsValid()) { + // See if we have a match by name alone + switchFormat = codec->iananame; + if (!switchFormat.IsValid()) { + PTRACE(2, "mod_opal\tCould not match FS codec " + << codec->iananame << '@' << codec->samples_per_second + << " (pt=" << (unsigned)codec->ianacode << ")" + " to an OPAL media format."); + continue; + } + } + + PTRACE(4, "mod_opal\tMatched FS codec " << codec->iananame << " to OPAL media format " << switchFormat); + +#if IMPLEMENT_MULTI_FAME_AUDIO + // Did we match or create a new media format? + if (switchFormat.IsValid() && codec->codec_type == SWITCH_CODEC_TYPE_AUDIO) { + // Calculate frames per packet, do not use codec->codec_frames_per_packet as that field + // has slightly different semantics when used in streamed codecs such as G.711 + int fpp = codec->samples_per_packet/switchFormat.GetFrameTime(); + + /* Set the frames/packet to maximum of what is in the FS table. The OPAL negotiations will + drop the value from there. This might fail if there are "holes" in the FS table, e.g. + if for some reason G.723.1 has 30ms and 90ms but not 60ms, then the OPAL negotiations + could end up with 60ms and the codec cannot be created. The "holes" are unlikely in + all but streamed codecs such as G.711, where it is theoretically possible for OPAL to + come up with 32ms and there is only 30ms and 40ms in the FS table. We deem these + scenarios sufficiently rare that we can safely ignore them ... for now. */ + + if (fpp > switchFormat.GetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption())) { + switchFormat.SetOptionInteger(OpalAudioFormat::RxFramesPerPacketOption(), fpp); + } + + if (fpp > switchFormat.GetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption())) { + switchFormat.SetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption(), fpp); + } + } +#endif // IMPLEMENT_MULTI_FAME_AUDIO + + m_switchMediaFormats += switchFormat; + } +} + + +OpalMediaStream *FSConnection::CreateMediaStream(const OpalMediaFormat & mediaFormat, unsigned sessionID, PBoolean isSource) +{ + return new FSMediaStream(*this, mediaFormat, sessionID, isSource); +} + + +void FSConnection::OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch) +{ + OpalConnection::OnPatchMediaStream(isSource, patch); + + if (PAssertNULL(m_fsChannel) == NULL) + return; + + if (patch.GetSource().GetMediaFormat().GetMediaType() != OpalMediaType::Audio()) + return; + + if (switch_channel_direction(m_fsChannel) == SWITCH_CALL_DIRECTION_INBOUND) { + if (isSource) + m_rxAudioOpened.Signal(); + else + m_txAudioOpened.Signal(); + } + else if (GetMediaStream(OpalMediaType::Audio(), !isSource) != NULL) { + // Have open media in both directions. + if (IsEstablished()) + switch_channel_mark_answered(m_fsChannel); + else if (!IsReleased()) + switch_channel_mark_pre_answered(m_fsChannel); + } +} + + +switch_status_t FSConnection::on_init() +{ + if (PAssertNULL(m_fsChannel) == NULL) + return SWITCH_STATUS_FALSE; + + PTRACE(4, "mod_opal\tStarted routing for connection " << *this); + switch_channel_set_state(m_fsChannel, CS_ROUTING); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::on_routing() +{ + if (PAssertNULL(m_fsChannel) == NULL) + return SWITCH_STATUS_FALSE; + + PTRACE(4, "mod_opal\tRouting connection " << *this); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::on_execute() +{ + if (PAssertNULL(m_fsChannel) == NULL) + return SWITCH_STATUS_FALSE; + + PTRACE(4, "mod_opal\tExecuting connection " << *this); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::on_destroy() +{ + PTRACE(3, "mod_opal\tFS on_destroy for connection " << *this); + + m_fsChannel = NULL; // Will be destoyed by FS, so don't use it any more. + + switch_core_codec_destroy(&m_read_codec); + switch_core_codec_destroy(&m_write_codec); + switch_core_codec_destroy(&m_vid_read_codec); + switch_core_codec_destroy(&m_vid_write_codec); + switch_core_timer_destroy(&m_read_timer); + switch_core_timer_destroy(&m_vid_read_timer); + + switch_core_session_set_private(m_fsSession, NULL); + SafeDereference(); + + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::on_hangup() +{ + if (PAssertNULL(m_fsChannel) == NULL) + return SWITCH_STATUS_FALSE; + + /* if this is still here it was our idea to hangup not opal's */ + ClearCallSynchronous(NULL, H323TranslateToCallEndReason( + (Q931::CauseValues)switch_channel_get_cause_q850(m_fsChannel), UINT_MAX)); + + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::on_exchange_media() +{ + PTRACE(4, "mod_opal\tExchanging media on connection " << *this); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::on_soft_execute() +{ + PTRACE(4, "mod_opal\tTransmit on connection " << *this); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::kill_channel(int sig) +{ + switch (sig) { + case SWITCH_SIG_KILL: + m_rxAudioOpened.Signal(); + m_txAudioOpened.Signal(); + PTRACE(4, "mod_opal\tSignal channel KILL on connection " << *this); + break; + case SWITCH_SIG_XFER: + case SWITCH_SIG_BREAK: + default: + PTRACE(4, "mod_opal\tSignal channel " << sig << " on connection " << *this); + break; + } + + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::send_dtmf(const switch_dtmf_t *dtmf) +{ + OnUserInputTone(dtmf->digit, dtmf->duration); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::receive_message(switch_core_session_message_t *msg) +{ + if (PAssertNULL(m_fsChannel) == NULL) + return SWITCH_STATUS_FALSE; + + switch (msg->message_id) { + case SWITCH_MESSAGE_INDICATE_RINGING: + case SWITCH_MESSAGE_INDICATE_PROGRESS: + case SWITCH_MESSAGE_INDICATE_ANSWER: + case SWITCH_MESSAGE_INDICATE_DEFLECT: + if (switch_channel_direction(m_fsChannel) == SWITCH_CALL_DIRECTION_INBOUND) { + switch_caller_profile_t * profile = switch_channel_get_caller_profile(m_fsChannel); + if (profile != NULL && profile->caller_extension != NULL) + { + PSafePtr other = GetOtherPartyConnection(); + if (other != NULL) { + other->SetLocalPartyName(profile->caller_extension->extension_number); + other->SetDisplayName(profile->caller_extension->extension_name); + } + SetLocalPartyName(profile->caller_extension->extension_number); + SetDisplayName(profile->caller_extension->extension_name); + } + } + else { + return SWITCH_STATUS_FALSE; + } + break; + + default: + break; + } + + switch (msg->message_id) { + case SWITCH_MESSAGE_INDICATE_BRIDGE: + case SWITCH_MESSAGE_INDICATE_UNBRIDGE: + case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: + m_flushAudio = true; + break; + + case SWITCH_MESSAGE_INDICATE_RINGING: + AlertingIncoming(); + break; + + case SWITCH_MESSAGE_INDICATE_PROGRESS: + AutoStartMediaStreams(); + AlertingIncoming(); + + if (!WaitForMedia()) + return SWITCH_STATUS_FALSE; + + if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) { + switch_channel_mark_pre_answered(m_fsChannel); + } + break; + + case SWITCH_MESSAGE_INDICATE_ANSWER: + AcceptIncoming(); + + if (!WaitForMedia()) + return SWITCH_STATUS_FALSE; + + if (!switch_channel_test_flag(m_fsChannel, CF_ANSWERED)) { + switch_channel_mark_answered(m_fsChannel); + } + break; + + case SWITCH_MESSAGE_INDICATE_DEFLECT: + ownerCall.Transfer(msg->string_arg, GetOtherPartyConnection()); + break; + + default: + PTRACE(3, "mod_opal\tReceived unhandled message " << msg->message_id << " on connection " << *this); + } + + return SWITCH_STATUS_SUCCESS; +} + + +bool FSConnection::WaitForMedia() +{ + PTRACE(4, "mod_opal\tAwaiting media start on connection " << *this); + m_rxAudioOpened.Wait(); + m_txAudioOpened.Wait(); + + if (IsReleased()) { + // Call got aborted + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_fsSession), SWITCH_LOG_ERROR, "Call abandoned!\n"); + return false; + } + + PTRACE(3, "mod_opal\tMedia started on connection " << *this); + return true; +} + + +switch_status_t FSConnection::receive_event(switch_event_t *event) +{ + PTRACE(4, "mod_opal\tReceived event " << event->event_id << " on connection " << *this); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::state_change() +{ + PTRACE(4, "mod_opal\tState changed on connection " << *this); + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSConnection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id) +{ + return read_frame(OpalMediaType::Audio(), frame, flags); +} + + +switch_status_t FSConnection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id) +{ + return write_frame(OpalMediaType::Audio(), frame, flags); +} + + +switch_status_t FSConnection::read_video_frame(switch_frame_t **frame, switch_io_flag_t flag, int stream_id) +{ + return read_frame(OpalMediaType::Video(), frame, flag); +} + + +switch_status_t FSConnection::write_video_frame(switch_frame_t *frame, switch_io_flag_t flag, int stream_id) +{ + return write_frame(OpalMediaType::Video(), frame, flag); +} + + +switch_status_t FSConnection::read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags) +{ + PSafePtr stream = PSafePtrCast (GetMediaStream(mediaType, false)); + return stream != NULL ? stream->read_frame(frame, flags) : SWITCH_STATUS_FALSE; +} + + +switch_status_t FSConnection::write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags) +{ + PSafePtr stream = PSafePtrCast(GetMediaStream(mediaType, true)); + return stream != NULL ? stream->write_frame(frame, flags) : SWITCH_STATUS_FALSE; +} + + +/////////////////////////////////////////////////////////////////////// + +FSMediaStream::FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, unsigned sessionID, bool isSource) + : OpalMediaStream(conn, mediaFormat, sessionID, isSource) + , m_connection(conn) + , m_readRTP(0, SWITCH_RECOMMENDED_BUFFER_SIZE) +{ + memset(&m_readFrame, 0, sizeof(m_readFrame)); +} + + +PBoolean FSMediaStream::Open() +{ + if (IsOpen()) { + return true; + } + + switch_core_session_t *fsSession = m_connection.GetSession(); + switch_channel_t *fsChannel = m_connection.GetChannel(); + if (PAssertNULL(fsSession) == NULL || PAssertNULL(fsChannel) == NULL) + return false; + + bool isAudio; + if (mediaFormat.GetMediaType() == OpalMediaType::Audio()) { + isAudio = true; + } else if (mediaFormat.GetMediaType() == OpalMediaType::Video()) { + isAudio = false; + } else { + return false; + } + + int ptime = mediaFormat.GetOptionInteger(OpalAudioFormat::TxFramesPerPacketOption()) * mediaFormat.GetFrameTime() / mediaFormat.GetTimeUnits(); + + if (IsSink()) { + m_switchCodec = isAudio ? &m_connection.m_read_codec : &m_connection.m_vid_read_codec; + m_switchTimer = isAudio ? &m_connection.m_read_timer : &m_connection.m_vid_read_timer; + m_readFrame.codec = m_switchCodec; + m_readFrame.rate = mediaFormat.GetClockRate(); + } else { + m_switchCodec = isAudio ? &m_connection.m_write_codec : &m_connection.m_vid_write_codec; + } + + // The following is performed on two different instances of this object. + if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP + mediaFormat.GetClockRate(), ptime, 1, // Channels + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings + switch_core_session_get_pool(fsSession)) != SWITCH_STATUS_SUCCESS) { + // Could not select a codecs using negotiated frames/packet, so try using default. + if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP + mediaFormat.GetClockRate(), 0, 1, // Channels + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings + switch_core_session_get_pool(fsSession)) != SWITCH_STATUS_SUCCESS) { + PTRACE(1, "mod_opal\t" << switch_channel_get_name(fsChannel) + << " cannot initialise " << (IsSink()? "read" : "write") << ' ' + << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); + switch_channel_hangup(fsChannel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); + return false; + } + PTRACE(2, "mod_opal\t" << switch_channel_get_name(fsChannel) + << " unsupported ptime of " << ptime << " on " << (IsSink()? "read" : "write") << ' ' + << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); + } + + if (IsSink()) { + if (isAudio) { + switch_core_session_set_read_codec(fsSession, m_switchCodec); + if (switch_core_timer_init(m_switchTimer, + "soft", + m_switchCodec->implementation->microseconds_per_packet / 1000, + m_switchCodec->implementation->samples_per_packet, + switch_core_session_get_pool(fsSession)) != SWITCH_STATUS_SUCCESS) { + PTRACE(1, "mod_opal\t" << switch_channel_get_name(fsChannel) + << " timer init failed on " << (IsSink()? "read" : "write") << ' ' + << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); + switch_core_codec_destroy(m_switchCodec); + m_switchCodec = NULL; + return false; + } + } else { + switch_core_session_set_video_read_codec(fsSession, m_switchCodec); + switch_channel_set_flag(fsChannel, CF_VIDEO); + } + } else { + if (isAudio) { + switch_core_session_set_write_codec(fsSession, m_switchCodec); + } else { + switch_core_session_set_video_write_codec(fsSession, m_switchCodec); + switch_channel_set_flag(fsChannel, CF_VIDEO); + } + } + + PTRACE(3, "mod_opal\t" << switch_channel_get_name(fsChannel) + << " initialised " << (IsSink()? "read" : "write") << ' ' + << mediaFormat.GetMediaType() << " codec " << mediaFormat << " for connection " << *this); + + return OpalMediaStream::Open(); +} + + +void FSMediaStream::InternalClose() +{ +} + + +PBoolean FSMediaStream::IsSynchronous() const +{ + return true; +} + + +PBoolean FSMediaStream::RequiresPatchThread(OpalMediaStream *) const +{ + return false; +} + + +int FSMediaStream::StartReadWrite(PatchPtr & mediaPatch) const +{ + if (!IsOpen()) { + PTRACE(2, "mod_opal\tNot open!"); + return -1; + } + + if (!m_switchCodec) { + PTRACE(2, "mod_opal\tNo codec!"); + return -1; + } + + if (!m_connection.IsChannelReady()) { + PTRACE(2, "mod_opal\tChannel not ready!"); + return -1; + } + + // We make referenced copy of pointer so can't be deleted out from under us + mediaPatch = m_mediaPatch; + if (mediaPatch == NULL) { + /*There is a race here... sometimes we make it here and m_mediaPatch is NULL + if we wait it shows up in 1ms, maybe there is a better way to wait. */ + PTRACE(3, "mod_opal\tPatch not ready!"); + return 1; + } + + return 0; +} + + +switch_status_t FSMediaStream::read_frame(switch_frame_t **frame, switch_io_flag_t flags) +{ + PatchPtr mediaPatch; + switch (StartReadWrite(mediaPatch)) { + case -1 : + return SWITCH_STATUS_FALSE; + case 1 : + return SWITCH_STATUS_SUCCESS; + } + + if (m_connection.NeedFlushAudio()) { + mediaPatch->GetSource().EnableJitterBuffer(); // This flushes data and resets jitter buffer + m_readRTP.SetPayloadSize(0); + } else { + m_readRTP.SetTimestamp(m_readFrame.timestamp + m_switchCodec->implementation->samples_per_packet); + + if (!mediaPatch->GetSource().ReadPacket(m_readRTP)) { + return SWITCH_STATUS_FALSE; + } + } + + if (m_switchTimer != NULL) { + switch_core_timer_next(m_switchTimer); + } + + if (m_switchCodec != NULL) { + if (!switch_core_codec_ready(m_switchCodec)) { + PTRACE(2, "mod_opal\tread_frame: codec not ready!"); + return SWITCH_STATUS_FALSE; + } + } + + m_readFrame.packet = m_readRTP.GetPointer(); + m_readFrame.packetlen = m_readRTP.GetHeaderSize() + m_readFrame.datalen; + +#if IMPLEMENT_MULTI_FAME_AUDIO + // Repackage frames in incoming packet to agree with what FS expects. + // Not implmented yet!!!!!!!!! + // Cheating and only supporting one frame per packet +#endif + + m_readFrame.buflen = m_readRTP.GetSize(); + m_readFrame.data = m_readRTP.GetPayloadPtr(); + m_readFrame.datalen = m_readRTP.GetPayloadSize(); + m_readFrame.timestamp = m_readRTP.GetTimestamp(); + m_readFrame.seq = m_readRTP.GetSequenceNumber(); + m_readFrame.ssrc = m_readRTP.GetSyncSource(); + m_readFrame.m = m_readRTP.GetMarker() ? SWITCH_TRUE : SWITCH_FALSE; + m_readFrame.payload = (switch_payload_t)m_readRTP.GetPayloadType(); + m_readFrame.flags = m_readFrame.datalen == 0 || + m_readFrame.payload == RTP_DataFrame::CN || + m_readFrame.payload == RTP_DataFrame::Cisco_CN ? SFF_CNG : 0; + + *frame = &m_readFrame; + + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t FSMediaStream::write_frame(const switch_frame_t *frame, switch_io_flag_t flags) +{ + PatchPtr mediaPatch; + switch (StartReadWrite(mediaPatch)) { + case -1 : + return SWITCH_STATUS_FALSE; + case 1 : + return SWITCH_STATUS_SUCCESS; + } + + if ((frame->flags & SFF_RAW_RTP) != 0) { + RTP_DataFrame rtp((const BYTE *)frame->packet, frame->packetlen, false); + return mediaPatch->PushFrame(rtp) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; + } + + RTP_DataFrame rtp(frame->datalen); + memcpy(rtp.GetPayloadPtr(), frame->data, frame->datalen); + + rtp.SetPayloadType(mediaFormat.GetPayloadType()); + + /* Not sure what FS is going to give us! + Suspect it depends on the mod on the other side sending it. */ + if (frame->timestamp != 0) + timestamp = frame->timestamp; + else if (frame->samples != 0) + timestamp += frame->samples; + else + timestamp += m_switchCodec->implementation->samples_per_packet; + rtp.SetTimestamp(timestamp); + + return mediaPatch->PushFrame(rtp) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; +} + + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4:s: + */ diff --git a/src/mod/endpoints/mod_opal/mod_opal.h b/src/mod/endpoints/mod_opal/mod_opal.h index 1915d54b90..5edc21f8a0 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.h +++ b/src/mod/endpoints/mod_opal/mod_opal.h @@ -1,270 +1,335 @@ -/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library / - * Soft-Switch Application - * - * Version: MPL 1.1 - * - * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com) - * - * 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. - * - * Contributor(s): - * Tuyan Ozipek (tuyanozipek@gmail.com) - * Lukasz Zwierko (lzwierko@gmail.com) - * Robert Jongbloed (robertj@voxlucida.com.au) - * - */ - - -#ifndef __FREESWITCH_MOD_OPAL__ -#define __FREESWITCH_MOD_OPAL__ - -#if defined(__GNUC__) && defined(HAVE_VISIBILITY) -#pragma GCC visibility push(default) -#endif - -#include -#include -#include -#include -#include - -#if defined(__GNUC__) && defined(HAVE_VISIBILITY) -#pragma GCC visibility pop -#endif - -#undef strcasecmp -#undef strncasecmp - -#define HAVE_APR -#include -#include -#define MODNAME "mod_opal" - - -class FSEndPoint; -class FSManager; - - -struct mod_opal_globals { - int trace_level; - char *codec_string; - char *context; - char *dialplan; -}; - -extern struct mod_opal_globals mod_opal_globals; - - -class FSProcess:public PLibraryProcess { - PCLASSINFO(FSProcess, PLibraryProcess); - - public: - FSProcess(); - ~FSProcess(); - - bool Initialise(switch_loadable_module_interface_t *iface); - - FSManager & GetManager() const { - return *m_manager; - } protected: - FSManager * m_manager; -}; - - -struct FSListener { - FSListener() { - } PString name; - OpalTransportAddress listenAddress; - PString localUserName; - PString gatekeeper; -}; - - -class FSCall:public OpalCall { - PCLASSINFO(FSCall, OpalCall); - public: - FSCall(OpalManager & manager); - virtual PBoolean OnSetUp(OpalConnection & connection); -}; - - -class FSManager:public OpalManager { - PCLASSINFO(FSManager, OpalManager); - - public: - FSManager(); - - bool Initialise(switch_loadable_module_interface_t *iface); - - switch_status_t ReadConfig(int reload); - - switch_endpoint_interface_t *GetSwitchInterface() const { - return m_FreeSwitch; - } virtual OpalCall *CreateCall(void *userData); - - private: - switch_endpoint_interface_t *m_FreeSwitch; - - H323EndPoint *m_h323ep; - IAX2EndPoint *m_iaxep; - FSEndPoint *m_fsep; - - PString m_gkAddress; - PString m_gkIdentifer; - PString m_gkInterface; - - list < FSListener > m_listeners; -}; - - -class FSConnection; -typedef struct { - switch_timer_t read_timer; - switch_codec_t read_codec; - switch_codec_t write_codec; - - switch_timer_t vid_read_timer; - switch_codec_t vid_read_codec; - switch_codec_t vid_write_codec; - FSConnection *me; -} opal_private_t; - - -class FSEndPoint:public OpalLocalEndPoint { - PCLASSINFO(FSEndPoint, OpalLocalEndPoint); - public: - FSEndPoint(FSManager & manager); - - virtual bool OnIncomingCall(OpalLocalConnection &); - virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions); -}; - - -#define DECLARE_CALLBACK0(name) \ - static switch_status_t name(switch_core_session_t *session) { \ - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \ - return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name() : SWITCH_STATUS_FALSE; } \ -switch_status_t name() - -#define DECLARE_CALLBACK1(name, type1, name1) \ - static switch_status_t name(switch_core_session_t *session, type1 name1) { \ - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \ - return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1) : SWITCH_STATUS_FALSE; } \ -switch_status_t name(type1 name1) - -#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \ - static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \ - opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \ - return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \ -switch_status_t name(type1 name1, type2 name2, type3 name3) - - - - -class FSConnection:public OpalLocalConnection { - PCLASSINFO(FSConnection, OpalLocalConnection) - - public: - FSConnection(OpalCall & call, - FSEndPoint & endpoint, - void *userData, - unsigned options, - OpalConnection::StringOptions * stringOptions, - switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel); - - virtual bool OnIncoming(); - virtual void OnReleased(); - virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia); - virtual void OnAlerting(); - virtual void OnEstablished(); - virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean); - virtual PBoolean OnOpenMediaStream(OpalMediaStream & stream); - virtual OpalMediaFormatList GetMediaFormats() const; - virtual PBoolean SendUserInputTone(char tone, unsigned duration); - virtual PBoolean SendUserInputString(const PString & value); - - void SetCodecs(); - - DECLARE_CALLBACK0(on_init); - DECLARE_CALLBACK0(on_routing); - DECLARE_CALLBACK0(on_execute); - - DECLARE_CALLBACK0(on_exchange_media); - DECLARE_CALLBACK0(on_soft_execute); - - DECLARE_CALLBACK1(kill_channel, int, sig); - DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf); - DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg); - DECLARE_CALLBACK1(receive_event, switch_event_t *, event); - DECLARE_CALLBACK0(state_change); - DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id); - DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id); - DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id); - DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id); - - switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags); - switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags); - - switch_core_session_t *GetSession() const { - return m_fsSession; - } private: - FSEndPoint & m_endpoint; - switch_core_session_t *m_fsSession; - switch_channel_t *m_fsChannel; - PSyncPoint m_rxAudioOpened; - PSyncPoint m_txAudioOpened; - OpalMediaFormatList m_switchMediaFormats; -}; - - -class FSMediaStream:public OpalMediaStream { - PCLASSINFO(FSMediaStream, OpalMediaStream); - public: - FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, ///< Media format for stream - unsigned sessionID, ///< Session number for stream - bool isSource ///< Is a source stream - ); - - virtual PBoolean Open(); - virtual PBoolean Close(); - virtual PBoolean IsSynchronous() const; - virtual PBoolean RequiresPatchThread(OpalMediaStream *) const; - - switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags); - switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags); - - private: - switch_core_session_t *m_fsSession; - switch_channel_t *m_fsChannel; - switch_timer_t *m_switchTimer; - switch_codec_t *m_switchCodec; - switch_frame_t m_readFrame; - unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE]; - RTP_DataFrame m_readRTP; - bool m_callOnStart; - uint32_t m_timeStamp; - - bool CheckPatchAndLock(); -}; - - -#endif /* __FREESWITCH_MOD_OPAL__ */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:nil - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4:s: - */ +/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library / + * Soft-Switch Application + * + * Version: MPL 1.1 + * + * Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com) + * Copyright (c) 2008-2012 Vox Lucida Pty. Ltd. (robertj@voxlucida.com.au) + * + * 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. + * + * Contributor(s): + * Tuyan Ozipek (tuyanozipek@gmail.com) + * Lukasz Zwierko (lzwierko@gmail.com) + * Robert Jongbloed (robertj@voxlucida.com.au) + * + */ + + +#ifndef __FREESWITCH_MOD_OPAL__ +#define __FREESWITCH_MOD_OPAL__ + +#if defined(__GNUC__) && defined(HAVE_VISIBILITY) +#pragma GCC visibility push(default) +#endif + +#include + +#if !defined(PTLIB_CHECK_VERSION) + #error PTLib is too old to use, must be >= 2.10.6 +#endif + +#include +#include +#include +#include + +#if defined(__GNUC__) && defined(HAVE_VISIBILITY) +#pragma GCC visibility pop +#endif + +#undef strcasecmp +#undef strncasecmp + + +#if _MSC_VER < 1600 +/*The following insanity is because libteletone_generate.h defines int8_t in + a slightly different manner to most other cases (SDL, PCAP, Java V8, stdint.h + etc) and does not provide a mechanism to prevent it's inclusion. Then, to + cap it off, VS2008 barfs on the difference. VS2010 seems OK with it. + + Sigh. + */ +#pragma include_alias(, <../../libs/libteletone/src/libteletone.h>) +#pragma include_alias(, <../../libs/libteletone/src/libteletone_generate.h>) +#pragma include_alias(, <../../libs/libteletone/src/libteletone_detect.h>) +#define int8_t signed int8_t +#include +#undef int8_t +#endif // End of insanity + + +#define HAVE_APR +#define uint32_t uint32_t // Avoid conflict in stdint definitions +#include +#undef uint32_t + +#include + + +#define MODNAME "mod_opal" + + +class FSEndPoint; +class FSManager; + + +class FSProcess : public PLibraryProcess +{ + PCLASSINFO(FSProcess, PLibraryProcess); + public: + FSProcess(); + ~FSProcess(); + + bool Initialise(switch_loadable_module_interface_t *iface); + + FSManager & GetManager() const + { + return *m_manager; + } + + protected: + FSManager * m_manager; +}; + + +struct FSListener +{ + FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { } + + PString m_name; + PIPSocket::Address m_address; + uint16_t m_port; +}; + + +class FSManager : public OpalManager +{ + PCLASSINFO(FSManager, OpalManager); + + public: + FSManager(); + + bool Initialise(switch_loadable_module_interface_t *iface); + + switch_status_t ReadConfig(int reload); + + switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; } + const PString & GetContext() const { return m_context; } + const PString & GetDialPlan() const { return m_dialplan; } + const PString & GetCodecPrefs() const { return m_codecPrefs; } + bool GetDisableTranscoding() const { return m_disableTranscoding; } + + private: + switch_endpoint_interface_t *m_FreeSwitch; + + H323EndPoint *m_h323ep; + IAX2EndPoint *m_iaxep; + FSEndPoint *m_fsep; + + PString m_context; + PString m_dialplan; + PString m_codecPrefs; + bool m_disableTranscoding; + PString m_gkAddress; + PString m_gkIdentifer; + PString m_gkInterface; + + list m_listeners; +}; + + +class FSEndPoint : public OpalLocalEndPoint +{ + PCLASSINFO(FSEndPoint, OpalLocalEndPoint); + public: + FSEndPoint(FSManager & manager); + + virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions); + + FSManager & GetManager() const { return m_manager; } + + protected: + FSManager & m_manager; +}; + + +class FSConnection; + + +class FSMediaStream : public OpalMediaStream +{ + PCLASSINFO(FSMediaStream, OpalMediaStream); + public: + FSMediaStream( + FSConnection & conn, + const OpalMediaFormat & mediaFormat, ///< Media format for stream + unsigned sessionID, ///< Session number for stream + bool isSource ///< Is a source stream + ); + + virtual PBoolean Open(); + virtual PBoolean IsSynchronous() const; + virtual PBoolean RequiresPatchThread(OpalMediaStream *) const; + + switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags); + switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags); + + protected: + virtual void InternalClose(); + int StartReadWrite(PatchPtr & mediaPatch) const; + + private: + bool CheckPatchAndLock(); + + FSConnection &m_connection; + switch_timer_t *m_switchTimer; + switch_codec_t *m_switchCodec; + switch_frame_t m_readFrame; + RTP_DataFrame m_readRTP; +}; + + +#define DECLARE_CALLBACK0(name) \ + static switch_status_t name(switch_core_session_t *session) { \ + FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \ + return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \ + switch_status_t name() + +#define DECLARE_CALLBACK1(name, type1, name1) \ + static switch_status_t name(switch_core_session_t *session, type1 name1) { \ + FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \ + return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \ + switch_status_t name(type1 name1) + +#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \ + static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \ + FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \ + return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \ + switch_status_t name(type1 name1, type2 name2, type3 name3) + + + + +class FSConnection : public OpalLocalConnection +{ + PCLASSINFO(FSConnection, OpalLocalConnection) + + public: + struct outgoing_params { + switch_event_t *var_event; + switch_caller_profile_t *outbound_profile; + switch_core_session_t **new_session; + switch_memory_pool_t **pool; + switch_originate_flag_t flags; + switch_call_cause_t *cancel_cause; + switch_call_cause_t fail_cause; + }; + + FSConnection(OpalCall & call, + FSEndPoint & endpoint, + unsigned options, + OpalConnection::StringOptions * stringOptions, + outgoing_params * params); + + virtual bool OnOutgoingSetUp(); + virtual bool OnIncoming(); + virtual void OnReleased(); + virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia); + virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean); + virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch); + virtual OpalMediaFormatList GetMediaFormats() const; + virtual PBoolean SendUserInputTone(char tone, unsigned duration); + + DECLARE_CALLBACK0(on_init); + DECLARE_CALLBACK0(on_destroy); + DECLARE_CALLBACK0(on_routing); + DECLARE_CALLBACK0(on_execute); + DECLARE_CALLBACK0(on_hangup); + + DECLARE_CALLBACK0(on_exchange_media); + DECLARE_CALLBACK0(on_soft_execute); + + DECLARE_CALLBACK1(kill_channel, int, sig); + DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf); + DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg); + DECLARE_CALLBACK1(receive_event, switch_event_t *, event); + DECLARE_CALLBACK0(state_change); + DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id); + DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id); + DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id); + DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id); + + __inline switch_core_session_t *GetSession() const + { + return m_fsSession; + } + + __inline switch_channel_t *GetChannel() const + { + return m_fsChannel; + } + + bool IsChannelReady() const + { + return m_fsChannel != NULL && switch_channel_ready(m_fsChannel); + } + + bool NeedFlushAudio() + { + if (!m_flushAudio) + return false; + m_flushAudio = false; + return true; + } + + protected: + void SetCodecs(); + bool WaitForMedia(); + + switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags); + switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags); + + private: + FSEndPoint &m_endpoint; + switch_core_session_t *m_fsSession; + switch_channel_t *m_fsChannel; + PSyncPoint m_rxAudioOpened; + PSyncPoint m_txAudioOpened; + OpalMediaFormatList m_switchMediaFormats; + + // If FS ever supports more than one audio and one video, this needs to change + switch_timer_t m_read_timer; + switch_codec_t m_read_codec; + switch_codec_t m_write_codec; + + switch_timer_t m_vid_read_timer; + switch_codec_t m_vid_read_codec; + switch_codec_t m_vid_write_codec; + + bool m_flushAudio; + + friend PBoolean FSMediaStream::Open(); +}; + + +#endif /* __FREESWITCH_MOD_OPAL__ */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4:s: + */ diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index c66ed8a95b..abc36620dd 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -2806,6 +2806,9 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t } else { switch_channel_t *channel = switch_core_session_get_channel(tp->session); switch_set_flag_locked(tp, TFLAG_ANSWER); + if (tp != globals.call_list) { + remove_pvt(tp); + } add_pvt(tp, PA_MASTER); switch_channel_mark_answered(channel); } diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index 5247074762..d43ae73d01 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -625,7 +625,7 @@ switch_call_cause_t rtmp_outgoing_channel(switch_core_session_t *session, switch /*switch_channel_mark_pre_answered(channel);*/ switch_channel_ring_ready(channel); - rtmp_send_incoming_call(*newsession); + rtmp_send_incoming_call(*newsession, var_event); switch_channel_set_state(channel, CS_INIT); switch_set_flag_locked(tech_pvt, TFLAG_IO); @@ -634,7 +634,7 @@ switch_call_cause_t rtmp_outgoing_channel(switch_core_session_t *session, switch switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock); - if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) { + if (switch_core_session_thread_launch(tech_pvt->session) == SWITCH_STATUS_FALSE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't spawn thread\n"); goto fail; } @@ -647,7 +647,9 @@ switch_call_cause_t rtmp_outgoing_channel(switch_core_session_t *session, switch fail: if (*newsession) { - switch_core_session_destroy(newsession); + if (!switch_core_session_running(*newsession) && !switch_core_session_started(*newsession)) { + switch_core_session_destroy(newsession); + } } if (rsession) { rtmp_session_rwunlock(rsession); @@ -847,6 +849,7 @@ switch_call_cause_t rtmp_session_create_call(rtmp_session_t *rsession, switch_co return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } + pool = switch_core_session_get_pool(*newsession); channel = switch_core_session_get_channel(*newsession); switch_channel_set_name(channel, switch_core_session_sprintf(*newsession, "rtmp/%s/%s", rsession->profile->name, number)); @@ -911,17 +914,21 @@ switch_call_cause_t rtmp_session_create_call(rtmp_session_t *rsession, switch_co } } - switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock); - - if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) { + if (switch_core_session_thread_launch(tech_pvt->session) == SWITCH_STATUS_FALSE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't spawn thread\n"); goto fail; } + switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock); + return SWITCH_CAUSE_SUCCESS; fail: - switch_core_session_destroy(newsession); + + if (!switch_core_session_running(*newsession) && !switch_core_session_started(*newsession)) { + switch_core_session_destroy(newsession); + } + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } @@ -1048,6 +1055,10 @@ void rtmp_add_registration(rtmp_session_t *rsession, const char *auth, const cha dup = strdup(auth); switch_split_user_domain(dup, &user, &domain); + + + reg->user = switch_core_strdup(rsession->pool, user); + reg->domain = switch_core_strdup(rsession->pool, domain); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "User", user); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Domain", domain); @@ -1072,9 +1083,11 @@ static void rtmp_clear_reg_auth(rtmp_session_t *rsession, const char *auth, cons /* Replace hash entry by its next ptr */ switch_core_hash_insert(rsession->profile->reg_hash, auth, reg->next); } - + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, RTMP_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) { rtmp_event_fill(rsession, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "User", reg->user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Domain", reg->domain); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Nickname", switch_str_nil(reg->nickname)); switch_event_fire(&event); } diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.h b/src/mod/endpoints/mod_rtmp/mod_rtmp.h index 388afeacb5..24ef575449 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.h +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.h @@ -529,6 +529,8 @@ typedef struct rtmp_reg rtmp_reg_t; struct rtmp_reg { const char *uuid; /* < The rtmp session id */ const char *nickname; /* < This instance's nickname, optional */ + const char *user; + const char *domain; rtmp_reg_t *next; /* < Next entry */ }; @@ -616,7 +618,7 @@ switch_status_t rtmp_send_message(rtmp_session_t *rsession, uint8_t amfnumber, u void rtmp_send_event(rtmp_session_t *rsession, switch_event_t *event); void rtmp_notify_call_state(switch_core_session_t *session); void rtmp_send_display_update(switch_core_session_t *session); -void rtmp_send_incoming_call(switch_core_session_t *session); +void rtmp_send_incoming_call(switch_core_session_t *session, switch_event_t *var_event); void rtmp_send_onhangup(switch_core_session_t *session); void rtmp_add_registration(rtmp_session_t *rsession, const char *auth, const char *nickname); void rtmp_clear_registration(rtmp_session_t *rsession, const char *auth, const char *nickname); diff --git a/src/mod/endpoints/mod_rtmp/rtmp.c b/src/mod/endpoints/mod_rtmp/rtmp.c index f28f518383..d334feea4b 100644 --- a/src/mod/endpoints/mod_rtmp/rtmp.c +++ b/src/mod/endpoints/mod_rtmp/rtmp.c @@ -357,6 +357,25 @@ void rtmp_get_user_variables(switch_event_t **event, switch_core_session_t *sess } } + +void rtmp_get_user_variables_event(switch_event_t **event, switch_event_t *var_event) +{ + switch_event_header_t *he; + + if (!*event && switch_event_create(event, SWITCH_EVENT_CLONE) != SWITCH_STATUS_SUCCESS) { + return; + } + + if ((he = var_event->headers)) { + for (; he; he = he->next) { + if (!strncmp(he->name, RTMP_USER_VARIABLE_PREFIX, strlen(RTMP_USER_VARIABLE_PREFIX))) { + switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, he->name, he->value); + } + } + } +} + + void rtmp_session_send_onattach(rtmp_session_t *rsession) { const char *uuid = ""; @@ -386,7 +405,7 @@ void rtmp_send_display_update(switch_core_session_t *session) amf0_str(switch_str_nil(tech_pvt->display_callee_id_number)), NULL); } -void rtmp_send_incoming_call(switch_core_session_t *session) +void rtmp_send_incoming_call(switch_core_session_t *session, switch_event_t *var_event) { rtmp_private_t *tech_pvt = switch_core_session_get_private(session); switch_channel_t *channel = switch_core_session_get_channel(session); @@ -394,7 +413,11 @@ void rtmp_send_incoming_call(switch_core_session_t *session) switch_event_t *event = NULL; amf0_data *obj = NULL; - rtmp_get_user_variables(&event, session); + if (var_event) { + rtmp_get_user_variables_event(&event, var_event); + } else { + rtmp_get_user_variables(&event, session); + } if (event) { amf_event_to_object(&obj, event); @@ -654,7 +677,7 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) s = 1537 - rsession->hspos; if (rsession->profile->io->read(rsession, rsession->hsbuf + rsession->hspos, &s) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read error\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disconnected from flash client\n"); return SWITCH_STATUS_FALSE; } @@ -685,7 +708,7 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) /* Receive C2 */ if (rsession->profile->io->read(rsession, rsession->hsbuf + rsession->hspos, &s) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read error\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disconnected from flash client\n"); return SWITCH_STATUS_FALSE; } @@ -712,7 +735,7 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) // Read the header's first byte s = 1; if (rsession->profile->io->read(rsession, (unsigned char*)buf, &s) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read error\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disconnected from flash client\n"); return SWITCH_STATUS_FALSE; } @@ -767,7 +790,7 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) switch_assert(s < 12 && s > 0); /** XXX **/ if (rsession->profile->io->read(rsession, readbuf, &s) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read error\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disconnected from flash client\n"); return SWITCH_STATUS_FALSE; } @@ -849,7 +872,7 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) switch_assert(s <= rsession->in_chunksize); if (rsession->profile->io->read(rsession, state->buf + state->buf_pos, &s) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read error\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disconnected from flash client\n"); return SWITCH_STATUS_FALSE; } rsession->recv += s; diff --git a/src/mod/endpoints/mod_rtmp/rtmp_sig.c b/src/mod/endpoints/mod_rtmp/rtmp_sig.c index 5f57eb04c7..a29465ecc0 100644 --- a/src/mod/endpoints/mod_rtmp/rtmp_sig.c +++ b/src/mod/endpoints/mod_rtmp/rtmp_sig.c @@ -539,7 +539,7 @@ RTMP_INVOKE_FUNCTION(rtmp_i_transfer) } if ((tech_pvt = rtmp_locate_private(rsession, uuid))) { - const char *other_uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *other_uuid = switch_channel_get_partner_uuid(tech_pvt->channel); switch_core_session_t *session; if (!zstr(other_uuid) && (session = switch_core_session_locate(other_uuid))) { @@ -570,8 +570,8 @@ RTMP_INVOKE_FUNCTION(rtmp_i_join) return SWITCH_STATUS_FALSE; } - if ((other_uuid[0] = switch_channel_get_variable(tech_pvt[0]->channel, SWITCH_SIGNAL_BOND_VARIABLE)) && - (other_uuid[1] = switch_channel_get_variable(tech_pvt[1]->channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if ((other_uuid[0] = switch_channel_get_partner_uuid(tech_pvt[0]->channel)) && + (other_uuid[1] = switch_channel_get_partner_uuid(tech_pvt[1]->channel))) { #ifndef RTMP_DONT_HOLD if (switch_test_flag(tech_pvt[0], TFLAG_DETACHED)) { @@ -725,8 +725,8 @@ RTMP_INVOKE_FUNCTION(rtmp_i_three_way) return SWITCH_STATUS_FALSE; } - if (!(other_uuid[0] = switch_channel_get_variable(tech_pvt[0]->channel, SWITCH_SIGNAL_BOND_VARIABLE)) || - !(other_uuid[1] = switch_channel_get_variable(tech_pvt[1]->channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if (!(other_uuid[0] = switch_channel_get_partner_uuid(tech_pvt[0]->channel)) || + !(other_uuid[1] = switch_channel_get_partner_uuid(tech_pvt[1]->channel))) { return SWITCH_STATUS_FALSE; /* Both calls aren't bridged */ } diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 8e47691c36..95f7e6c83e 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -784,12 +784,12 @@ switch_status_t skinny_session_transfer(switch_core_session_t *session, listener tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); - remote_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + remote_uuid = switch_channel_get_partner_uuid(channel); if (tech_pvt->transfer_from_call_id) { if((session2 = skinny_profile_find_session(listener->profile, listener, &line_instance, tech_pvt->transfer_from_call_id))) { switch_channel_t *channel2 = switch_core_session_get_channel(session2); - const char *remote_uuid2 = switch_channel_get_variable(channel2, SWITCH_SIGNAL_BOND_VARIABLE); + const char *remote_uuid2 = switch_channel_get_partner_uuid(channel2); if (switch_ivr_uuid_bridge(remote_uuid, remote_uuid2) == SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); switch_channel_hangup(channel2, SWITCH_CAUSE_NORMAL_CLEARING); @@ -1007,6 +1007,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r const char *value = switch_xml_attr_soft(xbutton, "value"); if(type == SKINNY_BUTTON_LINE) { const char *caller_name = switch_xml_attr_soft(xbutton, "caller-name"); + const char *reg_metadata = switch_xml_attr_soft(xbutton, "registration-metadata"); uint32_t ring_on_idle = atoi(switch_xml_attr_soft(xbutton, "ring-on-idle")); uint32_t ring_on_active = atoi(switch_xml_attr_soft(xbutton, "ring-on-active")); uint32_t busy_trigger = atoi(switch_xml_attr_soft(xbutton, "busy-trigger")); @@ -1030,7 +1031,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r switch_safe_free(sql); token = switch_mprintf("skinny/%q/%q/%q:%d", profile->name, value, request->data.reg.device_name, request->data.reg.instance); url = switch_mprintf("skinny/%q/%q", profile->name, value); - switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp"); + switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp", reg_metadata); switch_safe_free(token); switch_safe_free(url); } diff --git a/src/mod/endpoints/mod_skypopen/Makefile.am b/src/mod/endpoints/mod_skypopen/Makefile.am index ab1909817b..29a207cfa2 100644 --- a/src/mod/endpoints/mod_skypopen/Makefile.am +++ b/src/mod/endpoints/mod_skypopen/Makefile.am @@ -1,8 +1,8 @@ include $(top_srcdir)/build/modmake.rulesam MODNAME=mod_skypopen -TIFF_DIR=$(switch_srcdir)/libs/tiff-3.8.2 -TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-3.8.2 +TIFF_DIR=$(switch_srcdir)/libs/tiff-4.0.2 +TIFF_BUILDDIR=$(switch_builddir)/libs/tiff-4.0.2 TIFF_LA=$(TIFF_BUILDDIR)/libtiff/libtiff.la SPANDSP_DIR=$(switch_srcdir)/libs/spandsp diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.2008.vcproj b/src/mod/endpoints/mod_skypopen/mod_skypopen.2008.vcproj index 1e3acada07..328eaf30b0 100644 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.2008.vcproj +++ b/src/mod/endpoints/mod_skypopen/mod_skypopen.2008.vcproj @@ -39,7 +39,7 @@ /> - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) Level4 @@ -81,7 +81,7 @@ - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) Level4 @@ -96,7 +96,7 @@ - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) @@ -109,7 +109,7 @@ - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-3.8.2\libtiff;%(AdditionalIncludeDirectories) + %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\tiff-4.0.2\libtiff;%(AdditionalIncludeDirectories) diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.c b/src/mod/endpoints/mod_skypopen/mod_skypopen.c index 159840f5e4..21dea92d4f 100644 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.c +++ b/src/mod/endpoints/mod_skypopen/mod_skypopen.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2011, Anthony Minessale II * * Version: MPL 1.1 * @@ -21,19 +21,17 @@ * Portions created by the Initial Developer are Copyright (C) * the Initial Developer. All Rights Reserved. * - * This module (mod_skypopen) has been contributed by: - * - * Giovanni Maruzzelli (gmaruzz@gmail.com) - * - * - * Further Contributors: + * This module (mod_gsmopen) has been contributed by: * + * Giovanni Maruzzelli * + * Maintainer: Giovanni Maruzzelli * * mod_skypopen.c -- Skype compatible Endpoint Module * */ + #include "skypopen.h" #define SKYPE_CHAT_PROTO "skype" @@ -112,6 +110,7 @@ char *interface_status[] = { /* should match SKYPOPEN_STATE_xxx in skypopen.h */ "PREANSW", "DEAD" }; + char *skype_callflow[] = { /* should match CALLFLOW_XXX in skypopen.h */ "IDLE", "DOWN", @@ -381,7 +380,7 @@ static switch_status_t interface_exists(char *the_interface) if (tech_pvt->running && tech_pvt->SkypopenHandles.disp) { XEvent e; Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); - switch_sleep(20000); + switch_sleep(20000); XFlush(tech_pvt->SkypopenHandles.disp); memset(&e, 0, sizeof(e)); e.xclient.type = ClientMessage; @@ -739,6 +738,7 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int return SWITCH_STATUS_SUCCESS; } + static switch_status_t channel_on_consume_media(switch_core_session_t *session) { private_t *tech_pvt = NULL; @@ -765,6 +765,7 @@ static switch_status_t channel_on_soft_execute(switch_core_session_t *session) DEBUGA_SKYPE("%s CHANNEL SOFT_EXECUTE\n", SKYPOPEN_P_LOG, tech_pvt->name); return SWITCH_STATUS_SUCCESS; } + static switch_status_t channel_on_reset(switch_core_session_t *session) { private_t *tech_pvt = NULL; @@ -873,10 +874,10 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch switch_mutex_unlock(tech_pvt->mutex_audio_srv); if (!bytes_read) { - switch_sleep(1000); //XXX don't like this + switch_sleep(1000); //XXX don't like this try++; - if (try < 5){ - DEBUGA_SKYPE("skypopen_audio_read going back to read\n", SKYPOPEN_P_LOG); + if (try < 5) { + //DEBUGA_SKYPE("skypopen_audio_read going back to read\n", SKYPOPEN_P_LOG); goto read; } DEBUGA_SKYPE("READ BUFFER EMPTY, skypopen_audio_read Silence\n", SKYPOPEN_P_LOG); @@ -940,19 +941,19 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch char *p = digit_str; switch_channel_t *channel = switch_core_session_get_channel(session); - if(channel){ + if (channel) { while (p && *p) { - switch_dtmf_t dtmf = {0}; + switch_dtmf_t dtmf = { 0 }; dtmf.digit = *p; dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION; switch_channel_queue_dtmf(channel, &dtmf); p++; } - NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp, - (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp)); + NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, + (unsigned int) new_dtmf_timestamp, (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp)); tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp; - }else{ + } else { WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); } } @@ -1077,7 +1078,7 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session) return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t * msg) +static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) { switch_channel_t *channel; private_t *tech_pvt; @@ -1648,7 +1649,7 @@ static switch_status_t load_config(int reload_type) } else { DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPOPEN_P_LOG); } - switch_sleep(20000); + switch_sleep(20000); #endif /* WIN32 */ if (interface_id && interface_id < SKYPOPEN_MAX_INTERFACES) { @@ -1751,8 +1752,7 @@ static switch_status_t load_config(int reload_type) switch_threadattr_detach_set(skypopen_signaling_thread_attr, 0); switch_threadattr_stacksize_set(skypopen_signaling_thread_attr, SWITCH_THREAD_STACKSIZE); //switch_threadattr_priority_increase(skypopen_signaling_thread_attr); - switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id]. - skypopen_signaling_thread, skypopen_signaling_thread_attr, + switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread, skypopen_signaling_thread_attr, skypopen_signaling_thread_func, &globals.SKYPOPEN_INTERFACES[interface_id], skypopen_module_pool); switch_sleep(100000); @@ -1858,8 +1858,8 @@ static switch_status_t load_config(int reload_type) return SWITCH_STATUS_SUCCESS; } + static switch_status_t chat_send(switch_event_t *message_event) - { char *user = NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL; private_t *tech_pvt = NULL; @@ -1867,7 +1867,7 @@ static switch_status_t chat_send(switch_event_t *message_event) char skype_msg[1024]; const char *proto; - const char *from; + const char *from; const char *to; const char *subject; const char *body; @@ -1885,7 +1885,7 @@ static switch_status_t chat_send(switch_event_t *message_event) switch_assert(proto != NULL); //DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type, - // hint ? hint : "NULL"); + // hint ? hint : "NULL"); DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, hint ? hint : "NULL"); @@ -1912,9 +1912,8 @@ static switch_status_t chat_send(switch_event_t *message_event) if ((host = strchr(user, '@'))) { *host++ = '\0'; } - //DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type, - // hint ? hint : "NULL"); + // hint ? hint : "NULL"); DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, hint ? hint : "NULL"); if (hint && strlen(hint)) { @@ -1950,13 +1949,14 @@ static switch_status_t chat_send(switch_event_t *message_event) snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", to); skypopen_signaling_write(tech_pvt, skype_msg); - switch_sleep(20000); + switch_sleep(20000); } found = 0; while (!found) { for (i = 0; i < MAX_CHATS; i++) { + //DEBUGA_SKYPE("tech_pvt->chats[i].dialog_partner='%s' to='%s'\n", SKYPOPEN_P_LOG, tech_pvt->chats[i].dialog_partner, to); if (!strcmp(tech_pvt->chats[i].dialog_partner, to)) { snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname, body); skypopen_signaling_write(tech_pvt, skype_msg); @@ -1969,7 +1969,9 @@ static switch_status_t chat_send(switch_event_t *message_event) } tried++; if (tried > 20) { - ERRORA("No chat with dialog_partner='%s' was found\n", SKYPOPEN_P_LOG, to); + ERRORA + ("No chat with dialog_partner='%s' was found. (If you're using mod_sms this is a bug of mod_skypopen when using mod_sms, from next incoming message it will probably work...)\n", + SKYPOPEN_P_LOG, to); break; } switch_sleep(50000); @@ -2075,7 +2077,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown) XEvent e; Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); - switch_sleep(20000); + switch_sleep(20000); XFlush(tech_pvt->SkypopenHandles.disp); memset(&e, 0, sizeof(e)); e.xclient.type = ClientMessage; @@ -2171,7 +2173,7 @@ int dtmf_received(private_t *tech_pvt, char *value) if (channel) { if (switch_channel_test_flag(channel, CF_BRIDGED) - && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) { + && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) { NOTICA @@ -2193,13 +2195,51 @@ int dtmf_received(private_t *tech_pvt, char *value) WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]); } switch_core_session_rwunlock(session); - }else{ + } else { WARNINGA("received %c DTMF, but no session?\n", SKYPOPEN_P_LOG, value[0]); } return 0; } +void *SWITCH_THREAD_FUNC skypopen_do_mod_sms_thread(switch_thread_t *thread, void *obj) +{ + switch_event_t *event; + + + event = obj; + switch_core_chat_send("GLOBAL", event); /* mod_sms */ + + return event; + +} + + + +int start_mod_sms_thread(private_t *tech_pvt, switch_event_t *event) +{ + switch_threadattr_t *mod_sms_thread_thd_attr = NULL; + switch_thread_t *mod_sms_thread; + + + switch_threadattr_create(&mod_sms_thread_thd_attr, skypopen_module_pool); + switch_threadattr_detach_set(mod_sms_thread_thd_attr, 0); + switch_threadattr_stacksize_set(mod_sms_thread_thd_attr, SWITCH_THREAD_STACKSIZE); + if (switch_thread_create(&mod_sms_thread, mod_sms_thread_thd_attr, skypopen_do_mod_sms_thread, event, skypopen_module_pool) == SWITCH_STATUS_SUCCESS) { + DEBUGA_SKYPE("started mod_sms_thread thread.\n", SKYPOPEN_P_LOG); + } else { + ERRORA("failed to start mod_sms_thread thread.\n", SKYPOPEN_P_LOG); + return -1; + } + if (mod_sms_thread == NULL) { + WARNINGA("mod_sms_thread exited\n", SKYPOPEN_P_LOG); + return -1; + } + + return 0; +} + + int start_audio_threads(private_t *tech_pvt) { switch_threadattr_t *tcp_srv_thread_thd_attr = NULL; @@ -2235,7 +2275,8 @@ int start_audio_threads(private_t *tech_pvt) switch_threadattr_priority_increase(tcp_srv_thread_thd_attr); switch_mutex_lock(tech_pvt->mutex_thread_audio_srv); //DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG); - if (switch_thread_create(&tech_pvt->tcp_srv_thread, tcp_srv_thread_thd_attr, skypopen_do_tcp_srv_thread, tech_pvt, skypopen_module_pool) == SWITCH_STATUS_SUCCESS) { + if (switch_thread_create(&tech_pvt->tcp_srv_thread, tcp_srv_thread_thd_attr, skypopen_do_tcp_srv_thread, tech_pvt, skypopen_module_pool) == + SWITCH_STATUS_SUCCESS) { DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPOPEN_P_LOG); } else { ERRORA("failed to start tcp_srv_thread thread.\n", SKYPOPEN_P_LOG); @@ -2252,7 +2293,8 @@ int start_audio_threads(private_t *tech_pvt) switch_threadattr_priority_increase(tcp_cli_thread_thd_attr); switch_mutex_lock(tech_pvt->mutex_thread_audio_cli); //DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG); - if (switch_thread_create(&tech_pvt->tcp_cli_thread, tcp_cli_thread_thd_attr, skypopen_do_tcp_cli_thread, tech_pvt, skypopen_module_pool) == SWITCH_STATUS_SUCCESS) { + if (switch_thread_create(&tech_pvt->tcp_cli_thread, tcp_cli_thread_thd_attr, skypopen_do_tcp_cli_thread, tech_pvt, skypopen_module_pool) == + SWITCH_STATUS_SUCCESS) { DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPOPEN_P_LOG); } else { ERRORA("failed to start tcp_cli_thread thread.\n", SKYPOPEN_P_LOG); @@ -2470,27 +2512,26 @@ SWITCH_STANDARD_API(sk_function) goto end; } - - if (!strcasecmp(argv[0], "balances")) { - stream->write_function(stream, " Name \tBalance\tCurrency\n"); - stream->write_function(stream, " ==== \t=======\t========\n"); - - for (tmp_i = 0; tmp_i < SKYPOPEN_MAX_INTERFACES; tmp_i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[tmp_i].name)) { - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE"); - switch_sleep(20000); - - strncpy(tmp_message, globals.SKYPOPEN_INTERFACES[tmp_i].message, sizeof(globals.SKYPOPEN_INTERFACES[tmp_i].message)); - - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE_CURRENCY"); - switch_sleep(20000); - if(strlen(tmp_message)>21 && strlen(globals.SKYPOPEN_INTERFACES[tmp_i].message) > 30) - stream->write_function(stream, " %s \t%s\t%s\n", globals.SKYPOPEN_INTERFACES[tmp_i].name, tmp_message+21, globals.SKYPOPEN_INTERFACES[tmp_i].message+30); - } - } - } - if (!strcasecmp(argv[0], "list")) { + if (!strcasecmp(argv[0], "balances")) { + stream->write_function(stream, " Name \tBalance\tCurrency\n"); + stream->write_function(stream, " ==== \t=======\t========\n"); + + for (tmp_i = 0; tmp_i < SKYPOPEN_MAX_INTERFACES; tmp_i++) { + if (strlen(globals.SKYPOPEN_INTERFACES[tmp_i].name)) { + skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE"); + switch_sleep(20000); + + strncpy(tmp_message, globals.SKYPOPEN_INTERFACES[tmp_i].message, sizeof(globals.SKYPOPEN_INTERFACES[tmp_i].message)); + + skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE_CURRENCY"); + switch_sleep(20000); + if (strlen(tmp_message) > 21 && strlen(globals.SKYPOPEN_INTERFACES[tmp_i].message) > 30) + stream->write_function(stream, " %s \t%s\t%s\n", globals.SKYPOPEN_INTERFACES[tmp_i].name, tmp_message + 21, + globals.SKYPOPEN_INTERFACES[tmp_i].message + 30); + } + } + } else if (!strcasecmp(argv[0], "list")) { int i; unsigned int ib = 0; unsigned int ib_failed = 0; @@ -2503,14 +2544,14 @@ SWITCH_STANDARD_API(sk_function) for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) { if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - next_flag_char = i == globals.next_interface ? '*' : ' '; - ib += globals.SKYPOPEN_INTERFACES[i].ib_calls; - ib_failed += globals.SKYPOPEN_INTERFACES[i].ib_failed_calls; - ob += globals.SKYPOPEN_INTERFACES[i].ob_calls; - ob_failed += globals.SKYPOPEN_INTERFACES[i].ob_failed_calls; + next_flag_char = i == globals.next_interface ? '*' : ' '; + ib += globals.SKYPOPEN_INTERFACES[i].ib_calls; + ib_failed += globals.SKYPOPEN_INTERFACES[i].ib_failed_calls; + ob += globals.SKYPOPEN_INTERFACES[i].ob_calls; + ob_failed += globals.SKYPOPEN_INTERFACES[i].ob_failed_calls; stream->write_function(stream, - "%c %d\t[%s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n", + "%c %d\t[%6s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n", next_flag_char, i, globals.SKYPOPEN_INTERFACES[i].name, globals.SKYPOPEN_INTERFACES[i].ib_failed_calls, @@ -2966,12 +3007,24 @@ int incoming_chatmessage(private_t *tech_pvt, int which) if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); - 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, "hint", tech_pvt->chatmessages[which].from_dispname); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); +/* mod_sms begin */ + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); +/* mod_sms end */ + switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body); + if (session) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true"); if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) { @@ -3013,7 +3066,36 @@ int incoming_chatmessage(private_t *tech_pvt, int which) if (session) { switch_core_session_rwunlock(session); } - memset(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->chatmessages[which])); + + + if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); + //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->chatmessages[which].from_handle); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); +/* mod_sms begin */ + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); +/* mod_sms end */ + + switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body); + //switch_core_chat_send("GLOBAL", event); /* mod_sms */ + start_mod_sms_thread(tech_pvt, event); + //usleep(20000); + + } else { + ERRORA("cannot create event on interface %s. WHY?????\n", SKYPOPEN_P_LOG, tech_pvt->name); + } + return 0; } @@ -3030,19 +3112,19 @@ static switch_status_t compat_chat_send(const char *proto, const char *from, con switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "subject", subject); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "type", type); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "hint", hint); - + if (body) { switch_event_add_body(message_event, "%s", body); } } else { abort(); - } + } status = chat_send(message_event); switch_event_destroy(&message_event); return status; - + } SWITCH_STANDARD_API(skypopen_chat_function) @@ -3084,8 +3166,9 @@ SWITCH_STANDARD_API(skypopen_chat_function) goto end; } else { - NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, SKYPE_CHAT_PROTO, tech_pvt->skype_user, - argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name); + NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, SKYPE_CHAT_PROTO, + tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), + tech_pvt->name); compat_chat_send(SKYPE_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name); diff --git a/src/mod/endpoints/mod_skypopen/oss/main.c b/src/mod/endpoints/mod_skypopen/oss/main.c index d92d2dc863..897978a2b7 100644 --- a/src/mod/endpoints/mod_skypopen/oss/main.c +++ b/src/mod/endpoints/mod_skypopen/oss/main.c @@ -29,7 +29,6 @@ #include #include -#include /* cli(), *_flags */ #include /* copy_*_user */ #include diff --git a/src/mod/endpoints/mod_skypopen/oss/skypopen.h b/src/mod/endpoints/mod_skypopen/oss/skypopen.h index dca1f8870d..29e32feeca 100644 --- a/src/mod/endpoints/mod_skypopen/oss/skypopen.h +++ b/src/mod/endpoints/mod_skypopen/oss/skypopen.h @@ -21,6 +21,12 @@ #include #include /* needed for the _IOW etc stuff used later */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) +#include /* cli(), *_flags */ +#else +#include /* cli(), *_flags */ +#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) + #if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18) #define CENTOS_5 diff --git a/src/mod/endpoints/mod_skypopen/skypopen.h b/src/mod/endpoints/mod_skypopen/skypopen.h index 2be11bf4fc..d5f01f85e6 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen.h +++ b/src/mod/endpoints/mod_skypopen/skypopen.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2011, Anthony Minessale II + * Copyright (C) 2005-2011, Anthony Minessale II * * Version: MPL 1.1 * @@ -21,18 +21,17 @@ * Portions created by the Initial Developer are Copyright (C) * the Initial Developer. All Rights Reserved. * - * This module (mod_skypopen) has been contributed by: + * This module (mod_gsmopen) has been contributed by: * - * Giovanni Maruzzelli (gmaruzz@gmail.com) - * - * - * Further Contributors: + * Giovanni Maruzzelli * + * Maintainer: Giovanni Maruzzelli * * mod_skypopen.c -- Skype compatible Endpoint Module * */ + #include #include @@ -86,7 +85,7 @@ #endif #ifndef SKYPOPEN_SVN_VERSION -#define SKYPOPEN_SVN_VERSION SWITCH_VERSION_REVISION +#define SKYPOPEN_SVN_VERSION SWITCH_VERSION_FULL #endif /* SKYPOPEN_SVN_VERSION */ typedef enum { @@ -112,7 +111,7 @@ typedef enum { #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 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)), " ", __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 95746411e9..2126955452 100644 --- a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c +++ b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c @@ -1,3 +1,37 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2011, Anthony Minessale II + * + * 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 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. + * + * This module (mod_gsmopen) has been contributed by: + * + * Giovanni Maruzzelli + * + * Maintainer: Giovanni Maruzzelli + * + * skypopen_protocol.c -- Low Level Interface for mod_skypopen + * + */ + + #include "skypopen.h" #ifdef ASTERISK @@ -356,7 +390,7 @@ int skypopen_signaling_read(private_t *tech_pvt) } } if (!found) { - DEBUGA_SKYPE("why we do not have a chats slot free? we have more than %d chats in parallel?\n", SKYPOPEN_P_LOG, MAX_CHATS); + ERRORA("why we do not have a chats slot free? we have more than %d chats in parallel?\n", SKYPOPEN_P_LOG, MAX_CHATS); } DEBUGA_SKYPE("CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n", SKYPOPEN_P_LOG, id, i, @@ -378,109 +412,120 @@ int skypopen_signaling_read(private_t *tech_pvt) skypopen_strncpy(prop, where, sizeof(prop) - 1); skypopen_strncpy(value, *stringp, sizeof(value) - 1); - if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) { - DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - - if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) { - DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPOPEN_P_LOG, id); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (strlen(tech_pvt->chatmessages[i].id) == 0) { - strncpy(tech_pvt->chatmessages[i].id, id, sizeof(tech_pvt->chatmessages[i].id)); - strncpy(tech_pvt->chatmessages[i].type, value, sizeof(tech_pvt->chatmessages[i].type)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPOPEN_P_LOG, - MAX_CHATMESSAGES); - } else { - DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPOPEN_P_LOG, id, i, - tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id); - sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_HANDLE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_DISPNAME", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "GET CHATMESSAGE %s BODY", id); + if (!tech_pvt->report_incoming_chatmessages) { + if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) { + sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id); skypopen_signaling_write(tech_pvt, msg_to_skype); } - } - - if (!strcasecmp(prop, "CHATNAME")) { - DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].chatname, value, sizeof(tech_pvt->chatmessages[i].chatname)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } - } - if (!strcasecmp(prop, "FROM_HANDLE")) { - DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].from_handle, value, sizeof(tech_pvt->chatmessages[i].from_handle)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); + } else { + if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) { + DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPOPEN_P_LOG, id); + sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id); + skypopen_signaling_write(tech_pvt, msg_to_skype); } - } - if (!strcasecmp(prop, "FROM_DISPNAME")) { - DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].from_dispname, value, sizeof(tech_pvt->chatmessages[i].from_dispname)); - found = 1; - break; + if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) { + DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPOPEN_P_LOG, id); + found = 0; + for (i = 0; i < MAX_CHATMESSAGES; i++) { + if (strlen(tech_pvt->chatmessages[i].id) == 0) { + strncpy(tech_pvt->chatmessages[i].id, id, sizeof(tech_pvt->chatmessages[i].id)); + strncpy(tech_pvt->chatmessages[i].type, value, sizeof(tech_pvt->chatmessages[i].type)); + found = 1; + break; + } } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } - - } - if (!strcasecmp(prop, "BODY")) { - DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].body, value, sizeof(tech_pvt->chatmessages[i].body)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } else { - DEBUGA_SKYPE - ("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n", - SKYPOPEN_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname, - tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body); - if (strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->skype_user)) { //if the message was not sent by myself - incoming_chatmessage(tech_pvt, i); + if (!found) { + ERRORA("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPOPEN_P_LOG, + MAX_CHATMESSAGES); + } else { + DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPOPEN_P_LOG, id, i, + tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id); + sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id); + skypopen_signaling_write(tech_pvt, msg_to_skype); + //skypopen_sleep(1000); + sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_HANDLE", id); + skypopen_signaling_write(tech_pvt, msg_to_skype); + //skypopen_sleep(1000); + sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_DISPNAME", id); + skypopen_signaling_write(tech_pvt, msg_to_skype); + //skypopen_sleep(1000); + sprintf(msg_to_skype, "GET CHATMESSAGE %s BODY", id); + skypopen_signaling_write(tech_pvt, msg_to_skype); } } + if (!strcasecmp(prop, "CHATNAME")) { + DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPOPEN_P_LOG, id, value); + found = 0; + for (i = 0; i < MAX_CHATMESSAGES; i++) { + if (!strcmp(tech_pvt->chatmessages[i].id, id)) { + strncpy(tech_pvt->chatmessages[i].chatname, value, sizeof(tech_pvt->chatmessages[i].chatname)); + found = 1; + break; + } + } + if (!found) { + DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); + } + } + if (!strcasecmp(prop, "FROM_HANDLE")) { + DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPOPEN_P_LOG, id, value); + found = 0; + for (i = 0; i < MAX_CHATMESSAGES; i++) { + if (!strcmp(tech_pvt->chatmessages[i].id, id)) { + strncpy(tech_pvt->chatmessages[i].from_handle, value, sizeof(tech_pvt->chatmessages[i].from_handle)); + found = 1; + break; + } + } + if (!found) { + DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); + } + + } + if (!strcasecmp(prop, "FROM_DISPNAME")) { + DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPOPEN_P_LOG, id, value); + found = 0; + for (i = 0; i < MAX_CHATMESSAGES; i++) { + if (!strcmp(tech_pvt->chatmessages[i].id, id)) { + strncpy(tech_pvt->chatmessages[i].from_dispname, value, sizeof(tech_pvt->chatmessages[i].from_dispname)); + found = 1; + break; + } + } + if (!found) { + DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); + } + + } + if (!strcasecmp(prop, "BODY")) { + DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPOPEN_P_LOG, id, value); + found = 0; + for (i = 0; i < MAX_CHATMESSAGES; i++) { + if (!strcmp(tech_pvt->chatmessages[i].id, id)) { + strncpy(tech_pvt->chatmessages[i].body, value, sizeof(tech_pvt->chatmessages[i].body)); + found = 1; + break; + } + } + if (!found) { + DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); + } else { + DEBUGA_SKYPE + ("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n", + SKYPOPEN_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname, + tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body); + if (strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->skype_user)) { //if the message was not sent by myself + incoming_chatmessage(tech_pvt, i); + memset(&tech_pvt->chatmessages[i], '\0', sizeof(&tech_pvt->chatmessages[i])); + + sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id); + skypopen_signaling_write(tech_pvt, msg_to_skype); + } + } + + } } } @@ -885,7 +930,7 @@ void *skypopen_do_tcp_srv_thread_func(void *obj) || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) { //unsigned int fdselect; - int rt=1; + int rt = 1; //fd_set fs; //struct timeval to; int nospace; @@ -1022,7 +1067,7 @@ void *skypopen_do_tcp_cli_thread_func(void *obj) if (!(running && tech_pvt->running)) break; FD_ZERO(&fsgio); - togio.tv_usec = MS_SKYPOPEN * 1000 * 3; + togio.tv_usec = MS_SKYPOPEN * 1000 * 3; togio.tv_sec = 0; fdselectgio = s; FD_SET(fdselectgio, &fsgio); @@ -1137,7 +1182,7 @@ int skypopen_senddigit(private_t *tech_pvt, char digit) char msg_to_skype[1024]; DEBUGA_SKYPE("DIGIT received: %c\n", SKYPOPEN_P_LOG, digit); - if(digit != 'a' && digit != 'A' && digit != 'b' && digit != 'B' && digit != 'c' && digit != 'C' && digit != 'd' && digit != 'D'){ + if (digit != 'a' && digit != 'A' && digit != 'b' && digit != 'B' && digit != 'c' && digit != 'C' && digit != 'd' && digit != 'D') { sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit); skypopen_signaling_write(tech_pvt, msg_to_skype); } else { @@ -1690,7 +1735,7 @@ void skypopen_clean_disp(void *data) DEBUGA_SKYPE("NOT destroyed disp\n", SKYPOPEN_P_LOG); } DEBUGA_SKYPE("OUT destroyed disp\n", SKYPOPEN_P_LOG); - skypopen_sleep(20000); + skypopen_sleep(20000); } void *skypopen_do_skypeapi_thread_func(void *obj) @@ -1750,7 +1795,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj) if (session) { switch_channel_t *channel = switch_core_session_get_channel(session); - if(channel){ + if (channel) { switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_IO); @@ -1787,7 +1832,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj) switch_channel_t *channel = switch_core_session_get_channel(session); - if(channel){ + if (channel) { switch_mutex_lock(tech_pvt->flag_mutex); switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_VOICE); @@ -1899,7 +1944,7 @@ void *skypopen_do_skypeapi_thread_func(void *obj) case ClientMessage: if (an_event.xclient.format != 8) { - //skypopen_sleep(1000); //0.1 msec + //skypopen_sleep(1000); //0.1 msec break; } @@ -1959,11 +2004,10 @@ void *skypopen_do_skypeapi_thread_func(void *obj) //XFlush(disp); there_were_continues = 0; } - - //skypopen_sleep(1000); //0.1 msec + //skypopen_sleep(1000); //0.1 msec break; default: - //skypopen_sleep(1000); //0.1 msec + //skypopen_sleep(1000); //0.1 msec break; } //switch event.type } //while XPending diff --git a/src/mod/endpoints/mod_sofia/Makefile.am b/src/mod/endpoints/mod_sofia/Makefile.am index fb0ab25e0b..efd6b2c385 100644 --- a/src/mod/endpoints/mod_sofia/Makefile.am +++ b/src/mod/endpoints/mod_sofia/Makefile.am @@ -9,7 +9,7 @@ SOFIAUA_BUILDDIR=$(SOFIA_BUILDDIR)/libsofia-sip-ua SOFIALA=$(SOFIAUA_BUILDDIR)/libsofia-sip-ua.la mod_LTLIBRARIES = mod_sofia.la -mod_sofia_la_SOURCES = mod_sofia.c sofia.c sofia_glue.c sofia_presence.c sofia_reg.c sip-dig.c mod_sofia.h +mod_sofia_la_SOURCES = mod_sofia.c sofia.c sofia_glue.c sofia_presence.c sofia_reg.c sip-dig.c rtp.c mod_sofia.h mod_sofia_la_CFLAGS = $(AM_CFLAGS) -I. $(SOFIA_CMD_LINE_CFLAGS) mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/bnf -I$(SOFIAUA_BUILDDIR)/bnf mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/http -I$(SOFIAUA_BUILDDIR)/http diff --git a/src/mod/endpoints/mod_sofia/conf/sip_profiles/external.xml b/src/mod/endpoints/mod_sofia/conf/sip_profiles/external.xml deleted file mode 100644 index a709cbb94c..0000000000 --- a/src/mod/endpoints/mod_sofia/conf/sip_profiles/external.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_sofia/conf/sip_profiles/external/example.xml b/src/mod/endpoints/mod_sofia/conf/sip_profiles/external/example.xml deleted file mode 100644 index 70668a9ce5..0000000000 --- a/src/mod/endpoints/mod_sofia/conf/sip_profiles/external/example.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal-ipv6.xml b/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal-ipv6.xml deleted file mode 100644 index ee27a241a0..0000000000 --- a/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal-ipv6.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal.xml b/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal.xml deleted file mode 100644 index b8390c7934..0000000000 --- a/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal.xml +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal/example.xml b/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal/example.xml deleted file mode 100644 index fc061f96d1..0000000000 --- a/src/mod/endpoints/mod_sofia/conf/sip_profiles/internal/example.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml new file mode 100644 index 0000000000..39c53d56d4 --- /dev/null +++ b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml @@ -0,0 +1,477 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.2010.vcxproj b/src/mod/endpoints/mod_sofia/mod_sofia.2010.vcxproj index 5432c3323f..c5b0b0772f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.2010.vcxproj +++ b/src/mod/endpoints/mod_sofia/mod_sofia.2010.vcxproj @@ -138,6 +138,7 @@ + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 7e031f1f26..f7bfc6cb59 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -27,6 +27,7 @@ * Ken Rice * Paul D. Tinsley * Bret McDanel + * Raymond Chandler * * * mod_sofia.c -- SOFIA SIP Endpoint @@ -87,11 +88,11 @@ static switch_status_t sofia_on_init(switch_core_session_t *session) sofia_glue_tech_absorb_sdp(tech_pvt); } - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING) || switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING_BRIDGE)) { sofia_set_flag(tech_pvt, TFLAG_RECOVERED); } - if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { + if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) || switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) { const char *var; if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && !zstr(var)) { @@ -115,10 +116,10 @@ static switch_status_t sofia_on_init(switch_core_session_t *session) - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING_BRIDGE)) { switch_channel_set_state(channel, CS_RESET); } else { - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) { switch_channel_set_state(channel, CS_EXECUTE); } else { /* Move channel's state machine to ROUTING */ @@ -167,12 +168,12 @@ static switch_status_t sofia_on_reset(switch_core_session_t *session) switch_channel_get_name(switch_core_session_get_channel(session))); - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING_BRIDGE)) { switch_core_session_t *other_session = NULL; const char *uuid = switch_core_session_get_uuid(session); if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) { - const char *other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *other_uuid = switch_channel_get_partner_uuid(channel); int x = 0; if (other_uuid) { @@ -200,7 +201,7 @@ static switch_status_t sofia_on_reset(switch_core_session_t *session) } } - sofia_clear_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE); + switch_channel_clear_flag(tech_pvt->channel, CF_RECOVERING_BRIDGE); } @@ -232,7 +233,7 @@ static switch_status_t sofia_on_execute(switch_core_session_t *session) switch_channel_t *channel = switch_core_session_get_channel(session); switch_assert(tech_pvt != NULL); - sofia_clear_flag(tech_pvt, TFLAG_RECOVERING); + switch_channel_clear_flag(tech_pvt->channel, CF_RECOVERING); if (!sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) { sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD); @@ -370,10 +371,26 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session) { private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); switch_channel_t *channel = switch_core_session_get_channel(session); + char *uuid; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA DESTROY\n", switch_channel_get_name(channel)); if (tech_pvt) { + + if (tech_pvt->respond_phrase) { + switch_yield(100000); + } + + if (!zstr(tech_pvt->call_id)) { + switch_mutex_lock(tech_pvt->profile->flag_mutex); + if ((uuid = switch_core_hash_find(tech_pvt->profile->chat_hash, tech_pvt->call_id))) { + free(uuid); + uuid = NULL; + switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->call_id); + } + switch_mutex_unlock(tech_pvt->profile->flag_mutex); + } + if (switch_core_codec_ready(&tech_pvt->read_codec)) { switch_core_codec_destroy(&tech_pvt->read_codec); } @@ -403,7 +420,7 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session) sofia_profile_destroy(tech_pvt->profile); } } - + return SWITCH_STATUS_SUCCESS; } @@ -418,20 +435,17 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) const char *ps_cause = NULL, *use_my_cause; const char *gateway_name = NULL; sofia_gateway_t *gateway_ptr = NULL; - int rec; if ((gateway_name = switch_channel_get_variable(channel, "sip_gateway_name"))) { gateway_ptr = sofia_reg_find_gateway(gateway_name); } + if (!tech_pvt) { + return SWITCH_STATUS_SUCCESS; + } + switch_mutex_lock(tech_pvt->sofia_mutex); - rec = sofia_test_flag(tech_pvt, TFLAG_RECOVERING); - sofia_clear_flag(tech_pvt, TFLAG_RECOVERING); - - if (!rec) { - sofia_glue_tech_untrack(tech_pvt->profile, session, SWITCH_TRUE); - } if (!switch_channel_test_flag(channel, CF_ANSWERED)) { if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { @@ -491,6 +505,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) char reason[128] = ""; char *bye_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX); const char *val = NULL; + const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason"); @@ -503,7 +518,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) } else if (cause > 0 && cause < 128) { switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause)); } else { - switch_snprintf(reason, sizeof(reason), "%s;cause=%d;text=\"%s\"", tech_pvt->profile->username, cause, switch_channel_cause2str(cause)); + switch_snprintf(reason, sizeof(reason), "SIP;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause)); } } } @@ -534,6 +549,66 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) } } else { char *resp_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); + const char *phrase; + char *added_headers = NULL; + + + if (tech_pvt->respond_phrase) { + //phrase = su_strdup(nua_handle_home(tech_pvt->nh), tech_pvt->respond_phrase); + phrase = tech_pvt->respond_phrase; + } else { + phrase = sip_status_phrase(sip_cause); + } + + if (tech_pvt->respond_code) { + sip_cause = tech_pvt->respond_code; + switch (sip_cause) { + case 401: + case 407: + { + const char *to_host = switch_channel_get_variable(channel, "sip_challenge_realm"); + + if (zstr(to_host)) { + to_host = switch_channel_get_variable(channel, "sip_to_host"); + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Challenging call\n"); + sofia_reg_auth_challenge(tech_pvt->profile, tech_pvt->nh, NULL, REG_INVITE, to_host, 0); + *reason = '\0'; + } + break; + + case 484: + { + const char *to = switch_channel_get_variable(channel, "sip_to_uri"); + char *to_uri = NULL; + + if (to) { + char *p; + to_uri = switch_core_session_sprintf(session, "sip:%s", to); + if ((p = strstr(to_uri, ":5060"))) { + *p = '\0'; + } + + tech_pvt->respond_dest = to_uri; + + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", sip_cause, phrase); + + } + break; + + default: + break; + + } + } + + if (tech_pvt->respond_dest && !sofia_test_pflag(tech_pvt->profile, PFLAG_MANUAL_REDIRECT)) { + added_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX); + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause); if (!tech_pvt->got_bye) { @@ -548,15 +623,19 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL); } - nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), + nua_respond(tech_pvt->nh, sip_cause, phrase, TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), TAG_IF(cid, SIPTAG_HEADER_STR(cid)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_IF(!zstr(resp_headers), SIPTAG_HEADER_STR(resp_headers)), + TAG_IF(!zstr(added_headers), SIPTAG_HEADER_STR(added_headers)), + TAG_IF(tech_pvt->respond_dest, SIPTAG_CONTACT_STR(tech_pvt->respond_dest)), + TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); switch_safe_free(resp_headers); } + switch_safe_free(added_headers); } } sofia_set_flag_locked(tech_pvt, TFLAG_BYE); @@ -601,7 +680,10 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) int is_3pcc = 0; char *sticky = NULL; const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full"); - + + if (switch_channel_test_flag(channel, CF_CONFERENCE)) { + tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;isfocus", tech_pvt->reply_contact); + } if(sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE)) { // SNARK: complete hack to get final ack sent when a 3pcc invite has been passed from the other leg in bypass_media mode. @@ -1464,9 +1546,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch (msg->message_id) { case SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH: case SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC: - { - sofia_glue_tech_track(tech_pvt->profile, session); - } break; case SWITCH_MESSAGE_INDICATE_PROXY_MEDIA: { @@ -1587,7 +1666,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_BRIDGE: { - sofia_glue_tech_track(tech_pvt->profile, session); + + switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, NULL); sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY); @@ -1649,11 +1729,31 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } } goto end; + case SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE: + { + const char *event = switch_channel_get_variable(channel, "sip_blind_transfer_event"); + const char *uuid = switch_channel_get_variable(channel, "blind_transfer_uuid"); + char *xdest; + + if (event && uuid) { + nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"), + NUTAG_SUBSTATE(nua_substate_terminated), + SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), + SIPTAG_PAYLOAD_STR(msg->numeric_arg ? "SIP/2.0 200 OK\r\n" : "SIP/2.0 403 Forbidden\r\n"), + SIPTAG_EVENT_STR(event), TAG_END()); + + + if (!msg->numeric_arg) { + xdest = switch_core_session_sprintf(session, "intercept:%s", uuid); + switch_ivr_session_transfer(session, xdest, "inline", NULL); + } + } + + } + goto end; case SWITCH_MESSAGE_INDICATE_UNBRIDGE: if (switch_rtp_ready(tech_pvt->rtp_session)) { - sofia_glue_tech_track(tech_pvt->profile, session); - if (sofia_test_flag(tech_pvt, TFLAG_JB_PAUSED)) { sofia_clear_flag(tech_pvt, TFLAG_JB_PAUSED); if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) { @@ -1686,8 +1786,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_ONCE); } - //sofia_glue_tech_untrack(tech_pvt->profile, session); - } goto end; case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: @@ -1802,7 +1900,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE); - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) + if ((uuid = switch_channel_get_partner_uuid(channel)) && (other_session = switch_core_session_locate(uuid))) { other_channel = switch_core_session_get_channel(other_session); ip = switch_channel_get_variable(other_channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE); @@ -1924,6 +2022,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_set_flag(channel, CF_REQ_MEDIA); } sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE); + switch_channel_set_variable(channel, "sip_require_timer", "false"); sofia_glue_do_invite(session); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Request to send IMAGE on channel with not t38 options.\n", @@ -1995,6 +2094,42 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } } + case SWITCH_MESSAGE_INDICATE_MESSAGE: + { + char *ct = "text/plain"; + int ok = 0; + + if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { + ct = switch_core_session_sprintf(session, "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]); + ok = 1; + } + + if (switch_stristr("send_message", tech_pvt->x_freeswitch_support_remote)) { + ok = 1; + } + + if (switch_true(switch_channel_get_variable(channel, "fs_send_unsupported_message"))) { + ok = 1; + } + + if (ok) { + const char *pl = NULL; + + if (!zstr(msg->string_array_arg[2])) { + pl = msg->string_array_arg[2]; + } + + nua_message(tech_pvt->nh, + SIPTAG_CONTENT_TYPE_STR(ct), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(pl, SIPTAG_PAYLOAD_STR(pl)), + TAG_END()); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "%s send_message is not supported.\n", switch_channel_get_name(channel)); + } + } + break; case SWITCH_MESSAGE_INDICATE_INFO: { char *ct = "freeswitch/data"; @@ -2009,7 +2144,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi ok = 1; } + /* TODO: 1.4 remove this stanza */ if (switch_true(switch_channel_get_variable(channel, "fs_send_unspported_info"))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, + "fs_send_unspported_info is deprecated in favor of correctly spelled fs_send_unsupported_info\n"); + ok = 1; + } + + if (switch_true(switch_channel_get_variable(channel, "fs_send_unsupported_info"))) { ok = 1; } @@ -2038,7 +2180,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi const char *uuid; const char *call_id = NULL, *to_user = NULL, *to_host = NULL, *to_tag = NULL, *from_tag = NULL, *from_user = NULL, *from_host = NULL; - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) || (uuid = switch_channel_get_variable(channel, "originate_signal_bond"))) { + if ((uuid = switch_channel_get_partner_uuid(channel))) { switch_core_session_t *rsession; if ((rsession = switch_core_session_locate(uuid))) { switch_channel_t *rchannel = switch_core_session_get_channel(rsession); @@ -2095,6 +2237,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi number = tech_pvt->caller_profile->destination_number; } + switch_ivr_eavesdrop_update_display(session, name, number); + if (!sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY) && switch_channel_test_flag(channel, CF_ANSWERED)) { if (zstr(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) || zstr(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) { @@ -2166,7 +2310,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) { - const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *uuid = switch_channel_get_partner_uuid(channel); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND"); @@ -2224,14 +2368,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } break; case SWITCH_MESSAGE_INDICATE_REDIRECT: + if (!zstr(msg->string_arg)) { + if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { - char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); - char *added_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX); char *dest = (char *) msg->string_arg; char *argv[128] = { 0 }; char *mydata = NULL, *newdest = NULL; - int argc = 0, ok = 0, i; + int argc = 0, i; switch_size_t len = 0; if (strchr(dest, ',')) { @@ -2267,21 +2411,18 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirecting to %s\n", dest); - ok = sofia_test_pflag(tech_pvt->profile, PFLAG_MANUAL_REDIRECT); - + tech_pvt->respond_dest = dest; + if (argc > 1) { - nua_respond(tech_pvt->nh, SIP_300_MULTIPLE_CHOICES, SIPTAG_CONTACT_STR(dest), - TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), - TAG_IF((!zstr(added_headers) && !ok), SIPTAG_HEADER_STR(added_headers)), TAG_END()); + tech_pvt->respond_code = 300; + tech_pvt->respond_phrase = "Multiple Choices"; } else { - nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(dest), - TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), - TAG_IF((!zstr(added_headers) && !ok), SIPTAG_HEADER_STR(added_headers)), TAG_END()); + tech_pvt->respond_code = 302; + tech_pvt->respond_phrase = "Moved Temporarily"; } + switch_channel_hangup(tech_pvt->channel, sofia_glue_sip_cause_to_freeswitch(tech_pvt->respond_code)); - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); - switch_safe_free(extra_headers); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Too late for redirecting, already answered\n"); @@ -2301,161 +2442,143 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } nua_refer(tech_pvt->nh, SIPTAG_REFER_TO_STR(ref_to), SIPTAG_REFERRED_BY_STR(tech_pvt->contact_url), TAG_END()); switch_mutex_unlock(tech_pvt->sofia_mutex); - sofia_wait_for_reply(tech_pvt, 9999, 300); + sofia_wait_for_reply(tech_pvt, 9999, 10); switch_mutex_lock(tech_pvt->sofia_mutex); if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_refer_reply"))) { msg->string_reply = switch_core_session_strdup(session, var); } else { msg->string_reply = "no reply"; } + switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BLIND_TRANSFER); } break; case SWITCH_MESSAGE_INDICATE_RESPOND: - if (msg->numeric_arg || msg->string_arg) { - int code = msg->numeric_arg; - const char *reason = NULL; + { - if (code) { - reason = msg->string_arg; - } else { - if (!zstr(msg->string_arg)) { - if ((code = atoi(msg->string_arg))) { - if ((reason = strchr(msg->string_arg, ' '))) { - reason++; + if (msg->numeric_arg || msg->string_arg) { + int code = msg->numeric_arg; + const char *reason = NULL; + + if (code > 0) { + reason = msg->string_arg; + } else { + if (!zstr(msg->string_arg)) { + if ((code = atoi(msg->string_arg))) { + if ((reason = strchr(msg->string_arg, ' '))) { + reason++; + } } } } - } - if (!code) { - code = 488; - } - - if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) { - if (sofia_test_flag(tech_pvt, TFLAG_BYE)) { - goto end_lock; + if (!code) { + code = 488; } - } - if (zstr(reason) && code != 407 && code != 302) { - reason = sip_status_phrase(code); - if (zstr(reason)) { - reason = "Because"; + if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) { + if (sofia_test_flag(tech_pvt, TFLAG_BYE)) { + goto end_lock; + } } - } - if (code == 407 && !msg->numeric_arg) { - const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri"); - const char *to_host = reason; - - if (zstr(to_host)) { - to_host = switch_channel_get_variable(channel, "sip_to_host"); + if (zstr(reason) && code != 407 && code != 302) { + reason = sip_status_phrase(code); + if (zstr(reason)) { + reason = "Because"; + } } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri); - sofia_reg_auth_challenge(tech_pvt->profile, tech_pvt->nh, NULL, REG_INVITE, to_host, 0); - switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE); - } else if (code == 484 && msg->numeric_arg) { - const char *to = switch_channel_get_variable(channel, "sip_to_uri"); - const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); - char *cid = generate_pai_str(tech_pvt); - char *to_uri = NULL; - if (to) { + if (code == 302 && !zstr(msg->string_arg)) { char *p; - to_uri = switch_core_session_sprintf(session, "sip:%s", to); - if ((p = strstr(to_uri, ":5060"))) { + + if ((p = strchr(msg->string_arg, ' '))) { *p = '\0'; + msg->string_arg = p; } - } - if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { - char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason); + msg->message_id = SWITCH_MESSAGE_INDICATE_REDIRECT; + switch_core_session_receive_message(session, msg); + goto end_lock; + } else { + if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { + char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); + char *sdp = (char *) msg->pointer_arg; - nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), - SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL), - TAG_IF(cid, SIPTAG_HEADER_STR(cid)), - TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), - TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason); + sofia_clear_flag(tech_pvt, TFLAG_REINVITED); - sofia_set_flag_locked(tech_pvt, TFLAG_BYE); - switch_safe_free(extra_headers); - } - } else if (code == 302 && !zstr(msg->string_arg)) { - char *p; - - if ((p = strchr(msg->string_arg, ' '))) { - *p = '\0'; - msg->string_arg = p; - } - - msg->message_id = SWITCH_MESSAGE_INDICATE_REDIRECT; - switch_core_session_receive_message(session, msg); - goto end_lock; - } else { - if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { - char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); - char *sdp = (char *) msg->pointer_arg; - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason); - - if (!zstr((sdp))) { - if (!strcasecmp(sdp, "t38")) { - switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options"); - if (t38_options) { - sofia_glue_set_image_sdp(tech_pvt, t38_options, 0); - if (switch_rtp_ready(tech_pvt->rtp_session)) { - sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE); - switch_rtp_udptl_mode(tech_pvt->rtp_session); + if (!zstr((sdp))) { + if (!strcasecmp(sdp, "t38")) { + switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options"); + if (t38_options) { + sofia_glue_set_image_sdp(tech_pvt, t38_options, 0); + if (switch_rtp_ready(tech_pvt->rtp_session)) { + sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE); + switch_rtp_udptl_mode(tech_pvt->rtp_session); + } } - } - } else { - sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE); - } - - if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { - sofia_glue_tech_patch_sdp(tech_pvt); - sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); - } - if (sofia_use_soa(tech_pvt)) { - nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), - SOATAG_REUSE_REJECTED(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_END()); - } else { - nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - NUTAG_MEDIA_ENABLE(0), - SIPTAG_CONTENT_TYPE_STR("application/sdp"), - SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), - TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); - } - if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) { - /* Unlock the session signal to allow the ack to make it in */ - // Maybe we should timeout? - switch_mutex_unlock(tech_pvt->sofia_mutex); - - while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) { - switch_cond_next(); + } else { + sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE); } - /* Regain lock on sofia */ - switch_mutex_lock(tech_pvt->sofia_mutex); + if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + sofia_glue_tech_patch_sdp(tech_pvt); + sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); + } + if (sofia_use_soa(tech_pvt)) { + nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), + SOATAG_REUSE_REJECTED(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_END()); + } else { + nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + NUTAG_MEDIA_ENABLE(0), + SIPTAG_CONTENT_TYPE_STR("application/sdp"), + SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); + } + if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) { + /* Unlock the session signal to allow the ack to make it in */ + // Maybe we should timeout? + switch_mutex_unlock(tech_pvt->sofia_mutex); + + while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) { + switch_cond_next(); + } + + /* Regain lock on sofia */ + switch_mutex_lock(tech_pvt->sofia_mutex); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n"); - sofia_clear_flag(tech_pvt, TFLAG_3PCC); - sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK); - switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER); - } - } else { - nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); - } - switch_safe_free(extra_headers); - } - } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n"); + sofia_clear_flag(tech_pvt, TFLAG_3PCC); + sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK); + switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER); + } + } else { + if (msg->numeric_arg) { + if (code > 399) { + switch_call_cause_t cause = sofia_glue_sip_cause_to_freeswitch(code); + if (code == 401 || cause == 407) cause = SWITCH_CAUSE_USER_CHALLENGE; + tech_pvt->respond_code = code; + tech_pvt->respond_phrase = switch_core_session_strdup(tech_pvt->session, reason); + switch_channel_hangup(tech_pvt->channel, cause); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot respond.\n"); + } + } else { + nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); + } + + } + switch_safe_free(extra_headers); + } + } + + } } break; case SWITCH_MESSAGE_INDICATE_RINGING: @@ -2707,6 +2830,7 @@ struct cb_helper { uint32_t row_process; sofia_profile_t *profile; switch_stream_handle_t *stream; + switch_bool_t dedup; }; @@ -2971,6 +3095,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "NOMEDIA \t%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false"); stream->write_function(stream, "LATE-NEG \t%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false"); stream->write_function(stream, "PROXY-MEDIA \t%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false"); + stream->write_function(stream, "ZRTP-PASSTHRU \t%s\n", sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU) ? "true" : "false"); stream->write_function(stream, "AGGRESSIVENAT \t%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false"); stream->write_function(stream, "STUN-ENABLED \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false"); @@ -3249,6 +3374,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false"); stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false"); stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false"); + stream->write_function(stream, " %s\n", sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU) ? "true" : "false"); stream->write_function(stream, " %s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false"); stream->write_function(stream, " %s\n", @@ -3534,13 +3660,14 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t if (!strcasecmp(argv[1], "recover")) { if (argv[2] && !strcasecmp(argv[2], "flush")) { sofia_glue_profile_recover(profile, SWITCH_TRUE); + stream->write_function(stream, "Flushing recovery database.\n"); } else { int x = sofia_glue_profile_recover(profile, SWITCH_FALSE); if (x) { - stream->write_function(stream, "Recovered %d call(s)\n", x); + stream->write_function(stream, "Recovered %d session(s)\n", x); } else { - stream->write_function(stream, "No calls to recover.\n"); + stream->write_function(stream, "No sessions to recover.\n"); } } @@ -3614,6 +3741,17 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t if (!strcasecmp(argv[1], "stop")) { sofia_clear_pflag_locked(profile, PFLAG_RUNNING); + if (argv[2] && !strcasecmp(argv[2], "wait")) { + int loops = 20 * 2; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for %s to finish SIP transactions.\n", profile->name); + while (!sofia_test_pflag(profile, PFLAG_SHUTDOWN)) { + switch_yield(500000); + if (!--loops) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timeout Waiting for %s to finish SIP transactions.\n", profile->name); + break; + } + } + } stream->write_function(stream, "stopping: %s", profile->name); } else { sofia_set_pflag_locked(profile, PFLAG_RESPAWN); @@ -3686,11 +3824,22 @@ static int contact_callback(void *pArg, int argc, char **argv, char **columnName { struct cb_helper *cb = (struct cb_helper *) pArg; char *contact; - + cb->row_process++; - + if (!zstr(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1))) { - cb->stream->write_function(cb->stream, "%ssofia/%s/sip:%s,", argv[2], argv[1], sofia_glue_strip_proto(contact)); + if (cb->dedup) { + char *tmp = switch_mprintf("%ssofia/%s/sip:%s", argv[2], argv[1], sofia_glue_strip_proto(contact)); + + if (!strstr((char *)cb->stream->data, tmp)) { + cb->stream->write_function(cb->stream, "%s,", tmp); + } + + free(tmp); + + } else { + cb->stream->write_function(cb->stream, "%ssofia/%s/sip:%s,", argv[2], argv[1], sofia_glue_strip_proto(contact)); + } free(contact); } @@ -3893,7 +4042,8 @@ static void select_from_profile(sofia_profile_t *profile, const char *domain, const char *concat, const char *exclude_contact, - switch_stream_handle_t *stream) + switch_stream_handle_t *stream, + switch_bool_t dedup) { struct cb_helper cb; char *sql; @@ -3902,15 +4052,16 @@ static void select_from_profile(sofia_profile_t *profile, cb.profile = profile; cb.stream = stream; + cb.dedup = dedup; if (exclude_contact) { sql = switch_mprintf("select contact, profile_name, '%q' " - "from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%') " - "and contact not like '%%%s%%'", (concat != NULL) ? concat : "", user, domain, domain, exclude_contact); + "from sip_registrations where profile_name='%q' and sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%') " + "and contact not like '%%%s%%'", (concat != NULL) ? concat : "", profile->name, user, domain, domain, exclude_contact); } else { sql = switch_mprintf("select contact, profile_name, '%q' " - "from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')", - (concat != NULL) ? concat : "", user, domain, domain); + "from sip_registrations where profile_name='%q' and sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')", + (concat != NULL) ? concat : "", profile->name, user, domain, domain); } switch_assert(sql); @@ -3995,7 +4146,7 @@ SWITCH_STANDARD_API(sofia_contact_function) domain = profile->domain_name; } - select_from_profile(profile, user, domain, concat, exclude_contact, &mystream); + select_from_profile(profile, user, domain, concat, exclude_contact, &mystream, SWITCH_FALSE); sofia_glue_release_profile(profile); } else if (!zstr(domain)) { @@ -4008,7 +4159,7 @@ SWITCH_STANDARD_API(sofia_contact_function) for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, &var, NULL, &val); if ((profile = (sofia_profile_t *) val) && !strcmp((char *)var, profile->name)) { - select_from_profile(profile, user, domain, concat, exclude_contact, &mystream); + select_from_profile(profile, user, domain, concat, exclude_contact, &mystream, SWITCH_TRUE); profile = NULL; } } @@ -4103,7 +4254,7 @@ SWITCH_STANDARD_API(sofia_function) "sofia global siptrace \n" "sofia capture \n" " watchdog \n\n" - "sofia profile [start | stop | restart | rescan]\n" + "sofia profile [start | stop | restart | rescan] [wait]\n" " flush_inbound_reg [ | <[user]@domain>] [reboot]\n" " check_sync [ | <[user]@domain>]\n" " [register | unregister] [ | all]\n" @@ -4349,12 +4500,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session goto error; } - if (!(tech_pvt = (struct private_object *) switch_core_session_alloc(nsession, sizeof(*tech_pvt)))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error Creating Session\n"); - goto error; - } - switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession)); - switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession)); + tech_pvt = sofia_glue_new_pvt(nsession); data = switch_core_session_strdup(nsession, outbound_profile->destination_number); if ((dest_to = strchr(data, '^'))) { @@ -4469,9 +4615,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session dest_to = NULL; } } - + if (params) { tech_pvt->invite_contact = switch_core_session_sprintf(nsession, "%s;%s", gateway_ptr->register_contact, params); + tech_pvt->dest = switch_core_session_sprintf(nsession, "%s;%s", tech_pvt->dest, params); } else { tech_pvt->invite_contact = switch_core_session_strdup(nsession, gateway_ptr->register_contact); } @@ -4502,15 +4649,6 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session switch_channel_set_variable(nchannel, "sip_route_uri", gateway_ptr->outbound_sticky_proxy); } - if (gateway_ptr->ob_vars) { - switch_event_header_t *hp; - for (hp = gateway_ptr->ob_vars->headers; hp; hp = hp->next) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s setting variable [%s]=[%s]\n", - switch_channel_get_name(nchannel), hp->name, hp->value); - switch_channel_set_variable(nchannel, hp->name, hp->value); - } - } - } else { if (!(dest = strchr(profile_name, '/'))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid URL\n"); @@ -4671,8 +4809,27 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session not_const = (char *) caller_profile->caller_id_number; caller_profile->caller_id_number = switch_sanitize_number(not_const); + //caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest_num); switch_channel_set_caller_profile(nchannel, caller_profile); + + + if (gateway_ptr && gateway_ptr->ob_vars) { + switch_event_header_t *hp; + for (hp = gateway_ptr->ob_vars->headers; hp; hp = hp->next) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s setting variable [%s]=[%s]\n", + switch_channel_get_name(nchannel), hp->name, hp->value); + if (!strncmp(hp->name, "p:", 2)) { + switch_channel_set_profile_var(nchannel, hp->name + 2, hp->value); + } else { + switch_channel_set_variable(nchannel, hp->name, hp->value); + } + } + } + + + + sofia_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); sofia_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION); if (switch_channel_get_state(nchannel) == CS_NEW) { @@ -4748,6 +4905,17 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session sofia_clear_flag(ctech_pvt, TFLAG_ENABLE_SOA); } + if (switch_channel_test_flag(o_channel, CF_ZRTP_PASSTHRU_REQ)) { + const char *x = NULL; + sofia_glue_pass_zrtp_hash2(session, nsession); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[zrtp_passthru] Setting a-leg inherit_codec=true\n"); + switch_channel_set_variable(o_channel, "inherit_codec", "true"); + if ((x = switch_channel_get_variable(o_channel, "ep_codec_string"))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[zrtp_passthru] Setting b-leg absolute_codec_string='%s'\n", x); + switch_channel_set_variable(nchannel, "absolute_codec_string", x); + } + } + /* SNARK: lets copy this across so we can see if we're the other leg of 3PCC + bypass_media... */ if (sofia_test_flag(ctech_pvt, TFLAG_3PCC) && (switch_channel_test_flag(o_channel, CF_PROXY_MODE) || switch_channel_test_flag(o_channel, CF_PROXY_MEDIA))) { sofia_set_flag(tech_pvt, TFLAG_3PCC_INVITE); @@ -4869,6 +5037,8 @@ static void general_event_handler(switch_event_t *event) const char *body = switch_event_get_body(event); const char *to_uri = switch_event_get_header(event, "to-uri"); const char *from_uri = switch_event_get_header(event, "from-uri"); + const char *extra_headers = switch_event_get_header(event, "extra-headers"); + sofia_profile_t *profile; @@ -4927,7 +5097,8 @@ static void general_event_handler(switch_event_t *event) nua_notify(nh, NUTAG_NEWSUB(1), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), - SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); + SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); switch_safe_free(route_uri); @@ -4990,21 +5161,23 @@ static void general_event_handler(switch_event_t *event) const char *user = switch_event_get_header(event, "user"); const char *host = switch_event_get_header(event, "host"); const char *subject = switch_event_get_header(event, "subject"); + const char *uuid = switch_event_get_header(event, "uuid"); const char *body = switch_event_get_body(event); + sofia_profile_t *profile; nua_handle_t *nh; - - if (profile_name && ct && user && host) { + + 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 = 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; @@ -5013,7 +5186,7 @@ static void general_event_handler(switch_event_t *event) id = switch_mprintf("sip:%s@%s", user, host); switch_assert(id); - + for (m = list->head; m; m = m->next) { contact = sofia_glue_get_url_from_contact(m->val, 0); @@ -5032,8 +5205,19 @@ static void general_event_handler(switch_event_t *event) switch_console_free_matches(&list); sofia_glue_release_profile(profile); - } + } else if (uuid && ct) { + switch_core_session_t *session; + private_object_t *tech_pvt; + if ((session = switch_core_session_locate(uuid))) { + if ((tech_pvt = switch_core_session_get_private(session))) { + nua_message(tech_pvt->nh, + SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), + TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_IF(!zstr(subject), SIPTAG_SUBJECT_STR(subject)), TAG_END()); + } + switch_core_session_rwunlock(session); + } + } } break; case SWITCH_EVENT_SEND_INFO: @@ -5335,13 +5519,52 @@ static switch_status_t list_profile_gateway(const char *line, const char *cursor return status; } +SWITCH_STANDARD_APP(sofia_sla_function) +{ + private_object_t *tech_pvt; + switch_core_session_t *bargee_session; + + if (zstr(data)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: \n"); + return; + } + + if ((bargee_session = switch_core_session_locate((char *)data))) { + if (bargee_session == session) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "BARGE: %s (cannot barge on myself)\n", (char *) data); + } else { + switch_channel_t *channel; + + if (switch_core_session_check_interface(bargee_session, sofia_endpoint_interface)) { + tech_pvt = switch_core_session_get_private(bargee_session); + sofia_clear_flag(tech_pvt, TFLAG_SLA_BARGING); + sofia_set_flag(tech_pvt, TFLAG_SLA_BARGE); + switch_ivr_transfer_variable(bargee_session, session, SWITCH_SIGNAL_BOND_VARIABLE); + } + + if (switch_core_session_check_interface(session, sofia_endpoint_interface)) { + tech_pvt = switch_core_session_get_private(session); + sofia_set_flag(tech_pvt, TFLAG_SLA_BARGING); + } + + channel = switch_core_session_get_channel(session); + switch_channel_set_variable(channel, "sip_barging_uuid", (char *)data); + + } + + switch_core_session_rwunlock(bargee_session); + } + + switch_ivr_eavesdrop_session(session, data, NULL, ED_MUX_READ | ED_MUX_WRITE | ED_COPY_DISPLAY); +} + SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) { switch_chat_interface_t *chat_interface; switch_api_interface_t *api_interface; switch_management_interface_t *management_interface; - uint32_t cpus = switch_core_cpu_count(); + switch_application_interface_t *app_interface; struct in_addr in; memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals)); @@ -5369,7 +5592,22 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) mod_sofia_globals.auto_nat = (switch_nat_get_type() ? 1 : 0); switch_queue_create(&mod_sofia_globals.presence_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool); - switch_queue_create(&mod_sofia_globals.mwi_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool); + + mod_sofia_globals.cpu_count = switch_core_cpu_count(); + mod_sofia_globals.max_msg_queues = (mod_sofia_globals.cpu_count / 2) + 1; + if (mod_sofia_globals.max_msg_queues < 2) { + mod_sofia_globals.max_msg_queues = 2; + } + + if (mod_sofia_globals.max_msg_queues > SOFIA_MAX_MSG_QUEUE) { + mod_sofia_globals.max_msg_queues = SOFIA_MAX_MSG_QUEUE; + } + + switch_queue_create(&mod_sofia_globals.msg_queue, SOFIA_MSG_QUEUE_SIZE * mod_sofia_globals.max_msg_queues, mod_sofia_globals.pool); + + /* start one message thread */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Starting initial message thread.\n"); + sofia_msg_thread_start(0); if (config_sofia(0, NULL) != SWITCH_STATUS_SUCCESS) { mod_sofia_globals.running = 0; @@ -5379,48 +5617,42 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for profiles to start\n"); switch_yield(1500000); - /* start one message thread per cpu */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Starting %u message threads.\n", cpus); - sofia_msg_thread_start(cpus); - - if (switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL, - &mod_sofia_globals.custom_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_TERM; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, - &mod_sofia_globals.in_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_CONFERENCE_DATA, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, - &mod_sofia_globals.out_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, - &mod_sofia_globals.probe_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL, - &mod_sofia_globals.roster_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_WAITING, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_mwi_event_handler, NULL, - &mod_sofia_globals.mwi_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY, sofia_glue_track_event_handler, NULL, - &mod_sofia_globals.recovery_node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_MESSAGE_WAITING, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } @@ -5451,11 +5683,16 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) sofia_endpoint_interface->interface_name = "sofia"; sofia_endpoint_interface->io_routines = &sofia_io_routines; sofia_endpoint_interface->state_handler = &sofia_event_handlers; + sofia_endpoint_interface->recover_callback = sofia_recover_callback; management_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_MANAGEMENT_INTERFACE); management_interface->relative_oid = "1001"; management_interface->management_function = sofia_manage; + SWITCH_ADD_APP(app_interface, "sofia_sla", "private sofia sla function", + "private sofia sla function", sofia_sla_function, "", SAF_NONE); + + SWITCH_ADD_API(api_interface, "sofia", "Sofia Controls", sofia_function, " "); SWITCH_ADD_API(api_interface, "sofia_gateway_data", "Get data from a sofia gateway", sofia_gateway_data_function, " [ivar|ovar|var] "); @@ -5476,9 +5713,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_console_set_complete("add sofia profile"); switch_console_set_complete("add sofia profile restart all"); - + switch_console_set_complete("add sofia profile ::sofia::list_profiles start"); - switch_console_set_complete("add sofia profile ::sofia::list_profiles stop"); + switch_console_set_complete("add sofia profile ::sofia::list_profiles stop wait"); switch_console_set_complete("add sofia profile ::sofia::list_profiles rescan"); switch_console_set_complete("add sofia profile ::sofia::list_profiles restart"); @@ -5515,6 +5752,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) SWITCH_ADD_API(api_interface, "sofia_dig", "SIP DIG", sip_dig_function, ""); SWITCH_ADD_CHAT(chat_interface, SOFIA_CHAT_PROTO, sofia_presence_chat_send); + crtp_init(*module_interface); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } @@ -5534,14 +5773,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) } switch_mutex_unlock(mod_sofia_globals.mutex); - switch_event_unbind(&mod_sofia_globals.in_node); - switch_event_unbind(&mod_sofia_globals.probe_node); - switch_event_unbind(&mod_sofia_globals.out_node); - switch_event_unbind(&mod_sofia_globals.roster_node); - switch_event_unbind(&mod_sofia_globals.custom_node); - switch_event_unbind(&mod_sofia_globals.mwi_node); - switch_event_unbind(&mod_sofia_globals.recovery_node); + switch_event_unbind_callback(sofia_presence_event_handler); + switch_event_unbind_callback(general_event_handler); + switch_event_unbind_callback(event_handler); + + switch_queue_push(mod_sofia_globals.presence_queue, NULL); while (mod_sofia_globals.threads) { switch_cond_next(); @@ -5551,11 +5788,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) } - for (i = 0; i < mod_sofia_globals.msg_queue_len; i++) { - switch_queue_push(mod_sofia_globals.msg_queue[i], NULL); + for (i = 0; mod_sofia_globals.msg_queue_thread[i]; i++) { + switch_queue_push(mod_sofia_globals.msg_queue, NULL); } - for (i = 0; i < mod_sofia_globals.msg_queue_len; i++) { + + for (i = 0; mod_sofia_globals.msg_queue_thread[i]; i++) { switch_status_t st; switch_thread_join(&st, mod_sofia_globals.msg_queue_thread[i]); } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 730b592187..7d6659cdfc 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -28,6 +28,7 @@ * Paul D. Tinsley * Bret McDanel * Marcel Barbulescu + * Raymond Chandler * * * mod_sofia.h -- SOFIA SIP Endpoint @@ -36,6 +37,7 @@ /*Defines etc..*/ /*************************************************************************************************************************************************************/ +#define SOFIA_RECOVER "sofia" #define MANUAL_BYE 1 #define SQL_CACHE_TIMEOUT 300 #define DEFAULT_NONCE_TTL 60 @@ -89,10 +91,11 @@ typedef struct private_object private_object_t; #define MY_EVENT_RECOVERY "sofia::recovery_recv" #define MY_EVENT_RECOVERY_SEND "sofia::recovery_send" #define MY_EVENT_RECOVERY_RECOVERED "sofia::recovery_recovered" +#define MY_EVENT_ERROR "sofia::error" #define MULTICAST_EVENT "multicast::event" #define SOFIA_REPLACES_HEADER "_sofia_replaces_" -#define SOFIA_USER_AGENT "FreeSWITCH-mod_sofia/" SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO "-" SWITCH_VERSION_REVISION +#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_" @@ -151,6 +154,9 @@ typedef struct sofia_dispatch_event_s { sofia_profile_t *profile; int save; switch_core_session_t *session; + switch_core_session_t *init_session; + switch_memory_pool_t *pool; + struct sofia_dispatch_event_s *next; } sofia_dispatch_event_t; struct sofia_private { @@ -162,7 +168,6 @@ struct sofia_private { int destroy_me; int is_call; int is_static; - sofia_dispatch_event_t *de; }; #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);} @@ -242,7 +247,6 @@ typedef enum { PFLAG_LOG_AUTH_FAIL, PFLAG_FORWARD_MWI_NOTIFY, PFLAG_TRACK_CALLS, - PFLAG_TRACK_CALLS_EVENTS, PFLAG_DESTROY, PFLAG_EXTENDED_INFO_PARSING, PFLAG_T38_PASSTHRU, @@ -264,6 +268,10 @@ typedef enum { PFLAG_PRESENCE_MAP, PFLAG_OPTIONS_RESPOND_503_ON_BUSY, PFLAG_PRESENCE_DISABLE_EARLY, + PFLAG_CONFIRM_BLIND_TRANSFER, + PFLAG_THREAD_PER_REG, + PFLAG_MWI_USE_REG_CALLID, + PFLAG_FIRE_MESSAGE_EVENTS, /* No new flags below this line */ PFLAG_MAX } PFLAGS; @@ -273,7 +281,8 @@ typedef enum { PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1), PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2), PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3), - PFLAG_NDLB_ALLOW_NONDUP_SDP = (1 << 4) + PFLAG_NDLB_ALLOW_NONDUP_SDP = (1 << 4), + PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP = (1 << 5) } sofia_NDLB_t; typedef enum { @@ -313,14 +322,12 @@ typedef enum { TFLAG_TPORT_LOG, TFLAG_SENT_UPDATE, TFLAG_PROXY_MEDIA, + TFLAG_ZRTP_PASSTHRU, TFLAG_HOLD_LOCK, TFLAG_3PCC_HAS_ACK, TFLAG_PASS_RFC2833, TFLAG_UPDATING_DISPLAY, TFLAG_ENABLE_SOA, - TFLAG_TRACKED, - TFLAG_RECOVERING, - TFLAG_RECOVERING_BRIDGE, TFLAG_T38_PASSTHRU, TFLAG_RECOVERED, TFLAG_AUTOFLUSH_DURING_BRIDGE, @@ -331,12 +338,15 @@ typedef enum { TFLAG_LIBERAL_DTMF, TFLAG_GOT_ACK, TFLAG_CAPTURE, + TFLAG_REINVITED, + TFLAG_SLA_BARGE, + TFLAG_SLA_BARGING, /* No new flags below this line */ TFLAG_MAX } TFLAGS; -#define SOFIA_MAX_MSG_QUEUE 101 -#define SOFIA_MSG_QUEUE_SIZE 5000 +#define SOFIA_MAX_MSG_QUEUE 64 +#define SOFIA_MSG_QUEUE_SIZE 1000 struct mod_sofia_globals { switch_memory_pool_t *pool; @@ -346,23 +356,17 @@ struct mod_sofia_globals { uint32_t callid; int32_t running; int32_t threads; + int cpu_count; + int max_msg_queues; switch_mutex_t *mutex; char guess_ip[80]; char hostname[512]; switch_queue_t *presence_queue; - switch_queue_t *mwi_queue; - switch_queue_t *msg_queue[SOFIA_MAX_MSG_QUEUE]; + switch_queue_t *msg_queue; switch_thread_t *msg_queue_thread[SOFIA_MAX_MSG_QUEUE]; int msg_queue_len; struct sofia_private destroy_private; struct sofia_private keep_private; - switch_event_node_t *in_node; - switch_event_node_t *probe_node; - switch_event_node_t *out_node; - switch_event_node_t *roster_node; - switch_event_node_t *custom_node; - switch_event_node_t *mwi_node; - switch_event_node_t *recovery_node; int guess_mask; char guess_mask_str[16]; int debug_presence; @@ -433,9 +437,11 @@ typedef enum { struct sofia_gateway_subscription { sofia_gateway_t *gateway; + nua_handle_t *nh; char *expires_str; char *event; /* eg, 'message-summary' to subscribe to MWI events */ char *content_type; /* eg, application/simple-message-summary in the case of MWI events */ + char *request_uri; uint32_t freq; int32_t retry_seconds; time_t expires; @@ -447,7 +453,6 @@ struct sofia_gateway_subscription { struct sofia_gateway { sofia_private_t *sofia_private; nua_handle_t *nh; - nua_handle_t *sub_nh; sofia_profile_t *profile; char *name; char *register_scheme; @@ -486,7 +491,6 @@ struct sofia_gateway { int32_t retry_seconds; int32_t reg_timeout_seconds; int32_t failure_status; - sub_state_t sub_state; reg_state_t state; switch_memory_pool_t *pool; int deleted; @@ -507,7 +511,8 @@ struct sofia_gateway { typedef enum { PRES_TYPE_NONE = 0, PRES_TYPE_FULL = 1, - PRES_TYPE_PASSIVE = 2 + PRES_TYPE_PASSIVE = 2, + PRES_TYPE_PNP = 3 } sofia_presence_type_t; typedef enum { @@ -576,12 +581,15 @@ struct sofia_profile { char *rtcp_audio_interval_msec; char *rtcp_video_interval_msec; char *jb_msec; + char *pnp_prov_url; + char *pnp_notify_profile; sofia_cid_type_t cid_type; sofia_dtmf_t dtmf_type; int auto_restart; switch_port_t sip_port; switch_port_t tls_sip_port; int tls_version; + unsigned int tls_timeout; char *inbound_codec_string; char *outbound_codec_string; int running; @@ -604,6 +612,7 @@ struct sofia_profile { sofia_gateway_t *gateways; //su_home_t *home; switch_hash_t *chat_hash; + switch_hash_t *mwi_debounce_hash; //switch_core_db_t *master_db; switch_thread_rwlock_t *rwlock; switch_mutex_t *flag_mutex; @@ -815,6 +824,14 @@ struct private_object { switch_payload_t ianacodes[SWITCH_MAX_CODECS]; uint32_t session_timeout; enum nua_session_refresher session_refresher; + /** ZRTP **/ + char *local_sdp_audio_zrtp_hash; + char *local_sdp_video_zrtp_hash; + char *remote_sdp_audio_zrtp_hash; + char *remote_sdp_video_zrtp_hash; + char *respond_phrase; + int respond_code; + char *respond_dest; }; struct callback_t { @@ -902,8 +919,8 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]); -void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, - sofia_dispatch_event_t *de, tagi_t tags[]); +void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]); + void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, @@ -922,6 +939,8 @@ void launch_sofia_profile_thread(sofia_profile_t *profile); switch_status_t sofia_presence_chat_send(switch_event_t *message_event); void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt); +void sofia_glue_pass_zrtp_hash2(switch_core_session_t *aleg_session, switch_core_session_t *bleg_session); +void sofia_glue_pass_zrtp_hash(switch_core_session_t *session); /* * \brief Sets the "ep_codec_string" channel variable, parsing r_sdp and taing codec_string in consideration @@ -934,8 +953,8 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const char *host, char *val, switch_size_t len); void event_handler(switch_event_t *event); void sofia_presence_event_handler(switch_event_t *event); -void sofia_presence_mwi_event_handler(switch_event_t *event); -void sofia_glue_track_event_handler(switch_event_t *event); + + void sofia_presence_cancel(void); switch_status_t config_sofia(int reload, char *profile_name); void sofia_reg_auth_challenge(sofia_profile_t *profile, nua_handle_t *nh, sofia_dispatch_event_t *de, @@ -964,7 +983,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n sofia_dispatch_event_t *de, tagi_t tags[]); void sofia_presence_handle_sip_i_message(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, - sofia_private_t *sofia_private, sip_t const *sip, + switch_core_session_t *session, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]); void sofia_presence_handle_sip_r_subscribe(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, @@ -1093,7 +1112,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile); void sofia_glue_del_gateway(sofia_gateway_t *gp); void sofia_glue_gateway_list(sofia_profile_t *profile, switch_stream_handle_t *stream, int up); void sofia_glue_del_every_gateway(sofia_profile_t *profile); -void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, +void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip); void sofia_glue_restart_all_profiles(void); int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly); @@ -1131,7 +1150,7 @@ void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port); sofia_destination_t *sofia_glue_get_destination(char *data); void sofia_glue_free_destination(sofia_destination_t *dst); switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, - const char *body, const char *o_contact, const char *network_ip); + const char *body, const char *o_contact, const char *network_ip, const char *call_id); char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix); void sofia_glue_set_extra_headers(switch_core_session_t *session, sip_t const *sip, const char *prefix); char *sofia_glue_get_extra_headers_from_event(switch_event_t *event, const char *prefix); @@ -1139,8 +1158,6 @@ void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *profile, sip_t const *sip, switch_bool_t send); void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number); int sofia_sla_supported(sip_t const *sip); -void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *session, switch_bool_t force); -void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *session); int sofia_glue_recover(switch_bool_t flush); int sofia_glue_profile_recover(sofia_profile_t *profile, switch_bool_t flush); void sofia_profile_destroy(sofia_profile_t *profile); @@ -1169,3 +1186,18 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep); char *sofia_glue_get_host(const char *str, switch_memory_pool_t *pool); void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now); void sofia_msg_thread_start(int idx); +void crtp_init(switch_loadable_module_interface_t *module_interface); +int sofia_recover_callback(switch_core_session_t *session); +void sofia_glue_set_name(private_object_t *tech_pvt, const char *channame); +private_object_t *sofia_glue_new_pvt(switch_core_session_t *session); + +/* 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: + */ diff --git a/src/mod/endpoints/mod_sofia/rtp.c b/src/mod/endpoints/mod_sofia/rtp.c new file mode 100644 index 0000000000..b807cf962b --- /dev/null +++ b/src/mod/endpoints/mod_sofia/rtp.c @@ -0,0 +1,667 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2011, Anthony Minessale II + * + * 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 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): + * + * Mathieu Rene + * + * rtp.c -- RTP Controllable Channel Module + * + */ + +#include +#include "mod_sofia.h" + +#define kLOCALADDR "local_addr" +#define kLOCALPORT "local_port" +#define kREMOTEADDR "remote_addr" +#define kREMOTEPORT "remote_port" +#define kCODEC "codec" +#define kPTIME "ptime" +#define kPT "pt" +#define kRFC2833PT "rfc2833_pt" +#define kMODE "mode" +#define kRATE "rate" + +static struct { + switch_memory_pool_t *pool; + switch_endpoint_interface_t *endpoint_interface; +} crtp; + +typedef struct { + switch_core_session_t *session; + switch_channel_t *channel; + switch_codec_t read_codec, write_codec; + switch_frame_t read_frame; + + + + switch_rtp_bug_flag_t rtp_bugs; + switch_rtp_t *rtp_session; + + uint32_t timestamp_send; + + const char *local_address; + const char *remote_address; + const char *codec; + int ptime; + + const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS]; + int num_negotiated_codecs; + + char *origin; + + switch_port_t local_port; + switch_port_t remote_port; + switch_payload_t agreed_pt; /*XXX*/ + sofia_dtmf_t dtmf_type; + enum { + RTP_SENDONLY, + RTP_RECVONLY, + RTP_SENDRECV + } mode; +} crtp_private_t; + +static switch_status_t channel_on_init(switch_core_session_t *session); +static switch_status_t channel_on_destroy(switch_core_session_t *session); +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, + switch_memory_pool_t **pool, + switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); +static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); +static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); +static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg); +static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf); +static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event); + +switch_state_handler_table_t crtp_state_handlers = { + /*on_init */channel_on_init, + /*on_routing */ NULL, + /*on_execute */ NULL, + /*on_hangup*/ NULL, + /*on_exchange_media*/ NULL, + /*on_soft_execute*/ NULL, + /*on_consume_media*/ NULL, + /*on_hibernate*/ NULL, + /*on_reset*/ NULL, + /*on_park*/ NULL, + /*on_reporting*/ NULL, + /*on_destroy*/ channel_on_destroy + +}; + +switch_io_routines_t crtp_io_routines = { + /*outgoing_channel*/ channel_outgoing_channel, + /*read_frame*/ channel_read_frame, + /*write_frame*/ channel_write_frame, + /*kill_channel*/ NULL, + /*send_dtmf*/ channel_send_dtmf, + /*receive_message*/ channel_receive_message, + /*receive_event*/ channel_receive_event, + /*state_change*/ NULL, + /*read_video_frame*/ NULL, + /*write_video_frame*/ NULL, + /*state_run*/ NULL + + +}; + + +void crtp_init(switch_loadable_module_interface_t *module_interface) +{ + switch_endpoint_interface_t *endpoint_interface; + //switch_api_interface_t *api_interface; + + crtp.pool = module_interface->pool; + endpoint_interface = switch_loadable_module_create_interface(module_interface, SWITCH_ENDPOINT_INTERFACE); + endpoint_interface->interface_name = "rtp"; + endpoint_interface->io_routines = &crtp_io_routines; + endpoint_interface->state_handler = &crtp_state_handlers; + crtp.endpoint_interface = endpoint_interface; + + //SWITCH_ADD_API(api_interface, "rtp_test", "test", test_function, ""); +} + +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, + switch_memory_pool_t **pool, + switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) +{ + switch_channel_t *channel; + char name[128]; + crtp_private_t *tech_pvt = NULL; + switch_caller_profile_t *caller_profile; + + const char *err; + + + const char *local_addr = switch_event_get_header_nil(var_event, kLOCALADDR), + *szlocal_port = switch_event_get_header_nil(var_event, kLOCALPORT), + *remote_addr = switch_event_get_header_nil(var_event, kREMOTEADDR), + *szremote_port = switch_event_get_header_nil(var_event, kREMOTEPORT), + *codec = switch_event_get_header_nil(var_event, kCODEC), + *szptime = switch_event_get_header_nil(var_event, kPTIME), + //*mode = switch_event_get_header_nil(var_event, kMODE), + //*szrfc2833_pt = switch_event_get_header_nil(var_event, kRFC2833PT), + *szrate = switch_event_get_header_nil(var_event, kRATE), + *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; + + int ptime = !zstr(szptime) ? atoi(szptime) : 0, + //rfc2833_pt = !zstr(szrfc2833_pt) ? atoi(szrfc2833_pt) : 0, + rate = !zstr(szrate) ? atoi(szrate) : 8000, + pt = !zstr(szpt) ? atoi(szpt) : 0; + + if ( + ((zstr(remote_addr) || remote_port == 0) && (zstr(local_addr) || local_port == 0)) || + zstr(codec) || + zstr(szpt)) { + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required arguments\n"); + goto fail; + } + + + if (!(*new_session = switch_core_session_request(crtp.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't request session.\n"); + goto fail; + } + + channel = switch_core_session_get_channel(*new_session); + + tech_pvt = switch_core_session_alloc(*new_session, sizeof *tech_pvt); + tech_pvt->session = *new_session; + tech_pvt->channel = channel; + tech_pvt->local_address = switch_core_session_strdup(*new_session, local_addr); + tech_pvt->local_port = local_port; + 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->dtmf_type = DTMF_2833; /* XXX */ + + if (zstr(local_addr) || local_port == 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n"); + goto fail; + } else if (zstr(remote_addr) || remote_port == 0) { + tech_pvt->mode = RTP_RECVONLY; + } else { + tech_pvt->mode = RTP_SENDRECV; + } + + switch_core_session_set_private(*new_session, tech_pvt); + + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + + + snprintf(name, sizeof(name), "rtp/%s", outbound_profile->destination_number); + switch_channel_set_name(channel, name); + + switch_channel_set_state(channel, CS_INIT); + + if (switch_core_codec_init(&tech_pvt->read_codec, + codec, + NULL, + rate, + ptime, + 1, + /*SWITCH_CODEC_FLAG_ENCODE |*/ SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + goto fail; + } else { + if (switch_core_codec_init(&tech_pvt->write_codec, + codec, + NULL, + rate, + ptime, + 1, + SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + goto fail; + } + } + + if (switch_core_session_set_read_codec(*new_session, &tech_pvt->read_codec) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set read codec?\n"); + goto fail; + } + + if (switch_core_session_set_write_codec(*new_session, &tech_pvt->write_codec) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set write codec?\n"); + goto fail; + } + + if (!(tech_pvt->rtp_session = switch_rtp_new(local_addr, local_port, remote_addr, remote_port, tech_pvt->agreed_pt, + tech_pvt->read_codec.implementation->samples_per_packet, ptime * 1000, + flags, "soft", &err, switch_core_session_get_pool(*new_session)))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't setup RTP session: [%s]\n", err); + goto fail; + } + + if (switch_core_session_thread_launch(*new_session) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n"); + goto fail; + } + + switch_channel_mark_answered(channel); + + return SWITCH_CAUSE_SUCCESS; + +fail: + if (tech_pvt) { + if (tech_pvt->read_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (tech_pvt->write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + } + + if (*new_session) { + switch_core_session_destroy(new_session); + } + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; +} + +static switch_status_t channel_on_init(switch_core_session_t *session) +{ + + switch_channel_t *channel = switch_core_session_get_channel(session); + + switch_channel_set_state(channel, CS_CONSUME_MEDIA); + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t channel_on_destroy(switch_core_session_t *session) +{ + crtp_private_t *tech_pvt = switch_core_session_get_private(session); + + if ((tech_pvt = switch_core_session_get_private(session))) { + + if (tech_pvt->read_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (tech_pvt->write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + } + + return SWITCH_STATUS_SUCCESS; +} + + +static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) +{ + crtp_private_t *tech_pvt; + switch_channel_t *channel; + switch_status_t status; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_SENDONLY) { + switch_yield(20000); /* replace by local timer XXX */ + goto cng; + } + + if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) { + switch_dtmf_t dtmf = { 0 }; + switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf); + switch_channel_queue_dtmf(channel, &dtmf); + } + + tech_pvt->read_frame.flags = SFF_NONE; + tech_pvt->read_frame.codec = &tech_pvt->read_codec; + status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags); + + if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { + goto cng; + } + + *frame = &tech_pvt->read_frame; + return SWITCH_STATUS_SUCCESS; + +cng: + *frame = &tech_pvt->read_frame; + tech_pvt->read_frame.codec = &tech_pvt->read_codec; + tech_pvt->read_frame.flags |= SFF_CNG; + tech_pvt->read_frame.datalen = 0; + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) +{ + crtp_private_t *tech_pvt; + switch_channel_t *channel; + //int frames = 0, bytes = 0, samples = 0; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + +#if 0 + if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) { + if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) { + bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet; + frames = ((int) frame->datalen / bytes); + } else + frames = 1; + + samples = frames * tech_pvt->read_codec.implementation->samples_per_packet; + } + + tech_pvt->timestamp_send += samples; +#endif + if (tech_pvt->mode == RTP_RECVONLY) { + return SWITCH_STATUS_SUCCESS; + } + + switch_rtp_write_frame(tech_pvt->rtp_session, frame); + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) +{ + crtp_private_t *tech_pvt = NULL; + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch(tech_pvt->dtmf_type) { + case DTMF_2833: + { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Enqueuing RFC2833 DTMF %c of length %d\n", dtmf->digit, dtmf->duration); + return switch_rtp_queue_rfc2833(tech_pvt->rtp_session, dtmf); + } + case DTMF_NONE: + default: + { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding DTMF %c of length %d, DTMF type is NONE\n", dtmf->digit, dtmf->duration); + } + } + + return SWITCH_STATUS_SUCCESS; +} + +static switch_bool_t compare_var(switch_event_t *event, switch_channel_t *channel, const char *varname) +{ + const char *chan_val = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1); + const char *event_val = switch_event_get_header(event, varname); + + if (zstr(chan_val) || zstr(event_val)) { + return 1; + } + + return strcasecmp(chan_val, event_val); +} + +static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event) +{ + const char *command = switch_event_get_header(event, "command"); + switch_channel_t *channel = switch_core_session_get_channel(session); + crtp_private_t *tech_pvt = switch_core_session_get_private(session); + char *codec = switch_event_get_header_nil(event, kCODEC); + char *szptime = switch_event_get_header_nil(event, kPTIME); + char *szrate = switch_event_get_header_nil(event, kRATE); + char *szpt = switch_event_get_header_nil(event, kPT); + + int ptime = !zstr(szptime) ? atoi(szptime) : 0, + rate = !zstr(szrate) ? atoi(szrate) : 8000, + pt = !zstr(szpt) ? atoi(szpt) : 0; + + + if (!zstr(command) && !strcasecmp(command, "media_modify")) { + /* Compare parameters */ + if (compare_var(event, channel, kREMOTEADDR) || + 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; + const char *err; + + + switch_channel_set_variable(channel, kREMOTEADDR, remote_addr); + switch_channel_set_variable(channel, kREMOTEPORT, szremote_port); + + if (switch_rtp_set_remote_address(tech_pvt->rtp_session, remote_addr, remote_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set RTP remote: %s:%d\n", remote_addr, (int)remote_port); + tech_pvt->mode = RTP_SENDRECV; + } + } + + if (compare_var(event, channel, kCODEC) || + compare_var(event, channel, kPTIME) || + compare_var(event, channel, kPT) || + compare_var(event, channel, kRATE)) { + /* Reset codec */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec updating \n"); + + if (switch_core_codec_init(&tech_pvt->read_codec, + codec, + NULL, + rate, + ptime, + 1, + /*SWITCH_CODEC_FLAG_ENCODE |*/ SWITCH_CODEC_FLAG_DECODE, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + goto fail; + } else { + if (switch_core_codec_init(&tech_pvt->write_codec, + codec, + NULL, + rate, + ptime, + 1, + SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/, + NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + goto fail; + } + } + + if (switch_core_session_set_read_codec(session, &tech_pvt->read_codec) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set read codec?\n"); + goto fail; + } + + if (switch_core_session_set_write_codec(session, &tech_pvt->write_codec) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set write codec?\n"); + goto fail; + } + + switch_rtp_set_default_payload(tech_pvt->rtp_session, pt); + switch_rtp_set_recv_pt(tech_pvt->rtp_session, pt); + } + + if (compare_var(event, channel, kRFC2833PT)) { + const char *szpt = switch_channel_get_variable(channel, kRFC2833PT); + int pt = !zstr(szpt) ? atoi(szpt) : 0; + + switch_channel_set_variable(channel, kRFC2833PT, szpt); + switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt); + } + + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command); + } + + return SWITCH_STATUS_SUCCESS; +fail: + if (tech_pvt) { + if (tech_pvt->read_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (tech_pvt->write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + } + + if (session) { + switch_core_session_destroy(&session); + } + return SWITCH_STATUS_FALSE; + +} + +static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) +{ + crtp_private_t *tech_pvt = NULL; + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch (msg->message_id) { + case SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO: + { + if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { + int32_t flags = 0; + if (!strcasecmp(msg->string_array_arg[0], "read")) { + flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ; + } else if (!strcasecmp(msg->string_array_arg[0], "write")) { + flags |= SWITCH_RTP_FLAG_DEBUG_RTP_WRITE; + } else if (!strcasecmp(msg->string_array_arg[0], "both")) { + flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ | SWITCH_RTP_FLAG_DEBUG_RTP_WRITE; + } + + if (flags) { + if (switch_true(msg->string_array_arg[1])) { + switch_rtp_set_flag(tech_pvt->rtp_session, flags); + } else { + switch_rtp_clear_flag(tech_pvt->rtp_session, flags); + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Options\n"); + } + } + break; + } + case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: + if (switch_rtp_ready(tech_pvt->rtp_session)) { + rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_ONCE); + } + break; + case SWITCH_MESSAGE_INDICATE_JITTER_BUFFER: + { + if (switch_rtp_ready(tech_pvt->rtp_session)) { + int len = 0, maxlen = 0, qlen = 0, maxqlen = 50, max_drift = 0; + + if (msg->string_arg) { + char *p, *q; + const char *s; + + if (!strcasecmp(msg->string_arg, "pause")) { + switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE); + goto end; + } else if (!strcasecmp(msg->string_arg, "resume")) { + switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE); + goto end; + } else if (!strncasecmp(msg->string_arg, "debug:", 6)) { + s = msg->string_arg + 6; + if (s && !strcmp(s, "off")) { + s = NULL; + } + switch_rtp_debug_jitter_buffer(tech_pvt->rtp_session, s); + goto end; + } + + + if ((len = atoi(msg->string_arg))) { + qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000); + if (qlen < 1) { + qlen = 3; + } + } + + if (qlen) { + if ((p = strchr(msg->string_arg, ':'))) { + p++; + maxlen = atol(p); + if ((q = strchr(p, ':'))) { + q++; + max_drift = abs(atol(q)); + } + } + } + + + if (maxlen) { + maxqlen = maxlen / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000); + } + } + + if (qlen) { + if (maxqlen < qlen) { + maxqlen = qlen * 5; + } + if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, + tech_pvt->read_codec.implementation->samples_per_packet, + tech_pvt->read_codec.implementation->samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), + SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames) (%d max drift)\n", + len, qlen, maxqlen, max_drift); + switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER); + if (!switch_false(switch_channel_get_variable(tech_pvt->channel, "sip_jitter_buffer_plc"))) { + switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER_PLC); + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), + SWITCH_LOG_WARNING, "Error Setting Jitterbuffer to %dms (%d frames)\n", len, qlen); + } + + } else { + switch_rtp_deactivate_jitter_buffer(tech_pvt->rtp_session); + } + } + } + break; + + default: + break; + } +end: + return SWITCH_STATUS_SUCCESS; +} + diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 9614b1cba0..d132d15918 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -469,12 +469,33 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, 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 : ""); - switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "sip_content_type", sip->sip_content_type->c_type); + 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_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); + 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); + + 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; + hold = realloc(hold, cur_len); + switch_assert(hold); + strcat(hold,","); + strcat(hold, tmp); + free(tmp); + } + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Call-Info", hold); + free(hold); + } switch_event_fire(&s_event); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "dispatched freeswitch event for message-summary NOTIFY\n"); } else { @@ -578,6 +599,60 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, status = 200; phrase = "OK"; + if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGING)) { + const char *bargee_uuid = switch_channel_get_variable(channel, "sip_barging_uuid"); + switch_core_session_t *bargee_session; + uint32_t ttl = 0; + + if ((bargee_session = switch_core_session_locate(bargee_uuid))) { + //switch_channel_t *bargee_channel = switch_core_session_get_channel(bargee_session); + if ((ttl = switch_core_media_bug_count(bargee_session, "eavesdrop")) == 1) { + if (switch_core_session_check_interface(bargee_session, sofia_endpoint_interface)) { + private_object_t *bargee_tech_pvt = switch_core_session_get_private(bargee_session); + sofia_clear_flag(bargee_tech_pvt, TFLAG_SLA_BARGE); + } + } + switch_core_session_rwunlock(bargee_session); + } + } + + if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGE)) { + switch_core_session_t *new_session, *other_session; + const char *other_uuid = switch_channel_get_partner_uuid(tech_pvt->channel); + char *cmd = NULL; + + if (!zstr(other_uuid) && (other_session = switch_core_session_locate(other_uuid))) { + switch_channel_t *other_channel = switch_core_session_get_channel(other_session); + + switch_mutex_lock(profile->ireg_mutex); + if (switch_ivr_eavesdrop_pop_eavesdropper(session, &new_session) == SWITCH_STATUS_SUCCESS) { + switch_channel_t *new_channel = switch_core_session_get_channel(new_session); + const char *new_uuid = switch_core_session_get_uuid(new_session); + + + switch_channel_set_variable(new_channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL); + + switch_channel_set_flag(other_channel, CF_REDIRECT); + + switch_channel_set_state(new_channel, CS_RESET); + + switch_ivr_uuid_bridge(new_uuid, other_uuid); + cmd = switch_core_session_sprintf(session, "sleep:500,sofia_sla:%s inline", new_uuid); + + switch_channel_clear_flag(other_channel, CF_REDIRECT); + + switch_core_session_rwunlock(new_session); + } + switch_mutex_unlock(profile->ireg_mutex); + + switch_core_session_rwunlock(other_session); + } + + if (!zstr(cmd)) { + switch_ivr_eavesdrop_exec_all(session, "transfer", cmd); + } + } + sofia_set_flag_locked(tech_pvt, TFLAG_BYE); call_info = switch_channel_get_variable(channel, "presence_call_info_full"); @@ -670,6 +745,26 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, void sofia_handle_sip_r_message(int status, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip) { + const char *call_id; + int *mstatus; + + if (!(sip && sip->sip_call_id)) { + nua_handle_destroy(nh); + return; + } + + call_id = sip->sip_call_id->i_id; + + + + switch_mutex_lock(profile->flag_mutex); + mstatus = switch_core_hash_find(profile->chat_hash, call_id); + switch_mutex_unlock(profile->flag_mutex); + + if (mstatus) { + *mstatus = status; + } + } void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout) @@ -708,7 +803,7 @@ void sofia_send_callee_id(switch_core_session_t *session, const char *name, cons number = caller_profile->destination_number; } - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) { + if ((uuid = switch_channel_get_partner_uuid(channel)) && (session_b = switch_core_session_locate(uuid))) { switch_core_session_message_t *msg; //switch_channel_t *channel_b = switch_core_session_get_channel(session_b); @@ -805,6 +900,10 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro if ((tmp = switch_channel_get_variable(channel, "callee_id_number")) && !zstr(tmp)) { number = (char *) tmp; } + + if (zstr(number)) { + number = "unknown"; + } } if (zstr(name)) { @@ -817,7 +916,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro name = (char *) number; } - if (zstr(name) && zstr(number)) { + if (zstr(name) || zstr(number)) { goto end; } @@ -831,7 +930,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro caller_profile->callee_id_number = switch_sanitize_number(switch_core_strdup(caller_profile->pool, number)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Update Callee ID to \"%s\" <%s>\n", switch_channel_get_name(channel), name, number); - if (lazy || (att && !switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if (lazy || (att && !switch_channel_get_partner_uuid(channel))) { switch_channel_flip_cid(channel); } } @@ -839,7 +938,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro if (send) { if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) { - const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *uuid = switch_channel_get_partner_uuid(channel); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV"); if (uuid) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid); @@ -870,12 +969,6 @@ static void our_sofia_event_callback(nua_event_t event, int locked = 0; int check_destroy = 1; - if (sofia_private && sofia_private->is_call && sofia_private->de) { - sofia_dispatch_event_t *qde = sofia_private->de; - sofia_private->de = NULL; - sofia_process_dispatch_event(&qde); - } - profile->last_sip_event = switch_time_now(); /* sofia_private will be == &mod_sofia_globals.keep_private whenever a request is done with a new handle that has to be @@ -896,7 +989,9 @@ static void our_sofia_event_callback(nua_event_t event, return; } } else if (!zstr(sofia_private->uuid)) { - if ((session = de->session) || (session = switch_core_session_locate(sofia_private->uuid))) { + if ((session = de->init_session)) { + de->init_session = NULL; + } else if ((session = de->session) || (session = switch_core_session_locate(sofia_private->uuid))) { tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); if (tech_pvt) { @@ -933,20 +1028,6 @@ static void our_sofia_event_callback(nua_event_t event, } } - if ((event == nua_i_invite) && (!session)) { - uint32_t sess_count = switch_core_session_count(); - uint32_t sess_max = switch_core_session_limit(0); - - if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound()) { - nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); - - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No more sessions allowed at this time.\n"); - - goto done; - } - } - - if (sofia_test_pflag(profile, PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip && (event < nua_r_set_params || event > nua_r_authenticate)) { sip_authorization_t const *authorization = NULL; @@ -988,10 +1069,10 @@ static void our_sofia_event_callback(nua_event_t event, case nua_r_bye: case nua_r_unregister: case nua_r_unsubscribe: + case nua_i_terminated: case nua_r_publish: case nua_i_error: case nua_i_active: - case nua_i_terminated: case nua_r_set_params: case nua_i_prack: case nua_r_prack: @@ -999,16 +1080,19 @@ static void our_sofia_event_callback(nua_event_t event, case nua_i_cancel: - if (sip && channel && sip->sip_reason) { - char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason); + if (sip && channel) { + switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_cancel"); + + if (sip->sip_reason) { + char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason); - if (!zstr(reason_header)) { - switch_channel_set_variable_partner(channel, "sip_reason", reason_header); + if (!zstr(reason_header)) { + switch_channel_set_variable_partner(channel, "sip_reason", reason_header); + } } } break; - case nua_r_cancel: { if (status > 299 && nh) { @@ -1038,7 +1122,7 @@ static void our_sofia_event_callback(nua_event_t event, } extract_header_vars(profile, sip, session, nh); - sofia_glue_tech_track(tech_pvt->profile, session); + switch_core_recovery_track(session); sofia_set_flag(tech_pvt, TFLAG_GOT_ACK); } } @@ -1077,10 +1161,11 @@ static void our_sofia_event_callback(nua_event_t event, sofia_handle_sip_i_options(status, phrase, nua, profile, nh, sofia_private, sip, de, tags); break; case nua_i_invite: - if (session) { + if (session && sofia_private->is_call > 1) { sofia_handle_sip_i_reinvite(session, nua, profile, nh, sofia_private, sip, de, tags); } else { - sofia_handle_sip_i_invite(nua, profile, nh, sofia_private, sip, de, tags); + sofia_private->is_call++; + sofia_handle_sip_i_invite(session, nua, profile, nh, sofia_private, sip, de, tags); } break; case nua_i_publish: @@ -1095,7 +1180,7 @@ static void our_sofia_event_callback(nua_event_t event, sofia_handle_sip_i_state(session, status, phrase, nua, profile, nh, sofia_private, sip, de, tags); break; case nua_i_message: - sofia_presence_handle_sip_i_message(status, phrase, nua, profile, nh, sofia_private, sip, de, tags); + sofia_presence_handle_sip_i_message(status, phrase, nua, profile, nh, session, sofia_private, sip, de, tags); break; case nua_i_info: sofia_handle_sip_i_info(nua, profile, nh, session, sip, de, tags); @@ -1110,8 +1195,165 @@ static void our_sofia_event_callback(nua_event_t event, case nua_r_refer: break; case nua_i_refer: - if (session) + if (session) { sofia_handle_sip_i_refer(nua, profile, nh, session, sip, de, tags); + } else { + const char *req_user = NULL, *req_host = NULL, *action = NULL, *ref_by_user = NULL, *ref_to_user = NULL, *ref_to_host = NULL; + char *refer_to = NULL, *referred_by = NULL, *method = NULL, *full_url = NULL; + char *params = NULL, *iparams = NULL; + switch_event_t *event; + char *tmp; + + if (sip->sip_refer_to) { + ref_to_user = sip->sip_refer_to->r_url->url_user; + ref_to_host = sip->sip_refer_to->r_url->url_host; + + if (sip->sip_refer_to->r_url->url_params && switch_stristr("method=", sip->sip_refer_to->r_url->url_params)) { + params = su_strdup(nua_handle_home(nh), sip->sip_refer_to->r_url->url_params); + } + + + if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) { + + if ((tmp = sofia_glue_get_url_from_contact(refer_to, 0))) { + refer_to = tmp; + } + + if ((iparams = strrchr(refer_to, ';'))) { + *iparams++ = '\0'; + + if (!switch_stristr("method=", iparams)) { + params = iparams; + } + } + } + + if (params) { + method = switch_find_parameter(params, "method", NULL); + full_url = switch_find_parameter(params, "full_url", NULL); + } + + + } + + if (!method) { + method = strdup("INVITE"); + } + + if (!strcasecmp(method, "INVITE")) { + action = "call"; + } else if (!strcasecmp(method, "BYE")) { + action = "end"; + } else { + action = method; + } + + if (sip->sip_referred_by) { + referred_by = sofia_glue_get_url_from_contact(sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_referred_by), 0); + ref_by_user = sip->sip_referred_by->b_url->url_user; + } + else if(sip->sip_to && sip->sip_to->a_url) + { + referred_by = sofia_glue_get_url_from_contact(sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_to), 0); + ref_by_user = sip->sip_to->a_url->url_user; + } + + if (sip->sip_to && sip->sip_to->a_url) { + req_user = sip->sip_to->a_url->url_user; + req_host = sip->sip_to->a_url->url_host; + } + + if (switch_event_create(&event, SWITCH_EVENT_CALL_SETUP_REQ) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Requesting-Component", "mod_sofia"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Target-Component", req_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Target-Domain", req_host); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Request-Action", action); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Request-Target", "sofia/%s/%s", profile->name, refer_to); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Request-Target-URI", "%s", refer_to); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Request-Target-Extension", ref_to_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Request-Target-Domain", ref_to_host); + if (switch_true(full_url)) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "full-url", "true"); + } + + + if (!zstr(referred_by)) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Request-Sender", "sofia/%s/%s", profile->name, referred_by); + } + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "var_origination_caller_id_number", ref_by_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "var_origination_caller_id_name", ref_by_user); + switch_event_fire(&event); + } + + + + if (sip) { + char *sql; + sofia_nat_parse_t np = { { 0 } }; + char *contact_str; + char *proto = "sip", *orig_proto = "sip"; + const char *call_id, *full_from, *full_to, *full_via, *from_user = NULL, *from_host = NULL, *to_user, *to_host, *full_agent; + char to_tag[13] = ""; + char *event_str = "refer"; + + np.fs_path = 1; + contact_str = sofia_glue_gen_contact_str(profile, sip, nh, de, &np); + + call_id = sip->sip_call_id->i_id; + full_from = sip_header_as_string(nh->nh_home, (void *) sip->sip_from); + full_to = sip_header_as_string(nh->nh_home, (void *) sip->sip_to); + full_via = sip_header_as_string(nh->nh_home, (void *) sip->sip_via); + + full_agent = sip_header_as_string(nh->nh_home, (void *) sip->sip_user_agent); + + switch_stun_random_string(to_tag, 12, NULL); + + if (sip->sip_from) { + from_user = sip->sip_from->a_url->url_user; + from_host = sip->sip_from->a_url->url_host; + } else { + from_user = "n/a"; + from_host = "n/a"; + } + + if (sip->sip_to) { + to_user = sip->sip_to->a_url->url_user; + to_host = sip->sip_to->a_url->url_host; + } else { + to_user = "n/a"; + to_host = "n/a"; + } + + sql = switch_mprintf("insert into sip_subscriptions " + "(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from," + "full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip,version,orig_proto, full_to) " + "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q',-1,'%q','%q;tag=%q')", + proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : "", + event_str, contact_str, call_id, full_from, full_via, + (long) switch_epoch_time_now(NULL) + 60, + full_agent, accept, profile->name, mod_sofia_globals.hostname, + np.network_port, np.network_ip, orig_proto, full_to, to_tag); + + switch_assert(sql != NULL); + + + if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s REFER SUBSCRIBE %s@%s %s@%s\n%s\n", + profile->name, from_user, from_host, to_user, to_host, sql); + } + + + sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + + sip_to_tag(nh->nh_home, sip->sip_to, to_tag); + } + + nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_TO(sip->sip_to), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END()); + switch_safe_free(method); + switch_safe_free(full_url); + + } break; case nua_r_subscribe: sofia_presence_handle_sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, de, tags); @@ -1207,17 +1449,68 @@ static void our_sofia_event_callback(nua_event_t event, } } +void *SWITCH_THREAD_FUNC sofia_msg_thread_run_once(switch_thread_t *thread, void *obj) +{ + sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) obj; + switch_memory_pool_t *pool = NULL; + + if (de) { + pool = de->pool; + de->pool = NULL; + sofia_process_dispatch_event(&de); + } + + if (pool) { + switch_core_destroy_memory_pool(&pool); + } + + return NULL; +} + +void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep) +{ + sofia_dispatch_event_t *de = *dep; + switch_threadattr_t *thd_attr = NULL; + switch_memory_pool_t *pool; + switch_thread_t *thread; + sofia_profile_t *profile = (*dep)->profile; + switch_status_t status; + + switch_core_new_memory_pool(&pool); + + + *dep = NULL; + de->pool = pool; + + switch_mutex_lock(profile->ireg_mutex); + switch_threadattr_create(&thd_attr, de->pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + status = switch_thread_create(&thread, + thd_attr, + sofia_msg_thread_run_once, + de, + de->pool); + switch_mutex_unlock(profile->ireg_mutex); + + if (status != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot create threads!\n"); + sofia_process_dispatch_event(&de); + } +} + void sofia_process_dispatch_event(sofia_dispatch_event_t **dep) { sofia_dispatch_event_t *de = *dep; nua_handle_t *nh = de->nh; nua_t *nua = de->nua; sofia_profile_t *profile = de->profile; - + sofia_private_t *sofia_private = nua_handle_magic(de->nh); + switch_core_session_t *session = de->session; *dep = NULL; our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile, - de->nh, nua_handle_magic(de->nh), de->sip, de, (tagi_t *) de->data->e_tags); + de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags); nua_destroy_event(de->event); su_free(nh->nh_home, de); @@ -1225,37 +1518,69 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep) switch_mutex_lock(profile->flag_mutex); profile->queued_events--; switch_mutex_unlock(profile->flag_mutex); - + nua_handle_unref(nh); nua_stack_unref(nua); + + if (session) { + switch_ivr_parse_all_signal_data(session); + } } + +static int msg_queue_threads = 0; +//static int count = 0; + void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj) { void *pop; switch_queue_t *q = (switch_queue_t *) obj; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread Started\n"); + int my_id; - while(switch_queue_pop(q, &pop) == SWITCH_STATUS_SUCCESS && pop) { - sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop; - sofia_process_dispatch_event(&de); - switch_cond_next(); + for (my_id = 0; my_id < mod_sofia_globals.msg_queue_len; my_id++) { + if (mod_sofia_globals.msg_queue_thread[my_id] == thread) { + break; + } + } + + switch_mutex_lock(mod_sofia_globals.mutex); + msg_queue_threads++; + switch_mutex_unlock(mod_sofia_globals.mutex); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread %d Started\n", my_id); + + + for(;;) { + + if (switch_queue_pop(q, &pop) != SWITCH_STATUS_SUCCESS) { + switch_cond_next(); + continue; + } + + if (pop) { + sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop; + sofia_process_dispatch_event(&de); + } else { + break; + } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread Ended\n"); + switch_mutex_lock(mod_sofia_globals.mutex); + msg_queue_threads--; + switch_mutex_unlock(mod_sofia_globals.mutex); + return NULL; } -static int IDX = 0; - void sofia_msg_thread_start(int idx) { - if (idx >= SOFIA_MAX_MSG_QUEUE || (idx < mod_sofia_globals.msg_queue_len && mod_sofia_globals.msg_queue_thread[idx])) { + if (idx >= mod_sofia_globals.max_msg_queues || + idx >= SOFIA_MAX_MSG_QUEUE || (idx < mod_sofia_globals.msg_queue_len && mod_sofia_globals.msg_queue_thread[idx])) { return; } @@ -1266,18 +1591,16 @@ void sofia_msg_thread_start(int idx) mod_sofia_globals.msg_queue_len = idx + 1; for (i = 0; i < mod_sofia_globals.msg_queue_len; i++) { - if (!mod_sofia_globals.msg_queue[i]) { + if (!mod_sofia_globals.msg_queue_thread[i]) { switch_threadattr_t *thd_attr = NULL; - switch_queue_create(&mod_sofia_globals.msg_queue[i], SOFIA_MSG_QUEUE_SIZE, mod_sofia_globals.pool); - switch_threadattr_create(&thd_attr, mod_sofia_globals.pool); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - //switch_threadattr_priority_increase(thd_attr); + switch_threadattr_priority_increase(thd_attr); switch_thread_create(&mod_sofia_globals.msg_queue_thread[i], thd_attr, sofia_msg_thread_run, - mod_sofia_globals.msg_queue[i], + mod_sofia_globals.msg_queue, mod_sofia_globals.pool); } } @@ -1286,34 +1609,35 @@ void sofia_msg_thread_start(int idx) switch_mutex_unlock(mod_sofia_globals.mutex); } - +//static int foo = 0; static void sofia_queue_message(sofia_dispatch_event_t *de) { - int idx = 0; + int launch = 0; - if (mod_sofia_globals.running == 0) { + if (mod_sofia_globals.running == 0 || !mod_sofia_globals.msg_queue) { sofia_process_dispatch_event(&de); return; } - again: - switch_mutex_lock(mod_sofia_globals.mutex); - idx = IDX; - IDX++; - if (IDX >= mod_sofia_globals.msg_queue_len) IDX = 0; - switch_mutex_unlock(mod_sofia_globals.mutex); - - sofia_msg_thread_start(idx); + if (de->profile && sofia_test_pflag(de->profile, PFLAG_THREAD_PER_REG) && de->data->e_event == nua_i_register) { + sofia_process_dispatch_event_in_thread(&de); + return; + } - if (switch_queue_trypush(mod_sofia_globals.msg_queue[idx], de) != SWITCH_STATUS_SUCCESS) { - if (mod_sofia_globals.msg_queue_len < SOFIA_MAX_MSG_QUEUE) { - sofia_msg_thread_start(idx + 1); - goto again; - } else { - switch_queue_push(mod_sofia_globals.msg_queue[idx], de); + + if ((switch_queue_size(mod_sofia_globals.msg_queue) > (SOFIA_MSG_QUEUE_SIZE * msg_queue_threads))) { + launch++; + } + + + if (launch) { + if (mod_sofia_globals.msg_queue_len < mod_sofia_globals.max_msg_queues) { + sofia_msg_thread_start(mod_sofia_globals.msg_queue_len + 1); } } + + switch_queue_push(mod_sofia_globals.msg_queue, de); } @@ -1324,15 +1648,57 @@ void sofia_event_callback(nua_event_t event, tagi_t tags[]) { sofia_dispatch_event_t *de; + int critical = (((SOFIA_MSG_QUEUE_SIZE * mod_sofia_globals.max_msg_queues) * 900) / 1000); + uint32_t sess_count = switch_core_session_count(); + uint32_t sess_max = switch_core_session_limit(0); + switch(event) { + case nua_i_terminated: + if ((status == 401 || status == 407) && sofia_private && sofia_private->uuid) { + switch_core_session_t *session; - if (sofia_test_pflag(profile, PFLAG_STANDBY)) { - if (event < nua_r_set_params || event > nua_r_authenticate) { - nua_respond(nh, 503, "System Paused", TAG_END()); + if ((session = switch_core_session_locate(sofia_private->uuid))) { + private_object_t *tech_pvt = switch_core_session_get_private(session); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid); + + tech_pvt->sofia_private = NULL; + tech_pvt->nh = NULL; + sofia_set_flag(tech_pvt, TFLAG_BYE); + switch_mutex_lock(profile->flag_mutex); + switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session))); + switch_mutex_unlock(profile->flag_mutex); + switch_core_session_rwunlock(session); + } } - return; - } + goto end; + case nua_i_invite: + case nua_i_register: + case nua_i_options: + case nua_i_notify: + case nua_i_info: + + if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound()) { + nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + goto end; + } + + if (switch_queue_size(mod_sofia_globals.msg_queue) > critical) { + nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + goto end; + } + + if (sofia_test_pflag(profile, PFLAG_STANDBY)) { + nua_respond(nh, 503, "System Paused", TAG_END()); + goto end; + } + break; + + default: + break; + + } switch_mutex_lock(profile->flag_mutex); profile->queued_events++; @@ -1348,6 +1714,9 @@ void sofia_event_callback(nua_event_t event, de->nua = nua_stack_ref(nua); if (event == nua_i_invite && !sofia_private) { + switch_core_session_t *session; + private_object_t *tech_pvt = NULL; + if (!(sofia_private = su_alloc(nh->nh_home, sizeof(*sofia_private)))) { abort(); } @@ -1355,34 +1724,131 @@ void sofia_event_callback(nua_event_t event, memset(sofia_private, 0, sizeof(*sofia_private)); sofia_private->is_call++; sofia_private->is_static++; - sofia_private->de = de; nua_handle_bind(nh, sofia_private); - return; + + + if (sip->sip_call_id && sip->sip_call_id->i_id) { + char *uuid; + + switch_mutex_lock(profile->flag_mutex); + if ((uuid = (char *) switch_core_hash_find(profile->chat_hash, sip->sip_call_id->i_id))) { + switch_core_hash_delete(profile->chat_hash, sip->sip_call_id->i_id); + } + switch_mutex_unlock(profile->flag_mutex); + + if (uuid) { + if ((session = switch_core_session_locate(uuid))) { + tech_pvt = switch_core_session_get_private(session); + switch_copy_string(sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(sofia_private->uuid)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-attaching to session %s\n", sofia_private->uuid); + de->init_session = session; + sofia_clear_flag(tech_pvt, TFLAG_BYE); + tech_pvt->sofia_private = NULL; + tech_pvt->nh = NULL; + switch_core_session_queue_signal_data(session, de); + switch_core_session_rwunlock(session); + session = NULL; + free(uuid); + uuid = NULL; + goto end; + } else { + free(uuid); + uuid = NULL; + } + } + } + + if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) { + session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL, sip->sip_call_id->i_id); + } else { + session = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL); + } + + if (session) { + const char *channel_name = NULL; + tech_pvt = sofia_glue_new_pvt(session); + + if (sip->sip_from) { + channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from); + } + if (!channel_name && sip->sip_contact && sip->sip_contact->m_url) { + channel_name = url_set_chanvars(session, sip->sip_contact->m_url, sip_contact); + } + if (sip->sip_referred_by) { + channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by); + } + + sofia_glue_attach_private(session, profile, tech_pvt, channel_name); + + if (!tech_pvt->call_id && sip->sip_call_id && sip->sip_call_id->i_id) { + switch_channel_t *channel = switch_core_session_get_channel(session); + tech_pvt->call_id = switch_core_session_strdup(session, sip->sip_call_id->i_id); + switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id); + } + + } else { + nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + nua_destroy_event(de->event); + su_free(nh->nh_home, de); + + switch_mutex_lock(profile->flag_mutex); + profile->queued_events--; + switch_mutex_unlock(profile->flag_mutex); + + nua_handle_unref(nh); + nua_stack_unref(nua); + + goto end; + } + + + if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { + char *uuid; + + if (!switch_core_session_running(session) && !switch_core_session_started(session)) { + nua_handle_bind(nh, NULL); + sofia_private_free(sofia_private); + switch_core_session_destroy(&session); + nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); + } + switch_mutex_lock(profile->flag_mutex); + if ((uuid = switch_core_hash_find(profile->chat_hash, tech_pvt->call_id))) { + free(uuid); + uuid = NULL; + switch_core_hash_delete(profile->chat_hash, tech_pvt->call_id); + } + switch_mutex_unlock(profile->flag_mutex); + + goto end; + } + + switch_copy_string(sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(sofia_private->uuid)); + + de->init_session = session; + switch_core_session_queue_signal_data(session, de); + goto end; } if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) { switch_core_session_t *session; - if (!zstr(sofia_private->uuid)) { - if ((session = switch_core_session_locate(sofia_private->uuid))) { - if (switch_core_session_running(session)) { - switch_core_session_queue_signal_data(session, de); - } else { - switch_core_session_message_t msg = { 0 }; - msg.message_id = SWITCH_MESSAGE_INDICATE_SIGNAL_DATA; - msg.from = __FILE__; - msg.pointer_arg = de; - - switch_core_session_receive_message(session, &msg); - } - switch_core_session_rwunlock(session); - return; - } + if ((session = switch_core_session_locate(sofia_private->uuid))) { + switch_core_session_queue_signal_data(session, de); + switch_core_session_rwunlock(session); + goto end; } } - sofia_queue_message(de); + + end: + + if (profile->pres_type) { + switch_cond_next(); + } + + + return; } @@ -1421,7 +1887,7 @@ void event_handler(switch_event_t *event) switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, "MWI-Message-Account", switch_event_get_header_nil(event, "orig-MWI-Message-Account")); switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", switch_event_get_header_nil(event, "orig-MWI-Voice-Message")); /* we cannot use switch_event_fire, or otherwise we'll start an endless loop */ - sofia_presence_mwi_event_handler(pevent); + sofia_presence_event_handler(pevent); return; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nCannot inject MWI event\n"); @@ -1619,11 +2085,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread /* While we're running, or there is a pending sql statment that we haven't appended to sqlbuf yet, because of a lack of buffer space */ while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || sql) { - if (sofia_test_pflag(profile, PFLAG_STANDBY)) { - switch_yield(1000000); - continue; - } - if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) { /* Do we have enough statements or is the timeout expired */ while (sql || (sofia_test_pflag(profile, PFLAG_RUNNING) && mod_sofia_globals.running == 1 && @@ -1720,18 +2181,21 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread } } - if (++ireg_loops >= IREG_SECONDS) { - time_t now = switch_epoch_time_now(NULL); - sofia_reg_check_expire(profile, now, 0); - ireg_loops = 0; - } - if (++gateway_loops >= GATEWAY_SECONDS) { - sofia_reg_check_gateway(profile, switch_epoch_time_now(NULL)); - gateway_loops = 0; - } + if (!sofia_test_pflag(profile, PFLAG_STANDBY)) { + if (++ireg_loops >= IREG_SECONDS) { + time_t now = switch_epoch_time_now(NULL); + sofia_reg_check_expire(profile, now, 0); + ireg_loops = 0; + } + + if (++gateway_loops >= GATEWAY_SECONDS) { + sofia_reg_check_gateway(profile, switch_epoch_time_now(NULL)); + gateway_loops = 0; + } - sofia_sub_check_gateway(profile, time(NULL)); + sofia_sub_check_gateway(profile, time(NULL)); + } last_check = switch_micro_time_now(); } @@ -1912,6 +2376,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TPTAG_TLS_VERIFY_SUBJECTS(profile->tls_verify_in_subjects)), 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, + TPTAG_TLS_TIMEOUT(profile->tls_timeout)), TAG_IF(!strchr(profile->sipip, ':'), NTATAG_UDP_MTU(65535)), TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV), @@ -1947,17 +2413,11 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void nua_set_params(profile->nua, SIPTAG_ALLOW_STR("INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, UPDATE, INFO"), - NUTAG_APPL_METHOD("OPTIONS"), - NUTAG_APPL_METHOD("REFER"), - NUTAG_APPL_METHOD("REGISTER"), - NUTAG_APPL_METHOD("NOTIFY"), NUTAG_APPL_METHOD("INFO"), NUTAG_APPL_METHOD("ACK"), NUTAG_APPL_METHOD("SUBSCRIBE"), -#ifdef MANUAL_BYE - NUTAG_APPL_METHOD("BYE"), -#endif NUTAG_AUTOANSWER(0), NUTAG_AUTOACK(0), NUTAG_AUTOALERT(0), NUTAG_ENABLEMESSENGER(1), + NTATAG_EXTRA_100(0), TAG_IF((profile->mflags & MFLAG_REGISTER), NUTAG_ALLOW("REGISTER")), TAG_IF((profile->mflags & MFLAG_REFER), NUTAG_ALLOW("REFER")), TAG_IF(!sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_ALLOW("PRACK")), @@ -1965,6 +2425,15 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void NUTAG_ALLOW("NOTIFY"), NUTAG_ALLOW_EVENTS("talk"), NUTAG_ALLOW_EVENTS("hold"), + NUTAG_ALLOW_EVENTS("conference"), + NUTAG_APPL_METHOD("OPTIONS"), + NUTAG_APPL_METHOD("REFER"), + NUTAG_APPL_METHOD("REGISTER"), + NUTAG_APPL_METHOD("NOTIFY"), NUTAG_APPL_METHOD("INFO"), NUTAG_APPL_METHOD("ACK"), NUTAG_APPL_METHOD("SUBSCRIBE"), +#ifdef MANUAL_BYE + NUTAG_APPL_METHOD("BYE"), +#endif + NUTAG_SESSION_TIMER(profile->session_timeout), NTATAG_MAX_PROCEEDING(profile->max_proceeding), TAG_IF(profile->pres_type, NUTAG_ALLOW("PUBLISH")), @@ -1978,6 +2447,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("include-session-description")), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence.winfo")), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("message-summary")), + TAG_IF(profile->pres_type == PRES_TYPE_PNP, NUTAG_ALLOW_EVENTS("ua-profile")), NUTAG_ALLOW_EVENTS("refer"), SIPTAG_SUPPORTED_STR(supported), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name); @@ -2091,7 +2561,11 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void sofia_clear_pflag_locked(profile, PFLAG_SHUTDOWN); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n"); - switch_thread_join(&st, worker_thread); + if ( worker_thread ) { + switch_thread_join(&st, worker_thread); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Sofia worker thead failed to start\n"); + } sanity = 4; while (profile->inuse) { @@ -2147,6 +2621,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void sofia_glue_del_profile(profile); switch_core_hash_destroy(&profile->chat_hash); + switch_core_hash_destroy(&profile->mwi_debounce_hash); switch_thread_rwlock_unlock(profile->rwlock); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name); @@ -2279,6 +2754,7 @@ static void parse_gateway_subscriptions(sofia_profile_t *profile, sofia_gateway_ if ((gw_sub = switch_core_alloc(profile->pool, sizeof(*gw_sub)))) { char *expire_seconds = "3600", *retry_seconds = "30", *content_type = "NO_CONTENT_TYPE"; + uint32_t username_in_request = 0; char *event = (char *) switch_xml_attr_soft(subscription_tag, "event"); gw_sub->event = switch_core_strdup(gateway->pool, event); gw_sub->gateway = gateway; @@ -2293,6 +2769,8 @@ static void parse_gateway_subscriptions(sofia_profile_t *profile, sofia_gateway_ retry_seconds = val; } else if (!strcmp(var, "content-type")) { content_type = val; + } else if (!strcmp(var, "username-in-request")) { + username_in_request = switch_true(val); } } @@ -2308,6 +2786,13 @@ static void parse_gateway_subscriptions(sofia_profile_t *profile, sofia_gateway_ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gw_sub->freq); gw_sub->freq = 3600; } + + if(username_in_request) { + gw_sub->request_uri = gateway->register_to; + } else { + gw_sub->request_uri = gateway->register_url; + } + gw_sub->freq -= 2; gw_sub->content_type = switch_core_strdup(gateway->pool, content_type); gw_sub->next = gateway->subscriptions; @@ -2510,12 +2995,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) su_guid_generate(guid); su_guid_sprintf(str_guid, su_guid_strlen + 1, guid); str_rfc_5626 = switch_core_sprintf(gateway->pool, ";reg-id=%s;+sip.instance=\"\"",reg_id,str_guid); - } - - - if ((gw_subs_tag = switch_xml_child(gateway_tag, "subscriptions"))) { - parse_gateway_subscriptions(profile, gateway, gw_subs_tag); - } + } if (zstr(realm)) { if (zstr(proxy)) { @@ -2729,7 +3209,10 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) gateway->freq = 3600; } - + if ((gw_subs_tag = switch_xml_child(gateway_tag, "subscriptions"))) { + parse_gateway_subscriptions(profile, gateway, gw_subs_tag); + } + sofia_reg_add_gateway(profile, gateway->name, gateway); } @@ -2975,6 +3458,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else { sofia_clear_pflag(profile, PFLAG_IN_DIALOG_CHAT); } + } else if (!strcasecmp(var, "fire-message-events")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS); + } else { + sofia_clear_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS); + } } else if (!strcasecmp(var, "disable-hold")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_DISABLE_HOLD); @@ -3029,6 +3518,18 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else { sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL); } + } else if (!strcasecmp(var, "confirm-blind-transfer")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_CONFIRM_BLIND_TRANSFER); + } else { + sofia_clear_pflag(profile, PFLAG_CONFIRM_BLIND_TRANSFER); + } + } else if (!strcasecmp(var, "mwi-use-reg-callid")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_MWI_USE_REG_CALLID); + } else { + sofia_clear_pflag(profile, PFLAG_MWI_USE_REG_CALLID); + } } else if (!strcasecmp(var, "presence-proto-lookup")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_PRESENCE_MAP); @@ -3148,12 +3649,24 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else { sofia_clear_flag(profile, TFLAG_PROXY_MEDIA); } + } else if (!strcasecmp(var, "inbound-zrtp-passthru")) { + if (switch_true(val)) { + sofia_set_flag(profile, TFLAG_ZRTP_PASSTHRU); + } else { + sofia_clear_flag(profile, TFLAG_ZRTP_PASSTHRU); + } } else if (!strcasecmp(var, "inbound-use-callid-as-uuid")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_CALLID_AS_UUID); } else { sofia_clear_pflag(profile, PFLAG_CALLID_AS_UUID); } + } else if (!strcasecmp(var, "inbound-reg-in-new-thread")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_THREAD_PER_REG); + } else { + sofia_clear_pflag(profile, PFLAG_THREAD_PER_REG); + } } else if (!strcasecmp(var, "rtp-autoflush-during-bridge")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE); @@ -3190,6 +3703,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else { profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME; } + } else if (!strcasecmp(var, "NDLB-allow-crypto-in-avp")) { + if (switch_true(val)) { + profile->ndlb |= PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP; + } else { + profile->ndlb &= ~PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP; + } } else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) { if (switch_true(val)) { profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP; @@ -3516,6 +4035,10 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } } + if (sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU)) { + sofia_set_flag(profile, TFLAG_LATE_NEGOTIATION); + } + if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) { parse_gateways(profile, gateways_tag); } @@ -3651,18 +4174,6 @@ switch_status_t config_sofia(int reload, char *profile_name) mod_sofia_globals.debug_sla = atoi(val); } else if (!strcasecmp(var, "auto-restart")) { mod_sofia_globals.auto_restart = switch_true(val); - } else if (!strcasecmp(var, "message-threads")) { - int num = atoi(val); - - if (num < 1 || num > SOFIA_MAX_MSG_QUEUE - 1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "message-threads must be between 1 and %d", SOFIA_MAX_MSG_QUEUE -1); - } - - if (num < 1) num = 1; - if (num > SOFIA_MAX_MSG_QUEUE - 1) num = SOFIA_MAX_MSG_QUEUE -1; - - sofia_msg_thread_start(num); - } else if (!strcasecmp(var, "reg-deny-binding-fetch-and-no-lookup")) { /* backwards compatibility */ mod_sofia_globals.reg_deny_binding_fetch_and_no_lookup = switch_true(val); /* remove when noone complains about the extra lookup */ if (switch_true(val)) { @@ -3744,6 +4255,7 @@ switch_status_t config_sofia(int reload, char *profile_name) profile->dbname = switch_core_strdup(profile->pool, url); switch_core_hash_init(&profile->chat_hash, profile->pool); + switch_core_hash_init(&profile->mwi_debounce_hash, profile->pool); switch_thread_rwlock_create(&profile->rwlock, profile->pool); switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool); profile->dtmf_duration = 100; @@ -3751,6 +4263,7 @@ switch_status_t config_sofia(int reload, char *profile_name) profile->sip_force_expires = 0; profile->sip_expires_max_deviation = 0; profile->tls_version = 0; + profile->tls_timeout = 300; profile->mflags = MFLAG_REFER | MFLAG_REGISTER; profile->server_rport_level = 1; profile->client_rport_level = 1; @@ -3828,6 +4341,18 @@ switch_status_t config_sofia(int reload, char *profile_name) } else { sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL); } + } else if (!strcasecmp(var, "confirm-blind-transfer")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_CONFIRM_BLIND_TRANSFER); + } else { + sofia_clear_pflag(profile, PFLAG_CONFIRM_BLIND_TRANSFER); + } + } else if (!strcasecmp(var, "mwi-use-reg-callid")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_MWI_USE_REG_CALLID); + } else { + sofia_clear_pflag(profile, PFLAG_MWI_USE_REG_CALLID); + } } else if (!strcasecmp(var, "presence-proto-lookup")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_PRESENCE_MAP); @@ -3865,6 +4390,12 @@ switch_status_t config_sofia(int reload, char *profile_name) } else { sofia_clear_pflag(profile, PFLAG_IN_DIALOG_CHAT); } + } else if (!strcasecmp(var, "fire-message-events")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS); + } else { + sofia_clear_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS); + } } else if (!strcasecmp(var, "t38-passthru")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_T38_PASSTHRU); @@ -3991,6 +4522,8 @@ switch_status_t config_sofia(int reload, char *profile_name) } } else if (!strcasecmp(var, "inbound-proxy-media") && switch_true(val)) { sofia_set_flag(profile, TFLAG_PROXY_MEDIA); + } else if (!strcasecmp(var, "inbound-zrtp-passthru") && switch_true(val)) { + sofia_set_flag(profile, TFLAG_ZRTP_PASSTHRU); } else if (!strcasecmp(var, "force-subscription-expires")) { int tmp = atoi(val); if (tmp > 0) { @@ -4011,6 +4544,12 @@ switch_status_t config_sofia(int reload, char *profile_name) sofia_clear_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER); sofia_clear_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER); } + } else if (!strcasecmp(var, "inbound-reg-in-new-thread")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_THREAD_PER_REG); + } else { + sofia_clear_pflag(profile, PFLAG_THREAD_PER_REG); + } } else if (!strcasecmp(var, "inbound-use-callid-as-uuid")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_CALLID_AS_UUID); @@ -4026,9 +4565,6 @@ switch_status_t config_sofia(int reload, char *profile_name) } else if (!strcasecmp(var, "track-calls")) { if (switch_true(val)) { sofia_set_pflag(profile, PFLAG_TRACK_CALLS); - } else if (!strcasecmp(val, "events")) { - sofia_set_pflag(profile, PFLAG_TRACK_CALLS); - sofia_set_pflag(profile, PFLAG_TRACK_CALLS_EVENTS); } } else if (!strcasecmp(var, "NDLB-received-in-nat-reg-contact") && switch_true(val)) { sofia_set_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT); @@ -4219,10 +4755,16 @@ switch_status_t config_sofia(int reload, char *profile_name) } else if (!strcasecmp(val, "bypass-media-after-att-xfer")) { profile->media_options |= MEDIA_OPT_BYPASS_AFTER_ATT_XFER; } + } else if (!strcasecmp(var, "pnp-provision-url")) { + profile->pnp_prov_url = switch_core_strdup(profile->pool, val); + } else if (!strcasecmp(var, "pnp-notify-profile")) { + profile->pnp_notify_profile = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "manage-presence")) { if (!strcasecmp(val, "passive")) { profile->pres_type = PRES_TYPE_PASSIVE; + } else if (!strcasecmp(val, "pnp")) { + profile->pres_type = PRES_TYPE_PNP; } else if (switch_true(val)) { profile->pres_type = PRES_TYPE_FULL; } @@ -4545,6 +5087,9 @@ switch_status_t config_sofia(int reload, char *profile_name) } else { profile->tls_version = 0; } + } else if (!strcasecmp(var, "tls-timeout")) { + int v = atoi(val); + profile->tls_timeout = v > 0 ? (unsigned int)v : 300; } else if (!strcasecmp(var, "timer-T1")) { int v = atoi(val); if (v > 0) { @@ -4615,6 +5160,11 @@ switch_status_t config_sofia(int reload, char *profile_name) } } + if (sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU) && !sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ZRTP passthrough implictly enables inbound-late-negotiation\n"); + sofia_set_flag(profile, TFLAG_LATE_NEGOTIATION); + } + if ((!profile->cng_pt) && (!sofia_test_pflag(profile, PFLAG_SUPPRESS_CNG))) { profile->cng_pt = SWITCH_RTP_CNG_PAYLOAD; } @@ -4672,6 +5222,23 @@ switch_status_t config_sofia(int reload, char *profile_name) profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip); } + if (profile->pres_type == PRES_TYPE_PNP) { + if (!profile->pnp_prov_url) { + profile->pnp_prov_url = switch_core_sprintf(profile->pool, "http://%s/provision/", mod_sofia_globals.guess_ip); + } + + if (!profile->pnp_notify_profile) { + profile->pnp_notify_profile = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip); + } + + if (!profile->extsipip) { + profile->extsipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip); + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "we're configured to provision to [%s] on profile [%s]\n", + profile->pnp_prov_url, profile->pnp_notify_profile); + } + config_sofia_profile_urls(profile); if (sofia_test_pflag(profile, PFLAG_TLS) && !profile->tls_cert_dir) { @@ -4800,11 +5367,13 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu } else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to) { char *sql; time_t now = switch_epoch_time_now(NULL); + const char *call_id = sip->sip_call_id->i_id; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); - sql = switch_mprintf("update sip_registrations set expires=%ld where sip_user='%s' and sip_host='%s'", - (long) now, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); + sql = switch_mprintf("update sip_registrations set expires=%ld where sip_user='%s' and sip_host='%s' and call_id='%q'", + (long) now, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id); sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); } } @@ -4835,7 +5404,11 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status return; } - if (status >= 500 && sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850") + if (status > 299) { + switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_refuse"); + } + + if (status >= 500 && sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850") || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH") || !strcasecmp(sip->sip_reason->re_protocol, profile->username)) && sip->sip_reason->re_cause) { tech_pvt->q850_cause = atoi(sip->sip_reason->re_cause); @@ -5009,7 +5582,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status goto end; } - if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + if ((br = switch_channel_get_partner_uuid(channel))) { switch_xml_t root = NULL, domain = NULL; switch_core_session_t *a_session; switch_channel_t *a_channel; @@ -5168,7 +5741,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status if (sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) { sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE); - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { + if ((uuid = switch_channel_get_partner_uuid(channel)) && (other_session = switch_core_session_locate(uuid))) { const char *r_sdp = NULL; switch_core_session_message_t *msg; private_object_t *other_tech_pvt = switch_core_session_get_private(other_session); @@ -5195,8 +5768,10 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_t38_options_t *t38_options = sofia_glue_extract_t38_options(session, sip->sip_payload->pl_data); if (!t38_options) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_WARNING, "%s Error parsing SDP:\n%s\n", - switch_channel_get_name(tech_pvt->channel), sip->sip_payload->pl_data); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Could not parse T.38 options from sdp.\n"); + switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "T.38 NEGOTIATION ERROR"); + switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); + switch_core_session_rwunlock(other_session); goto end; } else { char *remote_host = switch_rtp_get_remote_host(tech_pvt->rtp_session); @@ -5229,15 +5804,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status } } - - if (t38_options) { - sofia_glue_copy_t38_options(t38_options, other_session); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Could not parse T.38 options from sdp.\n"); - switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "T.38 NEGOTIATION ERROR"); - switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); - goto end; - } + sofia_glue_copy_t38_options(t38_options, other_session); } } @@ -5290,7 +5857,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status } if ((!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED) && - !switch_channel_test_flag(channel, CF_RING_READY)) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { + !switch_channel_test_flag(channel, CF_RING_READY)) || switch_channel_test_flag(channel, CF_RECOVERING)) { const char *from_user = "", *from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = ""; const char *user_agent = "", *call_id = ""; const char *to_tag = ""; @@ -5370,8 +5937,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status extract_header_vars(profile, sip, session, nh); extract_vars(profile, sip, session); - sofia_glue_tech_track(tech_pvt->profile, session); - sofia_clear_flag(tech_pvt, TFLAG_RECOVERING); + switch_core_recovery_track(session); + switch_channel_clear_flag(tech_pvt->channel, CF_RECOVERING); } } @@ -5389,7 +5956,6 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status } } - /* Pure black magic, if you can't understand this code you are lucky.........*/ void *SWITCH_THREAD_FUNC media_on_hold_thread_run(switch_thread_t *thread, void *obj) { @@ -5400,9 +5966,15 @@ void *SWITCH_THREAD_FUNC media_on_hold_thread_run(switch_thread_t *thread, void switch_channel_t *channel = switch_core_session_get_channel(session); private_object_t *tech_pvt = switch_core_session_get_private(session); - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { + if ((uuid = switch_channel_get_partner_uuid(channel)) && (other_session = switch_core_session_locate(uuid))) { if (switch_core_session_compare(session, other_session)) { + switch_channel_t *other_channel = switch_core_session_get_channel(other_session); sofia_set_flag_locked(tech_pvt, TFLAG_HOLD_LOCK); + + switch_yield(250000); + switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); + switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); + switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE); if (tech_pvt->rtp_session) { @@ -5432,6 +6004,8 @@ static void launch_media_on_hold(switch_core_session_t *session) switch_thread_create(&thread, thd_attr, media_on_hold_thread_run, session, switch_core_session_get_pool(session)); } + + static void mark_transfer_record(switch_core_session_t *session, const char *br_a, const char *br_b) { switch_core_session_t *br_b_session, *br_a_session; @@ -5521,7 +6095,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, switch_channel_t *channel = NULL; private_object_t *tech_pvt = NULL; const char *replaces_str = NULL; - const char *uuid; switch_core_session_t *other_session = NULL; switch_channel_t *other_channel = NULL; //private_object_t *other_tech_pvt = NULL; @@ -5590,8 +6163,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } if (session) { - if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) { - /* Must you send 180 after 183 w/sdp ? sheesh */ + if (switch_channel_test_flag(channel, CF_ANSWERED) && (status == 180 || status == 183) && !r_sdp) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n", switch_channel_get_name(channel), nua_callstate_name(ss_state), status); goto done; @@ -5614,7 +6186,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, tech_pvt->remote_sdp_str = switch_core_session_strdup(session, r_sdp); switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp); - if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && (parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) { + if ((sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) && (parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) { if ((sdp = sdp_session(parser))) { sofia_glue_set_r_sdp_codec_string(session, sofia_glue_get_codec_string(tech_pvt), sdp); } @@ -5713,8 +6285,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } } - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { other_channel = switch_core_session_get_channel(other_session); if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) { switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp); @@ -5742,12 +6313,21 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, { const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from"); const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to"); + const char *wait_for_ack = switch_channel_get_variable(channel, "sip_wait_for_aleg_ack"); + + if (switch_true(wait_for_ack)) { + switch_core_session_t *other_session; + + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { + switch_channel_t *other_channel = switch_core_session_get_channel(other_session); + switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); + switch_core_session_rwunlock(other_session); + } + } if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE) && !sofia_test_flag(tech_pvt, TFLAG_SDP)) { sofia_set_flag(tech_pvt, TFLAG_SDP); - - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { other_channel = switch_core_session_get_channel(other_session); //other_tech_pvt = switch_core_session_get_private(other_session); @@ -5785,6 +6365,25 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; case nua_callstate_received: if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { + private_object_t *other_tech_pvt = switch_core_session_get_private(other_session); + int r = sofia_test_flag(other_tech_pvt, TFLAG_REINVITED); + switch_core_session_rwunlock(other_session); + + if (r) { + /* Due to a race between simultaneous reinvites to both legs of a bridge, + an earlier call to nua_invite silently failed. + So we reject the incoming invite with a 491 and redo the failed outgoing invite. */ + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "Other leg already handling a reinvite, so responding with 491\n"); + + nua_respond(tech_pvt->nh, SIP_491_REQUEST_PENDING, TAG_END()); + sofia_glue_do_invite(session); + goto done; + } + } + if (r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) { if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOMEDIA"); @@ -5842,7 +6441,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } if ((b_private = nua_handle_magic(bnh))) { - const char *br_b = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + const char *br_b = switch_channel_get_partner_uuid(channel); char *br_a = b_private->uuid; @@ -5930,8 +6529,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, sofia_set_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE); if ((switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) && sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) { sofia_set_flag_locked(tech_pvt, TFLAG_3PCC); - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { switch_core_session_message_t *msg; msg = switch_core_session_alloc(other_session, sizeof(*msg)); msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT; @@ -5972,13 +6570,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (switch_stristr("m=image", r_sdp)) { is_t38 = 1; } - + if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { switch_core_session_message_t *msg; + private_object_t *other_tech_pvt; - if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 && profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) { + if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 && (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD)) { if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp)) { tech_pvt->hold_laps = 1; switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp); @@ -6024,6 +6622,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_END()); } + + switch_channel_set_flag(channel, CF_PROXY_MODE); + switch_yield(250000); launch_media_on_hold(session); switch_core_session_rwunlock(other_session); @@ -6040,6 +6641,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } } + other_tech_pvt = switch_core_session_get_private(other_session); + if(sofia_test_flag(other_tech_pvt, TFLAG_REINVITED)) { + /* The other leg won the reinvite race */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg already handling reinvite, so responding with 491\n"); + nua_respond(tech_pvt->nh, SIP_491_REQUEST_PENDING, TAG_END()); + switch_core_session_rwunlock(other_session); + goto done; + } + sofia_set_flag(tech_pvt, TFLAG_REINVITED); + msg = switch_core_session_alloc(other_session, sizeof(*msg)); msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT; msg->from = __FILE__; @@ -6185,8 +6796,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } } - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { other_channel = switch_core_session_get_channel(other_session); if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) { switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp); @@ -6202,31 +6812,30 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, switch_core_session_rwunlock(other_session); } } else { - uint8_t match = 0; - int is_ok = 1; + uint8_t match = 0; + int is_ok = 1; + if (tech_pvt->num_codecs) { + match = sofia_glue_negotiate_sdp(session, r_sdp); + } - if (tech_pvt->num_codecs) { - match = sofia_glue_negotiate_sdp(session, r_sdp); - } - - if (match) { - sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE); - if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n"); - switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RTP ERROR"); + if (match) { + sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE); + if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n"); + switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RTP ERROR"); + is_ok = 0; + } + sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE); + } else { + switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR"); is_ok = 0; } - sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE); - } else { - switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR"); - is_ok = 0; - } - if (!is_ok) { - nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END()); - switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); - } + if (!is_ok) { + nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END()); + switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); + } } goto done; } @@ -6255,8 +6864,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, switch_channel_mark_answered(channel); if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { //other_channel = switch_core_session_get_channel(other_session); //switch_channel_answer(other_channel); switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_ANSWER); @@ -6282,8 +6890,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } } - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) - && (other_session = switch_core_session_locate(uuid))) { + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { other_channel = switch_core_session_get_channel(other_session); if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) { switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp); @@ -6577,12 +7184,15 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_EXPIRES_STR("60"), TAG_END()); + + switch_channel_set_variable(tech_pvt->channel, SOFIA_REPLACES_HEADER, NULL); + if (sip->sip_referred_by) { full_ref_by = sip_header_as_string(home, (void *) sip->sip_referred_by); } if ((refer_to = sip->sip_refer_to)) { - char *rep; + char *rep = NULL; full_ref_to = sip_header_as_string(home, (void *) sip->sip_refer_to); if (sofia_test_pflag(profile, PFLAG_FULL_ID)) { @@ -6593,7 +7203,13 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Process REFER to [%s@%s]\n", exten, (char *) refer_to->r_url->url_host); - if (refer_to->r_url->url_headers && (rep = (char *) switch_stristr("Replaces=", refer_to->r_url->url_headers))) { + + if (refer_to->r_url && refer_to->r_url->url_headers) { + rep = (char *) switch_stristr("Replaces=", refer_to->r_url->url_headers); + } + + + if (rep) { sip_replaces_t *replaces; nua_handle_t *bnh = NULL; @@ -6639,8 +7255,8 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t b_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session); channel_b = switch_core_session_get_channel(b_session); - br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE); - br_b = switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE); + br_a = switch_channel_get_partner_uuid(channel_a); + br_b = switch_channel_get_partner_uuid(channel_b); if (!switch_ivr_uuid_exists(br_a)) { br_a = NULL; @@ -6889,7 +7505,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t } nua_handle_unref(bnh); } else { /* the other channel is on a different box, we have to go find them */ - if (exten && (br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE))) { + if (exten && (br_a = switch_channel_get_partner_uuid(channel_a))) { switch_core_session_t *a_session; switch_channel_t *channel = switch_core_session_get_channel(session); @@ -7010,37 +7626,64 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t if (exten) { switch_channel_t *channel = switch_core_session_get_channel(session); const char *br; + switch_core_session_t *b_session; - if ((br = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { - switch_core_session_t *b_session; + if ((br = switch_channel_get_partner_uuid(channel)) && (b_session = switch_core_session_locate(br))) { - if ((b_session = switch_core_session_locate(br))) { - switch_channel_t *b_channel = switch_core_session_get_channel(b_session); - switch_channel_set_variable(channel, "transfer_fallback_extension", from->a_user); - if (!zstr(full_ref_by)) { - switch_channel_set_variable(b_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by); - } - if (!zstr(full_ref_to)) { - switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to); - } + const char *var; + switch_channel_t *b_channel = switch_core_session_get_channel(b_session); - if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) { - switch_core_media_bug_transfer_recordings(session, b_session); - } + switch_channel_set_variable(channel, "transfer_fallback_extension", from->a_user); + if (!zstr(full_ref_by)) { + switch_channel_set_variable(b_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by); + } - switch_ivr_session_transfer(b_session, exten, NULL, NULL); - switch_core_session_rwunlock(b_session); + if (!zstr(full_ref_to)) { + switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to); + } + + if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) { + switch_core_media_bug_transfer_recordings(session, b_session); } switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "BLIND_TRANSFER"); - nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"), - NUTAG_SUBSTATE(nua_substate_terminated),SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END()); + + if (((var = switch_channel_get_variable(channel, "confirm_blind_transfer")) && switch_true(var)) || + sofia_test_pflag(profile, PFLAG_CONFIRM_BLIND_TRANSFER)) { + switch_channel_set_state_flag(b_channel, CF_CONFIRM_BLIND_TRANSFER); + switch_channel_set_variable(channel, "sip_blind_transfer_event", etmp); + switch_channel_set_variable(b_channel, "blind_transfer_uuid", switch_core_session_get_uuid(session)); + switch_channel_set_variable(channel, "blind_transfer_uuid", switch_core_session_get_uuid(b_session)); + + switch_channel_set_variable(channel, "park_timeout", "600:blind_transfer"); + switch_channel_set_state(channel, CS_PARK); + } else { + nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"), + NUTAG_SUBSTATE(nua_substate_terminated), + SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), + SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END()); + } + + switch_ivr_session_transfer(b_session, exten, NULL, NULL); + switch_core_session_rwunlock(b_session); } else { + switch_event_t *event; + + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Error-Type", "blind_transfer"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Transfer-Exten", exten); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Full-Refer-To", full_ref_to); + switch_channel_event_set_data(channel, event); + switch_event_fire(&event); + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Blind Transfer 1 Legged calls\n"); switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR"); nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"), - NUTAG_SUBSTATE(nua_substate_terminated),SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END()); + NUTAG_SUBSTATE(nua_substate_terminated), + SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), + SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END()); } } @@ -7131,9 +7774,11 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0), 0, SWITCH_DTMF_ENDPOINT }; switch_event_t *event; private_object_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; if (session) { tech_pvt = (private_object_t *) switch_core_session_get_private(session); + channel = switch_core_session_get_channel(session); } if (sofia_test_pflag(profile, PFLAG_EXTENDED_INFO_PARSING)) { @@ -7198,8 +7843,6 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t } if (session) { - /* Get the channel */ - switch_channel_t *channel = switch_core_session_get_channel(session); const char *vval; /* Barf if we didn't get our private */ @@ -7317,7 +7960,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t const char *uuid; switch_core_session_t *session_b; - if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) { + if ((uuid = switch_channel_get_partner_uuid(channel)) && (session_b = switch_core_session_locate(uuid))) { while (switch_channel_has_dtmf(channel)) { switch_dtmf_t idtmf = { 0, 0 }; if (switch_channel_dequeue_dtmf(channel, &idtmf) == SWITCH_STATUS_SUCCESS) { @@ -7388,6 +8031,9 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t end: if (create_info_event(sip, nh, &event) == SWITCH_STATUS_SUCCESS) { + if (channel) { + switch_channel_event_set_data(channel, event); + } switch_event_fire(&event); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "dispatched freeswitch event for INFO\n"); } @@ -7404,6 +8050,11 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session, tagi_t tags[]) { char *call_info = NULL; + switch_channel_t *channel = NULL; + + if (session) { + channel = switch_core_session_get_channel(session); + } if (session && profile && sip && sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -7424,11 +8075,10 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session, switch_channel_set_variable_printf(channel, "sip_recieved_port", "%d", network_port); switch_channel_set_variable_printf(channel, "sip_via_rport", "%d", network_port); - sofia_glue_tech_track(tech_pvt->profile, session); + switch_core_recovery_track(session); } if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { - switch_channel_t *channel = switch_core_session_get_channel(session); if (channel && sip->sip_call_info) { char *p; if ((call_info = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_call_info))) { @@ -7442,12 +8092,18 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session, } } } + + if (channel) { + if (sip->sip_payload && sip->sip_payload->pl_data) { + switch_channel_set_variable(channel, "sip_reinvite_sdp", sip->sip_payload->pl_data); + } + switch_channel_execute_on(channel, "execute_on_sip_reinvite"); + } + } -void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, - sofia_dispatch_event_t *de, tagi_t tags[]) +void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]) { - switch_core_session_t *session = NULL; char key[128] = ""; sip_unknown_t *un; sip_remote_party_id_t *rpid = NULL; @@ -7458,7 +8114,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ sip_call_info_t *call_info = NULL; private_object_t *tech_pvt = NULL; switch_channel_t *channel = NULL; - const char *channel_name = NULL; + //const char *channel_name = NULL; const char *displayname = NULL; const char *destination_number = NULL; const char *from_user = NULL, *from_host = NULL; @@ -7482,14 +8138,23 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ nua_handle_t *bnh = NULL; char sip_acl_authed_by[512] = ""; char sip_acl_token[512] = ""; + const char *dialog_from_user = "", *dialog_from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = ""; + const char *user_agent = "", *call_id = ""; + url_t *from = NULL, *to = NULL, *contact = NULL; + const char *to_tag = ""; + const char *from_tag = ""; + char *sql = NULL; profile->ib_calls++; - if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING)) { + + 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()); goto fail; } + tech_pvt = switch_core_session_get_private(session); + if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n"); nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END()); @@ -7501,7 +8166,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ nua_respond(nh, 400, "Missing Contact Header", TAG_END()); goto fail; } - + sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port); if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) { @@ -7677,30 +8342,9 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ is_auth++; } - if (sofia_endpoint_interface) { - if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) { - session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL, sip->sip_call_id->i_id); - } else { - session = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL); - } - } - - if (!session) { - nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); - goto fail; - } - - if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); - nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END()); - switch_core_session_destroy(&session); - goto fail; - } - switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - + tech_pvt->remote_ip = switch_core_session_strdup(session, network_ip); tech_pvt->remote_port = network_port; @@ -7776,7 +8420,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if (sip->sip_from && sip->sip_from->a_url) { from_user = sip->sip_from->a_url->url_user; from_host = sip->sip_from->a_url->url_host; - channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from); + //channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from); if (sip->sip_from->a_url->url_params) { aniii = switch_find_parameter(sip->sip_from->a_url->url_params, "isup-oli", switch_core_session_get_pool(session)); @@ -7797,6 +8441,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } switch_channel_set_variable(channel, "sofia_profile_name", profile->name); + switch_channel_set_variable(channel, "recovery_profile_name", profile->name); switch_channel_set_variable(channel, "sofia_profile_domain_name", profile->domain_name); if (!zstr(sip->sip_from->a_display)) { @@ -8002,16 +8647,13 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } if (sip->sip_contact && sip->sip_contact->m_url) { - const char *contact_uri = url_set_chanvars(session, sip->sip_contact->m_url, sip_contact); - if (!channel_name) { - channel_name = contact_uri; - } + url_set_chanvars(session, sip->sip_contact->m_url, sip_contact); } if (sip->sip_referred_by) { referred_by_user = sip->sip_referred_by->b_url->url_user; //referred_by_host = sip->sip_referred_by->b_url->url_host; - channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by); + //channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by); check_decode(referred_by_user, session); @@ -8030,7 +8672,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } } - sofia_glue_attach_private(session, profile, tech_pvt, channel_name); + //sofia_glue_set_name(tech_pvt, channel_name); sofia_glue_tech_prepare_codecs(tech_pvt); switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL"); @@ -8043,9 +8685,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_channel_set_flag(channel, CF_PROXY_MEDIA); } - if (!tech_pvt->call_id && sip->sip_call_id && sip->sip_call_id->i_id) { - tech_pvt->call_id = switch_core_session_strdup(session, sip->sip_call_id->i_id); - switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id); + if (sofia_test_flag(tech_pvt, TFLAG_ZRTP_PASSTHRU)) { + switch_channel_set_flag(channel, CF_ZRTP_PASSTHRU_REQ); } if (sip->sip_subject && sip->sip_subject->g_string) { @@ -8307,11 +8948,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if ((b_session = switch_core_session_locate(b_private->uuid))) { switch_channel_t *b_channel = switch_core_session_get_channel(b_session); - const char *uuid; - int one_leg = 1; - private_object_t *b_tech_pvt = NULL; - const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE); - const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE); + const char *bridge_uuid; switch_caller_profile_t *orig_cp; const char *sent_name, *sent_number; orig_cp = switch_channel_get_caller_profile(b_channel); @@ -8336,77 +8973,58 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat); } + tech_pvt->caller_profile->dialplan = "inline"; - if (app && data && !strcasecmp(app, "conference")) { - tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,conference:%s+flags{dist-dtmf}", data); - tech_pvt->caller_profile->dialplan = "inline"; - } else { - if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) { - b_tech_pvt = switch_core_session_get_private(b_session); - } + bridge_uuid = switch_channel_get_partner_uuid(b_channel); - if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) { - one_leg = 0; + if (call_info) { + const char *olu; + switch_core_session_t *os; + switch_codec_implementation_t read_impl = { 0 }; + char *codec_str = ""; + + if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) { + olu = bridge_uuid; } else { - uuid = switch_core_session_get_uuid(b_session); + olu = b_private->uuid; } + + if ((os = switch_core_session_locate(olu))) { + switch_core_session_get_real_read_impl(os, &read_impl); + switch_core_session_rwunlock(os); - if (uuid) { - switch_core_session_t *c_session = NULL; - int do_conf = 0; - const char *c_app = NULL; - const char *c_data = NULL; + codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame, + read_impl.microseconds_per_packet / 1000); + } + + + + if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) { + tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, + "%sanswer,intercept:%s", codec_str, bridge_uuid); + } else { + tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, + "%sanswer,sofia_sla:%s", codec_str, b_private->uuid); + } + } else { + if (!zstr(bridge_uuid)) { + switch_channel_mark_hold(b_channel, SWITCH_FALSE); + tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid); + } else { + const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE); + const char *b_data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE); - uuid = switch_core_session_strdup(b_session, uuid); - - if (call_info && (c_session = switch_core_session_locate(uuid))) { - switch_channel_t *c_channel = switch_core_session_get_channel(c_session); - private_object_t *c_tech_pvt = NULL; - - c_app = switch_channel_get_variable(c_channel, SWITCH_CURRENT_APPLICATION_VARIABLE); - c_data = switch_channel_get_variable(c_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE); - - if (switch_core_session_check_interface(c_session, sofia_endpoint_interface)) { - c_tech_pvt = switch_core_session_get_private(c_session); - } + if (b_data && b_app) { + tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s:%s", b_app, b_data); + } else if (b_app) { + tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s", b_app); + } - if (!one_leg && - (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) && - (!c_tech_pvt || !sofia_test_flag(c_tech_pvt, TFLAG_SIP_HOLD))) { - char *ext = switch_core_session_sprintf(session, "answer,conference:%s@sla+flags{mintwo|dist-dtmf}", uuid); - - switch_channel_set_flag(c_channel, CF_REDIRECT); - switch_ivr_session_transfer(b_session, ext, "inline", NULL); - switch_ivr_session_transfer(c_session, ext, "inline", NULL); - switch_channel_clear_flag(c_channel, CF_REDIRECT); - do_conf = 1; - } - switch_core_session_rwunlock(c_session); - } - - if (do_conf) { - tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, - "answer,conference:%s@sla+flags{mintwo|dist-dtmf}", uuid); - } else { - if (one_leg && c_app) { - if (c_data) { - tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, - "answer,%s:%s", c_app, c_data); - } else { - tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, - "answer,%s", c_app); - } - } else { - switch_channel_mark_hold(b_channel, SWITCH_FALSE); - tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, - "answer,intercept:%s", uuid); - } - } - - tech_pvt->caller_profile->dialplan = "inline"; + switch_channel_hangup(b_channel, SWITCH_CAUSE_ATTENDED_TRANSFER); } } + switch_core_session_rwunlock(b_session); } } @@ -8513,132 +9131,99 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); } - tech_pvt->sofia_private = sofia_private; tech_pvt->nh = nh; - + if (profile->pres_type && sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT)) { sofia_presence_set_chat_hash(tech_pvt, sip); } - switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid)); - if (sip && switch_core_session_thread_launch(session) == SWITCH_STATUS_SUCCESS) { - const char *dialog_from_user = "", *dialog_from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = ""; - const char *user_agent = "", *call_id = ""; - url_t *from = NULL, *to = NULL, *contact = NULL; - const char *to_tag = ""; - const char *from_tag = ""; - char *sql = NULL; + if (sip->sip_to) { + to = sip->sip_to->a_url; + } + if (sip->sip_from) { + from = sip->sip_from->a_url; + } + if (sip->sip_contact) { + contact = sip->sip_contact->m_url; + } + + if (sip->sip_user_agent) { + user_agent = switch_str_nil(sip->sip_user_agent->g_string); + } + + if (sip->sip_call_id) { + call_id = switch_str_nil(sip->sip_call_id->i_id); + } + + if (to) { + to_user = switch_str_nil(to->url_user); + to_host = switch_str_nil(to->url_host); + to_tag = switch_str_nil(sip->sip_to->a_tag); + } + + if (from) { + dialog_from_user = switch_str_nil(from->url_user); + dialog_from_host = switch_str_nil(from->url_host); + from_tag = switch_str_nil(sip->sip_from->a_tag); + } + + if (contact) { + contact_user = switch_str_nil(contact->url_user); + contact_host = switch_str_nil(contact->url_host); + } + + if (profile->pres_type) { + const char *presence_data = switch_channel_get_variable(channel, "presence_data"); + const char *presence_id = switch_channel_get_variable(channel, "presence_id"); + char *full_contact = ""; + char *p = NULL; + time_t now; - if (sip->sip_to) { - to = sip->sip_to->a_url; - } - if (sip->sip_from) { - from = sip->sip_from->a_url; - } if (sip->sip_contact) { - contact = sip->sip_contact->m_url; + full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact); } - if (sip->sip_user_agent) { - user_agent = switch_str_nil(sip->sip_user_agent->g_string); - } - - if (sip->sip_call_id) { - call_id = switch_str_nil(sip->sip_call_id->i_id); - } - - if (to) { - to_user = switch_str_nil(to->url_user); - to_host = switch_str_nil(to->url_host); - to_tag = switch_str_nil(sip->sip_to->a_tag); - } - - if (from) { - dialog_from_user = switch_str_nil(from->url_user); - dialog_from_host = switch_str_nil(from->url_host); - from_tag = switch_str_nil(sip->sip_from->a_tag); - } - - if (contact) { - contact_user = switch_str_nil(contact->url_user); - contact_host = switch_str_nil(contact->url_host); - } - - if (profile->pres_type) { - const char *presence_data = switch_channel_get_variable(channel, "presence_data"); - const char *presence_id = switch_channel_get_variable(channel, "presence_id"); - char *full_contact = ""; - char *p = NULL; - time_t now; - - if (sip->sip_contact) { - full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact); + if (call_info_str && switch_stristr("appearance", call_info_str)) { + switch_channel_set_variable(channel, "presence_call_info_full", call_info_str); + if ((p = strchr(call_info_str, ';'))) { + p++; + switch_channel_set_variable(channel, "presence_call_info", p); } - - if (call_info_str && switch_stristr("appearance", call_info_str)) { - switch_channel_set_variable(channel, "presence_call_info_full", call_info_str); - if ((p = strchr(call_info_str, ';'))) { - p++; - switch_channel_set_variable(channel, "presence_call_info", p); - } - } - - now = switch_epoch_time_now(NULL); - - sql = switch_mprintf("insert into sip_dialogs " - "(call_id,uuid,sip_to_user,sip_to_host,sip_to_tag,sip_from_user,sip_from_host,sip_from_tag,contact_user," - "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data," - "call_info,rcd,call_info_state) " - "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'')", - call_id, - tech_pvt->sofia_private->uuid, - to_user, to_host, to_tag, dialog_from_user, dialog_from_host, from_tag, - contact_user, contact_host, "confirmed", "inbound", user_agent, - profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact), - switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(p), now); - - switch_assert(sql); - - sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex); - switch_safe_free(sql); - } - if (is_nat) { - sofia_set_flag(tech_pvt, TFLAG_NAT); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting NAT mode based on %s\n", is_nat); - switch_channel_set_variable(channel, "sip_nat_detected", "true"); - } - return; + now = switch_epoch_time_now(NULL); + + sql = switch_mprintf("insert into sip_dialogs " + "(call_id,uuid,sip_to_user,sip_to_host,sip_to_tag,sip_from_user,sip_from_host,sip_from_tag,contact_user," + "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data," + "call_info,rcd,call_info_state) " + "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'')", + call_id, + tech_pvt->sofia_private->uuid, + to_user, to_host, to_tag, dialog_from_user, dialog_from_host, from_tag, + contact_user, contact_host, "confirmed", "inbound", user_agent, + profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact), + switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(p), now); + + switch_assert(sql); + + sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex); + switch_safe_free(sql); + } - if (sess_count > 110) { - switch_mutex_lock(profile->flag_mutex); - switch_core_session_limit(sess_count - 10); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "LUKE: I'm hit, but not bad.\n"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, - "LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....\n" - "Green laserfire moves past the beeping little robot as his head turns. " - "After a few beeps and a twist of his mechanical arm,\n" - "Artoo reduces the max sessions to %d thus, saving the switch from certain doom.\n", sess_count - 10); - switch_mutex_unlock(profile->flag_mutex); + if (is_nat) { + sofia_set_flag(tech_pvt, TFLAG_NAT); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting NAT mode based on %s\n", is_nat); + switch_channel_set_variable(channel, "sip_nat_detected", "true"); } - if (tech_pvt->hash_key) { - switch_mutex_lock(tech_pvt->profile->flag_mutex); - switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->hash_key); - switch_mutex_unlock(tech_pvt->profile->flag_mutex); - } - - nua_handle_bind(nh, NULL); - sofia_private_free(sofia_private); - switch_core_session_destroy(&session); - nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); return; fail: profile->ib_failed_calls++; + return; } diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 0d7f0b526a..c642657fb7 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -184,7 +184,6 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen, int rate; int already_did[128] = { 0 }; int ptime = 0, noptime = 0; - const char *zrtp; switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d RTP/%sAVP", port, secure ? "S" : ""); @@ -344,11 +343,14 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen, switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=ptime:%d\n", cur_ptime); } - if ((zrtp = switch_channel_get_variable(tech_pvt->channel, "sdp_zrtp_hash_string"))) { - switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=zrtp-hash:%s\n", zrtp); + if (tech_pvt->local_sdp_audio_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Adding audio a=zrtp-hash:%s\n", + tech_pvt->local_sdp_audio_zrtp_hash); + switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=zrtp-hash:%s\n", + tech_pvt->local_sdp_audio_zrtp_hash); } - if (sr) { + if (!zstr(sr)) { switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=%s\n", sr); } } @@ -370,10 +372,10 @@ void sofia_glue_check_dtmf_type(private_object_t *tech_pvt) } } - +#define SDPBUFLEN 65536 void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch_port_t port, const char *sr, int force) { - char buf[2048]; + char *buf; int ptime = 0; uint32_t rate = 0; uint32_t v_port; @@ -391,8 +393,9 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch switch_event_t *map = NULL, *ptmap = NULL; const char *b_sdp = NULL; int verbose_sdp = 0; - const char *zrtp; - + + switch_zmalloc(buf, SDPBUFLEN); + sofia_glue_check_dtmf_type(tech_pvt); if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) || @@ -433,8 +436,9 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch verbose_sdp = 1; } - if (!force && !ip && !sr + if (!force && !ip && zstr(sr) && (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA))) { + switch_safe_free(buf); return; } @@ -446,6 +450,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch if (!ip) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s NO IP!\n", switch_channel_get_name(tech_pvt->channel)); + switch_safe_free(buf); return; } @@ -457,6 +462,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch if (!port) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s NO PORT!\n", switch_channel_get_name(tech_pvt->channel)); + switch_safe_free(buf); return; } @@ -464,7 +470,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch sofia_glue_sdp_map(b_sdp, &map, &ptmap); } - if (!sr) { + if (zstr(sr)) { if ((var_val = switch_channel_get_variable(tech_pvt->channel, "media_audio_mode"))) { sr = var_val; } else { @@ -484,12 +490,14 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch if ((tech_pvt->profile->ndlb & PFLAG_NDLB_SENDRECV_IN_SESSION) || ((var_val = switch_channel_get_variable(tech_pvt->channel, "ndlb_sendrecv_in_session")) && switch_true(var_val))) { - switch_snprintf(srbuf, sizeof(srbuf), "a=%s\n", sr); + if (!zstr(sr)) { + switch_snprintf(srbuf, sizeof(srbuf), "a=%s\n", sr); + } sr = NULL; } family = strchr(ip, ':') ? "IP6" : "IP4"; - switch_snprintf(buf, sizeof(buf), + switch_snprintf(buf, SDPBUFLEN, "v=0\n" "o=%s %010u %010u IN %s %s\n" "s=%s\n" @@ -498,25 +506,25 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch username, tech_pvt->owner_id, tech_pvt->session_id, family, ip, username, family, ip, srbuf); if (tech_pvt->rm_encoding) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=audio %d RTP/%sAVP", + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=audio %d RTP/%sAVP", port, (!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) ? "S" : ""); - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", tech_pvt->pt); if ((tech_pvt->dtmf_type == DTMF_2833 || sofia_test_pflag(tech_pvt->profile, PFLAG_LIBERAL_DTMF) || sofia_test_flag(tech_pvt, TFLAG_LIBERAL_DTMF)) && tech_pvt->te > 95) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", tech_pvt->te); } if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", tech_pvt->cng_pt); } - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n"); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\n"); rate = tech_pvt->rm_rate; - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->agreed_pt, tech_pvt->rm_encoding, rate); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->agreed_pt, tech_pvt->rm_encoding, rate); if (fmtp_out) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->agreed_pt, fmtp_out); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->agreed_pt, fmtp_out); } if (tech_pvt->read_codec.implementation && !ptime) { @@ -526,36 +534,40 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch if ((tech_pvt->dtmf_type == DTMF_2833 || sofia_test_pflag(tech_pvt->profile, PFLAG_LIBERAL_DTMF) || sofia_test_flag(tech_pvt, TFLAG_LIBERAL_DTMF)) && tech_pvt->te > 95) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te); } if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d CN/8000\n", tech_pvt->cng_pt); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d CN/8000\n", tech_pvt->cng_pt); if (!tech_pvt->rm_encoding) { tech_pvt->cng_pt = 0; } } else { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=silenceSupp:off - - - -\n"); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=silenceSupp:off - - - -\n"); } if (append_audio) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s%s", append_audio, end_of(append_audio) == '\n' ? "" : "\n"); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "%s%s", append_audio, end_of(append_audio) == '\n' ? "" : "\n"); } if (ptime) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ptime:%d\n", ptime); } - if ((zrtp = switch_channel_get_variable(tech_pvt->channel, "sdp_zrtp_hash_string"))) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=zrtp-hash:%s\n", zrtp); + + if (tech_pvt->local_sdp_audio_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Adding audio a=zrtp-hash:%s\n", + tech_pvt->local_sdp_audio_zrtp_hash); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=zrtp-hash:%s\n", + tech_pvt->local_sdp_audio_zrtp_hash); } - if (sr) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=%s\n", sr); + if (!zstr(sr)) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=%s\n", sr); } if (!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=crypto:%s\n", tech_pvt->local_crypto_key); - //switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n"); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=crypto:%s\n", tech_pvt->local_crypto_key); + //switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=encryption:optional\n"); } } else if (tech_pvt->num_codecs) { @@ -578,7 +590,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch int both = 1; if ((!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE))) { - generate_m(tech_pvt, buf, sizeof(buf), port, 0, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 1); + generate_m(tech_pvt, buf, SDPBUFLEN, port, 0, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 1); bp = (buf + strlen(buf)); /* asterisk can't handle AVP and SAVP in sep streams, way to blow off the spec....*/ @@ -589,7 +601,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } if (both) { - generate_m(tech_pvt, bp, sizeof(buf) - strlen(buf), port, 0, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 0); + generate_m(tech_pvt, bp, SDPBUFLEN - strlen(buf), port, 0, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 0); } } else { @@ -614,7 +626,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch cur_ptime = this_ptime; if ((!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE))) { - generate_m(tech_pvt, buf, sizeof(buf), port, cur_ptime, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 1); + generate_m(tech_pvt, bp, SDPBUFLEN - strlen(buf), port, cur_ptime, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 1); bp = (buf + strlen(buf)); /* asterisk can't handle AVP and SAVP in sep streams, way to blow off the spec....*/ @@ -624,7 +636,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } if (both) { - generate_m(tech_pvt, bp, sizeof(buf) - strlen(buf), port, cur_ptime, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 0); + generate_m(tech_pvt, bp, SDPBUFLEN - strlen(buf), port, cur_ptime, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 0); } } @@ -639,12 +651,12 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } if ((v_port = tech_pvt->adv_sdp_video_port)) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=video %d RTP/AVP", v_port); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=video %d RTP/AVP", v_port); /*****************************/ if (tech_pvt->video_rm_encoding) { sofia_glue_tech_set_video_codec(tech_pvt, 0); - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_agreed_pt); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", tech_pvt->video_agreed_pt); } else if (tech_pvt->num_codecs) { int i; int already_did[128] = { 0 }; @@ -662,28 +674,28 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch already_did[tech_pvt->ianacodes[i]] = 1; } - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->ianacodes[i]); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", tech_pvt->ianacodes[i]); if (!ptime) { ptime = imp->microseconds_per_packet / 1000; } } } - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n"); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\n"); if (tech_pvt->video_rm_encoding) { const char *of; rate = tech_pvt->video_rm_rate; - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->video_pt, tech_pvt->video_rm_encoding, + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->video_pt, tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate); - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) { pass_fmtp = tech_pvt->video_rm_fmtp; } else { pass_fmtp = NULL; - if (switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) { + if (switch_channel_get_partner_uuid(tech_pvt->channel)) { if ((of = switch_channel_get_variable_partner(tech_pvt->channel, "sip_video_fmtp"))) { pass_fmtp = of; } @@ -697,7 +709,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } if (pass_fmtp) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->video_pt, pass_fmtp); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->video_pt, pass_fmtp); } } else if (tech_pvt->num_codecs) { @@ -725,7 +737,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", ianacode, imp->iananame, + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d\n", ianacode, imp->iananame, imp->samples_per_second); if (!zstr(ov_fmtp)) { @@ -742,11 +754,18 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } if (!zstr(fmtp) && strcasecmp(fmtp, "_blank_")) { - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", ianacode, fmtp); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", ianacode, fmtp); } } } + + if (tech_pvt->local_sdp_video_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Adding video a=zrtp-hash:%s\n", + tech_pvt->local_sdp_video_zrtp_hash); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=zrtp-hash:%s\n", + tech_pvt->local_sdp_video_zrtp_hash); + } } } @@ -760,23 +779,29 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch } sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE); + + switch_safe_free(buf); } const char *sofia_glue_get_codec_string(private_object_t *tech_pvt) { - const char *codec_string = NULL, *preferred = NULL, *fallback = NULL; - - if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - preferred = tech_pvt->profile->outbound_codec_string; - fallback = tech_pvt->profile->inbound_codec_string; - } else { - preferred = tech_pvt->profile->inbound_codec_string; - fallback = tech_pvt->profile->outbound_codec_string; + const char *preferred = NULL, *fallback = NULL; + + if (!(preferred = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) { + preferred = switch_channel_get_variable(tech_pvt->channel, "codec_string"); + } + + if (!preferred) { + if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { + preferred = tech_pvt->profile->outbound_codec_string; + fallback = tech_pvt->profile->inbound_codec_string; + } else { + preferred = tech_pvt->profile->inbound_codec_string; + fallback = tech_pvt->profile->outbound_codec_string; + } } - codec_string = !zstr(preferred) ? preferred : fallback; - - return codec_string; + return !zstr(preferred) ? preferred : fallback; } void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt) @@ -856,12 +881,30 @@ void sofia_glue_check_video_codecs(private_object_t *tech_pvt) } } +private_object_t *sofia_glue_new_pvt(switch_core_session_t *session) +{ + private_object_t *tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)); + switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); + switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); + return tech_pvt; +} + +void sofia_glue_set_name(private_object_t *tech_pvt, const char *channame) +{ + char name[256]; + char *p; + + switch_snprintf(name, sizeof(name), "sofia/%s/%s", tech_pvt->profile->name, channame); + if ((p = strchr(name, ';'))) { + *p = '\0'; + } + switch_channel_set_name(tech_pvt->channel, name); +} void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame) { - char name[256]; + unsigned int x; - char *p; switch_assert(session != NULL); switch_assert(profile != NULL); @@ -908,6 +951,11 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * tech_pvt->session = session; tech_pvt->channel = switch_core_session_get_channel(session); + + if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) { + switch_channel_set_flag(tech_pvt->channel, CF_TRACKABLE); + } + sofia_glue_check_dtmf_type(tech_pvt); switch_channel_set_cap(tech_pvt->channel, CC_MEDIA_ACK); switch_channel_set_cap(tech_pvt->channel, CC_BYPASS_MEDIA); @@ -919,12 +967,9 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * switch_core_session_set_private(session, tech_pvt); if (channame) { - switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame); - if ((p = strchr(name, ';'))) { - *p = '\0'; - } - switch_channel_set_name(tech_pvt->channel, name); + sofia_glue_set_name(tech_pvt, channame); } + } switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port, @@ -1739,7 +1784,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt) } - } else if ((!strncmp("m=audio ", p, 8) && *(p + 9) != '0') || (!strncmp("m=image ", p, 8) && *(p + 9) != '0')) { + } else if ((!strncmp("m=audio ", p, 8) && *(p + 8) != '0') || (!strncmp("m=image ", p, 8) && *(p + 8) != '0')) { strncpy(q, p, 8); p += 8; @@ -1775,7 +1820,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt) has_audio++; - } else if (!strncmp("m=video ", p, 8) && *(p + 9) != '0') { + } else if (!strncmp("m=video ", p, 8) && *(p + 8) != '0') { if (!has_video) { sofia_glue_tech_choose_video_port(tech_pvt, 1); tech_pvt->video_rm_encoding = "PROXY-VID"; @@ -2057,8 +2102,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) char *mp = NULL, *mp_type = NULL; char *record_route = NULL; const char *recover_via = NULL; + int require_timer = 1; - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { + + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) { const char *recover_contact = switch_channel_get_variable(tech_pvt->channel, "sip_recover_contact"); recover_via = switch_channel_get_variable(tech_pvt->channel, "sip_recover_via"); @@ -2073,7 +2120,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } - rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER); + if ((rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER))) { + switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, NULL); + } switch_assert(tech_pvt != NULL); @@ -2087,6 +2136,11 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } + if ((val = switch_channel_get_variable_dup(channel, "sip_require_timer", SWITCH_FALSE, -1)) && switch_false(val)) { + require_timer = 0; + } + + cid_name = caller_profile->caller_id_name; cid_num = caller_profile->caller_id_number; sofia_glue_tech_prepare_codecs(tech_pvt); @@ -2378,7 +2432,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) cid_type = sofia_cid_name2type(val); } - if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) { + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) { if (zstr((use_name = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_name"))) && zstr((use_name = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_name")))) { if (!(use_name = switch_channel_get_variable(tech_pvt->channel, "sip_to_display"))) { @@ -2472,6 +2526,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) sofia_private->is_call++; sofia_private->is_static++; + if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) { + sofia_private->is_call++; + } + tech_pvt->sofia_private = sofia_private; switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid)); nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private); @@ -2505,6 +2563,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) if (!switch_channel_get_variable(channel, "sofia_profile_name")) { switch_channel_set_variable(channel, "sofia_profile_name", tech_pvt->profile->name); + switch_channel_set_variable(channel, "recovery_profile_name", tech_pvt->profile->name); } extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX); @@ -2571,6 +2630,11 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) tech_pvt->session_refresher = nua_no_refresher; } + if (tech_pvt->local_sdp_str) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, + "Local SDP:\n%s\n", tech_pvt->local_sdp_str); + } + if (sofia_use_soa(tech_pvt)) { nua_invite(tech_pvt->nh, NUTAG_AUTOANSWER(0), @@ -2607,6 +2671,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE)), TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL)), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), + TAG_IF(!require_timer, NUTAG_TIMER_AUTOREQUIRE(0)), TAG_IF(!zstr(tech_pvt->local_sdp_str), SOATAG_HOLD(holdstr)), TAG_END()); } else { nua_invite(tech_pvt->nh, @@ -2632,6 +2697,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) TAG_IF(!zstr(route), SIPTAG_ROUTE_STR(route)), TAG_IF(!zstr(invite_route_uri), NUTAG_INITIAL_ROUTE_STR(invite_route_uri)), TAG_IF(tech_pvt->profile->minimum_session_expires, NUTAG_MIN_SE(tech_pvt->profile->minimum_session_expires)), + TAG_IF(!require_timer, NUTAG_TIMER_AUTOREQUIRE(0)), TAG_IF(cseq, SIPTAG_CSEQ(cseq)), NUTAG_MEDIA_ENABLE(0), SIPTAG_CONTENT_TYPE_STR(mp_type ? mp_type : "application/sdp"), @@ -3122,6 +3188,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f uint32_t rtp_hold_timeout_sec = tech_pvt->profile->rtp_hold_timeout_sec; char *timer_name = NULL; const char *var; + uint32_t delay = tech_pvt->profile->rtp_digit_delay; switch_assert(tech_pvt != NULL); @@ -3139,10 +3206,6 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f sofia_set_flag_locked(tech_pvt, TFLAG_SECURE); } - if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_liberal_dtmf")) && switch_true(var)) { - sofia_set_flag_locked(tech_pvt, TFLAG_LIBERAL_DTMF); - } - if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE)) { status = SWITCH_STATUS_SUCCESS; goto end; @@ -3523,15 +3586,14 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f tech_pvt->cng_pt = 0; } - if (tech_pvt->profile->rtp_digit_delay || ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_digit_delay")))) { - uint32_t delay = tech_pvt->profile->rtp_digit_delay; + if (((val = switch_channel_get_variable(tech_pvt->channel, "rtp_digit_delay")))) { + int delayi = atoi(val); + if (delayi < 0) delayi = 0; + delay = (uint32_t) delayi; + } - if (!delay) { - int delayi = atoi(val); - if (delayi < 0) delayi = 0; - delay = (uint32_t) delay; - } + if (delay) { switch_rtp_set_interdigit_delay(tech_pvt->rtp_session, delay); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s Set rtp dtmf delay to %u\n", switch_channel_get_name(tech_pvt->channel), delay); @@ -3558,9 +3620,11 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); - if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASS)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASSTHRU)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_INFO, "Activating ZRTP PROXY MODE\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Disable NOTIMER_DURING_BRIDGE\n"); sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Activating audio UDPTL mode\n"); switch_rtp_udptl_mode(tech_pvt->rtp_session); } @@ -3747,7 +3811,10 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f } } } - + if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASSTHRU)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Activating video UDPTL mode\n"); + switch_rtp_udptl_mode(tech_pvt->video_rtp_session); + } } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err)); @@ -3772,8 +3839,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f end: sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE); - sofia_glue_tech_track(tech_pvt->profile, tech_pvt->session); - + switch_core_recovery_track(tech_pvt->session); switch_mutex_unlock(tech_pvt->sofia_mutex); @@ -3832,7 +3898,104 @@ static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size } +void sofia_glue_pass_zrtp_hash2(switch_core_session_t *aleg_session, switch_core_session_t *bleg_session) +{ + switch_channel_t *aleg_channel; + private_object_t *aleg_tech_pvt; + switch_channel_t *bleg_channel; + private_object_t *bleg_tech_pvt; + if (!switch_core_session_compare(aleg_session, bleg_session)) { + /* since this digs into channel internals its only compatible with sofia sessions*/ + return; + } + + aleg_channel = switch_core_session_get_channel(aleg_session); + aleg_tech_pvt = switch_core_session_get_private(aleg_session); + bleg_channel = switch_core_session_get_channel(bleg_session); + bleg_tech_pvt = switch_core_session_get_private(bleg_session); + + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Deciding whether to pass zrtp-hash between a-leg and b-leg\n"); + if (!(switch_channel_test_flag(aleg_tech_pvt->channel, CF_ZRTP_PASSTHRU_REQ))) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "CF_ZRTP_PASSTHRU_REQ not set on a-leg, so not propagating zrtp-hash\n"); + return; + } + if (aleg_tech_pvt->remote_sdp_audio_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing a-leg remote zrtp-hash (audio) to b-leg\n"); + bleg_tech_pvt->local_sdp_audio_zrtp_hash = switch_core_session_strdup(bleg_tech_pvt->session, aleg_tech_pvt->remote_sdp_audio_zrtp_hash); + switch_channel_set_variable(bleg_channel, "l_sdp_audio_zrtp_hash", bleg_tech_pvt->local_sdp_audio_zrtp_hash); + } + if (aleg_tech_pvt->remote_sdp_video_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing a-leg remote zrtp-hash (video) to b-leg\n"); + bleg_tech_pvt->local_sdp_video_zrtp_hash = switch_core_session_strdup(bleg_tech_pvt->session, aleg_tech_pvt->remote_sdp_video_zrtp_hash); + switch_channel_set_variable(bleg_channel, "l_sdp_video_zrtp_hash", bleg_tech_pvt->local_sdp_video_zrtp_hash); + } + if (bleg_tech_pvt->remote_sdp_audio_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing b-leg remote zrtp-hash (audio) to a-leg\n"); + aleg_tech_pvt->local_sdp_audio_zrtp_hash = switch_core_session_strdup(aleg_tech_pvt->session, bleg_tech_pvt->remote_sdp_audio_zrtp_hash); + switch_channel_set_variable(aleg_channel, "l_sdp_audio_zrtp_hash", aleg_tech_pvt->local_sdp_audio_zrtp_hash); + } + if (bleg_tech_pvt->remote_sdp_video_zrtp_hash) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing b-leg remote zrtp-hash (video) to a-leg\n"); + aleg_tech_pvt->local_sdp_video_zrtp_hash = switch_core_session_strdup(aleg_tech_pvt->session, bleg_tech_pvt->remote_sdp_video_zrtp_hash); + switch_channel_set_variable(aleg_channel, "l_sdp_video_zrtp_hash", aleg_tech_pvt->local_sdp_video_zrtp_hash); + } +} + +void sofia_glue_pass_zrtp_hash(switch_core_session_t *session) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + private_object_t *tech_pvt = switch_core_session_get_private(session); + switch_core_session_t *other_session; + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Deciding whether to pass zrtp-hash between legs\n"); + if (!(switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASSTHRU_REQ))) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "CF_ZRTP_PASSTHRU_REQ not set, so not propagating zrtp-hash\n"); + return; + } else if (!(switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS)) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "No partner channel found, so not propagating zrtp-hash\n"); + return; + } else { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Found peer channel; propagating zrtp-hash if set\n"); + sofia_glue_pass_zrtp_hash2(session, other_session); + switch_core_session_rwunlock(other_session); + } +} + +static void find_zrtp_hash(switch_core_session_t *session, sdp_session_t *sdp) +{ + switch_channel_t *channel = switch_core_session_get_channel(session); + private_object_t *tech_pvt = switch_core_session_get_private(session); + sdp_media_t *m; + sdp_attribute_t *attr; + int got_audio = 0, got_video = 0; + + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Looking for zrtp-hash\n"); + for (m = sdp->sdp_media; m; m = m->m_next) { + if (got_audio && got_video) break; + if (m->m_port && ((m->m_type == sdp_media_audio && !got_audio) + || (m->m_type == sdp_media_video && !got_video))) { + for (attr = m->m_attributes; attr; attr = attr->a_next) { + if (zstr(attr->a_name)) continue; + if (strcasecmp(attr->a_name, "zrtp-hash") || !(attr->a_value)) continue; + if (m->m_type == sdp_media_audio) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, + "Found audio zrtp-hash; setting r_sdp_audio_zrtp_hash=%s\n", attr->a_value); + switch_channel_set_variable(channel, "r_sdp_audio_zrtp_hash", attr->a_value); + tech_pvt->remote_sdp_audio_zrtp_hash = switch_core_session_strdup(tech_pvt->session, attr->a_value); + got_audio++; + } else if (m->m_type == sdp_media_video) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, + "Found video zrtp-hash; setting r_sdp_video_zrtp_hash=%s\n", attr->a_value); + switch_channel_set_variable(channel, "r_sdp_video_zrtp_hash", attr->a_value); + tech_pvt->remote_sdp_video_zrtp_hash = switch_core_session_strdup(tech_pvt->session, attr->a_value); + got_video++; + } + switch_channel_set_flag(channel, CF_ZRTP_HASH); + break; + } + } + } +} void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp) { @@ -3882,18 +4045,8 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha } } - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Looking for zrtp-hash to set sdp_zrtp_hash_string\n"); - for (m = sdp->sdp_media; m; m = m->m_next) { - for (attr = m->m_attributes; attr; attr = attr->a_next) { - if (zstr(attr->a_name)) continue; - if (!strcasecmp(attr->a_name, "zrtp-hash") && attr->a_value) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Found zrtp-hash, setting sdp_zrtp_hash_string=%s\n", attr->a_value); - switch_channel_set_variable(channel, "sdp_zrtp_hash_string", attr->a_value); - switch_channel_set_flag(channel, CF_ZRTP_HASH); - break; - } - } - } + find_zrtp_hash(session, sdp); + sofia_glue_pass_zrtp_hash(session); for (m = sdp->sdp_media; m; m = m->m_next) { ptime = dptime; @@ -4056,6 +4209,11 @@ int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly) { int changed = 0; + if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGE) || sofia_test_flag(tech_pvt, TFLAG_SLA_BARGING)) { + switch_channel_mark_hold(tech_pvt->channel, sendonly); + return 0; + } + if (sendonly && switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED)) { if (!sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) { const char *stream; @@ -4087,9 +4245,9 @@ int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly) if (!strcasecmp(stream, "indicate_hold")) { switch_channel_set_flag(tech_pvt->channel, CF_SUSPEND); switch_channel_set_flag(tech_pvt->channel, CF_HOLD); - switch_ivr_hold_uuid(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), NULL, 0); + switch_ivr_hold_uuid(switch_channel_get_partner_uuid(tech_pvt->channel), NULL, 0); } else { - switch_ivr_broadcast(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), stream, + switch_ivr_broadcast(switch_channel_get_partner_uuid(tech_pvt->channel), stream, SMF_ECHO_ALEG | SMF_LOOP | SMF_PRIORITY); switch_yield(250000); } @@ -4115,7 +4273,7 @@ int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly) switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets); } - if ((uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (b_session = switch_core_session_locate(uuid))) { + if ((uuid = switch_channel_get_partner_uuid(tech_pvt->channel)) && (b_session = switch_core_session_locate(uuid))) { switch_channel_t *b_channel = switch_core_session_get_channel(b_session); if (switch_channel_test_flag(tech_pvt->channel, CF_HOLD)) { @@ -4486,6 +4644,10 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s } } + if ((val = switch_channel_get_variable(tech_pvt->channel, "sip_liberal_dtmf")) && switch_true(val)) { + sofia_set_flag_locked(tech_pvt, TFLAG_LIBERAL_DTMF); + } + if ((m = sdp->sdp_media) && (m->m_mode == sdp_sendonly || m->m_mode == sdp_inactive || (m->m_connections && m->m_connections->c_address && !strcmp(m->m_connections->c_address, "0.0.0.0")))) { @@ -4565,6 +4727,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s switch_channel_set_variable(tech_pvt->channel, "t38_broken_boolean", "true"); } + find_zrtp_hash(session, sdp); + sofia_glue_pass_zrtp_hash(session); + for (m = sdp->sdp_media; m; m = m->m_next) { sdp_connection_t *connection; switch_core_session_t *other_session; @@ -4588,10 +4753,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s goto done; } - if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38)) { - sofia_set_flag(tech_pvt, TFLAG_NOREPLY); - } - if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) { switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); match = 0; @@ -4600,6 +4761,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s const char *var = switch_channel_get_variable(channel, "t38_passthru"); int pass = sofia_test_pflag(tech_pvt->profile, PFLAG_T38_PASSTHRU); + + if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38)) { + sofia_set_flag(tech_pvt, TFLAG_NOREPLY); + } + if (var) { if (!(pass = switch_true(var))) { if (!strcasecmp(var, "once")) { @@ -4686,16 +4852,16 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s ptime = atoi(attr->a_value); } else if (!strcasecmp(attr->a_name, "maxptime") && attr->a_value) { maxptime = atoi(attr->a_value); - } else if (!strcasecmp(attr->a_name, "zrtp-hash") && attr->a_value) { - switch_channel_set_variable(tech_pvt->channel, "sdp_zrtp_hash_string", attr->a_value); - switch_channel_set_flag(tech_pvt->channel, CF_ZRTP_HASH); } else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) { int crypto_tag; - if (m->m_proto != sdp_proto_srtp) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n"); - match = 0; - goto done; + if (!(tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP) && + !switch_true(switch_channel_get_variable(tech_pvt->channel, "sip_allow_crypto_in_avp"))) { + if (m->m_proto != sdp_proto_srtp) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n"); + match = 0; + goto done; + } } crypto = attr->a_value; @@ -5224,12 +5390,12 @@ void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp) switch_core_session_t *other_session; switch_channel_t *other_channel; - if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) + if ((val = switch_channel_get_partner_uuid(tech_pvt->channel)) && (other_session = switch_core_session_locate(val))) { other_channel = switch_core_session_get_channel(other_session); switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp); - if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && !sofia_test_flag(tech_pvt, TFLAG_RECOVERING) && + if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && !switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING) && (switch_channel_direction(other_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE))) { switch_ivr_nomedia(val, SMF_FORCE); @@ -5569,39 +5735,31 @@ void sofia_glue_del_profile(sofia_profile_t *profile) switch_mutex_unlock(mod_sofia_globals.hash_mutex); } -struct recover_helper { - sofia_profile_t *profile; - int total; -}; - - -static int recover_callback(void *pArg, int argc, char **argv, char **columnNames) +int sofia_recover_callback(switch_core_session_t *session) { - struct recover_helper *h = (struct recover_helper *) pArg; - switch_xml_t xml; - switch_core_session_t *session; - switch_channel_t *channel; + + switch_channel_t *channel = switch_core_session_get_channel(session); private_object_t *tech_pvt = NULL; + sofia_profile_t *profile = NULL; const char *tmp; const char *rr; + int r = 0; + const char *profile_name = switch_channel_get_variable_dup(channel, "recovery_profile_name", SWITCH_FALSE, -1); + - xml = switch_xml_parse_str_dynamic(argv[3], SWITCH_TRUE); - - if (!xml) - return 0; - - if (!(session = switch_core_session_request_xml(sofia_endpoint_interface, NULL, xml))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid cdr data, call not recovered\n"); + if (zstr(profile_name)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing profile\n"); return 0; } - if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); - switch_core_session_destroy(&session); + if (!(profile = sofia_glue_find_profile(profile_name))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Invalid profile %s\n", profile_name); return 0; } - channel = tech_pvt->channel = switch_core_session_get_channel(session); + + tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)); + tech_pvt->channel = channel; switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); @@ -5627,11 +5785,11 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName rr = switch_channel_get_variable(channel, "sip_invite_record_route"); if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { + int break_rfc = switch_true(switch_channel_get_variable(channel, "sip_recovery_break_rfc")); tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_req_uri")); - switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, "sip_full_from")); - switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, "sip_full_to")); + switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, break_rfc ? "sip_full_to" : "sip_full_from")); + switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, break_rfc ? "sip_full_from" : "sip_full_to")); } else { - tech_pvt->redirected = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_contact_uri")); if (zstr(rr)) { @@ -5658,7 +5816,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName tech_pvt->dest_to = tech_pvt->dest; - sofia_glue_attach_private(session, h->profile, tech_pvt, NULL); + sofia_glue_attach_private(session, profile, tech_pvt, NULL); switch_channel_set_name(tech_pvt->channel, switch_channel_get_variable(channel, "channel_name")); @@ -5680,7 +5838,6 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName } if (session) { - switch_caller_extension_t *extension = NULL; const char *ip = switch_channel_get_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE); const char *a_ip = switch_channel_get_variable(channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE); const char *port = switch_channel_get_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE); @@ -5688,7 +5845,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName const char *r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE); const char *use_uuid; - sofia_set_flag(tech_pvt, TFLAG_RECOVERING); + switch_channel_set_flag(channel, CF_RECOVERING); if ((use_uuid = switch_channel_get_variable(channel, "origination_uuid"))) { if (switch_core_session_set_uuid(session, use_uuid) == SWITCH_STATUS_SUCCESS) { @@ -5772,8 +5929,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1); if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { - switch_xml_free(xml); - return 0; + goto end; } if (switch_rtp_ready(tech_pvt->rtp_session)) { @@ -5797,39 +5953,13 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName } } - - if (switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) { - sofia_set_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE); - } else { - switch_xml_t callflow, param, x_extension; - if ((extension = switch_caller_extension_new(session, "recovery", "recovery")) == 0) { - abort(); - } - - if ((callflow = switch_xml_child(xml, "callflow")) && (x_extension = switch_xml_child(callflow, "extension"))) { - for (param = switch_xml_child(x_extension, "application"); param; param = param->next) { - const char *var = switch_xml_attr_soft(param, "app_name"); - const char *val = switch_xml_attr_soft(param, "app_data"); - /* skip announcement type apps */ - if (strcasecmp(var, "speak") && strcasecmp(var, "playback") && strcasecmp(var, "gentones") && strcasecmp(var, "say")) { - switch_caller_extension_add_application(session, extension, var, val); - } - } - } - - switch_channel_set_caller_extension(channel, extension); - } - - switch_channel_set_state(channel, CS_INIT); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Resurrecting fallen channel %s\n", switch_channel_get_name(channel)); - switch_core_session_thread_launch(session); } - switch_xml_free(xml); + r++; - h->total++; + end: - return 0; + return r; } @@ -5845,6 +5975,7 @@ int sofia_glue_recover(switch_bool_t flush) for (m = matches->head; m; m = m->next) { if ((profile = sofia_glue_find_profile(m->val))) { r += sofia_glue_profile_recover(profile, flush); + sofia_glue_release_profile(profile); } } switch_console_free_matches(&matches); @@ -5854,140 +5985,21 @@ int sofia_glue_recover(switch_bool_t flush) int sofia_glue_profile_recover(sofia_profile_t *profile, switch_bool_t flush) { - char *sql; int r = 0; if (profile) { - struct recover_helper h = { 0 }; - h.profile = profile; - h.total = 0; - sofia_clear_pflag_locked(profile, PFLAG_STANDBY); if (flush) { - sql = switch_mprintf("delete from sip_recovery where profile_name='%q'", profile->name); - sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + switch_core_recovery_flush(SOFIA_RECOVER, profile->name); } else { - - sql = switch_mprintf("select profile_name, hostname, uuid, metadata " - "from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name); - - sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, recover_callback, &h); - r += h.total; - free(sql); - sql = NULL; - - sql = switch_mprintf("delete " - "from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name); - - sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + r = switch_core_recovery_recover(SOFIA_RECOVER, profile->name); } } return r; } -void sofia_glue_track_event_handler(switch_event_t *event) -{ - char *sql, *buf = NULL; - char *profile_name = NULL; - - switch_assert(event); // Just a sanity check - - if ((buf = switch_event_get_header_nil(event, "sql")) && (profile_name = switch_event_get_header_nil(event, "profile_name"))) { - sofia_profile_t *profile; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", switch_event_get_header_nil(event, "Event-Calling-Function")); - if ((profile = sofia_glue_find_profile(profile_name))) { - sql = switch_mprintf("%s", buf); - sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); - sofia_glue_release_profile(profile); - } - } - - return; -} -void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *session, switch_bool_t force) -{ - char *sql = NULL; - private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); - - if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || (sofia_test_flag(tech_pvt, TFLAG_RECOVERING))) { - return; - } - - if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS) && (sofia_test_flag(tech_pvt, TFLAG_TRACKED) || force)) { - switch_event_t *event = NULL; - - if (force) { - sql = switch_mprintf("delete from sip_recovery where uuid='%q'", switch_core_session_get_uuid(session)); - - } else { - sql = switch_mprintf("delete from sip_recovery where runtime_uuid='%q' and uuid='%q'", - switch_core_get_uuid(), switch_core_session_get_uuid(session)); - } - - if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS_EVENTS)) { - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY_SEND) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile->name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sql", sql); - switch_event_fire(&event); - } - } - - sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); - sofia_clear_flag(tech_pvt, TFLAG_TRACKED); - - switch_safe_free(sql); - } - - -} - -void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *session) -{ - private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); - switch_xml_t cdr = NULL; - char *xml_cdr_text = NULL; - char *sql = NULL; - - if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { - return; - } - - if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { - xml_cdr_text = switch_xml_toxml_nolock(cdr, SWITCH_FALSE); - switch_xml_free(cdr); - } - - if (xml_cdr_text) { - if (sofia_test_flag(tech_pvt, TFLAG_TRACKED)) { - sql = switch_mprintf("update sip_recovery set metadata='%q' where uuid='%q'", xml_cdr_text, switch_core_session_get_uuid(session)); - } else { - - sql = switch_mprintf("insert into sip_recovery (runtime_uuid, profile_name, hostname, uuid, metadata) values ('%q','%q','%q','%q','%q')", - switch_core_get_uuid(), profile->name, mod_sofia_globals.hostname, switch_core_session_get_uuid(session), xml_cdr_text); - } - - if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS_EVENTS)) { - switch_event_t *event = NULL; - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RECOVERY_SEND) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile->name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sql", sql); - switch_event_fire(&event); - } - } - - sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); - - free(xml_cdr_text); - sofia_set_flag(tech_pvt, TFLAG_TRACKED); - - } - - - switch_safe_free(sql); - -} int sofia_glue_init_sql(sofia_profile_t *profile) { @@ -6019,15 +6031,6 @@ int sofia_glue_init_sql(sofia_profile_t *profile) " sub_host VARCHAR(255)\n" ");\n"; - char recovery_sql[] = - "CREATE TABLE sip_recovery (\n" - " runtime_uuid VARCHAR(255),\n" - " profile_name VARCHAR(255),\n" - " hostname VARCHAR(255),\n" - " uuid VARCHAR(255),\n" - " metadata text\n" - ");\n"; - char pres_sql[] = "CREATE TABLE sip_presence (\n" " sip_user VARCHAR(255),\n" @@ -6199,10 +6202,6 @@ int sofia_glue_init_sql(sofia_profile_t *profile) "create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)", "create index ssd_call_id on sip_shared_appearance_dialogs (call_id)", "create index ssd_expires on sip_shared_appearance_dialogs (expires)", - "create index sr_1 on sip_recovery (runtime_uuid)", - "create index sr_2 on sip_recovery (profile_name)", - "create index sr_3 on sip_recovery (hostname)", - "create index sr_4 on sip_recovery (uuid)", NULL }; @@ -6270,11 +6269,6 @@ int sofia_glue_init_sql(sofia_profile_t *profile) switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql); - free(test_sql); - test_sql = switch_mprintf("select count(profile_name) from sip_recovery where hostname='%q'", mod_sofia_globals.hostname); - - - switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_recovery", recovery_sql); free(test_sql); for (x = 0; indexes[x]; x++) { @@ -6630,7 +6624,7 @@ void sofia_glue_free_destination(sofia_destination_t *dst) } switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, - const char *body, const char *o_contact, const char *network_ip) + const char *body, const char *o_contact, const char *network_ip, const char *call_id) { char *id = NULL; nua_handle_t *nh; @@ -6693,6 +6687,7 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), TAG_IF(event, SIPTAG_EVENT_STR(event)), + TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)), TAG_IF(contenttype, SIPTAG_CONTENT_TYPE_STR(contenttype)), TAG_IF(body, SIPTAG_PAYLOAD_STR(body)), TAG_END()); switch_safe_free(contact); @@ -6718,7 +6713,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt) - if ((uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) + if ((uuid = switch_channel_get_partner_uuid(tech_pvt->channel)) && (other_session = switch_core_session_locate(uuid))) { other_channel = switch_core_session_get_channel(other_session); @@ -6756,7 +6751,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt) did_simplify = 1; - sofia_glue_tech_track(tech_pvt->profile, inbound_session); + switch_core_recovery_track(inbound_session); switch_channel_set_flag(inbound_channel, CF_SIMPLIFY); @@ -6879,6 +6874,14 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str if (switch_stristr("~GEN_ONE_GEN_ALL", str)) { *flag_pole &= ~RTP_BUG_GEN_ONE_GEN_ALL; } + + if (switch_stristr("CHANGE_SSRC_ON_MARKER", str)) { + *flag_pole |= RTP_BUG_CHANGE_SSRC_ON_MARKER; + } + + if (switch_stristr("~CHANGE_SSRC_ON_MARKER", str)) { + *flag_pole &= ~RTP_BUG_CHANGE_SSRC_ON_MARKER; + } } char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 72cca73d71..5445adae11 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -27,6 +27,7 @@ * Ken Rice * Paul D. Tinsley * Bret McDanel + * Raymond Chandler * * * sofia_presence.c -- SOFIA SIP Endpoint (presence code) @@ -90,6 +91,9 @@ struct presence_helper { switch_event_t *event; switch_stream_handle_t stream; char last_uuid[512]; + int hup; + int calls_up; + }; switch_status_t sofia_presence_chat_send(switch_event_t *message_event) @@ -124,7 +128,11 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) char *route_uri = NULL; const char *network_ip = NULL, *network_port = NULL, *from_proto; char *extra_headers = NULL; - + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; + int mstatus = 0, sanity = 0; + const char *blocking; + int is_blocking = 0; + proto = switch_event_get_header(message_event, "proto"); from_proto = switch_event_get_header(message_event, "from_proto"); from = switch_event_get_header(message_event, "from"); @@ -133,7 +141,9 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) body = switch_event_get_body(message_event); type = switch_event_get_header(message_event, "type"); from_full = switch_event_get_header(message_event, "from_full"); - + blocking = switch_event_get_header(message_event, "blocking"); + is_blocking = switch_true(blocking); + network_ip = switch_event_get_header(message_event, "to_sip_ip"); network_port = switch_event_get_header(message_event, "to_sip_port"); @@ -320,6 +330,14 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) switch_snprintf(header, sizeof(header), "X-FS-Sending-Message: %s", switch_core_get_uuid()); + switch_uuid_str(uuid_str, sizeof(uuid_str)); + + if (is_blocking) { + switch_mutex_lock(profile->flag_mutex); + switch_core_hash_insert(profile->chat_hash, uuid_str, &mstatus); + switch_mutex_unlock(profile->flag_mutex); + } + nua_message(msg_nh, TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(route_uri, NUTAG_PROXY(route_uri)), @@ -327,13 +345,30 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) SIPTAG_FROM_STR(from), TAG_IF(contact, NUTAG_URL(contact)), SIPTAG_TO_STR(dup_dest), - + SIPTAG_CALL_ID_STR(uuid_str), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), SIPTAG_HEADER_STR(header), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); + + + if (is_blocking) { + sanity = 200; + + while(!mstatus && --sanity && !msg_nh->nh_destroyed) { + switch_yield(100000); + } + + if (!(mstatus > 199 && mstatus < 300)) { + status = SWITCH_STATUS_FALSE; + } + + switch_mutex_lock(profile->flag_mutex); + switch_core_hash_delete(profile->chat_hash, uuid_str); + switch_mutex_unlock(profile->flag_mutex); + } sofia_glue_free_destination(dst); switch_safe_free(dup_dest); @@ -534,16 +569,16 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event) sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," "full_via,expires,user_agent,accept,profile_name,network_ip" ",'%q',full_to,network_ip,network_port from sip_subscriptions " - "where hostname='%q' and profile_name='%q' and event='message-summary' " + "where hostname='%q' and event='message-summary' " "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", - stream.data, mod_sofia_globals.hostname, profile->name, user, host, host); + stream.data, mod_sofia_globals.hostname, user, host, host); } else if (sub_call_id) { sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," "full_via,expires,user_agent,accept,profile_name,network_ip" ",'%q',full_to,network_ip,network_port from sip_subscriptions where " - "hostname='%q' and profile_name='%q' and event='message-summary' " + "hostname='%q' and event='message-summary' " "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%') and call_id='%q'", - stream.data, mod_sofia_globals.hostname, profile->name, user, host, host, sub_call_id); + stream.data, mod_sofia_globals.hostname, user, host, host, sub_call_id); } @@ -555,13 +590,13 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event) } if (for_everyone) { - sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q' " - "from sip_registrations where hostname='%q' and profile_name='%q' and mwi_user='%q' and mwi_host='%q'", - stream.data, mod_sofia_globals.hostname, profile->name, user, host); + sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q',call_id " + "from sip_registrations where hostname='%q' and mwi_user='%q' and mwi_host='%q'", + stream.data, mod_sofia_globals.hostname, user, host); } else if (call_id) { - sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q' " - "from sip_registrations where hostname='%q' and profile_name='%q' and call_id='%q'", - stream.data, mod_sofia_globals.hostname, profile->name, call_id); + sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q',call_id " + "from sip_registrations where hostname='%q' and call_id='%q'", + stream.data, mod_sofia_globals.hostname, call_id); } if (sql) { @@ -858,7 +893,124 @@ static void do_dialog_probe(switch_event_t *event) switch_safe_free(probe_user); } +static void send_conference_data(sofia_profile_t *profile, switch_event_t *event) +{ + char *sql; + struct pres_sql_cb cb = {profile, 0}; + const char *call_id = switch_event_get_header(event, "call_id"); + const char *from_user = switch_event_get_header(event, "conference-name"); + const char *from_host = switch_event_get_header(event, "conference-domain"); + const char *event_str = switch_event_get_header(event, "conference-event"); + const char *notfound = switch_event_get_header(event, "notfound"); + const char *body = switch_event_get_body(event); + const char *type = "application/conference-info+xml"; + const char *final = switch_event_get_header(event, "final"); + + if (!event_str) { + event_str = "conference"; + } + if (!strcasecmp(event_str, "refer")) { + type = "message/sipfrag"; + } + + + if (!(from_user && from_host)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event information not given\n"); + return; + } + + if (switch_true(notfound)) { + sql = switch_mprintf("update sip_subscriptions set expires=%ld where " + "hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q'", + (long)switch_epoch_time_now(NULL), + mod_sofia_globals.hostname, profile->name, + from_user, from_host, event_str); + + sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + } + + if (call_id) { + sql = switch_mprintf("select full_to, full_from, contact %q ';_;isfocus', expires, call_id, event, network_ip, network_port, " + "'%q' as ct,'%q' as pt " + " from sip_subscriptions where " + "hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q'" + "and call_id = '%q' ", + switch_sql_concat(), + type, + switch_str_nil(body), + mod_sofia_globals.hostname, profile->name, + from_user, from_host, event_str, call_id); + } else { + sql = switch_mprintf("select full_to, full_from, contact %q ';_;isfocus', expires, call_id, event, network_ip, network_port, " + "'%q' as ct,'%q' as pt " + " from sip_subscriptions where " + "hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q'", + switch_sql_concat(), + type, + switch_str_nil(body), + mod_sofia_globals.hostname, profile->name, + from_user, from_host, event_str); + } + + sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_send_sql, &cb); + + if (switch_true(final)) { + sql = switch_mprintf("delete from sip_subscriptions where " + "hostname='%q' and profile_name='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q'", + mod_sofia_globals.hostname, profile->name, + from_user, from_host, event_str); + + sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + } + switch_safe_free(sql); + +} + +static void conference_data_event_handler(switch_event_t *event) +{ + const char *pname; + //const char *from_user = switch_event_get_header(event, "conference-name"); + //const char *from_host = switch_event_get_header(event, "conference-domain"); + const char *host = switch_event_get_header(event, "conference-domain"); + char *dup_domain = NULL; + sofia_profile_t *profile = NULL; + + if (zstr(host)) { + dup_domain = switch_core_get_variable_dup("domain"); + host = dup_domain; + } + + if ((pname = switch_event_get_header(event, "sofia-profile"))) { + profile = sofia_glue_find_profile(pname); + } + + if (host && !profile) { + profile = sofia_glue_find_profile(host); + } + + if (profile) { + send_conference_data(profile, event); + sofia_glue_release_profile(profile); + } else { + switch_console_callback_match_t *matches; + + if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { + switch_console_callback_match_node_t *m; + + for (m = matches->head; m; m = m->next) { + if ((profile = sofia_glue_find_profile(m->val))) { + send_conference_data(profile, event); + sofia_glue_release_profile(profile); + } + } + + switch_console_free_matches(&matches); + } + } + + switch_safe_free(dup_domain); +} static void actual_sofia_presence_event_handler(switch_event_t *event) { @@ -1072,15 +1224,16 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) continue; } + + if (mod_sofia_globals.debug_sla > 1) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA EVENT:\n"); + DUMP_EVENT(event); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CHECK CALL_INFO [%s]\n", switch_str_nil(call_info)); + } + if (call_info) { -#if 0 - if (mod_sofia_globals.debug_sla > 1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA EVENT:\n"); - DUMP_EVENT(event); - } -#endif - if (uuid) { sql = switch_mprintf("update sip_dialogs set call_info='%q',call_info_state='%q' where " "hostname='%q' and profile_name='%q' and uuid='%q'", @@ -1112,6 +1265,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) "sip_user='%q' and sip_host='%q'", rpid, status, mod_sofia_globals.hostname, profile->name, euser, host); sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); + proto = SOFIA_CHAT_PROTO; } if (zstr(uuid)) { @@ -1167,6 +1321,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) } } #endif + if (zstr(call_id) && (dh.hits && presence_source && (!strcasecmp(presence_source, "register") || switch_stristr("register", status)))) { goto done; @@ -1250,87 +1405,90 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) switch_str_nil(status), switch_str_nil(rpid), host, dh.status,dh.rpid,dh.presence_id, mod_sofia_globals.hostname, profile->name, call_id); - } + } - - helper.profile = profile; - helper.event = event; - SWITCH_STANDARD_STREAM(helper.stream); - switch_assert(helper.stream.data); + helper.hup = hup; + helper.calls_up = dh.hits; + helper.profile = profile; + helper.event = event; + SWITCH_STANDARD_STREAM(helper.stream); + switch_assert(helper.stream.data); - if (mod_sofia_globals.debug_presence > 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s START_PRESENCE_SQL (%s)\n", - event->event_id == SWITCH_EVENT_PRESENCE_IN ? "IN" : "OUT", profile->name); - } - - if (mod_sofia_globals.debug_presence) { - char *buf; - switch_event_serialize(event, &buf, SWITCH_FALSE); - switch_assert(buf); - if (mod_sofia_globals.debug_presence > 1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DUMP PRESENCE SQL:\n%s\nEVENT DUMP:\n%s\n", sql, buf); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "EVENT DUMP:\n%s\n", buf); + if (mod_sofia_globals.debug_presence > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s START_PRESENCE_SQL (%s)\n", + event->event_id == SWITCH_EVENT_PRESENCE_IN ? "IN" : "OUT", profile->name); } - free(buf); - } - sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_callback, &helper); - switch_safe_free(sql); - - if (mod_sofia_globals.debug_presence > 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_SQL (%s)\n", - event->event_id == SWITCH_EVENT_PRESENCE_IN ? "IN" : "OUT", profile->name); - } - - - if (hup) { - /* so many phones get confused when whe hangup we have to reprobe to get them all to reset to absolute states so the lights stay correct */ - switch_event_t *s_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(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"); - switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); - switch_event_fire(&s_event); + if (mod_sofia_globals.debug_presence) { + char *buf; + switch_event_serialize(event, &buf, SWITCH_FALSE); + switch_assert(buf); + if (mod_sofia_globals.debug_presence > 1) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DUMP PRESENCE SQL:\n%s\nEVENT DUMP:\n%s\n", sql, buf); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "EVENT DUMP:\n%s\n", buf); + } + free(buf); } - } + + sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_callback, &helper); + switch_safe_free(sql); - if (!zstr((char *) helper.stream.data)) { - char *this_sql = (char *) helper.stream.data; - char *next = NULL; - char *last = NULL; + if (mod_sofia_globals.debug_presence > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_SQL (%s)\n", + event->event_id == SWITCH_EVENT_PRESENCE_IN ? "IN" : "OUT", profile->name); + } + + + if (hup && dh.hits < 1) { + /* so many phones get confused when whe hangup we have to reprobe to get them all to reset to absolute states so the lights stay correct */ + switch_event_t *s_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(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"); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); + switch_event_fire(&s_event); + } + } + + + if (!zstr((char *) helper.stream.data)) { + char *this_sql = (char *) helper.stream.data; + char *next = NULL; + char *last = NULL; - do { - if ((next = strchr(this_sql, ';'))) { - *next++ = '\0'; - while (*next == '\n' || *next == ' ' || *next == '\r') { + do { + if ((next = strchr(this_sql, ';'))) { *next++ = '\0'; + while (*next == '\n' || *next == ' ' || *next == '\r') { + *next++ = '\0'; + } } - } - if (!zstr(this_sql) && (!last || strcmp(last, this_sql))) { - sofia_glue_execute_sql(profile, &this_sql, SWITCH_FALSE); - last = this_sql; - } - this_sql = next; - } while (this_sql); - } - switch_safe_free(helper.stream.data); - helper.stream.data = NULL; + if (!zstr(this_sql) && (!last || strcmp(last, this_sql))) { + sofia_glue_execute_sql(profile, &this_sql, SWITCH_FALSE); + last = this_sql; + } + this_sql = next; + } while (this_sql); + } + switch_safe_free(helper.stream.data); + helper.stream.data = NULL; - sofia_glue_release_profile(profile); + sofia_glue_release_profile(profile); + } } + switch_console_free_matches(&matches); } - switch_console_free_matches(&matches); -} -done: -switch_safe_free(sql); -switch_safe_free(user); + done: + + switch_safe_free(sql); + switch_safe_free(user); } static int EVENT_THREAD_RUNNING = 0; @@ -1359,32 +1517,28 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread while (mod_sofia_globals.running == 1) { int count = 0; - if (switch_queue_trypop(mod_sofia_globals.presence_queue, &pop) == SWITCH_STATUS_SUCCESS) { - switch_event_t *event = (switch_event_t *) pop; - - if (!pop) { - break; - } - actual_sofia_presence_event_handler(event); - switch_event_destroy(&event); - count++; - } - - if (switch_queue_trypop(mod_sofia_globals.mwi_queue, &pop) == SWITCH_STATUS_SUCCESS) { + if (switch_queue_pop(mod_sofia_globals.presence_queue, &pop) == SWITCH_STATUS_SUCCESS) { switch_event_t *event = (switch_event_t *) pop; if (!pop) { break; } - actual_sofia_presence_mwi_event_handler(event); + switch(event->event_id) { + case SWITCH_EVENT_MESSAGE_WAITING: + actual_sofia_presence_mwi_event_handler(event); + break; + case SWITCH_EVENT_CONFERENCE_DATA: + conference_data_event_handler(event); + break; + default: + actual_sofia_presence_event_handler(event); + break; + } + switch_event_destroy(&event); count++; } - - if (!count) { - switch_yield(100000); - } } while (switch_queue_trypop(mod_sofia_globals.presence_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { @@ -1392,11 +1546,6 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread switch_event_destroy(&event); } - while (switch_queue_trypop(mod_sofia_globals.mwi_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { - switch_event_t *event = (switch_event_t *) pop; - switch_event_destroy(&event); - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Event Thread Ended\n"); switch_mutex_lock(mod_sofia_globals.mutex); @@ -1446,34 +1595,31 @@ void sofia_presence_event_handler(switch_event_t *event) } } -void sofia_presence_mwi_event_handler(switch_event_t *event) -{ - switch_event_t *cloned_event; - - switch_event_dup(&cloned_event, event); - switch_assert(cloned_event); - switch_queue_push(mod_sofia_globals.mwi_queue, cloned_event); - - if (!EVENT_THREAD_STARTED) { - sofia_presence_event_thread_start(); - } -} - static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, char **columnNames) { sofia_profile_t *profile = (sofia_profile_t *) pArg; - char *user = argv[1]; + char *user = argv[3]; char *host = argv[2]; switch_event_t *event; char *event_name = argv[5]; char *expires = argv[10]; + + if (!strcasecmp(event_name, "message-summary")) { + if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", user, host); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "VM-sub-call-id", argv[7]); + + if (mod_sofia_globals.debug_presence > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Create MESSAGE QUERY EVENT...\n"); + DUMP_EVENT(event); + } + + switch_event_fire(&event); } return 0; @@ -1755,6 +1901,20 @@ static int sofia_dialog_probe_callback(void *pArg, int argc, char **argv, char * remote_user = to_user; remote_host = local_host; } + else if (proto && !strcasecmp(proto, "pickup")) { + local_user = to_user; + local_user_param = switch_mprintf(";proto=%s", proto); + event_status = "hold"; + if (skip_proto) { + buf_to_free = switch_mprintf("sip:%s", to_user); + } else { + buf_to_free = switch_mprintf("sip:pickup+%s", to_user); + } + remote_uri = buf_to_free; + strcpy(remote_display_buf, "pickup"); + remote_user = to_user; + remote_host = local_host; + } else if (proto && !strcasecmp(proto, "conf")) { local_user = to_user; local_user_param = switch_mprintf(";proto=%s", proto); @@ -1848,14 +2008,22 @@ static void _send_presence_notify(sofia_profile_t *profile, char *our_contact = profile->url, *our_contact_dup = NULL; sofia_destination_t *dst = NULL; - char *contact_str, *contact, *user_via = NULL; + char *contact_str, *contact, *user_via = NULL, *send_contact = NULL; char *route_uri = NULL, *o_contact_dup = NULL, *tmp, *to_uri, *dcs = NULL; const char *tp; + char *cparams = NULL; if (zstr(full_to) || zstr(full_from) || zstr(o_contact)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "MISSING DATA TO SEND NOTIFY.\n"); return; } + + if ((cparams = strstr(o_contact, ";_;"))) { + cparams += 3; + } + + + tmp = (char *)o_contact; o_contact_dup = sofia_glue_get_url_from_contact(tmp, 1); @@ -1989,6 +2157,12 @@ static void _send_presence_notify(sofia_profile_t *profile, callsequence = ++profile->cseq_base; switch_mutex_unlock(profile->ireg_mutex); + if (cparams) { + send_contact = switch_mprintf("%s;%s", contact_str, cparams); + contact_str = send_contact; + } + + nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_CONTACT_STR(contact_str), TAG_END()); cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY); @@ -2024,6 +2198,7 @@ static void _send_presence_notify(sofia_profile_t *profile, sofia_glue_free_destination(dst); switch_safe_free(user_via); switch_safe_free(o_contact_dup); + switch_safe_free(send_contact); switch_safe_free(our_contact_dup); @@ -2173,6 +2348,10 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r prpid = "onthephone"; } + if (zstr(open)) { + open = "open"; + } + ret = switch_mprintf("\n" "\n" "\n" @@ -2414,6 +2593,10 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * is_dialog = !strcmp(event, "dialog"); + if (helper->hup && helper->calls_up > 0 && (!is_dialog || !user_agent || !switch_stristr("polycom", user_agent) || !switch_stristr("snom", user_agent))) { + goto end; + } + if (helper->event) { switch_stream_handle_t stream = { 0 }; const char *direction = switch_str_nil(switch_event_get_header(helper->event, "presence-call-direction")); @@ -2433,6 +2616,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * int force_status = 0; const char *call_state = switch_event_get_header(helper->event, "channel-state"); char *call_info_state = switch_event_get_header(helper->event, "presence-call-info-state"); + int term = 0; if (user_agent && switch_stristr("snom", user_agent) && uuid) { default_dialog = "full" ; @@ -2440,18 +2624,21 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * if (call_state && !strcasecmp(call_state, "cs_hangup")) { astate = "hangup"; - } + holding = 0; + term = 1; + } else { - if (event_status && !strncasecmp(event_status, "hold", 4)) { - holding = 1; - } + if (event_status && !strncasecmp(event_status, "hold", 4)) { + holding = 1; + } - if (force_event_status && !event_status) { - event_status = force_event_status; - } + if (force_event_status && !event_status) { + event_status = force_event_status; + } - if (event_status && !strncasecmp(event_status, "hold", 4)) { - holding = 1; + if (event_status && !strncasecmp(event_status, "hold", 4)) { + holding = 1; + } } if (!strcasecmp(direction, "inbound")) { @@ -2620,6 +2807,18 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * stream.write_function(&stream, "\n", uuid); } stream.write_function(&stream, "\n"); + } else if (!strcasecmp(proto, "pickup")) { + stream.write_function(&stream, "\nsip:%s@%s;proto=pickup\n", + !zstr(clean_to_user) ? clean_to_user : "unknown", host); + stream.write_function(&stream, "\n", !zstr(clean_to_user) ? clean_to_user : "unknown", host); + stream.write_function(&stream, "\n\n\n"); + stream.write_function(&stream, "\nsip:%s\n", uuid); + if (skip_proto) { + stream.write_function(&stream, "\n", uuid); + } else { + stream.write_function(&stream, "\n", uuid); + } + stream.write_function(&stream, "\n"); } else if (!strcasecmp(proto, "conf")) { stream.write_function(&stream, "\nsip:%s@%s;proto=conference\n", !zstr(clean_to_user) ? clean_to_user : "unknown", host); @@ -2666,8 +2865,6 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * open = "open"; if (switch_false(resub)) { - int term; - const char *direction = switch_event_get_header(helper->event, "Caller-Direction"); const char *op, *what = "Ring"; @@ -2689,7 +2886,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * if (!zstr(op)) { //switch_snprintf(status_line, sizeof(status_line), "%sing", what); //} else { - switch_snprintf(status_line, sizeof(status_line), "%s %s", what, op); + if (sofia_test_pflag(profile, PFLAG_PRESENCE_PRIVACY)) { + switch_snprintf(status_line, sizeof(status_line), "%s", what); + } else { + switch_snprintf(status_line, sizeof(status_line), "%s %s", what, op); + } } rpid = "on-the-phone"; @@ -2718,7 +2919,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * if (!term && !strcmp(status, "hold")) { rpid = "on-the-phone"; if (!zstr(op)) { - switch_snprintf(status_line, sizeof(status_line), "Hold %s", op); + if (sofia_test_pflag(profile, PFLAG_PRESENCE_PRIVACY)) { + switch_snprintf(status_line, sizeof(status_line), "Hold"); + } else { + switch_snprintf(status_line, sizeof(status_line), "Hold %s", op); + } force_status = 1; } } @@ -2727,7 +2932,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * open = "closed"; } - if (open_closed) { + if (!zstr(open_closed)) { open = open_closed; } @@ -2759,7 +2964,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * open = "closed"; } - if (open_closed) { + if (!zstr(open_closed)) { open = open_closed; } @@ -2874,6 +3079,7 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char const char *body = argv[5]; const char *o_contact = argv[2]; const char *network_ip = argv[4]; + const char *call_id = argv[6]; char *profile_name = argv[3]; struct mwi_helper *h = (struct mwi_helper *) pArg; @@ -2885,7 +3091,11 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char } } - sofia_glue_send_notify(profile, user, host, event, contenttype, body, o_contact, network_ip); + if (!sofia_test_pflag(profile, PFLAG_MWI_USE_REG_CALLID)) { + call_id = NULL; + } + + sofia_glue_send_notify(profile, user, host, event, contenttype, body, o_contact, network_ip, call_id); if (ext_profile) { sofia_glue_release_profile(ext_profile); @@ -3132,7 +3342,7 @@ static int sync_sla(sofia_profile_t *profile, const char *to_user, const char *t switch_core_hash_init(&sh->hash, sh->pool); sql = switch_mprintf("select sip_from_user,sip_from_host,call_info,call_info_state,uuid from sip_dialogs " - "where call_info_state is not null and hostname='%q' and profile_name='%q' " + "where call_info_state is not null and call_info_state != '' and hostname='%q' and profile_name='%q' " "and ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q') " "and profile_name='%q'", mod_sofia_globals.hostname, profile->name, to_user, to_host, to_user, to_host, profile->name); @@ -3228,7 +3438,9 @@ void sofia_presence_handle_sip_i_subscribe(int status, int sent_reply = 0; sip_contact_t const *contact; const char *ipv6; - const char *contact_user; + const char *contact_user = NULL; + const char *contact_host = NULL; + const char *contact_port = NULL; sofia_nat_parse_t np = { { 0 } }; int found_proto = 0; char to_tag[13] = ""; @@ -3250,8 +3462,11 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_stun_random_string(to_tag, 12, NULL); - //contact_host = sip->sip_contact->m_url->url_host; - contact_user = sip->sip_contact->m_url->url_user; + if ( sip->sip_contact && sip->sip_contact->m_url ) { + contact_host = sip->sip_contact->m_url->url_host; + contact_port = sip->sip_contact->m_url->url_port; + contact_user = sip->sip_contact->m_url->url_user; + } //tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END()); @@ -3355,7 +3570,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, if ((subbed = atoi(buf)) > 0) { sub_state = nua_substate_active; - } + } } if (sub_state == nua_substate_active) { @@ -3385,12 +3600,12 @@ void sofia_presence_handle_sip_i_subscribe(int status, "sub del sql: %s\n", sql); } - switch_mutex_lock(profile->ireg_mutex); switch_assert(sql != NULL); - sofia_glue_actually_execute_sql(profile, sql, NULL); + sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex); switch_safe_free(sql); sstr = switch_mprintf("terminated;reason=noresource"); + } else { sip_accept_t *ap = sip->sip_accept; char accept[256] = ""; @@ -3426,7 +3641,6 @@ void sofia_presence_handle_sip_i_subscribe(int status, sstr = switch_mprintf("active;expires=%ld", exp_delta); } - switch_mutex_unlock(profile->ireg_mutex); } if (status < 200) { @@ -3493,6 +3707,13 @@ void sofia_presence_handle_sip_i_subscribe(int status, switch_safe_free(new_contactstr); switch_safe_free(sticky); + + if (sub_state == nua_substate_terminated) { + nua_notify(nh, + SIPTAG_EXPIRES_STR("0"), + SIPTAG_SUBSCRIPTION_STATE_STR(sstr), + TAG_END()); + } } if (sub_state == nua_substate_terminated) { @@ -3567,7 +3788,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, now = switch_epoch_time_now(NULL); sql = switch_mprintf("insert into sip_dialogs (sip_from_user,sip_from_host,call_info,call_info_state,hostname,expires,rcd,profile_name) " - "values ('%q','%q','%q','seized','%q',%ld,%ld,'%q')", + "values ('%q','%q','%q','seized','%q',%"TIME_T_FMT",%ld,'%q')", to_user, to_host, switch_str_nil(p), mod_sofia_globals.hostname, switch_epoch_time_now(NULL) + exp_delta, (long)now, profile->name); @@ -3592,14 +3813,61 @@ void sofia_presence_handle_sip_i_subscribe(int status, if ((sql = switch_mprintf("select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from," "full_via,expires,user_agent,accept,profile_name,network_ip" " from sip_subscriptions where hostname='%q' and profile_name='%q' and " - "event='message-summary' and sip_user='%q' " + "event='message-summary' and sub_to_user='%q' " "and (sip_host='%q' or presence_hosts like '%%%q%%')", to_host, mod_sofia_globals.hostname, profile->name, to_user, to_host, to_host))) { + + if (mod_sofia_globals.debug_presence > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "SUBSCRIBE MWI SQL: %s\n", sql); + } + + sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_reg_callback, profile); switch_safe_free(sql); } + } else if (!strcasecmp(event, "conference")) { + switch_event_t *event; + switch_event_create(&event, SWITCH_EVENT_CONFERENCE_DATA_QUERY); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Name", to_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Domain", to_host); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Query-From", from_user); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Query-From-Domain", from_host); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-Id", call_id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Sofia-Profile", profile->name); + switch_event_fire(&event); + } else if ( sip->sip_event && sip->sip_event->o_type && !strcasecmp(sip->sip_event->o_type, "ua-profile") && contact_host ) { + switch_event_t *params; + char *uri = NULL; + char *extra_headers = NULL; + + if ( contact_port ) { + uri = switch_mprintf("sip:%s:%s", contact_host, contact_port); + } else { + uri = switch_mprintf("sip:%s", contact_host); + } + + if ( uri ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending pnp NOTIFY to %s\n", uri); + + /* Grandstream REALLY uses a header called Message Body */ + extra_headers = switch_mprintf("MessageBody: %s\r\n", profile->pnp_prov_url); + + switch_event_create(¶ms, SWITCH_EVENT_NOTIFY); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile->pnp_notify_profile); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "event-string", sip->sip_event->o_type); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "to-uri", uri); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from-uri", uri); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "extra-headers", extra_headers); + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "content-type", "application/url"); + switch_event_add_body(params, "%s", profile->pnp_prov_url); + switch_event_fire(¶ms); + + switch_safe_free(uri); + switch_safe_free(extra_headers); + } } end: @@ -3774,10 +4042,10 @@ void sofia_presence_handle_sip_r_subscribe(int status, gw_sub_ptr->state = SUB_STATE_FAILED; if (sofia_private) { - if (sofia_private->gateway->sub_nh) { - nua_handle_bind(sofia_private->gateway->sub_nh, NULL); - nua_handle_destroy(sofia_private->gateway->sub_nh); - sofia_private->gateway->sub_nh = NULL; + 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 { nua_handle_destroy(nh); @@ -4000,7 +4268,9 @@ void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip) void sofia_presence_handle_sip_i_message(int status, char const *phrase, - nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, + nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, + switch_core_session_t *session, + sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]) { @@ -4016,6 +4286,12 @@ void sofia_presence_handle_sip_i_message(int status, const char *us; char network_ip[80]; int network_port = 0; + switch_channel_t *channel = NULL; + + + if (session) { + channel = switch_core_session_get_channel(session); + } if ((us = sofia_glue_get_unknown_header(sip, "X-FS-Sending-Message")) && !strcmp(us, switch_core_get_uuid())) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not sending message to ourselves!\n"); @@ -4053,7 +4329,7 @@ void sofia_presence_handle_sip_i_message(int status, if (nh) { char hash_key[512]; private_object_t *tech_pvt; - switch_event_t *event; + switch_event_t *event, *event_dup; char *to_addr; char *from_addr; char *p; @@ -4111,6 +4387,28 @@ void sofia_presence_handle_sip_i_message(int status, if (msg) { switch_event_add_body(event, "%s", msg); } + + if (channel) { + switch_channel_event_set_data(channel, event); + } + + + if (sofia_test_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS)) { + if (switch_event_dup(&event_dup, event) == SWITCH_STATUS_SUCCESS) { + event_dup->event_id = SWITCH_EVENT_RECV_MESSAGE; + event_dup->flags |= EF_UNIQ_HEADERS; + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Name", switch_event_name(event->event_id)); + switch_event_fire(&event_dup); + } + } + + if (session) { + if (switch_event_dup(&event_dup, event) == SWITCH_STATUS_SUCCESS) { + switch_core_session_queue_event(session, &event_dup); + } + } + + } else { abort(); } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 81b8da1696..ccc8a4c901 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -65,26 +65,27 @@ static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr, int attach) } } -static void sofia_reg_new_sub_handle(sofia_gateway_t *gateway_ptr, int attach) -{ +static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr, int attach) +{ + 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); } - - if (gateway_ptr->sub_nh) { - nua_handle_bind(gateway_ptr->sub_nh, NULL); - nua_handle_destroy(gateway_ptr->sub_nh); - gateway_ptr->sub_nh = NULL; + + 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; sofia_private_free(gateway_ptr->sofia_private); } - - gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL, - NUTAG_URL(gateway_ptr->register_proxy), + + gw_sub_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL, + NUTAG_URL(gateway_ptr->register_proxy), 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()); @@ -96,31 +97,32 @@ static void sofia_reg_new_sub_handle(sofia_gateway_t *gateway_ptr, int attach) memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); gateway_ptr->sofia_private->gateway = gateway_ptr; - nua_handle_bind(gateway_ptr->sub_nh, gateway_ptr->sofia_private); + nua_handle_bind(gw_sub_ptr->nh, gateway_ptr->sofia_private); } switch_safe_free(register_host); switch_safe_free(user_via); } -static void sofia_reg_kill_sub(sofia_gateway_t *gateway_ptr) -{ +static void sofia_reg_kill_sub(sofia_gateway_subscription_t *gw_sub_ptr) +{ + sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway; - if (gateway_ptr->sub_nh) { - nua_handle_bind(gateway_ptr->sub_nh, NULL); + if (gw_sub_ptr->nh) { + nua_handle_bind(gw_sub_ptr->nh, NULL); } - - if (gateway_ptr->sub_state != SUB_STATE_SUBED && gateway_ptr->sub_state != SUB_STATE_UNSUBSCRIBE) { - if (gateway_ptr->sub_nh) { - nua_handle_destroy(gateway_ptr->sub_nh); - gateway_ptr->sub_nh = NULL; + + if (gw_sub_ptr->state != SUB_STATE_SUBED && gw_sub_ptr->state != SUB_STATE_UNSUBSCRIBE) { + if (gw_sub_ptr->nh) { + nua_handle_destroy(gw_sub_ptr->nh); + gw_sub_ptr->nh = NULL; } return; } - if (gateway_ptr->sub_nh) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Subbing %s\n", gateway_ptr->name); - nua_unsubscribe(gateway_ptr->sub_nh, NUTAG_URL(gateway_ptr->register_url), TAG_END()); + if (gw_sub_ptr->nh) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Subbing %s %s\n", gateway_ptr->name, gw_sub_ptr->event); + nua_unsubscribe(gw_sub_ptr->nh, NUTAG_URL(gw_sub_ptr->request_uri), TAG_END()); } } @@ -182,7 +184,7 @@ void sofia_reg_unregister(sofia_profile_t *profile) 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(gateway_ptr); + sofia_reg_kill_sub(gw_sub_ptr); } } @@ -211,7 +213,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) gw_sub_ptr->expires_str = "0"; } - gateway_ptr->sub_state = gw_sub_ptr->state; + //gateway_ptr->sub_state = gw_sub_ptr->state; switch (ostate) { case SUB_STATE_NOSUB: @@ -222,19 +224,19 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) break; case SUB_STATE_UNSUBSCRIBE: gw_sub_ptr->state = SUB_STATE_NOSUB; - sofia_reg_kill_sub(gateway_ptr); + sofia_reg_kill_sub(gw_sub_ptr); break; case SUB_STATE_UNSUBED: - sofia_reg_new_sub_handle(gateway_ptr, 1); + sofia_reg_new_sub_handle(gw_sub_ptr, 1); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); - + if (now) { - nua_subscribe(gateway_ptr->sub_nh, - NUTAG_URL(gateway_ptr->register_url), + nua_subscribe(gw_sub_ptr->nh, + NUTAG_URL(gw_sub_ptr->request_uri), SIPTAG_EVENT_STR(gw_sub_ptr->event), - SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), + TAG_IF(strcmp(gw_sub_ptr->content_type, "NO_CONTENT_TYPE"), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type)), SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_CONTACT_STR(gateway_ptr->register_contact), @@ -242,10 +244,10 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) TAG_NULL()); gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds; } else { - nua_unsubscribe(gateway_ptr->sub_nh, - NUTAG_URL(gateway_ptr->register_url), + nua_unsubscribe(gw_sub_ptr->nh, + NUTAG_URL(gw_sub_ptr->request_uri), SIPTAG_EVENT_STR(gw_sub_ptr->event), - SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), + TAG_IF(strcmp(gw_sub_ptr->content_type, "NO_CONTENT_TYPE"), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type)), SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), TAG_NULL()); @@ -428,6 +430,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) gateway_ptr->status = SOFIA_GATEWAY_DOWN; nua_unregister(gateway_ptr->nh, NUTAG_URL(gateway_ptr->register_url), + TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->distinct_to ? gateway_ptr->register_to : gateway_ptr->register_from), @@ -550,15 +553,16 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames { sofia_profile_t *profile = (sofia_profile_t *) pArg; nua_handle_t *nh; - char to[128] = ""; + char to[512] = ""; sofia_destination_t *dst = NULL; switch_snprintf(to, sizeof(to), "sip:%s@%s", argv[1], argv[2]); + dst = sofia_glue_get_destination(argv[3]); switch_assert(dst); nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url), - TAG_END()); + SIPTAG_CALL_ID_STR(argv[0]), TAG_END()); nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_options(nh, NTATAG_SIP_T2(5000), @@ -571,7 +575,7 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames } -void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, +void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip) { const char *event = "check-sync"; @@ -586,7 +590,7 @@ void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const cha event = "reboot"; } - sofia_glue_send_notify(profile, user, host, event, contenttype, body, contact, network_ip); + sofia_glue_send_notify(profile, user, host, event, contenttype, body, contact, network_ip, callid); } int sofia_sla_dialog_del_callback(void *pArg, int argc, char **argv, char **columnNames) @@ -607,7 +611,7 @@ int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames sofia_profile_t *profile = (sofia_profile_t *) pArg; if (argc > 12 && atoi(argv[12]) == 1) { - sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7], argv[11]); + sofia_reg_send_reboot(profile, argv[0], argv[1], argv[2], argv[3], argv[7], argv[11]); } if (argc >= 3) { @@ -786,7 +790,7 @@ int sofia_reg_check_callback(void *pArg, int argc, char **argv, char **columnNam { sofia_profile_t *profile = (sofia_profile_t *) pArg; - sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7], argv[11]); + sofia_reg_send_reboot(profile, argv[0], argv[1], argv[2], argv[3], argv[7], argv[11]); return 0; } @@ -992,6 +996,30 @@ uint32_t sofia_reg_reg_count(sofia_profile_t *profile, const char *user, const c return atoi(buf); } +static int debounce_check(sofia_profile_t *profile, const char *user, const char *host) +{ + char key[512] = ""; + int r = 0; + time_t *last, now = switch_epoch_time_now(NULL); + + snprintf(key, sizeof(key), "%s%s", user, host); + + if ((last = switch_core_hash_find(profile->mwi_debounce_hash, key))) { + if (now - *last > 30) { + *last = now; + r = 1; + } + } else { + last = switch_core_alloc(profile->pool, sizeof(*last)); + *last = now; + switch_core_hash_insert(profile->mwi_debounce_hash, key, last); + r = 1; + } + + return r; +} + + uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_dispatch_event_t *de, sofia_regtype_t regtype, char *key, uint32_t keylen, switch_event_t **v_event, const char *is_nat) @@ -1003,6 +1031,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand sip_contact_t const *contact = NULL; char *sql; switch_event_t *s_event; + const char *reg_meta = NULL; const char *to_user = NULL; const char *to_host = NULL; char *mwi_account = NULL; @@ -1460,6 +1489,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand to_user = var; } + if (v_event && *v_event && (var = switch_event_get_header(*v_event, "registration_metadata"))) { + reg_meta = var; + } + if (v_event && *v_event && (mwi_account = switch_event_get_header(*v_event, "mwi-account"))) { dup_mwi_account = strdup(mwi_account); switch_assert(dup_mwi_account != NULL); @@ -1534,7 +1567,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand url = switch_mprintf("sofia/%q/sip:%q", profile->name, sofia_glue_strip_proto(contact)); switch_core_add_registration(to_user, reg_host, call_id, url, (long) switch_epoch_time_now(NULL) + (long) exptime + 60, - network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp"); + network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp", reg_meta); switch_safe_free(url); switch_safe_free(contact); @@ -1667,11 +1700,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand if (contact) { if (exptime) { + int debounce_ok = debounce_check(profile, mwi_user, mwi_host); + switch_snprintf(exp_param, sizeof(exp_param), "expires=%ld", exptime); sip_contact_add_param(nua_handle_home(nh), sip->sip_contact, exp_param); - - if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) || - (reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) { + + if ((sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) || + (reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) && debounce_ok) { + if (switch_event_create(&s_mwi_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(s_mwi_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", mwi_user, mwi_host); switch_event_add_header_string(s_mwi_event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name); @@ -1679,9 +1715,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand } } - if (sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) || + if ((sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) || (reg_count == 1 && sofia_test_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER)) - || send_pres == 1 || (reg_count == 1 && send_pres == 2)) { + || send_pres == 1 || (reg_count == 1 && send_pres == 2)) && debounce_ok) { if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) { if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) { @@ -2091,6 +2127,10 @@ void sofia_reg_handle_sip_r_challenge(int status, switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "action", "reverse-auth-lookup"); + if ( sip->sip_call_id ) { + switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "sip_call_id", sip->sip_call_id->i_id); + } + if (switch_xml_locate_user_merged("id", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, NULL, &x_user, locate_params) == SWITCH_STATUS_SUCCESS) { if ((x_params = switch_xml_child(x_user, "params"))) { diff --git a/src/mod/endpoints/mod_unicall/mod_unicall.c b/src/mod/endpoints/mod_unicall/mod_unicall.c index e835647385..75680bd243 100644 --- a/src/mod/endpoints/mod_unicall/mod_unicall.c +++ b/src/mod/endpoints/mod_unicall/mod_unicall.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2008, Anthony Minessale II + * Copyright (C) 2005/2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/event_handlers/mod_cdr_mongodb/Makefile b/src/mod/event_handlers/mod_cdr_mongodb/Makefile index b9e04b983d..6a412a0f66 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/Makefile +++ b/src/mod/event_handlers/mod_cdr_mongodb/Makefile @@ -2,8 +2,8 @@ include ../../../../build/modmake.rules MONGODB_DRIVER=./driver/src LOCAL_CFLAGS=-I$(MONGODB_DRIVER) -LOCAL_OBJS=$(MONGODB_DRIVER)/md5.o \ - $(MONGODB_DRIVER)/mongo.o $(MONGODB_DRIVER)/net.o \ - $(MONGODB_DRIVER)/bson.o $(MONGODB_DRIVER)/numbers.o $(MONGODB_DRIVER)/encoding.o \ +LOCAL_OBJS=$(MONGODB_DRIVER)/encoding.o $(MONGODB_DRIVER)/env_posix.o \ + $(MONGODB_DRIVER)/bson.o $(MONGODB_DRIVER)/md5.o \ + $(MONGODB_DRIVER)/mongo.o $(MONGODB_DRIVER)/numbers.o local_depend: $(LOCAL_OBJS) diff --git a/src/mod/event_handlers/mod_cdr_mongodb/conf/autoload_configs/cdr_mongodb.conf.xml b/src/mod/event_handlers/mod_cdr_mongodb/conf/autoload_configs/cdr_mongodb.conf.xml index ce366d1bd0..e1daf62ada 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/conf/autoload_configs/cdr_mongodb.conf.xml +++ b/src/mod/event_handlers/mod_cdr_mongodb/conf/autoload_configs/cdr_mongodb.conf.xml @@ -1,6 +1,6 @@ - + diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/HISTORY.md b/src/mod/event_handlers/mod_cdr_mongodb/driver/HISTORY.md index f3f0fab21d..1659192909 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/HISTORY.md +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/HISTORY.md @@ -1,5 +1,35 @@ # MongoDB C Driver History +## 0.5.2 +2012-5-4 + +* Validate collection and database names on insert. +* Validate insert limits using max BSON size. +* Support getaddrinfo and SO_RCVTIMEO and SO_SNDTIMEO on Windows. +* Store errno/WSAGetLastError() on errors. +* Various bug fixes and refactorings. +* Update error reporting docs. + +## 0.5.1 + +* Env for POSIX, WIN32, and standard C. +* Various bug fixes. + +## 0.5 +2012-3-31 + +* Separate cursor-specific errors into their own enum: mongo_cursor_error_t. +* Catch $err return on bad queries and store the result in conn->getlasterrorcode + and conn->getlasterrstr. +* On queries that return $err, set cursor->err to MONGO_CURSOR_QUERY_FAIL. +* When passing bad BSON to a cursor object, set cursor->err to MONGO_CURSOR_BSON_ERROR, + and store the specific BSON error on the conn->err field. +* Remove bson_copy_basic(). +* bson_copy() will copy finished bson objects only. +* bson_copy() returns BSON_OK on success and BSON_ERROR on failure. +* Added a Makefile for easy compile and install on Linux and OS X. +* Replica set connect fixes. + ## 0.4 THIS RELEASE INCLUDES NUMEROUS BACKWARD-BREAKING CHANGES. diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/README.md b/src/mod/event_handlers/mod_cdr_mongodb/driver/README.md index 1afe39e69c..d8c7526683 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/README.md +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/README.md @@ -12,9 +12,9 @@ Until the 1.0 release, this driver should be considered alpha. Keep in mind that # Building First check out the version you want to build. *Always build from a particular tag, since HEAD may be -a work in progress.* For example, to build version 0.4, run: +a work in progress.* For example, to build version 0.5.2, run: - git checkout v0.4 + git checkout v0.5.2 You can then build the driver with scons: diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/SConstruct b/src/mod/event_handlers/mod_cdr_mongodb/driver/SConstruct deleted file mode 100644 index d3be2d89a6..0000000000 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/SConstruct +++ /dev/null @@ -1,178 +0,0 @@ -# -*- mode: python; -*- - -VERSION = "0.4" - -# --- options ---- -AddOption('--test-server', - dest='test_server', - default='127.0.0.1', - type='string', - nargs=1, - action='store', - help='IP address of server to use for testing') - -AddOption('--seed-start-port', - dest='seed_start_port', - default=30000, - type='int', - nargs=1, - action='store', - help='IP address of server to use for testing') - -AddOption('--c99', - dest='use_c99', - default=False, - action='store_true', - help='Compile with c99 (recommended for gcc)') - -AddOption('--d', - dest='optimize', - default=True, - action='store_false', - help='disable optimizations') - -AddOption('--use-platform', - dest='compile_platform', - default='GENERIC', - type='string', - nargs=1, - action='store', - help='Compile for a specific platform to take advantage ' - ' of particular system features. For the moment, this include timeouts only.' - ' Current options include LINUX, ' - ' GENERIC, and CUSTOM. If you specific CUSTOM, you must place a' - ' system-specific implementation of net.h and net.c in src/platform/custom/') - -import os, sys - -env = Environment( ENV=os.environ ) - -# ---- Docs ---- -def build_docs(env, target, source): - buildscript_path = os.path.join(os.path.abspath("docs")) - sys.path.insert(0, buildscript_path) - import buildscripts - from buildscripts import docs - docs.main() - -env.Alias("docs", [], [build_docs]) -env.AlwaysBuild("docs") - -# ---- Platforms ---- -PLATFORM_TEST_DIR = None -if "LINUX" == GetOption('compile_platform'): - env.Append( CPPFLAGS=" -D_MONGO_USE_LINUX_SYSTEM" ) - NET_LIB = "src/platform/linux/net.c" - PLATFORM_TEST_DIR = "test/platform/linux/" - PLATFORM_TESTS = [ "timeouts" ] -elif "CUSTOM" == GetOption('compile_platform'): - env.Append( CPPFLAGS=" -D_MONGO_USE_CUSTOM_SYSTEM" ) - NET_LIB = "src/platform/custom/net.c" -else: - NET_LIB = "src/net.c" - -# ---- Libraries ---- -if os.sys.platform in ["darwin", "linux2"]: - env.Append( CPPFLAGS=" -pedantic -Wall -ggdb -DMONGO_HAVE_STDINT" ) - env.Append( CPPPATH=["/opt/local/include/"] ) - env.Append( LIBPATH=["/opt/local/lib/"] ) - - if GetOption('use_c99'): - env.Append( CFLAGS=" -std=c99 " ) - env.Append( CXXDEFINES="MONGO_HAVE_STDINT" ) - else: - env.Append( CFLAGS=" -ansi " ) - - if GetOption('optimize'): - env.Append( CPPFLAGS=" -O3 " ) - # -O3 benchmarks *significantly* faster than -O2 when disabling networking -elif 'win32' == os.sys.platform: - env.Append( LIBS='ws2_32' ) - -#we shouldn't need these options in c99 mode -if not GetOption('use_c99'): - conf = Configure(env) - - if not conf.CheckType('int64_t'): - if conf.CheckType('int64_t', '#include \n'): - conf.env.Append( CPPDEFINES="MONGO_HAVE_STDINT" ) - elif conf.CheckType('int64_t', '#include \n'): - conf.env.Append( CPPDEFINES="MONGO_HAVE_UNISTD" ) - elif conf.CheckType('__int64'): - conf.env.Append( CPPDEFINES="MONGO_USE__INT64" ) - elif conf.CheckType('long long int'): - conf.env.Append( CPPDEFINES="MONGO_USE_LONG_LONG_INT" ) - else: - print "*** what is your 64 bit int type? ****" - Exit(1) - - env = conf.Finish() - -have_libjson = False -conf = Configure(env) -if conf.CheckLib('json'): - have_libjson = True -env = conf.Finish() - -if sys.byteorder == 'big': - env.Append( CPPDEFINES="MONGO_BIG_ENDIAN" ) - -env.Append( CPPPATH=["src/"] ) - -coreFiles = ["src/md5.c" ] -mFiles = [ "src/mongo.c", NET_LIB, "src/gridfs.c"] -bFiles = [ "src/bson.c", "src/numbers.c", "src/encoding.c"] -mLibFiles = coreFiles + mFiles + bFiles -bLibFiles = coreFiles + bFiles -m = env.Library( "mongoc" , mLibFiles ) -b = env.Library( "bson" , bLibFiles ) -env.Default( env.Alias( "lib" , [ m[0] , b[0] ] ) ) - -if os.sys.platform == "linux2": - env.Append( SHLINKFLAGS="-shared -Wl,-soname,libmongoc.so." + VERSION ) - env.Append( SHLINKFLAGS = "-shared -Wl,-soname,libbson.so." + VERSION ) - -dynm = env.SharedLibrary( "mongoc" , mLibFiles ) -dynb = env.SharedLibrary( "bson" , bLibFiles ) -env.Default( env.Alias( "sharedlib" , [ dynm[0] , dynb[0] ] ) ) - - - -# ---- Benchmarking ---- -benchmarkEnv = env.Clone() -benchmarkEnv.Append( CPPDEFINES=[('TEST_SERVER', r'\"%s\"'%GetOption('test_server')), -('SEED_START_PORT', r'%d'%GetOption('seed_start_port'))] ) -benchmarkEnv.Append( LIBS=[m, b] ) -benchmarkEnv.Prepend( LIBPATH=["."] ) -benchmarkEnv.Program( "benchmark" , [ "test/benchmark.c"] ) - -# ---- Tests ---- -testEnv = benchmarkEnv.Clone() -testCoreFiles = [ ] - -def run_tests( root, tests ): - for name in tests: - filename = "%s/%s.c" % (root, name) - exe = "test_" + name - test = testEnv.Program( exe , testCoreFiles + [filename] ) - test_alias = testEnv.Alias('test', [test], test[0].abspath + ' 2> ' + os.path.devnull) - AlwaysBuild(test_alias) - -tests = Split("sizes resize endian_swap bson bson_subobject simple update errors " -"count_delete auth gridfs validate examples helpers oid functions cursors replica_set") - -# Run standard tests -run_tests("test", tests) - -# Run platform tests -if not PLATFORM_TEST_DIR is None: - run_tests( PLATFORM_TEST_DIR, PLATFORM_TESTS ) - -if have_libjson: - tests.append('json') - testEnv.Append( LIBS=["json"] ) - -# special case for cpptest -test = testEnv.Program( 'test_cpp' , testCoreFiles + ['test/cpptest.cpp'] ) -test_alias = testEnv.Alias('test', [test], test[0].abspath + ' 2> '+ os.path.devnull) -AlwaysBuild(test_alias) diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.c index 349f42284c..26d17d8696 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.c @@ -33,7 +33,11 @@ static const int zero = 0; void *( *bson_malloc_func )( size_t ) = malloc; void *( *bson_realloc_func )( void *, size_t ) = realloc; void ( *bson_free )( void * ) = free; +#ifdef R_SAFETY_NET +bson_printf_func bson_printf; +#else bson_printf_func bson_printf = printf; +#endif bson_fprintf_func bson_fprintf = fprintf; bson_sprintf_func bson_sprintf = sprintf; @@ -48,33 +52,32 @@ static int ( *oid_inc_func )( void ) = NULL; READING ------------------------------ */ -bson *bson_empty( bson *obj ) { +MONGO_EXPORT bson* bson_create() { + return (bson*)bson_malloc(sizeof(bson)); +} + +MONGO_EXPORT void bson_dispose(bson* b) { + bson_free(b); +} + +MONGO_EXPORT bson *bson_empty( bson *obj ) { static char *data = "\005\0\0\0\0"; bson_init_data( obj, data ); obj->finished = 1; obj->err = 0; + obj->errstr = NULL; obj->stackPos = 0; return obj; } -void bson_copy_basic( bson *out, const bson *in ) { - if ( !out ) return; +MONGO_EXPORT int bson_copy( bson *out, const bson *in ) { + if ( !out ) return BSON_ERROR; + if ( !in->finished ) return BSON_ERROR; bson_init_size( out, bson_size( in ) ); memcpy( out->data, in->data, bson_size( in ) ); -} + out->finished = 1; -void bson_copy( bson *out, const bson *in ) { - int i; - - if ( !out ) return; - bson_copy_basic( out, in ); - out->cur = out->data + ( in->cur - in->data ); - out->dataSize = in->dataSize; - out->finished = in->finished; - out->stackPos = in->stackPos; - out->err = in->err; - for( i=0; istackPos; i++ ) - out->stack[i] = in->stack[i]; + return BSON_OK; } int bson_init_data( bson *b, char *data ) { @@ -82,6 +85,12 @@ int bson_init_data( bson *b, char *data ) { return BSON_OK; } +int bson_init_finished_data( bson *b, char *data ) { + bson_init_data( b, data ); + b->finished = 1; + return BSON_OK; +} + static void _bson_reset( bson *b ) { b->finished = 0; b->stackPos = 0; @@ -89,7 +98,7 @@ static void _bson_reset( bson *b ) { b->errstr = NULL; } -int bson_size( const bson *b ) { +MONGO_EXPORT int bson_size( const bson *b ) { int i; if ( ! b || ! b->data ) return 0; @@ -97,7 +106,12 @@ int bson_size( const bson *b ) { return i; } -const char *bson_data( bson *b ) { +MONGO_EXPORT int bson_buffer_size( const bson *b ) { + return (b->cur - b->data + 1); +} + + +MONGO_EXPORT const char *bson_data( const bson *b ) { return (const char *)b->data; } @@ -146,14 +160,14 @@ static char hexbyte( char hex ) { } } -void bson_oid_from_string( bson_oid_t *oid, const char *str ) { +MONGO_EXPORT void bson_oid_from_string( bson_oid_t *oid, const char *str ) { int i; for ( i=0; i<12; i++ ) { oid->bytes[i] = ( hexbyte( str[2*i] ) << 4 ) | hexbyte( str[2*i + 1] ); } } -void bson_oid_to_string( const bson_oid_t *oid, char *str ) { +MONGO_EXPORT void bson_oid_to_string( const bson_oid_t *oid, char *str ) { static const char hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; int i; for ( i=0; i<12; i++ ) { @@ -163,15 +177,15 @@ void bson_oid_to_string( const bson_oid_t *oid, char *str ) { str[24] = '\0'; } -void bson_set_oid_fuzz( int ( *func )( void ) ) { +MONGO_EXPORT void bson_set_oid_fuzz( int ( *func )( void ) ) { oid_fuzz_func = func; } -void bson_set_oid_inc( int ( *func )( void ) ) { +MONGO_EXPORT void bson_set_oid_inc( int ( *func )( void ) ) { oid_inc_func = func; } -void bson_oid_gen( bson_oid_t *oid ) { +MONGO_EXPORT void bson_oid_gen( bson_oid_t *oid ) { static int incr = 0; static int fuzz = 0; int i; @@ -196,18 +210,18 @@ void bson_oid_gen( bson_oid_t *oid ) { bson_big_endian32( &oid->ints[2], &i ); } -time_t bson_oid_generated_time( bson_oid_t *oid ) { +MONGO_EXPORT time_t bson_oid_generated_time( bson_oid_t *oid ) { time_t out; bson_big_endian32( &out, &oid->ints[0] ); return out; } -void bson_print( bson *b ) { +MONGO_EXPORT void bson_print( const bson *b ) { bson_print_raw( b->data , 0 ); } -void bson_print_raw( const char *data , int depth ) { +MONGO_EXPORT void bson_print_raw( const char *data , int depth ) { bson_iterator i; const char *key; int temp; @@ -223,69 +237,69 @@ void bson_print_raw( const char *data , int depth ) { key = bson_iterator_key( &i ); for ( temp=0; temp<=depth; temp++ ) - printf( "\t" ); + bson_printf( "\t" ); bson_printf( "%s : %d \t " , key , t ); switch ( t ) { case BSON_DOUBLE: - printf( "%f" , bson_iterator_double( &i ) ); + bson_printf( "%f" , bson_iterator_double( &i ) ); break; case BSON_STRING: - printf( "%s" , bson_iterator_string( &i ) ); + bson_printf( "%s" , bson_iterator_string( &i ) ); break; case BSON_SYMBOL: - printf( "SYMBOL: %s" , bson_iterator_string( &i ) ); + bson_printf( "SYMBOL: %s" , bson_iterator_string( &i ) ); break; case BSON_OID: bson_oid_to_string( bson_iterator_oid( &i ), oidhex ); - printf( "%s" , oidhex ); + bson_printf( "%s" , oidhex ); break; case BSON_BOOL: - printf( "%s" , bson_iterator_bool( &i ) ? "true" : "false" ); + bson_printf( "%s" , bson_iterator_bool( &i ) ? "true" : "false" ); break; case BSON_DATE: - printf( "%ld" , ( long int )bson_iterator_date( &i ) ); + bson_printf( "%ld" , ( long int )bson_iterator_date( &i ) ); break; case BSON_BINDATA: - printf( "BSON_BINDATA" ); + bson_printf( "BSON_BINDATA" ); break; case BSON_UNDEFINED: - printf( "BSON_UNDEFINED" ); + bson_printf( "BSON_UNDEFINED" ); break; case BSON_NULL: - printf( "BSON_NULL" ); + bson_printf( "BSON_NULL" ); break; case BSON_REGEX: - printf( "BSON_REGEX: %s", bson_iterator_regex( &i ) ); + bson_printf( "BSON_REGEX: %s", bson_iterator_regex( &i ) ); break; case BSON_CODE: - printf( "BSON_CODE: %s", bson_iterator_code( &i ) ); + bson_printf( "BSON_CODE: %s", bson_iterator_code( &i ) ); break; case BSON_CODEWSCOPE: - printf( "BSON_CODE_W_SCOPE: %s", bson_iterator_code( &i ) ); + bson_printf( "BSON_CODE_W_SCOPE: %s", bson_iterator_code( &i ) ); bson_init( &scope ); bson_iterator_code_scope( &i, &scope ); - printf( "\n\t SCOPE: " ); + bson_printf( "\n\t SCOPE: " ); bson_print( &scope ); break; case BSON_INT: - printf( "%d" , bson_iterator_int( &i ) ); + bson_printf( "%d" , bson_iterator_int( &i ) ); break; case BSON_LONG: - printf( "%lld" , ( long long int )bson_iterator_long( &i ) ); + bson_printf( "%lld" , ( uint64_t )bson_iterator_long( &i ) ); break; case BSON_TIMESTAMP: ts = bson_iterator_timestamp( &i ); - printf( "i: %d, t: %d", ts.i, ts.t ); + bson_printf( "i: %d, t: %d", ts.i, ts.t ); break; case BSON_OBJECT: case BSON_ARRAY: - printf( "\n" ); + bson_printf( "\n" ); bson_print_raw( bson_iterator_value( &i ) , depth + 1 ); break; default: bson_errprintf( "can't print type : %d\n" , t ); } - printf( "\n" ); + bson_printf( "\n" ); } } @@ -293,17 +307,25 @@ void bson_print_raw( const char *data , int depth ) { ITERATOR ------------------------------ */ -void bson_iterator_init( bson_iterator *i, const bson *b ) { +MONGO_EXPORT bson_iterator* bson_iterator_create() { + return (bson_iterator*)malloc(sizeof(bson_iterator*)); +} + +MONGO_EXPORT void bson_iterator_dispose(bson_iterator* i) { + free(i); +} + +MONGO_EXPORT void bson_iterator_init( bson_iterator *i, const bson *b ) { i->cur = b->data + 4; i->first = 1; } -void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ) { +MONGO_EXPORT void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ) { i->cur = buffer + 4; i->first = 1; } -bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ) { +MONGO_EXPORT bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ) { bson_iterator_init( it, (bson *)obj ); while( bson_iterator_next( it ) ) { if ( strcmp( name, bson_iterator_key( it ) ) == 0 ) @@ -312,11 +334,11 @@ bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ) { return bson_iterator_type( it ); } -bson_bool_t bson_iterator_more( const bson_iterator *i ) { +MONGO_EXPORT bson_bool_t bson_iterator_more( const bson_iterator *i ) { return *( i->cur ); } -bson_type bson_iterator_next( bson_iterator *i ) { +MONGO_EXPORT bson_type bson_iterator_next( bson_iterator *i ) { int ds; if ( i->first ) { @@ -384,15 +406,15 @@ bson_type bson_iterator_next( bson_iterator *i ) { return ( bson_type )( *i->cur ); } -bson_type bson_iterator_type( const bson_iterator *i ) { +MONGO_EXPORT bson_type bson_iterator_type( const bson_iterator *i ) { return ( bson_type )i->cur[0]; } -const char *bson_iterator_key( const bson_iterator *i ) { +MONGO_EXPORT const char *bson_iterator_key( const bson_iterator *i ) { return i->cur + 1; } -const char *bson_iterator_value( const bson_iterator *i ) { +MONGO_EXPORT const char *bson_iterator_value( const bson_iterator *i ) { const char *t = i->cur + 1; t += strlen( t ) + 1; return t; @@ -422,11 +444,11 @@ bson_bool_t bson_iterator_bool_raw( const bson_iterator *i ) { return bson_iterator_value( i )[0]; } -bson_oid_t *bson_iterator_oid( const bson_iterator *i ) { +MONGO_EXPORT bson_oid_t *bson_iterator_oid( const bson_iterator *i ) { return ( bson_oid_t * )bson_iterator_value( i ); } -int bson_iterator_int( const bson_iterator *i ) { +MONGO_EXPORT int bson_iterator_int( const bson_iterator *i ) { switch ( bson_iterator_type( i ) ) { case BSON_INT: return bson_iterator_int_raw( i ); @@ -439,7 +461,7 @@ int bson_iterator_int( const bson_iterator *i ) { } } -double bson_iterator_double( const bson_iterator *i ) { +MONGO_EXPORT double bson_iterator_double( const bson_iterator *i ) { switch ( bson_iterator_type( i ) ) { case BSON_INT: return bson_iterator_int_raw( i ); @@ -452,7 +474,7 @@ double bson_iterator_double( const bson_iterator *i ) { } } -int64_t bson_iterator_long( const bson_iterator *i ) { +MONGO_EXPORT int64_t bson_iterator_long( const bson_iterator *i ) { switch ( bson_iterator_type( i ) ) { case BSON_INT: return bson_iterator_int_raw( i ); @@ -465,14 +487,29 @@ int64_t bson_iterator_long( const bson_iterator *i ) { } } -bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i ) { +MONGO_EXPORT bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i ) { bson_timestamp_t ts; bson_little_endian32( &( ts.i ), bson_iterator_value( i ) ); bson_little_endian32( &( ts.t ), bson_iterator_value( i ) + 4 ); return ts; } -bson_bool_t bson_iterator_bool( const bson_iterator *i ) { + +MONGO_EXPORT int bson_iterator_timestamp_time( const bson_iterator *i ) { + int time; + bson_little_endian32( &time, bson_iterator_value( i ) + 4 ); + return time; +} + + +MONGO_EXPORT int bson_iterator_timestamp_increment( const bson_iterator *i ) { + int increment; + bson_little_endian32( &increment, bson_iterator_value( i ) ); + return increment; +} + + +MONGO_EXPORT bson_bool_t bson_iterator_bool( const bson_iterator *i ) { switch ( bson_iterator_type( i ) ) { case BSON_BOOL: return bson_iterator_bool_raw( i ); @@ -490,15 +527,21 @@ bson_bool_t bson_iterator_bool( const bson_iterator *i ) { } } -const char *bson_iterator_string( const bson_iterator *i ) { - return bson_iterator_value( i ) + 4; +MONGO_EXPORT const char *bson_iterator_string( const bson_iterator *i ) { + switch ( bson_iterator_type( i ) ) { + case BSON_STRING: + case BSON_SYMBOL: + return bson_iterator_value( i ) + 4; + default: + return ""; + } } int bson_iterator_string_len( const bson_iterator *i ) { return bson_iterator_int_raw( i ); } -const char *bson_iterator_code( const bson_iterator *i ) { +MONGO_EXPORT const char *bson_iterator_code( const bson_iterator *i ) { switch ( bson_iterator_type( i ) ) { case BSON_STRING: case BSON_CODE: @@ -510,57 +553,59 @@ const char *bson_iterator_code( const bson_iterator *i ) { } } -void bson_iterator_code_scope( const bson_iterator *i, bson *scope ) { +MONGO_EXPORT void bson_iterator_code_scope( const bson_iterator *i, bson *scope ) { if ( bson_iterator_type( i ) == BSON_CODEWSCOPE ) { int code_len; bson_little_endian32( &code_len, bson_iterator_value( i )+4 ); bson_init_data( scope, ( void * )( bson_iterator_value( i )+8+code_len ) ); + _bson_reset( scope ); + scope->finished = 1; } else { bson_empty( scope ); } } -bson_date_t bson_iterator_date( const bson_iterator *i ) { +MONGO_EXPORT bson_date_t bson_iterator_date( const bson_iterator *i ) { return bson_iterator_long_raw( i ); } -time_t bson_iterator_time_t( const bson_iterator *i ) { +MONGO_EXPORT time_t bson_iterator_time_t( const bson_iterator *i ) { return bson_iterator_date( i ) / 1000; } -int bson_iterator_bin_len( const bson_iterator *i ) { +MONGO_EXPORT int bson_iterator_bin_len( const bson_iterator *i ) { return ( bson_iterator_bin_type( i ) == BSON_BIN_BINARY_OLD ) ? bson_iterator_int_raw( i ) - 4 : bson_iterator_int_raw( i ); } -char bson_iterator_bin_type( const bson_iterator *i ) { +MONGO_EXPORT char bson_iterator_bin_type( const bson_iterator *i ) { return bson_iterator_value( i )[4]; } -const char *bson_iterator_bin_data( const bson_iterator *i ) { +MONGO_EXPORT const char *bson_iterator_bin_data( const bson_iterator *i ) { return ( bson_iterator_bin_type( i ) == BSON_BIN_BINARY_OLD ) ? bson_iterator_value( i ) + 9 : bson_iterator_value( i ) + 5; } -const char *bson_iterator_regex( const bson_iterator *i ) { +MONGO_EXPORT const char *bson_iterator_regex( const bson_iterator *i ) { return bson_iterator_value( i ); } -const char *bson_iterator_regex_opts( const bson_iterator *i ) { +MONGO_EXPORT const char *bson_iterator_regex_opts( const bson_iterator *i ) { const char *p = bson_iterator_value( i ); return p + strlen( p ) + 1; } -void bson_iterator_subobject( const bson_iterator *i, bson *sub ) { +MONGO_EXPORT void bson_iterator_subobject( const bson_iterator *i, bson *sub ) { bson_init_data( sub, ( char * )bson_iterator_value( i ) ); _bson_reset( sub ); sub->finished = 1; } -void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ) { +MONGO_EXPORT void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ) { bson_iterator_from_buffer( sub, bson_iterator_value( i ) ); } @@ -578,7 +623,7 @@ static void _bson_init_size( bson *b, int size ) { _bson_reset( b ); } -void bson_init( bson *b ) { +MONGO_EXPORT void bson_init( bson *b ) { _bson_init_size( b, initialBufferSize ); } @@ -635,7 +680,7 @@ int bson_ensure_space( bson *b, const int bytesNeeded ) { return BSON_OK; } -int bson_finish( bson *b ) { +MONGO_EXPORT int bson_finish( bson *b ) { int i; if( b->err & BSON_NOT_UTF8 ) @@ -652,12 +697,14 @@ int bson_finish( bson *b ) { return BSON_OK; } -void bson_destroy( bson *b ) { - bson_free( b->data ); - b->err = 0; - b->data = 0; - b->cur = 0; - b->finished = 1; +MONGO_EXPORT void bson_destroy( bson *b ) { + if (b) { + bson_free( b->data ); + b->err = 0; + b->data = 0; + b->cur = 0; + b->finished = 1; + } } static int bson_append_estart( bson *b, int type, const char *name, const int dataSize ) { @@ -686,41 +733,41 @@ static int bson_append_estart( bson *b, int type, const char *name, const int da BUILDING TYPES ------------------------------ */ -int bson_append_int( bson *b, const char *name, const int i ) { +MONGO_EXPORT int bson_append_int( bson *b, const char *name, const int i ) { if ( bson_append_estart( b, BSON_INT, name, 4 ) == BSON_ERROR ) return BSON_ERROR; bson_append32( b , &i ); return BSON_OK; } -int bson_append_long( bson *b, const char *name, const int64_t i ) { +MONGO_EXPORT int bson_append_long( bson *b, const char *name, const int64_t i ) { if ( bson_append_estart( b , BSON_LONG, name, 8 ) == BSON_ERROR ) return BSON_ERROR; bson_append64( b , &i ); return BSON_OK; } -int bson_append_double( bson *b, const char *name, const double d ) { +MONGO_EXPORT int bson_append_double( bson *b, const char *name, const double d ) { if ( bson_append_estart( b, BSON_DOUBLE, name, 8 ) == BSON_ERROR ) return BSON_ERROR; bson_append64( b , &d ); return BSON_OK; } -int bson_append_bool( bson *b, const char *name, const bson_bool_t i ) { +MONGO_EXPORT int bson_append_bool( bson *b, const char *name, const bson_bool_t i ) { if ( bson_append_estart( b, BSON_BOOL, name, 1 ) == BSON_ERROR ) return BSON_ERROR; bson_append_byte( b , i != 0 ); return BSON_OK; } -int bson_append_null( bson *b, const char *name ) { +MONGO_EXPORT int bson_append_null( bson *b, const char *name ) { if ( bson_append_estart( b , BSON_NULL, name, 0 ) == BSON_ERROR ) return BSON_ERROR; return BSON_OK; } -int bson_append_undefined( bson *b, const char *name ) { +MONGO_EXPORT int bson_append_undefined( bson *b, const char *name ) { if ( bson_append_estart( b, BSON_UNDEFINED, name, 0 ) == BSON_ERROR ) return BSON_ERROR; return BSON_OK; @@ -741,31 +788,31 @@ int bson_append_string_base( bson *b, const char *name, return BSON_OK; } -int bson_append_string( bson *b, const char *name, const char *value ) { +MONGO_EXPORT int bson_append_string( bson *b, const char *name, const char *value ) { return bson_append_string_base( b, name, value, strlen ( value ), BSON_STRING ); } -int bson_append_symbol( bson *b, const char *name, const char *value ) { +MONGO_EXPORT int bson_append_symbol( bson *b, const char *name, const char *value ) { return bson_append_string_base( b, name, value, strlen ( value ), BSON_SYMBOL ); } -int bson_append_code( bson *b, const char *name, const char *value ) { +MONGO_EXPORT int bson_append_code( bson *b, const char *name, const char *value ) { return bson_append_string_base( b, name, value, strlen ( value ), BSON_CODE ); } -int bson_append_string_n( bson *b, const char *name, const char *value, int len ) { +MONGO_EXPORT int bson_append_string_n( bson *b, const char *name, const char *value, int len ) { return bson_append_string_base( b, name, value, len, BSON_STRING ); } -int bson_append_symbol_n( bson *b, const char *name, const char *value, int len ) { +MONGO_EXPORT int bson_append_symbol_n( bson *b, const char *name, const char *value, int len ) { return bson_append_string_base( b, name, value, len, BSON_SYMBOL ); } -int bson_append_code_n( bson *b, const char *name, const char *value, int len ) { +MONGO_EXPORT int bson_append_code_n( bson *b, const char *name, const char *value, int len ) { return bson_append_string_base( b, name, value, len, BSON_CODE ); } -int bson_append_code_w_scope_n( bson *b, const char *name, +MONGO_EXPORT int bson_append_code_w_scope_n( bson *b, const char *name, const char *code, int len, const bson *scope ) { int sl = len + 1; @@ -779,11 +826,11 @@ int bson_append_code_w_scope_n( bson *b, const char *name, return BSON_OK; } -int bson_append_code_w_scope( bson *b, const char *name, const char *code, const bson *scope ) { +MONGO_EXPORT int bson_append_code_w_scope( bson *b, const char *name, const char *code, const bson *scope ) { return bson_append_code_w_scope_n( b, name, code, strlen ( code ), scope ); } -int bson_append_binary( bson *b, const char *name, char type, const char *str, int len ) { +MONGO_EXPORT int bson_append_binary( bson *b, const char *name, char type, const char *str, int len ) { if ( type == BSON_BIN_BINARY_OLD ) { int subtwolen = len + 4; if ( bson_append_estart( b, BSON_BINDATA, name, 4+1+4+len ) == BSON_ERROR ) @@ -802,20 +849,20 @@ int bson_append_binary( bson *b, const char *name, char type, const char *str, i return BSON_OK; } -int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid ) { +MONGO_EXPORT int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid ) { if ( bson_append_estart( b, BSON_OID, name, 12 ) == BSON_ERROR ) return BSON_ERROR; bson_append( b , oid , 12 ); return BSON_OK; } -int bson_append_new_oid( bson *b, const char *name ) { +MONGO_EXPORT int bson_append_new_oid( bson *b, const char *name ) { bson_oid_t oid; bson_oid_gen( &oid ); return bson_append_oid( b, name, &oid ); } -int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts ) { +MONGO_EXPORT int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts ) { const int plen = strlen( pattern )+1; const int olen = strlen( opts )+1; if ( bson_append_estart( b, BSON_REGEX, name, plen + olen ) == BSON_ERROR ) @@ -827,14 +874,14 @@ int bson_append_regex( bson *b, const char *name, const char *pattern, const cha return BSON_OK; } -int bson_append_bson( bson *b, const char *name, const bson *bson ) { +MONGO_EXPORT int bson_append_bson( bson *b, const char *name, const bson *bson ) { if ( bson_append_estart( b, BSON_OBJECT, name, bson_size( bson ) ) == BSON_ERROR ) return BSON_ERROR; bson_append( b , bson->data , bson_size( bson ) ); return BSON_OK; } -int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem ) { +MONGO_EXPORT int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem ) { bson_iterator next = *elem; int size; @@ -854,7 +901,7 @@ int bson_append_element( bson *b, const char *name_or_null, const bson_iterator return BSON_OK; } -int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ) { +MONGO_EXPORT int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ) { if ( bson_append_estart( b, BSON_TIMESTAMP, name, 8 ) == BSON_ERROR ) return BSON_ERROR; bson_append32( b , &( ts->i ) ); @@ -863,31 +910,39 @@ int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ) { return BSON_OK; } -int bson_append_date( bson *b, const char *name, bson_date_t millis ) { +MONGO_EXPORT int bson_append_timestamp2( bson *b, const char *name, int time, int increment ) { + if ( bson_append_estart( b, BSON_TIMESTAMP, name, 8 ) == BSON_ERROR ) return BSON_ERROR; + + bson_append32( b , &increment ); + bson_append32( b , &time ); + return BSON_OK; +} + +MONGO_EXPORT int bson_append_date( bson *b, const char *name, bson_date_t millis ) { if ( bson_append_estart( b, BSON_DATE, name, 8 ) == BSON_ERROR ) return BSON_ERROR; bson_append64( b , &millis ); return BSON_OK; } -int bson_append_time_t( bson *b, const char *name, time_t secs ) { +MONGO_EXPORT int bson_append_time_t( bson *b, const char *name, time_t secs ) { return bson_append_date( b, name, ( bson_date_t )secs * 1000 ); } -int bson_append_start_object( bson *b, const char *name ) { +MONGO_EXPORT int bson_append_start_object( bson *b, const char *name ) { if ( bson_append_estart( b, BSON_OBJECT, name, 5 ) == BSON_ERROR ) return BSON_ERROR; b->stack[ b->stackPos++ ] = b->cur - b->data; bson_append32( b , &zero ); return BSON_OK; } -int bson_append_start_array( bson *b, const char *name ) { +MONGO_EXPORT int bson_append_start_array( bson *b, const char *name ) { if ( bson_append_estart( b, BSON_ARRAY, name, 5 ) == BSON_ERROR ) return BSON_ERROR; b->stack[ b->stackPos++ ] = b->cur - b->data; bson_append32( b , &zero ); return BSON_OK; } -int bson_append_finish_object( bson *b ) { +MONGO_EXPORT int bson_append_finish_object( bson *b ) { char *start; int i; if ( bson_ensure_space( b, 1 ) == BSON_ERROR ) return BSON_ERROR; @@ -900,22 +955,25 @@ int bson_append_finish_object( bson *b ) { return BSON_OK; } -int bson_append_finish_array( bson *b ) { - return bson_append_finish_object( b ); +MONGO_EXPORT double bson_int64_to_double( int64_t i64 ) { + return (double)i64; } +MONGO_EXPORT int bson_append_finish_array( bson *b ) { + return bson_append_finish_object( b ); +} /* Error handling and allocators. */ static bson_err_handler err_handler = NULL; -bson_err_handler set_bson_err_handler( bson_err_handler func ) { +MONGO_EXPORT bson_err_handler set_bson_err_handler( bson_err_handler func ) { bson_err_handler old = err_handler; err_handler = func; return old; } -void *bson_malloc( int size ) { +MONGO_EXPORT void *bson_malloc( int size ) { void *p; p = bson_malloc_func( size ); bson_fatal_msg( !!p, "malloc() failed" ); @@ -933,7 +991,9 @@ int _bson_errprintf( const char *format, ... ) { va_list ap; int ret; va_start( ap, format ); +#ifndef R_SAFETY_NET ret = vfprintf( stderr, format, ap ); +#endif va_end( ap ); return ret; @@ -961,9 +1021,10 @@ void bson_fatal_msg( int ok , const char *msg ) { if ( err_handler ) { err_handler( msg ); } - +#ifndef R_SAFETY_NET bson_errprintf( "error: %s\n" , msg ); exit( -5 ); +#endif } @@ -976,3 +1037,28 @@ void bson_numstr( char *str, int i ) { else bson_sprintf( str,"%d", i ); } + +MONGO_EXPORT void bson_swap_endian64( void *outp, const void *inp ) { + const char *in = ( const char * )inp; + char *out = ( char * )outp; + + out[0] = in[7]; + out[1] = in[6]; + out[2] = in[5]; + out[3] = in[4]; + out[4] = in[3]; + out[5] = in[2]; + out[6] = in[1]; + out[7] = in[0]; + +} + +MONGO_EXPORT void bson_swap_endian32( void *outp, const void *inp ) { + const char *in = ( const char * )inp; + char *out = ( char * )outp; + + out[0] = in[3]; + out[1] = in[2]; + out[2] = in[1]; + out[3] = in[0]; +} diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.h index 2e385b9160..b83d1ca9c9 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.h +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/bson.h @@ -3,7 +3,7 @@ * @brief BSON Declarations */ -/* Copyright 2009-2011 10gen Inc. +/* Copyright 2009-2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,16 +18,63 @@ * limitations under the License. */ -#ifndef _BSON_H_ -#define _BSON_H_ +#ifndef BSON_H_ +#define BSON_H_ -#include "platform.h" #include #include #include #include #include +#ifdef __GNUC__ + #define MONGO_INLINE static __inline__ + #define MONGO_EXPORT +#else + #define MONGO_INLINE static + #ifdef MONGO_STATIC_BUILD + #define MONGO_EXPORT + #elif defined(MONGO_DLL_BUILD) + #define MONGO_EXPORT __declspec(dllexport) + #else + #define MONGO_EXPORT __declspec(dllimport) + #endif +#endif + +#ifdef __cplusplus +#define MONGO_EXTERN_C_START extern "C" { +#define MONGO_EXTERN_C_END } +#else +#define MONGO_EXTERN_C_START +#define MONGO_EXTERN_C_END +#endif + +#if defined(MONGO_HAVE_STDINT) || __STDC_VERSION__ >= 199901L +#include +#elif defined(MONGO_HAVE_UNISTD) +#include +#elif defined(MONGO_USE__INT64) +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#elif defined(MONGO_USE_LONG_LONG_INT) +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#else +#error Must compile with c99 or define MONGO_HAVE_STDINT, MONGO_HAVE_UNISTD, MONGO_USE__INT64, or MONGO_USE_LONG_INT. +#endif + +#ifdef MONGO_BIG_ENDIAN +#define bson_little_endian64(out, in) ( bson_swap_endian64(out, in) ) +#define bson_little_endian32(out, in) ( bson_swap_endian32(out, in) ) +#define bson_big_endian64(out, in) ( memcpy(out, in, 8) ) +#define bson_big_endian32(out, in) ( memcpy(out, in, 4) ) +#else +#define bson_little_endian64(out, in) ( memcpy(out, in, 8) ) +#define bson_little_endian32(out, in) ( memcpy(out, in, 4) ) +#define bson_big_endian64(out, in) ( bson_swap_endian64(out, in) ) +#define bson_big_endian32(out, in) ( bson_swap_endian32(out, in) ) +#endif + MONGO_EXTERN_C_START #define BSON_OK 0 @@ -84,12 +131,12 @@ typedef struct { } bson_iterator; typedef struct { - char *data; - char *cur; - int dataSize; - bson_bool_t finished; - int stack[32]; - int stackPos; + char *data; /**< Pointer to a block of data in this BSON object. */ + char *cur; /**< Pointer to the current position. */ + int dataSize; /**< The number of bytes allocated to char *data. */ + bson_bool_t finished; /**< When finished, the BSON object can no longer be modified. */ + int stack[32]; /**< A stack used to keep track of nested BSON elements. */ + int stackPos; /**< Index of current stack position. */ int err; /**< Bitfield representing errors or warnings on this buffer */ char *errstr; /**< A string representation of the most recent error or warning. */ } bson; @@ -112,6 +159,9 @@ typedef struct { READING ------------------------------ */ +MONGO_EXPORT bson* bson_create(); +MONGO_EXPORT void bson_dispose(bson* b); + /** * Size of a BSON object. * @@ -119,21 +169,22 @@ typedef struct { * * @return the size. */ -int bson_size( const bson *b ); +MONGO_EXPORT int bson_size( const bson *b ); +MONGO_EXPORT int bson_buffer_size( const bson *b ); /** * Print a string representation of a BSON object. * * @param b the BSON object to print. */ -void bson_print( bson *b ); +MONGO_EXPORT void bson_print( const bson *b ); /** * Return a pointer to the raw buffer stored by this bson object. * * @param b a BSON object */ -const char *bson_data( bson *b ); +MONGO_EXPORT const char *bson_data( const bson *b ); /** * Print a string representation of a BSON object. @@ -141,7 +192,7 @@ const char *bson_data( bson *b ); * @param bson the raw data to print. * @param depth the depth to recurse the object.x */ -void bson_print_raw( const char *bson , int depth ); +MONGO_EXPORT void bson_print_raw( const char *bson , int depth ); /** * Advance a bson_iterator to the named field. @@ -152,15 +203,18 @@ void bson_print_raw( const char *bson , int depth ); * * @return the type of the found object or BSON_EOO if it is not found. */ -bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ); +MONGO_EXPORT bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ); + +MONGO_EXPORT bson_iterator* bson_iterator_create(); +MONGO_EXPORT void bson_iterator_dispose(bson_iterator*); /** * Initialize a bson_iterator. * * @param i the bson_iterator to initialize. * @param bson the BSON object to associate with the iterator. */ -void bson_iterator_init( bson_iterator *i , const bson *b ); +MONGO_EXPORT void bson_iterator_init( bson_iterator *i , const bson *b ); /** * Initialize a bson iterator from a const char* buffer. Note @@ -169,7 +223,7 @@ void bson_iterator_init( bson_iterator *i , const bson *b ); * @param i the bson_iterator to initialize. * @param buffer the buffer to point to. */ -void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ); +MONGO_EXPORT void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ); /* more returns true for eoo. best to loop with bson_iterator_next(&it) */ /** @@ -179,7 +233,7 @@ void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ); * * @return returns true if there is more data. */ -bson_bool_t bson_iterator_more( const bson_iterator *i ); +MONGO_EXPORT bson_bool_t bson_iterator_more( const bson_iterator *i ); /** * Point the iterator at the next BSON object. @@ -188,7 +242,7 @@ bson_bool_t bson_iterator_more( const bson_iterator *i ); * * @return the type of the next BSON object. */ -bson_type bson_iterator_next( bson_iterator *i ); +MONGO_EXPORT bson_type bson_iterator_next( bson_iterator *i ); /** * Get the type of the BSON object currently pointed to by the iterator. @@ -197,7 +251,7 @@ bson_type bson_iterator_next( bson_iterator *i ); * * @return the type of the current BSON object. */ -bson_type bson_iterator_type( const bson_iterator *i ); +MONGO_EXPORT bson_type bson_iterator_type( const bson_iterator *i ); /** * Get the key of the BSON object currently pointed to by the iterator. @@ -206,7 +260,7 @@ bson_type bson_iterator_type( const bson_iterator *i ); * * @return the key of the current BSON object. */ -const char *bson_iterator_key( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_key( const bson_iterator *i ); /** * Get the value of the BSON object currently pointed to by the iterator. @@ -215,7 +269,7 @@ const char *bson_iterator_key( const bson_iterator *i ); * * @return the value of the current BSON object. */ -const char *bson_iterator_value( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_value( const bson_iterator *i ); /* these convert to the right type (return 0 if non-numeric) */ /** @@ -226,7 +280,7 @@ const char *bson_iterator_value( const bson_iterator *i ); * * @return the value of the current BSON object. */ -double bson_iterator_double( const bson_iterator *i ); +MONGO_EXPORT double bson_iterator_double( const bson_iterator *i ); /** * Get the int value of the BSON object currently pointed to by the iterator. @@ -235,7 +289,7 @@ double bson_iterator_double( const bson_iterator *i ); * * @return the value of the current BSON object. */ -int bson_iterator_int( const bson_iterator *i ); +MONGO_EXPORT int bson_iterator_int( const bson_iterator *i ); /** * Get the long value of the BSON object currently pointed to by the iterator. @@ -244,7 +298,7 @@ int bson_iterator_int( const bson_iterator *i ); * * @return the value of the current BSON object. */ -int64_t bson_iterator_long( const bson_iterator *i ); +MONGO_EXPORT int64_t bson_iterator_long( const bson_iterator *i ); /* return the bson timestamp as a whole or in parts */ /** @@ -255,7 +309,9 @@ int64_t bson_iterator_long( const bson_iterator *i ); * * @return the value of the current BSON object. */ -bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i ); +MONGO_EXPORT bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i ); +MONGO_EXPORT int bson_iterator_timestamp_time( const bson_iterator *i ); +MONGO_EXPORT int bson_iterator_timestamp_increment( const bson_iterator *i ); /** * Get the boolean value of the BSON object currently pointed to by @@ -267,7 +323,7 @@ bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i ); */ /* false: boolean false, 0 in any type, or null */ /* true: anything else (even empty strings and objects) */ -bson_bool_t bson_iterator_bool( const bson_iterator *i ); +MONGO_EXPORT bson_bool_t bson_iterator_bool( const bson_iterator *i ); /** * Get the double value of the BSON object currently pointed to by the @@ -318,7 +374,7 @@ bson_bool_t bson_iterator_bool_raw( const bson_iterator *i ); * * @return the value of the current BSON object. */ -bson_oid_t *bson_iterator_oid( const bson_iterator *i ); +MONGO_EXPORT bson_oid_t *bson_iterator_oid( const bson_iterator *i ); /** * Get the string value of the BSON object currently pointed to by the @@ -329,7 +385,7 @@ bson_oid_t *bson_iterator_oid( const bson_iterator *i ); * @return the value of the current BSON object. */ /* these can also be used with bson_code and bson_symbol*/ -const char *bson_iterator_string( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_string( const bson_iterator *i ); /** * Get the string length of the BSON object currently pointed to by the @@ -352,7 +408,7 @@ int bson_iterator_string_len( const bson_iterator *i ); */ /* works with bson_code, bson_codewscope, and BSON_STRING */ /* returns NULL for everything else */ -const char *bson_iterator_code( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_code( const bson_iterator *i ); /** * Calls bson_empty on scope if not a bson_codewscope @@ -361,7 +417,7 @@ const char *bson_iterator_code( const bson_iterator *i ); * @param scope the bson scope. */ /* calls bson_empty on scope if not a bson_codewscope */ -void bson_iterator_code_scope( const bson_iterator *i, bson *scope ); +MONGO_EXPORT void bson_iterator_code_scope( const bson_iterator *i, bson *scope ); /** * Get the date value of the BSON object currently pointed to by the @@ -372,7 +428,7 @@ void bson_iterator_code_scope( const bson_iterator *i, bson *scope ); * @return the date value of the current BSON object. */ /* both of these only work with bson_date */ -bson_date_t bson_iterator_date( const bson_iterator *i ); +MONGO_EXPORT bson_date_t bson_iterator_date( const bson_iterator *i ); /** * Get the time value of the BSON object currently pointed to by the @@ -382,7 +438,7 @@ bson_date_t bson_iterator_date( const bson_iterator *i ); * * @return the time value of the current BSON object. */ -time_t bson_iterator_time_t( const bson_iterator *i ); +MONGO_EXPORT time_t bson_iterator_time_t( const bson_iterator *i ); /** * Get the length of the BSON binary object currently pointed to by the @@ -392,7 +448,7 @@ time_t bson_iterator_time_t( const bson_iterator *i ); * * @return the length of the current BSON binary object. */ -int bson_iterator_bin_len( const bson_iterator *i ); +MONGO_EXPORT int bson_iterator_bin_len( const bson_iterator *i ); /** * Get the type of the BSON binary object currently pointed to by the @@ -402,7 +458,7 @@ int bson_iterator_bin_len( const bson_iterator *i ); * * @return the type of the current BSON binary object. */ -char bson_iterator_bin_type( const bson_iterator *i ); +MONGO_EXPORT char bson_iterator_bin_type( const bson_iterator *i ); /** * Get the value of the BSON binary object currently pointed to by the @@ -412,7 +468,7 @@ char bson_iterator_bin_type( const bson_iterator *i ); * * @return the value of the current BSON binary object. */ -const char *bson_iterator_bin_data( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_bin_data( const bson_iterator *i ); /** * Get the value of the BSON regex object currently pointed to by the @@ -422,7 +478,7 @@ const char *bson_iterator_bin_data( const bson_iterator *i ); * * @return the value of the current BSON regex object. */ -const char *bson_iterator_regex( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_regex( const bson_iterator *i ); /** * Get the options of the BSON regex object currently pointed to by the @@ -432,7 +488,7 @@ const char *bson_iterator_regex( const bson_iterator *i ); * * @return the options of the current BSON regex object. */ -const char *bson_iterator_regex_opts( const bson_iterator *i ); +MONGO_EXPORT const char *bson_iterator_regex_opts( const bson_iterator *i ); /* these work with BSON_OBJECT and BSON_ARRAY */ /** @@ -442,7 +498,7 @@ const char *bson_iterator_regex_opts( const bson_iterator *i ); * @param i the bson_iterator. * @param sub the BSON subobject destination. */ -void bson_iterator_subobject( const bson_iterator *i, bson *sub ); +MONGO_EXPORT void bson_iterator_subobject( const bson_iterator *i, bson *sub ); /** * Get a bson_iterator that on the BSON subobject. @@ -450,7 +506,7 @@ void bson_iterator_subobject( const bson_iterator *i, bson *sub ); * @param i the bson_iterator. * @param sub the iterator to point at the BSON subobject. */ -void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ); +MONGO_EXPORT void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ); /* str must be at least 24 hex chars + null byte */ /** @@ -459,7 +515,7 @@ void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ); * @param oid the bson_oid_t destination. * @param str a null terminated string comprised of at least 24 hex chars. */ -void bson_oid_from_string( bson_oid_t *oid, const char *str ); +MONGO_EXPORT void bson_oid_from_string( bson_oid_t *oid, const char *str ); /** * Create a string representation of the bson_oid_t. @@ -467,14 +523,14 @@ void bson_oid_from_string( bson_oid_t *oid, const char *str ); * @param oid the bson_oid_t source. * @param str the string representation destination. */ -void bson_oid_to_string( const bson_oid_t *oid, char *str ); +MONGO_EXPORT void bson_oid_to_string( const bson_oid_t *oid, char *str ); /** * Create a bson_oid object. * * @param oid the destination for the newly created bson_oid_t. */ -void bson_oid_gen( bson_oid_t *oid ); +MONGO_EXPORT void bson_oid_gen( bson_oid_t *oid ); /** * Set a function to be used to generate the second four bytes @@ -482,7 +538,7 @@ void bson_oid_gen( bson_oid_t *oid ); * * @param func a pointer to a function that returns an int. */ -void bson_set_oid_fuzz( int ( *func )( void ) ); +MONGO_EXPORT void bson_set_oid_fuzz( int ( *func )( void ) ); /** * Set a function to be used to generate the incrementing part @@ -491,14 +547,14 @@ void bson_set_oid_fuzz( int ( *func )( void ) ); * * @param func a pointer to a function that returns an int. */ -void bson_set_oid_inc( int ( *func )( void ) ); +MONGO_EXPORT void bson_set_oid_inc( int ( *func )( void ) ); /** * Get the time a bson_oid_t was created. * * @param oid the bson_oid_t. */ -time_t bson_oid_generated_time( bson_oid_t *oid ); /* Gives the time the OID was created */ +MONGO_EXPORT time_t bson_oid_generated_time( bson_oid_t *oid ); /* Gives the time the OID was created */ /* ---------------------------- BUILDING @@ -512,7 +568,7 @@ time_t bson_oid_generated_time( bson_oid_t *oid ); /* Gives the time the OID was * @note When finished, you must pass the bson object to * bson_destroy( ). */ -void bson_init( bson *b ); +MONGO_EXPORT void bson_init( bson *b ); /** * Initialize a BSON object, and point its data @@ -524,6 +580,7 @@ void bson_init( bson *b ); * @return BSON_OK or BSON_ERROR. */ int bson_init_data( bson *b , char *data ); +int bson_init_finished_data( bson *b, char *data ) ; /** * Initialize a BSON object, and set its @@ -555,7 +612,7 @@ int bson_ensure_space( bson *b, const int bytesNeeded ); * @return the standard error code. To deallocate memory, * call bson_destroy on the bson object. */ -int bson_finish( bson *b ); +MONGO_EXPORT int bson_finish( bson *b ); /** * Destroy a bson object. @@ -563,7 +620,7 @@ int bson_finish( bson *b ); * @param b the bson object to destroy. * */ -void bson_destroy( bson *b ); +MONGO_EXPORT void bson_destroy( bson *b ); /** * Returns a pointer to a static empty BSON object. @@ -573,23 +630,17 @@ void bson_destroy( bson *b ); * @return the empty initialized BSON object. */ /* returns pointer to static empty bson object */ -bson *bson_empty( bson *obj ); - -/** - * Copy BSON data only from one object to another. - * - * @param out the copy destination BSON object. - * @param in the copy source BSON object. - */ -void bson_copy_basic( bson *out, const bson *in ); +MONGO_EXPORT bson *bson_empty( bson *obj ); /** * Make a complete copy of the a BSON object. + * The source bson object must be in a finished + * state; otherwise, the copy will fail. * * @param out the copy destination BSON object. * @param in the copy source BSON object. */ -void bson_copy( bson *out, const bson *in ); /* puts data in new buffer. NOOP if out==NULL */ +MONGO_EXPORT int bson_copy( bson *out, const bson *in ); /* puts data in new buffer. NOOP if out==NULL */ /** * Append a previously created bson_oid_t to a bson object. @@ -600,7 +651,7 @@ void bson_copy( bson *out, const bson *in ); /* puts data in new buffer. NOOP if * * @return BSON_OK or BSON_ERROR. */ -int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid ); +MONGO_EXPORT int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid ); /** * Append a bson_oid_t to a bson. @@ -610,7 +661,7 @@ int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_new_oid( bson *b, const char *name ); +MONGO_EXPORT int bson_append_new_oid( bson *b, const char *name ); /** * Append an int to a bson. @@ -621,7 +672,7 @@ int bson_append_new_oid( bson *b, const char *name ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_int( bson *b, const char *name, const int i ); +MONGO_EXPORT int bson_append_int( bson *b, const char *name, const int i ); /** * Append an long to a bson. @@ -632,7 +683,7 @@ int bson_append_int( bson *b, const char *name, const int i ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_long( bson *b, const char *name, const int64_t i ); +MONGO_EXPORT int bson_append_long( bson *b, const char *name, const int64_t i ); /** * Append an double to a bson. @@ -643,7 +694,7 @@ int bson_append_long( bson *b, const char *name, const int64_t i ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_double( bson *b, const char *name, const double d ); +MONGO_EXPORT int bson_append_double( bson *b, const char *name, const double d ); /** * Append a string to a bson. @@ -654,7 +705,7 @@ int bson_append_double( bson *b, const char *name, const double d ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_string( bson *b, const char *name, const char *str ); +MONGO_EXPORT int bson_append_string( bson *b, const char *name, const char *str ); /** * Append len bytes of a string to a bson. @@ -666,7 +717,7 @@ int bson_append_string( bson *b, const char *name, const char *str ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_string_n( bson *b, const char *name, const char *str, int len ); +MONGO_EXPORT int bson_append_string_n( bson *b, const char *name, const char *str, int len ); /** * Append a symbol to a bson. @@ -677,7 +728,7 @@ int bson_append_string_n( bson *b, const char *name, const char *str, int len ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_symbol( bson *b, const char *name, const char *str ); +MONGO_EXPORT int bson_append_symbol( bson *b, const char *name, const char *str ); /** * Append len bytes of a symbol to a bson. @@ -689,7 +740,7 @@ int bson_append_symbol( bson *b, const char *name, const char *str ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_symbol_n( bson *b, const char *name, const char *str, int len ); +MONGO_EXPORT int bson_append_symbol_n( bson *b, const char *name, const char *str, int len ); /** * Append code to a bson. @@ -701,7 +752,7 @@ int bson_append_symbol_n( bson *b, const char *name, const char *str, int len ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_code( bson *b, const char *name, const char *str ); +MONGO_EXPORT int bson_append_code( bson *b, const char *name, const char *str ); /** * Append len bytes of code to a bson. @@ -713,7 +764,7 @@ int bson_append_code( bson *b, const char *name, const char *str ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_code_n( bson *b, const char *name, const char *str, int len ); +MONGO_EXPORT int bson_append_code_n( bson *b, const char *name, const char *str, int len ); /** * Append code to a bson with scope. @@ -725,7 +776,7 @@ int bson_append_code_n( bson *b, const char *name, const char *str, int len ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_code_w_scope( bson *b, const char *name, const char *code, const bson *scope ); +MONGO_EXPORT int bson_append_code_w_scope( bson *b, const char *name, const char *code, const bson *scope ); /** * Append len bytes of code to a bson with scope. @@ -738,7 +789,7 @@ int bson_append_code_w_scope( bson *b, const char *name, const char *code, const * * @return BSON_OK or BSON_ERROR. */ -int bson_append_code_w_scope_n( bson *b, const char *name, const char *code, int size, const bson *scope ); +MONGO_EXPORT int bson_append_code_w_scope_n( bson *b, const char *name, const char *code, int size, const bson *scope ); /** * Append binary data to a bson. @@ -751,7 +802,7 @@ int bson_append_code_w_scope_n( bson *b, const char *name, const char *code, int * * @return BSON_OK or BSON_ERROR. */ -int bson_append_binary( bson *b, const char *name, char type, const char *str, int len ); +MONGO_EXPORT int bson_append_binary( bson *b, const char *name, char type, const char *str, int len ); /** * Append a bson_bool_t to a bson. @@ -762,7 +813,7 @@ int bson_append_binary( bson *b, const char *name, char type, const char *str, i * * @return BSON_OK or BSON_ERROR. */ -int bson_append_bool( bson *b, const char *name, const bson_bool_t v ); +MONGO_EXPORT int bson_append_bool( bson *b, const char *name, const bson_bool_t v ); /** * Append a null value to a bson. @@ -772,7 +823,7 @@ int bson_append_bool( bson *b, const char *name, const bson_bool_t v ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_null( bson *b, const char *name ); +MONGO_EXPORT int bson_append_null( bson *b, const char *name ); /** * Append an undefined value to a bson. @@ -782,7 +833,7 @@ int bson_append_null( bson *b, const char *name ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_undefined( bson *b, const char *name ); +MONGO_EXPORT int bson_append_undefined( bson *b, const char *name ); /** * Append a regex value to a bson. @@ -794,7 +845,7 @@ int bson_append_undefined( bson *b, const char *name ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts ); +MONGO_EXPORT int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts ); /** * Append bson data to a bson. @@ -805,7 +856,7 @@ int bson_append_regex( bson *b, const char *name, const char *pattern, const cha * * @return BSON_OK or BSON_ERROR. */ -int bson_append_bson( bson *b, const char *name, const bson *bson ); +MONGO_EXPORT int bson_append_bson( bson *b, const char *name, const bson *bson ); /** * Append a BSON element to a bson from the current point of an iterator. @@ -816,7 +867,7 @@ int bson_append_bson( bson *b, const char *name, const bson *bson ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem ); +MONGO_EXPORT int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem ); /** * Append a bson_timestamp_t value to a bson. @@ -827,7 +878,8 @@ int bson_append_element( bson *b, const char *name_or_null, const bson_iterator * * @return BSON_OK or BSON_ERROR. */ -int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ); +MONGO_EXPORT int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ); +MONGO_EXPORT int bson_append_timestamp2( bson *b, const char *name, int time, int increment ); /* these both append a bson_date */ /** @@ -839,7 +891,7 @@ int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_date( bson *b, const char *name, bson_date_t millis ); +MONGO_EXPORT int bson_append_date( bson *b, const char *name, bson_date_t millis ); /** * Append a time_t value to a bson. @@ -850,7 +902,7 @@ int bson_append_date( bson *b, const char *name, bson_date_t millis ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_time_t( bson *b, const char *name, time_t secs ); +MONGO_EXPORT int bson_append_time_t( bson *b, const char *name, time_t secs ); /** * Start appending a new object to a bson. @@ -860,7 +912,7 @@ int bson_append_time_t( bson *b, const char *name, time_t secs ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_start_object( bson *b, const char *name ); +MONGO_EXPORT int bson_append_start_object( bson *b, const char *name ); /** * Start appending a new array to a bson. @@ -870,7 +922,7 @@ int bson_append_start_object( bson *b, const char *name ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_start_array( bson *b, const char *name ); +MONGO_EXPORT int bson_append_start_array( bson *b, const char *name ); /** * Finish appending a new object or array to a bson. @@ -879,7 +931,7 @@ int bson_append_start_array( bson *b, const char *name ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_finish_object( bson *b ); +MONGO_EXPORT int bson_append_finish_object( bson *b ); /** * Finish appending a new object or array to a bson. This @@ -889,13 +941,13 @@ int bson_append_finish_object( bson *b ); * * @return BSON_OK or BSON_ERROR. */ -int bson_append_finish_array( bson *b ); +MONGO_EXPORT int bson_append_finish_array( bson *b ); void bson_numstr( char *str, int i ); void bson_incnumstr( char *str ); -/* Error handling and stadard library function over-riding. */ +/* Error handling and standard library function over-riding. */ /* -------------------------------------------------------- */ /* bson_err_handlers shouldn't return!!! */ @@ -912,7 +964,6 @@ extern void ( *bson_free )( void * ); extern bson_printf_func bson_printf; extern bson_fprintf_func bson_fprintf; extern bson_sprintf_func bson_sprintf; - extern bson_printf_func bson_errprintf; /** @@ -924,7 +975,7 @@ extern bson_printf_func bson_errprintf; * * @sa malloc(3) */ -void *bson_malloc( int size ); +MONGO_EXPORT void *bson_malloc( int size ); /** * Changes the size of allocated memory and checks return value, @@ -946,7 +997,7 @@ void *bson_realloc( void *ptr, int size ); * * @return the old error handling function, or NULL. */ -bson_err_handler set_bson_err_handler( bson_err_handler func ); +MONGO_EXPORT bson_err_handler set_bson_err_handler( bson_err_handler func ); /* does nothing if ok != 0 */ /** @@ -971,5 +1022,15 @@ void bson_fatal_msg( int ok, const char *msg ); */ void bson_builder_error( bson *b ); +/** + * Cast an int64_t to double. This is necessary for embedding in + * certain environments. + * + */ +MONGO_EXPORT double bson_int64_to_double( int64_t i64 ); + +MONGO_EXPORT void bson_swap_endian32( void *outp, const void *inp ); +MONGO_EXPORT void bson_swap_endian64( void *outp, const void *inp ); + MONGO_EXTERN_C_END #endif diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.c index 8d2da1502f..00ecf18c92 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.c @@ -1,5 +1,5 @@ /* - * Copyright 2009-2011 10gen, Inc. + * Copyright 2009-2012 10gen, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.h index a2a07c6d5d..f13c31ee89 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.h +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/encoding.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2011 10gen, Inc. + * Copyright 2009-2012 10gen, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef _BSON_ENCODING_H_ -#define _BSON_ENCODING_H_ +#ifndef BSON_ENCODING_H_ +#define BSON_ENCODING_H_ MONGO_EXTERN_C_START diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env.h new file mode 100644 index 0000000000..463ee32f79 --- /dev/null +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env.h @@ -0,0 +1,39 @@ +/** @file env.h */ + +/* Copyright 2009-2012 10gen Inc. + * + * 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. + */ + +/* Header for generic net.h */ +#ifndef MONGO_ENV_H_ +#define MONGO_ENV_H_ + +#include "mongo.h" + +MONGO_EXTERN_C_START + +/* This is a no-op in the generic implementation. */ +int mongo_env_set_socket_op_timeout( mongo *conn, int millis ); +int mongo_env_read_socket( mongo *conn, void *buf, int len ); +int mongo_env_write_socket( mongo *conn, const void *buf, int len ); +int mongo_env_socket_connect( mongo *conn, const char *host, int port ); + +/* Initialize socket services */ +MONGO_EXPORT int mongo_env_sock_init( void ); + +/* Close a socket */ +MONGO_EXPORT int mongo_env_close_socket( int socket ); + +MONGO_EXTERN_C_END +#endif diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_posix.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_posix.c new file mode 100644 index 0000000000..f1020ca80d --- /dev/null +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_posix.c @@ -0,0 +1,165 @@ +/* env_posix.c */ + +/* Copyright 2009-2012 10gen Inc. + * + * 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. + */ + +/* Networking and other niceties for POSIX systems. */ +#include "env.h" +#include "mongo.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef NI_MAXSERV +# define NI_MAXSERV 32 +#endif + +int mongo_env_close_socket( int socket ) { + return close( socket ); +} + +int mongo_env_sock_init( void ) { + return 0; +} + +int mongo_env_write_socket( mongo *conn, const void *buf, int len ) { + const char *cbuf = buf; +#ifdef __APPLE__ + int flags = 0; +#else + int flags = MSG_NOSIGNAL; +#endif + + while ( len ) { + int sent = send( conn->sock, cbuf, len, flags ); + if ( sent == -1 ) { + if (errno == EPIPE) + conn->connected = 0; + __mongo_set_error( conn, MONGO_IO_ERROR, strerror( errno ), errno ); + return MONGO_ERROR; + } + cbuf += sent; + len -= sent; + } + + return MONGO_OK; +} + +int mongo_env_read_socket( mongo *conn, void *buf, int len ) { + char *cbuf = buf; + while ( len ) { + int sent = recv( conn->sock, cbuf, len, 0 ); + if ( sent == 0 || sent == -1 ) { + __mongo_set_error( conn, MONGO_IO_ERROR, strerror( errno ), errno ); + return MONGO_ERROR; + } + cbuf += sent; + len -= sent; + } + + return MONGO_OK; +} + +int mongo_env_set_socket_op_timeout( mongo *conn, int millis ) { + struct timeval tv; + tv.tv_sec = millis / 1000; + tv.tv_usec = ( millis % 1000 ) * 1000; + + if ( setsockopt( conn->sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof( tv ) ) == -1 ) { + conn->err = MONGO_IO_ERROR; + __mongo_set_error( conn, MONGO_IO_ERROR, "setsockopt SO_RCVTIMEO failed.", errno ); + return MONGO_ERROR; + } + + if ( setsockopt( conn->sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof( tv ) ) == -1 ) { + __mongo_set_error( conn, MONGO_IO_ERROR, "setsockopt SO_SNDTIMEO failed.", errno ); + return MONGO_ERROR; + } + + return MONGO_OK; +} + +int mongo_env_socket_connect( mongo *conn, const char *host, int port ) { + char port_str[NI_MAXSERV]; + int status; + + struct addrinfo ai_hints; + struct addrinfo *ai_list = NULL; + struct addrinfo *ai_ptr = NULL; + + conn->sock = 0; + conn->connected = 0; + sprintf(port_str,"%d",port); + + bson_sprintf( port_str, "%d", port ); + + memset( &ai_hints, 0, sizeof( ai_hints ) ); +#ifdef AI_ADDRCONFIG + ai_hints.ai_flags = AI_ADDRCONFIG; +#endif + ai_hints.ai_family = AF_UNSPEC; + ai_hints.ai_socktype = SOCK_STREAM; + + status = getaddrinfo( host, port_str, &ai_hints, &ai_list ); + if ( status != 0 ) { + bson_errprintf( "getaddrinfo failed: %s", gai_strerror( status ) ); + conn->err = MONGO_CONN_ADDR_FAIL; + return MONGO_ERROR; + } + + for ( ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next ) { + conn->sock = socket( ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol ); + if ( conn->sock < 0 ) { + conn->sock = 0; + continue; + } + + status = connect( conn->sock, ai_ptr->ai_addr, ai_ptr->ai_addrlen ); + if ( status != 0 ) { + mongo_env_close_socket( conn->sock ); + conn->sock = 0; + continue; + } + + if ( ai_ptr->ai_protocol == IPPROTO_TCP ) { + int flag = 1; + + setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, + ( void * ) &flag, sizeof( flag ) ); + if ( conn->op_timeout_ms > 0 ) + mongo_env_set_socket_op_timeout( conn, conn->op_timeout_ms ); + } + + conn->connected = 1; + break; + } + + freeaddrinfo( ai_list ); + + if ( ! conn->connected ) { + conn->err = MONGO_CONN_FAIL; + return MONGO_ERROR; + } + + return MONGO_OK; +} diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_standard.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_standard.c new file mode 100644 index 0000000000..36fa9f65c4 --- /dev/null +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_standard.c @@ -0,0 +1,168 @@ +/* env_standard.c */ + +/* Copyright 2009-2012 10gen Inc. + * + * 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. + */ + +/* Vanilla networking designed to work on all systems. */ +#include "env.h" +#include +#include + +#ifdef _WIN32 + #ifdef _MSC_VER + #include // send,recv,socklen_t etc + #include // addrinfo + #else + #include + #include + typedef int socklen_t; + #endif +#else +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#ifndef NI_MAXSERV +# define NI_MAXSERV 32 +#endif + +int mongo_env_close_socket( int socket ) { +#ifdef _WIN32 + return closesocket( socket ); +#else + return close( socket ); +#endif +} + +int mongo_env_write_socket( mongo *conn, const void *buf, int len ) { + const char *cbuf = buf; +#ifdef _WIN32 + int flags = 0; +#else +#ifdef __APPLE__ + int flags = 0; +#else + int flags = MSG_NOSIGNAL; +#endif +#endif + + while ( len ) { + int sent = send( conn->sock, cbuf, len, flags ); + if ( sent == -1 ) { + if (errno == EPIPE) + conn->connected = 0; + conn->err = MONGO_IO_ERROR; + return MONGO_ERROR; + } + cbuf += sent; + len -= sent; + } + + return MONGO_OK; +} + +int mongo_env_read_socket( mongo *conn, void *buf, int len ) { + char *cbuf = buf; + while ( len ) { + int sent = recv( conn->sock, cbuf, len, 0 ); + if ( sent == 0 || sent == -1 ) { + conn->err = MONGO_IO_ERROR; + return MONGO_ERROR; + } + cbuf += sent; + len -= sent; + } + + return MONGO_OK; +} + +/* This is a no-op in the generic implementation. */ +int mongo_env_set_socket_op_timeout( mongo *conn, int millis ) { + return MONGO_OK; +} + +int mongo_env_socket_connect( mongo *conn, const char *host, int port ) { + struct sockaddr_in sa; + socklen_t addressSize; + int flag = 1; + + if ( ( conn->sock = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) { + conn->sock = 0; + conn->err = MONGO_CONN_NO_SOCKET; + return MONGO_ERROR; + } + + memset( sa.sin_zero , 0 , sizeof( sa.sin_zero ) ); + sa.sin_family = AF_INET; + sa.sin_port = htons( port ); + sa.sin_addr.s_addr = inet_addr( host ); + addressSize = sizeof( sa ); + + if ( connect( conn->sock, ( struct sockaddr * )&sa, addressSize ) == -1 ) { + mongo_env_close_socket( conn->sock ); + conn->connected = 0; + conn->sock = 0; + conn->err = MONGO_CONN_FAIL; + return MONGO_ERROR; + } + + setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * ) &flag, sizeof( flag ) ); + + if( conn->op_timeout_ms > 0 ) + mongo_env_set_socket_op_timeout( conn, conn->op_timeout_ms ); + + conn->connected = 1; + + return MONGO_OK; +} + +MONGO_EXPORT int mongo_env_sock_init( void ) { + +#if defined(_WIN32) + WSADATA wsaData; + WORD wVers; +#elif defined(SIGPIPE) + struct sigaction act; +#endif + + static int called_once; + static int retval; + if (called_once) return retval; + called_once = 1; + +#if defined(_WIN32) + wVers = MAKEWORD(1, 1); + retval = (WSAStartup(wVers, &wsaData) == 0); +#elif defined(MACINTOSH) + GUSISetup(GUSIwithInternetSockets); + retval = 1; +#elif defined(SIGPIPE) + retval = 1; + if (sigaction(SIGPIPE, (struct sigaction *)NULL, &act) < 0) + retval = 0; + else if (act.sa_handler == SIG_DFL) { + act.sa_handler = SIG_IGN; + if (sigaction(SIGPIPE, &act, (struct sigaction *)NULL) < 0) + retval = 0; + } +#endif + return retval; +} diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_win32.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_win32.c new file mode 100644 index 0000000000..0b301cea61 --- /dev/null +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/env_win32.c @@ -0,0 +1,183 @@ +/* env_win32.c */ + +/* Copyright 2009-2012 10gen Inc. + * + * 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. + */ + +/* Networking and other niceties for WIN32. */ +#include "env.h" +#include "mongo.h" +#include + +#ifdef _MSC_VER +#include // send,recv,socklen_t etc +#include // addrinfo +#else +#include +#include +typedef int socklen_t; +#endif + +#ifndef NI_MAXSERV +# define NI_MAXSERV 32 +#endif + +static void mongo_clear_errors( mongo *conn ) { + conn->err = 0; + memset( conn->errstr, 0, MONGO_ERR_LEN ); +} + +int mongo_env_close_socket( int socket ) { + return closesocket( socket ); +} + +int mongo_env_write_socket( mongo *conn, const void *buf, int len ) { + const char *cbuf = buf; + int flags = 0; + + while ( len ) { + int sent = send( conn->sock, cbuf, len, flags ); + if ( sent == -1 ) { + __mongo_set_error( conn, MONGO_IO_ERROR, NULL, WSAGetLastError() ); + conn->connected = 0; + return MONGO_ERROR; + } + cbuf += sent; + len -= sent; + } + + return MONGO_OK; +} + +int mongo_env_read_socket( mongo *conn, void *buf, int len ) { + char *cbuf = buf; + + while ( len ) { + int sent = recv( conn->sock, cbuf, len, 0 ); + if ( sent == 0 || sent == -1 ) { + __mongo_set_error( conn, MONGO_IO_ERROR, NULL, WSAGetLastError() ); + return MONGO_ERROR; + } + cbuf += sent; + len -= sent; + } + + return MONGO_OK; +} + +int mongo_env_set_socket_op_timeout( mongo *conn, int millis ) { + if ( setsockopt( conn->sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&millis, + sizeof( millis ) ) == -1 ) { + __mongo_set_error( conn, MONGO_IO_ERROR, "setsockopt SO_RCVTIMEO failed.", + WSAGetLastError() ); + return MONGO_ERROR; + } + + if ( setsockopt( conn->sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)&millis, + sizeof( millis ) ) == -1 ) { + __mongo_set_error( conn, MONGO_IO_ERROR, "setsockopt SO_SNDTIMEO failed.", + WSAGetLastError() ); + return MONGO_ERROR; + } + + return MONGO_OK; +} + +int mongo_env_socket_connect( mongo *conn, const char *host, int port ) { + char port_str[NI_MAXSERV]; + char errstr[MONGO_ERR_LEN]; + int status; + + struct addrinfo ai_hints; + struct addrinfo *ai_list = NULL; + struct addrinfo *ai_ptr = NULL; + + conn->sock = 0; + conn->connected = 0; + + bson_sprintf( port_str, "%d", port ); + + memset( &ai_hints, 0, sizeof( ai_hints ) ); + ai_hints.ai_family = AF_UNSPEC; + ai_hints.ai_socktype = SOCK_STREAM; + ai_hints.ai_protocol = IPPROTO_TCP; + + status = getaddrinfo( host, port_str, &ai_hints, &ai_list ); + if ( status != 0 ) { + bson_sprintf( errstr, "getaddrinfo failed with error %d", status ); + __mongo_set_error( conn, MONGO_CONN_ADDR_FAIL, errstr, WSAGetLastError() ); + return MONGO_ERROR; + } + + for ( ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next ) { + conn->sock = socket( ai_ptr->ai_family, ai_ptr->ai_socktype, + ai_ptr->ai_protocol ); + + if ( conn->sock < 0 ) { + __mongo_set_error( conn, MONGO_SOCKET_ERROR, "socket() failed", + WSAGetLastError() ); + conn->sock = 0; + continue; + } + + status = connect( conn->sock, ai_ptr->ai_addr, ai_ptr->ai_addrlen ); + if ( status != 0 ) { + __mongo_set_error( conn, MONGO_SOCKET_ERROR, "connect() failed", + WSAGetLastError() ); + mongo_env_close_socket( conn->sock ); + conn->sock = 0; + continue; + } + + if ( ai_ptr->ai_protocol == IPPROTO_TCP ) { + int flag = 1; + + setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, + ( void * ) &flag, sizeof( flag ) ); + + if ( conn->op_timeout_ms > 0 ) + mongo_env_set_socket_op_timeout( conn, conn->op_timeout_ms ); + } + + conn->connected = 1; + break; + } + + freeaddrinfo( ai_list ); + + if ( ! conn->connected ) { + conn->err = MONGO_CONN_FAIL; + return MONGO_ERROR; + } + else { + mongo_clear_errors( conn ); + return MONGO_OK; + } +} + +MONGO_EXPORT int mongo_env_sock_init( void ) { + + WSADATA wsaData; + WORD wVers; + static int called_once; + static int retval; + + if (called_once) return retval; + + called_once = 1; + wVers = MAKEWORD(1, 1); + retval = (WSAStartup(wVers, &wsaData) == 0); + + return retval; +} diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/gridfs.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/gridfs.c index f51b397d3f..9b2d1455ef 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/gridfs.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/gridfs.c @@ -1,6 +1,6 @@ /* gridfs.c */ -/* Copyright 2009-2011 10gen Inc. +/* Copyright 2009-2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,27 @@ #include #include +MONGO_EXPORT gridfs* gridfs_create() { + return (gridfs*)bson_malloc(sizeof(gridfs)); +} + +MONGO_EXPORT void gridfs_dispose(gridfs* gfs) { + free(gfs); +} + +MONGO_EXPORT gridfile* gridfile_create() { + return (gridfile*)bson_malloc(sizeof(gridfile)); +} + +MONGO_EXPORT void gridfile_dispose(gridfile* gf) { + free(gf); +} + +MONGO_EXPORT void gridfile_get_descriptor(gridfile* gf, bson* out) { + *out = *gf->meta; +} + + static bson *chunk_new( bson_oid_t id, int chunkNumber, const char *data, int len ) { bson *b = bson_malloc( sizeof( bson ) ); @@ -104,7 +125,7 @@ int gridfs_init( mongo *client, const char *dbname, const char *prefix, return MONGO_OK; } -void gridfs_destroy( gridfs *gfs ) { +MONGO_EXPORT void gridfs_destroy( gridfs *gfs ) { if ( gfs == NULL ) return; if ( gfs->dbname ) bson_free( ( char * )gfs->dbname ); if ( gfs->prefix ) bson_free( ( char * )gfs->prefix ); @@ -120,14 +141,17 @@ static int gridfs_insert_file( gridfs *gfs, const char *name, bson res; bson_iterator it; int result; + int64_t d; /* Check run md5 */ bson_init( &command ); bson_append_oid( &command, "filemd5", &id ); bson_append_string( &command, "root", gfs->prefix ); bson_finish( &command ); - assert( mongo_run_command( gfs->client, gfs->dbname, &command, &res ) == MONGO_OK ); + result = mongo_run_command( gfs->client, gfs->dbname, &command, &res ); bson_destroy( &command ); + if (result != MONGO_OK) + return result; /* Create and insert BSON for file metadata */ bson_init( &ret ); @@ -137,7 +161,8 @@ static int gridfs_insert_file( gridfs *gfs, const char *name, } bson_append_long( &ret, "length", length ); bson_append_int( &ret, "chunkSize", DEFAULT_CHUNK_SIZE ); - bson_append_date( &ret, "uploadDate", ( bson_date_t )1000*time( NULL ) ); + d = ( bson_date_t )1000*time( NULL ); + bson_append_date( &ret, "uploadDate", d); bson_find( &it, &res, "md5" ); bson_append_string( &ret, "md5", bson_iterator_string( &it ) ); bson_destroy( &res ); @@ -151,7 +176,7 @@ static int gridfs_insert_file( gridfs *gfs, const char *name, return result; } -int gridfs_store_buffer( gridfs *gfs, const char *data, +MONGO_EXPORT int gridfs_store_buffer( gridfs *gfs, const char *data, gridfs_offset length, const char *remotename, const char *contenttype ) { @@ -163,7 +188,7 @@ int gridfs_store_buffer( gridfs *gfs, const char *data, bson *oChunk; /* Large files Assertion */ - assert( length <= 0xffffffff ); + /* assert( length <= 0xffffffff ); */ /* Generate and append an oid*/ bson_oid_gen( &id ); @@ -183,7 +208,7 @@ int gridfs_store_buffer( gridfs *gfs, const char *data, return gridfs_insert_file( gfs, remotename, id, length, contenttype ); } -void gridfile_writer_init( gridfile *gfile, gridfs *gfs, +MONGO_EXPORT void gridfile_writer_init( gridfile *gfile, gridfs *gfs, const char *remote_name, const char *content_type ) { gfile->gfs = gfs; @@ -200,7 +225,7 @@ void gridfile_writer_init( gridfile *gfile, gridfs *gfs, strcpy( ( char * )gfile->content_type, content_type ); } -void gridfile_write_buffer( gridfile *gfile, const char *data, +MONGO_EXPORT void gridfile_write_buffer( gridfile *gfile, const char *data, gridfs_offset length ) { int bytes_left = 0; @@ -221,14 +246,13 @@ void gridfile_write_buffer( gridfile *gfile, const char *data, gfile->pending_len += length; } else { /* At least one chunk of data to write */ + chunks_to_write = to_write / DEFAULT_CHUNK_SIZE; + bytes_left = to_write % DEFAULT_CHUNK_SIZE; /* If there's a pending chunk to be written, we need to combine * the buffer provided up to DEFAULT_CHUNK_SIZE. */ if ( gfile->pending_len > 0 ) { - chunks_to_write = to_write / DEFAULT_CHUNK_SIZE; - bytes_left = to_write % DEFAULT_CHUNK_SIZE; - data_partial_len = DEFAULT_CHUNK_SIZE - gfile->pending_len; buffer = ( char * )bson_malloc( DEFAULT_CHUNK_SIZE ); memcpy( buffer, gfile->pending_data, gfile->pending_len ); @@ -270,7 +294,7 @@ void gridfile_write_buffer( gridfile *gfile, const char *data, } } -int gridfile_writer_done( gridfile *gfile ) { +MONGO_EXPORT int gridfile_writer_done( gridfile *gfile ) { /* write any remaining pending chunk data. * pending data will always take up less than one chunk */ @@ -307,8 +331,11 @@ int gridfs_store_file( gridfs *gfs, const char *filename, /* Open the file and the correct stream */ if ( strcmp( filename, "-" ) == 0 ) fd = stdin; - else fd = fopen( filename, "rb" ); - assert( fd != NULL ); /* No such file */ + else { + fd = fopen( filename, "rb" ); + if (fd == NULL) + return MONGO_ERROR; + } /* Generate and append an oid*/ bson_oid_gen( &id ); @@ -339,7 +366,7 @@ int gridfs_store_file( gridfs *gfs, const char *filename, return gridfs_insert_file( gfs, remotename, id, length, contenttype ); } -void gridfs_remove_filename( gridfs *gfs, const char *filename ) { +MONGO_EXPORT void gridfs_remove_filename( gridfs *gfs, const char *filename ) { bson query; mongo_cursor *files; bson file; @@ -433,7 +460,7 @@ int gridfile_init( gridfs *gfs, bson *meta, gridfile *gfile ) return MONGO_OK; } -void gridfile_destroy( gridfile *gfile ) +MONGO_EXPORT void gridfile_destroy( gridfile *gfile ) { bson_destroy( gfile->meta ); @@ -444,21 +471,21 @@ bson_bool_t gridfile_exists( gridfile *gfile ) { return ( bson_bool_t )( gfile != NULL || gfile->meta == NULL ); } -const char *gridfile_get_filename( gridfile *gfile ) { +MONGO_EXPORT const char *gridfile_get_filename( gridfile *gfile ) { bson_iterator it; bson_find( &it, gfile->meta, "filename" ); return bson_iterator_string( &it ); } -int gridfile_get_chunksize( gridfile *gfile ) { +MONGO_EXPORT int gridfile_get_chunksize( gridfile *gfile ) { bson_iterator it; bson_find( &it, gfile->meta, "chunkSize" ); return bson_iterator_int( &it ); } -gridfs_offset gridfile_get_contentlength( gridfile *gfile ) { +MONGO_EXPORT gridfs_offset gridfile_get_contentlength( gridfile *gfile ) { bson_iterator it; bson_find( &it, gfile->meta, "length" ); @@ -469,7 +496,7 @@ gridfs_offset gridfile_get_contentlength( gridfile *gfile ) { return ( gridfs_offset )bson_iterator_long( &it ); } -const char *gridfile_get_contenttype( gridfile *gfile ) { +MONGO_EXPORT const char *gridfile_get_contenttype( gridfile *gfile ) { bson_iterator it; if ( bson_find( &it, gfile->meta, "contentType" ) ) @@ -477,14 +504,14 @@ const char *gridfile_get_contenttype( gridfile *gfile ) { else return NULL; } -bson_date_t gridfile_get_uploaddate( gridfile *gfile ) { +MONGO_EXPORT bson_date_t gridfile_get_uploaddate( gridfile *gfile ) { bson_iterator it; bson_find( &it, gfile->meta, "uploadDate" ); return bson_iterator_date( &it ); } -const char *gridfile_get_md5( gridfile *gfile ) { +MONGO_EXPORT const char *gridfile_get_md5( gridfile *gfile ) { bson_iterator it; bson_find( &it, gfile->meta, "md5" ); @@ -505,20 +532,16 @@ bson_bool_t gridfile_get_boolean( gridfile *gfile, const char *name ) { return bson_iterator_bool( &it ); } -bson gridfile_get_metadata( gridfile *gfile ) { - bson sub; +MONGO_EXPORT void gridfile_get_metadata( gridfile *gfile, bson* out ) { bson_iterator it; - if ( bson_find( &it, gfile->meta, "metadata" ) ) { - bson_iterator_subobject( &it, &sub ); - return sub; - } else { - bson_empty( &sub ); - return sub; - } + if ( bson_find( &it, gfile->meta, "metadata" ) ) + bson_iterator_subobject( &it, out ); + else + bson_empty( out ); } -int gridfile_get_numchunks( gridfile *gfile ) { +MONGO_EXPORT int gridfile_get_numchunks( gridfile *gfile ) { bson_iterator it; gridfs_offset length; gridfs_offset chunkSize; @@ -539,11 +562,12 @@ int gridfile_get_numchunks( gridfile *gfile ) { : ( int )( numchunks ); } -bson gridfile_get_chunk( gridfile *gfile, int n ) { +MONGO_EXPORT void gridfile_get_chunk( gridfile *gfile, int n, bson* out ) { bson query; - bson out; + bson_iterator it; bson_oid_t id; + int result; bson_init( &query ); bson_find( &it, gfile->meta, "_id" ); @@ -552,15 +576,18 @@ bson gridfile_get_chunk( gridfile *gfile, int n ) { bson_append_int( &query, "n", n ); bson_finish( &query ); - assert( mongo_find_one( gfile->gfs->client, - gfile->gfs->chunks_ns, - &query, NULL, &out ) == MONGO_OK ); - + result = (mongo_find_one(gfile->gfs->client, + gfile->gfs->chunks_ns, + &query, NULL, out ) == MONGO_OK ); bson_destroy( &query ); - return out; + if (!result) { + bson empty; + bson_empty(&empty); + bson_copy(out, &empty); + } } -mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size ) { +MONGO_EXPORT mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size ) { bson_iterator it; bson_oid_t id; bson gte; @@ -613,18 +640,18 @@ gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream ) { const int num = gridfile_get_numchunks( gfile ); for ( i=0; i Length of pending_data buffer */ } gridfile; +MONGO_EXPORT gridfs* gridfs_create(); +MONGO_EXPORT void gridfs_dispose(gridfs* gfs); +MONGO_EXPORT gridfile* gridfile_create(); +MONGO_EXPORT void gridfile_dispose(gridfile* gf); +MONGO_EXPORT void gridfile_get_descriptor(gridfile* gf, bson* out); + /** * Initializes a GridFS object * @param client - db connection @@ -60,7 +66,7 @@ typedef struct { * * @return - MONGO_OK or MONGO_ERROR. */ -int gridfs_init( mongo *client, const char *dbname, +MONGO_EXPORT int gridfs_init( mongo *client, const char *dbname, const char *prefix, gridfs *gfs ); /** @@ -69,7 +75,7 @@ int gridfs_init( mongo *client, const char *dbname, * * @param gfs a grid */ -void gridfs_destroy( gridfs *gfs ); +MONGO_EXPORT void gridfs_destroy( gridfs *gfs ); /** * Initializes a gridfile for writing incrementally with gridfs_write_buffer. @@ -77,7 +83,7 @@ void gridfs_destroy( gridfs *gfs ); * When done, you must call gridfs_writer_done to save the file metadata. * */ -void gridfile_writer_init( gridfile *gfile, gridfs *gfs, const char *remote_name, +MONGO_EXPORT void gridfile_writer_init( gridfile *gfile, gridfs *gfs, const char *remote_name, const char *content_type ); /** @@ -86,7 +92,7 @@ void gridfile_writer_init( gridfile *gfile, gridfs *gfs, const char *remote_name * stream to a GridFS file. When finished, be sure to call gridfs_writer_done. * */ -void gridfile_write_buffer( gridfile *gfile, const char *data, +MONGO_EXPORT void gridfile_write_buffer( gridfile *gfile, const char *data, gridfs_offset length ); /** @@ -96,7 +102,7 @@ void gridfile_write_buffer( gridfile *gfile, const char *data, * * @return - MONGO_OK or MONGO_ERROR. */ -int gridfile_writer_done( gridfile *gfile ); +MONGO_EXPORT int gridfile_writer_done( gridfile *gfile ); /** * Store a buffer as a GridFS file. @@ -108,7 +114,7 @@ int gridfile_writer_done( gridfile *gfile ); * * @return - MONGO_OK or MONGO_ERROR. */ -int gridfs_store_buffer( gridfs *gfs, const char *data, gridfs_offset length, +MONGO_EXPORT int gridfs_store_buffer( gridfs *gfs, const char *data, gridfs_offset length, const char *remotename, const char *contenttype ); @@ -121,7 +127,7 @@ int gridfs_store_buffer( gridfs *gfs, const char *data, gridfs_offset length, * * @return - MONGO_OK or MONGO_ERROR. */ -int gridfs_store_file( gridfs *gfs, const char *filename, +MONGO_EXPORT int gridfs_store_file( gridfs *gfs, const char *filename, const char *remotename, const char *contenttype ); /** @@ -129,7 +135,7 @@ int gridfs_store_file( gridfs *gfs, const char *filename, * @param gfs - the working GridFS * @param filename - the filename of the file/s to be removed */ -void gridfs_remove_filename( gridfs *gfs, const char *filename ); +MONGO_EXPORT void gridfs_remove_filename( gridfs *gfs, const char *filename ); /** * Find the first file matching the provided query within the @@ -141,7 +147,7 @@ void gridfs_remove_filename( gridfs *gfs, const char *filename ); * * @return MONGO_OK if successful, MONGO_ERROR otherwise */ -int gridfs_find_query( gridfs *gfs, bson *query, gridfile *gfile ); +MONGO_EXPORT int gridfs_find_query( gridfs *gfs, bson *query, gridfile *gfile ); /** * Find the first file referenced by filename within the GridFS @@ -152,7 +158,7 @@ int gridfs_find_query( gridfs *gfs, bson *query, gridfile *gfile ); * * @return MONGO_OK or MONGO_ERROR. */ -int gridfs_find_filename( gridfs *gfs, const char *filename, gridfile *gfile ); +MONGO_EXPORT int gridfs_find_filename( gridfs *gfs, const char *filename, gridfile *gfile ); /** * Initializes a GridFile containing the GridFS and file bson @@ -162,20 +168,20 @@ int gridfs_find_filename( gridfs *gfs, const char *filename, gridfile *gfile ); * * @return - MONGO_OK or MONGO_ERROR. */ -int gridfile_init( gridfs *gfs, bson *meta, gridfile *gfile ); +MONGO_EXPORT int gridfile_init( gridfs *gfs, bson *meta, gridfile *gfile ); /** * Destroys the GridFile * * @param oGridFIle - the GridFile being destroyed */ -void gridfile_destroy( gridfile *gfile ); +MONGO_EXPORT void gridfile_destroy( gridfile *gfile ); /** * Returns whether or not the GridFile exists * @param gfile - the GridFile being examined */ -bson_bool_t gridfile_exists( gridfile *gfile ); +MONGO_EXPORT bson_bool_t gridfile_exists( gridfile *gfile ); /** * Returns the filename of GridFile @@ -183,7 +189,7 @@ bson_bool_t gridfile_exists( gridfile *gfile ); * * @return - the filename of the Gridfile */ -const char *gridfile_get_filename( gridfile *gfile ); +MONGO_EXPORT const char *gridfile_get_filename( gridfile *gfile ); /** * Returns the size of the chunks of the GridFile @@ -191,7 +197,7 @@ const char *gridfile_get_filename( gridfile *gfile ); * * @return - the size of the chunks of the Gridfile */ -int gridfile_get_chunksize( gridfile *gfile ); +MONGO_EXPORT int gridfile_get_chunksize( gridfile *gfile ); /** * Returns the length of GridFile's data @@ -200,7 +206,7 @@ int gridfile_get_chunksize( gridfile *gfile ); * * @return - the length of the Gridfile's data */ -gridfs_offset gridfile_get_contentlength( gridfile *gfile ); +MONGO_EXPORT gridfs_offset gridfile_get_contentlength( gridfile *gfile ); /** * Returns the MIME type of the GridFile @@ -210,7 +216,7 @@ gridfs_offset gridfile_get_contentlength( gridfile *gfile ); * @return - the MIME type of the Gridfile * (NULL if no type specified) */ -const char *gridfile_get_contenttype( gridfile *gfile ); +MONGO_EXPORT const char *gridfile_get_contenttype( gridfile *gfile ); /** * Returns the upload date of GridFile @@ -219,7 +225,7 @@ const char *gridfile_get_contenttype( gridfile *gfile ); * * @return - the upload date of the Gridfile */ -bson_date_t gridfile_get_uploaddate( gridfile *gfile ); +MONGO_EXPORT bson_date_t gridfile_get_uploaddate( gridfile *gfile ); /** * Returns the MD5 of GridFile @@ -228,7 +234,7 @@ bson_date_t gridfile_get_uploaddate( gridfile *gfile ); * * @return - the MD5 of the Gridfile */ -const char *gridfile_get_md5( gridfile *gfile ); +MONGO_EXPORT const char *gridfile_get_md5( gridfile *gfile ); /** * Returns the field in GridFile specified by name @@ -260,7 +266,7 @@ bson_bool_t gridfile_get_boolean( gridfile *gfile, * @return - the metadata of the Gridfile in a bson object * (an empty bson is returned if none exists) */ -bson gridfile_get_metadata( gridfile *gfile ); +MONGO_EXPORT void gridfile_get_metadata( gridfile *gfile, bson* out ); /** * Returns the number of chunks in the GridFile @@ -268,7 +274,7 @@ bson gridfile_get_metadata( gridfile *gfile ); * * @return - the number of chunks in the Gridfile */ -int gridfile_get_numchunks( gridfile *gfile ); +MONGO_EXPORT int gridfile_get_numchunks( gridfile *gfile ); /** * Returns chunk n of GridFile @@ -276,7 +282,7 @@ int gridfile_get_numchunks( gridfile *gfile ); * * @return - the nth chunk of the Gridfile */ -bson gridfile_get_chunk( gridfile *gfile, int n ); +MONGO_EXPORT void gridfile_get_chunk( gridfile *gfile, int n, bson* out ); /** * Returns a mongo_cursor of *size* chunks starting with chunk *start* @@ -287,7 +293,7 @@ bson gridfile_get_chunk( gridfile *gfile, int n ); * * @return - mongo_cursor of the chunks (must be destroyed after use) */ -mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size ); +MONGO_EXPORT mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size ); /** * Writes the GridFile to a stream @@ -295,7 +301,7 @@ mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size ); * @param gfile - the working GridFile * @param stream - the file stream to write to */ -gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream ); +MONGO_EXPORT gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream ); /** * Reads length bytes from the GridFile to a buffer @@ -309,7 +315,7 @@ gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream ); * * @return - the number of bytes read */ -gridfs_offset gridfile_read( gridfile *gfile, gridfs_offset size, char *buf ); +MONGO_EXPORT gridfs_offset gridfile_read( gridfile *gfile, gridfs_offset size, char *buf ); /** * Updates the position in the file @@ -321,6 +327,6 @@ gridfs_offset gridfile_read( gridfile *gfile, gridfs_offset size, char *buf ); * * @return - resulting offset location */ -gridfs_offset gridfile_seek( gridfile *gfile, gridfs_offset offset ); +MONGO_EXPORT gridfs_offset gridfile_seek( gridfile *gfile, gridfs_offset offset ); #endif diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.c index d1c1e3ab0b..68edd29513 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.c @@ -309,7 +309,7 @@ mongo_md5_process(mongo_md5_state_t *pms, const mongo_md5_byte_t *data /*[64]*/) pms->abcd[3] += d; } -void +MONGO_EXPORT void mongo_md5_init(mongo_md5_state_t *pms) { pms->count[0] = pms->count[1] = 0; @@ -319,7 +319,7 @@ mongo_md5_init(mongo_md5_state_t *pms) pms->abcd[3] = 0x10325476; } -void +MONGO_EXPORT void mongo_md5_append(mongo_md5_state_t *pms, const mongo_md5_byte_t *data, int nbytes) { const mongo_md5_byte_t *p = data; @@ -357,7 +357,7 @@ mongo_md5_append(mongo_md5_state_t *pms, const mongo_md5_byte_t *data, int nbyte memcpy(pms->buf, p, left); } -void +MONGO_EXPORT void mongo_md5_finish(mongo_md5_state_t *pms, mongo_md5_byte_t digest[16]) { static const mongo_md5_byte_t pad[64] = { diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.h index 540da3a584..342b6a7307 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.h +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.h @@ -47,8 +47,8 @@ 1999-05-03 lpd Original version. */ -#ifndef md5_INCLUDED -# define md5_INCLUDED +#ifndef MONGO_MD5_H_ +#define MONGO_MD5_H_ /* * This package supports both compile-time and run-time determination of CPU @@ -59,6 +59,7 @@ * run on either big- or little-endian CPUs, but will run slightly less * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. */ +#include "bson.h" typedef unsigned char mongo_md5_byte_t; /* 8-bit byte */ typedef unsigned int mongo_md5_word_t; /* 32-bit word */ @@ -75,17 +76,17 @@ extern "C" { #endif - /* Initialize the algorithm. */ - void mongo_md5_init(mongo_md5_state_t *pms); +/* Initialize the algorithm. */ +MONGO_EXPORT void mongo_md5_init(mongo_md5_state_t *pms); - /* Append a string to the message. */ - void mongo_md5_append(mongo_md5_state_t *pms, const mongo_md5_byte_t *data, int nbytes); +/* Append a string to the message. */ +MONGO_EXPORT void mongo_md5_append(mongo_md5_state_t *pms, const mongo_md5_byte_t *data, int nbytes); - /* Finish the message and return the digest. */ - void mongo_md5_finish(mongo_md5_state_t *pms, mongo_md5_byte_t digest[16]); +/* Finish the message and return the digest. */ +MONGO_EXPORT void mongo_md5_finish(mongo_md5_state_t *pms, mongo_md5_byte_t digest[16]); #ifdef __cplusplus } /* end extern "C" */ #endif -#endif /* md5_INCLUDED */ +#endif /* MONGO_MD5_H_ */ diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.c index 2090e74312..eb16392297 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.c @@ -1,6 +1,6 @@ /* mongo.c */ -/* Copyright 2009-2011 10gen Inc. +/* Copyright 2009-2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,19 +17,235 @@ #include "mongo.h" #include "md5.h" +#include "env.h" #include #include #include #include -#ifdef _USE_LINUX_SYSTEM -#include "platform/linux/net.h" -#elif defined _USE_CUSTOM_SYSTEM -#include "platform/custom/net.h" -#else -#include "net.h" -#endif +MONGO_EXPORT mongo* mongo_create() { + return (mongo*)bson_malloc(sizeof(mongo)); +} + + +MONGO_EXPORT void mongo_dispose(mongo* conn) { + free(conn); +} + +MONGO_EXPORT int mongo_get_err(mongo* conn) { + return conn->err; +} + + +MONGO_EXPORT int mongo_is_connected(mongo* conn) { + return conn->connected != 0; +} + + +MONGO_EXPORT int mongo_get_op_timeout(mongo* conn) { + return conn->op_timeout_ms; +} + + +const char* _get_host_port(mongo_host_port* hp) { + static char _hp[sizeof(hp->host)+12]; + bson_sprintf(_hp, "%s:%d", hp->host, hp->port); + return _hp; +} + + +MONGO_EXPORT const char* mongo_get_primary(mongo* conn) { + mongo* conn_ = (mongo*)conn; + return _get_host_port(conn_->primary); +} + + +MONGO_EXPORT int mongo_get_socket(mongo* conn) { + mongo* conn_ = (mongo*)conn; + return conn_->sock; +} + + +MONGO_EXPORT int mongo_get_host_count(mongo* conn) { + mongo_replset* r = conn->replset; + mongo_host_port* hp; + int count = 0; + if (!r) return 0; + for (hp = r->hosts; hp; hp = hp->next) + ++count; + return count; +} + + +MONGO_EXPORT const char* mongo_get_host(mongo* conn, int i) { + mongo_replset* r = conn->replset; + mongo_host_port* hp; + int count = 0; + if (!r) return 0; + for (hp = r->hosts; hp; hp = hp->next) { + if (count == i) + return _get_host_port(hp); + ++count; + } + return 0; +} + + +MONGO_EXPORT mongo_cursor* mongo_cursor_create() { + return (mongo_cursor*)bson_malloc(sizeof(mongo_cursor)); +} + + +MONGO_EXPORT void mongo_cursor_dispose(mongo_cursor* cursor) { + free(cursor); +} + + +MONGO_EXPORT int mongo_get_server_err(mongo* conn) { + return conn->lasterrcode; +} + + +MONGO_EXPORT const char* mongo_get_server_err_string(mongo* conn) { + return conn->lasterrstr; +} + +MONGO_EXPORT void __mongo_set_error( mongo *conn, mongo_error_t err, const char *str, + int errcode ) { + int errstr_size, str_size; + + conn->err = err; + conn->errcode = errcode; + + if( str ) { + str_size = strlen( str ) + 1; + errstr_size = str_size > MONGO_ERR_LEN ? MONGO_ERR_LEN : str_size; + memcpy( conn->errstr, str, errstr_size ); + conn->errstr[errstr_size] = '\0'; + } +} + +MONGO_EXPORT void mongo_clear_errors( mongo *conn ) { + conn->err = 0; + conn->errcode = 0; + conn->lasterrcode = 0; + memset( conn->errstr, 0, MONGO_ERR_LEN ); + memset( conn->lasterrstr, 0, MONGO_ERR_LEN ); +} + +MONGO_EXPORT int mongo_validate_ns( mongo *conn, const char *ns ) { + char *last = NULL; + char *current = NULL; + const char *db_name = ns; + char *collection_name = NULL; + char errmsg[64]; + int ns_len = 0; + + /* If the first character is a '.', fail. */ + if( *ns == '.' ) { + __mongo_set_error( conn, MONGO_NS_INVALID, "ns cannot start with a '.'.", 0 ); + return MONGO_ERROR; + } + + /* Find the division between database and collection names. */ + for( current = (char *)ns; *current != '\0'; current++ ) { + if( *current == '.' ) { + current++; + break; + } + } + + /* Fail because the ns doesn't contain a '.' + * or the collection part starts with a dot. */ + if( *current == '\0' || *current == '.' ) { + __mongo_set_error( conn, MONGO_NS_INVALID, "ns cannot start with a '.'.", 0 ); + return MONGO_ERROR; + } + + /* Fail if collection length is 0. */ + if( *(current + 1) == '\0' ) { + __mongo_set_error( conn, MONGO_NS_INVALID, "Collection name missing.", 0 ); + return MONGO_ERROR; + } + + + /* Point to the beginning of the collection name. */ + collection_name = current; + + /* Ensure that the database name is greater than one char.*/ + if( collection_name - 1 == db_name ) { + __mongo_set_error( conn, MONGO_NS_INVALID, "Database name missing.", 0 ); + return MONGO_ERROR; + } + + /* Go back and validate the database name. */ + for( current = (char *)db_name; *current != '.'; current++ ) { + switch( *current ) { + case ' ': + case '$': + case '/': + case '\\': + __mongo_set_error( conn, MONGO_NS_INVALID, + "Database name may not contain ' ', '$', '/', or '\\'", 0 ); + return MONGO_ERROR; + default: + break; + } + + ns_len++; + } + + /* Add one to the length for the '.' character. */ + ns_len++; + + /* Now validate the collection name. */ + for( current = collection_name; *current != '\0'; current++ ) { + + /* Cannot have two consecutive dots. */ + if( last && *last == '.' && *current == '.' ) { + __mongo_set_error( conn, MONGO_NS_INVALID, + "Collection may not contain two consecutive '.'", 0 ); + return MONGO_ERROR; + } + + /* Cannot contain a '$' */ + if( *current == '$' ) { + __mongo_set_error( conn, MONGO_NS_INVALID, + "Collection may not contain '$'", 0 ); + return MONGO_ERROR; + } + + last = current; + ns_len++; + } + + if( ns_len > 128 ) { + bson_sprintf( errmsg, "Namespace too long; has %d but must <= 128.", + ns_len ); + __mongo_set_error( conn, MONGO_NS_INVALID, errmsg, 0 ); + return MONGO_ERROR; + } + + /* Cannot end with a '.' */ + if( *(current - 1) == '.' ) { + __mongo_set_error( conn, MONGO_NS_INVALID, + "Collection may not end with '.'", 0 ); + return MONGO_ERROR; + } + + return MONGO_OK; +} + +static void mongo_set_last_error( mongo *conn, bson_iterator *it, bson *obj ) { + int result_len = bson_iterator_string_len( it ); + const char *result_string = bson_iterator_string( it ); + int len = result_len < MONGO_ERR_LEN ? result_len : MONGO_ERR_LEN; + memcpy( conn->lasterrstr, result_string, len ); + + if( bson_find( it, obj, "code" ) != BSON_NULL ) + conn->lasterrcode = bson_iterator_int( it ); +} static const int ZERO = 0; static const int ONE = 1; @@ -57,13 +273,13 @@ int mongo_message_send( mongo *conn, mongo_message *mm ) { bson_little_endian32( &head.responseTo, &mm->head.responseTo ); bson_little_endian32( &head.op, &mm->head.op ); - res = mongo_write_socket( conn, &head, sizeof( head ) ); + res = mongo_env_write_socket( conn, &head, sizeof( head ) ); if( res != MONGO_OK ) { bson_free( mm ); return res; } - res = mongo_write_socket( conn, &mm->data, mm->head.len - sizeof( head ) ); + res = mongo_env_write_socket( conn, &mm->data, mm->head.len - sizeof( head ) ); if( res != MONGO_OK ) { bson_free( mm ); return res; @@ -80,8 +296,8 @@ int mongo_read_response( mongo *conn, mongo_reply **reply ) { unsigned int len; int res; - mongo_read_socket( conn, &head, sizeof( head ) ); - mongo_read_socket( conn, &fields, sizeof( fields ) ); + mongo_env_read_socket( conn, &head, sizeof( head ) ); + mongo_env_read_socket( conn, &fields, sizeof( fields ) ); bson_little_endian32( &len, &head.len ); @@ -100,7 +316,7 @@ int mongo_read_response( mongo *conn, mongo_reply **reply ) { bson_little_endian32( &out->fields.start, &fields.start ); bson_little_endian32( &out->fields.num, &fields.num ); - res = mongo_read_socket( conn, &out->objs, len-sizeof( head )-sizeof( fields ) ); + res = mongo_env_read_socket( conn, &out->objs, len-sizeof( head )-sizeof( fields ) ); if( res != MONGO_OK ) { bson_free( out ); return res; @@ -133,12 +349,17 @@ static int mongo_check_is_master( mongo *conn ) { bson out; bson_iterator it; bson_bool_t ismaster = 0; + int max_bson_size = MONGO_DEFAULT_MAX_BSON_SIZE; out.data = NULL; if ( mongo_simple_int_command( conn, "admin", "ismaster", 1, &out ) == MONGO_OK ) { if( bson_find( &it, &out, "ismaster" ) ) ismaster = bson_iterator_bool( &it ); + if( bson_find( &it, &out, "maxBsonObjectSize" ) ) { + max_bson_size = bson_iterator_int( &it ); + } + conn->max_bson_size = max_bson_size; } else { return MONGO_ERROR; } @@ -153,25 +374,25 @@ static int mongo_check_is_master( mongo *conn ) { } } -void mongo_init( mongo *conn ) { - conn->replset = NULL; - conn->err = 0; - conn->errstr = NULL; - conn->lasterrcode = 0; - conn->lasterrstr = NULL; - - conn->conn_timeout_ms = 0; - conn->op_timeout_ms = 0; +MONGO_EXPORT void mongo_init_sockets( void ) { + mongo_env_sock_init(); } -int mongo_connect( mongo *conn , const char *host, int port ) { + +MONGO_EXPORT void mongo_init( mongo *conn ) { + memset( conn, 0, sizeof( mongo ) ); + conn->max_bson_size = MONGO_DEFAULT_MAX_BSON_SIZE; +} + +MONGO_EXPORT int mongo_connect( mongo *conn , const char *host, int port ) { + mongo_init( conn ); + conn->primary = bson_malloc( sizeof( mongo_host_port ) ); strncpy( conn->primary->host, host, strlen( host ) + 1 ); conn->primary->port = port; conn->primary->next = NULL; - mongo_init( conn ); - if( mongo_socket_connect( conn, host, port ) != MONGO_OK ) + if( mongo_env_socket_connect( conn, host, port ) != MONGO_OK ) return MONGO_ERROR; if( mongo_check_is_master( conn ) != MONGO_OK ) @@ -180,7 +401,7 @@ int mongo_connect( mongo *conn , const char *host, int port ) { return MONGO_OK; } -void mongo_replset_init( mongo *conn, const char *name ) { +MONGO_EXPORT void mongo_replset_init( mongo *conn, const char *name ) { mongo_init( conn ); conn->replset = bson_malloc( sizeof( mongo_replset ) ); @@ -222,7 +443,7 @@ static void mongo_replset_free_list( mongo_host_port **list ) { *list = NULL; } -void mongo_replset_add_seed( mongo *conn, const char *host, int port ) { +MONGO_EXPORT void mongo_replset_add_seed( mongo *conn, const char *host, int port ) { mongo_replset_add_node( &conn->replset->seeds, host, port ); } @@ -291,7 +512,7 @@ static void mongo_replset_check_seed( mongo *conn ) { bson_destroy( &out ); bson_destroy( &hosts ); - mongo_close_socket( conn->sock ); + mongo_env_close_socket( conn->sock ); conn->sock = 0; conn->connected = 0; @@ -306,6 +527,7 @@ static int mongo_replset_check_host( mongo *conn ) { bson_iterator it; bson_bool_t ismaster = 0; const char *set_name; + int max_bson_size = MONGO_DEFAULT_MAX_BSON_SIZE; out.data = NULL; @@ -313,6 +535,10 @@ static int mongo_replset_check_host( mongo *conn ) { if( bson_find( &it, &out, "ismaster" ) ) ismaster = bson_iterator_bool( &it ); + if( bson_find( &it, &out, "maxBsonObjectSize" ) ) + max_bson_size = bson_iterator_int( &it ); + conn->max_bson_size = max_bson_size; + if( bson_find( &it, &out, "setName" ) ) { set_name = bson_iterator_string( &it ); if( strcmp( set_name, conn->replset->name ) != 0 ) { @@ -328,13 +554,13 @@ static int mongo_replset_check_host( mongo *conn ) { if( ismaster ) { conn->replset->primary_connected = 1; } else { - mongo_close_socket( conn->sock ); + mongo_env_close_socket( conn->sock ); } return MONGO_OK; } -int mongo_replset_connect( mongo *conn ) { +MONGO_EXPORT int mongo_replset_connect( mongo *conn ) { int res = 0; mongo_host_port *node; @@ -347,15 +573,12 @@ int mongo_replset_connect( mongo *conn ) { */ node = conn->replset->seeds; while( node != NULL ) { - res = mongo_socket_connect( conn, ( const char * )&node->host, node->port ); - if( res != MONGO_OK ) - return MONGO_ERROR; - - mongo_replset_check_seed( conn ); - - if( conn->replset->hosts ) - break; - + res = mongo_env_socket_connect( conn, ( const char * )&node->host, node->port ); + if( res == MONGO_OK ) { + mongo_replset_check_seed( conn ); + if( conn->replset->hosts ) + break; + } node = node->next; } @@ -367,19 +590,22 @@ int mongo_replset_connect( mongo *conn ) { node = conn->replset->hosts; while( node != NULL ) { - res = mongo_socket_connect( conn, ( const char * )&node->host, node->port ); + res = mongo_env_socket_connect( conn, ( const char * )&node->host, node->port ); if( res == MONGO_OK ) { if( mongo_replset_check_host( conn ) != MONGO_OK ) return MONGO_ERROR; /* Primary found, so return. */ - else if( conn->replset->primary_connected ) + else if( conn->replset->primary_connected ) { + strncpy( conn->primary->host, node->host, strlen( node->host ) + 1 ); + conn->primary->port = node->port; return MONGO_OK; + } /* No primary, so close the connection. */ else { - mongo_close_socket( conn->sock ); + mongo_env_close_socket( conn->sock ); conn->sock = 0; conn->connected = 0; } @@ -394,15 +620,15 @@ int mongo_replset_connect( mongo *conn ) { return MONGO_ERROR; } -int mongo_set_op_timeout( mongo *conn, int millis ) { +MONGO_EXPORT int mongo_set_op_timeout( mongo *conn, int millis ) { conn->op_timeout_ms = millis; if( conn->sock && conn->connected ) - mongo_set_socket_op_timeout( conn, millis ); + mongo_env_set_socket_op_timeout( conn, millis ); return MONGO_OK; } -int mongo_reconnect( mongo *conn ) { +MONGO_EXPORT int mongo_reconnect( mongo *conn ) { int res; mongo_disconnect( conn ); @@ -413,10 +639,10 @@ int mongo_reconnect( mongo *conn ) { res = mongo_replset_connect( conn ); return res; } else - return mongo_socket_connect( conn, conn->primary->host, conn->primary->port ); + return mongo_env_socket_connect( conn, conn->primary->host, conn->primary->port ); } -int mongo_check_connection( mongo *conn ) { +MONGO_EXPORT int mongo_check_connection( mongo *conn ) { if( ! conn->connected ) return MONGO_ERROR; @@ -426,7 +652,7 @@ int mongo_check_connection( mongo *conn ) { return MONGO_ERROR; } -void mongo_disconnect( mongo *conn ) { +MONGO_EXPORT void mongo_disconnect( mongo *conn ) { if( ! conn->connected ) return; @@ -436,13 +662,13 @@ void mongo_disconnect( mongo *conn ) { conn->replset->hosts = NULL; } - mongo_close_socket( conn->sock ); + mongo_env_close_socket( conn->sock ); conn->sock = 0; conn->connected = 0; } -void mongo_destroy( mongo *conn ) { +MONGO_EXPORT void mongo_destroy( mongo *conn ) { mongo_disconnect( conn ); if( conn->replset ) { @@ -454,17 +680,20 @@ void mongo_destroy( mongo *conn ) { } bson_free( conn->primary ); - bson_free( conn->errstr ); - bson_free( conn->lasterrstr ); - conn->err = 0; - conn->errstr = NULL; - conn->lasterrcode = 0; - conn->lasterrstr = NULL; + mongo_clear_errors( conn ); } /* Determine whether this BSON object is valid for the given operation. */ -static int mongo_bson_valid( mongo *conn, bson *bson, int write ) { +static int mongo_bson_valid( mongo *conn, const bson *bson, int write ) { + int size; + + size = bson_size( bson ); + if( size > conn->max_bson_size ) { + conn->err = MONGO_BSON_TOO_LARGE; + return MONGO_ERROR; + } + if( ! bson->finished ) { conn->err = MONGO_BSON_NOT_FINISHED; return MONGO_ERROR; @@ -486,20 +715,21 @@ static int mongo_bson_valid( mongo *conn, bson *bson, int write ) { } conn->err = 0; - conn->errstr = NULL; return MONGO_OK; } /* Determine whether this BSON object is valid for the given operation. */ -static int mongo_cursor_bson_valid( mongo_cursor *cursor, bson *bson ) { +static int mongo_cursor_bson_valid( mongo_cursor *cursor, const bson *bson ) { if( ! bson->finished ) { - cursor->err = MONGO_BSON_NOT_FINISHED; + cursor->err = MONGO_CURSOR_BSON_ERROR; + cursor->conn->err = MONGO_BSON_NOT_FINISHED; return MONGO_ERROR; } if( bson->err & BSON_NOT_UTF8 ) { - cursor->err = MONGO_BSON_INVALID; + cursor->err = MONGO_CURSOR_BSON_ERROR; + cursor->conn->err = MONGO_BSON_INVALID; return MONGO_ERROR; } @@ -508,13 +738,17 @@ static int mongo_cursor_bson_valid( mongo_cursor *cursor, bson *bson ) { /* MongoDB CRUD API */ -int mongo_insert_batch( mongo *conn, const char *ns, - bson **bsons, int count ) { +MONGO_EXPORT int mongo_insert_batch( mongo *conn, const char *ns, + const bson **bsons, int count ) { - int size = 16 + 4 + strlen( ns ) + 1; - int i; mongo_message *mm; + int i; char *data; + int overhead = 16 + 4 + strlen( ns ) + 1; + int size = overhead; + + if( mongo_validate_ns( conn, ns ) != MONGO_OK ) + return MONGO_ERROR; for( i=0; i conn->max_bson_size ) { + conn->err = MONGO_BSON_TOO_LARGE; + return MONGO_ERROR; + } + mm = mongo_message_create( size , 0 , 0 , MONGO_OP_INSERT ); data = &mm->data; @@ -535,11 +774,14 @@ int mongo_insert_batch( mongo *conn, const char *ns, return mongo_message_send( conn, mm ); } -int mongo_insert( mongo *conn , const char *ns , bson *bson ) { +MONGO_EXPORT int mongo_insert( mongo *conn , const char *ns , const bson *bson ) { char *data; mongo_message *mm; + if( mongo_validate_ns( conn, ns ) != MONGO_OK ) + return MONGO_ERROR; + /* Make sure that BSON is valid for insert. */ if( mongo_bson_valid( conn, bson, 1 ) != MONGO_OK ) { return MONGO_ERROR; @@ -559,7 +801,7 @@ int mongo_insert( mongo *conn , const char *ns , bson *bson ) { return mongo_message_send( conn, mm ); } -int mongo_update( mongo *conn, const char *ns, const bson *cond, +MONGO_EXPORT int mongo_update( mongo *conn, const char *ns, const bson *cond, const bson *op, int flags ) { char *data; @@ -590,14 +832,9 @@ int mongo_update( mongo *conn, const char *ns, const bson *cond, return mongo_message_send( conn, mm ); } -int mongo_remove( mongo *conn, const char *ns, const bson *cond ) { +MONGO_EXPORT int mongo_remove( mongo *conn, const char *ns, const bson *cond ) { char *data; - mongo_message *mm = mongo_message_create( 16 /* header */ - + 4 /* ZERO */ - + strlen( ns ) + 1 - + 4 /* ZERO */ - + bson_size( cond ) - , 0 , 0 , MONGO_OP_DELETE ); + mongo_message *mm; /* Make sure that the BSON is valid UTF-8. * TODO: decide whether to check cond as well. @@ -606,6 +843,13 @@ int mongo_remove( mongo *conn, const char *ns, const bson *cond ) { return MONGO_ERROR; } + mm = mongo_message_create( 16 /* header */ + + 4 /* ZERO */ + + strlen( ns ) + 1 + + 4 /* ZERO */ + + bson_size( cond ) + , 0 , 0 , MONGO_OP_DELETE ); + data = &mm->data; data = mongo_data_append32( data, &ZERO ); data = mongo_data_append( data, ns, strlen( ns ) + 1 ); @@ -621,6 +865,11 @@ static int mongo_cursor_op_query( mongo_cursor *cursor ) { bson empty; char *data; mongo_message *mm; + bson temp; + bson_iterator it; + + /* Clear any errors. */ + mongo_clear_errors( cursor->conn ); /* Set up default values for query and fields, if necessary. */ if( ! cursor->query ) @@ -662,6 +911,15 @@ static int mongo_cursor_op_query( mongo_cursor *cursor ) { return MONGO_ERROR; } + if( cursor->reply->fields.num == 1 ) { + bson_init_data( &temp, &cursor->reply->objs ); + if( bson_find( &it, &temp, "$err" ) ) { + mongo_set_last_error( cursor->conn, &it, &temp ); + cursor->err = MONGO_CURSOR_QUERY_FAIL; + return MONGO_ERROR; + } + } + cursor->seen += cursor->reply->fields.num; cursor->flags |= MONGO_CURSOR_QUERY_SENT; return MONGO_OK; @@ -719,8 +977,8 @@ static int mongo_cursor_get_more( mongo_cursor *cursor ) { } } -mongo_cursor *mongo_find( mongo *conn, const char *ns, bson *query, - bson *fields, int limit, int skip, int options ) { +MONGO_EXPORT mongo_cursor *mongo_find( mongo *conn, const char *ns, const bson *query, + const bson *fields, int limit, int skip, int options ) { mongo_cursor *cursor = ( mongo_cursor * )bson_malloc( sizeof( mongo_cursor ) ); mongo_cursor_init( cursor, conn, ns ); @@ -740,13 +998,20 @@ mongo_cursor *mongo_find( mongo *conn, const char *ns, bson *query, } } -int mongo_find_one( mongo *conn, const char *ns, bson *query, - bson *fields, bson *out ) { +MONGO_EXPORT int mongo_find_one( mongo *conn, const char *ns, const bson *query, + const bson *fields, bson *out ) { - mongo_cursor *cursor = mongo_find( conn, ns, query, fields, 1, 0, 0 ); + mongo_cursor cursor[1]; + mongo_cursor_init( cursor, conn, ns ); + mongo_cursor_set_query( cursor, query ); + mongo_cursor_set_fields( cursor, fields ); + mongo_cursor_set_limit( cursor, 1 ); - if ( cursor && mongo_cursor_next( cursor ) == MONGO_OK ) { - bson_copy_basic( out, &cursor->current ); + if ( mongo_cursor_next( cursor ) == MONGO_OK ) { + bson_init_size( out, bson_size( (bson *)&cursor->current ) ); + memcpy( out->data, cursor->current.data, + bson_size( (bson *)&cursor->current ) ); + out->finished = 1; mongo_cursor_destroy( cursor ); return MONGO_OK; } else { @@ -755,56 +1020,49 @@ int mongo_find_one( mongo *conn, const char *ns, bson *query, } } -void mongo_cursor_init( mongo_cursor *cursor, mongo *conn, const char *ns ) { +MONGO_EXPORT void mongo_cursor_init( mongo_cursor *cursor, mongo *conn, const char *ns ) { + memset( cursor, 0, sizeof( mongo_cursor ) ); cursor->conn = conn; cursor->ns = ( const char * )bson_malloc( strlen( ns ) + 1 ); strncpy( ( char * )cursor->ns, ns, strlen( ns ) + 1 ); cursor->current.data = NULL; - cursor->reply = NULL; - cursor->flags = 0; - cursor->seen = 0; - cursor->err = 0; - cursor->options = 0; - cursor->query = NULL; - cursor->fields = NULL; - cursor->skip = 0; - cursor->limit = 0; } -void mongo_cursor_set_query( mongo_cursor *cursor, bson *query ) { +MONGO_EXPORT void mongo_cursor_set_query( mongo_cursor *cursor, const bson *query ) { cursor->query = query; } -void mongo_cursor_set_fields( mongo_cursor *cursor, bson *fields ) { +MONGO_EXPORT void mongo_cursor_set_fields( mongo_cursor *cursor, const bson *fields ) { cursor->fields = fields; } -void mongo_cursor_set_skip( mongo_cursor *cursor, int skip ) { +MONGO_EXPORT void mongo_cursor_set_skip( mongo_cursor *cursor, int skip ) { cursor->skip = skip; } -void mongo_cursor_set_limit( mongo_cursor *cursor, int limit ) { +MONGO_EXPORT void mongo_cursor_set_limit( mongo_cursor *cursor, int limit ) { cursor->limit = limit; } -void mongo_cursor_set_options( mongo_cursor *cursor, int options ) { +MONGO_EXPORT void mongo_cursor_set_options( mongo_cursor *cursor, int options ) { cursor->options = options; } -const char *mongo_cursor_data( mongo_cursor *cursor ) { +MONGO_EXPORT const char *mongo_cursor_data( mongo_cursor *cursor ) { return cursor->current.data; } -const bson *mongo_cursor_bson( mongo_cursor *cursor ) { +MONGO_EXPORT const bson *mongo_cursor_bson( mongo_cursor *cursor ) { return (const bson *)&(cursor->current); } -int mongo_cursor_next( mongo_cursor *cursor ) { +MONGO_EXPORT int mongo_cursor_next( mongo_cursor *cursor ) { char *next_object; char *message_end; if( ! ( cursor->flags & MONGO_CURSOR_QUERY_SENT ) ) - mongo_cursor_op_query( cursor ); + if( mongo_cursor_op_query( cursor ) != MONGO_OK ) + return MONGO_ERROR; if( !cursor->reply ) return MONGO_ERROR; @@ -826,7 +1084,7 @@ int mongo_cursor_next( mongo_cursor *cursor ) { /* first */ if ( cursor->current.data == NULL ) { - bson_init_data( &cursor->current, &cursor->reply->objs ); + bson_init_finished_data( &cursor->current, &cursor->reply->objs ); return MONGO_OK; } @@ -843,15 +1101,15 @@ int mongo_cursor_next( mongo_cursor *cursor ) { return MONGO_ERROR; } - bson_init_data( &cursor->current, &cursor->reply->objs ); + bson_init_finished_data( &cursor->current, &cursor->reply->objs ); } else { - bson_init_data( &cursor->current, next_object ); + bson_init_finished_data( &cursor->current, next_object ); } return MONGO_OK; } -int mongo_cursor_destroy( mongo_cursor *cursor ) { +MONGO_EXPORT int mongo_cursor_destroy( mongo_cursor *cursor ) { int result = MONGO_OK; if ( !cursor ) return result; @@ -883,7 +1141,7 @@ int mongo_cursor_destroy( mongo_cursor *cursor ) { /* MongoDB Helper Functions */ -int mongo_create_index( mongo *conn, const char *ns, bson *key, int options, bson *out ) { +MONGO_EXPORT int mongo_create_index( mongo *conn, const char *ns, const bson *key, int options, bson *out ) { bson b; bson_iterator it; char name[255] = {'_'}; @@ -933,10 +1191,10 @@ bson_bool_t mongo_create_simple_index( mongo *conn, const char *ns, const char * return success; } -int64_t mongo_count( mongo *conn, const char *db, const char *ns, bson *query ) { +MONGO_EXPORT double mongo_count( mongo *conn, const char *db, const char *ns, const bson *query ) { bson cmd; bson out = {NULL, 0}; - int64_t count = -1; + double count = -1; bson_init( &cmd ); bson_append_string( &cmd, "count", ns ); @@ -947,7 +1205,7 @@ int64_t mongo_count( mongo *conn, const char *db, const char *ns, bson *query ) if( mongo_run_command( conn, db, &cmd, &out ) == MONGO_OK ) { bson_iterator it; if( bson_find( &it, &out, "n" ) ) - count = bson_iterator_long( &it ); + count = bson_iterator_double( &it ); bson_destroy( &cmd ); bson_destroy( &out ); return count; @@ -958,38 +1216,51 @@ int64_t mongo_count( mongo *conn, const char *db, const char *ns, bson *query ) } } -int mongo_run_command( mongo *conn, const char *db, bson *command, +MONGO_EXPORT int mongo_run_command( mongo *conn, const char *db, const bson *command, bson *out ) { + bson response = {NULL, 0}; bson fields; int sl = strlen( db ); char *ns = bson_malloc( sl + 5 + 1 ); /* ".$cmd" + nul */ - int res; + int res, success = 0; strcpy( ns, db ); strcpy( ns+sl, ".$cmd" ); - res = mongo_find_one( conn, ns, command, bson_empty( &fields ), out ); + res = mongo_find_one( conn, ns, command, bson_empty( &fields ), &response ); bson_free( ns ); - return res; + + if( res != MONGO_OK ) + return MONGO_ERROR; + else { + bson_iterator it; + if( bson_find( &it, &response, "ok" ) ) + success = bson_iterator_bool( &it ); + + if( !success ) { + conn->err = MONGO_COMMAND_FAILED; + return MONGO_ERROR; + } else { + if( out ) + *out = response; + return MONGO_OK; + } + } } -int mongo_simple_int_command( mongo *conn, const char *db, +MONGO_EXPORT int mongo_simple_int_command( mongo *conn, const char *db, const char *cmdstr, int arg, bson *realout ) { bson out = {NULL, 0}; bson cmd; - bson_bool_t success = 0; + int result; bson_init( &cmd ); bson_append_int( &cmd, cmdstr, arg ); bson_finish( &cmd ); - if( mongo_run_command( conn, db, &cmd, &out ) == MONGO_OK ) { - bson_iterator it; - if( bson_find( &it, &out, "ok" ) ) - success = bson_iterator_bool( &it ); - } + result = mongo_run_command( conn, db, &cmd, &out ); bson_destroy( &cmd ); @@ -998,30 +1269,21 @@ int mongo_simple_int_command( mongo *conn, const char *db, else bson_destroy( &out ); - if( success ) - return MONGO_OK; - else { - conn->err = MONGO_COMMAND_FAILED; - return MONGO_ERROR; - } + return result; } -int mongo_simple_str_command( mongo *conn, const char *db, +MONGO_EXPORT int mongo_simple_str_command( mongo *conn, const char *db, const char *cmdstr, const char *arg, bson *realout ) { bson out = {NULL, 0}; - int success = 0; + int result; bson cmd; bson_init( &cmd ); bson_append_string( &cmd, cmdstr, arg ); bson_finish( &cmd ); - if( mongo_run_command( conn, db, &cmd, &out ) == MONGO_OK ) { - bson_iterator it; - if( bson_find( &it, &out, "ok" ) ) - success = bson_iterator_bool( &it ); - } + result = mongo_run_command( conn, db, &cmd, &out ); bson_destroy( &cmd ); @@ -1030,21 +1292,18 @@ int mongo_simple_str_command( mongo *conn, const char *db, else bson_destroy( &out ); - if( success ) - return MONGO_OK; - else - return MONGO_ERROR; + return result; } -int mongo_cmd_drop_db( mongo *conn, const char *db ) { +MONGO_EXPORT int mongo_cmd_drop_db( mongo *conn, const char *db ) { return mongo_simple_int_command( conn, db, "dropDatabase", 1, NULL ); } -int mongo_cmd_drop_collection( mongo *conn, const char *db, const char *collection, bson *out ) { +MONGO_EXPORT int mongo_cmd_drop_collection( mongo *conn, const char *db, const char *collection, bson *out ) { return mongo_simple_str_command( conn, db, "drop", collection, out ); } -void mongo_cmd_reset_error( mongo *conn, const char *db ) { +MONGO_EXPORT void mongo_cmd_reset_error( mongo *conn, const char *db ) { mongo_simple_int_command( conn, db, "reseterror", 1, NULL ); } @@ -1055,23 +1314,13 @@ static int mongo_cmd_get_error_helper( mongo *conn, const char *db, bson_bool_t haserror = 0; /* Reset last error codes. */ - conn->lasterrcode = 0; - bson_free( conn->lasterrstr ); - conn->lasterrstr = NULL; + mongo_clear_errors( conn ); /* If there's an error, store its code and string in the connection object. */ if( mongo_simple_int_command( conn, db, cmdtype, 1, &out ) == MONGO_OK ) { bson_iterator it; haserror = ( bson_find( &it, &out, "err" ) != BSON_NULL ); - if( haserror ) { - conn->lasterrstr = ( char * )bson_malloc( bson_iterator_string_len( &it ) ); - if( conn->lasterrstr ) { - strcpy( conn->lasterrstr, bson_iterator_string( &it ) ); - } - - if( bson_find( &it, &out, "code" ) != BSON_NULL ) - conn->lasterrcode = bson_iterator_int( &it ); - } + if( haserror ) mongo_set_last_error( conn, &it, &out ); } if( realout ) @@ -1085,15 +1334,15 @@ static int mongo_cmd_get_error_helper( mongo *conn, const char *db, return MONGO_OK; } -int mongo_cmd_get_prev_error( mongo *conn, const char *db, bson *out ) { +MONGO_EXPORT int mongo_cmd_get_prev_error( mongo *conn, const char *db, bson *out ) { return mongo_cmd_get_error_helper( conn, db, out, "getpreverror" ); } -int mongo_cmd_get_last_error( mongo *conn, const char *db, bson *out ) { +MONGO_EXPORT int mongo_cmd_get_last_error( mongo *conn, const char *db, bson *out ) { return mongo_cmd_get_error_helper( conn, db, out, "getlasterror" ); } -bson_bool_t mongo_cmd_ismaster( mongo *conn, bson *realout ) { +MONGO_EXPORT bson_bool_t mongo_cmd_ismaster( mongo *conn, bson *realout ) { bson out = {NULL,0}; bson_bool_t ismaster = 0; @@ -1133,7 +1382,7 @@ static void mongo_pass_digest( const char *user, const char *pass, char hex_dige digest2hex( digest, hex_digest ); } -int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const char *pass ) { +MONGO_EXPORT int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const char *pass ) { bson user_obj; bson pass_obj; char hex_digest[33]; @@ -1164,12 +1413,12 @@ int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const cha return res; } -bson_bool_t mongo_cmd_authenticate( mongo *conn, const char *db, const char *user, const char *pass ) { +MONGO_EXPORT bson_bool_t mongo_cmd_authenticate( mongo *conn, const char *db, const char *user, const char *pass ) { bson from_db; bson cmd; bson out; const char *nonce; - bson_bool_t success = 0; + int result; mongo_md5_state_t st; mongo_md5_byte_t digest[16]; @@ -1200,18 +1449,11 @@ bson_bool_t mongo_cmd_authenticate( mongo *conn, const char *db, const char *use bson_finish( &cmd ); bson_destroy( &from_db ); - /*bson_init( &from_db ); */ - if( mongo_run_command( conn, db, &cmd, &out ) == MONGO_OK ) { - bson_iterator it; - if( bson_find( &it, &out, "ok" ) ) - success = bson_iterator_bool( &it ); - } + + result = mongo_run_command( conn, db, &cmd, &out ); bson_destroy( &from_db ); bson_destroy( &cmd ); - if( success ) - return MONGO_OK; - else - return MONGO_ERROR; + return result; } diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.h index 6f86174101..dd4c4b4f40 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.h +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/mongo.h @@ -3,7 +3,7 @@ * @brief Main MongoDB Declarations */ -/* Copyright 2009-2011 10gen Inc. +/* Copyright 2009-2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,22 +18,26 @@ * limitations under the License. */ -#ifndef _MONGO_H_ -#define _MONGO_H_ +#ifndef MONGO_H_ +#define MONGO_H_ #include "bson.h" MONGO_EXTERN_C_START #define MONGO_MAJOR 0 -#define MONGO_MINOR 4 -#define MONGO_PATCH 0 +#define MONGO_MINOR 5 +#define MONGO_PATCH 2 #define MONGO_OK 0 #define MONGO_ERROR -1 #define MONGO_DEFAULT_PORT 27017 +#define MONGO_DEFAULT_MAX_BSON_SIZE 4 * 1024 * 1024 + +#define MONGO_ERR_LEN 128 + typedef enum mongo_error_t { MONGO_CONN_SUCCESS = 0, /**< Connection success! */ MONGO_CONN_NO_SOCKET, /**< Could not create a socket. */ @@ -43,15 +47,25 @@ typedef enum mongo_error_t { MONGO_CONN_BAD_SET_NAME, /**< Given rs name doesn't match this replica set. */ MONGO_CONN_NO_PRIMARY, /**< Can't find primary in replica set. Connection closed. */ - MONGO_IO_ERROR, /**< An error occurred while reading or writing on socket. */ + MONGO_IO_ERROR, /**< An error occurred while reading or writing on the socket. */ + MONGO_SOCKET_ERROR, /**< Other socket error. */ MONGO_READ_SIZE_ERROR, /**< The response is not the expected length. */ MONGO_COMMAND_FAILED, /**< The command returned with 'ok' value of 0. */ + MONGO_NS_INVALID, /**< The name for the ns (database or collection) is invalid. */ + MONGO_BSON_INVALID, /**< BSON not valid for the specified op. */ + MONGO_BSON_NOT_FINISHED, /**< BSON object has not been finished. */ + MONGO_BSON_TOO_LARGE /**< BSON object exceeds max BSON size. */ +} mongo_error_t; + +typedef enum mongo_cursor_error_t { MONGO_CURSOR_EXHAUSTED, /**< The cursor has no more results. */ MONGO_CURSOR_INVALID, /**< The cursor has timed out or is not recognized. */ MONGO_CURSOR_PENDING, /**< Tailable cursor still alive but no data. */ - MONGO_BSON_INVALID, /**< BSON not valid for the specified op. */ - MONGO_BSON_NOT_FINISHED /**< BSON object has not been finished. */ -} mongo_error_t; + MONGO_CURSOR_QUERY_FAIL, /**< The server returned an '$err' object, indicating query failure. + See conn->lasterrcode and conn->lasterrstr for details. */ + MONGO_CURSOR_BSON_ERROR /**< Something is wrong with the BSON provided. See conn->err + for details. */ +} mongo_cursor_error_t; enum mongo_cursor_flags { MONGO_CURSOR_MUST_FREE = 1, /**< mongo_cursor_destroy should free cursor. */ @@ -137,12 +151,14 @@ typedef struct mongo { int flags; /**< Flags on this connection object. */ int conn_timeout_ms; /**< Connection timeout in milliseconds. */ int op_timeout_ms; /**< Read and write timeout in milliseconds. */ + int max_bson_size; /**< Largest BSON object allowed on this connection. */ bson_bool_t connected; /**< Connection status. */ - mongo_error_t err; /**< Most recent driver error code. */ - char *errstr; /**< String version of most recent driver error code. */ - int lasterrcode; /**< getlasterror given by the server on calls. */ - char *lasterrstr; /**< getlasterror string generated by server. */ + mongo_error_t err; /**< Most recent driver error code. */ + int errcode; /**< Most recent errno or WSAGetLastError(). */ + char errstr[MONGO_ERR_LEN]; /**< String version of error. */ + int lasterrcode; /**< getlasterror code from the server. */ + char lasterrstr[MONGO_ERR_LEN]; /**< getlasterror string from the server. */ } mongo; typedef struct { @@ -152,9 +168,9 @@ typedef struct { int flags; /**< Flags used internally by this drivers. */ int seen; /**< Number returned so far. */ bson current; /**< This cursor's current bson object. */ - mongo_error_t err; /**< Errors on this cursor. */ - bson *query; /**< Bitfield containing cursor options. */ - bson *fields; /**< Bitfield containing cursor options. */ + mongo_cursor_error_t err; /**< Errors on this cursor. */ + const bson *query; /**< Bitfield containing cursor options. */ + const bson *fields;/**< Bitfield containing cursor options. */ int options; /**< Bitfield containing cursor options. */ int limit; /**< Bitfield containing cursor options. */ int skip; /**< Bitfield containing cursor options. */ @@ -162,9 +178,44 @@ typedef struct { /* Connection API */ -/** Initialize a new mongo connection object. If not created - * with mongo_new, you must initialize each mongo - * object using this function. +MONGO_EXPORT mongo* mongo_create(); +MONGO_EXPORT void mongo_dispose(mongo* conn); +MONGO_EXPORT int mongo_get_err(mongo* conn); +MONGO_EXPORT int mongo_is_connected(mongo* conn); +MONGO_EXPORT int mongo_get_op_timeout(mongo* conn); +MONGO_EXPORT const char* mongo_get_primary(mongo* conn); +MONGO_EXPORT int mongo_get_socket(mongo* conn) ; +MONGO_EXPORT int mongo_get_host_count(mongo* conn); +MONGO_EXPORT const char* mongo_get_host(mongo* conn, int i); +MONGO_EXPORT mongo_cursor* mongo_cursor_create(); +MONGO_EXPORT void mongo_cursor_dispose(mongo_cursor* cursor); +MONGO_EXPORT int mongo_get_server_err(mongo* conn); +MONGO_EXPORT const char* mongo_get_server_err_string(mongo* conn); + +/** + * Set an error this mongo connection object. Mostly for internal use. + * + * @param conn a mongo connection object. + * @param err a driver error code of mongo_error_t. + * @param errstr a string version of the error. + * @param errorcode Currently errno or WSAGetLastError(). + */ +MONGO_EXPORT void __mongo_set_error( mongo *conn, mongo_error_t err, + const char *errstr, int errorcode ); +/** + * Clear all errors stored on this mongo connection object. + * + * @param conn a mongo connection object. + */ +MONGO_EXPORT void mongo_clear_errors( mongo *conn ); + +/** Initialize sockets for Windows. + */ +MONGO_EXPORT void mongo_init_sockets(); + +/** + * Initialize a new mongo connection object. You must initialize each mongo + * object using this function. * * @note When finished, you must pass this object to * mongo_destroy( ). @@ -172,7 +223,7 @@ typedef struct { * @param conn a mongo connection object allocated on the stack * or heap. */ -void mongo_init( mongo *conn ); +MONGO_EXPORT void mongo_init( mongo *conn ); /** * Connect to a single MongoDB server. @@ -182,9 +233,9 @@ void mongo_init( mongo *conn ); * @param port the port to connect to. * * @return MONGO_OK or MONGO_ERROR on failure. On failure, a constant of type - * mongo_conn_return_t will be set on the conn->err field. + * mongo_error_t will be set on the conn->err field. */ -int mongo_connect( mongo *conn , const char *host, int port ); +MONGO_EXPORT int mongo_connect( mongo *conn , const char *host, int port ); /** * Set up this connection object for connecting to a replica set. @@ -193,7 +244,7 @@ int mongo_connect( mongo *conn , const char *host, int port ); * @param conn a mongo object. * @param name the name of the replica set to connect to. * */ -void mongo_replset_init( mongo *conn, const char *name ); +MONGO_EXPORT void mongo_replset_init( mongo *conn, const char *name ); /** * Add a seed node to the replica set connection object. @@ -204,7 +255,7 @@ void mongo_replset_init( mongo *conn, const char *name ); * @param host a numerical network address or a network hostname. * @param port the port to connect to. */ -void mongo_replset_add_seed( mongo *conn, const char *host, int port ); +MONGO_EXPORT void mongo_replset_add_seed( mongo *conn, const char *host, int port ); /** * Utility function for converting a host-port string to a mongo_host_port. @@ -215,6 +266,17 @@ void mongo_replset_add_seed( mongo *conn, const char *host, int port ); */ void mongo_parse_host( const char *host_string, mongo_host_port *host_port ); +/** + * Utility function for validation database and collection names. + * + * @param conn a mongo object. + * + * @return MONGO_OK or MONGO_ERROR on failure. On failure, a constant of type + * mongo_conn_return_t will be set on the conn->err field. + * + */ +MONGO_EXPORT int mongo_validate_ns( mongo *conn, const char *ns ); + /** * Connect to a replica set. * @@ -226,7 +288,7 @@ void mongo_parse_host( const char *host_string, mongo_host_port *host_port ); * @return MONGO_OK or MONGO_ERROR on failure. On failure, a constant of type * mongo_conn_return_t will be set on the conn->err field. */ -int mongo_replset_connect( mongo *conn ); +MONGO_EXPORT int mongo_replset_connect( mongo *conn ); /** Set a timeout for operations on this connection. This * is a platform-specific feature, and only work on *nix @@ -238,7 +300,7 @@ int mongo_replset_connect( mongo *conn ); * @return MONGO_OK. On error, return MONGO_ERROR and * set the conn->err field. */ -int mongo_set_op_timeout( mongo *conn, int millis ); +MONGO_EXPORT int mongo_set_op_timeout( mongo *conn, int millis ); /** * Ensure that this connection is healthy by performing @@ -248,7 +310,7 @@ int mongo_set_op_timeout( mongo *conn, int millis ); * * @return MONGO_OK if connected; otherwise, MONGO_ERROR. */ -int mongo_check_connection( mongo *conn ); +MONGO_EXPORT int mongo_check_connection( mongo *conn ); /** * Try reconnecting to the server using the existing connection settings. @@ -261,7 +323,7 @@ int mongo_check_connection( mongo *conn ); * @return MONGO_OK or MONGO_ERROR and * set the conn->err field. */ -int mongo_reconnect( mongo *conn ); +MONGO_EXPORT int mongo_reconnect( mongo *conn ); /** * Close the current connection to the server. After calling @@ -270,7 +332,7 @@ int mongo_reconnect( mongo *conn ); * * @param conn a mongo object. */ -void mongo_disconnect( mongo *conn ); +MONGO_EXPORT void mongo_disconnect( mongo *conn ); /** * Close any existing connection to the server and free all allocated @@ -280,7 +342,7 @@ void mongo_disconnect( mongo *conn ); * * @param conn a mongo object. */ -void mongo_destroy( mongo *conn ); +MONGO_EXPORT void mongo_destroy( mongo *conn ); /** * Insert a BSON document into a MongoDB server. This function @@ -295,7 +357,7 @@ void mongo_destroy( mongo *conn ); * field is MONGO_BSON_INVALID, check the err field * on the bson struct for the reason. */ -int mongo_insert( mongo *conn, const char *ns, bson *data ); +MONGO_EXPORT int mongo_insert( mongo *conn, const char *ns, const bson *data ); /** * Insert a batch of BSON documents into a MongoDB server. This function @@ -309,8 +371,8 @@ int mongo_insert( mongo *conn, const char *ns, bson *data ); * @return MONGO_OK or MONGO_ERROR. * */ -int mongo_insert_batch( mongo *conn , const char *ns , - bson **data , int num ); +MONGO_EXPORT int mongo_insert_batch( mongo *conn , const char *ns , + const bson **data , int num ); /** * Update a document in a MongoDB server. @@ -324,7 +386,7 @@ int mongo_insert_batch( mongo *conn , const char *ns , * @return MONGO_OK or MONGO_ERROR with error stored in conn object. * */ -int mongo_update( mongo *conn, const char *ns, const bson *cond, +MONGO_EXPORT int mongo_update( mongo *conn, const char *ns, const bson *cond, const bson *op, int flags ); /** @@ -336,7 +398,7 @@ int mongo_update( mongo *conn, const char *ns, const bson *cond, * * @return MONGO_OK or MONGO_ERROR with error stored in conn object. */ -int mongo_remove( mongo *conn, const char *ns, const bson *cond ); +MONGO_EXPORT int mongo_remove( mongo *conn, const char *ns, const bson *cond ); /** * Find documents in a MongoDB server. @@ -353,8 +415,8 @@ int mongo_remove( mongo *conn, const char *ns, const bson *cond ); * an error has occurred. For finer-grained error checking, * use the cursor builder API instead. */ -mongo_cursor *mongo_find( mongo *conn, const char *ns, bson *query, - bson *fields, int limit, int skip, int options ); +MONGO_EXPORT mongo_cursor *mongo_find( mongo *conn, const char *ns, const bson *query, + const bson *fields, int limit, int skip, int options ); /** * Initalize a new cursor object. @@ -363,7 +425,7 @@ mongo_cursor *mongo_find( mongo *conn, const char *ns, bson *query, * @param ns the namespace, represented as the the database * name and collection name separated by a dot. e.g., "test.users" */ -void mongo_cursor_init( mongo_cursor *cursor, mongo *conn, const char *ns ); +MONGO_EXPORT void mongo_cursor_init( mongo_cursor *cursor, mongo *conn, const char *ns ); /** * Set the bson object specifying this cursor's query spec. If @@ -376,7 +438,7 @@ void mongo_cursor_init( mongo_cursor *cursor, mongo *conn, const char *ns ); * $query, $orderby, $hint, and/or $explain. See * http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol for details. */ -void mongo_cursor_set_query( mongo_cursor *cursor, bson *query ); +MONGO_EXPORT void mongo_cursor_set_query( mongo_cursor *cursor, const bson *query ); /** * Set the fields to return for this cursor. If you want to return @@ -386,7 +448,7 @@ void mongo_cursor_set_query( mongo_cursor *cursor, bson *query ); * @param fields a bson object representing the fields to return. * See http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields. */ -void mongo_cursor_set_fields( mongo_cursor *cursor, bson *fields ); +MONGO_EXPORT void mongo_cursor_set_fields( mongo_cursor *cursor, const bson *fields ); /** * Set the number of documents to skip. @@ -394,7 +456,7 @@ void mongo_cursor_set_fields( mongo_cursor *cursor, bson *fields ); * @param cursor * @param skip */ -void mongo_cursor_set_skip( mongo_cursor *cursor, int skip ); +MONGO_EXPORT void mongo_cursor_set_skip( mongo_cursor *cursor, int skip ); /** * Set the number of documents to return. @@ -402,7 +464,7 @@ void mongo_cursor_set_skip( mongo_cursor *cursor, int skip ); * @param cursor * @param limit */ -void mongo_cursor_set_limit( mongo_cursor *cursor, int limit ); +MONGO_EXPORT void mongo_cursor_set_limit( mongo_cursor *cursor, int limit ); /** * Set any of the available query options (e.g., MONGO_TAILABLE). @@ -411,7 +473,7 @@ void mongo_cursor_set_limit( mongo_cursor *cursor, int limit ); * @param options a bitfield storing query options. See * mongo_cursor_bitfield_t for available constants. */ -void mongo_cursor_set_options( mongo_cursor *cursor, int options ); +MONGO_EXPORT void mongo_cursor_set_options( mongo_cursor *cursor, int options ); /** * Return the current BSON object data as a const char*. This is useful @@ -419,7 +481,7 @@ void mongo_cursor_set_options( mongo_cursor *cursor, int options ); * * @param cursor */ -const char *mongo_cursor_data( mongo_cursor *cursor ); +MONGO_EXPORT const char *mongo_cursor_data( mongo_cursor *cursor ); /** * Return the current BSON object data as a const char*. This is useful @@ -427,7 +489,7 @@ const char *mongo_cursor_data( mongo_cursor *cursor ); * * @param cursor */ -const bson *mongo_cursor_bson( mongo_cursor *cursor ); +MONGO_EXPORT const bson *mongo_cursor_bson( mongo_cursor *cursor ); /** * Iterate the cursor, returning the next item. When successful, @@ -438,7 +500,7 @@ const bson *mongo_cursor_bson( mongo_cursor *cursor ); * @return MONGO_OK. On error, returns MONGO_ERROR and sets * cursor->err with a value of mongo_error_t. */ -int mongo_cursor_next( mongo_cursor *cursor ); +MONGO_EXPORT int mongo_cursor_next( mongo_cursor *cursor ); /** * Destroy a cursor object. When finished with a cursor, you @@ -449,7 +511,7 @@ int mongo_cursor_next( mongo_cursor *cursor ); * @return MONGO_OK or an error code. On error, check cursor->conn->err * for errors. */ -int mongo_cursor_destroy( mongo_cursor *cursor ); +MONGO_EXPORT int mongo_cursor_destroy( mongo_cursor *cursor ); /** * Find a single document in a MongoDB server. @@ -462,8 +524,8 @@ int mongo_cursor_destroy( mongo_cursor *cursor ); * */ /* out can be NULL if you don't care about results. useful for commands */ -bson_bool_t mongo_find_one( mongo *conn, const char *ns, bson *query, - bson *fields, bson *out ); +MONGO_EXPORT int mongo_find_one( mongo *conn, const char *ns, const bson *query, + const bson *fields, bson *out ); /* MongoDB Helper Functions */ @@ -478,8 +540,8 @@ bson_bool_t mongo_find_one( mongo *conn, const char *ns, bson *query, * @return the number of matching documents. If the command fails, * MONGO_ERROR is returned. */ -int64_t mongo_count( mongo *conn, const char *db, const char *coll, - bson *query ); +MONGO_EXPORT double mongo_count( mongo *conn, const char *db, const char *coll, + const bson *query ); /** * Create a compouned index. @@ -494,7 +556,7 @@ int64_t mongo_count( mongo *conn, const char *db, const char *coll, * * @return MONGO_OK if index is created successfully; otherwise, MONGO_ERROR. */ -int mongo_create_index( mongo *conn, const char *ns, bson *key, int options, bson *out ); +MONGO_EXPORT int mongo_create_index( mongo *conn, const char *ns, const bson *key, int options, bson *out ); /** * Create an index with a single key. @@ -521,9 +583,9 @@ bson_bool_t mongo_create_simple_index( mongo *conn, const char *ns, const char * * @param command the BSON command to run. * @param out the BSON result of the command. * - * @return true if the command ran without error. + * @return MONGO_OK if the command ran without error. */ -bson_bool_t mongo_run_command( mongo *conn, const char *db, bson *command, bson *out ); +MONGO_EXPORT int mongo_run_command( mongo *conn, const char *db, const bson *command, bson *out ); /** * Run a command that accepts a simple string key and integer value. @@ -537,7 +599,7 @@ bson_bool_t mongo_run_command( mongo *conn, const char *db, bson *command, bson * @return MONGO_OK or an error code. * */ -int mongo_simple_int_command( mongo *conn, const char *db, +MONGO_EXPORT int mongo_simple_int_command( mongo *conn, const char *db, const char *cmd, int arg, bson *out ); /** @@ -552,7 +614,7 @@ int mongo_simple_int_command( mongo *conn, const char *db, * @return true if the command ran without error. * */ -bson_bool_t mongo_simple_str_command( mongo *conn, const char *db, const char *cmd, const char *arg, bson *out ); +MONGO_EXPORT int mongo_simple_str_command( mongo *conn, const char *db, const char *cmd, const char *arg, bson *out ); /** * Drop a database. @@ -562,7 +624,7 @@ bson_bool_t mongo_simple_str_command( mongo *conn, const char *db, const char *c * * @return MONGO_OK or an error code. */ -int mongo_cmd_drop_db( mongo *conn, const char *db ); +MONGO_EXPORT int mongo_cmd_drop_db( mongo *conn, const char *db ); /** * Drop a collection. @@ -574,7 +636,7 @@ int mongo_cmd_drop_db( mongo *conn, const char *db ); * * @return true if the collection drop was successful. */ -bson_bool_t mongo_cmd_drop_collection( mongo *conn, const char *db, const char *collection, bson *out ); +MONGO_EXPORT int mongo_cmd_drop_collection( mongo *conn, const char *db, const char *collection, bson *out ); /** * Add a database user. @@ -586,7 +648,7 @@ bson_bool_t mongo_cmd_drop_collection( mongo *conn, const char *db, const char * * * @return MONGO_OK or MONGO_ERROR. */ -int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const char *pass ); +MONGO_EXPORT int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const char *pass ); /** * Authenticate a user. @@ -598,7 +660,7 @@ int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const cha * * @return MONGO_OK on sucess and MONGO_ERROR on failure. */ -int mongo_cmd_authenticate( mongo *conn, const char *db, const char *user, const char *pass ); +MONGO_EXPORT int mongo_cmd_authenticate( mongo *conn, const char *db, const char *user, const char *pass ); /** * Check if the current server is a master. @@ -609,7 +671,7 @@ int mongo_cmd_authenticate( mongo *conn, const char *db, const char *user, const * @return true if the server is a master. */ /* return value is master status */ -bson_bool_t mongo_cmd_ismaster( mongo *conn, bson *out ); +MONGO_EXPORT bson_bool_t mongo_cmd_ismaster( mongo *conn, bson *out ); /** * Get the error for the last command with the current connection. @@ -621,7 +683,7 @@ bson_bool_t mongo_cmd_ismaster( mongo *conn, bson *out ); * @return MONGO_OK if no error and MONGO_ERROR on error. On error, check the values * of conn->lasterrcode and conn->lasterrstr for the error status. */ -int mongo_cmd_get_last_error( mongo *conn, const char *db, bson *out ); +MONGO_EXPORT int mongo_cmd_get_last_error( mongo *conn, const char *db, bson *out ); /** * Get the most recent error with the current connection. @@ -633,7 +695,7 @@ int mongo_cmd_get_last_error( mongo *conn, const char *db, bson *out ); * @return MONGO_OK if no error and MONGO_ERROR on error. On error, check the values * of conn->lasterrcode and conn->lasterrstr for the error status. */ -int mongo_cmd_get_prev_error( mongo *conn, const char *db, bson *out ); +MONGO_EXPORT int mongo_cmd_get_prev_error( mongo *conn, const char *db, bson *out ); /** * Reset the error state for the connection. @@ -641,7 +703,8 @@ int mongo_cmd_get_prev_error( mongo *conn, const char *db, bson *out ); * @param conn a mongo object. * @param db the name of the database. */ -void mongo_cmd_reset_error( mongo *conn, const char *db ); +MONGO_EXPORT void mongo_cmd_reset_error( mongo *conn, const char *db ); + MONGO_EXTERN_C_END diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/net.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/net.c deleted file mode 100644 index 5c8ad9ba5e..0000000000 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/net.c +++ /dev/null @@ -1,98 +0,0 @@ -/* net.c */ - -/* Copyright 2009-2011 10gen Inc. - * - * 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. - */ - -/* Implementation for generic version of net.h */ -#include "net.h" -#include - -int mongo_write_socket( mongo *conn, const void *buf, int len ) { - const char *cbuf = buf; - while ( len ) { - int sent = send( conn->sock, cbuf, len, 0 ); - if ( sent == -1 ) { - conn->err = MONGO_IO_ERROR; - return MONGO_ERROR; - } - cbuf += sent; - len -= sent; - } - - return MONGO_OK; -} - -int mongo_read_socket( mongo *conn, void *buf, int len ) { - char *cbuf = buf; - while ( len ) { - int sent = recv( conn->sock, cbuf, len, 0 ); - if ( sent == 0 || sent == -1 ) { - conn->err = MONGO_IO_ERROR; - return MONGO_ERROR; - } - cbuf += sent; - len -= sent; - } - - return MONGO_OK; -} - -/* This is a no-op in the generic implementation. */ -int mongo_set_socket_op_timeout( mongo *conn, int millis ) { - return MONGO_OK; -} - -static int mongo_create_socket( mongo *conn ) { - int fd; - - if( ( fd = socket( AF_INET, SOCK_STREAM, 0 ) ) == -1 ) { - conn->err = MONGO_CONN_NO_SOCKET; - return MONGO_ERROR; - } - conn->sock = fd; - - return MONGO_OK; -} - -int mongo_socket_connect( mongo *conn, const char *host, int port ) { - struct sockaddr_in sa; - socklen_t addressSize; - int flag = 1; - - if( mongo_create_socket( conn ) != MONGO_OK ) - return MONGO_ERROR; - - memset( sa.sin_zero , 0 , sizeof( sa.sin_zero ) ); - sa.sin_family = AF_INET; - sa.sin_port = htons( port ); - sa.sin_addr.s_addr = inet_addr( host ); - addressSize = sizeof( sa ); - - if ( connect( conn->sock, ( struct sockaddr * )&sa, addressSize ) == -1 ) { - mongo_close_socket( conn->sock ); - conn->connected = 0; - conn->sock = 0; - conn->err = MONGO_CONN_FAIL; - return MONGO_ERROR; - } - - setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * ) &flag, sizeof( flag ) ); - if( conn->op_timeout_ms > 0 ) - mongo_set_socket_op_timeout( conn, conn->op_timeout_ms ); - - conn->connected = 1; - - return MONGO_OK; -} diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/net.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/net.h deleted file mode 100644 index 49190877c8..0000000000 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/net.h +++ /dev/null @@ -1,57 +0,0 @@ -/** @file net.h */ - -/* Copyright 2009-2011 10gen Inc. - * - * 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. - */ - -/* Header for generic net.h */ -#ifndef _MONGO_NET_H_ -#define _MONGO_NET_H_ - -#include "mongo.h" - -#ifdef _WIN32 -#include -#include -#define mongo_close_socket(sock) ( closesocket(sock) ) -typedef int socklen_t; -#else -#include -#include -#include -#include -#include -#include -#include -#define mongo_close_socket(sock) ( close(sock) ) -#endif - -#ifndef _WIN32 -#include -#endif - -#if defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1 -#define _MONGO_USE_GETADDRINFO -#endif - -MONGO_EXTERN_C_START - -/* This is a no-op in the generic implementation. */ -int mongo_set_socket_op_timeout( mongo *conn, int millis ); -int mongo_read_socket( mongo *conn, void *buf, int len ); -int mongo_write_socket( mongo *conn, const void *buf, int len ); -int mongo_socket_connect( mongo *conn, const char *host, int port ); - -MONGO_EXTERN_C_END -#endif diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/numbers.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/numbers.c index a63e3d73f9..b3032d5ee3 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/numbers.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/numbers.c @@ -1,4 +1,4 @@ -/* Copyright 2009-2011 10gen Inc. +/* Copyright 2009-2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform.h deleted file mode 100644 index 4a96af77e3..0000000000 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform.h +++ /dev/null @@ -1,94 +0,0 @@ -/** @file platform.h */ - -/** Copyright 2009-2011 10gen Inc. - * - * 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. - */ - - -/* all platform-specific ifdefs should go here */ - -#ifndef _PLATFORM_HACKS_H_ -#define _PLATFORM_HACKS_H_ - -#ifdef __GNUC__ -#define MONGO_INLINE static __inline__ -#else -#define MONGO_INLINE static -#endif - -#ifdef __cplusplus -#define MONGO_EXTERN_C_START extern "C" { -#define MONGO_EXTERN_C_END } -#else -#define MONGO_EXTERN_C_START -#define MONGO_EXTERN_C_END -#endif - - -#if defined(MONGO_HAVE_STDINT) || __STDC_VERSION__ >= 199901L -#include -#elif defined(MONGO_HAVE_UNISTD) -#include -#elif defined(MONGO_USE__INT64) -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#elif defined(MONGO_USE_LONG_LONG_INT) -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#else -#error must have a 64bit int type -#endif - -/* big endian is only used for OID generation. little is used everywhere else */ -#ifdef MONGO_BIG_ENDIAN -#define bson_little_endian64(out, in) ( bson_swap_endian64(out, in) ) -#define bson_little_endian32(out, in) ( bson_swap_endian32(out, in) ) -#define bson_big_endian64(out, in) ( memcpy(out, in, 8) ) -#define bson_big_endian32(out, in) ( memcpy(out, in, 4) ) -#else -#define bson_little_endian64(out, in) ( memcpy(out, in, 8) ) -#define bson_little_endian32(out, in) ( memcpy(out, in, 4) ) -#define bson_big_endian64(out, in) ( bson_swap_endian64(out, in) ) -#define bson_big_endian32(out, in) ( bson_swap_endian32(out, in) ) -#endif - -MONGO_EXTERN_C_START - -MONGO_INLINE void bson_swap_endian64( void *outp, const void *inp ) { - const char *in = ( const char * )inp; - char *out = ( char * )outp; - - out[0] = in[7]; - out[1] = in[6]; - out[2] = in[5]; - out[3] = in[4]; - out[4] = in[3]; - out[5] = in[2]; - out[6] = in[1]; - out[7] = in[0]; - -} -MONGO_INLINE void bson_swap_endian32( void *outp, const void *inp ) { - const char *in = ( const char * )inp; - char *out = ( char * )outp; - - out[0] = in[3]; - out[1] = in[2]; - out[2] = in[1]; - out[3] = in[0]; -} - -MONGO_EXTERN_C_END - -#endif diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform/linux/net.c b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform/linux/net.c deleted file mode 100644 index b2f7c22898..0000000000 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform/linux/net.c +++ /dev/null @@ -1,183 +0,0 @@ -/* net.c */ - -/* Copyright 2009-2011 10gen Inc. - * - * 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. - */ - -/* Implementation for Linux version of net.h */ -#include "net.h" -#include - -int mongo_write_socket( mongo *conn, const void *buf, int len ) { - const char *cbuf = buf; - while ( len ) { - int sent = send( conn->sock, cbuf, len, 0 ); - if ( sent == -1 ) { - conn->err = MONGO_IO_ERROR; - return MONGO_ERROR; - } - cbuf += sent; - len -= sent; - } - - return MONGO_OK; -} - -int mongo_read_socket( mongo *conn, void *buf, int len ) { - char *cbuf = buf; - while ( len ) { - int sent = recv( conn->sock, cbuf, len, 0 ); - if ( sent == 0 || sent == -1 ) { - conn->err = MONGO_IO_ERROR; - return MONGO_ERROR; - } - cbuf += sent; - len -= sent; - } - - return MONGO_OK; -} - -static int mongo_create_socket( mongo *conn ) { - int fd; - - if( ( fd = socket( AF_INET, SOCK_STREAM, 0 ) ) == -1 ) { - conn->err = MONGO_CONN_NO_SOCKET; - return MONGO_ERROR; - } - conn->sock = fd; - - return MONGO_OK; -} - -static int mongo_set_blocking_status( mongo *conn ) { - int flags; - int blocking; - - blocking = ( conn->conn_timeout_ms == 0 ); - if( blocking ) - return MONGO_OK; - else { - if( ( flags = fcntl( conn->sock, F_GETFL ) ) == -1 ) { - conn->err = MONGO_IO_ERROR; - mongo_close_socket( conn->sock ); - return MONGO_ERROR; - } - - flags |= O_NONBLOCK; - - if( ( flags = fcntl( conn->sock, F_SETFL, flags ) ) == -1 ) { - conn->err = MONGO_IO_ERROR; - mongo_close_socket( conn->sock ); - return MONGO_ERROR; - } - } - - return MONGO_OK; -} - -int mongo_set_socket_op_timeout( mongo *conn, int millis ) { - struct timeval tv; - tv.tv_sec = millis / 1000; - tv.tv_usec = ( millis % 1000 ) * 1000; - - if ( setsockopt( conn->sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof( tv ) ) == -1 ) { - conn->err = MONGO_IO_ERROR; - return MONGO_ERROR; - } - - if ( setsockopt( conn->sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof( tv ) ) == -1 ) { - conn->err = MONGO_IO_ERROR; - return MONGO_ERROR; - } - - return MONGO_OK; -} - -#ifdef _MONGO_USE_GETADDRINFO -int mongo_socket_connect( mongo *conn, const char *host, int port ) { - - struct addrinfo *addrs = NULL; - struct addrinfo hints; - int flag = 1; - char port_str[12]; - int ret; - - conn->sock = 0; - conn->connected = 0; - - memset( &hints, 0, sizeof( hints ) ); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - - sprintf( port_str, "%d", port ); - - if( mongo_create_socket( conn ) != MONGO_OK ) - return MONGO_ERROR; - - if( getaddrinfo( host, port_str, &hints, &addrs ) != 0 ) { - bson_errprintf( "getaddrinfo failed: %s", gai_strerror( ret ) ); - conn->err = MONGO_CONN_ADDR_FAIL; - return MONGO_ERROR; - } - - if ( connect( conn->sock, addrs->ai_addr, addrs->ai_addrlen ) == -1 ) { - mongo_close_socket( conn->sock ); - freeaddrinfo( addrs ); - conn->err = MONGO_CONN_FAIL; - return MONGO_ERROR; - } - - setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * )&flag, sizeof( flag ) ); - if( conn->op_timeout_ms > 0 ) - mongo_set_socket_op_timeout( conn, conn->op_timeout_ms ); - - conn->connected = 1; - freeaddrinfo( addrs ); - - return MONGO_OK; -} -#else -int mongo_socket_connect( mongo *conn, const char *host, int port ) { - struct sockaddr_in sa; - socklen_t addressSize; - int flag = 1; - - if( mongo_create_socket( conn ) != MONGO_OK ) - return MONGO_ERROR; - - memset( sa.sin_zero , 0 , sizeof( sa.sin_zero ) ); - sa.sin_family = AF_INET; - sa.sin_port = htons( port ); - sa.sin_addr.s_addr = inet_addr( host ); - addressSize = sizeof( sa ); - - if ( connect( conn->sock, ( struct sockaddr * )&sa, addressSize ) == -1 ) { - mongo_close_socket( conn->sock ); - conn->connected = 0; - conn->sock = 0; - conn->err = MONGO_CONN_FAIL; - return MONGO_ERROR; - } - - setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * ) &flag, sizeof( flag ) ); - - if( conn->op_timeout_ms > 0 ) - mongo_set_socket_op_timeout( conn, conn->op_timeout_ms ); - - conn->connected = 1; - - return MONGO_OK; -} -#endif diff --git a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform/linux/net.h b/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform/linux/net.h deleted file mode 100644 index 054247c1e8..0000000000 --- a/src/mod/event_handlers/mod_cdr_mongodb/driver/src/platform/linux/net.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file net.h - * @brief Networking. - */ - -/* Copyright 2009-2011 10gen Inc. - * - * 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. - */ - -/* Header for Linux net.h */ -#ifndef _MONGO_NET_H_ -#define _MONGO_NET_H_ - -#include "mongo.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define mongo_close_socket(sock) ( close(sock) ) - -#if defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1 -#define _MONGO_USE_GETADDRINFO -#endif - -MONGO_EXTERN_C_START - -int mongo_set_socket_op_timeout( mongo *conn, int millis ); -int mongo_read_socket( mongo *conn, void *buf, int len ); -int mongo_write_socket( mongo *conn, const void *buf, int len ); -int mongo_socket_connect( mongo *conn, const char *host, int port ); - -MONGO_EXTERN_C_END -#endif 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 f2ecd35a4a..fec5b516ef 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 @@ -124,11 +124,16 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) /* Channel variables */ bson_append_start_object(&cdr, "variables"); - for (hi = switch_channel_variable_first(channel); hi; hi = hi->next) { - if (!zstr(hi->name) && !zstr(hi->value)) { - bson_append_string(&cdr, hi->name, hi->value); + + 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); + } } + switch_channel_variable_last(channel); } + bson_append_finish_object(&cdr); /* variables */ @@ -140,7 +145,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) for (ap = app_log; ap; ap = ap->next) { bson_append_start_object(&cdr, "application"); bson_append_string(&cdr, "app_name", ap->app); - bson_append_string(&cdr, "app_data", ap->arg); + bson_append_string(&cdr, "app_data", switch_str_nil(ap->arg)); bson_append_long(&cdr, "app_stamp", ap->stamp); bson_append_finish_object(&cdr); /* application */ } @@ -181,7 +186,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) bson_append_bool(&cdr, "last_executed", 1); } bson_append_string(&cdr, "app_name", ap->application_name); - bson_append_string(&cdr, "app_data", ap->application_data); + bson_append_string(&cdr, "app_data", switch_str_nil(ap->application_data)); bson_append_finish_object(&cdr); } @@ -210,7 +215,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) bson_append_bool(&cdr, "last_executed", 1); } bson_append_string(&cdr, "app_name", ap->application_name); - bson_append_string(&cdr, "app_data", ap->application_data); + bson_append_string(&cdr, "app_data", switch_str_nil(ap->application_data)); bson_append_finish_object(&cdr); } @@ -355,7 +360,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_mongodb_load) memset(&globals, 0, sizeof(globals)); globals.pool = pool; if (load_config(pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Unable to load or parse config!\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load or parse config!\n"); + return SWITCH_STATUS_FALSE; } db_status = mongo_connect(globals.mongo_conn, globals.mongo_host, globals.mongo_port); 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 46e9e67e85..618b7eb829 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -28,6 +28,7 @@ * Rob Charlton * Darren Schreiber * Mike Jerris + * Tamas Cseke * * * handle_msg.c -- handle messages received from erlang nodes @@ -286,6 +287,8 @@ static switch_status_t handle_msg_event(listener_t *listener, int arity, ei_x_bu switch_set_flag_locked(listener, LFLAG_EVENTS); } + switch_thread_rwlock_wrlock(listener->event_rwlock); + for (i = 1; i < arity; i++) { if (!ei_decode_atom(buf->buff, &buf->index, atom)) { @@ -311,6 +314,8 @@ static switch_status_t handle_msg_event(listener_t *listener, int arity, ei_x_bu switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "enable event %s\n", atom); } } + switch_thread_rwlock_unlock(listener->event_rwlock); + ei_x_encode_atom(rbuf, "ok"); } return SWITCH_STATUS_SUCCESS; @@ -332,6 +337,8 @@ static switch_status_t handle_msg_session_event(listener_t *listener, erlang_msg switch_event_types_t type; int i = 0; + switch_thread_rwlock_wrlock(session->event_rwlock); + for (i = 1; i < arity; i++) { if (!ei_decode_atom(buf->buff, &buf->index, atom)) { @@ -357,6 +364,9 @@ static switch_status_t handle_msg_session_event(listener_t *listener, erlang_msg switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "enable event %s for session %s\n", atom, session->uuid_str); } } + + switch_thread_rwlock_unlock(session->event_rwlock); + ei_x_encode_atom(rbuf, "ok"); } else { ei_x_encode_tuple_header(rbuf, 2); @@ -380,10 +390,13 @@ static switch_status_t handle_msg_nixevent(listener_t *listener, int arity, ei_x int i = 0; switch_event_types_t type; + switch_thread_rwlock_wrlock(listener->event_rwlock); + for (i = 1; i < arity; i++) { if (!ei_decode_atom(buf->buff, &buf->index, atom)) { if (custom) { + switch_core_hash_delete(listener->event_hash, atom); } else if (switch_name_event(atom, &type) == SWITCH_STATUS_SUCCESS) { uint32_t x = 0; @@ -406,6 +419,8 @@ static switch_status_t handle_msg_nixevent(listener_t *listener, int arity, ei_x } } } + + switch_thread_rwlock_unlock(listener->event_rwlock); ei_x_encode_atom(rbuf, "ok"); } return SWITCH_STATUS_SUCCESS; @@ -426,6 +441,8 @@ static switch_status_t handle_msg_session_nixevent(listener_t *listener, erlang_ int i = 0; switch_event_types_t type; + switch_thread_rwlock_wrlock(session->event_rwlock); + for (i = 1; i < arity; i++) { if (!ei_decode_atom(buf->buff, &buf->index, atom)) { @@ -452,6 +469,8 @@ static switch_status_t handle_msg_session_nixevent(listener_t *listener, erlang_ } } } + switch_thread_rwlock_unlock(session->event_rwlock); + ei_x_encode_atom(rbuf, "ok"); } else { /* no session for this pid */ ei_x_encode_tuple_header(rbuf, 2); @@ -481,7 +500,7 @@ static switch_status_t handle_msg_setevent(listener_t *listener, erlang_msg *msg int i = 0; /* clear any previous event registrations */ - for( x = 0; x <= SWITCH_EVENT_ALL; x++){ + for(x = 0; x <= SWITCH_EVENT_ALL; x++) { event_list[x] = 0; } @@ -515,10 +534,11 @@ static switch_status_t handle_msg_setevent(listener_t *listener, erlang_msg *msg } } /* update the event subscriptions with the new ones */ + switch_thread_rwlock_wrlock(listener->event_rwlock); memcpy(listener->event_list, event_list, sizeof(uint8_t) * (SWITCH_EVENT_ALL + 1)); - /* wipe the old hash, and point the pointer at the new one */ switch_core_hash_destroy(&listener->event_hash); listener->event_hash = event_hash; + switch_thread_rwlock_unlock(listener->event_rwlock); /* TODO - we should flush any non-matching events from the queue */ ei_x_encode_atom(rbuf, "ok"); @@ -573,11 +593,15 @@ static switch_status_t handle_msg_session_setevent(listener_t *listener, erlang_ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "enable event %s for session %s\n", atom, session->uuid_str); } } + /* update the event subscriptions with the new ones */ + switch_thread_rwlock_wrlock(session->event_rwlock); memcpy(session->event_list, event_list, sizeof(uint8_t) * (SWITCH_EVENT_ALL + 1)); /* wipe the old hash, and point the pointer at the new one */ switch_core_hash_destroy(&session->event_hash); session->event_hash = event_hash; + switch_thread_rwlock_unlock(session->event_rwlock); + /* TODO - we should flush any non-matching events from the queue */ ei_x_encode_atom(rbuf, "ok"); } else { /* no session for this pid */ @@ -601,16 +625,16 @@ static switch_status_t handle_msg_api(listener_t *listener, erlang_msg * msg, in fail = SWITCH_TRUE; } - ei_get_type(buf->buff, &buf->index, &type, &size); + ei_get_type(buf->buff, &buf->index, &type, &size); if ((size > (sizeof(api_cmd) - 1)) || ei_decode_atom(buf->buff, &buf->index, api_cmd)) { fail = SWITCH_TRUE; } - ei_get_type(buf->buff, &buf->index, &type, &size); + ei_get_type(buf->buff, &buf->index, &type, &size); arg = malloc(size + 1); - if (ei_decode_string(buf->buff, &buf->index, arg)) { + if (ei_decode_string_or_binary(buf->buff, &buf->index, size, arg)) { fail = SWITCH_TRUE; } @@ -640,7 +664,7 @@ static switch_status_t handle_msg_bgapi(listener_t *listener, erlang_msg * msg, { char api_cmd[MAXATOMLEN]; char arg[1024]; - if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string(buf->buff, &buf->index, arg)) { + if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string_or_binary(buf->buff, &buf->index, 1023, arg)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); @@ -706,29 +730,29 @@ static switch_status_t handle_msg_sendevent(listener_t *listener, int arity, ei_ while (!ei_decode_tuple_header(buf->buff, &buf->index, &arity) && arity == 2) { i++; - ei_get_type(buf->buff, &buf->index, &type, &size); + ei_get_type(buf->buff, &buf->index, &type, &size); if ((size > (sizeof(key) - 1)) || ei_decode_string(buf->buff, &buf->index, key)) { fail = SWITCH_TRUE; break; } - ei_get_type(buf->buff, &buf->index, &type, &size); - value = malloc(size + 1); + ei_get_type(buf->buff, &buf->index, &type, &size); + value = malloc(size + 1); if (ei_decode_string(buf->buff, &buf->index, value)) { fail = SWITCH_TRUE; break; } - if (!fail && !strcmp(key, "body")) { - switch_safe_free(event->body); - event->body = value; - } else if (!fail) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value); - } - - /* Do not free malloc here! The above commands utilize the raw allocated memory and skip any copying/duplication. Faster. */ + if (!fail && !strcmp(key, "body")) { + switch_safe_free(event->body); + event->body = value; + } else if (!fail) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value); + } + + /* Do not free malloc here! The above commands utilize the raw allocated memory and skip any copying/duplication. Faster. */ } if (headerlength != i || fail) { @@ -763,30 +787,30 @@ static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_ char key[1024]; char *value; - int type; - int size; + int type; + int size; int i = 0; switch_bool_t fail = SWITCH_FALSE; while (!ei_decode_tuple_header(buf->buff, &buf->index, &arity) && arity == 2) { i++; - ei_get_type(buf->buff, &buf->index, &type, &size); + ei_get_type(buf->buff, &buf->index, &type, &size); if ((size > (sizeof(key) - 1)) || ei_decode_string(buf->buff, &buf->index, key)) { fail = SWITCH_TRUE; break; } - - ei_get_type(buf->buff, &buf->index, &type, &size); - value = malloc(size + 1); + + ei_get_type(buf->buff, &buf->index, &type, &size); + value = malloc(size + 1); if (ei_decode_string(buf->buff, &buf->index, value)) { - fail = SWITCH_TRUE; + fail = SWITCH_TRUE; break; } if (!fail) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value); } } @@ -794,6 +818,7 @@ static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_ ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); + switch_event_destroy(&event); } else { if (switch_core_session_queue_private_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { ei_x_encode_atom(rbuf, "ok"); @@ -801,6 +826,7 @@ static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_ ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badmem"); + switch_event_destroy(&event); } } @@ -1020,12 +1046,15 @@ static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, e if (switch_test_flag(listener, LFLAG_EVENTS)) { uint8_t x = 0; switch_clear_flag_locked(listener, LFLAG_EVENTS); + + switch_thread_rwlock_wrlock(listener->event_rwlock); for (x = 0; x <= SWITCH_EVENT_ALL; x++) { listener->event_list[x] = 0; } - /* wipe the hash */ - switch_core_hash_destroy(&listener->event_hash); - switch_core_hash_init(&listener->event_hash, listener->pool); + + switch_core_hash_delete_multi(listener->event_hash, NULL, NULL); + + switch_thread_rwlock_unlock(listener->event_rwlock); ei_x_encode_atom(rbuf, "ok"); } else { ei_x_encode_tuple_header(rbuf, 2); @@ -1040,12 +1069,15 @@ static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, e /*purge the event queue */ while (switch_queue_trypop(session->event_queue, &pop) == SWITCH_STATUS_SUCCESS); + + switch_thread_rwlock_wrlock(session->event_rwlock); for (x = 0; x <= SWITCH_EVENT_ALL; x++) { session->event_list[x] = 0; } /* wipe the hash */ - switch_core_hash_destroy(&session->event_hash); - switch_core_hash_init(&session->event_hash, session->pool); + switch_core_hash_delete_multi(session->event_hash, NULL, NULL); + switch_thread_rwlock_unlock(session->event_rwlock); + ei_x_encode_atom(rbuf, "ok"); } else { ei_x_encode_tuple_header(rbuf, 2); @@ -1076,13 +1108,14 @@ static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, e static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf) { erlang_ref ref; - erlang_pid *pid; + erlang_pid pid; char hash[100]; int arity; const void *key; void *val; session_elem_t *se; switch_hash_index_t *iter; + int found = 0; ei_decode_tuple_header(buf->buff, &buf->index, &arity); @@ -1091,15 +1124,7 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, return SWITCH_STATUS_FALSE; } - if (!(pid = malloc(sizeof(erlang_pid)))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n"); - ei_x_encode_tuple_header(rbuf, 2); - ei_x_encode_atom(rbuf, "error"); - ei_x_encode_atom(rbuf, "badmem"); - return SWITCH_STATUS_SUCCESS; - } - - if (ei_decode_pid(buf->buff, &buf->index, pid)) { + if (ei_decode_pid(buf->buff, &buf->index, &pid)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid pid in a reference/pid tuple\n"); return SWITCH_STATUS_FALSE; } @@ -1113,32 +1138,32 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, switch_hash_this(iter, &key, NULL, &val); se = (session_elem_t*)val; if (se->spawn_reply && !strncmp(se->spawn_reply->hash, hash, 100)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "found matching session for %s : %s\n", hash, se->uuid_str); - switch_mutex_lock(se->spawn_reply->mutex); - if (se->spawn_reply->state == reply_not_ready) { - switch_thread_cond_wait(se->spawn_reply->ready_or_found, se->spawn_reply->mutex); - } - if (se->spawn_reply->state == reply_waiting) { - se->spawn_reply->pid = pid; - switch_thread_cond_signal(se->spawn_reply->ready_or_found); - ei_x_encode_atom(rbuf, "ok"); - switch_thread_rwlock_unlock(listener->session_rwlock); - switch_mutex_unlock(se->spawn_reply->mutex); - return SWITCH_STATUS_SUCCESS; - } + switch_mutex_lock(se->spawn_reply->mutex); + + se->spawn_reply->pid = switch_core_alloc(se->pool, sizeof(erlang_pid)); + switch_assert(se->spawn_reply->pid != NULL); + memcpy(se->spawn_reply->pid, &pid, sizeof(erlang_pid)); + switch_thread_cond_signal(se->spawn_reply->ready_or_found); + switch_mutex_unlock(se->spawn_reply->mutex); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "get_pid came in too late for %s; %s\n", hash, se->uuid_str); + + found++; + break; } } switch_thread_rwlock_unlock(listener->session_rwlock); - ei_x_encode_tuple_header(rbuf, 2); - ei_x_encode_atom(rbuf, "error"); - ei_x_encode_atom(rbuf, "notfound"); - - switch_safe_free(pid); /* don't need it */ + if (found) { + ei_x_encode_atom(rbuf, "ok"); + } else { + ei_x_encode_tuple_header(rbuf, 2); + ei_x_encode_atom(rbuf, "error"); + ei_x_encode_atom(rbuf, "notfound"); + } return SWITCH_STATUS_SUCCESS; } @@ -1240,6 +1265,7 @@ int handle_msg(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buf buf->index = 0; ei_decode_version(buf->buff, &buf->index, &version); ei_get_type(buf->buff, &buf->index, &type, &size); + switch (type) { case ERL_SMALL_TUPLE_EXT: case ERL_LARGE_TUPLE_EXT: @@ -1288,11 +1314,8 @@ int handle_msg(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buf #ifdef EI_DEBUG ei_x_print_msg(rbuf, &msg->from, 1); #endif + return SWITCH_STATUS_SUCCESS != ret; - if (SWITCH_STATUS_SUCCESS == ret) - return 0; - else /* SWITCH_STATUS_TERM */ - return 1; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Empty reply, supressing\n"); return 0; 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 243303d9cd..c462cf30e1 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 @@ -26,6 +26,7 @@ * Anthony Minessale II * Andrew Thompson * Rob Charlton + * Tamas Cseke * * * mod_erlang_event.c -- Erlang Event Handler derived from mod_event_socket @@ -44,6 +45,7 @@ SWITCH_MODULE_DEFINITION(mod_erlang_event, mod_erlang_event_load, mod_erlang_eve static switch_memory_pool_t *module_pool = NULL; static void remove_listener(listener_t *listener); +static void destroy_listener(listener_t *listener); static switch_status_t state_handler(switch_core_session_t *session); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, prefs.ip); @@ -53,12 +55,15 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_nodename, prefs.nodename); static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj); static void launch_listener_thread(listener_t *listener); +session_elem_t *find_session_elem_by_uuid(listener_t *listener, const char *uuid); + static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level) { listener_t *l; switch_thread_rwlock_rdlock(globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { + if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) { switch_log_node_t *dnode = switch_log_node_dup(node); @@ -79,6 +84,7 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l l->lost_logs++; } } + } switch_thread_rwlock_unlock(globals.listener_rwlock); @@ -131,12 +137,11 @@ static void send_event_to_attached_sessions(listener_t *listener, switch_event_t return; } - switch_thread_rwlock_rdlock(listener->session_rwlock); - s = (session_elem_t*)switch_core_hash_find(listener->sessions, uuid); - switch_thread_rwlock_unlock(listener->session_rwlock); - - if (s) { + if ((s = (session_elem_t*)find_session_elem_by_uuid(listener, uuid))) { int send = 0; + + switch_thread_rwlock_rdlock(s->event_rwlock); + if (s->event_list[SWITCH_EVENT_ALL]) { send = 1; } else if ((s->event_list[event->event_id])) { @@ -145,6 +150,8 @@ static void send_event_to_attached_sessions(listener_t *listener, switch_event_t } } + switch_thread_rwlock_unlock(s->event_rwlock); + if (send) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_DEBUG, "Sending event %s to attached session %s\n", switch_event_name(event->event_id), s->uuid_str); @@ -161,7 +168,9 @@ static void send_event_to_attached_sessions(listener_t *listener, switch_event_t switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_DEBUG, "Ignoring event %s for attached session %s\n", switch_event_name(event->event_id), s->uuid_str); } + switch_thread_rwlock_unlock(s->rwlock); } + } static void event_handler(switch_event_t *event) @@ -175,9 +184,10 @@ static void event_handler(switch_event_t *event) return; } + switch_thread_rwlock_rdlock(globals.listener_rwlock); + lp = listen_list.listeners; - switch_thread_rwlock_rdlock(globals.listener_rwlock); while (lp) { uint8_t send = 0; @@ -194,6 +204,8 @@ static void event_handler(switch_event_t *event) continue; } + switch_thread_rwlock_rdlock(l->event_rwlock); + if (l->event_list[SWITCH_EVENT_ALL]) { send = 1; } else if ((l->event_list[event->event_id])) { @@ -202,6 +214,7 @@ static void event_handler(switch_event_t *event) } } + switch_thread_rwlock_unlock(l->event_rwlock); if (send) { if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) { @@ -251,7 +264,7 @@ static void close_socket(int *sock) static void add_listener(listener_t *listener) { - /* add me to the listeners so I get events */ + /* add me to the listeners so I get events */ switch_thread_rwlock_wrlock(globals.listener_rwlock); listener->next = listen_list.listeners; listen_list.listeners = listener; @@ -277,7 +290,7 @@ static void remove_listener(listener_t *listener) switch_thread_rwlock_unlock(globals.listener_rwlock); } -/* Search for a listener already talking to the specified node */ +/* Search for a listener already talking to the specified node and lock for reading*/ static listener_t *find_listener(char *nodename) { listener_t *l = NULL; @@ -285,6 +298,7 @@ static listener_t *find_listener(char *nodename) switch_thread_rwlock_rdlock(globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { if (!strncmp(nodename, l->peer_nodename, MAXNODELEN)) { + switch_thread_rwlock_rdlock(l->rwlock); break; } } @@ -303,30 +317,42 @@ static void add_session_elem_to_listener(listener_t *listener, session_elem_t *s static void remove_session_elem_from_listener(listener_t *listener, session_elem_t *session_element) { + switch_thread_rwlock_wrlock(listener->session_rwlock); switch_core_hash_delete(listener->sessions, session_element->uuid_str); + switch_thread_rwlock_unlock(listener->session_rwlock); } static void destroy_session_elem(session_elem_t *session_element) { switch_core_session_t *session; + /* wait for readers */ + switch_thread_rwlock_wrlock(session_element->rwlock); + switch_thread_rwlock_unlock(session_element->rwlock); + if ((session = switch_core_session_locate(session_element->uuid_str))) { - switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED); + switch_channel_t *channel = switch_core_session_get_channel(session); + + switch_channel_set_private(channel, "_erlang_session_", NULL); + switch_channel_clear_flag(channel, CF_CONTROLLED); switch_core_session_rwunlock(session); } - /* this allows the application threads to exit */ - switch_clear_flag_locked(session_element, LFLAG_SESSION_ALIVE); switch_core_destroy_memory_pool(&session_element->pool); - /*switch_safe_free(s); */ } -static void remove_session_elem_from_listener_locked(listener_t *listener, session_elem_t *session_element) +session_elem_t *find_session_elem_by_uuid(listener_t *listener, const char *uuid) { - switch_thread_rwlock_wrlock(listener->session_rwlock); - remove_session_elem_from_listener(listener, session_element); - switch_thread_rwlock_unlock(listener->session_rwlock); -} + session_elem_t *session = NULL; + + switch_thread_rwlock_rdlock(listener->session_rwlock); + if ((session = (session_elem_t*)switch_core_hash_find(listener->sessions, uuid))) { + switch_thread_rwlock_rdlock(session->rwlock); + } + switch_thread_rwlock_unlock(listener->session_rwlock); + + return session; + } session_elem_t *find_session_elem_by_pid(listener_t *listener, erlang_pid *pid) { @@ -338,15 +364,16 @@ session_elem_t *find_session_elem_by_pid(listener_t *listener, erlang_pid *pid) switch_thread_rwlock_rdlock(listener->session_rwlock); for (iter = switch_hash_first(NULL, listener->sessions); iter; iter = switch_hash_next(iter)) { switch_hash_this(iter, &key, NULL, &val); - session = (session_elem_t*)val; - if (session->process.type == ERLANG_PID && !ei_compare_pids(pid, &session->process.pid)) { - switch_thread_rwlock_unlock(listener->session_rwlock); - return session; + + if (((session_elem_t*)val)->process.type == ERLANG_PID && !ei_compare_pids(pid, &((session_elem_t*)val)->process.pid)) { + session = (session_elem_t*)val; + switch_thread_rwlock_rdlock(session->rwlock); + break; } } switch_thread_rwlock_unlock(listener->session_rwlock); - return NULL; + return session; } @@ -364,6 +391,7 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c switch_xml_t xml = NULL; ei_x_buff *rep; ei_x_buff buf; + ei_x_new_with_version(&buf); switch_uuid_get(&uuid); @@ -383,14 +411,20 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c switch_thread_rwlock_rdlock(globals.bindings_rwlock); - for (ptr = bindings.head; ptr; ptr = ptr->next) { - if (ptr->section != section) - continue; + /* Keep the listener from getting pulled out from under us */ + switch_thread_rwlock_rdlock(globals.listener_rwlock); + for (ptr = bindings.head; ptr; ptr = ptr->next) { + /* If we got listener_rwlock while a listner thread was dying after removing the listener + from listener_list but before locking for the bindings removal (now pending our lock) check + if it already closed the socket. Our listener pointer should still be good (pointed at an orphan + listener) until it is removed from the binding...*/ if (!ptr->listener) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NULL pointer binding!\n"); - switch_thread_rwlock_unlock(globals.bindings_rwlock); - goto cleanup; /* our pointer is trash */ + continue; + } + + if (ptr->section != section) { + continue; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "binding for %s in section %s with key %s and value %s requested from node %s\n", tag_name, sectionstr, key_name, key_value, ptr->process.pid.node); @@ -405,6 +439,7 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c /* Create a new fetch object. */ p = malloc(sizeof(*p)); switch_thread_cond_create(&p->ready_or_found, module_pool); + /* TODO module pool */ switch_mutex_init(&p->mutex, SWITCH_MUTEX_UNNESTED, module_pool); p->state = reply_not_ready; p->reply = NULL; @@ -416,11 +451,14 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c on our condition before the action starts. */ switch_mutex_lock(ptr->listener->sock_mutex); - ei_sendto(ptr->listener->ec, ptr->listener->sockfd, &ptr->process, &buf); + if (ptr->listener->sockfd) { + ei_sendto(ptr->listener->ec, ptr->listener->sockfd, &ptr->process, &buf); + } switch_mutex_unlock(ptr->listener->sock_mutex); } switch_thread_rwlock_unlock(globals.bindings_rwlock); + switch_thread_rwlock_unlock(globals.listener_rwlock); ei_x_free(&buf); @@ -432,8 +470,7 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c /* Tell the threads to be ready, and wait five seconds for a reply. */ switch_mutex_lock(p->mutex); //p->state = reply_waiting; - switch_thread_cond_timedwait(p->ready_or_found, - p->mutex, 5000000); + switch_thread_cond_timedwait(p->ready_or_found, p->mutex, 5000000); if (!p->reply) { p->state = reply_timeout; switch_mutex_unlock(p->mutex); @@ -464,7 +501,9 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c ei_decode_string_or_binary(rep->buff, &rep->index, size, xmlstr); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got data %s after %d milliseconds from %s for %s!\n", xmlstr, (int) (switch_micro_time_now() - now) / 1000, p->winner, uuid_str); + if (globals.debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got data %s after %d milliseconds from %s for %s!\n", xmlstr, (int) (switch_micro_time_now() - now) / 1000, p->winner, uuid_str); + } if (zstr(xmlstr)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n"); @@ -510,6 +549,7 @@ static switch_status_t notify_new_session(listener_t *listener, session_elem_t * if (!(session = switch_core_session_locate(session_element->uuid_str))) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_WARNING, "Can't locate session %s\n", session_element->uuid_str); + switch_event_destroy(&call_event); return SWITCH_STATUS_FALSE; } @@ -518,6 +558,7 @@ static switch_status_t notify_new_session(listener_t *listener, session_elem_t * switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event); switch_channel_event_set_data(channel, call_event); switch_core_session_rwunlock(session); + /* TODO reply? sure? */ switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply"); switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Reply-Text", "+OK\n"); @@ -553,6 +594,7 @@ static switch_status_t check_attached_sessions(listener_t *listener) /* event used to track sessions to remove */ switch_event_t *event = NULL; switch_event_header_t *header = NULL; + switch_event_create_subclass(&event, SWITCH_EVENT_CLONE, NULL); switch_assert(event); /* check up on all the attached sessions - @@ -560,6 +602,8 @@ static switch_status_t check_attached_sessions(listener_t *listener) if they have pending events in their queues then send them if the session has finished then clean it up */ + + /* TODO try to minimize critical section */ switch_thread_rwlock_rdlock(listener->session_rwlock); for (iter = switch_hash_first(NULL, listener->sessions); iter; iter = switch_hash_next(iter)) { switch_hash_this(iter, &key, NULL, &value); @@ -576,7 +620,7 @@ static switch_status_t check_attached_sessions(listener_t *listener) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delete", (const char *) key); continue; } - switch_set_flag(sp, LFLAG_OUTBOUND_INIT); + switch_set_flag_locked(sp, LFLAG_OUTBOUND_INIT); } if (switch_test_flag(sp, LFLAG_SESSION_COMPLETE)) { @@ -642,18 +686,16 @@ static switch_status_t check_attached_sessions(listener_t *listener) } } switch_thread_rwlock_unlock(listener->session_rwlock); - /* release the read lock and get a write lock */ - switch_thread_rwlock_wrlock(listener->session_rwlock); + /* do the deferred remove */ for (header = event->headers; header; header = header->next) { - if ((sp = (session_elem_t*)switch_core_hash_find(listener->sessions, header->value))) { + if ((sp = (session_elem_t*)find_session_elem_by_uuid(listener, header->value))) { remove_session_elem_from_listener(listener, sp); + switch_thread_rwlock_unlock(sp->rwlock); destroy_session_elem(sp); } } - switch_thread_rwlock_unlock(listener->session_rwlock); - /* remove the temporary event */ switch_event_destroy(&event); @@ -751,29 +793,32 @@ static void handle_exit(listener_t *listener, erlang_pid * pid) session_elem_t *s; remove_binding(NULL, pid); /* TODO - why don't we pass the listener as the first argument? */ - if ((s = find_session_elem_by_pid(listener, pid))) { - if (s->channel_state < CS_HANGUP) { - switch_core_session_t *session; - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_WARNING, "Outbound session for %s exited unexpectedly!\n", s->uuid_str); - if ((session = switch_core_session_locate(s->uuid_str))) { - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_channel_set_private(channel, "_erlang_session_", NULL); - switch_channel_set_private(channel, "_erlang_listener_", NULL); - switch_core_event_hook_remove_state_change(session, state_handler); - switch_core_session_rwunlock(session); + if ((s = find_session_elem_by_pid(listener, pid))) { + switch_core_session_t *session = NULL; + + if ((session = switch_core_session_locate(s->uuid_str))) { + switch_channel_t *channel = switch_core_session_get_channel(session); + + if (switch_channel_get_state(channel) < CS_HANGUP) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Outbound session exited unexpectedly %s!\n", s->uuid_str); } - /* TODO - if a spawned process that was handling an outbound call fails.. what do we do with the call? */ + + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + switch_core_session_rwunlock(session); } - remove_session_elem_from_listener_locked(listener, s); - destroy_session_elem(s); + + switch_thread_rwlock_unlock(s->rwlock); + } + if (listener->log_process.type == ERLANG_PID && !ei_compare_pids(&listener->log_process.pid, pid)) { void *pop; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Log handler process for node %s exited\n", pid->node); /*purge the log queue */ + /* TODO don't we want to clear flag first? */ while (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) { switch_log_node_t *dnode = (switch_log_node_t *) pop; switch_log_node_free(&dnode); @@ -789,6 +834,7 @@ static void handle_exit(listener_t *listener, erlang_pid * pid) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event handler process for node %s exited\n", pid->node); /*purge the event queue */ + /* TODO don't we want to clear flag first? */ while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) { switch_event_t *pevent = (switch_event_t *) pop; switch_event_destroy(&pevent); @@ -797,12 +843,13 @@ static void handle_exit(listener_t *listener, erlang_pid * pid) if (switch_test_flag(listener, LFLAG_EVENTS)) { uint8_t x = 0; switch_clear_flag_locked(listener, LFLAG_EVENTS); + + switch_thread_rwlock_wrlock(listener->event_rwlock); for (x = 0; x <= SWITCH_EVENT_ALL; x++) { listener->event_list[x] = 0; } - /* wipe the hash */ - switch_core_hash_destroy(&listener->event_hash); - switch_core_hash_init(&listener->event_hash, listener->pool); + switch_core_hash_delete_multi(listener->event_hash, NULL, NULL); + switch_thread_rwlock_unlock(listener->event_rwlock); } } } @@ -821,7 +868,7 @@ static void listener_main_loop(listener_t *listener) /* do we need the mutex when reading? */ /*switch_mutex_lock(listener->sock_mutex); */ - status = ei_xreceive_msg_tmo(listener->sockfd, &msg, &buf, 100); + status = ei_xreceive_msg_tmo(listener->sockfd, &msg, &buf, 10); /*switch_mutex_unlock(listener->sock_mutex); */ switch (status) { @@ -867,6 +914,7 @@ static void listener_main_loop(listener_t *listener) case ERL_EXIT: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_exit from %s <%d.%d.%d>\n", msg.from.node, msg.from.creation, msg.from.num, msg.from.serial); + handle_exit(listener, &msg.from); break; default: @@ -876,7 +924,7 @@ static void listener_main_loop(listener_t *listener) break; case ERL_ERROR: if (erl_errno != ETIMEDOUT && erl_errno != EAGAIN) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_error\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "erl_error: status=%d, erl_errno=%d errno=%d\n", status, erl_errno, errno); } break; default: @@ -894,6 +942,11 @@ static void listener_main_loop(listener_t *listener) return; } } + if (prefs.done) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "shutting down listener\n"); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "listener exit: status=%d, erl_errno=%d errno=%d\n", status, erl_errno, errno); + } } static switch_bool_t check_inbound_acl(listener_t *listener) @@ -943,10 +996,6 @@ static switch_bool_t check_inbound_acl(listener_t *listener) static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) { listener_t *listener = (listener_t *) obj; - session_elem_t *s; - const void *key; - void *value; - switch_hash_index_t *iter; switch_mutex_lock(globals.listener_count_mutex); prefs.threads++; @@ -965,38 +1014,10 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) listener_main_loop(listener); } - /* clean up */ - remove_listener(listener); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session complete, waiting for children\n"); - - switch_thread_rwlock_wrlock(listener->rwlock); - - if (listener->sockfd) { - close_socket(&listener->sockfd); - } - - switch_thread_rwlock_unlock(listener->rwlock); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Closed\n"); - switch_core_hash_destroy(&listener->event_hash); - /* remove any bindings for this connection */ - remove_binding(listener, NULL); - - /* clean up all the attached sessions */ - switch_thread_rwlock_wrlock(listener->session_rwlock); - for (iter = switch_hash_first(NULL, listener->sessions); iter; iter = switch_hash_next(iter)) { - switch_hash_this(iter, &key, NULL, &value); - s = (session_elem_t*)value; - destroy_session_elem(s); - } - switch_thread_rwlock_unlock(listener->session_rwlock); - - if (listener->pool) { - switch_memory_pool_t *pool = listener->pool; - switch_core_destroy_memory_pool(&pool); - } + remove_listener(listener); + destroy_listener(listener); switch_mutex_lock(globals.listener_count_mutex); prefs.threads--; @@ -1158,43 +1179,46 @@ static int config(void) return 0; } - static listener_t *new_listener(struct ei_cnode_s *ec, int clientfd) { - switch_memory_pool_t *listener_pool = NULL; + switch_memory_pool_t *pool = NULL; listener_t *listener = NULL; - if (switch_core_new_memory_pool(&listener_pool) != SWITCH_STATUS_SUCCESS) { + if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n"); return NULL; } - if (!(listener = switch_core_alloc(listener_pool, sizeof(*listener)))) { + if (!(listener = switch_core_alloc(pool, sizeof(*listener)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n"); + switch_core_destroy_memory_pool(&pool); return NULL; } memset(listener, 0, sizeof(*listener)); - switch_thread_rwlock_create(&listener->rwlock, listener_pool); - switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, listener_pool); - switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, listener_pool); + switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, pool); + switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, pool); listener->sockfd = clientfd; - listener->pool = listener_pool; - listener_pool = NULL; + listener->pool = pool; listener->ec = switch_core_alloc(listener->pool, sizeof(ei_cnode)); memcpy(listener->ec, ec, sizeof(ei_cnode)); listener->level = SWITCH_LOG_DEBUG; switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool); switch_mutex_init(&listener->sock_mutex, SWITCH_MUTEX_NESTED, listener->pool); + + switch_thread_rwlock_create(&listener->rwlock, pool); + switch_thread_rwlock_create(&listener->event_rwlock, pool); switch_thread_rwlock_create(&listener->session_rwlock, listener->pool); + switch_core_hash_init(&listener->event_hash, listener->pool); switch_core_hash_init(&listener->sessions, listener->pool); return listener; } -static listener_t *new_outbound_listener(char *node) + +static listener_t *new_outbound_listener_locked(char *node) { listener_t *listener = NULL; struct ei_cnode_s ec; @@ -1208,27 +1232,69 @@ static listener_t *new_outbound_listener(char *node) #endif if ((clientfd = ei_connect(&ec, node)) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error connecting to node %s (erl_errno=%d, errno=%d)!\n", node, erl_errno, errno); + return NULL; } listener = new_listener(&ec, clientfd); listener->peer_nodename = switch_core_strdup(listener->pool, node); } + + switch_thread_rwlock_rdlock(listener->rwlock); + return listener; } +void destroy_listener(listener_t * listener) +{ + session_elem_t *s = NULL; + const void *key; + void *value; + switch_hash_index_t *iter; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session complete, waiting for children\n"); + switch_thread_rwlock_wrlock(listener->rwlock); + + switch_mutex_lock(listener->sock_mutex); + if (listener->sockfd) { + close_socket(&listener->sockfd); + } + switch_mutex_unlock(listener->sock_mutex); + + switch_core_hash_destroy(&listener->event_hash); + + /* remove any bindings for this connection */ + remove_binding(listener, NULL); + + /* clean up all the attached sessions */ + switch_thread_rwlock_wrlock(listener->session_rwlock); + for (iter = switch_hash_first(NULL, listener->sessions); iter; iter = switch_hash_next(iter)) { + switch_hash_this(iter, &key, NULL, &value); + s = (session_elem_t*)value; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Orphaning call %s\n", s->uuid_str); + destroy_session_elem(s); + } + switch_thread_rwlock_unlock(listener->session_rwlock); + switch_thread_rwlock_unlock(listener->rwlock); + + if (listener->pool) { + switch_memory_pool_t *pool = listener->pool; + switch_core_destroy_memory_pool(&pool); + } + +} + static switch_status_t state_handler(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_state_t state = switch_channel_get_state(channel); session_elem_t *session_element = switch_channel_get_private(channel, "_erlang_session_"); - /*listener_t* listener = switch_channel_get_private(channel, "_erlang_listener_"); */ if (session_element) { session_element->channel_state = state; if (state == CS_DESTROY) { /* indicate that once all the events in the event queue are done * we can throw this away */ - switch_set_flag(session_element, LFLAG_SESSION_COMPLETE); + switch_set_flag_locked(session_element, LFLAG_SESSION_COMPLETE); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to update channel state for %s to %s\n", switch_core_session_get_uuid(session), @@ -1268,10 +1334,12 @@ session_elem_t *session_elem_create(listener_t *listener, switch_core_session_t session_element->event_list[x] = 0; } + switch_thread_rwlock_create(&session_element->rwlock, session_element->pool); + switch_thread_rwlock_create(&session_element->event_rwlock, session_element->pool); + session_element->event_list[SWITCH_EVENT_ALL] = 1; /* defaults to everything */ switch_channel_set_private(channel, "_erlang_session_", session_element); - switch_channel_set_private(channel, "_erlang_listener_", listener); switch_core_event_hook_add_state_change(session, state_handler); @@ -1285,7 +1353,6 @@ session_elem_t *attach_call_to_registered_process(listener_t *listener, char *re session_element->process.type = ERLANG_REG_PROCESS; session_element->process.reg_name = switch_core_session_strdup(session, reg_name); - switch_set_flag(session_element, LFLAG_SESSION_ALIVE); /* attach the session to the listener */ add_session_elem_to_listener(listener, session_element); @@ -1299,9 +1366,9 @@ session_elem_t *attach_call_to_pid(listener_t *listener, erlang_pid * pid, switc session_element->process.type = ERLANG_PID; memcpy(&session_element->process.pid, pid, sizeof(erlang_pid)); - switch_set_flag(session_element, LFLAG_SESSION_ALIVE); /* attach the session to the listener */ add_session_elem_to_listener(listener, session_element); + /* TODO link before added to listener? */ ei_link(listener, ei_self(listener->ec), pid); return session_element; @@ -1312,30 +1379,27 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul /* create a session list element */ session_elem_t *session_element = session_elem_create(listener, session); char hash[100]; - //void *p = NULL; spawn_reply_t *p; erlang_ref ref; - switch_set_flag(session_element, LFLAG_WAITING_FOR_PID); - - /* attach the session to the listener */ - add_session_elem_to_listener(listener, session_element); ei_init_ref(listener->ec, &ref); ei_hash_ref(&ref, hash); - /* insert the waiting marker */ p = switch_core_alloc(session_element->pool, sizeof(*p)); switch_thread_cond_create(&p->ready_or_found, session_element->pool); switch_mutex_init(&p->mutex, SWITCH_MUTEX_UNNESTED, session_element->pool); - p->state = reply_not_ready; - p->hash = hash; + p->hash = switch_core_strdup(session_element->pool, hash); p->pid = NULL; session_element->spawn_reply = p; - switch_mutex_lock(p->mutex); - p->state = reply_waiting; + /* insert the waiting marker */ + switch_set_flag(session_element, LFLAG_WAITING_FOR_PID); + + /* attach the session to the listener */ + add_session_elem_to_listener(listener, session_element); + if (!strcmp(function, "!")) { /* send a message to request a pid */ @@ -1365,13 +1429,12 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul */ } - switch_thread_cond_timedwait(p->ready_or_found, - p->mutex, 5000000); + switch_thread_cond_timedwait(p->ready_or_found, p->mutex, 5000000); if (!p->pid) { - p->state = reply_timeout; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid %s %s\n", hash, session_element->uuid_str); - remove_session_elem_from_listener_locked(listener, session_element); - destroy_session_elem(session_element); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return NULL; } @@ -1381,14 +1444,10 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul memcpy(&session_element->process.pid, p->pid, sizeof(erlang_pid)); session_element->spawn_reply = NULL; - switch_set_flag(session_element, LFLAG_SESSION_ALIVE); - switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT); - switch_clear_flag(session_element, LFLAG_WAITING_FOR_PID); + switch_clear_flag_locked(session_element, LFLAG_WAITING_FOR_PID); ei_link(listener, ei_self(listener->ec), &session_element->process.pid); - switch_safe_free(p->pid); - return session_element; } @@ -1416,11 +1475,9 @@ SWITCH_STANDARD_APP(erlang_outbound_function) char *reg_name = NULL, *node, *module = NULL, *function = NULL; listener_t *listener; int argc = 0, argc2 = 0; - char *argv[80] = { 0 }, *argv2[80] = { - 0}; + char *argv[80] = { 0 }, *argv2[80] = { 0 }; char *mydata, *myarg; char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1]; - switch_bool_t new_session = SWITCH_FALSE; session_elem_t *session_element = NULL; /* process app arguments */ @@ -1466,17 +1523,15 @@ SWITCH_STANDARD_APP(erlang_outbound_function) /* if there is no listener, then create one */ if (!listener) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating new listener for session\n"); - new_session = SWITCH_TRUE; - listener = new_outbound_listener(node); + if ((listener = new_outbound_listener_locked(node))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Launching new listener\n"); + launch_listener_thread(listener); + } } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Using existing listener for session\n"); } if (listener) { - if (new_session == SWITCH_TRUE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Launching new listener\n"); - launch_listener_thread(listener); - } if (module && function) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating new spawned session for listener\n"); @@ -1486,21 +1541,16 @@ SWITCH_STANDARD_APP(erlang_outbound_function) session_element = attach_call_to_registered_process(listener, reg_name, session); } + switch_thread_rwlock_unlock(listener->rwlock); + if (session_element) { - switch_ivr_park(session, NULL); - - /* keep app thread running for lifetime of session */ - if (switch_channel_down(switch_core_session_get_channel(session))) { - if ((session_element = switch_channel_get_private(switch_core_session_get_channel(session), "_erlang_session_"))) { - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "outbound session all done\n"); - switch_clear_flag_locked(session_element, LFLAG_SESSION_ALIVE); - } else { - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "outbound session already done\n"); - } - } } + + } else { + switch_thread_rwlock_unlock(globals.listener_rwlock); } + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "exit erlang_outbound_function\n"); } @@ -1539,13 +1589,15 @@ SWITCH_STANDARD_APP(erlang_sendmsg_function) listener = find_listener(node); if (!listener) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating new listener for sendmsg %s\n", node); - listener = new_outbound_listener(node); + listener = new_outbound_listener_locked(node); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Using existing listener for sendmsg to %s\n", node); } if (listener) { ei_reg_send(listener->ec, listener->sockfd, reg_name, buf.buff, buf.index); + + switch_thread_rwlock_unlock(listener->rwlock); } } @@ -1560,7 +1612,12 @@ SWITCH_STANDARD_API(erlang_cmd) const char *usage_string = "USAGE:\n" "--------------------------------------------------------------------------------\n" - "erlang listeners\n" "erlang sessions \n" "--------------------------------------------------------------------------------\n"; + "erlang listeners\n" + "erlang sessions \n" + "erlang bindings\n" + "erlang handlers\n" + "erlang debug \n" + "--------------------------------------------------------------------------------\n"; if (zstr(cmd)) { stream->write_function(stream, "%s", usage_string); @@ -1614,11 +1671,11 @@ SWITCH_STANDARD_API(erlang_cmd) stream->write_function(stream, "Outbound session for %s in state %s\n", sp->uuid_str, switch_channel_state_name(sp->channel_state)); } + switch_thread_rwlock_unlock(l->session_rwlock); if (empty) { stream->write_function(stream, "No active sessions for %s\n", argv[1]); } - switch_thread_rwlock_unlock(l->session_rwlock); break; } } @@ -1627,9 +1684,85 @@ SWITCH_STANDARD_API(erlang_cmd) if (!found) stream->write_function(stream, "Could not find a listener for %s\n", argv[1]); + } else if (!strcasecmp(argv[0], "handlers")) { + listener_t *l; + + switch_thread_rwlock_rdlock(globals.listener_rwlock); + + if (listen_list.listeners) { + for (l = listen_list.listeners; l; l = l->next) { + int x; + switch_hash_index_t *iter; + const void *key; + void *val; + + stream->write_function(stream, "Listener %s:\n--------------------------------\n", l->peer_nodename); + + for (x = SWITCH_EVENT_CUSTOM + 1; x < SWITCH_EVENT_ALL; x++) { + if (l->event_list[x] == 1) { + stream->write_function(stream, "%s\n", switch_event_name(x)); + } + } + stream->write_function(stream, "CUSTOM:\n", switch_event_name(x)); + + for (iter = switch_hash_first(NULL, l->event_hash); iter; iter = switch_hash_next(iter)) { + switch_hash_this(iter, &key, NULL, &val); + stream->write_function(stream, "\t%s\n", (char *)key); + } + stream->write_function(stream, "\n", (char *)key); + } + } else { + stream->write_function(stream, "No active handlers\n"); + } + + switch_thread_rwlock_unlock(globals.listener_rwlock); + + } else if (!strcasecmp(argv[0], "bindings")) { + int found = 0; + struct erlang_binding *ptr; + switch_thread_rwlock_wrlock(globals.bindings_rwlock); + switch_xml_set_binding_sections(bindings.search_binding, SWITCH_XML_SECTION_MAX); + + for (ptr = bindings.head; ptr; ptr = ptr->next) { + + if (ptr->process.type == ERLANG_PID) { + stream->write_function(stream, "%s ", ptr->process.pid.node); + } + + if (ptr->section == SWITCH_XML_SECTION_CONFIG) { + stream->write_function(stream, "config\n"); + }else if (ptr->section == SWITCH_XML_SECTION_DIRECTORY) { + stream->write_function(stream, "directory\n"); + } else if (ptr->section == SWITCH_XML_SECTION_DIALPLAN) { + stream->write_function(stream, "dialplan\n"); + } else if (ptr->section == SWITCH_XML_SECTION_PHRASES) { + stream->write_function(stream, "phrases\n"); + } else if (ptr->section == SWITCH_XML_SECTION_CHATPLAN) { + stream->write_function(stream, "chatplan\n"); + } else { + stream->write_function(stream, "unknown %d\n", ptr->section); + } + found++; + } + + switch_thread_rwlock_unlock(globals.bindings_rwlock); + + if (!found) { + stream->write_function(stream, "No bindings\n"); + } + + } else if (!strcasecmp(argv[0], "debug")) { + if (argc == 2) { + if (!strcasecmp(argv[1], "on")) { + globals.debug = 1; + } else { + globals.debug = 0; + } + } + stream->write_function(stream, "+OK debug %s\n", globals.debug ? "on" : "off"); + } else { - stream->write_function(stream, "USAGE: erlang sessions \n" - " erlang listeners\n"); + stream->write_function(stream, usage_string); goto done; } @@ -1822,6 +1955,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_erlang_event_runtime) if ((clientfd = ei_accept_tmo(&ec, (int) listen_list.sockfd, &conn, 500)) == ERL_ERROR) { if (prefs.done) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n"); + break; } else if (erl_errno == ETIMEDOUT) { continue; #ifdef WIN32 @@ -1835,9 +1969,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_erlang_event_runtime) /* if errno didn't get set, assume nothing *too* horrible occured */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Ignorable error in ei_accept - probable bad client version, bad cookie or bad nodename\n"); - continue; } - break; + continue; } listener = new_listener(&ec, clientfd); 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 121e7b4f95..6730a64a3a 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -35,12 +35,12 @@ typedef enum { LFLAG_WAITING_FOR_PID = (1 << 0), /* waiting for a node to return a pid */ LFLAG_OUTBOUND_INIT = (1 << 1), /* Erlang peer has been notified of this session */ - LFLAG_SESSION_ALIVE = (1 << 2), - LFLAG_SESSION_COMPLETE = (1 << 3), + LFLAG_SESSION_COMPLETE = (1 << 2), } session_flag_t; typedef enum { - ERLANG_PID = 0, + NONE = 0, + ERLANG_PID, ERLANG_REG_PROCESS } process_type; @@ -71,7 +71,6 @@ struct spawn_reply_struct { switch_thread_cond_t *ready_or_found; switch_mutex_t *mutex; - enum reply_state state; erlang_pid *pid; char *hash; }; @@ -83,6 +82,8 @@ struct session_elem { uint32_t flags; struct erlang_process process; switch_queue_t *event_queue; + switch_thread_rwlock_t *rwlock; + switch_thread_rwlock_t *event_rwlock; switch_channel_state_t channel_state; switch_memory_pool_t *pool; uint8_t event_list[SWITCH_EVENT_ALL + 1]; @@ -129,6 +130,7 @@ struct listener { uint8_t event_list[SWITCH_EVENT_ALL + 1]; switch_hash_t *event_hash; switch_thread_rwlock_t *rwlock; + switch_thread_rwlock_t *event_rwlock; switch_thread_rwlock_t *session_rwlock; //session_elem_t *session_list; switch_hash_t *sessions; @@ -172,6 +174,7 @@ struct globals_struct { unsigned int reference2; char TIMEOUT; /* marker for a timed out request */ char WAITING; /* marker for a request waiting for a response */ + int debug; }; typedef struct globals_struct globals_t; 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 518583a25d..371ce62b3a 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 @@ -96,6 +96,7 @@ struct listener { switch_event_t *filters; time_t linger_timeout; struct listener *next; + switch_pollfd_t *pollfd; }; typedef struct listener listener_t; @@ -475,6 +476,8 @@ SWITCH_STANDARD_APP(socket_function) listener->session = session; switch_set_flag(listener, LFLAG_ALLOW_LOG); + switch_socket_create_pollset(&listener->pollfd, listener->sock, SWITCH_POLLIN | SWITCH_POLLERR, listener->pool); + switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool); switch_mutex_init(&listener->filter_mutex, SWITCH_MUTEX_NESTED, listener->pool); @@ -833,6 +836,7 @@ SWITCH_STANDARD_API(event_sink_function) switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool); switch_mutex_init(&listener->filter_mutex, SWITCH_MUTEX_NESTED, listener->pool); + switch_core_hash_init(&listener->event_hash, listener->pool); switch_set_flag(listener, LFLAG_AUTHED); switch_set_flag(listener, LFLAG_STATEFUL); @@ -1185,7 +1189,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, } count++; if (count == 1) { - switch_event_create(event, SWITCH_EVENT_SOCKET_DATA); + switch_event_create(event, SWITCH_EVENT_CLONE); switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Command", mbuf); } else if (cur) { char *var, *val; @@ -1354,31 +1358,26 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, if (channel && switch_channel_down(channel) && !switch_test_flag(listener, LFLAG_HANDLE_DISCO)) { switch_set_flag_locked(listener, LFLAG_HANDLE_DISCO); if (switch_test_flag(listener, LFLAG_LINGER)) { - char message[128] = ""; char disco_buf[512] = ""; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session), SWITCH_LOG_DEBUG, "%s Socket Linger %d\n", + switch_channel_get_name(channel), (int)listener->linger_timeout); + + switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n" + "Controlled-Session-UUID: %s\n" + "Content-Disposition: linger\n" + "Channel-Name: %s\n" + "Linger-Time: %d\n" + "Content-Length: 0\n\n", + switch_core_session_get_uuid(listener->session), switch_channel_get_name(channel), (int)listener->linger_timeout); + if (listener->linger_timeout != (time_t) -1) { listener->linger_timeout += switch_epoch_time_now(NULL); - switch_snprintf(message, sizeof(message), - "Channel %s has disconnected, lingering %d seconds by request from remote.\n", - switch_channel_get_name(channel), listener->linger_timeout); - } else { - switch_snprintf(message, sizeof(message), - "Channel %s has disconnected, lingering by request from remote.\n", - switch_channel_get_name(channel)); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s", message); - - mlen = strlen(message); - - switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n" - "Controlled-Session-UUID: %s\n" - "Content-Disposition: linger\n" "Content-Length: %d\n\n", switch_core_session_get_uuid(listener->session), (int) mlen); - + len = strlen(disco_buf); switch_socket_send(listener->sock, disco_buf, &len); - len = mlen; - switch_socket_send(listener->sock, message, &len); } else { status = SWITCH_STATUS_FALSE; break; @@ -1386,7 +1385,10 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, } if (do_sleep) { - switch_cond_next(); + int fdr = 0; + switch_poll(listener->pollfd, 1, &fdr, 20000); + } else { + switch_os_yield(); } } @@ -2099,6 +2101,10 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even if (!strncasecmp(cmd, "sendevent", 9)) { char *ename; const char *uuid = NULL; + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; + switch_uuid_str(uuid_str, sizeof(uuid_str)); + + switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-UUID", uuid_str); strip_cr(cmd); @@ -2126,6 +2132,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even if ((uuid = switch_event_get_header(*event, "unique-id"))) { switch_core_session_t *dsession; + if ((dsession = switch_core_session_locate(uuid))) { switch_core_session_queue_event(dsession, event); switch_core_session_rwunlock(dsession); @@ -2133,9 +2140,10 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even } if (*event) { + switch_event_prep_for_delivery(*event); switch_event_fire(event); } - switch_snprintf(reply, reply_len, "+OK"); + switch_snprintf(reply, reply_len, "+OK %s", uuid_str); goto done; } else if (!strncasecmp(cmd, "api ", 4)) { struct api_command_struct acs = { 0 }; @@ -2855,6 +2863,9 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime) switch_mutex_init(&listener->filter_mutex, SWITCH_MUTEX_NESTED, listener->pool); switch_core_hash_init(&listener->event_hash, listener->pool); + switch_socket_create_pollset(&listener->pollfd, listener->sock, SWITCH_POLLIN | SWITCH_POLLERR, listener->pool); + + if (switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock) == SWITCH_STATUS_SUCCESS && listener->sa) { switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa); diff --git a/src/mod/event_handlers/mod_json_cdr/Makefile b/src/mod/event_handlers/mod_json_cdr/Makefile index 0620c7df63..c9dfa5399e 100644 --- a/src/mod/event_handlers/mod_json_cdr/Makefile +++ b/src/mod/event_handlers/mod_json_cdr/Makefile @@ -1,27 +1,4 @@ -json-c=json-c-0.9 BASE=../../../.. - -JSON_DIR=$(switch_srcdir)/libs/$(json-c) -JSON_BUILDDIR=$(switch_builddir)/libs/$(json-c) - -JSONLA=$(JSON_BUILDDIR)/libjson.la - -LOCAL_CFLAGS=-I$(JSON_DIR) -LOCAL_LIBADD=$(JSONLA) - include $(BASE)/build/modmake.rules -$(JSON_DIR): - $(GETLIB) $(json-c).tar.gz - -$(JSON_BUILDDIR)/Makefile: $(JSON_DIR) - mkdir -p $(JSON_BUILDDIR) - cd $(JSON_BUILDDIR) && $(DEFAULT_VARS) $(JSON_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(JSON_DIR) CPPFLAGS= LDFLAGS= - $(TOUCH_TARGET) - -$(JSONLA): $(JSON_BUILDDIR)/Makefile - cd $(JSON_BUILDDIR) && $(MAKE) - $(TOUCH_TARGET) - - 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 92a51c65cb..7b1cf2a6a9 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 @@ -33,7 +33,6 @@ #include #include #include -#include #define MAX_URLS 20 #define MAX_ERR_DIRS 20 @@ -131,6 +130,7 @@ static switch_status_t set_json_cdr_log_dirs() if ((path = switch_safe_strdup(globals.base_log_dir))) { switch_thread_rwlock_wrlock(globals.log_path_lock); switch_safe_free(globals.log_dir); + switch_dir_make_recursive(path, SWITCH_DEFAULT_DIR_PERMS, globals.pool); globals.log_dir = path; switch_thread_rwlock_unlock(globals.log_path_lock); } else { @@ -169,6 +169,7 @@ static switch_status_t set_json_cdr_log_dirs() if ((path = switch_safe_strdup(globals.base_err_log_dir[err_dir_index]))) { switch_thread_rwlock_wrlock(globals.log_path_lock); switch_safe_free(globals.err_log_dir[err_dir_index]); + switch_dir_make_recursive(path, SWITCH_DEFAULT_DIR_PERMS, globals.pool); globals.err_log_dir[err_dir_index] = path; switch_thread_rwlock_unlock(globals.log_path_lock); } else { @@ -181,432 +182,11 @@ static switch_status_t set_json_cdr_log_dirs() return status; } -#define json_object_safe_new_string(str) json_object_new_string(str ? str : "") -#define JSON_ENSURE_SUCCESS(obj) if (is_error(obj)) { return; } -static void set_json_profile_data(struct json_object *json, switch_caller_profile_t *caller_profile) -{ - struct json_object *param = NULL; - - param = json_object_safe_new_string((char *)caller_profile->username); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "username", param); - - param = json_object_safe_new_string((char *)caller_profile->dialplan); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "dialplan", param); - - param = json_object_safe_new_string((char *)caller_profile->caller_id_name); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "caller_id_name", param); - - param = json_object_safe_new_string((char *)caller_profile->ani); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "ani", param); - - param = json_object_safe_new_string((char *)caller_profile->aniii); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "aniii", param); - - param = json_object_safe_new_string((char *)caller_profile->caller_id_number); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "caller_id_number", param); - - param = json_object_safe_new_string((char *)caller_profile->network_addr); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "network_addr", param); - - param = json_object_safe_new_string((char *)caller_profile->rdnis); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "rdnis", param); - - param = json_object_safe_new_string(caller_profile->destination_number); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "destination_number", param); - - param = json_object_safe_new_string(caller_profile->uuid); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "uuid", param); - - param = json_object_safe_new_string((char *)caller_profile->source); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "source", param); - - param = json_object_safe_new_string((char *)caller_profile->context); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "context", param); - - param = json_object_safe_new_string(caller_profile->chan_name); - JSON_ENSURE_SUCCESS(param); - json_object_object_add(json, "chan_name", param); - -} - -static void set_json_chan_vars(struct json_object *json, switch_channel_t *channel) -{ - struct json_object *variable = NULL; - switch_event_header_t *hi = switch_channel_variable_first(channel); - - if (!hi) - return; - - for (; hi; hi = hi->next) { - if (!zstr(hi->name) && !zstr(hi->value)) { - char *data = hi->value; - if (globals.encode_values == ENCODING_DEFAULT) { - switch_size_t dlen = strlen(hi->value) * 3; - - if ((data = malloc(dlen))) { - memset(data, 0, dlen); - switch_url_encode(hi->value, data, dlen); - } - } - - variable = json_object_safe_new_string(data); - if (!is_error(variable)) { - json_object_object_add(json, hi->name, variable); - } - - if (data != hi->value) { - switch_safe_free(data); - } - } - } - switch_channel_variable_last(channel); -} - - - -static switch_status_t generate_json_cdr(switch_core_session_t *session, struct json_object **json_cdr) -{ - - struct json_object *cdr = json_object_new_object(); - switch_channel_t *channel = switch_core_session_get_channel(session); - switch_caller_profile_t *caller_profile; - struct json_object *variables, *j_main_cp, *j_caller_profile, *j_caller_extension, *j_times, *time_tag, - *j_application, *j_callflow, *j_inner_extension, *j_apps, *j_o, *j_channel_data, *j_field; - switch_app_log_t *app_log; - char tmp[512], *f; - - if (is_error(cdr)) { - return SWITCH_STATUS_FALSE; - } - - j_channel_data = json_object_new_object(); - if (is_error(j_channel_data)) { - goto error; - } - json_object_object_add(cdr, "channel_data", j_channel_data); - - - j_field = json_object_safe_new_string((char *) switch_channel_state_name(switch_channel_get_state(channel))); - json_object_object_add(j_channel_data, "state", j_field); - - j_field = json_object_safe_new_string(switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"); - - json_object_object_add(j_channel_data, "direction", j_field); - - - switch_snprintf(tmp, sizeof(tmp), "%d", switch_channel_get_state(channel)); - j_field = json_object_new_string((char *) tmp); - json_object_object_add(j_channel_data, "state_number", j_field); - - - if ((f = switch_channel_get_flag_string(channel))) { - j_field = json_object_safe_new_string((char *) f); - json_object_object_add(j_channel_data, "flags", j_field); - free(f); - } - - if ((f = switch_channel_get_cap_string(channel))) { - j_field = json_object_safe_new_string((char *) f); - json_object_object_add(j_channel_data, "caps", j_field); - free(f); - } - - - variables = json_object_new_object(); - json_object_object_add(cdr, "variables", variables); - - if (is_error(variables)) { - goto error; - } - - set_json_chan_vars(variables, channel); - - - if ((app_log = switch_core_session_get_app_log(session))) { - switch_app_log_t *ap; - - j_apps = json_object_new_object(); - - if (is_error(j_apps)) { - goto error; - } - - json_object_object_add(cdr, "app_log", j_apps); - - for (ap = app_log; ap; ap = ap->next) { - j_application = json_object_new_object(); - - if (is_error(j_application)) { - goto error; - } - - json_object_object_add(j_application, "app_name", json_object_safe_new_string(ap->app)); - json_object_object_add(j_application, "app_data", json_object_safe_new_string(ap->arg)); - - json_object_object_add(j_apps, "application", j_application); - } - } - - - caller_profile = switch_channel_get_caller_profile(channel); - - while (caller_profile) { - - j_callflow = json_object_new_object(); - - if (is_error(j_callflow)) { - goto error; - } - - json_object_object_add(cdr, "callflow", j_callflow); - - if (!zstr(caller_profile->dialplan)) { - json_object_object_add(j_callflow, "dialplan", json_object_safe_new_string((char *)caller_profile->dialplan)); - } - - if (!zstr(caller_profile->profile_index)) { - json_object_object_add(j_callflow, "profile_index", json_object_safe_new_string((char *)caller_profile->profile_index)); - } - - if (caller_profile->caller_extension) { - switch_caller_application_t *ap; - - j_caller_extension = json_object_new_object(); - - if (is_error(j_caller_extension)) { - goto error; - } - - json_object_object_add(j_callflow, "extension", j_caller_extension); - - json_object_object_add(j_caller_extension, "name", json_object_safe_new_string(caller_profile->caller_extension->extension_name)); - json_object_object_add(j_caller_extension, "number", json_object_safe_new_string(caller_profile->caller_extension->extension_number)); - - if (caller_profile->caller_extension->current_application) { - json_object_object_add(j_caller_extension, "current_app", json_object_safe_new_string(caller_profile->caller_extension->current_application->application_name)); - } - - for (ap = caller_profile->caller_extension->applications; ap; ap = ap->next) { - j_application = json_object_new_object(); - - if (is_error(j_application)) { - goto error; - } - - - json_object_object_add(j_caller_extension, "application", j_application); - - if (ap == caller_profile->caller_extension->current_application) { - json_object_object_add(j_application, "last_executed", json_object_new_string("true")); - } - json_object_object_add(j_application, "app_name", json_object_safe_new_string(ap->application_name)); - json_object_object_add(j_application, "app_data", json_object_safe_new_string(switch_str_nil(ap->application_data))); - } - - if (caller_profile->caller_extension->children) { - switch_caller_profile_t *cp = NULL; - for (cp = caller_profile->caller_extension->children; cp; cp = cp->next) { - - if (!cp->caller_extension) { - continue; - } - - j_inner_extension = json_object_new_object(); - if (is_error(j_inner_extension)) { - goto error; - } - - json_object_object_add(j_caller_extension, "sub_extensions", j_inner_extension); - - - j_caller_extension = json_object_new_object(); - if (is_error(j_caller_extension)) { - goto error; - } - - json_object_object_add(j_inner_extension, "extension", j_caller_extension); - - json_object_object_add(j_caller_extension, "name", json_object_safe_new_string(cp->caller_extension->extension_name)); - json_object_object_add(j_caller_extension, "number", json_object_safe_new_string(cp->caller_extension->extension_number)); - - json_object_object_add(j_caller_extension, "dialplan", json_object_safe_new_string((char *)cp->dialplan)); - - if (cp->caller_extension->current_application) { - json_object_object_add(j_caller_extension, "current_app", json_object_safe_new_string(cp->caller_extension->current_application->application_name)); - } - - for (ap = cp->caller_extension->applications; ap; ap = ap->next) { - j_application = json_object_new_object(); - - if (is_error(j_application)) { - goto error; - } - json_object_object_add(j_caller_extension, "application", j_application); - - if (ap == cp->caller_extension->current_application) { - json_object_object_add(j_application, "last_executed", json_object_new_string("true")); - } - json_object_object_add(j_application, "app_name", json_object_safe_new_string(ap->application_name)); - json_object_object_add(j_application, "app_data", json_object_safe_new_string(switch_str_nil(ap->application_data))); - } - } - } - } - - j_main_cp = json_object_new_object(); - if (is_error(j_main_cp)) { - goto error; - } - - json_object_object_add(j_callflow, "caller_profile", j_main_cp); - - set_json_profile_data(j_main_cp, caller_profile); - - if (caller_profile->originator_caller_profile) { - switch_caller_profile_t *cp = NULL; - - j_o = json_object_new_object(); - if (is_error(j_o)) { - goto error; - } - - json_object_object_add(j_main_cp, "originator", j_o); - - for (cp = caller_profile->originator_caller_profile; cp; cp = cp->next) { - j_caller_profile = json_object_new_object(); - if (is_error(j_caller_profile)) { - goto error; - } - - json_object_object_add(j_o, "originator_caller_profile", j_caller_profile); - - set_json_profile_data(j_caller_profile, cp); - } - } - - if (caller_profile->originatee_caller_profile) { - switch_caller_profile_t *cp = NULL; - - j_o = json_object_new_object(); - if (is_error(j_o)) { - goto error; - } - - json_object_object_add(j_main_cp, "originatee", j_o); - - for (cp = caller_profile->originatee_caller_profile; cp; cp = cp->next) { - - j_caller_profile = json_object_new_object(); - if (is_error(j_caller_profile)) { - goto error; - } - - json_object_object_add(j_o, "originatee_caller_profile", j_caller_profile); - set_json_profile_data(j_caller_profile, cp); - } - } - - if (caller_profile->times) { - - j_times = json_object_new_object(); - if (is_error(j_times)) { - goto error; - } - - json_object_object_add(j_callflow, "times", j_times); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->created); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "created_time", time_tag); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "profile_created_time", time_tag); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->progress); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "progress_time", time_tag); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "progress_media_time", time_tag); - - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->answered); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "answered_time", time_tag); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "hangup_time", time_tag); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->resurrected); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "resurrect_time", time_tag); - - switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred); - time_tag = json_object_new_string(tmp); - if (is_error(time_tag)) { - goto error; - } - json_object_object_add(j_times, "transfer_time", time_tag); - - } - - caller_profile = caller_profile->next; - } - - *json_cdr = cdr; - - return SWITCH_STATUS_SUCCESS; - - error: - - if (cdr) { - json_object_put(cdr); - } - - return SWITCH_STATUS_FALSE; -} - static switch_status_t my_on_reporting(switch_core_session_t *session) { - struct json_object *json_cdr = NULL; - const char *json_text = NULL; + cJSON *json_cdr = NULL; + char *json_text = NULL; char *path = NULL; char *curl_json_text = NULL; const char *logdir = NULL; @@ -637,12 +217,12 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) a_prefix = "a_"; - if (generate_json_cdr(session, &json_cdr) != SWITCH_STATUS_SUCCESS) { + if (switch_ivr_generate_json_cdr(session, &json_cdr, globals.encode_values == ENCODING_DEFAULT) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Generating Data!\n"); return SWITCH_STATUS_FALSE; } - json_text = json_object_to_json_string(json_cdr); + json_text = cJSON_PrintUnformatted(json_cdr); if (!json_text) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); @@ -673,12 +253,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) } } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } switch_safe_free(path); } @@ -705,6 +281,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) switch_b64_encode((unsigned char *) json_text, need_bytes / 3, (unsigned char *) json_text_escaped, need_bytes); } + switch_safe_free(json_text); json_text = json_text_escaped; if (!(curl_json_text = switch_mprintf("cdr=%s", json_text))) { @@ -831,12 +408,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) break; } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } @@ -861,8 +434,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) switch_safe_free(curl_json_text); } - json_object_put(json_cdr); - switch_safe_free(json_text_escaped); + cJSON_Delete(json_cdr); + switch_safe_free(json_text); return status; } 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 9f3eaf1cb6..77a0438cca 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 @@ -213,7 +213,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) } */ - if ((signal_bond = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && !zstr(signal_bond)) { + if ((signal_bond = switch_channel_get_partner_uuid(channel)) && !zstr(signal_bond)) { if (rc_avpair_add(rad_config, &send, PW_FS_OTHER_LEG_ID, (void*) signal_bond, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Failed adding Freeswitch-Other-Leg-Id: %s\n", uuid_str); rc_destroy(rad_config); diff --git a/src/mod/event_handlers/mod_snmp/FREESWITCH-MIB b/src/mod/event_handlers/mod_snmp/FREESWITCH-MIB index 68d83fe433..3cf8b2718f 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-2011, Anthony Minessale II +-- Copyright (C) 2005-2012, Anthony Minessale II -- -- Version: MPL 1.1 -- diff --git a/src/mod/event_handlers/mod_snmp/subagent.h b/src/mod/event_handlers/mod_snmp/subagent.h index ba3c523d49..45519a844a 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 5cc7c08186..740d8a86cb 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -1161,33 +1161,25 @@ static int web_callback(void *pArg, int argc, char **argv, char **columnNames) char title_b4[128] = ""; char title_aft[128 * 3 + 1] = ""; char *mp3, *m3u; - - /* - 0 uuid VARCHAR(255), - 1 created VARCHAR(255), - 2 name VARCHAR(255), - 3 state VARCHAR(255), - 4 cid_name VARCHAR(255), - 5 cid_num VARCHAR(255), - 6 ip_addr VARCHAR(255), - 7 dest VARCHAR(255), - 8 application VARCHAR(255), - 9 application_data VARCHAR(255), - 10 read_codec VARCHAR(255), - 11 read_rate VARCHAR(255), - 12 write_codec VARCHAR(255), - 13 write_rate VARCHAR(255) - */ + const char *uuid = argv[0]; + const char *created = argv[1]; + const char *cid_name = argv[2]; + const char *cid_num = argv[3]; + const char *dest = argv[4]; + const char *application = argv[5] ? argv[5] : "N/A"; + const char *application_data = argv[6] ? argv[6] : "N/A"; + const char *read_codec = argv[7]; + const char *read_rate = argv[8]; holder->stream->write_function(holder->stream, "
      \n", m3u); @@ -1411,7 +1403,7 @@ void do_broadcast(switch_stream_handle_t *stream) void do_index(switch_stream_handle_t *stream) { switch_cache_db_handle_t *db; - const char *sql = "select * from channels"; + const char *sql = "select uuid, created, cid_name, cid_num, dest, application, application_data, read_codec, read_rate from channels"; struct holder holder; char *errmsg; diff --git a/src/mod/formats/mod_vlc/mod_vlc.c b/src/mod/formats/mod_vlc/mod_vlc.c index 98a40f77ad..592acb1ff0 100644 --- a/src/mod/formats/mod_vlc/mod_vlc.c +++ b/src/mod/formats/mod_vlc/mod_vlc.c @@ -29,10 +29,14 @@ * * Examples: * + * To playback from an audio source into a file: * File: vlc:///path/to/file * Stream: http://path.to.file.com:port/file.pls * Stream: vlc://ftp://path.to.file.com:port/file.mp3 * + * To stream from a call(channel) out to a remote destination: + * vlc://#transcode{acodec=vorb,channels=1,samplerate=16000}:standard{access=http,mux=ogg,dst=:8080/thing.ogg} + * * Notes: * * Requires at least libvlc version 1.2 @@ -42,15 +46,19 @@ #include #include -#define VLC_BUFFER_SIZE 4096 +#define VLC_BUFFER_SIZE 65536 static char *vlc_file_supported_formats[SWITCH_MAX_CODECS] = { 0 }; +typedef int (*imem_get_t)(void *data, const char *cookie, + int64_t *dts, int64_t *pts, unsigned *flags, + size_t *, void **); +typedef void (*imem_release_t)(void *data, const char *cookie, size_t, void *); + /* Change valud to -vvv for vlc related debug. Be careful since vlc is at least as verbose as FS about logging */ const char *vlc_args = ""; libvlc_instance_t *read_inst; -libvlc_instance_t *inst_out; struct vlc_file_context { libvlc_media_player_t *mp; @@ -63,8 +71,10 @@ struct vlc_file_context { char *path; int samples; int playing; + int samplerate; int err; int pts; + libvlc_instance_t *inst_out; }; typedef struct vlc_file_context vlc_file_context_t; @@ -74,6 +84,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vlc_load); SWITCH_MODULE_DEFINITION(mod_vlc, mod_vlc_load, mod_vlc_shutdown, NULL); void vlc_auto_play_callback(void *data, const void *samples, unsigned count, int64_t pts) { + vlc_file_context_t *context = (vlc_file_context_t *) data; switch_mutex_lock(context->audio_mutex); @@ -88,8 +99,47 @@ void vlc_auto_play_callback(void *data, const void *samples, unsigned count, int switch_thread_cond_signal(context->started); } switch_mutex_unlock(context->audio_mutex); +} - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC callback for %s %d \n", context->path, count); +int vlc_imem_get_callback(void *data, const char *cookie, int64_t *dts, int64_t *pts, unsigned *flags, size_t *size, void **output) +{ + vlc_file_context_t *context = (vlc_file_context_t *) data; + int samples = 0; + int bytes = 0; + + switch_mutex_lock(context->audio_mutex); + + /* If the stream should no longer be sending audio */ + /* then pretend we have less than one sample of audio */ + /* so that libvlc will close the client connections */ + if ( context->playing == 0 && switch_buffer_inuse(context->audio_buffer) == 0 ) { + switch_mutex_unlock(context->audio_mutex); + return 1; + } + + samples = context->samples; + context->samples = 0; + + if ( samples ) { + bytes = samples * 2; + *output = malloc(bytes); + bytes = switch_buffer_read(context->audio_buffer, *output, bytes); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC imem samples: %d\n", samples); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC imem bytes: %d\n", bytes); + } else { + bytes = 128; + *output = malloc(bytes); + memset(*output, 0, bytes); + } + switch_mutex_unlock(context->audio_mutex); + + *size = (size_t) bytes; + return 0; +} + +void vlc_imem_release_callback(void *data, const char *cookie, size_t size, void *unknown) +{ + free(unknown); } static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *path) @@ -100,7 +150,8 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p context->pool = handle->memory_pool; context->path = switch_core_strdup(context->pool, path); - switch_buffer_create_dynamic(&(context->audio_buffer), VLC_BUFFER_SIZE, VLC_BUFFER_SIZE * 2, 0); + + switch_buffer_create_dynamic(&(context->audio_buffer), VLC_BUFFER_SIZE, VLC_BUFFER_SIZE * 8, 0); switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->pool); switch_thread_cond_create(&(context->started), context->pool); @@ -123,6 +174,11 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p context->m = libvlc_media_new_location(read_inst, context->path); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "VLC Path is unknown type %s\n", context->path); } + + if ( context->m == NULL ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for reading\n", path); + return SWITCH_STATUS_GENERR; + } context->playing = 0; context->err = 0; @@ -131,16 +187,49 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p if ( !handle->samplerate) handle->samplerate = 16000; - libvlc_audio_set_format(context->mp, "S16N", handle->samplerate, 1); + + context->samplerate = handle->samplerate; + + libvlc_audio_set_format(context->mp, "S16N", context->samplerate, 1); libvlc_audio_set_callbacks(context->mp, vlc_auto_play_callback, NULL,NULL,NULL,NULL, (void *) context); libvlc_media_player_play(context->mp); } else if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC does not yet support writing to a output stream"); - return SWITCH_STATUS_GENERR; + const char * opts[10] = { + vlc_args, + switch_mprintf("--sout=%s", path) + }; + int opts_count = 10; + + if ( !handle->samplerate) + handle->samplerate = 16000; + + context->samplerate = handle->samplerate; + opts[2] = switch_mprintf("--imem-get=%ld", vlc_imem_get_callback); + opts[3] = switch_mprintf("--imem-release=%ld", vlc_imem_release_callback); + opts[4] = switch_mprintf("--imem-cat=%d", 4); + opts[5] = "--demux=rawaud"; + opts[6] = "--rawaud-fourcc=s16l"; + opts[7] = switch_mprintf("--rawaud-samplerate=%d", context->samplerate); + opts[8] = switch_mprintf("--imem-data=%ld", context); + opts[9] = "--rawaud-channels=1"; + + /* Prepare to write to an output stream. */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC open %s for writing\n", path); + + /* load the vlc engine. */ + context->inst_out = libvlc_new(opts_count, opts); + + /* Tell VLC the audio will come from memory, and to use the callbacks to fetch it. */ + context->m = libvlc_media_new_location(context->inst_out, "imem/rawaud://"); + context->mp = libvlc_media_player_new_from_media(context->m); + context->samples = 0; + context->pts = 0; + context->playing = 1; + libvlc_media_player_play(context->mp); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC tried to open %s for unknown reason\n", path); return SWITCH_STATUS_GENERR; @@ -196,21 +285,46 @@ static switch_status_t vlc_file_read(switch_file_handle_t *handle, void *data, s return SWITCH_STATUS_SUCCESS; } +static switch_status_t vlc_file_write(switch_file_handle_t *handle, void *data, size_t *len) +{ + vlc_file_context_t *context = handle->private_info; + size_t bytes = *len * sizeof(int16_t); + + switch_mutex_lock(context->audio_mutex); + context->samples += *len; + switch_buffer_write(context->audio_buffer, data, bytes); + switch_mutex_unlock(context->audio_mutex); + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t vlc_file_close(switch_file_handle_t *handle) { vlc_file_context_t *context = handle->private_info; - - libvlc_media_player_stop(context->mp); - libvlc_media_release(context->m); - + context->playing = 0; + /* The clients need to empty the last of the audio buffer */ + while ( switch_buffer_inuse(context->audio_buffer) > 0 ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC waiting to close the files: %d \n", (int) switch_buffer_inuse(context->audio_buffer)); + sleep(1); + } + + /* Let the clients get the last of the audio stream */ + while ( 3 == libvlc_media_get_state(context->m) ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC waiting for clients: %d \n", libvlc_media_get_state(context->m)); + sleep(1); + } + if( context->mp ) libvlc_media_player_stop(context->mp); if( context->m ) libvlc_media_release(context->m); + if ( context->inst_out != NULL ) + libvlc_release(context->inst_out); + return SWITCH_STATUS_SUCCESS; } @@ -230,6 +344,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vlc_load) file_interface->file_open = vlc_file_open; file_interface->file_close = vlc_file_close; file_interface->file_read = vlc_file_read; + file_interface->file_write = vlc_file_write; /* load the vlc engine. */ read_inst = libvlc_new(1, &vlc_args); @@ -247,8 +362,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_vlc_shutdown) { if ( read_inst != NULL ) libvlc_release(read_inst); - if ( inst_out != NULL ) - libvlc_release(inst_out); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java index 4fecb81e00..07c051c074 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/EventConsumer.java @@ -91,8 +91,8 @@ public class EventConsumer { return new SWIGTYPE_p_uint32_t(freeswitchJNI.EventConsumer_node_index_get(swigCPtr, this), true); } - public EventConsumer(String event_name, String subclass_name) { - this(freeswitchJNI.new_EventConsumer(event_name, subclass_name), true); + public EventConsumer(String event_name, String subclass_name, int len) { + this(freeswitchJNI.new_EventConsumer(event_name, subclass_name, len), true); } public int bind(String event_name, String subclass_name) { diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java index b574831098..40f856cb41 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java @@ -81,7 +81,7 @@ class freeswitchJNI { public final static native long EventConsumer_enodes_get(long jarg1, EventConsumer jarg1_); public final static native void EventConsumer_node_index_set(long jarg1, EventConsumer jarg1_, long jarg2); public final static native long EventConsumer_node_index_get(long jarg1, EventConsumer jarg1_); - public final static native long new_EventConsumer(String jarg1, String jarg2); + public final static native long new_EventConsumer(String jarg1, String jarg2, int jarg3); public final static native void delete_EventConsumer(long jarg1); public final static native int EventConsumer_bind(long jarg1, EventConsumer jarg1_, String jarg2, String jarg3); public final static native long EventConsumer_pop(long jarg1, EventConsumer jarg1_, int jarg2, int jarg3); diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index c34420ea96..93499b61ab 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -1587,10 +1587,11 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1n } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1EventConsumer(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1EventConsumer(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jint jarg3) { jlong jresult = 0 ; char *arg1 = (char *) NULL ; char *arg2 = (char *) "" ; + int arg3 = (int) 5000 ; EventConsumer *result = 0 ; (void)jenv; @@ -1605,7 +1606,8 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1EventConsum arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); if (!arg2) return 0; } - result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2); + arg3 = (int)jarg3; + result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3); *(EventConsumer **)&jresult = result; if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2); diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp index 4886ae567e..0df0d8f11d 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-2011, Anthony Minessale II + * Copyright (C) 2005-2012, Anthony Minessale II * * Version: MPL 1.1 * @@ -260,7 +260,7 @@ static switch_xml_t lua_fetch(const char *section, mod_lua_conjure_event(L, params, "params", 1); } - if( error = lua_parse_and_execute(L, mycmd) ){ + if((error = lua_parse_and_execute(L, mycmd))){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n"); return NULL; } @@ -331,7 +331,7 @@ static switch_status_t do_config(void) if (cpath_stream.data_len) { char *lua_cpath = NULL; - if (lua_cpath = getenv("LUA_CPATH")) { + if ((lua_cpath = getenv("LUA_CPATH"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "lua: appending LUA_CPATH: '%s'\n", lua_cpath); cpath_stream.write_function(&cpath_stream, ";%s", lua_cpath); } @@ -349,7 +349,7 @@ static switch_status_t do_config(void) if (path_stream.data_len) { char *lua_path = NULL; - if (lua_path = getenv("LUA_PATH")) { + if ((lua_path = getenv("LUA_PATH"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "lua: appending LUA_PATH: '%s'\n", lua_path); path_stream.write_function(&path_stream, ";%s", lua_path); } diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index 3019c81083..679b852a81 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -3705,18 +3705,23 @@ static int _wrap_new_EventConsumer(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) NULL ; char *arg2 = (char *) "" ; + int arg3 = (int) 5000 ; EventConsumer *result = 0 ; - SWIG_check_num_args("EventConsumer",0,2) + SWIG_check_num_args("EventConsumer",0,3) if(lua_gettop(L)>=1 && !lua_isstring(L,1)) SWIG_fail_arg("EventConsumer",1,"char const *"); if(lua_gettop(L)>=2 && !lua_isstring(L,2)) SWIG_fail_arg("EventConsumer",2,"char const *"); + if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("EventConsumer",3,"int"); if(lua_gettop(L)>=1){ arg1 = (char *)lua_tostring(L, 1); } if(lua_gettop(L)>=2){ arg2 = (char *)lua_tostring(L, 2); } - result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2); + if(lua_gettop(L)>=3){ + arg3 = (int)lua_tonumber(L, 3); + } + result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3); SWIG_arg=0; SWIG_NewPointerObj(L,result,SWIGTYPE_p_EventConsumer,1); SWIG_arg++; return SWIG_arg; diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx index 27cc9fb600..c04fa86d95 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx @@ -1050,6 +1050,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_READ_RESULT_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ATT_XFER_RESULT_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("att_xfer_result"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1060,6 +1070,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_JSON_CDR_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("copy_json_cdr"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1150,6 +1170,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABL } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("execute_on_post_originate"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1210,6 +1240,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_ge } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("api_on_post_originate"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1400,6 +1440,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROXY_MEDIA_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ZRTP_PASSTHRU_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("zrtp_passthru"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1520,6 +1570,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SIGNAL_BOND_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("originate_signal_bond"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATOR_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -2800,6 +2860,34 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_packet_count_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_period_packet_count_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)->period_packet_count = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_period_packet_count_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)->period_packet_count); + jresult = new switch_size_t((const switch_size_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_media_packet_count_set(void * jarg1, void * jarg2) { switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; switch_size_t arg2 ; @@ -3058,6 +3146,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtcp_numbers_t_octet_count_ge } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_peer_ssrc_set(void * jarg1, unsigned long jarg2) { + switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_rtcp_numbers_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->peer_ssrc = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtcp_numbers_t_peer_ssrc_get(void * jarg1) { + unsigned long jresult ; + switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ; + uint32_t result; + + arg1 = (switch_rtcp_numbers_t *)jarg1; + result = (uint32_t) ((arg1)->peer_ssrc); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtcp_numbers_t() { void * jresult ; switch_rtcp_numbers_t *result = 0 ; @@ -3142,6 +3252,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_stats_t_rtcp_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_read_count_set(void * jarg1, unsigned long jarg2) { + switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_rtp_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->read_count = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtp_stats_t_read_count_get(void * jarg1) { + unsigned long jresult ; + switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_rtp_stats_t *)jarg1; + result = (uint32_t) ((arg1)->read_count); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtp_stats_t() { void * jresult ; switch_rtp_stats_t *result = 0 ; @@ -6425,6 +6557,54 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_disable_heartbeat(void * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_pop(void * jarg1, char * jarg2, void * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_media_bug_t **arg3 = (switch_media_bug_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_media_bug_t **)jarg3; + result = (switch_status_t)switch_core_media_bug_pop(arg1,(char const *)arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_exec_all(void * jarg1, char * jarg2, void * jarg3, void * jarg4) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_media_bug_exec_cb_t arg3 = (switch_media_bug_exec_cb_t) 0 ; + void *arg4 = (void *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_media_bug_exec_cb_t)jarg3; + arg4 = (void *)jarg4; + result = (switch_status_t)switch_core_media_bug_exec_all(arg1,(char const *)arg2,arg3,arg4); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_media_bug_count(void * jarg1, char * jarg2) { + unsigned long jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + uint32_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + result = (uint32_t)switch_core_media_bug_count(arg1,(char const *)arg2); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_add(void * jarg1, char * jarg2, char * jarg3, void * jarg4, void * jarg5, void * jarg6, unsigned long jarg7, void * jarg8) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -6531,6 +6711,16 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_read_replace_fram } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_media_bug_set_read_demux_frame(void * jarg1, void * jarg2) { + switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ; + switch_frame_t *arg2 = (switch_frame_t *) 0 ; + + arg1 = (switch_media_bug_t *)jarg1; + arg2 = (switch_frame_t *)jarg2; + switch_core_media_bug_set_read_demux_frame(arg1,arg2); +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_session(void * jarg1) { void * jresult ; switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ; @@ -6657,13 +6847,15 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_close(void * jarg1) { } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_remove_all(void * jarg1) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_remove_all_function(void * jarg1, char * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; - result = (switch_status_t)switch_core_media_bug_remove_all(arg1); + arg2 = (char *)jarg2; + result = (switch_status_t)switch_core_media_bug_remove_all_function(arg1,(char const *)arg2); jresult = result; return jresult; } @@ -6801,6 +6993,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_port_allocator_destroy(void * jar } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_test_flag(int jarg1) { + int jresult ; + int arg1 ; + int result; + + arg1 = (int)jarg1; + result = (int)switch_core_test_flag(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_init(unsigned long jarg1, int jarg2, void * jarg3) { int jresult ; switch_core_flag_t arg1 ; @@ -7415,6 +7619,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_thread_launch(void * jarg1 } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_thread_pool_launch(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_thread_pool_launch(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_channel(void * jarg1) { void * jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -7575,25 +7791,37 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_uuid() { } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_locate(char * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_perform_locate(char * jarg1, char * jarg2, char * jarg3, int jarg4) { void * jresult ; char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; switch_core_session_t *result = 0 ; arg1 = (char *)jarg1; - result = (switch_core_session_t *)switch_core_session_locate((char const *)arg1); + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (int)jarg4; + result = (switch_core_session_t *)switch_core_session_perform_locate((char const *)arg1,(char const *)arg2,(char const *)arg3,arg4); jresult = (void *)result; return jresult; } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_force_locate(char * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_perform_force_locate(char * jarg1, char * jarg2, char * jarg3, int jarg4) { void * jresult ; char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; switch_core_session_t *result = 0 ; arg1 = (char *)jarg1; - result = (switch_core_session_t *)switch_core_session_force_locate((char const *)arg1); + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (int)jarg4; + result = (switch_core_session_t *)switch_core_session_perform_force_locate((char const *)arg1,(char const *)arg2,(char const *)arg3,arg4); jresult = (void *)result; return jresult; } @@ -7721,15 +7949,21 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_hupall_endpoint(void * ja } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_partner(void * jarg1, void * jarg2) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_perform_get_partner(void * jarg1, void * jarg2, char * jarg3, char * jarg4, int jarg5) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (switch_core_session_t **)jarg2; - result = (switch_status_t)switch_core_session_get_partner(arg1,arg2); + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (int)jarg5; + result = (switch_status_t)switch_core_session_perform_get_partner(arg1,arg2,(char const *)arg3,(char const *)arg4,arg5); jresult = result; return jresult; } @@ -8099,24 +8333,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_outgoing_channel(void * ja } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_resurrect_channel(char * jarg1, void * jarg2, void * jarg3, void * jarg4) { - int jresult ; - char *arg1 = (char *) 0 ; - switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; - switch_memory_pool_t **arg3 = (switch_memory_pool_t **) 0 ; - void *arg4 = (void *) 0 ; - switch_call_cause_t result; - - arg1 = (char *)jarg1; - arg2 = (switch_core_session_t **)jarg2; - arg3 = (switch_memory_pool_t **)jarg3; - arg4 = (void *)jarg4; - result = (switch_call_cause_t)switch_core_session_resurrect_channel((char const *)arg1,arg2,arg3,arg4); - jresult = result; - return jresult; -} - - SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_perform_receive_message(void * jarg1, void * jarg2, char * jarg3, char * jarg4, int jarg5) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -8996,6 +9212,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_read_impl(void * jarg1 } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_real_read_impl(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_codec_implementation_t *arg2 = (switch_codec_implementation_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_codec_implementation_t *)jarg2; + result = (switch_status_t)switch_core_session_get_real_read_impl(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_write_impl(void * jarg1, void * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -9270,6 +9500,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_file_write(void * jarg1, void * ja } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_file_write_video(void * jarg1, void * jarg2, void * jarg3) { + int jresult ; + switch_file_handle_t *arg1 = (switch_file_handle_t *) 0 ; + void *arg2 = (void *) 0 ; + switch_size_t *arg3 = (switch_size_t *) 0 ; + switch_status_t result; + + arg1 = (switch_file_handle_t *)jarg1; + arg2 = (void *)jarg2; + arg3 = (switch_size_t *)jarg3; + result = (switch_status_t)switch_core_file_write_video(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_file_seek(void * jarg1, void * jarg2, long long jarg3, int jarg4) { int jresult ; switch_file_handle_t *arg1 = (switch_file_handle_t *) 0 ; @@ -10091,6 +10337,16 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_micro_time_now() { } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_mono_micro_time_now() { + void * jresult ; + switch_time_t result; + + result = switch_mono_micro_time_now(); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_memory_reclaim() { switch_core_memory_reclaim(); } @@ -10143,6 +10399,18 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_epoch_time_now(void * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_lookup_timezone(char * jarg1) { + char * jresult ; + char *arg1 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + result = (char *)switch_lookup_timezone((char const *)arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_strftime_tz(char * jarg1, char * jarg2, char * jarg3, unsigned long jarg4, void * jarg5) { int jresult ; char *arg1 = (char *) 0 ; @@ -10255,6 +10523,14 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_cond_yield(int jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_use_system_time(int jarg1) { + switch_bool_t arg1 ; + + arg1 = (switch_bool_t)jarg1; + switch_time_set_use_system_time(arg1); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_min_dtmf_duration(unsigned long jarg1) { unsigned long jresult ; uint32_t arg1 ; @@ -10384,7 +10660,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cond_next() { } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8, int jarg9) { int jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -10394,6 +10670,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char char *arg6 = (char *) 0 ; char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; + switch_bool_t arg9 ; switch_status_t result; arg1 = (char *)jarg1; @@ -10404,7 +10681,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char arg6 = (char *)jarg6; arg7 = (char *)jarg7; arg8 = (char *)jarg8; - result = (switch_status_t)switch_core_chat_send_args((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + arg9 = (switch_bool_t)jarg9; + result = (switch_status_t)switch_core_chat_send_args((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8,arg9); jresult = result; return jresult; } @@ -10452,6 +10730,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_preprocess_session(void * jarg1, ch } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_stop_thread() { + switch_core_sqldb_stop_thread(); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_start_thread() { + switch_core_sqldb_start_thread(); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_CACHE_DB_LEN_get() { int jresult ; int result; @@ -10898,6 +11186,24 @@ SWIGEXPORT int SWIGSTDCALL CSharp__switch_core_db_handle(void * jarg1, char * ja } +SWIGEXPORT int SWIGSTDCALL CSharp__switch_core_recovery_db_handle(void * jarg1, char * jarg2, char * jarg3, int jarg4) { + int jresult ; + switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + switch_status_t result; + + arg1 = (switch_cache_db_handle_t **)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (int)jarg4; + result = (switch_status_t)_switch_core_recovery_db_handle(arg1,(char const *)arg2,(char const *)arg3,arg4); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_test_reactive(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { int jresult ; switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; @@ -11004,7 +11310,7 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_default_ptime(char * jarg1, u } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8, char * jarg9) { int jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -11014,6 +11320,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, cha char *arg6 = (char *) 0 ; char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; + char *arg9 = (char *) 0 ; switch_status_t result; arg1 = (char *)jarg1; @@ -11024,7 +11331,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, cha arg6 = (char *)jarg6; arg7 = (char *)jarg7; arg8 = (char *)jarg8; - result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + arg9 = (char *)jarg9; + result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8,(char const *)arg9); jresult = result; return jresult; } @@ -11151,6 +11459,79 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_close_extra_files(void * jarg1, int ja } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_thread_set_cpu_affinity(int jarg1) { + int jresult ; + int arg1 ; + switch_status_t result; + + arg1 = (int)jarg1; + result = (switch_status_t)switch_core_thread_set_cpu_affinity(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_os_yield() { + switch_os_yield(); +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_get_stacksizes(void * jarg1, void * jarg2) { + int jresult ; + switch_size_t *arg1 = (switch_size_t *) 0 ; + switch_size_t *arg2 = (switch_size_t *) 0 ; + switch_status_t result; + + arg1 = (switch_size_t *)jarg1; + arg2 = (switch_size_t *)jarg2; + result = (switch_status_t)switch_core_get_stacksizes(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_recovery_recover(char * jarg1, char * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + result = (int)switch_core_recovery_recover((char const *)arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_untrack(void * jarg1, int jarg2) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_bool_t arg2 ; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + switch_core_recovery_untrack(arg1,arg2); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_track(void * jarg1) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + + arg1 = (switch_core_session_t *)jarg1; + switch_core_recovery_track(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_flush(char * jarg1, char * jarg2) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + switch_core_recovery_flush((char const *)arg1,(char const *)arg2); +} + + 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 ; @@ -11635,6 +12016,24 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_codec_interface( } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_parse_codec_buf(char * jarg1, void * jarg2, void * jarg3, void * jarg4) { + char * jresult ; + char *arg1 = (char *) 0 ; + uint32_t *arg2 = (uint32_t *) 0 ; + uint32_t *arg3 = (uint32_t *) 0 ; + uint32_t *arg4 = (uint32_t *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (uint32_t *)jarg2; + arg3 = (uint32_t *)jarg3; + arg4 = (uint32_t *)jarg4; + result = (char *)switch_parse_codec_buf(arg1,arg2,arg3,arg4); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_dialplan_interface(char * jarg1) { void * jresult ; char *arg1 = (char *) 0 ; @@ -13825,6 +14224,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_atoul(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strerror_r(int jarg1, char * jarg2, void * jarg3) { + char * jresult ; + int arg1 ; + char *arg2 = (char *) 0 ; + switch_size_t arg3 ; + switch_size_t *argp3 ; + char *result = 0 ; + + arg1 = (int)jarg1; + arg2 = (char *)jarg2; + argp3 = (switch_size_t *)jarg3; + if (!argp3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return 0; + } + arg3 = *argp3; + result = (char *)switch_strerror_r(arg1,arg2,arg3); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_var_set(void * jarg1, char * jarg2) { profile_node_t *arg1 = (profile_node_t *) 0 ; char *arg2 = (char *) 0 ; @@ -16572,28 +16993,6 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_routines_state_run_get(void * jar } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_resurrect_session_set(void * jarg1, void * jarg2) { - switch_io_routines *arg1 = (switch_io_routines *) 0 ; - switch_io_resurrect_session_t arg2 = (switch_io_resurrect_session_t) 0 ; - - arg1 = (switch_io_routines *)jarg1; - arg2 = (switch_io_resurrect_session_t)jarg2; - if (arg1) (arg1)->resurrect_session = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_routines_resurrect_session_get(void * jarg1) { - void * jresult ; - switch_io_routines *arg1 = (switch_io_routines *) 0 ; - switch_io_resurrect_session_t result; - - arg1 = (switch_io_routines *)jarg1; - result = (switch_io_resurrect_session_t) ((arg1)->resurrect_session); - jresult = (void *)result; - return jresult; -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_padding_set(void * jarg1, void * jarg2) { switch_io_routines *arg1 = (switch_io_routines *) 0 ; void **arg2 ; @@ -16843,6 +17242,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_endpoint_interface_next_get(void * j } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_recover_callback_set(void * jarg1, void * jarg2) { + switch_endpoint_interface *arg1 = (switch_endpoint_interface *) 0 ; + switch_core_recover_callback_t arg2 = (switch_core_recover_callback_t) 0 ; + + arg1 = (switch_endpoint_interface *)jarg1; + arg2 = (switch_core_recover_callback_t)jarg2; + if (arg1) (arg1)->recover_callback = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_endpoint_interface_recover_callback_get(void * jarg1) { + void * jresult ; + switch_endpoint_interface *arg1 = (switch_endpoint_interface *) 0 ; + switch_core_recover_callback_t result; + + arg1 = (switch_endpoint_interface *)jarg1; + result = (switch_core_recover_callback_t) ((arg1)->recover_callback); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_endpoint_interface() { void * jresult ; switch_endpoint_interface *result = 0 ; @@ -17696,6 +18117,50 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_interface_file_write_get(void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_read_video_set(void * jarg1, void * jarg2) { + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*arg2)(switch_file_handle_t *,void *,switch_size_t *) = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) 0 ; + + 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; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_interface_file_read_video_get(void * jarg1) { + void * jresult ; + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*result)(switch_file_handle_t *,void *,switch_size_t *) = 0 ; + + arg1 = (switch_file_interface *)jarg1; + result = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) ((arg1)->file_read_video); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_write_video_set(void * jarg1, void * jarg2) { + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*arg2)(switch_file_handle_t *,void *,switch_size_t *) = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) 0 ; + + 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; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_interface_file_write_video_get(void * jarg1) { + void * jresult ; + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*result)(switch_file_handle_t *,void *,switch_size_t *) = 0 ; + + arg1 = (switch_file_interface *)jarg1; + result = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) ((arg1)->file_write_video); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_seek_set(void * jarg1, void * jarg2) { switch_file_interface *arg1 = (switch_file_interface *) 0 ; switch_status_t (*arg2)(switch_file_handle_t *,unsigned int *,int64_t,int) = (switch_status_t (*)(switch_file_handle_t *,unsigned int *,int64_t,int)) 0 ; @@ -25633,6 +26098,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_transfer_to_extension(void * j } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_channel_get_partner_uuid(void * jarg1) { + char * jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + char *result = 0 ; + + arg1 = (switch_channel_t *)jarg1; + result = (char *)switch_channel_get_partner_uuid(arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg2, void * jarg3) { int jresult ; switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ; @@ -27013,6 +27490,26 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_check_permission_list(void * jarg } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_add_presence_data_cols(void * jarg1, void * jarg2, char * jarg3) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_event_t *arg2 = (switch_event_t *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_channel_t *)jarg1; + arg2 = (switch_event_t *)jarg2; + arg3 = (char *)jarg3; + switch_event_add_presence_data_cols(arg1,arg2,(char const *)arg3); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_launch_dispatch_threads(unsigned long jarg1) { + uint32_t arg1 ; + + arg1 = (uint32_t)jarg1; + switch_event_launch_dispatch_threads(arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RESAMPLE_QUALITY_get() { int jresult ; int result; @@ -27403,6 +27900,24 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_merge_sln(void * jarg1, unsig } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_unmerge_sln(void * jarg1, unsigned long jarg2, void * jarg3, unsigned long jarg4) { + unsigned long jresult ; + int16_t *arg1 = (int16_t *) 0 ; + uint32_t arg2 ; + int16_t *arg3 = (int16_t *) 0 ; + uint32_t arg4 ; + uint32_t result; + + arg1 = (int16_t *)jarg1; + arg2 = (uint32_t)jarg2; + arg3 = (int16_t *)jarg3; + arg4 = (uint32_t)jarg4; + result = (uint32_t)switch_unmerge_sln(arg1,arg2,arg3,arg4); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_mux_channels(void * jarg1, void * jarg2, unsigned long jarg3) { int16_t *arg1 = (int16_t *) 0 ; switch_size_t arg2 ; @@ -27847,6 +28362,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_activate_unicast(void * jarg1, char } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_generate_json_cdr(void * jarg1, void * jarg2, int jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + switch_bool_t arg3 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (cJSON **)jarg2; + arg3 = (switch_bool_t)jarg3; + result = (switch_status_t)switch_ivr_generate_json_cdr(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_generate_xml_cdr(void * jarg1, void * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -28257,6 +28788,52 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_record_session(void * jarg1, char * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_pop_eavesdropper(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_core_session_t **)jarg2; + result = (switch_status_t)switch_ivr_eavesdrop_pop_eavesdropper(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_exec_all(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_ivr_eavesdrop_exec_all(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_update_display(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_ivr_eavesdrop_update_display(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_session(void * jarg1, char * jarg2, char * jarg3, unsigned long jarg4) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -29969,6 +30546,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_kill_uuid(char * jarg1, int jarg2) } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_blind_transfer_ack(void * jarg1, int jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_bool_t arg2 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + result = (switch_status_t)switch_ivr_blind_transfer_ack(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; @@ -30506,17 +31097,37 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_destroy(void * jarg1) { } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_ice(void * jarg1, char * jarg2, char * jarg3) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_ice(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { int jresult ; switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; switch_status_t result; arg1 = (switch_rtp_t *)jarg1; arg2 = (char *)jarg2; arg3 = (char *)jarg3; - result = (switch_status_t)switch_rtp_activate_ice(arg1,arg2,arg3); + arg4 = (char *)jarg4; + result = (switch_status_t)switch_rtp_activate_ice(arg1,arg2,arg3,(char const *)arg4); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_rtcp_ice(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (switch_status_t)switch_rtp_activate_rtcp_ice(arg1,arg2,arg3,(char const *)arg4); jresult = result; return jresult; } @@ -30646,6 +31257,14 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_get_rtp_socket(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_ping(void * jarg1) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + + arg1 = (switch_rtp_t *)jarg1; + switch_rtp_ping(arg1); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtp_get_default_samples_per_interval(void * jarg1) { unsigned long jresult ; switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; @@ -31026,6 +31645,16 @@ SWIGEXPORT unsigned char SWIGSTDCALL CSharp_switch_rtp_check_auto_adj(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_interdigit_delay(void * jarg1, unsigned long jarg2) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (uint32_t)jarg2; + switch_rtp_set_interdigit_delay(arg1,arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_data_set(void * jarg1, char * jarg2) { switch_log_node_t *arg1 = (switch_log_node_t *) 0 ; char *arg2 = (char *) 0 ; @@ -33266,68 +33895,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_state_run(void * } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_resurrect_session_set(void * jarg1, void * jarg2) { - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - arg2 = (switch_resurrect_session_hook_t)jarg2; - if (arg1) (arg1)->resurrect_session = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_resurrect_session_get(void * jarg1) { - void * jresult ; - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_resurrect_session_hook_t result; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - result = (switch_resurrect_session_hook_t) ((arg1)->resurrect_session); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_next_set(void * jarg1, void * jarg2) { - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_io_event_hook_resurrect_session *arg2 = (switch_io_event_hook_resurrect_session *) 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - arg2 = (switch_io_event_hook_resurrect_session *)jarg2; - if (arg1) (arg1)->next = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_next_get(void * jarg1) { - void * jresult ; - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_io_event_hook_resurrect_session *result = 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - result = (switch_io_event_hook_resurrect_session *) ((arg1)->next); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_io_event_hook_resurrect_session() { - void * jresult ; - switch_io_event_hook_resurrect_session *result = 0 ; - - result = (switch_io_event_hook_resurrect_session *)new switch_io_event_hook_resurrect_session(); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_resurrect_session(void * jarg1) { - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - delete arg1; -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_outgoing_channel_set(void * jarg1, void * jarg2) { switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ; switch_io_event_hook_outgoing_channel_t *arg2 = (switch_io_event_hook_outgoing_channel_t *) 0 ; @@ -33592,28 +34159,6 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hooks_state_run_get(void * } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_resurrect_session_set(void * jarg1, void * jarg2) { - switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ; - switch_io_event_hook_resurrect_session_t *arg2 = (switch_io_event_hook_resurrect_session_t *) 0 ; - - arg1 = (switch_io_event_hooks *)jarg1; - arg2 = (switch_io_event_hook_resurrect_session_t *)jarg2; - if (arg1) (arg1)->resurrect_session = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hooks_resurrect_session_get(void * jarg1) { - void * jresult ; - switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ; - switch_io_event_hook_resurrect_session_t *result = 0 ; - - arg1 = (switch_io_event_hooks *)jarg1; - result = (switch_io_event_hook_resurrect_session_t *) ((arg1)->resurrect_session); - jresult = (void *)result; - return jresult; -} - - SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_io_event_hooks() { void * jresult ; switch_io_event_hooks *result = 0 ; @@ -33800,20 +34345,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_recv_dtmf(void * ja } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_resurrect_session(void * jarg1, void * jarg2) { - int jresult ; - switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; - switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ; - switch_status_t result; - - arg1 = (switch_core_session_t *)jarg1; - arg2 = (switch_resurrect_session_hook_t)jarg2; - result = (switch_status_t)switch_core_event_hook_add_resurrect_session(arg1,arg2); - jresult = result; - return jresult; -} - - SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_outgoing_channel(void * jarg1, void * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -33982,20 +34513,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_recv_dtmf(void * } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_resurrect_session(void * jarg1, void * jarg2) { - int jresult ; - switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; - switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ; - switch_status_t result; - - arg1 = (switch_core_session_t *)jarg1; - arg2 = (switch_resurrect_session_hook_t)jarg2; - result = (switch_status_t)switch_core_event_hook_remove_resurrect_session(arg1,arg2); - jresult = result; - return jresult; -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_created_set(void * jarg1, long long jarg2) { switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; int64_t arg2 ; @@ -35377,15 +35894,17 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_EventConsumer_node_index_get(void * } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_EventConsumer(char * jarg1, char * jarg2) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_EventConsumer(char * jarg1, char * jarg2, int jarg3) { void * jresult ; char *arg1 = (char *) NULL ; char *arg2 = (char *) "" ; + int arg3 = (int) 5000 ; EventConsumer *result = 0 ; arg1 = (char *)jarg1; arg2 = (char *)jarg2; - result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2); + arg3 = (int)jarg3; + result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3); jresult = (void *)result; return jresult; } diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 557cb05f76..bab4805383 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -1113,6 +1113,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_READ_RESULT_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ATT_XFER_RESULT_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "att_xfer_result"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1124,6 +1135,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_COPY_JSON_CDR_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "copy_json_cdr"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1223,6 +1245,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABL } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "execute_on_post_originate"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1289,6 +1322,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_ge } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "api_on_post_originate"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1498,6 +1542,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PROXY_MEDIA_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ZRTP_PASSTHRU_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "zrtp_passthru"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -1630,6 +1685,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SIGNAL_BOND_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "originate_signal_bond"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ORIGINATOR_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -2970,6 +3036,35 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_packet_count_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_period_packet_count_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)->period_packet_count = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_period_packet_count_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)->period_packet_count); + jresult = new switch_size_t((switch_size_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_media_packet_count_set(void * jarg1, void * jarg2) { switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ; switch_size_t arg2 ; @@ -3238,6 +3333,29 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtcp_numbers_t_octet_count_ge } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_peer_ssrc_set(void * jarg1, unsigned long jarg2) { + switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_rtcp_numbers_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->peer_ssrc = arg2; + +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtcp_numbers_t_peer_ssrc_get(void * jarg1) { + unsigned long jresult ; + switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ; + uint32_t result; + + arg1 = (switch_rtcp_numbers_t *)jarg1; + result = (uint32_t) ((arg1)->peer_ssrc); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtcp_numbers_t() { void * jresult ; switch_rtcp_numbers_t *result = 0 ; @@ -3326,6 +3444,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_stats_t_rtcp_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_read_count_set(void * jarg1, unsigned long jarg2) { + switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_rtp_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->read_count = arg2; + +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtp_stats_t_read_count_get(void * jarg1) { + unsigned long jresult ; + switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_rtp_stats_t *)jarg1; + result = (uint32_t) ((arg1)->read_count); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtp_stats_t() { void * jresult ; switch_rtp_stats_t *result = 0 ; @@ -6732,6 +6873,54 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_disable_heartbeat(void * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_pop(void * jarg1, char * jarg2, void * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_media_bug_t **arg3 = (switch_media_bug_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_media_bug_t **)jarg3; + result = (switch_status_t)switch_core_media_bug_pop(arg1,(char const *)arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_exec_all(void * jarg1, char * jarg2, void * jarg3, void * jarg4) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_media_bug_exec_cb_t arg3 = (switch_media_bug_exec_cb_t) 0 ; + void *arg4 = (void *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_media_bug_exec_cb_t)jarg3; + arg4 = (void *)jarg4; + result = (switch_status_t)switch_core_media_bug_exec_all(arg1,(char const *)arg2,arg3,arg4); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_media_bug_count(void * jarg1, char * jarg2) { + unsigned long jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + uint32_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + result = (uint32_t)switch_core_media_bug_count(arg1,(char const *)arg2); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_add(void * jarg1, char * jarg2, char * jarg3, void * jarg4, void * jarg5, void * jarg6, unsigned long jarg7, void * jarg8) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -6838,6 +7027,16 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_read_replace_fram } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_media_bug_set_read_demux_frame(void * jarg1, void * jarg2) { + switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ; + switch_frame_t *arg2 = (switch_frame_t *) 0 ; + + arg1 = (switch_media_bug_t *)jarg1; + arg2 = (switch_frame_t *)jarg2; + switch_core_media_bug_set_read_demux_frame(arg1,arg2); +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_session(void * jarg1) { void * jresult ; switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ; @@ -6964,13 +7163,15 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_close(void * jarg1) { } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_remove_all(void * jarg1) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_media_bug_remove_all_function(void * jarg1, char * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; - result = (switch_status_t)switch_core_media_bug_remove_all(arg1); + arg2 = (char *)jarg2; + result = (switch_status_t)switch_core_media_bug_remove_all_function(arg1,(char const *)arg2); jresult = result; return jresult; } @@ -7108,6 +7309,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_port_allocator_destroy(void * jar } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_test_flag(int jarg1) { + int jresult ; + int arg1 ; + int result; + + arg1 = (int)jarg1; + result = (int)switch_core_test_flag(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_init(unsigned long jarg1, int jarg2, void * jarg3) { int jresult ; switch_core_flag_t arg1 ; @@ -7694,6 +7907,16 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_id() { } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_id_dec() { + void * jresult ; + switch_size_t result; + + result = switch_core_session_id_dec(); + jresult = new switch_size_t((switch_size_t &)result); + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_request_by_name(char * jarg1, int jarg2, void * jarg3) { void * jresult ; char *arg1 = (char *) 0 ; @@ -7722,6 +7945,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_thread_launch(void * jarg1 } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_thread_pool_launch(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_thread_pool_launch(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_channel(void * jarg1) { void * jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -7882,25 +8117,37 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_uuid() { } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_locate(char * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_perform_locate(char * jarg1, char * jarg2, char * jarg3, int jarg4) { void * jresult ; char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; switch_core_session_t *result = 0 ; arg1 = (char *)jarg1; - result = (switch_core_session_t *)switch_core_session_locate((char const *)arg1); + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (int)jarg4; + result = (switch_core_session_t *)switch_core_session_perform_locate((char const *)arg1,(char const *)arg2,(char const *)arg3,arg4); jresult = (void *)result; return jresult; } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_force_locate(char * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_perform_force_locate(char * jarg1, char * jarg2, char * jarg3, int jarg4) { void * jresult ; char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; switch_core_session_t *result = 0 ; arg1 = (char *)jarg1; - result = (switch_core_session_t *)switch_core_session_force_locate((char const *)arg1); + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (int)jarg4; + result = (switch_core_session_t *)switch_core_session_perform_force_locate((char const *)arg1,(char const *)arg2,(char const *)arg3,arg4); jresult = (void *)result; return jresult; } @@ -8028,15 +8275,21 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_hupall_endpoint(void * ja } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_partner(void * jarg1, void * jarg2) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_perform_get_partner(void * jarg1, void * jarg2, char * jarg3, char * jarg4, int jarg5) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (switch_core_session_t **)jarg2; - result = (switch_status_t)switch_core_session_get_partner(arg1,arg2); + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (int)jarg5; + result = (switch_status_t)switch_core_session_perform_get_partner(arg1,arg2,(char const *)arg3,(char const *)arg4,arg5); jresult = result; return jresult; } @@ -8406,24 +8659,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_outgoing_channel(void * ja } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_resurrect_channel(char * jarg1, void * jarg2, void * jarg3, void * jarg4) { - int jresult ; - char *arg1 = (char *) 0 ; - switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; - switch_memory_pool_t **arg3 = (switch_memory_pool_t **) 0 ; - void *arg4 = (void *) 0 ; - switch_call_cause_t result; - - arg1 = (char *)jarg1; - arg2 = (switch_core_session_t **)jarg2; - arg3 = (switch_memory_pool_t **)jarg3; - arg4 = (void *)jarg4; - result = (switch_call_cause_t)switch_core_session_resurrect_channel((char const *)arg1,arg2,arg3,arg4); - jresult = result; - return jresult; -} - - SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_perform_receive_message(void * jarg1, void * jarg2, char * jarg3, char * jarg4, int jarg5) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -9303,6 +9538,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_read_impl(void * jarg1 } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_real_read_impl(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_codec_implementation_t *arg2 = (switch_codec_implementation_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_codec_implementation_t *)jarg2; + result = (switch_status_t)switch_core_session_get_real_read_impl(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_write_impl(void * jarg1, void * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -9577,6 +9826,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_file_write(void * jarg1, void * ja } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_file_write_video(void * jarg1, void * jarg2, void * jarg3) { + int jresult ; + switch_file_handle_t *arg1 = (switch_file_handle_t *) 0 ; + void *arg2 = (void *) 0 ; + switch_size_t *arg3 = (switch_size_t *) 0 ; + switch_status_t result; + + arg1 = (switch_file_handle_t *)jarg1; + arg2 = (void *)jarg2; + arg3 = (switch_size_t *)jarg3; + result = (switch_status_t)switch_core_file_write_video(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_file_seek(void * jarg1, void * jarg2, long long jarg3, int jarg4) { int jresult ; switch_file_handle_t *arg1 = (switch_file_handle_t *) 0 ; @@ -10398,6 +10663,16 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_micro_time_now() { } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_mono_micro_time_now() { + void * jresult ; + switch_time_t result; + + result = switch_mono_micro_time_now(); + jresult = new switch_time_t((switch_time_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_memory_reclaim() { switch_core_memory_reclaim(); } @@ -10450,6 +10725,18 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_epoch_time_now(void * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_lookup_timezone(char * jarg1) { + char * jresult ; + char *arg1 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + result = (char *)switch_lookup_timezone((char const *)arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_strftime_tz(char * jarg1, char * jarg2, char * jarg3, unsigned long jarg4, void * jarg5) { int jresult ; char *arg1 = (char *) 0 ; @@ -10562,6 +10849,14 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_cond_yield(int jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_time_set_use_system_time(int jarg1) { + switch_bool_t arg1 ; + + arg1 = (switch_bool_t)jarg1; + switch_time_set_use_system_time(arg1); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_min_dtmf_duration(unsigned long jarg1) { unsigned long jresult ; uint32_t arg1 ; @@ -10691,7 +10986,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cond_next() { } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8, int jarg9) { int jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -10701,6 +10996,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char char *arg6 = (char *) 0 ; char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; + switch_bool_t arg9 ; switch_status_t result; arg1 = (char *)jarg1; @@ -10711,7 +11007,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char arg6 = (char *)jarg6; arg7 = (char *)jarg7; arg8 = (char *)jarg8; - result = (switch_status_t)switch_core_chat_send_args((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + arg9 = (switch_bool_t)jarg9; + result = (switch_status_t)switch_core_chat_send_args((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8,arg9); jresult = result; return jresult; } @@ -10759,6 +11056,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_preprocess_session(void * jarg1, ch } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_stop_thread() { + switch_core_sqldb_stop_thread(); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_sqldb_start_thread() { + switch_core_sqldb_start_thread(); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_CACHE_DB_LEN_get() { int jresult ; int result; @@ -11214,6 +11521,24 @@ SWIGEXPORT int SWIGSTDCALL CSharp__switch_core_db_handle(void * jarg1, char * ja } +SWIGEXPORT int SWIGSTDCALL CSharp__switch_core_recovery_db_handle(void * jarg1, char * jarg2, char * jarg3, int jarg4) { + int jresult ; + switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + switch_status_t result; + + arg1 = (switch_cache_db_handle_t **)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (int)jarg4; + result = (switch_status_t)_switch_core_recovery_db_handle(arg1,(char const *)arg2,(char const *)arg3,arg4); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_test_reactive(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { int jresult ; switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; @@ -11320,7 +11645,7 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_default_ptime(char * jarg1, u } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8, char * jarg9) { int jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -11330,6 +11655,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, cha char *arg6 = (char *) 0 ; char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; + char *arg9 = (char *) 0 ; switch_status_t result; arg1 = (char *)jarg1; @@ -11340,7 +11666,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, cha arg6 = (char *)jarg6; arg7 = (char *)jarg7; arg8 = (char *)jarg8; - result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + arg9 = (char *)jarg9; + result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8,(char const *)arg9); jresult = result; return jresult; } @@ -11467,6 +11794,79 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_close_extra_files(void * jarg1, int ja } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_thread_set_cpu_affinity(int jarg1) { + int jresult ; + int arg1 ; + switch_status_t result; + + arg1 = (int)jarg1; + result = (switch_status_t)switch_core_thread_set_cpu_affinity(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_os_yield() { + switch_os_yield(); +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_get_stacksizes(void * jarg1, void * jarg2) { + int jresult ; + switch_size_t *arg1 = (switch_size_t *) 0 ; + switch_size_t *arg2 = (switch_size_t *) 0 ; + switch_status_t result; + + arg1 = (switch_size_t *)jarg1; + arg2 = (switch_size_t *)jarg2; + result = (switch_status_t)switch_core_get_stacksizes(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_recovery_recover(char * jarg1, char * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + result = (int)switch_core_recovery_recover((char const *)arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_untrack(void * jarg1, int jarg2) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_bool_t arg2 ; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + switch_core_recovery_untrack(arg1,arg2); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_track(void * jarg1) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + + arg1 = (switch_core_session_t *)jarg1; + switch_core_recovery_track(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_recovery_flush(char * jarg1, char * jarg2) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + switch_core_recovery_flush((char const *)arg1,(char const *)arg2); +} + + 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 ; @@ -11970,6 +12370,24 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_codec_interface( } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_parse_codec_buf(char * jarg1, void * jarg2, void * jarg3, void * jarg4) { + char * jresult ; + char *arg1 = (char *) 0 ; + uint32_t *arg2 = (uint32_t *) 0 ; + uint32_t *arg3 = (uint32_t *) 0 ; + uint32_t *arg4 = (uint32_t *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (uint32_t *)jarg2; + arg3 = (uint32_t *)jarg3; + arg4 = (uint32_t *)jarg4; + result = (char *)switch_parse_codec_buf(arg1,arg2,arg3,arg4); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_dialplan_interface(char * jarg1) { void * jresult ; char *arg1 = (char *) 0 ; @@ -14166,6 +14584,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_atoul(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_strerror_r(int jarg1, char * jarg2, void * jarg3) { + char * jresult ; + int arg1 ; + char *arg2 = (char *) 0 ; + switch_size_t arg3 ; + char *result = 0 ; + switch_size_t *argp3 ; + + arg1 = (int)jarg1; + arg2 = (char *)jarg2; + argp3 = (switch_size_t *)jarg3; + if (!argp3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return 0; + } + arg3 = *argp3; + result = (char *)switch_strerror_r(arg1,arg2,arg3); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_profile_node_t_var_set(void * jarg1, char * jarg2) { profile_node_t *arg1 = (profile_node_t *) 0 ; char *arg2 = (char *) 0 ; @@ -16995,29 +17435,6 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_routines_state_run_get(void * jar } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_resurrect_session_set(void * jarg1, void * jarg2) { - switch_io_routines *arg1 = (switch_io_routines *) 0 ; - switch_io_resurrect_session_t arg2 = (switch_io_resurrect_session_t) 0 ; - - arg1 = (switch_io_routines *)jarg1; - arg2 = (switch_io_resurrect_session_t)jarg2; - if (arg1) (arg1)->resurrect_session = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_routines_resurrect_session_get(void * jarg1) { - void * jresult ; - switch_io_routines *arg1 = (switch_io_routines *) 0 ; - switch_io_resurrect_session_t result; - - arg1 = (switch_io_routines *)jarg1; - result = (switch_io_resurrect_session_t) ((arg1)->resurrect_session); - jresult = (void *)result; - return jresult; -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_padding_set(void * jarg1, void * jarg2) { switch_io_routines *arg1 = (switch_io_routines *) 0 ; void **arg2 ; @@ -17276,6 +17693,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_endpoint_interface_next_get(void * j } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_endpoint_interface_recover_callback_set(void * jarg1, void * jarg2) { + switch_endpoint_interface *arg1 = (switch_endpoint_interface *) 0 ; + switch_core_recover_callback_t arg2 = (switch_core_recover_callback_t) 0 ; + + arg1 = (switch_endpoint_interface *)jarg1; + arg2 = (switch_core_recover_callback_t)jarg2; + if (arg1) (arg1)->recover_callback = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_endpoint_interface_recover_callback_get(void * jarg1) { + void * jresult ; + switch_endpoint_interface *arg1 = (switch_endpoint_interface *) 0 ; + switch_core_recover_callback_t result; + + arg1 = (switch_endpoint_interface *)jarg1; + result = (switch_core_recover_callback_t) ((arg1)->recover_callback); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_endpoint_interface() { void * jresult ; switch_endpoint_interface *result = 0 ; @@ -18164,6 +18604,52 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_interface_file_write_get(void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_read_video_set(void * jarg1, void * jarg2) { + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*arg2)(switch_file_handle_t *,void *,switch_size_t *) = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) 0 ; + + 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; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_interface_file_read_video_get(void * jarg1) { + void * jresult ; + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*result)(switch_file_handle_t *,void *,switch_size_t *) = 0 ; + + arg1 = (switch_file_interface *)jarg1; + result = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) ((arg1)->file_read_video); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_write_video_set(void * jarg1, void * jarg2) { + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*arg2)(switch_file_handle_t *,void *,switch_size_t *) = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) 0 ; + + 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; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_interface_file_write_video_get(void * jarg1) { + void * jresult ; + switch_file_interface *arg1 = (switch_file_interface *) 0 ; + switch_status_t (*result)(switch_file_handle_t *,void *,switch_size_t *) = 0 ; + + arg1 = (switch_file_interface *)jarg1; + result = (switch_status_t (*)(switch_file_handle_t *,void *,switch_size_t *)) ((arg1)->file_write_video); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_interface_file_seek_set(void * jarg1, void * jarg2) { switch_file_interface *arg1 = (switch_file_interface *) 0 ; switch_status_t (*arg2)(switch_file_handle_t *,unsigned int *,int64_t,int) = (switch_status_t (*)(switch_file_handle_t *,unsigned int *,int64_t,int)) 0 ; @@ -26328,6 +26814,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_transfer_to_extension(void * j } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_channel_get_partner_uuid(void * jarg1) { + char * jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + char *result = 0 ; + + arg1 = (switch_channel_t *)jarg1; + result = (char *)switch_channel_get_partner_uuid(arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg2, void * jarg3) { int jresult ; switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ; @@ -27723,6 +28221,26 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_check_permission_list(void * jarg } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_add_presence_data_cols(void * jarg1, void * jarg2, char * jarg3) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_event_t *arg2 = (switch_event_t *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_channel_t *)jarg1; + arg2 = (switch_event_t *)jarg2; + arg3 = (char *)jarg3; + switch_event_add_presence_data_cols(arg1,arg2,(char const *)arg3); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_launch_dispatch_threads(unsigned long jarg1) { + uint32_t arg1 ; + + arg1 = (uint32_t)jarg1; + switch_event_launch_dispatch_threads(arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RESAMPLE_QUALITY_get() { int jresult ; int result; @@ -28123,6 +28641,24 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_merge_sln(void * jarg1, unsig } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_unmerge_sln(void * jarg1, unsigned long jarg2, void * jarg3, unsigned long jarg4) { + unsigned long jresult ; + int16_t *arg1 = (int16_t *) 0 ; + uint32_t arg2 ; + int16_t *arg3 = (int16_t *) 0 ; + uint32_t arg4 ; + uint32_t result; + + arg1 = (int16_t *)jarg1; + arg2 = (uint32_t)jarg2; + arg3 = (int16_t *)jarg3; + arg4 = (uint32_t)jarg4; + result = (uint32_t)switch_unmerge_sln(arg1,arg2,arg3,arg4); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_mux_channels(void * jarg1, void * jarg2, unsigned long jarg3) { int16_t *arg1 = (int16_t *) 0 ; switch_size_t arg2 ; @@ -28581,6 +29117,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_activate_unicast(void * jarg1, char } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_generate_json_cdr(void * jarg1, void * jarg2, int jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + switch_bool_t arg3 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (cJSON **)jarg2; + arg3 = (switch_bool_t)jarg3; + result = (switch_status_t)switch_ivr_generate_json_cdr(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_generate_xml_cdr(void * jarg1, void * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -28991,6 +29543,52 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_record_session(void * jarg1, char * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_pop_eavesdropper(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_core_session_t **)jarg2; + result = (switch_status_t)switch_ivr_eavesdrop_pop_eavesdropper(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_exec_all(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_ivr_eavesdrop_exec_all(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_update_display(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_ivr_eavesdrop_update_display(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_eavesdrop_session(void * jarg1, char * jarg2, char * jarg3, unsigned long jarg4) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -30703,6 +31301,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_kill_uuid(char * jarg1, int jarg2) } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_blind_transfer_ack(void * jarg1, int jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_bool_t arg2 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + result = (switch_status_t)switch_ivr_blind_transfer_ack(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; @@ -31251,17 +31863,37 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_destroy(void * jarg1) { } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_ice(void * jarg1, char * jarg2, char * jarg3) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_ice(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { int jresult ; switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; switch_status_t result; arg1 = (switch_rtp_t *)jarg1; arg2 = (char *)jarg2; arg3 = (char *)jarg3; - result = (switch_status_t)switch_rtp_activate_ice(arg1,arg2,arg3); + arg4 = (char *)jarg4; + result = (switch_status_t)switch_rtp_activate_ice(arg1,arg2,arg3,(char const *)arg4); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_rtcp_ice(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + result = (switch_status_t)switch_rtp_activate_rtcp_ice(arg1,arg2,arg3,(char const *)arg4); jresult = result; return jresult; } @@ -31391,6 +32023,14 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_get_rtp_socket(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_ping(void * jarg1) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + + arg1 = (switch_rtp_t *)jarg1; + switch_rtp_ping(arg1); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtp_get_default_samples_per_interval(void * jarg1) { unsigned long jresult ; switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; @@ -31771,6 +32411,16 @@ SWIGEXPORT unsigned char SWIGSTDCALL CSharp_switch_rtp_check_auto_adj(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_interdigit_delay(void * jarg1, unsigned long jarg2) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (uint32_t)jarg2; + switch_rtp_set_interdigit_delay(arg1,arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_log_node_t_data_set(void * jarg1, char * jarg2) { switch_log_node_t *arg1 = (switch_log_node_t *) 0 ; char *arg2 = (char *) 0 ; @@ -34056,71 +34706,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_state_run(void * } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_resurrect_session_set(void * jarg1, void * jarg2) { - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - arg2 = (switch_resurrect_session_hook_t)jarg2; - if (arg1) (arg1)->resurrect_session = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_resurrect_session_get(void * jarg1) { - void * jresult ; - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_resurrect_session_hook_t result; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - result = (switch_resurrect_session_hook_t) ((arg1)->resurrect_session); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_next_set(void * jarg1, void * jarg2) { - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_io_event_hook_resurrect_session *arg2 = (switch_io_event_hook_resurrect_session *) 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - arg2 = (switch_io_event_hook_resurrect_session *)jarg2; - if (arg1) (arg1)->next = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_next_get(void * jarg1) { - void * jresult ; - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - switch_io_event_hook_resurrect_session *result = 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - result = (switch_io_event_hook_resurrect_session *) ((arg1)->next); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_io_event_hook_resurrect_session() { - void * jresult ; - switch_io_event_hook_resurrect_session *result = 0 ; - - result = (switch_io_event_hook_resurrect_session *)new switch_io_event_hook_resurrect_session(); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_resurrect_session(void * jarg1) { - switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ; - - arg1 = (switch_io_event_hook_resurrect_session *)jarg1; - delete arg1; - -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_outgoing_channel_set(void * jarg1, void * jarg2) { switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ; switch_io_event_hook_outgoing_channel_t *arg2 = (switch_io_event_hook_outgoing_channel_t *) 0 ; @@ -34397,29 +34982,6 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hooks_state_run_get(void * } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_resurrect_session_set(void * jarg1, void * jarg2) { - switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ; - switch_io_event_hook_resurrect_session_t *arg2 = (switch_io_event_hook_resurrect_session_t *) 0 ; - - arg1 = (switch_io_event_hooks *)jarg1; - arg2 = (switch_io_event_hook_resurrect_session_t *)jarg2; - if (arg1) (arg1)->resurrect_session = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hooks_resurrect_session_get(void * jarg1) { - void * jresult ; - switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ; - switch_io_event_hook_resurrect_session_t *result = 0 ; - - arg1 = (switch_io_event_hooks *)jarg1; - result = (switch_io_event_hook_resurrect_session_t *) ((arg1)->resurrect_session); - jresult = (void *)result; - return jresult; -} - - SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_io_event_hooks() { void * jresult ; switch_io_event_hooks *result = 0 ; @@ -34607,20 +35169,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_recv_dtmf(void * ja } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_resurrect_session(void * jarg1, void * jarg2) { - int jresult ; - switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; - switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ; - switch_status_t result; - - arg1 = (switch_core_session_t *)jarg1; - arg2 = (switch_resurrect_session_hook_t)jarg2; - result = (switch_status_t)switch_core_event_hook_add_resurrect_session(arg1,arg2); - jresult = result; - return jresult; -} - - SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_outgoing_channel(void * jarg1, void * jarg2) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -34789,20 +35337,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_recv_dtmf(void * } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_resurrect_session(void * jarg1, void * jarg2) { - int jresult ; - switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; - switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ; - switch_status_t result; - - arg1 = (switch_core_session_t *)jarg1; - arg2 = (switch_resurrect_session_hook_t)jarg2; - result = (switch_status_t)switch_core_event_hook_remove_resurrect_session(arg1,arg2); - jresult = result; - return jresult; -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_created_set(void * jarg1, long long jarg2) { switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; int64_t arg2 ; @@ -36196,15 +36730,17 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_EventConsumer_node_index_get(void * } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_EventConsumer(char * jarg1, char * jarg2) { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_EventConsumer(char * jarg1, char * jarg2, int jarg3) { void * jresult ; char *arg1 = (char *) NULL ; char *arg2 = (char *) "" ; + int arg3 = (int) 5000 ; EventConsumer *result = 0 ; arg1 = (char *)jarg1; arg2 = (char *)jarg2; - result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2); + arg3 = (int)jarg3; + result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3); jresult = (void *)result; return jresult; } diff --git a/src/mod/languages/mod_managed/managed/swig.2010.cs b/src/mod/languages/mod_managed/managed/swig.2010.cs index d814ce15b9..4c3360c043 100644 --- a/src/mod/languages/mod_managed/managed/swig.2010.cs +++ b/src/mod/languages/mod_managed/managed/swig.2010.cs @@ -857,7 +857,7 @@ public class EventConsumer : IDisposable { } } - public EventConsumer(string event_name, string subclass_name) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name), true) { + public EventConsumer(string event_name, string subclass_name, int len) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name, len), true) { } public int bind(string event_name, string subclass_name) { @@ -1066,6 +1066,21 @@ public class freeswitch { freeswitchPINVOKE.switch_core_session_disable_heartbeat(SWIGTYPE_p_switch_core_session.getCPtr(session)); } + public static switch_status_t switch_core_media_bug_pop(SWIGTYPE_p_switch_core_session orig_session, string function, SWIGTYPE_p_p_switch_media_bug pop) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_pop(SWIGTYPE_p_switch_core_session.getCPtr(orig_session), function, SWIGTYPE_p_p_switch_media_bug.getCPtr(pop)); + return ret; + } + + public static switch_status_t switch_core_media_bug_exec_all(SWIGTYPE_p_switch_core_session orig_session, string function, SWIGTYPE_p_f_p_switch_media_bug_p_void__void cb, SWIGTYPE_p_void user_data) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_exec_all(SWIGTYPE_p_switch_core_session.getCPtr(orig_session), function, SWIGTYPE_p_f_p_switch_media_bug_p_void__void.getCPtr(cb), SWIGTYPE_p_void.getCPtr(user_data)); + return ret; + } + + public static uint switch_core_media_bug_count(SWIGTYPE_p_switch_core_session orig_session, string function) { + uint ret = freeswitchPINVOKE.switch_core_media_bug_count(SWIGTYPE_p_switch_core_session.getCPtr(orig_session), function); + return ret; + } + public static switch_status_t switch_core_media_bug_add(SWIGTYPE_p_switch_core_session session, string function, string target, SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t callback, SWIGTYPE_p_void user_data, SWIGTYPE_p_time_t stop_time, uint flags, SWIGTYPE_p_p_switch_media_bug new_bug) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_add(SWIGTYPE_p_switch_core_session.getCPtr(session), function, target, SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t.getCPtr(callback), SWIGTYPE_p_void.getCPtr(user_data), SWIGTYPE_p_time_t.getCPtr(stop_time), flags, SWIGTYPE_p_p_switch_media_bug.getCPtr(new_bug)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -1106,6 +1121,10 @@ public class freeswitch { return ret; } + public static void switch_core_media_bug_set_read_demux_frame(SWIGTYPE_p_switch_media_bug bug, switch_frame frame) { + freeswitchPINVOKE.switch_core_media_bug_set_read_demux_frame(SWIGTYPE_p_switch_media_bug.getCPtr(bug), switch_frame.getCPtr(frame)); + } + public static SWIGTYPE_p_switch_core_session switch_core_media_bug_get_session(SWIGTYPE_p_switch_media_bug bug) { IntPtr cPtr = freeswitchPINVOKE.switch_core_media_bug_get_session(SWIGTYPE_p_switch_media_bug.getCPtr(bug)); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); @@ -1156,8 +1175,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_media_bug_remove_all(SWIGTYPE_p_switch_core_session session) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_remove_all(SWIGTYPE_p_switch_core_session.getCPtr(session)); + public static switch_status_t switch_core_media_bug_remove_all_function(SWIGTYPE_p_switch_core_session session, string function) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_remove_all_function(SWIGTYPE_p_switch_core_session.getCPtr(session), function); return ret; } @@ -1209,6 +1228,11 @@ public class freeswitch { freeswitchPINVOKE.switch_core_port_allocator_destroy(SWIGTYPE_p_p_switch_core_port_allocator.getCPtr(alloc)); } + public static int switch_core_test_flag(int flag) { + int ret = freeswitchPINVOKE.switch_core_test_flag(flag); + return ret; + } + public static switch_status_t switch_core_init(uint flags, switch_bool_t console, ref string err) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_init(flags, (int)console, ref err); return ret; @@ -1436,6 +1460,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_thread_pool_launch(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_thread_pool_launch(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static SWIGTYPE_p_switch_channel switch_core_session_get_channel(SWIGTYPE_p_switch_core_session session) { IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_channel(SWIGTYPE_p_switch_core_session.getCPtr(session)); SWIGTYPE_p_switch_channel ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_channel(cPtr, false); @@ -1503,14 +1532,14 @@ public class freeswitch { return ret; } - public static SWIGTYPE_p_switch_core_session switch_core_session_locate(string uuid_str) { - IntPtr cPtr = freeswitchPINVOKE.switch_core_session_locate(uuid_str); + public static SWIGTYPE_p_switch_core_session switch_core_session_perform_locate(string uuid_str, string file, string func, int line) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_perform_locate(uuid_str, file, func, line); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); return ret; } - public static SWIGTYPE_p_switch_core_session switch_core_session_force_locate(string uuid_str) { - IntPtr cPtr = freeswitchPINVOKE.switch_core_session_force_locate(uuid_str); + public static SWIGTYPE_p_switch_core_session switch_core_session_perform_force_locate(string uuid_str, string file, string func, int line) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_perform_force_locate(uuid_str, file, func, line); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); return ret; } @@ -1565,8 +1594,8 @@ public class freeswitch { freeswitchPINVOKE.switch_core_session_hupall_endpoint(switch_endpoint_interface.getCPtr(endpoint_interface), (int)cause); } - public static switch_status_t switch_core_session_get_partner(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session partner) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_partner(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(partner)); + public static switch_status_t switch_core_session_perform_get_partner(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session partner, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_perform_get_partner(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(partner), file, func, line); return ret; } @@ -1699,11 +1728,6 @@ public class freeswitch { return ret; } - public static switch_call_cause_t switch_core_session_resurrect_channel(string endpoint_name, SWIGTYPE_p_p_switch_core_session new_session, SWIGTYPE_p_p_apr_pool_t pool, SWIGTYPE_p_void data) { - switch_call_cause_t ret = (switch_call_cause_t)freeswitchPINVOKE.switch_core_session_resurrect_channel(endpoint_name, SWIGTYPE_p_p_switch_core_session.getCPtr(new_session), SWIGTYPE_p_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_void.getCPtr(data)); - return ret; - } - public static switch_status_t switch_core_session_perform_receive_message(SWIGTYPE_p_switch_core_session session, switch_core_session_message message, string file, string func, int line) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_perform_receive_message(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_core_session_message.getCPtr(message), file, func, line); return ret; @@ -2000,6 +2024,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_get_real_read_impl(SWIGTYPE_p_switch_core_session session, switch_codec_implementation impp) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_real_read_impl(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_codec_implementation.getCPtr(impp)); + return ret; + } + public static switch_status_t switch_core_session_get_write_impl(SWIGTYPE_p_switch_core_session session, switch_codec_implementation impp) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_write_impl(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_codec_implementation.getCPtr(impp)); return ret; @@ -2101,6 +2130,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_file_write_video(switch_file_handle fh, SWIGTYPE_p_void data, SWIGTYPE_p_switch_size_t len) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_file_write_video(switch_file_handle.getCPtr(fh), SWIGTYPE_p_void.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(len)); + return ret; + } + public static switch_status_t switch_core_file_seek(switch_file_handle fh, SWIGTYPE_p_unsigned_int cur_pos, long samples, int whence) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_file_seek(switch_file_handle.getCPtr(fh), SWIGTYPE_p_unsigned_int.getCPtr(cur_pos), samples, whence); return ret; @@ -2403,6 +2437,11 @@ public class freeswitch { return ret; } + public static SWIGTYPE_p_switch_time_t switch_mono_micro_time_now() { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_mono_micro_time_now(), true); + return ret; + } + public static void switch_core_memory_reclaim() { freeswitchPINVOKE.switch_core_memory_reclaim(); } @@ -2437,6 +2476,11 @@ public class freeswitch { return ret; } + public static string switch_lookup_timezone(string tz_name) { + string ret = freeswitchPINVOKE.switch_lookup_timezone(tz_name); + return ret; + } + public static switch_status_t switch_strftime_tz(string tz, string format, string date, uint len, SWIGTYPE_p_switch_time_t thetime) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_strftime_tz(tz, format, date, len, SWIGTYPE_p_switch_time_t.getCPtr(thetime)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -2478,6 +2522,10 @@ public class freeswitch { freeswitchPINVOKE.switch_time_set_cond_yield((int)enable); } + public static void switch_time_set_use_system_time(switch_bool_t enable) { + freeswitchPINVOKE.switch_time_set_use_system_time((int)enable); + } + public static uint switch_core_min_dtmf_duration(uint duration) { uint ret = freeswitchPINVOKE.switch_core_min_dtmf_duration(duration); return ret; @@ -2532,8 +2580,8 @@ public class freeswitch { freeswitchPINVOKE.switch_cond_next(); } - public static switch_status_t switch_core_chat_send_args(string dest_proto, string proto, string from, string to, string subject, string body, string type, string hint) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send_args(dest_proto, proto, from, to, subject, body, type, hint); + public static switch_status_t switch_core_chat_send_args(string dest_proto, string proto, string from, string to, string subject, string body, string type, string hint, switch_bool_t blocking) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send_args(dest_proto, proto, from, to, subject, body, type, hint, (int)blocking); return ret; } @@ -2552,6 +2600,14 @@ public class freeswitch { return ret; } + public static void switch_core_sqldb_stop_thread() { + freeswitchPINVOKE.switch_core_sqldb_stop_thread(); + } + + public static void switch_core_sqldb_start_thread() { + freeswitchPINVOKE.switch_core_sqldb_start_thread(); + } + public static string switch_cache_db_type_name(switch_cache_db_handle_type_t type) { string ret = freeswitchPINVOKE.switch_cache_db_type_name((int)type); return ret; @@ -2604,6 +2660,11 @@ public class freeswitch { return ret; } + public static switch_status_t _switch_core_recovery_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_core_recovery_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh), file, func, line); + return ret; + } + public static switch_bool_t switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle db, string test_sql, string drop_sql, string reactive_sql) { switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle.getCPtr(db), test_sql, drop_sql, reactive_sql); return ret; @@ -2647,8 +2708,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto); + public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto, string metadata) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto, metadata); return ret; } @@ -2699,6 +2760,37 @@ public class freeswitch { freeswitchPINVOKE.switch_close_extra_files(SWIGTYPE_p_int.getCPtr(keep), keep_ttl); } + public static switch_status_t switch_core_thread_set_cpu_affinity(int cpu) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_thread_set_cpu_affinity(cpu); + return ret; + } + + public static void switch_os_yield() { + freeswitchPINVOKE.switch_os_yield(); + } + + public static switch_status_t switch_core_get_stacksizes(SWIGTYPE_p_switch_size_t cur, SWIGTYPE_p_switch_size_t max) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_get_stacksizes(SWIGTYPE_p_switch_size_t.getCPtr(cur), SWIGTYPE_p_switch_size_t.getCPtr(max)); + return ret; + } + + public static int switch_core_recovery_recover(string technology, string profile_name) { + int ret = freeswitchPINVOKE.switch_core_recovery_recover(technology, profile_name); + return ret; + } + + public static void switch_core_recovery_untrack(SWIGTYPE_p_switch_core_session session, switch_bool_t force) { + freeswitchPINVOKE.switch_core_recovery_untrack(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)force); + } + + public static void switch_core_recovery_track(SWIGTYPE_p_switch_core_session session) { + freeswitchPINVOKE.switch_core_recovery_track(SWIGTYPE_p_switch_core_session.getCPtr(session)); + } + + public static void switch_core_recovery_flush(string technology, string profile_name) { + freeswitchPINVOKE.switch_core_recovery_flush(technology, profile_name); + } + 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; @@ -2720,6 +2812,11 @@ public class freeswitch { return ret; } + public static string switch_parse_codec_buf(string buf, SWIGTYPE_p_unsigned_long interval, SWIGTYPE_p_unsigned_long rate, SWIGTYPE_p_unsigned_long bit) { + string ret = freeswitchPINVOKE.switch_parse_codec_buf(buf, SWIGTYPE_p_unsigned_long.getCPtr(interval), SWIGTYPE_p_unsigned_long.getCPtr(rate), SWIGTYPE_p_unsigned_long.getCPtr(bit)); + return ret; + } + public static switch_dialplan_interface switch_loadable_module_get_dialplan_interface(string name) { IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_dialplan_interface(name); switch_dialplan_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_dialplan_interface(cPtr, false); @@ -3445,6 +3542,12 @@ public class freeswitch { return ret; } + public static string switch_strerror_r(int errnum, string buf, SWIGTYPE_p_switch_size_t buflen) { + string ret = freeswitchPINVOKE.switch_strerror_r(errnum, buf, SWIGTYPE_p_switch_size_t.getCPtr(buflen)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static switch_caller_extension switch_caller_extension_new(SWIGTYPE_p_switch_core_session session, string extension_name, string extension_number) { IntPtr cPtr = freeswitchPINVOKE.switch_caller_extension_new(SWIGTYPE_p_switch_core_session.getCPtr(session), extension_name, extension_number); switch_caller_extension ret = (cPtr == IntPtr.Zero) ? null : new switch_caller_extension(cPtr, false); @@ -4080,6 +4183,11 @@ public class freeswitch { freeswitchPINVOKE.switch_channel_transfer_to_extension(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_caller_extension.getCPtr(caller_extension)); } + public static string switch_channel_get_partner_uuid(SWIGTYPE_p_switch_channel channel) { + string ret = freeswitchPINVOKE.switch_channel_get_partner_uuid(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + public static switch_status_t switch_buffer_create(SWIGTYPE_p_apr_pool_t pool, SWIGTYPE_p_p_switch_buffer buffer, SWIGTYPE_p_switch_size_t max_len) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_buffer_create(SWIGTYPE_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_p_switch_buffer.getCPtr(buffer), SWIGTYPE_p_switch_size_t.getCPtr(max_len)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4370,6 +4478,14 @@ public class freeswitch { return ret; } + public static void switch_event_add_presence_data_cols(SWIGTYPE_p_switch_channel channel, switch_event arg1, string prefix) { + freeswitchPINVOKE.switch_event_add_presence_data_cols(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1), prefix); + } + + public static void switch_event_launch_dispatch_threads(uint max) { + freeswitchPINVOKE.switch_event_launch_dispatch_threads(max); + } + 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; @@ -4426,6 +4542,11 @@ public class freeswitch { return ret; } + public static uint switch_unmerge_sln(SWIGTYPE_p_short data, uint samples, SWIGTYPE_p_short other_data, uint other_samples) { + uint ret = freeswitchPINVOKE.switch_unmerge_sln(SWIGTYPE_p_short.getCPtr(data), samples, SWIGTYPE_p_short.getCPtr(other_data), other_samples); + return ret; + } + public static void switch_mux_channels(SWIGTYPE_p_short data, SWIGTYPE_p_switch_size_t samples, uint channels) { freeswitchPINVOKE.switch_mux_channels(SWIGTYPE_p_short.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(samples), channels); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4441,6 +4562,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_generate_json_cdr(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_cJSON json_cdr, switch_bool_t urlencode) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_generate_json_cdr(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_cJSON.getCPtr(json_cdr), (int)urlencode); + return ret; + } + public static switch_status_t switch_ivr_generate_xml_cdr(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_xml xml_cdr) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_generate_xml_cdr(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_xml.getCPtr(xml_cdr)); return ret; @@ -4572,6 +4698,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_eavesdrop_pop_eavesdropper(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session sessionp) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_pop_eavesdropper(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(sessionp)); + return ret; + } + + public static switch_status_t switch_ivr_eavesdrop_exec_all(SWIGTYPE_p_switch_core_session session, string app, string arg) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_exec_all(SWIGTYPE_p_switch_core_session.getCPtr(session), app, arg); + return ret; + } + + public static switch_status_t switch_ivr_eavesdrop_update_display(SWIGTYPE_p_switch_core_session session, string name, string number) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_update_display(SWIGTYPE_p_switch_core_session.getCPtr(session), name, number); + return ret; + } + public static switch_status_t switch_ivr_eavesdrop_session(SWIGTYPE_p_switch_core_session session, string uuid, string require_group, uint flags) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_session(SWIGTYPE_p_switch_core_session.getCPtr(session), uuid, require_group, flags); return ret; @@ -5088,6 +5229,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_blind_transfer_ack(SWIGTYPE_p_switch_core_session session, switch_bool_t success) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_blind_transfer_ack(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)success); + return ret; + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -5205,8 +5351,13 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_destroy(SWIGTYPE_p_p_switch_rtp.getCPtr(rtp_session)); } - public static switch_status_t switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp rtp_session, string login, string rlogin) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), login, rlogin); + public static switch_status_t switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp rtp_session, string login, string rlogin, string password) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), login, rlogin, password); + return ret; + } + + public static switch_status_t switch_rtp_activate_rtcp_ice(SWIGTYPE_p_switch_rtp rtp_session, string login, string rlogin, string password) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_rtcp_ice(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), login, rlogin, password); return ret; } @@ -5254,6 +5405,10 @@ public class freeswitch { return ret; } + public static void switch_rtp_ping(SWIGTYPE_p_switch_rtp rtp_session) { + freeswitchPINVOKE.switch_rtp_ping(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session)); + } + public static uint switch_rtp_get_default_samples_per_interval(SWIGTYPE_p_switch_rtp rtp_session) { uint ret = freeswitchPINVOKE.switch_rtp_get_default_samples_per_interval(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session)); return ret; @@ -5387,6 +5542,10 @@ public class freeswitch { return ret; } + public static void switch_rtp_set_interdigit_delay(SWIGTYPE_p_switch_rtp rtp_session, uint delay) { + freeswitchPINVOKE.switch_rtp_set_interdigit_delay(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), delay); + } + public static switch_status_t switch_log_init(SWIGTYPE_p_apr_pool_t pool, switch_bool_t colorize) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_log_init(SWIGTYPE_p_apr_pool_t.getCPtr(pool), (int)colorize); return ret; @@ -5773,11 +5932,6 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_event_hook_add_resurrect_session(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_add_resurrect_session(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(resurrect_session)); - return ret; - } - public static switch_status_t switch_core_event_hook_remove_outgoing_channel(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_core_session_p_switch_event_p_switch_caller_profile_p_switch_core_session_unsigned_long__switch_status_t outgoing_channel) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_remove_outgoing_channel(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_core_session_p_switch_event_p_switch_caller_profile_p_switch_core_session_unsigned_long__switch_status_t.getCPtr(outgoing_channel)); return ret; @@ -5838,11 +5992,6 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_event_hook_remove_resurrect_session(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_remove_resurrect_session(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(resurrect_session)); - return ret; - } - public static uint switch_scheduler_add_task(SWIGTYPE_p_time_t task_runtime, SWIGTYPE_p_f_p_switch_scheduler_task__void func, string desc, string group, uint cmd_id, SWIGTYPE_p_void cmd_arg, uint flags) { uint ret = freeswitchPINVOKE.switch_scheduler_add_task(SWIGTYPE_p_time_t.getCPtr(task_runtime), SWIGTYPE_p_f_p_switch_scheduler_task__void.getCPtr(func), desc, group, cmd_id, SWIGTYPE_p_void.getCPtr(cmd_arg), flags); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -6004,7 +6153,9 @@ public class freeswitch { public static readonly string SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE = freeswitchPINVOKE.SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE_get(); public static readonly string SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_READ_RESULT_VARIABLE = freeswitchPINVOKE.SWITCH_READ_RESULT_VARIABLE_get(); + public static readonly string SWITCH_ATT_XFER_RESULT_VARIABLE = freeswitchPINVOKE.SWITCH_ATT_XFER_RESULT_VARIABLE_get(); public static readonly string SWITCH_COPY_XML_CDR_VARIABLE = freeswitchPINVOKE.SWITCH_COPY_XML_CDR_VARIABLE_get(); + public static readonly string SWITCH_COPY_JSON_CDR_VARIABLE = freeswitchPINVOKE.SWITCH_COPY_JSON_CDR_VARIABLE_get(); public static readonly string SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE = freeswitchPINVOKE.SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get(); public static readonly string SWITCH_TRANSFER_HISTORY_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_HISTORY_VARIABLE_get(); public static readonly string SWITCH_TRANSFER_SOURCE_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_SOURCE_VARIABLE_get(); @@ -6014,12 +6165,14 @@ public class freeswitch { public static readonly string SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get(); + public static readonly string SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_RING_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_RING_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get(); + public static readonly string SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CALL_TIMEOUT_VARIABLE = freeswitchPINVOKE.SWITCH_CALL_TIMEOUT_VARIABLE_get(); public static readonly string SWITCH_HOLDING_UUID_VARIABLE = freeswitchPINVOKE.SWITCH_HOLDING_UUID_VARIABLE_get(); public static readonly string SWITCH_SOFT_HOLDING_UUID_VARIABLE = freeswitchPINVOKE.SWITCH_SOFT_HOLDING_UUID_VARIABLE_get(); @@ -6039,6 +6192,7 @@ public class freeswitch { public static readonly string SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME = freeswitchPINVOKE.SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME_get(); public static readonly string SWITCH_BYPASS_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_BYPASS_MEDIA_VARIABLE_get(); public static readonly string SWITCH_PROXY_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_PROXY_MEDIA_VARIABLE_get(); + public static readonly string SWITCH_ZRTP_PASSTHRU_VARIABLE = freeswitchPINVOKE.SWITCH_ZRTP_PASSTHRU_VARIABLE_get(); public static readonly string SWITCH_ENDPOINT_DISPOSITION_VARIABLE = freeswitchPINVOKE.SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get(); public static readonly string SWITCH_HOLD_MUSIC_VARIABLE = freeswitchPINVOKE.SWITCH_HOLD_MUSIC_VARIABLE_get(); public static readonly string SWITCH_TEMP_HOLD_MUSIC_VARIABLE = freeswitchPINVOKE.SWITCH_TEMP_HOLD_MUSIC_VARIABLE_get(); @@ -6051,6 +6205,7 @@ public class freeswitch { public static readonly string SWITCH_LAST_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_LAST_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_SIGNAL_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_SIGNAL_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_SIGNAL_BOND_VARIABLE = freeswitchPINVOKE.SWITCH_SIGNAL_BOND_VARIABLE_get(); + public static readonly string SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get(); public static readonly string SWITCH_ORIGINATOR_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_VARIABLE_get(); public static readonly string SWITCH_ORIGINATOR_CODEC_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_CODEC_VARIABLE_get(); public static readonly string SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE_get(); @@ -6551,9 +6706,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_READ_RESULT_VARIABLE_get")] public static extern string SWITCH_READ_RESULT_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ATT_XFER_RESULT_VARIABLE_get")] + public static extern string SWITCH_ATT_XFER_RESULT_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get")] public static extern string SWITCH_COPY_XML_CDR_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_COPY_JSON_CDR_VARIABLE_get")] + public static extern string SWITCH_COPY_JSON_CDR_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get")] public static extern string SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get(); @@ -6581,6 +6742,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get")] public static extern string SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get")] + public static extern string SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get")] public static extern string SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get(); @@ -6599,6 +6763,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get")] public static extern string SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get")] + public static extern string SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get")] public static extern string SWITCH_CALL_TIMEOUT_VARIABLE_get(); @@ -6656,6 +6823,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_PROXY_MEDIA_VARIABLE_get")] public static extern string SWITCH_PROXY_MEDIA_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ZRTP_PASSTHRU_VARIABLE_get")] + public static extern string SWITCH_ZRTP_PASSTHRU_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get")] public static extern string SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get(); @@ -6692,6 +6862,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_SIGNAL_BOND_VARIABLE_get")] public static extern string SWITCH_SIGNAL_BOND_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get")] + public static extern string SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ORIGINATOR_VARIABLE_get")] public static extern string SWITCH_ORIGINATOR_VARIABLE_get(); @@ -7022,6 +7195,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_packet_count_get")] public static extern IntPtr switch_rtp_numbers_t_packet_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_period_packet_count_set")] + public static extern void switch_rtp_numbers_t_period_packet_count_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_period_packet_count_get")] + public static extern IntPtr switch_rtp_numbers_t_period_packet_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_media_packet_count_set")] public static extern void switch_rtp_numbers_t_media_packet_count_set(HandleRef jarg1, HandleRef jarg2); @@ -7082,6 +7261,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtcp_numbers_t_octet_count_get")] public static extern uint switch_rtcp_numbers_t_octet_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtcp_numbers_t_peer_ssrc_set")] + public static extern void switch_rtcp_numbers_t_peer_ssrc_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtcp_numbers_t_peer_ssrc_get")] + public static extern uint switch_rtcp_numbers_t_peer_ssrc_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtcp_numbers_t")] public static extern IntPtr new_switch_rtcp_numbers_t(); @@ -7106,6 +7291,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_stats_t_rtcp_get")] public static extern IntPtr switch_rtp_stats_t_rtcp_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_stats_t_read_count_set")] + public static extern void switch_rtp_stats_t_read_count_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_stats_t_read_count_get")] + public static extern uint switch_rtp_stats_t_read_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtp_stats_t")] public static extern IntPtr new_switch_rtp_stats_t(); @@ -7952,6 +8143,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_disable_heartbeat")] public static extern void switch_core_session_disable_heartbeat(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_pop")] + public static extern int switch_core_media_bug_pop(HandleRef jarg1, string jarg2, HandleRef jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_exec_all")] + public static extern int switch_core_media_bug_exec_all(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_count")] + public static extern uint switch_core_media_bug_count(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_add")] public static extern int switch_core_media_bug_add(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4, HandleRef jarg5, HandleRef jarg6, uint jarg7, HandleRef jarg8); @@ -7976,6 +8176,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_read_replace_frame")] public static extern IntPtr switch_core_media_bug_get_read_replace_frame(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_set_read_demux_frame")] + public static extern void switch_core_media_bug_set_read_demux_frame(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_session")] public static extern IntPtr switch_core_media_bug_get_session(HandleRef jarg1); @@ -8006,8 +8209,8 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_close")] public static extern int switch_core_media_bug_close(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_remove_all")] - public static extern int switch_core_media_bug_remove_all(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_remove_all_function")] + public static extern int switch_core_media_bug_remove_all_function(HandleRef jarg1, string jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_enumerate")] public static extern int switch_core_media_bug_enumerate(HandleRef jarg1, HandleRef jarg2); @@ -8039,6 +8242,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_port_allocator_destroy")] public static extern void switch_core_port_allocator_destroy(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_test_flag")] + public static extern int switch_core_test_flag(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_init")] public static extern int switch_core_init(uint jarg1, int jarg2, ref string jarg3); @@ -8174,6 +8380,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_thread_launch")] public static extern int switch_core_session_thread_launch(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_thread_pool_launch")] + public static extern int switch_core_session_thread_pool_launch(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_channel")] public static extern IntPtr switch_core_session_get_channel(HandleRef jarg1); @@ -8216,11 +8425,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_uuid")] public static extern string switch_core_get_uuid(); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_locate")] - public static extern IntPtr switch_core_session_locate(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_locate")] + public static extern IntPtr switch_core_session_perform_locate(string jarg1, string jarg2, string jarg3, int jarg4); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_force_locate")] - public static extern IntPtr switch_core_session_force_locate(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_force_locate")] + public static extern IntPtr switch_core_session_perform_force_locate(string jarg1, string jarg2, string jarg3, int jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable")] public static extern string switch_core_get_variable(string jarg1); @@ -8255,8 +8464,8 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_hupall_endpoint")] public static extern void switch_core_session_hupall_endpoint(HandleRef jarg1, int jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_partner")] - public static extern int switch_core_session_get_partner(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_get_partner")] + public static extern int switch_core_session_perform_get_partner(HandleRef jarg1, HandleRef jarg2, string jarg3, string jarg4, int jarg5); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_message_send")] public static extern int switch_core_session_message_send(string jarg1, HandleRef jarg2); @@ -8336,9 +8545,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_outgoing_channel")] public static extern int switch_core_session_outgoing_channel(HandleRef jarg1, HandleRef jarg2, string jarg3, HandleRef jarg4, HandleRef jarg5, HandleRef jarg6, uint jarg7, HandleRef jarg8); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_resurrect_channel")] - public static extern int switch_core_session_resurrect_channel(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_receive_message")] public static extern int switch_core_session_perform_receive_message(HandleRef jarg1, HandleRef jarg2, string jarg3, string jarg4, int jarg5); @@ -8519,6 +8725,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_read_impl")] public static extern int switch_core_session_get_read_impl(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_real_read_impl")] + public static extern int switch_core_session_get_real_read_impl(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_write_impl")] public static extern int switch_core_session_get_write_impl(HandleRef jarg1, HandleRef jarg2); @@ -8576,6 +8785,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_write")] public static extern int switch_core_file_write(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_write_video")] + public static extern int switch_core_file_write_video(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_seek")] public static extern int switch_core_file_seek(HandleRef jarg1, HandleRef jarg2, long jarg3, int jarg4); @@ -8759,6 +8971,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_micro_time_now")] public static extern IntPtr switch_micro_time_now(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_mono_micro_time_now")] + public static extern IntPtr switch_mono_micro_time_now(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_memory_reclaim")] public static extern void switch_core_memory_reclaim(); @@ -8783,6 +8998,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_epoch_time_now")] public static extern IntPtr switch_epoch_time_now(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_lookup_timezone")] + public static extern string switch_lookup_timezone(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_strftime_tz")] public static extern int switch_strftime_tz(string jarg1, string jarg2, string jarg3, uint jarg4, HandleRef jarg5); @@ -8810,6 +9028,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_time_set_cond_yield")] public static extern void switch_time_set_cond_yield(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_time_set_use_system_time")] + public static extern void switch_time_set_use_system_time(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_min_dtmf_duration")] public static extern uint switch_core_min_dtmf_duration(uint jarg1); @@ -8844,7 +9065,7 @@ class freeswitchPINVOKE { public static extern void switch_cond_next(); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send_args")] - public static extern int switch_core_chat_send_args(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8); + public static extern int switch_core_chat_send_args(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8, int jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send")] public static extern int switch_core_chat_send(string jarg1, HandleRef jarg2); @@ -8855,6 +9076,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_preprocess_session")] public static extern int switch_ivr_preprocess_session(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_stop_thread")] + public static extern void switch_core_sqldb_stop_thread(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_start_thread")] + public static extern void switch_core_sqldb_start_thread(); + [DllImport("mod_managed", EntryPoint="CSharp_CACHE_DB_LEN_get")] public static extern int CACHE_DB_LEN_get(); @@ -8963,6 +9190,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp__switch_core_db_handle")] public static extern int _switch_core_db_handle(HandleRef jarg1, string jarg2, string jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp__switch_core_recovery_db_handle")] + public static extern int _switch_core_recovery_db_handle(HandleRef jarg1, string jarg2, string jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_test_reactive")] public static extern int switch_cache_db_test_reactive(HandleRef jarg1, string jarg2, string jarg3, string jarg4); @@ -8991,7 +9221,7 @@ class freeswitchPINVOKE { public static extern uint switch_default_ptime(string jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_add_registration")] - public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8); + public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8, string jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_del_registration")] public static extern int switch_core_del_registration(string jarg1, string jarg2, string jarg3); @@ -9023,6 +9253,27 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_close_extra_files")] public static extern void switch_close_extra_files(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_thread_set_cpu_affinity")] + public static extern int switch_core_thread_set_cpu_affinity(int jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_os_yield")] + public static extern void switch_os_yield(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_stacksizes")] + public static extern int switch_core_get_stacksizes(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_recover")] + public static extern int switch_core_recovery_recover(string jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_untrack")] + public static extern void switch_core_recovery_untrack(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_track")] + public static extern void switch_core_recovery_track(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_flush")] + public static extern void switch_core_recovery_flush(string jarg1, string jarg2); + [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); @@ -9155,6 +9406,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_codec_interface")] public static extern IntPtr switch_loadable_module_get_codec_interface(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_parse_codec_buf")] + public static extern string switch_parse_codec_buf(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_dialplan_interface")] public static extern IntPtr switch_loadable_module_get_dialplan_interface(string jarg1); @@ -9605,6 +9859,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_atoul")] public static extern uint switch_atoul(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_strerror_r")] + public static extern string switch_strerror_r(int jarg1, string jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_profile_node_t_var_set")] public static extern void profile_node_t_var_set(HandleRef jarg1, string jarg2); @@ -10286,12 +10543,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_state_run_get")] public static extern IntPtr switch_io_routines_state_run_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_resurrect_session_set")] - public static extern void switch_io_routines_resurrect_session_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_resurrect_session_get")] - public static extern IntPtr switch_io_routines_resurrect_session_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_padding_set")] public static extern void switch_io_routines_padding_set(HandleRef jarg1, HandleRef jarg2); @@ -10358,6 +10609,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_endpoint_interface_next_get")] public static extern IntPtr switch_endpoint_interface_next_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_endpoint_interface_recover_callback_set")] + public static extern void switch_endpoint_interface_recover_callback_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_endpoint_interface_recover_callback_get")] + public static extern IntPtr switch_endpoint_interface_recover_callback_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_endpoint_interface")] public static extern IntPtr new_switch_endpoint_interface(); @@ -10586,6 +10843,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_write_get")] public static extern IntPtr switch_file_interface_file_write_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_read_video_set")] + public static extern void switch_file_interface_file_read_video_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_read_video_get")] + public static extern IntPtr switch_file_interface_file_read_video_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_write_video_set")] + public static extern void switch_file_interface_file_write_video_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_write_video_get")] + public static extern IntPtr switch_file_interface_file_write_video_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_seek_set")] public static extern void switch_file_interface_file_seek_set(HandleRef jarg1, HandleRef jarg2); @@ -12593,6 +12862,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_transfer_to_extension")] public static extern void switch_channel_transfer_to_extension(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_partner_uuid")] + public static extern string switch_channel_get_partner_uuid(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_buffer_create")] public static extern int switch_buffer_create(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); @@ -12887,6 +13159,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_check_permission_list")] public static extern int switch_event_check_permission_list(HandleRef jarg1, string jarg2); + [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_event_launch_dispatch_threads")] + public static extern void switch_event_launch_dispatch_threads(uint jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RESAMPLE_QUALITY_get")] public static extern int SWITCH_RESAMPLE_QUALITY_get(); @@ -12980,6 +13258,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_merge_sln")] public static extern uint switch_merge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_unmerge_sln")] + public static extern uint switch_unmerge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_mux_channels")] public static extern void switch_mux_channels(HandleRef jarg1, HandleRef jarg2, uint jarg3); @@ -13091,6 +13372,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_activate_unicast")] public static extern int switch_ivr_activate_unicast(HandleRef jarg1, string jarg2, ushort jarg3, string jarg4, ushort jarg5, string jarg6, string jarg7); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_generate_json_cdr")] + public static extern int switch_ivr_generate_json_cdr(HandleRef jarg1, HandleRef jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_generate_xml_cdr")] public static extern int switch_ivr_generate_xml_cdr(HandleRef jarg1, HandleRef jarg2); @@ -13169,6 +13453,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_record_session")] public static extern int switch_ivr_record_session(HandleRef jarg1, string jarg2, uint jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_pop_eavesdropper")] + public static extern int switch_ivr_eavesdrop_pop_eavesdropper(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_exec_all")] + public static extern int switch_ivr_eavesdrop_exec_all(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_update_display")] + public static extern int switch_ivr_eavesdrop_update_display(HandleRef jarg1, string jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_session")] public static extern int switch_ivr_eavesdrop_session(HandleRef jarg1, string jarg2, string jarg3, uint jarg4); @@ -13481,6 +13774,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_kill_uuid")] public static extern int switch_ivr_kill_uuid(string jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_blind_transfer_ack")] + public static extern int switch_ivr_blind_transfer_ack(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); @@ -13611,7 +13907,10 @@ class freeswitchPINVOKE { public static extern void switch_rtp_destroy(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_ice")] - public static extern int switch_rtp_activate_ice(HandleRef jarg1, string jarg2, string jarg3); + public static extern int switch_rtp_activate_ice(HandleRef jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_rtcp_ice")] + public static extern int switch_rtp_activate_rtcp_ice(HandleRef jarg1, string jarg2, string jarg3, string jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_rtcp")] public static extern int switch_rtp_activate_rtcp(HandleRef jarg1, int jarg2, ushort jarg3); @@ -13640,6 +13939,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_rtp_socket")] public static extern IntPtr switch_rtp_get_rtp_socket(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_ping")] + public static extern void switch_rtp_ping(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_default_samples_per_interval")] public static extern uint switch_rtp_get_default_samples_per_interval(HandleRef jarg1); @@ -13724,6 +14026,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_check_auto_adj")] public static extern byte switch_rtp_check_auto_adj(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_interdigit_delay")] + public static extern void switch_rtp_set_interdigit_delay(HandleRef jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_log_node_t_data_set")] public static extern void switch_log_node_t_data_set(HandleRef jarg1, string jarg2); @@ -14270,24 +14575,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_io_event_hook_state_run")] public static extern void delete_switch_io_event_hook_state_run(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_resurrect_session_set")] - public static extern void switch_io_event_hook_resurrect_session_resurrect_session_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_resurrect_session_get")] - public static extern IntPtr switch_io_event_hook_resurrect_session_resurrect_session_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_next_set")] - public static extern void switch_io_event_hook_resurrect_session_next_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_next_get")] - public static extern IntPtr switch_io_event_hook_resurrect_session_next_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_new_switch_io_event_hook_resurrect_session")] - public static extern IntPtr new_switch_io_event_hook_resurrect_session(); - - [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_io_event_hook_resurrect_session")] - public static extern void delete_switch_io_event_hook_resurrect_session(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_outgoing_channel_set")] public static extern void switch_io_event_hooks_outgoing_channel_set(HandleRef jarg1, HandleRef jarg2); @@ -14360,12 +14647,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_state_run_get")] public static extern IntPtr switch_io_event_hooks_state_run_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_resurrect_session_set")] - public static extern void switch_io_event_hooks_resurrect_session_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_resurrect_session_get")] - public static extern IntPtr switch_io_event_hooks_resurrect_session_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_new_switch_io_event_hooks")] public static extern IntPtr new_switch_io_event_hooks(); @@ -14408,9 +14689,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_recv_dtmf")] public static extern int switch_core_event_hook_add_recv_dtmf(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_resurrect_session")] - public static extern int switch_core_event_hook_add_resurrect_session(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_outgoing_channel")] public static extern int switch_core_event_hook_remove_outgoing_channel(HandleRef jarg1, HandleRef jarg2); @@ -14447,9 +14725,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_recv_dtmf")] public static extern int switch_core_event_hook_remove_recv_dtmf(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_resurrect_session")] - public static extern int switch_core_event_hook_remove_resurrect_session(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_created_set")] public static extern void switch_scheduler_task_created_set(HandleRef jarg1, long jarg2); @@ -14784,7 +15059,7 @@ class freeswitchPINVOKE { public static extern uint EventConsumer_node_index_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_new_EventConsumer")] - public static extern IntPtr new_EventConsumer(string jarg1, string jarg2); + public static extern IntPtr new_EventConsumer(string jarg1, string jarg2, int jarg3); [DllImport("mod_managed", EntryPoint="CSharp_delete_EventConsumer")] public static extern void delete_EventConsumer(HandleRef jarg1); @@ -15590,36 +15865,6 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; -public class SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t { - private HandleRef swigCPtr; - - internal SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t(IntPtr cPtr, bool futureUse) { - swigCPtr = new HandleRef(this, cPtr); - } - - protected SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t() { - swigCPtr = new HandleRef(null, IntPtr.Zero); - } - - internal static HandleRef getCPtr(SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_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_p_switch_loadable_module_interface_p_apr_pool_t__switch_status_t { private HandleRef swigCPtr; @@ -16880,6 +17125,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_switch_core_session__int { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_core_session__int(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_core_session__int() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_core_session__int 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_core_session__switch_status_t { private HandleRef swigCPtr; @@ -17420,6 +17695,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_switch_media_bug_p_void__void { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_media_bug_p_void__void(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_media_bug_p_void__void() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_media_bug_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_rtp_p_switch_socket_t_p_void_switch_size_t_p_switch_sockaddr_t__void { private HandleRef swigCPtr; @@ -18200,6 +18505,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_cJSON { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_cJSON(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_cJSON() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_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_p_p_char { private HandleRef swigCPtr; @@ -23052,8 +23387,18 @@ public enum switch_channel_flag_t { CF_VIDEO_REFRESH_REQ, CF_SERVICE_AUDIO, CF_SERVICE_VIDEO, + CF_ZRTP_PASSTHRU_REQ, + CF_ZRTP_PASSTHRU, CF_ZRTP_HASH, - CF_ZRTP_PASS, + CF_CHANNEL_SWAP, + CF_PICKUP, + CF_CONFIRM_BLIND_TRANSFER, + CF_NO_PRESENCE, + CF_CONFERENCE, + CF_RECOVERING, + CF_RECOVERING_BRIDGE, + CF_TRACKED, + CF_TRACKABLE, CF_FLAG_MAX } @@ -24660,7 +25005,9 @@ namespace FreeSWITCH.Native { SCF_THREADED_SYSTEM_EXEC = (1 << 18), SCF_SYNC_CLOCK_REQUESTED = (1 << 19), SCF_CORE_ODBC_REQ = (1 << 20), - SCF_DEBUG_SQL = (1 << 21) + SCF_DEBUG_SQL = (1 << 21), + SCF_API_EXPANSION = (1 << 22), + SCF_SESSION_THREAD_POOL = (1 << 23) } } @@ -24971,6 +25318,8 @@ public enum switch_core_session_message_types_t { SWITCH_MESSAGE_INDICATE_SIGNAL_DATA, SWITCH_MESSAGE_INDICATE_INFO, SWITCH_MESSAGE_INDICATE_AUDIO_DATA, + SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, + SWITCH_MESSAGE_INDICATE_STUN_ERROR, SWITCH_MESSAGE_INVALID } @@ -25930,7 +26279,8 @@ namespace FreeSWITCH.Native { ED_NONE = 0, ED_MUX_READ = (1 << 0), ED_MUX_WRITE = (1 << 1), - ED_DTMF = (1 << 2) + ED_DTMF = (1 << 2), + ED_COPY_DISPLAY = (1 << 3) } } @@ -26074,6 +26424,17 @@ public class switch_endpoint_interface : IDisposable { } } + public SWIGTYPE_p_f_p_switch_core_session__int recover_callback { + set { + freeswitchPINVOKE.switch_endpoint_interface_recover_callback_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session__int.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_endpoint_interface_recover_callback_get(swigCPtr); + 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 switch_endpoint_interface() : this(freeswitchPINVOKE.new_switch_endpoint_interface(), true) { } @@ -26472,6 +26833,10 @@ public enum switch_event_types_t { SWITCH_EVENT_SOCKET_DATA, SWITCH_EVENT_MEDIA_BUG_START, SWITCH_EVENT_MEDIA_BUG_STOP, + SWITCH_EVENT_CONFERENCE_DATA_QUERY, + SWITCH_EVENT_CONFERENCE_DATA, + SWITCH_EVENT_CALL_SETUP_REQ, + SWITCH_EVENT_CALL_SETUP_RESULT, SWITCH_EVENT_ALL } @@ -27075,6 +27440,28 @@ public class switch_file_interface : IDisposable { } } + public SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t file_read_video { + set { + freeswitchPINVOKE.switch_file_interface_file_read_video_set(swigCPtr, SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_file_interface_file_read_video_get(swigCPtr); + SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t(cPtr, false); + return ret; + } + } + + public SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t file_write_video { + set { + freeswitchPINVOKE.switch_file_interface_file_write_video_set(swigCPtr, SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_file_interface_file_write_video_get(swigCPtr); + SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t(cPtr, false); + return ret; + } + } + public SWIGTYPE_p_f_p_switch_file_handle_p_unsigned_int_long_long_int__switch_status_t file_seek { set { freeswitchPINVOKE.switch_file_interface_file_seek_set(swigCPtr, SWIGTYPE_p_f_p_switch_file_handle_p_unsigned_int_long_long_int__switch_status_t.getCPtr(value)); @@ -27722,17 +28109,6 @@ public class switch_io_event_hooks : IDisposable { } } - public switch_io_event_hook_resurrect_session resurrect_session { - set { - freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_get(swigCPtr); - switch_io_event_hook_resurrect_session ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_resurrect_session(cPtr, false); - return ret; - } - } - public switch_io_event_hooks() : this(freeswitchPINVOKE.new_switch_io_event_hooks(), true) { } @@ -28178,77 +28554,6 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; -public class switch_io_event_hook_resurrect_session : IDisposable { - private HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal switch_io_event_hook_resurrect_session(IntPtr cPtr, bool cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = new HandleRef(this, cPtr); - } - - internal static HandleRef getCPtr(switch_io_event_hook_resurrect_session obj) { - return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; - } - - ~switch_io_event_hook_resurrect_session() { - Dispose(); - } - - public virtual void Dispose() { - lock(this) { - if (swigCPtr.Handle != IntPtr.Zero) { - if (swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_resurrect_session(swigCPtr); - } - swigCPtr = new HandleRef(null, IntPtr.Zero); - } - GC.SuppressFinalize(this); - } - } - - public SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session { - set { - freeswitchPINVOKE.switch_io_event_hook_resurrect_session_resurrect_session_set(swigCPtr, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_resurrect_session_resurrect_session_get(swigCPtr); - SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t(cPtr, false); - return ret; - } - } - - public switch_io_event_hook_resurrect_session next { - set { - freeswitchPINVOKE.switch_io_event_hook_resurrect_session_next_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_resurrect_session_next_get(swigCPtr); - switch_io_event_hook_resurrect_session ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_resurrect_session(cPtr, false); - return ret; - } - } - - public switch_io_event_hook_resurrect_session() : this(freeswitchPINVOKE.new_switch_io_event_hook_resurrect_session(), 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_io_event_hook_send_dtmf : IDisposable { private HandleRef swigCPtr; protected bool swigCMemOwn; @@ -28843,17 +29148,6 @@ public class switch_io_routines : IDisposable { } } - public SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session { - set { - freeswitchPINVOKE.switch_io_routines_resurrect_session_set(swigCPtr, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_routines_resurrect_session_get(swigCPtr); - SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t(cPtr, false); - return ret; - } - } - public SWIGTYPE_p_p_void padding { set { freeswitchPINVOKE.switch_io_routines_padding_set(swigCPtr, SWIGTYPE_p_p_void.getCPtr(value)); @@ -28891,8 +29185,7 @@ public enum switch_io_routine_name_t { SWITCH_IO_RECEIVE_EVENT, SWITCH_IO_STATE_CHANGE, SWITCH_IO_READ_VIDEO_FRAME, - SWITCH_IO_WRITE_VIDEO_FRAME, - SWITCH_IO_RESURRECT_SESSION + SWITCH_IO_WRITE_VIDEO_FRAME } } @@ -29926,7 +30219,8 @@ namespace FreeSWITCH.Native { SMBF_THREAD_LOCK = (1 << 7), SMBF_PRUNE = (1 << 8), SMBF_NO_PAUSE = (1 << 9), - SMBF_STEREO_SWAP = (1 << 10) + SMBF_STEREO_SWAP = (1 << 10), + SMBF_LOCK = (1 << 11) } } @@ -30232,6 +30526,16 @@ public class switch_rtcp_numbers_t : IDisposable { } } + public uint peer_ssrc { + set { + freeswitchPINVOKE.switch_rtcp_numbers_t_peer_ssrc_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_rtcp_numbers_t_peer_ssrc_get(swigCPtr); + return ret; + } + } + public switch_rtcp_numbers_t() : this(freeswitchPINVOKE.new_switch_rtcp_numbers_t(), true) { } @@ -30258,7 +30562,8 @@ public enum switch_rtp_bug_flag_t { RTP_BUG_NEVER_SEND_MARKER = (1 << 5), RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6), RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7), - RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8) + RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8), + RTP_BUG_CHANGE_SSRC_ON_MARKER = (1 << 9) } } @@ -30680,6 +30985,18 @@ public class switch_rtp_numbers_t : IDisposable { } } + public SWIGTYPE_p_switch_size_t period_packet_count { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_period_packet_count_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_period_packet_count_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public SWIGTYPE_p_switch_size_t media_packet_count { set { freeswitchPINVOKE.switch_rtp_numbers_t_media_packet_count_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); @@ -30846,6 +31163,16 @@ public class switch_rtp_stats_t : IDisposable { } } + public uint read_count { + set { + freeswitchPINVOKE.switch_rtp_stats_t_read_count_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_rtp_stats_t_read_count_get(swigCPtr); + return ret; + } + } + public switch_rtp_stats_t() : this(freeswitchPINVOKE.new_switch_rtp_stats_t(), true) { } @@ -31318,7 +31645,10 @@ public enum switch_session_ctl_t { SCSC_READY_CHECK, SCSC_THREADED_SYSTEM_EXEC, SCSC_SYNC_CLOCK_WHEN_IDLE, - SCSC_DEBUG_SQL + SCSC_DEBUG_SQL, + SCSC_SQL, + SCSC_API_EXPANSION, + SCSC_RECOVER } } diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 94fecfa933..9167e028a0 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -709,7 +709,7 @@ public class EventConsumer : IDisposable { } } - public EventConsumer(string event_name, string subclass_name) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name), true) { + public EventConsumer(string event_name, string subclass_name, int len) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name, len), true) { } public int bind(string event_name, string subclass_name) { @@ -1054,6 +1054,21 @@ public class freeswitch { freeswitchPINVOKE.switch_core_session_disable_heartbeat(SWIGTYPE_p_switch_core_session.getCPtr(session)); } + public static switch_status_t switch_core_media_bug_pop(SWIGTYPE_p_switch_core_session orig_session, string function, SWIGTYPE_p_p_switch_media_bug pop) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_pop(SWIGTYPE_p_switch_core_session.getCPtr(orig_session), function, SWIGTYPE_p_p_switch_media_bug.getCPtr(pop)); + return ret; + } + + public static switch_status_t switch_core_media_bug_exec_all(SWIGTYPE_p_switch_core_session orig_session, string function, SWIGTYPE_p_f_p_switch_media_bug_p_void__void cb, SWIGTYPE_p_void user_data) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_exec_all(SWIGTYPE_p_switch_core_session.getCPtr(orig_session), function, SWIGTYPE_p_f_p_switch_media_bug_p_void__void.getCPtr(cb), SWIGTYPE_p_void.getCPtr(user_data)); + return ret; + } + + public static uint switch_core_media_bug_count(SWIGTYPE_p_switch_core_session orig_session, string function) { + uint ret = freeswitchPINVOKE.switch_core_media_bug_count(SWIGTYPE_p_switch_core_session.getCPtr(orig_session), function); + return ret; + } + public static switch_status_t switch_core_media_bug_add(SWIGTYPE_p_switch_core_session session, string function, string target, SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t callback, SWIGTYPE_p_void user_data, SWIGTYPE_p_time_t stop_time, uint flags, SWIGTYPE_p_p_switch_media_bug new_bug) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_add(SWIGTYPE_p_switch_core_session.getCPtr(session), function, target, SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t.getCPtr(callback), SWIGTYPE_p_void.getCPtr(user_data), SWIGTYPE_p_time_t.getCPtr(stop_time), flags, SWIGTYPE_p_p_switch_media_bug.getCPtr(new_bug)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -1094,6 +1109,10 @@ public class freeswitch { return ret; } + public static void switch_core_media_bug_set_read_demux_frame(SWIGTYPE_p_switch_media_bug bug, switch_frame frame) { + freeswitchPINVOKE.switch_core_media_bug_set_read_demux_frame(SWIGTYPE_p_switch_media_bug.getCPtr(bug), switch_frame.getCPtr(frame)); + } + public static SWIGTYPE_p_switch_core_session switch_core_media_bug_get_session(SWIGTYPE_p_switch_media_bug bug) { IntPtr cPtr = freeswitchPINVOKE.switch_core_media_bug_get_session(SWIGTYPE_p_switch_media_bug.getCPtr(bug)); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); @@ -1144,8 +1163,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_media_bug_remove_all(SWIGTYPE_p_switch_core_session session) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_remove_all(SWIGTYPE_p_switch_core_session.getCPtr(session)); + public static switch_status_t switch_core_media_bug_remove_all_function(SWIGTYPE_p_switch_core_session session, string function) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_media_bug_remove_all_function(SWIGTYPE_p_switch_core_session.getCPtr(session), function); return ret; } @@ -1197,6 +1216,11 @@ public class freeswitch { freeswitchPINVOKE.switch_core_port_allocator_destroy(SWIGTYPE_p_p_switch_core_port_allocator.getCPtr(alloc)); } + public static int switch_core_test_flag(int flag) { + int ret = freeswitchPINVOKE.switch_core_test_flag(flag); + return ret; + } + public static switch_status_t switch_core_init(uint flags, switch_bool_t console, ref string err) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_init(flags, (int)console, ref err); return ret; @@ -1413,6 +1437,11 @@ public class freeswitch { return ret; } + public static SWIGTYPE_p_switch_size_t switch_core_session_id_dec() { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_core_session_id_dec(), true); + return ret; + } + public static SWIGTYPE_p_switch_core_session switch_core_session_request_by_name(string endpoint_name, switch_call_direction_t direction, SWIGTYPE_p_p_apr_pool_t pool) { IntPtr cPtr = freeswitchPINVOKE.switch_core_session_request_by_name(endpoint_name, (int)direction, SWIGTYPE_p_p_apr_pool_t.getCPtr(pool)); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); @@ -1424,6 +1453,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_thread_pool_launch(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_thread_pool_launch(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static SWIGTYPE_p_switch_channel switch_core_session_get_channel(SWIGTYPE_p_switch_core_session session) { IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_channel(SWIGTYPE_p_switch_core_session.getCPtr(session)); SWIGTYPE_p_switch_channel ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_channel(cPtr, false); @@ -1491,14 +1525,14 @@ public class freeswitch { return ret; } - public static SWIGTYPE_p_switch_core_session switch_core_session_locate(string uuid_str) { - IntPtr cPtr = freeswitchPINVOKE.switch_core_session_locate(uuid_str); + public static SWIGTYPE_p_switch_core_session switch_core_session_perform_locate(string uuid_str, string file, string func, int line) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_perform_locate(uuid_str, file, func, line); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); return ret; } - public static SWIGTYPE_p_switch_core_session switch_core_session_force_locate(string uuid_str) { - IntPtr cPtr = freeswitchPINVOKE.switch_core_session_force_locate(uuid_str); + public static SWIGTYPE_p_switch_core_session switch_core_session_perform_force_locate(string uuid_str, string file, string func, int line) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_perform_force_locate(uuid_str, file, func, line); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); return ret; } @@ -1553,8 +1587,8 @@ public class freeswitch { freeswitchPINVOKE.switch_core_session_hupall_endpoint(switch_endpoint_interface.getCPtr(endpoint_interface), (int)cause); } - public static switch_status_t switch_core_session_get_partner(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session partner) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_partner(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(partner)); + public static switch_status_t switch_core_session_perform_get_partner(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session partner, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_perform_get_partner(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(partner), file, func, line); return ret; } @@ -1687,11 +1721,6 @@ public class freeswitch { return ret; } - public static switch_call_cause_t switch_core_session_resurrect_channel(string endpoint_name, SWIGTYPE_p_p_switch_core_session new_session, SWIGTYPE_p_p_apr_pool_t pool, SWIGTYPE_p_void data) { - switch_call_cause_t ret = (switch_call_cause_t)freeswitchPINVOKE.switch_core_session_resurrect_channel(endpoint_name, SWIGTYPE_p_p_switch_core_session.getCPtr(new_session), SWIGTYPE_p_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_void.getCPtr(data)); - return ret; - } - public static switch_status_t switch_core_session_perform_receive_message(SWIGTYPE_p_switch_core_session session, switch_core_session_message message, string file, string func, int line) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_perform_receive_message(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_core_session_message.getCPtr(message), file, func, line); return ret; @@ -1988,6 +2017,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_get_real_read_impl(SWIGTYPE_p_switch_core_session session, switch_codec_implementation impp) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_real_read_impl(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_codec_implementation.getCPtr(impp)); + return ret; + } + public static switch_status_t switch_core_session_get_write_impl(SWIGTYPE_p_switch_core_session session, switch_codec_implementation impp) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_write_impl(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_codec_implementation.getCPtr(impp)); return ret; @@ -2089,6 +2123,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_file_write_video(switch_file_handle fh, SWIGTYPE_p_void data, SWIGTYPE_p_switch_size_t len) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_file_write_video(switch_file_handle.getCPtr(fh), SWIGTYPE_p_void.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(len)); + return ret; + } + public static switch_status_t switch_core_file_seek(switch_file_handle fh, SWIGTYPE_p_unsigned_int cur_pos, long samples, int whence) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_file_seek(switch_file_handle.getCPtr(fh), SWIGTYPE_p_unsigned_int.getCPtr(cur_pos), samples, whence); return ret; @@ -2391,6 +2430,11 @@ public class freeswitch { return ret; } + public static SWIGTYPE_p_switch_time_t switch_mono_micro_time_now() { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_mono_micro_time_now(), true); + return ret; + } + public static void switch_core_memory_reclaim() { freeswitchPINVOKE.switch_core_memory_reclaim(); } @@ -2425,6 +2469,11 @@ public class freeswitch { return ret; } + public static string switch_lookup_timezone(string tz_name) { + string ret = freeswitchPINVOKE.switch_lookup_timezone(tz_name); + return ret; + } + public static switch_status_t switch_strftime_tz(string tz, string format, string date, uint len, SWIGTYPE_p_switch_time_t thetime) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_strftime_tz(tz, format, date, len, SWIGTYPE_p_switch_time_t.getCPtr(thetime)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -2466,6 +2515,10 @@ public class freeswitch { freeswitchPINVOKE.switch_time_set_cond_yield((int)enable); } + public static void switch_time_set_use_system_time(switch_bool_t enable) { + freeswitchPINVOKE.switch_time_set_use_system_time((int)enable); + } + public static uint switch_core_min_dtmf_duration(uint duration) { uint ret = freeswitchPINVOKE.switch_core_min_dtmf_duration(duration); return ret; @@ -2520,8 +2573,8 @@ public class freeswitch { freeswitchPINVOKE.switch_cond_next(); } - public static switch_status_t switch_core_chat_send_args(string dest_proto, string proto, string from, string to, string subject, string body, string type, string hint) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send_args(dest_proto, proto, from, to, subject, body, type, hint); + public static switch_status_t switch_core_chat_send_args(string dest_proto, string proto, string from, string to, string subject, string body, string type, string hint, switch_bool_t blocking) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send_args(dest_proto, proto, from, to, subject, body, type, hint, (int)blocking); return ret; } @@ -2540,6 +2593,14 @@ public class freeswitch { return ret; } + public static void switch_core_sqldb_stop_thread() { + freeswitchPINVOKE.switch_core_sqldb_stop_thread(); + } + + public static void switch_core_sqldb_start_thread() { + freeswitchPINVOKE.switch_core_sqldb_start_thread(); + } + public static string switch_cache_db_type_name(switch_cache_db_handle_type_t type) { string ret = freeswitchPINVOKE.switch_cache_db_type_name((int)type); return ret; @@ -2592,6 +2653,11 @@ public class freeswitch { return ret; } + public static switch_status_t _switch_core_recovery_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_core_recovery_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh), file, func, line); + return ret; + } + public static switch_bool_t switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle db, string test_sql, string drop_sql, string reactive_sql) { switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle.getCPtr(db), test_sql, drop_sql, reactive_sql); return ret; @@ -2635,8 +2701,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto); + public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto, string metadata) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto, metadata); return ret; } @@ -2687,6 +2753,37 @@ public class freeswitch { freeswitchPINVOKE.switch_close_extra_files(SWIGTYPE_p_int.getCPtr(keep), keep_ttl); } + public static switch_status_t switch_core_thread_set_cpu_affinity(int cpu) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_thread_set_cpu_affinity(cpu); + return ret; + } + + public static void switch_os_yield() { + freeswitchPINVOKE.switch_os_yield(); + } + + public static switch_status_t switch_core_get_stacksizes(SWIGTYPE_p_switch_size_t cur, SWIGTYPE_p_switch_size_t max) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_get_stacksizes(SWIGTYPE_p_switch_size_t.getCPtr(cur), SWIGTYPE_p_switch_size_t.getCPtr(max)); + return ret; + } + + public static int switch_core_recovery_recover(string technology, string profile_name) { + int ret = freeswitchPINVOKE.switch_core_recovery_recover(technology, profile_name); + return ret; + } + + public static void switch_core_recovery_untrack(SWIGTYPE_p_switch_core_session session, switch_bool_t force) { + freeswitchPINVOKE.switch_core_recovery_untrack(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)force); + } + + public static void switch_core_recovery_track(SWIGTYPE_p_switch_core_session session) { + freeswitchPINVOKE.switch_core_recovery_track(SWIGTYPE_p_switch_core_session.getCPtr(session)); + } + + public static void switch_core_recovery_flush(string technology, string profile_name) { + freeswitchPINVOKE.switch_core_recovery_flush(technology, profile_name); + } + 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; @@ -2708,6 +2805,11 @@ public class freeswitch { return ret; } + public static string switch_parse_codec_buf(string buf, SWIGTYPE_p_unsigned_long interval, SWIGTYPE_p_unsigned_long rate, SWIGTYPE_p_unsigned_long bit) { + string ret = freeswitchPINVOKE.switch_parse_codec_buf(buf, SWIGTYPE_p_unsigned_long.getCPtr(interval), SWIGTYPE_p_unsigned_long.getCPtr(rate), SWIGTYPE_p_unsigned_long.getCPtr(bit)); + return ret; + } + public static switch_dialplan_interface switch_loadable_module_get_dialplan_interface(string name) { IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_dialplan_interface(name); switch_dialplan_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_dialplan_interface(cPtr, false); @@ -3433,6 +3535,12 @@ public class freeswitch { return ret; } + public static string switch_strerror_r(int errnum, string buf, SWIGTYPE_p_switch_size_t buflen) { + string ret = freeswitchPINVOKE.switch_strerror_r(errnum, buf, SWIGTYPE_p_switch_size_t.getCPtr(buflen)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static switch_caller_extension switch_caller_extension_new(SWIGTYPE_p_switch_core_session session, string extension_name, string extension_number) { IntPtr cPtr = freeswitchPINVOKE.switch_caller_extension_new(SWIGTYPE_p_switch_core_session.getCPtr(session), extension_name, extension_number); switch_caller_extension ret = (cPtr == IntPtr.Zero) ? null : new switch_caller_extension(cPtr, false); @@ -4068,6 +4176,11 @@ public class freeswitch { freeswitchPINVOKE.switch_channel_transfer_to_extension(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_caller_extension.getCPtr(caller_extension)); } + public static string switch_channel_get_partner_uuid(SWIGTYPE_p_switch_channel channel) { + string ret = freeswitchPINVOKE.switch_channel_get_partner_uuid(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + public static switch_status_t switch_buffer_create(SWIGTYPE_p_apr_pool_t pool, SWIGTYPE_p_p_switch_buffer buffer, SWIGTYPE_p_switch_size_t max_len) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_buffer_create(SWIGTYPE_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_p_switch_buffer.getCPtr(buffer), SWIGTYPE_p_switch_size_t.getCPtr(max_len)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4358,6 +4471,14 @@ public class freeswitch { return ret; } + public static void switch_event_add_presence_data_cols(SWIGTYPE_p_switch_channel channel, switch_event arg1, string prefix) { + freeswitchPINVOKE.switch_event_add_presence_data_cols(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1), prefix); + } + + public static void switch_event_launch_dispatch_threads(uint max) { + freeswitchPINVOKE.switch_event_launch_dispatch_threads(max); + } + 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; @@ -4414,6 +4535,11 @@ public class freeswitch { return ret; } + public static uint switch_unmerge_sln(SWIGTYPE_p_short data, uint samples, SWIGTYPE_p_short other_data, uint other_samples) { + uint ret = freeswitchPINVOKE.switch_unmerge_sln(SWIGTYPE_p_short.getCPtr(data), samples, SWIGTYPE_p_short.getCPtr(other_data), other_samples); + return ret; + } + public static void switch_mux_channels(SWIGTYPE_p_short data, SWIGTYPE_p_switch_size_t samples, uint channels) { freeswitchPINVOKE.switch_mux_channels(SWIGTYPE_p_short.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(samples), channels); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4429,6 +4555,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_generate_json_cdr(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_cJSON json_cdr, switch_bool_t urlencode) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_generate_json_cdr(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_cJSON.getCPtr(json_cdr), (int)urlencode); + return ret; + } + public static switch_status_t switch_ivr_generate_xml_cdr(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_xml xml_cdr) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_generate_xml_cdr(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_xml.getCPtr(xml_cdr)); return ret; @@ -4560,6 +4691,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_eavesdrop_pop_eavesdropper(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session sessionp) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_pop_eavesdropper(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(sessionp)); + return ret; + } + + public static switch_status_t switch_ivr_eavesdrop_exec_all(SWIGTYPE_p_switch_core_session session, string app, string arg) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_exec_all(SWIGTYPE_p_switch_core_session.getCPtr(session), app, arg); + return ret; + } + + public static switch_status_t switch_ivr_eavesdrop_update_display(SWIGTYPE_p_switch_core_session session, string name, string number) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_update_display(SWIGTYPE_p_switch_core_session.getCPtr(session), name, number); + return ret; + } + public static switch_status_t switch_ivr_eavesdrop_session(SWIGTYPE_p_switch_core_session session, string uuid, string require_group, uint flags) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_eavesdrop_session(SWIGTYPE_p_switch_core_session.getCPtr(session), uuid, require_group, flags); return ret; @@ -5076,6 +5222,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_blind_transfer_ack(SWIGTYPE_p_switch_core_session session, switch_bool_t success) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_blind_transfer_ack(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)success); + return ret; + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -5193,8 +5344,13 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_destroy(SWIGTYPE_p_p_switch_rtp.getCPtr(rtp_session)); } - public static switch_status_t switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp rtp_session, string login, string rlogin) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), login, rlogin); + public static switch_status_t switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp rtp_session, string login, string rlogin, string password) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_ice(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), login, rlogin, password); + return ret; + } + + public static switch_status_t switch_rtp_activate_rtcp_ice(SWIGTYPE_p_switch_rtp rtp_session, string login, string rlogin, string password) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_rtcp_ice(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), login, rlogin, password); return ret; } @@ -5242,6 +5398,10 @@ public class freeswitch { return ret; } + public static void switch_rtp_ping(SWIGTYPE_p_switch_rtp rtp_session) { + freeswitchPINVOKE.switch_rtp_ping(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session)); + } + public static uint switch_rtp_get_default_samples_per_interval(SWIGTYPE_p_switch_rtp rtp_session) { uint ret = freeswitchPINVOKE.switch_rtp_get_default_samples_per_interval(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session)); return ret; @@ -5375,6 +5535,10 @@ public class freeswitch { return ret; } + public static void switch_rtp_set_interdigit_delay(SWIGTYPE_p_switch_rtp rtp_session, uint delay) { + freeswitchPINVOKE.switch_rtp_set_interdigit_delay(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), delay); + } + public static switch_status_t switch_log_init(SWIGTYPE_p_apr_pool_t pool, switch_bool_t colorize) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_log_init(SWIGTYPE_p_apr_pool_t.getCPtr(pool), (int)colorize); return ret; @@ -5761,11 +5925,6 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_event_hook_add_resurrect_session(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_add_resurrect_session(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(resurrect_session)); - return ret; - } - public static switch_status_t switch_core_event_hook_remove_outgoing_channel(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_core_session_p_switch_event_p_switch_caller_profile_p_switch_core_session_unsigned_long__switch_status_t outgoing_channel) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_remove_outgoing_channel(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_core_session_p_switch_event_p_switch_caller_profile_p_switch_core_session_unsigned_long__switch_status_t.getCPtr(outgoing_channel)); return ret; @@ -5826,11 +5985,6 @@ public class freeswitch { return ret; } - public static switch_status_t switch_core_event_hook_remove_resurrect_session(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_remove_resurrect_session(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(resurrect_session)); - return ret; - } - public static uint switch_scheduler_add_task(SWIGTYPE_p_time_t task_runtime, SWIGTYPE_p_f_p_switch_scheduler_task__void func, string desc, string group, uint cmd_id, SWIGTYPE_p_void cmd_arg, uint flags) { uint ret = freeswitchPINVOKE.switch_scheduler_add_task(SWIGTYPE_p_time_t.getCPtr(task_runtime), SWIGTYPE_p_f_p_switch_scheduler_task__void.getCPtr(func), desc, group, cmd_id, SWIGTYPE_p_void.getCPtr(cmd_arg), flags); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -5992,7 +6146,9 @@ public class freeswitch { public static readonly string SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE = freeswitchPINVOKE.SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE_get(); public static readonly string SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_READ_RESULT_VARIABLE = freeswitchPINVOKE.SWITCH_READ_RESULT_VARIABLE_get(); + public static readonly string SWITCH_ATT_XFER_RESULT_VARIABLE = freeswitchPINVOKE.SWITCH_ATT_XFER_RESULT_VARIABLE_get(); public static readonly string SWITCH_COPY_XML_CDR_VARIABLE = freeswitchPINVOKE.SWITCH_COPY_XML_CDR_VARIABLE_get(); + public static readonly string SWITCH_COPY_JSON_CDR_VARIABLE = freeswitchPINVOKE.SWITCH_COPY_JSON_CDR_VARIABLE_get(); public static readonly string SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE = freeswitchPINVOKE.SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get(); public static readonly string SWITCH_TRANSFER_HISTORY_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_HISTORY_VARIABLE_get(); public static readonly string SWITCH_TRANSFER_SOURCE_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_SOURCE_VARIABLE_get(); @@ -6002,12 +6158,14 @@ public class freeswitch { public static readonly string SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_TONE_DETECT_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get(); + public static readonly string SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_RING_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_RING_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_TONE_DETECT_VARIABLE_get(); public static readonly string SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get(); + public static readonly string SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get(); public static readonly string SWITCH_CALL_TIMEOUT_VARIABLE = freeswitchPINVOKE.SWITCH_CALL_TIMEOUT_VARIABLE_get(); public static readonly string SWITCH_HOLDING_UUID_VARIABLE = freeswitchPINVOKE.SWITCH_HOLDING_UUID_VARIABLE_get(); public static readonly string SWITCH_SOFT_HOLDING_UUID_VARIABLE = freeswitchPINVOKE.SWITCH_SOFT_HOLDING_UUID_VARIABLE_get(); @@ -6027,6 +6185,7 @@ public class freeswitch { public static readonly string SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME = freeswitchPINVOKE.SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME_get(); public static readonly string SWITCH_BYPASS_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_BYPASS_MEDIA_VARIABLE_get(); public static readonly string SWITCH_PROXY_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_PROXY_MEDIA_VARIABLE_get(); + public static readonly string SWITCH_ZRTP_PASSTHRU_VARIABLE = freeswitchPINVOKE.SWITCH_ZRTP_PASSTHRU_VARIABLE_get(); public static readonly string SWITCH_ENDPOINT_DISPOSITION_VARIABLE = freeswitchPINVOKE.SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get(); public static readonly string SWITCH_HOLD_MUSIC_VARIABLE = freeswitchPINVOKE.SWITCH_HOLD_MUSIC_VARIABLE_get(); public static readonly string SWITCH_TEMP_HOLD_MUSIC_VARIABLE = freeswitchPINVOKE.SWITCH_TEMP_HOLD_MUSIC_VARIABLE_get(); @@ -6039,6 +6198,7 @@ public class freeswitch { public static readonly string SWITCH_LAST_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_LAST_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_SIGNAL_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_SIGNAL_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_SIGNAL_BOND_VARIABLE = freeswitchPINVOKE.SWITCH_SIGNAL_BOND_VARIABLE_get(); + public static readonly string SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get(); public static readonly string SWITCH_ORIGINATOR_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_VARIABLE_get(); public static readonly string SWITCH_ORIGINATOR_CODEC_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_CODEC_VARIABLE_get(); public static readonly string SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE_get(); @@ -6535,9 +6695,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_READ_RESULT_VARIABLE_get")] public static extern string SWITCH_READ_RESULT_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ATT_XFER_RESULT_VARIABLE_get")] + public static extern string SWITCH_ATT_XFER_RESULT_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_COPY_XML_CDR_VARIABLE_get")] public static extern string SWITCH_COPY_XML_CDR_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_COPY_JSON_CDR_VARIABLE_get")] + public static extern string SWITCH_COPY_JSON_CDR_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get")] public static extern string SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get(); @@ -6565,6 +6731,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get")] public static extern string SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get")] + public static extern string SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get")] public static extern string SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE_get(); @@ -6583,6 +6752,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get")] public static extern string SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get")] + public static extern string SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CALL_TIMEOUT_VARIABLE_get")] public static extern string SWITCH_CALL_TIMEOUT_VARIABLE_get(); @@ -6640,6 +6812,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_PROXY_MEDIA_VARIABLE_get")] public static extern string SWITCH_PROXY_MEDIA_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ZRTP_PASSTHRU_VARIABLE_get")] + public static extern string SWITCH_ZRTP_PASSTHRU_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get")] public static extern string SWITCH_ENDPOINT_DISPOSITION_VARIABLE_get(); @@ -6676,6 +6851,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_SIGNAL_BOND_VARIABLE_get")] public static extern string SWITCH_SIGNAL_BOND_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get")] + public static extern string SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ORIGINATOR_VARIABLE_get")] public static extern string SWITCH_ORIGINATOR_VARIABLE_get(); @@ -7006,6 +7184,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_packet_count_get")] public static extern IntPtr switch_rtp_numbers_t_packet_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_period_packet_count_set")] + public static extern void switch_rtp_numbers_t_period_packet_count_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_period_packet_count_get")] + public static extern IntPtr switch_rtp_numbers_t_period_packet_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_media_packet_count_set")] public static extern void switch_rtp_numbers_t_media_packet_count_set(HandleRef jarg1, HandleRef jarg2); @@ -7066,6 +7250,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtcp_numbers_t_octet_count_get")] public static extern uint switch_rtcp_numbers_t_octet_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtcp_numbers_t_peer_ssrc_set")] + public static extern void switch_rtcp_numbers_t_peer_ssrc_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtcp_numbers_t_peer_ssrc_get")] + public static extern uint switch_rtcp_numbers_t_peer_ssrc_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtcp_numbers_t")] public static extern IntPtr new_switch_rtcp_numbers_t(); @@ -7090,6 +7280,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_stats_t_rtcp_get")] public static extern IntPtr switch_rtp_stats_t_rtcp_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_stats_t_read_count_set")] + public static extern void switch_rtp_stats_t_read_count_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_stats_t_read_count_get")] + public static extern uint switch_rtp_stats_t_read_count_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtp_stats_t")] public static extern IntPtr new_switch_rtp_stats_t(); @@ -7936,6 +8132,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_disable_heartbeat")] public static extern void switch_core_session_disable_heartbeat(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_pop")] + public static extern int switch_core_media_bug_pop(HandleRef jarg1, string jarg2, HandleRef jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_exec_all")] + public static extern int switch_core_media_bug_exec_all(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_count")] + public static extern uint switch_core_media_bug_count(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_add")] public static extern int switch_core_media_bug_add(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4, HandleRef jarg5, HandleRef jarg6, uint jarg7, HandleRef jarg8); @@ -7960,6 +8165,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_read_replace_frame")] public static extern IntPtr switch_core_media_bug_get_read_replace_frame(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_set_read_demux_frame")] + public static extern void switch_core_media_bug_set_read_demux_frame(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_session")] public static extern IntPtr switch_core_media_bug_get_session(HandleRef jarg1); @@ -7990,8 +8198,8 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_close")] public static extern int switch_core_media_bug_close(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_remove_all")] - public static extern int switch_core_media_bug_remove_all(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_remove_all_function")] + public static extern int switch_core_media_bug_remove_all_function(HandleRef jarg1, string jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_enumerate")] public static extern int switch_core_media_bug_enumerate(HandleRef jarg1, HandleRef jarg2); @@ -8023,6 +8231,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_port_allocator_destroy")] public static extern void switch_core_port_allocator_destroy(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_test_flag")] + public static extern int switch_core_test_flag(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_init")] public static extern int switch_core_init(uint jarg1, int jarg2, ref string jarg3); @@ -8152,12 +8363,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_id")] public static extern IntPtr switch_core_session_id(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_id_dec")] + public static extern IntPtr switch_core_session_id_dec(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_request_by_name")] public static extern IntPtr switch_core_session_request_by_name(string jarg1, int jarg2, HandleRef jarg3); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_thread_launch")] public static extern int switch_core_session_thread_launch(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_thread_pool_launch")] + public static extern int switch_core_session_thread_pool_launch(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_channel")] public static extern IntPtr switch_core_session_get_channel(HandleRef jarg1); @@ -8200,11 +8417,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_uuid")] public static extern string switch_core_get_uuid(); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_locate")] - public static extern IntPtr switch_core_session_locate(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_locate")] + public static extern IntPtr switch_core_session_perform_locate(string jarg1, string jarg2, string jarg3, int jarg4); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_force_locate")] - public static extern IntPtr switch_core_session_force_locate(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_force_locate")] + public static extern IntPtr switch_core_session_perform_force_locate(string jarg1, string jarg2, string jarg3, int jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable")] public static extern string switch_core_get_variable(string jarg1); @@ -8239,8 +8456,8 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_hupall_endpoint")] public static extern void switch_core_session_hupall_endpoint(HandleRef jarg1, int jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_partner")] - public static extern int switch_core_session_get_partner(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_get_partner")] + public static extern int switch_core_session_perform_get_partner(HandleRef jarg1, HandleRef jarg2, string jarg3, string jarg4, int jarg5); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_message_send")] public static extern int switch_core_session_message_send(string jarg1, HandleRef jarg2); @@ -8320,9 +8537,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_outgoing_channel")] public static extern int switch_core_session_outgoing_channel(HandleRef jarg1, HandleRef jarg2, string jarg3, HandleRef jarg4, HandleRef jarg5, HandleRef jarg6, uint jarg7, HandleRef jarg8); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_resurrect_channel")] - public static extern int switch_core_session_resurrect_channel(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_perform_receive_message")] public static extern int switch_core_session_perform_receive_message(HandleRef jarg1, HandleRef jarg2, string jarg3, string jarg4, int jarg5); @@ -8503,6 +8717,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_read_impl")] public static extern int switch_core_session_get_read_impl(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_real_read_impl")] + public static extern int switch_core_session_get_real_read_impl(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_write_impl")] public static extern int switch_core_session_get_write_impl(HandleRef jarg1, HandleRef jarg2); @@ -8560,6 +8777,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_write")] public static extern int switch_core_file_write(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_write_video")] + public static extern int switch_core_file_write_video(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_seek")] public static extern int switch_core_file_seek(HandleRef jarg1, HandleRef jarg2, long jarg3, int jarg4); @@ -8743,6 +8963,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_micro_time_now")] public static extern IntPtr switch_micro_time_now(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_mono_micro_time_now")] + public static extern IntPtr switch_mono_micro_time_now(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_memory_reclaim")] public static extern void switch_core_memory_reclaim(); @@ -8767,6 +8990,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_epoch_time_now")] public static extern IntPtr switch_epoch_time_now(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_lookup_timezone")] + public static extern string switch_lookup_timezone(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_strftime_tz")] public static extern int switch_strftime_tz(string jarg1, string jarg2, string jarg3, uint jarg4, HandleRef jarg5); @@ -8794,6 +9020,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_time_set_cond_yield")] public static extern void switch_time_set_cond_yield(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_time_set_use_system_time")] + public static extern void switch_time_set_use_system_time(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_min_dtmf_duration")] public static extern uint switch_core_min_dtmf_duration(uint jarg1); @@ -8828,7 +9057,7 @@ class freeswitchPINVOKE { public static extern void switch_cond_next(); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send_args")] - public static extern int switch_core_chat_send_args(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8); + public static extern int switch_core_chat_send_args(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8, int jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send")] public static extern int switch_core_chat_send(string jarg1, HandleRef jarg2); @@ -8839,6 +9068,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_preprocess_session")] public static extern int switch_ivr_preprocess_session(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_stop_thread")] + public static extern void switch_core_sqldb_stop_thread(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_sqldb_start_thread")] + public static extern void switch_core_sqldb_start_thread(); + [DllImport("mod_managed", EntryPoint="CSharp_CACHE_DB_LEN_get")] public static extern int CACHE_DB_LEN_get(); @@ -8947,6 +9182,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp__switch_core_db_handle")] public static extern int _switch_core_db_handle(HandleRef jarg1, string jarg2, string jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp__switch_core_recovery_db_handle")] + public static extern int _switch_core_recovery_db_handle(HandleRef jarg1, string jarg2, string jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_test_reactive")] public static extern int switch_cache_db_test_reactive(HandleRef jarg1, string jarg2, string jarg3, string jarg4); @@ -8975,7 +9213,7 @@ class freeswitchPINVOKE { public static extern uint switch_default_ptime(string jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_add_registration")] - public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8); + public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8, string jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_del_registration")] public static extern int switch_core_del_registration(string jarg1, string jarg2, string jarg3); @@ -9007,6 +9245,27 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_close_extra_files")] public static extern void switch_close_extra_files(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_thread_set_cpu_affinity")] + public static extern int switch_core_thread_set_cpu_affinity(int jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_os_yield")] + public static extern void switch_os_yield(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_stacksizes")] + public static extern int switch_core_get_stacksizes(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_recover")] + public static extern int switch_core_recovery_recover(string jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_untrack")] + public static extern void switch_core_recovery_untrack(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_track")] + public static extern void switch_core_recovery_track(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_recovery_flush")] + public static extern void switch_core_recovery_flush(string jarg1, string jarg2); + [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); @@ -9139,6 +9398,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_codec_interface")] public static extern IntPtr switch_loadable_module_get_codec_interface(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_parse_codec_buf")] + public static extern string switch_parse_codec_buf(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_dialplan_interface")] public static extern IntPtr switch_loadable_module_get_dialplan_interface(string jarg1); @@ -9589,6 +9851,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_atoul")] public static extern uint switch_atoul(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_strerror_r")] + public static extern string switch_strerror_r(int jarg1, string jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_profile_node_t_var_set")] public static extern void profile_node_t_var_set(HandleRef jarg1, string jarg2); @@ -10270,12 +10535,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_state_run_get")] public static extern IntPtr switch_io_routines_state_run_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_resurrect_session_set")] - public static extern void switch_io_routines_resurrect_session_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_resurrect_session_get")] - public static extern IntPtr switch_io_routines_resurrect_session_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_padding_set")] public static extern void switch_io_routines_padding_set(HandleRef jarg1, HandleRef jarg2); @@ -10342,6 +10601,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_endpoint_interface_next_get")] public static extern IntPtr switch_endpoint_interface_next_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_endpoint_interface_recover_callback_set")] + public static extern void switch_endpoint_interface_recover_callback_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_endpoint_interface_recover_callback_get")] + public static extern IntPtr switch_endpoint_interface_recover_callback_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_endpoint_interface")] public static extern IntPtr new_switch_endpoint_interface(); @@ -10570,6 +10835,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_write_get")] public static extern IntPtr switch_file_interface_file_write_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_read_video_set")] + public static extern void switch_file_interface_file_read_video_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_read_video_get")] + public static extern IntPtr switch_file_interface_file_read_video_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_write_video_set")] + public static extern void switch_file_interface_file_write_video_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_write_video_get")] + public static extern IntPtr switch_file_interface_file_write_video_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_interface_file_seek_set")] public static extern void switch_file_interface_file_seek_set(HandleRef jarg1, HandleRef jarg2); @@ -12577,6 +12854,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_transfer_to_extension")] public static extern void switch_channel_transfer_to_extension(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_partner_uuid")] + public static extern string switch_channel_get_partner_uuid(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_buffer_create")] public static extern int switch_buffer_create(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); @@ -12871,6 +13151,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_check_permission_list")] public static extern int switch_event_check_permission_list(HandleRef jarg1, string jarg2); + [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_event_launch_dispatch_threads")] + public static extern void switch_event_launch_dispatch_threads(uint jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RESAMPLE_QUALITY_get")] public static extern int SWITCH_RESAMPLE_QUALITY_get(); @@ -12964,6 +13250,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_merge_sln")] public static extern uint switch_merge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_unmerge_sln")] + public static extern uint switch_unmerge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_mux_channels")] public static extern void switch_mux_channels(HandleRef jarg1, HandleRef jarg2, uint jarg3); @@ -13075,6 +13364,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_activate_unicast")] public static extern int switch_ivr_activate_unicast(HandleRef jarg1, string jarg2, ushort jarg3, string jarg4, ushort jarg5, string jarg6, string jarg7); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_generate_json_cdr")] + public static extern int switch_ivr_generate_json_cdr(HandleRef jarg1, HandleRef jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_generate_xml_cdr")] public static extern int switch_ivr_generate_xml_cdr(HandleRef jarg1, HandleRef jarg2); @@ -13153,6 +13445,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_record_session")] public static extern int switch_ivr_record_session(HandleRef jarg1, string jarg2, uint jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_pop_eavesdropper")] + public static extern int switch_ivr_eavesdrop_pop_eavesdropper(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_exec_all")] + public static extern int switch_ivr_eavesdrop_exec_all(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_update_display")] + public static extern int switch_ivr_eavesdrop_update_display(HandleRef jarg1, string jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_eavesdrop_session")] public static extern int switch_ivr_eavesdrop_session(HandleRef jarg1, string jarg2, string jarg3, uint jarg4); @@ -13465,6 +13766,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_kill_uuid")] public static extern int switch_ivr_kill_uuid(string jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_blind_transfer_ack")] + public static extern int switch_ivr_blind_transfer_ack(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); @@ -13595,7 +13899,10 @@ class freeswitchPINVOKE { public static extern void switch_rtp_destroy(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_ice")] - public static extern int switch_rtp_activate_ice(HandleRef jarg1, string jarg2, string jarg3); + public static extern int switch_rtp_activate_ice(HandleRef jarg1, string jarg2, string jarg3, string jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_rtcp_ice")] + public static extern int switch_rtp_activate_rtcp_ice(HandleRef jarg1, string jarg2, string jarg3, string jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_rtcp")] public static extern int switch_rtp_activate_rtcp(HandleRef jarg1, int jarg2, ushort jarg3); @@ -13624,6 +13931,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_rtp_socket")] public static extern IntPtr switch_rtp_get_rtp_socket(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_ping")] + public static extern void switch_rtp_ping(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_default_samples_per_interval")] public static extern uint switch_rtp_get_default_samples_per_interval(HandleRef jarg1); @@ -13708,6 +14018,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_check_auto_adj")] public static extern byte switch_rtp_check_auto_adj(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_interdigit_delay")] + public static extern void switch_rtp_set_interdigit_delay(HandleRef jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_log_node_t_data_set")] public static extern void switch_log_node_t_data_set(HandleRef jarg1, string jarg2); @@ -14254,24 +14567,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_io_event_hook_state_run")] public static extern void delete_switch_io_event_hook_state_run(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_resurrect_session_set")] - public static extern void switch_io_event_hook_resurrect_session_resurrect_session_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_resurrect_session_get")] - public static extern IntPtr switch_io_event_hook_resurrect_session_resurrect_session_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_next_set")] - public static extern void switch_io_event_hook_resurrect_session_next_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_next_get")] - public static extern IntPtr switch_io_event_hook_resurrect_session_next_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_new_switch_io_event_hook_resurrect_session")] - public static extern IntPtr new_switch_io_event_hook_resurrect_session(); - - [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_io_event_hook_resurrect_session")] - public static extern void delete_switch_io_event_hook_resurrect_session(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_outgoing_channel_set")] public static extern void switch_io_event_hooks_outgoing_channel_set(HandleRef jarg1, HandleRef jarg2); @@ -14344,12 +14639,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_state_run_get")] public static extern IntPtr switch_io_event_hooks_state_run_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_resurrect_session_set")] - public static extern void switch_io_event_hooks_resurrect_session_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_resurrect_session_get")] - public static extern IntPtr switch_io_event_hooks_resurrect_session_get(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_new_switch_io_event_hooks")] public static extern IntPtr new_switch_io_event_hooks(); @@ -14392,9 +14681,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_recv_dtmf")] public static extern int switch_core_event_hook_add_recv_dtmf(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_resurrect_session")] - public static extern int switch_core_event_hook_add_resurrect_session(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_outgoing_channel")] public static extern int switch_core_event_hook_remove_outgoing_channel(HandleRef jarg1, HandleRef jarg2); @@ -14431,9 +14717,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_recv_dtmf")] public static extern int switch_core_event_hook_remove_recv_dtmf(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_resurrect_session")] - public static extern int switch_core_event_hook_remove_resurrect_session(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_created_set")] public static extern void switch_scheduler_task_created_set(HandleRef jarg1, long jarg2); @@ -14768,7 +15051,7 @@ class freeswitchPINVOKE { public static extern uint EventConsumer_node_index_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_new_EventConsumer")] - public static extern IntPtr new_EventConsumer(string jarg1, string jarg2); + public static extern IntPtr new_EventConsumer(string jarg1, string jarg2, int jarg3); [DllImport("mod_managed", EntryPoint="CSharp_delete_EventConsumer")] public static extern void delete_EventConsumer(HandleRef jarg1); @@ -15562,36 +15845,6 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; -public class SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t { - private HandleRef swigCPtr; - - internal SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t(IntPtr cPtr, bool futureUse) { - swigCPtr = new HandleRef(this, cPtr); - } - - protected SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t() { - swigCPtr = new HandleRef(null, IntPtr.Zero); - } - - internal static HandleRef getCPtr(SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_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 - * - * 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_p_switch_loadable_module_interface_p_apr_pool_t__switch_status_t { private HandleRef swigCPtr; @@ -16312,6 +16565,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_switch_core_session__int { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_core_session__int(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_core_session__int() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_core_session__int 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 + * + * 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_core_session_int__switch_status_t { private HandleRef swigCPtr; @@ -17362,6 +17645,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_switch_media_bug_p_void__void { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_media_bug_p_void__void(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_media_bug_p_void__void() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_media_bug_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 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_f_p_switch_rtp_p_switch_socket_t_p_void_switch_size_t_p_switch_sockaddr_t__void { private HandleRef swigCPtr; @@ -18142,6 +18455,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_cJSON { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_cJSON(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_cJSON() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_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 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_p_p_char { private HandleRef swigCPtr; @@ -22996,8 +23339,19 @@ public enum switch_channel_flag_t { CF_VIDEO_REFRESH_REQ, CF_SERVICE_AUDIO, CF_SERVICE_VIDEO, + CF_ZRTP_PASSTHRU_REQ, + CF_ZRTP_PASSTHRU, CF_ZRTP_HASH, - CF_ZRTP_PASS, + CF_CHANNEL_SWAP, + CF_PICKUP, + CF_CONFIRM_BLIND_TRANSFER, + CF_NO_PRESENCE, + CF_CONFERENCE, + CF_RECOVERING, + CF_RECOVERING_BRIDGE, + CF_TRACKED, + CF_TRACKABLE, + CF_NO_CDR, CF_FLAG_MAX } @@ -24582,7 +24936,9 @@ namespace FreeSWITCH.Native { SCF_THREADED_SYSTEM_EXEC = (1 << 18), SCF_SYNC_CLOCK_REQUESTED = (1 << 19), SCF_CORE_ODBC_REQ = (1 << 20), - SCF_DEBUG_SQL = (1 << 21) + SCF_DEBUG_SQL = (1 << 21), + SCF_API_EXPANSION = (1 << 22), + SCF_SESSION_THREAD_POOL = (1 << 23) } } @@ -24891,6 +25247,8 @@ public enum switch_core_session_message_types_t { SWITCH_MESSAGE_INDICATE_SIGNAL_DATA, SWITCH_MESSAGE_INDICATE_INFO, SWITCH_MESSAGE_INDICATE_AUDIO_DATA, + SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, + SWITCH_MESSAGE_INDICATE_STUN_ERROR, SWITCH_MESSAGE_INVALID } @@ -25836,7 +26194,8 @@ namespace FreeSWITCH.Native { ED_NONE = 0, ED_MUX_READ = (1 << 0), ED_MUX_WRITE = (1 << 1), - ED_DTMF = (1 << 2) + ED_DTMF = (1 << 2), + ED_COPY_DISPLAY = (1 << 3) } } @@ -25978,6 +26337,17 @@ public class switch_endpoint_interface : IDisposable { } } + public SWIGTYPE_p_f_p_switch_core_session__int recover_callback { + set { + freeswitchPINVOKE.switch_endpoint_interface_recover_callback_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session__int.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_endpoint_interface_recover_callback_get(swigCPtr); + 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 switch_endpoint_interface() : this(freeswitchPINVOKE.new_switch_endpoint_interface(), true) { } @@ -26372,6 +26742,10 @@ public enum switch_event_types_t { SWITCH_EVENT_SOCKET_DATA, SWITCH_EVENT_MEDIA_BUG_START, SWITCH_EVENT_MEDIA_BUG_STOP, + SWITCH_EVENT_CONFERENCE_DATA_QUERY, + SWITCH_EVENT_CONFERENCE_DATA, + SWITCH_EVENT_CALL_SETUP_REQ, + SWITCH_EVENT_CALL_SETUP_RESULT, SWITCH_EVENT_ALL } @@ -26971,6 +27345,28 @@ public class switch_file_interface : IDisposable { } } + public SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t file_read_video { + set { + freeswitchPINVOKE.switch_file_interface_file_read_video_set(swigCPtr, SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_file_interface_file_read_video_get(swigCPtr); + SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t(cPtr, false); + return ret; + } + } + + public SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t file_write_video { + set { + freeswitchPINVOKE.switch_file_interface_file_write_video_set(swigCPtr, SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_file_interface_file_write_video_get(swigCPtr); + SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_file_handle_p_void_p_switch_size_t__switch_status_t(cPtr, false); + return ret; + } + } + public SWIGTYPE_p_f_p_switch_file_handle_p_unsigned_int_long_long_int__switch_status_t file_seek { set { freeswitchPINVOKE.switch_file_interface_file_seek_set(swigCPtr, SWIGTYPE_p_f_p_switch_file_handle_p_unsigned_int_long_long_int__switch_status_t.getCPtr(value)); @@ -27866,75 +28262,6 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; -public class switch_io_event_hook_resurrect_session : IDisposable { - private HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal switch_io_event_hook_resurrect_session(IntPtr cPtr, bool cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = new HandleRef(this, cPtr); - } - - internal static HandleRef getCPtr(switch_io_event_hook_resurrect_session obj) { - return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; - } - - ~switch_io_event_hook_resurrect_session() { - Dispose(); - } - - public virtual void Dispose() { - lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_io_event_hook_resurrect_session(swigCPtr); - } - swigCPtr = new HandleRef(null, IntPtr.Zero); - GC.SuppressFinalize(this); - } - } - - public SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session { - set { - freeswitchPINVOKE.switch_io_event_hook_resurrect_session_resurrect_session_set(swigCPtr, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_resurrect_session_resurrect_session_get(swigCPtr); - SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t(cPtr, false); - return ret; - } - } - - public switch_io_event_hook_resurrect_session next { - set { - freeswitchPINVOKE.switch_io_event_hook_resurrect_session_next_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_resurrect_session_next_get(swigCPtr); - switch_io_event_hook_resurrect_session ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_resurrect_session(cPtr, false); - return ret; - } - } - - public switch_io_event_hook_resurrect_session() : this(freeswitchPINVOKE.new_switch_io_event_hook_resurrect_session(), true) { - } - -} - -} -/* ---------------------------------------------------------------------------- - * 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 switch_io_event_hooks : IDisposable { private HandleRef swigCPtr; protected bool swigCMemOwn; @@ -28095,17 +28422,6 @@ public class switch_io_event_hooks : IDisposable { } } - public switch_io_event_hook_resurrect_session resurrect_session { - set { - freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_get(swigCPtr); - switch_io_event_hook_resurrect_session ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_resurrect_session(cPtr, false); - return ret; - } - } - public switch_io_event_hooks() : this(freeswitchPINVOKE.new_switch_io_event_hooks(), true) { } @@ -28563,8 +28879,7 @@ public enum switch_io_routine_name_t { SWITCH_IO_RECEIVE_EVENT, SWITCH_IO_STATE_CHANGE, SWITCH_IO_READ_VIDEO_FRAME, - SWITCH_IO_WRITE_VIDEO_FRAME, - SWITCH_IO_RESURRECT_SESSION + SWITCH_IO_WRITE_VIDEO_FRAME } } @@ -28730,17 +29045,6 @@ public class switch_io_routines : IDisposable { } } - public SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session { - set { - freeswitchPINVOKE.switch_io_routines_resurrect_session_set(swigCPtr, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_io_routines_resurrect_session_get(swigCPtr); - SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t(cPtr, false); - return ret; - } - } - public SWIGTYPE_p_p_void padding { set { freeswitchPINVOKE.switch_io_routines_padding_set(swigCPtr, SWIGTYPE_p_p_void.getCPtr(value)); @@ -29776,7 +30080,8 @@ namespace FreeSWITCH.Native { SMBF_THREAD_LOCK = (1 << 7), SMBF_PRUNE = (1 << 8), SMBF_NO_PAUSE = (1 << 9), - SMBF_STEREO_SWAP = (1 << 10) + SMBF_STEREO_SWAP = (1 << 10), + SMBF_LOCK = (1 << 11) } } @@ -30078,6 +30383,16 @@ public class switch_rtcp_numbers_t : IDisposable { } } + public uint peer_ssrc { + set { + freeswitchPINVOKE.switch_rtcp_numbers_t_peer_ssrc_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_rtcp_numbers_t_peer_ssrc_get(swigCPtr); + return ret; + } + } + public switch_rtcp_numbers_t() : this(freeswitchPINVOKE.new_switch_rtcp_numbers_t(), true) { } @@ -30104,7 +30419,8 @@ public enum switch_rtp_bug_flag_t { RTP_BUG_NEVER_SEND_MARKER = (1 << 5), RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6), RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7), - RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8) + RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8), + RTP_BUG_CHANGE_SSRC_ON_MARKER = (1 << 9) } } @@ -30520,6 +30836,18 @@ public class switch_rtp_numbers_t : IDisposable { } } + public SWIGTYPE_p_switch_size_t period_packet_count { + set { + freeswitchPINVOKE.switch_rtp_numbers_t_period_packet_count_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_period_packet_count_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public SWIGTYPE_p_switch_size_t media_packet_count { set { freeswitchPINVOKE.switch_rtp_numbers_t_media_packet_count_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); @@ -30684,6 +31012,16 @@ public class switch_rtp_stats_t : IDisposable { } } + public uint read_count { + set { + freeswitchPINVOKE.switch_rtp_stats_t_read_count_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_rtp_stats_t_read_count_get(swigCPtr); + return ret; + } + } + public switch_rtp_stats_t() : this(freeswitchPINVOKE.new_switch_rtp_stats_t(), true) { } @@ -31150,7 +31488,10 @@ public enum switch_session_ctl_t { SCSC_READY_CHECK, SCSC_THREADED_SYSTEM_EXEC, SCSC_SYNC_CLOCK_WHEN_IDLE, - SCSC_DEBUG_SQL + SCSC_DEBUG_SQL, + SCSC_SQL, + SCSC_API_EXPANSION, + SCSC_RECOVER } } diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index a3855445a4..dd4b385299 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -4675,6 +4675,7 @@ XS(_wrap_new_EventConsumer) { { char *arg1 = (char *) NULL ; char *arg2 = (char *) "" ; + int arg3 = (int) 5000 ; EventConsumer *result = 0 ; int res1 ; char *buf1 = 0 ; @@ -4682,11 +4683,13 @@ XS(_wrap_new_EventConsumer) { int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; int argvi = 0; dXSARGS; - if ((items < 0) || (items > 2)) { - SWIG_croak("Usage: new_EventConsumer(event_name,subclass_name);"); + if ((items < 0) || (items > 3)) { + SWIG_croak("Usage: new_EventConsumer(event_name,subclass_name,len);"); } if (items > 0) { res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); @@ -4702,14 +4705,23 @@ XS(_wrap_new_EventConsumer) { } arg2 = reinterpret_cast< char * >(buf2); } - result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_EventConsumer" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EventConsumer, SWIG_OWNER | SWIG_SHADOW); argvi++ ; if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); } } diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index c45da0b464..d2098edd1c 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -5406,6 +5406,7 @@ SWIGINTERN PyObject *_wrap_new_EventConsumer(PyObject *SWIGUNUSEDPARM(self), PyO PyObject *resultobj = 0; char *arg1 = (char *) NULL ; char *arg2 = (char *) "" ; + int arg3 = (int) 5000 ; EventConsumer *result = 0 ; int res1 ; char *buf1 = 0 ; @@ -5413,10 +5414,13 @@ SWIGINTERN PyObject *_wrap_new_EventConsumer(PyObject *SWIGUNUSEDPARM(self), PyO int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"|OO:new_EventConsumer",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"|OOO:new_EventConsumer",&obj0,&obj1,&obj2)) SWIG_fail; if (obj0) { res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { @@ -5431,7 +5435,14 @@ SWIGINTERN PyObject *_wrap_new_EventConsumer(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = reinterpret_cast< char * >(buf2); } - result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2); + if (obj2) { + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_EventConsumer" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EventConsumer, SWIG_POINTER_NEW | 0 ); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index e17c590a71..d50030c218 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -688,6 +688,35 @@ static JSBool event_fire(JSContext * cx, JSObject * obj, uintN argc, jsval * arg return JS_TRUE; } + +static JSBool event_chat_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) +{ + struct event_obj *eo = JS_GetPrivate(cx, obj); + + if (eo) { + if (argc > 0) { + char *app = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); + char *arg = NULL; + + if (argc > 1) { + arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); + } + + goto end; + + switch_core_execute_chat_app(eo->event, app, arg); + + *rval = BOOLEAN_TO_JSVAL(JS_TRUE); + return JS_TRUE; + } + } + + end: + + *rval = BOOLEAN_TO_JSVAL(JS_FALSE); + return JS_FALSE; +} + static JSBool event_destroy_(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) { struct event_obj *eo = JS_GetPrivate(cx, obj); @@ -718,6 +747,7 @@ static JSFunctionSpec event_methods[] = { {"getType", event_get_type, 1}, {"serialize", event_serialize, 0}, {"fire", event_fire, 0}, + {"chatExecute", event_chat_execute, 0}, {"destroy", event_destroy_, 0}, {0} }; @@ -2383,7 +2413,7 @@ static JSBool session_hangup(JSContext * cx, JSObject * obj, uintN argc, jsval * if (switch_channel_up(channel)) { jsval ret = JS_TRUE; - if (argc > 1) { + if (argc > 0) { if (JSVAL_IS_INT(argv[0])) { int32 i = 0; JS_ValueToInt32(cx, argv[0], &i); @@ -3486,6 +3516,48 @@ static JSBool js_api_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * return JS_TRUE; } +static JSBool js_email(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) +{ + char *to = NULL, *from = NULL, *headers = NULL, *body = NULL, *file = NULL, *convert_cmd = NULL, *convert_ext = NULL; + + if (argc > 0) { + to = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); + } + + if (argc > 1) { + from = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); + } + + if (argc > 2) { + headers = JS_GetStringBytes(JS_ValueToString(cx, argv[2])); + } + + if (argc > 3) { + body = JS_GetStringBytes(JS_ValueToString(cx, argv[3])); + } + + if (argc > 4) { + file = JS_GetStringBytes(JS_ValueToString(cx, argv[4])); + } + + if (argc > 5) { + convert_cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[5])); + } + + if (argc > 6) { + convert_ext = JS_GetStringBytes(JS_ValueToString(cx, argv[6])); + } + + if (to && from && headers && body && switch_simple_email(to, from, headers, body, file, convert_cmd, convert_ext) == SWITCH_TRUE) { + *rval = BOOLEAN_TO_JSVAL(JS_TRUE); + return JS_TRUE; + } + + *rval = BOOLEAN_TO_JSVAL(JS_FALSE); + return JS_FALSE; + +} + static JSBool js_bridge(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) { struct js_session *jss_a = NULL, *jss_b = NULL; @@ -3593,6 +3665,7 @@ static JSFunctionSpec fs_functions[] = { {"exit", js_exit, 0}, {"include", js_include, 1}, {"bridge", js_bridge, 2}, + {"email", js_email, 3}, {"apiExecute", js_api_execute, 2}, {"use", js_api_use, 1}, {"msleep", js_api_sleep, 1}, @@ -3628,7 +3701,7 @@ static int env_init(JSContext * cx, JSObject * javascript_object) return 1; } -static void js_parse_and_execute(switch_core_session_t *session, const char *input_code, struct request_obj *ro) +static void js_parse_and_execute(switch_core_session_t *session, const char *input_code, struct request_obj *ro, switch_event_t *message) { JSObject *javascript_global_object = NULL; char buf[1024], *arg, *argv[512]; @@ -3657,6 +3730,12 @@ static void js_parse_and_execute(switch_core_session_t *session, const char *inp if (!(session && new_js_session(cx, javascript_global_object, session, &jss, "session", flags))) { switch_snprintf(buf, sizeof(buf), "~var session = false;"); eval_some_js(buf, cx, javascript_global_object, &rval); + + if (message) { + new_js_event(message, "message", cx, javascript_global_object); + } + + } if (ro) { new_request(cx, javascript_global_object, ro); @@ -3704,7 +3783,16 @@ static void js_parse_and_execute(switch_core_session_t *session, const char *inp SWITCH_STANDARD_APP(js_dp_function) { - js_parse_and_execute(session, data, NULL); + js_parse_and_execute(session, data, NULL, NULL); +} + +SWITCH_STANDARD_CHAT_APP(js_chat_function) +{ + + js_parse_and_execute(NULL, data, NULL, message); + + return SWITCH_STATUS_SUCCESS; + } struct js_task { @@ -3717,7 +3805,7 @@ static void *SWITCH_THREAD_FUNC js_thread_run(switch_thread_t *thread, void *obj struct js_task *task = (struct js_task *) obj; switch_memory_pool_t *pool; - js_parse_and_execute(NULL, task->code, NULL); + js_parse_and_execute(NULL, task->code, NULL, NULL); if ((pool = task->pool)) { switch_core_destroy_memory_pool(&pool); @@ -3775,7 +3863,7 @@ SWITCH_STANDARD_API(jsapi_function) ro.session = session; ro.stream = stream; - js_parse_and_execute(session, (char *) cmd, &ro); + js_parse_and_execute(session, (char *) cmd, &ro, NULL); return SWITCH_STATUS_SUCCESS; } @@ -3795,6 +3883,8 @@ SWITCH_STANDARD_API(launch_async) SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load) { switch_application_interface_t *app_interface; + switch_chat_application_interface_t *chat_app_interface; + //switch_status_t status; //if ((status = init_js()) != SWITCH_STATUS_SUCCESS) { @@ -3812,6 +3902,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load) SWITCH_ADD_APP(app_interface, "javascript", "Launch JS ivr", "Run a javascript ivr on a channel", js_dp_function, "
      bmp2tiffbmp2tiff Convert BMP images to TIFF
      fax2psfax2ps Convert a Group 3- or Group 4- compressed TIFF to PostScript that is significantly more compressed than is generated by tiff2ps (unless tiff2ps writes PS Level II)
      fax2tifffax2tiff Convert raw Group 3 or Group 4 facsimile data to TIFF
      gif2tiffA quick hack that converts GIF 87a format images to TIFFgif2tiffA quick hack that converts GIF 87a (old) format images to TIFF
      pal2rgbpal2rgb Convert a Palette-style image to a full color RGB image by applying the colormap
      ppm2tiffA quick hack that converts PPM format images to TIFFppm2tiffA quick hack that converts 8-bit PPM format images to TIFF
      ras2tiffras2tiff A quick hack that converts Sun rasterfile format images to TIFF -- it's less than complete
      raw2tiffraw2tiff Create a TIFF file from raw data
      rgb2ycbcrrgb2ycbcr Convert an RGB, grayscale, or bilevel TIFF image to a YCbCr TIFF image; it's mainly provided for testing
      sgi2tiffsgi2tiff A program to convert SGI image files to TIFF. This program is only useful on SGI machines as it uses -limage.
      thumbnailthumbnail Copy a bilevel TIFF to one that includes 8-bit greyscale "thumbnail images" for each page; it is provided as an example of how one might use the SubIFD tag (and the library support for it)
      tiff2bwtiff2bw A simple program to convert a color image to grayscale
      tiff2pdftiff2pdf Convert TIFF images to PDF
      tiff2pstiff2ps Convert TIFF images to PostScript
      tiff2rgbatiff2rgba Convert a TIFF image to RGBA color space
      tiffcmptiffcmp Compare the contents of two TIFF files (it does not check all the directory information, but does check all the data)
      tiffcptiffcp Copy, concatenate, and convert TIFF images (e.g. switching from Compression=5 to Compression=1)
      tiffdithertiffcropProvides selection of images from within one or more multi-image +TIFF files, with orthogonal rotation, mirroring, cropping, and +extraction of multiple sections and exporting to one or more files. +It extends the functionality of tiffcp to support additional bit +depths in strips and tiles and enhances the selection capabilities of +tiffsplit. Bilevel images can be inverted and images may be split into +segments to fit on multiple /pages/ (standard paper sizes), plus other +functions described in the tiffcrop man page
      tiffdither Dither a b&w image into a bilevel image (suitable for use in creating fax files)
      tiffdumptiffdump Display the verbatim contents of the TIFF directory in a file (it's very useful for debugging bogus files that you may get from someone that claims they support TIFF)
      tiffinfotiffinfo Display information about one or more TIFF files.
      tiffmediantiffmedian A version of Paul Heckbert's median cut program that reads an -RGB TIFF image, and creates a TIFF palette file as a result; it's -useful for converting full-color RGB images to 8-bit color for your -friends that have cheapo 8-bit framebuffers.
      tiffsettiffset Set a field in a TIFF header
      tiffsplittiffsplit Create one or more single-image files from a (possibly) multi-image file
      %s%s%s%s%s%s%s%s", - argv[1], argv[4], argv[5], argv[7], argv[8] ? argv[8] : "N/A", argv[9] ? argv[9] : "N/A", argv[10], argv[11]); + created, cid_name, cid_num, dest, application, application_data, read_codec, read_rate); - snprintf(title_b4, sizeof(title_b4), "%s <%s>", argv[4], argv[5]); + snprintf(title_b4, sizeof(title_b4), "%s <%s>", cid_name, cid_num); switch_url_encode(title_b4, title_aft, sizeof(title_aft)); - mp3 = switch_mprintf("http://%s:%s%s/mp3/%s/%s.mp3", holder->host, holder->port, holder->uri, argv[0], argv[5]); - m3u = switch_mprintf("http://%s:%s%s/m3u/mp3/%s/%s.mp3.m3u", holder->host, holder->port, holder->uri, argv[0], argv[5]); + mp3 = switch_mprintf("http://%s:%s%s/mp3/%s/%s.mp3", holder->host, holder->port, holder->uri, uuid, cid_num); + m3u = switch_mprintf("http://%s:%s%s/m3u/mp3/%s/%s.mp3.m3u", holder->host, holder->port, holder->uri, uuid, cid_num); holder->stream->write_function(holder->stream, "[mp3] ", mp3); holder->stream->write_function(holder->stream, "[m3u]